@affectively/dash 5.4.0 → 5.4.5
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/README.md +8 -189
- package/dist/automerge_wasm_bg-4hg5vg2g.wasm +0 -0
- package/dist/engine/sqlite.d.ts +30 -0
- package/dist/engine/vec_extension.d.ts +2 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +53895 -0
- package/dist/middleware/errorHandler.d.ts +60 -0
- package/dist/{src/sync → sync}/AeonDurableSync.d.ts +8 -9
- package/dist/sync/AeonDurableSync.js +1984 -0
- package/dist/{src/sync → sync}/AutomergeProvider.d.ts +8 -8
- package/dist/sync/AutomergeProvider.js +4421 -0
- package/dist/sync/HybridProvider.d.ts +124 -0
- package/dist/sync/HybridProvider.js +8328 -0
- package/dist/sync/connection/WebRTCConnection.d.ts +23 -0
- package/dist/sync/connection/WebRTCConnection.js +59 -0
- package/dist/sync/index.d.ts +13 -0
- package/dist/sync/index.js +12773 -0
- package/dist/sync/provider/YjsSqliteProvider.d.ts +17 -0
- package/dist/sync/provider/YjsSqliteProvider.js +54 -0
- package/dist/sync/types.d.ts +74 -0
- package/dist/sync/webtransport/WebTransportProvider.d.ts +16 -0
- package/dist/sync/webtransport/WebTransportProvider.js +55 -0
- package/package.json +62 -70
- package/dist/src/api/firebase/auth/index.d.ts +0 -137
- package/dist/src/api/firebase/auth/index.js +0 -352
- package/dist/src/api/firebase/auth/providers.d.ts +0 -254
- package/dist/src/api/firebase/auth/providers.js +0 -518
- package/dist/src/api/firebase/database/index.d.ts +0 -108
- package/dist/src/api/firebase/database/index.js +0 -368
- package/dist/src/api/firebase/errors.d.ts +0 -15
- package/dist/src/api/firebase/errors.js +0 -215
- package/dist/src/api/firebase/firestore/data-types.d.ts +0 -116
- package/dist/src/api/firebase/firestore/data-types.js +0 -280
- package/dist/src/api/firebase/firestore/index.d.ts +0 -7
- package/dist/src/api/firebase/firestore/index.js +0 -13
- package/dist/src/api/firebase/firestore/listeners.d.ts +0 -20
- package/dist/src/api/firebase/firestore/listeners.js +0 -50
- package/dist/src/api/firebase/firestore/operations.d.ts +0 -123
- package/dist/src/api/firebase/firestore/operations.js +0 -490
- package/dist/src/api/firebase/firestore/query.d.ts +0 -118
- package/dist/src/api/firebase/firestore/query.js +0 -418
- package/dist/src/api/firebase/index.d.ts +0 -11
- package/dist/src/api/firebase/index.js +0 -17
- package/dist/src/api/firebase/storage/index.d.ts +0 -100
- package/dist/src/api/firebase/storage/index.js +0 -286
- package/dist/src/api/firebase/types.d.ts +0 -341
- package/dist/src/api/firebase/types.js +0 -4
- package/dist/src/auth/manager.d.ts +0 -182
- package/dist/src/auth/manager.js +0 -598
- package/dist/src/engine/ai.js +0 -76
- package/dist/src/engine/sqlite.d.ts +0 -353
- package/dist/src/engine/sqlite.js +0 -1328
- package/dist/src/engine/vec_extension.d.ts +0 -5
- package/dist/src/engine/vec_extension.js +0 -10
- package/dist/src/index.d.ts +0 -21
- package/dist/src/index.js +0 -26
- package/dist/src/mcp/server.js +0 -87
- package/dist/src/reactivity/signal.js +0 -31
- package/dist/src/schema/lens.d.ts +0 -29
- package/dist/src/schema/lens.js +0 -122
- package/dist/src/sync/AeonDurableSync.js +0 -67
- package/dist/src/sync/AutomergeProvider.js +0 -153
- package/dist/src/sync/aeon/config.d.ts +0 -21
- package/dist/src/sync/aeon/config.js +0 -14
- package/dist/src/sync/aeon/delta-adapter.d.ts +0 -62
- package/dist/src/sync/aeon/delta-adapter.js +0 -98
- package/dist/src/sync/aeon/index.d.ts +0 -18
- package/dist/src/sync/aeon/index.js +0 -19
- package/dist/src/sync/aeon/offline-adapter.d.ts +0 -110
- package/dist/src/sync/aeon/offline-adapter.js +0 -227
- package/dist/src/sync/aeon/presence-adapter.d.ts +0 -114
- package/dist/src/sync/aeon/presence-adapter.js +0 -157
- package/dist/src/sync/aeon/schema-adapter.d.ts +0 -95
- package/dist/src/sync/aeon/schema-adapter.js +0 -163
- package/dist/src/sync/backup.d.ts +0 -12
- package/dist/src/sync/backup.js +0 -44
- package/dist/src/sync/connection.d.ts +0 -20
- package/dist/src/sync/connection.js +0 -50
- package/dist/src/sync/d1-provider.d.ts +0 -103
- package/dist/src/sync/d1-provider.js +0 -418
- package/dist/src/sync/hybrid-provider.d.ts +0 -307
- package/dist/src/sync/hybrid-provider.js +0 -1353
- package/dist/src/sync/provider.d.ts +0 -11
- package/dist/src/sync/provider.js +0 -67
- package/dist/src/sync/types.d.ts +0 -32
- package/dist/src/sync/types.js +0 -4
- package/dist/src/sync/verify.d.ts +0 -1
- package/dist/src/sync/verify.js +0 -23
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{src/engine → engine}/ai.d.ts +0 -0
- /package/dist/{src/mcp → mcp}/server.d.ts +0 -0
- /package/dist/{src/reactivity → reactivity}/signal.d.ts +0 -0
|
@@ -0,0 +1,4421 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
7
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
8
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
9
|
+
for (let key of __getOwnPropNames(mod))
|
|
10
|
+
if (!__hasOwnProp.call(to, key))
|
|
11
|
+
__defProp(to, key, {
|
|
12
|
+
get: () => mod[key],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, {
|
|
21
|
+
get: all[name],
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
set: (newValue) => all[name] = () => newValue
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
28
|
+
|
|
29
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/web/automerge_wasm.js
|
|
30
|
+
var exports_automerge_wasm = {};
|
|
31
|
+
__export(exports_automerge_wasm, {
|
|
32
|
+
wasmReleaseInfo: () => wasmReleaseInfo,
|
|
33
|
+
readBundle: () => readBundle,
|
|
34
|
+
load: () => load,
|
|
35
|
+
initSyncState: () => initSyncState,
|
|
36
|
+
initSync: () => initSync,
|
|
37
|
+
importSyncState: () => importSyncState,
|
|
38
|
+
exportSyncState: () => exportSyncState,
|
|
39
|
+
encodeSyncState: () => encodeSyncState,
|
|
40
|
+
encodeSyncMessage: () => encodeSyncMessage,
|
|
41
|
+
encodeChange: () => encodeChange,
|
|
42
|
+
default: () => __wbg_init,
|
|
43
|
+
decodeSyncState: () => decodeSyncState,
|
|
44
|
+
decodeSyncMessage: () => decodeSyncMessage,
|
|
45
|
+
decodeChange: () => decodeChange,
|
|
46
|
+
create: () => create,
|
|
47
|
+
SyncState: () => SyncState,
|
|
48
|
+
Automerge: () => Automerge
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
class Automerge {
|
|
52
|
+
static __wrap(ptr) {
|
|
53
|
+
ptr = ptr >>> 0;
|
|
54
|
+
const obj = Object.create(Automerge.prototype);
|
|
55
|
+
obj.__wbg_ptr = ptr;
|
|
56
|
+
AutomergeFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
57
|
+
return obj;
|
|
58
|
+
}
|
|
59
|
+
__destroy_into_raw() {
|
|
60
|
+
const ptr = this.__wbg_ptr;
|
|
61
|
+
this.__wbg_ptr = 0;
|
|
62
|
+
AutomergeFinalization.unregister(this);
|
|
63
|
+
return ptr;
|
|
64
|
+
}
|
|
65
|
+
free() {
|
|
66
|
+
const ptr = this.__destroy_into_raw();
|
|
67
|
+
wasm.__wbg_automerge_free(ptr, 0);
|
|
68
|
+
}
|
|
69
|
+
applyAndReturnPatches(object, meta) {
|
|
70
|
+
const ret = wasm.automerge_applyAndReturnPatches(this.__wbg_ptr, object, meta);
|
|
71
|
+
if (ret[2]) {
|
|
72
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
73
|
+
}
|
|
74
|
+
return takeFromExternrefTable0(ret[0]);
|
|
75
|
+
}
|
|
76
|
+
applyChanges(changes) {
|
|
77
|
+
const ret = wasm.automerge_applyChanges(this.__wbg_ptr, changes);
|
|
78
|
+
if (ret[1]) {
|
|
79
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
applyPatches(object, meta) {
|
|
83
|
+
const ret = wasm.automerge_applyPatches(this.__wbg_ptr, object, meta);
|
|
84
|
+
if (ret[2]) {
|
|
85
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
86
|
+
}
|
|
87
|
+
return takeFromExternrefTable0(ret[0]);
|
|
88
|
+
}
|
|
89
|
+
clone(actor) {
|
|
90
|
+
var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
91
|
+
var len0 = WASM_VECTOR_LEN;
|
|
92
|
+
const ret = wasm.automerge_clone(this.__wbg_ptr, ptr0, len0);
|
|
93
|
+
if (ret[2]) {
|
|
94
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
95
|
+
}
|
|
96
|
+
return Automerge.__wrap(ret[0]);
|
|
97
|
+
}
|
|
98
|
+
commit(message, time) {
|
|
99
|
+
var ptr0 = isLikeNone(message) ? 0 : passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
100
|
+
var len0 = WASM_VECTOR_LEN;
|
|
101
|
+
const ret = wasm.automerge_commit(this.__wbg_ptr, ptr0, len0, !isLikeNone(time), isLikeNone(time) ? 0 : time);
|
|
102
|
+
return ret;
|
|
103
|
+
}
|
|
104
|
+
delete(obj, prop) {
|
|
105
|
+
const ret = wasm.automerge_delete(this.__wbg_ptr, obj, prop);
|
|
106
|
+
if (ret[1]) {
|
|
107
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
diff(before, after) {
|
|
111
|
+
const ret = wasm.automerge_diff(this.__wbg_ptr, before, after);
|
|
112
|
+
if (ret[2]) {
|
|
113
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
114
|
+
}
|
|
115
|
+
return takeFromExternrefTable0(ret[0]);
|
|
116
|
+
}
|
|
117
|
+
diffIncremental() {
|
|
118
|
+
const ret = wasm.automerge_diffIncremental(this.__wbg_ptr);
|
|
119
|
+
if (ret[2]) {
|
|
120
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
121
|
+
}
|
|
122
|
+
return takeFromExternrefTable0(ret[0]);
|
|
123
|
+
}
|
|
124
|
+
diffPath(path, before, after, options) {
|
|
125
|
+
const ret = wasm.automerge_diffPath(this.__wbg_ptr, path, before, after, options);
|
|
126
|
+
if (ret[2]) {
|
|
127
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
128
|
+
}
|
|
129
|
+
return takeFromExternrefTable0(ret[0]);
|
|
130
|
+
}
|
|
131
|
+
dump() {
|
|
132
|
+
wasm.automerge_dump(this.__wbg_ptr);
|
|
133
|
+
}
|
|
134
|
+
emptyChange(message, time) {
|
|
135
|
+
var ptr0 = isLikeNone(message) ? 0 : passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
136
|
+
var len0 = WASM_VECTOR_LEN;
|
|
137
|
+
const ret = wasm.automerge_emptyChange(this.__wbg_ptr, ptr0, len0, !isLikeNone(time), isLikeNone(time) ? 0 : time);
|
|
138
|
+
return ret;
|
|
139
|
+
}
|
|
140
|
+
enableFreeze(enable) {
|
|
141
|
+
const ret = wasm.automerge_enableFreeze(this.__wbg_ptr, enable);
|
|
142
|
+
if (ret[2]) {
|
|
143
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
144
|
+
}
|
|
145
|
+
return ret[0] !== 0;
|
|
146
|
+
}
|
|
147
|
+
fork(actor, heads) {
|
|
148
|
+
var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
149
|
+
var len0 = WASM_VECTOR_LEN;
|
|
150
|
+
const ret = wasm.automerge_fork(this.__wbg_ptr, ptr0, len0, heads);
|
|
151
|
+
if (ret[2]) {
|
|
152
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
153
|
+
}
|
|
154
|
+
return Automerge.__wrap(ret[0]);
|
|
155
|
+
}
|
|
156
|
+
generateSyncMessage(state) {
|
|
157
|
+
_assertClass(state, SyncState);
|
|
158
|
+
const ret = wasm.automerge_generateSyncMessage(this.__wbg_ptr, state.__wbg_ptr);
|
|
159
|
+
return ret;
|
|
160
|
+
}
|
|
161
|
+
get(obj, prop, heads) {
|
|
162
|
+
const ret = wasm.automerge_get(this.__wbg_ptr, obj, prop, heads);
|
|
163
|
+
if (ret[2]) {
|
|
164
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
165
|
+
}
|
|
166
|
+
return takeFromExternrefTable0(ret[0]);
|
|
167
|
+
}
|
|
168
|
+
getActorId() {
|
|
169
|
+
let deferred1_0;
|
|
170
|
+
let deferred1_1;
|
|
171
|
+
try {
|
|
172
|
+
const ret = wasm.automerge_getActorId(this.__wbg_ptr);
|
|
173
|
+
deferred1_0 = ret[0];
|
|
174
|
+
deferred1_1 = ret[1];
|
|
175
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
176
|
+
} finally {
|
|
177
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
getAll(obj, arg, heads) {
|
|
181
|
+
const ret = wasm.automerge_getAll(this.__wbg_ptr, obj, arg, heads);
|
|
182
|
+
if (ret[2]) {
|
|
183
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
184
|
+
}
|
|
185
|
+
return takeFromExternrefTable0(ret[0]);
|
|
186
|
+
}
|
|
187
|
+
getBlock(text, index, heads) {
|
|
188
|
+
const ret = wasm.automerge_getBlock(this.__wbg_ptr, text, index, heads);
|
|
189
|
+
if (ret[2]) {
|
|
190
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
191
|
+
}
|
|
192
|
+
return takeFromExternrefTable0(ret[0]);
|
|
193
|
+
}
|
|
194
|
+
getChangeByHash(hash) {
|
|
195
|
+
const ret = wasm.automerge_getChangeByHash(this.__wbg_ptr, hash);
|
|
196
|
+
if (ret[2]) {
|
|
197
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
198
|
+
}
|
|
199
|
+
return takeFromExternrefTable0(ret[0]);
|
|
200
|
+
}
|
|
201
|
+
getChangeMetaByHash(hash) {
|
|
202
|
+
const ret = wasm.automerge_getChangeMetaByHash(this.__wbg_ptr, hash);
|
|
203
|
+
if (ret[2]) {
|
|
204
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
205
|
+
}
|
|
206
|
+
return takeFromExternrefTable0(ret[0]);
|
|
207
|
+
}
|
|
208
|
+
getChanges(have_deps) {
|
|
209
|
+
const ret = wasm.automerge_getChanges(this.__wbg_ptr, have_deps);
|
|
210
|
+
if (ret[2]) {
|
|
211
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
212
|
+
}
|
|
213
|
+
return takeFromExternrefTable0(ret[0]);
|
|
214
|
+
}
|
|
215
|
+
getChangesAdded(other) {
|
|
216
|
+
_assertClass(other, Automerge);
|
|
217
|
+
const ret = wasm.automerge_getChangesAdded(this.__wbg_ptr, other.__wbg_ptr);
|
|
218
|
+
return ret;
|
|
219
|
+
}
|
|
220
|
+
getChangesMeta(have_deps) {
|
|
221
|
+
const ret = wasm.automerge_getChangesMeta(this.__wbg_ptr, have_deps);
|
|
222
|
+
if (ret[2]) {
|
|
223
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
224
|
+
}
|
|
225
|
+
return takeFromExternrefTable0(ret[0]);
|
|
226
|
+
}
|
|
227
|
+
getCursor(obj, position, heads, move_cursor) {
|
|
228
|
+
let deferred2_0;
|
|
229
|
+
let deferred2_1;
|
|
230
|
+
try {
|
|
231
|
+
const ret = wasm.automerge_getCursor(this.__wbg_ptr, obj, position, heads, move_cursor);
|
|
232
|
+
var ptr1 = ret[0];
|
|
233
|
+
var len1 = ret[1];
|
|
234
|
+
if (ret[3]) {
|
|
235
|
+
ptr1 = 0;
|
|
236
|
+
len1 = 0;
|
|
237
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
238
|
+
}
|
|
239
|
+
deferred2_0 = ptr1;
|
|
240
|
+
deferred2_1 = len1;
|
|
241
|
+
return getStringFromWasm0(ptr1, len1);
|
|
242
|
+
} finally {
|
|
243
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
getCursorPosition(obj, cursor, heads) {
|
|
247
|
+
const ret = wasm.automerge_getCursorPosition(this.__wbg_ptr, obj, cursor, heads);
|
|
248
|
+
if (ret[2]) {
|
|
249
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
250
|
+
}
|
|
251
|
+
return ret[0];
|
|
252
|
+
}
|
|
253
|
+
getDecodedChangeByHash(hash) {
|
|
254
|
+
const ret = wasm.automerge_getDecodedChangeByHash(this.__wbg_ptr, hash);
|
|
255
|
+
if (ret[2]) {
|
|
256
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
257
|
+
}
|
|
258
|
+
return takeFromExternrefTable0(ret[0]);
|
|
259
|
+
}
|
|
260
|
+
getHeads() {
|
|
261
|
+
const ret = wasm.automerge_getHeads(this.__wbg_ptr);
|
|
262
|
+
return ret;
|
|
263
|
+
}
|
|
264
|
+
getLastLocalChange() {
|
|
265
|
+
const ret = wasm.automerge_getLastLocalChange(this.__wbg_ptr);
|
|
266
|
+
return ret;
|
|
267
|
+
}
|
|
268
|
+
getMissingDeps(heads) {
|
|
269
|
+
const ret = wasm.automerge_getMissingDeps(this.__wbg_ptr, heads);
|
|
270
|
+
if (ret[2]) {
|
|
271
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
272
|
+
}
|
|
273
|
+
return takeFromExternrefTable0(ret[0]);
|
|
274
|
+
}
|
|
275
|
+
getWithType(obj, prop, heads) {
|
|
276
|
+
const ret = wasm.automerge_getWithType(this.__wbg_ptr, obj, prop, heads);
|
|
277
|
+
if (ret[2]) {
|
|
278
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
279
|
+
}
|
|
280
|
+
return takeFromExternrefTable0(ret[0]);
|
|
281
|
+
}
|
|
282
|
+
hasOurChanges(state) {
|
|
283
|
+
_assertClass(state, SyncState);
|
|
284
|
+
const ret = wasm.automerge_hasOurChanges(this.__wbg_ptr, state.__wbg_ptr);
|
|
285
|
+
return ret !== 0;
|
|
286
|
+
}
|
|
287
|
+
increment(obj, prop, value) {
|
|
288
|
+
const ret = wasm.automerge_increment(this.__wbg_ptr, obj, prop, value);
|
|
289
|
+
if (ret[1]) {
|
|
290
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
insert(obj, index, value, datatype) {
|
|
294
|
+
const ret = wasm.automerge_insert(this.__wbg_ptr, obj, index, value, datatype);
|
|
295
|
+
if (ret[1]) {
|
|
296
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
insertObject(obj, index, value) {
|
|
300
|
+
let deferred2_0;
|
|
301
|
+
let deferred2_1;
|
|
302
|
+
try {
|
|
303
|
+
const ret = wasm.automerge_insertObject(this.__wbg_ptr, obj, index, value);
|
|
304
|
+
var ptr1 = ret[0];
|
|
305
|
+
var len1 = ret[1];
|
|
306
|
+
if (ret[3]) {
|
|
307
|
+
ptr1 = 0;
|
|
308
|
+
len1 = 0;
|
|
309
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
310
|
+
}
|
|
311
|
+
deferred2_0 = ptr1;
|
|
312
|
+
deferred2_1 = len1;
|
|
313
|
+
return getStringFromWasm0(ptr1, len1);
|
|
314
|
+
} finally {
|
|
315
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
integrate() {
|
|
319
|
+
wasm.automerge_integrate(this.__wbg_ptr);
|
|
320
|
+
}
|
|
321
|
+
isolate(heads) {
|
|
322
|
+
const ret = wasm.automerge_isolate(this.__wbg_ptr, heads);
|
|
323
|
+
if (ret[1]) {
|
|
324
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
joinBlock(obj, index) {
|
|
328
|
+
const ret = wasm.automerge_joinBlock(this.__wbg_ptr, obj, index);
|
|
329
|
+
if (ret[1]) {
|
|
330
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
keys(obj, heads) {
|
|
334
|
+
const ret = wasm.automerge_keys(this.__wbg_ptr, obj, heads);
|
|
335
|
+
if (ret[2]) {
|
|
336
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
337
|
+
}
|
|
338
|
+
return takeFromExternrefTable0(ret[0]);
|
|
339
|
+
}
|
|
340
|
+
length(obj, heads) {
|
|
341
|
+
const ret = wasm.automerge_length(this.__wbg_ptr, obj, heads);
|
|
342
|
+
if (ret[2]) {
|
|
343
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
344
|
+
}
|
|
345
|
+
return ret[0];
|
|
346
|
+
}
|
|
347
|
+
loadIncremental(data) {
|
|
348
|
+
const ret = wasm.automerge_loadIncremental(this.__wbg_ptr, data);
|
|
349
|
+
if (ret[2]) {
|
|
350
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
351
|
+
}
|
|
352
|
+
return ret[0];
|
|
353
|
+
}
|
|
354
|
+
mark(obj, range, name, value, datatype) {
|
|
355
|
+
const ret = wasm.automerge_mark(this.__wbg_ptr, obj, range, name, value, datatype);
|
|
356
|
+
if (ret[1]) {
|
|
357
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
marks(obj, heads) {
|
|
361
|
+
const ret = wasm.automerge_marks(this.__wbg_ptr, obj, heads);
|
|
362
|
+
if (ret[2]) {
|
|
363
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
364
|
+
}
|
|
365
|
+
return takeFromExternrefTable0(ret[0]);
|
|
366
|
+
}
|
|
367
|
+
marksAt(obj, index, heads) {
|
|
368
|
+
const ret = wasm.automerge_marksAt(this.__wbg_ptr, obj, index, heads);
|
|
369
|
+
if (ret[2]) {
|
|
370
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
371
|
+
}
|
|
372
|
+
return takeFromExternrefTable0(ret[0]);
|
|
373
|
+
}
|
|
374
|
+
materialize(obj, heads, meta) {
|
|
375
|
+
const ret = wasm.automerge_materialize(this.__wbg_ptr, obj, heads, meta);
|
|
376
|
+
if (ret[2]) {
|
|
377
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
378
|
+
}
|
|
379
|
+
return takeFromExternrefTable0(ret[0]);
|
|
380
|
+
}
|
|
381
|
+
merge(other) {
|
|
382
|
+
_assertClass(other, Automerge);
|
|
383
|
+
const ret = wasm.automerge_merge(this.__wbg_ptr, other.__wbg_ptr);
|
|
384
|
+
if (ret[2]) {
|
|
385
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
386
|
+
}
|
|
387
|
+
return takeFromExternrefTable0(ret[0]);
|
|
388
|
+
}
|
|
389
|
+
static new(actor) {
|
|
390
|
+
var ptr0 = isLikeNone(actor) ? 0 : passStringToWasm0(actor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
391
|
+
var len0 = WASM_VECTOR_LEN;
|
|
392
|
+
const ret = wasm.automerge_new(ptr0, len0);
|
|
393
|
+
if (ret[2]) {
|
|
394
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
395
|
+
}
|
|
396
|
+
return Automerge.__wrap(ret[0]);
|
|
397
|
+
}
|
|
398
|
+
objInfo(obj, heads) {
|
|
399
|
+
const ret = wasm.automerge_objInfo(this.__wbg_ptr, obj, heads);
|
|
400
|
+
if (ret[2]) {
|
|
401
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
402
|
+
}
|
|
403
|
+
return takeFromExternrefTable0(ret[0]);
|
|
404
|
+
}
|
|
405
|
+
pendingOps() {
|
|
406
|
+
const ret = wasm.automerge_pendingOps(this.__wbg_ptr);
|
|
407
|
+
return ret;
|
|
408
|
+
}
|
|
409
|
+
push(obj, value, datatype) {
|
|
410
|
+
const ret = wasm.automerge_push(this.__wbg_ptr, obj, value, datatype);
|
|
411
|
+
if (ret[1]) {
|
|
412
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
pushObject(obj, value) {
|
|
416
|
+
let deferred2_0;
|
|
417
|
+
let deferred2_1;
|
|
418
|
+
try {
|
|
419
|
+
const ret = wasm.automerge_pushObject(this.__wbg_ptr, obj, value);
|
|
420
|
+
var ptr1 = ret[0];
|
|
421
|
+
var len1 = ret[1];
|
|
422
|
+
if (ret[3]) {
|
|
423
|
+
ptr1 = 0;
|
|
424
|
+
len1 = 0;
|
|
425
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
426
|
+
}
|
|
427
|
+
deferred2_0 = ptr1;
|
|
428
|
+
deferred2_1 = len1;
|
|
429
|
+
return getStringFromWasm0(ptr1, len1);
|
|
430
|
+
} finally {
|
|
431
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
put(obj, prop, value, datatype) {
|
|
435
|
+
const ret = wasm.automerge_put(this.__wbg_ptr, obj, prop, value, datatype);
|
|
436
|
+
if (ret[1]) {
|
|
437
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
putObject(obj, prop, value) {
|
|
441
|
+
const ret = wasm.automerge_putObject(this.__wbg_ptr, obj, prop, value);
|
|
442
|
+
if (ret[2]) {
|
|
443
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
444
|
+
}
|
|
445
|
+
return takeFromExternrefTable0(ret[0]);
|
|
446
|
+
}
|
|
447
|
+
receiveSyncMessage(state, message) {
|
|
448
|
+
_assertClass(state, SyncState);
|
|
449
|
+
const ret = wasm.automerge_receiveSyncMessage(this.__wbg_ptr, state.__wbg_ptr, message);
|
|
450
|
+
if (ret[1]) {
|
|
451
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
registerDatatype(datatype, construct, deconstruct) {
|
|
455
|
+
const ret = wasm.automerge_registerDatatype(this.__wbg_ptr, datatype, construct, deconstruct);
|
|
456
|
+
if (ret[1]) {
|
|
457
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
resetDiffCursor() {
|
|
461
|
+
wasm.automerge_resetDiffCursor(this.__wbg_ptr);
|
|
462
|
+
}
|
|
463
|
+
rollback() {
|
|
464
|
+
const ret = wasm.automerge_rollback(this.__wbg_ptr);
|
|
465
|
+
return ret;
|
|
466
|
+
}
|
|
467
|
+
save() {
|
|
468
|
+
const ret = wasm.automerge_save(this.__wbg_ptr);
|
|
469
|
+
return ret;
|
|
470
|
+
}
|
|
471
|
+
saveAndVerify() {
|
|
472
|
+
const ret = wasm.automerge_saveAndVerify(this.__wbg_ptr);
|
|
473
|
+
if (ret[2]) {
|
|
474
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
475
|
+
}
|
|
476
|
+
return takeFromExternrefTable0(ret[0]);
|
|
477
|
+
}
|
|
478
|
+
saveBundle(hashes) {
|
|
479
|
+
const ret = wasm.automerge_saveBundle(this.__wbg_ptr, hashes);
|
|
480
|
+
if (ret[2]) {
|
|
481
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
482
|
+
}
|
|
483
|
+
return takeFromExternrefTable0(ret[0]);
|
|
484
|
+
}
|
|
485
|
+
saveIncremental() {
|
|
486
|
+
const ret = wasm.automerge_saveIncremental(this.__wbg_ptr);
|
|
487
|
+
return ret;
|
|
488
|
+
}
|
|
489
|
+
saveNoCompress() {
|
|
490
|
+
const ret = wasm.automerge_saveNoCompress(this.__wbg_ptr);
|
|
491
|
+
return ret;
|
|
492
|
+
}
|
|
493
|
+
saveSince(heads) {
|
|
494
|
+
const ret = wasm.automerge_saveSince(this.__wbg_ptr, heads);
|
|
495
|
+
if (ret[2]) {
|
|
496
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
497
|
+
}
|
|
498
|
+
return takeFromExternrefTable0(ret[0]);
|
|
499
|
+
}
|
|
500
|
+
spans(obj, heads) {
|
|
501
|
+
const ret = wasm.automerge_spans(this.__wbg_ptr, obj, heads);
|
|
502
|
+
if (ret[2]) {
|
|
503
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
504
|
+
}
|
|
505
|
+
return takeFromExternrefTable0(ret[0]);
|
|
506
|
+
}
|
|
507
|
+
splice(obj, start, delete_count, text) {
|
|
508
|
+
const ret = wasm.automerge_splice(this.__wbg_ptr, obj, start, delete_count, text);
|
|
509
|
+
if (ret[1]) {
|
|
510
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
splitBlock(obj, index, block) {
|
|
514
|
+
const ret = wasm.automerge_splitBlock(this.__wbg_ptr, obj, index, block);
|
|
515
|
+
if (ret[1]) {
|
|
516
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
stats() {
|
|
520
|
+
const ret = wasm.automerge_stats(this.__wbg_ptr);
|
|
521
|
+
return ret;
|
|
522
|
+
}
|
|
523
|
+
text(obj, heads) {
|
|
524
|
+
let deferred2_0;
|
|
525
|
+
let deferred2_1;
|
|
526
|
+
try {
|
|
527
|
+
const ret = wasm.automerge_text(this.__wbg_ptr, obj, heads);
|
|
528
|
+
var ptr1 = ret[0];
|
|
529
|
+
var len1 = ret[1];
|
|
530
|
+
if (ret[3]) {
|
|
531
|
+
ptr1 = 0;
|
|
532
|
+
len1 = 0;
|
|
533
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
534
|
+
}
|
|
535
|
+
deferred2_0 = ptr1;
|
|
536
|
+
deferred2_1 = len1;
|
|
537
|
+
return getStringFromWasm0(ptr1, len1);
|
|
538
|
+
} finally {
|
|
539
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
toJS(meta) {
|
|
543
|
+
const ret = wasm.automerge_toJS(this.__wbg_ptr, meta);
|
|
544
|
+
if (ret[2]) {
|
|
545
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
546
|
+
}
|
|
547
|
+
return takeFromExternrefTable0(ret[0]);
|
|
548
|
+
}
|
|
549
|
+
topoHistoryTraversal() {
|
|
550
|
+
const ret = wasm.automerge_topoHistoryTraversal(this.__wbg_ptr);
|
|
551
|
+
return ret;
|
|
552
|
+
}
|
|
553
|
+
unmark(obj, range, name) {
|
|
554
|
+
const ret = wasm.automerge_unmark(this.__wbg_ptr, obj, range, name);
|
|
555
|
+
if (ret[1]) {
|
|
556
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
updateBlock(obj, index, block) {
|
|
560
|
+
const ret = wasm.automerge_updateBlock(this.__wbg_ptr, obj, index, block);
|
|
561
|
+
if (ret[1]) {
|
|
562
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
updateDiffCursor() {
|
|
566
|
+
wasm.automerge_updateDiffCursor(this.__wbg_ptr);
|
|
567
|
+
}
|
|
568
|
+
updateSpans(obj, args, config) {
|
|
569
|
+
const ret = wasm.automerge_updateSpans(this.__wbg_ptr, obj, args, config);
|
|
570
|
+
if (ret[1]) {
|
|
571
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
updateText(obj, new_text) {
|
|
575
|
+
const ret = wasm.automerge_updateText(this.__wbg_ptr, obj, new_text);
|
|
576
|
+
if (ret[1]) {
|
|
577
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
class SyncState {
|
|
583
|
+
static __wrap(ptr) {
|
|
584
|
+
ptr = ptr >>> 0;
|
|
585
|
+
const obj = Object.create(SyncState.prototype);
|
|
586
|
+
obj.__wbg_ptr = ptr;
|
|
587
|
+
SyncStateFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
588
|
+
return obj;
|
|
589
|
+
}
|
|
590
|
+
__destroy_into_raw() {
|
|
591
|
+
const ptr = this.__wbg_ptr;
|
|
592
|
+
this.__wbg_ptr = 0;
|
|
593
|
+
SyncStateFinalization.unregister(this);
|
|
594
|
+
return ptr;
|
|
595
|
+
}
|
|
596
|
+
free() {
|
|
597
|
+
const ptr = this.__destroy_into_raw();
|
|
598
|
+
wasm.__wbg_syncstate_free(ptr, 0);
|
|
599
|
+
}
|
|
600
|
+
clone() {
|
|
601
|
+
const ret = wasm.syncstate_clone(this.__wbg_ptr);
|
|
602
|
+
return SyncState.__wrap(ret);
|
|
603
|
+
}
|
|
604
|
+
get lastSentHeads() {
|
|
605
|
+
const ret = wasm.syncstate_lastSentHeads(this.__wbg_ptr);
|
|
606
|
+
return ret;
|
|
607
|
+
}
|
|
608
|
+
set lastSentHeads(heads) {
|
|
609
|
+
const ret = wasm.syncstate_set_lastSentHeads(this.__wbg_ptr, heads);
|
|
610
|
+
if (ret[1]) {
|
|
611
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
set sentHashes(hashes) {
|
|
615
|
+
const ret = wasm.syncstate_set_sentHashes(this.__wbg_ptr, hashes);
|
|
616
|
+
if (ret[1]) {
|
|
617
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
get sharedHeads() {
|
|
621
|
+
const ret = wasm.syncstate_sharedHeads(this.__wbg_ptr);
|
|
622
|
+
return ret;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
function create(options) {
|
|
626
|
+
const ret = wasm.create(options);
|
|
627
|
+
if (ret[2]) {
|
|
628
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
629
|
+
}
|
|
630
|
+
return Automerge.__wrap(ret[0]);
|
|
631
|
+
}
|
|
632
|
+
function decodeChange(change) {
|
|
633
|
+
const ret = wasm.decodeChange(change);
|
|
634
|
+
if (ret[2]) {
|
|
635
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
636
|
+
}
|
|
637
|
+
return takeFromExternrefTable0(ret[0]);
|
|
638
|
+
}
|
|
639
|
+
function decodeSyncMessage(msg) {
|
|
640
|
+
const ret = wasm.decodeSyncMessage(msg);
|
|
641
|
+
if (ret[2]) {
|
|
642
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
643
|
+
}
|
|
644
|
+
return takeFromExternrefTable0(ret[0]);
|
|
645
|
+
}
|
|
646
|
+
function decodeSyncState(data) {
|
|
647
|
+
const ret = wasm.decodeSyncState(data);
|
|
648
|
+
if (ret[2]) {
|
|
649
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
650
|
+
}
|
|
651
|
+
return SyncState.__wrap(ret[0]);
|
|
652
|
+
}
|
|
653
|
+
function encodeChange(change) {
|
|
654
|
+
const ret = wasm.encodeChange(change);
|
|
655
|
+
if (ret[2]) {
|
|
656
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
657
|
+
}
|
|
658
|
+
return takeFromExternrefTable0(ret[0]);
|
|
659
|
+
}
|
|
660
|
+
function encodeSyncMessage(message) {
|
|
661
|
+
const ret = wasm.encodeSyncMessage(message);
|
|
662
|
+
if (ret[2]) {
|
|
663
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
664
|
+
}
|
|
665
|
+
return takeFromExternrefTable0(ret[0]);
|
|
666
|
+
}
|
|
667
|
+
function encodeSyncState(state) {
|
|
668
|
+
_assertClass(state, SyncState);
|
|
669
|
+
const ret = wasm.encodeSyncState(state.__wbg_ptr);
|
|
670
|
+
return ret;
|
|
671
|
+
}
|
|
672
|
+
function exportSyncState(state) {
|
|
673
|
+
_assertClass(state, SyncState);
|
|
674
|
+
const ret = wasm.exportSyncState(state.__wbg_ptr);
|
|
675
|
+
return ret;
|
|
676
|
+
}
|
|
677
|
+
function importSyncState(state) {
|
|
678
|
+
const ret = wasm.importSyncState(state);
|
|
679
|
+
if (ret[2]) {
|
|
680
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
681
|
+
}
|
|
682
|
+
return SyncState.__wrap(ret[0]);
|
|
683
|
+
}
|
|
684
|
+
function initSyncState() {
|
|
685
|
+
const ret = wasm.initSyncState();
|
|
686
|
+
return SyncState.__wrap(ret);
|
|
687
|
+
}
|
|
688
|
+
function load(data, options) {
|
|
689
|
+
const ret = wasm.load(data, options);
|
|
690
|
+
if (ret[2]) {
|
|
691
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
692
|
+
}
|
|
693
|
+
return Automerge.__wrap(ret[0]);
|
|
694
|
+
}
|
|
695
|
+
function readBundle(bundle) {
|
|
696
|
+
const ret = wasm.readBundle(bundle);
|
|
697
|
+
if (ret[2]) {
|
|
698
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
699
|
+
}
|
|
700
|
+
return takeFromExternrefTable0(ret[0]);
|
|
701
|
+
}
|
|
702
|
+
function wasmReleaseInfo() {
|
|
703
|
+
const ret = wasm.wasmReleaseInfo();
|
|
704
|
+
return ret;
|
|
705
|
+
}
|
|
706
|
+
function __wbg_get_imports() {
|
|
707
|
+
const import0 = {
|
|
708
|
+
__proto__: null,
|
|
709
|
+
__wbg_BigInt_b7bbccdff258c9f2: function(arg0) {
|
|
710
|
+
const ret = BigInt(arg0);
|
|
711
|
+
return ret;
|
|
712
|
+
},
|
|
713
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
714
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
715
|
+
return ret;
|
|
716
|
+
},
|
|
717
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
718
|
+
const ret = String(arg1);
|
|
719
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
720
|
+
const len1 = WASM_VECTOR_LEN;
|
|
721
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
722
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
723
|
+
},
|
|
724
|
+
__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
|
|
725
|
+
const v = arg0;
|
|
726
|
+
const ret = typeof v === "boolean" ? v : undefined;
|
|
727
|
+
return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
|
|
728
|
+
},
|
|
729
|
+
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
730
|
+
const ret = debugString(arg1);
|
|
731
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
732
|
+
const len1 = WASM_VECTOR_LEN;
|
|
733
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
734
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
735
|
+
},
|
|
736
|
+
__wbg___wbindgen_gt_d7bb3629eac381f5: function(arg0, arg1) {
|
|
737
|
+
const ret = arg0 > arg1;
|
|
738
|
+
return ret;
|
|
739
|
+
},
|
|
740
|
+
__wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
|
|
741
|
+
const ret = typeof arg0 === "bigint";
|
|
742
|
+
return ret;
|
|
743
|
+
},
|
|
744
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
745
|
+
const ret = typeof arg0 === "function";
|
|
746
|
+
return ret;
|
|
747
|
+
},
|
|
748
|
+
__wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
|
|
749
|
+
const ret = arg0 === null;
|
|
750
|
+
return ret;
|
|
751
|
+
},
|
|
752
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
753
|
+
const val = arg0;
|
|
754
|
+
const ret = typeof val === "object" && val !== null;
|
|
755
|
+
return ret;
|
|
756
|
+
},
|
|
757
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
758
|
+
const ret = typeof arg0 === "string";
|
|
759
|
+
return ret;
|
|
760
|
+
},
|
|
761
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
762
|
+
const ret = arg0 === undefined;
|
|
763
|
+
return ret;
|
|
764
|
+
},
|
|
765
|
+
__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
|
|
766
|
+
const ret = arg0 == arg1;
|
|
767
|
+
return ret;
|
|
768
|
+
},
|
|
769
|
+
__wbg___wbindgen_lt_bb59cc3d23526e0d: function(arg0, arg1) {
|
|
770
|
+
const ret = arg0 < arg1;
|
|
771
|
+
return ret;
|
|
772
|
+
},
|
|
773
|
+
__wbg___wbindgen_neg_6b4d356dff49dcc6: function(arg0) {
|
|
774
|
+
const ret = -arg0;
|
|
775
|
+
return ret;
|
|
776
|
+
},
|
|
777
|
+
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
778
|
+
const obj = arg1;
|
|
779
|
+
const ret = typeof obj === "number" ? obj : undefined;
|
|
780
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
781
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
782
|
+
},
|
|
783
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
784
|
+
const obj = arg1;
|
|
785
|
+
const ret = typeof obj === "string" ? obj : undefined;
|
|
786
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
787
|
+
var len1 = WASM_VECTOR_LEN;
|
|
788
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
789
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
790
|
+
},
|
|
791
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
792
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
793
|
+
},
|
|
794
|
+
__wbg_apply_2e22c45cb4f12415: function() {
|
|
795
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
796
|
+
const ret = Reflect.apply(arg0, arg1, arg2);
|
|
797
|
+
return ret;
|
|
798
|
+
}, arguments);
|
|
799
|
+
},
|
|
800
|
+
__wbg_assign_6170c0d04d5c26f4: function(arg0, arg1) {
|
|
801
|
+
const ret = Object.assign(arg0, arg1);
|
|
802
|
+
return ret;
|
|
803
|
+
},
|
|
804
|
+
__wbg_call_389efe28435a9388: function() {
|
|
805
|
+
return handleError(function(arg0, arg1) {
|
|
806
|
+
const ret = arg0.call(arg1);
|
|
807
|
+
return ret;
|
|
808
|
+
}, arguments);
|
|
809
|
+
},
|
|
810
|
+
__wbg_call_4708e0c13bdc8e95: function() {
|
|
811
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
812
|
+
const ret = arg0.call(arg1, arg2);
|
|
813
|
+
return ret;
|
|
814
|
+
}, arguments);
|
|
815
|
+
},
|
|
816
|
+
__wbg_concat_f6e5ebc81f4917f1: function(arg0, arg1) {
|
|
817
|
+
const ret = arg0.concat(arg1);
|
|
818
|
+
return ret;
|
|
819
|
+
},
|
|
820
|
+
__wbg_defineProperty_fc8692a66be8fe2d: function(arg0, arg1, arg2) {
|
|
821
|
+
const ret = Object.defineProperty(arg0, arg1, arg2);
|
|
822
|
+
return ret;
|
|
823
|
+
},
|
|
824
|
+
__wbg_deleteProperty_8c8a05da881fea59: function() {
|
|
825
|
+
return handleError(function(arg0, arg1) {
|
|
826
|
+
const ret = Reflect.deleteProperty(arg0, arg1);
|
|
827
|
+
return ret;
|
|
828
|
+
}, arguments);
|
|
829
|
+
},
|
|
830
|
+
__wbg_done_57b39ecd9addfe81: function(arg0) {
|
|
831
|
+
const ret = arg0.done;
|
|
832
|
+
return ret;
|
|
833
|
+
},
|
|
834
|
+
__wbg_entries_58c7934c745daac7: function(arg0) {
|
|
835
|
+
const ret = Object.entries(arg0);
|
|
836
|
+
return ret;
|
|
837
|
+
},
|
|
838
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
839
|
+
let deferred0_0;
|
|
840
|
+
let deferred0_1;
|
|
841
|
+
try {
|
|
842
|
+
deferred0_0 = arg0;
|
|
843
|
+
deferred0_1 = arg1;
|
|
844
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
845
|
+
} finally {
|
|
846
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
847
|
+
}
|
|
848
|
+
},
|
|
849
|
+
__wbg_for_c3adefd268cb6f1c: function(arg0, arg1) {
|
|
850
|
+
const ret = Symbol.for(getStringFromWasm0(arg0, arg1));
|
|
851
|
+
return ret;
|
|
852
|
+
},
|
|
853
|
+
__wbg_freeze_661d9047fd889cd0: function(arg0) {
|
|
854
|
+
const ret = Object.freeze(arg0);
|
|
855
|
+
return ret;
|
|
856
|
+
},
|
|
857
|
+
__wbg_from_bddd64e7d5ff6941: function(arg0) {
|
|
858
|
+
const ret = Array.from(arg0);
|
|
859
|
+
return ret;
|
|
860
|
+
},
|
|
861
|
+
__wbg_getRandomValues_1c61fac11405ffdc: function() {
|
|
862
|
+
return handleError(function(arg0, arg1) {
|
|
863
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
864
|
+
}, arguments);
|
|
865
|
+
},
|
|
866
|
+
__wbg_getTime_1e3cd1391c5c3995: function(arg0) {
|
|
867
|
+
const ret = arg0.getTime();
|
|
868
|
+
return ret;
|
|
869
|
+
},
|
|
870
|
+
__wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
|
|
871
|
+
const ret = arg0[arg1 >>> 0];
|
|
872
|
+
return ret;
|
|
873
|
+
},
|
|
874
|
+
__wbg_get_b3ed3ad4be2bc8ac: function() {
|
|
875
|
+
return handleError(function(arg0, arg1) {
|
|
876
|
+
const ret = Reflect.get(arg0, arg1);
|
|
877
|
+
return ret;
|
|
878
|
+
}, arguments);
|
|
879
|
+
},
|
|
880
|
+
__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
|
|
881
|
+
let result;
|
|
882
|
+
try {
|
|
883
|
+
result = arg0 instanceof ArrayBuffer;
|
|
884
|
+
} catch (_) {
|
|
885
|
+
result = false;
|
|
886
|
+
}
|
|
887
|
+
const ret = result;
|
|
888
|
+
return ret;
|
|
889
|
+
},
|
|
890
|
+
__wbg_instanceof_Date_1b9f15b87f10aa4c: function(arg0) {
|
|
891
|
+
let result;
|
|
892
|
+
try {
|
|
893
|
+
result = arg0 instanceof Date;
|
|
894
|
+
} catch (_) {
|
|
895
|
+
result = false;
|
|
896
|
+
}
|
|
897
|
+
const ret = result;
|
|
898
|
+
return ret;
|
|
899
|
+
},
|
|
900
|
+
__wbg_instanceof_Object_1c6af87502b733ed: function(arg0) {
|
|
901
|
+
let result;
|
|
902
|
+
try {
|
|
903
|
+
result = arg0 instanceof Object;
|
|
904
|
+
} catch (_) {
|
|
905
|
+
result = false;
|
|
906
|
+
}
|
|
907
|
+
const ret = result;
|
|
908
|
+
return ret;
|
|
909
|
+
},
|
|
910
|
+
__wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
|
|
911
|
+
let result;
|
|
912
|
+
try {
|
|
913
|
+
result = arg0 instanceof Uint8Array;
|
|
914
|
+
} catch (_) {
|
|
915
|
+
result = false;
|
|
916
|
+
}
|
|
917
|
+
const ret = result;
|
|
918
|
+
return ret;
|
|
919
|
+
},
|
|
920
|
+
__wbg_isArray_a2cef7634fcb7c0d: function(arg0) {
|
|
921
|
+
const ret = Array.isArray(arg0);
|
|
922
|
+
return ret;
|
|
923
|
+
},
|
|
924
|
+
__wbg_isArray_d314bb98fcf08331: function(arg0) {
|
|
925
|
+
const ret = Array.isArray(arg0);
|
|
926
|
+
return ret;
|
|
927
|
+
},
|
|
928
|
+
__wbg_iterator_6ff6560ca1568e55: function() {
|
|
929
|
+
const ret = Symbol.iterator;
|
|
930
|
+
return ret;
|
|
931
|
+
},
|
|
932
|
+
__wbg_keys_b50a709a76add04e: function(arg0) {
|
|
933
|
+
const ret = Object.keys(arg0);
|
|
934
|
+
return ret;
|
|
935
|
+
},
|
|
936
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
937
|
+
const ret = arg0.length;
|
|
938
|
+
return ret;
|
|
939
|
+
},
|
|
940
|
+
__wbg_length_35a7bace40f36eac: function(arg0) {
|
|
941
|
+
const ret = arg0.length;
|
|
942
|
+
return ret;
|
|
943
|
+
},
|
|
944
|
+
__wbg_length_68dc7c5cf1b6d349: function(arg0) {
|
|
945
|
+
const ret = arg0.length;
|
|
946
|
+
return ret;
|
|
947
|
+
},
|
|
948
|
+
__wbg_log_6b5ca2e6124b2808: function(arg0) {
|
|
949
|
+
console.log(arg0);
|
|
950
|
+
},
|
|
951
|
+
__wbg_log_b948c93e3e66d64f: function(arg0, arg1) {
|
|
952
|
+
console.log(arg0, arg1);
|
|
953
|
+
},
|
|
954
|
+
__wbg_new_245cd5c49157e602: function(arg0) {
|
|
955
|
+
const ret = new Date(arg0);
|
|
956
|
+
return ret;
|
|
957
|
+
},
|
|
958
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
959
|
+
const ret = new Object;
|
|
960
|
+
return ret;
|
|
961
|
+
},
|
|
962
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
963
|
+
const ret = new Array;
|
|
964
|
+
return ret;
|
|
965
|
+
},
|
|
966
|
+
__wbg_new_72b49615380db768: function(arg0, arg1) {
|
|
967
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
968
|
+
return ret;
|
|
969
|
+
},
|
|
970
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
971
|
+
const ret = new Error;
|
|
972
|
+
return ret;
|
|
973
|
+
},
|
|
974
|
+
__wbg_new_911dabf69fa7eb20: function(arg0, arg1) {
|
|
975
|
+
const ret = new RangeError(getStringFromWasm0(arg0, arg1));
|
|
976
|
+
return ret;
|
|
977
|
+
},
|
|
978
|
+
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
979
|
+
const ret = new Uint8Array(arg0);
|
|
980
|
+
return ret;
|
|
981
|
+
},
|
|
982
|
+
__wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
|
|
983
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
984
|
+
return ret;
|
|
985
|
+
},
|
|
986
|
+
__wbg_next_3482f54c49e8af19: function() {
|
|
987
|
+
return handleError(function(arg0) {
|
|
988
|
+
const ret = arg0.next();
|
|
989
|
+
return ret;
|
|
990
|
+
}, arguments);
|
|
991
|
+
},
|
|
992
|
+
__wbg_next_418f80d8f5303233: function(arg0) {
|
|
993
|
+
const ret = arg0.next;
|
|
994
|
+
return ret;
|
|
995
|
+
},
|
|
996
|
+
__wbg_ownKeys_c7100fb5fa376c6f: function() {
|
|
997
|
+
return handleError(function(arg0) {
|
|
998
|
+
const ret = Reflect.ownKeys(arg0);
|
|
999
|
+
return ret;
|
|
1000
|
+
}, arguments);
|
|
1001
|
+
},
|
|
1002
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
1003
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1004
|
+
},
|
|
1005
|
+
__wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
|
|
1006
|
+
const ret = arg0.push(arg1);
|
|
1007
|
+
return ret;
|
|
1008
|
+
},
|
|
1009
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
1010
|
+
arg0[arg1] = arg2;
|
|
1011
|
+
},
|
|
1012
|
+
__wbg_set_6cb8631f80447a67: function() {
|
|
1013
|
+
return handleError(function(arg0, arg1, arg2) {
|
|
1014
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
1015
|
+
return ret;
|
|
1016
|
+
}, arguments);
|
|
1017
|
+
},
|
|
1018
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
1019
|
+
arg0[arg1 >>> 0] = arg2;
|
|
1020
|
+
},
|
|
1021
|
+
__wbg_slice_b0fa09b1e0041d42: function(arg0, arg1, arg2) {
|
|
1022
|
+
const ret = arg0.slice(arg1 >>> 0, arg2 >>> 0);
|
|
1023
|
+
return ret;
|
|
1024
|
+
},
|
|
1025
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
1026
|
+
const ret = arg1.stack;
|
|
1027
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1028
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1029
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1030
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1031
|
+
},
|
|
1032
|
+
__wbg_stringify_e4a940b133e6b7d8: function(arg0, arg1) {
|
|
1033
|
+
const ret = JSON.stringify(arg1);
|
|
1034
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1035
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1036
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1037
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1038
|
+
},
|
|
1039
|
+
__wbg_toString_3cadee6e7c22b39e: function() {
|
|
1040
|
+
return handleError(function(arg0, arg1) {
|
|
1041
|
+
const ret = arg0.toString(arg1);
|
|
1042
|
+
return ret;
|
|
1043
|
+
}, arguments);
|
|
1044
|
+
},
|
|
1045
|
+
__wbg_toString_56d946daff83867b: function(arg0, arg1, arg2) {
|
|
1046
|
+
const ret = arg1.toString(arg2);
|
|
1047
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1048
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1049
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1050
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1051
|
+
},
|
|
1052
|
+
__wbg_toString_b388ecd2d3c517c3: function(arg0) {
|
|
1053
|
+
const ret = arg0.toString();
|
|
1054
|
+
return ret;
|
|
1055
|
+
},
|
|
1056
|
+
__wbg_unshift_a4a28a3b4a2e621b: function(arg0, arg1) {
|
|
1057
|
+
const ret = arg0.unshift(arg1);
|
|
1058
|
+
return ret;
|
|
1059
|
+
},
|
|
1060
|
+
__wbg_value_0546255b415e96c1: function(arg0) {
|
|
1061
|
+
const ret = arg0.value;
|
|
1062
|
+
return ret;
|
|
1063
|
+
},
|
|
1064
|
+
__wbg_values_5da93bc719d272cf: function(arg0) {
|
|
1065
|
+
const ret = Object.values(arg0);
|
|
1066
|
+
return ret;
|
|
1067
|
+
},
|
|
1068
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
1069
|
+
const ret = arg0;
|
|
1070
|
+
return ret;
|
|
1071
|
+
},
|
|
1072
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
1073
|
+
const ret = arg0;
|
|
1074
|
+
return ret;
|
|
1075
|
+
},
|
|
1076
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1077
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1078
|
+
return ret;
|
|
1079
|
+
},
|
|
1080
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
1081
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
1082
|
+
return ret;
|
|
1083
|
+
},
|
|
1084
|
+
__wbindgen_init_externref_table: function() {
|
|
1085
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1086
|
+
const offset = table.grow(4);
|
|
1087
|
+
table.set(0, undefined);
|
|
1088
|
+
table.set(offset + 0, undefined);
|
|
1089
|
+
table.set(offset + 1, null);
|
|
1090
|
+
table.set(offset + 2, true);
|
|
1091
|
+
table.set(offset + 3, false);
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
return {
|
|
1095
|
+
__proto__: null,
|
|
1096
|
+
"./automerge_wasm_bg.js": import0
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
function addToExternrefTable0(obj) {
|
|
1100
|
+
const idx = wasm.__externref_table_alloc();
|
|
1101
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1102
|
+
return idx;
|
|
1103
|
+
}
|
|
1104
|
+
function _assertClass(instance, klass) {
|
|
1105
|
+
if (!(instance instanceof klass)) {
|
|
1106
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
function debugString(val) {
|
|
1110
|
+
const type = typeof val;
|
|
1111
|
+
if (type == "number" || type == "boolean" || val == null) {
|
|
1112
|
+
return `${val}`;
|
|
1113
|
+
}
|
|
1114
|
+
if (type == "string") {
|
|
1115
|
+
return `"${val}"`;
|
|
1116
|
+
}
|
|
1117
|
+
if (type == "symbol") {
|
|
1118
|
+
const description = val.description;
|
|
1119
|
+
if (description == null) {
|
|
1120
|
+
return "Symbol";
|
|
1121
|
+
} else {
|
|
1122
|
+
return `Symbol(${description})`;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
if (type == "function") {
|
|
1126
|
+
const name = val.name;
|
|
1127
|
+
if (typeof name == "string" && name.length > 0) {
|
|
1128
|
+
return `Function(${name})`;
|
|
1129
|
+
} else {
|
|
1130
|
+
return "Function";
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
if (Array.isArray(val)) {
|
|
1134
|
+
const length = val.length;
|
|
1135
|
+
let debug = "[";
|
|
1136
|
+
if (length > 0) {
|
|
1137
|
+
debug += debugString(val[0]);
|
|
1138
|
+
}
|
|
1139
|
+
for (let i = 1;i < length; i++) {
|
|
1140
|
+
debug += ", " + debugString(val[i]);
|
|
1141
|
+
}
|
|
1142
|
+
debug += "]";
|
|
1143
|
+
return debug;
|
|
1144
|
+
}
|
|
1145
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
1146
|
+
let className;
|
|
1147
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
1148
|
+
className = builtInMatches[1];
|
|
1149
|
+
} else {
|
|
1150
|
+
return toString.call(val);
|
|
1151
|
+
}
|
|
1152
|
+
if (className == "Object") {
|
|
1153
|
+
try {
|
|
1154
|
+
return "Object(" + JSON.stringify(val) + ")";
|
|
1155
|
+
} catch (_) {
|
|
1156
|
+
return "Object";
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
if (val instanceof Error) {
|
|
1160
|
+
return `${val.name}: ${val.message}
|
|
1161
|
+
${val.stack}`;
|
|
1162
|
+
}
|
|
1163
|
+
return className;
|
|
1164
|
+
}
|
|
1165
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1166
|
+
ptr = ptr >>> 0;
|
|
1167
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1168
|
+
}
|
|
1169
|
+
function getDataViewMemory0() {
|
|
1170
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
|
|
1171
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1172
|
+
}
|
|
1173
|
+
return cachedDataViewMemory0;
|
|
1174
|
+
}
|
|
1175
|
+
function getStringFromWasm0(ptr, len) {
|
|
1176
|
+
ptr = ptr >>> 0;
|
|
1177
|
+
return decodeText(ptr, len);
|
|
1178
|
+
}
|
|
1179
|
+
function getUint8ArrayMemory0() {
|
|
1180
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1181
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1182
|
+
}
|
|
1183
|
+
return cachedUint8ArrayMemory0;
|
|
1184
|
+
}
|
|
1185
|
+
function handleError(f, args) {
|
|
1186
|
+
try {
|
|
1187
|
+
return f.apply(this, args);
|
|
1188
|
+
} catch (e) {
|
|
1189
|
+
const idx = addToExternrefTable0(e);
|
|
1190
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
function isLikeNone(x) {
|
|
1194
|
+
return x === undefined || x === null;
|
|
1195
|
+
}
|
|
1196
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1197
|
+
if (realloc === undefined) {
|
|
1198
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1199
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
1200
|
+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
1201
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1202
|
+
return ptr2;
|
|
1203
|
+
}
|
|
1204
|
+
let len = arg.length;
|
|
1205
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1206
|
+
const mem = getUint8ArrayMemory0();
|
|
1207
|
+
let offset = 0;
|
|
1208
|
+
for (;offset < len; offset++) {
|
|
1209
|
+
const code = arg.charCodeAt(offset);
|
|
1210
|
+
if (code > 127)
|
|
1211
|
+
break;
|
|
1212
|
+
mem[ptr + offset] = code;
|
|
1213
|
+
}
|
|
1214
|
+
if (offset !== len) {
|
|
1215
|
+
if (offset !== 0) {
|
|
1216
|
+
arg = arg.slice(offset);
|
|
1217
|
+
}
|
|
1218
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1219
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1220
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1221
|
+
offset += ret.written;
|
|
1222
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1223
|
+
}
|
|
1224
|
+
WASM_VECTOR_LEN = offset;
|
|
1225
|
+
return ptr;
|
|
1226
|
+
}
|
|
1227
|
+
function takeFromExternrefTable0(idx) {
|
|
1228
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1229
|
+
wasm.__externref_table_dealloc(idx);
|
|
1230
|
+
return value;
|
|
1231
|
+
}
|
|
1232
|
+
function decodeText(ptr, len) {
|
|
1233
|
+
numBytesDecoded += len;
|
|
1234
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1235
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
1236
|
+
cachedTextDecoder.decode();
|
|
1237
|
+
numBytesDecoded = len;
|
|
1238
|
+
}
|
|
1239
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1240
|
+
}
|
|
1241
|
+
function __wbg_finalize_init(instance, module) {
|
|
1242
|
+
wasm = instance.exports;
|
|
1243
|
+
wasmModule = module;
|
|
1244
|
+
cachedDataViewMemory0 = null;
|
|
1245
|
+
cachedUint8ArrayMemory0 = null;
|
|
1246
|
+
wasm.__wbindgen_start();
|
|
1247
|
+
return wasm;
|
|
1248
|
+
}
|
|
1249
|
+
async function __wbg_load(module, imports) {
|
|
1250
|
+
if (typeof Response === "function" && module instanceof Response) {
|
|
1251
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
1252
|
+
try {
|
|
1253
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1254
|
+
} catch (e) {
|
|
1255
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
1256
|
+
if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
|
|
1257
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1258
|
+
} else {
|
|
1259
|
+
throw e;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
const bytes = await module.arrayBuffer();
|
|
1264
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1265
|
+
} else {
|
|
1266
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1267
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1268
|
+
return { instance, module };
|
|
1269
|
+
} else {
|
|
1270
|
+
return instance;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
function expectedResponseType(type) {
|
|
1274
|
+
switch (type) {
|
|
1275
|
+
case "basic":
|
|
1276
|
+
case "cors":
|
|
1277
|
+
case "default":
|
|
1278
|
+
return true;
|
|
1279
|
+
}
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
function initSync(module) {
|
|
1284
|
+
if (wasm !== undefined)
|
|
1285
|
+
return wasm;
|
|
1286
|
+
if (module !== undefined) {
|
|
1287
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1288
|
+
({ module } = module);
|
|
1289
|
+
} else {
|
|
1290
|
+
console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
const imports = __wbg_get_imports();
|
|
1294
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1295
|
+
module = new WebAssembly.Module(module);
|
|
1296
|
+
}
|
|
1297
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1298
|
+
return __wbg_finalize_init(instance, module);
|
|
1299
|
+
}
|
|
1300
|
+
async function __wbg_init(module_or_path) {
|
|
1301
|
+
if (wasm !== undefined)
|
|
1302
|
+
return wasm;
|
|
1303
|
+
if (module_or_path !== undefined) {
|
|
1304
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1305
|
+
({ module_or_path } = module_or_path);
|
|
1306
|
+
} else {
|
|
1307
|
+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
if (module_or_path === undefined) {
|
|
1311
|
+
module_or_path = new URL("automerge_wasm_bg.wasm", import.meta.url);
|
|
1312
|
+
}
|
|
1313
|
+
const imports = __wbg_get_imports();
|
|
1314
|
+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
|
|
1315
|
+
module_or_path = fetch(module_or_path);
|
|
1316
|
+
}
|
|
1317
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1318
|
+
return __wbg_finalize_init(instance, module);
|
|
1319
|
+
}
|
|
1320
|
+
var AutomergeFinalization, SyncStateFinalization, cachedDataViewMemory0 = null, cachedUint8ArrayMemory0 = null, cachedTextDecoder, MAX_SAFARI_DECODE_BYTES = 2146435072, numBytesDecoded = 0, cachedTextEncoder, WASM_VECTOR_LEN = 0, wasmModule, wasm;
|
|
1321
|
+
var init_automerge_wasm = __esm(() => {
|
|
1322
|
+
if (Symbol.dispose)
|
|
1323
|
+
Automerge.prototype[Symbol.dispose] = Automerge.prototype.free;
|
|
1324
|
+
if (Symbol.dispose)
|
|
1325
|
+
SyncState.prototype[Symbol.dispose] = SyncState.prototype.free;
|
|
1326
|
+
AutomergeFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm.__wbg_automerge_free(ptr >>> 0, 1));
|
|
1327
|
+
SyncStateFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm.__wbg_syncstate_free(ptr >>> 0, 1));
|
|
1328
|
+
cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
1329
|
+
cachedTextDecoder.decode();
|
|
1330
|
+
cachedTextEncoder = new TextEncoder;
|
|
1331
|
+
if (!("encodeInto" in cachedTextEncoder)) {
|
|
1332
|
+
cachedTextEncoder.encodeInto = function(arg, view) {
|
|
1333
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1334
|
+
view.set(buf);
|
|
1335
|
+
return {
|
|
1336
|
+
read: arg.length,
|
|
1337
|
+
written: buf.length
|
|
1338
|
+
};
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
|
|
1343
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/low_level.js
|
|
1344
|
+
function UseApi(api) {
|
|
1345
|
+
for (const k in api) {
|
|
1346
|
+
ApiHandler[k] = api[k];
|
|
1347
|
+
}
|
|
1348
|
+
_initialized = true;
|
|
1349
|
+
for (const listener of _initializeListeners) {
|
|
1350
|
+
listener();
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
function initializeWasm(wasmBlob) {
|
|
1354
|
+
return __wbg_init({ module_or_path: wasmBlob }).then((_) => {
|
|
1355
|
+
UseApi(exports_automerge_wasm);
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
function initializeBase64Wasm(wasmBase64) {
|
|
1359
|
+
return initializeWasm(Uint8Array.from(atob(wasmBase64), (c) => c.charCodeAt(0)));
|
|
1360
|
+
}
|
|
1361
|
+
function wasmInitialized() {
|
|
1362
|
+
if (_initialized)
|
|
1363
|
+
return Promise.resolve();
|
|
1364
|
+
return new Promise((resolve) => {
|
|
1365
|
+
_initializeListeners.push(resolve);
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
function isWasmInitialized() {
|
|
1369
|
+
return _initialized;
|
|
1370
|
+
}
|
|
1371
|
+
var _initialized = false, _initializeListeners, ApiHandler;
|
|
1372
|
+
var init_low_level = __esm(() => {
|
|
1373
|
+
init_automerge_wasm();
|
|
1374
|
+
init_automerge_wasm();
|
|
1375
|
+
_initializeListeners = [];
|
|
1376
|
+
ApiHandler = {
|
|
1377
|
+
create(options) {
|
|
1378
|
+
throw new RangeError("Automerge.use() not called");
|
|
1379
|
+
},
|
|
1380
|
+
load(data, options) {
|
|
1381
|
+
throw new RangeError("Automerge.use() not called (load)");
|
|
1382
|
+
},
|
|
1383
|
+
encodeChange(change) {
|
|
1384
|
+
throw new RangeError("Automerge.use() not called (encodeChange)");
|
|
1385
|
+
},
|
|
1386
|
+
decodeChange(change) {
|
|
1387
|
+
throw new RangeError("Automerge.use() not called (decodeChange)");
|
|
1388
|
+
},
|
|
1389
|
+
initSyncState() {
|
|
1390
|
+
throw new RangeError("Automerge.use() not called (initSyncState)");
|
|
1391
|
+
},
|
|
1392
|
+
encodeSyncMessage(message) {
|
|
1393
|
+
throw new RangeError("Automerge.use() not called (encodeSyncMessage)");
|
|
1394
|
+
},
|
|
1395
|
+
decodeSyncMessage(msg) {
|
|
1396
|
+
throw new RangeError("Automerge.use() not called (decodeSyncMessage)");
|
|
1397
|
+
},
|
|
1398
|
+
encodeSyncState(state) {
|
|
1399
|
+
throw new RangeError("Automerge.use() not called (encodeSyncState)");
|
|
1400
|
+
},
|
|
1401
|
+
decodeSyncState(data) {
|
|
1402
|
+
throw new RangeError("Automerge.use() not called (decodeSyncState)");
|
|
1403
|
+
},
|
|
1404
|
+
exportSyncState(state) {
|
|
1405
|
+
throw new RangeError("Automerge.use() not called (exportSyncState)");
|
|
1406
|
+
},
|
|
1407
|
+
importSyncState(state) {
|
|
1408
|
+
throw new RangeError("Automerge.use() not called (importSyncState)");
|
|
1409
|
+
},
|
|
1410
|
+
readBundle(data) {
|
|
1411
|
+
throw new RangeError("Automerge.use() not called (readBundle)");
|
|
1412
|
+
},
|
|
1413
|
+
wasmReleaseInfo() {
|
|
1414
|
+
throw new RangeError("Automerge.use() not called (wasmReleaseInfo)");
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1419
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm_bg.wasm
|
|
1420
|
+
var exports_automerge_wasm_bg = {};
|
|
1421
|
+
__export(exports_automerge_wasm_bg, {
|
|
1422
|
+
default: () => automerge_wasm_bg_default
|
|
1423
|
+
});
|
|
1424
|
+
var automerge_wasm_bg_default = "../automerge_wasm_bg-4hg5vg2g.wasm";
|
|
1425
|
+
var init_automerge_wasm_bg = () => {};
|
|
1426
|
+
|
|
1427
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm_bg.js
|
|
1428
|
+
class Automerge2 {
|
|
1429
|
+
static __wrap(ptr) {
|
|
1430
|
+
ptr = ptr >>> 0;
|
|
1431
|
+
const obj = Object.create(Automerge2.prototype);
|
|
1432
|
+
obj.__wbg_ptr = ptr;
|
|
1433
|
+
AutomergeFinalization2.register(obj, obj.__wbg_ptr, obj);
|
|
1434
|
+
return obj;
|
|
1435
|
+
}
|
|
1436
|
+
__destroy_into_raw() {
|
|
1437
|
+
const ptr = this.__wbg_ptr;
|
|
1438
|
+
this.__wbg_ptr = 0;
|
|
1439
|
+
AutomergeFinalization2.unregister(this);
|
|
1440
|
+
return ptr;
|
|
1441
|
+
}
|
|
1442
|
+
free() {
|
|
1443
|
+
const ptr = this.__destroy_into_raw();
|
|
1444
|
+
wasm2.__wbg_automerge_free(ptr, 0);
|
|
1445
|
+
}
|
|
1446
|
+
applyAndReturnPatches(object, meta) {
|
|
1447
|
+
const ret = wasm2.automerge_applyAndReturnPatches(this.__wbg_ptr, object, meta);
|
|
1448
|
+
if (ret[2]) {
|
|
1449
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1450
|
+
}
|
|
1451
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1452
|
+
}
|
|
1453
|
+
applyChanges(changes) {
|
|
1454
|
+
const ret = wasm2.automerge_applyChanges(this.__wbg_ptr, changes);
|
|
1455
|
+
if (ret[1]) {
|
|
1456
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
applyPatches(object, meta) {
|
|
1460
|
+
const ret = wasm2.automerge_applyPatches(this.__wbg_ptr, object, meta);
|
|
1461
|
+
if (ret[2]) {
|
|
1462
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1463
|
+
}
|
|
1464
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1465
|
+
}
|
|
1466
|
+
clone(actor) {
|
|
1467
|
+
var ptr0 = isLikeNone2(actor) ? 0 : passStringToWasm02(actor, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
1468
|
+
var len0 = WASM_VECTOR_LEN2;
|
|
1469
|
+
const ret = wasm2.automerge_clone(this.__wbg_ptr, ptr0, len0);
|
|
1470
|
+
if (ret[2]) {
|
|
1471
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1472
|
+
}
|
|
1473
|
+
return Automerge2.__wrap(ret[0]);
|
|
1474
|
+
}
|
|
1475
|
+
commit(message, time) {
|
|
1476
|
+
var ptr0 = isLikeNone2(message) ? 0 : passStringToWasm02(message, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
1477
|
+
var len0 = WASM_VECTOR_LEN2;
|
|
1478
|
+
const ret = wasm2.automerge_commit(this.__wbg_ptr, ptr0, len0, !isLikeNone2(time), isLikeNone2(time) ? 0 : time);
|
|
1479
|
+
return ret;
|
|
1480
|
+
}
|
|
1481
|
+
delete(obj, prop) {
|
|
1482
|
+
const ret = wasm2.automerge_delete(this.__wbg_ptr, obj, prop);
|
|
1483
|
+
if (ret[1]) {
|
|
1484
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
diff(before, after) {
|
|
1488
|
+
const ret = wasm2.automerge_diff(this.__wbg_ptr, before, after);
|
|
1489
|
+
if (ret[2]) {
|
|
1490
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1491
|
+
}
|
|
1492
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1493
|
+
}
|
|
1494
|
+
diffIncremental() {
|
|
1495
|
+
const ret = wasm2.automerge_diffIncremental(this.__wbg_ptr);
|
|
1496
|
+
if (ret[2]) {
|
|
1497
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1498
|
+
}
|
|
1499
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1500
|
+
}
|
|
1501
|
+
diffPath(path, before, after, options) {
|
|
1502
|
+
const ret = wasm2.automerge_diffPath(this.__wbg_ptr, path, before, after, options);
|
|
1503
|
+
if (ret[2]) {
|
|
1504
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1505
|
+
}
|
|
1506
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1507
|
+
}
|
|
1508
|
+
dump() {
|
|
1509
|
+
wasm2.automerge_dump(this.__wbg_ptr);
|
|
1510
|
+
}
|
|
1511
|
+
emptyChange(message, time) {
|
|
1512
|
+
var ptr0 = isLikeNone2(message) ? 0 : passStringToWasm02(message, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
1513
|
+
var len0 = WASM_VECTOR_LEN2;
|
|
1514
|
+
const ret = wasm2.automerge_emptyChange(this.__wbg_ptr, ptr0, len0, !isLikeNone2(time), isLikeNone2(time) ? 0 : time);
|
|
1515
|
+
return ret;
|
|
1516
|
+
}
|
|
1517
|
+
enableFreeze(enable) {
|
|
1518
|
+
const ret = wasm2.automerge_enableFreeze(this.__wbg_ptr, enable);
|
|
1519
|
+
if (ret[2]) {
|
|
1520
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1521
|
+
}
|
|
1522
|
+
return ret[0] !== 0;
|
|
1523
|
+
}
|
|
1524
|
+
fork(actor, heads) {
|
|
1525
|
+
var ptr0 = isLikeNone2(actor) ? 0 : passStringToWasm02(actor, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
1526
|
+
var len0 = WASM_VECTOR_LEN2;
|
|
1527
|
+
const ret = wasm2.automerge_fork(this.__wbg_ptr, ptr0, len0, heads);
|
|
1528
|
+
if (ret[2]) {
|
|
1529
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1530
|
+
}
|
|
1531
|
+
return Automerge2.__wrap(ret[0]);
|
|
1532
|
+
}
|
|
1533
|
+
generateSyncMessage(state) {
|
|
1534
|
+
_assertClass2(state, SyncState2);
|
|
1535
|
+
const ret = wasm2.automerge_generateSyncMessage(this.__wbg_ptr, state.__wbg_ptr);
|
|
1536
|
+
return ret;
|
|
1537
|
+
}
|
|
1538
|
+
get(obj, prop, heads) {
|
|
1539
|
+
const ret = wasm2.automerge_get(this.__wbg_ptr, obj, prop, heads);
|
|
1540
|
+
if (ret[2]) {
|
|
1541
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1542
|
+
}
|
|
1543
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1544
|
+
}
|
|
1545
|
+
getActorId() {
|
|
1546
|
+
let deferred1_0;
|
|
1547
|
+
let deferred1_1;
|
|
1548
|
+
try {
|
|
1549
|
+
const ret = wasm2.automerge_getActorId(this.__wbg_ptr);
|
|
1550
|
+
deferred1_0 = ret[0];
|
|
1551
|
+
deferred1_1 = ret[1];
|
|
1552
|
+
return getStringFromWasm02(ret[0], ret[1]);
|
|
1553
|
+
} finally {
|
|
1554
|
+
wasm2.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
getAll(obj, arg, heads) {
|
|
1558
|
+
const ret = wasm2.automerge_getAll(this.__wbg_ptr, obj, arg, heads);
|
|
1559
|
+
if (ret[2]) {
|
|
1560
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1561
|
+
}
|
|
1562
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1563
|
+
}
|
|
1564
|
+
getBlock(text, index, heads) {
|
|
1565
|
+
const ret = wasm2.automerge_getBlock(this.__wbg_ptr, text, index, heads);
|
|
1566
|
+
if (ret[2]) {
|
|
1567
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1568
|
+
}
|
|
1569
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1570
|
+
}
|
|
1571
|
+
getChangeByHash(hash) {
|
|
1572
|
+
const ret = wasm2.automerge_getChangeByHash(this.__wbg_ptr, hash);
|
|
1573
|
+
if (ret[2]) {
|
|
1574
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1575
|
+
}
|
|
1576
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1577
|
+
}
|
|
1578
|
+
getChangeMetaByHash(hash) {
|
|
1579
|
+
const ret = wasm2.automerge_getChangeMetaByHash(this.__wbg_ptr, hash);
|
|
1580
|
+
if (ret[2]) {
|
|
1581
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1582
|
+
}
|
|
1583
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1584
|
+
}
|
|
1585
|
+
getChanges(have_deps) {
|
|
1586
|
+
const ret = wasm2.automerge_getChanges(this.__wbg_ptr, have_deps);
|
|
1587
|
+
if (ret[2]) {
|
|
1588
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1589
|
+
}
|
|
1590
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1591
|
+
}
|
|
1592
|
+
getChangesAdded(other) {
|
|
1593
|
+
_assertClass2(other, Automerge2);
|
|
1594
|
+
const ret = wasm2.automerge_getChangesAdded(this.__wbg_ptr, other.__wbg_ptr);
|
|
1595
|
+
return ret;
|
|
1596
|
+
}
|
|
1597
|
+
getChangesMeta(have_deps) {
|
|
1598
|
+
const ret = wasm2.automerge_getChangesMeta(this.__wbg_ptr, have_deps);
|
|
1599
|
+
if (ret[2]) {
|
|
1600
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1601
|
+
}
|
|
1602
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1603
|
+
}
|
|
1604
|
+
getCursor(obj, position, heads, move_cursor) {
|
|
1605
|
+
let deferred2_0;
|
|
1606
|
+
let deferred2_1;
|
|
1607
|
+
try {
|
|
1608
|
+
const ret = wasm2.automerge_getCursor(this.__wbg_ptr, obj, position, heads, move_cursor);
|
|
1609
|
+
var ptr1 = ret[0];
|
|
1610
|
+
var len1 = ret[1];
|
|
1611
|
+
if (ret[3]) {
|
|
1612
|
+
ptr1 = 0;
|
|
1613
|
+
len1 = 0;
|
|
1614
|
+
throw takeFromExternrefTable02(ret[2]);
|
|
1615
|
+
}
|
|
1616
|
+
deferred2_0 = ptr1;
|
|
1617
|
+
deferred2_1 = len1;
|
|
1618
|
+
return getStringFromWasm02(ptr1, len1);
|
|
1619
|
+
} finally {
|
|
1620
|
+
wasm2.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
getCursorPosition(obj, cursor, heads) {
|
|
1624
|
+
const ret = wasm2.automerge_getCursorPosition(this.__wbg_ptr, obj, cursor, heads);
|
|
1625
|
+
if (ret[2]) {
|
|
1626
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1627
|
+
}
|
|
1628
|
+
return ret[0];
|
|
1629
|
+
}
|
|
1630
|
+
getDecodedChangeByHash(hash) {
|
|
1631
|
+
const ret = wasm2.automerge_getDecodedChangeByHash(this.__wbg_ptr, hash);
|
|
1632
|
+
if (ret[2]) {
|
|
1633
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1634
|
+
}
|
|
1635
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1636
|
+
}
|
|
1637
|
+
getHeads() {
|
|
1638
|
+
const ret = wasm2.automerge_getHeads(this.__wbg_ptr);
|
|
1639
|
+
return ret;
|
|
1640
|
+
}
|
|
1641
|
+
getLastLocalChange() {
|
|
1642
|
+
const ret = wasm2.automerge_getLastLocalChange(this.__wbg_ptr);
|
|
1643
|
+
return ret;
|
|
1644
|
+
}
|
|
1645
|
+
getMissingDeps(heads) {
|
|
1646
|
+
const ret = wasm2.automerge_getMissingDeps(this.__wbg_ptr, heads);
|
|
1647
|
+
if (ret[2]) {
|
|
1648
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1649
|
+
}
|
|
1650
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1651
|
+
}
|
|
1652
|
+
getWithType(obj, prop, heads) {
|
|
1653
|
+
const ret = wasm2.automerge_getWithType(this.__wbg_ptr, obj, prop, heads);
|
|
1654
|
+
if (ret[2]) {
|
|
1655
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1656
|
+
}
|
|
1657
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1658
|
+
}
|
|
1659
|
+
hasOurChanges(state) {
|
|
1660
|
+
_assertClass2(state, SyncState2);
|
|
1661
|
+
const ret = wasm2.automerge_hasOurChanges(this.__wbg_ptr, state.__wbg_ptr);
|
|
1662
|
+
return ret !== 0;
|
|
1663
|
+
}
|
|
1664
|
+
increment(obj, prop, value) {
|
|
1665
|
+
const ret = wasm2.automerge_increment(this.__wbg_ptr, obj, prop, value);
|
|
1666
|
+
if (ret[1]) {
|
|
1667
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
insert(obj, index, value, datatype) {
|
|
1671
|
+
const ret = wasm2.automerge_insert(this.__wbg_ptr, obj, index, value, datatype);
|
|
1672
|
+
if (ret[1]) {
|
|
1673
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
insertObject(obj, index, value) {
|
|
1677
|
+
let deferred2_0;
|
|
1678
|
+
let deferred2_1;
|
|
1679
|
+
try {
|
|
1680
|
+
const ret = wasm2.automerge_insertObject(this.__wbg_ptr, obj, index, value);
|
|
1681
|
+
var ptr1 = ret[0];
|
|
1682
|
+
var len1 = ret[1];
|
|
1683
|
+
if (ret[3]) {
|
|
1684
|
+
ptr1 = 0;
|
|
1685
|
+
len1 = 0;
|
|
1686
|
+
throw takeFromExternrefTable02(ret[2]);
|
|
1687
|
+
}
|
|
1688
|
+
deferred2_0 = ptr1;
|
|
1689
|
+
deferred2_1 = len1;
|
|
1690
|
+
return getStringFromWasm02(ptr1, len1);
|
|
1691
|
+
} finally {
|
|
1692
|
+
wasm2.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
integrate() {
|
|
1696
|
+
wasm2.automerge_integrate(this.__wbg_ptr);
|
|
1697
|
+
}
|
|
1698
|
+
isolate(heads) {
|
|
1699
|
+
const ret = wasm2.automerge_isolate(this.__wbg_ptr, heads);
|
|
1700
|
+
if (ret[1]) {
|
|
1701
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
joinBlock(obj, index) {
|
|
1705
|
+
const ret = wasm2.automerge_joinBlock(this.__wbg_ptr, obj, index);
|
|
1706
|
+
if (ret[1]) {
|
|
1707
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
keys(obj, heads) {
|
|
1711
|
+
const ret = wasm2.automerge_keys(this.__wbg_ptr, obj, heads);
|
|
1712
|
+
if (ret[2]) {
|
|
1713
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1714
|
+
}
|
|
1715
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1716
|
+
}
|
|
1717
|
+
length(obj, heads) {
|
|
1718
|
+
const ret = wasm2.automerge_length(this.__wbg_ptr, obj, heads);
|
|
1719
|
+
if (ret[2]) {
|
|
1720
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1721
|
+
}
|
|
1722
|
+
return ret[0];
|
|
1723
|
+
}
|
|
1724
|
+
loadIncremental(data) {
|
|
1725
|
+
const ret = wasm2.automerge_loadIncremental(this.__wbg_ptr, data);
|
|
1726
|
+
if (ret[2]) {
|
|
1727
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1728
|
+
}
|
|
1729
|
+
return ret[0];
|
|
1730
|
+
}
|
|
1731
|
+
mark(obj, range, name, value, datatype) {
|
|
1732
|
+
const ret = wasm2.automerge_mark(this.__wbg_ptr, obj, range, name, value, datatype);
|
|
1733
|
+
if (ret[1]) {
|
|
1734
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
marks(obj, heads) {
|
|
1738
|
+
const ret = wasm2.automerge_marks(this.__wbg_ptr, obj, heads);
|
|
1739
|
+
if (ret[2]) {
|
|
1740
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1741
|
+
}
|
|
1742
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1743
|
+
}
|
|
1744
|
+
marksAt(obj, index, heads) {
|
|
1745
|
+
const ret = wasm2.automerge_marksAt(this.__wbg_ptr, obj, index, heads);
|
|
1746
|
+
if (ret[2]) {
|
|
1747
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1748
|
+
}
|
|
1749
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1750
|
+
}
|
|
1751
|
+
materialize(obj, heads, meta) {
|
|
1752
|
+
const ret = wasm2.automerge_materialize(this.__wbg_ptr, obj, heads, meta);
|
|
1753
|
+
if (ret[2]) {
|
|
1754
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1755
|
+
}
|
|
1756
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1757
|
+
}
|
|
1758
|
+
merge(other) {
|
|
1759
|
+
_assertClass2(other, Automerge2);
|
|
1760
|
+
const ret = wasm2.automerge_merge(this.__wbg_ptr, other.__wbg_ptr);
|
|
1761
|
+
if (ret[2]) {
|
|
1762
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1763
|
+
}
|
|
1764
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1765
|
+
}
|
|
1766
|
+
static new(actor) {
|
|
1767
|
+
var ptr0 = isLikeNone2(actor) ? 0 : passStringToWasm02(actor, wasm2.__wbindgen_malloc, wasm2.__wbindgen_realloc);
|
|
1768
|
+
var len0 = WASM_VECTOR_LEN2;
|
|
1769
|
+
const ret = wasm2.automerge_new(ptr0, len0);
|
|
1770
|
+
if (ret[2]) {
|
|
1771
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1772
|
+
}
|
|
1773
|
+
return Automerge2.__wrap(ret[0]);
|
|
1774
|
+
}
|
|
1775
|
+
objInfo(obj, heads) {
|
|
1776
|
+
const ret = wasm2.automerge_objInfo(this.__wbg_ptr, obj, heads);
|
|
1777
|
+
if (ret[2]) {
|
|
1778
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1779
|
+
}
|
|
1780
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1781
|
+
}
|
|
1782
|
+
pendingOps() {
|
|
1783
|
+
const ret = wasm2.automerge_pendingOps(this.__wbg_ptr);
|
|
1784
|
+
return ret;
|
|
1785
|
+
}
|
|
1786
|
+
push(obj, value, datatype) {
|
|
1787
|
+
const ret = wasm2.automerge_push(this.__wbg_ptr, obj, value, datatype);
|
|
1788
|
+
if (ret[1]) {
|
|
1789
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
pushObject(obj, value) {
|
|
1793
|
+
let deferred2_0;
|
|
1794
|
+
let deferred2_1;
|
|
1795
|
+
try {
|
|
1796
|
+
const ret = wasm2.automerge_pushObject(this.__wbg_ptr, obj, value);
|
|
1797
|
+
var ptr1 = ret[0];
|
|
1798
|
+
var len1 = ret[1];
|
|
1799
|
+
if (ret[3]) {
|
|
1800
|
+
ptr1 = 0;
|
|
1801
|
+
len1 = 0;
|
|
1802
|
+
throw takeFromExternrefTable02(ret[2]);
|
|
1803
|
+
}
|
|
1804
|
+
deferred2_0 = ptr1;
|
|
1805
|
+
deferred2_1 = len1;
|
|
1806
|
+
return getStringFromWasm02(ptr1, len1);
|
|
1807
|
+
} finally {
|
|
1808
|
+
wasm2.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
put(obj, prop, value, datatype) {
|
|
1812
|
+
const ret = wasm2.automerge_put(this.__wbg_ptr, obj, prop, value, datatype);
|
|
1813
|
+
if (ret[1]) {
|
|
1814
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
putObject(obj, prop, value) {
|
|
1818
|
+
const ret = wasm2.automerge_putObject(this.__wbg_ptr, obj, prop, value);
|
|
1819
|
+
if (ret[2]) {
|
|
1820
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1821
|
+
}
|
|
1822
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1823
|
+
}
|
|
1824
|
+
receiveSyncMessage(state, message) {
|
|
1825
|
+
_assertClass2(state, SyncState2);
|
|
1826
|
+
const ret = wasm2.automerge_receiveSyncMessage(this.__wbg_ptr, state.__wbg_ptr, message);
|
|
1827
|
+
if (ret[1]) {
|
|
1828
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
registerDatatype(datatype, construct, deconstruct) {
|
|
1832
|
+
const ret = wasm2.automerge_registerDatatype(this.__wbg_ptr, datatype, construct, deconstruct);
|
|
1833
|
+
if (ret[1]) {
|
|
1834
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
resetDiffCursor() {
|
|
1838
|
+
wasm2.automerge_resetDiffCursor(this.__wbg_ptr);
|
|
1839
|
+
}
|
|
1840
|
+
rollback() {
|
|
1841
|
+
const ret = wasm2.automerge_rollback(this.__wbg_ptr);
|
|
1842
|
+
return ret;
|
|
1843
|
+
}
|
|
1844
|
+
save() {
|
|
1845
|
+
const ret = wasm2.automerge_save(this.__wbg_ptr);
|
|
1846
|
+
return ret;
|
|
1847
|
+
}
|
|
1848
|
+
saveAndVerify() {
|
|
1849
|
+
const ret = wasm2.automerge_saveAndVerify(this.__wbg_ptr);
|
|
1850
|
+
if (ret[2]) {
|
|
1851
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1852
|
+
}
|
|
1853
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1854
|
+
}
|
|
1855
|
+
saveBundle(hashes) {
|
|
1856
|
+
const ret = wasm2.automerge_saveBundle(this.__wbg_ptr, hashes);
|
|
1857
|
+
if (ret[2]) {
|
|
1858
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1859
|
+
}
|
|
1860
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1861
|
+
}
|
|
1862
|
+
saveIncremental() {
|
|
1863
|
+
const ret = wasm2.automerge_saveIncremental(this.__wbg_ptr);
|
|
1864
|
+
return ret;
|
|
1865
|
+
}
|
|
1866
|
+
saveNoCompress() {
|
|
1867
|
+
const ret = wasm2.automerge_saveNoCompress(this.__wbg_ptr);
|
|
1868
|
+
return ret;
|
|
1869
|
+
}
|
|
1870
|
+
saveSince(heads) {
|
|
1871
|
+
const ret = wasm2.automerge_saveSince(this.__wbg_ptr, heads);
|
|
1872
|
+
if (ret[2]) {
|
|
1873
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1874
|
+
}
|
|
1875
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1876
|
+
}
|
|
1877
|
+
spans(obj, heads) {
|
|
1878
|
+
const ret = wasm2.automerge_spans(this.__wbg_ptr, obj, heads);
|
|
1879
|
+
if (ret[2]) {
|
|
1880
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1881
|
+
}
|
|
1882
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1883
|
+
}
|
|
1884
|
+
splice(obj, start, delete_count, text) {
|
|
1885
|
+
const ret = wasm2.automerge_splice(this.__wbg_ptr, obj, start, delete_count, text);
|
|
1886
|
+
if (ret[1]) {
|
|
1887
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
splitBlock(obj, index, block) {
|
|
1891
|
+
const ret = wasm2.automerge_splitBlock(this.__wbg_ptr, obj, index, block);
|
|
1892
|
+
if (ret[1]) {
|
|
1893
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
stats() {
|
|
1897
|
+
const ret = wasm2.automerge_stats(this.__wbg_ptr);
|
|
1898
|
+
return ret;
|
|
1899
|
+
}
|
|
1900
|
+
text(obj, heads) {
|
|
1901
|
+
let deferred2_0;
|
|
1902
|
+
let deferred2_1;
|
|
1903
|
+
try {
|
|
1904
|
+
const ret = wasm2.automerge_text(this.__wbg_ptr, obj, heads);
|
|
1905
|
+
var ptr1 = ret[0];
|
|
1906
|
+
var len1 = ret[1];
|
|
1907
|
+
if (ret[3]) {
|
|
1908
|
+
ptr1 = 0;
|
|
1909
|
+
len1 = 0;
|
|
1910
|
+
throw takeFromExternrefTable02(ret[2]);
|
|
1911
|
+
}
|
|
1912
|
+
deferred2_0 = ptr1;
|
|
1913
|
+
deferred2_1 = len1;
|
|
1914
|
+
return getStringFromWasm02(ptr1, len1);
|
|
1915
|
+
} finally {
|
|
1916
|
+
wasm2.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
toJS(meta) {
|
|
1920
|
+
const ret = wasm2.automerge_toJS(this.__wbg_ptr, meta);
|
|
1921
|
+
if (ret[2]) {
|
|
1922
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
1923
|
+
}
|
|
1924
|
+
return takeFromExternrefTable02(ret[0]);
|
|
1925
|
+
}
|
|
1926
|
+
topoHistoryTraversal() {
|
|
1927
|
+
const ret = wasm2.automerge_topoHistoryTraversal(this.__wbg_ptr);
|
|
1928
|
+
return ret;
|
|
1929
|
+
}
|
|
1930
|
+
unmark(obj, range, name) {
|
|
1931
|
+
const ret = wasm2.automerge_unmark(this.__wbg_ptr, obj, range, name);
|
|
1932
|
+
if (ret[1]) {
|
|
1933
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
updateBlock(obj, index, block) {
|
|
1937
|
+
const ret = wasm2.automerge_updateBlock(this.__wbg_ptr, obj, index, block);
|
|
1938
|
+
if (ret[1]) {
|
|
1939
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
updateDiffCursor() {
|
|
1943
|
+
wasm2.automerge_updateDiffCursor(this.__wbg_ptr);
|
|
1944
|
+
}
|
|
1945
|
+
updateSpans(obj, args, config) {
|
|
1946
|
+
const ret = wasm2.automerge_updateSpans(this.__wbg_ptr, obj, args, config);
|
|
1947
|
+
if (ret[1]) {
|
|
1948
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
updateText(obj, new_text) {
|
|
1952
|
+
const ret = wasm2.automerge_updateText(this.__wbg_ptr, obj, new_text);
|
|
1953
|
+
if (ret[1]) {
|
|
1954
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
class SyncState2 {
|
|
1960
|
+
static __wrap(ptr) {
|
|
1961
|
+
ptr = ptr >>> 0;
|
|
1962
|
+
const obj = Object.create(SyncState2.prototype);
|
|
1963
|
+
obj.__wbg_ptr = ptr;
|
|
1964
|
+
SyncStateFinalization2.register(obj, obj.__wbg_ptr, obj);
|
|
1965
|
+
return obj;
|
|
1966
|
+
}
|
|
1967
|
+
__destroy_into_raw() {
|
|
1968
|
+
const ptr = this.__wbg_ptr;
|
|
1969
|
+
this.__wbg_ptr = 0;
|
|
1970
|
+
SyncStateFinalization2.unregister(this);
|
|
1971
|
+
return ptr;
|
|
1972
|
+
}
|
|
1973
|
+
free() {
|
|
1974
|
+
const ptr = this.__destroy_into_raw();
|
|
1975
|
+
wasm2.__wbg_syncstate_free(ptr, 0);
|
|
1976
|
+
}
|
|
1977
|
+
clone() {
|
|
1978
|
+
const ret = wasm2.syncstate_clone(this.__wbg_ptr);
|
|
1979
|
+
return SyncState2.__wrap(ret);
|
|
1980
|
+
}
|
|
1981
|
+
get lastSentHeads() {
|
|
1982
|
+
const ret = wasm2.syncstate_lastSentHeads(this.__wbg_ptr);
|
|
1983
|
+
return ret;
|
|
1984
|
+
}
|
|
1985
|
+
set lastSentHeads(heads) {
|
|
1986
|
+
const ret = wasm2.syncstate_set_lastSentHeads(this.__wbg_ptr, heads);
|
|
1987
|
+
if (ret[1]) {
|
|
1988
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
set sentHashes(hashes) {
|
|
1992
|
+
const ret = wasm2.syncstate_set_sentHashes(this.__wbg_ptr, hashes);
|
|
1993
|
+
if (ret[1]) {
|
|
1994
|
+
throw takeFromExternrefTable02(ret[0]);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
get sharedHeads() {
|
|
1998
|
+
const ret = wasm2.syncstate_sharedHeads(this.__wbg_ptr);
|
|
1999
|
+
return ret;
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
function create2(options) {
|
|
2003
|
+
const ret = wasm2.create(options);
|
|
2004
|
+
if (ret[2]) {
|
|
2005
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2006
|
+
}
|
|
2007
|
+
return Automerge2.__wrap(ret[0]);
|
|
2008
|
+
}
|
|
2009
|
+
function decodeChange2(change) {
|
|
2010
|
+
const ret = wasm2.decodeChange(change);
|
|
2011
|
+
if (ret[2]) {
|
|
2012
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2013
|
+
}
|
|
2014
|
+
return takeFromExternrefTable02(ret[0]);
|
|
2015
|
+
}
|
|
2016
|
+
function decodeSyncMessage2(msg) {
|
|
2017
|
+
const ret = wasm2.decodeSyncMessage(msg);
|
|
2018
|
+
if (ret[2]) {
|
|
2019
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2020
|
+
}
|
|
2021
|
+
return takeFromExternrefTable02(ret[0]);
|
|
2022
|
+
}
|
|
2023
|
+
function decodeSyncState2(data) {
|
|
2024
|
+
const ret = wasm2.decodeSyncState(data);
|
|
2025
|
+
if (ret[2]) {
|
|
2026
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2027
|
+
}
|
|
2028
|
+
return SyncState2.__wrap(ret[0]);
|
|
2029
|
+
}
|
|
2030
|
+
function encodeChange2(change) {
|
|
2031
|
+
const ret = wasm2.encodeChange(change);
|
|
2032
|
+
if (ret[2]) {
|
|
2033
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2034
|
+
}
|
|
2035
|
+
return takeFromExternrefTable02(ret[0]);
|
|
2036
|
+
}
|
|
2037
|
+
function encodeSyncMessage2(message) {
|
|
2038
|
+
const ret = wasm2.encodeSyncMessage(message);
|
|
2039
|
+
if (ret[2]) {
|
|
2040
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2041
|
+
}
|
|
2042
|
+
return takeFromExternrefTable02(ret[0]);
|
|
2043
|
+
}
|
|
2044
|
+
function encodeSyncState2(state) {
|
|
2045
|
+
_assertClass2(state, SyncState2);
|
|
2046
|
+
const ret = wasm2.encodeSyncState(state.__wbg_ptr);
|
|
2047
|
+
return ret;
|
|
2048
|
+
}
|
|
2049
|
+
function exportSyncState2(state) {
|
|
2050
|
+
_assertClass2(state, SyncState2);
|
|
2051
|
+
const ret = wasm2.exportSyncState(state.__wbg_ptr);
|
|
2052
|
+
return ret;
|
|
2053
|
+
}
|
|
2054
|
+
function importSyncState2(state) {
|
|
2055
|
+
const ret = wasm2.importSyncState(state);
|
|
2056
|
+
if (ret[2]) {
|
|
2057
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2058
|
+
}
|
|
2059
|
+
return SyncState2.__wrap(ret[0]);
|
|
2060
|
+
}
|
|
2061
|
+
function initSyncState2() {
|
|
2062
|
+
const ret = wasm2.initSyncState();
|
|
2063
|
+
return SyncState2.__wrap(ret);
|
|
2064
|
+
}
|
|
2065
|
+
function load2(data, options) {
|
|
2066
|
+
const ret = wasm2.load(data, options);
|
|
2067
|
+
if (ret[2]) {
|
|
2068
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2069
|
+
}
|
|
2070
|
+
return Automerge2.__wrap(ret[0]);
|
|
2071
|
+
}
|
|
2072
|
+
function readBundle2(bundle) {
|
|
2073
|
+
const ret = wasm2.readBundle(bundle);
|
|
2074
|
+
if (ret[2]) {
|
|
2075
|
+
throw takeFromExternrefTable02(ret[1]);
|
|
2076
|
+
}
|
|
2077
|
+
return takeFromExternrefTable02(ret[0]);
|
|
2078
|
+
}
|
|
2079
|
+
function wasmReleaseInfo2() {
|
|
2080
|
+
const ret = wasm2.wasmReleaseInfo();
|
|
2081
|
+
return ret;
|
|
2082
|
+
}
|
|
2083
|
+
function _assertClass2(instance, klass) {
|
|
2084
|
+
if (!(instance instanceof klass)) {
|
|
2085
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
function getStringFromWasm02(ptr, len) {
|
|
2089
|
+
ptr = ptr >>> 0;
|
|
2090
|
+
return decodeText2(ptr, len);
|
|
2091
|
+
}
|
|
2092
|
+
function getUint8ArrayMemory02() {
|
|
2093
|
+
if (cachedUint8ArrayMemory02 === null || cachedUint8ArrayMemory02.byteLength === 0) {
|
|
2094
|
+
cachedUint8ArrayMemory02 = new Uint8Array(wasm2.memory.buffer);
|
|
2095
|
+
}
|
|
2096
|
+
return cachedUint8ArrayMemory02;
|
|
2097
|
+
}
|
|
2098
|
+
function isLikeNone2(x) {
|
|
2099
|
+
return x === undefined || x === null;
|
|
2100
|
+
}
|
|
2101
|
+
function passStringToWasm02(arg, malloc, realloc) {
|
|
2102
|
+
if (realloc === undefined) {
|
|
2103
|
+
const buf = cachedTextEncoder2.encode(arg);
|
|
2104
|
+
const ptr2 = malloc(buf.length, 1) >>> 0;
|
|
2105
|
+
getUint8ArrayMemory02().subarray(ptr2, ptr2 + buf.length).set(buf);
|
|
2106
|
+
WASM_VECTOR_LEN2 = buf.length;
|
|
2107
|
+
return ptr2;
|
|
2108
|
+
}
|
|
2109
|
+
let len = arg.length;
|
|
2110
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
2111
|
+
const mem = getUint8ArrayMemory02();
|
|
2112
|
+
let offset = 0;
|
|
2113
|
+
for (;offset < len; offset++) {
|
|
2114
|
+
const code = arg.charCodeAt(offset);
|
|
2115
|
+
if (code > 127)
|
|
2116
|
+
break;
|
|
2117
|
+
mem[ptr + offset] = code;
|
|
2118
|
+
}
|
|
2119
|
+
if (offset !== len) {
|
|
2120
|
+
if (offset !== 0) {
|
|
2121
|
+
arg = arg.slice(offset);
|
|
2122
|
+
}
|
|
2123
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
2124
|
+
const view = getUint8ArrayMemory02().subarray(ptr + offset, ptr + len);
|
|
2125
|
+
const ret = cachedTextEncoder2.encodeInto(arg, view);
|
|
2126
|
+
offset += ret.written;
|
|
2127
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
2128
|
+
}
|
|
2129
|
+
WASM_VECTOR_LEN2 = offset;
|
|
2130
|
+
return ptr;
|
|
2131
|
+
}
|
|
2132
|
+
function takeFromExternrefTable02(idx) {
|
|
2133
|
+
const value = wasm2.__wbindgen_externrefs.get(idx);
|
|
2134
|
+
wasm2.__externref_table_dealloc(idx);
|
|
2135
|
+
return value;
|
|
2136
|
+
}
|
|
2137
|
+
function decodeText2(ptr, len) {
|
|
2138
|
+
numBytesDecoded2 += len;
|
|
2139
|
+
if (numBytesDecoded2 >= MAX_SAFARI_DECODE_BYTES2) {
|
|
2140
|
+
cachedTextDecoder2 = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
2141
|
+
cachedTextDecoder2.decode();
|
|
2142
|
+
numBytesDecoded2 = len;
|
|
2143
|
+
}
|
|
2144
|
+
return cachedTextDecoder2.decode(getUint8ArrayMemory02().subarray(ptr, ptr + len));
|
|
2145
|
+
}
|
|
2146
|
+
function __wbg_set_wasm(val) {
|
|
2147
|
+
wasm2 = val;
|
|
2148
|
+
}
|
|
2149
|
+
var AutomergeFinalization2, SyncStateFinalization2, cachedUint8ArrayMemory02 = null, cachedTextDecoder2, MAX_SAFARI_DECODE_BYTES2 = 2146435072, numBytesDecoded2 = 0, cachedTextEncoder2, WASM_VECTOR_LEN2 = 0, wasm2;
|
|
2150
|
+
var init_automerge_wasm_bg2 = __esm(() => {
|
|
2151
|
+
if (Symbol.dispose)
|
|
2152
|
+
Automerge2.prototype[Symbol.dispose] = Automerge2.prototype.free;
|
|
2153
|
+
if (Symbol.dispose)
|
|
2154
|
+
SyncState2.prototype[Symbol.dispose] = SyncState2.prototype.free;
|
|
2155
|
+
AutomergeFinalization2 = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm2.__wbg_automerge_free(ptr >>> 0, 1));
|
|
2156
|
+
SyncStateFinalization2 = typeof FinalizationRegistry === "undefined" ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry((ptr) => wasm2.__wbg_syncstate_free(ptr >>> 0, 1));
|
|
2157
|
+
cachedTextDecoder2 = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
2158
|
+
cachedTextDecoder2.decode();
|
|
2159
|
+
cachedTextEncoder2 = new TextEncoder;
|
|
2160
|
+
if (!("encodeInto" in cachedTextEncoder2)) {
|
|
2161
|
+
cachedTextEncoder2.encodeInto = function(arg, view) {
|
|
2162
|
+
const buf = cachedTextEncoder2.encode(arg);
|
|
2163
|
+
view.set(buf);
|
|
2164
|
+
return {
|
|
2165
|
+
read: arg.length,
|
|
2166
|
+
written: buf.length
|
|
2167
|
+
};
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
});
|
|
2171
|
+
|
|
2172
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/wasm_bindgen_output/bundler/automerge_wasm.js
|
|
2173
|
+
var exports_automerge_wasm2 = {};
|
|
2174
|
+
__export(exports_automerge_wasm2, {
|
|
2175
|
+
wasmReleaseInfo: () => wasmReleaseInfo2,
|
|
2176
|
+
readBundle: () => readBundle2,
|
|
2177
|
+
load: () => load2,
|
|
2178
|
+
initSyncState: () => initSyncState2,
|
|
2179
|
+
importSyncState: () => importSyncState2,
|
|
2180
|
+
exportSyncState: () => exportSyncState2,
|
|
2181
|
+
encodeSyncState: () => encodeSyncState2,
|
|
2182
|
+
encodeSyncMessage: () => encodeSyncMessage2,
|
|
2183
|
+
encodeChange: () => encodeChange2,
|
|
2184
|
+
decodeSyncState: () => decodeSyncState2,
|
|
2185
|
+
decodeSyncMessage: () => decodeSyncMessage2,
|
|
2186
|
+
decodeChange: () => decodeChange2,
|
|
2187
|
+
create: () => create2,
|
|
2188
|
+
SyncState: () => SyncState2,
|
|
2189
|
+
Automerge: () => Automerge2
|
|
2190
|
+
});
|
|
2191
|
+
var init_automerge_wasm2 = __esm(() => {
|
|
2192
|
+
init_automerge_wasm_bg();
|
|
2193
|
+
init_automerge_wasm_bg2();
|
|
2194
|
+
init_automerge_wasm_bg2();
|
|
2195
|
+
__wbg_set_wasm(exports_automerge_wasm_bg);
|
|
2196
|
+
undefined();
|
|
2197
|
+
});
|
|
2198
|
+
|
|
2199
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/constants.js
|
|
2200
|
+
var STATE, TRACE, OBJECT_ID, IS_PROXY, CLEAR_CACHE, UINT, INT, F64, COUNTER, TEXT, IMMUTABLE_STRING;
|
|
2201
|
+
var init_constants = __esm(() => {
|
|
2202
|
+
STATE = Symbol.for("_am_meta");
|
|
2203
|
+
TRACE = Symbol.for("_am_trace");
|
|
2204
|
+
OBJECT_ID = Symbol.for("_am_objectId");
|
|
2205
|
+
IS_PROXY = Symbol.for("_am_isProxy");
|
|
2206
|
+
CLEAR_CACHE = Symbol.for("_am_clearCache");
|
|
2207
|
+
UINT = Symbol.for("_am_uint");
|
|
2208
|
+
INT = Symbol.for("_am_int");
|
|
2209
|
+
F64 = Symbol.for("_am_f64");
|
|
2210
|
+
COUNTER = Symbol.for("_am_counter");
|
|
2211
|
+
TEXT = Symbol.for("_am_text");
|
|
2212
|
+
IMMUTABLE_STRING = Symbol.for("_am_immutableString");
|
|
2213
|
+
});
|
|
2214
|
+
|
|
2215
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/counter.js
|
|
2216
|
+
class Counter {
|
|
2217
|
+
constructor(value) {
|
|
2218
|
+
this.value = value || 0;
|
|
2219
|
+
Reflect.defineProperty(this, COUNTER, { value: true });
|
|
2220
|
+
}
|
|
2221
|
+
valueOf() {
|
|
2222
|
+
return this.value;
|
|
2223
|
+
}
|
|
2224
|
+
toString() {
|
|
2225
|
+
return this.valueOf().toString();
|
|
2226
|
+
}
|
|
2227
|
+
toJSON() {
|
|
2228
|
+
return this.value;
|
|
2229
|
+
}
|
|
2230
|
+
increment(_delta) {
|
|
2231
|
+
throw new Error("Counters should not be incremented outside of a change callback");
|
|
2232
|
+
}
|
|
2233
|
+
decrement(_delta) {
|
|
2234
|
+
throw new Error("Counters should not be decremented outside of a change callback");
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
function getWriteableCounter(value, context, path, objectId, key) {
|
|
2238
|
+
return new WriteableCounter(value, context, path, objectId, key);
|
|
2239
|
+
}
|
|
2240
|
+
var WriteableCounter;
|
|
2241
|
+
var init_counter = __esm(() => {
|
|
2242
|
+
init_constants();
|
|
2243
|
+
WriteableCounter = class WriteableCounter extends Counter {
|
|
2244
|
+
constructor(value, context, path, objectId, key) {
|
|
2245
|
+
super(value);
|
|
2246
|
+
this.context = context;
|
|
2247
|
+
this.path = path;
|
|
2248
|
+
this.objectId = objectId;
|
|
2249
|
+
this.key = key;
|
|
2250
|
+
}
|
|
2251
|
+
increment(delta) {
|
|
2252
|
+
delta = typeof delta === "number" ? delta : 1;
|
|
2253
|
+
this.context.increment(this.objectId, this.key, delta);
|
|
2254
|
+
this.value += delta;
|
|
2255
|
+
return this.value;
|
|
2256
|
+
}
|
|
2257
|
+
decrement(delta) {
|
|
2258
|
+
return this.increment(typeof delta === "number" ? -delta : -1);
|
|
2259
|
+
}
|
|
2260
|
+
};
|
|
2261
|
+
});
|
|
2262
|
+
|
|
2263
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/immutable_string.js
|
|
2264
|
+
class ImmutableString {
|
|
2265
|
+
constructor(val) {
|
|
2266
|
+
this[_a] = true;
|
|
2267
|
+
this.val = val;
|
|
2268
|
+
}
|
|
2269
|
+
toString() {
|
|
2270
|
+
return this.val;
|
|
2271
|
+
}
|
|
2272
|
+
toJSON() {
|
|
2273
|
+
return this.val;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
var _a;
|
|
2277
|
+
var init_immutable_string = __esm(() => {
|
|
2278
|
+
init_constants();
|
|
2279
|
+
_a = IMMUTABLE_STRING;
|
|
2280
|
+
});
|
|
2281
|
+
|
|
2282
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/proxies.js
|
|
2283
|
+
function parseListIndex(key) {
|
|
2284
|
+
if (typeof key === "string" && /^[0-9]+$/.test(key))
|
|
2285
|
+
key = parseInt(key, 10);
|
|
2286
|
+
if (typeof key !== "number") {
|
|
2287
|
+
return key;
|
|
2288
|
+
}
|
|
2289
|
+
if (key < 0 || isNaN(key) || key === Infinity || key === -Infinity) {
|
|
2290
|
+
throw new RangeError("A list index must be positive, but you passed " + key);
|
|
2291
|
+
}
|
|
2292
|
+
return key;
|
|
2293
|
+
}
|
|
2294
|
+
function valueAt(target, prop) {
|
|
2295
|
+
const { context, objectId, path } = target;
|
|
2296
|
+
const value = context.getWithType(objectId, prop);
|
|
2297
|
+
if (value === null) {
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
const datatype = value[0];
|
|
2301
|
+
const val = value[1];
|
|
2302
|
+
switch (datatype) {
|
|
2303
|
+
case undefined:
|
|
2304
|
+
return;
|
|
2305
|
+
case "map":
|
|
2306
|
+
return mapProxy(context, val, [...path, prop]);
|
|
2307
|
+
case "list":
|
|
2308
|
+
return listProxy(context, val, [...path, prop]);
|
|
2309
|
+
case "text":
|
|
2310
|
+
return context.text(val);
|
|
2311
|
+
case "str":
|
|
2312
|
+
return new ImmutableString(val);
|
|
2313
|
+
case "uint":
|
|
2314
|
+
return val;
|
|
2315
|
+
case "int":
|
|
2316
|
+
return val;
|
|
2317
|
+
case "f64":
|
|
2318
|
+
return val;
|
|
2319
|
+
case "boolean":
|
|
2320
|
+
return val;
|
|
2321
|
+
case "null":
|
|
2322
|
+
return null;
|
|
2323
|
+
case "bytes":
|
|
2324
|
+
return val;
|
|
2325
|
+
case "timestamp":
|
|
2326
|
+
return val;
|
|
2327
|
+
case "counter": {
|
|
2328
|
+
const counter = getWriteableCounter(val, context, path, objectId, prop);
|
|
2329
|
+
return counter;
|
|
2330
|
+
}
|
|
2331
|
+
default:
|
|
2332
|
+
throw RangeError(`datatype ${datatype} unimplemented`);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
function import_value(value, path, context) {
|
|
2336
|
+
const type = typeof value;
|
|
2337
|
+
switch (type) {
|
|
2338
|
+
case "object":
|
|
2339
|
+
if (value == null) {
|
|
2340
|
+
return [null, "null"];
|
|
2341
|
+
} else if (value[UINT]) {
|
|
2342
|
+
return [value.value, "uint"];
|
|
2343
|
+
} else if (value[INT]) {
|
|
2344
|
+
return [value.value, "int"];
|
|
2345
|
+
} else if (value[F64]) {
|
|
2346
|
+
return [value.value, "f64"];
|
|
2347
|
+
} else if (value[COUNTER]) {
|
|
2348
|
+
return [value.value, "counter"];
|
|
2349
|
+
} else if (value instanceof Date) {
|
|
2350
|
+
return [value.getTime(), "timestamp"];
|
|
2351
|
+
} else if (isImmutableString(value)) {
|
|
2352
|
+
return [value.toString(), "str"];
|
|
2353
|
+
} else if (value instanceof Uint8Array) {
|
|
2354
|
+
return [value, "bytes"];
|
|
2355
|
+
} else if (value instanceof Array) {
|
|
2356
|
+
return [value, "list"];
|
|
2357
|
+
} else if (Object.prototype.toString.call(value) === "[object Object]") {
|
|
2358
|
+
return [value, "map"];
|
|
2359
|
+
} else if (isSameDocument(value, context)) {
|
|
2360
|
+
throw new RangeError("Cannot create a reference to an existing document object");
|
|
2361
|
+
} else {
|
|
2362
|
+
throw new RangeError(`Cannot assign unknown object: ${value}`);
|
|
2363
|
+
}
|
|
2364
|
+
case "boolean":
|
|
2365
|
+
return [value, "boolean"];
|
|
2366
|
+
case "bigint":
|
|
2367
|
+
if (value > MAX_I64) {
|
|
2368
|
+
return [value, "uint"];
|
|
2369
|
+
} else {
|
|
2370
|
+
return [value, "int"];
|
|
2371
|
+
}
|
|
2372
|
+
case "number":
|
|
2373
|
+
if (Number.isInteger(value)) {
|
|
2374
|
+
return [value, "int"];
|
|
2375
|
+
} else {
|
|
2376
|
+
return [value, "f64"];
|
|
2377
|
+
}
|
|
2378
|
+
case "string":
|
|
2379
|
+
return [value, "text"];
|
|
2380
|
+
case "undefined":
|
|
2381
|
+
throw new RangeError([
|
|
2382
|
+
`Cannot assign undefined value at ${printPath(path)}, `,
|
|
2383
|
+
"because `undefined` is not a valid JSON data type. ",
|
|
2384
|
+
"You might consider setting the property's value to `null`, ",
|
|
2385
|
+
"or using `delete` to remove it altogether."
|
|
2386
|
+
].join(""));
|
|
2387
|
+
default:
|
|
2388
|
+
throw new RangeError([
|
|
2389
|
+
`Cannot assign ${type} value at ${printPath(path)}. `,
|
|
2390
|
+
`All JSON primitive datatypes (object, array, string, number, boolean, null) `,
|
|
2391
|
+
`are supported in an Automerge document; ${type} values are not. `
|
|
2392
|
+
].join(""));
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
function isSameDocument(val, context) {
|
|
2396
|
+
var _b, _c;
|
|
2397
|
+
if (val instanceof Date) {
|
|
2398
|
+
return false;
|
|
2399
|
+
}
|
|
2400
|
+
if (val && ((_c = (_b = val[STATE]) === null || _b === undefined ? undefined : _b.handle) === null || _c === undefined ? undefined : _c.__wbg_ptr) === context.__wbg_ptr) {
|
|
2401
|
+
return true;
|
|
2402
|
+
}
|
|
2403
|
+
return false;
|
|
2404
|
+
}
|
|
2405
|
+
function mapProxy(context, objectId, path) {
|
|
2406
|
+
const target = {
|
|
2407
|
+
context,
|
|
2408
|
+
objectId,
|
|
2409
|
+
path: path || [],
|
|
2410
|
+
cache: {}
|
|
2411
|
+
};
|
|
2412
|
+
const proxied = {};
|
|
2413
|
+
Object.assign(proxied, target);
|
|
2414
|
+
const result = new Proxy(proxied, MapHandler);
|
|
2415
|
+
return result;
|
|
2416
|
+
}
|
|
2417
|
+
function listProxy(context, objectId, path) {
|
|
2418
|
+
const target = {
|
|
2419
|
+
context,
|
|
2420
|
+
objectId,
|
|
2421
|
+
path: path || [],
|
|
2422
|
+
cache: {}
|
|
2423
|
+
};
|
|
2424
|
+
const proxied = [];
|
|
2425
|
+
Object.assign(proxied, target);
|
|
2426
|
+
return new Proxy(proxied, ListHandler);
|
|
2427
|
+
}
|
|
2428
|
+
function rootProxy(context) {
|
|
2429
|
+
return mapProxy(context, "_root", []);
|
|
2430
|
+
}
|
|
2431
|
+
function listMethods(target) {
|
|
2432
|
+
const { context, objectId, path } = target;
|
|
2433
|
+
const methods = {
|
|
2434
|
+
at(index) {
|
|
2435
|
+
return valueAt(target, index);
|
|
2436
|
+
},
|
|
2437
|
+
deleteAt(index, numDelete) {
|
|
2438
|
+
if (typeof numDelete === "number") {
|
|
2439
|
+
context.splice(objectId, index, numDelete);
|
|
2440
|
+
} else {
|
|
2441
|
+
context.delete(objectId, index);
|
|
2442
|
+
}
|
|
2443
|
+
return this;
|
|
2444
|
+
},
|
|
2445
|
+
fill(val, start, end) {
|
|
2446
|
+
const [value, datatype] = import_value(val, [...path, start], context);
|
|
2447
|
+
const length = context.length(objectId);
|
|
2448
|
+
start = parseListIndex(start || 0);
|
|
2449
|
+
end = parseListIndex(end || length);
|
|
2450
|
+
for (let i = start;i < Math.min(end, length); i++) {
|
|
2451
|
+
if (datatype === "list" || datatype === "map") {
|
|
2452
|
+
context.putObject(objectId, i, value);
|
|
2453
|
+
} else if (datatype === "text") {
|
|
2454
|
+
context.putObject(objectId, i, value);
|
|
2455
|
+
} else {
|
|
2456
|
+
context.put(objectId, i, value, datatype);
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
return this;
|
|
2460
|
+
},
|
|
2461
|
+
indexOf(searchElement, start = 0) {
|
|
2462
|
+
const length = context.length(objectId);
|
|
2463
|
+
for (let i = start;i < length; i++) {
|
|
2464
|
+
const valueWithType = context.getWithType(objectId, i);
|
|
2465
|
+
if (!valueWithType) {
|
|
2466
|
+
continue;
|
|
2467
|
+
}
|
|
2468
|
+
const [valType, value] = valueWithType;
|
|
2469
|
+
const isObject = ["map", "list", "text"].includes(valType);
|
|
2470
|
+
if (!isObject) {
|
|
2471
|
+
if (value === searchElement) {
|
|
2472
|
+
return i;
|
|
2473
|
+
} else {
|
|
2474
|
+
continue;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
if (valType === "text" && typeof searchElement === "string") {
|
|
2478
|
+
if (searchElement === valueAt(target, i)) {
|
|
2479
|
+
return i;
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
if (searchElement[OBJECT_ID] === value) {
|
|
2483
|
+
return i;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
return -1;
|
|
2487
|
+
},
|
|
2488
|
+
insertAt(index, ...values) {
|
|
2489
|
+
this.splice(index, 0, ...values);
|
|
2490
|
+
return this;
|
|
2491
|
+
},
|
|
2492
|
+
pop() {
|
|
2493
|
+
const length = context.length(objectId);
|
|
2494
|
+
if (length == 0) {
|
|
2495
|
+
return;
|
|
2496
|
+
}
|
|
2497
|
+
const last = valueAt(target, length - 1);
|
|
2498
|
+
context.delete(objectId, length - 1);
|
|
2499
|
+
return last;
|
|
2500
|
+
},
|
|
2501
|
+
push(...values) {
|
|
2502
|
+
const len = context.length(objectId);
|
|
2503
|
+
this.splice(len, 0, ...values);
|
|
2504
|
+
return context.length(objectId);
|
|
2505
|
+
},
|
|
2506
|
+
shift() {
|
|
2507
|
+
if (context.length(objectId) == 0)
|
|
2508
|
+
return;
|
|
2509
|
+
const first = valueAt(target, 0);
|
|
2510
|
+
context.delete(objectId, 0);
|
|
2511
|
+
return first;
|
|
2512
|
+
},
|
|
2513
|
+
splice(index, del, ...vals) {
|
|
2514
|
+
index = parseListIndex(index);
|
|
2515
|
+
if (typeof del !== "number") {
|
|
2516
|
+
del = context.length(objectId) - index;
|
|
2517
|
+
}
|
|
2518
|
+
del = parseListIndex(del);
|
|
2519
|
+
for (const val of vals) {
|
|
2520
|
+
if (isSameDocument(val, context)) {
|
|
2521
|
+
throw new RangeError("Cannot create a reference to an existing document object");
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
const result = [];
|
|
2525
|
+
for (let i = 0;i < del; i++) {
|
|
2526
|
+
const value = valueAt(target, index);
|
|
2527
|
+
if (value !== undefined) {
|
|
2528
|
+
result.push(value);
|
|
2529
|
+
}
|
|
2530
|
+
context.delete(objectId, index);
|
|
2531
|
+
}
|
|
2532
|
+
const values = vals.map((val, index2) => {
|
|
2533
|
+
try {
|
|
2534
|
+
return import_value(val, [...path], context);
|
|
2535
|
+
} catch (e) {
|
|
2536
|
+
if (e instanceof RangeError) {
|
|
2537
|
+
throw new RangeError(`${e.message} (at index ${index2} in the input)`);
|
|
2538
|
+
} else {
|
|
2539
|
+
throw e;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
});
|
|
2543
|
+
for (const [value, datatype] of values) {
|
|
2544
|
+
switch (datatype) {
|
|
2545
|
+
case "list": {
|
|
2546
|
+
const list = context.insertObject(objectId, index, []);
|
|
2547
|
+
const proxyList = listProxy(context, list, [...path, index]);
|
|
2548
|
+
proxyList.splice(0, 0, ...value);
|
|
2549
|
+
break;
|
|
2550
|
+
}
|
|
2551
|
+
case "text": {
|
|
2552
|
+
context.insertObject(objectId, index, value);
|
|
2553
|
+
break;
|
|
2554
|
+
}
|
|
2555
|
+
case "map": {
|
|
2556
|
+
const map = context.insertObject(objectId, index, {});
|
|
2557
|
+
const proxyMap = mapProxy(context, map, [...path, index]);
|
|
2558
|
+
for (const key in value) {
|
|
2559
|
+
proxyMap[key] = value[key];
|
|
2560
|
+
}
|
|
2561
|
+
break;
|
|
2562
|
+
}
|
|
2563
|
+
default:
|
|
2564
|
+
context.insert(objectId, index, value, datatype);
|
|
2565
|
+
}
|
|
2566
|
+
index += 1;
|
|
2567
|
+
}
|
|
2568
|
+
return result;
|
|
2569
|
+
},
|
|
2570
|
+
unshift(...values) {
|
|
2571
|
+
this.splice(0, 0, ...values);
|
|
2572
|
+
return context.length(objectId);
|
|
2573
|
+
},
|
|
2574
|
+
entries() {
|
|
2575
|
+
let i = 0;
|
|
2576
|
+
const iterator = {
|
|
2577
|
+
next: () => {
|
|
2578
|
+
const value = valueAt(target, i);
|
|
2579
|
+
if (value === undefined) {
|
|
2580
|
+
return { value: undefined, done: true };
|
|
2581
|
+
} else {
|
|
2582
|
+
return { value: [i++, value], done: false };
|
|
2583
|
+
}
|
|
2584
|
+
},
|
|
2585
|
+
[Symbol.iterator]() {
|
|
2586
|
+
return this;
|
|
2587
|
+
}
|
|
2588
|
+
};
|
|
2589
|
+
return iterator;
|
|
2590
|
+
},
|
|
2591
|
+
keys() {
|
|
2592
|
+
let i = 0;
|
|
2593
|
+
const len = context.length(objectId);
|
|
2594
|
+
const iterator = {
|
|
2595
|
+
next: () => {
|
|
2596
|
+
if (i < len) {
|
|
2597
|
+
return { value: i++, done: false };
|
|
2598
|
+
}
|
|
2599
|
+
return { value: undefined, done: true };
|
|
2600
|
+
},
|
|
2601
|
+
[Symbol.iterator]() {
|
|
2602
|
+
return this;
|
|
2603
|
+
}
|
|
2604
|
+
};
|
|
2605
|
+
return iterator;
|
|
2606
|
+
},
|
|
2607
|
+
values() {
|
|
2608
|
+
let i = 0;
|
|
2609
|
+
const iterator = {
|
|
2610
|
+
next: () => {
|
|
2611
|
+
const value = valueAt(target, i++);
|
|
2612
|
+
if (value === undefined) {
|
|
2613
|
+
return { value: undefined, done: true };
|
|
2614
|
+
} else {
|
|
2615
|
+
return { value, done: false };
|
|
2616
|
+
}
|
|
2617
|
+
},
|
|
2618
|
+
[Symbol.iterator]() {
|
|
2619
|
+
return this;
|
|
2620
|
+
}
|
|
2621
|
+
};
|
|
2622
|
+
return iterator;
|
|
2623
|
+
},
|
|
2624
|
+
toArray() {
|
|
2625
|
+
const list = [];
|
|
2626
|
+
let value;
|
|
2627
|
+
do {
|
|
2628
|
+
value = valueAt(target, list.length);
|
|
2629
|
+
if (value !== undefined) {
|
|
2630
|
+
list.push(value);
|
|
2631
|
+
}
|
|
2632
|
+
} while (value !== undefined);
|
|
2633
|
+
return list;
|
|
2634
|
+
},
|
|
2635
|
+
map(f) {
|
|
2636
|
+
return this.toArray().map(f);
|
|
2637
|
+
},
|
|
2638
|
+
toString() {
|
|
2639
|
+
return this.toArray().toString();
|
|
2640
|
+
},
|
|
2641
|
+
toLocaleString() {
|
|
2642
|
+
return this.toArray().toLocaleString();
|
|
2643
|
+
},
|
|
2644
|
+
forEach(f) {
|
|
2645
|
+
return this.toArray().forEach(f);
|
|
2646
|
+
},
|
|
2647
|
+
concat(other) {
|
|
2648
|
+
return this.toArray().concat(other);
|
|
2649
|
+
},
|
|
2650
|
+
every(f) {
|
|
2651
|
+
return this.toArray().every(f);
|
|
2652
|
+
},
|
|
2653
|
+
filter(f) {
|
|
2654
|
+
return this.toArray().filter(f);
|
|
2655
|
+
},
|
|
2656
|
+
find(f) {
|
|
2657
|
+
let index = 0;
|
|
2658
|
+
for (const v of this) {
|
|
2659
|
+
if (f(v, index)) {
|
|
2660
|
+
return v;
|
|
2661
|
+
}
|
|
2662
|
+
index += 1;
|
|
2663
|
+
}
|
|
2664
|
+
},
|
|
2665
|
+
findIndex(f) {
|
|
2666
|
+
let index = 0;
|
|
2667
|
+
for (const v of this) {
|
|
2668
|
+
if (f(v, index)) {
|
|
2669
|
+
return index;
|
|
2670
|
+
}
|
|
2671
|
+
index += 1;
|
|
2672
|
+
}
|
|
2673
|
+
return -1;
|
|
2674
|
+
},
|
|
2675
|
+
includes(elem) {
|
|
2676
|
+
return this.find((e) => e === elem) !== undefined;
|
|
2677
|
+
},
|
|
2678
|
+
join(sep) {
|
|
2679
|
+
return this.toArray().join(sep);
|
|
2680
|
+
},
|
|
2681
|
+
reduce(f, initialValue) {
|
|
2682
|
+
return this.toArray().reduce(f, initialValue);
|
|
2683
|
+
},
|
|
2684
|
+
reduceRight(f, initialValue) {
|
|
2685
|
+
return this.toArray().reduceRight(f, initialValue);
|
|
2686
|
+
},
|
|
2687
|
+
lastIndexOf(search, fromIndex = Infinity) {
|
|
2688
|
+
return this.toArray().lastIndexOf(search, fromIndex);
|
|
2689
|
+
},
|
|
2690
|
+
slice(index, num) {
|
|
2691
|
+
return this.toArray().slice(index, num);
|
|
2692
|
+
},
|
|
2693
|
+
some(f) {
|
|
2694
|
+
let index = 0;
|
|
2695
|
+
for (const v of this) {
|
|
2696
|
+
if (f(v, index)) {
|
|
2697
|
+
return true;
|
|
2698
|
+
}
|
|
2699
|
+
index += 1;
|
|
2700
|
+
}
|
|
2701
|
+
return false;
|
|
2702
|
+
},
|
|
2703
|
+
[Symbol.iterator]: function* () {
|
|
2704
|
+
let i = 0;
|
|
2705
|
+
let value = valueAt(target, i);
|
|
2706
|
+
while (value !== undefined) {
|
|
2707
|
+
yield value;
|
|
2708
|
+
i += 1;
|
|
2709
|
+
value = valueAt(target, i);
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
return methods;
|
|
2714
|
+
}
|
|
2715
|
+
function printPath(path) {
|
|
2716
|
+
const jsonPointerComponents = path.map((component) => {
|
|
2717
|
+
if (typeof component === "number") {
|
|
2718
|
+
return component.toString();
|
|
2719
|
+
} else if (typeof component === "string") {
|
|
2720
|
+
return component.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2723
|
+
if (path.length === 0) {
|
|
2724
|
+
return "";
|
|
2725
|
+
} else {
|
|
2726
|
+
return "/" + jsonPointerComponents.join("/");
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
function isImmutableString(obj) {
|
|
2730
|
+
return typeof obj === "object" && obj !== null && Object.prototype.hasOwnProperty.call(obj, IMMUTABLE_STRING);
|
|
2731
|
+
}
|
|
2732
|
+
function isCounter(obj) {
|
|
2733
|
+
return typeof obj === "object" && obj !== null && Object.prototype.hasOwnProperty.call(obj, COUNTER);
|
|
2734
|
+
}
|
|
2735
|
+
var MAX_I64, MapHandler, ListHandler;
|
|
2736
|
+
var init_proxies = __esm(() => {
|
|
2737
|
+
init_counter();
|
|
2738
|
+
init_constants();
|
|
2739
|
+
init_immutable_string();
|
|
2740
|
+
MAX_I64 = BigInt("9223372036854775807");
|
|
2741
|
+
MapHandler = {
|
|
2742
|
+
get(target, key) {
|
|
2743
|
+
const { context, objectId, cache } = target;
|
|
2744
|
+
if (key === Symbol.toStringTag) {
|
|
2745
|
+
return target[Symbol.toStringTag];
|
|
2746
|
+
}
|
|
2747
|
+
if (key === OBJECT_ID)
|
|
2748
|
+
return objectId;
|
|
2749
|
+
if (key === IS_PROXY)
|
|
2750
|
+
return true;
|
|
2751
|
+
if (key === TRACE)
|
|
2752
|
+
return target.trace;
|
|
2753
|
+
if (key === STATE)
|
|
2754
|
+
return { handle: context };
|
|
2755
|
+
if (!cache[key]) {
|
|
2756
|
+
cache[key] = valueAt(target, key);
|
|
2757
|
+
}
|
|
2758
|
+
return cache[key];
|
|
2759
|
+
},
|
|
2760
|
+
set(target, key, val) {
|
|
2761
|
+
const { context, objectId, path } = target;
|
|
2762
|
+
target.cache = {};
|
|
2763
|
+
if (isSameDocument(val, context)) {
|
|
2764
|
+
throw new RangeError("Cannot create a reference to an existing document object");
|
|
2765
|
+
}
|
|
2766
|
+
if (key === TRACE) {
|
|
2767
|
+
target.trace = val;
|
|
2768
|
+
return true;
|
|
2769
|
+
}
|
|
2770
|
+
if (key === CLEAR_CACHE) {
|
|
2771
|
+
return true;
|
|
2772
|
+
}
|
|
2773
|
+
const [value, datatype] = import_value(val, [...path, key], context);
|
|
2774
|
+
switch (datatype) {
|
|
2775
|
+
case "list": {
|
|
2776
|
+
const list = context.putObject(objectId, key, []);
|
|
2777
|
+
const proxyList = listProxy(context, list, [...path, key]);
|
|
2778
|
+
for (let i = 0;i < value.length; i++) {
|
|
2779
|
+
proxyList[i] = value[i];
|
|
2780
|
+
}
|
|
2781
|
+
break;
|
|
2782
|
+
}
|
|
2783
|
+
case "text": {
|
|
2784
|
+
context.putObject(objectId, key, value);
|
|
2785
|
+
break;
|
|
2786
|
+
}
|
|
2787
|
+
case "map": {
|
|
2788
|
+
const map = context.putObject(objectId, key, {});
|
|
2789
|
+
const proxyMap = mapProxy(context, map, [...path, key]);
|
|
2790
|
+
for (const key2 in value) {
|
|
2791
|
+
proxyMap[key2] = value[key2];
|
|
2792
|
+
}
|
|
2793
|
+
break;
|
|
2794
|
+
}
|
|
2795
|
+
default:
|
|
2796
|
+
context.put(objectId, key, value, datatype);
|
|
2797
|
+
}
|
|
2798
|
+
return true;
|
|
2799
|
+
},
|
|
2800
|
+
deleteProperty(target, key) {
|
|
2801
|
+
const { context, objectId } = target;
|
|
2802
|
+
target.cache = {};
|
|
2803
|
+
context.delete(objectId, key);
|
|
2804
|
+
return true;
|
|
2805
|
+
},
|
|
2806
|
+
has(target, key) {
|
|
2807
|
+
const value = this.get(target, key);
|
|
2808
|
+
return value !== undefined;
|
|
2809
|
+
},
|
|
2810
|
+
getOwnPropertyDescriptor(target, key) {
|
|
2811
|
+
const value = this.get(target, key);
|
|
2812
|
+
if (typeof value !== "undefined") {
|
|
2813
|
+
return {
|
|
2814
|
+
configurable: true,
|
|
2815
|
+
enumerable: true,
|
|
2816
|
+
value
|
|
2817
|
+
};
|
|
2818
|
+
}
|
|
2819
|
+
},
|
|
2820
|
+
ownKeys(target) {
|
|
2821
|
+
const { context, objectId } = target;
|
|
2822
|
+
const keys = context.keys(objectId);
|
|
2823
|
+
return [...new Set(keys)];
|
|
2824
|
+
}
|
|
2825
|
+
};
|
|
2826
|
+
ListHandler = {
|
|
2827
|
+
get(target, index) {
|
|
2828
|
+
const { context, objectId } = target;
|
|
2829
|
+
index = parseListIndex(index);
|
|
2830
|
+
if (index === Symbol.hasInstance) {
|
|
2831
|
+
return (instance) => {
|
|
2832
|
+
return Array.isArray(instance);
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
if (index === Symbol.toStringTag) {
|
|
2836
|
+
return target[Symbol.toStringTag];
|
|
2837
|
+
}
|
|
2838
|
+
if (index === OBJECT_ID)
|
|
2839
|
+
return objectId;
|
|
2840
|
+
if (index === IS_PROXY)
|
|
2841
|
+
return true;
|
|
2842
|
+
if (index === TRACE)
|
|
2843
|
+
return target.trace;
|
|
2844
|
+
if (index === STATE)
|
|
2845
|
+
return { handle: context };
|
|
2846
|
+
if (index === "length")
|
|
2847
|
+
return context.length(objectId);
|
|
2848
|
+
if (typeof index === "number") {
|
|
2849
|
+
return valueAt(target, index);
|
|
2850
|
+
} else {
|
|
2851
|
+
return listMethods(target)[index];
|
|
2852
|
+
}
|
|
2853
|
+
},
|
|
2854
|
+
set(target, index, val) {
|
|
2855
|
+
const { context, objectId, path } = target;
|
|
2856
|
+
index = parseListIndex(index);
|
|
2857
|
+
if (isSameDocument(val, context)) {
|
|
2858
|
+
throw new RangeError("Cannot create a reference to an existing document object");
|
|
2859
|
+
}
|
|
2860
|
+
if (index === CLEAR_CACHE) {
|
|
2861
|
+
return true;
|
|
2862
|
+
}
|
|
2863
|
+
if (index === TRACE) {
|
|
2864
|
+
target.trace = val;
|
|
2865
|
+
return true;
|
|
2866
|
+
}
|
|
2867
|
+
if (typeof index == "string") {
|
|
2868
|
+
throw new RangeError("list index must be a number");
|
|
2869
|
+
}
|
|
2870
|
+
const [value, datatype] = import_value(val, [...path, index], context);
|
|
2871
|
+
switch (datatype) {
|
|
2872
|
+
case "list": {
|
|
2873
|
+
let list;
|
|
2874
|
+
if (index >= context.length(objectId)) {
|
|
2875
|
+
list = context.insertObject(objectId, index, []);
|
|
2876
|
+
} else {
|
|
2877
|
+
list = context.putObject(objectId, index, []);
|
|
2878
|
+
}
|
|
2879
|
+
const proxyList = listProxy(context, list, [...path, index]);
|
|
2880
|
+
proxyList.splice(0, 0, ...value);
|
|
2881
|
+
break;
|
|
2882
|
+
}
|
|
2883
|
+
case "text": {
|
|
2884
|
+
if (index >= context.length(objectId)) {
|
|
2885
|
+
context.insertObject(objectId, index, value);
|
|
2886
|
+
} else {
|
|
2887
|
+
context.putObject(objectId, index, value);
|
|
2888
|
+
}
|
|
2889
|
+
break;
|
|
2890
|
+
}
|
|
2891
|
+
case "map": {
|
|
2892
|
+
let map;
|
|
2893
|
+
if (index >= context.length(objectId)) {
|
|
2894
|
+
map = context.insertObject(objectId, index, {});
|
|
2895
|
+
} else {
|
|
2896
|
+
map = context.putObject(objectId, index, {});
|
|
2897
|
+
}
|
|
2898
|
+
const proxyMap = mapProxy(context, map, [...path, index]);
|
|
2899
|
+
for (const key in value) {
|
|
2900
|
+
proxyMap[key] = value[key];
|
|
2901
|
+
}
|
|
2902
|
+
break;
|
|
2903
|
+
}
|
|
2904
|
+
default:
|
|
2905
|
+
if (index >= context.length(objectId)) {
|
|
2906
|
+
context.insert(objectId, index, value, datatype);
|
|
2907
|
+
} else {
|
|
2908
|
+
context.put(objectId, index, value, datatype);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
return true;
|
|
2912
|
+
},
|
|
2913
|
+
deleteProperty(target, index) {
|
|
2914
|
+
const { context, objectId } = target;
|
|
2915
|
+
index = parseListIndex(index);
|
|
2916
|
+
const elem = context.get(objectId, index);
|
|
2917
|
+
if (elem != null && elem[0] == "counter") {
|
|
2918
|
+
throw new TypeError("Unsupported operation: deleting a counter from a list");
|
|
2919
|
+
}
|
|
2920
|
+
context.delete(objectId, index);
|
|
2921
|
+
return true;
|
|
2922
|
+
},
|
|
2923
|
+
has(target, index) {
|
|
2924
|
+
const { context, objectId } = target;
|
|
2925
|
+
index = parseListIndex(index);
|
|
2926
|
+
if (typeof index === "number") {
|
|
2927
|
+
return index < context.length(objectId);
|
|
2928
|
+
}
|
|
2929
|
+
return index === "length";
|
|
2930
|
+
},
|
|
2931
|
+
getOwnPropertyDescriptor(target, index) {
|
|
2932
|
+
const { context, objectId } = target;
|
|
2933
|
+
if (index === "length")
|
|
2934
|
+
return { writable: true, value: context.length(objectId) };
|
|
2935
|
+
if (index === OBJECT_ID)
|
|
2936
|
+
return { configurable: false, enumerable: false, value: objectId };
|
|
2937
|
+
index = parseListIndex(index);
|
|
2938
|
+
const value = valueAt(target, index);
|
|
2939
|
+
return { configurable: true, enumerable: true, value };
|
|
2940
|
+
},
|
|
2941
|
+
getPrototypeOf(target) {
|
|
2942
|
+
return Object.getPrototypeOf(target);
|
|
2943
|
+
},
|
|
2944
|
+
ownKeys() {
|
|
2945
|
+
const keys = [];
|
|
2946
|
+
keys.push("length");
|
|
2947
|
+
return keys;
|
|
2948
|
+
}
|
|
2949
|
+
};
|
|
2950
|
+
});
|
|
2951
|
+
|
|
2952
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/numbers.js
|
|
2953
|
+
class Int {
|
|
2954
|
+
constructor(value) {
|
|
2955
|
+
if (!(Number.isInteger(value) && value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER)) {
|
|
2956
|
+
throw new RangeError(`Value ${value} cannot be a uint`);
|
|
2957
|
+
}
|
|
2958
|
+
this.value = value;
|
|
2959
|
+
Reflect.defineProperty(this, INT, { value: true });
|
|
2960
|
+
Object.freeze(this);
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
|
|
2964
|
+
class Uint {
|
|
2965
|
+
constructor(value) {
|
|
2966
|
+
if (!(Number.isInteger(value) && value <= Number.MAX_SAFE_INTEGER && value >= 0)) {
|
|
2967
|
+
throw new RangeError(`Value ${value} cannot be a uint`);
|
|
2968
|
+
}
|
|
2969
|
+
this.value = value;
|
|
2970
|
+
Reflect.defineProperty(this, UINT, { value: true });
|
|
2971
|
+
Object.freeze(this);
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
class Float64 {
|
|
2976
|
+
constructor(value) {
|
|
2977
|
+
if (typeof value !== "number") {
|
|
2978
|
+
throw new RangeError(`Value ${value} cannot be a float64`);
|
|
2979
|
+
}
|
|
2980
|
+
this.value = value || 0;
|
|
2981
|
+
Reflect.defineProperty(this, F64, { value: true });
|
|
2982
|
+
Object.freeze(this);
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
var init_numbers = __esm(() => {
|
|
2986
|
+
init_constants();
|
|
2987
|
+
});
|
|
2988
|
+
|
|
2989
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/types.js
|
|
2990
|
+
var init_types = __esm(() => {
|
|
2991
|
+
init_counter();
|
|
2992
|
+
init_numbers();
|
|
2993
|
+
init_immutable_string();
|
|
2994
|
+
});
|
|
2995
|
+
|
|
2996
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/generated/release-info.js
|
|
2997
|
+
var JS_GIT_HEAD = "b8dfc4845c50633f9d850a5d4e2a4219d518f8ad";
|
|
2998
|
+
|
|
2999
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/internal_state.js
|
|
3000
|
+
function _state(doc, checkroot = true) {
|
|
3001
|
+
if (typeof doc !== "object") {
|
|
3002
|
+
throw new RangeError("must be the document root");
|
|
3003
|
+
}
|
|
3004
|
+
const state = Reflect.get(doc, STATE);
|
|
3005
|
+
if (state === undefined || state == null || checkroot && _obj(doc) !== "_root") {
|
|
3006
|
+
throw new RangeError("must be the document root");
|
|
3007
|
+
}
|
|
3008
|
+
return state;
|
|
3009
|
+
}
|
|
3010
|
+
function _clear_cache(doc) {
|
|
3011
|
+
Reflect.set(doc, CLEAR_CACHE, true);
|
|
3012
|
+
}
|
|
3013
|
+
function _trace(doc) {
|
|
3014
|
+
return Reflect.get(doc, TRACE);
|
|
3015
|
+
}
|
|
3016
|
+
function _obj(doc) {
|
|
3017
|
+
if (!(typeof doc === "object") || doc === null) {
|
|
3018
|
+
return null;
|
|
3019
|
+
}
|
|
3020
|
+
return Reflect.get(doc, OBJECT_ID);
|
|
3021
|
+
}
|
|
3022
|
+
function _is_proxy(doc) {
|
|
3023
|
+
return !!Reflect.get(doc, IS_PROXY);
|
|
3024
|
+
}
|
|
3025
|
+
var init_internal_state = __esm(() => {
|
|
3026
|
+
init_constants();
|
|
3027
|
+
});
|
|
3028
|
+
|
|
3029
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/apply_patches.js
|
|
3030
|
+
function applyPatch(doc, patch) {
|
|
3031
|
+
let path = resolvePath(doc, patch.path);
|
|
3032
|
+
if (patch.action === "put") {
|
|
3033
|
+
applyPutPatch(doc, path, patch);
|
|
3034
|
+
} else if (patch.action === "insert") {
|
|
3035
|
+
applyInsertPatch(doc, path, patch);
|
|
3036
|
+
} else if (patch.action === "del") {
|
|
3037
|
+
applyDelPatch(doc, path, patch);
|
|
3038
|
+
} else if (patch.action === "splice") {
|
|
3039
|
+
applySplicePatch(doc, path, patch);
|
|
3040
|
+
} else if (patch.action === "inc") {
|
|
3041
|
+
applyIncPatch(doc, path, patch);
|
|
3042
|
+
} else if (patch.action === "mark") {
|
|
3043
|
+
applyMarkPatch(doc, path, patch);
|
|
3044
|
+
} else if (patch.action === "unmark") {
|
|
3045
|
+
applyUnmarkPatch(doc, path, patch);
|
|
3046
|
+
} else if (patch.action === "conflict") {} else {
|
|
3047
|
+
throw new RangeError(`unsupported patch: ${patch}`);
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
function applyPutPatch(doc, path, patch) {
|
|
3051
|
+
let { obj: parent, prop } = pathElemAt(path, -1);
|
|
3052
|
+
parent[prop] = patch.value;
|
|
3053
|
+
}
|
|
3054
|
+
function applyInsertPatch(doc, path, patch) {
|
|
3055
|
+
let { obj: parent, prop } = pathElemAt(path, -1);
|
|
3056
|
+
if (!Array.isArray(parent)) {
|
|
3057
|
+
throw new RangeError(`target is not an array for patch`);
|
|
3058
|
+
}
|
|
3059
|
+
if (!(typeof prop === "number")) {
|
|
3060
|
+
throw new RangeError(`index is not a number for patch`);
|
|
3061
|
+
}
|
|
3062
|
+
parent.splice(prop, 0, ...patch.values);
|
|
3063
|
+
}
|
|
3064
|
+
function applyDelPatch(doc, path, patch) {
|
|
3065
|
+
let { obj: parent, prop, parentPath } = pathElemAt(path, -1);
|
|
3066
|
+
if (!(typeof prop === "number")) {
|
|
3067
|
+
throw new RangeError(`index is not a number for patch`);
|
|
3068
|
+
}
|
|
3069
|
+
if (Array.isArray(parent)) {
|
|
3070
|
+
parent.splice(prop, patch.length || 1);
|
|
3071
|
+
} else if (typeof parent === "string") {
|
|
3072
|
+
if (isAutomerge(doc)) {
|
|
3073
|
+
splice(doc, parentPath, prop, patch.length || 1);
|
|
3074
|
+
} else {
|
|
3075
|
+
let { obj: grandParent, prop: grandParentProp } = pathElemAt(path, -2);
|
|
3076
|
+
if (typeof prop !== "number") {
|
|
3077
|
+
throw new RangeError(`index is not a number for patch`);
|
|
3078
|
+
}
|
|
3079
|
+
let target = grandParent[grandParentProp];
|
|
3080
|
+
if (target == null || typeof target !== "string") {
|
|
3081
|
+
throw new RangeError(`target is not a string for patch`);
|
|
3082
|
+
}
|
|
3083
|
+
let newString = target.slice(0, prop) + target.slice(prop + (patch.length || 1));
|
|
3084
|
+
grandParent[grandParentProp] = newString;
|
|
3085
|
+
}
|
|
3086
|
+
} else {
|
|
3087
|
+
throw new RangeError(`target is not an array or string for patch`);
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
function applySplicePatch(doc, path, patch) {
|
|
3091
|
+
if (isAutomerge(doc)) {
|
|
3092
|
+
let { obj: parent, prop, parentPath } = pathElemAt(path, -1);
|
|
3093
|
+
if (!(typeof prop === "number")) {
|
|
3094
|
+
throw new RangeError(`index is not a number for patch`);
|
|
3095
|
+
}
|
|
3096
|
+
splice(doc, parentPath, prop, 0, patch.value);
|
|
3097
|
+
} else {
|
|
3098
|
+
let { obj: parent, prop } = pathElemAt(path, -1);
|
|
3099
|
+
let { obj: grandParent, prop: grandParentProp } = pathElemAt(path, -2);
|
|
3100
|
+
if (typeof prop !== "number") {
|
|
3101
|
+
throw new RangeError(`index is not a number for patch`);
|
|
3102
|
+
}
|
|
3103
|
+
let target = grandParent[grandParentProp];
|
|
3104
|
+
if (target == null || typeof target !== "string") {
|
|
3105
|
+
throw new RangeError(`target is not a string for patch`);
|
|
3106
|
+
}
|
|
3107
|
+
let newString = target.slice(0, prop) + patch.value + target.slice(prop);
|
|
3108
|
+
grandParent[grandParentProp] = newString;
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
function applyIncPatch(doc, path, patch) {
|
|
3112
|
+
let { obj: parent, prop } = pathElemAt(path, -1);
|
|
3113
|
+
const counter = parent[prop];
|
|
3114
|
+
if (isAutomerge(doc)) {
|
|
3115
|
+
if (!isCounter(counter)) {
|
|
3116
|
+
throw new RangeError(`target is not a counter for patch`);
|
|
3117
|
+
}
|
|
3118
|
+
counter.increment(patch.value);
|
|
3119
|
+
} else {
|
|
3120
|
+
if (!(typeof counter === "number")) {
|
|
3121
|
+
throw new RangeError(`target is not a number for patch`);
|
|
3122
|
+
}
|
|
3123
|
+
parent[prop] = counter + patch.value;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
function applyMarkPatch(doc, path, patch) {
|
|
3127
|
+
let { obj: parent, prop } = pathElemAt(path, -1);
|
|
3128
|
+
if (!isAutomerge(doc)) {
|
|
3129
|
+
return;
|
|
3130
|
+
}
|
|
3131
|
+
for (const markSpec of patch.marks) {
|
|
3132
|
+
mark(doc, patch.path, { start: markSpec.start, end: markSpec.end, expand: "none" }, markSpec.name, markSpec.value);
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
function applyUnmarkPatch(doc, path, patch) {
|
|
3136
|
+
if (!isAutomerge(doc)) {
|
|
3137
|
+
return;
|
|
3138
|
+
}
|
|
3139
|
+
unmark(doc, patch.path, { start: patch.start, end: patch.end, expand: "none" }, patch.name);
|
|
3140
|
+
}
|
|
3141
|
+
function applyPatches(doc, patches) {
|
|
3142
|
+
for (const patch of patches) {
|
|
3143
|
+
applyPatch(doc, patch);
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
function resolvePath(doc, path) {
|
|
3147
|
+
const result = [];
|
|
3148
|
+
let current = doc;
|
|
3149
|
+
let currentPath = [];
|
|
3150
|
+
for (const [index, prop] of path.entries()) {
|
|
3151
|
+
result.push({ obj: current, prop, parentPath: currentPath.slice() });
|
|
3152
|
+
currentPath.push(prop);
|
|
3153
|
+
if (index !== path.length - 1) {
|
|
3154
|
+
if (current == null || typeof current != "object") {
|
|
3155
|
+
throw new Error(`Invalid path: ${path}`);
|
|
3156
|
+
}
|
|
3157
|
+
current = current[prop];
|
|
3158
|
+
} else {
|
|
3159
|
+
break;
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
return result;
|
|
3163
|
+
}
|
|
3164
|
+
function pathElemAt(resolved, index) {
|
|
3165
|
+
let result = resolved.at(index);
|
|
3166
|
+
if (result == undefined) {
|
|
3167
|
+
throw new Error("invalid path");
|
|
3168
|
+
}
|
|
3169
|
+
return result;
|
|
3170
|
+
}
|
|
3171
|
+
var init_apply_patches = __esm(() => {
|
|
3172
|
+
init_implementation();
|
|
3173
|
+
});
|
|
3174
|
+
|
|
3175
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/conflicts.js
|
|
3176
|
+
function conflictAt(context, objectId, prop, withinChangeCallback) {
|
|
3177
|
+
const values = context.getAll(objectId, prop);
|
|
3178
|
+
if (values.length <= 1) {
|
|
3179
|
+
return;
|
|
3180
|
+
}
|
|
3181
|
+
const result = {};
|
|
3182
|
+
for (const fullVal of values) {
|
|
3183
|
+
switch (fullVal[0]) {
|
|
3184
|
+
case "map":
|
|
3185
|
+
if (withinChangeCallback) {
|
|
3186
|
+
result[fullVal[1]] = mapProxy(context, fullVal[1], [prop]);
|
|
3187
|
+
} else {
|
|
3188
|
+
result[fullVal[1]] = reifyFullValue(context, [fullVal[0], fullVal[1]]);
|
|
3189
|
+
}
|
|
3190
|
+
break;
|
|
3191
|
+
case "list":
|
|
3192
|
+
if (withinChangeCallback) {
|
|
3193
|
+
result[fullVal[1]] = listProxy(context, fullVal[1], [prop]);
|
|
3194
|
+
} else {
|
|
3195
|
+
result[fullVal[1]] = reifyFullValue(context, [fullVal[0], fullVal[1]]);
|
|
3196
|
+
}
|
|
3197
|
+
break;
|
|
3198
|
+
case "text":
|
|
3199
|
+
result[fullVal[1]] = context.text(fullVal[1]);
|
|
3200
|
+
break;
|
|
3201
|
+
case "str":
|
|
3202
|
+
case "uint":
|
|
3203
|
+
case "int":
|
|
3204
|
+
case "f64":
|
|
3205
|
+
case "boolean":
|
|
3206
|
+
case "bytes":
|
|
3207
|
+
case "null":
|
|
3208
|
+
result[fullVal[2]] = fullVal[1];
|
|
3209
|
+
break;
|
|
3210
|
+
case "counter":
|
|
3211
|
+
result[fullVal[2]] = new Counter(fullVal[1]);
|
|
3212
|
+
break;
|
|
3213
|
+
case "timestamp":
|
|
3214
|
+
result[fullVal[2]] = new Date(fullVal[1]);
|
|
3215
|
+
break;
|
|
3216
|
+
default:
|
|
3217
|
+
throw RangeError(`datatype ${fullVal[0]} unimplemented`);
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
return result;
|
|
3221
|
+
}
|
|
3222
|
+
function reifyFullValue(context, fullValue) {
|
|
3223
|
+
switch (fullValue[0]) {
|
|
3224
|
+
case "map":
|
|
3225
|
+
const mapResult = {};
|
|
3226
|
+
for (const key of context.keys(fullValue[1])) {
|
|
3227
|
+
let subVal = context.getWithType(fullValue[1], key);
|
|
3228
|
+
if (!subVal) {
|
|
3229
|
+
throw new Error("unexpected null map value");
|
|
3230
|
+
}
|
|
3231
|
+
mapResult[key] = reifyFullValue(context, subVal);
|
|
3232
|
+
}
|
|
3233
|
+
return Object.freeze(mapResult);
|
|
3234
|
+
case "list":
|
|
3235
|
+
const listResult = [];
|
|
3236
|
+
const length = context.length(fullValue[1]);
|
|
3237
|
+
for (let i = 0;i < length; i++) {
|
|
3238
|
+
let subVal = context.getWithType(fullValue[1], i);
|
|
3239
|
+
if (!subVal) {
|
|
3240
|
+
throw new Error("unexpected null list element");
|
|
3241
|
+
}
|
|
3242
|
+
listResult.push(reifyFullValue(context, subVal));
|
|
3243
|
+
}
|
|
3244
|
+
return Object.freeze(listResult);
|
|
3245
|
+
case "text":
|
|
3246
|
+
return context.text(fullValue[1]);
|
|
3247
|
+
case "str":
|
|
3248
|
+
case "uint":
|
|
3249
|
+
case "int":
|
|
3250
|
+
case "f64":
|
|
3251
|
+
case "boolean":
|
|
3252
|
+
case "bytes":
|
|
3253
|
+
case "null":
|
|
3254
|
+
return fullValue[1];
|
|
3255
|
+
case "counter":
|
|
3256
|
+
return new Counter(fullValue[1]);
|
|
3257
|
+
case "timestamp":
|
|
3258
|
+
return new Date(fullValue[1]);
|
|
3259
|
+
default:
|
|
3260
|
+
throw RangeError(`datatype ${fullValue[0]} unimplemented`);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
var init_conflicts = __esm(() => {
|
|
3264
|
+
init_types();
|
|
3265
|
+
init_proxies();
|
|
3266
|
+
});
|
|
3267
|
+
|
|
3268
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/implementation.js
|
|
3269
|
+
var exports_implementation = {};
|
|
3270
|
+
__export(exports_implementation, {
|
|
3271
|
+
wasmInitialized: () => wasmInitialized,
|
|
3272
|
+
view: () => view,
|
|
3273
|
+
use: () => use,
|
|
3274
|
+
updateText: () => updateText,
|
|
3275
|
+
updateSpans: () => updateSpans,
|
|
3276
|
+
updateBlock: () => updateBlock,
|
|
3277
|
+
unmark: () => unmark,
|
|
3278
|
+
topoHistoryTraversal: () => topoHistoryTraversal,
|
|
3279
|
+
toJS: () => toJS,
|
|
3280
|
+
stats: () => stats,
|
|
3281
|
+
splitBlock: () => splitBlock,
|
|
3282
|
+
splice: () => splice,
|
|
3283
|
+
spans: () => spans,
|
|
3284
|
+
saveSince: () => saveSince,
|
|
3285
|
+
saveIncremental: () => saveIncremental,
|
|
3286
|
+
saveBundle: () => saveBundle,
|
|
3287
|
+
save: () => save,
|
|
3288
|
+
releaseInfo: () => releaseInfo,
|
|
3289
|
+
receiveSyncMessage: () => receiveSyncMessage,
|
|
3290
|
+
readBundle: () => readBundle3,
|
|
3291
|
+
merge: () => merge,
|
|
3292
|
+
marksAt: () => marksAt,
|
|
3293
|
+
marks: () => marks,
|
|
3294
|
+
mark: () => mark,
|
|
3295
|
+
loadIncremental: () => loadIncremental,
|
|
3296
|
+
load: () => load3,
|
|
3297
|
+
joinBlock: () => joinBlock,
|
|
3298
|
+
isWasmInitialized: () => isWasmInitialized,
|
|
3299
|
+
isRawString: () => isRawString,
|
|
3300
|
+
isImmutableString: () => isImmutableString,
|
|
3301
|
+
isCounter: () => isCounter,
|
|
3302
|
+
isAutomerge: () => isAutomerge,
|
|
3303
|
+
inspectChange: () => inspectChange,
|
|
3304
|
+
insertAt: () => insertAt,
|
|
3305
|
+
initializeWasm: () => initializeWasm,
|
|
3306
|
+
initializeBase64Wasm: () => initializeBase64Wasm,
|
|
3307
|
+
initSyncState: () => initSyncState3,
|
|
3308
|
+
init: () => init,
|
|
3309
|
+
hasOurChanges: () => hasOurChanges,
|
|
3310
|
+
hasHeads: () => hasHeads,
|
|
3311
|
+
getObjectId: () => getObjectId,
|
|
3312
|
+
getMissingDeps: () => getMissingDeps,
|
|
3313
|
+
getLastLocalChange: () => getLastLocalChange,
|
|
3314
|
+
getHistory: () => getHistory,
|
|
3315
|
+
getHeads: () => getHeads,
|
|
3316
|
+
getCursorPosition: () => getCursorPosition,
|
|
3317
|
+
getCursor: () => getCursor,
|
|
3318
|
+
getConflicts: () => getConflicts,
|
|
3319
|
+
getChangesSince: () => getChangesSince,
|
|
3320
|
+
getChangesMetaSince: () => getChangesMetaSince,
|
|
3321
|
+
getChanges: () => getChanges,
|
|
3322
|
+
getBackend: () => getBackend,
|
|
3323
|
+
getAllChanges: () => getAllChanges,
|
|
3324
|
+
getActorId: () => getActorId,
|
|
3325
|
+
generateSyncMessage: () => generateSyncMessage,
|
|
3326
|
+
from: () => from,
|
|
3327
|
+
free: () => free,
|
|
3328
|
+
equals: () => equals,
|
|
3329
|
+
encodeSyncState: () => encodeSyncState3,
|
|
3330
|
+
encodeSyncMessage: () => encodeSyncMessage3,
|
|
3331
|
+
encodeChange: () => encodeChange3,
|
|
3332
|
+
emptyChange: () => emptyChange,
|
|
3333
|
+
dump: () => dump,
|
|
3334
|
+
diffPath: () => diffPath,
|
|
3335
|
+
diff: () => diff,
|
|
3336
|
+
deleteAt: () => deleteAt,
|
|
3337
|
+
decodeSyncState: () => decodeSyncState3,
|
|
3338
|
+
decodeSyncMessage: () => decodeSyncMessage3,
|
|
3339
|
+
decodeChange: () => decodeChange3,
|
|
3340
|
+
clone: () => clone,
|
|
3341
|
+
changeAt: () => changeAt,
|
|
3342
|
+
change: () => change,
|
|
3343
|
+
block: () => block,
|
|
3344
|
+
applyPatches: () => applyPatches,
|
|
3345
|
+
applyPatch: () => applyPatch,
|
|
3346
|
+
applyChanges: () => applyChanges,
|
|
3347
|
+
Uint: () => Uint,
|
|
3348
|
+
RawString: () => RawString,
|
|
3349
|
+
Int: () => Int,
|
|
3350
|
+
ImmutableString: () => ImmutableString,
|
|
3351
|
+
Float64: () => Float64,
|
|
3352
|
+
Counter: () => Counter
|
|
3353
|
+
});
|
|
3354
|
+
function insertAt(list, index, ...values) {
|
|
3355
|
+
if (!_is_proxy(list)) {
|
|
3356
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
3357
|
+
}
|
|
3358
|
+
list.insertAt(index, ...values);
|
|
3359
|
+
}
|
|
3360
|
+
function deleteAt(list, index, numDelete) {
|
|
3361
|
+
if (!_is_proxy(list)) {
|
|
3362
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
3363
|
+
}
|
|
3364
|
+
list.deleteAt(index, numDelete);
|
|
3365
|
+
}
|
|
3366
|
+
function use(api) {
|
|
3367
|
+
UseApi(api);
|
|
3368
|
+
}
|
|
3369
|
+
function getBackend(doc) {
|
|
3370
|
+
return _state(doc).handle;
|
|
3371
|
+
}
|
|
3372
|
+
function importOpts(_actor) {
|
|
3373
|
+
if (typeof _actor === "object") {
|
|
3374
|
+
return _actor;
|
|
3375
|
+
} else {
|
|
3376
|
+
return { actor: _actor };
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
function getChangesSince(state, heads) {
|
|
3380
|
+
const n = _state(state);
|
|
3381
|
+
return n.handle.getChanges(heads);
|
|
3382
|
+
}
|
|
3383
|
+
function getChangesMetaSince(state, heads) {
|
|
3384
|
+
const n = _state(state);
|
|
3385
|
+
return n.handle.getChangesMeta(heads);
|
|
3386
|
+
}
|
|
3387
|
+
function cursorToIndex(state, value, index) {
|
|
3388
|
+
if (typeof index == "string") {
|
|
3389
|
+
if (/^-?[0-9]+@[0-9a-zA-Z]+$|^[se]$/.test(index)) {
|
|
3390
|
+
return state.handle.getCursorPosition(value, index);
|
|
3391
|
+
} else {
|
|
3392
|
+
throw new RangeError("index must be a number or cursor");
|
|
3393
|
+
}
|
|
3394
|
+
} else {
|
|
3395
|
+
return index;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
function init(_opts) {
|
|
3399
|
+
const opts = importOpts(_opts);
|
|
3400
|
+
const freeze = !!opts.freeze;
|
|
3401
|
+
const patchCallback = opts.patchCallback;
|
|
3402
|
+
const actor = opts.actor;
|
|
3403
|
+
const handle = ApiHandler.create({ actor });
|
|
3404
|
+
handle.enableFreeze(!!opts.freeze);
|
|
3405
|
+
registerDatatypes(handle);
|
|
3406
|
+
const doc = handle.materialize("/", undefined, {
|
|
3407
|
+
handle,
|
|
3408
|
+
heads: undefined,
|
|
3409
|
+
freeze,
|
|
3410
|
+
patchCallback
|
|
3411
|
+
});
|
|
3412
|
+
return doc;
|
|
3413
|
+
}
|
|
3414
|
+
function view(doc, heads) {
|
|
3415
|
+
const state = _state(doc);
|
|
3416
|
+
const handle = state.handle;
|
|
3417
|
+
return state.handle.materialize("/", heads, Object.assign(Object.assign({}, state), {
|
|
3418
|
+
handle,
|
|
3419
|
+
heads
|
|
3420
|
+
}));
|
|
3421
|
+
}
|
|
3422
|
+
function clone(doc, _opts) {
|
|
3423
|
+
const state = _state(doc);
|
|
3424
|
+
const heads = state.heads;
|
|
3425
|
+
const opts = importOpts(_opts);
|
|
3426
|
+
const handle = state.handle.fork(opts.actor, heads);
|
|
3427
|
+
handle.updateDiffCursor();
|
|
3428
|
+
const { heads: _oldHeads } = state, stateSansHeads = __rest(state, ["heads"]);
|
|
3429
|
+
stateSansHeads.patchCallback = opts.patchCallback;
|
|
3430
|
+
return handle.applyPatches(doc, Object.assign(Object.assign({}, stateSansHeads), { handle }));
|
|
3431
|
+
}
|
|
3432
|
+
function free(doc) {
|
|
3433
|
+
return _state(doc).handle.free();
|
|
3434
|
+
}
|
|
3435
|
+
function from(initialState, _opts) {
|
|
3436
|
+
return _change(init(_opts), "from", {}, (d) => Object.assign(d, initialState)).newDoc;
|
|
3437
|
+
}
|
|
3438
|
+
function change(doc, options, callback) {
|
|
3439
|
+
if (typeof options === "function") {
|
|
3440
|
+
return _change(doc, "change", {}, options).newDoc;
|
|
3441
|
+
} else if (typeof callback === "function") {
|
|
3442
|
+
if (typeof options === "string") {
|
|
3443
|
+
options = { message: options };
|
|
3444
|
+
}
|
|
3445
|
+
return _change(doc, "change", options, callback).newDoc;
|
|
3446
|
+
} else {
|
|
3447
|
+
throw RangeError("Invalid args for change");
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
function changeAt(doc, scope, options, callback) {
|
|
3451
|
+
if (typeof options === "function") {
|
|
3452
|
+
return _change(doc, "changeAt", {}, options, scope);
|
|
3453
|
+
} else if (typeof callback === "function") {
|
|
3454
|
+
if (typeof options === "string") {
|
|
3455
|
+
options = { message: options };
|
|
3456
|
+
}
|
|
3457
|
+
return _change(doc, "changeAt", options, callback, scope);
|
|
3458
|
+
} else {
|
|
3459
|
+
throw RangeError("Invalid args for changeAt");
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
function progressDocument(doc, source, heads, callback) {
|
|
3463
|
+
if (heads == null) {
|
|
3464
|
+
return doc;
|
|
3465
|
+
}
|
|
3466
|
+
const state = _state(doc);
|
|
3467
|
+
const nextState = Object.assign(Object.assign({}, state), { heads: undefined });
|
|
3468
|
+
const { value: nextDoc, patches } = state.handle.applyAndReturnPatches(doc, nextState);
|
|
3469
|
+
if (patches.length > 0) {
|
|
3470
|
+
if (callback != null) {
|
|
3471
|
+
callback(patches, { before: doc, after: nextDoc, source });
|
|
3472
|
+
}
|
|
3473
|
+
const newState = _state(nextDoc);
|
|
3474
|
+
newState.mostRecentPatch = {
|
|
3475
|
+
before: _state(doc).heads,
|
|
3476
|
+
after: newState.handle.getHeads(),
|
|
3477
|
+
patches
|
|
3478
|
+
};
|
|
3479
|
+
}
|
|
3480
|
+
state.heads = heads;
|
|
3481
|
+
return nextDoc;
|
|
3482
|
+
}
|
|
3483
|
+
function _change(doc, source, options, callback, scope) {
|
|
3484
|
+
if (typeof callback !== "function") {
|
|
3485
|
+
throw new RangeError("invalid change function");
|
|
3486
|
+
}
|
|
3487
|
+
const state = _state(doc);
|
|
3488
|
+
if (doc === undefined || state === undefined) {
|
|
3489
|
+
throw new RangeError("must be the document root");
|
|
3490
|
+
}
|
|
3491
|
+
if (state.heads) {
|
|
3492
|
+
throw new RangeError("Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.");
|
|
3493
|
+
}
|
|
3494
|
+
if (_is_proxy(doc)) {
|
|
3495
|
+
throw new RangeError("Calls to Automerge.change cannot be nested");
|
|
3496
|
+
}
|
|
3497
|
+
let heads = state.handle.getHeads();
|
|
3498
|
+
if (scope && headsEqual(scope, heads)) {
|
|
3499
|
+
scope = undefined;
|
|
3500
|
+
}
|
|
3501
|
+
if (scope) {
|
|
3502
|
+
state.handle.isolate(scope);
|
|
3503
|
+
heads = scope;
|
|
3504
|
+
}
|
|
3505
|
+
if (!("time" in options)) {
|
|
3506
|
+
options.time = Math.floor(Date.now() / 1000);
|
|
3507
|
+
}
|
|
3508
|
+
try {
|
|
3509
|
+
state.heads = heads;
|
|
3510
|
+
const root = rootProxy(state.handle);
|
|
3511
|
+
callback(root);
|
|
3512
|
+
if (state.handle.pendingOps() === 0) {
|
|
3513
|
+
state.heads = undefined;
|
|
3514
|
+
if (scope) {
|
|
3515
|
+
state.handle.integrate();
|
|
3516
|
+
}
|
|
3517
|
+
return {
|
|
3518
|
+
newDoc: doc,
|
|
3519
|
+
newHeads: null
|
|
3520
|
+
};
|
|
3521
|
+
} else {
|
|
3522
|
+
const newHead = state.handle.commit(options.message, options.time);
|
|
3523
|
+
state.handle.integrate();
|
|
3524
|
+
return {
|
|
3525
|
+
newDoc: progressDocument(doc, source, heads, options.patchCallback || state.patchCallback),
|
|
3526
|
+
newHeads: newHead != null ? [newHead] : null
|
|
3527
|
+
};
|
|
3528
|
+
}
|
|
3529
|
+
} catch (e) {
|
|
3530
|
+
state.heads = undefined;
|
|
3531
|
+
state.handle.rollback();
|
|
3532
|
+
throw e;
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
function emptyChange(doc, options) {
|
|
3536
|
+
if (options === undefined) {
|
|
3537
|
+
options = {};
|
|
3538
|
+
}
|
|
3539
|
+
if (typeof options === "string") {
|
|
3540
|
+
options = { message: options };
|
|
3541
|
+
}
|
|
3542
|
+
if (!("time" in options)) {
|
|
3543
|
+
options.time = Math.floor(Date.now() / 1000);
|
|
3544
|
+
}
|
|
3545
|
+
const state = _state(doc);
|
|
3546
|
+
if (state.heads) {
|
|
3547
|
+
throw new RangeError("Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.");
|
|
3548
|
+
}
|
|
3549
|
+
if (_is_proxy(doc)) {
|
|
3550
|
+
throw new RangeError("Calls to Automerge.change cannot be nested");
|
|
3551
|
+
}
|
|
3552
|
+
const heads = state.handle.getHeads();
|
|
3553
|
+
state.handle.emptyChange(options.message, options.time);
|
|
3554
|
+
return progressDocument(doc, "emptyChange", heads);
|
|
3555
|
+
}
|
|
3556
|
+
function load3(data, _opts) {
|
|
3557
|
+
const opts = importOpts(_opts);
|
|
3558
|
+
if (opts.patchCallback) {
|
|
3559
|
+
return loadIncremental(init(opts), data);
|
|
3560
|
+
}
|
|
3561
|
+
const actor = opts.actor;
|
|
3562
|
+
const patchCallback = opts.patchCallback;
|
|
3563
|
+
const unchecked = opts.unchecked || false;
|
|
3564
|
+
const allowMissingDeps = opts.allowMissingChanges || false;
|
|
3565
|
+
const convertImmutableStringsToText = opts.convertImmutableStringsToText || false;
|
|
3566
|
+
const handle = ApiHandler.load(data, {
|
|
3567
|
+
actor,
|
|
3568
|
+
unchecked,
|
|
3569
|
+
allowMissingDeps,
|
|
3570
|
+
convertImmutableStringsToText
|
|
3571
|
+
});
|
|
3572
|
+
handle.enableFreeze(!!opts.freeze);
|
|
3573
|
+
registerDatatypes(handle);
|
|
3574
|
+
const doc = handle.materialize("/", undefined, {
|
|
3575
|
+
handle,
|
|
3576
|
+
heads: undefined,
|
|
3577
|
+
patchCallback
|
|
3578
|
+
});
|
|
3579
|
+
return doc;
|
|
3580
|
+
}
|
|
3581
|
+
function loadIncremental(doc, data, opts) {
|
|
3582
|
+
if (!opts) {
|
|
3583
|
+
opts = {};
|
|
3584
|
+
}
|
|
3585
|
+
const state = _state(doc);
|
|
3586
|
+
if (state.heads) {
|
|
3587
|
+
throw new RangeError("Attempting to change an out of date document - set at: " + _trace(doc));
|
|
3588
|
+
}
|
|
3589
|
+
if (_is_proxy(doc)) {
|
|
3590
|
+
throw new RangeError("Calls to Automerge.change cannot be nested");
|
|
3591
|
+
}
|
|
3592
|
+
const heads = state.handle.getHeads();
|
|
3593
|
+
state.handle.loadIncremental(data);
|
|
3594
|
+
return progressDocument(doc, "loadIncremental", heads, opts.patchCallback || state.patchCallback);
|
|
3595
|
+
}
|
|
3596
|
+
function saveIncremental(doc) {
|
|
3597
|
+
const state = _state(doc);
|
|
3598
|
+
if (state.heads) {
|
|
3599
|
+
throw new RangeError("Attempting to change an out of date document - set at: " + _trace(doc));
|
|
3600
|
+
}
|
|
3601
|
+
if (_is_proxy(doc)) {
|
|
3602
|
+
throw new RangeError("Calls to Automerge.change cannot be nested");
|
|
3603
|
+
}
|
|
3604
|
+
return state.handle.saveIncremental();
|
|
3605
|
+
}
|
|
3606
|
+
function save(doc) {
|
|
3607
|
+
return _state(doc).handle.save();
|
|
3608
|
+
}
|
|
3609
|
+
function merge(local, remote) {
|
|
3610
|
+
const localState = _state(local);
|
|
3611
|
+
if (localState.heads) {
|
|
3612
|
+
throw new RangeError("Attempting to change an out of date document - set at: " + _trace(local));
|
|
3613
|
+
}
|
|
3614
|
+
const heads = localState.handle.getHeads();
|
|
3615
|
+
const remoteState = _state(remote);
|
|
3616
|
+
const changes = localState.handle.getChangesAdded(remoteState.handle);
|
|
3617
|
+
localState.handle.applyChanges(changes);
|
|
3618
|
+
return progressDocument(local, "merge", heads, localState.patchCallback);
|
|
3619
|
+
}
|
|
3620
|
+
function getActorId(doc) {
|
|
3621
|
+
const state = _state(doc);
|
|
3622
|
+
return state.handle.getActorId();
|
|
3623
|
+
}
|
|
3624
|
+
function getConflicts(doc, prop) {
|
|
3625
|
+
const state = _state(doc, false);
|
|
3626
|
+
const objectId = _obj(doc);
|
|
3627
|
+
if (objectId != null) {
|
|
3628
|
+
const withinChangeCallback = _is_proxy(doc);
|
|
3629
|
+
return conflictAt(state.handle, objectId, prop, withinChangeCallback);
|
|
3630
|
+
} else {
|
|
3631
|
+
return;
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
function getLastLocalChange(doc) {
|
|
3635
|
+
const state = _state(doc);
|
|
3636
|
+
return state.handle.getLastLocalChange() || undefined;
|
|
3637
|
+
}
|
|
3638
|
+
function getObjectId(doc, prop) {
|
|
3639
|
+
if (prop) {
|
|
3640
|
+
const state = _state(doc, false);
|
|
3641
|
+
const objectId = _obj(doc);
|
|
3642
|
+
if (!state || !objectId) {
|
|
3643
|
+
return null;
|
|
3644
|
+
}
|
|
3645
|
+
return state.handle.get(objectId, prop);
|
|
3646
|
+
} else {
|
|
3647
|
+
return _obj(doc);
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
function getChanges(oldState, newState) {
|
|
3651
|
+
const n = _state(newState);
|
|
3652
|
+
return n.handle.getChanges(getHeads(oldState));
|
|
3653
|
+
}
|
|
3654
|
+
function getAllChanges(doc) {
|
|
3655
|
+
const state = _state(doc);
|
|
3656
|
+
return state.handle.getChanges([]);
|
|
3657
|
+
}
|
|
3658
|
+
function applyChanges(doc, changes, opts) {
|
|
3659
|
+
const state = _state(doc);
|
|
3660
|
+
if (!opts) {
|
|
3661
|
+
opts = {};
|
|
3662
|
+
}
|
|
3663
|
+
if (state.heads) {
|
|
3664
|
+
throw new RangeError("Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.");
|
|
3665
|
+
}
|
|
3666
|
+
if (_is_proxy(doc)) {
|
|
3667
|
+
throw new RangeError("Calls to Automerge.change cannot be nested");
|
|
3668
|
+
}
|
|
3669
|
+
const heads = state.handle.getHeads();
|
|
3670
|
+
state.handle.applyChanges(changes);
|
|
3671
|
+
state.heads = heads;
|
|
3672
|
+
return [
|
|
3673
|
+
progressDocument(doc, "applyChanges", heads, opts.patchCallback || state.patchCallback)
|
|
3674
|
+
];
|
|
3675
|
+
}
|
|
3676
|
+
function getHistory(doc) {
|
|
3677
|
+
const history = getAllChanges(doc);
|
|
3678
|
+
return history.map((change2, index) => ({
|
|
3679
|
+
get change() {
|
|
3680
|
+
return decodeChange3(change2);
|
|
3681
|
+
},
|
|
3682
|
+
get snapshot() {
|
|
3683
|
+
const [state] = applyChanges(init(), history.slice(0, index + 1));
|
|
3684
|
+
return state;
|
|
3685
|
+
}
|
|
3686
|
+
}));
|
|
3687
|
+
}
|
|
3688
|
+
function diff(doc, before, after) {
|
|
3689
|
+
checkHeads(before, "before heads");
|
|
3690
|
+
checkHeads(after, "after heads");
|
|
3691
|
+
const state = _state(doc);
|
|
3692
|
+
if (state.mostRecentPatch && equals(state.mostRecentPatch.before, before) && equals(state.mostRecentPatch.after, after)) {
|
|
3693
|
+
return state.mostRecentPatch.patches;
|
|
3694
|
+
}
|
|
3695
|
+
return state.handle.diff(before, after);
|
|
3696
|
+
}
|
|
3697
|
+
function diffPath(doc, path, before, after, opts) {
|
|
3698
|
+
checkHeads(before, "before");
|
|
3699
|
+
checkHeads(after, "after");
|
|
3700
|
+
const state = _state(doc);
|
|
3701
|
+
const objPath = absoluteObjPath(doc, path, "diff");
|
|
3702
|
+
return state.handle.diffPath(objPath, before, after, opts);
|
|
3703
|
+
}
|
|
3704
|
+
function headsEqual(heads1, heads2) {
|
|
3705
|
+
if (heads1.length !== heads2.length) {
|
|
3706
|
+
return false;
|
|
3707
|
+
}
|
|
3708
|
+
for (let i = 0;i < heads1.length; i++) {
|
|
3709
|
+
if (heads1[i] !== heads2[i]) {
|
|
3710
|
+
return false;
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
return true;
|
|
3714
|
+
}
|
|
3715
|
+
function checkHeads(heads, fieldname) {
|
|
3716
|
+
if (!Array.isArray(heads)) {
|
|
3717
|
+
throw new Error(`invalid ${fieldname}: must be an array`);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
function equals(val1, val2) {
|
|
3721
|
+
if (!isObject(val1) || !isObject(val2))
|
|
3722
|
+
return val1 === val2;
|
|
3723
|
+
const keys1 = Object.keys(val1).sort(), keys2 = Object.keys(val2).sort();
|
|
3724
|
+
if (keys1.length !== keys2.length)
|
|
3725
|
+
return false;
|
|
3726
|
+
for (let i = 0;i < keys1.length; i++) {
|
|
3727
|
+
if (keys1[i] !== keys2[i])
|
|
3728
|
+
return false;
|
|
3729
|
+
if (!equals(val1[keys1[i]], val2[keys2[i]]))
|
|
3730
|
+
return false;
|
|
3731
|
+
}
|
|
3732
|
+
return true;
|
|
3733
|
+
}
|
|
3734
|
+
function encodeSyncState3(state) {
|
|
3735
|
+
const sync = ApiHandler.importSyncState(state);
|
|
3736
|
+
const result = ApiHandler.encodeSyncState(sync);
|
|
3737
|
+
sync.free();
|
|
3738
|
+
return result;
|
|
3739
|
+
}
|
|
3740
|
+
function decodeSyncState3(state) {
|
|
3741
|
+
const sync = ApiHandler.decodeSyncState(state);
|
|
3742
|
+
const result = ApiHandler.exportSyncState(sync);
|
|
3743
|
+
sync.free();
|
|
3744
|
+
return result;
|
|
3745
|
+
}
|
|
3746
|
+
function generateSyncMessage(doc, inState) {
|
|
3747
|
+
const state = _state(doc);
|
|
3748
|
+
const syncState = ApiHandler.importSyncState(inState);
|
|
3749
|
+
const message = state.handle.generateSyncMessage(syncState);
|
|
3750
|
+
const outState = ApiHandler.exportSyncState(syncState);
|
|
3751
|
+
return [outState, message];
|
|
3752
|
+
}
|
|
3753
|
+
function receiveSyncMessage(doc, inState, message, opts) {
|
|
3754
|
+
const syncState = ApiHandler.importSyncState(inState);
|
|
3755
|
+
if (!opts) {
|
|
3756
|
+
opts = {};
|
|
3757
|
+
}
|
|
3758
|
+
const state = _state(doc);
|
|
3759
|
+
if (state.heads) {
|
|
3760
|
+
throw new RangeError("Attempting to change an outdated document. Use Automerge.clone() if you wish to make a writable copy.");
|
|
3761
|
+
}
|
|
3762
|
+
if (_is_proxy(doc)) {
|
|
3763
|
+
throw new RangeError("Calls to Automerge.change cannot be nested");
|
|
3764
|
+
}
|
|
3765
|
+
const heads = state.handle.getHeads();
|
|
3766
|
+
state.handle.receiveSyncMessage(syncState, message);
|
|
3767
|
+
const outSyncState = ApiHandler.exportSyncState(syncState);
|
|
3768
|
+
return [
|
|
3769
|
+
progressDocument(doc, "receiveSyncMessage", heads, opts.patchCallback || state.patchCallback),
|
|
3770
|
+
outSyncState,
|
|
3771
|
+
null
|
|
3772
|
+
];
|
|
3773
|
+
}
|
|
3774
|
+
function hasOurChanges(doc, remoteState) {
|
|
3775
|
+
const state = _state(doc);
|
|
3776
|
+
const syncState = ApiHandler.importSyncState(remoteState);
|
|
3777
|
+
return state.handle.hasOurChanges(syncState);
|
|
3778
|
+
}
|
|
3779
|
+
function initSyncState3() {
|
|
3780
|
+
return ApiHandler.exportSyncState(ApiHandler.initSyncState());
|
|
3781
|
+
}
|
|
3782
|
+
function encodeChange3(change2) {
|
|
3783
|
+
return ApiHandler.encodeChange(change2);
|
|
3784
|
+
}
|
|
3785
|
+
function decodeChange3(data) {
|
|
3786
|
+
return ApiHandler.decodeChange(data);
|
|
3787
|
+
}
|
|
3788
|
+
function encodeSyncMessage3(message) {
|
|
3789
|
+
return ApiHandler.encodeSyncMessage(message);
|
|
3790
|
+
}
|
|
3791
|
+
function decodeSyncMessage3(message) {
|
|
3792
|
+
return ApiHandler.decodeSyncMessage(message);
|
|
3793
|
+
}
|
|
3794
|
+
function getMissingDeps(doc, heads) {
|
|
3795
|
+
const state = _state(doc);
|
|
3796
|
+
return state.handle.getMissingDeps(heads);
|
|
3797
|
+
}
|
|
3798
|
+
function getHeads(doc) {
|
|
3799
|
+
const state = _state(doc);
|
|
3800
|
+
return state.heads || state.handle.getHeads();
|
|
3801
|
+
}
|
|
3802
|
+
function dump(doc) {
|
|
3803
|
+
const state = _state(doc);
|
|
3804
|
+
state.handle.dump();
|
|
3805
|
+
}
|
|
3806
|
+
function toJS(doc) {
|
|
3807
|
+
const state = _state(doc);
|
|
3808
|
+
const enabled = state.handle.enableFreeze(false);
|
|
3809
|
+
const result = state.handle.materialize("/", state.heads);
|
|
3810
|
+
state.handle.enableFreeze(enabled);
|
|
3811
|
+
return result;
|
|
3812
|
+
}
|
|
3813
|
+
function isAutomerge(doc) {
|
|
3814
|
+
if (typeof doc == "object" && doc !== null) {
|
|
3815
|
+
return getObjectId(doc) === "_root" && !!Reflect.get(doc, STATE);
|
|
3816
|
+
} else {
|
|
3817
|
+
return false;
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
function isObject(obj) {
|
|
3821
|
+
return typeof obj === "object" && obj !== null;
|
|
3822
|
+
}
|
|
3823
|
+
function saveSince(doc, heads) {
|
|
3824
|
+
const state = _state(doc);
|
|
3825
|
+
const result = state.handle.saveSince(heads);
|
|
3826
|
+
return result;
|
|
3827
|
+
}
|
|
3828
|
+
function hasHeads(doc, heads) {
|
|
3829
|
+
const state = _state(doc);
|
|
3830
|
+
for (const hash of heads) {
|
|
3831
|
+
if (!state.handle.getChangeByHash(hash)) {
|
|
3832
|
+
return false;
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
return true;
|
|
3836
|
+
}
|
|
3837
|
+
function registerDatatypes(handle) {
|
|
3838
|
+
handle.registerDatatype("counter", (n) => new Counter(n), (n) => {
|
|
3839
|
+
if (n instanceof Counter) {
|
|
3840
|
+
return n.value;
|
|
3841
|
+
}
|
|
3842
|
+
});
|
|
3843
|
+
handle.registerDatatype("str", (n) => {
|
|
3844
|
+
return new ImmutableString(n);
|
|
3845
|
+
}, (s) => {
|
|
3846
|
+
if (isImmutableString(s)) {
|
|
3847
|
+
return s.val;
|
|
3848
|
+
}
|
|
3849
|
+
});
|
|
3850
|
+
}
|
|
3851
|
+
function topoHistoryTraversal(doc) {
|
|
3852
|
+
const state = _state(doc);
|
|
3853
|
+
return state.handle.topoHistoryTraversal();
|
|
3854
|
+
}
|
|
3855
|
+
function inspectChange(doc, changeHash) {
|
|
3856
|
+
const state = _state(doc);
|
|
3857
|
+
return state.handle.getDecodedChangeByHash(changeHash);
|
|
3858
|
+
}
|
|
3859
|
+
function stats(doc) {
|
|
3860
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
3861
|
+
const state = _state(doc);
|
|
3862
|
+
const wasmStats = state.handle.stats();
|
|
3863
|
+
const release = releaseInfo();
|
|
3864
|
+
return Object.assign(Object.assign({}, wasmStats), { cargoPackageName: (_b = (_a2 = release.wasm) === null || _a2 === undefined ? undefined : _a2.cargoPackageName) !== null && _b !== undefined ? _b : "unknown", cargoPackageVersion: (_d = (_c = release.wasm) === null || _c === undefined ? undefined : _c.cargoPackageVersion) !== null && _d !== undefined ? _d : "unknown", rustcVersion: (_f = (_e = release.wasm) === null || _e === undefined ? undefined : _e.rustcVersion) !== null && _f !== undefined ? _f : "unknown" });
|
|
3865
|
+
}
|
|
3866
|
+
function releaseInfo() {
|
|
3867
|
+
let wasm3 = null;
|
|
3868
|
+
try {
|
|
3869
|
+
wasm3 = ApiHandler.wasmReleaseInfo();
|
|
3870
|
+
} catch (_a2) {}
|
|
3871
|
+
return {
|
|
3872
|
+
js: {
|
|
3873
|
+
gitHead: JS_GIT_HEAD
|
|
3874
|
+
},
|
|
3875
|
+
wasm: wasm3
|
|
3876
|
+
};
|
|
3877
|
+
}
|
|
3878
|
+
function splice(doc, path, index, del, newText) {
|
|
3879
|
+
const objPath = absoluteObjPath(doc, path, "splice");
|
|
3880
|
+
if (!_is_proxy(doc)) {
|
|
3881
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
3882
|
+
}
|
|
3883
|
+
const state = _state(doc, false);
|
|
3884
|
+
_clear_cache(doc);
|
|
3885
|
+
index = cursorToIndex(state, objPath, index);
|
|
3886
|
+
try {
|
|
3887
|
+
return state.handle.splice(objPath, index, del, newText);
|
|
3888
|
+
} catch (e) {
|
|
3889
|
+
throw new RangeError(`Cannot splice: ${e}`);
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
function updateText(doc, path, newText) {
|
|
3893
|
+
const objPath = absoluteObjPath(doc, path, "updateText");
|
|
3894
|
+
if (!_is_proxy(doc)) {
|
|
3895
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
3896
|
+
}
|
|
3897
|
+
const state = _state(doc, false);
|
|
3898
|
+
_clear_cache(doc);
|
|
3899
|
+
try {
|
|
3900
|
+
return state.handle.updateText(objPath, newText);
|
|
3901
|
+
} catch (e) {
|
|
3902
|
+
throw new RangeError(`Cannot updateText: ${e}`);
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
function spans(doc, path) {
|
|
3906
|
+
const state = _state(doc, false);
|
|
3907
|
+
const objPath = absoluteObjPath(doc, path, "spans");
|
|
3908
|
+
try {
|
|
3909
|
+
return state.handle.spans(objPath, state.heads);
|
|
3910
|
+
} catch (e) {
|
|
3911
|
+
throw new RangeError(`Cannot splice: ${e}`);
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
function block(doc, path, index) {
|
|
3915
|
+
const objPath = absoluteObjPath(doc, path, "splitBlock");
|
|
3916
|
+
const state = _state(doc, false);
|
|
3917
|
+
index = cursorToIndex(state, objPath, index);
|
|
3918
|
+
try {
|
|
3919
|
+
return state.handle.getBlock(objPath, index);
|
|
3920
|
+
} catch (e) {
|
|
3921
|
+
throw new RangeError(`Cannot get block: ${e}`);
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
function splitBlock(doc, path, index, block2) {
|
|
3925
|
+
if (!_is_proxy(doc)) {
|
|
3926
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
3927
|
+
}
|
|
3928
|
+
const objPath = absoluteObjPath(doc, path, "splitBlock");
|
|
3929
|
+
const state = _state(doc, false);
|
|
3930
|
+
_clear_cache(doc);
|
|
3931
|
+
index = cursorToIndex(state, objPath, index);
|
|
3932
|
+
try {
|
|
3933
|
+
state.handle.splitBlock(objPath, index, block2);
|
|
3934
|
+
} catch (e) {
|
|
3935
|
+
throw new RangeError(`Cannot splice: ${e}`);
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
function joinBlock(doc, path, index) {
|
|
3939
|
+
if (!_is_proxy(doc)) {
|
|
3940
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
3941
|
+
}
|
|
3942
|
+
const objPath = absoluteObjPath(doc, path, "joinBlock");
|
|
3943
|
+
const state = _state(doc, false);
|
|
3944
|
+
_clear_cache(doc);
|
|
3945
|
+
index = cursorToIndex(state, objPath, index);
|
|
3946
|
+
try {
|
|
3947
|
+
state.handle.joinBlock(objPath, index);
|
|
3948
|
+
} catch (e) {
|
|
3949
|
+
throw new RangeError(`Cannot joinBlock: ${e}`);
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
function updateBlock(doc, path, index, block2) {
|
|
3953
|
+
if (!_is_proxy(doc)) {
|
|
3954
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
3955
|
+
}
|
|
3956
|
+
const objPath = absoluteObjPath(doc, path, "updateBlock");
|
|
3957
|
+
const state = _state(doc, false);
|
|
3958
|
+
_clear_cache(doc);
|
|
3959
|
+
index = cursorToIndex(state, objPath, index);
|
|
3960
|
+
try {
|
|
3961
|
+
state.handle.updateBlock(objPath, index, block2);
|
|
3962
|
+
} catch (e) {
|
|
3963
|
+
throw new RangeError(`Cannot updateBlock: ${e}`);
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
function updateSpans(doc, path, newSpans, config) {
|
|
3967
|
+
if (!_is_proxy(doc)) {
|
|
3968
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
3969
|
+
}
|
|
3970
|
+
const objPath = absoluteObjPath(doc, path, "updateSpans");
|
|
3971
|
+
const state = _state(doc, false);
|
|
3972
|
+
_clear_cache(doc);
|
|
3973
|
+
try {
|
|
3974
|
+
state.handle.updateSpans(objPath, newSpans, config);
|
|
3975
|
+
} catch (e) {
|
|
3976
|
+
throw new RangeError(`Cannot updateSpans: ${e}`);
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
function getCursor(doc, path, position, move) {
|
|
3980
|
+
const objPath = absoluteObjPath(doc, path, "getCursor");
|
|
3981
|
+
const state = _state(doc, false);
|
|
3982
|
+
try {
|
|
3983
|
+
return state.handle.getCursor(objPath, position, state.heads, move);
|
|
3984
|
+
} catch (e) {
|
|
3985
|
+
throw new RangeError(`Cannot getCursor: ${e}`);
|
|
3986
|
+
}
|
|
3987
|
+
}
|
|
3988
|
+
function getCursorPosition(doc, path, cursor) {
|
|
3989
|
+
const objPath = absoluteObjPath(doc, path, "getCursorPosition");
|
|
3990
|
+
const state = _state(doc, false);
|
|
3991
|
+
try {
|
|
3992
|
+
return state.handle.getCursorPosition(objPath, cursor, state.heads);
|
|
3993
|
+
} catch (e) {
|
|
3994
|
+
throw new RangeError(`Cannot getCursorPosition: ${e}`);
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
function mark(doc, path, range, name, value) {
|
|
3998
|
+
const objPath = absoluteObjPath(doc, path, "mark");
|
|
3999
|
+
if (!_is_proxy(doc)) {
|
|
4000
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
4001
|
+
}
|
|
4002
|
+
const state = _state(doc, false);
|
|
4003
|
+
try {
|
|
4004
|
+
return state.handle.mark(objPath, range, name, value);
|
|
4005
|
+
} catch (e) {
|
|
4006
|
+
throw new RangeError(`Cannot mark: ${e}`);
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
4009
|
+
function unmark(doc, path, range, name) {
|
|
4010
|
+
const objPath = absoluteObjPath(doc, path, "unmark");
|
|
4011
|
+
if (!_is_proxy(doc)) {
|
|
4012
|
+
throw new RangeError("object cannot be modified outside of a change block");
|
|
4013
|
+
}
|
|
4014
|
+
const state = _state(doc, false);
|
|
4015
|
+
try {
|
|
4016
|
+
return state.handle.unmark(objPath, range, name);
|
|
4017
|
+
} catch (e) {
|
|
4018
|
+
throw new RangeError(`Cannot unmark: ${e}`);
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
function marks(doc, path) {
|
|
4022
|
+
const objPath = absoluteObjPath(doc, path, "marks");
|
|
4023
|
+
const state = _state(doc, false);
|
|
4024
|
+
try {
|
|
4025
|
+
return state.handle.marks(objPath);
|
|
4026
|
+
} catch (e) {
|
|
4027
|
+
throw new RangeError(`Cannot call marks(): ${e}`);
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
function marksAt(doc, path, index) {
|
|
4031
|
+
const objPath = absoluteObjPath(doc, path, "marksAt");
|
|
4032
|
+
const state = _state(doc, false);
|
|
4033
|
+
try {
|
|
4034
|
+
return state.handle.marksAt(objPath, index);
|
|
4035
|
+
} catch (e) {
|
|
4036
|
+
throw new RangeError(`Cannot call marksAt(): ${e}`);
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
function absoluteObjPath(doc, path, functionName) {
|
|
4040
|
+
path = path.slice();
|
|
4041
|
+
const objectId = _obj(doc);
|
|
4042
|
+
if (!objectId) {
|
|
4043
|
+
throw new RangeError(`invalid object for ${functionName}`);
|
|
4044
|
+
}
|
|
4045
|
+
path.unshift(objectId);
|
|
4046
|
+
return path.join("/");
|
|
4047
|
+
}
|
|
4048
|
+
function saveBundle(doc, hashes) {
|
|
4049
|
+
const state = _state(doc, false);
|
|
4050
|
+
return state.handle.saveBundle(hashes);
|
|
4051
|
+
}
|
|
4052
|
+
function readBundle3(bundle) {
|
|
4053
|
+
return ApiHandler.readBundle(bundle);
|
|
4054
|
+
}
|
|
4055
|
+
var __rest = function(s, e) {
|
|
4056
|
+
var t = {};
|
|
4057
|
+
for (var p in s)
|
|
4058
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4059
|
+
t[p] = s[p];
|
|
4060
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
4061
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s);i < p.length; i++) {
|
|
4062
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
4063
|
+
t[p[i]] = s[p[i]];
|
|
4064
|
+
}
|
|
4065
|
+
return t;
|
|
4066
|
+
}, _SyncStateSymbol, isRawString, RawString;
|
|
4067
|
+
var init_implementation = __esm(() => {
|
|
4068
|
+
init_proxies();
|
|
4069
|
+
init_proxies();
|
|
4070
|
+
init_constants();
|
|
4071
|
+
init_types();
|
|
4072
|
+
init_types();
|
|
4073
|
+
init_low_level();
|
|
4074
|
+
init_low_level();
|
|
4075
|
+
init_immutable_string();
|
|
4076
|
+
init_immutable_string();
|
|
4077
|
+
init_internal_state();
|
|
4078
|
+
init_apply_patches();
|
|
4079
|
+
init_conflicts();
|
|
4080
|
+
_SyncStateSymbol = Symbol("_syncstate");
|
|
4081
|
+
isRawString = isImmutableString;
|
|
4082
|
+
RawString = ImmutableString;
|
|
4083
|
+
});
|
|
4084
|
+
|
|
4085
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/index.js
|
|
4086
|
+
var init_mjs = __esm(() => {
|
|
4087
|
+
init_implementation();
|
|
4088
|
+
init_implementation();
|
|
4089
|
+
});
|
|
4090
|
+
|
|
4091
|
+
// ../../node_modules/.pnpm/@automerge+automerge@3.2.4/node_modules/@automerge/automerge/dist/mjs/entrypoints/fullfat_bundler.js
|
|
4092
|
+
var exports_fullfat_bundler = {};
|
|
4093
|
+
__export(exports_fullfat_bundler, {
|
|
4094
|
+
wasmInitialized: () => wasmInitialized,
|
|
4095
|
+
view: () => view,
|
|
4096
|
+
use: () => use,
|
|
4097
|
+
updateText: () => updateText,
|
|
4098
|
+
updateSpans: () => updateSpans,
|
|
4099
|
+
updateBlock: () => updateBlock,
|
|
4100
|
+
unmark: () => unmark,
|
|
4101
|
+
topoHistoryTraversal: () => topoHistoryTraversal,
|
|
4102
|
+
toJS: () => toJS,
|
|
4103
|
+
stats: () => stats,
|
|
4104
|
+
splitBlock: () => splitBlock,
|
|
4105
|
+
splice: () => splice,
|
|
4106
|
+
spans: () => spans,
|
|
4107
|
+
saveSince: () => saveSince,
|
|
4108
|
+
saveIncremental: () => saveIncremental,
|
|
4109
|
+
saveBundle: () => saveBundle,
|
|
4110
|
+
save: () => save,
|
|
4111
|
+
releaseInfo: () => releaseInfo,
|
|
4112
|
+
receiveSyncMessage: () => receiveSyncMessage,
|
|
4113
|
+
readBundle: () => readBundle3,
|
|
4114
|
+
next: () => exports_implementation,
|
|
4115
|
+
merge: () => merge,
|
|
4116
|
+
marksAt: () => marksAt,
|
|
4117
|
+
marks: () => marks,
|
|
4118
|
+
mark: () => mark,
|
|
4119
|
+
loadIncremental: () => loadIncremental,
|
|
4120
|
+
load: () => load3,
|
|
4121
|
+
joinBlock: () => joinBlock,
|
|
4122
|
+
isWasmInitialized: () => isWasmInitialized,
|
|
4123
|
+
isRawString: () => isRawString,
|
|
4124
|
+
isImmutableString: () => isImmutableString,
|
|
4125
|
+
isCounter: () => isCounter,
|
|
4126
|
+
isAutomerge: () => isAutomerge,
|
|
4127
|
+
inspectChange: () => inspectChange,
|
|
4128
|
+
insertAt: () => insertAt,
|
|
4129
|
+
initializeWasm: () => initializeWasm,
|
|
4130
|
+
initializeBase64Wasm: () => initializeBase64Wasm,
|
|
4131
|
+
initSyncState: () => initSyncState3,
|
|
4132
|
+
init: () => init,
|
|
4133
|
+
hasOurChanges: () => hasOurChanges,
|
|
4134
|
+
hasHeads: () => hasHeads,
|
|
4135
|
+
getObjectId: () => getObjectId,
|
|
4136
|
+
getMissingDeps: () => getMissingDeps,
|
|
4137
|
+
getLastLocalChange: () => getLastLocalChange,
|
|
4138
|
+
getHistory: () => getHistory,
|
|
4139
|
+
getHeads: () => getHeads,
|
|
4140
|
+
getCursorPosition: () => getCursorPosition,
|
|
4141
|
+
getCursor: () => getCursor,
|
|
4142
|
+
getConflicts: () => getConflicts,
|
|
4143
|
+
getChangesSince: () => getChangesSince,
|
|
4144
|
+
getChangesMetaSince: () => getChangesMetaSince,
|
|
4145
|
+
getChanges: () => getChanges,
|
|
4146
|
+
getBackend: () => getBackend,
|
|
4147
|
+
getAllChanges: () => getAllChanges,
|
|
4148
|
+
getActorId: () => getActorId,
|
|
4149
|
+
generateSyncMessage: () => generateSyncMessage,
|
|
4150
|
+
from: () => from,
|
|
4151
|
+
free: () => free,
|
|
4152
|
+
equals: () => equals,
|
|
4153
|
+
encodeSyncState: () => encodeSyncState3,
|
|
4154
|
+
encodeSyncMessage: () => encodeSyncMessage3,
|
|
4155
|
+
encodeChange: () => encodeChange3,
|
|
4156
|
+
emptyChange: () => emptyChange,
|
|
4157
|
+
dump: () => dump,
|
|
4158
|
+
diffPath: () => diffPath,
|
|
4159
|
+
diff: () => diff,
|
|
4160
|
+
deleteAt: () => deleteAt,
|
|
4161
|
+
decodeSyncState: () => decodeSyncState3,
|
|
4162
|
+
decodeSyncMessage: () => decodeSyncMessage3,
|
|
4163
|
+
decodeChange: () => decodeChange3,
|
|
4164
|
+
clone: () => clone,
|
|
4165
|
+
changeAt: () => changeAt,
|
|
4166
|
+
change: () => change,
|
|
4167
|
+
block: () => block,
|
|
4168
|
+
applyPatches: () => applyPatches,
|
|
4169
|
+
applyPatch: () => applyPatch,
|
|
4170
|
+
applyChanges: () => applyChanges,
|
|
4171
|
+
Uint: () => Uint,
|
|
4172
|
+
RawString: () => RawString,
|
|
4173
|
+
Int: () => Int,
|
|
4174
|
+
ImmutableString: () => ImmutableString,
|
|
4175
|
+
Float64: () => Float64,
|
|
4176
|
+
Counter: () => Counter
|
|
4177
|
+
});
|
|
4178
|
+
var init_fullfat_bundler = __esm(() => {
|
|
4179
|
+
init_low_level();
|
|
4180
|
+
init_automerge_wasm2();
|
|
4181
|
+
init_mjs();
|
|
4182
|
+
UseApi(exports_automerge_wasm2);
|
|
4183
|
+
});
|
|
4184
|
+
|
|
4185
|
+
// src/sync/AutomergeProvider.ts
|
|
4186
|
+
var RELAY_PROTOCOL = "dashrelay-v1";
|
|
4187
|
+
|
|
4188
|
+
class AutomergeProvider {
|
|
4189
|
+
config;
|
|
4190
|
+
_doc;
|
|
4191
|
+
_onChange;
|
|
4192
|
+
_ws = null;
|
|
4193
|
+
_syncState = null;
|
|
4194
|
+
_automerge = null;
|
|
4195
|
+
_ready;
|
|
4196
|
+
_destroyed = false;
|
|
4197
|
+
_joined = false;
|
|
4198
|
+
_reconnectTimer = null;
|
|
4199
|
+
_reconnectDelayMs = 1000;
|
|
4200
|
+
_maxReconnectDelayMs = 30000;
|
|
4201
|
+
constructor(doc, config, options) {
|
|
4202
|
+
this._doc = doc;
|
|
4203
|
+
this.config = config;
|
|
4204
|
+
this._onChange = options?.onChange;
|
|
4205
|
+
this._ready = this.initialize();
|
|
4206
|
+
}
|
|
4207
|
+
async initialize() {
|
|
4208
|
+
const am = await Promise.resolve().then(() => (init_fullfat_bundler(), exports_fullfat_bundler));
|
|
4209
|
+
this._automerge = am;
|
|
4210
|
+
this._syncState = am.initSyncState();
|
|
4211
|
+
this.connectWebSocket();
|
|
4212
|
+
}
|
|
4213
|
+
getRelayUrl() {
|
|
4214
|
+
if (this.config.websocket?.url) {
|
|
4215
|
+
return toRelaySocketUrl(this.config.websocket.url);
|
|
4216
|
+
}
|
|
4217
|
+
if (this.config.webtransport?.url) {
|
|
4218
|
+
return toRelaySocketUrl(this.config.webtransport.url);
|
|
4219
|
+
}
|
|
4220
|
+
return null;
|
|
4221
|
+
}
|
|
4222
|
+
getJoinAuthToken() {
|
|
4223
|
+
const ucanToken = this.config.ucanToken?.trim();
|
|
4224
|
+
if (ucanToken && ucanToken.length > 0) {
|
|
4225
|
+
return ucanToken;
|
|
4226
|
+
}
|
|
4227
|
+
const apiKey = this.config.apiKey?.trim();
|
|
4228
|
+
if (apiKey && apiKey.length > 0) {
|
|
4229
|
+
return apiKey;
|
|
4230
|
+
}
|
|
4231
|
+
return;
|
|
4232
|
+
}
|
|
4233
|
+
connectWebSocket() {
|
|
4234
|
+
if (this._destroyed) {
|
|
4235
|
+
return;
|
|
4236
|
+
}
|
|
4237
|
+
const relayUrl = this.getRelayUrl();
|
|
4238
|
+
if (!relayUrl) {
|
|
4239
|
+
return;
|
|
4240
|
+
}
|
|
4241
|
+
const wsUrl = new URL(relayUrl);
|
|
4242
|
+
wsUrl.searchParams.set("room", this.config.roomName);
|
|
4243
|
+
try {
|
|
4244
|
+
this._ws = new WebSocket(wsUrl.toString());
|
|
4245
|
+
this._ws.binaryType = "arraybuffer";
|
|
4246
|
+
this._joined = false;
|
|
4247
|
+
} catch {
|
|
4248
|
+
this.scheduleReconnect();
|
|
4249
|
+
return;
|
|
4250
|
+
}
|
|
4251
|
+
this._ws.addEventListener("open", () => {
|
|
4252
|
+
this._reconnectDelayMs = 1000;
|
|
4253
|
+
if (!this._ws || this._ws.readyState !== WebSocket.OPEN) {
|
|
4254
|
+
return;
|
|
4255
|
+
}
|
|
4256
|
+
const joinMessage = {
|
|
4257
|
+
type: "join",
|
|
4258
|
+
protocol: RELAY_PROTOCOL,
|
|
4259
|
+
room: this.config.roomName,
|
|
4260
|
+
auth: this.getJoinAuthToken(),
|
|
4261
|
+
mode: "opaque-relay",
|
|
4262
|
+
clientId: `automerge-${Math.random().toString(36).slice(2, 10)}`
|
|
4263
|
+
};
|
|
4264
|
+
this._ws.send(JSON.stringify(joinMessage));
|
|
4265
|
+
});
|
|
4266
|
+
this._ws.addEventListener("message", (event) => {
|
|
4267
|
+
this.handleSocketMessage(event.data).catch(() => {
|
|
4268
|
+
this._ws?.close();
|
|
4269
|
+
});
|
|
4270
|
+
});
|
|
4271
|
+
this._ws.addEventListener("close", () => {
|
|
4272
|
+
this._ws = null;
|
|
4273
|
+
this._joined = false;
|
|
4274
|
+
this.scheduleReconnect();
|
|
4275
|
+
});
|
|
4276
|
+
this._ws.addEventListener("error", () => {});
|
|
4277
|
+
}
|
|
4278
|
+
async handleSocketMessage(data) {
|
|
4279
|
+
if (typeof data === "string") {
|
|
4280
|
+
this.handleControlMessage(data);
|
|
4281
|
+
return;
|
|
4282
|
+
}
|
|
4283
|
+
if (data instanceof ArrayBuffer) {
|
|
4284
|
+
this.handleBinaryMessage(data);
|
|
4285
|
+
return;
|
|
4286
|
+
}
|
|
4287
|
+
if (data instanceof Blob) {
|
|
4288
|
+
const buffer = await data.arrayBuffer();
|
|
4289
|
+
this.handleBinaryMessage(buffer);
|
|
4290
|
+
}
|
|
4291
|
+
}
|
|
4292
|
+
handleControlMessage(raw) {
|
|
4293
|
+
let payload;
|
|
4294
|
+
try {
|
|
4295
|
+
payload = JSON.parse(raw);
|
|
4296
|
+
} catch {
|
|
4297
|
+
return;
|
|
4298
|
+
}
|
|
4299
|
+
const record = asRecord(payload);
|
|
4300
|
+
if (!record) {
|
|
4301
|
+
return;
|
|
4302
|
+
}
|
|
4303
|
+
const type = record["type"];
|
|
4304
|
+
if (type === "joined") {
|
|
4305
|
+
const joined = record;
|
|
4306
|
+
if (joined.protocol === RELAY_PROTOCOL && joined.room === this.config.roomName && joined.mode === "opaque-relay") {
|
|
4307
|
+
this._joined = true;
|
|
4308
|
+
this.sendSyncMessage();
|
|
4309
|
+
}
|
|
4310
|
+
return;
|
|
4311
|
+
}
|
|
4312
|
+
if (type === "error") {
|
|
4313
|
+
const relayError = record;
|
|
4314
|
+
throw new Error(relayError.error || "relay_error");
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
handleBinaryMessage(data) {
|
|
4318
|
+
if (!this._joined) {
|
|
4319
|
+
return;
|
|
4320
|
+
}
|
|
4321
|
+
this.handleMessage(data);
|
|
4322
|
+
}
|
|
4323
|
+
scheduleReconnect() {
|
|
4324
|
+
if (this._destroyed || this._reconnectTimer) {
|
|
4325
|
+
return;
|
|
4326
|
+
}
|
|
4327
|
+
this._reconnectTimer = setTimeout(() => {
|
|
4328
|
+
this._reconnectTimer = null;
|
|
4329
|
+
this.connectWebSocket();
|
|
4330
|
+
}, this._reconnectDelayMs);
|
|
4331
|
+
this._reconnectDelayMs = Math.min(this._reconnectDelayMs * 2, this._maxReconnectDelayMs);
|
|
4332
|
+
}
|
|
4333
|
+
sendSyncMessage() {
|
|
4334
|
+
const am = this._automerge;
|
|
4335
|
+
if (!am || !this._ws || this._ws.readyState !== WebSocket.OPEN || !this._joined) {
|
|
4336
|
+
return;
|
|
4337
|
+
}
|
|
4338
|
+
const [nextSyncState, message] = am.generateSyncMessage(this._doc, this._syncState);
|
|
4339
|
+
this._syncState = nextSyncState;
|
|
4340
|
+
if (message) {
|
|
4341
|
+
this._ws.send(message);
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
handleMessage(data) {
|
|
4345
|
+
const am = this._automerge;
|
|
4346
|
+
if (!am) {
|
|
4347
|
+
return;
|
|
4348
|
+
}
|
|
4349
|
+
const message = new Uint8Array(data);
|
|
4350
|
+
const [nextDoc, nextSyncState] = am.receiveSyncMessage(this._doc, this._syncState, message);
|
|
4351
|
+
this._doc = nextDoc;
|
|
4352
|
+
this._syncState = nextSyncState;
|
|
4353
|
+
this._onChange?.(this._doc);
|
|
4354
|
+
this.sendSyncMessage();
|
|
4355
|
+
}
|
|
4356
|
+
updateDoc(newDoc) {
|
|
4357
|
+
this._doc = newDoc;
|
|
4358
|
+
this.sendSyncMessage();
|
|
4359
|
+
}
|
|
4360
|
+
get doc() {
|
|
4361
|
+
return this._doc;
|
|
4362
|
+
}
|
|
4363
|
+
get ready() {
|
|
4364
|
+
return this._ready;
|
|
4365
|
+
}
|
|
4366
|
+
get roomName() {
|
|
4367
|
+
return this.config.roomName;
|
|
4368
|
+
}
|
|
4369
|
+
get connected() {
|
|
4370
|
+
return this._ws !== null && this._ws.readyState === WebSocket.OPEN && this._joined;
|
|
4371
|
+
}
|
|
4372
|
+
disconnect() {
|
|
4373
|
+
if (this._reconnectTimer) {
|
|
4374
|
+
clearTimeout(this._reconnectTimer);
|
|
4375
|
+
this._reconnectTimer = null;
|
|
4376
|
+
}
|
|
4377
|
+
if (this._ws) {
|
|
4378
|
+
this._ws.close();
|
|
4379
|
+
this._ws = null;
|
|
4380
|
+
}
|
|
4381
|
+
this._joined = false;
|
|
4382
|
+
}
|
|
4383
|
+
async destroy() {
|
|
4384
|
+
this._destroyed = true;
|
|
4385
|
+
this.disconnect();
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
function toWsUrl(url) {
|
|
4389
|
+
if (url.startsWith("wss://") || url.startsWith("ws://")) {
|
|
4390
|
+
return url;
|
|
4391
|
+
}
|
|
4392
|
+
if (url.startsWith("https://")) {
|
|
4393
|
+
return `wss://${url.slice("https://".length)}`;
|
|
4394
|
+
}
|
|
4395
|
+
if (url.startsWith("http://")) {
|
|
4396
|
+
return `ws://${url.slice("http://".length)}`;
|
|
4397
|
+
}
|
|
4398
|
+
return url;
|
|
4399
|
+
}
|
|
4400
|
+
function toRelaySocketUrl(url) {
|
|
4401
|
+
const wsUrl = toWsUrl(url).replace(/\/+$/, "");
|
|
4402
|
+
if (/\/relay\/sync$/i.test(wsUrl)) {
|
|
4403
|
+
return wsUrl;
|
|
4404
|
+
}
|
|
4405
|
+
if (/\/relay$/i.test(wsUrl)) {
|
|
4406
|
+
return `${wsUrl}/sync`;
|
|
4407
|
+
}
|
|
4408
|
+
if (/\/sync$/i.test(wsUrl)) {
|
|
4409
|
+
return wsUrl.replace(/\/sync$/i, "/relay/sync");
|
|
4410
|
+
}
|
|
4411
|
+
return `${wsUrl}/relay/sync`;
|
|
4412
|
+
}
|
|
4413
|
+
function asRecord(value) {
|
|
4414
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
4415
|
+
return null;
|
|
4416
|
+
}
|
|
4417
|
+
return value;
|
|
4418
|
+
}
|
|
4419
|
+
export {
|
|
4420
|
+
AutomergeProvider
|
|
4421
|
+
};
|