loro-crdt 1.0.9 → 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 +16 -0
- package/bundler/loro_wasm.d.ts +114 -35
- package/bundler/loro_wasm_bg.js +177 -20
- package/bundler/loro_wasm_bg.wasm +0 -0
- package/bundler/loro_wasm_bg.wasm.d.ts +14 -3
- package/nodejs/loro_wasm.d.ts +114 -35
- package/nodejs/loro_wasm.js +177 -20
- package/nodejs/loro_wasm_bg.wasm +0 -0
- package/nodejs/loro_wasm_bg.wasm.d.ts +14 -3
- package/package.json +1 -1
- package/web/loro_wasm.d.ts +128 -38
- package/web/loro_wasm.js +176 -19
- package/web/loro_wasm_bg.wasm +0 -0
- package/web/loro_wasm_bg.wasm.d.ts +14 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6e878d2: Feat add API to query creators, the last editors/movers
|
|
8
|
+
- 778ca54: Feat: allow users to query the changed containers in the target id range
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 6616101: Perf: optimize importBatch
|
|
13
|
+
|
|
14
|
+
When using importBatch to import a series of snapshots and updates, we should import the snapshot with the greatest version first.
|
|
15
|
+
|
|
16
|
+
- 6e878d2: Feat: getLastEditor on LoroMap
|
|
17
|
+
- 8486234: Fix get encoded blob meta
|
|
18
|
+
|
|
3
19
|
## 1.0.9
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/bundler/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,
|
|
@@ -1012,6 +1023,32 @@ interface LoroText {
|
|
|
1012
1023
|
insert(pos: number, text: string): void;
|
|
1013
1024
|
delete(pos: number, len: number): void;
|
|
1014
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;
|
|
1015
1052
|
}
|
|
1016
1053
|
interface LoroTree<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
1017
1054
|
new(): LoroTree<T>;
|
|
@@ -1080,6 +1117,7 @@ interface LoroTreeNode<T extends Record<string, unknown> = Record<string, unknow
|
|
|
1080
1117
|
* the WASM boundary.
|
|
1081
1118
|
*/
|
|
1082
1119
|
children(): Array<LoroTreeNode<T>> | undefined;
|
|
1120
|
+
toJSON(): TreeNodeJSON<T>;
|
|
1083
1121
|
}
|
|
1084
1122
|
interface AwarenessWasm<T extends Value = Value> {
|
|
1085
1123
|
getState(peer: PeerID): T | undefined;
|
|
@@ -1532,9 +1570,9 @@ export class LoroDoc {
|
|
|
1532
1570
|
* @param ids - the changes to visit
|
|
1533
1571
|
* @param f - the callback function, return `true` to continue visiting, return `false` to stop
|
|
1534
1572
|
* @param {({ peer: PeerID, counter: number })[]} ids
|
|
1535
|
-
* @param {
|
|
1573
|
+
* @param {(change: ChangeMeta) => boolean} f
|
|
1536
1574
|
*/
|
|
1537
|
-
travelChangeAncestors(ids: ({ peer: PeerID, counter: number })[], f:
|
|
1575
|
+
travelChangeAncestors(ids: ({ peer: PeerID, counter: number })[], f: (change: ChangeMeta) => boolean): void;
|
|
1538
1576
|
/**
|
|
1539
1577
|
* Checkout the `DocState` to a specific version.
|
|
1540
1578
|
*
|
|
@@ -2010,6 +2048,23 @@ export class LoroDoc {
|
|
|
2010
2048
|
*/
|
|
2011
2049
|
getCursorPos(cursor: Cursor): { update?: Cursor, offset: number, side: Side };
|
|
2012
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
|
+
/**
|
|
2013
2068
|
* Peer ID of the current writer.
|
|
2014
2069
|
*/
|
|
2015
2070
|
readonly peerId: bigint;
|
|
@@ -2105,6 +2160,11 @@ export class LoroList {
|
|
|
2105
2160
|
*/
|
|
2106
2161
|
clear(): void;
|
|
2107
2162
|
/**
|
|
2163
|
+
* @param {number} pos
|
|
2164
|
+
* @returns {{ peer: PeerID, counter: number } | undefined}
|
|
2165
|
+
*/
|
|
2166
|
+
getIdAt(pos: number): { peer: PeerID, counter: number } | undefined;
|
|
2167
|
+
/**
|
|
2108
2168
|
* Get the id of this container.
|
|
2109
2169
|
*/
|
|
2110
2170
|
readonly id: ContainerID;
|
|
@@ -2255,6 +2315,12 @@ export class LoroMap {
|
|
|
2255
2315
|
*/
|
|
2256
2316
|
clear(): void;
|
|
2257
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
|
+
/**
|
|
2258
2324
|
* The container id of this handler.
|
|
2259
2325
|
*/
|
|
2260
2326
|
readonly id: ContainerID;
|
|
@@ -2375,6 +2441,24 @@ export class LoroMovableList {
|
|
|
2375
2441
|
*/
|
|
2376
2442
|
clear(): void;
|
|
2377
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
|
+
/**
|
|
2378
2462
|
* Get the id of this container.
|
|
2379
2463
|
*/
|
|
2380
2464
|
readonly id: ContainerID;
|
|
@@ -2415,11 +2499,14 @@ export class LoroText {
|
|
|
2415
2499
|
*/
|
|
2416
2500
|
kind(): 'Text';
|
|
2417
2501
|
/**
|
|
2418
|
-
* Iterate each span(internal storage unit)
|
|
2502
|
+
* Iterate each text span(internal storage unit)
|
|
2419
2503
|
*
|
|
2420
2504
|
* The callback function will be called for each span in the text.
|
|
2421
2505
|
* If the callback returns `false`, the iteration will stop.
|
|
2422
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
|
+
*
|
|
2423
2510
|
* @example
|
|
2424
2511
|
* ```ts
|
|
2425
2512
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -2433,35 +2520,6 @@ export class LoroText {
|
|
|
2433
2520
|
*/
|
|
2434
2521
|
iter(callback: Function): void;
|
|
2435
2522
|
/**
|
|
2436
|
-
* Update the current text to the target text.
|
|
2437
|
-
*
|
|
2438
|
-
* It will calculate the minimal difference and apply it to the current text.
|
|
2439
|
-
* It uses Myers' diff algorithm to compute the optimal difference.
|
|
2440
|
-
*
|
|
2441
|
-
* This could take a long time for large texts (e.g. > 50_000 characters).
|
|
2442
|
-
* In that case, you should use `updateByLine` instead.
|
|
2443
|
-
*
|
|
2444
|
-
* @example
|
|
2445
|
-
* ```ts
|
|
2446
|
-
* import { LoroDoc } from "loro-crdt";
|
|
2447
|
-
*
|
|
2448
|
-
* const doc = new LoroDoc();
|
|
2449
|
-
* const text = doc.getText("text");
|
|
2450
|
-
* text.insert(0, "Hello");
|
|
2451
|
-
* text.update("Hello World");
|
|
2452
|
-
* console.log(text.toString()); // "Hello World"
|
|
2453
|
-
* ```
|
|
2454
|
-
* @param {string} text
|
|
2455
|
-
*/
|
|
2456
|
-
update(text: string): void;
|
|
2457
|
-
/**
|
|
2458
|
-
* Update the current text to the target text, the difference is calculated line by line.
|
|
2459
|
-
*
|
|
2460
|
-
* It uses Myers' diff algorithm to compute the optimal difference.
|
|
2461
|
-
* @param {string} text
|
|
2462
|
-
*/
|
|
2463
|
-
updateByLine(text: string): void;
|
|
2464
|
-
/**
|
|
2465
2523
|
* Insert the string at the given index (utf-16 index).
|
|
2466
2524
|
*
|
|
2467
2525
|
* @example
|
|
@@ -2705,6 +2763,12 @@ export class LoroText {
|
|
|
2705
2763
|
*/
|
|
2706
2764
|
push(s: string): void;
|
|
2707
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
|
+
/**
|
|
2708
2772
|
* Get the container id of the text.
|
|
2709
2773
|
*/
|
|
2710
2774
|
readonly id: ContainerID;
|
|
@@ -2974,6 +3038,21 @@ export class LoroTreeNode {
|
|
|
2974
3038
|
*/
|
|
2975
3039
|
isDeleted(): boolean;
|
|
2976
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
|
+
/**
|
|
2977
3056
|
* The TreeID of the node.
|
|
2978
3057
|
*/
|
|
2979
3058
|
readonly id: TreeID;
|
package/bundler/loro_wasm_bg.js
CHANGED
|
@@ -368,17 +368,18 @@ function _assertClass(instance, klass) {
|
|
|
368
368
|
* - endVersionVector
|
|
369
369
|
* - startTimestamp
|
|
370
370
|
* - endTimestamp
|
|
371
|
-
* -
|
|
371
|
+
* - mode
|
|
372
372
|
* - changeNum
|
|
373
373
|
* @param {Uint8Array} blob
|
|
374
|
+
* @param {boolean} check_checksum
|
|
374
375
|
* @returns {ImportBlobMetadata}
|
|
375
376
|
*/
|
|
376
|
-
export function decodeImportBlobMeta(blob) {
|
|
377
|
+
export function decodeImportBlobMeta(blob, check_checksum) {
|
|
377
378
|
try {
|
|
378
379
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
379
380
|
const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export_0);
|
|
380
381
|
const len0 = WASM_VECTOR_LEN;
|
|
381
|
-
wasm.decodeImportBlobMeta(retptr, ptr0, len0);
|
|
382
|
+
wasm.decodeImportBlobMeta(retptr, ptr0, len0, check_checksum);
|
|
382
383
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
383
384
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
384
385
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -1210,7 +1211,7 @@ export class LoroDoc {
|
|
|
1210
1211
|
* @param ids - the changes to visit
|
|
1211
1212
|
* @param f - the callback function, return `true` to continue visiting, return `false` to stop
|
|
1212
1213
|
* @param {({ peer: PeerID, counter: number })[]} ids
|
|
1213
|
-
* @param {
|
|
1214
|
+
* @param {(change: ChangeMeta) => boolean} f
|
|
1214
1215
|
*/
|
|
1215
1216
|
travelChangeAncestors(ids, f) {
|
|
1216
1217
|
try {
|
|
@@ -2357,6 +2358,40 @@ export class LoroDoc {
|
|
|
2357
2358
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2358
2359
|
}
|
|
2359
2360
|
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Gets container IDs modified in the given ID range.
|
|
2363
|
+
*
|
|
2364
|
+
* **NOTE:** This method will implicitly commit.
|
|
2365
|
+
*
|
|
2366
|
+
* This method identifies which containers were affected by changes in a given range of operations.
|
|
2367
|
+
* It can be used together with `doc.travelChangeAncestors()` to analyze the history of changes
|
|
2368
|
+
* and determine which containers were modified by each change.
|
|
2369
|
+
*
|
|
2370
|
+
* @param id - The starting ID of the change range
|
|
2371
|
+
* @param len - The length of the change range to check
|
|
2372
|
+
* @returns An array of container IDs that were modified in the given range
|
|
2373
|
+
* @param {{ peer: PeerID, counter: number }} id
|
|
2374
|
+
* @param {number} len
|
|
2375
|
+
* @returns {(ContainerID)[]}
|
|
2376
|
+
*/
|
|
2377
|
+
getChangedContainersIn(id, len) {
|
|
2378
|
+
try {
|
|
2379
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2380
|
+
wasm.lorodoc_getChangedContainersIn(retptr, this.__wbg_ptr, addHeapObject(id), len);
|
|
2381
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2382
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2383
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2384
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
2385
|
+
if (r3) {
|
|
2386
|
+
throw takeObject(r2);
|
|
2387
|
+
}
|
|
2388
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
2389
|
+
wasm.__wbindgen_export_5(r0, r1 * 4, 4);
|
|
2390
|
+
return v1;
|
|
2391
|
+
} finally {
|
|
2392
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2360
2395
|
}
|
|
2361
2396
|
|
|
2362
2397
|
const LoroListFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -2757,6 +2792,14 @@ export class LoroList {
|
|
|
2757
2792
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2758
2793
|
}
|
|
2759
2794
|
}
|
|
2795
|
+
/**
|
|
2796
|
+
* @param {number} pos
|
|
2797
|
+
* @returns {{ peer: PeerID, counter: number } | undefined}
|
|
2798
|
+
*/
|
|
2799
|
+
getIdAt(pos) {
|
|
2800
|
+
const ret = wasm.lorolist_getIdAt(this.__wbg_ptr, pos);
|
|
2801
|
+
return takeObject(ret);
|
|
2802
|
+
}
|
|
2760
2803
|
}
|
|
2761
2804
|
|
|
2762
2805
|
const LoroMapFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3188,6 +3231,17 @@ export class LoroMap {
|
|
|
3188
3231
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3189
3232
|
}
|
|
3190
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
|
+
}
|
|
3191
3245
|
}
|
|
3192
3246
|
|
|
3193
3247
|
const LoroMovableListFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3660,6 +3714,33 @@ export class LoroMovableList {
|
|
|
3660
3714
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3661
3715
|
}
|
|
3662
3716
|
}
|
|
3717
|
+
/**
|
|
3718
|
+
* Get the creator of the list item at the given position.
|
|
3719
|
+
* @param {number} pos
|
|
3720
|
+
* @returns {PeerID | undefined}
|
|
3721
|
+
*/
|
|
3722
|
+
getCreatorAt(pos) {
|
|
3723
|
+
const ret = wasm.loromovablelist_getCreatorAt(this.__wbg_ptr, pos);
|
|
3724
|
+
return takeObject(ret);
|
|
3725
|
+
}
|
|
3726
|
+
/**
|
|
3727
|
+
* Get the last mover of the list item at the given position.
|
|
3728
|
+
* @param {number} pos
|
|
3729
|
+
* @returns {PeerID | undefined}
|
|
3730
|
+
*/
|
|
3731
|
+
getLastMoverAt(pos) {
|
|
3732
|
+
const ret = wasm.loromovablelist_getLastMoverAt(this.__wbg_ptr, pos);
|
|
3733
|
+
return takeObject(ret);
|
|
3734
|
+
}
|
|
3735
|
+
/**
|
|
3736
|
+
* Get the last editor of the list item at the given position.
|
|
3737
|
+
* @param {number} pos
|
|
3738
|
+
* @returns {PeerID | undefined}
|
|
3739
|
+
*/
|
|
3740
|
+
getLastEditorAt(pos) {
|
|
3741
|
+
const ret = wasm.loromovablelist_getLastEditorAt(this.__wbg_ptr, pos);
|
|
3742
|
+
return takeObject(ret);
|
|
3743
|
+
}
|
|
3663
3744
|
}
|
|
3664
3745
|
|
|
3665
3746
|
const LoroTextFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3711,11 +3792,14 @@ export class LoroText {
|
|
|
3711
3792
|
return takeObject(ret);
|
|
3712
3793
|
}
|
|
3713
3794
|
/**
|
|
3714
|
-
* Iterate each span(internal storage unit)
|
|
3795
|
+
* Iterate each text span(internal storage unit)
|
|
3715
3796
|
*
|
|
3716
3797
|
* The callback function will be called for each span in the text.
|
|
3717
3798
|
* If the callback returns `false`, the iteration will stop.
|
|
3718
3799
|
*
|
|
3800
|
+
* Limitation: you cannot access or alter the doc state when iterating (this is for performance consideration).
|
|
3801
|
+
* If you need to access or alter the doc state, please use `toString` instead.
|
|
3802
|
+
*
|
|
3719
3803
|
* @example
|
|
3720
3804
|
* ```ts
|
|
3721
3805
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -3754,22 +3838,44 @@ export class LoroText {
|
|
|
3754
3838
|
* console.log(text.toString()); // "Hello World"
|
|
3755
3839
|
* ```
|
|
3756
3840
|
* @param {string} text
|
|
3841
|
+
* @param {any} options
|
|
3757
3842
|
*/
|
|
3758
|
-
update(text) {
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3843
|
+
update(text, options) {
|
|
3844
|
+
try {
|
|
3845
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3846
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
3847
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3848
|
+
wasm.lorotext_update(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options));
|
|
3849
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3850
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3851
|
+
if (r1) {
|
|
3852
|
+
throw takeObject(r0);
|
|
3853
|
+
}
|
|
3854
|
+
} finally {
|
|
3855
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3856
|
+
}
|
|
3762
3857
|
}
|
|
3763
3858
|
/**
|
|
3764
3859
|
* Update the current text to the target text, the difference is calculated line by line.
|
|
3765
3860
|
*
|
|
3766
3861
|
* It uses Myers' diff algorithm to compute the optimal difference.
|
|
3767
3862
|
* @param {string} text
|
|
3863
|
+
* @param {any} options
|
|
3768
3864
|
*/
|
|
3769
|
-
updateByLine(text) {
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3865
|
+
updateByLine(text, options) {
|
|
3866
|
+
try {
|
|
3867
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3868
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
3869
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3870
|
+
wasm.lorotext_updateByLine(retptr, this.__wbg_ptr, ptr0, len0, addHeapObject(options));
|
|
3871
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3872
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3873
|
+
if (r1) {
|
|
3874
|
+
throw takeObject(r0);
|
|
3875
|
+
}
|
|
3876
|
+
} finally {
|
|
3877
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3878
|
+
}
|
|
3773
3879
|
}
|
|
3774
3880
|
/**
|
|
3775
3881
|
* Insert the string at the given index (utf-16 index).
|
|
@@ -4267,6 +4373,15 @@ export class LoroText {
|
|
|
4267
4373
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
4268
4374
|
}
|
|
4269
4375
|
}
|
|
4376
|
+
/**
|
|
4377
|
+
* Get the editor of the text at the given position.
|
|
4378
|
+
* @param {number} pos
|
|
4379
|
+
* @returns {PeerID | undefined}
|
|
4380
|
+
*/
|
|
4381
|
+
getEditorOf(pos) {
|
|
4382
|
+
const ret = wasm.lorotext_getEditorOf(this.__wbg_ptr, pos);
|
|
4383
|
+
return takeObject(ret);
|
|
4384
|
+
}
|
|
4270
4385
|
}
|
|
4271
4386
|
|
|
4272
4387
|
const LoroTreeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -4961,6 +5076,24 @@ export class LoroTreeNode {
|
|
|
4961
5076
|
}
|
|
4962
5077
|
}
|
|
4963
5078
|
/**
|
|
5079
|
+
* @returns {any}
|
|
5080
|
+
*/
|
|
5081
|
+
toJSON() {
|
|
5082
|
+
try {
|
|
5083
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
5084
|
+
wasm.lorotreenode_toJSON(retptr, this.__wbg_ptr);
|
|
5085
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
5086
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
5087
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
5088
|
+
if (r2) {
|
|
5089
|
+
throw takeObject(r1);
|
|
5090
|
+
}
|
|
5091
|
+
return takeObject(r0);
|
|
5092
|
+
} finally {
|
|
5093
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
/**
|
|
4964
5097
|
* Get the parent node of this node.
|
|
4965
5098
|
*
|
|
4966
5099
|
* - The parent of the root node is `undefined`.
|
|
@@ -5013,6 +5146,30 @@ export class LoroTreeNode {
|
|
|
5013
5146
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
5014
5147
|
}
|
|
5015
5148
|
}
|
|
5149
|
+
/**
|
|
5150
|
+
* Get the last mover of this node.
|
|
5151
|
+
* @returns {{ peer: PeerID, counter: number } | undefined}
|
|
5152
|
+
*/
|
|
5153
|
+
getLastMoveId() {
|
|
5154
|
+
const ret = wasm.lorotreenode_getLastMoveId(this.__wbg_ptr);
|
|
5155
|
+
return takeObject(ret);
|
|
5156
|
+
}
|
|
5157
|
+
/**
|
|
5158
|
+
* Get the creation id of this node.
|
|
5159
|
+
* @returns {{ peer: PeerID, counter: number }}
|
|
5160
|
+
*/
|
|
5161
|
+
creationId() {
|
|
5162
|
+
const ret = wasm.lorotreenode_creationId(this.__wbg_ptr);
|
|
5163
|
+
return takeObject(ret);
|
|
5164
|
+
}
|
|
5165
|
+
/**
|
|
5166
|
+
* Get the creator of this node.
|
|
5167
|
+
* @returns {PeerID}
|
|
5168
|
+
*/
|
|
5169
|
+
creator() {
|
|
5170
|
+
const ret = wasm.lorotreenode_creator(this.__wbg_ptr);
|
|
5171
|
+
return takeObject(ret);
|
|
5172
|
+
}
|
|
5016
5173
|
}
|
|
5017
5174
|
|
|
5018
5175
|
const UndoManagerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -5400,6 +5557,11 @@ export function __wbg_versionvector_new(arg0) {
|
|
|
5400
5557
|
return addHeapObject(ret);
|
|
5401
5558
|
};
|
|
5402
5559
|
|
|
5560
|
+
export function __wbindgen_is_function(arg0) {
|
|
5561
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
5562
|
+
return ret;
|
|
5563
|
+
};
|
|
5564
|
+
|
|
5403
5565
|
export function __wbindgen_string_new(arg0, arg1) {
|
|
5404
5566
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
5405
5567
|
return addHeapObject(ret);
|
|
@@ -5488,11 +5650,6 @@ export function __wbindgen_as_number(arg0) {
|
|
|
5488
5650
|
return ret;
|
|
5489
5651
|
};
|
|
5490
5652
|
|
|
5491
|
-
export function __wbindgen_is_function(arg0) {
|
|
5492
|
-
const ret = typeof(getObject(arg0)) === 'function';
|
|
5493
|
-
return ret;
|
|
5494
|
-
};
|
|
5495
|
-
|
|
5496
5653
|
export function __wbindgen_is_string(arg0) {
|
|
5497
5654
|
const ret = typeof(getObject(arg0)) === 'string';
|
|
5498
5655
|
return ret;
|
|
@@ -5937,12 +6094,12 @@ export function __wbindgen_memory() {
|
|
|
5937
6094
|
return addHeapObject(ret);
|
|
5938
6095
|
};
|
|
5939
6096
|
|
|
5940
|
-
export function
|
|
6097
|
+
export function __wbindgen_closure_wrapper491(arg0, arg1, arg2) {
|
|
5941
6098
|
const ret = makeMutClosure(arg0, arg1, 9, __wbg_adapter_58);
|
|
5942
6099
|
return addHeapObject(ret);
|
|
5943
6100
|
};
|
|
5944
6101
|
|
|
5945
|
-
export function
|
|
6102
|
+
export function __wbindgen_closure_wrapper494(arg0, arg1, arg2) {
|
|
5946
6103
|
const ret = makeMutClosure(arg0, arg1, 11, __wbg_adapter_61);
|
|
5947
6104
|
return addHeapObject(ret);
|
|
5948
6105
|
};
|
|
Binary file
|
|
@@ -89,12 +89,13 @@ export function lorodoc_frontiersToVV(a: number, b: number, c: number, d: number
|
|
|
89
89
|
export function lorodoc_vvToFrontiers(a: number, b: number, c: number): void;
|
|
90
90
|
export function lorodoc_getByPath(a: number, b: number, c: number): number;
|
|
91
91
|
export function lorodoc_getCursorPos(a: number, b: number, c: number): void;
|
|
92
|
+
export function lorodoc_getChangedContainersIn(a: number, b: number, c: number, d: number): void;
|
|
92
93
|
export function __wbg_lorotext_free(a: number): void;
|
|
93
94
|
export function lorotext_new(): number;
|
|
94
95
|
export function lorotext_kind(a: number): number;
|
|
95
96
|
export function lorotext_iter(a: number, b: number): void;
|
|
96
|
-
export function lorotext_update(a: number, b: number, c: number): void;
|
|
97
|
-
export function lorotext_updateByLine(a: number, b: number, c: number): void;
|
|
97
|
+
export function lorotext_update(a: number, b: number, c: number, d: number, e: number): void;
|
|
98
|
+
export function lorotext_updateByLine(a: number, b: number, c: number, d: number, e: number): void;
|
|
98
99
|
export function lorotext_insert(a: number, b: number, c: number, d: number, e: number): void;
|
|
99
100
|
export function lorotext_slice(a: number, b: number, c: number, d: number): void;
|
|
100
101
|
export function lorotext_charAt(a: number, b: number, c: number): void;
|
|
@@ -114,6 +115,7 @@ export function lorotext_parent(a: number): number;
|
|
|
114
115
|
export function lorotext_getAttached(a: number): number;
|
|
115
116
|
export function lorotext_getCursor(a: number, b: number, c: number): number;
|
|
116
117
|
export function lorotext_push(a: number, b: number, c: number, d: number): void;
|
|
118
|
+
export function lorotext_getEditorOf(a: number, b: number): number;
|
|
117
119
|
export function __wbg_loromap_free(a: number): void;
|
|
118
120
|
export function loromap_new(): number;
|
|
119
121
|
export function loromap_kind(a: number): number;
|
|
@@ -132,6 +134,7 @@ export function loromap_size(a: number): number;
|
|
|
132
134
|
export function loromap_parent(a: number): number;
|
|
133
135
|
export function loromap_getAttached(a: number): number;
|
|
134
136
|
export function loromap_clear(a: number, b: number): void;
|
|
137
|
+
export function loromap_getLastEditor(a: number, b: number, c: number): number;
|
|
135
138
|
export function __wbg_lorolist_free(a: number): void;
|
|
136
139
|
export function lorolist_new(): number;
|
|
137
140
|
export function lorolist_kind(a: number): number;
|
|
@@ -152,6 +155,7 @@ export function lorolist_getCursor(a: number, b: number, c: number): number;
|
|
|
152
155
|
export function lorolist_push(a: number, b: number, c: number): void;
|
|
153
156
|
export function lorolist_pop(a: number, b: number): void;
|
|
154
157
|
export function lorolist_clear(a: number, b: number): void;
|
|
158
|
+
export function lorolist_getIdAt(a: number, b: number): number;
|
|
155
159
|
export function loromovablelist_new(): number;
|
|
156
160
|
export function loromovablelist_kind(a: number): number;
|
|
157
161
|
export function loromovablelist_insert(a: number, b: number, c: number, d: number): void;
|
|
@@ -172,6 +176,9 @@ export function loromovablelist_setContainer(a: number, b: number, c: number, d:
|
|
|
172
176
|
export function loromovablelist_push(a: number, b: number, c: number): void;
|
|
173
177
|
export function loromovablelist_pop(a: number, b: number): void;
|
|
174
178
|
export function loromovablelist_clear(a: number, b: number): void;
|
|
179
|
+
export function loromovablelist_getCreatorAt(a: number, b: number): number;
|
|
180
|
+
export function loromovablelist_getLastMoverAt(a: number, b: number): number;
|
|
181
|
+
export function loromovablelist_getLastEditorAt(a: number, b: number): number;
|
|
175
182
|
export function __wbg_lorotree_free(a: number): void;
|
|
176
183
|
export function lorotreenode___getClassname(a: number, b: number): void;
|
|
177
184
|
export function __wbg_lorotreenode_free(a: number): void;
|
|
@@ -183,9 +190,13 @@ export function lorotreenode_moveBefore(a: number, b: number, c: number): void;
|
|
|
183
190
|
export function lorotreenode_index(a: number, b: number): void;
|
|
184
191
|
export function lorotreenode_fractionalIndex(a: number, b: number): void;
|
|
185
192
|
export function lorotreenode_data(a: number, b: number): void;
|
|
193
|
+
export function lorotreenode_toJSON(a: number, b: number): void;
|
|
186
194
|
export function lorotreenode_parent(a: number, b: number): void;
|
|
187
195
|
export function lorotreenode_children(a: number): number;
|
|
188
196
|
export function lorotreenode_isDeleted(a: number, b: number): void;
|
|
197
|
+
export function lorotreenode_getLastMoveId(a: number): number;
|
|
198
|
+
export function lorotreenode_creationId(a: number): number;
|
|
199
|
+
export function lorotreenode_creator(a: number): number;
|
|
189
200
|
export function lorotree_new(): number;
|
|
190
201
|
export function lorotree_kind(a: number): number;
|
|
191
202
|
export function lorotree_createNode(a: number, b: number, c: number, d: number, e: number): void;
|
|
@@ -235,7 +246,7 @@ export function versionvector_encode(a: number, b: number): void;
|
|
|
235
246
|
export function versionvector_decode(a: number, b: number, c: number): void;
|
|
236
247
|
export function versionvector_get(a: number, b: number, c: number): void;
|
|
237
248
|
export function versionvector_compare(a: number, b: number, c: number): void;
|
|
238
|
-
export function decodeImportBlobMeta(a: number, b: number, c: number): void;
|
|
249
|
+
export function decodeImportBlobMeta(a: number, b: number, c: number, d: number): void;
|
|
239
250
|
export function __wbg_loromovablelist_free(a: number): void;
|
|
240
251
|
export function loromovablelist_parent(a: number): number;
|
|
241
252
|
export function lorotext_isAttached(a: number): number;
|