@pluv/crdt-loro 3.2.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +17 -16
- package/CHANGELOG.md +27 -0
- package/dist/chunk-15K8U1wQ.mjs +18 -0
- package/dist/index.d.mts +73 -74
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +295 -342
- package/dist/index.mjs.map +1 -0
- package/package.json +20 -16
- package/tsdown.config.ts +14 -0
- package/dist/index.d.ts +0 -94
- package/dist/index.js +0 -377
package/dist/index.mjs
CHANGED
|
@@ -1,366 +1,319 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __typeError = (msg) => {
|
|
8
|
-
throw TypeError(msg);
|
|
9
|
-
};
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var __export = (target, all) => {
|
|
24
|
-
for (var name in all)
|
|
25
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
-
};
|
|
27
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
28
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
29
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
30
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
31
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
32
|
-
|
|
33
|
-
// src/loro.ts
|
|
34
|
-
var loro_exports = {};
|
|
35
|
-
__export(loro_exports, {
|
|
36
|
-
CrdtLoroDoc: () => CrdtLoroDoc,
|
|
37
|
-
counter: () => counter,
|
|
38
|
-
doc: () => doc,
|
|
39
|
-
kind: () => kind,
|
|
40
|
-
list: () => list,
|
|
41
|
-
map: () => map,
|
|
42
|
-
movableList: () => movableList,
|
|
43
|
-
object: () => object,
|
|
44
|
-
text: () => text,
|
|
45
|
-
tree: () => tree
|
|
46
|
-
});
|
|
1
|
+
import { t as __exportAll } from "./chunk-15K8U1wQ.mjs";
|
|
2
|
+
import { LoroCounter, LoroDoc, LoroList, LoroMap, LoroMovableList, LoroText, LoroTree, UndoManager, isContainer } from "loro-crdt";
|
|
3
|
+
import { fromUint8Array, toUint8Array } from "js-base64";
|
|
4
|
+
import { AbstractCrdtDocFactory } from "@pluv/crdt";
|
|
47
5
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const counter2 = new LoroCounter();
|
|
52
|
-
return counter2;
|
|
6
|
+
//#region src/counter.ts
|
|
7
|
+
const counter = () => {
|
|
8
|
+
return new LoroCounter();
|
|
53
9
|
};
|
|
54
10
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
else list2.insert(i, item);
|
|
96
|
-
});
|
|
97
|
-
return list2;
|
|
98
|
-
},
|
|
99
|
-
text(name, value = "") {
|
|
100
|
-
const text2 = doc2.getText(name);
|
|
101
|
-
text2.insert(0, value);
|
|
102
|
-
return text2;
|
|
103
|
-
},
|
|
104
|
-
tree(name) {
|
|
105
|
-
return doc2.getTree(name);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/doc/builder.ts
|
|
13
|
+
const builder = (doc$1) => {
|
|
14
|
+
return {
|
|
15
|
+
counter(name) {
|
|
16
|
+
return doc$1.getCounter(name);
|
|
17
|
+
},
|
|
18
|
+
list(name, value = []) {
|
|
19
|
+
const list$1 = doc$1.getList(name);
|
|
20
|
+
value.forEach((item, i) => {
|
|
21
|
+
if (isContainer(item)) list$1.insertContainer(i, item);
|
|
22
|
+
else list$1.insert(i, item);
|
|
23
|
+
});
|
|
24
|
+
return list$1;
|
|
25
|
+
},
|
|
26
|
+
map(name, value = {}) {
|
|
27
|
+
const container = doc$1.getMap(name);
|
|
28
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
29
|
+
if (isContainer(item)) container.setContainer(key, item);
|
|
30
|
+
else container.set(key, item);
|
|
31
|
+
});
|
|
32
|
+
return container;
|
|
33
|
+
},
|
|
34
|
+
moveableList(name, value = []) {
|
|
35
|
+
const list$1 = doc$1.getMovableList(name);
|
|
36
|
+
value.forEach((item, i) => {
|
|
37
|
+
if (isContainer(item)) list$1.insertContainer(i, item);
|
|
38
|
+
else list$1.insert(i, item);
|
|
39
|
+
});
|
|
40
|
+
return list$1;
|
|
41
|
+
},
|
|
42
|
+
text(name, value = "") {
|
|
43
|
+
const text$1 = doc$1.getText(name);
|
|
44
|
+
text$1.insert(0, value);
|
|
45
|
+
return text$1;
|
|
46
|
+
},
|
|
47
|
+
tree(name) {
|
|
48
|
+
return doc$1.getTree(name);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
108
51
|
};
|
|
109
52
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/doc/CrdtLoroDoc.ts
|
|
55
|
+
const MAX_UNDO_STEPS = 100;
|
|
56
|
+
const MERGE_INTERVAL_MS = 1e3;
|
|
57
|
+
const PLUV_ID_FIELD = "__$pluv";
|
|
115
58
|
var CrdtLoroDoc = class {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
_CrdtLoroDoc_instances = new WeakSet();
|
|
274
|
-
_setPluvId_fn = function() {
|
|
275
|
-
const text2 = this.value.getText(PLUV_ID_FIELD);
|
|
276
|
-
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
277
|
-
text2.insert(0, id);
|
|
59
|
+
value = new LoroDoc();
|
|
60
|
+
#_storage;
|
|
61
|
+
#_undoManager = null;
|
|
62
|
+
constructor(params = () => ({})) {
|
|
63
|
+
const storage = params(builder(this.value));
|
|
64
|
+
const keys = Object.keys(this.value.toJSON()).reduce((set, key) => set.add(key), /* @__PURE__ */ new Set());
|
|
65
|
+
this.#_storage = Object.entries(storage).reduce((acc, [key, node]) => keys.has(key) ? {
|
|
66
|
+
...acc,
|
|
67
|
+
[key]: node
|
|
68
|
+
} : acc, {});
|
|
69
|
+
if (!!Object.keys(storage).length) this.#_setPluvId();
|
|
70
|
+
this.value.commit();
|
|
71
|
+
}
|
|
72
|
+
applyEncodedState(params) {
|
|
73
|
+
const update = typeof params.update === "string" ? toUint8Array(params.update) : params.update;
|
|
74
|
+
if (!update) return this;
|
|
75
|
+
this.value.import(update);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
batchApplyEncodedState(params) {
|
|
79
|
+
const filtered = (params.updates ?? []).reduce((acc, update) => {
|
|
80
|
+
if (!update) return acc;
|
|
81
|
+
if (typeof update === "string") {
|
|
82
|
+
acc.push(toUint8Array(update));
|
|
83
|
+
return acc;
|
|
84
|
+
}
|
|
85
|
+
if (typeof update === "object") {
|
|
86
|
+
acc.push(update);
|
|
87
|
+
return acc;
|
|
88
|
+
}
|
|
89
|
+
return acc;
|
|
90
|
+
}, []);
|
|
91
|
+
if (!filtered.length) return this;
|
|
92
|
+
if (filtered.length === 1) {
|
|
93
|
+
const update = filtered[0] ?? null;
|
|
94
|
+
if (!!update) this.value.import(update);
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
this.value.importBatch(filtered);
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
canRedo() {
|
|
101
|
+
if (!this.#_undoManager) return false;
|
|
102
|
+
return this.#_undoManager.canRedo();
|
|
103
|
+
}
|
|
104
|
+
canUndo() {
|
|
105
|
+
if (!this.#_undoManager) return false;
|
|
106
|
+
return this.#_undoManager.canUndo();
|
|
107
|
+
}
|
|
108
|
+
destroy() {}
|
|
109
|
+
get(key) {
|
|
110
|
+
if (typeof key === "undefined") return this.#_storage;
|
|
111
|
+
return this.#_storage[key];
|
|
112
|
+
}
|
|
113
|
+
getEncodedState() {
|
|
114
|
+
return fromUint8Array(this.value.export({ mode: "snapshot" }));
|
|
115
|
+
}
|
|
116
|
+
toJson(type) {
|
|
117
|
+
if (typeof type === "string") {
|
|
118
|
+
const container = this.#_storage[type];
|
|
119
|
+
return container instanceof LoroText ? container.toString() : container instanceof LoroCounter ? container.value : container.toJSON();
|
|
120
|
+
}
|
|
121
|
+
return Object.entries(this.#_storage).reduce((acc, [key, value]) => ({
|
|
122
|
+
...acc,
|
|
123
|
+
[key]: value instanceof LoroText ? value.toString() : value.toJSON()
|
|
124
|
+
}), {});
|
|
125
|
+
}
|
|
126
|
+
isEmpty() {
|
|
127
|
+
const serialized = this.value.toJSON();
|
|
128
|
+
return !serialized || !Object.keys(serialized).length;
|
|
129
|
+
}
|
|
130
|
+
rebuildStorage(reference) {
|
|
131
|
+
if (!!Object.keys(this.#_storage).length) {
|
|
132
|
+
console.warn("Attempted to rebuild storage multiple times");
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
this.#_storage = Object.entries(reference).reduce((acc, [key, node]) => {
|
|
136
|
+
if (node instanceof LoroCounter) return {
|
|
137
|
+
...acc,
|
|
138
|
+
[key]: this.value.getCounter(key)
|
|
139
|
+
};
|
|
140
|
+
if (node instanceof LoroList) return {
|
|
141
|
+
...acc,
|
|
142
|
+
[key]: this.value.getList(key)
|
|
143
|
+
};
|
|
144
|
+
if (node instanceof LoroMap) return {
|
|
145
|
+
...acc,
|
|
146
|
+
[key]: this.value.getMap(key)
|
|
147
|
+
};
|
|
148
|
+
if (node instanceof LoroMovableList) return {
|
|
149
|
+
...acc,
|
|
150
|
+
[key]: this.value.getMovableList(key)
|
|
151
|
+
};
|
|
152
|
+
if (node instanceof LoroText) return {
|
|
153
|
+
...acc,
|
|
154
|
+
[key]: this.value.getText(key)
|
|
155
|
+
};
|
|
156
|
+
if (node instanceof LoroTree) return {
|
|
157
|
+
...acc,
|
|
158
|
+
[key]: this.value.getTree(key)
|
|
159
|
+
};
|
|
160
|
+
return acc;
|
|
161
|
+
}, {});
|
|
162
|
+
return this.track();
|
|
163
|
+
}
|
|
164
|
+
redo() {
|
|
165
|
+
this.#_undoManager?.redo();
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
subscribe(listener) {
|
|
169
|
+
const fn = (event) => {
|
|
170
|
+
const update = fromUint8Array(this.value.export({ mode: "update" }));
|
|
171
|
+
listener({
|
|
172
|
+
doc: this,
|
|
173
|
+
local: event.by === "local",
|
|
174
|
+
origin: event.origin ? String(event.origin) : null,
|
|
175
|
+
update
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
return Object.values(this.#_storage).reduce((acc, crdtType) => {
|
|
179
|
+
const unsubscribe = crdtType.subscribe(fn);
|
|
180
|
+
return () => {
|
|
181
|
+
acc();
|
|
182
|
+
unsubscribe();
|
|
183
|
+
};
|
|
184
|
+
}, () => void 0);
|
|
185
|
+
}
|
|
186
|
+
track() {
|
|
187
|
+
if (this.#_undoManager) {
|
|
188
|
+
this.#_undoManager.clear();
|
|
189
|
+
this.#_undoManager.free();
|
|
190
|
+
this.#_undoManager = null;
|
|
191
|
+
}
|
|
192
|
+
this.#_undoManager = new UndoManager(this.value, {
|
|
193
|
+
maxUndoSteps: MAX_UNDO_STEPS,
|
|
194
|
+
mergeInterval: MERGE_INTERVAL_MS
|
|
195
|
+
});
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* @description Unlike Yjs, this method is required to be called after each loro operation.
|
|
200
|
+
* @date January 12, 2025
|
|
201
|
+
*/
|
|
202
|
+
transact(fn) {
|
|
203
|
+
fn();
|
|
204
|
+
this.value.commit();
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
undo() {
|
|
208
|
+
this.#_undoManager?.undo();
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
#_setPluvId() {
|
|
212
|
+
const text$1 = this.value.getText(PLUV_ID_FIELD);
|
|
213
|
+
const id = typeof crypto !== "undefined" ? crypto.randomUUID() : Math.random().toString();
|
|
214
|
+
text$1.insert(0, id);
|
|
215
|
+
}
|
|
278
216
|
};
|
|
279
217
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
var CrdtLoroDocFactory = class
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/doc/CrdtLoroDocFactory.ts
|
|
220
|
+
var CrdtLoroDocFactory = class CrdtLoroDocFactory extends AbstractCrdtDocFactory {
|
|
221
|
+
_initialStorage;
|
|
222
|
+
constructor(initialStorage = () => ({})) {
|
|
223
|
+
super(initialStorage);
|
|
224
|
+
this._initialStorage = initialStorage;
|
|
225
|
+
}
|
|
226
|
+
getEmpty() {
|
|
227
|
+
return new CrdtLoroDoc();
|
|
228
|
+
}
|
|
229
|
+
getFactory(initialStorage) {
|
|
230
|
+
return new CrdtLoroDocFactory(initialStorage ?? this._initialStorage);
|
|
231
|
+
}
|
|
232
|
+
getInitialized(initialStorage) {
|
|
233
|
+
return new CrdtLoroDoc(initialStorage ?? this._initialStorage);
|
|
234
|
+
}
|
|
296
235
|
};
|
|
297
236
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/doc/doc.ts
|
|
239
|
+
const doc = (value = () => ({})) => {
|
|
240
|
+
return new CrdtLoroDocFactory(value);
|
|
301
241
|
};
|
|
302
242
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/list.ts
|
|
245
|
+
const list = (value = []) => {
|
|
246
|
+
const container = new LoroList();
|
|
247
|
+
value.forEach((item, i) => {
|
|
248
|
+
if (isContainer(item)) container.insertContainer(i, item);
|
|
249
|
+
else container.insert(i, item);
|
|
250
|
+
});
|
|
251
|
+
return container;
|
|
312
252
|
};
|
|
313
253
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/map.ts
|
|
256
|
+
const map = (value = []) => {
|
|
257
|
+
const container = new LoroMap();
|
|
258
|
+
value.forEach(([key, item]) => {
|
|
259
|
+
if (isContainer(item)) container.setContainer(key, item);
|
|
260
|
+
else container.set(key, item);
|
|
261
|
+
});
|
|
262
|
+
return container;
|
|
323
263
|
};
|
|
324
264
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/movableList.ts
|
|
267
|
+
const movableList = (value = []) => {
|
|
268
|
+
const container = new LoroMovableList();
|
|
269
|
+
value.forEach((item, i) => {
|
|
270
|
+
if (isContainer(item)) container.insertContainer(i, item);
|
|
271
|
+
else container.insert(i, item);
|
|
272
|
+
});
|
|
273
|
+
return container;
|
|
334
274
|
};
|
|
335
275
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/object.ts
|
|
278
|
+
const object = (value) => {
|
|
279
|
+
const container = new LoroMap();
|
|
280
|
+
Object.entries(value).forEach(([key, item]) => {
|
|
281
|
+
if (isContainer(item)) container.setContainer(key, item);
|
|
282
|
+
else container.set(key, item);
|
|
283
|
+
});
|
|
284
|
+
return container;
|
|
345
285
|
};
|
|
346
286
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/text.ts
|
|
289
|
+
const text = (value = "") => {
|
|
290
|
+
const container = new LoroText();
|
|
291
|
+
container.insert(0, value);
|
|
292
|
+
return container;
|
|
353
293
|
};
|
|
354
294
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
return container;
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/tree.ts
|
|
297
|
+
const tree = () => {
|
|
298
|
+
return new LoroTree();
|
|
360
299
|
};
|
|
361
300
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/loro.ts
|
|
303
|
+
var loro_exports = /* @__PURE__ */ __exportAll({
|
|
304
|
+
CrdtLoroDoc: () => CrdtLoroDoc,
|
|
305
|
+
counter: () => counter,
|
|
306
|
+
doc: () => doc,
|
|
307
|
+
kind: () => kind,
|
|
308
|
+
list: () => list,
|
|
309
|
+
map: () => map,
|
|
310
|
+
movableList: () => movableList,
|
|
311
|
+
object: () => object,
|
|
312
|
+
text: () => text,
|
|
313
|
+
tree: () => tree
|
|
314
|
+
});
|
|
315
|
+
const kind = "loro";
|
|
316
|
+
|
|
317
|
+
//#endregion
|
|
318
|
+
export { loro_exports as loro };
|
|
319
|
+
//# sourceMappingURL=index.mjs.map
|