@liveblocks/core 1.2.2-test3 → 1.2.2

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/dist/index.d.mts CHANGED
@@ -856,6 +856,7 @@ declare type YDocUpdate = {
856
856
  readonly type: ServerMsgCode.UPDATE_YDOC;
857
857
  readonly update: string;
858
858
  readonly isSync: boolean;
859
+ readonly stateVector: string | null;
859
860
  };
860
861
  /**
861
862
  * Sent by the WebSocket server and broadcasted to all clients to announce that
package/dist/index.d.ts CHANGED
@@ -856,6 +856,7 @@ declare type YDocUpdate = {
856
856
  readonly type: ServerMsgCode.UPDATE_YDOC;
857
857
  readonly update: string;
858
858
  readonly isSync: boolean;
859
+ readonly stateVector: string | null;
859
860
  };
860
861
  /**
861
862
  * Sent by the WebSocket server and broadcasted to all clients to announce that
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/version.ts
2
2
  var PKG_NAME = "@liveblocks/core";
3
- var PKG_VERSION = "1.2.2-test3";
3
+ var PKG_VERSION = "1.2.2";
4
4
  var PKG_FORMAT = "cjs";
5
5
 
6
6
  // src/dupe-detection.ts
@@ -2068,7 +2068,6 @@ var LiveList = class _LiveList extends AbstractCrdt {
2068
2068
  super();
2069
2069
  this._items = [];
2070
2070
  this._implicitlyDeletedItems = /* @__PURE__ */ new WeakSet();
2071
- this._unacknowledgedDeletedIds = /* @__PURE__ */ new Set();
2072
2071
  this._unacknowledgedSets = /* @__PURE__ */ new Map();
2073
2072
  let position = void 0;
2074
2073
  for (const item of items) {
@@ -2220,10 +2219,6 @@ var LiveList = class _LiveList extends AbstractCrdt {
2220
2219
  this._unacknowledgedSets.delete(op.parentKey);
2221
2220
  }
2222
2221
  }
2223
- if (this._unacknowledgedDeletedIds.has(op.id)) {
2224
- this._unacknowledgedDeletedIds.delete(op.id);
2225
- return delta.length === 0 ? { modified: false } : { modified: makeUpdate(this, delta), reverse: [] };
2226
- }
2227
2222
  const indexOfItemWithSamePosition = this._indexOfPosition(op.parentKey);
2228
2223
  const existingItem = this._items.find((item) => item._id === op.id);
2229
2224
  if (existingItem !== void 0) {
@@ -2321,11 +2316,6 @@ var LiveList = class _LiveList extends AbstractCrdt {
2321
2316
  }
2322
2317
  /** @internal */
2323
2318
  _applyInsertAck(op) {
2324
- if (this._unacknowledgedDeletedIds.has(op.id)) {
2325
- return {
2326
- modified: false
2327
- };
2328
- }
2329
2319
  const existingItem = this._items.find((item) => item._id === op.id);
2330
2320
  const key = asPos(op.parentKey);
2331
2321
  const itemIndexAtPosition = this._indexOfPosition(key);
@@ -2668,7 +2658,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2668
2658
  _optionalChain([this, 'access', _74 => _74._pool, 'optionalAccess', _75 => _75.assertStorageIsWritable, 'call', _76 => _76()]);
2669
2659
  if (index < 0 || index > this._items.length) {
2670
2660
  throw new Error(
2671
- `Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
2661
+ `Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
2672
2662
  );
2673
2663
  }
2674
2664
  const before2 = this._items[index - 1] ? this._items[index - 1]._parentPos : void 0;
@@ -2756,7 +2746,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2756
2746
  _optionalChain([this, 'access', _80 => _80._pool, 'optionalAccess', _81 => _81.assertStorageIsWritable, 'call', _82 => _82()]);
2757
2747
  if (index < 0 || index >= this._items.length) {
2758
2748
  throw new Error(
2759
- `Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
2749
+ `Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
2760
2750
  );
2761
2751
  }
2762
2752
  const item = this._items[index];
@@ -2764,8 +2754,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
2764
2754
  this._items.splice(index, 1);
2765
2755
  this.invalidate();
2766
2756
  if (this._pool) {
2767
- const childId = item._id;
2768
- if (childId) {
2757
+ const childRecordId = item._id;
2758
+ if (childRecordId) {
2769
2759
  const storageUpdates = /* @__PURE__ */ new Map();
2770
2760
  storageUpdates.set(
2771
2761
  nn(this._id),
@@ -2774,7 +2764,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
2774
2764
  this._pool.dispatch(
2775
2765
  [
2776
2766
  {
2777
- id: childId,
2767
+ id: childRecordId,
2778
2768
  opId: this._pool.generateOpId(),
2779
2769
  type: 5 /* DELETE_CRDT */
2780
2770
  }
@@ -2823,16 +2813,13 @@ var LiveList = class _LiveList extends AbstractCrdt {
2823
2813
  _optionalChain([this, 'access', _86 => _86._pool, 'optionalAccess', _87 => _87.assertStorageIsWritable, 'call', _88 => _88()]);
2824
2814
  if (index < 0 || index >= this._items.length) {
2825
2815
  throw new Error(
2826
- `Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
2816
+ `Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
2827
2817
  );
2828
2818
  }
2829
2819
  const existingItem = this._items[index];
2830
2820
  const position = existingItem._getParentKeyOrThrow();
2831
2821
  const existingId = existingItem._id;
2832
2822
  existingItem._detach();
2833
- if (existingId !== void 0) {
2834
- this._unacknowledgedDeletedIds.add(existingId);
2835
- }
2836
2823
  const value = lsonToLiveNode(item);
2837
2824
  value._setParentLink(this, position);
2838
2825
  this._items[index] = value;
@@ -5281,10 +5268,14 @@ ${Array.from(traces).join("\n\n")}`
5281
5268
  };
5282
5269
  }
5283
5270
  function fetchYDoc(vector) {
5284
- context.buffer.messages.push({
5285
- type: 300 /* FETCH_YDOC */,
5286
- vector
5287
- });
5271
+ if (!context.buffer.messages.find((m) => {
5272
+ return m.type === 300 /* FETCH_YDOC */ && m.vector === vector;
5273
+ })) {
5274
+ context.buffer.messages.push({
5275
+ type: 300 /* FETCH_YDOC */,
5276
+ vector
5277
+ });
5278
+ }
5288
5279
  flushNowOrSoon();
5289
5280
  }
5290
5281
  function undo() {