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/test-esm/index.js
CHANGED
|
@@ -54520,6 +54520,35 @@ var GarbageCollector = class {
|
|
|
54520
54520
|
}
|
|
54521
54521
|
};
|
|
54522
54522
|
|
|
54523
|
+
// src/runtime/cache/stuff.ts
|
|
54524
|
+
function evaluateKey(key, variables = null) {
|
|
54525
|
+
let evaluated = "";
|
|
54526
|
+
let varName = "";
|
|
54527
|
+
let inString = false;
|
|
54528
|
+
for (const char of key) {
|
|
54529
|
+
if (varName) {
|
|
54530
|
+
if (varChars.includes(char)) {
|
|
54531
|
+
varName += char;
|
|
54532
|
+
continue;
|
|
54533
|
+
}
|
|
54534
|
+
const value = variables?.[varName.slice(1)];
|
|
54535
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
54536
|
+
varName = "";
|
|
54537
|
+
}
|
|
54538
|
+
if (char === "$" && !inString) {
|
|
54539
|
+
varName = "$";
|
|
54540
|
+
continue;
|
|
54541
|
+
}
|
|
54542
|
+
if (char === '"') {
|
|
54543
|
+
inString = !inString;
|
|
54544
|
+
}
|
|
54545
|
+
evaluated += char;
|
|
54546
|
+
}
|
|
54547
|
+
return evaluated;
|
|
54548
|
+
}
|
|
54549
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
54550
|
+
var rootID = "_ROOT_";
|
|
54551
|
+
|
|
54523
54552
|
// src/runtime/cache/lists.ts
|
|
54524
54553
|
var ListManager = class {
|
|
54525
54554
|
rootID;
|
|
@@ -54586,11 +54615,15 @@ var ListManager = class {
|
|
|
54586
54615
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
54587
54616
|
}
|
|
54588
54617
|
removeIDFromAllLists(id, layer) {
|
|
54618
|
+
let removed = false;
|
|
54589
54619
|
for (const fieldMap of this.lists.values()) {
|
|
54590
54620
|
for (const list of fieldMap.values()) {
|
|
54591
|
-
list.removeID(id, void 0, layer)
|
|
54621
|
+
if (list.removeID(id, void 0, layer)) {
|
|
54622
|
+
removed = true;
|
|
54623
|
+
}
|
|
54592
54624
|
}
|
|
54593
54625
|
}
|
|
54626
|
+
return removed;
|
|
54594
54627
|
}
|
|
54595
54628
|
deleteField(parentID, field) {
|
|
54596
54629
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -54893,7 +54926,13 @@ var ListCollection = class {
|
|
|
54893
54926
|
this.lists.forEach((list) => list.addToList(...args));
|
|
54894
54927
|
}
|
|
54895
54928
|
removeID(...args) {
|
|
54896
|
-
|
|
54929
|
+
let removed = false;
|
|
54930
|
+
this.lists.forEach((list) => {
|
|
54931
|
+
if (list.removeID(...args)) {
|
|
54932
|
+
removed = true;
|
|
54933
|
+
}
|
|
54934
|
+
});
|
|
54935
|
+
return removed;
|
|
54897
54936
|
}
|
|
54898
54937
|
remove(...args) {
|
|
54899
54938
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -55012,6 +55051,7 @@ var InMemoryStorage = class {
|
|
|
55012
55051
|
}
|
|
55013
55052
|
registerIDMapping(from, to) {
|
|
55014
55053
|
this.idMaps[from] = to;
|
|
55054
|
+
this.idMaps[to] = from;
|
|
55015
55055
|
}
|
|
55016
55056
|
createLayer(optimistic = false) {
|
|
55017
55057
|
const layer = new Layer(this.idCount++);
|
|
@@ -55022,11 +55062,11 @@ var InMemoryStorage = class {
|
|
|
55022
55062
|
insert(id, field, location, target) {
|
|
55023
55063
|
return this.topLayer.insert(id, field, location, target);
|
|
55024
55064
|
}
|
|
55025
|
-
remove(id, field, target,
|
|
55026
|
-
return
|
|
55065
|
+
remove(id, field, target, layer = this.topLayer) {
|
|
55066
|
+
return layer.remove(id, field, target);
|
|
55027
55067
|
}
|
|
55028
|
-
delete(id,
|
|
55029
|
-
return
|
|
55068
|
+
delete(id, layer = this.topLayer) {
|
|
55069
|
+
return layer.delete(id);
|
|
55030
55070
|
}
|
|
55031
55071
|
deleteField(id, field) {
|
|
55032
55072
|
return this.topLayer.deleteField(id, field);
|
|
@@ -55064,6 +55104,9 @@ var InMemoryStorage = class {
|
|
|
55064
55104
|
return;
|
|
55065
55105
|
}
|
|
55066
55106
|
operations.remove.add(v);
|
|
55107
|
+
if (this.idMaps[v]) {
|
|
55108
|
+
operations.remove.add(this.idMaps[v]);
|
|
55109
|
+
}
|
|
55067
55110
|
});
|
|
55068
55111
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
55069
55112
|
const targetLayer = this.topLayer;
|
|
@@ -55090,7 +55133,11 @@ var InMemoryStorage = class {
|
|
|
55090
55133
|
operations.remove.add(op.id);
|
|
55091
55134
|
}
|
|
55092
55135
|
if (isInsertOperation(op)) {
|
|
55093
|
-
|
|
55136
|
+
if (op.location === OperationLocation.end) {
|
|
55137
|
+
operations.insert[op.location].unshift(op.id);
|
|
55138
|
+
} else {
|
|
55139
|
+
operations.insert[op.location].push(op.id);
|
|
55140
|
+
}
|
|
55094
55141
|
}
|
|
55095
55142
|
if (isDeleteOperation(op)) {
|
|
55096
55143
|
return {
|
|
@@ -55336,7 +55383,7 @@ var Layer = class {
|
|
|
55336
55383
|
}
|
|
55337
55384
|
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
55338
55385
|
const fields = {};
|
|
55339
|
-
for (const opMap of [
|
|
55386
|
+
for (const opMap of [layer.operations[id], this.operations[id]].filter(Boolean)) {
|
|
55340
55387
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
55341
55388
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
55342
55389
|
}
|
|
@@ -55401,34 +55448,6 @@ var OperationKind = {
|
|
|
55401
55448
|
remove: "remove"
|
|
55402
55449
|
};
|
|
55403
55450
|
|
|
55404
|
-
// src/runtime/cache/stuff.ts
|
|
55405
|
-
function evaluateKey(key, variables = null) {
|
|
55406
|
-
let evaluated = "";
|
|
55407
|
-
let varName = "";
|
|
55408
|
-
let inString = false;
|
|
55409
|
-
for (const char of key) {
|
|
55410
|
-
if (varName) {
|
|
55411
|
-
if (varChars.includes(char)) {
|
|
55412
|
-
varName += char;
|
|
55413
|
-
continue;
|
|
55414
|
-
}
|
|
55415
|
-
const value = variables?.[varName.slice(1)];
|
|
55416
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
55417
|
-
varName = "";
|
|
55418
|
-
}
|
|
55419
|
-
if (char === "$" && !inString) {
|
|
55420
|
-
varName = "$";
|
|
55421
|
-
continue;
|
|
55422
|
-
}
|
|
55423
|
-
if (char === '"') {
|
|
55424
|
-
inString = !inString;
|
|
55425
|
-
}
|
|
55426
|
-
evaluated += char;
|
|
55427
|
-
}
|
|
55428
|
-
return evaluated;
|
|
55429
|
-
}
|
|
55430
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
55431
|
-
|
|
55432
55451
|
// src/runtime/cache/subscription.ts
|
|
55433
55452
|
var InMemorySubscriptions = class {
|
|
55434
55453
|
cache;
|
|
@@ -55440,6 +55459,9 @@ var InMemorySubscriptions = class {
|
|
|
55440
55459
|
activeFields(parent2) {
|
|
55441
55460
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
55442
55461
|
}
|
|
55462
|
+
copySubscribers(from, to) {
|
|
55463
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
55464
|
+
}
|
|
55443
55465
|
add({
|
|
55444
55466
|
parent: parent2,
|
|
55445
55467
|
spec,
|
|
@@ -55622,6 +55644,11 @@ var InMemorySubscriptions = class {
|
|
|
55622
55644
|
get(id, field) {
|
|
55623
55645
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
55624
55646
|
}
|
|
55647
|
+
getAll(id) {
|
|
55648
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
55649
|
+
(fieldSub) => fieldSub.selections
|
|
55650
|
+
);
|
|
55651
|
+
}
|
|
55625
55652
|
remove(id, selection, targets, variables, visited = []) {
|
|
55626
55653
|
visited.push(id);
|
|
55627
55654
|
const linkedIDs = [];
|
|
@@ -55663,7 +55690,7 @@ var InMemorySubscriptions = class {
|
|
|
55663
55690
|
}
|
|
55664
55691
|
const subscriberField = subscriber.get(fieldName);
|
|
55665
55692
|
for (const spec of specs) {
|
|
55666
|
-
const counts =
|
|
55693
|
+
const counts = subscriberField?.referenceCounts;
|
|
55667
55694
|
if (!counts?.has(spec.set)) {
|
|
55668
55695
|
continue;
|
|
55669
55696
|
}
|
|
@@ -55686,24 +55713,23 @@ var InMemorySubscriptions = class {
|
|
|
55686
55713
|
this.subscribers.delete(id);
|
|
55687
55714
|
}
|
|
55688
55715
|
}
|
|
55689
|
-
removeAllSubscribers(id, targets
|
|
55690
|
-
|
|
55691
|
-
|
|
55692
|
-
|
|
55693
|
-
|
|
55694
|
-
|
|
55695
|
-
|
|
55696
|
-
|
|
55697
|
-
|
|
55698
|
-
|
|
55699
|
-
|
|
55700
|
-
|
|
55701
|
-
|
|
55702
|
-
|
|
55703
|
-
}
|
|
55704
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
55716
|
+
removeAllSubscribers(id, targets) {
|
|
55717
|
+
if (!targets) {
|
|
55718
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
55719
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
55720
|
+
);
|
|
55721
|
+
}
|
|
55722
|
+
for (const target of targets) {
|
|
55723
|
+
for (const subselection of this.findSubSelections(
|
|
55724
|
+
target.parentID || rootID,
|
|
55725
|
+
target.selection,
|
|
55726
|
+
target.variables || {},
|
|
55727
|
+
id
|
|
55728
|
+
)) {
|
|
55729
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
55705
55730
|
}
|
|
55706
55731
|
}
|
|
55732
|
+
return;
|
|
55707
55733
|
}
|
|
55708
55734
|
get size() {
|
|
55709
55735
|
let size = 0;
|
|
@@ -55714,6 +55740,32 @@ var InMemorySubscriptions = class {
|
|
|
55714
55740
|
}
|
|
55715
55741
|
return size;
|
|
55716
55742
|
}
|
|
55743
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
55744
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
55745
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
55746
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
55747
|
+
if (!fieldSelection.selection) {
|
|
55748
|
+
continue;
|
|
55749
|
+
}
|
|
55750
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
55751
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
55752
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
55753
|
+
if (links.includes(searchTarget)) {
|
|
55754
|
+
selections.push(fieldSelection.selection);
|
|
55755
|
+
} else {
|
|
55756
|
+
for (const link of links) {
|
|
55757
|
+
this.findSubSelections(
|
|
55758
|
+
link,
|
|
55759
|
+
fieldSelection.selection,
|
|
55760
|
+
variables,
|
|
55761
|
+
searchTarget,
|
|
55762
|
+
selections
|
|
55763
|
+
);
|
|
55764
|
+
}
|
|
55765
|
+
}
|
|
55766
|
+
}
|
|
55767
|
+
return selections;
|
|
55768
|
+
}
|
|
55717
55769
|
};
|
|
55718
55770
|
|
|
55719
55771
|
// src/runtime/cache/cache.ts
|
|
@@ -55791,11 +55843,17 @@ var Cache = class {
|
|
|
55791
55843
|
}
|
|
55792
55844
|
registerKeyMap(source, mapped) {
|
|
55793
55845
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
55846
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
55794
55847
|
}
|
|
55795
55848
|
delete(id, layer) {
|
|
55796
|
-
this._internal_unstable.
|
|
55797
|
-
|
|
55798
|
-
|
|
55849
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
55850
|
+
Boolean
|
|
55851
|
+
);
|
|
55852
|
+
for (const recordID of recordIDs) {
|
|
55853
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
55854
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
55855
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
55856
|
+
}
|
|
55799
55857
|
}
|
|
55800
55858
|
setConfig(config) {
|
|
55801
55859
|
this._internal_unstable.setConfig(config);
|
|
@@ -56101,6 +56159,9 @@ var CacheInternal = class {
|
|
|
56101
56159
|
layer,
|
|
56102
56160
|
forceNotify
|
|
56103
56161
|
});
|
|
56162
|
+
let action = () => {
|
|
56163
|
+
layer.writeLink(parent2, key, linkedIDs);
|
|
56164
|
+
};
|
|
56104
56165
|
if (applyUpdates && updates) {
|
|
56105
56166
|
if (key === "edges") {
|
|
56106
56167
|
const newNodeIDs = [];
|
|
@@ -56135,8 +56196,26 @@ var CacheInternal = class {
|
|
|
56135
56196
|
}
|
|
56136
56197
|
if (update === "prepend") {
|
|
56137
56198
|
linkedIDs = newIDs.concat(oldIDs);
|
|
56199
|
+
if (layer?.optimistic) {
|
|
56200
|
+
action = () => {
|
|
56201
|
+
for (const id of newIDs) {
|
|
56202
|
+
if (id) {
|
|
56203
|
+
layer.insert(parent2, key, "start", id);
|
|
56204
|
+
}
|
|
56205
|
+
}
|
|
56206
|
+
};
|
|
56207
|
+
}
|
|
56138
56208
|
} else if (update === "append") {
|
|
56139
56209
|
linkedIDs = oldIDs.concat(newIDs);
|
|
56210
|
+
if (layer?.optimistic) {
|
|
56211
|
+
action = () => {
|
|
56212
|
+
for (const id of newIDs) {
|
|
56213
|
+
if (id) {
|
|
56214
|
+
layer.insert(parent2, key, "end", id);
|
|
56215
|
+
}
|
|
56216
|
+
}
|
|
56217
|
+
};
|
|
56218
|
+
}
|
|
56140
56219
|
} else if (update === "replace") {
|
|
56141
56220
|
linkedIDs = newIDs;
|
|
56142
56221
|
}
|
|
@@ -56155,7 +56234,7 @@ var CacheInternal = class {
|
|
|
56155
56234
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
56156
56235
|
}
|
|
56157
56236
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
56158
|
-
|
|
56237
|
+
action();
|
|
56159
56238
|
}
|
|
56160
56239
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
56161
56240
|
if (id == null) {
|
|
@@ -56210,6 +56289,9 @@ var CacheInternal = class {
|
|
|
56210
56289
|
if (!targetID) {
|
|
56211
56290
|
continue;
|
|
56212
56291
|
}
|
|
56292
|
+
toNotify.push(
|
|
56293
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
56294
|
+
);
|
|
56213
56295
|
this.cache.delete(targetID, layer);
|
|
56214
56296
|
}
|
|
56215
56297
|
}
|
|
@@ -56631,7 +56713,6 @@ function variableValue(value, args) {
|
|
|
56631
56713
|
);
|
|
56632
56714
|
}
|
|
56633
56715
|
}
|
|
56634
|
-
var rootID = "_ROOT_";
|
|
56635
56716
|
function defaultComponentField({
|
|
56636
56717
|
cache,
|
|
56637
56718
|
component,
|
package/build/vite-cjs/index.js
CHANGED
|
@@ -66689,6 +66689,35 @@ var GarbageCollector = class {
|
|
|
66689
66689
|
}
|
|
66690
66690
|
};
|
|
66691
66691
|
|
|
66692
|
+
// src/runtime/cache/stuff.ts
|
|
66693
|
+
function evaluateKey(key, variables = null) {
|
|
66694
|
+
let evaluated = "";
|
|
66695
|
+
let varName = "";
|
|
66696
|
+
let inString = false;
|
|
66697
|
+
for (const char of key) {
|
|
66698
|
+
if (varName) {
|
|
66699
|
+
if (varChars.includes(char)) {
|
|
66700
|
+
varName += char;
|
|
66701
|
+
continue;
|
|
66702
|
+
}
|
|
66703
|
+
const value = variables?.[varName.slice(1)];
|
|
66704
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
66705
|
+
varName = "";
|
|
66706
|
+
}
|
|
66707
|
+
if (char === "$" && !inString) {
|
|
66708
|
+
varName = "$";
|
|
66709
|
+
continue;
|
|
66710
|
+
}
|
|
66711
|
+
if (char === '"') {
|
|
66712
|
+
inString = !inString;
|
|
66713
|
+
}
|
|
66714
|
+
evaluated += char;
|
|
66715
|
+
}
|
|
66716
|
+
return evaluated;
|
|
66717
|
+
}
|
|
66718
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
66719
|
+
var rootID = "_ROOT_";
|
|
66720
|
+
|
|
66692
66721
|
// src/runtime/cache/lists.ts
|
|
66693
66722
|
var ListManager = class {
|
|
66694
66723
|
rootID;
|
|
@@ -66755,11 +66784,15 @@ var ListManager = class {
|
|
|
66755
66784
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
66756
66785
|
}
|
|
66757
66786
|
removeIDFromAllLists(id, layer) {
|
|
66787
|
+
let removed = false;
|
|
66758
66788
|
for (const fieldMap of this.lists.values()) {
|
|
66759
66789
|
for (const list of fieldMap.values()) {
|
|
66760
|
-
list.removeID(id, void 0, layer)
|
|
66790
|
+
if (list.removeID(id, void 0, layer)) {
|
|
66791
|
+
removed = true;
|
|
66792
|
+
}
|
|
66761
66793
|
}
|
|
66762
66794
|
}
|
|
66795
|
+
return removed;
|
|
66763
66796
|
}
|
|
66764
66797
|
deleteField(parentID, field) {
|
|
66765
66798
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -67062,7 +67095,13 @@ var ListCollection = class {
|
|
|
67062
67095
|
this.lists.forEach((list) => list.addToList(...args));
|
|
67063
67096
|
}
|
|
67064
67097
|
removeID(...args) {
|
|
67065
|
-
|
|
67098
|
+
let removed = false;
|
|
67099
|
+
this.lists.forEach((list) => {
|
|
67100
|
+
if (list.removeID(...args)) {
|
|
67101
|
+
removed = true;
|
|
67102
|
+
}
|
|
67103
|
+
});
|
|
67104
|
+
return removed;
|
|
67066
67105
|
}
|
|
67067
67106
|
remove(...args) {
|
|
67068
67107
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -67181,6 +67220,7 @@ var InMemoryStorage = class {
|
|
|
67181
67220
|
}
|
|
67182
67221
|
registerIDMapping(from, to) {
|
|
67183
67222
|
this.idMaps[from] = to;
|
|
67223
|
+
this.idMaps[to] = from;
|
|
67184
67224
|
}
|
|
67185
67225
|
createLayer(optimistic = false) {
|
|
67186
67226
|
const layer = new Layer(this.idCount++);
|
|
@@ -67191,11 +67231,11 @@ var InMemoryStorage = class {
|
|
|
67191
67231
|
insert(id, field, location, target) {
|
|
67192
67232
|
return this.topLayer.insert(id, field, location, target);
|
|
67193
67233
|
}
|
|
67194
|
-
remove(id, field, target,
|
|
67195
|
-
return
|
|
67234
|
+
remove(id, field, target, layer = this.topLayer) {
|
|
67235
|
+
return layer.remove(id, field, target);
|
|
67196
67236
|
}
|
|
67197
|
-
delete(id,
|
|
67198
|
-
return
|
|
67237
|
+
delete(id, layer = this.topLayer) {
|
|
67238
|
+
return layer.delete(id);
|
|
67199
67239
|
}
|
|
67200
67240
|
deleteField(id, field) {
|
|
67201
67241
|
return this.topLayer.deleteField(id, field);
|
|
@@ -67233,6 +67273,9 @@ var InMemoryStorage = class {
|
|
|
67233
67273
|
return;
|
|
67234
67274
|
}
|
|
67235
67275
|
operations.remove.add(v);
|
|
67276
|
+
if (this.idMaps[v]) {
|
|
67277
|
+
operations.remove.add(this.idMaps[v]);
|
|
67278
|
+
}
|
|
67236
67279
|
});
|
|
67237
67280
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
67238
67281
|
const targetLayer = this.topLayer;
|
|
@@ -67259,7 +67302,11 @@ var InMemoryStorage = class {
|
|
|
67259
67302
|
operations.remove.add(op.id);
|
|
67260
67303
|
}
|
|
67261
67304
|
if (isInsertOperation(op)) {
|
|
67262
|
-
|
|
67305
|
+
if (op.location === OperationLocation.end) {
|
|
67306
|
+
operations.insert[op.location].unshift(op.id);
|
|
67307
|
+
} else {
|
|
67308
|
+
operations.insert[op.location].push(op.id);
|
|
67309
|
+
}
|
|
67263
67310
|
}
|
|
67264
67311
|
if (isDeleteOperation(op)) {
|
|
67265
67312
|
return {
|
|
@@ -67505,7 +67552,7 @@ var Layer = class {
|
|
|
67505
67552
|
}
|
|
67506
67553
|
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
67507
67554
|
const fields = {};
|
|
67508
|
-
for (const opMap of [
|
|
67555
|
+
for (const opMap of [layer.operations[id], this.operations[id]].filter(Boolean)) {
|
|
67509
67556
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
67510
67557
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
67511
67558
|
}
|
|
@@ -67570,34 +67617,6 @@ var OperationKind = {
|
|
|
67570
67617
|
remove: "remove"
|
|
67571
67618
|
};
|
|
67572
67619
|
|
|
67573
|
-
// src/runtime/cache/stuff.ts
|
|
67574
|
-
function evaluateKey(key, variables = null) {
|
|
67575
|
-
let evaluated = "";
|
|
67576
|
-
let varName = "";
|
|
67577
|
-
let inString = false;
|
|
67578
|
-
for (const char of key) {
|
|
67579
|
-
if (varName) {
|
|
67580
|
-
if (varChars.includes(char)) {
|
|
67581
|
-
varName += char;
|
|
67582
|
-
continue;
|
|
67583
|
-
}
|
|
67584
|
-
const value = variables?.[varName.slice(1)];
|
|
67585
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
67586
|
-
varName = "";
|
|
67587
|
-
}
|
|
67588
|
-
if (char === "$" && !inString) {
|
|
67589
|
-
varName = "$";
|
|
67590
|
-
continue;
|
|
67591
|
-
}
|
|
67592
|
-
if (char === '"') {
|
|
67593
|
-
inString = !inString;
|
|
67594
|
-
}
|
|
67595
|
-
evaluated += char;
|
|
67596
|
-
}
|
|
67597
|
-
return evaluated;
|
|
67598
|
-
}
|
|
67599
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
67600
|
-
|
|
67601
67620
|
// src/runtime/cache/subscription.ts
|
|
67602
67621
|
var InMemorySubscriptions = class {
|
|
67603
67622
|
cache;
|
|
@@ -67609,6 +67628,9 @@ var InMemorySubscriptions = class {
|
|
|
67609
67628
|
activeFields(parent2) {
|
|
67610
67629
|
return Object.keys(this.subscribers.get(parent2) || {});
|
|
67611
67630
|
}
|
|
67631
|
+
copySubscribers(from, to) {
|
|
67632
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
67633
|
+
}
|
|
67612
67634
|
add({
|
|
67613
67635
|
parent: parent2,
|
|
67614
67636
|
spec,
|
|
@@ -67791,6 +67813,11 @@ var InMemorySubscriptions = class {
|
|
|
67791
67813
|
get(id, field) {
|
|
67792
67814
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
67793
67815
|
}
|
|
67816
|
+
getAll(id) {
|
|
67817
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
67818
|
+
(fieldSub) => fieldSub.selections
|
|
67819
|
+
);
|
|
67820
|
+
}
|
|
67794
67821
|
remove(id, selection, targets, variables, visited = []) {
|
|
67795
67822
|
visited.push(id);
|
|
67796
67823
|
const linkedIDs = [];
|
|
@@ -67832,7 +67859,7 @@ var InMemorySubscriptions = class {
|
|
|
67832
67859
|
}
|
|
67833
67860
|
const subscriberField = subscriber.get(fieldName);
|
|
67834
67861
|
for (const spec of specs) {
|
|
67835
|
-
const counts =
|
|
67862
|
+
const counts = subscriberField?.referenceCounts;
|
|
67836
67863
|
if (!counts?.has(spec.set)) {
|
|
67837
67864
|
continue;
|
|
67838
67865
|
}
|
|
@@ -67855,24 +67882,23 @@ var InMemorySubscriptions = class {
|
|
|
67855
67882
|
this.subscribers.delete(id);
|
|
67856
67883
|
}
|
|
67857
67884
|
}
|
|
67858
|
-
removeAllSubscribers(id, targets
|
|
67859
|
-
|
|
67860
|
-
|
|
67861
|
-
|
|
67862
|
-
|
|
67863
|
-
|
|
67864
|
-
|
|
67865
|
-
|
|
67866
|
-
|
|
67867
|
-
|
|
67868
|
-
|
|
67869
|
-
|
|
67870
|
-
|
|
67871
|
-
|
|
67872
|
-
}
|
|
67873
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
67885
|
+
removeAllSubscribers(id, targets) {
|
|
67886
|
+
if (!targets) {
|
|
67887
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
67888
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
67889
|
+
);
|
|
67890
|
+
}
|
|
67891
|
+
for (const target of targets) {
|
|
67892
|
+
for (const subselection of this.findSubSelections(
|
|
67893
|
+
target.parentID || rootID,
|
|
67894
|
+
target.selection,
|
|
67895
|
+
target.variables || {},
|
|
67896
|
+
id
|
|
67897
|
+
)) {
|
|
67898
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
67874
67899
|
}
|
|
67875
67900
|
}
|
|
67901
|
+
return;
|
|
67876
67902
|
}
|
|
67877
67903
|
get size() {
|
|
67878
67904
|
let size = 0;
|
|
@@ -67883,6 +67909,32 @@ var InMemorySubscriptions = class {
|
|
|
67883
67909
|
}
|
|
67884
67910
|
return size;
|
|
67885
67911
|
}
|
|
67912
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
67913
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
67914
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
67915
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
67916
|
+
if (!fieldSelection.selection) {
|
|
67917
|
+
continue;
|
|
67918
|
+
}
|
|
67919
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
67920
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
67921
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
67922
|
+
if (links.includes(searchTarget)) {
|
|
67923
|
+
selections.push(fieldSelection.selection);
|
|
67924
|
+
} else {
|
|
67925
|
+
for (const link of links) {
|
|
67926
|
+
this.findSubSelections(
|
|
67927
|
+
link,
|
|
67928
|
+
fieldSelection.selection,
|
|
67929
|
+
variables,
|
|
67930
|
+
searchTarget,
|
|
67931
|
+
selections
|
|
67932
|
+
);
|
|
67933
|
+
}
|
|
67934
|
+
}
|
|
67935
|
+
}
|
|
67936
|
+
return selections;
|
|
67937
|
+
}
|
|
67886
67938
|
};
|
|
67887
67939
|
|
|
67888
67940
|
// src/runtime/cache/cache.ts
|
|
@@ -67960,11 +68012,17 @@ var Cache = class {
|
|
|
67960
68012
|
}
|
|
67961
68013
|
registerKeyMap(source, mapped) {
|
|
67962
68014
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
68015
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
67963
68016
|
}
|
|
67964
68017
|
delete(id, layer) {
|
|
67965
|
-
this._internal_unstable.
|
|
67966
|
-
|
|
67967
|
-
|
|
68018
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
68019
|
+
Boolean
|
|
68020
|
+
);
|
|
68021
|
+
for (const recordID of recordIDs) {
|
|
68022
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
68023
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
68024
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
68025
|
+
}
|
|
67968
68026
|
}
|
|
67969
68027
|
setConfig(config2) {
|
|
67970
68028
|
this._internal_unstable.setConfig(config2);
|
|
@@ -68270,6 +68328,9 @@ var CacheInternal = class {
|
|
|
68270
68328
|
layer,
|
|
68271
68329
|
forceNotify
|
|
68272
68330
|
});
|
|
68331
|
+
let action = () => {
|
|
68332
|
+
layer.writeLink(parent2, key, linkedIDs);
|
|
68333
|
+
};
|
|
68273
68334
|
if (applyUpdates && updates) {
|
|
68274
68335
|
if (key === "edges") {
|
|
68275
68336
|
const newNodeIDs = [];
|
|
@@ -68304,8 +68365,26 @@ var CacheInternal = class {
|
|
|
68304
68365
|
}
|
|
68305
68366
|
if (update === "prepend") {
|
|
68306
68367
|
linkedIDs = newIDs.concat(oldIDs);
|
|
68368
|
+
if (layer?.optimistic) {
|
|
68369
|
+
action = () => {
|
|
68370
|
+
for (const id of newIDs) {
|
|
68371
|
+
if (id) {
|
|
68372
|
+
layer.insert(parent2, key, "start", id);
|
|
68373
|
+
}
|
|
68374
|
+
}
|
|
68375
|
+
};
|
|
68376
|
+
}
|
|
68307
68377
|
} else if (update === "append") {
|
|
68308
68378
|
linkedIDs = oldIDs.concat(newIDs);
|
|
68379
|
+
if (layer?.optimistic) {
|
|
68380
|
+
action = () => {
|
|
68381
|
+
for (const id of newIDs) {
|
|
68382
|
+
if (id) {
|
|
68383
|
+
layer.insert(parent2, key, "end", id);
|
|
68384
|
+
}
|
|
68385
|
+
}
|
|
68386
|
+
};
|
|
68387
|
+
}
|
|
68309
68388
|
} else if (update === "replace") {
|
|
68310
68389
|
linkedIDs = newIDs;
|
|
68311
68390
|
}
|
|
@@ -68324,7 +68403,7 @@ var CacheInternal = class {
|
|
|
68324
68403
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
68325
68404
|
}
|
|
68326
68405
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
68327
|
-
|
|
68406
|
+
action();
|
|
68328
68407
|
}
|
|
68329
68408
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
68330
68409
|
if (id == null) {
|
|
@@ -68379,6 +68458,9 @@ var CacheInternal = class {
|
|
|
68379
68458
|
if (!targetID) {
|
|
68380
68459
|
continue;
|
|
68381
68460
|
}
|
|
68461
|
+
toNotify.push(
|
|
68462
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
68463
|
+
);
|
|
68382
68464
|
this.cache.delete(targetID, layer);
|
|
68383
68465
|
}
|
|
68384
68466
|
}
|
|
@@ -68800,7 +68882,6 @@ function variableValue(value, args) {
|
|
|
68800
68882
|
);
|
|
68801
68883
|
}
|
|
68802
68884
|
}
|
|
68803
|
-
var rootID = "_ROOT_";
|
|
68804
68885
|
function defaultComponentField({
|
|
68805
68886
|
cache,
|
|
68806
68887
|
component,
|