Skip to content

Collaborator

Defined in: collab.ts:155

Makes a single editor a live collaborator on a shared document.

Typical usage:

const net = createMemoryNetwork({ origin: baseDoc });
const me = new Collaborator({ peer: { id: 'alice' }, editor, transport: net.connect() });
me.onChange((s) => render(s)); // react to confirmed/pending changes
me.setPresence({ status: 'editing' }); // broadcast awareness
// ...local edits flow automatically via the editor's transactions.
new Collaborator(options): Collaborator;

Defined in: collab.ts:178

ParameterType
optionsCollaboratorOptions

Collaborator

PropertyModifierTypeDescriptionDefined in
ledgerreadonlyTransactionLedgerThe confirmed (canonical) log this client has applied — the shared source of truth, for diff/serialize.collab.ts:159
peerreadonlyPeer-collab.ts:156
presencereadonlyPresenceTracker-collab.ts:157
get confirmedDocument(): DocumentNode;

Defined in: collab.ts:224

The confirmed/canonical document (excludes un-acked local edits).

DocumentNode


get document(): DocumentNode;

Defined in: collab.ts:219

The optimistic document currently shown in the editor (confirmed + pending).

DocumentNode


get peers(): PeerPresence[];

Defined in: collab.ts:229

Other peers’ presence (what you render as remote cursors).

PeerPresence[]


get status(): CollabStatus;

Defined in: collab.ts:214

CollabStatus

destroy(): void;

Defined in: collab.ts:263

Detach from the editor and transport, announcing departure.

void


onChange(listener): () => void;

Defined in: collab.ts:238

ParameterType
listenerCollabChangeListener

() => void


patchPresence(patch): void;

Defined in: collab.ts:252

Merge a partial patch into this client’s awareness state and broadcast it.

ParameterType
patchPartial<PresenceState>

void


setPresence(state): void;

Defined in: collab.ts:246

Replace this client’s awareness state and broadcast it.

ParameterType
statePresenceState

void


start(): void;

Defined in: collab.ts:197

Begin the handshake (send hello). Called automatically unless autoStart: false.

void


sync(): void;

Defined in: collab.ts:258

Request any canonical records this client is missing (late join / reconnect).

void


versionVector(): VersionVector;

Defined in: collab.ts:234

This client’s view vector — the highest seq seen per source.

VersionVector