houdini-react 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/plugin-cjs/index.js +137 -56
- package/build/plugin-esm/index.js +137 -56
- package/package.json +2 -2
|
@@ -76069,6 +76069,33 @@ var GarbageCollector = class {
|
|
|
76069
76069
|
}
|
|
76070
76070
|
}
|
|
76071
76071
|
};
|
|
76072
|
+
function evaluateKey(key, variables = null) {
|
|
76073
|
+
let evaluated = "";
|
|
76074
|
+
let varName = "";
|
|
76075
|
+
let inString = false;
|
|
76076
|
+
for (const char of key) {
|
|
76077
|
+
if (varName) {
|
|
76078
|
+
if (varChars.includes(char)) {
|
|
76079
|
+
varName += char;
|
|
76080
|
+
continue;
|
|
76081
|
+
}
|
|
76082
|
+
const value = variables?.[varName.slice(1)];
|
|
76083
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
76084
|
+
varName = "";
|
|
76085
|
+
}
|
|
76086
|
+
if (char === "$" && !inString) {
|
|
76087
|
+
varName = "$";
|
|
76088
|
+
continue;
|
|
76089
|
+
}
|
|
76090
|
+
if (char === '"') {
|
|
76091
|
+
inString = !inString;
|
|
76092
|
+
}
|
|
76093
|
+
evaluated += char;
|
|
76094
|
+
}
|
|
76095
|
+
return evaluated;
|
|
76096
|
+
}
|
|
76097
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
76098
|
+
var rootID = "_ROOT_";
|
|
76072
76099
|
var ListManager = class {
|
|
76073
76100
|
rootID;
|
|
76074
76101
|
cache;
|
|
@@ -76134,11 +76161,15 @@ var ListManager = class {
|
|
|
76134
76161
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
76135
76162
|
}
|
|
76136
76163
|
removeIDFromAllLists(id, layer) {
|
|
76164
|
+
let removed = false;
|
|
76137
76165
|
for (const fieldMap of this.lists.values()) {
|
|
76138
76166
|
for (const list of fieldMap.values()) {
|
|
76139
|
-
list.removeID(id, void 0, layer)
|
|
76167
|
+
if (list.removeID(id, void 0, layer)) {
|
|
76168
|
+
removed = true;
|
|
76169
|
+
}
|
|
76140
76170
|
}
|
|
76141
76171
|
}
|
|
76172
|
+
return removed;
|
|
76142
76173
|
}
|
|
76143
76174
|
deleteField(parentID, field) {
|
|
76144
76175
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -76441,7 +76472,13 @@ var ListCollection = class {
|
|
|
76441
76472
|
this.lists.forEach((list) => list.addToList(...args));
|
|
76442
76473
|
}
|
|
76443
76474
|
removeID(...args) {
|
|
76444
|
-
|
|
76475
|
+
let removed = false;
|
|
76476
|
+
this.lists.forEach((list) => {
|
|
76477
|
+
if (list.removeID(...args)) {
|
|
76478
|
+
removed = true;
|
|
76479
|
+
}
|
|
76480
|
+
});
|
|
76481
|
+
return removed;
|
|
76445
76482
|
}
|
|
76446
76483
|
remove(...args) {
|
|
76447
76484
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -76556,6 +76593,7 @@ var InMemoryStorage = class {
|
|
|
76556
76593
|
}
|
|
76557
76594
|
registerIDMapping(from, to) {
|
|
76558
76595
|
this.idMaps[from] = to;
|
|
76596
|
+
this.idMaps[to] = from;
|
|
76559
76597
|
}
|
|
76560
76598
|
createLayer(optimistic = false) {
|
|
76561
76599
|
const layer = new Layer(this.idCount++);
|
|
@@ -76566,11 +76604,11 @@ var InMemoryStorage = class {
|
|
|
76566
76604
|
insert(id, field, location, target) {
|
|
76567
76605
|
return this.topLayer.insert(id, field, location, target);
|
|
76568
76606
|
}
|
|
76569
|
-
remove(id, field, target,
|
|
76570
|
-
return
|
|
76607
|
+
remove(id, field, target, layer = this.topLayer) {
|
|
76608
|
+
return layer.remove(id, field, target);
|
|
76571
76609
|
}
|
|
76572
|
-
delete(id,
|
|
76573
|
-
return
|
|
76610
|
+
delete(id, layer = this.topLayer) {
|
|
76611
|
+
return layer.delete(id);
|
|
76574
76612
|
}
|
|
76575
76613
|
deleteField(id, field) {
|
|
76576
76614
|
return this.topLayer.deleteField(id, field);
|
|
@@ -76608,6 +76646,9 @@ var InMemoryStorage = class {
|
|
|
76608
76646
|
return;
|
|
76609
76647
|
}
|
|
76610
76648
|
operations.remove.add(v);
|
|
76649
|
+
if (this.idMaps[v]) {
|
|
76650
|
+
operations.remove.add(this.idMaps[v]);
|
|
76651
|
+
}
|
|
76611
76652
|
});
|
|
76612
76653
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
76613
76654
|
const targetLayer = this.topLayer;
|
|
@@ -76634,7 +76675,11 @@ var InMemoryStorage = class {
|
|
|
76634
76675
|
operations.remove.add(op.id);
|
|
76635
76676
|
}
|
|
76636
76677
|
if (isInsertOperation(op)) {
|
|
76637
|
-
|
|
76678
|
+
if (op.location === OperationLocation.end) {
|
|
76679
|
+
operations.insert[op.location].unshift(op.id);
|
|
76680
|
+
} else {
|
|
76681
|
+
operations.insert[op.location].push(op.id);
|
|
76682
|
+
}
|
|
76638
76683
|
}
|
|
76639
76684
|
if (isDeleteOperation(op)) {
|
|
76640
76685
|
return {
|
|
@@ -76880,7 +76925,7 @@ var Layer = class {
|
|
|
76880
76925
|
}
|
|
76881
76926
|
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
76882
76927
|
const fields = {};
|
|
76883
|
-
for (const opMap of [
|
|
76928
|
+
for (const opMap of [layer.operations[id], this.operations[id]].filter(Boolean)) {
|
|
76884
76929
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
76885
76930
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
76886
76931
|
}
|
|
@@ -76944,32 +76989,6 @@ var OperationKind = {
|
|
|
76944
76989
|
insert: "insert",
|
|
76945
76990
|
remove: "remove"
|
|
76946
76991
|
};
|
|
76947
|
-
function evaluateKey(key, variables = null) {
|
|
76948
|
-
let evaluated = "";
|
|
76949
|
-
let varName = "";
|
|
76950
|
-
let inString = false;
|
|
76951
|
-
for (const char of key) {
|
|
76952
|
-
if (varName) {
|
|
76953
|
-
if (varChars.includes(char)) {
|
|
76954
|
-
varName += char;
|
|
76955
|
-
continue;
|
|
76956
|
-
}
|
|
76957
|
-
const value = variables?.[varName.slice(1)];
|
|
76958
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
76959
|
-
varName = "";
|
|
76960
|
-
}
|
|
76961
|
-
if (char === "$" && !inString) {
|
|
76962
|
-
varName = "$";
|
|
76963
|
-
continue;
|
|
76964
|
-
}
|
|
76965
|
-
if (char === '"') {
|
|
76966
|
-
inString = !inString;
|
|
76967
|
-
}
|
|
76968
|
-
evaluated += char;
|
|
76969
|
-
}
|
|
76970
|
-
return evaluated;
|
|
76971
|
-
}
|
|
76972
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
76973
76992
|
var InMemorySubscriptions = class {
|
|
76974
76993
|
cache;
|
|
76975
76994
|
constructor(cache) {
|
|
@@ -76980,6 +76999,9 @@ var InMemorySubscriptions = class {
|
|
|
76980
76999
|
activeFields(parent) {
|
|
76981
77000
|
return Object.keys(this.subscribers.get(parent) || {});
|
|
76982
77001
|
}
|
|
77002
|
+
copySubscribers(from, to) {
|
|
77003
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
77004
|
+
}
|
|
76983
77005
|
add({
|
|
76984
77006
|
parent,
|
|
76985
77007
|
spec,
|
|
@@ -77162,6 +77184,11 @@ var InMemorySubscriptions = class {
|
|
|
77162
77184
|
get(id, field) {
|
|
77163
77185
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
77164
77186
|
}
|
|
77187
|
+
getAll(id) {
|
|
77188
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
77189
|
+
(fieldSub) => fieldSub.selections
|
|
77190
|
+
);
|
|
77191
|
+
}
|
|
77165
77192
|
remove(id, selection, targets, variables, visited = []) {
|
|
77166
77193
|
visited.push(id);
|
|
77167
77194
|
const linkedIDs = [];
|
|
@@ -77203,7 +77230,7 @@ var InMemorySubscriptions = class {
|
|
|
77203
77230
|
}
|
|
77204
77231
|
const subscriberField = subscriber.get(fieldName);
|
|
77205
77232
|
for (const spec of specs) {
|
|
77206
|
-
const counts =
|
|
77233
|
+
const counts = subscriberField?.referenceCounts;
|
|
77207
77234
|
if (!counts?.has(spec.set)) {
|
|
77208
77235
|
continue;
|
|
77209
77236
|
}
|
|
@@ -77226,24 +77253,23 @@ var InMemorySubscriptions = class {
|
|
|
77226
77253
|
this.subscribers.delete(id);
|
|
77227
77254
|
}
|
|
77228
77255
|
}
|
|
77229
|
-
removeAllSubscribers(id, targets
|
|
77230
|
-
|
|
77231
|
-
|
|
77232
|
-
|
|
77233
|
-
|
|
77234
|
-
|
|
77235
|
-
|
|
77236
|
-
|
|
77237
|
-
|
|
77238
|
-
|
|
77239
|
-
|
|
77240
|
-
|
|
77241
|
-
|
|
77242
|
-
|
|
77243
|
-
}
|
|
77244
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
77256
|
+
removeAllSubscribers(id, targets) {
|
|
77257
|
+
if (!targets) {
|
|
77258
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
77259
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
77260
|
+
);
|
|
77261
|
+
}
|
|
77262
|
+
for (const target of targets) {
|
|
77263
|
+
for (const subselection of this.findSubSelections(
|
|
77264
|
+
target.parentID || rootID,
|
|
77265
|
+
target.selection,
|
|
77266
|
+
target.variables || {},
|
|
77267
|
+
id
|
|
77268
|
+
)) {
|
|
77269
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
77245
77270
|
}
|
|
77246
77271
|
}
|
|
77272
|
+
return;
|
|
77247
77273
|
}
|
|
77248
77274
|
get size() {
|
|
77249
77275
|
let size = 0;
|
|
@@ -77254,6 +77280,32 @@ var InMemorySubscriptions = class {
|
|
|
77254
77280
|
}
|
|
77255
77281
|
return size;
|
|
77256
77282
|
}
|
|
77283
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
77284
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
77285
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
77286
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
77287
|
+
if (!fieldSelection.selection) {
|
|
77288
|
+
continue;
|
|
77289
|
+
}
|
|
77290
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
77291
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
77292
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
77293
|
+
if (links.includes(searchTarget)) {
|
|
77294
|
+
selections.push(fieldSelection.selection);
|
|
77295
|
+
} else {
|
|
77296
|
+
for (const link of links) {
|
|
77297
|
+
this.findSubSelections(
|
|
77298
|
+
link,
|
|
77299
|
+
fieldSelection.selection,
|
|
77300
|
+
variables,
|
|
77301
|
+
searchTarget,
|
|
77302
|
+
selections
|
|
77303
|
+
);
|
|
77304
|
+
}
|
|
77305
|
+
}
|
|
77306
|
+
}
|
|
77307
|
+
return selections;
|
|
77308
|
+
}
|
|
77257
77309
|
};
|
|
77258
77310
|
var Cache = class {
|
|
77259
77311
|
_internal_unstable;
|
|
@@ -77329,11 +77381,17 @@ var Cache = class {
|
|
|
77329
77381
|
}
|
|
77330
77382
|
registerKeyMap(source, mapped) {
|
|
77331
77383
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
77384
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
77332
77385
|
}
|
|
77333
77386
|
delete(id, layer) {
|
|
77334
|
-
this._internal_unstable.
|
|
77335
|
-
|
|
77336
|
-
|
|
77387
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
77388
|
+
Boolean
|
|
77389
|
+
);
|
|
77390
|
+
for (const recordID of recordIDs) {
|
|
77391
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
77392
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
77393
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
77394
|
+
}
|
|
77337
77395
|
}
|
|
77338
77396
|
setConfig(config) {
|
|
77339
77397
|
this._internal_unstable.setConfig(config);
|
|
@@ -77639,6 +77697,9 @@ var CacheInternal = class {
|
|
|
77639
77697
|
layer,
|
|
77640
77698
|
forceNotify
|
|
77641
77699
|
});
|
|
77700
|
+
let action = () => {
|
|
77701
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
77702
|
+
};
|
|
77642
77703
|
if (applyUpdates && updates) {
|
|
77643
77704
|
if (key === "edges") {
|
|
77644
77705
|
const newNodeIDs = [];
|
|
@@ -77673,8 +77734,26 @@ var CacheInternal = class {
|
|
|
77673
77734
|
}
|
|
77674
77735
|
if (update === "prepend") {
|
|
77675
77736
|
linkedIDs = newIDs.concat(oldIDs);
|
|
77737
|
+
if (layer?.optimistic) {
|
|
77738
|
+
action = () => {
|
|
77739
|
+
for (const id of newIDs) {
|
|
77740
|
+
if (id) {
|
|
77741
|
+
layer.insert(parent, key, "start", id);
|
|
77742
|
+
}
|
|
77743
|
+
}
|
|
77744
|
+
};
|
|
77745
|
+
}
|
|
77676
77746
|
} else if (update === "append") {
|
|
77677
77747
|
linkedIDs = oldIDs.concat(newIDs);
|
|
77748
|
+
if (layer?.optimistic) {
|
|
77749
|
+
action = () => {
|
|
77750
|
+
for (const id of newIDs) {
|
|
77751
|
+
if (id) {
|
|
77752
|
+
layer.insert(parent, key, "end", id);
|
|
77753
|
+
}
|
|
77754
|
+
}
|
|
77755
|
+
};
|
|
77756
|
+
}
|
|
77678
77757
|
} else if (update === "replace") {
|
|
77679
77758
|
linkedIDs = newIDs;
|
|
77680
77759
|
}
|
|
@@ -77693,7 +77772,7 @@ var CacheInternal = class {
|
|
|
77693
77772
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
77694
77773
|
}
|
|
77695
77774
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
77696
|
-
|
|
77775
|
+
action();
|
|
77697
77776
|
}
|
|
77698
77777
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
77699
77778
|
if (id == null) {
|
|
@@ -77748,6 +77827,9 @@ var CacheInternal = class {
|
|
|
77748
77827
|
if (!targetID) {
|
|
77749
77828
|
continue;
|
|
77750
77829
|
}
|
|
77830
|
+
toNotify.push(
|
|
77831
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
77832
|
+
);
|
|
77751
77833
|
this.cache.delete(targetID, layer);
|
|
77752
77834
|
}
|
|
77753
77835
|
}
|
|
@@ -78169,7 +78251,6 @@ function variableValue(value, args) {
|
|
|
78169
78251
|
);
|
|
78170
78252
|
}
|
|
78171
78253
|
}
|
|
78172
|
-
var rootID = "_ROOT_";
|
|
78173
78254
|
function defaultComponentField({
|
|
78174
78255
|
cache,
|
|
78175
78256
|
component,
|
|
@@ -76059,6 +76059,33 @@ var GarbageCollector = class {
|
|
|
76059
76059
|
}
|
|
76060
76060
|
}
|
|
76061
76061
|
};
|
|
76062
|
+
function evaluateKey(key, variables = null) {
|
|
76063
|
+
let evaluated = "";
|
|
76064
|
+
let varName = "";
|
|
76065
|
+
let inString = false;
|
|
76066
|
+
for (const char of key) {
|
|
76067
|
+
if (varName) {
|
|
76068
|
+
if (varChars.includes(char)) {
|
|
76069
|
+
varName += char;
|
|
76070
|
+
continue;
|
|
76071
|
+
}
|
|
76072
|
+
const value = variables?.[varName.slice(1)];
|
|
76073
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
76074
|
+
varName = "";
|
|
76075
|
+
}
|
|
76076
|
+
if (char === "$" && !inString) {
|
|
76077
|
+
varName = "$";
|
|
76078
|
+
continue;
|
|
76079
|
+
}
|
|
76080
|
+
if (char === '"') {
|
|
76081
|
+
inString = !inString;
|
|
76082
|
+
}
|
|
76083
|
+
evaluated += char;
|
|
76084
|
+
}
|
|
76085
|
+
return evaluated;
|
|
76086
|
+
}
|
|
76087
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
76088
|
+
var rootID = "_ROOT_";
|
|
76062
76089
|
var ListManager = class {
|
|
76063
76090
|
rootID;
|
|
76064
76091
|
cache;
|
|
@@ -76124,11 +76151,15 @@ var ListManager = class {
|
|
|
76124
76151
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
76125
76152
|
}
|
|
76126
76153
|
removeIDFromAllLists(id, layer) {
|
|
76154
|
+
let removed = false;
|
|
76127
76155
|
for (const fieldMap of this.lists.values()) {
|
|
76128
76156
|
for (const list of fieldMap.values()) {
|
|
76129
|
-
list.removeID(id, void 0, layer)
|
|
76157
|
+
if (list.removeID(id, void 0, layer)) {
|
|
76158
|
+
removed = true;
|
|
76159
|
+
}
|
|
76130
76160
|
}
|
|
76131
76161
|
}
|
|
76162
|
+
return removed;
|
|
76132
76163
|
}
|
|
76133
76164
|
deleteField(parentID, field) {
|
|
76134
76165
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -76431,7 +76462,13 @@ var ListCollection = class {
|
|
|
76431
76462
|
this.lists.forEach((list) => list.addToList(...args));
|
|
76432
76463
|
}
|
|
76433
76464
|
removeID(...args) {
|
|
76434
|
-
|
|
76465
|
+
let removed = false;
|
|
76466
|
+
this.lists.forEach((list) => {
|
|
76467
|
+
if (list.removeID(...args)) {
|
|
76468
|
+
removed = true;
|
|
76469
|
+
}
|
|
76470
|
+
});
|
|
76471
|
+
return removed;
|
|
76435
76472
|
}
|
|
76436
76473
|
remove(...args) {
|
|
76437
76474
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -76546,6 +76583,7 @@ var InMemoryStorage = class {
|
|
|
76546
76583
|
}
|
|
76547
76584
|
registerIDMapping(from, to) {
|
|
76548
76585
|
this.idMaps[from] = to;
|
|
76586
|
+
this.idMaps[to] = from;
|
|
76549
76587
|
}
|
|
76550
76588
|
createLayer(optimistic = false) {
|
|
76551
76589
|
const layer = new Layer(this.idCount++);
|
|
@@ -76556,11 +76594,11 @@ var InMemoryStorage = class {
|
|
|
76556
76594
|
insert(id, field, location, target) {
|
|
76557
76595
|
return this.topLayer.insert(id, field, location, target);
|
|
76558
76596
|
}
|
|
76559
|
-
remove(id, field, target,
|
|
76560
|
-
return
|
|
76597
|
+
remove(id, field, target, layer = this.topLayer) {
|
|
76598
|
+
return layer.remove(id, field, target);
|
|
76561
76599
|
}
|
|
76562
|
-
delete(id,
|
|
76563
|
-
return
|
|
76600
|
+
delete(id, layer = this.topLayer) {
|
|
76601
|
+
return layer.delete(id);
|
|
76564
76602
|
}
|
|
76565
76603
|
deleteField(id, field) {
|
|
76566
76604
|
return this.topLayer.deleteField(id, field);
|
|
@@ -76598,6 +76636,9 @@ var InMemoryStorage = class {
|
|
|
76598
76636
|
return;
|
|
76599
76637
|
}
|
|
76600
76638
|
operations.remove.add(v);
|
|
76639
|
+
if (this.idMaps[v]) {
|
|
76640
|
+
operations.remove.add(this.idMaps[v]);
|
|
76641
|
+
}
|
|
76601
76642
|
});
|
|
76602
76643
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
76603
76644
|
const targetLayer = this.topLayer;
|
|
@@ -76624,7 +76665,11 @@ var InMemoryStorage = class {
|
|
|
76624
76665
|
operations.remove.add(op.id);
|
|
76625
76666
|
}
|
|
76626
76667
|
if (isInsertOperation(op)) {
|
|
76627
|
-
|
|
76668
|
+
if (op.location === OperationLocation.end) {
|
|
76669
|
+
operations.insert[op.location].unshift(op.id);
|
|
76670
|
+
} else {
|
|
76671
|
+
operations.insert[op.location].push(op.id);
|
|
76672
|
+
}
|
|
76628
76673
|
}
|
|
76629
76674
|
if (isDeleteOperation(op)) {
|
|
76630
76675
|
return {
|
|
@@ -76870,7 +76915,7 @@ var Layer = class {
|
|
|
76870
76915
|
}
|
|
76871
76916
|
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
76872
76917
|
const fields = {};
|
|
76873
|
-
for (const opMap of [
|
|
76918
|
+
for (const opMap of [layer.operations[id], this.operations[id]].filter(Boolean)) {
|
|
76874
76919
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
76875
76920
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
76876
76921
|
}
|
|
@@ -76934,32 +76979,6 @@ var OperationKind = {
|
|
|
76934
76979
|
insert: "insert",
|
|
76935
76980
|
remove: "remove"
|
|
76936
76981
|
};
|
|
76937
|
-
function evaluateKey(key, variables = null) {
|
|
76938
|
-
let evaluated = "";
|
|
76939
|
-
let varName = "";
|
|
76940
|
-
let inString = false;
|
|
76941
|
-
for (const char of key) {
|
|
76942
|
-
if (varName) {
|
|
76943
|
-
if (varChars.includes(char)) {
|
|
76944
|
-
varName += char;
|
|
76945
|
-
continue;
|
|
76946
|
-
}
|
|
76947
|
-
const value = variables?.[varName.slice(1)];
|
|
76948
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
76949
|
-
varName = "";
|
|
76950
|
-
}
|
|
76951
|
-
if (char === "$" && !inString) {
|
|
76952
|
-
varName = "$";
|
|
76953
|
-
continue;
|
|
76954
|
-
}
|
|
76955
|
-
if (char === '"') {
|
|
76956
|
-
inString = !inString;
|
|
76957
|
-
}
|
|
76958
|
-
evaluated += char;
|
|
76959
|
-
}
|
|
76960
|
-
return evaluated;
|
|
76961
|
-
}
|
|
76962
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
76963
76982
|
var InMemorySubscriptions = class {
|
|
76964
76983
|
cache;
|
|
76965
76984
|
constructor(cache) {
|
|
@@ -76970,6 +76989,9 @@ var InMemorySubscriptions = class {
|
|
|
76970
76989
|
activeFields(parent) {
|
|
76971
76990
|
return Object.keys(this.subscribers.get(parent) || {});
|
|
76972
76991
|
}
|
|
76992
|
+
copySubscribers(from, to) {
|
|
76993
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
76994
|
+
}
|
|
76973
76995
|
add({
|
|
76974
76996
|
parent,
|
|
76975
76997
|
spec,
|
|
@@ -77152,6 +77174,11 @@ var InMemorySubscriptions = class {
|
|
|
77152
77174
|
get(id, field) {
|
|
77153
77175
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
77154
77176
|
}
|
|
77177
|
+
getAll(id) {
|
|
77178
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
77179
|
+
(fieldSub) => fieldSub.selections
|
|
77180
|
+
);
|
|
77181
|
+
}
|
|
77155
77182
|
remove(id, selection, targets, variables, visited = []) {
|
|
77156
77183
|
visited.push(id);
|
|
77157
77184
|
const linkedIDs = [];
|
|
@@ -77193,7 +77220,7 @@ var InMemorySubscriptions = class {
|
|
|
77193
77220
|
}
|
|
77194
77221
|
const subscriberField = subscriber.get(fieldName);
|
|
77195
77222
|
for (const spec of specs) {
|
|
77196
|
-
const counts =
|
|
77223
|
+
const counts = subscriberField?.referenceCounts;
|
|
77197
77224
|
if (!counts?.has(spec.set)) {
|
|
77198
77225
|
continue;
|
|
77199
77226
|
}
|
|
@@ -77216,24 +77243,23 @@ var InMemorySubscriptions = class {
|
|
|
77216
77243
|
this.subscribers.delete(id);
|
|
77217
77244
|
}
|
|
77218
77245
|
}
|
|
77219
|
-
removeAllSubscribers(id, targets
|
|
77220
|
-
|
|
77221
|
-
|
|
77222
|
-
|
|
77223
|
-
|
|
77224
|
-
|
|
77225
|
-
|
|
77226
|
-
|
|
77227
|
-
|
|
77228
|
-
|
|
77229
|
-
|
|
77230
|
-
|
|
77231
|
-
|
|
77232
|
-
|
|
77233
|
-
}
|
|
77234
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
77246
|
+
removeAllSubscribers(id, targets) {
|
|
77247
|
+
if (!targets) {
|
|
77248
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
77249
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
77250
|
+
);
|
|
77251
|
+
}
|
|
77252
|
+
for (const target of targets) {
|
|
77253
|
+
for (const subselection of this.findSubSelections(
|
|
77254
|
+
target.parentID || rootID,
|
|
77255
|
+
target.selection,
|
|
77256
|
+
target.variables || {},
|
|
77257
|
+
id
|
|
77258
|
+
)) {
|
|
77259
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
77235
77260
|
}
|
|
77236
77261
|
}
|
|
77262
|
+
return;
|
|
77237
77263
|
}
|
|
77238
77264
|
get size() {
|
|
77239
77265
|
let size = 0;
|
|
@@ -77244,6 +77270,32 @@ var InMemorySubscriptions = class {
|
|
|
77244
77270
|
}
|
|
77245
77271
|
return size;
|
|
77246
77272
|
}
|
|
77273
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
77274
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
77275
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
77276
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
77277
|
+
if (!fieldSelection.selection) {
|
|
77278
|
+
continue;
|
|
77279
|
+
}
|
|
77280
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
77281
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
77282
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
77283
|
+
if (links.includes(searchTarget)) {
|
|
77284
|
+
selections.push(fieldSelection.selection);
|
|
77285
|
+
} else {
|
|
77286
|
+
for (const link of links) {
|
|
77287
|
+
this.findSubSelections(
|
|
77288
|
+
link,
|
|
77289
|
+
fieldSelection.selection,
|
|
77290
|
+
variables,
|
|
77291
|
+
searchTarget,
|
|
77292
|
+
selections
|
|
77293
|
+
);
|
|
77294
|
+
}
|
|
77295
|
+
}
|
|
77296
|
+
}
|
|
77297
|
+
return selections;
|
|
77298
|
+
}
|
|
77247
77299
|
};
|
|
77248
77300
|
var Cache = class {
|
|
77249
77301
|
_internal_unstable;
|
|
@@ -77319,11 +77371,17 @@ var Cache = class {
|
|
|
77319
77371
|
}
|
|
77320
77372
|
registerKeyMap(source, mapped) {
|
|
77321
77373
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
77374
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
77322
77375
|
}
|
|
77323
77376
|
delete(id, layer) {
|
|
77324
|
-
this._internal_unstable.
|
|
77325
|
-
|
|
77326
|
-
|
|
77377
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
77378
|
+
Boolean
|
|
77379
|
+
);
|
|
77380
|
+
for (const recordID of recordIDs) {
|
|
77381
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
77382
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
77383
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
77384
|
+
}
|
|
77327
77385
|
}
|
|
77328
77386
|
setConfig(config) {
|
|
77329
77387
|
this._internal_unstable.setConfig(config);
|
|
@@ -77629,6 +77687,9 @@ var CacheInternal = class {
|
|
|
77629
77687
|
layer,
|
|
77630
77688
|
forceNotify
|
|
77631
77689
|
});
|
|
77690
|
+
let action = () => {
|
|
77691
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
77692
|
+
};
|
|
77632
77693
|
if (applyUpdates && updates) {
|
|
77633
77694
|
if (key === "edges") {
|
|
77634
77695
|
const newNodeIDs = [];
|
|
@@ -77663,8 +77724,26 @@ var CacheInternal = class {
|
|
|
77663
77724
|
}
|
|
77664
77725
|
if (update === "prepend") {
|
|
77665
77726
|
linkedIDs = newIDs.concat(oldIDs);
|
|
77727
|
+
if (layer?.optimistic) {
|
|
77728
|
+
action = () => {
|
|
77729
|
+
for (const id of newIDs) {
|
|
77730
|
+
if (id) {
|
|
77731
|
+
layer.insert(parent, key, "start", id);
|
|
77732
|
+
}
|
|
77733
|
+
}
|
|
77734
|
+
};
|
|
77735
|
+
}
|
|
77666
77736
|
} else if (update === "append") {
|
|
77667
77737
|
linkedIDs = oldIDs.concat(newIDs);
|
|
77738
|
+
if (layer?.optimistic) {
|
|
77739
|
+
action = () => {
|
|
77740
|
+
for (const id of newIDs) {
|
|
77741
|
+
if (id) {
|
|
77742
|
+
layer.insert(parent, key, "end", id);
|
|
77743
|
+
}
|
|
77744
|
+
}
|
|
77745
|
+
};
|
|
77746
|
+
}
|
|
77668
77747
|
} else if (update === "replace") {
|
|
77669
77748
|
linkedIDs = newIDs;
|
|
77670
77749
|
}
|
|
@@ -77683,7 +77762,7 @@ var CacheInternal = class {
|
|
|
77683
77762
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
77684
77763
|
}
|
|
77685
77764
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
77686
|
-
|
|
77765
|
+
action();
|
|
77687
77766
|
}
|
|
77688
77767
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
77689
77768
|
if (id == null) {
|
|
@@ -77738,6 +77817,9 @@ var CacheInternal = class {
|
|
|
77738
77817
|
if (!targetID) {
|
|
77739
77818
|
continue;
|
|
77740
77819
|
}
|
|
77820
|
+
toNotify.push(
|
|
77821
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
77822
|
+
);
|
|
77741
77823
|
this.cache.delete(targetID, layer);
|
|
77742
77824
|
}
|
|
77743
77825
|
}
|
|
@@ -78159,7 +78241,6 @@ function variableValue(value, args) {
|
|
|
78159
78241
|
);
|
|
78160
78242
|
}
|
|
78161
78243
|
}
|
|
78162
|
-
var rootID = "_ROOT_";
|
|
78163
78244
|
function defaultComponentField({
|
|
78164
78245
|
cache,
|
|
78165
78246
|
component,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.55",
|
|
4
4
|
"description": "The React plugin for houdini",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"recast": "^0.23.1",
|
|
44
44
|
"rollup": "^3.7.4",
|
|
45
45
|
"use-deep-compare-effect": "^1.8.1",
|
|
46
|
-
"houdini": "^1.2.
|
|
46
|
+
"houdini": "^1.2.55"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"build"
|