houdini-react 1.2.54 → 1.2.56
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 +138 -56
- package/build/plugin-esm/index.js +138 -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
|
}
|
|
@@ -76920,6 +76965,7 @@ var Layer = class {
|
|
|
76920
76965
|
[id]: {
|
|
76921
76966
|
...this.operations[id],
|
|
76922
76967
|
fields: {
|
|
76968
|
+
...this.operations[id]?.fields,
|
|
76923
76969
|
[field]: [...this.operations[id]?.fields[field] || [], operation]
|
|
76924
76970
|
}
|
|
76925
76971
|
}
|
|
@@ -76944,32 +76990,6 @@ var OperationKind = {
|
|
|
76944
76990
|
insert: "insert",
|
|
76945
76991
|
remove: "remove"
|
|
76946
76992
|
};
|
|
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
76993
|
var InMemorySubscriptions = class {
|
|
76974
76994
|
cache;
|
|
76975
76995
|
constructor(cache) {
|
|
@@ -76980,6 +77000,9 @@ var InMemorySubscriptions = class {
|
|
|
76980
77000
|
activeFields(parent) {
|
|
76981
77001
|
return Object.keys(this.subscribers.get(parent) || {});
|
|
76982
77002
|
}
|
|
77003
|
+
copySubscribers(from, to) {
|
|
77004
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
77005
|
+
}
|
|
76983
77006
|
add({
|
|
76984
77007
|
parent,
|
|
76985
77008
|
spec,
|
|
@@ -77162,6 +77185,11 @@ var InMemorySubscriptions = class {
|
|
|
77162
77185
|
get(id, field) {
|
|
77163
77186
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
77164
77187
|
}
|
|
77188
|
+
getAll(id) {
|
|
77189
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
77190
|
+
(fieldSub) => fieldSub.selections
|
|
77191
|
+
);
|
|
77192
|
+
}
|
|
77165
77193
|
remove(id, selection, targets, variables, visited = []) {
|
|
77166
77194
|
visited.push(id);
|
|
77167
77195
|
const linkedIDs = [];
|
|
@@ -77203,7 +77231,7 @@ var InMemorySubscriptions = class {
|
|
|
77203
77231
|
}
|
|
77204
77232
|
const subscriberField = subscriber.get(fieldName);
|
|
77205
77233
|
for (const spec of specs) {
|
|
77206
|
-
const counts =
|
|
77234
|
+
const counts = subscriberField?.referenceCounts;
|
|
77207
77235
|
if (!counts?.has(spec.set)) {
|
|
77208
77236
|
continue;
|
|
77209
77237
|
}
|
|
@@ -77226,24 +77254,23 @@ var InMemorySubscriptions = class {
|
|
|
77226
77254
|
this.subscribers.delete(id);
|
|
77227
77255
|
}
|
|
77228
77256
|
}
|
|
77229
|
-
removeAllSubscribers(id, targets
|
|
77230
|
-
|
|
77231
|
-
|
|
77232
|
-
|
|
77233
|
-
|
|
77234
|
-
|
|
77235
|
-
|
|
77236
|
-
|
|
77237
|
-
|
|
77238
|
-
|
|
77239
|
-
|
|
77240
|
-
|
|
77241
|
-
|
|
77242
|
-
|
|
77243
|
-
}
|
|
77244
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
77257
|
+
removeAllSubscribers(id, targets) {
|
|
77258
|
+
if (!targets) {
|
|
77259
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
77260
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
77261
|
+
);
|
|
77262
|
+
}
|
|
77263
|
+
for (const target of targets) {
|
|
77264
|
+
for (const subselection of this.findSubSelections(
|
|
77265
|
+
target.parentID || rootID,
|
|
77266
|
+
target.selection,
|
|
77267
|
+
target.variables || {},
|
|
77268
|
+
id
|
|
77269
|
+
)) {
|
|
77270
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
77245
77271
|
}
|
|
77246
77272
|
}
|
|
77273
|
+
return;
|
|
77247
77274
|
}
|
|
77248
77275
|
get size() {
|
|
77249
77276
|
let size = 0;
|
|
@@ -77254,6 +77281,32 @@ var InMemorySubscriptions = class {
|
|
|
77254
77281
|
}
|
|
77255
77282
|
return size;
|
|
77256
77283
|
}
|
|
77284
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
77285
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
77286
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
77287
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
77288
|
+
if (!fieldSelection.selection) {
|
|
77289
|
+
continue;
|
|
77290
|
+
}
|
|
77291
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
77292
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
77293
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
77294
|
+
if (links.includes(searchTarget)) {
|
|
77295
|
+
selections.push(fieldSelection.selection);
|
|
77296
|
+
} else {
|
|
77297
|
+
for (const link of links) {
|
|
77298
|
+
this.findSubSelections(
|
|
77299
|
+
link,
|
|
77300
|
+
fieldSelection.selection,
|
|
77301
|
+
variables,
|
|
77302
|
+
searchTarget,
|
|
77303
|
+
selections
|
|
77304
|
+
);
|
|
77305
|
+
}
|
|
77306
|
+
}
|
|
77307
|
+
}
|
|
77308
|
+
return selections;
|
|
77309
|
+
}
|
|
77257
77310
|
};
|
|
77258
77311
|
var Cache = class {
|
|
77259
77312
|
_internal_unstable;
|
|
@@ -77329,11 +77382,17 @@ var Cache = class {
|
|
|
77329
77382
|
}
|
|
77330
77383
|
registerKeyMap(source, mapped) {
|
|
77331
77384
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
77385
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
77332
77386
|
}
|
|
77333
77387
|
delete(id, layer) {
|
|
77334
|
-
this._internal_unstable.
|
|
77335
|
-
|
|
77336
|
-
|
|
77388
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
77389
|
+
Boolean
|
|
77390
|
+
);
|
|
77391
|
+
for (const recordID of recordIDs) {
|
|
77392
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
77393
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
77394
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
77395
|
+
}
|
|
77337
77396
|
}
|
|
77338
77397
|
setConfig(config) {
|
|
77339
77398
|
this._internal_unstable.setConfig(config);
|
|
@@ -77639,6 +77698,9 @@ var CacheInternal = class {
|
|
|
77639
77698
|
layer,
|
|
77640
77699
|
forceNotify
|
|
77641
77700
|
});
|
|
77701
|
+
let action = () => {
|
|
77702
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
77703
|
+
};
|
|
77642
77704
|
if (applyUpdates && updates) {
|
|
77643
77705
|
if (key === "edges") {
|
|
77644
77706
|
const newNodeIDs = [];
|
|
@@ -77673,8 +77735,26 @@ var CacheInternal = class {
|
|
|
77673
77735
|
}
|
|
77674
77736
|
if (update === "prepend") {
|
|
77675
77737
|
linkedIDs = newIDs.concat(oldIDs);
|
|
77738
|
+
if (layer?.optimistic) {
|
|
77739
|
+
action = () => {
|
|
77740
|
+
for (const id of newIDs) {
|
|
77741
|
+
if (id) {
|
|
77742
|
+
layer.insert(parent, key, "start", id);
|
|
77743
|
+
}
|
|
77744
|
+
}
|
|
77745
|
+
};
|
|
77746
|
+
}
|
|
77676
77747
|
} else if (update === "append") {
|
|
77677
77748
|
linkedIDs = oldIDs.concat(newIDs);
|
|
77749
|
+
if (layer?.optimistic) {
|
|
77750
|
+
action = () => {
|
|
77751
|
+
for (const id of newIDs) {
|
|
77752
|
+
if (id) {
|
|
77753
|
+
layer.insert(parent, key, "end", id);
|
|
77754
|
+
}
|
|
77755
|
+
}
|
|
77756
|
+
};
|
|
77757
|
+
}
|
|
77678
77758
|
} else if (update === "replace") {
|
|
77679
77759
|
linkedIDs = newIDs;
|
|
77680
77760
|
}
|
|
@@ -77693,7 +77773,7 @@ var CacheInternal = class {
|
|
|
77693
77773
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
77694
77774
|
}
|
|
77695
77775
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
77696
|
-
|
|
77776
|
+
action();
|
|
77697
77777
|
}
|
|
77698
77778
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
77699
77779
|
if (id == null) {
|
|
@@ -77748,6 +77828,9 @@ var CacheInternal = class {
|
|
|
77748
77828
|
if (!targetID) {
|
|
77749
77829
|
continue;
|
|
77750
77830
|
}
|
|
77831
|
+
toNotify.push(
|
|
77832
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
77833
|
+
);
|
|
77751
77834
|
this.cache.delete(targetID, layer);
|
|
77752
77835
|
}
|
|
77753
77836
|
}
|
|
@@ -78169,7 +78252,6 @@ function variableValue(value, args) {
|
|
|
78169
78252
|
);
|
|
78170
78253
|
}
|
|
78171
78254
|
}
|
|
78172
|
-
var rootID = "_ROOT_";
|
|
78173
78255
|
function defaultComponentField({
|
|
78174
78256
|
cache,
|
|
78175
78257
|
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
|
}
|
|
@@ -76910,6 +76955,7 @@ var Layer = class {
|
|
|
76910
76955
|
[id]: {
|
|
76911
76956
|
...this.operations[id],
|
|
76912
76957
|
fields: {
|
|
76958
|
+
...this.operations[id]?.fields,
|
|
76913
76959
|
[field]: [...this.operations[id]?.fields[field] || [], operation]
|
|
76914
76960
|
}
|
|
76915
76961
|
}
|
|
@@ -76934,32 +76980,6 @@ var OperationKind = {
|
|
|
76934
76980
|
insert: "insert",
|
|
76935
76981
|
remove: "remove"
|
|
76936
76982
|
};
|
|
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
76983
|
var InMemorySubscriptions = class {
|
|
76964
76984
|
cache;
|
|
76965
76985
|
constructor(cache) {
|
|
@@ -76970,6 +76990,9 @@ var InMemorySubscriptions = class {
|
|
|
76970
76990
|
activeFields(parent) {
|
|
76971
76991
|
return Object.keys(this.subscribers.get(parent) || {});
|
|
76972
76992
|
}
|
|
76993
|
+
copySubscribers(from, to) {
|
|
76994
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
76995
|
+
}
|
|
76973
76996
|
add({
|
|
76974
76997
|
parent,
|
|
76975
76998
|
spec,
|
|
@@ -77152,6 +77175,11 @@ var InMemorySubscriptions = class {
|
|
|
77152
77175
|
get(id, field) {
|
|
77153
77176
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
77154
77177
|
}
|
|
77178
|
+
getAll(id) {
|
|
77179
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
77180
|
+
(fieldSub) => fieldSub.selections
|
|
77181
|
+
);
|
|
77182
|
+
}
|
|
77155
77183
|
remove(id, selection, targets, variables, visited = []) {
|
|
77156
77184
|
visited.push(id);
|
|
77157
77185
|
const linkedIDs = [];
|
|
@@ -77193,7 +77221,7 @@ var InMemorySubscriptions = class {
|
|
|
77193
77221
|
}
|
|
77194
77222
|
const subscriberField = subscriber.get(fieldName);
|
|
77195
77223
|
for (const spec of specs) {
|
|
77196
|
-
const counts =
|
|
77224
|
+
const counts = subscriberField?.referenceCounts;
|
|
77197
77225
|
if (!counts?.has(spec.set)) {
|
|
77198
77226
|
continue;
|
|
77199
77227
|
}
|
|
@@ -77216,24 +77244,23 @@ var InMemorySubscriptions = class {
|
|
|
77216
77244
|
this.subscribers.delete(id);
|
|
77217
77245
|
}
|
|
77218
77246
|
}
|
|
77219
|
-
removeAllSubscribers(id, targets
|
|
77220
|
-
|
|
77221
|
-
|
|
77222
|
-
|
|
77223
|
-
|
|
77224
|
-
|
|
77225
|
-
|
|
77226
|
-
|
|
77227
|
-
|
|
77228
|
-
|
|
77229
|
-
|
|
77230
|
-
|
|
77231
|
-
|
|
77232
|
-
|
|
77233
|
-
}
|
|
77234
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
77247
|
+
removeAllSubscribers(id, targets) {
|
|
77248
|
+
if (!targets) {
|
|
77249
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
77250
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
77251
|
+
);
|
|
77252
|
+
}
|
|
77253
|
+
for (const target of targets) {
|
|
77254
|
+
for (const subselection of this.findSubSelections(
|
|
77255
|
+
target.parentID || rootID,
|
|
77256
|
+
target.selection,
|
|
77257
|
+
target.variables || {},
|
|
77258
|
+
id
|
|
77259
|
+
)) {
|
|
77260
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
77235
77261
|
}
|
|
77236
77262
|
}
|
|
77263
|
+
return;
|
|
77237
77264
|
}
|
|
77238
77265
|
get size() {
|
|
77239
77266
|
let size = 0;
|
|
@@ -77244,6 +77271,32 @@ var InMemorySubscriptions = class {
|
|
|
77244
77271
|
}
|
|
77245
77272
|
return size;
|
|
77246
77273
|
}
|
|
77274
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
77275
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
77276
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
77277
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
77278
|
+
if (!fieldSelection.selection) {
|
|
77279
|
+
continue;
|
|
77280
|
+
}
|
|
77281
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
77282
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
77283
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
77284
|
+
if (links.includes(searchTarget)) {
|
|
77285
|
+
selections.push(fieldSelection.selection);
|
|
77286
|
+
} else {
|
|
77287
|
+
for (const link of links) {
|
|
77288
|
+
this.findSubSelections(
|
|
77289
|
+
link,
|
|
77290
|
+
fieldSelection.selection,
|
|
77291
|
+
variables,
|
|
77292
|
+
searchTarget,
|
|
77293
|
+
selections
|
|
77294
|
+
);
|
|
77295
|
+
}
|
|
77296
|
+
}
|
|
77297
|
+
}
|
|
77298
|
+
return selections;
|
|
77299
|
+
}
|
|
77247
77300
|
};
|
|
77248
77301
|
var Cache = class {
|
|
77249
77302
|
_internal_unstable;
|
|
@@ -77319,11 +77372,17 @@ var Cache = class {
|
|
|
77319
77372
|
}
|
|
77320
77373
|
registerKeyMap(source, mapped) {
|
|
77321
77374
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
77375
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
77322
77376
|
}
|
|
77323
77377
|
delete(id, layer) {
|
|
77324
|
-
this._internal_unstable.
|
|
77325
|
-
|
|
77326
|
-
|
|
77378
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
77379
|
+
Boolean
|
|
77380
|
+
);
|
|
77381
|
+
for (const recordID of recordIDs) {
|
|
77382
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
77383
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
77384
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
77385
|
+
}
|
|
77327
77386
|
}
|
|
77328
77387
|
setConfig(config) {
|
|
77329
77388
|
this._internal_unstable.setConfig(config);
|
|
@@ -77629,6 +77688,9 @@ var CacheInternal = class {
|
|
|
77629
77688
|
layer,
|
|
77630
77689
|
forceNotify
|
|
77631
77690
|
});
|
|
77691
|
+
let action = () => {
|
|
77692
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
77693
|
+
};
|
|
77632
77694
|
if (applyUpdates && updates) {
|
|
77633
77695
|
if (key === "edges") {
|
|
77634
77696
|
const newNodeIDs = [];
|
|
@@ -77663,8 +77725,26 @@ var CacheInternal = class {
|
|
|
77663
77725
|
}
|
|
77664
77726
|
if (update === "prepend") {
|
|
77665
77727
|
linkedIDs = newIDs.concat(oldIDs);
|
|
77728
|
+
if (layer?.optimistic) {
|
|
77729
|
+
action = () => {
|
|
77730
|
+
for (const id of newIDs) {
|
|
77731
|
+
if (id) {
|
|
77732
|
+
layer.insert(parent, key, "start", id);
|
|
77733
|
+
}
|
|
77734
|
+
}
|
|
77735
|
+
};
|
|
77736
|
+
}
|
|
77666
77737
|
} else if (update === "append") {
|
|
77667
77738
|
linkedIDs = oldIDs.concat(newIDs);
|
|
77739
|
+
if (layer?.optimistic) {
|
|
77740
|
+
action = () => {
|
|
77741
|
+
for (const id of newIDs) {
|
|
77742
|
+
if (id) {
|
|
77743
|
+
layer.insert(parent, key, "end", id);
|
|
77744
|
+
}
|
|
77745
|
+
}
|
|
77746
|
+
};
|
|
77747
|
+
}
|
|
77668
77748
|
} else if (update === "replace") {
|
|
77669
77749
|
linkedIDs = newIDs;
|
|
77670
77750
|
}
|
|
@@ -77683,7 +77763,7 @@ var CacheInternal = class {
|
|
|
77683
77763
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
77684
77764
|
}
|
|
77685
77765
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
77686
|
-
|
|
77766
|
+
action();
|
|
77687
77767
|
}
|
|
77688
77768
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
77689
77769
|
if (id == null) {
|
|
@@ -77738,6 +77818,9 @@ var CacheInternal = class {
|
|
|
77738
77818
|
if (!targetID) {
|
|
77739
77819
|
continue;
|
|
77740
77820
|
}
|
|
77821
|
+
toNotify.push(
|
|
77822
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
77823
|
+
);
|
|
77741
77824
|
this.cache.delete(targetID, layer);
|
|
77742
77825
|
}
|
|
77743
77826
|
}
|
|
@@ -78159,7 +78242,6 @@ function variableValue(value, args) {
|
|
|
78159
78242
|
);
|
|
78160
78243
|
}
|
|
78161
78244
|
}
|
|
78162
|
-
var rootID = "_ROOT_";
|
|
78163
78245
|
function defaultComponentField({
|
|
78164
78246
|
cache,
|
|
78165
78247
|
component,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.56",
|
|
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.56"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"build"
|