loro-crdt 1.5.5 → 1.5.7
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 +13 -0
- package/base64/index.js +63 -8
- package/base64/loro_wasm.d.ts +50 -15
- package/base64/loro_wasm_bg-8058cd67.js +64 -0
- package/bundler/loro_wasm.d.ts +50 -15
- package/bundler/loro_wasm_bg.js +58 -4
- package/bundler/loro_wasm_bg.wasm +0 -0
- package/bundler/loro_wasm_bg.wasm.d.ts +3 -0
- package/nodejs/loro_wasm.d.ts +50 -15
- package/nodejs/loro_wasm.js +58 -4
- package/nodejs/loro_wasm_bg.wasm +0 -0
- package/nodejs/loro_wasm_bg.wasm.d.ts +3 -0
- package/package.json +4 -1
- package/web/loro_wasm.d.ts +53 -15
- package/web/loro_wasm.js +58 -4
- package/web/loro_wasm_bg.wasm +0 -0
- package/web/loro_wasm_bg.wasm.d.ts +3 -0
- package/base64/loro_wasm_bg-40e94009.js +0 -64
package/bundler/loro_wasm.d.ts
CHANGED
|
@@ -24,6 +24,26 @@ export function setDebug(): void;
|
|
|
24
24
|
* - changeNum
|
|
25
25
|
*/
|
|
26
26
|
export function decodeImportBlobMeta(blob: Uint8Array, check_checksum: boolean): ImportBlobMetadata;
|
|
27
|
+
/**
|
|
28
|
+
* Redacts sensitive content in JSON updates within the specified version range.
|
|
29
|
+
*
|
|
30
|
+
* This function allows you to share document history while removing potentially sensitive content.
|
|
31
|
+
* It preserves the document structure and collaboration capabilities while replacing content with
|
|
32
|
+
* placeholders according to these redaction rules:
|
|
33
|
+
*
|
|
34
|
+
* - Preserves delete and move operations
|
|
35
|
+
* - Replaces text insertion content with the Unicode replacement character
|
|
36
|
+
* - Substitutes list and map insert values with null
|
|
37
|
+
* - Maintains structure of child containers
|
|
38
|
+
* - Replaces text mark values with null
|
|
39
|
+
* - Preserves map keys and text annotation keys
|
|
40
|
+
*
|
|
41
|
+
* @param {Object|string} jsonUpdates - The JSON updates to redact (object or JSON string)
|
|
42
|
+
* @param {Object} versionRange - Version range defining what content to redact,
|
|
43
|
+
* format: { peerId: [startCounter, endCounter], ... }
|
|
44
|
+
* @returns {Object} The redacted JSON updates
|
|
45
|
+
*/
|
|
46
|
+
export function redactJsonUpdates(json_updates: string | JsonSchema, version_range: any): JsonSchema;
|
|
27
47
|
|
|
28
48
|
/**
|
|
29
49
|
* Container types supported by loro.
|
|
@@ -194,11 +214,11 @@ interface LoroDoc {
|
|
|
194
214
|
* doc.commit();
|
|
195
215
|
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("test");
|
|
196
216
|
* ```
|
|
197
|
-
*
|
|
217
|
+
*
|
|
198
218
|
* ### Advanced Example: Creating a Merkle DAG
|
|
199
|
-
*
|
|
219
|
+
*
|
|
200
220
|
* By combining `doc.subscribePreCommit` with `doc.exportJsonInIdSpan`, you can implement advanced features like representing Loro's editing history as a Merkle DAG:
|
|
201
|
-
*
|
|
221
|
+
*
|
|
202
222
|
* ```ts
|
|
203
223
|
* const doc = new LoroDoc();
|
|
204
224
|
* doc.setPeerId(0);
|
|
@@ -218,7 +238,7 @@ interface LoroDoc {
|
|
|
218
238
|
* const sha256Hash = hash.digest('hex');
|
|
219
239
|
* e.modifier.setMessage(sha256Hash);
|
|
220
240
|
* });
|
|
221
|
-
*
|
|
241
|
+
*
|
|
222
242
|
* doc.getList("list").insert(0, 100);
|
|
223
243
|
* doc.commit();
|
|
224
244
|
* // Change 0
|
|
@@ -236,8 +256,8 @@ interface LoroDoc {
|
|
|
236
256
|
* // }
|
|
237
257
|
* // ]
|
|
238
258
|
* // }
|
|
239
|
-
*
|
|
240
|
-
*
|
|
259
|
+
*
|
|
260
|
+
*
|
|
241
261
|
* doc.getList("list").insert(0, 200);
|
|
242
262
|
* doc.commit();
|
|
243
263
|
* // Change 1
|
|
@@ -257,13 +277,13 @@ interface LoroDoc {
|
|
|
257
277
|
* // }
|
|
258
278
|
* // ]
|
|
259
279
|
* // }
|
|
260
|
-
*
|
|
280
|
+
*
|
|
261
281
|
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("2af99cf93869173984bcf6b1ce5412610b0413d027a5511a8f720a02a4432853");
|
|
262
282
|
* expect(doc.getChangeAt({ peer: "0", counter: 1 }).message).toBe("aedbb442c554ecf59090e0e8339df1d8febf647f25cc37c67be0c6e27071d37f");
|
|
263
283
|
* ```
|
|
264
|
-
*
|
|
284
|
+
*
|
|
265
285
|
* @param f - A callback function that receives a pre commit event.
|
|
266
|
-
*
|
|
286
|
+
*
|
|
267
287
|
**/
|
|
268
288
|
subscribePreCommit(f: (e: { changeMeta: Change, origin: string, modifier: ChangeModifier }) => void): () => void
|
|
269
289
|
|
|
@@ -587,9 +607,6 @@ interface LoroMovableList {
|
|
|
587
607
|
}
|
|
588
608
|
|
|
589
609
|
export type Side = -1 | 0 | 1;
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
610
|
export type JsonOpID = `${number}@${PeerID}`;
|
|
594
611
|
export type JsonContainerID = `🦜:${ContainerID}` ;
|
|
595
612
|
export type JsonValue =
|
|
@@ -888,6 +905,24 @@ interface UndoManager {
|
|
|
888
905
|
* @param listener - The callback function.
|
|
889
906
|
*/
|
|
890
907
|
setOnPop(listener?: UndoConfig["onPop"]): void;
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Starts a new grouping of undo operations.
|
|
911
|
+
* All changes/commits made after this call will be grouped/merged together.
|
|
912
|
+
* to end the group, call `groupEnd`.
|
|
913
|
+
*
|
|
914
|
+
* If a remote import is received within the group, its possible that the undo item will be
|
|
915
|
+
* split and the group will be automatically ended.
|
|
916
|
+
*
|
|
917
|
+
* Calling `groupStart` within an active group will throw but have no effect.
|
|
918
|
+
*
|
|
919
|
+
*/
|
|
920
|
+
groupStart(): void;
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Ends the current grouping of undo operations.
|
|
924
|
+
*/
|
|
925
|
+
groupEnd(): void;
|
|
891
926
|
}
|
|
892
927
|
interface LoroDoc<T extends Record<string, Container> = Record<string, Container>> {
|
|
893
928
|
/**
|
|
@@ -931,7 +966,7 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
|
|
|
931
966
|
* import { LoroDoc } from "loro-crdt";
|
|
932
967
|
*
|
|
933
968
|
* const doc = new LoroDoc();
|
|
934
|
-
* const list = doc.
|
|
969
|
+
* const list = doc.getMovableList("list");
|
|
935
970
|
* ```
|
|
936
971
|
*/
|
|
937
972
|
getMovableList<Key extends keyof T | ContainerID>(name: Key): T[Key] extends LoroMovableList ? T[Key] : LoroMovableList;
|
|
@@ -967,9 +1002,9 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
|
|
|
967
1002
|
* It ensures deterministic output, making it ideal for hash calculations and integrity checks.
|
|
968
1003
|
*
|
|
969
1004
|
* This method can also export pending changes from the uncommitted transaction that have not yet been applied to the OpLog.
|
|
970
|
-
*
|
|
1005
|
+
*
|
|
971
1006
|
* This method will NOT trigger a new commit implicitly.
|
|
972
|
-
*
|
|
1007
|
+
*
|
|
973
1008
|
* @param idSpan - The id span to export.
|
|
974
1009
|
* @returns The changes in the given id span.
|
|
975
1010
|
*/
|
package/bundler/loro_wasm_bg.js
CHANGED
|
@@ -383,6 +383,44 @@ export function decodeImportBlobMeta(blob, check_checksum) {
|
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Redacts sensitive content in JSON updates within the specified version range.
|
|
388
|
+
*
|
|
389
|
+
* This function allows you to share document history while removing potentially sensitive content.
|
|
390
|
+
* It preserves the document structure and collaboration capabilities while replacing content with
|
|
391
|
+
* placeholders according to these redaction rules:
|
|
392
|
+
*
|
|
393
|
+
* - Preserves delete and move operations
|
|
394
|
+
* - Replaces text insertion content with the Unicode replacement character
|
|
395
|
+
* - Substitutes list and map insert values with null
|
|
396
|
+
* - Maintains structure of child containers
|
|
397
|
+
* - Replaces text mark values with null
|
|
398
|
+
* - Preserves map keys and text annotation keys
|
|
399
|
+
*
|
|
400
|
+
* @param {Object|string} jsonUpdates - The JSON updates to redact (object or JSON string)
|
|
401
|
+
* @param {Object} versionRange - Version range defining what content to redact,
|
|
402
|
+
* format: { peerId: [startCounter, endCounter], ... }
|
|
403
|
+
* @returns {Object} The redacted JSON updates
|
|
404
|
+
* @param {string | JsonSchema} json_updates
|
|
405
|
+
* @param {any} version_range
|
|
406
|
+
* @returns {JsonSchema}
|
|
407
|
+
*/
|
|
408
|
+
export function redactJsonUpdates(json_updates, version_range) {
|
|
409
|
+
try {
|
|
410
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
411
|
+
wasm.redactJsonUpdates(retptr, addHeapObject(json_updates), addHeapObject(version_range));
|
|
412
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
413
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
414
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
415
|
+
if (r2) {
|
|
416
|
+
throw takeObject(r1);
|
|
417
|
+
}
|
|
418
|
+
return takeObject(r0);
|
|
419
|
+
} finally {
|
|
420
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
386
424
|
function __wbg_adapter_60(arg0, arg1, arg2) {
|
|
387
425
|
wasm.__wbindgen_export_5(arg0, arg1, addHeapObject(arg2));
|
|
388
426
|
}
|
|
@@ -6133,6 +6171,22 @@ export class UndoManager {
|
|
|
6133
6171
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
6134
6172
|
}
|
|
6135
6173
|
}
|
|
6174
|
+
groupStart() {
|
|
6175
|
+
try {
|
|
6176
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
6177
|
+
wasm.undomanager_groupStart(retptr, this.__wbg_ptr);
|
|
6178
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
6179
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
6180
|
+
if (r1) {
|
|
6181
|
+
throw takeObject(r0);
|
|
6182
|
+
}
|
|
6183
|
+
} finally {
|
|
6184
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
groupEnd() {
|
|
6188
|
+
wasm.undomanager_groupEnd(this.__wbg_ptr);
|
|
6189
|
+
}
|
|
6136
6190
|
/**
|
|
6137
6191
|
* Can undo the last operation.
|
|
6138
6192
|
* @returns {boolean}
|
|
@@ -6751,7 +6805,7 @@ export function __wbg_node_02999533c4ea02e3(arg0) {
|
|
|
6751
6805
|
return addHeapObject(ret);
|
|
6752
6806
|
};
|
|
6753
6807
|
|
|
6754
|
-
export function
|
|
6808
|
+
export function __wbg_now_dc4980649ae44bd7() {
|
|
6755
6809
|
const ret = Date.now();
|
|
6756
6810
|
return ret;
|
|
6757
6811
|
};
|
|
@@ -6893,12 +6947,12 @@ export function __wbindgen_cb_drop(arg0) {
|
|
|
6893
6947
|
};
|
|
6894
6948
|
|
|
6895
6949
|
export function __wbindgen_closure_wrapper483(arg0, arg1, arg2) {
|
|
6896
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6950
|
+
const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
|
|
6897
6951
|
return addHeapObject(ret);
|
|
6898
6952
|
};
|
|
6899
6953
|
|
|
6900
|
-
export function
|
|
6901
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6954
|
+
export function __wbindgen_closure_wrapper486(arg0, arg1, arg2) {
|
|
6955
|
+
const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
|
|
6902
6956
|
return addHeapObject(ret);
|
|
6903
6957
|
};
|
|
6904
6958
|
|
|
Binary file
|
|
@@ -280,6 +280,8 @@ export const __wbg_undomanager_free: (a: number, b: number) => void;
|
|
|
280
280
|
export const undomanager_new: (a: number, b: number) => number;
|
|
281
281
|
export const undomanager_undo: (a: number, b: number) => void;
|
|
282
282
|
export const undomanager_redo: (a: number, b: number) => void;
|
|
283
|
+
export const undomanager_groupStart: (a: number, b: number) => void;
|
|
284
|
+
export const undomanager_groupEnd: (a: number) => void;
|
|
283
285
|
export const undomanager_canUndo: (a: number) => number;
|
|
284
286
|
export const undomanager_canRedo: (a: number) => number;
|
|
285
287
|
export const undomanager_setMaxUndoSteps: (a: number, b: number) => void;
|
|
@@ -304,6 +306,7 @@ export const decodeImportBlobMeta: (a: number, b: number, c: number, d: number)
|
|
|
304
306
|
export const __wbg_changemodifier_free: (a: number, b: number) => void;
|
|
305
307
|
export const changemodifier_setMessage: (a: number, b: number, c: number) => number;
|
|
306
308
|
export const changemodifier_setTimestamp: (a: number, b: number) => number;
|
|
309
|
+
export const redactJsonUpdates: (a: number, b: number, c: number) => void;
|
|
307
310
|
export const lorodoc_importUpdateBatch: (a: number, b: number, c: number) => void;
|
|
308
311
|
export const __wbg_loromovablelist_free: (a: number, b: number) => void;
|
|
309
312
|
export const __wbindgen_export_0: (a: number, b: number) => number;
|
package/nodejs/loro_wasm.d.ts
CHANGED
|
@@ -24,6 +24,26 @@ export function setDebug(): void;
|
|
|
24
24
|
* - changeNum
|
|
25
25
|
*/
|
|
26
26
|
export function decodeImportBlobMeta(blob: Uint8Array, check_checksum: boolean): ImportBlobMetadata;
|
|
27
|
+
/**
|
|
28
|
+
* Redacts sensitive content in JSON updates within the specified version range.
|
|
29
|
+
*
|
|
30
|
+
* This function allows you to share document history while removing potentially sensitive content.
|
|
31
|
+
* It preserves the document structure and collaboration capabilities while replacing content with
|
|
32
|
+
* placeholders according to these redaction rules:
|
|
33
|
+
*
|
|
34
|
+
* - Preserves delete and move operations
|
|
35
|
+
* - Replaces text insertion content with the Unicode replacement character
|
|
36
|
+
* - Substitutes list and map insert values with null
|
|
37
|
+
* - Maintains structure of child containers
|
|
38
|
+
* - Replaces text mark values with null
|
|
39
|
+
* - Preserves map keys and text annotation keys
|
|
40
|
+
*
|
|
41
|
+
* @param {Object|string} jsonUpdates - The JSON updates to redact (object or JSON string)
|
|
42
|
+
* @param {Object} versionRange - Version range defining what content to redact,
|
|
43
|
+
* format: { peerId: [startCounter, endCounter], ... }
|
|
44
|
+
* @returns {Object} The redacted JSON updates
|
|
45
|
+
*/
|
|
46
|
+
export function redactJsonUpdates(json_updates: string | JsonSchema, version_range: any): JsonSchema;
|
|
27
47
|
|
|
28
48
|
/**
|
|
29
49
|
* Container types supported by loro.
|
|
@@ -194,11 +214,11 @@ interface LoroDoc {
|
|
|
194
214
|
* doc.commit();
|
|
195
215
|
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("test");
|
|
196
216
|
* ```
|
|
197
|
-
*
|
|
217
|
+
*
|
|
198
218
|
* ### Advanced Example: Creating a Merkle DAG
|
|
199
|
-
*
|
|
219
|
+
*
|
|
200
220
|
* By combining `doc.subscribePreCommit` with `doc.exportJsonInIdSpan`, you can implement advanced features like representing Loro's editing history as a Merkle DAG:
|
|
201
|
-
*
|
|
221
|
+
*
|
|
202
222
|
* ```ts
|
|
203
223
|
* const doc = new LoroDoc();
|
|
204
224
|
* doc.setPeerId(0);
|
|
@@ -218,7 +238,7 @@ interface LoroDoc {
|
|
|
218
238
|
* const sha256Hash = hash.digest('hex');
|
|
219
239
|
* e.modifier.setMessage(sha256Hash);
|
|
220
240
|
* });
|
|
221
|
-
*
|
|
241
|
+
*
|
|
222
242
|
* doc.getList("list").insert(0, 100);
|
|
223
243
|
* doc.commit();
|
|
224
244
|
* // Change 0
|
|
@@ -236,8 +256,8 @@ interface LoroDoc {
|
|
|
236
256
|
* // }
|
|
237
257
|
* // ]
|
|
238
258
|
* // }
|
|
239
|
-
*
|
|
240
|
-
*
|
|
259
|
+
*
|
|
260
|
+
*
|
|
241
261
|
* doc.getList("list").insert(0, 200);
|
|
242
262
|
* doc.commit();
|
|
243
263
|
* // Change 1
|
|
@@ -257,13 +277,13 @@ interface LoroDoc {
|
|
|
257
277
|
* // }
|
|
258
278
|
* // ]
|
|
259
279
|
* // }
|
|
260
|
-
*
|
|
280
|
+
*
|
|
261
281
|
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("2af99cf93869173984bcf6b1ce5412610b0413d027a5511a8f720a02a4432853");
|
|
262
282
|
* expect(doc.getChangeAt({ peer: "0", counter: 1 }).message).toBe("aedbb442c554ecf59090e0e8339df1d8febf647f25cc37c67be0c6e27071d37f");
|
|
263
283
|
* ```
|
|
264
|
-
*
|
|
284
|
+
*
|
|
265
285
|
* @param f - A callback function that receives a pre commit event.
|
|
266
|
-
*
|
|
286
|
+
*
|
|
267
287
|
**/
|
|
268
288
|
subscribePreCommit(f: (e: { changeMeta: Change, origin: string, modifier: ChangeModifier }) => void): () => void
|
|
269
289
|
|
|
@@ -587,9 +607,6 @@ interface LoroMovableList {
|
|
|
587
607
|
}
|
|
588
608
|
|
|
589
609
|
export type Side = -1 | 0 | 1;
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
610
|
export type JsonOpID = `${number}@${PeerID}`;
|
|
594
611
|
export type JsonContainerID = `🦜:${ContainerID}` ;
|
|
595
612
|
export type JsonValue =
|
|
@@ -888,6 +905,24 @@ interface UndoManager {
|
|
|
888
905
|
* @param listener - The callback function.
|
|
889
906
|
*/
|
|
890
907
|
setOnPop(listener?: UndoConfig["onPop"]): void;
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Starts a new grouping of undo operations.
|
|
911
|
+
* All changes/commits made after this call will be grouped/merged together.
|
|
912
|
+
* to end the group, call `groupEnd`.
|
|
913
|
+
*
|
|
914
|
+
* If a remote import is received within the group, its possible that the undo item will be
|
|
915
|
+
* split and the group will be automatically ended.
|
|
916
|
+
*
|
|
917
|
+
* Calling `groupStart` within an active group will throw but have no effect.
|
|
918
|
+
*
|
|
919
|
+
*/
|
|
920
|
+
groupStart(): void;
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Ends the current grouping of undo operations.
|
|
924
|
+
*/
|
|
925
|
+
groupEnd(): void;
|
|
891
926
|
}
|
|
892
927
|
interface LoroDoc<T extends Record<string, Container> = Record<string, Container>> {
|
|
893
928
|
/**
|
|
@@ -931,7 +966,7 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
|
|
|
931
966
|
* import { LoroDoc } from "loro-crdt";
|
|
932
967
|
*
|
|
933
968
|
* const doc = new LoroDoc();
|
|
934
|
-
* const list = doc.
|
|
969
|
+
* const list = doc.getMovableList("list");
|
|
935
970
|
* ```
|
|
936
971
|
*/
|
|
937
972
|
getMovableList<Key extends keyof T | ContainerID>(name: Key): T[Key] extends LoroMovableList ? T[Key] : LoroMovableList;
|
|
@@ -967,9 +1002,9 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
|
|
|
967
1002
|
* It ensures deterministic output, making it ideal for hash calculations and integrity checks.
|
|
968
1003
|
*
|
|
969
1004
|
* This method can also export pending changes from the uncommitted transaction that have not yet been applied to the OpLog.
|
|
970
|
-
*
|
|
1005
|
+
*
|
|
971
1006
|
* This method will NOT trigger a new commit implicitly.
|
|
972
|
-
*
|
|
1007
|
+
*
|
|
973
1008
|
* @param idSpan - The id span to export.
|
|
974
1009
|
* @returns The changes in the given id span.
|
|
975
1010
|
*/
|
package/nodejs/loro_wasm.js
CHANGED
|
@@ -379,6 +379,44 @@ module.exports.decodeImportBlobMeta = function(blob, check_checksum) {
|
|
|
379
379
|
}
|
|
380
380
|
};
|
|
381
381
|
|
|
382
|
+
/**
|
|
383
|
+
* Redacts sensitive content in JSON updates within the specified version range.
|
|
384
|
+
*
|
|
385
|
+
* This function allows you to share document history while removing potentially sensitive content.
|
|
386
|
+
* It preserves the document structure and collaboration capabilities while replacing content with
|
|
387
|
+
* placeholders according to these redaction rules:
|
|
388
|
+
*
|
|
389
|
+
* - Preserves delete and move operations
|
|
390
|
+
* - Replaces text insertion content with the Unicode replacement character
|
|
391
|
+
* - Substitutes list and map insert values with null
|
|
392
|
+
* - Maintains structure of child containers
|
|
393
|
+
* - Replaces text mark values with null
|
|
394
|
+
* - Preserves map keys and text annotation keys
|
|
395
|
+
*
|
|
396
|
+
* @param {Object|string} jsonUpdates - The JSON updates to redact (object or JSON string)
|
|
397
|
+
* @param {Object} versionRange - Version range defining what content to redact,
|
|
398
|
+
* format: { peerId: [startCounter, endCounter], ... }
|
|
399
|
+
* @returns {Object} The redacted JSON updates
|
|
400
|
+
* @param {string | JsonSchema} json_updates
|
|
401
|
+
* @param {any} version_range
|
|
402
|
+
* @returns {JsonSchema}
|
|
403
|
+
*/
|
|
404
|
+
module.exports.redactJsonUpdates = function(json_updates, version_range) {
|
|
405
|
+
try {
|
|
406
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
407
|
+
wasm.redactJsonUpdates(retptr, addHeapObject(json_updates), addHeapObject(version_range));
|
|
408
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
409
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
410
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
411
|
+
if (r2) {
|
|
412
|
+
throw takeObject(r1);
|
|
413
|
+
}
|
|
414
|
+
return takeObject(r0);
|
|
415
|
+
} finally {
|
|
416
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
|
|
382
420
|
function __wbg_adapter_60(arg0, arg1, arg2) {
|
|
383
421
|
wasm.__wbindgen_export_5(arg0, arg1, addHeapObject(arg2));
|
|
384
422
|
}
|
|
@@ -6141,6 +6179,22 @@ class UndoManager {
|
|
|
6141
6179
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
6142
6180
|
}
|
|
6143
6181
|
}
|
|
6182
|
+
groupStart() {
|
|
6183
|
+
try {
|
|
6184
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
6185
|
+
wasm.undomanager_groupStart(retptr, this.__wbg_ptr);
|
|
6186
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
6187
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
6188
|
+
if (r1) {
|
|
6189
|
+
throw takeObject(r0);
|
|
6190
|
+
}
|
|
6191
|
+
} finally {
|
|
6192
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
6193
|
+
}
|
|
6194
|
+
}
|
|
6195
|
+
groupEnd() {
|
|
6196
|
+
wasm.undomanager_groupEnd(this.__wbg_ptr);
|
|
6197
|
+
}
|
|
6144
6198
|
/**
|
|
6145
6199
|
* Can undo the last operation.
|
|
6146
6200
|
* @returns {boolean}
|
|
@@ -6761,7 +6815,7 @@ module.exports.__wbg_node_02999533c4ea02e3 = function(arg0) {
|
|
|
6761
6815
|
return addHeapObject(ret);
|
|
6762
6816
|
};
|
|
6763
6817
|
|
|
6764
|
-
module.exports.
|
|
6818
|
+
module.exports.__wbg_now_dc4980649ae44bd7 = function() {
|
|
6765
6819
|
const ret = Date.now();
|
|
6766
6820
|
return ret;
|
|
6767
6821
|
};
|
|
@@ -6903,12 +6957,12 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
|
|
|
6903
6957
|
};
|
|
6904
6958
|
|
|
6905
6959
|
module.exports.__wbindgen_closure_wrapper483 = function(arg0, arg1, arg2) {
|
|
6906
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6960
|
+
const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
|
|
6907
6961
|
return addHeapObject(ret);
|
|
6908
6962
|
};
|
|
6909
6963
|
|
|
6910
|
-
module.exports.
|
|
6911
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
6964
|
+
module.exports.__wbindgen_closure_wrapper486 = function(arg0, arg1, arg2) {
|
|
6965
|
+
const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
|
|
6912
6966
|
return addHeapObject(ret);
|
|
6913
6967
|
};
|
|
6914
6968
|
|
package/nodejs/loro_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -280,6 +280,8 @@ export const __wbg_undomanager_free: (a: number, b: number) => void;
|
|
|
280
280
|
export const undomanager_new: (a: number, b: number) => number;
|
|
281
281
|
export const undomanager_undo: (a: number, b: number) => void;
|
|
282
282
|
export const undomanager_redo: (a: number, b: number) => void;
|
|
283
|
+
export const undomanager_groupStart: (a: number, b: number) => void;
|
|
284
|
+
export const undomanager_groupEnd: (a: number) => void;
|
|
283
285
|
export const undomanager_canUndo: (a: number) => number;
|
|
284
286
|
export const undomanager_canRedo: (a: number) => number;
|
|
285
287
|
export const undomanager_setMaxUndoSteps: (a: number, b: number) => void;
|
|
@@ -304,6 +306,7 @@ export const decodeImportBlobMeta: (a: number, b: number, c: number, d: number)
|
|
|
304
306
|
export const __wbg_changemodifier_free: (a: number, b: number) => void;
|
|
305
307
|
export const changemodifier_setMessage: (a: number, b: number, c: number) => number;
|
|
306
308
|
export const changemodifier_setTimestamp: (a: number, b: number) => number;
|
|
309
|
+
export const redactJsonUpdates: (a: number, b: number, c: number) => void;
|
|
307
310
|
export const lorodoc_importUpdateBatch: (a: number, b: number, c: number) => void;
|
|
308
311
|
export const __wbg_loromovablelist_free: (a: number, b: number) => void;
|
|
309
312
|
export const __wbindgen_export_0: (a: number, b: number) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loro-crdt",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Loro CRDTs is a high-performance CRDT framework that makes your app state synchronized, collaborative and maintainable effortlessly.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crdt",
|
|
@@ -36,12 +36,15 @@
|
|
|
36
36
|
"author": "",
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@actions/core": "^1.11.1",
|
|
40
|
+
"@actions/github": "^6.0.1",
|
|
39
41
|
"@rollup/plugin-alias": "^5.1.1",
|
|
40
42
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
41
43
|
"@rollup/plugin-typescript": "^12.1.1",
|
|
42
44
|
"@rollup/plugin-wasm": "^6.2.2",
|
|
43
45
|
"@typescript-eslint/parser": "^6.2.0",
|
|
44
46
|
"@vitest/ui": "^1.0.4",
|
|
47
|
+
"brotli-wasm": "^3.0.1",
|
|
45
48
|
"esbuild": "^0.18.20",
|
|
46
49
|
"eslint": "^8.46.0",
|
|
47
50
|
"loro-crdt-alpha-4": "npm:loro-crdt@=1.0.0-alpha.4",
|
package/web/loro_wasm.d.ts
CHANGED
|
@@ -24,6 +24,26 @@ export function setDebug(): void;
|
|
|
24
24
|
* - changeNum
|
|
25
25
|
*/
|
|
26
26
|
export function decodeImportBlobMeta(blob: Uint8Array, check_checksum: boolean): ImportBlobMetadata;
|
|
27
|
+
/**
|
|
28
|
+
* Redacts sensitive content in JSON updates within the specified version range.
|
|
29
|
+
*
|
|
30
|
+
* This function allows you to share document history while removing potentially sensitive content.
|
|
31
|
+
* It preserves the document structure and collaboration capabilities while replacing content with
|
|
32
|
+
* placeholders according to these redaction rules:
|
|
33
|
+
*
|
|
34
|
+
* - Preserves delete and move operations
|
|
35
|
+
* - Replaces text insertion content with the Unicode replacement character
|
|
36
|
+
* - Substitutes list and map insert values with null
|
|
37
|
+
* - Maintains structure of child containers
|
|
38
|
+
* - Replaces text mark values with null
|
|
39
|
+
* - Preserves map keys and text annotation keys
|
|
40
|
+
*
|
|
41
|
+
* @param {Object|string} jsonUpdates - The JSON updates to redact (object or JSON string)
|
|
42
|
+
* @param {Object} versionRange - Version range defining what content to redact,
|
|
43
|
+
* format: { peerId: [startCounter, endCounter], ... }
|
|
44
|
+
* @returns {Object} The redacted JSON updates
|
|
45
|
+
*/
|
|
46
|
+
export function redactJsonUpdates(json_updates: string | JsonSchema, version_range: any): JsonSchema;
|
|
27
47
|
|
|
28
48
|
/**
|
|
29
49
|
* Container types supported by loro.
|
|
@@ -194,11 +214,11 @@ interface LoroDoc {
|
|
|
194
214
|
* doc.commit();
|
|
195
215
|
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("test");
|
|
196
216
|
* ```
|
|
197
|
-
*
|
|
217
|
+
*
|
|
198
218
|
* ### Advanced Example: Creating a Merkle DAG
|
|
199
|
-
*
|
|
219
|
+
*
|
|
200
220
|
* By combining `doc.subscribePreCommit` with `doc.exportJsonInIdSpan`, you can implement advanced features like representing Loro's editing history as a Merkle DAG:
|
|
201
|
-
*
|
|
221
|
+
*
|
|
202
222
|
* ```ts
|
|
203
223
|
* const doc = new LoroDoc();
|
|
204
224
|
* doc.setPeerId(0);
|
|
@@ -218,7 +238,7 @@ interface LoroDoc {
|
|
|
218
238
|
* const sha256Hash = hash.digest('hex');
|
|
219
239
|
* e.modifier.setMessage(sha256Hash);
|
|
220
240
|
* });
|
|
221
|
-
*
|
|
241
|
+
*
|
|
222
242
|
* doc.getList("list").insert(0, 100);
|
|
223
243
|
* doc.commit();
|
|
224
244
|
* // Change 0
|
|
@@ -236,8 +256,8 @@ interface LoroDoc {
|
|
|
236
256
|
* // }
|
|
237
257
|
* // ]
|
|
238
258
|
* // }
|
|
239
|
-
*
|
|
240
|
-
*
|
|
259
|
+
*
|
|
260
|
+
*
|
|
241
261
|
* doc.getList("list").insert(0, 200);
|
|
242
262
|
* doc.commit();
|
|
243
263
|
* // Change 1
|
|
@@ -257,13 +277,13 @@ interface LoroDoc {
|
|
|
257
277
|
* // }
|
|
258
278
|
* // ]
|
|
259
279
|
* // }
|
|
260
|
-
*
|
|
280
|
+
*
|
|
261
281
|
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("2af99cf93869173984bcf6b1ce5412610b0413d027a5511a8f720a02a4432853");
|
|
262
282
|
* expect(doc.getChangeAt({ peer: "0", counter: 1 }).message).toBe("aedbb442c554ecf59090e0e8339df1d8febf647f25cc37c67be0c6e27071d37f");
|
|
263
283
|
* ```
|
|
264
|
-
*
|
|
284
|
+
*
|
|
265
285
|
* @param f - A callback function that receives a pre commit event.
|
|
266
|
-
*
|
|
286
|
+
*
|
|
267
287
|
**/
|
|
268
288
|
subscribePreCommit(f: (e: { changeMeta: Change, origin: string, modifier: ChangeModifier }) => void): () => void
|
|
269
289
|
|
|
@@ -587,9 +607,6 @@ interface LoroMovableList {
|
|
|
587
607
|
}
|
|
588
608
|
|
|
589
609
|
export type Side = -1 | 0 | 1;
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
610
|
export type JsonOpID = `${number}@${PeerID}`;
|
|
594
611
|
export type JsonContainerID = `🦜:${ContainerID}` ;
|
|
595
612
|
export type JsonValue =
|
|
@@ -888,6 +905,24 @@ interface UndoManager {
|
|
|
888
905
|
* @param listener - The callback function.
|
|
889
906
|
*/
|
|
890
907
|
setOnPop(listener?: UndoConfig["onPop"]): void;
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Starts a new grouping of undo operations.
|
|
911
|
+
* All changes/commits made after this call will be grouped/merged together.
|
|
912
|
+
* to end the group, call `groupEnd`.
|
|
913
|
+
*
|
|
914
|
+
* If a remote import is received within the group, its possible that the undo item will be
|
|
915
|
+
* split and the group will be automatically ended.
|
|
916
|
+
*
|
|
917
|
+
* Calling `groupStart` within an active group will throw but have no effect.
|
|
918
|
+
*
|
|
919
|
+
*/
|
|
920
|
+
groupStart(): void;
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Ends the current grouping of undo operations.
|
|
924
|
+
*/
|
|
925
|
+
groupEnd(): void;
|
|
891
926
|
}
|
|
892
927
|
interface LoroDoc<T extends Record<string, Container> = Record<string, Container>> {
|
|
893
928
|
/**
|
|
@@ -931,7 +966,7 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
|
|
|
931
966
|
* import { LoroDoc } from "loro-crdt";
|
|
932
967
|
*
|
|
933
968
|
* const doc = new LoroDoc();
|
|
934
|
-
* const list = doc.
|
|
969
|
+
* const list = doc.getMovableList("list");
|
|
935
970
|
* ```
|
|
936
971
|
*/
|
|
937
972
|
getMovableList<Key extends keyof T | ContainerID>(name: Key): T[Key] extends LoroMovableList ? T[Key] : LoroMovableList;
|
|
@@ -967,9 +1002,9 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
|
|
|
967
1002
|
* It ensures deterministic output, making it ideal for hash calculations and integrity checks.
|
|
968
1003
|
*
|
|
969
1004
|
* This method can also export pending changes from the uncommitted transaction that have not yet been applied to the OpLog.
|
|
970
|
-
*
|
|
1005
|
+
*
|
|
971
1006
|
* This method will NOT trigger a new commit implicitly.
|
|
972
|
-
*
|
|
1007
|
+
*
|
|
973
1008
|
* @param idSpan - The id span to export.
|
|
974
1009
|
* @returns The changes in the given id span.
|
|
975
1010
|
*/
|
|
@@ -3934,6 +3969,8 @@ export interface InitOutput {
|
|
|
3934
3969
|
readonly undomanager_new: (a: number, b: number) => number;
|
|
3935
3970
|
readonly undomanager_undo: (a: number, b: number) => void;
|
|
3936
3971
|
readonly undomanager_redo: (a: number, b: number) => void;
|
|
3972
|
+
readonly undomanager_groupStart: (a: number, b: number) => void;
|
|
3973
|
+
readonly undomanager_groupEnd: (a: number) => void;
|
|
3937
3974
|
readonly undomanager_canUndo: (a: number) => number;
|
|
3938
3975
|
readonly undomanager_canRedo: (a: number) => number;
|
|
3939
3976
|
readonly undomanager_setMaxUndoSteps: (a: number, b: number) => void;
|
|
@@ -3958,6 +3995,7 @@ export interface InitOutput {
|
|
|
3958
3995
|
readonly __wbg_changemodifier_free: (a: number, b: number) => void;
|
|
3959
3996
|
readonly changemodifier_setMessage: (a: number, b: number, c: number) => number;
|
|
3960
3997
|
readonly changemodifier_setTimestamp: (a: number, b: number) => number;
|
|
3998
|
+
readonly redactJsonUpdates: (a: number, b: number, c: number) => void;
|
|
3961
3999
|
readonly lorodoc_importUpdateBatch: (a: number, b: number, c: number) => void;
|
|
3962
4000
|
readonly __wbg_loromovablelist_free: (a: number, b: number) => void;
|
|
3963
4001
|
readonly __wbindgen_export_0: (a: number, b: number) => number;
|