AI-native design editor. Open-source Figma alternative.
Collab
How a room's Yjs document maps to and from a SceneGraph. The app's rooms, transports, presence, and voice live in src/app/collab (src/AGENTS.md); this package holds only the document mapping, so a server can read a room the same way the editor does.
- The package depends on
@open-pencil/scene-graph,yjs,es-toolkit, andvalibot, never Vue or app code, and reaches an editor only through theCollabEditorinterface; a graph with no events and nothing to redraw is a complete editor (packages/collab/tests/graph-sync.test.ts). - A shared document records each layer's parent history, order key and page, never
parentIdorchildIds, and only Share or a room's conversion sets its root inmeta; local edits are written bywriteLocalPlacementand remote changes applied byapplySharedTreeinpackages/collab/src/shared-tree/sync.ts, which resolve the tree withLayerTreefrompackages/collab/src/tree/(tests/app/collab/random-edits.test.ts). - What a document holds outside its layers, its document node's plugin data, comment threads, libraries and color space, travels in the room's own maps through
bindDocumentSync(packages/collab/src/document/sync.ts), entry by entry and thread by thread, never on the root layer, so people changing it at once all keep their change (tests/app/collab/document/sync.test.ts). - Changing how a shared document records data bumps
TREE_FORMATandCOLLAB_APP_IDtogether, so mismatched builds never meet; rooms saved by an earlier format are not converted (packages/collab/src/shared-tree/fields.ts).