loro-crdt 1.5.4 → 1.5.6

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.
@@ -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 =
@@ -931,7 +948,7 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
931
948
  * import { LoroDoc } from "loro-crdt";
932
949
  *
933
950
  * const doc = new LoroDoc();
934
- * const list = doc.getList("list");
951
+ * const list = doc.getMovableList("list");
935
952
  * ```
936
953
  */
937
954
  getMovableList<Key extends keyof T | ContainerID>(name: Key): T[Key] extends LoroMovableList ? T[Key] : LoroMovableList;
@@ -967,9 +984,9 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
967
984
  * It ensures deterministic output, making it ideal for hash calculations and integrity checks.
968
985
  *
969
986
  * This method can also export pending changes from the uncommitted transaction that have not yet been applied to the OpLog.
970
- *
987
+ *
971
988
  * This method will NOT trigger a new commit implicitly.
972
- *
989
+ *
973
990
  * @param idSpan - The id span to export.
974
991
  * @returns The changes in the given id span.
975
992
  */
@@ -3958,6 +3975,7 @@ export interface InitOutput {
3958
3975
  readonly __wbg_changemodifier_free: (a: number, b: number) => void;
3959
3976
  readonly changemodifier_setMessage: (a: number, b: number, c: number) => number;
3960
3977
  readonly changemodifier_setTimestamp: (a: number, b: number) => number;
3978
+ readonly redactJsonUpdates: (a: number, b: number, c: number) => void;
3961
3979
  readonly lorodoc_importUpdateBatch: (a: number, b: number, c: number) => void;
3962
3980
  readonly __wbg_loromovablelist_free: (a: number, b: number) => void;
3963
3981
  readonly __wbindgen_export_0: (a: number, b: number) => number;
package/web/loro_wasm.js CHANGED
@@ -375,6 +375,44 @@ export function decodeImportBlobMeta(blob, check_checksum) {
375
375
  }
376
376
  }
377
377
 
378
+ /**
379
+ * Redacts sensitive content in JSON updates within the specified version range.
380
+ *
381
+ * This function allows you to share document history while removing potentially sensitive content.
382
+ * It preserves the document structure and collaboration capabilities while replacing content with
383
+ * placeholders according to these redaction rules:
384
+ *
385
+ * - Preserves delete and move operations
386
+ * - Replaces text insertion content with the Unicode replacement character
387
+ * - Substitutes list and map insert values with null
388
+ * - Maintains structure of child containers
389
+ * - Replaces text mark values with null
390
+ * - Preserves map keys and text annotation keys
391
+ *
392
+ * @param {Object|string} jsonUpdates - The JSON updates to redact (object or JSON string)
393
+ * @param {Object} versionRange - Version range defining what content to redact,
394
+ * format: { peerId: [startCounter, endCounter], ... }
395
+ * @returns {Object} The redacted JSON updates
396
+ * @param {string | JsonSchema} json_updates
397
+ * @param {any} version_range
398
+ * @returns {JsonSchema}
399
+ */
400
+ export function redactJsonUpdates(json_updates, version_range) {
401
+ try {
402
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
403
+ wasm.redactJsonUpdates(retptr, addHeapObject(json_updates), addHeapObject(version_range));
404
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
405
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
406
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
407
+ if (r2) {
408
+ throw takeObject(r1);
409
+ }
410
+ return takeObject(r0);
411
+ } finally {
412
+ wasm.__wbindgen_add_to_stack_pointer(16);
413
+ }
414
+ }
415
+
378
416
  function __wbg_adapter_60(arg0, arg1, arg2) {
379
417
  wasm.__wbindgen_export_5(arg0, arg1, addHeapObject(arg2));
380
418
  }
@@ -6838,7 +6876,7 @@ function __wbg_get_imports() {
6838
6876
  const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
6839
6877
  return addHeapObject(ret);
6840
6878
  };
6841
- imports.wbg.__wbindgen_closure_wrapper486 = function(arg0, arg1, arg2) {
6879
+ imports.wbg.__wbindgen_closure_wrapper485 = function(arg0, arg1, arg2) {
6842
6880
  const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
6843
6881
  return addHeapObject(ret);
6844
6882
  };
Binary file
@@ -304,6 +304,7 @@ export const decodeImportBlobMeta: (a: number, b: number, c: number, d: number)
304
304
  export const __wbg_changemodifier_free: (a: number, b: number) => void;
305
305
  export const changemodifier_setMessage: (a: number, b: number, c: number) => number;
306
306
  export const changemodifier_setTimestamp: (a: number, b: number) => number;
307
+ export const redactJsonUpdates: (a: number, b: number, c: number) => void;
307
308
  export const lorodoc_importUpdateBatch: (a: number, b: number, c: number) => void;
308
309
  export const __wbg_loromovablelist_free: (a: number, b: number) => void;
309
310
  export const __wbindgen_export_0: (a: number, b: number) => number;