learn
packages/

Common

Platform-neutral element models, collaboration protocols, validation, and reconciliation.

Room commits reconcile deterministically per element: both sides apply the same winner-picking rules, so concurrent edits converge without a central lock. The protocol caps everything it carries — elements per commit, preview sizes, selection ids — and the validators enforce those caps on both ends of the socket.

What it owns

  • Element models shared by the editor and the servers
  • Sync rules: normalization, ordering, tombstones, and winner-picking
  • Client/server message shapes for collaboration and presence
  • Validation for sync batches and collab frames

Files

File list and purposes from the folder README.

FilePurpose
src/sync.tsNormalization, ordering, tombstones, and reconciliation.
src/syncValidate.tsSync element and batch validation.
src/collab.tsCollaboration protocol re-export.
src/presence.tsPresence message shapes and validation.
src/laser.tsLaser trail types.
src/library.tsLibrary item models.
src/types.tsShared types.
src/constants.tsShared limits.
src/element/Element model entry and types.

Dependencies

No runtime dependencies.

Development and tooling (1)
LibraryVersion rangeWhy it is used here
Vitest^5.0.1Runs the unit and regression test suites.

Dependencies as of commit b0026d9.

Internal packages used

common package
BrowserAPIRealtimeCacheDatabaseShareddurableephemeral

Talks to

Sources: packages/common/README.md, packages/common/src/README.md, packages/common/src/sync.ts, packages/common/src/syncValidate.ts, packages/common/src/collab.ts, packages/common/src/presence.ts, packages/common/src/laser.ts (documented at commit b0026d9)

On this page