loro-crdt 1.5.1 → 1.5.2

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.
@@ -2508,6 +2508,29 @@ export class LoroDoc {
2508
2508
  * ```
2509
2509
  */
2510
2510
  getUncommittedOpsAsJson(): JsonSchema | undefined;
2511
+ /**
2512
+ * Delete all content from a root container and hide it from the document.
2513
+ *
2514
+ * When a root container is empty and hidden:
2515
+ * - It won't show up in `get_deep_value()` results
2516
+ * - It won't be included in document snapshots
2517
+ *
2518
+ * Only works on root containers (containers without parents).
2519
+ */
2520
+ deleteRootContainer(cid: ContainerID): void;
2521
+ /**
2522
+ * Set whether to hide empty root containers.
2523
+ *
2524
+ * @example
2525
+ * ```ts
2526
+ * const doc = new LoroDoc();
2527
+ * const map = doc.getMap("map");
2528
+ * console.log(doc.toJSON()); // { map: {} }
2529
+ * doc.setHideEmptyRootContainers(true);
2530
+ * console.log(doc.toJSON()); // {}
2531
+ * ```
2532
+ */
2533
+ setHideEmptyRootContainers(hide: boolean): void;
2511
2534
  /**
2512
2535
  * Peer ID of the current writer.
2513
2536
  */
@@ -3029,6 +3029,55 @@ export class LoroDoc {
3029
3029
  const ret = wasm.lorodoc_subscribePreCommit(this.__wbg_ptr, addHeapObject(f));
3030
3030
  return takeObject(ret);
3031
3031
  }
3032
+ /**
3033
+ * Delete all content from a root container and hide it from the document.
3034
+ *
3035
+ * When a root container is empty and hidden:
3036
+ * - It won't show up in `get_deep_value()` results
3037
+ * - It won't be included in document snapshots
3038
+ *
3039
+ * Only works on root containers (containers without parents).
3040
+ * @param {ContainerID} cid
3041
+ */
3042
+ deleteRootContainer(cid) {
3043
+ try {
3044
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3045
+ wasm.lorodoc_deleteRootContainer(retptr, this.__wbg_ptr, addHeapObject(cid));
3046
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3047
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3048
+ if (r1) {
3049
+ throw takeObject(r0);
3050
+ }
3051
+ } finally {
3052
+ wasm.__wbindgen_add_to_stack_pointer(16);
3053
+ }
3054
+ }
3055
+ /**
3056
+ * Set whether to hide empty root containers.
3057
+ *
3058
+ * @example
3059
+ * ```ts
3060
+ * const doc = new LoroDoc();
3061
+ * const map = doc.getMap("map");
3062
+ * console.log(doc.toJSON()); // { map: {} }
3063
+ * doc.setHideEmptyRootContainers(true);
3064
+ * console.log(doc.toJSON()); // {}
3065
+ * ```
3066
+ * @param {boolean} hide
3067
+ */
3068
+ setHideEmptyRootContainers(hide) {
3069
+ try {
3070
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3071
+ wasm.lorodoc_setHideEmptyRootContainers(retptr, this.__wbg_ptr, hide);
3072
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3073
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3074
+ if (r1) {
3075
+ throw takeObject(r0);
3076
+ }
3077
+ } finally {
3078
+ wasm.__wbindgen_add_to_stack_pointer(16);
3079
+ }
3080
+ }
3032
3081
  }
3033
3082
 
3034
3083
  const LoroListFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -6843,12 +6892,12 @@ export function __wbindgen_cb_drop(arg0) {
6843
6892
  return ret;
6844
6893
  };
6845
6894
 
6846
- export function __wbindgen_closure_wrapper487(arg0, arg1, arg2) {
6895
+ export function __wbindgen_closure_wrapper483(arg0, arg1, arg2) {
6847
6896
  const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
6848
6897
  return addHeapObject(ret);
6849
6898
  };
6850
6899
 
6851
- export function __wbindgen_closure_wrapper490(arg0, arg1, arg2) {
6900
+ export function __wbindgen_closure_wrapper486(arg0, arg1, arg2) {
6852
6901
  const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
6853
6902
  return addHeapObject(ret);
6854
6903
  };
Binary file
@@ -124,6 +124,8 @@ export const lorodoc_diff: (a: number, b: number, c: number, d: number, e: numbe
124
124
  export const lorodoc_getUncommittedOpsAsJson: (a: number, b: number) => void;
125
125
  export const lorodoc_subscribeFirstCommitFromPeer: (a: number, b: number) => number;
126
126
  export const lorodoc_subscribePreCommit: (a: number, b: number) => number;
127
+ export const lorodoc_deleteRootContainer: (a: number, b: number, c: number) => void;
128
+ export const lorodoc_setHideEmptyRootContainers: (a: number, b: number, c: number) => void;
127
129
  export const __wbg_lorotext_free: (a: number, b: number) => void;
128
130
  export const lorotext_new: () => number;
129
131
  export const lorotext_kind: (a: number) => number;
@@ -2508,6 +2508,29 @@ export class LoroDoc {
2508
2508
  * ```
2509
2509
  */
2510
2510
  getUncommittedOpsAsJson(): JsonSchema | undefined;
2511
+ /**
2512
+ * Delete all content from a root container and hide it from the document.
2513
+ *
2514
+ * When a root container is empty and hidden:
2515
+ * - It won't show up in `get_deep_value()` results
2516
+ * - It won't be included in document snapshots
2517
+ *
2518
+ * Only works on root containers (containers without parents).
2519
+ */
2520
+ deleteRootContainer(cid: ContainerID): void;
2521
+ /**
2522
+ * Set whether to hide empty root containers.
2523
+ *
2524
+ * @example
2525
+ * ```ts
2526
+ * const doc = new LoroDoc();
2527
+ * const map = doc.getMap("map");
2528
+ * console.log(doc.toJSON()); // { map: {} }
2529
+ * doc.setHideEmptyRootContainers(true);
2530
+ * console.log(doc.toJSON()); // {}
2531
+ * ```
2532
+ */
2533
+ setHideEmptyRootContainers(hide: boolean): void;
2511
2534
  /**
2512
2535
  * Peer ID of the current writer.
2513
2536
  */
@@ -3030,6 +3030,55 @@ class LoroDoc {
3030
3030
  const ret = wasm.lorodoc_subscribePreCommit(this.__wbg_ptr, addHeapObject(f));
3031
3031
  return takeObject(ret);
3032
3032
  }
3033
+ /**
3034
+ * Delete all content from a root container and hide it from the document.
3035
+ *
3036
+ * When a root container is empty and hidden:
3037
+ * - It won't show up in `get_deep_value()` results
3038
+ * - It won't be included in document snapshots
3039
+ *
3040
+ * Only works on root containers (containers without parents).
3041
+ * @param {ContainerID} cid
3042
+ */
3043
+ deleteRootContainer(cid) {
3044
+ try {
3045
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3046
+ wasm.lorodoc_deleteRootContainer(retptr, this.__wbg_ptr, addHeapObject(cid));
3047
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3048
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3049
+ if (r1) {
3050
+ throw takeObject(r0);
3051
+ }
3052
+ } finally {
3053
+ wasm.__wbindgen_add_to_stack_pointer(16);
3054
+ }
3055
+ }
3056
+ /**
3057
+ * Set whether to hide empty root containers.
3058
+ *
3059
+ * @example
3060
+ * ```ts
3061
+ * const doc = new LoroDoc();
3062
+ * const map = doc.getMap("map");
3063
+ * console.log(doc.toJSON()); // { map: {} }
3064
+ * doc.setHideEmptyRootContainers(true);
3065
+ * console.log(doc.toJSON()); // {}
3066
+ * ```
3067
+ * @param {boolean} hide
3068
+ */
3069
+ setHideEmptyRootContainers(hide) {
3070
+ try {
3071
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3072
+ wasm.lorodoc_setHideEmptyRootContainers(retptr, this.__wbg_ptr, hide);
3073
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3074
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3075
+ if (r1) {
3076
+ throw takeObject(r0);
3077
+ }
3078
+ } finally {
3079
+ wasm.__wbindgen_add_to_stack_pointer(16);
3080
+ }
3081
+ }
3033
3082
  }
3034
3083
  module.exports.LoroDoc = LoroDoc;
3035
3084
 
@@ -6853,12 +6902,12 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
6853
6902
  return ret;
6854
6903
  };
6855
6904
 
6856
- module.exports.__wbindgen_closure_wrapper487 = function(arg0, arg1, arg2) {
6905
+ module.exports.__wbindgen_closure_wrapper483 = function(arg0, arg1, arg2) {
6857
6906
  const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
6858
6907
  return addHeapObject(ret);
6859
6908
  };
6860
6909
 
6861
- module.exports.__wbindgen_closure_wrapper490 = function(arg0, arg1, arg2) {
6910
+ module.exports.__wbindgen_closure_wrapper486 = function(arg0, arg1, arg2) {
6862
6911
  const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
6863
6912
  return addHeapObject(ret);
6864
6913
  };
Binary file
@@ -124,6 +124,8 @@ export const lorodoc_diff: (a: number, b: number, c: number, d: number, e: numbe
124
124
  export const lorodoc_getUncommittedOpsAsJson: (a: number, b: number) => void;
125
125
  export const lorodoc_subscribeFirstCommitFromPeer: (a: number, b: number) => number;
126
126
  export const lorodoc_subscribePreCommit: (a: number, b: number) => number;
127
+ export const lorodoc_deleteRootContainer: (a: number, b: number, c: number) => void;
128
+ export const lorodoc_setHideEmptyRootContainers: (a: number, b: number, c: number) => void;
127
129
  export const __wbg_lorotext_free: (a: number, b: number) => void;
128
130
  export const lorotext_new: () => number;
129
131
  export const lorotext_kind: (a: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loro-crdt",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
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",
@@ -2508,6 +2508,29 @@ export class LoroDoc {
2508
2508
  * ```
2509
2509
  */
2510
2510
  getUncommittedOpsAsJson(): JsonSchema | undefined;
2511
+ /**
2512
+ * Delete all content from a root container and hide it from the document.
2513
+ *
2514
+ * When a root container is empty and hidden:
2515
+ * - It won't show up in `get_deep_value()` results
2516
+ * - It won't be included in document snapshots
2517
+ *
2518
+ * Only works on root containers (containers without parents).
2519
+ */
2520
+ deleteRootContainer(cid: ContainerID): void;
2521
+ /**
2522
+ * Set whether to hide empty root containers.
2523
+ *
2524
+ * @example
2525
+ * ```ts
2526
+ * const doc = new LoroDoc();
2527
+ * const map = doc.getMap("map");
2528
+ * console.log(doc.toJSON()); // { map: {} }
2529
+ * doc.setHideEmptyRootContainers(true);
2530
+ * console.log(doc.toJSON()); // {}
2531
+ * ```
2532
+ */
2533
+ setHideEmptyRootContainers(hide: boolean): void;
2511
2534
  /**
2512
2535
  * Peer ID of the current writer.
2513
2536
  */
@@ -3755,6 +3778,8 @@ export interface InitOutput {
3755
3778
  readonly lorodoc_getUncommittedOpsAsJson: (a: number, b: number) => void;
3756
3779
  readonly lorodoc_subscribeFirstCommitFromPeer: (a: number, b: number) => number;
3757
3780
  readonly lorodoc_subscribePreCommit: (a: number, b: number) => number;
3781
+ readonly lorodoc_deleteRootContainer: (a: number, b: number, c: number) => void;
3782
+ readonly lorodoc_setHideEmptyRootContainers: (a: number, b: number, c: number) => void;
3758
3783
  readonly __wbg_lorotext_free: (a: number, b: number) => void;
3759
3784
  readonly lorotext_new: () => number;
3760
3785
  readonly lorotext_kind: (a: number) => number;
package/web/loro_wasm.js CHANGED
@@ -3021,6 +3021,55 @@ export class LoroDoc {
3021
3021
  const ret = wasm.lorodoc_subscribePreCommit(this.__wbg_ptr, addHeapObject(f));
3022
3022
  return takeObject(ret);
3023
3023
  }
3024
+ /**
3025
+ * Delete all content from a root container and hide it from the document.
3026
+ *
3027
+ * When a root container is empty and hidden:
3028
+ * - It won't show up in `get_deep_value()` results
3029
+ * - It won't be included in document snapshots
3030
+ *
3031
+ * Only works on root containers (containers without parents).
3032
+ * @param {ContainerID} cid
3033
+ */
3034
+ deleteRootContainer(cid) {
3035
+ try {
3036
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3037
+ wasm.lorodoc_deleteRootContainer(retptr, this.__wbg_ptr, addHeapObject(cid));
3038
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3039
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3040
+ if (r1) {
3041
+ throw takeObject(r0);
3042
+ }
3043
+ } finally {
3044
+ wasm.__wbindgen_add_to_stack_pointer(16);
3045
+ }
3046
+ }
3047
+ /**
3048
+ * Set whether to hide empty root containers.
3049
+ *
3050
+ * @example
3051
+ * ```ts
3052
+ * const doc = new LoroDoc();
3053
+ * const map = doc.getMap("map");
3054
+ * console.log(doc.toJSON()); // { map: {} }
3055
+ * doc.setHideEmptyRootContainers(true);
3056
+ * console.log(doc.toJSON()); // {}
3057
+ * ```
3058
+ * @param {boolean} hide
3059
+ */
3060
+ setHideEmptyRootContainers(hide) {
3061
+ try {
3062
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3063
+ wasm.lorodoc_setHideEmptyRootContainers(retptr, this.__wbg_ptr, hide);
3064
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3065
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3066
+ if (r1) {
3067
+ throw takeObject(r0);
3068
+ }
3069
+ } finally {
3070
+ wasm.__wbindgen_add_to_stack_pointer(16);
3071
+ }
3072
+ }
3024
3073
  }
3025
3074
 
3026
3075
  const LoroListFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -6785,11 +6834,11 @@ function __wbg_get_imports() {
6785
6834
  const ret = false;
6786
6835
  return ret;
6787
6836
  };
6788
- imports.wbg.__wbindgen_closure_wrapper487 = function(arg0, arg1, arg2) {
6837
+ imports.wbg.__wbindgen_closure_wrapper483 = function(arg0, arg1, arg2) {
6789
6838
  const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
6790
6839
  return addHeapObject(ret);
6791
6840
  };
6792
- imports.wbg.__wbindgen_closure_wrapper490 = function(arg0, arg1, arg2) {
6841
+ imports.wbg.__wbindgen_closure_wrapper486 = function(arg0, arg1, arg2) {
6793
6842
  const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
6794
6843
  return addHeapObject(ret);
6795
6844
  };
Binary file
@@ -124,6 +124,8 @@ export const lorodoc_diff: (a: number, b: number, c: number, d: number, e: numbe
124
124
  export const lorodoc_getUncommittedOpsAsJson: (a: number, b: number) => void;
125
125
  export const lorodoc_subscribeFirstCommitFromPeer: (a: number, b: number) => number;
126
126
  export const lorodoc_subscribePreCommit: (a: number, b: number) => number;
127
+ export const lorodoc_deleteRootContainer: (a: number, b: number, c: number) => void;
128
+ export const lorodoc_setHideEmptyRootContainers: (a: number, b: number, c: number) => void;
127
129
  export const __wbg_lorotext_free: (a: number, b: number) => void;
128
130
  export const lorotext_new: () => number;
129
131
  export const lorotext_kind: (a: number) => number;