Skip to content

YjsProvider

Defined in: yjs/src/peerborne-yjs.ts:537

  • CRDTProvider<Doc, Uint8Array, (doc) => void>

new YjsProvider(): YjsProvider

YjsProvider

readonly actorBinding: CRDTActorBinding<Doc, Uint8Array<ArrayBufferLike>> = yjsActorBinding

Defined in: yjs/src/peerborne-yjs.ts:541

Client IDs are 53-bit values derived from the signer and an instance nonce.

CRDTProvider.actorBinding

coversVersion(document, version): boolean

Defined in: yjs/src/peerborne-yjs.ts:1014

Report whether document holds all of the state that version, from encodeVersion() on another replica, describes. Every insertion and deletion counts, so a replica that lacks a deletion is not covered. Return false, without throwing, for a malformed version.

Doc

CRDT document to inspect.

Uint8Array

Bytes from another replica’s encodeVersion().

boolean

CRDTProvider.coversVersion


createDocumentSession(document): CRDTDocumentSession<Doc, Uint8Array<ArrayBufferLike>, (doc) => void>

Defined in: yjs/src/peerborne-yjs.ts:544

Staging accepts scalars and shared Map/Array/Text values, not opaque mutable payloads.

Doc

CRDTDocumentSession<Doc, Uint8Array<ArrayBufferLike>, (doc) => void>

CRDTProvider.createDocumentSession


encodeVersion(document): Uint8Array

Defined in: yjs/src/peerborne-yjs.ts:1011

Encode a compact version of document’s state, such as Automerge heads, a Loro version vector or a Yjs state vector with its delete set. A writer whose catch-up reply does not fit a frame sends it, and the requester loads only when coversVersion() reports that it lacks some of that state. When not implemented, the requester always loads.

Doc

CRDT document to describe.

Uint8Array

CRDTProvider.encodeVersion


getChangesSinceSnapshot(document, snapshot): Uint8Array<ArrayBufferLike> | undefined

Defined in: yjs/src/peerborne-yjs.ts:992

Encode the changes document holds beyond snapshot, a state from getSnapshot() without an actor manifest, so that remoteChange() applies them to a new document that snapshot was applied to. Return undefined when document does not hold every change in snapshot, or when applying the changes would take longer than restoring the full state. A local checkpoint stores a document that its latest snapshot covers in part as that snapshot and these changes, so it holds the state once.

Doc

CRDT document to encode.

Uint8Array

State that getSnapshot() returned for an earlier state.

Uint8Array<ArrayBufferLike> | undefined

CRDTProvider.getChangesSinceSnapshot


getHistory(document): Uint8Array

Defined in: yjs/src/peerborne-yjs.ts:981

Gets all changes for the document.

Doc

CRDT document to inspect.

Uint8Array

CRDTProvider.getHistory


getSnapshot(document): Uint8Array

Defined in: yjs/src/peerborne-yjs.ts:989

Get a compacted state snapshot of the document. Used for onboarding new members without replaying individual changes.

For Yjs: Y.encodeStateAsUpdateV2(doc) (directly applicable via remoteChange()) For Automerge: Automerge.save(doc) (requires applySnapshot() since save format differs from the incremental change format used by remoteChange())

Doc

CRDT document to snapshot.

Uint8Array

A snapshot representation. If the snapshot format differs from the incremental change format, implement applySnapshot() as well.

CRDTProvider.getSnapshot


hasPendingChanges(document): boolean

Defined in: yjs/src/peerborne-yjs.ts:1005

Report whether document holds remote changes that wait for missing causal dependencies, such as Automerge’s queued changes or Yjs pending structs and deletions. Automatic catch-up asks peers for missed updates while this is true. When not implemented, only failed block fetches and advertised heads reveal a gap.

Doc

CRDT document to inspect.

boolean

CRDTProvider.hasPendingChanges


localChange(document, message, changeFn): [Doc, Uint8Array<ArrayBufferLike>]

Defined in: yjs/src/peerborne-yjs.ts:947

The change holds only the transactions changeFn ran. Yjs folds pending remote structs into a state-vector diff, which would make a local change carry other actors’ operations.

Doc

string

(doc) => void

[Doc, Uint8Array<ArrayBufferLike>]

CRDTProvider.localChange


newDocument(): Doc

Defined in: yjs/src/peerborne-yjs.ts:939

Create a new empty (contains the equivalent of {}) CRDT document.

Doc

CRDTProvider.newDocument


remoteChange(document, changes): Doc

Defined in: yjs/src/peerborne-yjs.ts:973

Apply CRDT document changes made by a remote peer.

Doc

CRDT document to update.

Uint8Array

An object describing changes made by a peer. CRDT-specific.

Doc

CRDTProvider.remoteChange