loro-crdt 1.7.2 → 1.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - be09e65: feat!: events are not async anymore
8
+
9
+ ## 1.7.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 4ccf048: fix: propagate errors instead of unwrap #808
14
+
3
15
  ## 1.7.2
4
16
 
5
17
  ### Patch Changes
package/base64/index.js CHANGED
@@ -350,6 +350,11 @@ function _assertClass(instance, klass) {
350
350
  throw new Error(`expected instance of ${klass.name}`);
351
351
  }
352
352
  }
353
+
354
+ function callPendingEvents() {
355
+ wasm.callPendingEvents();
356
+ }
357
+
353
358
  /**
354
359
  * Decode the metadata of the import blob.
355
360
  *
@@ -6522,6 +6527,10 @@ function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
6522
6527
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
6523
6528
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
6524
6529
  }
6530
+ function __wbg_apply_36be6a55257c99bf() { return handleError(function (arg0, arg1, arg2) {
6531
+ const ret = getObject(arg0).apply(getObject(arg1), getObject(arg2));
6532
+ return addHeapObject(ret);
6533
+ }, arguments) }
6525
6534
  function __wbg_apply_eb9e9b97497f91e4() { return handleError(function (arg0, arg1, arg2) {
6526
6535
  const ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2));
6527
6536
  return addHeapObject(ret);
@@ -6913,11 +6922,11 @@ function __wbindgen_cb_drop(arg0) {
6913
6922
  const ret = false;
6914
6923
  return ret;
6915
6924
  }
6916
- function __wbindgen_closure_wrapper563(arg0, arg1, arg2) {
6925
+ function __wbindgen_closure_wrapper566(arg0, arg1, arg2) {
6917
6926
  const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
6918
6927
  return addHeapObject(ret);
6919
6928
  }
6920
- function __wbindgen_closure_wrapper566(arg0, arg1, arg2) {
6929
+ function __wbindgen_closure_wrapper569(arg0, arg1, arg2) {
6921
6930
  const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
6922
6931
  return addHeapObject(ret);
6923
6932
  }
@@ -7039,6 +7048,7 @@ var imports = /*#__PURE__*/Object.freeze({
7039
7048
  UndoManager: UndoManager,
7040
7049
  VersionVector: VersionVector,
7041
7050
  __wbg_String_8f0eb39a4a4c2f66: __wbg_String_8f0eb39a4a4c2f66,
7051
+ __wbg_apply_36be6a55257c99bf: __wbg_apply_36be6a55257c99bf,
7042
7052
  __wbg_apply_eb9e9b97497f91e4: __wbg_apply_eb9e9b97497f91e4,
7043
7053
  __wbg_buffer_609cc3eee51ed158: __wbg_buffer_609cc3eee51ed158,
7044
7054
  __wbg_call_672a4d21634d4a24: __wbg_call_672a4d21634d4a24,
@@ -7123,8 +7133,8 @@ var imports = /*#__PURE__*/Object.freeze({
7123
7133
  __wbindgen_bigint_get_as_i64: __wbindgen_bigint_get_as_i64,
7124
7134
  __wbindgen_boolean_get: __wbindgen_boolean_get,
7125
7135
  __wbindgen_cb_drop: __wbindgen_cb_drop,
7126
- __wbindgen_closure_wrapper563: __wbindgen_closure_wrapper563,
7127
7136
  __wbindgen_closure_wrapper566: __wbindgen_closure_wrapper566,
7137
+ __wbindgen_closure_wrapper569: __wbindgen_closure_wrapper569,
7128
7138
  __wbindgen_debug_string: __wbindgen_debug_string,
7129
7139
  __wbindgen_error_new: __wbindgen_error_new,
7130
7140
  __wbindgen_in: __wbindgen_in,
@@ -7148,6 +7158,7 @@ var imports = /*#__PURE__*/Object.freeze({
7148
7158
  __wbindgen_string_new: __wbindgen_string_new,
7149
7159
  __wbindgen_throw: __wbindgen_throw,
7150
7160
  __wbindgen_typeof: __wbindgen_typeof,
7161
+ callPendingEvents: callPendingEvents,
7151
7162
  decodeFrontiers: decodeFrontiers,
7152
7163
  decodeImportBlobMeta: decodeImportBlobMeta,
7153
7164
  encodeFrontiers: encodeFrontiers,
@@ -7160,7 +7171,7 @@ var imports = /*#__PURE__*/Object.freeze({
7160
7171
  // Without this patch, Cloudflare Worker would raise issue like: "Uncaught TypeError: wasm2.__wbindgen_start is not a function"
7161
7172
 
7162
7173
  if (!('Bun' in globalThis))
7163
- import loro_wasm_bg_js from './loro_wasm_bg-a4a986e3.js';
7174
+ import loro_wasm_bg_js from './loro_wasm_bg-ca748f92.js';
7164
7175
  const instance = new WebAssembly.Instance(loro_wasm_bg_js(), {
7165
7176
  "./loro_wasm_bg.js": imports,
7166
7177
  });
@@ -7448,9 +7459,11 @@ LoroDoc.prototype.toJsonWithReplacer = function (replacer) {
7448
7459
  };
7449
7460
  const run = (layer) => {
7450
7461
  if (Array.isArray(layer)) {
7451
- return layer.map((item, index) => {
7462
+ return layer
7463
+ .map((item, index) => {
7452
7464
  return m(index, item);
7453
- }).filter((item) => item !== undefined);
7465
+ })
7466
+ .filter((item) => item !== undefined);
7454
7467
  }
7455
7468
  const result = {};
7456
7469
  for (const [key, value] of Object.entries(layer)) {
@@ -7471,5 +7484,69 @@ function idStrToId(idStr) {
7471
7484
  peer: peer,
7472
7485
  };
7473
7486
  }
7487
+ const CALL_PENDING_EVENTS_WRAPPED = Symbol("loro.callPendingEventsWrapped");
7488
+ function decorateMethod(prototype, method) {
7489
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, method);
7490
+ if (!descriptor || typeof descriptor.value !== "function") {
7491
+ return;
7492
+ }
7493
+ const original = descriptor.value;
7494
+ if (original[CALL_PENDING_EVENTS_WRAPPED]) {
7495
+ return;
7496
+ }
7497
+ const wrapped = function (...args) {
7498
+ try {
7499
+ const result = original.apply(this, args);
7500
+ if (result && typeof result.then === "function") {
7501
+ return result.finally(() => {
7502
+ callPendingEvents();
7503
+ });
7504
+ }
7505
+ callPendingEvents();
7506
+ return result;
7507
+ }
7508
+ catch (error) {
7509
+ callPendingEvents();
7510
+ throw error;
7511
+ }
7512
+ };
7513
+ wrapped[CALL_PENDING_EVENTS_WRAPPED] = true;
7514
+ Object.defineProperty(prototype, method, {
7515
+ ...descriptor,
7516
+ value: wrapped,
7517
+ });
7518
+ }
7519
+ function decorateMethods(prototype, methods) {
7520
+ for (const method of methods) {
7521
+ decorateMethod(prototype, method);
7522
+ }
7523
+ }
7524
+ function decorateAllPrototypeMethods(prototype) {
7525
+ const visited = new Set();
7526
+ let current = prototype;
7527
+ while (current &&
7528
+ current !== Object.prototype &&
7529
+ current !== Function.prototype) {
7530
+ for (const property of Object.getOwnPropertyNames(current)) {
7531
+ if (property === "constructor" || visited.has(property)) {
7532
+ continue;
7533
+ }
7534
+ visited.add(property);
7535
+ decorateMethod(current, property);
7536
+ }
7537
+ for (const symbol of Object.getOwnPropertySymbols(current)) {
7538
+ if (visited.has(symbol)) {
7539
+ continue;
7540
+ }
7541
+ visited.add(symbol);
7542
+ decorateMethod(current, symbol);
7543
+ }
7544
+ current = Object.getPrototypeOf(current);
7545
+ }
7546
+ }
7547
+ decorateAllPrototypeMethods(LoroDoc.prototype);
7548
+ decorateAllPrototypeMethods(EphemeralStoreWasm.prototype);
7549
+ decorateAllPrototypeMethods(AwarenessWasm.prototype);
7550
+ decorateMethods(UndoManager.prototype, ["undo", "redo"]);
7474
7551
 
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_eb9e9b97497f91e4, __wbg_buffer_609cc3eee51ed158, __wbg_call_672a4d21634d4a24, __wbg_call_7cccdd69e0791ae2, __wbg_call_833bed5770ea2041, __wbg_call_b8adc8b1d0a0d8eb, __wbg_changemodifier_new, __wbg_crypto_574e78ad8b13b65f, __wbg_cursor_new, __wbg_done_769e5ede4b31c67b, __wbg_entries_3265d4158b33e5dc, __wbg_entries_c8a90a7ed73e84ce, __wbg_error_7534b8e9a36f1ab4, __wbg_error_9912f7d6d7835a4b, __wbg_from_2a5d3e218e67aa85, __wbg_getRandomValues_b8f5dbd5f3995a9e, __wbg_get_67b2ba62fc30de12, __wbg_get_b9b93047fe3cf45b, __wbg_getindex_5b00c274b05714aa, __wbg_getwithrefkey_1dc361bd10053bfe, __wbg_instanceof_ArrayBuffer_e14585432e3737fc, __wbg_instanceof_Map_f3469ce2244d2430, __wbg_instanceof_Object_7f2dcef8f78644a4, __wbg_instanceof_Uint8Array_17156bcf118086a9, __wbg_isArray_a1eab7e0d067391b, __wbg_isSafeInteger_343e2beeeece1bb0, __wbg_iterator_9a24c88df860dc65, __wbg_length_a446193dc22c12f8, __wbg_length_e2d2a49132c1b256, __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_a61aeb35a24c1329, __wbg_new_405e22f390576ce2, __wbg_new_5e0be73521bc8c17, __wbg_new_78feb108b6472713, __wbg_new_8a6f238a6ece86ea, __wbg_new_a12002a7f91c75be, __wbg_newnoargs_105ed471475aaf50, __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a, __wbg_newwithlength_a381634e90c276d4, __wbg_newwithlength_c4c419ef0bc8a1f8, __wbg_next_25feadfc0913fea9, __wbg_next_6574e1a8a62d1055, __wbg_node_905d3e251edff8a2, __wbg_now_bbd8229e4a52638e, __wbg_ownKeys_3930041068756f1f, __wbg_process_dc0fbacc7c1c06f7, __wbg_push_737cfc8c1432c2c6, __wbg_randomFillSync_ac0988aba3254290, __wbg_require_60cc747a6bc5215a, __wbg_resolve_4851785c9c5f573d, __wbg_set_37837023f3d740e8, __wbg_set_3f1d0b984ed272ed, __wbg_set_65595bdd868b3009, __wbg_set_8fc6bf8a5b1071d1, __wbg_set_bb8cecf6a62b9f46, __wbg_set_wasm, __wbg_setindex_dcd71eabf405bde1, __wbg_stack_0ed75d68575b0f3c, __wbg_static_accessor_GLOBAL_88a902d13a557d07, __wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0, __wbg_static_accessor_SELF_37c5d418e4bf5819, __wbg_static_accessor_WINDOW_5de37043a91a9c40, __wbg_subarray_aa9065fa9dc5df96, __wbg_then_44b73946d2fb3e7d, __wbg_value_cd1ffa7b1ab794f1, __wbg_versions_c01dfd4722a88165, __wbg_versionvector_new, __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 };
7552
+ 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_36be6a55257c99bf, __wbg_apply_eb9e9b97497f91e4, __wbg_buffer_609cc3eee51ed158, __wbg_call_672a4d21634d4a24, __wbg_call_7cccdd69e0791ae2, __wbg_call_833bed5770ea2041, __wbg_call_b8adc8b1d0a0d8eb, __wbg_changemodifier_new, __wbg_crypto_574e78ad8b13b65f, __wbg_cursor_new, __wbg_done_769e5ede4b31c67b, __wbg_entries_3265d4158b33e5dc, __wbg_entries_c8a90a7ed73e84ce, __wbg_error_7534b8e9a36f1ab4, __wbg_error_9912f7d6d7835a4b, __wbg_from_2a5d3e218e67aa85, __wbg_getRandomValues_b8f5dbd5f3995a9e, __wbg_get_67b2ba62fc30de12, __wbg_get_b9b93047fe3cf45b, __wbg_getindex_5b00c274b05714aa, __wbg_getwithrefkey_1dc361bd10053bfe, __wbg_instanceof_ArrayBuffer_e14585432e3737fc, __wbg_instanceof_Map_f3469ce2244d2430, __wbg_instanceof_Object_7f2dcef8f78644a4, __wbg_instanceof_Uint8Array_17156bcf118086a9, __wbg_isArray_a1eab7e0d067391b, __wbg_isSafeInteger_343e2beeeece1bb0, __wbg_iterator_9a24c88df860dc65, __wbg_length_a446193dc22c12f8, __wbg_length_e2d2a49132c1b256, __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_a61aeb35a24c1329, __wbg_new_405e22f390576ce2, __wbg_new_5e0be73521bc8c17, __wbg_new_78feb108b6472713, __wbg_new_8a6f238a6ece86ea, __wbg_new_a12002a7f91c75be, __wbg_newnoargs_105ed471475aaf50, __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a, __wbg_newwithlength_a381634e90c276d4, __wbg_newwithlength_c4c419ef0bc8a1f8, __wbg_next_25feadfc0913fea9, __wbg_next_6574e1a8a62d1055, __wbg_node_905d3e251edff8a2, __wbg_now_bbd8229e4a52638e, __wbg_ownKeys_3930041068756f1f, __wbg_process_dc0fbacc7c1c06f7, __wbg_push_737cfc8c1432c2c6, __wbg_randomFillSync_ac0988aba3254290, __wbg_require_60cc747a6bc5215a, __wbg_resolve_4851785c9c5f573d, __wbg_set_37837023f3d740e8, __wbg_set_3f1d0b984ed272ed, __wbg_set_65595bdd868b3009, __wbg_set_8fc6bf8a5b1071d1, __wbg_set_bb8cecf6a62b9f46, __wbg_set_wasm, __wbg_setindex_dcd71eabf405bde1, __wbg_stack_0ed75d68575b0f3c, __wbg_static_accessor_GLOBAL_88a902d13a557d07, __wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0, __wbg_static_accessor_SELF_37c5d418e4bf5819, __wbg_static_accessor_WINDOW_5de37043a91a9c40, __wbg_subarray_aa9065fa9dc5df96, __wbg_then_44b73946d2fb3e7d, __wbg_value_cd1ffa7b1ab794f1, __wbg_versions_c01dfd4722a88165, __wbg_versionvector_new, __wbindgen_as_number, __wbindgen_bigint_from_i64, __wbindgen_bigint_from_u64, __wbindgen_bigint_get_as_i64, __wbindgen_boolean_get, __wbindgen_cb_drop, __wbindgen_closure_wrapper566, __wbindgen_closure_wrapper569, __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, callPendingEvents, decodeFrontiers, decodeImportBlobMeta, encodeFrontiers, getType, idStrToId, isContainer, isContainerId, newContainerID, newRootContainerID, redactJsonUpdates, run, setDebug };
@@ -11,6 +11,7 @@ export function decodeFrontiers(bytes: Uint8Array): { peer: PeerID, counter: num
11
11
  * Enable debug info of Loro
12
12
  */
13
13
  export function setDebug(): void;
14
+ export function callPendingEvents(): void;
14
15
  /**
15
16
  * Decode the metadata of the import blob.
16
17
  *