YjsProvider
Defined in: yjs/src/peerborne-yjs.ts:537
Implements
Section titled “Implements”CRDTProvider<Doc,Uint8Array, (doc) =>void>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new YjsProvider():
YjsProvider
Returns
Section titled “Returns”YjsProvider
Properties
Section titled “Properties”actorBinding
Section titled “actorBinding”
readonlyactorBinding: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.
Implementation of
Section titled “Implementation of”CRDTProvider.actorBinding
Methods
Section titled “Methods”coversVersion()
Section titled “coversVersion()”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.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to inspect.
version
Section titled “version”Uint8Array
Bytes from another replica’s encodeVersion().
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”CRDTProvider.coversVersion
createDocumentSession()
Section titled “createDocumentSession()”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.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
Returns
Section titled “Returns”CRDTDocumentSession<Doc, Uint8Array<ArrayBufferLike>, (doc) => void>
Implementation of
Section titled “Implementation of”CRDTProvider.createDocumentSession
encodeVersion()
Section titled “encodeVersion()”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.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to describe.
Returns
Section titled “Returns”Uint8Array
Implementation of
Section titled “Implementation of”CRDTProvider.encodeVersion
getChangesSinceSnapshot()
Section titled “getChangesSinceSnapshot()”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.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to encode.
snapshot
Section titled “snapshot”Uint8Array
State that getSnapshot() returned for an earlier state.
Returns
Section titled “Returns”Uint8Array<ArrayBufferLike> | undefined
Implementation of
Section titled “Implementation of”CRDTProvider.getChangesSinceSnapshot
getHistory()
Section titled “getHistory()”getHistory(
document):Uint8Array
Defined in: yjs/src/peerborne-yjs.ts:981
Gets all changes for the document.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to inspect.
Returns
Section titled “Returns”Uint8Array
Implementation of
Section titled “Implementation of”CRDTProvider.getHistory
getSnapshot()
Section titled “getSnapshot()”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())
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to snapshot.
Returns
Section titled “Returns”Uint8Array
A snapshot representation. If the snapshot format differs from the
incremental change format, implement applySnapshot() as well.
Implementation of
Section titled “Implementation of”CRDTProvider.getSnapshot
hasPendingChanges()
Section titled “hasPendingChanges()”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.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to inspect.
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”CRDTProvider.hasPendingChanges
localChange()
Section titled “localChange()”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.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
message
Section titled “message”string
changeFn
Section titled “changeFn”(doc) => void
Returns
Section titled “Returns”[Doc, Uint8Array<ArrayBufferLike>]
Implementation of
Section titled “Implementation of”CRDTProvider.localChange
newDocument()
Section titled “newDocument()”newDocument():
Doc
Defined in: yjs/src/peerborne-yjs.ts:939
Create a new empty (contains the equivalent of {}) CRDT document.
Returns
Section titled “Returns”Doc
Implementation of
Section titled “Implementation of”CRDTProvider.newDocument
remoteChange()
Section titled “remoteChange()”remoteChange(
document,changes):Doc
Defined in: yjs/src/peerborne-yjs.ts:973
Apply CRDT document changes made by a remote peer.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to update.
changes
Section titled “changes”Uint8Array
An object describing changes made by a peer. CRDT-specific.
Returns
Section titled “Returns”Doc
Implementation of
Section titled “Implementation of”CRDTProvider.remoteChange