loro-crdt 1.2.2 → 1.2.3

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 42949c0: Fix VersionVector ownership issue in WASM binding
8
+ - 1ca1275: feat: UndoManager's onPush now can access the change event
9
+
3
10
  ## 1.2.2
4
11
 
5
12
  ### Patch Changes
package/base64/index.js CHANGED
@@ -1815,18 +1815,13 @@ class LoroDoc {
1815
1815
  * // get updates from specific version to the latest version
1816
1816
  * const updates2 = doc.exportFrom(version);
1817
1817
  * ```
1818
- * @param {VersionVector | undefined} [vv]
1818
+ * @param {any} vv
1819
1819
  * @returns {Uint8Array}
1820
1820
  */
1821
1821
  exportFrom(vv) {
1822
1822
  try {
1823
1823
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1824
- let ptr0 = 0;
1825
- if (!isLikeNone(vv)) {
1826
- _assertClass(vv, VersionVector);
1827
- ptr0 = vv.__destroy_into_raw();
1828
- }
1829
- wasm.lorodoc_exportFrom(retptr, this.__wbg_ptr, ptr0);
1824
+ wasm.lorodoc_exportFrom(retptr, this.__wbg_ptr, addHeapObject(vv));
1830
1825
  var r0 = getInt32Memory0()[retptr / 4 + 0];
1831
1826
  var r1 = getInt32Memory0()[retptr / 4 + 1];
1832
1827
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -1834,9 +1829,9 @@ class LoroDoc {
1834
1829
  if (r3) {
1835
1830
  throw takeObject(r2);
1836
1831
  }
1837
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
1832
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1838
1833
  wasm.__wbindgen_export_5(r0, r1 * 1, 1);
1839
- return v2;
1834
+ return v1;
1840
1835
  } finally {
1841
1836
  wasm.__wbindgen_add_to_stack_pointer(16);
1842
1837
  }
@@ -1900,24 +1895,14 @@ class LoroDoc {
1900
1895
  }
1901
1896
  /**
1902
1897
  * Export updates in the given range in JSON format.
1903
- * @param {VersionVector | undefined} [start_vv]
1904
- * @param {VersionVector | undefined} [end_vv]
1898
+ * @param {any} start_vv
1899
+ * @param {any} end_vv
1905
1900
  * @returns {JsonSchema}
1906
1901
  */
1907
1902
  exportJsonUpdates(start_vv, end_vv) {
1908
1903
  try {
1909
1904
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1910
- let ptr0 = 0;
1911
- if (!isLikeNone(start_vv)) {
1912
- _assertClass(start_vv, VersionVector);
1913
- ptr0 = start_vv.__destroy_into_raw();
1914
- }
1915
- let ptr1 = 0;
1916
- if (!isLikeNone(end_vv)) {
1917
- _assertClass(end_vv, VersionVector);
1918
- ptr1 = end_vv.__destroy_into_raw();
1919
- }
1920
- wasm.lorodoc_exportJsonUpdates(retptr, this.__wbg_ptr, ptr0, ptr1);
1905
+ wasm.lorodoc_exportJsonUpdates(retptr, this.__wbg_ptr, addHeapObject(start_vv), addHeapObject(end_vv));
1921
1906
  var r0 = getInt32Memory0()[retptr / 4 + 0];
1922
1907
  var r1 = getInt32Memory0()[retptr / 4 + 1];
1923
1908
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -5949,6 +5934,10 @@ function __wbindgen_is_string(arg0) {
5949
5934
  const ret = typeof(getObject(arg0)) === 'string';
5950
5935
  return ret;
5951
5936
  }
5937
+ function __wbindgen_is_null(arg0) {
5938
+ const ret = getObject(arg0) === null;
5939
+ return ret;
5940
+ }
5952
5941
  function __wbindgen_number_new(arg0) {
5953
5942
  const ret = arg0;
5954
5943
  return addHeapObject(ret);
@@ -5957,10 +5946,6 @@ function __wbindgen_typeof(arg0) {
5957
5946
  const ret = typeof getObject(arg0);
5958
5947
  return addHeapObject(ret);
5959
5948
  }
5960
- function __wbindgen_is_null(arg0) {
5961
- const ret = getObject(arg0) === null;
5962
- return ret;
5963
- }
5964
5949
  function __wbg_error_c8c2cca30a630316(arg0, arg1) {
5965
5950
  console.error(getStringFromWasm0(arg0, arg1));
5966
5951
  }
@@ -6453,7 +6438,7 @@ var imports = /*#__PURE__*/Object.freeze({
6453
6438
  // Without this patch, Cloudflare Worker would raise issue like: "Uncaught TypeError: wasm2.__wbindgen_start is not a function"
6454
6439
 
6455
6440
 
6456
- import loro_wasm_bg_js from './loro_wasm_bg-8056e30c.js';
6441
+ import loro_wasm_bg_js from './loro_wasm_bg-c9740ed0.js';
6457
6442
  const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
6458
6443
  "./loro_wasm_bg.js": imports,
6459
6444
  });
@@ -268,7 +268,7 @@ export type UndoConfig = {
268
268
  mergeInterval?: number,
269
269
  maxUndoSteps?: number,
270
270
  excludeOriginPrefixes?: string[],
271
- onPush?: (isUndo: boolean, counterRange: { start: number, end: number }) => { value: Value, cursors: Cursor[] },
271
+ onPush?: (isUndo: boolean, counterRange: { start: number, end: number }, event?: LoroEventBatch) => { value: Value, cursors: Cursor[] },
272
272
  onPop?: (isUndo: boolean, value: { value: Value, cursors: Cursor[] }, counterRange: { start: number, end: number }) => void
273
273
  };
274
274
  export type Container = LoroList | LoroMap | LoroText | LoroTree | LoroMovableList;
@@ -793,6 +793,14 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
793
793
  */
794
794
  getTree<Key extends keyof T | ContainerID>(name: Key): T[Key] extends LoroTree ? T[Key] : LoroTree;
795
795
  getText(key: string | ContainerID): LoroText;
796
+ /**
797
+ * Export the updates in the given range.
798
+ *
799
+ * @param start - The start version vector.
800
+ * @param end - The end version vector.
801
+ * @returns The updates in the given range.
802
+ */
803
+ exportJsonUpdates(start?: VersionVector, end?: VersionVector): JsonSchema;
796
804
  }
797
805
  interface LoroList<T = unknown> {
798
806
  new(): LoroList<T>;
@@ -1866,13 +1874,6 @@ export class LoroDoc {
1866
1874
  */
1867
1875
  export(mode: ExportMode): Uint8Array;
1868
1876
  /**
1869
- * Export updates in the given range in JSON format.
1870
- * @param {VersionVector | undefined} [start_vv]
1871
- * @param {VersionVector | undefined} [end_vv]
1872
- * @returns {JsonSchema}
1873
- */
1874
- exportJsonUpdates(start_vv?: VersionVector, end_vv?: VersionVector): JsonSchema;
1875
- /**
1876
1877
  * Import updates from the JSON format.
1877
1878
  *
1878
1879
  * only supports backward compatibility but not forward compatibility.