houdini-svelte 0.0.0-20240804155440 → 0.0.0-20240819194752
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 +274 -112
- package/build/plugin-esm/index.js +274 -112
- package/build/preprocess-cjs/index.js +274 -112
- package/build/preprocess-esm/index.js +274 -112
- package/build/test-cjs/index.js +548 -224
- package/build/test-esm/index.js +548 -224
- package/package.json +2 -2
|
@@ -86779,6 +86779,33 @@ var GarbageCollector = class {
|
|
|
86779
86779
|
}
|
|
86780
86780
|
}
|
|
86781
86781
|
};
|
|
86782
|
+
function evaluateKey(key2, variables = null) {
|
|
86783
|
+
let evaluated = "";
|
|
86784
|
+
let varName = "";
|
|
86785
|
+
let inString = false;
|
|
86786
|
+
for (const char of key2) {
|
|
86787
|
+
if (varName) {
|
|
86788
|
+
if (varChars.includes(char)) {
|
|
86789
|
+
varName += char;
|
|
86790
|
+
continue;
|
|
86791
|
+
}
|
|
86792
|
+
const value = variables?.[varName.slice(1)];
|
|
86793
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
86794
|
+
varName = "";
|
|
86795
|
+
}
|
|
86796
|
+
if (char === "$" && !inString) {
|
|
86797
|
+
varName = "$";
|
|
86798
|
+
continue;
|
|
86799
|
+
}
|
|
86800
|
+
if (char === '"') {
|
|
86801
|
+
inString = !inString;
|
|
86802
|
+
}
|
|
86803
|
+
evaluated += char;
|
|
86804
|
+
}
|
|
86805
|
+
return evaluated;
|
|
86806
|
+
}
|
|
86807
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
86808
|
+
var rootID = "_ROOT_";
|
|
86782
86809
|
var ListManager = class {
|
|
86783
86810
|
rootID;
|
|
86784
86811
|
cache;
|
|
@@ -86844,11 +86871,15 @@ var ListManager = class {
|
|
|
86844
86871
|
this.listsByField.get(parentID).get(list3.key).push(handler);
|
|
86845
86872
|
}
|
|
86846
86873
|
removeIDFromAllLists(id2, layer) {
|
|
86874
|
+
let removed2 = false;
|
|
86847
86875
|
for (const fieldMap of this.lists.values()) {
|
|
86848
86876
|
for (const list3 of fieldMap.values()) {
|
|
86849
|
-
list3.removeID(id2, void 0, layer)
|
|
86877
|
+
if (list3.removeID(id2, void 0, layer)) {
|
|
86878
|
+
removed2 = true;
|
|
86879
|
+
}
|
|
86850
86880
|
}
|
|
86851
86881
|
}
|
|
86882
|
+
return removed2;
|
|
86852
86883
|
}
|
|
86853
86884
|
deleteField(parentID, field) {
|
|
86854
86885
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -87151,7 +87182,13 @@ var ListCollection = class {
|
|
|
87151
87182
|
this.lists.forEach((list3) => list3.addToList(...args));
|
|
87152
87183
|
}
|
|
87153
87184
|
removeID(...args) {
|
|
87154
|
-
|
|
87185
|
+
let removed2 = false;
|
|
87186
|
+
this.lists.forEach((list3) => {
|
|
87187
|
+
if (list3.removeID(...args)) {
|
|
87188
|
+
removed2 = true;
|
|
87189
|
+
}
|
|
87190
|
+
});
|
|
87191
|
+
return removed2;
|
|
87155
87192
|
}
|
|
87156
87193
|
remove(...args) {
|
|
87157
87194
|
this.lists.forEach((list3) => list3.remove(...args));
|
|
@@ -87266,6 +87303,7 @@ var InMemoryStorage = class {
|
|
|
87266
87303
|
}
|
|
87267
87304
|
registerIDMapping(from, to) {
|
|
87268
87305
|
this.idMaps[from] = to;
|
|
87306
|
+
this.idMaps[to] = from;
|
|
87269
87307
|
}
|
|
87270
87308
|
createLayer(optimistic = false) {
|
|
87271
87309
|
const layer = new Layer(this.idCount++);
|
|
@@ -87276,11 +87314,11 @@ var InMemoryStorage = class {
|
|
|
87276
87314
|
insert(id2, field, location, target) {
|
|
87277
87315
|
return this.topLayer.insert(id2, field, location, target);
|
|
87278
87316
|
}
|
|
87279
|
-
remove(id2, field, target,
|
|
87280
|
-
return
|
|
87317
|
+
remove(id2, field, target, layer = this.topLayer) {
|
|
87318
|
+
return layer.remove(id2, field, target);
|
|
87281
87319
|
}
|
|
87282
|
-
delete(id2,
|
|
87283
|
-
return
|
|
87320
|
+
delete(id2, layer = this.topLayer) {
|
|
87321
|
+
return layer.delete(id2);
|
|
87284
87322
|
}
|
|
87285
87323
|
deleteField(id2, field) {
|
|
87286
87324
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -87318,6 +87356,9 @@ var InMemoryStorage = class {
|
|
|
87318
87356
|
return;
|
|
87319
87357
|
}
|
|
87320
87358
|
operations.remove.add(v2);
|
|
87359
|
+
if (this.idMaps[v2]) {
|
|
87360
|
+
operations.remove.add(this.idMaps[v2]);
|
|
87361
|
+
}
|
|
87321
87362
|
});
|
|
87322
87363
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
87323
87364
|
const targetLayer = this.topLayer;
|
|
@@ -87344,7 +87385,11 @@ var InMemoryStorage = class {
|
|
|
87344
87385
|
operations.remove.add(op.id);
|
|
87345
87386
|
}
|
|
87346
87387
|
if (isInsertOperation(op)) {
|
|
87347
|
-
|
|
87388
|
+
if (op.location === OperationLocation.end) {
|
|
87389
|
+
operations.insert[op.location].unshift(op.id);
|
|
87390
|
+
} else {
|
|
87391
|
+
operations.insert[op.location].push(op.id);
|
|
87392
|
+
}
|
|
87348
87393
|
}
|
|
87349
87394
|
if (isDeleteOperation(op)) {
|
|
87350
87395
|
return {
|
|
@@ -87590,7 +87635,7 @@ var Layer = class {
|
|
|
87590
87635
|
}
|
|
87591
87636
|
for (const [id2, ops] of Object.entries(layer.operations)) {
|
|
87592
87637
|
const fields = {};
|
|
87593
|
-
for (const opMap of [
|
|
87638
|
+
for (const opMap of [layer.operations[id2], this.operations[id2]].filter(Boolean)) {
|
|
87594
87639
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
87595
87640
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
87596
87641
|
}
|
|
@@ -87654,32 +87699,6 @@ var OperationKind = {
|
|
|
87654
87699
|
insert: "insert",
|
|
87655
87700
|
remove: "remove"
|
|
87656
87701
|
};
|
|
87657
|
-
function evaluateKey(key2, variables = null) {
|
|
87658
|
-
let evaluated = "";
|
|
87659
|
-
let varName = "";
|
|
87660
|
-
let inString = false;
|
|
87661
|
-
for (const char of key2) {
|
|
87662
|
-
if (varName) {
|
|
87663
|
-
if (varChars.includes(char)) {
|
|
87664
|
-
varName += char;
|
|
87665
|
-
continue;
|
|
87666
|
-
}
|
|
87667
|
-
const value = variables?.[varName.slice(1)];
|
|
87668
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
87669
|
-
varName = "";
|
|
87670
|
-
}
|
|
87671
|
-
if (char === "$" && !inString) {
|
|
87672
|
-
varName = "$";
|
|
87673
|
-
continue;
|
|
87674
|
-
}
|
|
87675
|
-
if (char === '"') {
|
|
87676
|
-
inString = !inString;
|
|
87677
|
-
}
|
|
87678
|
-
evaluated += char;
|
|
87679
|
-
}
|
|
87680
|
-
return evaluated;
|
|
87681
|
-
}
|
|
87682
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
87683
87702
|
var InMemorySubscriptions = class {
|
|
87684
87703
|
cache;
|
|
87685
87704
|
constructor(cache) {
|
|
@@ -87690,6 +87709,9 @@ var InMemorySubscriptions = class {
|
|
|
87690
87709
|
activeFields(parent2) {
|
|
87691
87710
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
87692
87711
|
}
|
|
87712
|
+
copySubscribers(from, to) {
|
|
87713
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
87714
|
+
}
|
|
87693
87715
|
add({
|
|
87694
87716
|
parent: parent2,
|
|
87695
87717
|
spec,
|
|
@@ -87872,6 +87894,11 @@ var InMemorySubscriptions = class {
|
|
|
87872
87894
|
get(id2, field) {
|
|
87873
87895
|
return this.subscribers.get(id2)?.get(field)?.selections || [];
|
|
87874
87896
|
}
|
|
87897
|
+
getAll(id2) {
|
|
87898
|
+
return [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
87899
|
+
(fieldSub) => fieldSub.selections
|
|
87900
|
+
);
|
|
87901
|
+
}
|
|
87875
87902
|
remove(id2, selection, targets, variables, visited = []) {
|
|
87876
87903
|
visited.push(id2);
|
|
87877
87904
|
const linkedIDs = [];
|
|
@@ -87913,7 +87940,7 @@ var InMemorySubscriptions = class {
|
|
|
87913
87940
|
}
|
|
87914
87941
|
const subscriberField = subscriber.get(fieldName);
|
|
87915
87942
|
for (const spec of specs) {
|
|
87916
|
-
const counts =
|
|
87943
|
+
const counts = subscriberField?.referenceCounts;
|
|
87917
87944
|
if (!counts?.has(spec.set)) {
|
|
87918
87945
|
continue;
|
|
87919
87946
|
}
|
|
@@ -87936,24 +87963,23 @@ var InMemorySubscriptions = class {
|
|
|
87936
87963
|
this.subscribers.delete(id2);
|
|
87937
87964
|
}
|
|
87938
87965
|
}
|
|
87939
|
-
removeAllSubscribers(id2, targets
|
|
87940
|
-
|
|
87941
|
-
|
|
87942
|
-
|
|
87943
|
-
|
|
87944
|
-
|
|
87945
|
-
|
|
87946
|
-
|
|
87947
|
-
|
|
87948
|
-
|
|
87949
|
-
|
|
87950
|
-
|
|
87951
|
-
|
|
87952
|
-
|
|
87953
|
-
}
|
|
87954
|
-
this.removeAllSubscribers(id22, subscribers, visited);
|
|
87966
|
+
removeAllSubscribers(id2, targets) {
|
|
87967
|
+
if (!targets) {
|
|
87968
|
+
targets = [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
87969
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
87970
|
+
);
|
|
87971
|
+
}
|
|
87972
|
+
for (const target of targets) {
|
|
87973
|
+
for (const subselection of this.findSubSelections(
|
|
87974
|
+
target.parentID || rootID,
|
|
87975
|
+
target.selection,
|
|
87976
|
+
target.variables || {},
|
|
87977
|
+
id2
|
|
87978
|
+
)) {
|
|
87979
|
+
this.remove(id2, subselection, targets, target.variables || {});
|
|
87955
87980
|
}
|
|
87956
87981
|
}
|
|
87982
|
+
return;
|
|
87957
87983
|
}
|
|
87958
87984
|
get size() {
|
|
87959
87985
|
let size = 0;
|
|
@@ -87964,6 +87990,32 @@ var InMemorySubscriptions = class {
|
|
|
87964
87990
|
}
|
|
87965
87991
|
return size;
|
|
87966
87992
|
}
|
|
87993
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
87994
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
87995
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
87996
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
87997
|
+
if (!fieldSelection.selection) {
|
|
87998
|
+
continue;
|
|
87999
|
+
}
|
|
88000
|
+
const key2 = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
88001
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key2);
|
|
88002
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
88003
|
+
if (links.includes(searchTarget)) {
|
|
88004
|
+
selections.push(fieldSelection.selection);
|
|
88005
|
+
} else {
|
|
88006
|
+
for (const link of links) {
|
|
88007
|
+
this.findSubSelections(
|
|
88008
|
+
link,
|
|
88009
|
+
fieldSelection.selection,
|
|
88010
|
+
variables,
|
|
88011
|
+
searchTarget,
|
|
88012
|
+
selections
|
|
88013
|
+
);
|
|
88014
|
+
}
|
|
88015
|
+
}
|
|
88016
|
+
}
|
|
88017
|
+
return selections;
|
|
88018
|
+
}
|
|
87967
88019
|
};
|
|
87968
88020
|
var Cache = class {
|
|
87969
88021
|
_internal_unstable;
|
|
@@ -88039,11 +88091,17 @@ var Cache = class {
|
|
|
88039
88091
|
}
|
|
88040
88092
|
registerKeyMap(source2, mapped) {
|
|
88041
88093
|
this._internal_unstable.storage.registerIDMapping(source2, mapped);
|
|
88094
|
+
this._internal_unstable.subscriptions.copySubscribers(source2, mapped);
|
|
88042
88095
|
}
|
|
88043
88096
|
delete(id2, layer) {
|
|
88044
|
-
this._internal_unstable.
|
|
88045
|
-
|
|
88046
|
-
|
|
88097
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id2], id2].filter(
|
|
88098
|
+
Boolean
|
|
88099
|
+
);
|
|
88100
|
+
for (const recordID of recordIDs) {
|
|
88101
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
88102
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
88103
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
88104
|
+
}
|
|
88047
88105
|
}
|
|
88048
88106
|
setConfig(config) {
|
|
88049
88107
|
this._internal_unstable.setConfig(config);
|
|
@@ -88349,6 +88407,9 @@ var CacheInternal = class {
|
|
|
88349
88407
|
layer,
|
|
88350
88408
|
forceNotify
|
|
88351
88409
|
});
|
|
88410
|
+
let action = () => {
|
|
88411
|
+
layer.writeLink(parent2, key2, linkedIDs);
|
|
88412
|
+
};
|
|
88352
88413
|
if (applyUpdates && updates) {
|
|
88353
88414
|
if (key2 === "edges") {
|
|
88354
88415
|
const newNodeIDs = [];
|
|
@@ -88383,8 +88444,26 @@ var CacheInternal = class {
|
|
|
88383
88444
|
}
|
|
88384
88445
|
if (update2 === "prepend") {
|
|
88385
88446
|
linkedIDs = newIDs.concat(oldIDs);
|
|
88447
|
+
if (layer?.optimistic) {
|
|
88448
|
+
action = () => {
|
|
88449
|
+
for (const id2 of newIDs) {
|
|
88450
|
+
if (id2) {
|
|
88451
|
+
layer.insert(parent2, key2, "start", id2);
|
|
88452
|
+
}
|
|
88453
|
+
}
|
|
88454
|
+
};
|
|
88455
|
+
}
|
|
88386
88456
|
} else if (update2 === "append") {
|
|
88387
88457
|
linkedIDs = oldIDs.concat(newIDs);
|
|
88458
|
+
if (layer?.optimistic) {
|
|
88459
|
+
action = () => {
|
|
88460
|
+
for (const id2 of newIDs) {
|
|
88461
|
+
if (id2) {
|
|
88462
|
+
layer.insert(parent2, key2, "end", id2);
|
|
88463
|
+
}
|
|
88464
|
+
}
|
|
88465
|
+
};
|
|
88466
|
+
}
|
|
88388
88467
|
} else if (update2 === "replace") {
|
|
88389
88468
|
linkedIDs = newIDs;
|
|
88390
88469
|
}
|
|
@@ -88403,7 +88482,7 @@ var CacheInternal = class {
|
|
|
88403
88482
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
88404
88483
|
}
|
|
88405
88484
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
88406
|
-
|
|
88485
|
+
action();
|
|
88407
88486
|
}
|
|
88408
88487
|
for (const id2 of newIDs.filter((id22) => !oldIDs.includes(id22))) {
|
|
88409
88488
|
if (id2 == null) {
|
|
@@ -88458,6 +88537,9 @@ var CacheInternal = class {
|
|
|
88458
88537
|
if (!targetID) {
|
|
88459
88538
|
continue;
|
|
88460
88539
|
}
|
|
88540
|
+
toNotify.push(
|
|
88541
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
88542
|
+
);
|
|
88461
88543
|
this.cache.delete(targetID, layer);
|
|
88462
88544
|
}
|
|
88463
88545
|
}
|
|
@@ -88879,7 +88961,6 @@ function variableValue(value, args) {
|
|
|
88879
88961
|
);
|
|
88880
88962
|
}
|
|
88881
88963
|
}
|
|
88882
|
-
var rootID = "_ROOT_";
|
|
88883
88964
|
function defaultComponentField({
|
|
88884
88965
|
cache,
|
|
88885
88966
|
component,
|
|
@@ -151873,6 +151954,33 @@ var GarbageCollector2 = class {
|
|
|
151873
151954
|
}
|
|
151874
151955
|
}
|
|
151875
151956
|
};
|
|
151957
|
+
function evaluateKey2(key2, variables = null) {
|
|
151958
|
+
let evaluated = "";
|
|
151959
|
+
let varName = "";
|
|
151960
|
+
let inString = false;
|
|
151961
|
+
for (const char of key2) {
|
|
151962
|
+
if (varName) {
|
|
151963
|
+
if (varChars2.includes(char)) {
|
|
151964
|
+
varName += char;
|
|
151965
|
+
continue;
|
|
151966
|
+
}
|
|
151967
|
+
const value = variables?.[varName.slice(1)];
|
|
151968
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
151969
|
+
varName = "";
|
|
151970
|
+
}
|
|
151971
|
+
if (char === "$" && !inString) {
|
|
151972
|
+
varName = "$";
|
|
151973
|
+
continue;
|
|
151974
|
+
}
|
|
151975
|
+
if (char === '"') {
|
|
151976
|
+
inString = !inString;
|
|
151977
|
+
}
|
|
151978
|
+
evaluated += char;
|
|
151979
|
+
}
|
|
151980
|
+
return evaluated;
|
|
151981
|
+
}
|
|
151982
|
+
var varChars2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
151983
|
+
var rootID2 = "_ROOT_";
|
|
151876
151984
|
var ListManager2 = class {
|
|
151877
151985
|
rootID;
|
|
151878
151986
|
cache;
|
|
@@ -151938,11 +152046,15 @@ var ListManager2 = class {
|
|
|
151938
152046
|
this.listsByField.get(parentID).get(list3.key).push(handler);
|
|
151939
152047
|
}
|
|
151940
152048
|
removeIDFromAllLists(id2, layer) {
|
|
152049
|
+
let removed2 = false;
|
|
151941
152050
|
for (const fieldMap of this.lists.values()) {
|
|
151942
152051
|
for (const list3 of fieldMap.values()) {
|
|
151943
|
-
list3.removeID(id2, void 0, layer)
|
|
152052
|
+
if (list3.removeID(id2, void 0, layer)) {
|
|
152053
|
+
removed2 = true;
|
|
152054
|
+
}
|
|
151944
152055
|
}
|
|
151945
152056
|
}
|
|
152057
|
+
return removed2;
|
|
151946
152058
|
}
|
|
151947
152059
|
deleteField(parentID, field) {
|
|
151948
152060
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -152245,7 +152357,13 @@ var ListCollection2 = class {
|
|
|
152245
152357
|
this.lists.forEach((list3) => list3.addToList(...args));
|
|
152246
152358
|
}
|
|
152247
152359
|
removeID(...args) {
|
|
152248
|
-
|
|
152360
|
+
let removed2 = false;
|
|
152361
|
+
this.lists.forEach((list3) => {
|
|
152362
|
+
if (list3.removeID(...args)) {
|
|
152363
|
+
removed2 = true;
|
|
152364
|
+
}
|
|
152365
|
+
});
|
|
152366
|
+
return removed2;
|
|
152249
152367
|
}
|
|
152250
152368
|
remove(...args) {
|
|
152251
152369
|
this.lists.forEach((list3) => list3.remove(...args));
|
|
@@ -152360,6 +152478,7 @@ var InMemoryStorage2 = class {
|
|
|
152360
152478
|
}
|
|
152361
152479
|
registerIDMapping(from, to) {
|
|
152362
152480
|
this.idMaps[from] = to;
|
|
152481
|
+
this.idMaps[to] = from;
|
|
152363
152482
|
}
|
|
152364
152483
|
createLayer(optimistic = false) {
|
|
152365
152484
|
const layer = new Layer2(this.idCount++);
|
|
@@ -152370,11 +152489,11 @@ var InMemoryStorage2 = class {
|
|
|
152370
152489
|
insert(id2, field, location, target) {
|
|
152371
152490
|
return this.topLayer.insert(id2, field, location, target);
|
|
152372
152491
|
}
|
|
152373
|
-
remove(id2, field, target,
|
|
152374
|
-
return
|
|
152492
|
+
remove(id2, field, target, layer = this.topLayer) {
|
|
152493
|
+
return layer.remove(id2, field, target);
|
|
152375
152494
|
}
|
|
152376
|
-
delete(id2,
|
|
152377
|
-
return
|
|
152495
|
+
delete(id2, layer = this.topLayer) {
|
|
152496
|
+
return layer.delete(id2);
|
|
152378
152497
|
}
|
|
152379
152498
|
deleteField(id2, field) {
|
|
152380
152499
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -152412,6 +152531,9 @@ var InMemoryStorage2 = class {
|
|
|
152412
152531
|
return;
|
|
152413
152532
|
}
|
|
152414
152533
|
operations.remove.add(v2);
|
|
152534
|
+
if (this.idMaps[v2]) {
|
|
152535
|
+
operations.remove.add(this.idMaps[v2]);
|
|
152536
|
+
}
|
|
152415
152537
|
});
|
|
152416
152538
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
152417
152539
|
const targetLayer = this.topLayer;
|
|
@@ -152438,7 +152560,11 @@ var InMemoryStorage2 = class {
|
|
|
152438
152560
|
operations.remove.add(op.id);
|
|
152439
152561
|
}
|
|
152440
152562
|
if (isInsertOperation2(op)) {
|
|
152441
|
-
|
|
152563
|
+
if (op.location === OperationLocation2.end) {
|
|
152564
|
+
operations.insert[op.location].unshift(op.id);
|
|
152565
|
+
} else {
|
|
152566
|
+
operations.insert[op.location].push(op.id);
|
|
152567
|
+
}
|
|
152442
152568
|
}
|
|
152443
152569
|
if (isDeleteOperation2(op)) {
|
|
152444
152570
|
return {
|
|
@@ -152684,7 +152810,7 @@ var Layer2 = class {
|
|
|
152684
152810
|
}
|
|
152685
152811
|
for (const [id2, ops] of Object.entries(layer.operations)) {
|
|
152686
152812
|
const fields = {};
|
|
152687
|
-
for (const opMap of [
|
|
152813
|
+
for (const opMap of [layer.operations[id2], this.operations[id2]].filter(Boolean)) {
|
|
152688
152814
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
152689
152815
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
152690
152816
|
}
|
|
@@ -152748,32 +152874,6 @@ var OperationKind2 = {
|
|
|
152748
152874
|
insert: "insert",
|
|
152749
152875
|
remove: "remove"
|
|
152750
152876
|
};
|
|
152751
|
-
function evaluateKey2(key2, variables = null) {
|
|
152752
|
-
let evaluated = "";
|
|
152753
|
-
let varName = "";
|
|
152754
|
-
let inString = false;
|
|
152755
|
-
for (const char of key2) {
|
|
152756
|
-
if (varName) {
|
|
152757
|
-
if (varChars2.includes(char)) {
|
|
152758
|
-
varName += char;
|
|
152759
|
-
continue;
|
|
152760
|
-
}
|
|
152761
|
-
const value = variables?.[varName.slice(1)];
|
|
152762
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
152763
|
-
varName = "";
|
|
152764
|
-
}
|
|
152765
|
-
if (char === "$" && !inString) {
|
|
152766
|
-
varName = "$";
|
|
152767
|
-
continue;
|
|
152768
|
-
}
|
|
152769
|
-
if (char === '"') {
|
|
152770
|
-
inString = !inString;
|
|
152771
|
-
}
|
|
152772
|
-
evaluated += char;
|
|
152773
|
-
}
|
|
152774
|
-
return evaluated;
|
|
152775
|
-
}
|
|
152776
|
-
var varChars2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
152777
152877
|
var InMemorySubscriptions2 = class {
|
|
152778
152878
|
cache;
|
|
152779
152879
|
constructor(cache) {
|
|
@@ -152784,6 +152884,9 @@ var InMemorySubscriptions2 = class {
|
|
|
152784
152884
|
activeFields(parent2) {
|
|
152785
152885
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
152786
152886
|
}
|
|
152887
|
+
copySubscribers(from, to) {
|
|
152888
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
152889
|
+
}
|
|
152787
152890
|
add({
|
|
152788
152891
|
parent: parent2,
|
|
152789
152892
|
spec,
|
|
@@ -152966,6 +153069,11 @@ var InMemorySubscriptions2 = class {
|
|
|
152966
153069
|
get(id2, field) {
|
|
152967
153070
|
return this.subscribers.get(id2)?.get(field)?.selections || [];
|
|
152968
153071
|
}
|
|
153072
|
+
getAll(id2) {
|
|
153073
|
+
return [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
153074
|
+
(fieldSub) => fieldSub.selections
|
|
153075
|
+
);
|
|
153076
|
+
}
|
|
152969
153077
|
remove(id2, selection, targets, variables, visited = []) {
|
|
152970
153078
|
visited.push(id2);
|
|
152971
153079
|
const linkedIDs = [];
|
|
@@ -153007,7 +153115,7 @@ var InMemorySubscriptions2 = class {
|
|
|
153007
153115
|
}
|
|
153008
153116
|
const subscriberField = subscriber.get(fieldName);
|
|
153009
153117
|
for (const spec of specs) {
|
|
153010
|
-
const counts =
|
|
153118
|
+
const counts = subscriberField?.referenceCounts;
|
|
153011
153119
|
if (!counts?.has(spec.set)) {
|
|
153012
153120
|
continue;
|
|
153013
153121
|
}
|
|
@@ -153030,24 +153138,23 @@ var InMemorySubscriptions2 = class {
|
|
|
153030
153138
|
this.subscribers.delete(id2);
|
|
153031
153139
|
}
|
|
153032
153140
|
}
|
|
153033
|
-
removeAllSubscribers(id2, targets
|
|
153034
|
-
|
|
153035
|
-
|
|
153036
|
-
|
|
153037
|
-
|
|
153038
|
-
|
|
153039
|
-
|
|
153040
|
-
|
|
153041
|
-
|
|
153042
|
-
|
|
153043
|
-
|
|
153044
|
-
|
|
153045
|
-
|
|
153046
|
-
|
|
153047
|
-
}
|
|
153048
|
-
this.removeAllSubscribers(id22, subscribers, visited);
|
|
153141
|
+
removeAllSubscribers(id2, targets) {
|
|
153142
|
+
if (!targets) {
|
|
153143
|
+
targets = [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
153144
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
153145
|
+
);
|
|
153146
|
+
}
|
|
153147
|
+
for (const target of targets) {
|
|
153148
|
+
for (const subselection of this.findSubSelections(
|
|
153149
|
+
target.parentID || rootID2,
|
|
153150
|
+
target.selection,
|
|
153151
|
+
target.variables || {},
|
|
153152
|
+
id2
|
|
153153
|
+
)) {
|
|
153154
|
+
this.remove(id2, subselection, targets, target.variables || {});
|
|
153049
153155
|
}
|
|
153050
153156
|
}
|
|
153157
|
+
return;
|
|
153051
153158
|
}
|
|
153052
153159
|
get size() {
|
|
153053
153160
|
let size = 0;
|
|
@@ -153058,6 +153165,32 @@ var InMemorySubscriptions2 = class {
|
|
|
153058
153165
|
}
|
|
153059
153166
|
return size;
|
|
153060
153167
|
}
|
|
153168
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
153169
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
153170
|
+
let targetSelection = getFieldsForType2(selection, __typename, false);
|
|
153171
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
153172
|
+
if (!fieldSelection.selection) {
|
|
153173
|
+
continue;
|
|
153174
|
+
}
|
|
153175
|
+
const key2 = evaluateKey2(fieldSelection.keyRaw, variables || {});
|
|
153176
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key2);
|
|
153177
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten2(linkedRecord.value);
|
|
153178
|
+
if (links.includes(searchTarget)) {
|
|
153179
|
+
selections.push(fieldSelection.selection);
|
|
153180
|
+
} else {
|
|
153181
|
+
for (const link of links) {
|
|
153182
|
+
this.findSubSelections(
|
|
153183
|
+
link,
|
|
153184
|
+
fieldSelection.selection,
|
|
153185
|
+
variables,
|
|
153186
|
+
searchTarget,
|
|
153187
|
+
selections
|
|
153188
|
+
);
|
|
153189
|
+
}
|
|
153190
|
+
}
|
|
153191
|
+
}
|
|
153192
|
+
return selections;
|
|
153193
|
+
}
|
|
153061
153194
|
};
|
|
153062
153195
|
var Cache2 = class {
|
|
153063
153196
|
_internal_unstable;
|
|
@@ -153133,11 +153266,17 @@ var Cache2 = class {
|
|
|
153133
153266
|
}
|
|
153134
153267
|
registerKeyMap(source2, mapped) {
|
|
153135
153268
|
this._internal_unstable.storage.registerIDMapping(source2, mapped);
|
|
153269
|
+
this._internal_unstable.subscriptions.copySubscribers(source2, mapped);
|
|
153136
153270
|
}
|
|
153137
153271
|
delete(id2, layer) {
|
|
153138
|
-
this._internal_unstable.
|
|
153139
|
-
|
|
153140
|
-
|
|
153272
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id2], id2].filter(
|
|
153273
|
+
Boolean
|
|
153274
|
+
);
|
|
153275
|
+
for (const recordID of recordIDs) {
|
|
153276
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
153277
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
153278
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
153279
|
+
}
|
|
153141
153280
|
}
|
|
153142
153281
|
setConfig(config2) {
|
|
153143
153282
|
this._internal_unstable.setConfig(config2);
|
|
@@ -153443,6 +153582,9 @@ var CacheInternal2 = class {
|
|
|
153443
153582
|
layer,
|
|
153444
153583
|
forceNotify
|
|
153445
153584
|
});
|
|
153585
|
+
let action = () => {
|
|
153586
|
+
layer.writeLink(parent2, key2, linkedIDs);
|
|
153587
|
+
};
|
|
153446
153588
|
if (applyUpdates && updates) {
|
|
153447
153589
|
if (key2 === "edges") {
|
|
153448
153590
|
const newNodeIDs = [];
|
|
@@ -153477,8 +153619,26 @@ var CacheInternal2 = class {
|
|
|
153477
153619
|
}
|
|
153478
153620
|
if (update2 === "prepend") {
|
|
153479
153621
|
linkedIDs = newIDs.concat(oldIDs);
|
|
153622
|
+
if (layer?.optimistic) {
|
|
153623
|
+
action = () => {
|
|
153624
|
+
for (const id2 of newIDs) {
|
|
153625
|
+
if (id2) {
|
|
153626
|
+
layer.insert(parent2, key2, "start", id2);
|
|
153627
|
+
}
|
|
153628
|
+
}
|
|
153629
|
+
};
|
|
153630
|
+
}
|
|
153480
153631
|
} else if (update2 === "append") {
|
|
153481
153632
|
linkedIDs = oldIDs.concat(newIDs);
|
|
153633
|
+
if (layer?.optimistic) {
|
|
153634
|
+
action = () => {
|
|
153635
|
+
for (const id2 of newIDs) {
|
|
153636
|
+
if (id2) {
|
|
153637
|
+
layer.insert(parent2, key2, "end", id2);
|
|
153638
|
+
}
|
|
153639
|
+
}
|
|
153640
|
+
};
|
|
153641
|
+
}
|
|
153482
153642
|
} else if (update2 === "replace") {
|
|
153483
153643
|
linkedIDs = newIDs;
|
|
153484
153644
|
}
|
|
@@ -153497,7 +153657,7 @@ var CacheInternal2 = class {
|
|
|
153497
153657
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
153498
153658
|
}
|
|
153499
153659
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
153500
|
-
|
|
153660
|
+
action();
|
|
153501
153661
|
}
|
|
153502
153662
|
for (const id2 of newIDs.filter((id22) => !oldIDs.includes(id22))) {
|
|
153503
153663
|
if (id2 == null) {
|
|
@@ -153552,6 +153712,9 @@ var CacheInternal2 = class {
|
|
|
153552
153712
|
if (!targetID) {
|
|
153553
153713
|
continue;
|
|
153554
153714
|
}
|
|
153715
|
+
toNotify.push(
|
|
153716
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
153717
|
+
);
|
|
153555
153718
|
this.cache.delete(targetID, layer);
|
|
153556
153719
|
}
|
|
153557
153720
|
}
|
|
@@ -153973,7 +154136,6 @@ function variableValue2(value, args) {
|
|
|
153973
154136
|
);
|
|
153974
154137
|
}
|
|
153975
154138
|
}
|
|
153976
|
-
var rootID2 = "_ROOT_";
|
|
153977
154139
|
function defaultComponentField2({
|
|
153978
154140
|
cache,
|
|
153979
154141
|
component,
|