loro-crdt 1.16.2 → 1.16.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/web/loro_wasm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { stateBinary, stateCid, stateContainer, stateIndex, stateOptions, stateRootCid, stateSet, stateSlice, stateValue } from './snippets/loro-wasm-00a42dcc1beb7b21/inline0.js';
1
+ import { stateBinary, stateCid, stateContainer, stateIndex, stateOptions, stateRootCid, stateSet, stateSlice, stateValue } from './snippets/loro-wasm-704a44faa43c032c/inline0.js';
2
2
 
3
3
  let wasm;
4
4
 
@@ -1352,12 +1352,30 @@ export class LoroDoc {
1352
1352
  * doc2.applyDiff(diff);
1353
1353
  * console.log(doc2.getText("text").toString()); // "Hello"
1354
1354
  * ```
1355
+ *
1356
+ * Pass `{ fullState: true }` when applying the result of `doc.diff()` to a document that may
1357
+ * keep hidden state for a mergeable child the diff makes visible again (e.g. applying
1358
+ * `doc.diff(afterDelete, beforeDelete)` to `doc` itself or to a copy of it). The child's
1359
+ * entry is then read as its full content and aligned with that hidden state. Without it
1360
+ * (the default), entries are applied as increments, which is right for events forwarded to
1361
+ * a document that shares the source's hidden state. Never pass it for events from local
1362
+ * commits; see `ApplyDiffOptions.fullState`.
1363
+ *
1364
+ * ```ts
1365
+ * const text = doc.getMap("m").ensureMergeableText("t");
1366
+ * text.insert(0, "hello");
1367
+ * const before = doc.frontiers();
1368
+ * doc.getMap("m").delete("t");
1369
+ * doc.applyDiff(doc.diff(doc.frontiers(), before), { fullState: true });
1370
+ * console.log(doc.getMap("m").get("t").toString()); // "hello"
1371
+ * ```
1355
1372
  * @param {[ContainerID, Diff|JsonDiff][]} diff
1373
+ * @param {ApplyDiffOptions | null} [options]
1356
1374
  */
1357
- applyDiff(diff) {
1375
+ applyDiff(diff, options) {
1358
1376
  try {
1359
1377
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1360
- wasm.lorodoc_applyDiff(retptr, this.__wbg_ptr, addHeapObject(diff));
1378
+ wasm.lorodoc_applyDiff(retptr, this.__wbg_ptr, addHeapObject(diff), isLikeNone(options) ? 0 : addHeapObject(options));
1361
1379
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1362
1380
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1363
1381
  if (r1) {
@@ -7413,6 +7431,9 @@ export class UndoManager {
7413
7431
  }
7414
7432
  /**
7415
7433
  * Redo the last undone operation.
7434
+ *
7435
+ * Throws like `undo` on steps that would recreate a container of an
7436
+ * unknown type.
7416
7437
  * @returns {boolean}
7417
7438
  */
7418
7439
  redo() {
@@ -7432,6 +7453,12 @@ export class UndoManager {
7432
7453
  }
7433
7454
  /**
7434
7455
  * Undo the last operation.
7456
+ *
7457
+ * Throws without changing the doc if the step would have to recreate a
7458
+ * container of a type unknown to this version (created by a newer
7459
+ * loro-crdt). That step, with every edit merged into it, is dropped and its
7460
+ * edits stay; the next call undoes the step before it, rebased over the
7461
+ * dropped step's edits like over a remote peer's.
7435
7462
  * @returns {boolean}
7436
7463
  */
7437
7464
  undo() {
@@ -7840,7 +7867,7 @@ function __wbg_get_imports() {
7840
7867
  const ret = getObject(arg0).entries();
7841
7868
  return addHeapObject(ret);
7842
7869
  };
7843
- imports.wbg.__wbg_error_b1d64315f7b2330b = function(arg0, arg1) {
7870
+ imports.wbg.__wbg_error_1d6f2b3f2c5a33ec = function(arg0, arg1) {
7844
7871
  console.error(getStringFromWasm0(arg0, arg1));
7845
7872
  };
7846
7873
  imports.wbg.__wbg_from_2a5d3e218e67aa85 = function(arg0) {
@@ -7952,7 +7979,7 @@ function __wbg_get_imports() {
7952
7979
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
7953
7980
  }
7954
7981
  };
7955
- imports.wbg.__wbg_log_df8a54ea863a0cd4 = function(arg0, arg1) {
7982
+ imports.wbg.__wbg_log_f665cabe523a97df = function(arg0, arg1) {
7956
7983
  console.log(getStringFromWasm0(arg0, arg1));
7957
7984
  };
7958
7985
  imports.wbg.__wbg_lorocounter_new = function(arg0) {
@@ -8054,7 +8081,7 @@ function __wbg_get_imports() {
8054
8081
  const ret = getObject(arg0).node;
8055
8082
  return addHeapObject(ret);
8056
8083
  };
8057
- imports.wbg.__wbg_now_a326ae9abb0bdbb1 = function() {
8084
+ imports.wbg.__wbg_now_454cbad00d40f177 = function() {
8058
8085
  const ret = Date.now();
8059
8086
  return ret;
8060
8087
  };
@@ -8101,37 +8128,37 @@ function __wbg_get_imports() {
8101
8128
  imports.wbg.__wbg_setindex_dcd71eabf405bde1 = function(arg0, arg1, arg2) {
8102
8129
  getObject(arg0)[arg1 >>> 0] = arg2;
8103
8130
  };
8104
- imports.wbg.__wbg_stateBinary_16871a591dc334f0 = function(arg0, arg1) {
8131
+ imports.wbg.__wbg_stateBinary_9e1da8a4daa74bc6 = function(arg0, arg1) {
8105
8132
  const ret = stateBinary(getArrayU8FromWasm0(arg0, arg1));
8106
8133
  return addHeapObject(ret);
8107
8134
  };
8108
- imports.wbg.__wbg_stateCid_c73ac0b2e145d6fa = function(arg0, arg1, arg2) {
8135
+ imports.wbg.__wbg_stateCid_c43ea762fb462319 = function(arg0, arg1, arg2) {
8109
8136
  const ret = stateCid(getObject(arg0), arg1, arg2);
8110
8137
  return addHeapObject(ret);
8111
8138
  };
8112
- imports.wbg.__wbg_stateContainer_7e2e342eb34cfc43 = function(arg0, arg1, arg2) {
8139
+ imports.wbg.__wbg_stateContainer_cd983f42c6fe987d = function(arg0, arg1, arg2) {
8113
8140
  const ret = stateContainer(arg0, getObject(arg1), takeObject(arg2));
8114
8141
  return addHeapObject(ret);
8115
8142
  };
8116
- imports.wbg.__wbg_stateIndex_1649f9be165adc06 = function() { return handleError(function (arg0, arg1, arg2) {
8143
+ imports.wbg.__wbg_stateIndex_1fbac6394e58cff9 = function() { return handleError(function (arg0, arg1, arg2) {
8117
8144
  stateIndex(getObject(arg0), arg1 >>> 0, getObject(arg2));
8118
8145
  }, arguments) };
8119
- imports.wbg.__wbg_stateOptions_715a60383a215f03 = function() { return handleError(function (arg0, arg1) {
8146
+ imports.wbg.__wbg_stateOptions_dcb483514d1b925d = function() { return handleError(function (arg0, arg1) {
8120
8147
  const ret = stateOptions(takeObject(arg0), arg1 !== 0);
8121
8148
  return addHeapObject(ret);
8122
8149
  }, arguments) };
8123
- imports.wbg.__wbg_stateRootCid_fd5a57597e5a6878 = function(arg0, arg1, arg2) {
8150
+ imports.wbg.__wbg_stateRootCid_9198769cdd9f37d5 = function(arg0, arg1, arg2) {
8124
8151
  const ret = stateRootCid(getStringFromWasm0(arg0, arg1), arg2);
8125
8152
  return addHeapObject(ret);
8126
8153
  };
8127
- imports.wbg.__wbg_stateSet_94c2e7ed3e5880bb = function() { return handleError(function (arg0, arg1, arg2) {
8154
+ imports.wbg.__wbg_stateSet_a3e74b27d3d26f9d = function() { return handleError(function (arg0, arg1, arg2) {
8128
8155
  stateSet(getObject(arg0), getObject(arg1), getObject(arg2));
8129
8156
  }, arguments) };
8130
- imports.wbg.__wbg_stateSlice_90b6948816597251 = function(arg0, arg1, arg2) {
8157
+ imports.wbg.__wbg_stateSlice_aafffe8ecba122b8 = function(arg0, arg1, arg2) {
8131
8158
  const ret = stateSlice(takeObject(arg0), arg1 >>> 0, arg2 >>> 0);
8132
8159
  return addHeapObject(ret);
8133
8160
  };
8134
- imports.wbg.__wbg_stateValue_26fc5effdba0aa3e = function(arg0) {
8161
+ imports.wbg.__wbg_stateValue_8ed644fcdb61558c = function(arg0) {
8135
8162
  const ret = stateValue(takeObject(arg0));
8136
8163
  return addHeapObject(ret);
8137
8164
  };
@@ -8171,7 +8198,7 @@ function __wbg_get_imports() {
8171
8198
  const ret = VersionVector.__wrap(arg0);
8172
8199
  return addHeapObject(ret);
8173
8200
  };
8174
- imports.wbg.__wbg_warn_3405af8b3bbb5a6a = function(arg0, arg1) {
8201
+ imports.wbg.__wbg_warn_52b319b1b6be3d2f = function(arg0, arg1) {
8175
8202
  console.warn(getStringFromWasm0(arg0, arg1));
8176
8203
  };
8177
8204
  imports.wbg.__wbindgen_as_number = function(arg0) {
@@ -8206,11 +8233,11 @@ function __wbg_get_imports() {
8206
8233
  const ret = false;
8207
8234
  return ret;
8208
8235
  };
8209
- imports.wbg.__wbindgen_closure_wrapper283 = function(arg0, arg1, arg2) {
8236
+ imports.wbg.__wbindgen_closure_wrapper285 = function(arg0, arg1, arg2) {
8210
8237
  const ret = makeMutClosure(arg0, arg1, 15, __wbg_adapter_58);
8211
8238
  return addHeapObject(ret);
8212
8239
  };
8213
- imports.wbg.__wbindgen_closure_wrapper542 = function(arg0, arg1, arg2) {
8240
+ imports.wbg.__wbindgen_closure_wrapper544 = function(arg0, arg1, arg2) {
8214
8241
  const ret = makeMutClosure(arg0, arg1, 15, __wbg_adapter_61);
8215
8242
  return addHeapObject(ret);
8216
8243
  };
Binary file
@@ -66,7 +66,7 @@ export const lorocounter_parent: (a: number, b: number) => void;
66
66
  export const lorocounter_subscribe: (a: number, b: number, c: number) => void;
67
67
  export const lorocounter_toContainerTree: (a: number, b: number, c: number) => void;
68
68
  export const lorodoc_JSONPath: (a: number, b: number, c: number, d: number) => void;
69
- export const lorodoc_applyDiff: (a: number, b: number, c: number) => void;
69
+ export const lorodoc_applyDiff: (a: number, b: number, c: number, d: number) => void;
70
70
  export const lorodoc_attach: (a: number) => void;
71
71
  export const lorodoc_changeCount: (a: number) => number;
72
72
  export const lorodoc_checkout: (a: number, b: number, c: number, d: number) => void;