houdini 1.2.54 → 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/cmd-cjs/index.js +141 -60
- package/build/cmd-esm/index.js +141 -60
- package/build/codegen-cjs/index.js +139 -58
- package/build/codegen-esm/index.js +139 -58
- package/build/lib-cjs/index.js +142 -59
- package/build/lib-esm/index.js +142 -59
- package/build/runtime/cache/cache.d.ts +1 -2
- package/build/runtime/cache/constants.d.ts +1 -0
- package/build/runtime/cache/lists.d.ts +2 -2
- package/build/runtime/cache/storage.d.ts +4 -4
- package/build/runtime/cache/stuff.d.ts +1 -0
- package/build/runtime/cache/subscription.d.ts +4 -1
- package/build/runtime-cjs/cache/cache.d.ts +1 -2
- package/build/runtime-cjs/cache/cache.js +41 -14
- package/build/runtime-cjs/cache/constants.d.ts +1 -0
- package/build/runtime-cjs/cache/constants.js +28 -0
- package/build/runtime-cjs/cache/lists.d.ts +2 -2
- package/build/runtime-cjs/cache/lists.js +14 -4
- package/build/runtime-cjs/cache/storage.d.ts +4 -4
- package/build/runtime-cjs/cache/storage.js +14 -6
- package/build/runtime-cjs/cache/stuff.d.ts +1 -0
- package/build/runtime-cjs/cache/stuff.js +5 -2
- package/build/runtime-cjs/cache/subscription.d.ts +4 -1
- package/build/runtime-cjs/cache/subscription.js +51 -19
- package/build/runtime-cjs/client/plugins/optimisticKeys.js +3 -1
- package/build/runtime-cjs/public/record.js +2 -2
- package/build/runtime-esm/cache/cache.d.ts +1 -2
- package/build/runtime-esm/cache/cache.js +35 -7
- package/build/runtime-esm/cache/constants.d.ts +1 -0
- package/build/runtime-esm/cache/constants.js +4 -0
- package/build/runtime-esm/cache/lists.d.ts +2 -2
- package/build/runtime-esm/cache/lists.js +13 -3
- package/build/runtime-esm/cache/storage.d.ts +4 -4
- package/build/runtime-esm/cache/storage.js +14 -6
- package/build/runtime-esm/cache/stuff.d.ts +1 -0
- package/build/runtime-esm/cache/stuff.js +3 -1
- package/build/runtime-esm/cache/subscription.d.ts +4 -1
- package/build/runtime-esm/cache/subscription.js +51 -19
- package/build/runtime-esm/client/plugins/optimisticKeys.js +3 -1
- package/build/runtime-esm/public/record.js +1 -1
- package/build/test-cjs/index.js +139 -58
- package/build/test-esm/index.js +139 -58
- package/build/vite-cjs/index.js +139 -58
- package/build/vite-esm/index.js +139 -58
- package/package.json +1 -1
- package/build/runtime/cache/schema.d.ts +0 -21
- package/build/runtime-cjs/cache/schema.d.ts +0 -21
- package/build/runtime-cjs/cache/schema.js +0 -66
- package/build/runtime-esm/cache/schema.d.ts +0 -21
- package/build/runtime-esm/cache/schema.js +0 -42
package/build/cmd-esm/index.js
CHANGED
|
@@ -65298,6 +65298,35 @@ var GarbageCollector = class {
|
|
|
65298
65298
|
}
|
|
65299
65299
|
};
|
|
65300
65300
|
|
|
65301
|
+
// src/runtime/cache/stuff.ts
|
|
65302
|
+
function evaluateKey(key, variables = null) {
|
|
65303
|
+
let evaluated = "";
|
|
65304
|
+
let varName = "";
|
|
65305
|
+
let inString = false;
|
|
65306
|
+
for (const char of key) {
|
|
65307
|
+
if (varName) {
|
|
65308
|
+
if (varChars.includes(char)) {
|
|
65309
|
+
varName += char;
|
|
65310
|
+
continue;
|
|
65311
|
+
}
|
|
65312
|
+
const value = variables?.[varName.slice(1)];
|
|
65313
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
65314
|
+
varName = "";
|
|
65315
|
+
}
|
|
65316
|
+
if (char === "$" && !inString) {
|
|
65317
|
+
varName = "$";
|
|
65318
|
+
continue;
|
|
65319
|
+
}
|
|
65320
|
+
if (char === '"') {
|
|
65321
|
+
inString = !inString;
|
|
65322
|
+
}
|
|
65323
|
+
evaluated += char;
|
|
65324
|
+
}
|
|
65325
|
+
return evaluated;
|
|
65326
|
+
}
|
|
65327
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
65328
|
+
var rootID = "_ROOT_";
|
|
65329
|
+
|
|
65301
65330
|
// src/runtime/cache/lists.ts
|
|
65302
65331
|
var ListManager = class {
|
|
65303
65332
|
rootID;
|
|
@@ -65364,11 +65393,15 @@ var ListManager = class {
|
|
|
65364
65393
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
65365
65394
|
}
|
|
65366
65395
|
removeIDFromAllLists(id, layer) {
|
|
65396
|
+
let removed = false;
|
|
65367
65397
|
for (const fieldMap of this.lists.values()) {
|
|
65368
65398
|
for (const list of fieldMap.values()) {
|
|
65369
|
-
list.removeID(id, void 0, layer)
|
|
65399
|
+
if (list.removeID(id, void 0, layer)) {
|
|
65400
|
+
removed = true;
|
|
65401
|
+
}
|
|
65370
65402
|
}
|
|
65371
65403
|
}
|
|
65404
|
+
return removed;
|
|
65372
65405
|
}
|
|
65373
65406
|
deleteField(parentID, field) {
|
|
65374
65407
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -65671,7 +65704,13 @@ var ListCollection = class {
|
|
|
65671
65704
|
this.lists.forEach((list) => list.addToList(...args));
|
|
65672
65705
|
}
|
|
65673
65706
|
removeID(...args) {
|
|
65674
|
-
|
|
65707
|
+
let removed = false;
|
|
65708
|
+
this.lists.forEach((list) => {
|
|
65709
|
+
if (list.removeID(...args)) {
|
|
65710
|
+
removed = true;
|
|
65711
|
+
}
|
|
65712
|
+
});
|
|
65713
|
+
return removed;
|
|
65675
65714
|
}
|
|
65676
65715
|
remove(...args) {
|
|
65677
65716
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -65790,6 +65829,7 @@ var InMemoryStorage = class {
|
|
|
65790
65829
|
}
|
|
65791
65830
|
registerIDMapping(from, to) {
|
|
65792
65831
|
this.idMaps[from] = to;
|
|
65832
|
+
this.idMaps[to] = from;
|
|
65793
65833
|
}
|
|
65794
65834
|
createLayer(optimistic = false) {
|
|
65795
65835
|
const layer = new Layer(this.idCount++);
|
|
@@ -65800,11 +65840,11 @@ var InMemoryStorage = class {
|
|
|
65800
65840
|
insert(id, field, location, target) {
|
|
65801
65841
|
return this.topLayer.insert(id, field, location, target);
|
|
65802
65842
|
}
|
|
65803
|
-
remove(id, field, target,
|
|
65804
|
-
return
|
|
65843
|
+
remove(id, field, target, layer = this.topLayer) {
|
|
65844
|
+
return layer.remove(id, field, target);
|
|
65805
65845
|
}
|
|
65806
|
-
delete(id,
|
|
65807
|
-
return
|
|
65846
|
+
delete(id, layer = this.topLayer) {
|
|
65847
|
+
return layer.delete(id);
|
|
65808
65848
|
}
|
|
65809
65849
|
deleteField(id, field) {
|
|
65810
65850
|
return this.topLayer.deleteField(id, field);
|
|
@@ -65842,6 +65882,9 @@ var InMemoryStorage = class {
|
|
|
65842
65882
|
return;
|
|
65843
65883
|
}
|
|
65844
65884
|
operations.remove.add(v2);
|
|
65885
|
+
if (this.idMaps[v2]) {
|
|
65886
|
+
operations.remove.add(this.idMaps[v2]);
|
|
65887
|
+
}
|
|
65845
65888
|
});
|
|
65846
65889
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
65847
65890
|
const targetLayer = this.topLayer;
|
|
@@ -65868,7 +65911,11 @@ var InMemoryStorage = class {
|
|
|
65868
65911
|
operations.remove.add(op.id);
|
|
65869
65912
|
}
|
|
65870
65913
|
if (isInsertOperation(op)) {
|
|
65871
|
-
|
|
65914
|
+
if (op.location === OperationLocation.end) {
|
|
65915
|
+
operations.insert[op.location].unshift(op.id);
|
|
65916
|
+
} else {
|
|
65917
|
+
operations.insert[op.location].push(op.id);
|
|
65918
|
+
}
|
|
65872
65919
|
}
|
|
65873
65920
|
if (isDeleteOperation(op)) {
|
|
65874
65921
|
return {
|
|
@@ -66114,7 +66161,7 @@ var Layer = class {
|
|
|
66114
66161
|
}
|
|
66115
66162
|
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
66116
66163
|
const fields = {};
|
|
66117
|
-
for (const opMap of [
|
|
66164
|
+
for (const opMap of [layer.operations[id], this.operations[id]].filter(Boolean)) {
|
|
66118
66165
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
66119
66166
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
66120
66167
|
}
|
|
@@ -66179,34 +66226,6 @@ var OperationKind = {
|
|
|
66179
66226
|
remove: "remove"
|
|
66180
66227
|
};
|
|
66181
66228
|
|
|
66182
|
-
// src/runtime/cache/stuff.ts
|
|
66183
|
-
function evaluateKey(key, variables = null) {
|
|
66184
|
-
let evaluated = "";
|
|
66185
|
-
let varName = "";
|
|
66186
|
-
let inString = false;
|
|
66187
|
-
for (const char of key) {
|
|
66188
|
-
if (varName) {
|
|
66189
|
-
if (varChars.includes(char)) {
|
|
66190
|
-
varName += char;
|
|
66191
|
-
continue;
|
|
66192
|
-
}
|
|
66193
|
-
const value = variables?.[varName.slice(1)];
|
|
66194
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
66195
|
-
varName = "";
|
|
66196
|
-
}
|
|
66197
|
-
if (char === "$" && !inString) {
|
|
66198
|
-
varName = "$";
|
|
66199
|
-
continue;
|
|
66200
|
-
}
|
|
66201
|
-
if (char === '"') {
|
|
66202
|
-
inString = !inString;
|
|
66203
|
-
}
|
|
66204
|
-
evaluated += char;
|
|
66205
|
-
}
|
|
66206
|
-
return evaluated;
|
|
66207
|
-
}
|
|
66208
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
66209
|
-
|
|
66210
66229
|
// src/runtime/cache/subscription.ts
|
|
66211
66230
|
var InMemorySubscriptions = class {
|
|
66212
66231
|
cache;
|
|
@@ -66218,6 +66237,9 @@ var InMemorySubscriptions = class {
|
|
|
66218
66237
|
activeFields(parent2) {
|
|
66219
66238
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
66220
66239
|
}
|
|
66240
|
+
copySubscribers(from, to) {
|
|
66241
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
66242
|
+
}
|
|
66221
66243
|
add({
|
|
66222
66244
|
parent: parent2,
|
|
66223
66245
|
spec,
|
|
@@ -66400,6 +66422,11 @@ var InMemorySubscriptions = class {
|
|
|
66400
66422
|
get(id, field) {
|
|
66401
66423
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
66402
66424
|
}
|
|
66425
|
+
getAll(id) {
|
|
66426
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
66427
|
+
(fieldSub) => fieldSub.selections
|
|
66428
|
+
);
|
|
66429
|
+
}
|
|
66403
66430
|
remove(id, selection, targets, variables, visited = []) {
|
|
66404
66431
|
visited.push(id);
|
|
66405
66432
|
const linkedIDs = [];
|
|
@@ -66441,7 +66468,7 @@ var InMemorySubscriptions = class {
|
|
|
66441
66468
|
}
|
|
66442
66469
|
const subscriberField = subscriber.get(fieldName);
|
|
66443
66470
|
for (const spec of specs) {
|
|
66444
|
-
const counts =
|
|
66471
|
+
const counts = subscriberField?.referenceCounts;
|
|
66445
66472
|
if (!counts?.has(spec.set)) {
|
|
66446
66473
|
continue;
|
|
66447
66474
|
}
|
|
@@ -66464,24 +66491,23 @@ var InMemorySubscriptions = class {
|
|
|
66464
66491
|
this.subscribers.delete(id);
|
|
66465
66492
|
}
|
|
66466
66493
|
}
|
|
66467
|
-
removeAllSubscribers(id, targets
|
|
66468
|
-
|
|
66469
|
-
|
|
66470
|
-
|
|
66471
|
-
|
|
66472
|
-
|
|
66473
|
-
|
|
66474
|
-
|
|
66475
|
-
|
|
66476
|
-
|
|
66477
|
-
|
|
66478
|
-
|
|
66479
|
-
|
|
66480
|
-
|
|
66481
|
-
}
|
|
66482
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
66494
|
+
removeAllSubscribers(id, targets) {
|
|
66495
|
+
if (!targets) {
|
|
66496
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
66497
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
66498
|
+
);
|
|
66499
|
+
}
|
|
66500
|
+
for (const target of targets) {
|
|
66501
|
+
for (const subselection of this.findSubSelections(
|
|
66502
|
+
target.parentID || rootID,
|
|
66503
|
+
target.selection,
|
|
66504
|
+
target.variables || {},
|
|
66505
|
+
id
|
|
66506
|
+
)) {
|
|
66507
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
66483
66508
|
}
|
|
66484
66509
|
}
|
|
66510
|
+
return;
|
|
66485
66511
|
}
|
|
66486
66512
|
get size() {
|
|
66487
66513
|
let size = 0;
|
|
@@ -66492,6 +66518,32 @@ var InMemorySubscriptions = class {
|
|
|
66492
66518
|
}
|
|
66493
66519
|
return size;
|
|
66494
66520
|
}
|
|
66521
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
66522
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
66523
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
66524
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
66525
|
+
if (!fieldSelection.selection) {
|
|
66526
|
+
continue;
|
|
66527
|
+
}
|
|
66528
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
66529
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
66530
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
66531
|
+
if (links.includes(searchTarget)) {
|
|
66532
|
+
selections.push(fieldSelection.selection);
|
|
66533
|
+
} else {
|
|
66534
|
+
for (const link of links) {
|
|
66535
|
+
this.findSubSelections(
|
|
66536
|
+
link,
|
|
66537
|
+
fieldSelection.selection,
|
|
66538
|
+
variables,
|
|
66539
|
+
searchTarget,
|
|
66540
|
+
selections
|
|
66541
|
+
);
|
|
66542
|
+
}
|
|
66543
|
+
}
|
|
66544
|
+
}
|
|
66545
|
+
return selections;
|
|
66546
|
+
}
|
|
66495
66547
|
};
|
|
66496
66548
|
|
|
66497
66549
|
// src/runtime/cache/cache.ts
|
|
@@ -66569,11 +66621,17 @@ var Cache = class {
|
|
|
66569
66621
|
}
|
|
66570
66622
|
registerKeyMap(source, mapped) {
|
|
66571
66623
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
66624
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
66572
66625
|
}
|
|
66573
66626
|
delete(id, layer) {
|
|
66574
|
-
this._internal_unstable.
|
|
66575
|
-
|
|
66576
|
-
|
|
66627
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
66628
|
+
Boolean
|
|
66629
|
+
);
|
|
66630
|
+
for (const recordID of recordIDs) {
|
|
66631
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
66632
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
66633
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
66634
|
+
}
|
|
66577
66635
|
}
|
|
66578
66636
|
setConfig(config) {
|
|
66579
66637
|
this._internal_unstable.setConfig(config);
|
|
@@ -66879,6 +66937,9 @@ var CacheInternal = class {
|
|
|
66879
66937
|
layer,
|
|
66880
66938
|
forceNotify
|
|
66881
66939
|
});
|
|
66940
|
+
let action = () => {
|
|
66941
|
+
layer.writeLink(parent2, key, linkedIDs);
|
|
66942
|
+
};
|
|
66882
66943
|
if (applyUpdates && updates) {
|
|
66883
66944
|
if (key === "edges") {
|
|
66884
66945
|
const newNodeIDs = [];
|
|
@@ -66913,8 +66974,26 @@ var CacheInternal = class {
|
|
|
66913
66974
|
}
|
|
66914
66975
|
if (update === "prepend") {
|
|
66915
66976
|
linkedIDs = newIDs.concat(oldIDs);
|
|
66977
|
+
if (layer?.optimistic) {
|
|
66978
|
+
action = () => {
|
|
66979
|
+
for (const id of newIDs) {
|
|
66980
|
+
if (id) {
|
|
66981
|
+
layer.insert(parent2, key, "start", id);
|
|
66982
|
+
}
|
|
66983
|
+
}
|
|
66984
|
+
};
|
|
66985
|
+
}
|
|
66916
66986
|
} else if (update === "append") {
|
|
66917
66987
|
linkedIDs = oldIDs.concat(newIDs);
|
|
66988
|
+
if (layer?.optimistic) {
|
|
66989
|
+
action = () => {
|
|
66990
|
+
for (const id of newIDs) {
|
|
66991
|
+
if (id) {
|
|
66992
|
+
layer.insert(parent2, key, "end", id);
|
|
66993
|
+
}
|
|
66994
|
+
}
|
|
66995
|
+
};
|
|
66996
|
+
}
|
|
66918
66997
|
} else if (update === "replace") {
|
|
66919
66998
|
linkedIDs = newIDs;
|
|
66920
66999
|
}
|
|
@@ -66933,7 +67012,7 @@ var CacheInternal = class {
|
|
|
66933
67012
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
66934
67013
|
}
|
|
66935
67014
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
66936
|
-
|
|
67015
|
+
action();
|
|
66937
67016
|
}
|
|
66938
67017
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
66939
67018
|
if (id == null) {
|
|
@@ -66988,6 +67067,9 @@ var CacheInternal = class {
|
|
|
66988
67067
|
if (!targetID) {
|
|
66989
67068
|
continue;
|
|
66990
67069
|
}
|
|
67070
|
+
toNotify.push(
|
|
67071
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
67072
|
+
);
|
|
66991
67073
|
this.cache.delete(targetID, layer);
|
|
66992
67074
|
}
|
|
66993
67075
|
}
|
|
@@ -67409,7 +67491,6 @@ function variableValue(value, args) {
|
|
|
67409
67491
|
);
|
|
67410
67492
|
}
|
|
67411
67493
|
}
|
|
67412
|
-
var rootID = "_ROOT_";
|
|
67413
67494
|
function defaultComponentField({
|
|
67414
67495
|
cache,
|
|
67415
67496
|
component,
|
|
@@ -78335,12 +78416,12 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
78335
78416
|
}
|
|
78336
78417
|
packageJSON2.devDependencies = {
|
|
78337
78418
|
...packageJSON2.devDependencies,
|
|
78338
|
-
houdini: "^1.2.
|
|
78419
|
+
houdini: "^1.2.55"
|
|
78339
78420
|
};
|
|
78340
78421
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
78341
78422
|
packageJSON2.devDependencies = {
|
|
78342
78423
|
...packageJSON2.devDependencies,
|
|
78343
|
-
"houdini-svelte": "^1.2.
|
|
78424
|
+
"houdini-svelte": "^1.2.55"
|
|
78344
78425
|
};
|
|
78345
78426
|
} else {
|
|
78346
78427
|
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
|
|
@@ -54513,6 +54513,35 @@ var GarbageCollector = class {
|
|
|
54513
54513
|
}
|
|
54514
54514
|
};
|
|
54515
54515
|
|
|
54516
|
+
// src/runtime/cache/stuff.ts
|
|
54517
|
+
function evaluateKey(key, variables = null) {
|
|
54518
|
+
let evaluated = "";
|
|
54519
|
+
let varName = "";
|
|
54520
|
+
let inString = false;
|
|
54521
|
+
for (const char of key) {
|
|
54522
|
+
if (varName) {
|
|
54523
|
+
if (varChars.includes(char)) {
|
|
54524
|
+
varName += char;
|
|
54525
|
+
continue;
|
|
54526
|
+
}
|
|
54527
|
+
const value = variables?.[varName.slice(1)];
|
|
54528
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
54529
|
+
varName = "";
|
|
54530
|
+
}
|
|
54531
|
+
if (char === "$" && !inString) {
|
|
54532
|
+
varName = "$";
|
|
54533
|
+
continue;
|
|
54534
|
+
}
|
|
54535
|
+
if (char === '"') {
|
|
54536
|
+
inString = !inString;
|
|
54537
|
+
}
|
|
54538
|
+
evaluated += char;
|
|
54539
|
+
}
|
|
54540
|
+
return evaluated;
|
|
54541
|
+
}
|
|
54542
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
54543
|
+
var rootID = "_ROOT_";
|
|
54544
|
+
|
|
54516
54545
|
// src/runtime/cache/lists.ts
|
|
54517
54546
|
var ListManager = class {
|
|
54518
54547
|
rootID;
|
|
@@ -54579,11 +54608,15 @@ var ListManager = class {
|
|
|
54579
54608
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
54580
54609
|
}
|
|
54581
54610
|
removeIDFromAllLists(id, layer) {
|
|
54611
|
+
let removed = false;
|
|
54582
54612
|
for (const fieldMap of this.lists.values()) {
|
|
54583
54613
|
for (const list of fieldMap.values()) {
|
|
54584
|
-
list.removeID(id, void 0, layer)
|
|
54614
|
+
if (list.removeID(id, void 0, layer)) {
|
|
54615
|
+
removed = true;
|
|
54616
|
+
}
|
|
54585
54617
|
}
|
|
54586
54618
|
}
|
|
54619
|
+
return removed;
|
|
54587
54620
|
}
|
|
54588
54621
|
deleteField(parentID, field) {
|
|
54589
54622
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -54886,7 +54919,13 @@ var ListCollection = class {
|
|
|
54886
54919
|
this.lists.forEach((list) => list.addToList(...args));
|
|
54887
54920
|
}
|
|
54888
54921
|
removeID(...args) {
|
|
54889
|
-
|
|
54922
|
+
let removed = false;
|
|
54923
|
+
this.lists.forEach((list) => {
|
|
54924
|
+
if (list.removeID(...args)) {
|
|
54925
|
+
removed = true;
|
|
54926
|
+
}
|
|
54927
|
+
});
|
|
54928
|
+
return removed;
|
|
54890
54929
|
}
|
|
54891
54930
|
remove(...args) {
|
|
54892
54931
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -55005,6 +55044,7 @@ var InMemoryStorage = class {
|
|
|
55005
55044
|
}
|
|
55006
55045
|
registerIDMapping(from, to) {
|
|
55007
55046
|
this.idMaps[from] = to;
|
|
55047
|
+
this.idMaps[to] = from;
|
|
55008
55048
|
}
|
|
55009
55049
|
createLayer(optimistic = false) {
|
|
55010
55050
|
const layer = new Layer(this.idCount++);
|
|
@@ -55015,11 +55055,11 @@ var InMemoryStorage = class {
|
|
|
55015
55055
|
insert(id, field, location, target) {
|
|
55016
55056
|
return this.topLayer.insert(id, field, location, target);
|
|
55017
55057
|
}
|
|
55018
|
-
remove(id, field, target,
|
|
55019
|
-
return
|
|
55058
|
+
remove(id, field, target, layer = this.topLayer) {
|
|
55059
|
+
return layer.remove(id, field, target);
|
|
55020
55060
|
}
|
|
55021
|
-
delete(id,
|
|
55022
|
-
return
|
|
55061
|
+
delete(id, layer = this.topLayer) {
|
|
55062
|
+
return layer.delete(id);
|
|
55023
55063
|
}
|
|
55024
55064
|
deleteField(id, field) {
|
|
55025
55065
|
return this.topLayer.deleteField(id, field);
|
|
@@ -55057,6 +55097,9 @@ var InMemoryStorage = class {
|
|
|
55057
55097
|
return;
|
|
55058
55098
|
}
|
|
55059
55099
|
operations.remove.add(v);
|
|
55100
|
+
if (this.idMaps[v]) {
|
|
55101
|
+
operations.remove.add(this.idMaps[v]);
|
|
55102
|
+
}
|
|
55060
55103
|
});
|
|
55061
55104
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
55062
55105
|
const targetLayer = this.topLayer;
|
|
@@ -55083,7 +55126,11 @@ var InMemoryStorage = class {
|
|
|
55083
55126
|
operations.remove.add(op.id);
|
|
55084
55127
|
}
|
|
55085
55128
|
if (isInsertOperation(op)) {
|
|
55086
|
-
|
|
55129
|
+
if (op.location === OperationLocation.end) {
|
|
55130
|
+
operations.insert[op.location].unshift(op.id);
|
|
55131
|
+
} else {
|
|
55132
|
+
operations.insert[op.location].push(op.id);
|
|
55133
|
+
}
|
|
55087
55134
|
}
|
|
55088
55135
|
if (isDeleteOperation(op)) {
|
|
55089
55136
|
return {
|
|
@@ -55329,7 +55376,7 @@ var Layer = class {
|
|
|
55329
55376
|
}
|
|
55330
55377
|
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
55331
55378
|
const fields = {};
|
|
55332
|
-
for (const opMap of [
|
|
55379
|
+
for (const opMap of [layer.operations[id], this.operations[id]].filter(Boolean)) {
|
|
55333
55380
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
55334
55381
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
55335
55382
|
}
|
|
@@ -55394,34 +55441,6 @@ var OperationKind = {
|
|
|
55394
55441
|
remove: "remove"
|
|
55395
55442
|
};
|
|
55396
55443
|
|
|
55397
|
-
// src/runtime/cache/stuff.ts
|
|
55398
|
-
function evaluateKey(key, variables = null) {
|
|
55399
|
-
let evaluated = "";
|
|
55400
|
-
let varName = "";
|
|
55401
|
-
let inString = false;
|
|
55402
|
-
for (const char of key) {
|
|
55403
|
-
if (varName) {
|
|
55404
|
-
if (varChars.includes(char)) {
|
|
55405
|
-
varName += char;
|
|
55406
|
-
continue;
|
|
55407
|
-
}
|
|
55408
|
-
const value = variables?.[varName.slice(1)];
|
|
55409
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
55410
|
-
varName = "";
|
|
55411
|
-
}
|
|
55412
|
-
if (char === "$" && !inString) {
|
|
55413
|
-
varName = "$";
|
|
55414
|
-
continue;
|
|
55415
|
-
}
|
|
55416
|
-
if (char === '"') {
|
|
55417
|
-
inString = !inString;
|
|
55418
|
-
}
|
|
55419
|
-
evaluated += char;
|
|
55420
|
-
}
|
|
55421
|
-
return evaluated;
|
|
55422
|
-
}
|
|
55423
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
55424
|
-
|
|
55425
55444
|
// src/runtime/cache/subscription.ts
|
|
55426
55445
|
var InMemorySubscriptions = class {
|
|
55427
55446
|
cache;
|
|
@@ -55433,6 +55452,9 @@ var InMemorySubscriptions = class {
|
|
|
55433
55452
|
activeFields(parent2) {
|
|
55434
55453
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
55435
55454
|
}
|
|
55455
|
+
copySubscribers(from, to) {
|
|
55456
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
55457
|
+
}
|
|
55436
55458
|
add({
|
|
55437
55459
|
parent: parent2,
|
|
55438
55460
|
spec,
|
|
@@ -55615,6 +55637,11 @@ var InMemorySubscriptions = class {
|
|
|
55615
55637
|
get(id, field) {
|
|
55616
55638
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
55617
55639
|
}
|
|
55640
|
+
getAll(id) {
|
|
55641
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
55642
|
+
(fieldSub) => fieldSub.selections
|
|
55643
|
+
);
|
|
55644
|
+
}
|
|
55618
55645
|
remove(id, selection, targets, variables, visited = []) {
|
|
55619
55646
|
visited.push(id);
|
|
55620
55647
|
const linkedIDs = [];
|
|
@@ -55656,7 +55683,7 @@ var InMemorySubscriptions = class {
|
|
|
55656
55683
|
}
|
|
55657
55684
|
const subscriberField = subscriber.get(fieldName);
|
|
55658
55685
|
for (const spec of specs) {
|
|
55659
|
-
const counts =
|
|
55686
|
+
const counts = subscriberField?.referenceCounts;
|
|
55660
55687
|
if (!counts?.has(spec.set)) {
|
|
55661
55688
|
continue;
|
|
55662
55689
|
}
|
|
@@ -55679,24 +55706,23 @@ var InMemorySubscriptions = class {
|
|
|
55679
55706
|
this.subscribers.delete(id);
|
|
55680
55707
|
}
|
|
55681
55708
|
}
|
|
55682
|
-
removeAllSubscribers(id, targets
|
|
55683
|
-
|
|
55684
|
-
|
|
55685
|
-
|
|
55686
|
-
|
|
55687
|
-
|
|
55688
|
-
|
|
55689
|
-
|
|
55690
|
-
|
|
55691
|
-
|
|
55692
|
-
|
|
55693
|
-
|
|
55694
|
-
|
|
55695
|
-
|
|
55696
|
-
}
|
|
55697
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
55709
|
+
removeAllSubscribers(id, targets) {
|
|
55710
|
+
if (!targets) {
|
|
55711
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
55712
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
55713
|
+
);
|
|
55714
|
+
}
|
|
55715
|
+
for (const target of targets) {
|
|
55716
|
+
for (const subselection of this.findSubSelections(
|
|
55717
|
+
target.parentID || rootID,
|
|
55718
|
+
target.selection,
|
|
55719
|
+
target.variables || {},
|
|
55720
|
+
id
|
|
55721
|
+
)) {
|
|
55722
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
55698
55723
|
}
|
|
55699
55724
|
}
|
|
55725
|
+
return;
|
|
55700
55726
|
}
|
|
55701
55727
|
get size() {
|
|
55702
55728
|
let size = 0;
|
|
@@ -55707,6 +55733,32 @@ var InMemorySubscriptions = class {
|
|
|
55707
55733
|
}
|
|
55708
55734
|
return size;
|
|
55709
55735
|
}
|
|
55736
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
55737
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
55738
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
55739
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
55740
|
+
if (!fieldSelection.selection) {
|
|
55741
|
+
continue;
|
|
55742
|
+
}
|
|
55743
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
55744
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
55745
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
55746
|
+
if (links.includes(searchTarget)) {
|
|
55747
|
+
selections.push(fieldSelection.selection);
|
|
55748
|
+
} else {
|
|
55749
|
+
for (const link of links) {
|
|
55750
|
+
this.findSubSelections(
|
|
55751
|
+
link,
|
|
55752
|
+
fieldSelection.selection,
|
|
55753
|
+
variables,
|
|
55754
|
+
searchTarget,
|
|
55755
|
+
selections
|
|
55756
|
+
);
|
|
55757
|
+
}
|
|
55758
|
+
}
|
|
55759
|
+
}
|
|
55760
|
+
return selections;
|
|
55761
|
+
}
|
|
55710
55762
|
};
|
|
55711
55763
|
|
|
55712
55764
|
// src/runtime/cache/cache.ts
|
|
@@ -55784,11 +55836,17 @@ var Cache = class {
|
|
|
55784
55836
|
}
|
|
55785
55837
|
registerKeyMap(source, mapped) {
|
|
55786
55838
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
55839
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
55787
55840
|
}
|
|
55788
55841
|
delete(id, layer) {
|
|
55789
|
-
this._internal_unstable.
|
|
55790
|
-
|
|
55791
|
-
|
|
55842
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
55843
|
+
Boolean
|
|
55844
|
+
);
|
|
55845
|
+
for (const recordID of recordIDs) {
|
|
55846
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
55847
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
55848
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
55849
|
+
}
|
|
55792
55850
|
}
|
|
55793
55851
|
setConfig(config) {
|
|
55794
55852
|
this._internal_unstable.setConfig(config);
|
|
@@ -56094,6 +56152,9 @@ var CacheInternal = class {
|
|
|
56094
56152
|
layer,
|
|
56095
56153
|
forceNotify
|
|
56096
56154
|
});
|
|
56155
|
+
let action = () => {
|
|
56156
|
+
layer.writeLink(parent2, key, linkedIDs);
|
|
56157
|
+
};
|
|
56097
56158
|
if (applyUpdates && updates) {
|
|
56098
56159
|
if (key === "edges") {
|
|
56099
56160
|
const newNodeIDs = [];
|
|
@@ -56128,8 +56189,26 @@ var CacheInternal = class {
|
|
|
56128
56189
|
}
|
|
56129
56190
|
if (update === "prepend") {
|
|
56130
56191
|
linkedIDs = newIDs.concat(oldIDs);
|
|
56192
|
+
if (layer?.optimistic) {
|
|
56193
|
+
action = () => {
|
|
56194
|
+
for (const id of newIDs) {
|
|
56195
|
+
if (id) {
|
|
56196
|
+
layer.insert(parent2, key, "start", id);
|
|
56197
|
+
}
|
|
56198
|
+
}
|
|
56199
|
+
};
|
|
56200
|
+
}
|
|
56131
56201
|
} else if (update === "append") {
|
|
56132
56202
|
linkedIDs = oldIDs.concat(newIDs);
|
|
56203
|
+
if (layer?.optimistic) {
|
|
56204
|
+
action = () => {
|
|
56205
|
+
for (const id of newIDs) {
|
|
56206
|
+
if (id) {
|
|
56207
|
+
layer.insert(parent2, key, "end", id);
|
|
56208
|
+
}
|
|
56209
|
+
}
|
|
56210
|
+
};
|
|
56211
|
+
}
|
|
56133
56212
|
} else if (update === "replace") {
|
|
56134
56213
|
linkedIDs = newIDs;
|
|
56135
56214
|
}
|
|
@@ -56148,7 +56227,7 @@ var CacheInternal = class {
|
|
|
56148
56227
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
56149
56228
|
}
|
|
56150
56229
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
56151
|
-
|
|
56230
|
+
action();
|
|
56152
56231
|
}
|
|
56153
56232
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
56154
56233
|
if (id == null) {
|
|
@@ -56203,6 +56282,9 @@ var CacheInternal = class {
|
|
|
56203
56282
|
if (!targetID) {
|
|
56204
56283
|
continue;
|
|
56205
56284
|
}
|
|
56285
|
+
toNotify.push(
|
|
56286
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
56287
|
+
);
|
|
56206
56288
|
this.cache.delete(targetID, layer);
|
|
56207
56289
|
}
|
|
56208
56290
|
}
|
|
@@ -56624,7 +56706,6 @@ function variableValue(value, args) {
|
|
|
56624
56706
|
);
|
|
56625
56707
|
}
|
|
56626
56708
|
}
|
|
56627
|
-
var rootID = "_ROOT_";
|
|
56628
56709
|
function defaultComponentField({
|
|
56629
56710
|
cache,
|
|
56630
56711
|
component,
|