loro-crdt 1.4.2 → 1.4.4

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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 28d1264: feat(wasm): enhance toJsonWithReplacer to handle nested containers in replacer returned value
8
+ - 28d1264: fix(wasm): add toJSON to LoroText
9
+
10
+ Now all containers have toJSON method.
11
+
12
+ ## 1.4.3
13
+
14
+ ### Patch Changes
15
+
16
+ - 2a82396: feat: add new ways to control commit options (#656)
17
+ - 2a82396: fix: mark err on detached LoroText (#659)
18
+
3
19
  ## 1.4.2
4
20
 
5
21
  ### Patch Changes
package/base64/index.js CHANGED
@@ -276,6 +276,27 @@ function getArrayJsValueFromWasm0(ptr, len) {
276
276
  }
277
277
  return result;
278
278
  }
279
+ /**
280
+ * Get the version of Loro
281
+ * @returns {string}
282
+ */
283
+ function LORO_VERSION() {
284
+ let deferred1_0;
285
+ let deferred1_1;
286
+ try {
287
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
288
+ wasm.LORO_VERSION(retptr);
289
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
290
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
291
+ deferred1_0 = r0;
292
+ deferred1_1 = r1;
293
+ return getStringFromWasm0(r0, r1);
294
+ } finally {
295
+ wasm.__wbindgen_add_to_stack_pointer(16);
296
+ wasm.__wbindgen_export_5(deferred1_0, deferred1_1, 1);
297
+ }
298
+ }
299
+
279
300
  /**
280
301
  */
281
302
  function run() {
@@ -1719,6 +1740,45 @@ class LoroDoc {
1719
1740
  wasm.lorodoc_setNextCommitMessage(this.__wbg_ptr, ptr0, len0);
1720
1741
  }
1721
1742
  /**
1743
+ * Set the origin of the next commit
1744
+ * @param {string} origin
1745
+ */
1746
+ setNextCommitOrigin(origin) {
1747
+ const ptr0 = passStringToWasm0(origin, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
1748
+ const len0 = WASM_VECTOR_LEN;
1749
+ wasm.lorodoc_setNextCommitOrigin(this.__wbg_ptr, ptr0, len0);
1750
+ }
1751
+ /**
1752
+ * Set the timestamp of the next commit
1753
+ * @param {number} timestamp
1754
+ */
1755
+ setNextCommitTimestamp(timestamp) {
1756
+ wasm.lorodoc_setNextCommitTimestamp(this.__wbg_ptr, timestamp);
1757
+ }
1758
+ /**
1759
+ * Set the options of the next commit
1760
+ * @param {{ origin?: string, timestamp?: number, message?: string }} options
1761
+ */
1762
+ setNextCommitOptions(options) {
1763
+ try {
1764
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1765
+ wasm.lorodoc_setNextCommitOptions(retptr, this.__wbg_ptr, addHeapObject(options));
1766
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1767
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1768
+ if (r1) {
1769
+ throw takeObject(r0);
1770
+ }
1771
+ } finally {
1772
+ wasm.__wbindgen_add_to_stack_pointer(16);
1773
+ }
1774
+ }
1775
+ /**
1776
+ * Clear the options of the next commit
1777
+ */
1778
+ clearNextCommitOptions() {
1779
+ wasm.lorodoc_clearNextCommitOptions(this.__wbg_ptr);
1780
+ }
1781
+ /**
1722
1782
  * Get deep value of the document with container id
1723
1783
  * @returns {any}
1724
1784
  */
@@ -4850,6 +4910,14 @@ class LoroText {
4850
4910
  wasm.__wbindgen_export_5(deferred1_0, deferred1_1, 1);
4851
4911
  }
4852
4912
  }
4913
+ /**
4914
+ * Get the JSON representation of the text.
4915
+ * @returns {any}
4916
+ */
4917
+ toJSON() {
4918
+ const ret = wasm.lorotext_toJSON(this.__wbg_ptr);
4919
+ return takeObject(ret);
4920
+ }
4853
4921
  }
4854
4922
 
4855
4923
  const LoroTreeFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -6559,6 +6627,7 @@ var imports = /*#__PURE__*/Object.freeze({
6559
6627
  __proto__: null,
6560
6628
  AwarenessWasm: AwarenessWasm,
6561
6629
  Cursor: Cursor,
6630
+ LORO_VERSION: LORO_VERSION,
6562
6631
  LoroCounter: LoroCounter,
6563
6632
  LoroDoc: LoroDoc,
6564
6633
  LoroList: LoroList,
@@ -6689,7 +6758,7 @@ var imports = /*#__PURE__*/Object.freeze({
6689
6758
  // Without this patch, Cloudflare Worker would raise issue like: "Uncaught TypeError: wasm2.__wbindgen_start is not a function"
6690
6759
 
6691
6760
 
6692
- import loro_wasm_bg_js from './loro_wasm_bg-b04f3476.js';
6761
+ import loro_wasm_bg_js from './loro_wasm_bg-ec1c7122.js';
6693
6762
  const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
6694
6763
  "./loro_wasm_bg.js": imports,
6695
6764
  });
@@ -6847,10 +6916,12 @@ class Awareness {
6847
6916
  }
6848
6917
  }
6849
6918
  LoroDoc.prototype.toJsonWithReplacer = function (replacer) {
6919
+ const processed = new Set();
6850
6920
  const doc = this;
6851
6921
  const m = (key, value) => {
6852
6922
  if (typeof value === "string") {
6853
- if (isContainerId(value)) {
6923
+ if (isContainerId(value) && !processed.has(value)) {
6924
+ processed.add(value);
6854
6925
  const container = doc.getContainerById(value);
6855
6926
  if (container == null) {
6856
6927
  throw new Error(`ContainerID not found: ${value}`);
@@ -6866,9 +6937,15 @@ LoroDoc.prototype.toJsonWithReplacer = function (replacer) {
6866
6937
  if (isContainer(ans)) {
6867
6938
  throw new Error("Using new container is not allowed in toJsonWithReplacer");
6868
6939
  }
6940
+ if (typeof ans === "object" && ans != null) {
6941
+ return run(ans);
6942
+ }
6869
6943
  return ans;
6870
6944
  }
6871
6945
  }
6946
+ if (typeof value === "object" && value != null) {
6947
+ return run(value);
6948
+ }
6872
6949
  const ans = replacer(key, value);
6873
6950
  if (isContainer(ans)) {
6874
6951
  throw new Error("Using new container is not allowed in toJsonWithReplacer");
@@ -6890,8 +6967,8 @@ LoroDoc.prototype.toJsonWithReplacer = function (replacer) {
6890
6967
  }
6891
6968
  return result;
6892
6969
  };
6893
- const layer = this.getShallowValue();
6970
+ const layer = doc.getShallowValue();
6894
6971
  return run(layer);
6895
6972
  };
6896
6973
 
6897
- export { Awareness, AwarenessWasm, Cursor, 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 };
6974
+ 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 };
@@ -1,6 +1,11 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * Get the version of Loro
5
+ * @returns {string}
6
+ */
7
+ export function LORO_VERSION(): string;
8
+ /**
4
9
  */
5
10
  export function run(): void;
6
11
  /**
@@ -1916,6 +1921,25 @@ export class LoroDoc {
1916
1921
  */
1917
1922
  setNextCommitMessage(msg: string): void;
1918
1923
  /**
1924
+ * Set the origin of the next commit
1925
+ * @param {string} origin
1926
+ */
1927
+ setNextCommitOrigin(origin: string): void;
1928
+ /**
1929
+ * Set the timestamp of the next commit
1930
+ * @param {number} timestamp
1931
+ */
1932
+ setNextCommitTimestamp(timestamp: number): void;
1933
+ /**
1934
+ * Set the options of the next commit
1935
+ * @param {{ origin?: string, timestamp?: number, message?: string }} options
1936
+ */
1937
+ setNextCommitOptions(options: { origin?: string, timestamp?: number, message?: string }): void;
1938
+ /**
1939
+ * Clear the options of the next commit
1940
+ */
1941
+ clearNextCommitOptions(): void;
1942
+ /**
1919
1943
  * Get deep value of the document with container id
1920
1944
  * @returns {any}
1921
1945
  */
@@ -3208,6 +3232,11 @@ export class LoroText {
3208
3232
  */
3209
3233
  getShallowValue(): string;
3210
3234
  /**
3235
+ * Get the JSON representation of the text.
3236
+ * @returns {any}
3237
+ */
3238
+ toJSON(): any;
3239
+ /**
3211
3240
  * Get the container id of the text.
3212
3241
  */
3213
3242
  readonly id: ContainerID;