Skip to content

AutomergeProvider

Defined in: automerge/src/peerborne-automerge.ts:80

T = any

  • CRDTProvider<Doc<T>, BinaryChange[], (doc) => void>

new AutomergeProvider<T>(): AutomergeProvider<T>

AutomergeProvider<T>

readonly initialInvitationCapacityProfile: "peerborne-automerge-json-subtle-p384-v1" = INITIAL_INVITATION_CAPACITY_PROFILE

Defined in: automerge/src/peerborne-automerge.ts:83

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().

Doc<T>

Current CRDT document.

Change[]

Snapshot state from getSnapshot().

Doc<T>

The updated document with the snapshot state merged in.

CRDTProvider.applySnapshot


getHistory(document): Change[]

Defined in: automerge/src/peerborne-automerge.ts:104

Gets all changes for the document.

Doc<T>

CRDT document to inspect.

Change[]

CRDTProvider.getHistory


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())

Doc<T>

CRDT document to snapshot.

Change[]

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

CRDTProvider.getSnapshot


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.

Doc<T>

CRDT document to change.

string

A description of the change made.

(doc) => void

A function that modifies a CRDT document (provided as a parameter). This function will be run as a part of .localChange(...)

[Doc<T>, Change[]]

CRDTProvider.localChange


newDocument(): Doc<T>

Defined in: automerge/src/peerborne-automerge.ts:86

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

Doc<T>

CRDTProvider.newDocument


remoteChange(document, changes): Doc<T>

Defined in: automerge/src/peerborne-automerge.ts:100

Apply CRDT document changes made by a remote peer.

Doc<T>

CRDT document to update.

Change[]

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

Doc<T>

CRDTProvider.remoteChange