@liveblocks/client 0.16.2 → 0.16.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/esm/index.js +11 -3
- package/esm/index.mjs +11 -3
- package/index.js +15 -4
- package/package.json +1 -1
package/esm/index.js
CHANGED
|
@@ -1823,6 +1823,7 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
1823
1823
|
return `${getConnectionId()}:${state.opClock++}`;
|
|
1824
1824
|
}
|
|
1825
1825
|
function apply(item, isLocal) {
|
|
1826
|
+
var _a;
|
|
1826
1827
|
const result = {
|
|
1827
1828
|
reverse: [],
|
|
1828
1829
|
updates: {
|
|
@@ -1830,6 +1831,7 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
1830
1831
|
presence: false
|
|
1831
1832
|
}
|
|
1832
1833
|
};
|
|
1834
|
+
const createdNodeIds = /* @__PURE__ */ new Set();
|
|
1833
1835
|
for (const op of item) {
|
|
1834
1836
|
if (op.type === "presence") {
|
|
1835
1837
|
const reverse = {
|
|
@@ -1844,7 +1846,7 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
1844
1846
|
state.buffer.presence = op.data;
|
|
1845
1847
|
} else {
|
|
1846
1848
|
for (const key in op.data) {
|
|
1847
|
-
state.buffer.presence[key] = op.data;
|
|
1849
|
+
state.buffer.presence[key] = op.data[key];
|
|
1848
1850
|
}
|
|
1849
1851
|
}
|
|
1850
1852
|
result.reverse.unshift(reverse);
|
|
@@ -1855,8 +1857,14 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
1855
1857
|
}
|
|
1856
1858
|
const applyOpResult = applyOp(op, isLocal);
|
|
1857
1859
|
if (applyOpResult.modified) {
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
+
const parentId = (_a = applyOpResult.modified.node._parent) == null ? void 0 : _a._id;
|
|
1861
|
+
if (!createdNodeIds.has(parentId)) {
|
|
1862
|
+
result.updates.storageUpdates.set(applyOpResult.modified.node._id, mergeStorageUpdates(result.updates.storageUpdates.get(applyOpResult.modified.node._id), applyOpResult.modified));
|
|
1863
|
+
result.reverse.unshift(...applyOpResult.reverse);
|
|
1864
|
+
}
|
|
1865
|
+
if (op.type === OpType.CreateList || op.type === OpType.CreateMap || op.type === OpType.CreateObject) {
|
|
1866
|
+
createdNodeIds.add(applyOpResult.modified.node._id);
|
|
1867
|
+
}
|
|
1860
1868
|
}
|
|
1861
1869
|
}
|
|
1862
1870
|
}
|
package/esm/index.mjs
CHANGED
|
@@ -1823,6 +1823,7 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
1823
1823
|
return `${getConnectionId()}:${state.opClock++}`;
|
|
1824
1824
|
}
|
|
1825
1825
|
function apply(item, isLocal) {
|
|
1826
|
+
var _a;
|
|
1826
1827
|
const result = {
|
|
1827
1828
|
reverse: [],
|
|
1828
1829
|
updates: {
|
|
@@ -1830,6 +1831,7 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
1830
1831
|
presence: false
|
|
1831
1832
|
}
|
|
1832
1833
|
};
|
|
1834
|
+
const createdNodeIds = /* @__PURE__ */ new Set();
|
|
1833
1835
|
for (const op of item) {
|
|
1834
1836
|
if (op.type === "presence") {
|
|
1835
1837
|
const reverse = {
|
|
@@ -1844,7 +1846,7 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
1844
1846
|
state.buffer.presence = op.data;
|
|
1845
1847
|
} else {
|
|
1846
1848
|
for (const key in op.data) {
|
|
1847
|
-
state.buffer.presence[key] = op.data;
|
|
1849
|
+
state.buffer.presence[key] = op.data[key];
|
|
1848
1850
|
}
|
|
1849
1851
|
}
|
|
1850
1852
|
result.reverse.unshift(reverse);
|
|
@@ -1855,8 +1857,14 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
1855
1857
|
}
|
|
1856
1858
|
const applyOpResult = applyOp(op, isLocal);
|
|
1857
1859
|
if (applyOpResult.modified) {
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
+
const parentId = (_a = applyOpResult.modified.node._parent) == null ? void 0 : _a._id;
|
|
1861
|
+
if (!createdNodeIds.has(parentId)) {
|
|
1862
|
+
result.updates.storageUpdates.set(applyOpResult.modified.node._id, mergeStorageUpdates(result.updates.storageUpdates.get(applyOpResult.modified.node._id), applyOpResult.modified));
|
|
1863
|
+
result.reverse.unshift(...applyOpResult.reverse);
|
|
1864
|
+
}
|
|
1865
|
+
if (op.type === OpType.CreateList || op.type === OpType.CreateMap || op.type === OpType.CreateObject) {
|
|
1866
|
+
createdNodeIds.add(applyOpResult.modified.node._id);
|
|
1867
|
+
}
|
|
1860
1868
|
}
|
|
1861
1869
|
}
|
|
1862
1870
|
}
|
package/index.js
CHANGED
|
@@ -2736,6 +2736,7 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
2736
2736
|
presence: false
|
|
2737
2737
|
}
|
|
2738
2738
|
};
|
|
2739
|
+
var createdNodeIds = new Set();
|
|
2739
2740
|
|
|
2740
2741
|
for (var _iterator7 = _createForOfIteratorHelperLoose(item), _step7; !(_step7 = _iterator7()).done;) {
|
|
2741
2742
|
var op = _step7.value;
|
|
@@ -2756,7 +2757,7 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
2756
2757
|
state.buffer.presence = op.data;
|
|
2757
2758
|
} else {
|
|
2758
2759
|
for (var _key3 in op.data) {
|
|
2759
|
-
state.buffer.presence[_key3] = op.data;
|
|
2760
|
+
state.buffer.presence[_key3] = op.data[_key3];
|
|
2760
2761
|
}
|
|
2761
2762
|
}
|
|
2762
2763
|
|
|
@@ -2770,11 +2771,21 @@ function makeStateMachine(state, context, mockedEffects) {
|
|
|
2770
2771
|
var applyOpResult = applyOp(op, isLocal);
|
|
2771
2772
|
|
|
2772
2773
|
if (applyOpResult.modified) {
|
|
2773
|
-
var
|
|
2774
|
+
var _applyOpResult$modifi;
|
|
2774
2775
|
|
|
2775
|
-
|
|
2776
|
+
var parentId = (_applyOpResult$modifi = applyOpResult.modified.node._parent) == null ? void 0 : _applyOpResult$modifi._id;
|
|
2776
2777
|
|
|
2777
|
-
(
|
|
2778
|
+
if (!createdNodeIds.has(parentId)) {
|
|
2779
|
+
var _result$reverse;
|
|
2780
|
+
|
|
2781
|
+
result.updates.storageUpdates.set(applyOpResult.modified.node._id, mergeStorageUpdates(result.updates.storageUpdates.get(applyOpResult.modified.node._id), applyOpResult.modified));
|
|
2782
|
+
|
|
2783
|
+
(_result$reverse = result.reverse).unshift.apply(_result$reverse, applyOpResult.reverse);
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
if (op.type === OpType.CreateList || op.type === OpType.CreateMap || op.type === OpType.CreateObject) {
|
|
2787
|
+
createdNodeIds.add(applyOpResult.modified.node._id);
|
|
2788
|
+
}
|
|
2778
2789
|
}
|
|
2779
2790
|
}
|
|
2780
2791
|
}
|