loro-crdt 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/bundler/loro_wasm.d.ts +132 -35
- package/bundler/loro_wasm_bg.js +240 -20
- package/bundler/loro_wasm_bg.wasm +0 -0
- package/bundler/loro_wasm_bg.wasm.d.ts +17 -3
- package/nodejs/loro_wasm.d.ts +132 -35
- package/nodejs/loro_wasm.js +240 -20
- package/nodejs/loro_wasm_bg.wasm +0 -0
- package/nodejs/loro_wasm_bg.wasm.d.ts +17 -3
- package/package.json +1 -1
- package/web/loro_wasm.d.ts +149 -38
- package/web/loro_wasm.js +239 -19
- package/web/loro_wasm_bg.wasm +0 -0
- package/web/loro_wasm_bg.wasm.d.ts +17 -3
package/nodejs/loro_wasm.d.ts
CHANGED
|
@@ -26,12 +26,13 @@ export function setDebug(): void;
|
|
|
26
26
|
* - endVersionVector
|
|
27
27
|
* - startTimestamp
|
|
28
28
|
* - endTimestamp
|
|
29
|
-
* -
|
|
29
|
+
* - mode
|
|
30
30
|
* - changeNum
|
|
31
31
|
* @param {Uint8Array} blob
|
|
32
|
+
* @param {boolean} check_checksum
|
|
32
33
|
* @returns {ImportBlobMetadata}
|
|
33
34
|
*/
|
|
34
|
-
export function decodeImportBlobMeta(blob: Uint8Array): ImportBlobMetadata;
|
|
35
|
+
export function decodeImportBlobMeta(blob: Uint8Array, check_checksum: boolean): ImportBlobMetadata;
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* Container types supported by loro.
|
|
@@ -262,7 +263,7 @@ export interface ImportBlobMetadata {
|
|
|
262
263
|
startFrontiers: OpId[],
|
|
263
264
|
startTimestamp: number;
|
|
264
265
|
endTimestamp: number;
|
|
265
|
-
|
|
266
|
+
mode: "outdated-snapshot" | "outdated-update" | "snapshot" | "shallow-snapshot" | "update";
|
|
266
267
|
changeNum: number;
|
|
267
268
|
}
|
|
268
269
|
|
|
@@ -351,6 +352,11 @@ export type TreeNodeValue = {
|
|
|
351
352
|
children: TreeNodeValue[],
|
|
352
353
|
}
|
|
353
354
|
|
|
355
|
+
export type TreeNodeJSON<T> = Omit<TreeNodeValue, 'meta' | 'children'> & {
|
|
356
|
+
meta: T,
|
|
357
|
+
children: TreeNodeJSON<T>[],
|
|
358
|
+
}
|
|
359
|
+
|
|
354
360
|
interface LoroTree{
|
|
355
361
|
toArray(): TreeNodeValue[];
|
|
356
362
|
getNodes(options?: { withDeleted: boolean = false }): LoroTreeNode[];
|
|
@@ -432,6 +438,11 @@ export type JsonChange = {
|
|
|
432
438
|
ops: JsonOp[]
|
|
433
439
|
}
|
|
434
440
|
|
|
441
|
+
export interface TextUpdateOptions {
|
|
442
|
+
timeoutMs?: number,
|
|
443
|
+
useRefinedDiff?: boolean,
|
|
444
|
+
}
|
|
445
|
+
|
|
435
446
|
export type ExportMode = {
|
|
436
447
|
mode: "update",
|
|
437
448
|
from?: VersionVector,
|
|
@@ -779,6 +790,10 @@ interface LoroList<T = unknown> {
|
|
|
779
790
|
* ```
|
|
780
791
|
*/
|
|
781
792
|
insertContainer<C extends Container>(pos: number, child: C): T extends C ? T : C;
|
|
793
|
+
/**
|
|
794
|
+
* Push a container to the end of the list.
|
|
795
|
+
*/
|
|
796
|
+
pushContainer<C extends Container>(child: C): T extends C ? T : C;
|
|
782
797
|
/**
|
|
783
798
|
* Get the value at the index. If the value is a container, the corresponding handler will be returned.
|
|
784
799
|
*
|
|
@@ -851,6 +866,10 @@ interface LoroMovableList<T = unknown> {
|
|
|
851
866
|
* ```
|
|
852
867
|
*/
|
|
853
868
|
insertContainer<C extends Container>(pos: number, child: C): T extends C ? T : C;
|
|
869
|
+
/**
|
|
870
|
+
* Push a container to the end of the list.
|
|
871
|
+
*/
|
|
872
|
+
pushContainer<C extends Container>(child: C): T extends C ? T : C;
|
|
854
873
|
/**
|
|
855
874
|
* Get the value at the index. If the value is a container, the corresponding handler will be returned.
|
|
856
875
|
*
|
|
@@ -1004,6 +1023,32 @@ interface LoroText {
|
|
|
1004
1023
|
insert(pos: number, text: string): void;
|
|
1005
1024
|
delete(pos: number, len: number): void;
|
|
1006
1025
|
subscribe(listener: Listener): Subscription;
|
|
1026
|
+
/**
|
|
1027
|
+
* Update the current text to the target text.
|
|
1028
|
+
*
|
|
1029
|
+
* It will calculate the minimal difference and apply it to the current text.
|
|
1030
|
+
* It uses Myers' diff algorithm to compute the optimal difference.
|
|
1031
|
+
*
|
|
1032
|
+
* This could take a long time for large texts (e.g. > 50_000 characters).
|
|
1033
|
+
* In that case, you should use `updateByLine` instead.
|
|
1034
|
+
*
|
|
1035
|
+
* @example
|
|
1036
|
+
* ```ts
|
|
1037
|
+
* import { LoroDoc } from "loro-crdt";
|
|
1038
|
+
*
|
|
1039
|
+
* const doc = new LoroDoc();
|
|
1040
|
+
* const text = doc.getText("text");
|
|
1041
|
+
* text.insert(0, "Hello");
|
|
1042
|
+
* text.update("Hello World");
|
|
1043
|
+
* console.log(text.toString()); // "Hello World"
|
|
1044
|
+
* ```
|
|
1045
|
+
*/
|
|
1046
|
+
update(text: string, options?: TextUpdateOptions): void;
|
|
1047
|
+
/**
|
|
1048
|
+
* Update the current text based on the provided text.
|
|
1049
|
+
* This update calculation is line-based, which will be more efficient but less precise.
|
|
1050
|
+
*/
|
|
1051
|
+
updateByLine(text: string, options?: TextUpdateOptions): void;
|
|
1007
1052
|
}
|
|
1008
1053
|
interface LoroTree<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
1009
1054
|
new(): LoroTree<T>;
|
|
@@ -1072,6 +1117,7 @@ interface LoroTreeNode<T extends Record<string, unknown> = Record<string, unknow
|
|
|
1072
1117
|
* the WASM boundary.
|
|
1073
1118
|
*/
|
|
1074
1119
|
children(): Array<LoroTreeNode<T>> | undefined;
|
|
1120
|
+
toJSON(): TreeNodeJSON<T>;
|
|
1075
1121
|
}
|
|
1076
1122
|
interface AwarenessWasm<T extends Value = Value> {
|
|
1077
1123
|
getState(peer: PeerID): T | undefined;
|
|
@@ -1479,11 +1525,16 @@ export class LoroDoc {
|
|
|
1479
1525
|
* Duplicate the document with a different PeerID
|
|
1480
1526
|
*
|
|
1481
1527
|
* The time complexity and space complexity of this operation are both O(n),
|
|
1528
|
+
*
|
|
1529
|
+
* When called in detached mode, it will fork at the current state frontiers.
|
|
1530
|
+
* It will have the same effect as `forkAt(&self.frontiers())`.
|
|
1482
1531
|
* @returns {LoroDoc}
|
|
1483
1532
|
*/
|
|
1484
1533
|
fork(): LoroDoc;
|
|
1485
1534
|
/**
|
|
1486
1535
|
* Creates a new LoroDoc at a specified version (Frontiers)
|
|
1536
|
+
*
|
|
1537
|
+
* The created doc will only contain the history before the specified frontiers.
|
|
1487
1538
|
* @param {({ peer: PeerID, counter: number })[]} frontiers
|
|
1488
1539
|
* @returns {LoroDoc}
|
|
1489
1540
|
*/
|
|
@@ -1519,9 +1570,9 @@ export class LoroDoc {
|
|
|
1519
1570
|
* @param ids - the changes to visit
|
|
1520
1571
|
* @param f - the callback function, return `true` to continue visiting, return `false` to stop
|
|
1521
1572
|
* @param {({ peer: PeerID, counter: number })[]} ids
|
|
1522
|
-
* @param {
|
|
1573
|
+
* @param {(change: ChangeMeta) => boolean} f
|
|
1523
1574
|
*/
|
|
1524
|
-
travelChangeAncestors(ids: ({ peer: PeerID, counter: number })[], f:
|
|
1575
|
+
travelChangeAncestors(ids: ({ peer: PeerID, counter: number })[], f: (change: ChangeMeta) => boolean): void;
|
|
1525
1576
|
/**
|
|
1526
1577
|
* Checkout the `DocState` to a specific version.
|
|
1527
1578
|
*
|
|
@@ -1997,6 +2048,23 @@ export class LoroDoc {
|
|
|
1997
2048
|
*/
|
|
1998
2049
|
getCursorPos(cursor: Cursor): { update?: Cursor, offset: number, side: Side };
|
|
1999
2050
|
/**
|
|
2051
|
+
* Gets container IDs modified in the given ID range.
|
|
2052
|
+
*
|
|
2053
|
+
* **NOTE:** This method will implicitly commit.
|
|
2054
|
+
*
|
|
2055
|
+
* This method identifies which containers were affected by changes in a given range of operations.
|
|
2056
|
+
* It can be used together with `doc.travelChangeAncestors()` to analyze the history of changes
|
|
2057
|
+
* and determine which containers were modified by each change.
|
|
2058
|
+
*
|
|
2059
|
+
* @param id - The starting ID of the change range
|
|
2060
|
+
* @param len - The length of the change range to check
|
|
2061
|
+
* @returns An array of container IDs that were modified in the given range
|
|
2062
|
+
* @param {{ peer: PeerID, counter: number }} id
|
|
2063
|
+
* @param {number} len
|
|
2064
|
+
* @returns {(ContainerID)[]}
|
|
2065
|
+
*/
|
|
2066
|
+
getChangedContainersIn(id: { peer: PeerID, counter: number }, len: number): (ContainerID)[];
|
|
2067
|
+
/**
|
|
2000
2068
|
* Peer ID of the current writer.
|
|
2001
2069
|
*/
|
|
2002
2070
|
readonly peerId: bigint;
|
|
@@ -2092,6 +2160,11 @@ export class LoroList {
|
|
|
2092
2160
|
*/
|
|
2093
2161
|
clear(): void;
|
|
2094
2162
|
/**
|
|
2163
|
+
* @param {number} pos
|
|
2164
|
+
* @returns {{ peer: PeerID, counter: number } | undefined}
|
|
2165
|
+
*/
|
|
2166
|
+
getIdAt(pos: number): { peer: PeerID, counter: number } | undefined;
|
|
2167
|
+
/**
|
|
2095
2168
|
* Get the id of this container.
|
|
2096
2169
|
*/
|
|
2097
2170
|
readonly id: ContainerID;
|
|
@@ -2242,6 +2315,12 @@ export class LoroMap {
|
|
|
2242
2315
|
*/
|
|
2243
2316
|
clear(): void;
|
|
2244
2317
|
/**
|
|
2318
|
+
* Get the peer id of the last editor on the given entry
|
|
2319
|
+
* @param {string} key
|
|
2320
|
+
* @returns {PeerID | undefined}
|
|
2321
|
+
*/
|
|
2322
|
+
getLastEditor(key: string): PeerID | undefined;
|
|
2323
|
+
/**
|
|
2245
2324
|
* The container id of this handler.
|
|
2246
2325
|
*/
|
|
2247
2326
|
readonly id: ContainerID;
|
|
@@ -2362,6 +2441,24 @@ export class LoroMovableList {
|
|
|
2362
2441
|
*/
|
|
2363
2442
|
clear(): void;
|
|
2364
2443
|
/**
|
|
2444
|
+
* Get the creator of the list item at the given position.
|
|
2445
|
+
* @param {number} pos
|
|
2446
|
+
* @returns {PeerID | undefined}
|
|
2447
|
+
*/
|
|
2448
|
+
getCreatorAt(pos: number): PeerID | undefined;
|
|
2449
|
+
/**
|
|
2450
|
+
* Get the last mover of the list item at the given position.
|
|
2451
|
+
* @param {number} pos
|
|
2452
|
+
* @returns {PeerID | undefined}
|
|
2453
|
+
*/
|
|
2454
|
+
getLastMoverAt(pos: number): PeerID | undefined;
|
|
2455
|
+
/**
|
|
2456
|
+
* Get the last editor of the list item at the given position.
|
|
2457
|
+
* @param {number} pos
|
|
2458
|
+
* @returns {PeerID | undefined}
|
|
2459
|
+
*/
|
|
2460
|
+
getLastEditorAt(pos: number): PeerID | undefined;
|
|
2461
|
+
/**
|
|
2365
2462
|
* Get the id of this container.
|
|
2366
2463
|
*/
|
|
2367
2464
|
readonly id: ContainerID;
|
|
@@ -2402,11 +2499,14 @@ export class LoroText {
|
|
|
2402
2499
|
*/
|
|
2403
2500
|
kind(): 'Text';
|
|
2404
2501
|
/**
|
|
2405
|
-
* Iterate each span(internal storage unit)
|
|
2502
|
+
* Iterate each text span(internal storage unit)
|
|
2406
2503
|
*
|
|
2407
2504
|
* The callback function will be called for each span in the text.
|
|
2408
2505
|
* If the callback returns `false`, the iteration will stop.
|
|
2409
2506
|
*
|
|
2507
|
+
* Limitation: you cannot access or alter the doc state when iterating (this is for performance consideration).
|
|
2508
|
+
* If you need to access or alter the doc state, please use `toString` instead.
|
|
2509
|
+
*
|
|
2410
2510
|
* @example
|
|
2411
2511
|
* ```ts
|
|
2412
2512
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -2420,35 +2520,6 @@ export class LoroText {
|
|
|
2420
2520
|
*/
|
|
2421
2521
|
iter(callback: Function): void;
|
|
2422
2522
|
/**
|
|
2423
|
-
* Update the current text to the target text.
|
|
2424
|
-
*
|
|
2425
|
-
* It will calculate the minimal difference and apply it to the current text.
|
|
2426
|
-
* It uses Myers' diff algorithm to compute the optimal difference.
|
|
2427
|
-
*
|
|
2428
|
-
* This could take a long time for large texts (e.g. > 50_000 characters).
|
|
2429
|
-
* In that case, you should use `updateByLine` instead.
|
|
2430
|
-
*
|
|
2431
|
-
* @example
|
|
2432
|
-
* ```ts
|
|
2433
|
-
* import { LoroDoc } from "loro-crdt";
|
|
2434
|
-
*
|
|
2435
|
-
* const doc = new LoroDoc();
|
|
2436
|
-
* const text = doc.getText("text");
|
|
2437
|
-
* text.insert(0, "Hello");
|
|
2438
|
-
* text.update("Hello World");
|
|
2439
|
-
* console.log(text.toString()); // "Hello World"
|
|
2440
|
-
* ```
|
|
2441
|
-
* @param {string} text
|
|
2442
|
-
*/
|
|
2443
|
-
update(text: string): void;
|
|
2444
|
-
/**
|
|
2445
|
-
* Update the current text to the target text, the difference is calculated line by line.
|
|
2446
|
-
*
|
|
2447
|
-
* It uses Myers' diff algorithm to compute the optimal difference.
|
|
2448
|
-
* @param {string} text
|
|
2449
|
-
*/
|
|
2450
|
-
updateByLine(text: string): void;
|
|
2451
|
-
/**
|
|
2452
2523
|
* Insert the string at the given index (utf-16 index).
|
|
2453
2524
|
*
|
|
2454
2525
|
* @example
|
|
@@ -2687,6 +2758,17 @@ export class LoroText {
|
|
|
2687
2758
|
*/
|
|
2688
2759
|
getAttached(): LoroText | undefined;
|
|
2689
2760
|
/**
|
|
2761
|
+
* Push a string to the end of the text.
|
|
2762
|
+
* @param {string} s
|
|
2763
|
+
*/
|
|
2764
|
+
push(s: string): void;
|
|
2765
|
+
/**
|
|
2766
|
+
* Get the editor of the text at the given position.
|
|
2767
|
+
* @param {number} pos
|
|
2768
|
+
* @returns {PeerID | undefined}
|
|
2769
|
+
*/
|
|
2770
|
+
getEditorOf(pos: number): PeerID | undefined;
|
|
2771
|
+
/**
|
|
2690
2772
|
* Get the container id of the text.
|
|
2691
2773
|
*/
|
|
2692
2774
|
readonly id: ContainerID;
|
|
@@ -2956,6 +3038,21 @@ export class LoroTreeNode {
|
|
|
2956
3038
|
*/
|
|
2957
3039
|
isDeleted(): boolean;
|
|
2958
3040
|
/**
|
|
3041
|
+
* Get the last mover of this node.
|
|
3042
|
+
* @returns {{ peer: PeerID, counter: number } | undefined}
|
|
3043
|
+
*/
|
|
3044
|
+
getLastMoveId(): { peer: PeerID, counter: number } | undefined;
|
|
3045
|
+
/**
|
|
3046
|
+
* Get the creation id of this node.
|
|
3047
|
+
* @returns {{ peer: PeerID, counter: number }}
|
|
3048
|
+
*/
|
|
3049
|
+
creationId(): { peer: PeerID, counter: number };
|
|
3050
|
+
/**
|
|
3051
|
+
* Get the creator of this node.
|
|
3052
|
+
* @returns {PeerID}
|
|
3053
|
+
*/
|
|
3054
|
+
creator(): PeerID;
|
|
3055
|
+
/**
|
|
2959
3056
|
* The TreeID of the node.
|
|
2960
3057
|
*/
|
|
2961
3058
|
readonly id: TreeID;
|
package/nodejs/loro_wasm.js
CHANGED
|
@@ -363,17 +363,18 @@ function _assertClass(instance, klass) {
|
|
|
363
363
|
* - endVersionVector
|
|
364
364
|
* - startTimestamp
|
|
365
365
|
* - endTimestamp
|
|
366
|
-
* -
|
|
366
|
+
* - mode
|
|
367
367
|
* - changeNum
|
|
368
368
|
* @param {Uint8Array} blob
|
|
369
|
+
* @param {boolean} check_checksum
|
|
369
370
|
* @returns {ImportBlobMetadata}
|
|
370
371
|
*/
|
|
371
|
-
module.exports.decodeImportBlobMeta = function(blob) {
|
|
372
|
+
module.exports.decodeImportBlobMeta = function(blob, check_checksum) {
|
|
372
373
|
try {
|
|
373
374
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
374
375
|
const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export_0);
|
|
375
376
|
const len0 = WASM_VECTOR_LEN;
|
|
376
|
-
wasm.decodeImportBlobMeta(retptr, ptr0, len0);
|
|
377
|
+
wasm.decodeImportBlobMeta(retptr, ptr0, len0, check_checksum);
|
|
377
378
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
378
379
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
379
380
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -1132,6 +1133,9 @@ class LoroDoc {
|
|
|
1132
1133
|
* Duplicate the document with a different PeerID
|
|
1133
1134
|
*
|
|
1134
1135
|
* The time complexity and space complexity of this operation are both O(n),
|
|
1136
|
+
*
|
|
1137
|
+
* When called in detached mode, it will fork at the current state frontiers.
|
|
1138
|
+
* It will have the same effect as `forkAt(&self.frontiers())`.
|
|
1135
1139
|
* @returns {LoroDoc}
|
|
1136
1140
|
*/
|
|
1137
1141
|
fork() {
|
|
@@ -1140,6 +1144,8 @@ class LoroDoc {
|
|
|
1140
1144
|
}
|
|
1141
1145
|
/**
|
|
1142
1146
|
* Creates a new LoroDoc at a specified version (Frontiers)
|
|
1147
|
+
*
|
|
1148
|
+
* The created doc will only contain the history before the specified frontiers.
|
|
1143
1149
|
* @param {({ peer: PeerID, counter: number })[]} frontiers
|
|
1144
1150
|
* @returns {LoroDoc}
|
|
1145
1151
|
*/
|
|
@@ -1203,7 +1209,7 @@ class LoroDoc {
|
|
|
1203
1209
|
* @param ids - the changes to visit
|
|
1204
1210
|
* @param f - the callback function, return `true` to continue visiting, return `false` to stop
|
|
1205
1211
|
* @param {({ peer: PeerID, counter: number })[]} ids
|
|
1206
|
-
* @param {
|
|
1212
|
+
* @param {(change: ChangeMeta) => boolean} f
|
|
1207
1213
|
*/
|
|
1208
1214
|
travelChangeAncestors(ids, f) {
|
|
1209
1215
|
try {
|
|
@@ -2350,6 +2356,40 @@ class LoroDoc {
|
|
|
2350
2356
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2351
2357
|
}
|
|
2352
2358
|
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Gets container IDs modified in the given ID range.
|
|
2361
|
+
*
|
|
2362
|
+
* **NOTE:** This method will implicitly commit.
|
|
2363
|
+
*
|
|
2364
|
+
* This method identifies which containers were affected by changes in a given range of operations.
|
|
2365
|
+
* It can be used together with `doc.travelChangeAncestors()` to analyze the history of changes
|
|
2366
|
+
* and determine which containers were modified by each change.
|
|
2367
|
+
*
|
|
2368
|
+
* @param id - The starting ID of the change range
|
|
2369
|
+
* @param len - The length of the change range to check
|
|
2370
|
+
* @returns An array of container IDs that were modified in the given range
|
|
2371
|
+
* @param {{ peer: PeerID, counter: number }} id
|
|
2372
|
+
* @param {number} len
|
|
2373
|
+
* @returns {(ContainerID)[]}
|
|
2374
|
+
*/
|
|
2375
|
+
getChangedContainersIn(id, len) {
|
|
2376
|
+
try {
|
|
2377
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2378
|
+
wasm.lorodoc_getChangedContainersIn(retptr, this.__wbg_ptr, addHeapObject(id), len);
|
|
2379
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2380
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2381
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2382
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
2383
|
+
if (r3) {
|
|
2384
|
+
throw takeObject(r2);
|
|
2385
|
+
}
|
|
2386
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
2387
|
+
wasm.__wbindgen_export_5(r0, r1 * 4, 4);
|
|
2388
|
+
return v1;
|
|
2389
|
+
} finally {
|
|
2390
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2353
2393
|
}
|
|
2354
2394
|
module.exports.LoroDoc = LoroDoc;
|
|
2355
2395
|
|
|
@@ -2574,6 +2614,25 @@ class LoroList {
|
|
|
2574
2614
|
}
|
|
2575
2615
|
}
|
|
2576
2616
|
/**
|
|
2617
|
+
* @param {Container} child
|
|
2618
|
+
* @returns {Container}
|
|
2619
|
+
*/
|
|
2620
|
+
pushContainer(child) {
|
|
2621
|
+
try {
|
|
2622
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2623
|
+
wasm.lorolist_pushContainer(retptr, this.__wbg_ptr, addHeapObject(child));
|
|
2624
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2625
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2626
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2627
|
+
if (r2) {
|
|
2628
|
+
throw takeObject(r1);
|
|
2629
|
+
}
|
|
2630
|
+
return takeObject(r0);
|
|
2631
|
+
} finally {
|
|
2632
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
/**
|
|
2577
2636
|
* Subscribe to the changes of the list.
|
|
2578
2637
|
*
|
|
2579
2638
|
* Returns a subscription callback, which can be used to unsubscribe.
|
|
@@ -2732,6 +2791,14 @@ class LoroList {
|
|
|
2732
2791
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2733
2792
|
}
|
|
2734
2793
|
}
|
|
2794
|
+
/**
|
|
2795
|
+
* @param {number} pos
|
|
2796
|
+
* @returns {{ peer: PeerID, counter: number } | undefined}
|
|
2797
|
+
*/
|
|
2798
|
+
getIdAt(pos) {
|
|
2799
|
+
const ret = wasm.lorolist_getIdAt(this.__wbg_ptr, pos);
|
|
2800
|
+
return takeObject(ret);
|
|
2801
|
+
}
|
|
2735
2802
|
}
|
|
2736
2803
|
module.exports.LoroList = LoroList;
|
|
2737
2804
|
|
|
@@ -3164,6 +3231,17 @@ class LoroMap {
|
|
|
3164
3231
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3165
3232
|
}
|
|
3166
3233
|
}
|
|
3234
|
+
/**
|
|
3235
|
+
* Get the peer id of the last editor on the given entry
|
|
3236
|
+
* @param {string} key
|
|
3237
|
+
* @returns {PeerID | undefined}
|
|
3238
|
+
*/
|
|
3239
|
+
getLastEditor(key) {
|
|
3240
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
3241
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3242
|
+
const ret = wasm.loromap_getLastEditor(this.__wbg_ptr, ptr0, len0);
|
|
3243
|
+
return takeObject(ret);
|
|
3244
|
+
}
|
|
3167
3245
|
}
|
|
3168
3246
|
module.exports.LoroMap = LoroMap;
|
|
3169
3247
|
|
|
@@ -3388,6 +3466,26 @@ class LoroMovableList {
|
|
|
3388
3466
|
}
|
|
3389
3467
|
}
|
|
3390
3468
|
/**
|
|
3469
|
+
* Push a container to the end of the list.
|
|
3470
|
+
* @param {Container} child
|
|
3471
|
+
* @returns {Container}
|
|
3472
|
+
*/
|
|
3473
|
+
pushContainer(child) {
|
|
3474
|
+
try {
|
|
3475
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3476
|
+
wasm.loromovablelist_pushContainer(retptr, this.__wbg_ptr, addHeapObject(child));
|
|
3477
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3478
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3479
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
3480
|
+
if (r2) {
|
|
3481
|
+
throw takeObject(r1);
|
|
3482
|
+
}
|
|
3483
|
+
return takeObject(r0);
|
|
3484
|
+
} finally {
|
|
3485
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
/**
|
|
3391
3489
|
* Subscribe to the changes of the list.
|
|
3392
3490
|
*
|
|
3393
3491
|
* Returns a subscription callback, which can be used to unsubscribe.
|
|
@@ -3617,6 +3715,33 @@ class LoroMovableList {
|
|
|
3617
3715
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3618
3716
|
}
|
|
3619
3717
|
}
|
|
3718
|
+
/**
|
|
3719
|
+
* Get the creator of the list item at the given position.
|
|
3720
|
+
* @param {number} pos
|
|
3721
|
+
* @returns {PeerID | undefined}
|
|
3722
|
+
*/
|
|
3723
|
+
getCreatorAt(pos) {
|
|
3724
|
+
const ret = wasm.loromovablelist_getCreatorAt(this.__wbg_ptr, pos);
|
|
3725
|
+
return takeObject(ret);
|
|
3726
|
+
}
|
|
3727
|
+
/**
|
|
3728
|
+
* Get the last mover of the list item at the given position.
|
|
3729
|
+
* @param {number} pos
|
|
3730
|
+
* @returns {PeerID | undefined}
|
|
3731
|
+
*/
|
|
3732
|
+
getLastMoverAt(pos) {
|
|
3733
|
+
const ret = wasm.loromovablelist_getLastMoverAt(this.__wbg_ptr, pos);
|
|
3734
|
+
return takeObject(ret);
|
|
3735
|
+
}
|
|
3736
|
+
/**
|
|
3737
|
+
* Get the last editor of the list item at the given position.
|
|
3738
|
+
* @param {number} pos
|
|
3739
|
+
* @returns {PeerID | undefined}
|
|
3740
|
+
*/
|
|
3741
|
+
getLastEditorAt(pos) {
|
|
3742
|
+
const ret = wasm.loromovablelist_getLastEditorAt(this.__wbg_ptr, pos);
|
|
3743
|
+
return takeObject(ret);
|
|
3744
|
+
}
|
|
3620
3745
|
}
|
|
3621
3746
|
module.exports.LoroMovableList = LoroMovableList;
|
|
3622
3747
|
|
|
@@ -3669,11 +3794,14 @@ class LoroText {
|
|
|
3669
3794
|
return takeObject(ret);
|
|
3670
3795
|
}
|
|
3671
3796
|
/**
|
|
3672
|
-
* Iterate each span(internal storage unit)
|
|
3797
|
+
* Iterate each text span(internal storage unit)
|
|
3673
3798
|
*
|
|
3674
3799
|
* The callback function will be called for each span in the text.
|
|
3675
3800
|
* If the callback returns `false`, the iteration will stop.
|
|
3676
3801
|
*
|
|
3802
|
+
* Limitation: you cannot access or alter the doc state when iterating (this is for performance consideration).
|
|
3803
|
+
* If you need to access or alter the doc state, please use `toString` instead.
|
|
3804
|
+
*
|
|
3677
3805
|
* @example
|
|
3678
3806
|
* ```ts
|
|
3679
3807
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -3712,22 +3840,44 @@ class LoroText {
|
|
|
3712
3840
|
* console.log(text.toString()); // "Hello World"
|
|
3713
3841
|
* ```
|
|
3714
3842
|
* @param {string} text
|
|
3843
|
+
* @param {any} options
|
|
3715
3844
|
*/
|
|
3716
|
-
update(text) {
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3845
|
+
update(text, options) {
|
|
3846
|
+
try {
|
|
3847
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3848
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
3849
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3850
|
+
wasm.lorotext_update(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options));
|
|
3851
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3852
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3853
|
+
if (r1) {
|
|
3854
|
+
throw takeObject(r0);
|
|
3855
|
+
}
|
|
3856
|
+
} finally {
|
|
3857
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3858
|
+
}
|
|
3720
3859
|
}
|
|
3721
3860
|
/**
|
|
3722
3861
|
* Update the current text to the target text, the difference is calculated line by line.
|
|
3723
3862
|
*
|
|
3724
3863
|
* It uses Myers' diff algorithm to compute the optimal difference.
|
|
3725
3864
|
* @param {string} text
|
|
3865
|
+
* @param {any} options
|
|
3726
3866
|
*/
|
|
3727
|
-
updateByLine(text) {
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3867
|
+
updateByLine(text, options) {
|
|
3868
|
+
try {
|
|
3869
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3870
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
3871
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3872
|
+
wasm.lorotext_updateByLine(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options));
|
|
3873
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3874
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3875
|
+
if (r1) {
|
|
3876
|
+
throw takeObject(r0);
|
|
3877
|
+
}
|
|
3878
|
+
} finally {
|
|
3879
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3880
|
+
}
|
|
3731
3881
|
}
|
|
3732
3882
|
/**
|
|
3733
3883
|
* Insert the string at the given index (utf-16 index).
|
|
@@ -4206,6 +4356,34 @@ class LoroText {
|
|
|
4206
4356
|
const ret = wasm.lorotext_getCursor(this.__wbg_ptr, pos, addHeapObject(side));
|
|
4207
4357
|
return ret === 0 ? undefined : Cursor.__wrap(ret);
|
|
4208
4358
|
}
|
|
4359
|
+
/**
|
|
4360
|
+
* Push a string to the end of the text.
|
|
4361
|
+
* @param {string} s
|
|
4362
|
+
*/
|
|
4363
|
+
push(s) {
|
|
4364
|
+
try {
|
|
4365
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
4366
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
4367
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4368
|
+
wasm.lorotext_push(retptr, this.__wbg_ptr, ptr0, len0);
|
|
4369
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
4370
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
4371
|
+
if (r1) {
|
|
4372
|
+
throw takeObject(r0);
|
|
4373
|
+
}
|
|
4374
|
+
} finally {
|
|
4375
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
4376
|
+
}
|
|
4377
|
+
}
|
|
4378
|
+
/**
|
|
4379
|
+
* Get the editor of the text at the given position.
|
|
4380
|
+
* @param {number} pos
|
|
4381
|
+
* @returns {PeerID | undefined}
|
|
4382
|
+
*/
|
|
4383
|
+
getEditorOf(pos) {
|
|
4384
|
+
const ret = wasm.lorotext_getEditorOf(this.__wbg_ptr, pos);
|
|
4385
|
+
return takeObject(ret);
|
|
4386
|
+
}
|
|
4209
4387
|
}
|
|
4210
4388
|
module.exports.LoroText = LoroText;
|
|
4211
4389
|
|
|
@@ -4902,6 +5080,24 @@ class LoroTreeNode {
|
|
|
4902
5080
|
}
|
|
4903
5081
|
}
|
|
4904
5082
|
/**
|
|
5083
|
+
* @returns {any}
|
|
5084
|
+
*/
|
|
5085
|
+
toJSON() {
|
|
5086
|
+
try {
|
|
5087
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
5088
|
+
wasm.lorotreenode_toJSON(retptr, this.__wbg_ptr);
|
|
5089
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
5090
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
5091
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
5092
|
+
if (r2) {
|
|
5093
|
+
throw takeObject(r1);
|
|
5094
|
+
}
|
|
5095
|
+
return takeObject(r0);
|
|
5096
|
+
} finally {
|
|
5097
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
5098
|
+
}
|
|
5099
|
+
}
|
|
5100
|
+
/**
|
|
4905
5101
|
* Get the parent node of this node.
|
|
4906
5102
|
*
|
|
4907
5103
|
* - The parent of the root node is `undefined`.
|
|
@@ -4954,6 +5150,30 @@ class LoroTreeNode {
|
|
|
4954
5150
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
4955
5151
|
}
|
|
4956
5152
|
}
|
|
5153
|
+
/**
|
|
5154
|
+
* Get the last mover of this node.
|
|
5155
|
+
* @returns {{ peer: PeerID, counter: number } | undefined}
|
|
5156
|
+
*/
|
|
5157
|
+
getLastMoveId() {
|
|
5158
|
+
const ret = wasm.lorotreenode_getLastMoveId(this.__wbg_ptr);
|
|
5159
|
+
return takeObject(ret);
|
|
5160
|
+
}
|
|
5161
|
+
/**
|
|
5162
|
+
* Get the creation id of this node.
|
|
5163
|
+
* @returns {{ peer: PeerID, counter: number }}
|
|
5164
|
+
*/
|
|
5165
|
+
creationId() {
|
|
5166
|
+
const ret = wasm.lorotreenode_creationId(this.__wbg_ptr);
|
|
5167
|
+
return takeObject(ret);
|
|
5168
|
+
}
|
|
5169
|
+
/**
|
|
5170
|
+
* Get the creator of this node.
|
|
5171
|
+
* @returns {PeerID}
|
|
5172
|
+
*/
|
|
5173
|
+
creator() {
|
|
5174
|
+
const ret = wasm.lorotreenode_creator(this.__wbg_ptr);
|
|
5175
|
+
return takeObject(ret);
|
|
5176
|
+
}
|
|
4957
5177
|
}
|
|
4958
5178
|
module.exports.LoroTreeNode = LoroTreeNode;
|
|
4959
5179
|
|
|
@@ -5344,6 +5564,11 @@ module.exports.__wbg_versionvector_new = function(arg0) {
|
|
|
5344
5564
|
return addHeapObject(ret);
|
|
5345
5565
|
};
|
|
5346
5566
|
|
|
5567
|
+
module.exports.__wbindgen_is_function = function(arg0) {
|
|
5568
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
5569
|
+
return ret;
|
|
5570
|
+
};
|
|
5571
|
+
|
|
5347
5572
|
module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
5348
5573
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
5349
5574
|
return addHeapObject(ret);
|
|
@@ -5432,11 +5657,6 @@ module.exports.__wbindgen_as_number = function(arg0) {
|
|
|
5432
5657
|
return ret;
|
|
5433
5658
|
};
|
|
5434
5659
|
|
|
5435
|
-
module.exports.__wbindgen_is_function = function(arg0) {
|
|
5436
|
-
const ret = typeof(getObject(arg0)) === 'function';
|
|
5437
|
-
return ret;
|
|
5438
|
-
};
|
|
5439
|
-
|
|
5440
5660
|
module.exports.__wbindgen_is_string = function(arg0) {
|
|
5441
5661
|
const ret = typeof(getObject(arg0)) === 'string';
|
|
5442
5662
|
return ret;
|
|
@@ -5881,12 +6101,12 @@ module.exports.__wbindgen_memory = function() {
|
|
|
5881
6101
|
return addHeapObject(ret);
|
|
5882
6102
|
};
|
|
5883
6103
|
|
|
5884
|
-
module.exports.
|
|
6104
|
+
module.exports.__wbindgen_closure_wrapper491 = function(arg0, arg1, arg2) {
|
|
5885
6105
|
const ret = makeMutClosure(arg0, arg1, 9, __wbg_adapter_58);
|
|
5886
6106
|
return addHeapObject(ret);
|
|
5887
6107
|
};
|
|
5888
6108
|
|
|
5889
|
-
module.exports.
|
|
6109
|
+
module.exports.__wbindgen_closure_wrapper494 = function(arg0, arg1, arg2) {
|
|
5890
6110
|
const ret = makeMutClosure(arg0, arg1, 11, __wbg_adapter_61);
|
|
5891
6111
|
return addHeapObject(ret);
|
|
5892
6112
|
};
|
package/nodejs/loro_wasm_bg.wasm
CHANGED
|
Binary file
|