@vuer-ai/vuer-rtc 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuer-ai/vuer-rtc",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "CRDT-based real-time collaborative data structures",
@@ -27,8 +27,22 @@
27
27
  "./hooks": {
28
28
  "types": "./dist/hooks.d.ts",
29
29
  "import": "./dist/hooks.js"
30
+ },
31
+ "./serdes": {
32
+ "types": "./dist/serdes.d.ts",
33
+ "import": "./dist/serdes.js"
34
+ },
35
+ "./sync": {
36
+ "types": "./dist/sync/index.d.ts",
37
+ "import": "./dist/sync/index.js"
30
38
  }
31
39
  },
40
+ "scripts": {
41
+ "build": "tsc",
42
+ "dev": "tsc --watch",
43
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
44
+ "test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch"
45
+ },
32
46
  "peerDependencies": {
33
47
  "react": ">=18.0.0"
34
48
  },
@@ -49,11 +63,5 @@
49
63
  "dependencies": {
50
64
  "@msgpack/msgpack": "^3.1.3",
51
65
  "nanoid": "^5.1.6"
52
- },
53
- "scripts": {
54
- "build": "tsc",
55
- "dev": "tsc --watch",
56
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
57
- "test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch"
58
66
  }
59
- }
67
+ }
@@ -1,8 +0,0 @@
1
- # pytest cache directory #
2
-
3
- This directory contains data from the pytest's cache plugin,
4
- which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
-
6
- **Do not** commit this to version control.
7
-
8
- See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
@@ -1,102 +0,0 @@
1
- /**
2
- * ContentTree - B-tree optimized for CRDT text operations
3
- *
4
- * Stores Items in document order with dual-count annotations (visible chars
5
- * and total items) at each node for O(log n) position lookup and insertion.
6
- *
7
- * Follows Seph Gentle's diamond-types content-tree design:
8
- * - Leaf nodes hold up to MAX_LEAF items
9
- * - Internal nodes hold up to MAX_INTERNAL children
10
- * - Each node caches { visChars, totalItems } for its subtree
11
- * - Parent pointers enable O(log n) ordinal computation
12
- */
13
- /** Minimal item interface — tree only needs content + deleted state */
14
- export interface TreeItem {
15
- content: string;
16
- isDeleted: boolean;
17
- }
18
- export interface Counts {
19
- visChars: number;
20
- totalItems: number;
21
- }
22
- export interface LeafNode {
23
- type: 'leaf';
24
- items: TreeItem[];
25
- counts: Counts;
26
- parent: InternalNode | null;
27
- }
28
- export interface InternalNode {
29
- type: 'internal';
30
- children: TreeNode[];
31
- childCounts: Counts[];
32
- counts: Counts;
33
- parent: InternalNode | null;
34
- }
35
- export type TreeNode = LeafNode | InternalNode;
36
- export interface ItemTree {
37
- root: TreeNode;
38
- _itemLeaf: WeakMap<TreeItem, LeafNode>;
39
- }
40
- export interface VisiblePosResult {
41
- ordinal: number;
42
- item: TreeItem;
43
- charOffset: number;
44
- }
45
- export declare function createTree(): ItemTree;
46
- /**
47
- * Build a balanced tree from a pre-ordered flat array. O(n).
48
- */
49
- export declare function bulkLoad(items: TreeItem[]): ItemTree;
50
- /**
51
- * Insert an item at the given ordinal position. O(log n).
52
- */
53
- export declare function insertAt(tree: ItemTree, ordinal: number, item: TreeItem): void;
54
- /**
55
- * Replace one item at the given ordinal with two items (for CRDT span splitting).
56
- * O(log n).
57
- */
58
- export declare function splitAtOrdinal(tree: ItemTree, ordinal: number, leftItem: TreeItem, rightItem: TreeItem): void;
59
- /**
60
- * Recalculate tree counts after mutating an item (e.g. marking deleted).
61
- * Call this AFTER changing the item's state.
62
- *
63
- * Recalculates from the containing leaf up to the root. We cannot use
64
- * in-place decrement because parent.childCounts[i] is the same reference
65
- * as child.counts — in-place would double-count.
66
- */
67
- export declare function recalcCountsFor(tree: ItemTree, item: TreeItem): void;
68
- /**
69
- * Get the item at the given ordinal. O(log n).
70
- */
71
- export declare function getAt(tree: ItemTree, ordinal: number): TreeItem;
72
- /**
73
- * Total visible characters. O(1).
74
- */
75
- export declare function totalVisChars(tree: ItemTree): number;
76
- /**
77
- * Total items (including deleted). O(1).
78
- */
79
- export declare function totalItems(tree: ItemTree): number;
80
- /**
81
- * Find an item by visible character position. O(log n).
82
- * Returns null if position is beyond the end.
83
- */
84
- export declare function findByVisiblePos(tree: ItemTree, charPos: number): VisiblePosResult | null;
85
- /**
86
- * Compute the ordinal (total-item position) of an item. O(log n).
87
- * Uses parent pointers to walk up from the containing leaf.
88
- */
89
- export declare function computeOrdinal(tree: ItemTree, item: TreeItem): number;
90
- /**
91
- * Iterate all items in document order. O(n).
92
- */
93
- export declare function iterateAll(tree: ItemTree): Generator<TreeItem>;
94
- /**
95
- * Iterate items starting from a given ordinal. O(log n) to seek + O(k) to iterate.
96
- */
97
- export declare function iterateFrom(tree: ItemTree, startOrdinal: number): Generator<TreeItem>;
98
- /**
99
- * Collect all items into a flat array. O(n).
100
- */
101
- export declare function flattenItems(tree: ItemTree): TreeItem[];
102
- //# sourceMappingURL=ContentTree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentTree.d.ts","sourceRoot":"","sources":["../../src/crdt/ContentTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,uEAAuE;AACvE,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CAC7B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CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAEjD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,MAAM,GACd,gBAAgB,GAAG,IAAI,CA4BzB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAqBrE;AAMD;;GAEG;AACH,wBAAiB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,CAE/D;AAYD;;GAEG;AACH,wBAAiB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAYtF;AAuBD;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAIvD"}
@@ -1,461 +0,0 @@
1
- /**
2
- * ContentTree - B-tree optimized for CRDT text operations
3
- *
4
- * Stores Items in document order with dual-count annotations (visible chars
5
- * and total items) at each node for O(log n) position lookup and insertion.
6
- *
7
- * Follows Seph Gentle's diamond-types content-tree design:
8
- * - Leaf nodes hold up to MAX_LEAF items
9
- * - Internal nodes hold up to MAX_INTERNAL children
10
- * - Each node caches { visChars, totalItems } for its subtree
11
- * - Parent pointers enable O(log n) ordinal computation
12
- */
13
- // ============================================
14
- // Constants
15
- // ============================================
16
- const MAX_LEAF = 32;
17
- const MAX_INTERNAL = 16;
18
- const LEAF_SPLIT = MAX_LEAF >>> 1;
19
- const INTERNAL_SPLIT = MAX_INTERNAL >>> 1;
20
- // ============================================
21
- // Internal helpers
22
- // ============================================
23
- function leafCounts(items) {
24
- let visChars = 0;
25
- for (let i = 0; i < items.length; i++) {
26
- if (!items[i].isDeleted)
27
- visChars += items[i].content.length;
28
- }
29
- return { visChars, totalItems: items.length };
30
- }
31
- function sumChildCounts(childCounts) {
32
- let visChars = 0, totalItems = 0;
33
- for (let i = 0; i < childCounts.length; i++) {
34
- visChars += childCounts[i].visChars;
35
- totalItems += childCounts[i].totalItems;
36
- }
37
- return { visChars, totalItems };
38
- }
39
- /**
40
- * Find the leaf and local index for a given ordinal (total-item position).
41
- * Returns the accumulated ordinal prefix for computing the global ordinal.
42
- */
43
- function findLeafByOrdinal(node, ordinal) {
44
- while (node.type === 'internal') {
45
- let remaining = ordinal;
46
- let found = false;
47
- for (let i = 0; i < node.children.length; i++) {
48
- const count = node.childCounts[i].totalItems;
49
- if (remaining < count) {
50
- node = node.children[i];
51
- ordinal = remaining;
52
- found = true;
53
- break;
54
- }
55
- remaining -= count;
56
- }
57
- if (!found) {
58
- // Ordinal at the very end — go to last child
59
- const internal = node;
60
- node = internal.children[internal.children.length - 1];
61
- ordinal = node.type === 'leaf' ? node.items.length : node.counts.totalItems;
62
- }
63
- }
64
- return { leaf: node, localIdx: ordinal };
65
- }
66
- /**
67
- * Find the leaf and local index for a given visible char position.
68
- * Also returns the ordinal (total-item index) for the found item.
69
- */
70
- function findLeafByVisiblePos(node, charPos) {
71
- let ordinalPrefix = 0;
72
- while (node.type === 'internal') {
73
- let remaining = charPos;
74
- for (let i = 0; i < node.children.length; i++) {
75
- const vis = node.childCounts[i].visChars;
76
- if (remaining < vis || i === node.children.length - 1) {
77
- node = node.children[i];
78
- charPos = remaining;
79
- break;
80
- }
81
- remaining -= vis;
82
- ordinalPrefix += node.childCounts[i].totalItems;
83
- }
84
- }
85
- return { leaf: node, ordinalPrefix, remainingChars: charPos };
86
- }
87
- /**
88
- * Update counts from a leaf up to the root after a mutation.
89
- */
90
- function updateCountsUp(leaf) {
91
- leaf.counts = leafCounts(leaf.items);
92
- let child = leaf;
93
- let parent = leaf.parent;
94
- while (parent) {
95
- // Find the child index and update its count
96
- for (let i = 0; i < parent.children.length; i++) {
97
- if (parent.children[i] === child) {
98
- parent.childCounts[i] = child.counts;
99
- break;
100
- }
101
- }
102
- parent.counts = sumChildCounts(parent.childCounts);
103
- child = parent;
104
- parent = parent.parent;
105
- }
106
- }
107
- /**
108
- * Split a leaf that has exceeded MAX_LEAF items.
109
- * Returns the new right leaf. The tree is updated via parent insertion.
110
- */
111
- function splitLeaf(tree, leaf) {
112
- const rightItems = leaf.items.splice(LEAF_SPLIT);
113
- const rightLeaf = {
114
- type: 'leaf',
115
- items: rightItems,
116
- counts: leafCounts(rightItems),
117
- parent: null, // set below
118
- };
119
- leaf.counts = leafCounts(leaf.items);
120
- // Update _itemLeaf for moved items
121
- for (let i = 0; i < rightItems.length; i++) {
122
- tree._itemLeaf.set(rightItems[i], rightLeaf);
123
- }
124
- insertChildAfter(tree, leaf, rightLeaf);
125
- }
126
- /**
127
- * Insert a new child node into its parent (or create a new root).
128
- */
129
- function insertChildAfter(tree, leftChild, rightChild) {
130
- const parent = leftChild.parent;
131
- if (!parent) {
132
- // Create new root
133
- const newRoot = {
134
- type: 'internal',
135
- children: [leftChild, rightChild],
136
- childCounts: [leftChild.counts, rightChild.counts],
137
- counts: { visChars: 0, totalItems: 0 },
138
- parent: null,
139
- };
140
- newRoot.counts = sumChildCounts(newRoot.childCounts);
141
- leftChild.parent = newRoot;
142
- rightChild.parent = newRoot;
143
- tree.root = newRoot;
144
- return;
145
- }
146
- // Find leftChild's index in parent
147
- let idx = -1;
148
- for (let i = 0; i < parent.children.length; i++) {
149
- if (parent.children[i] === leftChild) {
150
- idx = i;
151
- break;
152
- }
153
- }
154
- // Insert rightChild after leftChild
155
- parent.children.splice(idx + 1, 0, rightChild);
156
- parent.childCounts.splice(idx + 1, 0, rightChild.counts);
157
- rightChild.parent = parent;
158
- // Update parent counts
159
- parent.childCounts[idx] = leftChild.counts;
160
- parent.counts = sumChildCounts(parent.childCounts);
161
- // Check overflow
162
- if (parent.children.length > MAX_INTERNAL) {
163
- splitInternal(tree, parent);
164
- }
165
- else {
166
- // Propagate count changes up
167
- let child = parent;
168
- let p = parent.parent;
169
- while (p) {
170
- for (let i = 0; i < p.children.length; i++) {
171
- if (p.children[i] === child) {
172
- p.childCounts[i] = child.counts;
173
- break;
174
- }
175
- }
176
- p.counts = sumChildCounts(p.childCounts);
177
- child = p;
178
- p = p.parent;
179
- }
180
- }
181
- }
182
- /**
183
- * Split an internal node that has exceeded MAX_INTERNAL children.
184
- */
185
- function splitInternal(tree, node) {
186
- const rightChildren = node.children.splice(INTERNAL_SPLIT);
187
- const rightCounts = node.childCounts.splice(INTERNAL_SPLIT);
188
- const rightNode = {
189
- type: 'internal',
190
- children: rightChildren,
191
- childCounts: rightCounts,
192
- counts: sumChildCounts(rightCounts),
193
- parent: null,
194
- };
195
- // Update parent pointers for moved children
196
- for (let i = 0; i < rightChildren.length; i++) {
197
- rightChildren[i].parent = rightNode;
198
- }
199
- node.counts = sumChildCounts(node.childCounts);
200
- insertChildAfter(tree, node, rightNode);
201
- }
202
- // ============================================
203
- // Public API — Creation
204
- // ============================================
205
- export function createTree() {
206
- const leaf = {
207
- type: 'leaf',
208
- items: [],
209
- counts: { visChars: 0, totalItems: 0 },
210
- parent: null,
211
- };
212
- return { root: leaf, _itemLeaf: new WeakMap() };
213
- }
214
- /**
215
- * Build a balanced tree from a pre-ordered flat array. O(n).
216
- */
217
- export function bulkLoad(items) {
218
- const tree = { root: null, _itemLeaf: new WeakMap() };
219
- if (items.length === 0) {
220
- tree.root = { type: 'leaf', items: [], counts: { visChars: 0, totalItems: 0 }, parent: null };
221
- return tree;
222
- }
223
- // Create leaves
224
- const leaves = [];
225
- for (let i = 0; i < items.length; i += MAX_LEAF) {
226
- const chunk = items.slice(i, Math.min(i + MAX_LEAF, items.length));
227
- const leaf = {
228
- type: 'leaf',
229
- items: chunk,
230
- counts: leafCounts(chunk),
231
- parent: null,
232
- };
233
- for (let j = 0; j < chunk.length; j++) {
234
- tree._itemLeaf.set(chunk[j], leaf);
235
- }
236
- leaves.push(leaf);
237
- }
238
- if (leaves.length === 1) {
239
- tree.root = leaves[0];
240
- return tree;
241
- }
242
- // Build internal nodes bottom-up
243
- let currentLevel = leaves;
244
- while (currentLevel.length > 1) {
245
- const nextLevel = [];
246
- for (let i = 0; i < currentLevel.length; i += MAX_INTERNAL) {
247
- const children = currentLevel.slice(i, Math.min(i + MAX_INTERNAL, currentLevel.length));
248
- const childCounts = children.map(c => ({ ...c.counts }));
249
- const node = {
250
- type: 'internal',
251
- children,
252
- childCounts,
253
- counts: sumChildCounts(childCounts),
254
- parent: null,
255
- };
256
- for (let j = 0; j < children.length; j++) {
257
- children[j].parent = node;
258
- }
259
- nextLevel.push(node);
260
- }
261
- currentLevel = nextLevel;
262
- }
263
- tree.root = currentLevel[0];
264
- return tree;
265
- }
266
- // ============================================
267
- // Public API — Mutation
268
- // ============================================
269
- /**
270
- * Insert an item at the given ordinal position. O(log n).
271
- */
272
- export function insertAt(tree, ordinal, item) {
273
- const { leaf, localIdx } = findLeafByOrdinal(tree.root, ordinal);
274
- leaf.items.splice(localIdx, 0, item);
275
- tree._itemLeaf.set(item, leaf);
276
- updateCountsUp(leaf);
277
- if (leaf.items.length > MAX_LEAF) {
278
- splitLeaf(tree, leaf);
279
- }
280
- }
281
- /**
282
- * Replace one item at the given ordinal with two items (for CRDT span splitting).
283
- * O(log n).
284
- */
285
- export function splitAtOrdinal(tree, ordinal, leftItem, rightItem) {
286
- const { leaf, localIdx } = findLeafByOrdinal(tree.root, ordinal);
287
- // Replace with left, insert right after
288
- leaf.items.splice(localIdx, 1, leftItem, rightItem);
289
- tree._itemLeaf.set(leftItem, leaf);
290
- tree._itemLeaf.set(rightItem, leaf);
291
- updateCountsUp(leaf);
292
- if (leaf.items.length > MAX_LEAF) {
293
- splitLeaf(tree, leaf);
294
- }
295
- }
296
- /**
297
- * Recalculate tree counts after mutating an item (e.g. marking deleted).
298
- * Call this AFTER changing the item's state.
299
- *
300
- * Recalculates from the containing leaf up to the root. We cannot use
301
- * in-place decrement because parent.childCounts[i] is the same reference
302
- * as child.counts — in-place would double-count.
303
- */
304
- export function recalcCountsFor(tree, item) {
305
- const leaf = tree._itemLeaf.get(item);
306
- if (!leaf)
307
- return;
308
- updateCountsUp(leaf);
309
- }
310
- // ============================================
311
- // Public API — Query
312
- // ============================================
313
- /**
314
- * Get the item at the given ordinal. O(log n).
315
- */
316
- export function getAt(tree, ordinal) {
317
- const { leaf, localIdx } = findLeafByOrdinal(tree.root, ordinal);
318
- return leaf.items[localIdx];
319
- }
320
- /**
321
- * Total visible characters. O(1).
322
- */
323
- export function totalVisChars(tree) {
324
- return tree.root.counts.visChars;
325
- }
326
- /**
327
- * Total items (including deleted). O(1).
328
- */
329
- export function totalItems(tree) {
330
- return tree.root.counts.totalItems;
331
- }
332
- /**
333
- * Find an item by visible character position. O(log n).
334
- * Returns null if position is beyond the end.
335
- */
336
- export function findByVisiblePos(tree, charPos) {
337
- if (charPos < 0 || tree.root.counts.visChars === 0)
338
- return null;
339
- const { leaf, ordinalPrefix, remainingChars } = findLeafByVisiblePos(tree.root, charPos);
340
- let visPos = remainingChars;
341
- for (let i = 0; i < leaf.items.length; i++) {
342
- const item = leaf.items[i];
343
- if (item.isDeleted)
344
- continue;
345
- const len = item.content.length;
346
- if (visPos < len) {
347
- return { ordinal: ordinalPrefix + i, item, charOffset: visPos };
348
- }
349
- visPos -= len;
350
- }
351
- // Position at the very end — return last visible item
352
- for (let i = leaf.items.length - 1; i >= 0; i--) {
353
- if (!leaf.items[i].isDeleted) {
354
- return {
355
- ordinal: ordinalPrefix + i,
356
- item: leaf.items[i],
357
- charOffset: leaf.items[i].content.length,
358
- };
359
- }
360
- }
361
- return null;
362
- }
363
- /**
364
- * Compute the ordinal (total-item position) of an item. O(log n).
365
- * Uses parent pointers to walk up from the containing leaf.
366
- */
367
- export function computeOrdinal(tree, item) {
368
- const leaf = tree._itemLeaf.get(item);
369
- if (!leaf)
370
- return -1;
371
- const localIdx = leaf.items.indexOf(item);
372
- if (localIdx === -1)
373
- return -1;
374
- let ordinal = localIdx;
375
- let child = leaf;
376
- let parent = child.parent;
377
- while (parent) {
378
- for (let i = 0; i < parent.children.length; i++) {
379
- if (parent.children[i] === child)
380
- break;
381
- ordinal += parent.childCounts[i].totalItems;
382
- }
383
- child = parent;
384
- parent = parent.parent;
385
- }
386
- return ordinal;
387
- }
388
- // ============================================
389
- // Public API — Iteration
390
- // ============================================
391
- /**
392
- * Iterate all items in document order. O(n).
393
- */
394
- export function* iterateAll(tree) {
395
- yield* iterateNode(tree.root);
396
- }
397
- function* iterateNode(node) {
398
- if (node.type === 'leaf') {
399
- yield* node.items;
400
- }
401
- else {
402
- for (let i = 0; i < node.children.length; i++) {
403
- yield* iterateNode(node.children[i]);
404
- }
405
- }
406
- }
407
- /**
408
- * Iterate items starting from a given ordinal. O(log n) to seek + O(k) to iterate.
409
- */
410
- export function* iterateFrom(tree, startOrdinal) {
411
- if (startOrdinal >= tree.root.counts.totalItems)
412
- return;
413
- const { leaf, localIdx } = findLeafByOrdinal(tree.root, startOrdinal);
414
- // Yield remaining items in this leaf
415
- for (let i = localIdx; i < leaf.items.length; i++) {
416
- yield leaf.items[i];
417
- }
418
- // Walk to subsequent leaves via parent chain
419
- yield* iterateAfterLeaf(leaf);
420
- }
421
- function* iterateAfterLeaf(leaf) {
422
- let child = leaf;
423
- let parent = child.parent;
424
- while (parent) {
425
- // Find our index in parent
426
- let idx = -1;
427
- for (let i = 0; i < parent.children.length; i++) {
428
- if (parent.children[i] === child) {
429
- idx = i;
430
- break;
431
- }
432
- }
433
- // Yield all subsequent siblings' items
434
- for (let i = idx + 1; i < parent.children.length; i++) {
435
- yield* iterateNode(parent.children[i]);
436
- }
437
- child = parent;
438
- parent = parent.parent;
439
- }
440
- }
441
- /**
442
- * Collect all items into a flat array. O(n).
443
- */
444
- export function flattenItems(tree) {
445
- const result = [];
446
- collectItems(tree.root, result);
447
- return result;
448
- }
449
- function collectItems(node, result) {
450
- if (node.type === 'leaf') {
451
- for (let i = 0; i < node.items.length; i++) {
452
- result.push(node.items[i]);
453
- }
454
- }
455
- else {
456
- for (let i = 0; i < node.children.length; i++) {
457
- collectItems(node.children[i], result);
458
- }
459
- }
460
- }
461
- //# sourceMappingURL=ContentTree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContentTree.js","sourceRoot":"","sources":["../../src/crdt/ContentTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA6CH,+CAA+C;AAC/C,YAAY;AACZ,+CAA+C;AAE/C,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,UAAU,GAAG,QAAQ,KAAK,CAAC,CAAC;AAClC,MAAM,cAAc,GAAG,YAAY,KAAK,CAAC,CAAC;AAE1C,+CAA+C;AAC/C,mBAAmB;AACnB,+CAA+C;AAE/C,SAAS,UAAU,CAAC,KAAiB;IACnC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;YAAE,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAC/D,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,cAAc,CAAC,WAAqB;IAC3C,IAAI,QAAQ,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,QAAQ,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACpC,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAC1C,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAClC,CAAC;AAED;;;G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