@dovetail-ts/crdt-automerge 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/dist/index.d.ts +48 -0
- package/dist/index.js +185 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @dovetail-ts/crdt-automerge
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 480744b: First release of Dovetail: real-time and offline sync for Ember.
|
|
8
|
+
|
|
9
|
+
- `@dovetail-ts/core`: the connection life cycle, live store subscriptions, the optimistic ledger with rebase and rollback, the offline write queue in IndexedDB with a leader tab and dead letters, `DocSession` and `PresenceRoom`.
|
|
10
|
+
- `@dovetail-ts/warp-drive`: the store feed into WarpDrive.
|
|
11
|
+
- `@dovetail-ts/crdt`, `crdt-yjs`, `crdt-loro` and `crdt-automerge`: one `DocEngine` interface with three engines.
|
|
12
|
+
- `@dovetail-ts/tiptap`: co-editing in Tiptap 3 with carets, per-user undo, versions and comment threads.
|
|
13
|
+
- `@dovetail-ts/ember`, `notifications` and `inspector`: presence and status components, the inbox, toasts and activity feeds, and a dev panel.
|
|
14
|
+
- `@dovetail-ts/server`, the transports (`transport-ws`, `transport-sse`, `transport-cable`) and `conformance`: a Node server and one wire protocol that the Rails gems also pass.
|
|
15
|
+
- Adapters for Hocuspocus, Liveblocks, PartyKit and Supabase, and integrations for Switchyard, Millwork, Benchdog and Lattice. The Neon adapter is not in 1.0: it waits for a stable Neon Realtime client (1.1).
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [480744b]
|
|
20
|
+
- @dovetail-ts/crdt@1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joe Gaudet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dovetail-ts/crdt-automerge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Automerge `DocEngine` of Dovetail, on `@automerge/automerge`.
|
|
4
|
+
|
|
5
|
+
Part of [Dovetail](https://joegaudet.com/dovetail/). Not released yet.
|
|
6
|
+
|
|
7
|
+
## Use it
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { automergeEngine } from '@dovetail-ts/crdt-automerge'
|
|
11
|
+
|
|
12
|
+
const engine = automergeEngine()
|
|
13
|
+
const handle = engine.create()
|
|
14
|
+
handle.change(doc => {
|
|
15
|
+
doc.body = 'Hello'
|
|
16
|
+
})
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- `handle.doc` is the Automerge document now. `handle.change(fn, origin)` changes it.
|
|
20
|
+
- Make a root key on one peer only. Two peers that make the same root key at the same time
|
|
21
|
+
conflict, and Automerge keeps one value only.
|
|
22
|
+
- `handle.map(name)` keeps each key in its own root key (`${name}/${key}`), so the keys of
|
|
23
|
+
two peers do not conflict.
|
|
24
|
+
- The state vector is the heads of the document.
|
|
25
|
+
|
|
26
|
+
## Capabilities
|
|
27
|
+
|
|
28
|
+
| Capability | Value | Why |
|
|
29
|
+
| ---------------- | ----- | ------------------------------------------------------------------------- |
|
|
30
|
+
| `tiptap` | false | `@automerge/prosemirror` 0.2 makes its own schema, not the Tiptap schema. |
|
|
31
|
+
| `cursors` | false | There is no Tiptap binding. |
|
|
32
|
+
| `undo` | false | Automerge has no undo manager. |
|
|
33
|
+
| `history` | true | A version keeps the heads. `open` uses `view`. |
|
|
34
|
+
| `commentAnchors` | true | Automerge cursors in a text root key. |
|
|
35
|
+
|
|
36
|
+
`@dovetail-ts/tiptap` gives a `CapabilityError` for an Automerge document.
|
|
37
|
+
|
|
38
|
+
## The capability matrix
|
|
39
|
+
|
|
40
|
+
| Feature | Yjs (`y-prosemirror`) | Loro (`loro-prosemirror`) | Automerge (`@automerge/prosemirror`) |
|
|
41
|
+
| --------------- | -------------------------- | ------------------------------------------------------ | ---------------------------------------------------------------------------- |
|
|
42
|
+
| Tiptap binding | Yes | Yes (`loroBinding`, `@dovetail-ts/tiptap/loro`) | No: `@automerge/prosemirror` 0.2 makes its own schema, not the Tiptap schema |
|
|
43
|
+
| Remote cursors | Yes | Yes (the caret plugin of `loro-prosemirror`) | No: no Tiptap binding |
|
|
44
|
+
| Per-user undo | Yes (`UndoManager` origin) | Yes (Loro `UndoManager`: local changes, not by origin) | No: Automerge has no undo manager |
|
|
45
|
+
| Version history | Yes (snapshots) | Yes (native: frontiers, `forkAt`, diff) | Yes (native: heads, `view`), engine API only |
|
|
46
|
+
| Comment anchors | Yes (relative positions) | Yes (Loro cursors) | Yes (Automerge cursors), engine API only |
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as A from '@automerge/automerge';
|
|
2
|
+
import type { DocAwareness, DocEngine, DocHandle, DocVersions, EngineCapabilities, SharedMap } from '@dovetail-ts/crdt';
|
|
3
|
+
/** The root of an Automerge document of Dovetail. */
|
|
4
|
+
export type AutomergeRoot = Record<string, unknown>;
|
|
5
|
+
export interface AutomergeEngineOptions {
|
|
6
|
+
/** The clock of the version dates. The default is `Date.now`. */
|
|
7
|
+
now?: () => number;
|
|
8
|
+
}
|
|
9
|
+
/** Makes the Automerge engine. */
|
|
10
|
+
export declare function automergeEngine(options?: AutomergeEngineOptions): AutomergeEngine;
|
|
11
|
+
export declare class AutomergeEngine implements DocEngine {
|
|
12
|
+
readonly now: () => number;
|
|
13
|
+
readonly name = "automerge";
|
|
14
|
+
readonly capabilities: EngineCapabilities;
|
|
15
|
+
constructor(now: () => number);
|
|
16
|
+
create(): AutomergeDocHandle;
|
|
17
|
+
load(snapshot: Uint8Array): AutomergeDocHandle;
|
|
18
|
+
}
|
|
19
|
+
type Listener = (update: Uint8Array, origin: unknown) => void;
|
|
20
|
+
type PatchListener = (patches: A.Patch[], origin: unknown) => void;
|
|
21
|
+
/** An Automerge document. `doc` is the value now: each change makes a new value. */
|
|
22
|
+
export declare class AutomergeDocHandle implements DocHandle {
|
|
23
|
+
#private;
|
|
24
|
+
readonly engine: AutomergeEngine;
|
|
25
|
+
readonly awareness: DocAwareness;
|
|
26
|
+
readonly versions: DocVersions;
|
|
27
|
+
constructor(engine: AutomergeEngine, doc: A.Doc<AutomergeRoot>);
|
|
28
|
+
get doc(): A.Doc<AutomergeRoot>;
|
|
29
|
+
/** Changes the document with `change`, as one change with `origin`. */
|
|
30
|
+
change(change: (doc: AutomergeRoot) => void, origin?: unknown): void;
|
|
31
|
+
applyUpdate(update: Uint8Array, origin?: unknown): void;
|
|
32
|
+
encodeStateVector(): Uint8Array;
|
|
33
|
+
encodeUpdate(stateVector?: Uint8Array): Uint8Array;
|
|
34
|
+
snapshot(): Uint8Array;
|
|
35
|
+
onUpdate(listener: Listener): () => void;
|
|
36
|
+
/** Calls `listener` with the Automerge patches of each change, local or merged. */
|
|
37
|
+
onPatch(listener: PatchListener): () => void;
|
|
38
|
+
/**
|
|
39
|
+
* A map in the root keys `${name}/${key}`. Two peers that make the same map object at the
|
|
40
|
+
* same time conflict, and Automerge keeps one of the objects only. Root keys do not conflict.
|
|
41
|
+
*/
|
|
42
|
+
map(name: string): SharedMap;
|
|
43
|
+
/** A position in the text of the root key `field`. */
|
|
44
|
+
relativePosition(field: string, index: number): Uint8Array;
|
|
45
|
+
absolutePosition(position: Uint8Array): number | null;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as A from '@automerge/automerge';
|
|
2
|
+
import { JsonAwareness } from '@dovetail-ts/crdt';
|
|
3
|
+
|
|
4
|
+
// src/index.ts
|
|
5
|
+
function automergeEngine(options = {}) {
|
|
6
|
+
return new AutomergeEngine(options.now ?? Date.now);
|
|
7
|
+
}
|
|
8
|
+
var AutomergeEngine = class {
|
|
9
|
+
constructor(now) {
|
|
10
|
+
this.now = now;
|
|
11
|
+
}
|
|
12
|
+
now;
|
|
13
|
+
name = "automerge";
|
|
14
|
+
capabilities = {
|
|
15
|
+
tiptap: false,
|
|
16
|
+
cursors: false,
|
|
17
|
+
undo: false,
|
|
18
|
+
history: true,
|
|
19
|
+
commentAnchors: true
|
|
20
|
+
};
|
|
21
|
+
create() {
|
|
22
|
+
return new AutomergeDocHandle(this, A.init());
|
|
23
|
+
}
|
|
24
|
+
load(snapshot) {
|
|
25
|
+
return new AutomergeDocHandle(this, A.loadIncremental(A.init(), snapshot));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var encoder = new TextEncoder();
|
|
29
|
+
var decoder = new TextDecoder();
|
|
30
|
+
var encode = (value) => encoder.encode(JSON.stringify(value));
|
|
31
|
+
var decode = (bytes) => JSON.parse(decoder.decode(bytes));
|
|
32
|
+
var copy = (value) => JSON.parse(JSON.stringify(value));
|
|
33
|
+
var AutomergeDocHandle = class {
|
|
34
|
+
constructor(engine, doc) {
|
|
35
|
+
this.engine = engine;
|
|
36
|
+
this.#doc = doc;
|
|
37
|
+
this.awareness = new JsonAwareness(A.getActorId(doc));
|
|
38
|
+
this.versions = new AutomergeVersions(this);
|
|
39
|
+
}
|
|
40
|
+
engine;
|
|
41
|
+
awareness;
|
|
42
|
+
versions;
|
|
43
|
+
#doc;
|
|
44
|
+
#listeners = /* @__PURE__ */ new Set();
|
|
45
|
+
#patchListeners = /* @__PURE__ */ new Set();
|
|
46
|
+
get doc() {
|
|
47
|
+
return this.#doc;
|
|
48
|
+
}
|
|
49
|
+
/** Changes the document with `change`, as one change with `origin`. */
|
|
50
|
+
change(change2, origin) {
|
|
51
|
+
const before = A.getHeads(this.#doc);
|
|
52
|
+
let patches = [];
|
|
53
|
+
this.#doc = A.change(this.#doc, { patchCallback: (p) => patches = p }, change2);
|
|
54
|
+
if (A.getHeads(this.#doc).join() === before.join()) return;
|
|
55
|
+
this.#changed(patches, A.saveSince(this.#doc, before), origin);
|
|
56
|
+
}
|
|
57
|
+
applyUpdate(update, origin) {
|
|
58
|
+
let patches = [];
|
|
59
|
+
this.#doc = A.loadIncremental(this.#doc, update, { patchCallback: (p) => patches = p });
|
|
60
|
+
this.#changed(patches, update, origin);
|
|
61
|
+
}
|
|
62
|
+
encodeStateVector() {
|
|
63
|
+
return encode(A.getHeads(this.#doc));
|
|
64
|
+
}
|
|
65
|
+
encodeUpdate(stateVector) {
|
|
66
|
+
const heads = stateVector ? decode(stateVector) : [];
|
|
67
|
+
if (!Array.isArray(heads)) throw new Error("This is not an Automerge state vector.");
|
|
68
|
+
const known = heads.filter(
|
|
69
|
+
(head) => typeof head === "string" && A.hasHeads(this.#doc, [head])
|
|
70
|
+
);
|
|
71
|
+
return A.saveSince(this.#doc, known);
|
|
72
|
+
}
|
|
73
|
+
snapshot() {
|
|
74
|
+
return A.save(this.#doc);
|
|
75
|
+
}
|
|
76
|
+
onUpdate(listener) {
|
|
77
|
+
this.#listeners.add(listener);
|
|
78
|
+
return () => this.#listeners.delete(listener);
|
|
79
|
+
}
|
|
80
|
+
/** Calls `listener` with the Automerge patches of each change, local or merged. */
|
|
81
|
+
onPatch(listener) {
|
|
82
|
+
this.#patchListeners.add(listener);
|
|
83
|
+
return () => this.#patchListeners.delete(listener);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A map in the root keys `${name}/${key}`. Two peers that make the same map object at the
|
|
87
|
+
* same time conflict, and Automerge keeps one of the objects only. Root keys do not conflict.
|
|
88
|
+
*/
|
|
89
|
+
map(name) {
|
|
90
|
+
const prefix = `${name}/`;
|
|
91
|
+
return {
|
|
92
|
+
get: (key) => this.#doc[prefix + key],
|
|
93
|
+
set: (key, value, origin) => this.change((doc) => {
|
|
94
|
+
doc[prefix + key] = copy(value);
|
|
95
|
+
}, origin),
|
|
96
|
+
delete: (key, origin) => this.change((doc) => {
|
|
97
|
+
delete doc[prefix + key];
|
|
98
|
+
}, origin),
|
|
99
|
+
entries: () => Object.entries(this.#doc).filter(([key]) => key.startsWith(prefix)).map(([key, value]) => [key.slice(prefix.length), value]),
|
|
100
|
+
onChange: (listener) => this.onPatch((patches, origin) => {
|
|
101
|
+
const keys = new Set(
|
|
102
|
+
patches.map((patch) => String(patch.path[0])).filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length))
|
|
103
|
+
);
|
|
104
|
+
if (keys.size > 0) listener([...keys], origin);
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** A position in the text of the root key `field`. */
|
|
109
|
+
relativePosition(field, index) {
|
|
110
|
+
return encode({ field, cursor: A.getCursor(this.#doc, [field], index) });
|
|
111
|
+
}
|
|
112
|
+
absolutePosition(position) {
|
|
113
|
+
const { field, cursor } = decode(position);
|
|
114
|
+
try {
|
|
115
|
+
return A.getCursorPosition(this.#doc, [field], cursor);
|
|
116
|
+
} catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
destroy() {
|
|
121
|
+
this.#listeners.clear();
|
|
122
|
+
this.#patchListeners.clear();
|
|
123
|
+
this.awareness.setLocalState(null);
|
|
124
|
+
}
|
|
125
|
+
#changed(patches, update, origin) {
|
|
126
|
+
for (const listener of this.#patchListeners) listener(patches, origin);
|
|
127
|
+
for (const listener of this.#listeners) listener(update, origin);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var AutomergeVersions = class {
|
|
131
|
+
constructor(handle) {
|
|
132
|
+
this.handle = handle;
|
|
133
|
+
}
|
|
134
|
+
handle;
|
|
135
|
+
get #map() {
|
|
136
|
+
return this.handle.map("dovetail:versions");
|
|
137
|
+
}
|
|
138
|
+
list() {
|
|
139
|
+
return this.#map.entries().map(([, value]) => {
|
|
140
|
+
const { id, name, createdAt, by } = value;
|
|
141
|
+
return { id, name, createdAt, by };
|
|
142
|
+
}).sort((a, b) => a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id));
|
|
143
|
+
}
|
|
144
|
+
create(options = {}) {
|
|
145
|
+
const { doc, engine, awareness } = this.handle;
|
|
146
|
+
const count = this.#map.entries().length;
|
|
147
|
+
const version = {
|
|
148
|
+
id: `${awareness.clientId}-${count}`,
|
|
149
|
+
name: options.name ?? `Version ${count + 1}`,
|
|
150
|
+
createdAt: new Date(engine.now()).toISOString(),
|
|
151
|
+
by: options.by ?? null
|
|
152
|
+
};
|
|
153
|
+
this.#map.set(version.id, { ...version, heads: A.getHeads(doc) });
|
|
154
|
+
return version;
|
|
155
|
+
}
|
|
156
|
+
open(id) {
|
|
157
|
+
return new AutomergeDocHandle(this.handle.engine, A.clone(this.#view(id)));
|
|
158
|
+
}
|
|
159
|
+
restore(id, origin) {
|
|
160
|
+
const old = this.#view(id);
|
|
161
|
+
this.handle.change((doc) => {
|
|
162
|
+
const content = (key) => !key.startsWith("dovetail:");
|
|
163
|
+
for (const key of Object.keys(doc).filter(content)) if (!(key in old)) delete doc[key];
|
|
164
|
+
for (const [key, value] of Object.entries(old).filter(([key2]) => content(key2))) {
|
|
165
|
+
if (typeof value === "string" && typeof doc[key] === "string") {
|
|
166
|
+
A.updateSpans(doc, [key], A.spans(old, [key]));
|
|
167
|
+
} else {
|
|
168
|
+
doc[key] = copy(value);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, origin);
|
|
172
|
+
}
|
|
173
|
+
onChange(listener) {
|
|
174
|
+
return this.#map.onChange(() => listener());
|
|
175
|
+
}
|
|
176
|
+
#view(id) {
|
|
177
|
+
const stored = this.#map.get(id);
|
|
178
|
+
if (!stored) throw new Error(`No version "${id}" in this document.`);
|
|
179
|
+
return A.view(this.handle.doc, stored.heads);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export { AutomergeDocHandle, AutomergeEngine, automergeEngine };
|
|
184
|
+
//# sourceMappingURL=index.js.map
|
|
185
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["change","key"],"mappings":";;;;AAwBO,SAAS,eAAA,CAAgB,OAAA,GAAkC,EAAC,EAAoB;AACrF,EAAA,OAAO,IAAI,eAAA,CAAgB,OAAA,CAAQ,GAAA,IAAO,KAAK,GAAG,CAAA;AACpD;AAEO,IAAM,kBAAN,MAA2C;AAAA,EAUhD,YAAqB,GAAA,EAAmB;AAAnB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAoB;AAAA,EAApB,GAA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AS,CAAA,CAAA,IAAA,CAAK,IAAA,CAAK,MAAA,CAAO,GAAA,EAAK,OAAO,KAAK,CAAA;AAAA,EAC7C;AACF,CAAA","file":"index.js","sourcesContent":["// The Automerge DocEngine (ADR 0002, ADR 0014). Versions use the native history of Automerge\n// (heads), and comment anchors use Automerge cursors. There is no Tiptap binding and no undo.\nimport * as A from '@automerge/automerge'\nimport type {\n DocAwareness,\n DocEngine,\n DocHandle,\n DocVersions,\n EngineCapabilities,\n JsonValue,\n SharedMap,\n Version,\n} from '@dovetail-ts/crdt'\nimport { JsonAwareness } from '@dovetail-ts/crdt'\n\n/** The root of an Automerge document of Dovetail. */\nexport type AutomergeRoot = Record<string, unknown>\n\nexport interface AutomergeEngineOptions {\n /** The clock of the version dates. The default is `Date.now`. */\n now?: () => number\n}\n\n/** Makes the Automerge engine. */\nexport function automergeEngine(options: AutomergeEngineOptions = {}): AutomergeEngine {\n return new AutomergeEngine(options.now ?? Date.now)\n}\n\nexport class AutomergeEngine implements DocEngine {\n readonly name = 'automerge'\n readonly capabilities: EngineCapabilities = {\n tiptap: false,\n cursors: false,\n undo: false,\n history: true,\n commentAnchors: true,\n }\n\n constructor(readonly now: () => number) {}\n\n create(): AutomergeDocHandle {\n return new AutomergeDocHandle(this, A.init<AutomergeRoot>())\n }\n\n load(snapshot: Uint8Array): AutomergeDocHandle {\n return new AutomergeDocHandle(this, A.loadIncremental(A.init<AutomergeRoot>(), snapshot))\n }\n}\n\ntype Listener = (update: Uint8Array, origin: unknown) => void\ntype PatchListener = (patches: A.Patch[], origin: unknown) => void\n\nconst encoder = new TextEncoder()\nconst decoder = new TextDecoder()\nconst encode = (value: JsonValue) => encoder.encode(JSON.stringify(value))\nconst decode = (bytes: Uint8Array): unknown => JSON.parse(decoder.decode(bytes))\n// Automerge does not take an object of another document, so give it a copy.\nconst copy = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T\n\n/** An Automerge document. `doc` is the value now: each change makes a new value. */\nexport class AutomergeDocHandle implements DocHandle {\n readonly awareness: DocAwareness\n readonly versions: DocVersions\n #doc: A.Doc<AutomergeRoot>\n #listeners = new Set<Listener>()\n #patchListeners = new Set<PatchListener>()\n\n constructor(\n readonly engine: AutomergeEngine,\n doc: A.Doc<AutomergeRoot>,\n ) {\n this.#doc = doc\n this.awareness = new JsonAwareness(A.getActorId(doc))\n this.versions = new AutomergeVersions(this)\n }\n\n get doc(): A.Doc<AutomergeRoot> {\n return this.#doc\n }\n\n /** Changes the document with `change`, as one change with `origin`. */\n change(change: (doc: AutomergeRoot) => void, origin?: unknown): void {\n const before = A.getHeads(this.#doc)\n let patches: A.Patch[] = []\n this.#doc = A.change(this.#doc, { patchCallback: p => (patches = p) }, change)\n if (A.getHeads(this.#doc).join() === before.join()) return\n this.#changed(patches, A.saveSince(this.#doc, before), origin)\n }\n\n applyUpdate(update: Uint8Array, origin?: unknown): void {\n let patches: A.Patch[] = []\n this.#doc = A.loadIncremental(this.#doc, update, { patchCallback: p => (patches = p) })\n this.#changed(patches, update, origin)\n }\n\n encodeStateVector(): Uint8Array {\n return encode(A.getHeads(this.#doc))\n }\n\n encodeUpdate(stateVector?: Uint8Array): Uint8Array {\n const heads = stateVector ? decode(stateVector) : []\n if (!Array.isArray(heads)) throw new Error('This is not an Automerge state vector.')\n // A head that this document does not have is a change of the peer only. The changes after\n // the other heads hold all the changes that the peer does not have.\n const known = heads.filter(\n (head): head is string => typeof head === 'string' && A.hasHeads(this.#doc, [head]),\n )\n return A.saveSince(this.#doc, known)\n }\n\n snapshot(): Uint8Array {\n return A.save(this.#doc)\n }\n\n onUpdate(listener: Listener): () => void {\n this.#listeners.add(listener)\n return () => this.#listeners.delete(listener)\n }\n\n /** Calls `listener` with the Automerge patches of each change, local or merged. */\n onPatch(listener: PatchListener): () => void {\n this.#patchListeners.add(listener)\n return () => this.#patchListeners.delete(listener)\n }\n\n /**\n * A map in the root keys `${name}/${key}`. Two peers that make the same map object at the\n * same time conflict, and Automerge keeps one of the objects only. Root keys do not conflict.\n */\n map(name: string): SharedMap {\n const prefix = `${name}/`\n return {\n get: key => this.#doc[prefix + key] as JsonValue | undefined,\n set: (key, value, origin) =>\n this.change(doc => {\n doc[prefix + key] = copy(value)\n }, origin),\n delete: (key, origin) =>\n this.change(doc => {\n delete doc[prefix + key]\n }, origin),\n entries: () =>\n Object.entries(this.#doc)\n .filter(([key]) => key.startsWith(prefix))\n .map(([key, value]) => [key.slice(prefix.length), value as JsonValue]),\n onChange: listener =>\n this.onPatch((patches, origin) => {\n const keys = new Set(\n patches\n .map(patch => String(patch.path[0]))\n .filter(key => key.startsWith(prefix))\n .map(key => key.slice(prefix.length)),\n )\n if (keys.size > 0) listener([...keys], origin)\n }),\n }\n }\n\n /** A position in the text of the root key `field`. */\n relativePosition(field: string, index: number): Uint8Array {\n return encode({ field, cursor: A.getCursor(this.#doc, [field], index) })\n }\n\n absolutePosition(position: Uint8Array): number | null {\n const { field, cursor } = decode(position) as { field: string; cursor: A.Cursor }\n try {\n return A.getCursorPosition(this.#doc, [field], cursor)\n } catch {\n // The text of the cursor is gone.\n return null\n }\n }\n\n destroy(): void {\n this.#listeners.clear()\n this.#patchListeners.clear()\n this.awareness.setLocalState(null)\n }\n\n #changed(patches: A.Patch[], update: Uint8Array, origin: unknown): void {\n for (const listener of this.#patchListeners) listener(patches, origin)\n for (const listener of this.#listeners) listener(update, origin)\n }\n}\n\ntype Stored = Version & { heads: A.Heads }\n\n/** The versions of an Automerge document: the heads of each version, in `dovetail:versions`. */\nclass AutomergeVersions implements DocVersions {\n constructor(readonly handle: AutomergeDocHandle) {}\n\n get #map(): SharedMap {\n return this.handle.map('dovetail:versions')\n }\n\n list(): Version[] {\n return this.#map\n .entries()\n .map(([, value]) => {\n const { id, name, createdAt, by } = value as unknown as Stored\n return { id, name, createdAt, by }\n })\n .sort((a, b) => a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id))\n }\n\n create(options: { name?: string; by?: string | null } = {}): Version {\n const { doc, engine, awareness } = this.handle\n const count = this.#map.entries().length\n const version: Version = {\n id: `${awareness.clientId}-${count}`,\n name: options.name ?? `Version ${count + 1}`,\n createdAt: new Date(engine.now()).toISOString(),\n by: options.by ?? null,\n }\n this.#map.set(version.id, { ...version, heads: A.getHeads(doc) })\n return version\n }\n\n open(id: string): DocHandle {\n return new AutomergeDocHandle(this.handle.engine, A.clone(this.#view(id)))\n }\n\n restore(id: string, origin?: unknown): void {\n const old = this.#view(id)\n this.handle.change(doc => {\n const content = (key: string) => !key.startsWith('dovetail:')\n for (const key of Object.keys(doc).filter(content)) if (!(key in old)) delete doc[key]\n for (const [key, value] of Object.entries(old).filter(([key]) => content(key))) {\n if (typeof value === 'string' && typeof doc[key] === 'string') {\n A.updateSpans(doc, [key], A.spans(old, [key]))\n } else {\n doc[key] = copy(value)\n }\n }\n }, origin)\n }\n\n onChange(listener: () => void): () => void {\n return this.#map.onChange(() => listener())\n }\n\n #view(id: string): A.Doc<AutomergeRoot> {\n const stored = this.#map.get(id) as unknown as Stored | undefined\n if (!stored) throw new Error(`No version \"${id}\" in this document.`)\n return A.view(this.handle.doc, stored.heads)\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dovetail-ts/crdt-automerge",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The Automerge DocEngine.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Joe Gaudet <joe@joegaudet.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/joegaudet/dovetail.git",
|
|
10
|
+
"directory": "packages/crdt-automerge"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://joegaudet.com/dovetail/",
|
|
13
|
+
"bugs": "https://github.com/joegaudet/dovetail/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"realtime",
|
|
16
|
+
"offline",
|
|
17
|
+
"sync",
|
|
18
|
+
"crdt"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"CHANGELOG.md",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@automerge/automerge": "^3.5.0",
|
|
38
|
+
"@dovetail-ts/crdt": "1.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"tsup": "^8.5.1"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=22.12.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc --build --force && tsup"
|
|
51
|
+
}
|
|
6
52
|
}
|