@liveblocks/core 1.2.2-test2 → 1.2.2-test4
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.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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-
|
|
3
|
+
var PKG_VERSION = "1.2.2-test4";
|
|
4
4
|
var PKG_FORMAT = "cjs";
|
|
5
5
|
|
|
6
6
|
// src/dupe-detection.ts
|
|
@@ -2068,6 +2068,7 @@ 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();
|
|
2071
2072
|
this._unacknowledgedSets = /* @__PURE__ */ new Map();
|
|
2072
2073
|
let position = void 0;
|
|
2073
2074
|
for (const item of items) {
|
|
@@ -2211,6 +2212,9 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2211
2212
|
if (deletedDelta) {
|
|
2212
2213
|
delta.push(deletedDelta);
|
|
2213
2214
|
}
|
|
2215
|
+
if (this._unacknowledgedDeletedIds.has(nn(op.deletedId))) {
|
|
2216
|
+
this._unacknowledgedDeletedIds.delete(nn(op.deletedId));
|
|
2217
|
+
}
|
|
2214
2218
|
const unacknowledgedOpId = this._unacknowledgedSets.get(op.parentKey);
|
|
2215
2219
|
if (unacknowledgedOpId !== void 0) {
|
|
2216
2220
|
if (unacknowledgedOpId !== op.opId) {
|
|
@@ -2316,6 +2320,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2316
2320
|
}
|
|
2317
2321
|
/** @internal */
|
|
2318
2322
|
_applyInsertAck(op) {
|
|
2323
|
+
if (this._unacknowledgedDeletedIds.has(op.id)) {
|
|
2324
|
+
return {
|
|
2325
|
+
modified: false
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2319
2328
|
const existingItem = this._items.find((item) => item._id === op.id);
|
|
2320
2329
|
const key = asPos(op.parentKey);
|
|
2321
2330
|
const itemIndexAtPosition = this._indexOfPosition(key);
|
|
@@ -2658,7 +2667,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2658
2667
|
_optionalChain([this, 'access', _74 => _74._pool, 'optionalAccess', _75 => _75.assertStorageIsWritable, 'call', _76 => _76()]);
|
|
2659
2668
|
if (index < 0 || index > this._items.length) {
|
|
2660
2669
|
throw new Error(
|
|
2661
|
-
`Cannot insert list item at index "
|
|
2670
|
+
`Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
|
|
2662
2671
|
);
|
|
2663
2672
|
}
|
|
2664
2673
|
const before2 = this._items[index - 1] ? this._items[index - 1]._parentPos : void 0;
|
|
@@ -2746,7 +2755,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2746
2755
|
_optionalChain([this, 'access', _80 => _80._pool, 'optionalAccess', _81 => _81.assertStorageIsWritable, 'call', _82 => _82()]);
|
|
2747
2756
|
if (index < 0 || index >= this._items.length) {
|
|
2748
2757
|
throw new Error(
|
|
2749
|
-
`Cannot delete list item at index "
|
|
2758
|
+
`Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
2750
2759
|
);
|
|
2751
2760
|
}
|
|
2752
2761
|
const item = this._items[index];
|
|
@@ -2754,8 +2763,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2754
2763
|
this._items.splice(index, 1);
|
|
2755
2764
|
this.invalidate();
|
|
2756
2765
|
if (this._pool) {
|
|
2757
|
-
const
|
|
2758
|
-
if (
|
|
2766
|
+
const childId = item._id;
|
|
2767
|
+
if (childId) {
|
|
2759
2768
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
2760
2769
|
storageUpdates.set(
|
|
2761
2770
|
nn(this._id),
|
|
@@ -2764,7 +2773,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2764
2773
|
this._pool.dispatch(
|
|
2765
2774
|
[
|
|
2766
2775
|
{
|
|
2767
|
-
id:
|
|
2776
|
+
id: childId,
|
|
2768
2777
|
opId: this._pool.generateOpId(),
|
|
2769
2778
|
type: 5 /* DELETE_CRDT */
|
|
2770
2779
|
}
|
|
@@ -2813,13 +2822,16 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2813
2822
|
_optionalChain([this, 'access', _86 => _86._pool, 'optionalAccess', _87 => _87.assertStorageIsWritable, 'call', _88 => _88()]);
|
|
2814
2823
|
if (index < 0 || index >= this._items.length) {
|
|
2815
2824
|
throw new Error(
|
|
2816
|
-
`Cannot set list item at index "
|
|
2825
|
+
`Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
2817
2826
|
);
|
|
2818
2827
|
}
|
|
2819
2828
|
const existingItem = this._items[index];
|
|
2820
2829
|
const position = existingItem._getParentKeyOrThrow();
|
|
2821
2830
|
const existingId = existingItem._id;
|
|
2822
2831
|
existingItem._detach();
|
|
2832
|
+
if (existingId !== void 0) {
|
|
2833
|
+
this._unacknowledgedDeletedIds.add(existingId);
|
|
2834
|
+
}
|
|
2823
2835
|
const value = lsonToLiveNode(item);
|
|
2824
2836
|
value._setParentLink(this, position);
|
|
2825
2837
|
this._items[index] = value;
|