loro-crdt 1.6.0 → 1.7.1

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,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d308d1: fix: use null when export json update with undefined value
8
+ - 1aad1d5: Add toJSON to LoroCounter
9
+
10
+ ## 1.7.0
11
+
12
+ ### Minor Changes
13
+
14
+ - 3a0db5b: feat: add APIs to fetch values associated with the top Undo and Redo stack entries (#790)
15
+ - JS/WASM: `undo.topUndoValue()` and `undo.topRedoValue()` return the `value` from the top undo/redo item (or `undefined` when empty).
16
+ - Rust: `UndoManager::{top_undo_meta, top_redo_meta, top_undo_value, top_redo_value}` to inspect top-of-stack metadata and values.
17
+ - Internal: stack now supports peeking the top item metadata without mutation.
18
+
19
+ This enables attaching human-readable labels via `onPush`/`onPop` and retrieving them to keep Undo/Redo menu items up to date.
20
+
21
+ - 9a98e8d: Distinguish explicit vs implicit empty commit behavior for commit options.
22
+ - Explicit commits (user-invoked `commit()` / `commit_with(...)`): if the transaction is empty, commit options (message/timestamp/origin) are swallowed and will NOT carry over.
23
+ - Implicit commits (e.g., `export`, `checkout` internal barriers): if the transaction is empty, message/timestamp/origin are preserved for the next transaction.
24
+
25
+ Rationale: align behavior with intent. Explicit commits “finalize now”, so empty commits should not leak options. Implicit commits act as processing barriers and should not destroy user-provided options for the next real change.
26
+
27
+ Note: This refines behavior without changing the API.
28
+
29
+ ### Patch Changes
30
+
31
+ - 0fe9681: fix: handle default values for fractionalIndex and index in LoroTreeNode
32
+
3
33
  ## 1.6.0
4
34
 
5
35
  ### Minor Changes
package/base64/index.js CHANGED
@@ -1122,6 +1122,13 @@ class LoroCounter {
1122
1122
  const ret = wasm.lorocounter_getShallowValue(this.__wbg_ptr);
1123
1123
  return ret;
1124
1124
  }
1125
+ /**
1126
+ * @returns {number}
1127
+ */
1128
+ toJSON() {
1129
+ const ret = wasm.lorocounter_toJSON(this.__wbg_ptr);
1130
+ return ret;
1131
+ }
1125
1132
  }
1126
1133
 
1127
1134
  const LoroDocFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1683,6 +1690,13 @@ class LoroDoc {
1683
1690
  * the largest existing timestamp will be used instead.
1684
1691
  *
1685
1692
  * NOTE: The `origin` will not be persisted, but the `message` will.
1693
+ *
1694
+ * Behavior on empty commits:
1695
+ * - This method is an explicit commit. If the pending transaction is empty, any provided
1696
+ * options (message/timestamp/origin) are swallowed and will not carry over to the next commit.
1697
+ * - Implicit commits triggered by `export`/`checkout` act as processing barriers. If the
1698
+ * transaction is empty in those cases, `message`/`timestamp`/`origin` are preserved for the
1699
+ * next commit.
1686
1700
  * @param {{ origin?: string, timestamp?: number, message?: string } | null} [options]
1687
1701
  */
1688
1702
  commit(options) {
@@ -6222,6 +6236,24 @@ class UndoManager {
6222
6236
  const ret = wasm.undomanager_canRedo(this.__wbg_ptr);
6223
6237
  return ret !== 0;
6224
6238
  }
6239
+ /**
6240
+ * Get the value associated with the top undo stack item, if any.
6241
+ * Returns `undefined` if there is no undo item.
6242
+ * @returns {Value | undefined}
6243
+ */
6244
+ topUndoValue() {
6245
+ const ret = wasm.undomanager_topUndoValue(this.__wbg_ptr);
6246
+ return takeObject(ret);
6247
+ }
6248
+ /**
6249
+ * Get the value associated with the top redo stack item, if any.
6250
+ * Returns `undefined` if there is no redo item.
6251
+ * @returns {Value | undefined}
6252
+ */
6253
+ topRedoValue() {
6254
+ const ret = wasm.undomanager_topRedoValue(this.__wbg_ptr);
6255
+ return takeObject(ret);
6256
+ }
6225
6257
  /**
6226
6258
  * The number of max undo steps.
6227
6259
  * If the number of undo steps exceeds this number, the oldest undo step will be removed.
@@ -6767,7 +6799,7 @@ function __wbg_node_02999533c4ea02e3(arg0) {
6767
6799
  const ret = getObject(arg0).node;
6768
6800
  return addHeapObject(ret);
6769
6801
  }
6770
- function __wbg_now_4f8b2820be8a682c() {
6802
+ function __wbg_now_bbd8229e4a52638e() {
6771
6803
  const ret = Date.now();
6772
6804
  return ret;
6773
6805
  }
@@ -7063,7 +7095,7 @@ var imports = /*#__PURE__*/Object.freeze({
7063
7095
  __wbg_next_928df8c15fc0c9b0: __wbg_next_928df8c15fc0c9b0,
7064
7096
  __wbg_next_9dc0926f351c7090: __wbg_next_9dc0926f351c7090,
7065
7097
  __wbg_node_02999533c4ea02e3: __wbg_node_02999533c4ea02e3,
7066
- __wbg_now_4f8b2820be8a682c: __wbg_now_4f8b2820be8a682c,
7098
+ __wbg_now_bbd8229e4a52638e: __wbg_now_bbd8229e4a52638e,
7067
7099
  __wbg_ownKeys_b16312a839a4152c: __wbg_ownKeys_b16312a839a4152c,
7068
7100
  __wbg_process_5c1d670bc53614b8: __wbg_process_5c1d670bc53614b8,
7069
7101
  __wbg_push_e7d7247e69dad3ee: __wbg_push_e7d7247e69dad3ee,
@@ -7128,7 +7160,7 @@ var imports = /*#__PURE__*/Object.freeze({
7128
7160
  // Without this patch, Cloudflare Worker would raise issue like: "Uncaught TypeError: wasm2.__wbindgen_start is not a function"
7129
7161
 
7130
7162
  if (!('Bun' in globalThis))
7131
- import loro_wasm_bg_js from './loro_wasm_bg-654bb6e4.js';
7163
+ import loro_wasm_bg_js from './loro_wasm_bg-512df4ec.js';
7132
7164
  const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
7133
7165
  "./loro_wasm_bg.js": imports,
7134
7166
  });
@@ -7440,4 +7472,4 @@ function idStrToId(idStr) {
7440
7472
  };
7441
7473
  }
7442
7474
 
7443
- export { Awareness, AwarenessWasm, ChangeModifier, Cursor, EphemeralStore, EphemeralStoreWasm, LORO_VERSION, Loro, LoroCounter, LoroDoc, LoroList, LoroMap, LoroMovableList, LoroText, LoroTree, LoroTreeNode, UndoManager, VersionVector, __wbg_String_8f0eb39a4a4c2f66, __wbg_apply_9bb7fe8fff013a3f, __wbg_buffer_ef9774282e5dab94, __wbg_call_0ad083564791763a, __wbg_call_a34b6b4765f27be0, __wbg_call_d00953b926be4879, __wbg_call_efe5a4db7065d1a2, __wbg_changemodifier_new, __wbg_crypto_ed58b8e10a292839, __wbg_cursor_new, __wbg_done_f4c254830a095eaf, __wbg_entries_4dce6361e3ba6fbc, __wbg_entries_83beb641792ccb9c, __wbg_error_7534b8e9a36f1ab4, __wbg_error_9912f7d6d7835a4b, __wbg_from_3aa0fcaa8eef0104, __wbg_getRandomValues_bcb4912f16000dc4, __wbg_get_0c3cc364764a0b98, __wbg_get_b996a12be035ef4f, __wbg_getindex_a471648b3037c750, __wbg_getwithrefkey_1dc361bd10053bfe, __wbg_globalThis_6b4d52a0b6aaeaea, __wbg_global_49324ce12193de77, __wbg_instanceof_ArrayBuffer_ff40e55b5978e215, __wbg_instanceof_Map_0f3f3653f757ced1, __wbg_instanceof_Object_9108547bac1f91b1, __wbg_instanceof_Uint8Array_db97368f94b1373f, __wbg_isArray_8738f1062fa88586, __wbg_isSafeInteger_a1b3e0811faecf2f, __wbg_iterator_c0c688f37fa815e6, __wbg_length_12246a78d2f65d3a, __wbg_length_c24da17096edfe57, __wbg_log_0cc1b7768397bcfe, __wbg_log_0fd6c49475c7bece, __wbg_log_cb9e190acc5753fb, __wbg_lorocounter_new, __wbg_lorolist_new, __wbg_loromap_new, __wbg_loromovablelist_new, __wbg_lorotext_new, __wbg_lorotree_new, __wbg_lorotreenode_new, __wbg_mark_7438147ce31e9d4b, __wbg_measure_fb7825c11612c823, __wbg_msCrypto_0a36e2ec3a343d26, __wbg_new_518e2184725aa711, __wbg_new_59845962d1127937, __wbg_new_67abf4a77618ee3e, __wbg_new_8a6f238a6ece86ea, __wbg_new_e2d07398d7689006, __wbg_newnoargs_a136448eeb7d48ac, __wbg_newwithbyteoffsetandlength_84908302a4c137cf, __wbg_newwithlength_4c216eaaf23f2f9a, __wbg_newwithlength_88b49de1eb24d63e, __wbg_next_928df8c15fc0c9b0, __wbg_next_9dc0926f351c7090, __wbg_node_02999533c4ea02e3, __wbg_now_4f8b2820be8a682c, __wbg_ownKeys_b16312a839a4152c, __wbg_process_5c1d670bc53614b8, __wbg_push_e7d7247e69dad3ee, __wbg_randomFillSync_ab2cfe79ebbf2740, __wbg_require_79b1e9274cde3c87, __wbg_resolve_267ff08e7e1d2ce4, __wbg_self_cca3ca60d61220f4, __wbg_set_1b50d2de855a9d50, __wbg_set_393f510a6b7e9da5, __wbg_set_3f1d0b984ed272ed, __wbg_set_5deee49b10b2b780, __wbg_set_93ba9407b5476ec6, __wbg_set_wasm, __wbg_setindex_e0b7b31bfc87ba3f, __wbg_stack_0ed75d68575b0f3c, __wbg_subarray_2dc34705c0dc7cdb, __wbg_then_84907e7a6730461e, __wbg_value_51f8a88d4a1805fb, __wbg_versions_c71aa1626a93e0a1, __wbg_versionvector_new, __wbg_window_2aba046d3fc4ad7c, __wbindgen_as_number, __wbindgen_bigint_from_i64, __wbindgen_bigint_from_u64, __wbindgen_bigint_get_as_i64, __wbindgen_boolean_get, __wbindgen_cb_drop, __wbindgen_closure_wrapper563, __wbindgen_closure_wrapper565, __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, redactJsonUpdates, run, setDebug };
7475
+ export { Awareness, AwarenessWasm, ChangeModifier, Cursor, EphemeralStore, EphemeralStoreWasm, LORO_VERSION, Loro, LoroCounter, LoroDoc, LoroList, LoroMap, LoroMovableList, LoroText, LoroTree, LoroTreeNode, UndoManager, VersionVector, __wbg_String_8f0eb39a4a4c2f66, __wbg_apply_9bb7fe8fff013a3f, __wbg_buffer_ef9774282e5dab94, __wbg_call_0ad083564791763a, __wbg_call_a34b6b4765f27be0, __wbg_call_d00953b926be4879, __wbg_call_efe5a4db7065d1a2, __wbg_changemodifier_new, __wbg_crypto_ed58b8e10a292839, __wbg_cursor_new, __wbg_done_f4c254830a095eaf, __wbg_entries_4dce6361e3ba6fbc, __wbg_entries_83beb641792ccb9c, __wbg_error_7534b8e9a36f1ab4, __wbg_error_9912f7d6d7835a4b, __wbg_from_3aa0fcaa8eef0104, __wbg_getRandomValues_bcb4912f16000dc4, __wbg_get_0c3cc364764a0b98, __wbg_get_b996a12be035ef4f, __wbg_getindex_a471648b3037c750, __wbg_getwithrefkey_1dc361bd10053bfe, __wbg_globalThis_6b4d52a0b6aaeaea, __wbg_global_49324ce12193de77, __wbg_instanceof_ArrayBuffer_ff40e55b5978e215, __wbg_instanceof_Map_0f3f3653f757ced1, __wbg_instanceof_Object_9108547bac1f91b1, __wbg_instanceof_Uint8Array_db97368f94b1373f, __wbg_isArray_8738f1062fa88586, __wbg_isSafeInteger_a1b3e0811faecf2f, __wbg_iterator_c0c688f37fa815e6, __wbg_length_12246a78d2f65d3a, __wbg_length_c24da17096edfe57, __wbg_log_0cc1b7768397bcfe, __wbg_log_0fd6c49475c7bece, __wbg_log_cb9e190acc5753fb, __wbg_lorocounter_new, __wbg_lorolist_new, __wbg_loromap_new, __wbg_loromovablelist_new, __wbg_lorotext_new, __wbg_lorotree_new, __wbg_lorotreenode_new, __wbg_mark_7438147ce31e9d4b, __wbg_measure_fb7825c11612c823, __wbg_msCrypto_0a36e2ec3a343d26, __wbg_new_518e2184725aa711, __wbg_new_59845962d1127937, __wbg_new_67abf4a77618ee3e, __wbg_new_8a6f238a6ece86ea, __wbg_new_e2d07398d7689006, __wbg_newnoargs_a136448eeb7d48ac, __wbg_newwithbyteoffsetandlength_84908302a4c137cf, __wbg_newwithlength_4c216eaaf23f2f9a, __wbg_newwithlength_88b49de1eb24d63e, __wbg_next_928df8c15fc0c9b0, __wbg_next_9dc0926f351c7090, __wbg_node_02999533c4ea02e3, __wbg_now_bbd8229e4a52638e, __wbg_ownKeys_b16312a839a4152c, __wbg_process_5c1d670bc53614b8, __wbg_push_e7d7247e69dad3ee, __wbg_randomFillSync_ab2cfe79ebbf2740, __wbg_require_79b1e9274cde3c87, __wbg_resolve_267ff08e7e1d2ce4, __wbg_self_cca3ca60d61220f4, __wbg_set_1b50d2de855a9d50, __wbg_set_393f510a6b7e9da5, __wbg_set_3f1d0b984ed272ed, __wbg_set_5deee49b10b2b780, __wbg_set_93ba9407b5476ec6, __wbg_set_wasm, __wbg_setindex_e0b7b31bfc87ba3f, __wbg_stack_0ed75d68575b0f3c, __wbg_subarray_2dc34705c0dc7cdb, __wbg_then_84907e7a6730461e, __wbg_value_51f8a88d4a1805fb, __wbg_versions_c71aa1626a93e0a1, __wbg_versionvector_new, __wbg_window_2aba046d3fc4ad7c, __wbindgen_as_number, __wbindgen_bigint_from_i64, __wbindgen_bigint_from_u64, __wbindgen_bigint_get_as_i64, __wbindgen_boolean_get, __wbindgen_cb_drop, __wbindgen_closure_wrapper563, __wbindgen_closure_wrapper565, __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, redactJsonUpdates, run, setDebug };
@@ -1640,6 +1640,7 @@ export class LoroCounter {
1640
1640
  * Get the value of the counter.
1641
1641
  */
1642
1642
  getShallowValue(): number;
1643
+ toJSON(): number;
1643
1644
  /**
1644
1645
  * The container id of this handler.
1645
1646
  */
@@ -2001,6 +2002,13 @@ export class LoroDoc {
2001
2002
  * the largest existing timestamp will be used instead.
2002
2003
  *
2003
2004
  * NOTE: The `origin` will not be persisted, but the `message` will.
2005
+ *
2006
+ * Behavior on empty commits:
2007
+ * - This method is an explicit commit. If the pending transaction is empty, any provided
2008
+ * options (message/timestamp/origin) are swallowed and will not carry over to the next commit.
2009
+ * - Implicit commits triggered by `export`/`checkout` act as processing barriers. If the
2010
+ * transaction is empty in those cases, `message`/`timestamp`/`origin` are preserved for the
2011
+ * next commit.
2004
2012
  */
2005
2013
  commit(options?: { origin?: string, timestamp?: number, message?: string } | null): void;
2006
2014
  /**
@@ -3621,6 +3629,16 @@ export class UndoManager {
3621
3629
  * Can redo the last operation.
3622
3630
  */
3623
3631
  canRedo(): boolean;
3632
+ /**
3633
+ * Get the value associated with the top undo stack item, if any.
3634
+ * Returns `undefined` if there is no undo item.
3635
+ */
3636
+ topUndoValue(): Value | undefined;
3637
+ /**
3638
+ * Get the value associated with the top redo stack item, if any.
3639
+ * Returns `undefined` if there is no redo item.
3640
+ */
3641
+ topRedoValue(): Value | undefined;
3624
3642
  /**
3625
3643
  * The number of max undo steps.
3626
3644
  * If the number of undo steps exceeds this number, the oldest undo step will be removed.