houdini-svelte 2.2.0-next.3 → 2.2.0-next.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/build/plugin-cjs/index.js +72 -58
- package/build/plugin-esm/index.js +72 -58
- package/build/preprocess-cjs/index.js +72 -58
- package/build/preprocess-esm/index.js +72 -58
- package/build/test-cjs/index.js +144 -116
- package/build/test-esm/index.js +144 -116
- package/package.json +2 -2
|
@@ -90491,20 +90491,21 @@ var CacheInternal = class {
|
|
|
90491
90491
|
} else if (Array.isArray(value) && // make typescript happy
|
|
90492
90492
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
90493
90493
|
let oldIDs = [...previousValue || []];
|
|
90494
|
-
|
|
90495
|
-
|
|
90496
|
-
|
|
90497
|
-
|
|
90498
|
-
|
|
90499
|
-
|
|
90500
|
-
|
|
90501
|
-
|
|
90502
|
-
|
|
90503
|
-
|
|
90504
|
-
|
|
90505
|
-
|
|
90506
|
-
|
|
90507
|
-
|
|
90494
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
90495
|
+
oldIDs = oldIDs.filter((id) => {
|
|
90496
|
+
for (const layer2 of this.storage.data) {
|
|
90497
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
90498
|
+
if (operation.fields?.[key])
|
|
90499
|
+
for (const listOperation of operation.fields[key]) {
|
|
90500
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
90501
|
+
return false;
|
|
90502
|
+
}
|
|
90503
|
+
}
|
|
90504
|
+
}
|
|
90505
|
+
}
|
|
90506
|
+
return true;
|
|
90507
|
+
});
|
|
90508
|
+
}
|
|
90508
90509
|
let linkedIDs = [];
|
|
90509
90510
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
90510
90511
|
value,
|
|
@@ -90523,39 +90524,45 @@ var CacheInternal = class {
|
|
|
90523
90524
|
layer.writeLink(parent2, key, linkedIDs);
|
|
90524
90525
|
};
|
|
90525
90526
|
if (applyUpdates && updates) {
|
|
90526
|
-
|
|
90527
|
-
const
|
|
90528
|
-
for (const id of
|
|
90527
|
+
const filterIDs = (keep, insert) => {
|
|
90528
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
90529
|
+
for (const id of keep) {
|
|
90529
90530
|
if (!id) {
|
|
90530
90531
|
continue;
|
|
90531
90532
|
}
|
|
90532
90533
|
const { value: node } = this.storage.get(id, "node");
|
|
90533
|
-
if (
|
|
90534
|
+
if (!node) {
|
|
90534
90535
|
continue;
|
|
90535
90536
|
}
|
|
90536
|
-
|
|
90537
|
+
const nodeID = this.storage.get(node, "id");
|
|
90538
|
+
if (!nodeID) {
|
|
90537
90539
|
continue;
|
|
90538
90540
|
}
|
|
90539
|
-
|
|
90541
|
+
existingIDs.add(nodeID.value);
|
|
90540
90542
|
}
|
|
90541
|
-
|
|
90543
|
+
return insert.filter((id) => {
|
|
90542
90544
|
if (!id) {
|
|
90543
90545
|
return true;
|
|
90544
90546
|
}
|
|
90545
|
-
const { value:
|
|
90546
|
-
|
|
90547
|
-
|
|
90548
|
-
return false;
|
|
90547
|
+
const { value: node } = this.storage.get(id, "node");
|
|
90548
|
+
if (!node) {
|
|
90549
|
+
return true;
|
|
90549
90550
|
}
|
|
90550
|
-
|
|
90551
|
+
const nodeID = this.storage.get(node, "id");
|
|
90552
|
+
if (!nodeID) {
|
|
90553
|
+
return true;
|
|
90554
|
+
}
|
|
90555
|
+
return !existingIDs.has(nodeID.value);
|
|
90551
90556
|
});
|
|
90552
|
-
}
|
|
90557
|
+
};
|
|
90553
90558
|
for (const update of applyUpdates) {
|
|
90554
90559
|
if (update !== "replace" && !updates.includes(update)) {
|
|
90555
90560
|
continue;
|
|
90556
90561
|
}
|
|
90557
90562
|
if (update === "prepend") {
|
|
90558
|
-
linkedIDs = newIDs.concat(
|
|
90563
|
+
linkedIDs = newIDs.concat(
|
|
90564
|
+
filterIDs(newIDs, oldIDs)
|
|
90565
|
+
);
|
|
90559
90566
|
if (layer?.optimistic) {
|
|
90560
90567
|
action = () => {
|
|
90561
90568
|
for (const id of newIDs) {
|
|
@@ -90566,7 +90573,7 @@ var CacheInternal = class {
|
|
|
90566
90573
|
};
|
|
90567
90574
|
}
|
|
90568
90575
|
} else if (update === "append") {
|
|
90569
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
90576
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
90570
90577
|
if (layer?.optimistic) {
|
|
90571
90578
|
action = () => {
|
|
90572
90579
|
for (const id of newIDs) {
|
|
@@ -163265,20 +163272,21 @@ var CacheInternal2 = class {
|
|
|
163265
163272
|
} else if (Array.isArray(value) && // make typescript happy
|
|
163266
163273
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
163267
163274
|
let oldIDs = [...previousValue || []];
|
|
163268
|
-
|
|
163269
|
-
|
|
163270
|
-
|
|
163271
|
-
|
|
163272
|
-
|
|
163273
|
-
|
|
163274
|
-
|
|
163275
|
-
|
|
163276
|
-
|
|
163277
|
-
|
|
163278
|
-
|
|
163279
|
-
|
|
163280
|
-
|
|
163281
|
-
|
|
163275
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
163276
|
+
oldIDs = oldIDs.filter((id) => {
|
|
163277
|
+
for (const layer2 of this.storage.data) {
|
|
163278
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
163279
|
+
if (operation.fields?.[key])
|
|
163280
|
+
for (const listOperation of operation.fields[key]) {
|
|
163281
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
163282
|
+
return false;
|
|
163283
|
+
}
|
|
163284
|
+
}
|
|
163285
|
+
}
|
|
163286
|
+
}
|
|
163287
|
+
return true;
|
|
163288
|
+
});
|
|
163289
|
+
}
|
|
163282
163290
|
let linkedIDs = [];
|
|
163283
163291
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
163284
163292
|
value,
|
|
@@ -163297,39 +163305,45 @@ var CacheInternal2 = class {
|
|
|
163297
163305
|
layer.writeLink(parent2, key, linkedIDs);
|
|
163298
163306
|
};
|
|
163299
163307
|
if (applyUpdates && updates) {
|
|
163300
|
-
|
|
163301
|
-
const
|
|
163302
|
-
for (const id of
|
|
163308
|
+
const filterIDs = (keep, insert) => {
|
|
163309
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
163310
|
+
for (const id of keep) {
|
|
163303
163311
|
if (!id) {
|
|
163304
163312
|
continue;
|
|
163305
163313
|
}
|
|
163306
163314
|
const { value: node } = this.storage.get(id, "node");
|
|
163307
|
-
if (
|
|
163315
|
+
if (!node) {
|
|
163308
163316
|
continue;
|
|
163309
163317
|
}
|
|
163310
|
-
|
|
163318
|
+
const nodeID = this.storage.get(node, "id");
|
|
163319
|
+
if (!nodeID) {
|
|
163311
163320
|
continue;
|
|
163312
163321
|
}
|
|
163313
|
-
|
|
163322
|
+
existingIDs.add(nodeID.value);
|
|
163314
163323
|
}
|
|
163315
|
-
|
|
163324
|
+
return insert.filter((id) => {
|
|
163316
163325
|
if (!id) {
|
|
163317
163326
|
return true;
|
|
163318
163327
|
}
|
|
163319
|
-
const { value:
|
|
163320
|
-
|
|
163321
|
-
|
|
163322
|
-
return false;
|
|
163328
|
+
const { value: node } = this.storage.get(id, "node");
|
|
163329
|
+
if (!node) {
|
|
163330
|
+
return true;
|
|
163323
163331
|
}
|
|
163324
|
-
|
|
163332
|
+
const nodeID = this.storage.get(node, "id");
|
|
163333
|
+
if (!nodeID) {
|
|
163334
|
+
return true;
|
|
163335
|
+
}
|
|
163336
|
+
return !existingIDs.has(nodeID.value);
|
|
163325
163337
|
});
|
|
163326
|
-
}
|
|
163338
|
+
};
|
|
163327
163339
|
for (const update of applyUpdates) {
|
|
163328
163340
|
if (update !== "replace" && !updates.includes(update)) {
|
|
163329
163341
|
continue;
|
|
163330
163342
|
}
|
|
163331
163343
|
if (update === "prepend") {
|
|
163332
|
-
linkedIDs = newIDs.concat(
|
|
163344
|
+
linkedIDs = newIDs.concat(
|
|
163345
|
+
filterIDs(newIDs, oldIDs)
|
|
163346
|
+
);
|
|
163333
163347
|
if (layer?.optimistic) {
|
|
163334
163348
|
action = () => {
|
|
163335
163349
|
for (const id of newIDs) {
|
|
@@ -163340,7 +163354,7 @@ var CacheInternal2 = class {
|
|
|
163340
163354
|
};
|
|
163341
163355
|
}
|
|
163342
163356
|
} else if (update === "append") {
|
|
163343
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
163357
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
163344
163358
|
if (layer?.optimistic) {
|
|
163345
163359
|
action = () => {
|
|
163346
163360
|
for (const id of newIDs) {
|
package/build/test-cjs/index.js
CHANGED
|
@@ -87148,20 +87148,21 @@ var CacheInternal = class {
|
|
|
87148
87148
|
} else if (Array.isArray(value) && // make typescript happy
|
|
87149
87149
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
87150
87150
|
let oldIDs = [...previousValue || []];
|
|
87151
|
-
|
|
87152
|
-
|
|
87153
|
-
|
|
87154
|
-
|
|
87155
|
-
|
|
87156
|
-
|
|
87157
|
-
|
|
87158
|
-
|
|
87159
|
-
|
|
87160
|
-
|
|
87161
|
-
|
|
87162
|
-
|
|
87163
|
-
|
|
87164
|
-
|
|
87151
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
87152
|
+
oldIDs = oldIDs.filter((id) => {
|
|
87153
|
+
for (const layer2 of this.storage.data) {
|
|
87154
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
87155
|
+
if (operation.fields?.[key])
|
|
87156
|
+
for (const listOperation of operation.fields[key]) {
|
|
87157
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
87158
|
+
return false;
|
|
87159
|
+
}
|
|
87160
|
+
}
|
|
87161
|
+
}
|
|
87162
|
+
}
|
|
87163
|
+
return true;
|
|
87164
|
+
});
|
|
87165
|
+
}
|
|
87165
87166
|
let linkedIDs = [];
|
|
87166
87167
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
87167
87168
|
value,
|
|
@@ -87180,39 +87181,45 @@ var CacheInternal = class {
|
|
|
87180
87181
|
layer.writeLink(parent2, key, linkedIDs);
|
|
87181
87182
|
};
|
|
87182
87183
|
if (applyUpdates && updates) {
|
|
87183
|
-
|
|
87184
|
-
const
|
|
87185
|
-
for (const id of
|
|
87184
|
+
const filterIDs = (keep, insert) => {
|
|
87185
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
87186
|
+
for (const id of keep) {
|
|
87186
87187
|
if (!id) {
|
|
87187
87188
|
continue;
|
|
87188
87189
|
}
|
|
87189
87190
|
const { value: node } = this.storage.get(id, "node");
|
|
87190
|
-
if (
|
|
87191
|
+
if (!node) {
|
|
87191
87192
|
continue;
|
|
87192
87193
|
}
|
|
87193
|
-
|
|
87194
|
+
const nodeID = this.storage.get(node, "id");
|
|
87195
|
+
if (!nodeID) {
|
|
87194
87196
|
continue;
|
|
87195
87197
|
}
|
|
87196
|
-
|
|
87198
|
+
existingIDs.add(nodeID.value);
|
|
87197
87199
|
}
|
|
87198
|
-
|
|
87200
|
+
return insert.filter((id) => {
|
|
87199
87201
|
if (!id) {
|
|
87200
87202
|
return true;
|
|
87201
87203
|
}
|
|
87202
|
-
const { value:
|
|
87203
|
-
|
|
87204
|
-
|
|
87205
|
-
return false;
|
|
87204
|
+
const { value: node } = this.storage.get(id, "node");
|
|
87205
|
+
if (!node) {
|
|
87206
|
+
return true;
|
|
87206
87207
|
}
|
|
87207
|
-
|
|
87208
|
+
const nodeID = this.storage.get(node, "id");
|
|
87209
|
+
if (!nodeID) {
|
|
87210
|
+
return true;
|
|
87211
|
+
}
|
|
87212
|
+
return !existingIDs.has(nodeID.value);
|
|
87208
87213
|
});
|
|
87209
|
-
}
|
|
87214
|
+
};
|
|
87210
87215
|
for (const update of applyUpdates) {
|
|
87211
87216
|
if (update !== "replace" && !updates.includes(update)) {
|
|
87212
87217
|
continue;
|
|
87213
87218
|
}
|
|
87214
87219
|
if (update === "prepend") {
|
|
87215
|
-
linkedIDs = newIDs.concat(
|
|
87220
|
+
linkedIDs = newIDs.concat(
|
|
87221
|
+
filterIDs(newIDs, oldIDs)
|
|
87222
|
+
);
|
|
87216
87223
|
if (layer?.optimistic) {
|
|
87217
87224
|
action = () => {
|
|
87218
87225
|
for (const id of newIDs) {
|
|
@@ -87223,7 +87230,7 @@ var CacheInternal = class {
|
|
|
87223
87230
|
};
|
|
87224
87231
|
}
|
|
87225
87232
|
} else if (update === "append") {
|
|
87226
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
87233
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
87227
87234
|
if (layer?.optimistic) {
|
|
87228
87235
|
action = () => {
|
|
87229
87236
|
for (const id of newIDs) {
|
|
@@ -152669,20 +152676,21 @@ var CacheInternal2 = class {
|
|
|
152669
152676
|
} else if (Array.isArray(value) && // make typescript happy
|
|
152670
152677
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
152671
152678
|
let oldIDs = [...previousValue || []];
|
|
152672
|
-
|
|
152673
|
-
|
|
152674
|
-
|
|
152675
|
-
|
|
152676
|
-
|
|
152677
|
-
|
|
152678
|
-
|
|
152679
|
-
|
|
152680
|
-
|
|
152681
|
-
|
|
152682
|
-
|
|
152683
|
-
|
|
152684
|
-
|
|
152685
|
-
|
|
152679
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
152680
|
+
oldIDs = oldIDs.filter((id) => {
|
|
152681
|
+
for (const layer2 of this.storage.data) {
|
|
152682
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
152683
|
+
if (operation.fields?.[key])
|
|
152684
|
+
for (const listOperation of operation.fields[key]) {
|
|
152685
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
152686
|
+
return false;
|
|
152687
|
+
}
|
|
152688
|
+
}
|
|
152689
|
+
}
|
|
152690
|
+
}
|
|
152691
|
+
return true;
|
|
152692
|
+
});
|
|
152693
|
+
}
|
|
152686
152694
|
let linkedIDs = [];
|
|
152687
152695
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
152688
152696
|
value,
|
|
@@ -152701,39 +152709,45 @@ var CacheInternal2 = class {
|
|
|
152701
152709
|
layer.writeLink(parent2, key, linkedIDs);
|
|
152702
152710
|
};
|
|
152703
152711
|
if (applyUpdates && updates) {
|
|
152704
|
-
|
|
152705
|
-
const
|
|
152706
|
-
for (const id of
|
|
152712
|
+
const filterIDs = (keep, insert) => {
|
|
152713
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
152714
|
+
for (const id of keep) {
|
|
152707
152715
|
if (!id) {
|
|
152708
152716
|
continue;
|
|
152709
152717
|
}
|
|
152710
152718
|
const { value: node } = this.storage.get(id, "node");
|
|
152711
|
-
if (
|
|
152719
|
+
if (!node) {
|
|
152712
152720
|
continue;
|
|
152713
152721
|
}
|
|
152714
|
-
|
|
152722
|
+
const nodeID = this.storage.get(node, "id");
|
|
152723
|
+
if (!nodeID) {
|
|
152715
152724
|
continue;
|
|
152716
152725
|
}
|
|
152717
|
-
|
|
152726
|
+
existingIDs.add(nodeID.value);
|
|
152718
152727
|
}
|
|
152719
|
-
|
|
152728
|
+
return insert.filter((id) => {
|
|
152720
152729
|
if (!id) {
|
|
152721
152730
|
return true;
|
|
152722
152731
|
}
|
|
152723
|
-
const { value:
|
|
152724
|
-
|
|
152725
|
-
|
|
152726
|
-
return false;
|
|
152732
|
+
const { value: node } = this.storage.get(id, "node");
|
|
152733
|
+
if (!node) {
|
|
152734
|
+
return true;
|
|
152727
152735
|
}
|
|
152728
|
-
|
|
152736
|
+
const nodeID = this.storage.get(node, "id");
|
|
152737
|
+
if (!nodeID) {
|
|
152738
|
+
return true;
|
|
152739
|
+
}
|
|
152740
|
+
return !existingIDs.has(nodeID.value);
|
|
152729
152741
|
});
|
|
152730
|
-
}
|
|
152742
|
+
};
|
|
152731
152743
|
for (const update of applyUpdates) {
|
|
152732
152744
|
if (update !== "replace" && !updates.includes(update)) {
|
|
152733
152745
|
continue;
|
|
152734
152746
|
}
|
|
152735
152747
|
if (update === "prepend") {
|
|
152736
|
-
linkedIDs = newIDs.concat(
|
|
152748
|
+
linkedIDs = newIDs.concat(
|
|
152749
|
+
filterIDs(newIDs, oldIDs)
|
|
152750
|
+
);
|
|
152737
152751
|
if (layer?.optimistic) {
|
|
152738
152752
|
action = () => {
|
|
152739
152753
|
for (const id of newIDs) {
|
|
@@ -152744,7 +152758,7 @@ var CacheInternal2 = class {
|
|
|
152744
152758
|
};
|
|
152745
152759
|
}
|
|
152746
152760
|
} else if (update === "append") {
|
|
152747
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
152761
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
152748
152762
|
if (layer?.optimistic) {
|
|
152749
152763
|
action = () => {
|
|
152750
152764
|
for (const id of newIDs) {
|
|
@@ -225789,20 +225803,21 @@ var CacheInternal3 = class {
|
|
|
225789
225803
|
} else if (Array.isArray(value) && // make typescript happy
|
|
225790
225804
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
225791
225805
|
let oldIDs = [...previousValue || []];
|
|
225792
|
-
|
|
225793
|
-
|
|
225794
|
-
|
|
225795
|
-
|
|
225796
|
-
|
|
225797
|
-
|
|
225798
|
-
|
|
225799
|
-
|
|
225800
|
-
|
|
225801
|
-
|
|
225802
|
-
|
|
225803
|
-
|
|
225804
|
-
|
|
225805
|
-
|
|
225806
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
225807
|
+
oldIDs = oldIDs.filter((id) => {
|
|
225808
|
+
for (const layer2 of this.storage.data) {
|
|
225809
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
225810
|
+
if (operation.fields?.[key])
|
|
225811
|
+
for (const listOperation of operation.fields[key]) {
|
|
225812
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
225813
|
+
return false;
|
|
225814
|
+
}
|
|
225815
|
+
}
|
|
225816
|
+
}
|
|
225817
|
+
}
|
|
225818
|
+
return true;
|
|
225819
|
+
});
|
|
225820
|
+
}
|
|
225806
225821
|
let linkedIDs = [];
|
|
225807
225822
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
225808
225823
|
value,
|
|
@@ -225821,39 +225836,45 @@ var CacheInternal3 = class {
|
|
|
225821
225836
|
layer.writeLink(parent2, key, linkedIDs);
|
|
225822
225837
|
};
|
|
225823
225838
|
if (applyUpdates && updates) {
|
|
225824
|
-
|
|
225825
|
-
const
|
|
225826
|
-
for (const id of
|
|
225839
|
+
const filterIDs = (keep, insert) => {
|
|
225840
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
225841
|
+
for (const id of keep) {
|
|
225827
225842
|
if (!id) {
|
|
225828
225843
|
continue;
|
|
225829
225844
|
}
|
|
225830
225845
|
const { value: node } = this.storage.get(id, "node");
|
|
225831
|
-
if (
|
|
225846
|
+
if (!node) {
|
|
225832
225847
|
continue;
|
|
225833
225848
|
}
|
|
225834
|
-
|
|
225849
|
+
const nodeID = this.storage.get(node, "id");
|
|
225850
|
+
if (!nodeID) {
|
|
225835
225851
|
continue;
|
|
225836
225852
|
}
|
|
225837
|
-
|
|
225853
|
+
existingIDs.add(nodeID.value);
|
|
225838
225854
|
}
|
|
225839
|
-
|
|
225855
|
+
return insert.filter((id) => {
|
|
225840
225856
|
if (!id) {
|
|
225841
225857
|
return true;
|
|
225842
225858
|
}
|
|
225843
|
-
const { value:
|
|
225844
|
-
|
|
225845
|
-
|
|
225846
|
-
return false;
|
|
225859
|
+
const { value: node } = this.storage.get(id, "node");
|
|
225860
|
+
if (!node) {
|
|
225861
|
+
return true;
|
|
225847
225862
|
}
|
|
225848
|
-
|
|
225863
|
+
const nodeID = this.storage.get(node, "id");
|
|
225864
|
+
if (!nodeID) {
|
|
225865
|
+
return true;
|
|
225866
|
+
}
|
|
225867
|
+
return !existingIDs.has(nodeID.value);
|
|
225849
225868
|
});
|
|
225850
|
-
}
|
|
225869
|
+
};
|
|
225851
225870
|
for (const update of applyUpdates) {
|
|
225852
225871
|
if (update !== "replace" && !updates.includes(update)) {
|
|
225853
225872
|
continue;
|
|
225854
225873
|
}
|
|
225855
225874
|
if (update === "prepend") {
|
|
225856
|
-
linkedIDs = newIDs.concat(
|
|
225875
|
+
linkedIDs = newIDs.concat(
|
|
225876
|
+
filterIDs(newIDs, oldIDs)
|
|
225877
|
+
);
|
|
225857
225878
|
if (layer?.optimistic) {
|
|
225858
225879
|
action = () => {
|
|
225859
225880
|
for (const id of newIDs) {
|
|
@@ -225864,7 +225885,7 @@ var CacheInternal3 = class {
|
|
|
225864
225885
|
};
|
|
225865
225886
|
}
|
|
225866
225887
|
} else if (update === "append") {
|
|
225867
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
225888
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
225868
225889
|
if (layer?.optimistic) {
|
|
225869
225890
|
action = () => {
|
|
225870
225891
|
for (const id of newIDs) {
|
|
@@ -298587,20 +298608,21 @@ var CacheInternal4 = class {
|
|
|
298587
298608
|
} else if (Array.isArray(value) && // make typescript happy
|
|
298588
298609
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
298589
298610
|
let oldIDs = [...previousValue || []];
|
|
298590
|
-
|
|
298591
|
-
|
|
298592
|
-
|
|
298593
|
-
|
|
298594
|
-
|
|
298595
|
-
|
|
298596
|
-
|
|
298597
|
-
|
|
298598
|
-
|
|
298599
|
-
|
|
298600
|
-
|
|
298601
|
-
|
|
298602
|
-
|
|
298603
|
-
|
|
298611
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
298612
|
+
oldIDs = oldIDs.filter((id) => {
|
|
298613
|
+
for (const layer2 of this.storage.data) {
|
|
298614
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
298615
|
+
if (operation.fields?.[key])
|
|
298616
|
+
for (const listOperation of operation.fields[key]) {
|
|
298617
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
298618
|
+
return false;
|
|
298619
|
+
}
|
|
298620
|
+
}
|
|
298621
|
+
}
|
|
298622
|
+
}
|
|
298623
|
+
return true;
|
|
298624
|
+
});
|
|
298625
|
+
}
|
|
298604
298626
|
let linkedIDs = [];
|
|
298605
298627
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
298606
298628
|
value,
|
|
@@ -298619,39 +298641,45 @@ var CacheInternal4 = class {
|
|
|
298619
298641
|
layer.writeLink(parent2, key, linkedIDs);
|
|
298620
298642
|
};
|
|
298621
298643
|
if (applyUpdates && updates) {
|
|
298622
|
-
|
|
298623
|
-
const
|
|
298624
|
-
for (const id of
|
|
298644
|
+
const filterIDs = (keep, insert) => {
|
|
298645
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
298646
|
+
for (const id of keep) {
|
|
298625
298647
|
if (!id) {
|
|
298626
298648
|
continue;
|
|
298627
298649
|
}
|
|
298628
298650
|
const { value: node } = this.storage.get(id, "node");
|
|
298629
|
-
if (
|
|
298651
|
+
if (!node) {
|
|
298630
298652
|
continue;
|
|
298631
298653
|
}
|
|
298632
|
-
|
|
298654
|
+
const nodeID = this.storage.get(node, "id");
|
|
298655
|
+
if (!nodeID) {
|
|
298633
298656
|
continue;
|
|
298634
298657
|
}
|
|
298635
|
-
|
|
298658
|
+
existingIDs.add(nodeID.value);
|
|
298636
298659
|
}
|
|
298637
|
-
|
|
298660
|
+
return insert.filter((id) => {
|
|
298638
298661
|
if (!id) {
|
|
298639
298662
|
return true;
|
|
298640
298663
|
}
|
|
298641
|
-
const { value:
|
|
298642
|
-
|
|
298643
|
-
|
|
298644
|
-
return false;
|
|
298664
|
+
const { value: node } = this.storage.get(id, "node");
|
|
298665
|
+
if (!node) {
|
|
298666
|
+
return true;
|
|
298645
298667
|
}
|
|
298646
|
-
|
|
298668
|
+
const nodeID = this.storage.get(node, "id");
|
|
298669
|
+
if (!nodeID) {
|
|
298670
|
+
return true;
|
|
298671
|
+
}
|
|
298672
|
+
return !existingIDs.has(nodeID.value);
|
|
298647
298673
|
});
|
|
298648
|
-
}
|
|
298674
|
+
};
|
|
298649
298675
|
for (const update of applyUpdates) {
|
|
298650
298676
|
if (update !== "replace" && !updates.includes(update)) {
|
|
298651
298677
|
continue;
|
|
298652
298678
|
}
|
|
298653
298679
|
if (update === "prepend") {
|
|
298654
|
-
linkedIDs = newIDs.concat(
|
|
298680
|
+
linkedIDs = newIDs.concat(
|
|
298681
|
+
filterIDs(newIDs, oldIDs)
|
|
298682
|
+
);
|
|
298655
298683
|
if (layer?.optimistic) {
|
|
298656
298684
|
action = () => {
|
|
298657
298685
|
for (const id of newIDs) {
|
|
@@ -298662,7 +298690,7 @@ var CacheInternal4 = class {
|
|
|
298662
298690
|
};
|
|
298663
298691
|
}
|
|
298664
298692
|
} else if (update === "append") {
|
|
298665
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
298693
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
298666
298694
|
if (layer?.optimistic) {
|
|
298667
298695
|
action = () => {
|
|
298668
298696
|
for (const id of newIDs) {
|