AutomergeProvider
Defined in: automerge/src/peerborne-automerge.ts:80
Type Parameters
Section titled “Type Parameters”T = any
Implements
Section titled “Implements”CRDTProvider<Doc<T>,BinaryChange[], (doc) =>void>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AutomergeProvider<
T>():AutomergeProvider<T>
Returns
Section titled “Returns”AutomergeProvider<T>
Properties
Section titled “Properties”initialInvitationCapacityProfile
Section titled “initialInvitationCapacityProfile”
readonlyinitialInvitationCapacityProfile:"peerborne-automerge-json-subtle-p384-v1"=INITIAL_INVITATION_CAPACITY_PROFILE
Defined in: automerge/src/peerborne-automerge.ts:83
Methods
Section titled “Methods”applySnapshot()
Section titled “applySnapshot()”applySnapshot(
document,snapshot):Doc<T>
Defined in: automerge/src/peerborne-automerge.ts:114
Apply a full-state snapshot produced by getSnapshot().
Implement this when the snapshot format differs from incremental changes
(e.g. Automerge’s save() output cannot be applied via applyChanges()).
When not implemented, the caller falls back to remoteChange().
Parameters
Section titled “Parameters”document
Section titled “document”Doc<T>
Current CRDT document.
snapshot
Section titled “snapshot”Change[]
Snapshot state from getSnapshot().
Returns
Section titled “Returns”Doc<T>
The updated document with the snapshot state merged in.
Implementation of
Section titled “Implementation of”CRDTProvider.applySnapshot
getHistory()
Section titled “getHistory()”getHistory(
document):Change[]
Defined in: automerge/src/peerborne-automerge.ts:104
Gets all changes for the document.
Parameters
Section titled “Parameters”document
Section titled “document”Doc<T>
CRDT document to inspect.
Returns
Section titled “Returns”Change[]
Implementation of
Section titled “Implementation of”CRDTProvider.getHistory
getSnapshot()
Section titled “getSnapshot()”getSnapshot(
document):Change[]
Defined in: automerge/src/peerborne-automerge.ts:107
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<T>
CRDT document to snapshot.
Returns
Section titled “Returns”Change[]
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
localChange()
Section titled “localChange()”localChange(
document,message,changeFn): [Doc<T>,Change[]]
Defined in: automerge/src/peerborne-automerge.ts:89
Apply locally made changes to provided CRDT document as defined by changeFn.
Parameters
Section titled “Parameters”document
Section titled “document”Doc<T>
CRDT document to change.
message
Section titled “message”string
A description of the change made.
changeFn
Section titled “changeFn”(doc) => void
A function that modifies a CRDT document (provided as a parameter).
This function will be run as a part of .localChange(...)
Returns
Section titled “Returns”[Doc<T>, Change[]]
Implementation of
Section titled “Implementation of”CRDTProvider.localChange
newDocument()
Section titled “newDocument()”newDocument():
Doc<T>
Defined in: automerge/src/peerborne-automerge.ts:86
Create a new empty (contains the equivalent of {}) CRDT document.
Returns
Section titled “Returns”Doc<T>
Implementation of
Section titled “Implementation of”CRDTProvider.newDocument
remoteChange()
Section titled “remoteChange()”remoteChange(
document,changes):Doc<T>
Defined in: automerge/src/peerborne-automerge.ts:100
Apply CRDT document changes made by a remote peer.
Parameters
Section titled “Parameters”document
Section titled “document”Doc<T>
CRDT document to update.
changes
Section titled “changes”Change[]
An object describing changes made by a peer. CRDT-specific.
Returns
Section titled “Returns”Doc<T>
Implementation of
Section titled “Implementation of”CRDTProvider.remoteChange