Loro
@homeostate/crdt-loro
Loro CRDT backend for @homeostate/core
Draft / placeholder release. 0.0.0 reserves the name while the API is still
being designed. Nothing here is stable — do not depend on it yet.
Loro backend for
@homeostate/core.
It maps the synced state onto a LoroMap (nested objects become LoroMap, arrays
LoroList, strings LoroText) and writes fine-grained operations derived from
getChanges, committed as one transaction per write.
Install
npm install @homeostate/core @homeostate/crdt-loro loro-crdtloro-crdt is a peer dependency.
Usage
import { LoroDoc } from "loro-crdt";
import { createSyncEngine } from "@homeostate/core";
import { createLoroBackend } from "@homeostate/crdt-loro";
const doc = new LoroDoc();
const engine = createSyncEngine(createLoroBackend(doc, "shared"), adapter);
engine.connect();The synced state lives in doc.getMap('shared'); a middle-of-array delete, a toggle, or a
keystroke each produce one small update. Replication is yours to wire, for example with
doc.subscribeLocalUpdates on one side and doc.import on the other. The engine hears
about every commit that did not come through its own write, imports and local edits alike.
Loro stores undefined as null, so such values read back as null.