houdini-svelte 1.2.53 → 1.2.55
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/fsPatch.d.ts +1 -1
- package/build/plugin-cjs/index.js +296 -127
- package/build/plugin-esm/index.js +296 -127
- package/build/preprocess-cjs/index.js +274 -112
- package/build/preprocess-esm/index.js +274 -112
- package/build/test-cjs/index.js +570 -239
- package/build/test-esm/index.js +570 -239
- package/package.json +2 -2
|
@@ -79165,6 +79165,33 @@ var GarbageCollector = class {
|
|
|
79165
79165
|
}
|
|
79166
79166
|
}
|
|
79167
79167
|
};
|
|
79168
|
+
function evaluateKey(key, variables = null) {
|
|
79169
|
+
let evaluated = "";
|
|
79170
|
+
let varName = "";
|
|
79171
|
+
let inString = false;
|
|
79172
|
+
for (const char of key) {
|
|
79173
|
+
if (varName) {
|
|
79174
|
+
if (varChars.includes(char)) {
|
|
79175
|
+
varName += char;
|
|
79176
|
+
continue;
|
|
79177
|
+
}
|
|
79178
|
+
const value2 = variables?.[varName.slice(1)];
|
|
79179
|
+
evaluated += typeof value2 !== "undefined" ? JSON.stringify(value2) : "undefined";
|
|
79180
|
+
varName = "";
|
|
79181
|
+
}
|
|
79182
|
+
if (char === "$" && !inString) {
|
|
79183
|
+
varName = "$";
|
|
79184
|
+
continue;
|
|
79185
|
+
}
|
|
79186
|
+
if (char === '"') {
|
|
79187
|
+
inString = !inString;
|
|
79188
|
+
}
|
|
79189
|
+
evaluated += char;
|
|
79190
|
+
}
|
|
79191
|
+
return evaluated;
|
|
79192
|
+
}
|
|
79193
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
79194
|
+
var rootID = "_ROOT_";
|
|
79168
79195
|
var ListManager = class {
|
|
79169
79196
|
rootID;
|
|
79170
79197
|
cache;
|
|
@@ -79230,11 +79257,15 @@ var ListManager = class {
|
|
|
79230
79257
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
79231
79258
|
}
|
|
79232
79259
|
removeIDFromAllLists(id2, layer) {
|
|
79260
|
+
let removed = false;
|
|
79233
79261
|
for (const fieldMap of this.lists.values()) {
|
|
79234
79262
|
for (const list of fieldMap.values()) {
|
|
79235
|
-
list.removeID(id2, void 0, layer)
|
|
79263
|
+
if (list.removeID(id2, void 0, layer)) {
|
|
79264
|
+
removed = true;
|
|
79265
|
+
}
|
|
79236
79266
|
}
|
|
79237
79267
|
}
|
|
79268
|
+
return removed;
|
|
79238
79269
|
}
|
|
79239
79270
|
deleteField(parentID, field) {
|
|
79240
79271
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -79537,7 +79568,13 @@ var ListCollection = class {
|
|
|
79537
79568
|
this.lists.forEach((list) => list.addToList(...args));
|
|
79538
79569
|
}
|
|
79539
79570
|
removeID(...args) {
|
|
79540
|
-
|
|
79571
|
+
let removed = false;
|
|
79572
|
+
this.lists.forEach((list) => {
|
|
79573
|
+
if (list.removeID(...args)) {
|
|
79574
|
+
removed = true;
|
|
79575
|
+
}
|
|
79576
|
+
});
|
|
79577
|
+
return removed;
|
|
79541
79578
|
}
|
|
79542
79579
|
remove(...args) {
|
|
79543
79580
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -79652,6 +79689,7 @@ var InMemoryStorage = class {
|
|
|
79652
79689
|
}
|
|
79653
79690
|
registerIDMapping(from, to) {
|
|
79654
79691
|
this.idMaps[from] = to;
|
|
79692
|
+
this.idMaps[to] = from;
|
|
79655
79693
|
}
|
|
79656
79694
|
createLayer(optimistic = false) {
|
|
79657
79695
|
const layer = new Layer(this.idCount++);
|
|
@@ -79662,11 +79700,11 @@ var InMemoryStorage = class {
|
|
|
79662
79700
|
insert(id2, field, location, target) {
|
|
79663
79701
|
return this.topLayer.insert(id2, field, location, target);
|
|
79664
79702
|
}
|
|
79665
|
-
remove(id2, field, target,
|
|
79666
|
-
return
|
|
79703
|
+
remove(id2, field, target, layer = this.topLayer) {
|
|
79704
|
+
return layer.remove(id2, field, target);
|
|
79667
79705
|
}
|
|
79668
|
-
delete(id2,
|
|
79669
|
-
return
|
|
79706
|
+
delete(id2, layer = this.topLayer) {
|
|
79707
|
+
return layer.delete(id2);
|
|
79670
79708
|
}
|
|
79671
79709
|
deleteField(id2, field) {
|
|
79672
79710
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -79704,6 +79742,9 @@ var InMemoryStorage = class {
|
|
|
79704
79742
|
return;
|
|
79705
79743
|
}
|
|
79706
79744
|
operations.remove.add(v);
|
|
79745
|
+
if (this.idMaps[v]) {
|
|
79746
|
+
operations.remove.add(this.idMaps[v]);
|
|
79747
|
+
}
|
|
79707
79748
|
});
|
|
79708
79749
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
79709
79750
|
const targetLayer = this.topLayer;
|
|
@@ -79730,7 +79771,11 @@ var InMemoryStorage = class {
|
|
|
79730
79771
|
operations.remove.add(op.id);
|
|
79731
79772
|
}
|
|
79732
79773
|
if (isInsertOperation(op)) {
|
|
79733
|
-
|
|
79774
|
+
if (op.location === OperationLocation.end) {
|
|
79775
|
+
operations.insert[op.location].unshift(op.id);
|
|
79776
|
+
} else {
|
|
79777
|
+
operations.insert[op.location].push(op.id);
|
|
79778
|
+
}
|
|
79734
79779
|
}
|
|
79735
79780
|
if (isDeleteOperation(op)) {
|
|
79736
79781
|
return {
|
|
@@ -79976,7 +80021,7 @@ var Layer = class {
|
|
|
79976
80021
|
}
|
|
79977
80022
|
for (const [id2, ops] of Object.entries(layer.operations)) {
|
|
79978
80023
|
const fields = {};
|
|
79979
|
-
for (const opMap of [
|
|
80024
|
+
for (const opMap of [layer.operations[id2], this.operations[id2]].filter(Boolean)) {
|
|
79980
80025
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
79981
80026
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
79982
80027
|
}
|
|
@@ -80040,32 +80085,6 @@ var OperationKind = {
|
|
|
80040
80085
|
insert: "insert",
|
|
80041
80086
|
remove: "remove"
|
|
80042
80087
|
};
|
|
80043
|
-
function evaluateKey(key, variables = null) {
|
|
80044
|
-
let evaluated = "";
|
|
80045
|
-
let varName = "";
|
|
80046
|
-
let inString = false;
|
|
80047
|
-
for (const char of key) {
|
|
80048
|
-
if (varName) {
|
|
80049
|
-
if (varChars.includes(char)) {
|
|
80050
|
-
varName += char;
|
|
80051
|
-
continue;
|
|
80052
|
-
}
|
|
80053
|
-
const value2 = variables?.[varName.slice(1)];
|
|
80054
|
-
evaluated += typeof value2 !== "undefined" ? JSON.stringify(value2) : "undefined";
|
|
80055
|
-
varName = "";
|
|
80056
|
-
}
|
|
80057
|
-
if (char === "$" && !inString) {
|
|
80058
|
-
varName = "$";
|
|
80059
|
-
continue;
|
|
80060
|
-
}
|
|
80061
|
-
if (char === '"') {
|
|
80062
|
-
inString = !inString;
|
|
80063
|
-
}
|
|
80064
|
-
evaluated += char;
|
|
80065
|
-
}
|
|
80066
|
-
return evaluated;
|
|
80067
|
-
}
|
|
80068
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
80069
80088
|
var InMemorySubscriptions = class {
|
|
80070
80089
|
cache;
|
|
80071
80090
|
constructor(cache) {
|
|
@@ -80076,6 +80095,9 @@ var InMemorySubscriptions = class {
|
|
|
80076
80095
|
activeFields(parent2) {
|
|
80077
80096
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
80078
80097
|
}
|
|
80098
|
+
copySubscribers(from, to) {
|
|
80099
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
80100
|
+
}
|
|
80079
80101
|
add({
|
|
80080
80102
|
parent: parent2,
|
|
80081
80103
|
spec,
|
|
@@ -80258,6 +80280,11 @@ var InMemorySubscriptions = class {
|
|
|
80258
80280
|
get(id2, field) {
|
|
80259
80281
|
return this.subscribers.get(id2)?.get(field)?.selections || [];
|
|
80260
80282
|
}
|
|
80283
|
+
getAll(id2) {
|
|
80284
|
+
return [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
80285
|
+
(fieldSub) => fieldSub.selections
|
|
80286
|
+
);
|
|
80287
|
+
}
|
|
80261
80288
|
remove(id2, selection, targets, variables, visited = []) {
|
|
80262
80289
|
visited.push(id2);
|
|
80263
80290
|
const linkedIDs = [];
|
|
@@ -80299,7 +80326,7 @@ var InMemorySubscriptions = class {
|
|
|
80299
80326
|
}
|
|
80300
80327
|
const subscriberField = subscriber.get(fieldName);
|
|
80301
80328
|
for (const spec of specs) {
|
|
80302
|
-
const counts =
|
|
80329
|
+
const counts = subscriberField?.referenceCounts;
|
|
80303
80330
|
if (!counts?.has(spec.set)) {
|
|
80304
80331
|
continue;
|
|
80305
80332
|
}
|
|
@@ -80322,24 +80349,23 @@ var InMemorySubscriptions = class {
|
|
|
80322
80349
|
this.subscribers.delete(id2);
|
|
80323
80350
|
}
|
|
80324
80351
|
}
|
|
80325
|
-
removeAllSubscribers(id2, targets
|
|
80326
|
-
|
|
80327
|
-
|
|
80328
|
-
|
|
80329
|
-
|
|
80330
|
-
|
|
80331
|
-
|
|
80332
|
-
|
|
80333
|
-
|
|
80334
|
-
|
|
80335
|
-
|
|
80336
|
-
|
|
80337
|
-
|
|
80338
|
-
|
|
80339
|
-
}
|
|
80340
|
-
this.removeAllSubscribers(id22, subscribers, visited);
|
|
80352
|
+
removeAllSubscribers(id2, targets) {
|
|
80353
|
+
if (!targets) {
|
|
80354
|
+
targets = [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
80355
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
80356
|
+
);
|
|
80357
|
+
}
|
|
80358
|
+
for (const target of targets) {
|
|
80359
|
+
for (const subselection of this.findSubSelections(
|
|
80360
|
+
target.parentID || rootID,
|
|
80361
|
+
target.selection,
|
|
80362
|
+
target.variables || {},
|
|
80363
|
+
id2
|
|
80364
|
+
)) {
|
|
80365
|
+
this.remove(id2, subselection, targets, target.variables || {});
|
|
80341
80366
|
}
|
|
80342
80367
|
}
|
|
80368
|
+
return;
|
|
80343
80369
|
}
|
|
80344
80370
|
get size() {
|
|
80345
80371
|
let size = 0;
|
|
@@ -80350,6 +80376,32 @@ var InMemorySubscriptions = class {
|
|
|
80350
80376
|
}
|
|
80351
80377
|
return size;
|
|
80352
80378
|
}
|
|
80379
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
80380
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
80381
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
80382
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
80383
|
+
if (!fieldSelection.selection) {
|
|
80384
|
+
continue;
|
|
80385
|
+
}
|
|
80386
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
80387
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
80388
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
80389
|
+
if (links.includes(searchTarget)) {
|
|
80390
|
+
selections.push(fieldSelection.selection);
|
|
80391
|
+
} else {
|
|
80392
|
+
for (const link of links) {
|
|
80393
|
+
this.findSubSelections(
|
|
80394
|
+
link,
|
|
80395
|
+
fieldSelection.selection,
|
|
80396
|
+
variables,
|
|
80397
|
+
searchTarget,
|
|
80398
|
+
selections
|
|
80399
|
+
);
|
|
80400
|
+
}
|
|
80401
|
+
}
|
|
80402
|
+
}
|
|
80403
|
+
return selections;
|
|
80404
|
+
}
|
|
80353
80405
|
};
|
|
80354
80406
|
var Cache = class {
|
|
80355
80407
|
_internal_unstable;
|
|
@@ -80425,11 +80477,17 @@ var Cache = class {
|
|
|
80425
80477
|
}
|
|
80426
80478
|
registerKeyMap(source, mapped) {
|
|
80427
80479
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
80480
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
80428
80481
|
}
|
|
80429
80482
|
delete(id2, layer) {
|
|
80430
|
-
this._internal_unstable.
|
|
80431
|
-
|
|
80432
|
-
|
|
80483
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id2], id2].filter(
|
|
80484
|
+
Boolean
|
|
80485
|
+
);
|
|
80486
|
+
for (const recordID of recordIDs) {
|
|
80487
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
80488
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
80489
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
80490
|
+
}
|
|
80433
80491
|
}
|
|
80434
80492
|
setConfig(config2) {
|
|
80435
80493
|
this._internal_unstable.setConfig(config2);
|
|
@@ -80735,6 +80793,9 @@ var CacheInternal = class {
|
|
|
80735
80793
|
layer,
|
|
80736
80794
|
forceNotify
|
|
80737
80795
|
});
|
|
80796
|
+
let action = () => {
|
|
80797
|
+
layer.writeLink(parent2, key, linkedIDs);
|
|
80798
|
+
};
|
|
80738
80799
|
if (applyUpdates && updates) {
|
|
80739
80800
|
if (key === "edges") {
|
|
80740
80801
|
const newNodeIDs = [];
|
|
@@ -80769,8 +80830,26 @@ var CacheInternal = class {
|
|
|
80769
80830
|
}
|
|
80770
80831
|
if (update === "prepend") {
|
|
80771
80832
|
linkedIDs = newIDs.concat(oldIDs);
|
|
80833
|
+
if (layer?.optimistic) {
|
|
80834
|
+
action = () => {
|
|
80835
|
+
for (const id2 of newIDs) {
|
|
80836
|
+
if (id2) {
|
|
80837
|
+
layer.insert(parent2, key, "start", id2);
|
|
80838
|
+
}
|
|
80839
|
+
}
|
|
80840
|
+
};
|
|
80841
|
+
}
|
|
80772
80842
|
} else if (update === "append") {
|
|
80773
80843
|
linkedIDs = oldIDs.concat(newIDs);
|
|
80844
|
+
if (layer?.optimistic) {
|
|
80845
|
+
action = () => {
|
|
80846
|
+
for (const id2 of newIDs) {
|
|
80847
|
+
if (id2) {
|
|
80848
|
+
layer.insert(parent2, key, "end", id2);
|
|
80849
|
+
}
|
|
80850
|
+
}
|
|
80851
|
+
};
|
|
80852
|
+
}
|
|
80774
80853
|
} else if (update === "replace") {
|
|
80775
80854
|
linkedIDs = newIDs;
|
|
80776
80855
|
}
|
|
@@ -80789,7 +80868,7 @@ var CacheInternal = class {
|
|
|
80789
80868
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
80790
80869
|
}
|
|
80791
80870
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
80792
|
-
|
|
80871
|
+
action();
|
|
80793
80872
|
}
|
|
80794
80873
|
for (const id2 of newIDs.filter((id22) => !oldIDs.includes(id22))) {
|
|
80795
80874
|
if (id2 == null) {
|
|
@@ -80844,6 +80923,9 @@ var CacheInternal = class {
|
|
|
80844
80923
|
if (!targetID) {
|
|
80845
80924
|
continue;
|
|
80846
80925
|
}
|
|
80926
|
+
toNotify.push(
|
|
80927
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
80928
|
+
);
|
|
80847
80929
|
this.cache.delete(targetID, layer);
|
|
80848
80930
|
}
|
|
80849
80931
|
}
|
|
@@ -81265,7 +81347,6 @@ function variableValue(value2, args) {
|
|
|
81265
81347
|
);
|
|
81266
81348
|
}
|
|
81267
81349
|
}
|
|
81268
|
-
var rootID = "_ROOT_";
|
|
81269
81350
|
function defaultComponentField({
|
|
81270
81351
|
cache,
|
|
81271
81352
|
component,
|
|
@@ -172686,6 +172767,33 @@ var GarbageCollector2 = class {
|
|
|
172686
172767
|
}
|
|
172687
172768
|
}
|
|
172688
172769
|
};
|
|
172770
|
+
function evaluateKey2(key, variables = null) {
|
|
172771
|
+
let evaluated = "";
|
|
172772
|
+
let varName = "";
|
|
172773
|
+
let inString = false;
|
|
172774
|
+
for (const char of key) {
|
|
172775
|
+
if (varName) {
|
|
172776
|
+
if (varChars2.includes(char)) {
|
|
172777
|
+
varName += char;
|
|
172778
|
+
continue;
|
|
172779
|
+
}
|
|
172780
|
+
const value2 = variables?.[varName.slice(1)];
|
|
172781
|
+
evaluated += typeof value2 !== "undefined" ? JSON.stringify(value2) : "undefined";
|
|
172782
|
+
varName = "";
|
|
172783
|
+
}
|
|
172784
|
+
if (char === "$" && !inString) {
|
|
172785
|
+
varName = "$";
|
|
172786
|
+
continue;
|
|
172787
|
+
}
|
|
172788
|
+
if (char === '"') {
|
|
172789
|
+
inString = !inString;
|
|
172790
|
+
}
|
|
172791
|
+
evaluated += char;
|
|
172792
|
+
}
|
|
172793
|
+
return evaluated;
|
|
172794
|
+
}
|
|
172795
|
+
var varChars2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
172796
|
+
var rootID2 = "_ROOT_";
|
|
172689
172797
|
var ListManager2 = class {
|
|
172690
172798
|
rootID;
|
|
172691
172799
|
cache;
|
|
@@ -172751,11 +172859,15 @@ var ListManager2 = class {
|
|
|
172751
172859
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
172752
172860
|
}
|
|
172753
172861
|
removeIDFromAllLists(id2, layer) {
|
|
172862
|
+
let removed = false;
|
|
172754
172863
|
for (const fieldMap of this.lists.values()) {
|
|
172755
172864
|
for (const list of fieldMap.values()) {
|
|
172756
|
-
list.removeID(id2, void 0, layer)
|
|
172865
|
+
if (list.removeID(id2, void 0, layer)) {
|
|
172866
|
+
removed = true;
|
|
172867
|
+
}
|
|
172757
172868
|
}
|
|
172758
172869
|
}
|
|
172870
|
+
return removed;
|
|
172759
172871
|
}
|
|
172760
172872
|
deleteField(parentID, field) {
|
|
172761
172873
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -173058,7 +173170,13 @@ var ListCollection2 = class {
|
|
|
173058
173170
|
this.lists.forEach((list) => list.addToList(...args));
|
|
173059
173171
|
}
|
|
173060
173172
|
removeID(...args) {
|
|
173061
|
-
|
|
173173
|
+
let removed = false;
|
|
173174
|
+
this.lists.forEach((list) => {
|
|
173175
|
+
if (list.removeID(...args)) {
|
|
173176
|
+
removed = true;
|
|
173177
|
+
}
|
|
173178
|
+
});
|
|
173179
|
+
return removed;
|
|
173062
173180
|
}
|
|
173063
173181
|
remove(...args) {
|
|
173064
173182
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -173173,6 +173291,7 @@ var InMemoryStorage2 = class {
|
|
|
173173
173291
|
}
|
|
173174
173292
|
registerIDMapping(from, to) {
|
|
173175
173293
|
this.idMaps[from] = to;
|
|
173294
|
+
this.idMaps[to] = from;
|
|
173176
173295
|
}
|
|
173177
173296
|
createLayer(optimistic = false) {
|
|
173178
173297
|
const layer = new Layer2(this.idCount++);
|
|
@@ -173183,11 +173302,11 @@ var InMemoryStorage2 = class {
|
|
|
173183
173302
|
insert(id2, field, location, target) {
|
|
173184
173303
|
return this.topLayer.insert(id2, field, location, target);
|
|
173185
173304
|
}
|
|
173186
|
-
remove(id2, field, target,
|
|
173187
|
-
return
|
|
173305
|
+
remove(id2, field, target, layer = this.topLayer) {
|
|
173306
|
+
return layer.remove(id2, field, target);
|
|
173188
173307
|
}
|
|
173189
|
-
delete(id2,
|
|
173190
|
-
return
|
|
173308
|
+
delete(id2, layer = this.topLayer) {
|
|
173309
|
+
return layer.delete(id2);
|
|
173191
173310
|
}
|
|
173192
173311
|
deleteField(id2, field) {
|
|
173193
173312
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -173225,6 +173344,9 @@ var InMemoryStorage2 = class {
|
|
|
173225
173344
|
return;
|
|
173226
173345
|
}
|
|
173227
173346
|
operations.remove.add(v);
|
|
173347
|
+
if (this.idMaps[v]) {
|
|
173348
|
+
operations.remove.add(this.idMaps[v]);
|
|
173349
|
+
}
|
|
173228
173350
|
});
|
|
173229
173351
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
173230
173352
|
const targetLayer = this.topLayer;
|
|
@@ -173251,7 +173373,11 @@ var InMemoryStorage2 = class {
|
|
|
173251
173373
|
operations.remove.add(op.id);
|
|
173252
173374
|
}
|
|
173253
173375
|
if (isInsertOperation2(op)) {
|
|
173254
|
-
|
|
173376
|
+
if (op.location === OperationLocation2.end) {
|
|
173377
|
+
operations.insert[op.location].unshift(op.id);
|
|
173378
|
+
} else {
|
|
173379
|
+
operations.insert[op.location].push(op.id);
|
|
173380
|
+
}
|
|
173255
173381
|
}
|
|
173256
173382
|
if (isDeleteOperation2(op)) {
|
|
173257
173383
|
return {
|
|
@@ -173497,7 +173623,7 @@ var Layer2 = class {
|
|
|
173497
173623
|
}
|
|
173498
173624
|
for (const [id2, ops] of Object.entries(layer.operations)) {
|
|
173499
173625
|
const fields = {};
|
|
173500
|
-
for (const opMap of [
|
|
173626
|
+
for (const opMap of [layer.operations[id2], this.operations[id2]].filter(Boolean)) {
|
|
173501
173627
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
173502
173628
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
173503
173629
|
}
|
|
@@ -173561,32 +173687,6 @@ var OperationKind2 = {
|
|
|
173561
173687
|
insert: "insert",
|
|
173562
173688
|
remove: "remove"
|
|
173563
173689
|
};
|
|
173564
|
-
function evaluateKey2(key, variables = null) {
|
|
173565
|
-
let evaluated = "";
|
|
173566
|
-
let varName = "";
|
|
173567
|
-
let inString = false;
|
|
173568
|
-
for (const char of key) {
|
|
173569
|
-
if (varName) {
|
|
173570
|
-
if (varChars2.includes(char)) {
|
|
173571
|
-
varName += char;
|
|
173572
|
-
continue;
|
|
173573
|
-
}
|
|
173574
|
-
const value2 = variables?.[varName.slice(1)];
|
|
173575
|
-
evaluated += typeof value2 !== "undefined" ? JSON.stringify(value2) : "undefined";
|
|
173576
|
-
varName = "";
|
|
173577
|
-
}
|
|
173578
|
-
if (char === "$" && !inString) {
|
|
173579
|
-
varName = "$";
|
|
173580
|
-
continue;
|
|
173581
|
-
}
|
|
173582
|
-
if (char === '"') {
|
|
173583
|
-
inString = !inString;
|
|
173584
|
-
}
|
|
173585
|
-
evaluated += char;
|
|
173586
|
-
}
|
|
173587
|
-
return evaluated;
|
|
173588
|
-
}
|
|
173589
|
-
var varChars2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
173590
173690
|
var InMemorySubscriptions2 = class {
|
|
173591
173691
|
cache;
|
|
173592
173692
|
constructor(cache) {
|
|
@@ -173597,6 +173697,9 @@ var InMemorySubscriptions2 = class {
|
|
|
173597
173697
|
activeFields(parent2) {
|
|
173598
173698
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
173599
173699
|
}
|
|
173700
|
+
copySubscribers(from, to) {
|
|
173701
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
173702
|
+
}
|
|
173600
173703
|
add({
|
|
173601
173704
|
parent: parent2,
|
|
173602
173705
|
spec,
|
|
@@ -173779,6 +173882,11 @@ var InMemorySubscriptions2 = class {
|
|
|
173779
173882
|
get(id2, field) {
|
|
173780
173883
|
return this.subscribers.get(id2)?.get(field)?.selections || [];
|
|
173781
173884
|
}
|
|
173885
|
+
getAll(id2) {
|
|
173886
|
+
return [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
173887
|
+
(fieldSub) => fieldSub.selections
|
|
173888
|
+
);
|
|
173889
|
+
}
|
|
173782
173890
|
remove(id2, selection, targets, variables, visited = []) {
|
|
173783
173891
|
visited.push(id2);
|
|
173784
173892
|
const linkedIDs = [];
|
|
@@ -173820,7 +173928,7 @@ var InMemorySubscriptions2 = class {
|
|
|
173820
173928
|
}
|
|
173821
173929
|
const subscriberField = subscriber.get(fieldName);
|
|
173822
173930
|
for (const spec of specs) {
|
|
173823
|
-
const counts =
|
|
173931
|
+
const counts = subscriberField?.referenceCounts;
|
|
173824
173932
|
if (!counts?.has(spec.set)) {
|
|
173825
173933
|
continue;
|
|
173826
173934
|
}
|
|
@@ -173843,24 +173951,23 @@ var InMemorySubscriptions2 = class {
|
|
|
173843
173951
|
this.subscribers.delete(id2);
|
|
173844
173952
|
}
|
|
173845
173953
|
}
|
|
173846
|
-
removeAllSubscribers(id2, targets
|
|
173847
|
-
|
|
173848
|
-
|
|
173849
|
-
|
|
173850
|
-
|
|
173851
|
-
|
|
173852
|
-
|
|
173853
|
-
|
|
173854
|
-
|
|
173855
|
-
|
|
173856
|
-
|
|
173857
|
-
|
|
173858
|
-
|
|
173859
|
-
|
|
173860
|
-
}
|
|
173861
|
-
this.removeAllSubscribers(id22, subscribers, visited);
|
|
173954
|
+
removeAllSubscribers(id2, targets) {
|
|
173955
|
+
if (!targets) {
|
|
173956
|
+
targets = [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
173957
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
173958
|
+
);
|
|
173959
|
+
}
|
|
173960
|
+
for (const target of targets) {
|
|
173961
|
+
for (const subselection of this.findSubSelections(
|
|
173962
|
+
target.parentID || rootID2,
|
|
173963
|
+
target.selection,
|
|
173964
|
+
target.variables || {},
|
|
173965
|
+
id2
|
|
173966
|
+
)) {
|
|
173967
|
+
this.remove(id2, subselection, targets, target.variables || {});
|
|
173862
173968
|
}
|
|
173863
173969
|
}
|
|
173970
|
+
return;
|
|
173864
173971
|
}
|
|
173865
173972
|
get size() {
|
|
173866
173973
|
let size = 0;
|
|
@@ -173871,6 +173978,32 @@ var InMemorySubscriptions2 = class {
|
|
|
173871
173978
|
}
|
|
173872
173979
|
return size;
|
|
173873
173980
|
}
|
|
173981
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
173982
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
173983
|
+
let targetSelection = getFieldsForType2(selection, __typename, false);
|
|
173984
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
173985
|
+
if (!fieldSelection.selection) {
|
|
173986
|
+
continue;
|
|
173987
|
+
}
|
|
173988
|
+
const key = evaluateKey2(fieldSelection.keyRaw, variables || {});
|
|
173989
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
173990
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten2(linkedRecord.value);
|
|
173991
|
+
if (links.includes(searchTarget)) {
|
|
173992
|
+
selections.push(fieldSelection.selection);
|
|
173993
|
+
} else {
|
|
173994
|
+
for (const link of links) {
|
|
173995
|
+
this.findSubSelections(
|
|
173996
|
+
link,
|
|
173997
|
+
fieldSelection.selection,
|
|
173998
|
+
variables,
|
|
173999
|
+
searchTarget,
|
|
174000
|
+
selections
|
|
174001
|
+
);
|
|
174002
|
+
}
|
|
174003
|
+
}
|
|
174004
|
+
}
|
|
174005
|
+
return selections;
|
|
174006
|
+
}
|
|
173874
174007
|
};
|
|
173875
174008
|
var Cache2 = class {
|
|
173876
174009
|
_internal_unstable;
|
|
@@ -173946,11 +174079,17 @@ var Cache2 = class {
|
|
|
173946
174079
|
}
|
|
173947
174080
|
registerKeyMap(source, mapped) {
|
|
173948
174081
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
174082
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
173949
174083
|
}
|
|
173950
174084
|
delete(id2, layer) {
|
|
173951
|
-
this._internal_unstable.
|
|
173952
|
-
|
|
173953
|
-
|
|
174085
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id2], id2].filter(
|
|
174086
|
+
Boolean
|
|
174087
|
+
);
|
|
174088
|
+
for (const recordID of recordIDs) {
|
|
174089
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
174090
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
174091
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
174092
|
+
}
|
|
173954
174093
|
}
|
|
173955
174094
|
setConfig(config2) {
|
|
173956
174095
|
this._internal_unstable.setConfig(config2);
|
|
@@ -174256,6 +174395,9 @@ var CacheInternal2 = class {
|
|
|
174256
174395
|
layer,
|
|
174257
174396
|
forceNotify
|
|
174258
174397
|
});
|
|
174398
|
+
let action = () => {
|
|
174399
|
+
layer.writeLink(parent2, key, linkedIDs);
|
|
174400
|
+
};
|
|
174259
174401
|
if (applyUpdates && updates) {
|
|
174260
174402
|
if (key === "edges") {
|
|
174261
174403
|
const newNodeIDs = [];
|
|
@@ -174290,8 +174432,26 @@ var CacheInternal2 = class {
|
|
|
174290
174432
|
}
|
|
174291
174433
|
if (update === "prepend") {
|
|
174292
174434
|
linkedIDs = newIDs.concat(oldIDs);
|
|
174435
|
+
if (layer?.optimistic) {
|
|
174436
|
+
action = () => {
|
|
174437
|
+
for (const id2 of newIDs) {
|
|
174438
|
+
if (id2) {
|
|
174439
|
+
layer.insert(parent2, key, "start", id2);
|
|
174440
|
+
}
|
|
174441
|
+
}
|
|
174442
|
+
};
|
|
174443
|
+
}
|
|
174293
174444
|
} else if (update === "append") {
|
|
174294
174445
|
linkedIDs = oldIDs.concat(newIDs);
|
|
174446
|
+
if (layer?.optimistic) {
|
|
174447
|
+
action = () => {
|
|
174448
|
+
for (const id2 of newIDs) {
|
|
174449
|
+
if (id2) {
|
|
174450
|
+
layer.insert(parent2, key, "end", id2);
|
|
174451
|
+
}
|
|
174452
|
+
}
|
|
174453
|
+
};
|
|
174454
|
+
}
|
|
174295
174455
|
} else if (update === "replace") {
|
|
174296
174456
|
linkedIDs = newIDs;
|
|
174297
174457
|
}
|
|
@@ -174310,7 +174470,7 @@ var CacheInternal2 = class {
|
|
|
174310
174470
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
174311
174471
|
}
|
|
174312
174472
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
174313
|
-
|
|
174473
|
+
action();
|
|
174314
174474
|
}
|
|
174315
174475
|
for (const id2 of newIDs.filter((id22) => !oldIDs.includes(id22))) {
|
|
174316
174476
|
if (id2 == null) {
|
|
@@ -174365,6 +174525,9 @@ var CacheInternal2 = class {
|
|
|
174365
174525
|
if (!targetID) {
|
|
174366
174526
|
continue;
|
|
174367
174527
|
}
|
|
174528
|
+
toNotify.push(
|
|
174529
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
174530
|
+
);
|
|
174368
174531
|
this.cache.delete(targetID, layer);
|
|
174369
174532
|
}
|
|
174370
174533
|
}
|
|
@@ -174786,7 +174949,6 @@ function variableValue2(value2, args) {
|
|
|
174786
174949
|
);
|
|
174787
174950
|
}
|
|
174788
174951
|
}
|
|
174789
|
-
var rootID2 = "_ROOT_";
|
|
174790
174952
|
function defaultComponentField2({
|
|
174791
174953
|
cache,
|
|
174792
174954
|
component,
|