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
|
@@ -75808,6 +75808,33 @@ var GarbageCollector = class {
|
|
|
75808
75808
|
}
|
|
75809
75809
|
}
|
|
75810
75810
|
};
|
|
75811
|
+
function evaluateKey(key, variables = null) {
|
|
75812
|
+
let evaluated = "";
|
|
75813
|
+
let varName = "";
|
|
75814
|
+
let inString = false;
|
|
75815
|
+
for (const char of key) {
|
|
75816
|
+
if (varName) {
|
|
75817
|
+
if (varChars.includes(char)) {
|
|
75818
|
+
varName += char;
|
|
75819
|
+
continue;
|
|
75820
|
+
}
|
|
75821
|
+
const value2 = variables?.[varName.slice(1)];
|
|
75822
|
+
evaluated += typeof value2 !== "undefined" ? JSON.stringify(value2) : "undefined";
|
|
75823
|
+
varName = "";
|
|
75824
|
+
}
|
|
75825
|
+
if (char === "$" && !inString) {
|
|
75826
|
+
varName = "$";
|
|
75827
|
+
continue;
|
|
75828
|
+
}
|
|
75829
|
+
if (char === '"') {
|
|
75830
|
+
inString = !inString;
|
|
75831
|
+
}
|
|
75832
|
+
evaluated += char;
|
|
75833
|
+
}
|
|
75834
|
+
return evaluated;
|
|
75835
|
+
}
|
|
75836
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
75837
|
+
var rootID = "_ROOT_";
|
|
75811
75838
|
var ListManager = class {
|
|
75812
75839
|
rootID;
|
|
75813
75840
|
cache;
|
|
@@ -75873,11 +75900,15 @@ var ListManager = class {
|
|
|
75873
75900
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
75874
75901
|
}
|
|
75875
75902
|
removeIDFromAllLists(id2, layer) {
|
|
75903
|
+
let removed = false;
|
|
75876
75904
|
for (const fieldMap of this.lists.values()) {
|
|
75877
75905
|
for (const list of fieldMap.values()) {
|
|
75878
|
-
list.removeID(id2, void 0, layer)
|
|
75906
|
+
if (list.removeID(id2, void 0, layer)) {
|
|
75907
|
+
removed = true;
|
|
75908
|
+
}
|
|
75879
75909
|
}
|
|
75880
75910
|
}
|
|
75911
|
+
return removed;
|
|
75881
75912
|
}
|
|
75882
75913
|
deleteField(parentID, field) {
|
|
75883
75914
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -76180,7 +76211,13 @@ var ListCollection = class {
|
|
|
76180
76211
|
this.lists.forEach((list) => list.addToList(...args));
|
|
76181
76212
|
}
|
|
76182
76213
|
removeID(...args) {
|
|
76183
|
-
|
|
76214
|
+
let removed = false;
|
|
76215
|
+
this.lists.forEach((list) => {
|
|
76216
|
+
if (list.removeID(...args)) {
|
|
76217
|
+
removed = true;
|
|
76218
|
+
}
|
|
76219
|
+
});
|
|
76220
|
+
return removed;
|
|
76184
76221
|
}
|
|
76185
76222
|
remove(...args) {
|
|
76186
76223
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -76295,6 +76332,7 @@ var InMemoryStorage = class {
|
|
|
76295
76332
|
}
|
|
76296
76333
|
registerIDMapping(from, to) {
|
|
76297
76334
|
this.idMaps[from] = to;
|
|
76335
|
+
this.idMaps[to] = from;
|
|
76298
76336
|
}
|
|
76299
76337
|
createLayer(optimistic = false) {
|
|
76300
76338
|
const layer = new Layer(this.idCount++);
|
|
@@ -76305,11 +76343,11 @@ var InMemoryStorage = class {
|
|
|
76305
76343
|
insert(id2, field, location, target) {
|
|
76306
76344
|
return this.topLayer.insert(id2, field, location, target);
|
|
76307
76345
|
}
|
|
76308
|
-
remove(id2, field, target,
|
|
76309
|
-
return
|
|
76346
|
+
remove(id2, field, target, layer = this.topLayer) {
|
|
76347
|
+
return layer.remove(id2, field, target);
|
|
76310
76348
|
}
|
|
76311
|
-
delete(id2,
|
|
76312
|
-
return
|
|
76349
|
+
delete(id2, layer = this.topLayer) {
|
|
76350
|
+
return layer.delete(id2);
|
|
76313
76351
|
}
|
|
76314
76352
|
deleteField(id2, field) {
|
|
76315
76353
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -76347,6 +76385,9 @@ var InMemoryStorage = class {
|
|
|
76347
76385
|
return;
|
|
76348
76386
|
}
|
|
76349
76387
|
operations.remove.add(v);
|
|
76388
|
+
if (this.idMaps[v]) {
|
|
76389
|
+
operations.remove.add(this.idMaps[v]);
|
|
76390
|
+
}
|
|
76350
76391
|
});
|
|
76351
76392
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
76352
76393
|
const targetLayer = this.topLayer;
|
|
@@ -76373,7 +76414,11 @@ var InMemoryStorage = class {
|
|
|
76373
76414
|
operations.remove.add(op.id);
|
|
76374
76415
|
}
|
|
76375
76416
|
if (isInsertOperation(op)) {
|
|
76376
|
-
|
|
76417
|
+
if (op.location === OperationLocation.end) {
|
|
76418
|
+
operations.insert[op.location].unshift(op.id);
|
|
76419
|
+
} else {
|
|
76420
|
+
operations.insert[op.location].push(op.id);
|
|
76421
|
+
}
|
|
76377
76422
|
}
|
|
76378
76423
|
if (isDeleteOperation(op)) {
|
|
76379
76424
|
return {
|
|
@@ -76619,7 +76664,7 @@ var Layer = class {
|
|
|
76619
76664
|
}
|
|
76620
76665
|
for (const [id2, ops] of Object.entries(layer.operations)) {
|
|
76621
76666
|
const fields = {};
|
|
76622
|
-
for (const opMap of [
|
|
76667
|
+
for (const opMap of [layer.operations[id2], this.operations[id2]].filter(Boolean)) {
|
|
76623
76668
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
76624
76669
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
76625
76670
|
}
|
|
@@ -76683,32 +76728,6 @@ var OperationKind = {
|
|
|
76683
76728
|
insert: "insert",
|
|
76684
76729
|
remove: "remove"
|
|
76685
76730
|
};
|
|
76686
|
-
function evaluateKey(key, variables = null) {
|
|
76687
|
-
let evaluated = "";
|
|
76688
|
-
let varName = "";
|
|
76689
|
-
let inString = false;
|
|
76690
|
-
for (const char of key) {
|
|
76691
|
-
if (varName) {
|
|
76692
|
-
if (varChars.includes(char)) {
|
|
76693
|
-
varName += char;
|
|
76694
|
-
continue;
|
|
76695
|
-
}
|
|
76696
|
-
const value2 = variables?.[varName.slice(1)];
|
|
76697
|
-
evaluated += typeof value2 !== "undefined" ? JSON.stringify(value2) : "undefined";
|
|
76698
|
-
varName = "";
|
|
76699
|
-
}
|
|
76700
|
-
if (char === "$" && !inString) {
|
|
76701
|
-
varName = "$";
|
|
76702
|
-
continue;
|
|
76703
|
-
}
|
|
76704
|
-
if (char === '"') {
|
|
76705
|
-
inString = !inString;
|
|
76706
|
-
}
|
|
76707
|
-
evaluated += char;
|
|
76708
|
-
}
|
|
76709
|
-
return evaluated;
|
|
76710
|
-
}
|
|
76711
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
76712
76731
|
var InMemorySubscriptions = class {
|
|
76713
76732
|
cache;
|
|
76714
76733
|
constructor(cache) {
|
|
@@ -76719,6 +76738,9 @@ var InMemorySubscriptions = class {
|
|
|
76719
76738
|
activeFields(parent2) {
|
|
76720
76739
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
76721
76740
|
}
|
|
76741
|
+
copySubscribers(from, to) {
|
|
76742
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
76743
|
+
}
|
|
76722
76744
|
add({
|
|
76723
76745
|
parent: parent2,
|
|
76724
76746
|
spec,
|
|
@@ -76901,6 +76923,11 @@ var InMemorySubscriptions = class {
|
|
|
76901
76923
|
get(id2, field) {
|
|
76902
76924
|
return this.subscribers.get(id2)?.get(field)?.selections || [];
|
|
76903
76925
|
}
|
|
76926
|
+
getAll(id2) {
|
|
76927
|
+
return [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
76928
|
+
(fieldSub) => fieldSub.selections
|
|
76929
|
+
);
|
|
76930
|
+
}
|
|
76904
76931
|
remove(id2, selection, targets, variables, visited = []) {
|
|
76905
76932
|
visited.push(id2);
|
|
76906
76933
|
const linkedIDs = [];
|
|
@@ -76942,7 +76969,7 @@ var InMemorySubscriptions = class {
|
|
|
76942
76969
|
}
|
|
76943
76970
|
const subscriberField = subscriber.get(fieldName);
|
|
76944
76971
|
for (const spec of specs) {
|
|
76945
|
-
const counts =
|
|
76972
|
+
const counts = subscriberField?.referenceCounts;
|
|
76946
76973
|
if (!counts?.has(spec.set)) {
|
|
76947
76974
|
continue;
|
|
76948
76975
|
}
|
|
@@ -76965,24 +76992,23 @@ var InMemorySubscriptions = class {
|
|
|
76965
76992
|
this.subscribers.delete(id2);
|
|
76966
76993
|
}
|
|
76967
76994
|
}
|
|
76968
|
-
removeAllSubscribers(id2, targets
|
|
76969
|
-
|
|
76970
|
-
|
|
76971
|
-
|
|
76972
|
-
|
|
76973
|
-
|
|
76974
|
-
|
|
76975
|
-
|
|
76976
|
-
|
|
76977
|
-
|
|
76978
|
-
|
|
76979
|
-
|
|
76980
|
-
|
|
76981
|
-
|
|
76982
|
-
}
|
|
76983
|
-
this.removeAllSubscribers(id22, subscribers, visited);
|
|
76995
|
+
removeAllSubscribers(id2, targets) {
|
|
76996
|
+
if (!targets) {
|
|
76997
|
+
targets = [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
76998
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
76999
|
+
);
|
|
77000
|
+
}
|
|
77001
|
+
for (const target of targets) {
|
|
77002
|
+
for (const subselection of this.findSubSelections(
|
|
77003
|
+
target.parentID || rootID,
|
|
77004
|
+
target.selection,
|
|
77005
|
+
target.variables || {},
|
|
77006
|
+
id2
|
|
77007
|
+
)) {
|
|
77008
|
+
this.remove(id2, subselection, targets, target.variables || {});
|
|
76984
77009
|
}
|
|
76985
77010
|
}
|
|
77011
|
+
return;
|
|
76986
77012
|
}
|
|
76987
77013
|
get size() {
|
|
76988
77014
|
let size = 0;
|
|
@@ -76993,6 +77019,32 @@ var InMemorySubscriptions = class {
|
|
|
76993
77019
|
}
|
|
76994
77020
|
return size;
|
|
76995
77021
|
}
|
|
77022
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
77023
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
77024
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
77025
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
77026
|
+
if (!fieldSelection.selection) {
|
|
77027
|
+
continue;
|
|
77028
|
+
}
|
|
77029
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
77030
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
77031
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
77032
|
+
if (links.includes(searchTarget)) {
|
|
77033
|
+
selections.push(fieldSelection.selection);
|
|
77034
|
+
} else {
|
|
77035
|
+
for (const link of links) {
|
|
77036
|
+
this.findSubSelections(
|
|
77037
|
+
link,
|
|
77038
|
+
fieldSelection.selection,
|
|
77039
|
+
variables,
|
|
77040
|
+
searchTarget,
|
|
77041
|
+
selections
|
|
77042
|
+
);
|
|
77043
|
+
}
|
|
77044
|
+
}
|
|
77045
|
+
}
|
|
77046
|
+
return selections;
|
|
77047
|
+
}
|
|
76996
77048
|
};
|
|
76997
77049
|
var Cache = class {
|
|
76998
77050
|
_internal_unstable;
|
|
@@ -77068,11 +77120,17 @@ var Cache = class {
|
|
|
77068
77120
|
}
|
|
77069
77121
|
registerKeyMap(source, mapped) {
|
|
77070
77122
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
77123
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
77071
77124
|
}
|
|
77072
77125
|
delete(id2, layer) {
|
|
77073
|
-
this._internal_unstable.
|
|
77074
|
-
|
|
77075
|
-
|
|
77126
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id2], id2].filter(
|
|
77127
|
+
Boolean
|
|
77128
|
+
);
|
|
77129
|
+
for (const recordID of recordIDs) {
|
|
77130
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
77131
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
77132
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
77133
|
+
}
|
|
77076
77134
|
}
|
|
77077
77135
|
setConfig(config2) {
|
|
77078
77136
|
this._internal_unstable.setConfig(config2);
|
|
@@ -77378,6 +77436,9 @@ var CacheInternal = class {
|
|
|
77378
77436
|
layer,
|
|
77379
77437
|
forceNotify
|
|
77380
77438
|
});
|
|
77439
|
+
let action = () => {
|
|
77440
|
+
layer.writeLink(parent2, key, linkedIDs);
|
|
77441
|
+
};
|
|
77381
77442
|
if (applyUpdates && updates) {
|
|
77382
77443
|
if (key === "edges") {
|
|
77383
77444
|
const newNodeIDs = [];
|
|
@@ -77412,8 +77473,26 @@ var CacheInternal = class {
|
|
|
77412
77473
|
}
|
|
77413
77474
|
if (update === "prepend") {
|
|
77414
77475
|
linkedIDs = newIDs.concat(oldIDs);
|
|
77476
|
+
if (layer?.optimistic) {
|
|
77477
|
+
action = () => {
|
|
77478
|
+
for (const id2 of newIDs) {
|
|
77479
|
+
if (id2) {
|
|
77480
|
+
layer.insert(parent2, key, "start", id2);
|
|
77481
|
+
}
|
|
77482
|
+
}
|
|
77483
|
+
};
|
|
77484
|
+
}
|
|
77415
77485
|
} else if (update === "append") {
|
|
77416
77486
|
linkedIDs = oldIDs.concat(newIDs);
|
|
77487
|
+
if (layer?.optimistic) {
|
|
77488
|
+
action = () => {
|
|
77489
|
+
for (const id2 of newIDs) {
|
|
77490
|
+
if (id2) {
|
|
77491
|
+
layer.insert(parent2, key, "end", id2);
|
|
77492
|
+
}
|
|
77493
|
+
}
|
|
77494
|
+
};
|
|
77495
|
+
}
|
|
77417
77496
|
} else if (update === "replace") {
|
|
77418
77497
|
linkedIDs = newIDs;
|
|
77419
77498
|
}
|
|
@@ -77432,7 +77511,7 @@ var CacheInternal = class {
|
|
|
77432
77511
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
77433
77512
|
}
|
|
77434
77513
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
77435
|
-
|
|
77514
|
+
action();
|
|
77436
77515
|
}
|
|
77437
77516
|
for (const id2 of newIDs.filter((id22) => !oldIDs.includes(id22))) {
|
|
77438
77517
|
if (id2 == null) {
|
|
@@ -77487,6 +77566,9 @@ var CacheInternal = class {
|
|
|
77487
77566
|
if (!targetID) {
|
|
77488
77567
|
continue;
|
|
77489
77568
|
}
|
|
77569
|
+
toNotify.push(
|
|
77570
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
77571
|
+
);
|
|
77490
77572
|
this.cache.delete(targetID, layer);
|
|
77491
77573
|
}
|
|
77492
77574
|
}
|
|
@@ -77908,7 +77990,6 @@ function variableValue(value2, args) {
|
|
|
77908
77990
|
);
|
|
77909
77991
|
}
|
|
77910
77992
|
}
|
|
77911
|
-
var rootID = "_ROOT_";
|
|
77912
77993
|
function defaultComponentField({
|
|
77913
77994
|
cache,
|
|
77914
77995
|
component,
|
|
@@ -140787,6 +140868,33 @@ var GarbageCollector2 = class {
|
|
|
140787
140868
|
}
|
|
140788
140869
|
}
|
|
140789
140870
|
};
|
|
140871
|
+
function evaluateKey2(key, variables = null) {
|
|
140872
|
+
let evaluated = "";
|
|
140873
|
+
let varName = "";
|
|
140874
|
+
let inString = false;
|
|
140875
|
+
for (const char of key) {
|
|
140876
|
+
if (varName) {
|
|
140877
|
+
if (varChars2.includes(char)) {
|
|
140878
|
+
varName += char;
|
|
140879
|
+
continue;
|
|
140880
|
+
}
|
|
140881
|
+
const value2 = variables?.[varName.slice(1)];
|
|
140882
|
+
evaluated += typeof value2 !== "undefined" ? JSON.stringify(value2) : "undefined";
|
|
140883
|
+
varName = "";
|
|
140884
|
+
}
|
|
140885
|
+
if (char === "$" && !inString) {
|
|
140886
|
+
varName = "$";
|
|
140887
|
+
continue;
|
|
140888
|
+
}
|
|
140889
|
+
if (char === '"') {
|
|
140890
|
+
inString = !inString;
|
|
140891
|
+
}
|
|
140892
|
+
evaluated += char;
|
|
140893
|
+
}
|
|
140894
|
+
return evaluated;
|
|
140895
|
+
}
|
|
140896
|
+
var varChars2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
140897
|
+
var rootID2 = "_ROOT_";
|
|
140790
140898
|
var ListManager2 = class {
|
|
140791
140899
|
rootID;
|
|
140792
140900
|
cache;
|
|
@@ -140852,11 +140960,15 @@ var ListManager2 = class {
|
|
|
140852
140960
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
140853
140961
|
}
|
|
140854
140962
|
removeIDFromAllLists(id2, layer) {
|
|
140963
|
+
let removed = false;
|
|
140855
140964
|
for (const fieldMap of this.lists.values()) {
|
|
140856
140965
|
for (const list of fieldMap.values()) {
|
|
140857
|
-
list.removeID(id2, void 0, layer)
|
|
140966
|
+
if (list.removeID(id2, void 0, layer)) {
|
|
140967
|
+
removed = true;
|
|
140968
|
+
}
|
|
140858
140969
|
}
|
|
140859
140970
|
}
|
|
140971
|
+
return removed;
|
|
140860
140972
|
}
|
|
140861
140973
|
deleteField(parentID, field) {
|
|
140862
140974
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -141159,7 +141271,13 @@ var ListCollection2 = class {
|
|
|
141159
141271
|
this.lists.forEach((list) => list.addToList(...args));
|
|
141160
141272
|
}
|
|
141161
141273
|
removeID(...args) {
|
|
141162
|
-
|
|
141274
|
+
let removed = false;
|
|
141275
|
+
this.lists.forEach((list) => {
|
|
141276
|
+
if (list.removeID(...args)) {
|
|
141277
|
+
removed = true;
|
|
141278
|
+
}
|
|
141279
|
+
});
|
|
141280
|
+
return removed;
|
|
141163
141281
|
}
|
|
141164
141282
|
remove(...args) {
|
|
141165
141283
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -141274,6 +141392,7 @@ var InMemoryStorage2 = class {
|
|
|
141274
141392
|
}
|
|
141275
141393
|
registerIDMapping(from, to) {
|
|
141276
141394
|
this.idMaps[from] = to;
|
|
141395
|
+
this.idMaps[to] = from;
|
|
141277
141396
|
}
|
|
141278
141397
|
createLayer(optimistic = false) {
|
|
141279
141398
|
const layer = new Layer2(this.idCount++);
|
|
@@ -141284,11 +141403,11 @@ var InMemoryStorage2 = class {
|
|
|
141284
141403
|
insert(id2, field, location, target) {
|
|
141285
141404
|
return this.topLayer.insert(id2, field, location, target);
|
|
141286
141405
|
}
|
|
141287
|
-
remove(id2, field, target,
|
|
141288
|
-
return
|
|
141406
|
+
remove(id2, field, target, layer = this.topLayer) {
|
|
141407
|
+
return layer.remove(id2, field, target);
|
|
141289
141408
|
}
|
|
141290
|
-
delete(id2,
|
|
141291
|
-
return
|
|
141409
|
+
delete(id2, layer = this.topLayer) {
|
|
141410
|
+
return layer.delete(id2);
|
|
141292
141411
|
}
|
|
141293
141412
|
deleteField(id2, field) {
|
|
141294
141413
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -141326,6 +141445,9 @@ var InMemoryStorage2 = class {
|
|
|
141326
141445
|
return;
|
|
141327
141446
|
}
|
|
141328
141447
|
operations.remove.add(v);
|
|
141448
|
+
if (this.idMaps[v]) {
|
|
141449
|
+
operations.remove.add(this.idMaps[v]);
|
|
141450
|
+
}
|
|
141329
141451
|
});
|
|
141330
141452
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
141331
141453
|
const targetLayer = this.topLayer;
|
|
@@ -141352,7 +141474,11 @@ var InMemoryStorage2 = class {
|
|
|
141352
141474
|
operations.remove.add(op.id);
|
|
141353
141475
|
}
|
|
141354
141476
|
if (isInsertOperation2(op)) {
|
|
141355
|
-
|
|
141477
|
+
if (op.location === OperationLocation2.end) {
|
|
141478
|
+
operations.insert[op.location].unshift(op.id);
|
|
141479
|
+
} else {
|
|
141480
|
+
operations.insert[op.location].push(op.id);
|
|
141481
|
+
}
|
|
141356
141482
|
}
|
|
141357
141483
|
if (isDeleteOperation2(op)) {
|
|
141358
141484
|
return {
|
|
@@ -141598,7 +141724,7 @@ var Layer2 = class {
|
|
|
141598
141724
|
}
|
|
141599
141725
|
for (const [id2, ops] of Object.entries(layer.operations)) {
|
|
141600
141726
|
const fields = {};
|
|
141601
|
-
for (const opMap of [
|
|
141727
|
+
for (const opMap of [layer.operations[id2], this.operations[id2]].filter(Boolean)) {
|
|
141602
141728
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
141603
141729
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
141604
141730
|
}
|
|
@@ -141662,32 +141788,6 @@ var OperationKind2 = {
|
|
|
141662
141788
|
insert: "insert",
|
|
141663
141789
|
remove: "remove"
|
|
141664
141790
|
};
|
|
141665
|
-
function evaluateKey2(key, variables = null) {
|
|
141666
|
-
let evaluated = "";
|
|
141667
|
-
let varName = "";
|
|
141668
|
-
let inString = false;
|
|
141669
|
-
for (const char of key) {
|
|
141670
|
-
if (varName) {
|
|
141671
|
-
if (varChars2.includes(char)) {
|
|
141672
|
-
varName += char;
|
|
141673
|
-
continue;
|
|
141674
|
-
}
|
|
141675
|
-
const value2 = variables?.[varName.slice(1)];
|
|
141676
|
-
evaluated += typeof value2 !== "undefined" ? JSON.stringify(value2) : "undefined";
|
|
141677
|
-
varName = "";
|
|
141678
|
-
}
|
|
141679
|
-
if (char === "$" && !inString) {
|
|
141680
|
-
varName = "$";
|
|
141681
|
-
continue;
|
|
141682
|
-
}
|
|
141683
|
-
if (char === '"') {
|
|
141684
|
-
inString = !inString;
|
|
141685
|
-
}
|
|
141686
|
-
evaluated += char;
|
|
141687
|
-
}
|
|
141688
|
-
return evaluated;
|
|
141689
|
-
}
|
|
141690
|
-
var varChars2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
141691
141791
|
var InMemorySubscriptions2 = class {
|
|
141692
141792
|
cache;
|
|
141693
141793
|
constructor(cache) {
|
|
@@ -141698,6 +141798,9 @@ var InMemorySubscriptions2 = class {
|
|
|
141698
141798
|
activeFields(parent2) {
|
|
141699
141799
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
141700
141800
|
}
|
|
141801
|
+
copySubscribers(from, to) {
|
|
141802
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
141803
|
+
}
|
|
141701
141804
|
add({
|
|
141702
141805
|
parent: parent2,
|
|
141703
141806
|
spec,
|
|
@@ -141880,6 +141983,11 @@ var InMemorySubscriptions2 = class {
|
|
|
141880
141983
|
get(id2, field) {
|
|
141881
141984
|
return this.subscribers.get(id2)?.get(field)?.selections || [];
|
|
141882
141985
|
}
|
|
141986
|
+
getAll(id2) {
|
|
141987
|
+
return [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
141988
|
+
(fieldSub) => fieldSub.selections
|
|
141989
|
+
);
|
|
141990
|
+
}
|
|
141883
141991
|
remove(id2, selection, targets, variables, visited = []) {
|
|
141884
141992
|
visited.push(id2);
|
|
141885
141993
|
const linkedIDs = [];
|
|
@@ -141921,7 +142029,7 @@ var InMemorySubscriptions2 = class {
|
|
|
141921
142029
|
}
|
|
141922
142030
|
const subscriberField = subscriber.get(fieldName);
|
|
141923
142031
|
for (const spec of specs) {
|
|
141924
|
-
const counts =
|
|
142032
|
+
const counts = subscriberField?.referenceCounts;
|
|
141925
142033
|
if (!counts?.has(spec.set)) {
|
|
141926
142034
|
continue;
|
|
141927
142035
|
}
|
|
@@ -141944,24 +142052,23 @@ var InMemorySubscriptions2 = class {
|
|
|
141944
142052
|
this.subscribers.delete(id2);
|
|
141945
142053
|
}
|
|
141946
142054
|
}
|
|
141947
|
-
removeAllSubscribers(id2, targets
|
|
141948
|
-
|
|
141949
|
-
|
|
141950
|
-
|
|
141951
|
-
|
|
141952
|
-
|
|
141953
|
-
|
|
141954
|
-
|
|
141955
|
-
|
|
141956
|
-
|
|
141957
|
-
|
|
141958
|
-
|
|
141959
|
-
|
|
141960
|
-
|
|
141961
|
-
}
|
|
141962
|
-
this.removeAllSubscribers(id22, subscribers, visited);
|
|
142055
|
+
removeAllSubscribers(id2, targets) {
|
|
142056
|
+
if (!targets) {
|
|
142057
|
+
targets = [...this.subscribers.get(id2)?.values() || []].flatMap(
|
|
142058
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
142059
|
+
);
|
|
142060
|
+
}
|
|
142061
|
+
for (const target of targets) {
|
|
142062
|
+
for (const subselection of this.findSubSelections(
|
|
142063
|
+
target.parentID || rootID2,
|
|
142064
|
+
target.selection,
|
|
142065
|
+
target.variables || {},
|
|
142066
|
+
id2
|
|
142067
|
+
)) {
|
|
142068
|
+
this.remove(id2, subselection, targets, target.variables || {});
|
|
141963
142069
|
}
|
|
141964
142070
|
}
|
|
142071
|
+
return;
|
|
141965
142072
|
}
|
|
141966
142073
|
get size() {
|
|
141967
142074
|
let size = 0;
|
|
@@ -141972,6 +142079,32 @@ var InMemorySubscriptions2 = class {
|
|
|
141972
142079
|
}
|
|
141973
142080
|
return size;
|
|
141974
142081
|
}
|
|
142082
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
142083
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
142084
|
+
let targetSelection = getFieldsForType2(selection, __typename, false);
|
|
142085
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
142086
|
+
if (!fieldSelection.selection) {
|
|
142087
|
+
continue;
|
|
142088
|
+
}
|
|
142089
|
+
const key = evaluateKey2(fieldSelection.keyRaw, variables || {});
|
|
142090
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
142091
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten2(linkedRecord.value);
|
|
142092
|
+
if (links.includes(searchTarget)) {
|
|
142093
|
+
selections.push(fieldSelection.selection);
|
|
142094
|
+
} else {
|
|
142095
|
+
for (const link of links) {
|
|
142096
|
+
this.findSubSelections(
|
|
142097
|
+
link,
|
|
142098
|
+
fieldSelection.selection,
|
|
142099
|
+
variables,
|
|
142100
|
+
searchTarget,
|
|
142101
|
+
selections
|
|
142102
|
+
);
|
|
142103
|
+
}
|
|
142104
|
+
}
|
|
142105
|
+
}
|
|
142106
|
+
return selections;
|
|
142107
|
+
}
|
|
141975
142108
|
};
|
|
141976
142109
|
var Cache2 = class {
|
|
141977
142110
|
_internal_unstable;
|
|
@@ -142047,11 +142180,17 @@ var Cache2 = class {
|
|
|
142047
142180
|
}
|
|
142048
142181
|
registerKeyMap(source, mapped) {
|
|
142049
142182
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
142183
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
142050
142184
|
}
|
|
142051
142185
|
delete(id2, layer) {
|
|
142052
|
-
this._internal_unstable.
|
|
142053
|
-
|
|
142054
|
-
|
|
142186
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id2], id2].filter(
|
|
142187
|
+
Boolean
|
|
142188
|
+
);
|
|
142189
|
+
for (const recordID of recordIDs) {
|
|
142190
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
142191
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
142192
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
142193
|
+
}
|
|
142055
142194
|
}
|
|
142056
142195
|
setConfig(config2) {
|
|
142057
142196
|
this._internal_unstable.setConfig(config2);
|
|
@@ -142357,6 +142496,9 @@ var CacheInternal2 = class {
|
|
|
142357
142496
|
layer,
|
|
142358
142497
|
forceNotify
|
|
142359
142498
|
});
|
|
142499
|
+
let action = () => {
|
|
142500
|
+
layer.writeLink(parent2, key, linkedIDs);
|
|
142501
|
+
};
|
|
142360
142502
|
if (applyUpdates && updates) {
|
|
142361
142503
|
if (key === "edges") {
|
|
142362
142504
|
const newNodeIDs = [];
|
|
@@ -142391,8 +142533,26 @@ var CacheInternal2 = class {
|
|
|
142391
142533
|
}
|
|
142392
142534
|
if (update === "prepend") {
|
|
142393
142535
|
linkedIDs = newIDs.concat(oldIDs);
|
|
142536
|
+
if (layer?.optimistic) {
|
|
142537
|
+
action = () => {
|
|
142538
|
+
for (const id2 of newIDs) {
|
|
142539
|
+
if (id2) {
|
|
142540
|
+
layer.insert(parent2, key, "start", id2);
|
|
142541
|
+
}
|
|
142542
|
+
}
|
|
142543
|
+
};
|
|
142544
|
+
}
|
|
142394
142545
|
} else if (update === "append") {
|
|
142395
142546
|
linkedIDs = oldIDs.concat(newIDs);
|
|
142547
|
+
if (layer?.optimistic) {
|
|
142548
|
+
action = () => {
|
|
142549
|
+
for (const id2 of newIDs) {
|
|
142550
|
+
if (id2) {
|
|
142551
|
+
layer.insert(parent2, key, "end", id2);
|
|
142552
|
+
}
|
|
142553
|
+
}
|
|
142554
|
+
};
|
|
142555
|
+
}
|
|
142396
142556
|
} else if (update === "replace") {
|
|
142397
142557
|
linkedIDs = newIDs;
|
|
142398
142558
|
}
|
|
@@ -142411,7 +142571,7 @@ var CacheInternal2 = class {
|
|
|
142411
142571
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
142412
142572
|
}
|
|
142413
142573
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
142414
|
-
|
|
142574
|
+
action();
|
|
142415
142575
|
}
|
|
142416
142576
|
for (const id2 of newIDs.filter((id22) => !oldIDs.includes(id22))) {
|
|
142417
142577
|
if (id2 == null) {
|
|
@@ -142466,6 +142626,9 @@ var CacheInternal2 = class {
|
|
|
142466
142626
|
if (!targetID) {
|
|
142467
142627
|
continue;
|
|
142468
142628
|
}
|
|
142629
|
+
toNotify.push(
|
|
142630
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
142631
|
+
);
|
|
142469
142632
|
this.cache.delete(targetID, layer);
|
|
142470
142633
|
}
|
|
142471
142634
|
}
|
|
@@ -142887,7 +143050,6 @@ function variableValue2(value2, args) {
|
|
|
142887
143050
|
);
|
|
142888
143051
|
}
|
|
142889
143052
|
}
|
|
142890
|
-
var rootID2 = "_ROOT_";
|
|
142891
143053
|
function defaultComponentField2({
|
|
142892
143054
|
cache,
|
|
142893
143055
|
component,
|
|
@@ -172507,7 +172669,7 @@ async function codegen_default(input) {
|
|
|
172507
172669
|
// src/plugin/fsPatch.ts
|
|
172508
172670
|
import filesystem, { Dirent } from "node:fs";
|
|
172509
172671
|
import filesystemPromises from "node:fs/promises";
|
|
172510
|
-
var fsPatch_default = (
|
|
172672
|
+
var fsPatch_default = (getFramework) => ({
|
|
172511
172673
|
async resolveId(filepath, _, { config: config2, isEntry }) {
|
|
172512
172674
|
if (!isEntry) {
|
|
172513
172675
|
const match = filepath.match("^((../)+)src/routes");
|
|
@@ -172517,7 +172679,7 @@ var fsPatch_default = (getFramwork) => ({
|
|
|
172517
172679
|
return;
|
|
172518
172680
|
}
|
|
172519
172681
|
filepath = path_exports.posixify(filepath.toString());
|
|
172520
|
-
if (is_route_script(
|
|
172682
|
+
if (is_route_script(getFramework(), filepath) || is_root_layout(config2, filepath) || is_root_layout_server(config2, filepath)) {
|
|
172521
172683
|
return {
|
|
172522
172684
|
id: resolve_relative(config2, filepath)
|
|
172523
172685
|
};
|
|
@@ -172525,7 +172687,7 @@ var fsPatch_default = (getFramwork) => ({
|
|
|
172525
172687
|
},
|
|
172526
172688
|
load: async (filepath, { config: config2 }) => {
|
|
172527
172689
|
filepath = path_exports.posixify(filepath.toString());
|
|
172528
|
-
if (is_route_script(
|
|
172690
|
+
if (is_route_script(getFramework(), filepath) || is_root_layout_server(config2, filepath)) {
|
|
172529
172691
|
filepath = resolve_relative(config2, filepath);
|
|
172530
172692
|
return {
|
|
172531
172693
|
code: await fs_exports.readFile(filepath) || await fs_exports.readFile(path_exports.join(config2.projectRoot, filepath)) || ""
|
|
@@ -172543,34 +172705,40 @@ var _readDirSync = filesystem.readdirSync;
|
|
|
172543
172705
|
var _statSync = filesystem.statSync;
|
|
172544
172706
|
var _readFileSync = filesystem.readFileSync;
|
|
172545
172707
|
var _unlinkSync = filesystem.unlinkSync;
|
|
172708
|
+
function getStringFilepath(fp) {
|
|
172709
|
+
if (fp instanceof URL) {
|
|
172710
|
+
return fp.pathname;
|
|
172711
|
+
}
|
|
172712
|
+
return fp.toString();
|
|
172713
|
+
}
|
|
172546
172714
|
filesystem.readFileSync = function(fp, options) {
|
|
172547
|
-
const filepath = fp
|
|
172715
|
+
const filepath = getStringFilepath(fp);
|
|
172548
172716
|
if (filepath.endsWith("+page.js") || filepath.endsWith("+layout.js") || filepath.replace(".ts", ".js").endsWith("+layout.server.js")) {
|
|
172549
172717
|
try {
|
|
172550
|
-
return _readFileSync(
|
|
172718
|
+
return _readFileSync(fp, options);
|
|
172551
172719
|
} catch {
|
|
172552
172720
|
return typeof options === "string" || options?.encoding ? "" : Buffer.from("");
|
|
172553
172721
|
}
|
|
172554
172722
|
}
|
|
172555
172723
|
if (filepath.endsWith(path_exports.join("src", "routes", "+layout.svelte"))) {
|
|
172556
172724
|
try {
|
|
172557
|
-
return _readFileSync(
|
|
172725
|
+
return _readFileSync(fp, options);
|
|
172558
172726
|
} catch {
|
|
172559
172727
|
return typeof options === "string" || options?.encoding ? empty_layout : Buffer.from(empty_layout);
|
|
172560
172728
|
}
|
|
172561
172729
|
}
|
|
172562
|
-
return _readFileSync(
|
|
172730
|
+
return _readFileSync(fp, options);
|
|
172563
172731
|
};
|
|
172564
172732
|
filesystem.statSync = function(fp, options) {
|
|
172565
|
-
let filepath = fp
|
|
172733
|
+
let filepath = getStringFilepath(fp);
|
|
172566
172734
|
if (!filepath.includes("routes") || !path_exports.basename(filepath).startsWith("+")) {
|
|
172567
172735
|
return _statSync(fp, options);
|
|
172568
172736
|
}
|
|
172569
172737
|
try {
|
|
172570
|
-
const result = _statSync(
|
|
172738
|
+
const result = _statSync(fp, options);
|
|
172571
172739
|
return result;
|
|
172572
172740
|
} catch (error2) {
|
|
172573
|
-
filepath = path_exports.posixify(filepath
|
|
172741
|
+
filepath = path_exports.posixify(filepath);
|
|
172574
172742
|
const mock3 = virtual_file(path_exports.basename(filepath), { withFileTypes: true });
|
|
172575
172743
|
if (filepath.endsWith(path_exports.join("routes", "+layout.svelte")) || filepath.endsWith(path_exports.join("routes", "+layout.svelte")) || filepath.endsWith(path_exports.join("routes", "+layout.server.js")) || filepath.endsWith(path_exports.join("routes", "+layout.server.js"))) {
|
|
172576
172744
|
return mock3;
|
|
@@ -172588,10 +172756,11 @@ filesystem.unlinkSync = function(filepath) {
|
|
|
172588
172756
|
} catch {
|
|
172589
172757
|
}
|
|
172590
172758
|
};
|
|
172591
|
-
filesystem.readdirSync = function(
|
|
172592
|
-
|
|
172593
|
-
|
|
172594
|
-
|
|
172759
|
+
filesystem.readdirSync = function(fp, options) {
|
|
172760
|
+
const filepath = getStringFilepath(fp);
|
|
172761
|
+
if (!filepath.includes("routes"))
|
|
172762
|
+
return _readDirSync(fp, options);
|
|
172763
|
+
const result = _readDirSync(fp, options);
|
|
172595
172764
|
const file_names = result.map((file) => {
|
|
172596
172765
|
if (file instanceof Dirent) {
|
|
172597
172766
|
return file.name;
|
|
@@ -172607,7 +172776,7 @@ filesystem.readdirSync = function(filepath, options) {
|
|
|
172607
172776
|
if (contains("+page.svelte", "+page.gql") && !contains("+page.js", "+page.ts")) {
|
|
172608
172777
|
result.push(virtual_file("+page.js", options));
|
|
172609
172778
|
}
|
|
172610
|
-
const posix_filepath = path_exports.posixify(filepath
|
|
172779
|
+
const posix_filepath = path_exports.posixify(filepath);
|
|
172611
172780
|
if ((is_root_route(posix_filepath) || contains("+layout.svelte", "+layout.gql")) && !contains("+layout.ts", "+layout.js")) {
|
|
172612
172781
|
result.push(virtual_file("+layout.js", options));
|
|
172613
172782
|
}
|