canvist_collab 0.2.1

Yjs collaboration for canvist documents: a step-to-yrs binding, the y-sync protocol, awareness, and shared undo
Documentation

canvist_collab

Real-time collaboration for canvist documents over Yjs, using yrs.

Most apps add it through canvist, the crate to install, as canvist::collab behind the collab feature: cargo add canvist --features collab.

  • Binding: mirrors a canvist_model document into a yrs document and back. Each model step becomes yrs operations and each remote yrs event becomes steps, so nothing is ever diffed.
  • Plain Yjs: the shared document follows a documented schema of Y.Map blocks, Y.Text with marks as formatting, and nested Y.Arrays, so JavaScript Yjs peers, y-websocket, and Hocuspocus take part without knowing about canvist.
  • Robust: updates may arrive out of order or twice, blocks that break the schema are hidden rather than deleted, and concurrent moves of one block keep a single copy.
  • Shared undo: a yrs UndoManager that only undoes local changes, behind a History trait the editor can swap.
  • Sync and presence: a transport-agnostic y-sync session for y-websocket and Hocuspocus servers, and awareness carets that stay on their characters while others type.

Mirroring a keystroke into a Yjs update takes about 2 µs, and applying a remote keystroke about 2.5 µs, whether the document has 100 blocks or 10,000. Run cargo bench -p canvist_collab to reproduce.

The compatibility tests run a real JavaScript Yjs peer under Deno, which the devenv shell provides.

Shared block trees are limited to 64 levels, counting root blocks as level 1. An update that exceeds this limit returns CollabError::BlockDepthLimit before changing the model. The CRDT retains the update; once a peer corrects its nesting, the binding rebuilds the model from the bounded shared state.