loro-crdt 1.5.9 → 1.5.11

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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 34180e7: Fix(js): delete an entry in map should emit an event that set the field as undefined instead of null
8
+ - 0bb9786: Fix: avoid panic when importing data to ephemeral store
9
+
10
+ ## 1.5.10
11
+
12
+ ### Patch Changes
13
+
14
+ - f8bef58: Fix local event error (#763)
15
+
3
16
  ## 1.5.9
4
17
 
5
18
  ### Patch Changes
@@ -55,7 +68,6 @@
55
68
  ### Patch Changes
56
69
 
57
70
  - 742cf7d: Fix memory leak caused by wasm-bindgen
58
-
59
71
  - https://github.com/rustwasm/wasm-bindgen/issues/3854
60
72
 
61
73
  ## 1.5.0
@@ -302,7 +314,6 @@
302
314
  - ddafb7e: feat: diff, applyDiff, and revertTo #610
303
315
 
304
316
  Add new version-control-related primitives:
305
-
306
317
  - **`diff(from, to)`**: calculate the difference between two versions. The returned results have similar structures to the differences in events.
307
318
  - **`revertTo(targetVersion)`**: revert the document back to the target version. The difference between this and `checkout(targetVersion)` is this method will generate a series of new operations, which will transform the current doc into the same as the target version.
308
319
  - **`applyDiff(diff)`**: you can use it to apply the differences generated from `diff(from, to)`.
@@ -452,7 +463,6 @@
452
463
  ### Patch Changes
453
464
 
454
465
  - 3b7a738: Add getShallowValue and toJsonWIthReplacer
455
-
456
466
  - Add getShallowValue for each container (#581)
457
467
  - Implement toJsonWithReplacer method for LoroDoc to customize JSON serialization (#582)
458
468
  - Rename importUpdateBatch into importBatch & refine type (#580)
@@ -612,11 +622,9 @@
612
622
  - Performance improvement and bug fixes
613
623
 
614
624
  ### 🚀 Features
615
-
616
625
  - Redact (#504)
617
626
 
618
627
  ### 🐛 Bug Fixes
619
-
620
628
  - Ffi Subscription (#505)
621
629
  - Ffi remove try unwrap (#506)
622
630
  - Movable list undo impl (#509)
@@ -624,18 +632,15 @@
624
632
  - IsContainerDeleted cache err (#513)
625
633
 
626
634
  ### 📚 Documentation
627
-
628
635
  - Refine wasm docs
629
636
 
630
637
  ### ⚡ Performance
631
-
632
638
  - Optimize shrink frontiers
633
639
  - Optimize batch container registrations on arena (#510)
634
640
  - Optimize high concurrency performance (#514)
635
641
  - Use better data structure for frontiers (#515)
636
642
 
637
643
  ### Perf
638
-
639
644
  - Commit speed & text insert cache (#511)
640
645
 
641
646
  ## 1.0.0-alpha.5
@@ -643,11 +648,9 @@
643
648
  ### Patch Changes
644
649
 
645
650
  - ## Fix
646
-
647
651
  - Use release build
648
652
 
649
653
  ## Test
650
-
651
654
  - Add compatibility tests (#503)
652
655
 
653
656
  ## 1.0.0-alpha.4
@@ -655,7 +658,6 @@
655
658
  ### Patch Changes
656
659
 
657
660
  - ### 🚀 Features
658
-
659
661
  - _(wasm)_ Commit message & get pending ops length (#477)
660
662
  - Update text by line (#480)
661
663
  - Add clear methods (#478)
@@ -666,7 +668,6 @@
666
668
  - Add import status (#494)
667
669
 
668
670
  ### 🐛 Bug Fixes
669
-
670
671
  - Get correct tree_cache current vv when retreating (#476)
671
672
  - Gc snapshot error (#481)
672
673
  - Checkout into middle of marks
@@ -678,7 +679,6 @@
678
679
  - Create event cannot find parent (#498)
679
680
 
680
681
  ### 🚜 Refactor
681
-
682
682
  - [**breaking**] Don't wait for `commit` to update version info
683
683
  - Avoid footgun of impl ord for cid
684
684
  - Loro import function should return LoroEncodeError (#487)
@@ -687,7 +687,6 @@
687
687
  - [**breaking**] List state snapshot schema for v1.0 (#485)
688
688
 
689
689
  ### ⚡ Performance
690
-
691
690
  - Make shrink frontiers faster when the peer num is large (#482)
692
691
  - Optimize tree cache find children speed
693
692
  - Avoid memory leak when forking repeatedly (#500)
@@ -696,12 +695,10 @@
696
695
  - Optimize diff calc cache use (#475)
697
696
 
698
697
  ### 🧪 Testing
699
-
700
698
  - Make awareness more robust
701
699
  - Bench large folder with 1M files & 100M ops (#495)
702
700
 
703
701
  ### ⚙️ Miscellaneous Tasks
704
-
705
702
  - Use cached diff calc
706
703
 
707
704
  ## 1.0.0-alpha.3
@@ -709,20 +706,16 @@
709
706
  ### Patch Changes
710
707
 
711
708
  - ### 🐛 Bug Fixes
712
-
713
709
  - Cursor behavior when using gc-snapshot (#472)
714
710
  - _(wasm)_ Type err
715
711
 
716
712
  ### ⚙️ Miscellaneous Tasks
717
-
718
713
  - Make tree parent id pub on loro crate
719
714
 
720
715
  ### Feat
721
-
722
716
  - Allow editing on detached mode (#473)
723
717
 
724
718
  ### Fix
725
-
726
719
  - Get tree's alive children correctly (#474)
727
720
  - Should not emit event when exporting gc-snapshot (#471)
728
721
 
@@ -731,11 +724,9 @@
731
724
  ### Patch Changes
732
725
 
733
726
  - ### 🚀 Features
734
-
735
727
  - Fork doc at the target version (#469)
736
728
 
737
729
  ### 🚜 Refactor
738
-
739
730
  - BREAKING CHANGE: Use hierarchy value for tree value (#470)
740
731
 
741
732
  ## 1.0.0-alpha.1
@@ -743,24 +734,20 @@
743
734
  ### Patch Changes
744
735
 
745
736
  - ### 🚀 Features
746
-
747
737
  - Get shallow value of doc (#463)
748
738
  - Add state only snapshot & refine check slow test
749
739
  - Add new cid method to js binding
750
740
  - Jsonpath experimental support (#466)
751
741
 
752
742
  ### 🐛 Bug Fixes
753
-
754
743
  - Raise error if perform action on a deleted container (#465)
755
744
  - Raise error if moving a deleted node
756
745
  - Export snapshot error on a gc doc
757
746
 
758
747
  ### 🚜 Refactor
759
-
760
748
  - Tree contains & isDeleted (#467)
761
749
 
762
750
  ### 🧪 Testing
763
-
764
751
  - Check state correctness on shallow doc
765
752
 
766
753
  ## 1.0.0-alpha.0
@@ -799,27 +786,22 @@
799
786
  ### Patch Changes
800
787
 
801
788
  - 38b4bcf: Add text update API
802
-
803
789
  - Remove the patch for crypto
804
790
  - Add text update API (#404)
805
791
  - Check invalid root container name (#411)
806
792
 
807
793
  ### 🐛 Bug Fixes
808
-
809
794
  - Workaround lldb bug make loro crate debuggable (#414)
810
795
  - Delete the **bring back** tree node from the undo container remap (#423)
811
796
 
812
797
  ### 📚 Documentation
813
-
814
798
  - Fix typo
815
799
  - Refine docs about event (#417)
816
800
 
817
801
  ### 🎨 Styling
818
-
819
802
  - Use clippy to perf code (#407)
820
803
 
821
804
  ### ⚙️ Miscellaneous Tasks
822
-
823
805
  - Add test tools (#410)
824
806
 
825
807
  ## 0.16.7
@@ -829,24 +811,20 @@
829
811
  - 45c98d5: Better text APIs and bug fixes
830
812
 
831
813
  ### 🚀 Features
832
-
833
814
  - Add insert_utf8 and delete_utf8 for Rust Text API (#396)
834
815
  - Add text iter (#400)
835
816
  - Add more text api (#398)
836
817
 
837
818
  ### 🐛 Bug Fixes
838
-
839
819
  - Tree undo when processing deleted node (#399)
840
820
  - Tree diff calc children should be sorted by idlp (#401)
841
821
  - When computing the len of the map, do not count elements that are None (#402)
842
822
 
843
823
  ### 📚 Documentation
844
-
845
824
  - Update wasm docs
846
825
  - Rm experimental warning
847
826
 
848
827
  ### ⚙️ Miscellaneous Tasks
849
-
850
828
  - Update fuzz config
851
829
  - Pnpm
852
830
  - Rename position to fractional_index (#381)
@@ -889,7 +867,6 @@
889
867
  - 34f6064: Better undo events & transform cursors by undo manager (#369)
890
868
 
891
869
  #### 🧪 Testing
892
-
893
870
  - Enable compatibility test (#367)
894
871
 
895
872
  ## 0.16.1
@@ -897,7 +874,6 @@
897
874
  ### Patch Changes
898
875
 
899
876
  - 5cd80b0: Refine undo impl
900
-
901
877
  - Add "undo" origin for undo and redo event
902
878
  - Allow users to skip certain local operations
903
879
  - Skip undo/redo ops that are not visible to users
@@ -910,23 +886,19 @@
910
886
  - c12c2b9: Movable Tree Children & Undo
911
887
 
912
888
  #### 🐛 Bug Fixes
913
-
914
889
  - Refine error message on corrupted data (#356)
915
890
  - Add MovableList to CONTAINER_TYPES (#359)
916
891
  - Better jitter for fractional index (#360)
917
892
 
918
893
  #### 🧪 Testing
919
-
920
894
  - Add compatibility tests (#357)
921
895
 
922
896
  #### Feat
923
-
924
897
  - Make the encoding format forward and backward compatible (#329)
925
898
  - Undo (#361)
926
899
  - Use fractional index to order the children of the tree (#298)
927
900
 
928
901
  #### 🐛 Bug Fixes
929
-
930
902
  - Tree fuzz sort value (#351)
931
903
  - Upgrade wasm-bindgen to fix str free err (#353)
932
904
 
@@ -937,13 +909,11 @@
937
909
  - 43506cc: Fix unsound issue caused by wasm-bindgen
938
910
 
939
911
  #### 🐛 Bug Fixes
940
-
941
912
  - Fix potential movable list bug (#354)
942
913
  - Tree fuzz sort value (#351)
943
914
  - Upgrade wasm-bindgen to fix str free err (#353)
944
915
 
945
916
  #### 📚 Documentation
946
-
947
917
  - Simplify readme (#352)
948
918
 
949
919
  ## 0.15.2
@@ -953,15 +923,12 @@
953
923
  - e30678d: Perf: fix deletions merge
954
924
 
955
925
  #### 🐛 Bug Fixes
956
-
957
926
  - _(wasm)_ Movable list .kind() (#342)
958
927
 
959
928
  #### ⚡ Performance
960
-
961
929
  - Delete span merge err (#348)
962
930
 
963
931
  #### ⚙️ Miscellaneous Tasks
964
-
965
932
  - Warn missing debug impl (#347)
966
933
 
967
934
  <!-- generated by git-cliff -->
@@ -973,7 +940,6 @@
973
940
  - 04c6290: Bug fixes and improvements.
974
941
 
975
942
  #### 🐛 Bug Fixes
976
-
977
943
  - Impl a few unimplemented! for movable tree (#335)
978
944
  - Refine ts type; reject invalid operations (#334)
979
945
  - Get cursor err on text and movable list (#337)
@@ -981,12 +947,10 @@
981
947
  - Upgrade generic-btree to allow large btree (#344)
982
948
 
983
949
  #### 📚 Documentation
984
-
985
950
  - Add warn(missing_docs) to loro and loro-wasm (#339)
986
951
  - Minor fix on set_change_merge_interval api (#341)
987
952
 
988
953
  #### ⚙️ Miscellaneous Tasks
989
-
990
954
  - Skip the checking if not debug_assertions (#340)
991
955
 
992
956
  <!-- generated by git-cliff -->
@@ -1034,7 +998,6 @@
1034
998
  - 24cf9b9: Bug Fix
1035
999
 
1036
1000
  #### 🐛 Bug Fixes
1037
-
1038
1001
  - Attached container can be inserted to `Map` or `List` (#331)
1039
1002
 
1040
1003
  ## 0.14.5
@@ -1044,11 +1007,9 @@
1044
1007
  - 73e3ba5: Bug Fix
1045
1008
 
1046
1009
  #### 🐛 Bug Fixes
1047
-
1048
1010
  - _(js)_ Allow convert from undefined to LoroValue (#323)
1049
1011
 
1050
1012
  #### 🚜 Refactor
1051
-
1052
1013
  - Refine ts type (#322)
1053
1014
 
1054
1015
  ## 0.14.4
@@ -1056,12 +1017,10 @@
1056
1017
  ### Patch Changes
1057
1018
 
1058
1019
  - 598d97e: ### 🚜 Refactor
1059
-
1060
1020
  - Refine the TS Type of Awareness
1061
1021
  - Parse Uint8array to LoroValue::Binary (#320)
1062
1022
 
1063
1023
  ### 📚 Documentation
1064
-
1065
1024
  - Update how to publish new npm pkgs
1066
1025
 
1067
1026
  ## 0.14.3
@@ -1075,7 +1034,6 @@
1075
1034
  ### Patch Changes
1076
1035
 
1077
1036
  - Refactor rename `StablePosition` to `Cursor`
1078
-
1079
1037
  - Rename stable pos to cursor (#317)
1080
1038
 
1081
1039
  <!-- generated by git-cliff -->
@@ -1087,7 +1045,6 @@
1087
1045
  - Supports Cursors
1088
1046
 
1089
1047
  #### 🚀 Features
1090
-
1091
1048
  - Cursors (#290)
1092
1049
 
1093
1050
  ## 0.14.0
@@ -1097,27 +1054,22 @@
1097
1054
  - Improved API
1098
1055
 
1099
1056
  ### 🚀 Features
1100
-
1101
1057
  - Access value/container by path (#308)
1102
1058
  - Decode import blob meta (#307)
1103
1059
 
1104
1060
  ### 🐛 Bug Fixes
1105
-
1106
1061
  - Decode iter return result by updating columnar to 0.3.4 (#309)
1107
1062
 
1108
1063
  ### 🚜 Refactor
1109
-
1110
1064
  - Replace "local" and "fromCheckout" in event with "triggeredBy" (#312)
1111
1065
  - Add concrete type for each different container (#313)
1112
1066
  - _(ts)_ Make types better (#315)
1113
1067
 
1114
1068
  ### 📚 Documentation
1115
-
1116
1069
  - Refine wasm docs (#304)
1117
1070
  - Clarify that peer id should be convertible to a u64 (#306)
1118
1071
 
1119
1072
  ### ⚙️ Miscellaneous Tasks
1120
-
1121
1073
  - Add coverage report cli (#311)
1122
1074
 
1123
1075
  ## 0.13.1
@@ -1157,7 +1109,6 @@
1157
1109
  ### Minor Changes
1158
1110
 
1159
1111
  - Fix a few bugs and include BREAKING CHANG refactors
1160
-
1161
1112
  - fix: should not reset the state when calling checkout to latest (#265)
1162
1113
  - refactor: only send a event for one `import`/`transaction`/`checkout` (#263)
1163
1114
  - perf: optimize snapshot encoding speed (#264)
package/base64/index.d.ts CHANGED
@@ -73,27 +73,34 @@ export declare class Awareness<T extends Value = Value> {
73
73
  private startTimerIfNotEmpty;
74
74
  }
75
75
  /**
76
- * EphemeralStore is a structure that allows to track the ephemeral state of the peers.
76
+ * EphemeralStore tracks ephemeral key-value state across peers.
77
77
  *
78
- * It can be used to synchronize cursor positions, selections, and the names of the peers.
79
- * Each entry uses timestamp-based LWW (Last-Write-Wins) for conflict resolution.
78
+ * - Use it for lightweight presence/state like cursors, selections, and UI hints.
79
+ * - Conflict resolution is timestamp-based LWW (Last-Write-Wins) per key.
80
+ * - Timeout unit: milliseconds.
81
+ * - After timeout: keys are considered expired. They are omitted from
82
+ * `encode(key)`, `encodeAll()` and `getAllStates()`. A periodic cleanup runs
83
+ * while the store is non-empty and removes expired keys; when removals happen
84
+ * subscribers receive an event with `by: "timeout"` and the `removed` keys.
80
85
  *
81
- * If we don't receive a state update from a peer within the timeout, we will remove their state.
82
- * The timeout is in milliseconds. This can be used to handle the offline state of a peer.
86
+ * See: https://loro.dev/docs/tutorial/ephemeral
83
87
  *
84
- * @example
88
+ * @param timeout Inactivity timeout in milliseconds (default: 30000). If a key
89
+ * doesn't receive updates within this duration, it will expire and be removed
90
+ * on the next cleanup tick.
85
91
  *
92
+ * @example
86
93
  * ```ts
87
94
  * const store = new EphemeralStore();
88
95
  * const store2 = new EphemeralStore();
89
- * // Subscribe to local updates
90
- * store.subscribeLocalUpdates((data)=>{
91
- * store2.apply(data);
92
- * })
93
- * // Subscribe to all updates
94
- * store2.subscribe((event)=>{
95
- * console.log("event: ", event);
96
- * })
96
+ * // Subscribe to local updates and forward over the wire
97
+ * store.subscribeLocalUpdates((data) => {
98
+ * store2.apply(data);
99
+ * });
100
+ * // Subscribe to all updates (including removals by timeout)
101
+ * store2.subscribe((event) => {
102
+ * console.log("event:", event);
103
+ * });
97
104
  * // Set a value
98
105
  * store.set("key", "value");
99
106
  * // Encode the value
package/base64/index.js CHANGED
@@ -925,9 +925,19 @@ class EphemeralStoreWasm {
925
925
  * @param {Uint8Array} data
926
926
  */
927
927
  apply(data) {
928
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
929
- const len0 = WASM_VECTOR_LEN;
930
- wasm.ephemeralstorewasm_apply(this.__wbg_ptr, ptr0, len0);
928
+ try {
929
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
930
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
931
+ const len0 = WASM_VECTOR_LEN;
932
+ wasm.ephemeralstorewasm_apply(retptr, this.__wbg_ptr, ptr0, len0);
933
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
934
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
935
+ if (r1) {
936
+ throw takeObject(r0);
937
+ }
938
+ } finally {
939
+ wasm.__wbindgen_add_to_stack_pointer(16);
940
+ }
931
941
  }
932
942
  removeOutdated() {
933
943
  wasm.ephemeralstorewasm_removeOutdated(this.__wbg_ptr);
@@ -2266,6 +2276,7 @@ class LoroDoc {
2266
2276
  * @param mode - The export mode to use. Can be one of:
2267
2277
  * - `{ mode: "snapshot" }`: Export a full snapshot of the document.
2268
2278
  * - `{ mode: "update", from?: VersionVector }`: Export updates from the given version vector.
2279
+ * If `from` is not provided, it will export the whole history of the document.
2269
2280
  * - `{ mode: "updates-in-range", spans: { id: ID, len: number }[] }`: Export updates within the specified ID spans.
2270
2281
  * - `{ mode: "shallow-snapshot", frontiers: Frontiers }`: Export a garbage-collected snapshot up to the given frontiers.
2271
2282
  *
@@ -6171,6 +6182,14 @@ class UndoManager {
6171
6182
  wasm.__wbindgen_add_to_stack_pointer(16);
6172
6183
  }
6173
6184
  }
6185
+ /**
6186
+ * Get the peer id of the undo manager.
6187
+ * @returns {PeerID}
6188
+ */
6189
+ peer() {
6190
+ const ret = wasm.undomanager_peer(this.__wbg_ptr);
6191
+ return takeObject(ret);
6192
+ }
6174
6193
  groupStart() {
6175
6194
  try {
6176
6195
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
@@ -6748,7 +6767,7 @@ function __wbg_node_02999533c4ea02e3(arg0) {
6748
6767
  const ret = getObject(arg0).node;
6749
6768
  return addHeapObject(ret);
6750
6769
  }
6751
- function __wbg_now_439b66158bc4f246() {
6770
+ function __wbg_now_4f8b2820be8a682c() {
6752
6771
  const ret = Date.now();
6753
6772
  return ret;
6754
6773
  }
@@ -6863,11 +6882,11 @@ function __wbindgen_cb_drop(arg0) {
6863
6882
  return ret;
6864
6883
  }
6865
6884
  function __wbindgen_closure_wrapper563(arg0, arg1, arg2) {
6866
- const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_60);
6885
+ const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
6867
6886
  return addHeapObject(ret);
6868
6887
  }
6869
- function __wbindgen_closure_wrapper566(arg0, arg1, arg2) {
6870
- const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_63);
6888
+ function __wbindgen_closure_wrapper565(arg0, arg1, arg2) {
6889
+ const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
6871
6890
  return addHeapObject(ret);
6872
6891
  }
6873
6892
  function __wbindgen_debug_string(arg0, arg1) {
@@ -7044,7 +7063,7 @@ var imports = /*#__PURE__*/Object.freeze({
7044
7063
  __wbg_next_928df8c15fc0c9b0: __wbg_next_928df8c15fc0c9b0,
7045
7064
  __wbg_next_9dc0926f351c7090: __wbg_next_9dc0926f351c7090,
7046
7065
  __wbg_node_02999533c4ea02e3: __wbg_node_02999533c4ea02e3,
7047
- __wbg_now_439b66158bc4f246: __wbg_now_439b66158bc4f246,
7066
+ __wbg_now_4f8b2820be8a682c: __wbg_now_4f8b2820be8a682c,
7048
7067
  __wbg_ownKeys_b16312a839a4152c: __wbg_ownKeys_b16312a839a4152c,
7049
7068
  __wbg_process_5c1d670bc53614b8: __wbg_process_5c1d670bc53614b8,
7050
7069
  __wbg_push_e7d7247e69dad3ee: __wbg_push_e7d7247e69dad3ee,
@@ -7073,7 +7092,7 @@ var imports = /*#__PURE__*/Object.freeze({
7073
7092
  __wbindgen_boolean_get: __wbindgen_boolean_get,
7074
7093
  __wbindgen_cb_drop: __wbindgen_cb_drop,
7075
7094
  __wbindgen_closure_wrapper563: __wbindgen_closure_wrapper563,
7076
- __wbindgen_closure_wrapper566: __wbindgen_closure_wrapper566,
7095
+ __wbindgen_closure_wrapper565: __wbindgen_closure_wrapper565,
7077
7096
  __wbindgen_debug_string: __wbindgen_debug_string,
7078
7097
  __wbindgen_error_new: __wbindgen_error_new,
7079
7098
  __wbindgen_in: __wbindgen_in,
@@ -7109,7 +7128,7 @@ var imports = /*#__PURE__*/Object.freeze({
7109
7128
  // Without this patch, Cloudflare Worker would raise issue like: "Uncaught TypeError: wasm2.__wbindgen_start is not a function"
7110
7129
 
7111
7130
 
7112
- import loro_wasm_bg_js from './loro_wasm_bg-467afd22.js';
7131
+ import loro_wasm_bg_js from './loro_wasm_bg-ec172175.js';
7113
7132
  const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
7114
7133
  "./loro_wasm_bg.js": imports,
7115
7134
  });
@@ -7269,27 +7288,34 @@ class Awareness {
7269
7288
  }
7270
7289
  }
7271
7290
  /**
7272
- * EphemeralStore is a structure that allows to track the ephemeral state of the peers.
7291
+ * EphemeralStore tracks ephemeral key-value state across peers.
7273
7292
  *
7274
- * It can be used to synchronize cursor positions, selections, and the names of the peers.
7275
- * Each entry uses timestamp-based LWW (Last-Write-Wins) for conflict resolution.
7293
+ * - Use it for lightweight presence/state like cursors, selections, and UI hints.
7294
+ * - Conflict resolution is timestamp-based LWW (Last-Write-Wins) per key.
7295
+ * - Timeout unit: milliseconds.
7296
+ * - After timeout: keys are considered expired. They are omitted from
7297
+ * `encode(key)`, `encodeAll()` and `getAllStates()`. A periodic cleanup runs
7298
+ * while the store is non-empty and removes expired keys; when removals happen
7299
+ * subscribers receive an event with `by: "timeout"` and the `removed` keys.
7276
7300
  *
7277
- * If we don't receive a state update from a peer within the timeout, we will remove their state.
7278
- * The timeout is in milliseconds. This can be used to handle the offline state of a peer.
7301
+ * See: https://loro.dev/docs/tutorial/ephemeral
7279
7302
  *
7280
- * @example
7303
+ * @param timeout Inactivity timeout in milliseconds (default: 30000). If a key
7304
+ * doesn't receive updates within this duration, it will expire and be removed
7305
+ * on the next cleanup tick.
7281
7306
  *
7307
+ * @example
7282
7308
  * ```ts
7283
7309
  * const store = new EphemeralStore();
7284
7310
  * const store2 = new EphemeralStore();
7285
- * // Subscribe to local updates
7286
- * store.subscribeLocalUpdates((data)=>{
7287
- * store2.apply(data);
7288
- * })
7289
- * // Subscribe to all updates
7290
- * store2.subscribe((event)=>{
7291
- * console.log("event: ", event);
7292
- * })
7311
+ * // Subscribe to local updates and forward over the wire
7312
+ * store.subscribeLocalUpdates((data) => {
7313
+ * store2.apply(data);
7314
+ * });
7315
+ * // Subscribe to all updates (including removals by timeout)
7316
+ * store2.subscribe((event) => {
7317
+ * console.log("event:", event);
7318
+ * });
7293
7319
  * // Set a value
7294
7320
  * store.set("key", "value");
7295
7321
  * // Encode the value
@@ -7414,4 +7440,4 @@ function idStrToId(idStr) {
7414
7440
  };
7415
7441
  }
7416
7442
 
7417
- 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_439b66158bc4f246, __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_wrapper566, __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 };
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 };
@@ -2181,6 +2181,7 @@ export class LoroDoc {
2181
2181
  * @param mode - The export mode to use. Can be one of:
2182
2182
  * - `{ mode: "snapshot" }`: Export a full snapshot of the document.
2183
2183
  * - `{ mode: "update", from?: VersionVector }`: Export updates from the given version vector.
2184
+ * If `from` is not provided, it will export the whole history of the document.
2184
2185
  * - `{ mode: "updates-in-range", spans: { id: ID, len: number }[] }`: Export updates within the specified ID spans.
2185
2186
  * - `{ mode: "shallow-snapshot", frontiers: Frontiers }`: Export a garbage-collected snapshot up to the given frontiers.
2186
2187
  *
@@ -3608,6 +3609,10 @@ export class UndoManager {
3608
3609
  * Redo the last undone operation.
3609
3610
  */
3610
3611
  redo(): boolean;
3612
+ /**
3613
+ * Get the peer id of the undo manager.
3614
+ */
3615
+ peer(): PeerID;
3611
3616
  /**
3612
3617
  * Can undo the last operation.
3613
3618
  */