loro-crdt 1.4.5 → 1.5.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/base64/index.js CHANGED
@@ -621,6 +621,52 @@ class AwarenessWasm {
621
621
  }
622
622
  }
623
623
 
624
+ const ChangeModifierFinalization = (typeof FinalizationRegistry === 'undefined')
625
+ ? { register: () => {}, unregister: () => {} }
626
+ : new FinalizationRegistry(ptr => wasm.__wbg_changemodifier_free(ptr >>> 0));
627
+ /**
628
+ */
629
+ class ChangeModifier {
630
+
631
+ static __wrap(ptr) {
632
+ ptr = ptr >>> 0;
633
+ const obj = Object.create(ChangeModifier.prototype);
634
+ obj.__wbg_ptr = ptr;
635
+ ChangeModifierFinalization.register(obj, obj.__wbg_ptr, obj);
636
+ return obj;
637
+ }
638
+
639
+ __destroy_into_raw() {
640
+ const ptr = this.__wbg_ptr;
641
+ this.__wbg_ptr = 0;
642
+ ChangeModifierFinalization.unregister(this);
643
+ return ptr;
644
+ }
645
+
646
+ free() {
647
+ const ptr = this.__destroy_into_raw();
648
+ wasm.__wbg_changemodifier_free(ptr);
649
+ }
650
+ /**
651
+ * @param {string} message
652
+ * @returns {ChangeModifier}
653
+ */
654
+ setMessage(message) {
655
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
656
+ const len0 = WASM_VECTOR_LEN;
657
+ const ret = wasm.changemodifier_setMessage(this.__wbg_ptr, ptr0, len0);
658
+ return ChangeModifier.__wrap(ret);
659
+ }
660
+ /**
661
+ * @param {number} timestamp
662
+ * @returns {ChangeModifier}
663
+ */
664
+ setTimestamp(timestamp) {
665
+ const ret = wasm.changemodifier_setTimestamp(this.__wbg_ptr, timestamp);
666
+ return ChangeModifier.__wrap(ret);
667
+ }
668
+ }
669
+
624
670
  const CursorFinalization = (typeof FinalizationRegistry === 'undefined')
625
671
  ? { register: () => {}, unregister: () => {} }
626
672
  : new FinalizationRegistry(ptr => wasm.__wbg_cursor_free(ptr >>> 0));
@@ -753,6 +799,161 @@ class Cursor {
753
799
  }
754
800
  }
755
801
 
802
+ const EphemeralStoreWasmFinalization = (typeof FinalizationRegistry === 'undefined')
803
+ ? { register: () => {}, unregister: () => {} }
804
+ : new FinalizationRegistry(ptr => wasm.__wbg_ephemeralstorewasm_free(ptr >>> 0));
805
+ /**
806
+ */
807
+ class EphemeralStoreWasm {
808
+
809
+ __destroy_into_raw() {
810
+ const ptr = this.__wbg_ptr;
811
+ this.__wbg_ptr = 0;
812
+ EphemeralStoreWasmFinalization.unregister(this);
813
+ return ptr;
814
+ }
815
+
816
+ free() {
817
+ const ptr = this.__destroy_into_raw();
818
+ wasm.__wbg_ephemeralstorewasm_free(ptr);
819
+ }
820
+ /**
821
+ * Creates a new `EphemeralStore` instance.
822
+ *
823
+ * The `timeout` parameter specifies the duration in milliseconds.
824
+ * A state of a peer is considered outdated, if the last update of the state of the peer
825
+ * is older than the `timeout`.
826
+ * @param {number} timeout
827
+ */
828
+ constructor(timeout) {
829
+ const ret = wasm.ephemeralstorewasm_new(timeout);
830
+ this.__wbg_ptr = ret >>> 0;
831
+ return this;
832
+ }
833
+ /**
834
+ * @param {string} key
835
+ * @param {any} value
836
+ */
837
+ set(key, value) {
838
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
839
+ const len0 = WASM_VECTOR_LEN;
840
+ wasm.ephemeralstorewasm_set(this.__wbg_ptr, ptr0, len0, addHeapObject(value));
841
+ }
842
+ /**
843
+ * @param {string} key
844
+ */
845
+ delete(key) {
846
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
847
+ const len0 = WASM_VECTOR_LEN;
848
+ wasm.ephemeralstorewasm_delete(this.__wbg_ptr, ptr0, len0);
849
+ }
850
+ /**
851
+ * @param {string} key
852
+ * @returns {any}
853
+ */
854
+ get(key) {
855
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
856
+ const len0 = WASM_VECTOR_LEN;
857
+ const ret = wasm.ephemeralstorewasm_get(this.__wbg_ptr, ptr0, len0);
858
+ return takeObject(ret);
859
+ }
860
+ /**
861
+ * @returns {any}
862
+ */
863
+ getAllStates() {
864
+ const ret = wasm.ephemeralstorewasm_getAllStates(this.__wbg_ptr);
865
+ return takeObject(ret);
866
+ }
867
+ /**
868
+ * @param {Function} f
869
+ * @returns {any}
870
+ */
871
+ subscribeLocalUpdates(f) {
872
+ const ret = wasm.ephemeralstorewasm_subscribeLocalUpdates(this.__wbg_ptr, addHeapObject(f));
873
+ return takeObject(ret);
874
+ }
875
+ /**
876
+ * @param {Function} f
877
+ * @returns {any}
878
+ */
879
+ subscribe(f) {
880
+ const ret = wasm.ephemeralstorewasm_subscribe(this.__wbg_ptr, addHeapObject(f));
881
+ return takeObject(ret);
882
+ }
883
+ /**
884
+ * @param {string} key
885
+ * @returns {Uint8Array}
886
+ */
887
+ encode(key) {
888
+ try {
889
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
890
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
891
+ const len0 = WASM_VECTOR_LEN;
892
+ wasm.ephemeralstorewasm_encode(retptr, this.__wbg_ptr, ptr0, len0);
893
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
894
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
895
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
896
+ wasm.__wbindgen_export_5(r0, r1 * 1, 1);
897
+ return v2;
898
+ } finally {
899
+ wasm.__wbindgen_add_to_stack_pointer(16);
900
+ }
901
+ }
902
+ /**
903
+ * @returns {Uint8Array}
904
+ */
905
+ encodeAll() {
906
+ try {
907
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
908
+ wasm.ephemeralstorewasm_encodeAll(retptr, this.__wbg_ptr);
909
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
910
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
911
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
912
+ wasm.__wbindgen_export_5(r0, r1 * 1, 1);
913
+ return v1;
914
+ } finally {
915
+ wasm.__wbindgen_add_to_stack_pointer(16);
916
+ }
917
+ }
918
+ /**
919
+ * @param {Uint8Array} data
920
+ */
921
+ apply(data) {
922
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
923
+ const len0 = WASM_VECTOR_LEN;
924
+ wasm.ephemeralstorewasm_apply(this.__wbg_ptr, ptr0, len0);
925
+ }
926
+ /**
927
+ */
928
+ removeOutdated() {
929
+ wasm.ephemeralstorewasm_removeOutdated(this.__wbg_ptr);
930
+ }
931
+ /**
932
+ * If the state is empty.
933
+ * @returns {boolean}
934
+ */
935
+ isEmpty() {
936
+ const ret = wasm.ephemeralstorewasm_isEmpty(this.__wbg_ptr);
937
+ return ret !== 0;
938
+ }
939
+ /**
940
+ * @returns {(string)[]}
941
+ */
942
+ keys() {
943
+ try {
944
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
945
+ wasm.ephemeralstorewasm_keys(retptr, this.__wbg_ptr);
946
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
947
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
948
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
949
+ wasm.__wbindgen_export_5(r0, r1 * 4, 4);
950
+ return v1;
951
+ } finally {
952
+ wasm.__wbindgen_add_to_stack_pointer(16);
953
+ }
954
+ }
955
+ }
956
+
756
957
  const LoroCounterFinalization = (typeof FinalizationRegistry === 'undefined')
757
958
  ? { register: () => {}, unregister: () => {} }
758
959
  : new FinalizationRegistry(ptr => wasm.__wbg_lorocounter_free(ptr >>> 0));
@@ -2805,6 +3006,61 @@ class LoroDoc {
2805
3006
  wasm.__wbindgen_add_to_stack_pointer(16);
2806
3007
  }
2807
3008
  }
3009
+ /**
3010
+ * Get the pending operations from the current transaction in JSON format
3011
+ *
3012
+ * This method returns a JSON representation of operations that have been applied
3013
+ * but not yet committed in the current transaction.
3014
+ *
3015
+ * It will use the same data format as `doc.exportJsonUpdates()`
3016
+ *
3017
+ * @example
3018
+ * ```ts
3019
+ * const doc = new LoroDoc();
3020
+ * const text = doc.getText("text");
3021
+ * text.insert(0, "Hello");
3022
+ * // Get pending ops before commit
3023
+ * const pendingOps = doc.getPendingOpsFromCurrentTxnAsJson();
3024
+ * doc.commit();
3025
+ * const emptyOps = doc.getPendingOpsFromCurrentTxnAsJson(); // this is undefined
3026
+ * ```
3027
+ * @returns {JsonSchema | undefined}
3028
+ */
3029
+ getUncommittedOpsAsJson() {
3030
+ try {
3031
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3032
+ wasm.lorodoc_getUncommittedOpsAsJson(retptr, this.__wbg_ptr);
3033
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3034
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3035
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3036
+ if (r2) {
3037
+ throw takeObject(r1);
3038
+ }
3039
+ return takeObject(r0);
3040
+ } finally {
3041
+ wasm.__wbindgen_add_to_stack_pointer(16);
3042
+ }
3043
+ }
3044
+ /**
3045
+ * @param {Function} f
3046
+ * @returns {any}
3047
+ */
3048
+ subscribeFirstCommitFromPeer(f) {
3049
+ const ret = wasm.lorodoc_subscribeFirstCommitFromPeer(this.__wbg_ptr, addHeapObject(f));
3050
+ return takeObject(ret);
3051
+ }
3052
+ /**
3053
+ * Subscribe to the pre-commit event.
3054
+ *
3055
+ * The callback will be called when the changes are committed but not yet applied to the OpLog.
3056
+ * You can modify the commit message and timestamp in the callback by `ChangeModifier`.
3057
+ * @param {Function} f
3058
+ * @returns {any}
3059
+ */
3060
+ subscribePreCommit(f) {
3061
+ const ret = wasm.lorodoc_subscribePreCommit(this.__wbg_ptr, addHeapObject(f));
3062
+ return takeObject(ret);
3063
+ }
2808
3064
  }
2809
3065
 
2810
3066
  const LoroListFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -4635,8 +4891,6 @@ class LoroText {
4635
4891
  *
4636
4892
  * You can use it to create a highlight, make a range of text bold, or add a link to a range of text.
4637
4893
  *
4638
- * Note: this is not suitable for unmergeable annotations like comments.
4639
- *
4640
4894
  * @example
4641
4895
  * ```ts
4642
4896
  * import { LoroDoc } from "loro-crdt";
@@ -6150,10 +6404,6 @@ function __wbg_lorocounter_new(arg0) {
6150
6404
  const ret = LoroCounter.__wrap(arg0);
6151
6405
  return addHeapObject(ret);
6152
6406
  }
6153
- function __wbg_lorotreenode_new(arg0) {
6154
- const ret = LoroTreeNode.__wrap(arg0);
6155
- return addHeapObject(ret);
6156
- }
6157
6407
  function __wbg_cursor_new(arg0) {
6158
6408
  const ret = Cursor.__wrap(arg0);
6159
6409
  return addHeapObject(ret);
@@ -6162,26 +6412,34 @@ function __wbg_loromap_new(arg0) {
6162
6412
  const ret = LoroMap.__wrap(arg0);
6163
6413
  return addHeapObject(ret);
6164
6414
  }
6165
- function __wbg_lorotext_new(arg0) {
6166
- const ret = LoroText.__wrap(arg0);
6415
+ function __wbg_lorotreenode_new(arg0) {
6416
+ const ret = LoroTreeNode.__wrap(arg0);
6167
6417
  return addHeapObject(ret);
6168
6418
  }
6169
- function __wbg_lorotree_new(arg0) {
6170
- const ret = LoroTree.__wrap(arg0);
6419
+ function __wbg_lorolist_new(arg0) {
6420
+ const ret = LoroList.__wrap(arg0);
6421
+ return addHeapObject(ret);
6422
+ }
6423
+ function __wbg_lorotext_new(arg0) {
6424
+ const ret = LoroText.__wrap(arg0);
6171
6425
  return addHeapObject(ret);
6172
6426
  }
6173
6427
  function __wbg_loromovablelist_new(arg0) {
6174
6428
  const ret = LoroMovableList.__wrap(arg0);
6175
6429
  return addHeapObject(ret);
6176
6430
  }
6177
- function __wbg_lorolist_new(arg0) {
6178
- const ret = LoroList.__wrap(arg0);
6431
+ function __wbg_lorotree_new(arg0) {
6432
+ const ret = LoroTree.__wrap(arg0);
6179
6433
  return addHeapObject(ret);
6180
6434
  }
6181
6435
  function __wbg_versionvector_new(arg0) {
6182
6436
  const ret = VersionVector.__wrap(arg0);
6183
6437
  return addHeapObject(ret);
6184
6438
  }
6439
+ function __wbg_changemodifier_new(arg0) {
6440
+ const ret = ChangeModifier.__wrap(arg0);
6441
+ return addHeapObject(ret);
6442
+ }
6185
6443
  function __wbindgen_is_function(arg0) {
6186
6444
  const ret = typeof(getObject(arg0)) === 'function';
6187
6445
  return ret;
@@ -6370,7 +6628,7 @@ function __wbg_error_f851667af71bcfc6(arg0, arg1) {
6370
6628
  wasm.__wbindgen_export_5(deferred0_0, deferred0_1, 1);
6371
6629
  }
6372
6630
  }
6373
- const __wbg_now_cd30a09c9b727b65 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
6631
+ const __wbg_now_761faa1e2f3f9d93 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
6374
6632
 
6375
6633
  function __wbg_crypto_1d1f22824a6a080c(arg0) {
6376
6634
  const ret = getObject(arg0).crypto;
@@ -6396,12 +6654,12 @@ function __wbg_msCrypto_eb05e62b530a1508(arg0) {
6396
6654
  const ret = getObject(arg0).msCrypto;
6397
6655
  return addHeapObject(ret);
6398
6656
  }
6399
- function __wbg_getRandomValues_3aa56aa6edec874c() { return handleError(function (arg0, arg1) {
6400
- getObject(arg0).getRandomValues(getObject(arg1));
6401
- }, arguments) }
6402
6657
  function __wbg_randomFillSync_5c9c955aa56b6049() { return handleError(function (arg0, arg1) {
6403
6658
  getObject(arg0).randomFillSync(takeObject(arg1));
6404
6659
  }, arguments) }
6660
+ function __wbg_getRandomValues_3aa56aa6edec874c() { return handleError(function (arg0, arg1) {
6661
+ getObject(arg0).getRandomValues(getObject(arg1));
6662
+ }, arguments) }
6405
6663
  function __wbg_self_ce0dbfc45cf2f5be() { return handleError(function () {
6406
6664
  const ret = self.self;
6407
6665
  return addHeapObject(ret);
@@ -6634,19 +6892,21 @@ function __wbindgen_memory() {
6634
6892
  const ret = wasm.memory;
6635
6893
  return addHeapObject(ret);
6636
6894
  }
6637
- function __wbindgen_closure_wrapper482(arg0, arg1, arg2) {
6638
- const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
6895
+ function __wbindgen_closure_wrapper487(arg0, arg1, arg2) {
6896
+ const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
6639
6897
  return addHeapObject(ret);
6640
6898
  }
6641
- function __wbindgen_closure_wrapper485(arg0, arg1, arg2) {
6642
- const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
6899
+ function __wbindgen_closure_wrapper489(arg0, arg1, arg2) {
6900
+ const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
6643
6901
  return addHeapObject(ret);
6644
6902
  }
6645
6903
 
6646
6904
  var imports = /*#__PURE__*/Object.freeze({
6647
6905
  __proto__: null,
6648
6906
  AwarenessWasm: AwarenessWasm,
6907
+ ChangeModifier: ChangeModifier,
6649
6908
  Cursor: Cursor,
6909
+ EphemeralStoreWasm: EphemeralStoreWasm,
6650
6910
  LORO_VERSION: LORO_VERSION,
6651
6911
  LoroCounter: LoroCounter,
6652
6912
  LoroDoc: LoroDoc,
@@ -6665,6 +6925,7 @@ var imports = /*#__PURE__*/Object.freeze({
6665
6925
  __wbg_call_8e7cb608789c2528: __wbg_call_8e7cb608789c2528,
6666
6926
  __wbg_call_938992c832f74314: __wbg_call_938992c832f74314,
6667
6927
  __wbg_call_b3ca7c6051f9bec1: __wbg_call_b3ca7c6051f9bec1,
6928
+ __wbg_changemodifier_new: __wbg_changemodifier_new,
6668
6929
  __wbg_crypto_1d1f22824a6a080c: __wbg_crypto_1d1f22824a6a080c,
6669
6930
  __wbg_cursor_new: __wbg_cursor_new,
6670
6931
  __wbg_done_298b57d23c0fc80c: __wbg_done_298b57d23c0fc80c,
@@ -6714,7 +6975,7 @@ var imports = /*#__PURE__*/Object.freeze({
6714
6975
  __wbg_next_196c84450b364254: __wbg_next_196c84450b364254,
6715
6976
  __wbg_next_40fc327bfc8770e6: __wbg_next_40fc327bfc8770e6,
6716
6977
  __wbg_node_104a2ff8d6ea03a2: __wbg_node_104a2ff8d6ea03a2,
6717
- __wbg_now_cd30a09c9b727b65: __wbg_now_cd30a09c9b727b65,
6978
+ __wbg_now_761faa1e2f3f9d93: __wbg_now_761faa1e2f3f9d93,
6718
6979
  __wbg_ownKeys_658942b7f28d1fe9: __wbg_ownKeys_658942b7f28d1fe9,
6719
6980
  __wbg_process_4a72847cc503995b: __wbg_process_4a72847cc503995b,
6720
6981
  __wbg_push_a5b05aedc7234f9f: __wbg_push_a5b05aedc7234f9f,
@@ -6742,8 +7003,8 @@ var imports = /*#__PURE__*/Object.freeze({
6742
7003
  __wbindgen_bigint_get_as_i64: __wbindgen_bigint_get_as_i64,
6743
7004
  __wbindgen_boolean_get: __wbindgen_boolean_get,
6744
7005
  __wbindgen_cb_drop: __wbindgen_cb_drop,
6745
- __wbindgen_closure_wrapper482: __wbindgen_closure_wrapper482,
6746
- __wbindgen_closure_wrapper485: __wbindgen_closure_wrapper485,
7006
+ __wbindgen_closure_wrapper487: __wbindgen_closure_wrapper487,
7007
+ __wbindgen_closure_wrapper489: __wbindgen_closure_wrapper489,
6747
7008
  __wbindgen_debug_string: __wbindgen_debug_string,
6748
7009
  __wbindgen_error_new: __wbindgen_error_new,
6749
7010
  __wbindgen_in: __wbindgen_in,
@@ -6778,7 +7039,7 @@ var imports = /*#__PURE__*/Object.freeze({
6778
7039
  // Without this patch, Cloudflare Worker would raise issue like: "Uncaught TypeError: wasm2.__wbindgen_start is not a function"
6779
7040
 
6780
7041
 
6781
- import loro_wasm_bg_js from './loro_wasm_bg-2fc402da.js';
7042
+ import loro_wasm_bg_js from './loro_wasm_bg-536e230f.js';
6782
7043
  const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
6783
7044
  "./loro_wasm_bg.js": imports,
6784
7045
  });
@@ -6858,10 +7119,12 @@ function newRootContainerID(name, type) {
6858
7119
  return `cid:root-${name}:${type}`;
6859
7120
  }
6860
7121
  /**
7122
+ * @deprecated Please use `EphemeralStore` instead.
7123
+ *
6861
7124
  * Awareness is a structure that allows to track the ephemeral state of the peers.
6862
7125
  *
6863
7126
  * If we don't receive a state update from a peer within the timeout, we will remove their state.
6864
- * The timeout is in milliseconds. This can be used to handle the off-line state of a peer.
7127
+ * The timeout is in milliseconds. This can be used to handle the offline state of a peer.
6865
7128
  */
6866
7129
  class Awareness {
6867
7130
  constructor(peer, timeout = 30000) {
@@ -6935,6 +7198,86 @@ class Awareness {
6935
7198
  }, this.timeout / 2);
6936
7199
  }
6937
7200
  }
7201
+ /**
7202
+ * EphemeralStore is a structure that allows to track the ephemeral state of the peers.
7203
+ *
7204
+ * It can be used to synchronize cursor positions, selections, and the names of the peers.
7205
+ * Each entry uses timestamp-based LWW (Last-Write-Wins) for conflict resolution.
7206
+ *
7207
+ * If we don't receive a state update from a peer within the timeout, we will remove their state.
7208
+ * The timeout is in milliseconds. This can be used to handle the offline state of a peer.
7209
+ *
7210
+ * @example
7211
+ *
7212
+ * ```ts
7213
+ * const store = new EphemeralStore();
7214
+ * const store2 = new EphemeralStore();
7215
+ * // Subscribe to local updates
7216
+ * store.subscribeLocalUpdates((data)=>{
7217
+ * store2.apply(data);
7218
+ * })
7219
+ * // Subscribe to all updates
7220
+ * store2.subscribe((event)=>{
7221
+ * console.log("event: ", event);
7222
+ * })
7223
+ * // Set a value
7224
+ * store.set("key", "value");
7225
+ * // Encode the value
7226
+ * const encoded = store.encode("key");
7227
+ * // Apply the encoded value
7228
+ * store2.apply(encoded);
7229
+ * ```
7230
+ */
7231
+ class EphemeralStore {
7232
+ constructor(timeout = 30000) {
7233
+ this.inner = new EphemeralStoreWasm(timeout);
7234
+ this.timeout = timeout;
7235
+ }
7236
+ apply(bytes) {
7237
+ this.inner.apply(bytes);
7238
+ this.startTimerIfNotEmpty();
7239
+ }
7240
+ set(key, value) {
7241
+ this.inner.set(key, value);
7242
+ this.startTimerIfNotEmpty();
7243
+ }
7244
+ get(key) {
7245
+ return this.inner.get(key);
7246
+ }
7247
+ getAllStates() {
7248
+ return this.inner.getAllStates();
7249
+ }
7250
+ encode(key) {
7251
+ return this.inner.encode(key);
7252
+ }
7253
+ encodeAll() {
7254
+ return this.inner.encodeAll();
7255
+ }
7256
+ keys() {
7257
+ return this.inner.keys();
7258
+ }
7259
+ destroy() {
7260
+ clearInterval(this.timer);
7261
+ }
7262
+ subscribe(listener) {
7263
+ return this.inner.subscribe(listener);
7264
+ }
7265
+ subscribeLocalUpdates(listener) {
7266
+ return this.inner.subscribeLocalUpdates(listener);
7267
+ }
7268
+ startTimerIfNotEmpty() {
7269
+ if (this.inner.isEmpty() || this.timer != null) {
7270
+ return;
7271
+ }
7272
+ this.timer = setInterval(() => {
7273
+ this.inner.removeOutdated();
7274
+ if (this.inner.isEmpty()) {
7275
+ clearInterval(this.timer);
7276
+ this.timer = undefined;
7277
+ }
7278
+ }, this.timeout / 2);
7279
+ }
7280
+ }
6938
7281
  LoroDoc.prototype.toJsonWithReplacer = function (replacer) {
6939
7282
  const processed = new Set();
6940
7283
  const doc = this;
@@ -6990,5 +7333,12 @@ LoroDoc.prototype.toJsonWithReplacer = function (replacer) {
6990
7333
  const layer = doc.getShallowValue();
6991
7334
  return run(layer);
6992
7335
  };
7336
+ function idStrToId(idStr) {
7337
+ const [counter, peer] = idStr.split("@");
7338
+ return {
7339
+ counter: parseInt(counter),
7340
+ peer: peer,
7341
+ };
7342
+ }
6993
7343
 
6994
- export { Awareness, AwarenessWasm, Cursor, LORO_VERSION, Loro, LoroCounter, LoroDoc, LoroList, LoroMap, LoroMovableList, LoroText, LoroTree, LoroTreeNode, UndoManager, VersionVector, __wbg_String_b9412f8799faab3e, __wbg_apply_0a5aa603881e6d79, __wbg_buffer_12d079cc21e14bdb, __wbg_call_27c0f87801dedf93, __wbg_call_8e7cb608789c2528, __wbg_call_938992c832f74314, __wbg_call_b3ca7c6051f9bec1, __wbg_crypto_1d1f22824a6a080c, __wbg_cursor_new, __wbg_done_298b57d23c0fc80c, __wbg_entries_95cc2c823b285a09, __wbg_entries_ce844941d0c51880, __wbg_error_9384d761bf46409d, __wbg_error_f851667af71bcfc6, __wbg_from_89e3fc3ba5e6fb48, __wbg_getRandomValues_3aa56aa6edec874c, __wbg_get_bd8e338fbd5f5cc8, __wbg_get_e3c254076557e348, __wbg_getindex_03d06b4e7ea3475e, __wbg_getwithrefkey_edc2c8960f0f1191, __wbg_globalThis_d1e6af4856ba331b, __wbg_global_207b558942527489, __wbg_instanceof_ArrayBuffer_836825be07d4c9d2, __wbg_instanceof_Map_87917e0a7aaf4012, __wbg_instanceof_Object_71ca3c0a59266746, __wbg_instanceof_Uint8Array_2b3bbecd033d19f6, __wbg_isArray_2ab64d95e09ea0ae, __wbg_isSafeInteger_f7b04ef02296c4d2, __wbg_iterator_2cee6dadfd956dfa, __wbg_length_c20a40f15020d68a, __wbg_length_cd7af8117672b8b8, __wbg_log_aba5996d9bde071f, __wbg_log_c86c3e1bf097ba35, __wbg_log_c9486ca5d8e2cbe8, __wbg_lorocounter_new, __wbg_lorolist_new, __wbg_loromap_new, __wbg_loromovablelist_new, __wbg_lorotext_new, __wbg_lorotree_new, __wbg_lorotreenode_new, __wbg_mark_40e050a77cc39fea, __wbg_measure_aa7a73f17813f708, __wbg_msCrypto_eb05e62b530a1508, __wbg_new_16b304a2cfa7ff4a, __wbg_new_63b92bc8671ed464, __wbg_new_72fb9a18b5ae2624, __wbg_new_abda76e883ba8a5f, __wbg_new_d9bc3a0147634640, __wbg_newnoargs_e258087cd0daa0ea, __wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb, __wbg_newwithlength_66ae46612e7f0234, __wbg_newwithlength_e9b4878cebadb3d3, __wbg_next_196c84450b364254, __wbg_next_40fc327bfc8770e6, __wbg_node_104a2ff8d6ea03a2, __wbg_now_cd30a09c9b727b65, __wbg_ownKeys_658942b7f28d1fe9, __wbg_process_4a72847cc503995b, __wbg_push_a5b05aedc7234f9f, __wbg_randomFillSync_5c9c955aa56b6049, __wbg_require_cca90b1a94a0255b, __wbg_resolve_b0083a7967828ec8, __wbg_self_ce0dbfc45cf2f5be, __wbg_set_1f9b04f170055d33, __wbg_set_8417257aaedc936b, __wbg_set_a47bac70306a19a7, __wbg_set_d4638f722068f043, __wbg_set_f975102236d3c502, __wbg_set_wasm, __wbg_setindex_0b7ede192dc5eca8, __wbg_stack_658279fe44541cf6, __wbg_subarray_a1f73cd4b5b42fe1, __wbg_then_0c86a60e8fcfe9f6, __wbg_value_d93c65011f51a456, __wbg_versions_f686565e586dd935, __wbg_versionvector_new, __wbg_window_c6fb939a7f436783, __wbindgen_as_number, __wbindgen_bigint_from_i64, __wbindgen_bigint_from_u64, __wbindgen_bigint_get_as_i64, __wbindgen_boolean_get, __wbindgen_cb_drop, __wbindgen_closure_wrapper482, __wbindgen_closure_wrapper485, __wbindgen_debug_string, __wbindgen_error_new, __wbindgen_in, __wbindgen_is_array, __wbindgen_is_bigint, __wbindgen_is_falsy, __wbindgen_is_function, __wbindgen_is_null, __wbindgen_is_object, __wbindgen_is_string, __wbindgen_is_undefined, __wbindgen_jsval_eq, __wbindgen_jsval_loose_eq, __wbindgen_memory, __wbindgen_number_get, __wbindgen_number_new, __wbindgen_object_clone_ref, __wbindgen_object_drop_ref, __wbindgen_rethrow, __wbindgen_string_get, __wbindgen_string_new, __wbindgen_throw, __wbindgen_typeof, decodeFrontiers, decodeImportBlobMeta, encodeFrontiers, getType, isContainer, isContainerId, newContainerID, newRootContainerID, run, setDebug };
7344
+ export { Awareness, AwarenessWasm, ChangeModifier, Cursor, EphemeralStore, EphemeralStoreWasm, LORO_VERSION, Loro, LoroCounter, LoroDoc, LoroList, LoroMap, LoroMovableList, LoroText, LoroTree, LoroTreeNode, UndoManager, VersionVector, __wbg_String_b9412f8799faab3e, __wbg_apply_0a5aa603881e6d79, __wbg_buffer_12d079cc21e14bdb, __wbg_call_27c0f87801dedf93, __wbg_call_8e7cb608789c2528, __wbg_call_938992c832f74314, __wbg_call_b3ca7c6051f9bec1, __wbg_changemodifier_new, __wbg_crypto_1d1f22824a6a080c, __wbg_cursor_new, __wbg_done_298b57d23c0fc80c, __wbg_entries_95cc2c823b285a09, __wbg_entries_ce844941d0c51880, __wbg_error_9384d761bf46409d, __wbg_error_f851667af71bcfc6, __wbg_from_89e3fc3ba5e6fb48, __wbg_getRandomValues_3aa56aa6edec874c, __wbg_get_bd8e338fbd5f5cc8, __wbg_get_e3c254076557e348, __wbg_getindex_03d06b4e7ea3475e, __wbg_getwithrefkey_edc2c8960f0f1191, __wbg_globalThis_d1e6af4856ba331b, __wbg_global_207b558942527489, __wbg_instanceof_ArrayBuffer_836825be07d4c9d2, __wbg_instanceof_Map_87917e0a7aaf4012, __wbg_instanceof_Object_71ca3c0a59266746, __wbg_instanceof_Uint8Array_2b3bbecd033d19f6, __wbg_isArray_2ab64d95e09ea0ae, __wbg_isSafeInteger_f7b04ef02296c4d2, __wbg_iterator_2cee6dadfd956dfa, __wbg_length_c20a40f15020d68a, __wbg_length_cd7af8117672b8b8, __wbg_log_aba5996d9bde071f, __wbg_log_c86c3e1bf097ba35, __wbg_log_c9486ca5d8e2cbe8, __wbg_lorocounter_new, __wbg_lorolist_new, __wbg_loromap_new, __wbg_loromovablelist_new, __wbg_lorotext_new, __wbg_lorotree_new, __wbg_lorotreenode_new, __wbg_mark_40e050a77cc39fea, __wbg_measure_aa7a73f17813f708, __wbg_msCrypto_eb05e62b530a1508, __wbg_new_16b304a2cfa7ff4a, __wbg_new_63b92bc8671ed464, __wbg_new_72fb9a18b5ae2624, __wbg_new_abda76e883ba8a5f, __wbg_new_d9bc3a0147634640, __wbg_newnoargs_e258087cd0daa0ea, __wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb, __wbg_newwithlength_66ae46612e7f0234, __wbg_newwithlength_e9b4878cebadb3d3, __wbg_next_196c84450b364254, __wbg_next_40fc327bfc8770e6, __wbg_node_104a2ff8d6ea03a2, __wbg_now_761faa1e2f3f9d93, __wbg_ownKeys_658942b7f28d1fe9, __wbg_process_4a72847cc503995b, __wbg_push_a5b05aedc7234f9f, __wbg_randomFillSync_5c9c955aa56b6049, __wbg_require_cca90b1a94a0255b, __wbg_resolve_b0083a7967828ec8, __wbg_self_ce0dbfc45cf2f5be, __wbg_set_1f9b04f170055d33, __wbg_set_8417257aaedc936b, __wbg_set_a47bac70306a19a7, __wbg_set_d4638f722068f043, __wbg_set_f975102236d3c502, __wbg_set_wasm, __wbg_setindex_0b7ede192dc5eca8, __wbg_stack_658279fe44541cf6, __wbg_subarray_a1f73cd4b5b42fe1, __wbg_then_0c86a60e8fcfe9f6, __wbg_value_d93c65011f51a456, __wbg_versions_f686565e586dd935, __wbg_versionvector_new, __wbg_window_c6fb939a7f436783, __wbindgen_as_number, __wbindgen_bigint_from_i64, __wbindgen_bigint_from_u64, __wbindgen_bigint_get_as_i64, __wbindgen_boolean_get, __wbindgen_cb_drop, __wbindgen_closure_wrapper487, __wbindgen_closure_wrapper489, __wbindgen_debug_string, __wbindgen_error_new, __wbindgen_in, __wbindgen_is_array, __wbindgen_is_bigint, __wbindgen_is_falsy, __wbindgen_is_function, __wbindgen_is_null, __wbindgen_is_object, __wbindgen_is_string, __wbindgen_is_undefined, __wbindgen_jsval_eq, __wbindgen_jsval_loose_eq, __wbindgen_memory, __wbindgen_number_get, __wbindgen_number_new, __wbindgen_object_clone_ref, __wbindgen_object_drop_ref, __wbindgen_rethrow, __wbindgen_string_get, __wbindgen_string_new, __wbindgen_throw, __wbindgen_typeof, decodeFrontiers, decodeImportBlobMeta, encodeFrontiers, getType, idStrToId, isContainer, isContainerId, newContainerID, newRootContainerID, run, setDebug };