@cr_docs_t/dts 0.24.0 → 0.26.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/dist/dts/Fugue/FNode.d.ts +2 -4
- package/dist/dts/Fugue/FNode.d.ts.map +1 -1
- package/dist/dts/Fugue/FNode.js +2 -2
- package/dist/dts/Fugue/FugueList.d.ts +1 -1
- package/dist/dts/Fugue/FugueList.d.ts.map +1 -1
- package/dist/dts/Fugue/FugueList.js +10 -15
- package/dist/dts/Fugue/index.d.ts +0 -1
- package/dist/dts/Fugue/index.d.ts.map +1 -1
- package/dist/dts/Fugue/index.js +1 -1
- package/dist/dts/FugueTree/FTree.d.ts +147 -0
- package/dist/dts/FugueTree/FTree.d.ts.map +1 -0
- package/dist/dts/FugueTree/FTree.js +467 -0
- package/dist/dts/FugueTree/FugueTree.d.ts +127 -0
- package/dist/dts/FugueTree/FugueTree.d.ts.map +1 -0
- package/dist/dts/FugueTree/FugueTree.js +351 -0
- package/dist/dts/FugueTree/index.d.ts +3 -0
- package/dist/dts/FugueTree/index.d.ts.map +1 -0
- package/dist/dts/FugueTree/index.js +2 -0
- package/dist/dts/Serailizers/Fugue/Message.d.ts +1 -1
- package/dist/dts/Serailizers/Fugue/Message.d.ts.map +1 -1
- package/dist/dts/Serailizers/Fugue/Message.js +12 -4
- package/dist/dts/Serailizers/Fugue/State.d.ts +1 -1
- package/dist/dts/Serailizers/Fugue/State.d.ts.map +1 -1
- package/dist/dts/Serailizers/FugueTree/Message.d.ts +13 -0
- package/dist/dts/Serailizers/FugueTree/Message.d.ts.map +1 -0
- package/dist/dts/Serailizers/FugueTree/Message.js +21 -0
- package/dist/dts/Serailizers/FugueTree/State.d.ts +9 -0
- package/dist/dts/Serailizers/FugueTree/State.d.ts.map +1 -0
- package/dist/dts/Serailizers/FugueTree/State.js +16 -0
- package/dist/dts/Serailizers/FugueTree/index.d.ts +3 -0
- package/dist/dts/Serailizers/FugueTree/index.d.ts.map +1 -0
- package/dist/dts/Serailizers/FugueTree/index.js +2 -0
- package/dist/dts/Serailizers/index.d.ts +1 -1
- package/dist/dts/Serailizers/index.d.ts.map +1 -1
- package/dist/dts/Serailizers/index.js +2 -1
- package/dist/dts/TotalOrder/StringTotalOrder.d.ts +2 -2
- package/dist/dts/TotalOrder/StringTotalOrder.d.ts.map +1 -1
- package/dist/dts/index.d.ts +2 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/index.js +2 -1
- package/dist/tests/FugueTree.test.d.ts +2 -0
- package/dist/tests/FugueTree.test.d.ts.map +1 -0
- package/dist/tests/FugueTree.test.js +8 -0
- package/dist/tests/mocks.d.ts +2 -1
- package/dist/tests/mocks.d.ts.map +1 -1
- package/dist/tests/mocks.js +2 -1
- package/dist/types/Fugue/Fugue.d.ts +2 -2
- package/dist/types/Fugue/Fugue.d.ts.map +1 -1
- package/dist/types/FugueTree/Message.d.ts +42 -0
- package/dist/types/FugueTree/Message.d.ts.map +1 -0
- package/dist/types/FugueTree/Message.js +27 -0
- package/dist/types/FugueTree/index.d.ts +2 -0
- package/dist/types/FugueTree/index.d.ts.map +1 -0
- package/dist/types/FugueTree/index.js +1 -0
- package/dist/types/Models/Schema.d.ts +18 -0
- package/dist/types/Models/Schema.d.ts.map +1 -1
- package/dist/types/Models/Schema.js +7 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export declare class FNode<P> {
|
|
1
|
+
export declare class FListNode<P> {
|
|
3
2
|
value?: string;
|
|
4
|
-
operation?: Operation;
|
|
5
3
|
position: P;
|
|
6
|
-
constructor(position: P, value?: string
|
|
4
|
+
constructor(position: P, value?: string);
|
|
7
5
|
}
|
|
8
6
|
//# sourceMappingURL=FNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FNode.d.ts","sourceRoot":"","sources":["../../../src/dts/Fugue/FNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FNode.d.ts","sourceRoot":"","sources":["../../../src/dts/Fugue/FNode.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS,CAAC,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,CAAC;gBAEA,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM;CAI1C"}
|
package/dist/dts/Fugue/FNode.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FugueState, FugueMessage } from "../../types/index.js";
|
|
1
|
+
import { FugueState, FugueMessage } from "../../types/Fugue/index.js";
|
|
2
2
|
import { UniquelyDenseTotalOrder } from "../TotalOrder/UniquelyDenseTotalOrder.js";
|
|
3
3
|
/**
|
|
4
4
|
* A Fugue List CRDT, with insert and delete operations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FugueList.d.ts","sourceRoot":"","sources":["../../../src/dts/Fugue/FugueList.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"FugueList.d.ts","sourceRoot":"","sources":["../../../src/dts/Fugue/FugueList.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAa,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAGnF;;GAEG;AACH,qBAAa,SAAS,CAAC,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAM;IAC1B,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACvC,eAAe,SAAK;IACpB,EAAE,EAAE,SAAS,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,SAAS,OAAO;gBAGrB,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,EACtC,EAAE,EAAE,SAAS,GAAG,IAAI,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM;IAQzB;;;OAGG;IACH,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,oBAAoB;IAmB5B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAqBxB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAenC;;;;;OAKG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAiD3C;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;OAIG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAajD;;;;;OAKG;IACH,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,MAAM,GAAG,SAAS;IAejD;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM;IAqBpB;;;;;OAKG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAqD3C;;;OAGG;IACH,OAAO,IAAI,MAAM;IAmBjB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAcpB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAqGnB;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE;IAW/C,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,cAAc;CAOjB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Operation } from "../../types/index.js";
|
|
3
|
-
import { FugueMessageSerialzier } from "../Serailizers/index.js";
|
|
1
|
+
import { FListNode } from "./FNode.js";
|
|
2
|
+
import { Operation } from "../../types/Fugue/index.js";
|
|
3
|
+
import { FugueMessageSerialzier } from "../Serailizers/Fugue/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* A Fugue List CRDT, with insert and delete operations
|
|
6
6
|
*/
|
|
@@ -59,13 +59,13 @@ export class FugueList {
|
|
|
59
59
|
// Don't insert if it already exists,
|
|
60
60
|
// TODO: ideally this should trigger a collision resolution
|
|
61
61
|
if (!existing) {
|
|
62
|
-
cell.push(new
|
|
62
|
+
cell.push(new FListNode(position, value));
|
|
63
63
|
cell.sort((a, b) => this.totalOrder.compare(a.position, b.position));
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
// Insert new cell at index
|
|
67
67
|
else {
|
|
68
|
-
this.state.splice(index, 0, [new
|
|
68
|
+
this.state.splice(index, 0, [new FListNode(position, value)]);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
@@ -88,7 +88,6 @@ export class FugueList {
|
|
|
88
88
|
*/
|
|
89
89
|
insert(index, value) {
|
|
90
90
|
const pos = this.generatePosition(index);
|
|
91
|
-
console.log({ index, pos });
|
|
92
91
|
this.insertAtPosition(pos, value);
|
|
93
92
|
this.propagate({
|
|
94
93
|
documentID: this.documentID,
|
|
@@ -121,7 +120,7 @@ export class FugueList {
|
|
|
121
120
|
for (const c of value) {
|
|
122
121
|
const pos = this.totalOrder.createBetween(cL, rA);
|
|
123
122
|
// Collect new cells
|
|
124
|
-
newCells.push([new
|
|
123
|
+
newCells.push([new FListNode(pos, c)]);
|
|
125
124
|
// Batch propagate
|
|
126
125
|
msgs.push({
|
|
127
126
|
documentID: this.documentID,
|
|
@@ -158,7 +157,6 @@ export class FugueList {
|
|
|
158
157
|
if (node) {
|
|
159
158
|
// Tombstone the node, TODO: Implement garbage collection
|
|
160
159
|
node.value = undefined;
|
|
161
|
-
node.operation = Operation.DELETE;
|
|
162
160
|
return;
|
|
163
161
|
}
|
|
164
162
|
}
|
|
@@ -205,7 +203,6 @@ export class FugueList {
|
|
|
205
203
|
*/
|
|
206
204
|
delete(index) {
|
|
207
205
|
const position = this.findVisiblePosition(index);
|
|
208
|
-
console.log({ index, position });
|
|
209
206
|
if (!position) {
|
|
210
207
|
console.warn(`No element at position -> ${position}`);
|
|
211
208
|
return;
|
|
@@ -245,7 +242,6 @@ export class FugueList {
|
|
|
245
242
|
const pos = n.position;
|
|
246
243
|
// Tombstone the node
|
|
247
244
|
n.value = undefined;
|
|
248
|
-
n.operation = Operation.DELETE;
|
|
249
245
|
deletedCount++;
|
|
250
246
|
// Batch
|
|
251
247
|
msgs.push({
|
|
@@ -347,7 +343,6 @@ export class FugueList {
|
|
|
347
343
|
const node = cell.find((n) => this.totalOrder.compare(n.position, pos) === 0);
|
|
348
344
|
if (node && node.value !== undefined) {
|
|
349
345
|
node.value = undefined; // Tombstone
|
|
350
|
-
node.operation = Operation.DELETE;
|
|
351
346
|
}
|
|
352
347
|
}
|
|
353
348
|
}
|
|
@@ -369,7 +364,7 @@ export class FugueList {
|
|
|
369
364
|
const existing = cell.find((n) => this.totalOrder.compare(n.position, position) === 0);
|
|
370
365
|
// Don't insert if it already exists
|
|
371
366
|
if (!existing) {
|
|
372
|
-
cell.push(new
|
|
367
|
+
cell.push(new FListNode(position, data ? data : undefined));
|
|
373
368
|
cell.sort((a, b) => this.totalOrder.compare(a.position, b.position));
|
|
374
369
|
}
|
|
375
370
|
}
|
|
@@ -379,11 +374,11 @@ export class FugueList {
|
|
|
379
374
|
// - This index is not contiguous with the previous group
|
|
380
375
|
if (startIdx === -1) {
|
|
381
376
|
startIdx = idx;
|
|
382
|
-
batchCells = [[new
|
|
377
|
+
batchCells = [[new FListNode(position, data ? data : undefined)]];
|
|
383
378
|
}
|
|
384
379
|
// If the index is the same as startIdx, continue the batch
|
|
385
380
|
else if (idx === startIdx) {
|
|
386
|
-
batchCells.push([new
|
|
381
|
+
batchCells.push([new FListNode(position, data ? data : undefined)]);
|
|
387
382
|
}
|
|
388
383
|
// The index is different, i.e. not contiguous, so flush the current batch,
|
|
389
384
|
// commit it and start a new one
|
|
@@ -396,7 +391,7 @@ export class FugueList {
|
|
|
396
391
|
// we must add the length of the batch we just inserted.
|
|
397
392
|
const shift = idx >= startIdx ? batchCells.length : 0;
|
|
398
393
|
startIdx = idx + shift;
|
|
399
|
-
batchCells = [[new
|
|
394
|
+
batchCells = [[new FListNode(position, data ? data : undefined)]];
|
|
400
395
|
}
|
|
401
396
|
}
|
|
402
397
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dts/Fugue/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dts/Fugue/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC"}
|
package/dist/dts/Fugue/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./FNode.js";
|
|
1
|
+
// export * from "./FNode.js";
|
|
2
2
|
export * from "./FugueList.js";
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export type NodeSide = "L" | "R";
|
|
2
|
+
/**
|
|
3
|
+
* Lamport type identifier containing the sender replica id
|
|
4
|
+
* and a counter
|
|
5
|
+
*/
|
|
6
|
+
export type ID = {
|
|
7
|
+
sender: string;
|
|
8
|
+
counter: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Represents a node in a FTree. Each node corresponds to a character in the document, with a:
|
|
12
|
+
* - unique ID that identifies the node and allows it to be referenced by other nodes (e.g. for insertions to the right of it).
|
|
13
|
+
* - character value (null for the root node and deleted nodes)
|
|
14
|
+
* - boolean isDeleted indicating whether the character has been deleted
|
|
15
|
+
* - parent pointer to the node's parent (null for the root)
|
|
16
|
+
* - side indicating whether the node is a left or right child of its parent (the root is considered a right child)
|
|
17
|
+
* - leftChildren and rightChildren arrays containing the node's children on each side, sorted in the order they were inserted (with ties broken by sender ID)
|
|
18
|
+
* - size of the subtree rooted at this node, counting only non-deleted nodes, for performance of index-based operations
|
|
19
|
+
* - rightOrigin pointer to the node to the right of which this node was inserted, if any (null if inserted at the end of its siblings, undefined if not yet set)
|
|
20
|
+
*/
|
|
21
|
+
export interface FNode {
|
|
22
|
+
id: ID;
|
|
23
|
+
value: string | null;
|
|
24
|
+
isDeleted: boolean;
|
|
25
|
+
parent: FNode | null;
|
|
26
|
+
side: NodeSide;
|
|
27
|
+
leftChildren: FNode[];
|
|
28
|
+
rightChildren: FNode[];
|
|
29
|
+
size: number;
|
|
30
|
+
rightOrigin?: FNode | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Serializable version of FNode used for saving/loading. Pointers to other nodes are replaced with IDs,
|
|
34
|
+
* and children arrays are omitted since they can be reconstructed from parent and rightOrigin pointers.
|
|
35
|
+
*/
|
|
36
|
+
export interface FNodeSave {
|
|
37
|
+
value: string | null;
|
|
38
|
+
isDeleted: boolean;
|
|
39
|
+
parent: ID | null;
|
|
40
|
+
side: NodeSide;
|
|
41
|
+
size: number;
|
|
42
|
+
rightOrigin?: ID | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* FTree is a CRDT for collaborative text editing. It represents the document as a tree of nodes,
|
|
46
|
+
* where each node corresponds to a character. The tree structure encodes the relative ordering
|
|
47
|
+
* of characters, and each node has a unique ID that allows it to be referenced by other nodes.
|
|
48
|
+
* The tree supports insertions and deletions of characters, and can be traversed in order to reconstruct the document text.
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
export declare class FTree {
|
|
52
|
+
readonly root: FNode;
|
|
53
|
+
private readonly nodes;
|
|
54
|
+
constructor();
|
|
55
|
+
/**
|
|
56
|
+
* Get the node with the given ID. Throws an error if no such node exists.
|
|
57
|
+
* @param id - the ID of the node to retrieve
|
|
58
|
+
* @returns the node with the given ID
|
|
59
|
+
*/
|
|
60
|
+
getByID(id: ID): FNode;
|
|
61
|
+
/**
|
|
62
|
+
* Add a node to the tree with the given ID, value, parent, side, and optional rightOrigin.
|
|
63
|
+
* The node is inserted among its siblings according to the order defined by rightOrigin and sender ID,
|
|
64
|
+
* and the size of all ancestors is updated accordingly.
|
|
65
|
+
* @param id - the ID of the new node
|
|
66
|
+
* @param value - the character value of the new node
|
|
67
|
+
* @param parent - the parent node of the new node
|
|
68
|
+
* @param side - the side (left or right) of the new node with respect to its parent
|
|
69
|
+
* @param rightOriginID - the ID of the node to the right of which the new node was inserted, or null if inserted at the end of its siblings (optional)
|
|
70
|
+
*/
|
|
71
|
+
addNode(id: ID, value: string, parent: FNode, side: NodeSide, rightOriginID?: ID | null): void;
|
|
72
|
+
/**
|
|
73
|
+
* TODO: Maybe change the children types to linked list to make insertions more efficient, since we expect many insertions at the end of the siblings.
|
|
74
|
+
* Inserts a node into the correct position among its parent node's children arrays based on the
|
|
75
|
+
* node's rightOrigin and sender ID, and the existing order of its rightOrigin among its siblings.
|
|
76
|
+
* @param node - The node to insert into its siblings
|
|
77
|
+
*/
|
|
78
|
+
private insertIntoSiblings;
|
|
79
|
+
/**
|
|
80
|
+
* Determines whether node a should come before node b in the document order, based on their rightOrigin and sender ID.
|
|
81
|
+
* returns true if a should come before b, false otherwise. i.e. a < b
|
|
82
|
+
* @param a - the first node to compare
|
|
83
|
+
* @param b - the second node to compare
|
|
84
|
+
*/
|
|
85
|
+
private isLess;
|
|
86
|
+
/**
|
|
87
|
+
* Find the depth of a node in the tree, defined as the number of edges from the node to the root. The root has depth 0.
|
|
88
|
+
* @param node - the node whose depth to calculate
|
|
89
|
+
* @returns the depth of the node in the tree
|
|
90
|
+
*/
|
|
91
|
+
depth(node: FNode): number;
|
|
92
|
+
/**
|
|
93
|
+
* Update the size of a node and all its ancestors by adding delta.
|
|
94
|
+
* This should be called whenever a node is inserted or deleted to keep the size values accurate.
|
|
95
|
+
* @param node - the node whose size and ancestors' sizes to update
|
|
96
|
+
* @param delta - the amount to add to the size of the node and its ancestors (positive for insertions, negative for deletions)
|
|
97
|
+
*/
|
|
98
|
+
updateSize(node: FNode, delta: number): void;
|
|
99
|
+
/**
|
|
100
|
+
* Get the node by index from a starting node, i.e. the node corresponding to the index-th non-deleted
|
|
101
|
+
* character in the subtree rooted at the starting node, where indices are 0-based.
|
|
102
|
+
* @param node - node to start the search from (e.g. the root for document-level indexing)
|
|
103
|
+
* @param index - the index of the node to retrieve among the non-deleted nodes in the subtree rooted at the starting node
|
|
104
|
+
* @returns the node corresponding to the index-th non-deleted character in the subtree rooted at the starting node
|
|
105
|
+
*/
|
|
106
|
+
getByIndex(node: FNode, index: number): FNode;
|
|
107
|
+
/**
|
|
108
|
+
* Get the index of a node disregarding the deleted nodes starting from the root
|
|
109
|
+
* @param node - the node whose index to calculate among the non-deleted nodes in the subtree rooted at the root
|
|
110
|
+
* @returns the index of the node among the non-deleted nodes in the subtree rooted at the root
|
|
111
|
+
*/
|
|
112
|
+
getVisibleIndex(node: FNode): number;
|
|
113
|
+
/**
|
|
114
|
+
* Get the leftmost descendant of a node, i.e. the node corresponding to the first non-deleted character in the subtree
|
|
115
|
+
* rooted at the given node in document order.
|
|
116
|
+
* @param node - the node whose leftmost descendant to find
|
|
117
|
+
* @returns the leftmost descendant of the given node
|
|
118
|
+
*/
|
|
119
|
+
leftmostDescendant(node: FNode): FNode;
|
|
120
|
+
/**
|
|
121
|
+
* Get the next non-descendant of a node, i.e. the node corresponding to the next non-deleted character in document order
|
|
122
|
+
* that is not in the subtree rooted at the given node.
|
|
123
|
+
* @param node - the node whose next non-descendant to find
|
|
124
|
+
* @returns the next non-descendant of the given node, or null if there is no such node (i.e. the given node is the last non-deleted character in document order)
|
|
125
|
+
*/
|
|
126
|
+
nextNonDescendant(node: FNode): FNode | null;
|
|
127
|
+
/**
|
|
128
|
+
* Traverse the subtree rooted at a node in document order, yielding the value of each non-deleted node.
|
|
129
|
+
* @param node - the node to traverse from
|
|
130
|
+
*/
|
|
131
|
+
traverse(node: FNode): IterableIterator<string>;
|
|
132
|
+
/**
|
|
133
|
+
* Serialize the tree into a Uint8Array. The tree is converted into a JSON object where each node is
|
|
134
|
+
* represented by its value, isDeleted flag, parent ID, side, size, and rightOrigin ID (if applicable).
|
|
135
|
+
* The JSON object is then converted to a string and encoded as a Uint8Array for storage or transmission.
|
|
136
|
+
* @returns a Uint8Array containing the serialized tree data
|
|
137
|
+
*/
|
|
138
|
+
save(): Uint8Array;
|
|
139
|
+
/**
|
|
140
|
+
* Load the tree from a Uint8Array containing serialized tree data in the format produced by the save() method.
|
|
141
|
+
* The data is parsed from JSON format, and the tree is reconstructed by first creating all nodes without setting their parent or rightOrigin pointers,
|
|
142
|
+
* then filling in the parent and rightOrigin pointers, and finally calling insertIntoSiblings on each node to reconstruct the children arrays.
|
|
143
|
+
* @param saveData - a Uint8Array containing the serialized tree data to load
|
|
144
|
+
*/
|
|
145
|
+
load(saveData: Uint8Array): void;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=FTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FTree.d.ts","sourceRoot":"","sources":["../../../src/dts/FugueTree/FTree.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,EAAE,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,KAAK;IAClB,EAAE,EAAE,EAAE,CAAC;IACP,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,KAAK,EAAE,CAAC;IACtB,aAAa,EAAE,KAAK,EAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,qBAAa,KAAK;IAGd,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAGrB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;;IAgBpD;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK;IAStB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAiC9F;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;;;;OAKG;IACH,OAAO,CAAC,MAAM;IAiDd;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM;IAU1B;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ5C;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK;IAkC7C;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM;IAoCpC;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK;IAMtC;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI;IAoB5C;;;OAGG;IACF,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAmChD;;;;;OAKG;IACH,IAAI,IAAI,UAAU;IAqBlB;;;;;OAKG;IACH,IAAI,CAAC,QAAQ,EAAE,UAAU;CAiF5B"}
|