houdini 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/cmd-cjs/index.js +142 -60
- package/build/cmd-esm/index.js +142 -60
- package/build/codegen-cjs/index.js +140 -58
- package/build/codegen-esm/index.js +140 -58
- package/build/lib-cjs/index.js +143 -59
- package/build/lib-esm/index.js +143 -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 +15 -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 +15 -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 +140 -58
- package/build/test-esm/index.js +140 -58
- package/build/vite-cjs/index.js +140 -58
- package/build/vite-esm/index.js +140 -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/lib-cjs/index.js
CHANGED
|
@@ -63939,6 +63939,35 @@ var GarbageCollector = class {
|
|
|
63939
63939
|
}
|
|
63940
63940
|
};
|
|
63941
63941
|
|
|
63942
|
+
// src/runtime/cache/stuff.ts
|
|
63943
|
+
function evaluateKey(key, variables = null) {
|
|
63944
|
+
let evaluated = "";
|
|
63945
|
+
let varName = "";
|
|
63946
|
+
let inString = false;
|
|
63947
|
+
for (const char of key) {
|
|
63948
|
+
if (varName) {
|
|
63949
|
+
if (varChars.includes(char)) {
|
|
63950
|
+
varName += char;
|
|
63951
|
+
continue;
|
|
63952
|
+
}
|
|
63953
|
+
const value = variables?.[varName.slice(1)];
|
|
63954
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
63955
|
+
varName = "";
|
|
63956
|
+
}
|
|
63957
|
+
if (char === "$" && !inString) {
|
|
63958
|
+
varName = "$";
|
|
63959
|
+
continue;
|
|
63960
|
+
}
|
|
63961
|
+
if (char === '"') {
|
|
63962
|
+
inString = !inString;
|
|
63963
|
+
}
|
|
63964
|
+
evaluated += char;
|
|
63965
|
+
}
|
|
63966
|
+
return evaluated;
|
|
63967
|
+
}
|
|
63968
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
63969
|
+
var rootID = "_ROOT_";
|
|
63970
|
+
|
|
63942
63971
|
// src/runtime/cache/lists.ts
|
|
63943
63972
|
var ListManager = class {
|
|
63944
63973
|
rootID;
|
|
@@ -64005,11 +64034,15 @@ var ListManager = class {
|
|
|
64005
64034
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
64006
64035
|
}
|
|
64007
64036
|
removeIDFromAllLists(id, layer) {
|
|
64037
|
+
let removed = false;
|
|
64008
64038
|
for (const fieldMap of this.lists.values()) {
|
|
64009
64039
|
for (const list of fieldMap.values()) {
|
|
64010
|
-
list.removeID(id, void 0, layer)
|
|
64040
|
+
if (list.removeID(id, void 0, layer)) {
|
|
64041
|
+
removed = true;
|
|
64042
|
+
}
|
|
64011
64043
|
}
|
|
64012
64044
|
}
|
|
64045
|
+
return removed;
|
|
64013
64046
|
}
|
|
64014
64047
|
deleteField(parentID, field) {
|
|
64015
64048
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -64312,7 +64345,13 @@ var ListCollection = class {
|
|
|
64312
64345
|
this.lists.forEach((list) => list.addToList(...args));
|
|
64313
64346
|
}
|
|
64314
64347
|
removeID(...args) {
|
|
64315
|
-
|
|
64348
|
+
let removed = false;
|
|
64349
|
+
this.lists.forEach((list) => {
|
|
64350
|
+
if (list.removeID(...args)) {
|
|
64351
|
+
removed = true;
|
|
64352
|
+
}
|
|
64353
|
+
});
|
|
64354
|
+
return removed;
|
|
64316
64355
|
}
|
|
64317
64356
|
remove(...args) {
|
|
64318
64357
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -64431,6 +64470,7 @@ var InMemoryStorage = class {
|
|
|
64431
64470
|
}
|
|
64432
64471
|
registerIDMapping(from, to) {
|
|
64433
64472
|
this.idMaps[from] = to;
|
|
64473
|
+
this.idMaps[to] = from;
|
|
64434
64474
|
}
|
|
64435
64475
|
createLayer(optimistic = false) {
|
|
64436
64476
|
const layer = new Layer(this.idCount++);
|
|
@@ -64441,11 +64481,11 @@ var InMemoryStorage = class {
|
|
|
64441
64481
|
insert(id, field, location, target) {
|
|
64442
64482
|
return this.topLayer.insert(id, field, location, target);
|
|
64443
64483
|
}
|
|
64444
|
-
remove(id, field, target,
|
|
64445
|
-
return
|
|
64484
|
+
remove(id, field, target, layer = this.topLayer) {
|
|
64485
|
+
return layer.remove(id, field, target);
|
|
64446
64486
|
}
|
|
64447
|
-
delete(id,
|
|
64448
|
-
return
|
|
64487
|
+
delete(id, layer = this.topLayer) {
|
|
64488
|
+
return layer.delete(id);
|
|
64449
64489
|
}
|
|
64450
64490
|
deleteField(id, field) {
|
|
64451
64491
|
return this.topLayer.deleteField(id, field);
|
|
@@ -64483,6 +64523,9 @@ var InMemoryStorage = class {
|
|
|
64483
64523
|
return;
|
|
64484
64524
|
}
|
|
64485
64525
|
operations.remove.add(v);
|
|
64526
|
+
if (this.idMaps[v]) {
|
|
64527
|
+
operations.remove.add(this.idMaps[v]);
|
|
64528
|
+
}
|
|
64486
64529
|
});
|
|
64487
64530
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
64488
64531
|
const targetLayer = this.topLayer;
|
|
@@ -64509,7 +64552,11 @@ var InMemoryStorage = class {
|
|
|
64509
64552
|
operations.remove.add(op.id);
|
|
64510
64553
|
}
|
|
64511
64554
|
if (isInsertOperation(op)) {
|
|
64512
|
-
|
|
64555
|
+
if (op.location === OperationLocation.end) {
|
|
64556
|
+
operations.insert[op.location].unshift(op.id);
|
|
64557
|
+
} else {
|
|
64558
|
+
operations.insert[op.location].push(op.id);
|
|
64559
|
+
}
|
|
64513
64560
|
}
|
|
64514
64561
|
if (isDeleteOperation(op)) {
|
|
64515
64562
|
return {
|
|
@@ -64755,7 +64802,7 @@ var Layer = class {
|
|
|
64755
64802
|
}
|
|
64756
64803
|
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
64757
64804
|
const fields = {};
|
|
64758
|
-
for (const opMap of [
|
|
64805
|
+
for (const opMap of [layer.operations[id], this.operations[id]].filter(Boolean)) {
|
|
64759
64806
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
64760
64807
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
64761
64808
|
}
|
|
@@ -64795,6 +64842,7 @@ var Layer = class {
|
|
|
64795
64842
|
[id]: {
|
|
64796
64843
|
...this.operations[id],
|
|
64797
64844
|
fields: {
|
|
64845
|
+
...this.operations[id]?.fields,
|
|
64798
64846
|
[field]: [...this.operations[id]?.fields[field] || [], operation]
|
|
64799
64847
|
}
|
|
64800
64848
|
}
|
|
@@ -64820,34 +64868,6 @@ var OperationKind = {
|
|
|
64820
64868
|
remove: "remove"
|
|
64821
64869
|
};
|
|
64822
64870
|
|
|
64823
|
-
// src/runtime/cache/stuff.ts
|
|
64824
|
-
function evaluateKey(key, variables = null) {
|
|
64825
|
-
let evaluated = "";
|
|
64826
|
-
let varName = "";
|
|
64827
|
-
let inString = false;
|
|
64828
|
-
for (const char of key) {
|
|
64829
|
-
if (varName) {
|
|
64830
|
-
if (varChars.includes(char)) {
|
|
64831
|
-
varName += char;
|
|
64832
|
-
continue;
|
|
64833
|
-
}
|
|
64834
|
-
const value = variables?.[varName.slice(1)];
|
|
64835
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
64836
|
-
varName = "";
|
|
64837
|
-
}
|
|
64838
|
-
if (char === "$" && !inString) {
|
|
64839
|
-
varName = "$";
|
|
64840
|
-
continue;
|
|
64841
|
-
}
|
|
64842
|
-
if (char === '"') {
|
|
64843
|
-
inString = !inString;
|
|
64844
|
-
}
|
|
64845
|
-
evaluated += char;
|
|
64846
|
-
}
|
|
64847
|
-
return evaluated;
|
|
64848
|
-
}
|
|
64849
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
64850
|
-
|
|
64851
64871
|
// src/runtime/cache/subscription.ts
|
|
64852
64872
|
var InMemorySubscriptions = class {
|
|
64853
64873
|
cache;
|
|
@@ -64859,6 +64879,9 @@ var InMemorySubscriptions = class {
|
|
|
64859
64879
|
activeFields(parent) {
|
|
64860
64880
|
return Object.keys(this.subscribers.get(parent) || {});
|
|
64861
64881
|
}
|
|
64882
|
+
copySubscribers(from, to) {
|
|
64883
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
64884
|
+
}
|
|
64862
64885
|
add({
|
|
64863
64886
|
parent,
|
|
64864
64887
|
spec,
|
|
@@ -65041,6 +65064,11 @@ var InMemorySubscriptions = class {
|
|
|
65041
65064
|
get(id, field) {
|
|
65042
65065
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
65043
65066
|
}
|
|
65067
|
+
getAll(id) {
|
|
65068
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
65069
|
+
(fieldSub) => fieldSub.selections
|
|
65070
|
+
);
|
|
65071
|
+
}
|
|
65044
65072
|
remove(id, selection, targets, variables, visited = []) {
|
|
65045
65073
|
visited.push(id);
|
|
65046
65074
|
const linkedIDs = [];
|
|
@@ -65082,7 +65110,7 @@ var InMemorySubscriptions = class {
|
|
|
65082
65110
|
}
|
|
65083
65111
|
const subscriberField = subscriber.get(fieldName);
|
|
65084
65112
|
for (const spec of specs) {
|
|
65085
|
-
const counts =
|
|
65113
|
+
const counts = subscriberField?.referenceCounts;
|
|
65086
65114
|
if (!counts?.has(spec.set)) {
|
|
65087
65115
|
continue;
|
|
65088
65116
|
}
|
|
@@ -65105,24 +65133,23 @@ var InMemorySubscriptions = class {
|
|
|
65105
65133
|
this.subscribers.delete(id);
|
|
65106
65134
|
}
|
|
65107
65135
|
}
|
|
65108
|
-
removeAllSubscribers(id, targets
|
|
65109
|
-
|
|
65110
|
-
|
|
65111
|
-
|
|
65112
|
-
|
|
65113
|
-
|
|
65114
|
-
|
|
65115
|
-
|
|
65116
|
-
|
|
65117
|
-
|
|
65118
|
-
|
|
65119
|
-
|
|
65120
|
-
|
|
65121
|
-
|
|
65122
|
-
}
|
|
65123
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
65136
|
+
removeAllSubscribers(id, targets) {
|
|
65137
|
+
if (!targets) {
|
|
65138
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
65139
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
65140
|
+
);
|
|
65141
|
+
}
|
|
65142
|
+
for (const target of targets) {
|
|
65143
|
+
for (const subselection of this.findSubSelections(
|
|
65144
|
+
target.parentID || rootID,
|
|
65145
|
+
target.selection,
|
|
65146
|
+
target.variables || {},
|
|
65147
|
+
id
|
|
65148
|
+
)) {
|
|
65149
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
65124
65150
|
}
|
|
65125
65151
|
}
|
|
65152
|
+
return;
|
|
65126
65153
|
}
|
|
65127
65154
|
get size() {
|
|
65128
65155
|
let size = 0;
|
|
@@ -65133,6 +65160,32 @@ var InMemorySubscriptions = class {
|
|
|
65133
65160
|
}
|
|
65134
65161
|
return size;
|
|
65135
65162
|
}
|
|
65163
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
65164
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
65165
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
65166
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
65167
|
+
if (!fieldSelection.selection) {
|
|
65168
|
+
continue;
|
|
65169
|
+
}
|
|
65170
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
65171
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
65172
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
65173
|
+
if (links.includes(searchTarget)) {
|
|
65174
|
+
selections.push(fieldSelection.selection);
|
|
65175
|
+
} else {
|
|
65176
|
+
for (const link of links) {
|
|
65177
|
+
this.findSubSelections(
|
|
65178
|
+
link,
|
|
65179
|
+
fieldSelection.selection,
|
|
65180
|
+
variables,
|
|
65181
|
+
searchTarget,
|
|
65182
|
+
selections
|
|
65183
|
+
);
|
|
65184
|
+
}
|
|
65185
|
+
}
|
|
65186
|
+
}
|
|
65187
|
+
return selections;
|
|
65188
|
+
}
|
|
65136
65189
|
};
|
|
65137
65190
|
|
|
65138
65191
|
// src/runtime/cache/cache.ts
|
|
@@ -65210,11 +65263,17 @@ var Cache = class {
|
|
|
65210
65263
|
}
|
|
65211
65264
|
registerKeyMap(source, mapped) {
|
|
65212
65265
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
65266
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
65213
65267
|
}
|
|
65214
65268
|
delete(id, layer) {
|
|
65215
|
-
this._internal_unstable.
|
|
65216
|
-
|
|
65217
|
-
|
|
65269
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
65270
|
+
Boolean
|
|
65271
|
+
);
|
|
65272
|
+
for (const recordID of recordIDs) {
|
|
65273
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
65274
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
65275
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
65276
|
+
}
|
|
65218
65277
|
}
|
|
65219
65278
|
setConfig(config) {
|
|
65220
65279
|
this._internal_unstable.setConfig(config);
|
|
@@ -65520,6 +65579,9 @@ var CacheInternal = class {
|
|
|
65520
65579
|
layer,
|
|
65521
65580
|
forceNotify
|
|
65522
65581
|
});
|
|
65582
|
+
let action = () => {
|
|
65583
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
65584
|
+
};
|
|
65523
65585
|
if (applyUpdates && updates) {
|
|
65524
65586
|
if (key === "edges") {
|
|
65525
65587
|
const newNodeIDs = [];
|
|
@@ -65554,8 +65616,26 @@ var CacheInternal = class {
|
|
|
65554
65616
|
}
|
|
65555
65617
|
if (update === "prepend") {
|
|
65556
65618
|
linkedIDs = newIDs.concat(oldIDs);
|
|
65619
|
+
if (layer?.optimistic) {
|
|
65620
|
+
action = () => {
|
|
65621
|
+
for (const id of newIDs) {
|
|
65622
|
+
if (id) {
|
|
65623
|
+
layer.insert(parent, key, "start", id);
|
|
65624
|
+
}
|
|
65625
|
+
}
|
|
65626
|
+
};
|
|
65627
|
+
}
|
|
65557
65628
|
} else if (update === "append") {
|
|
65558
65629
|
linkedIDs = oldIDs.concat(newIDs);
|
|
65630
|
+
if (layer?.optimistic) {
|
|
65631
|
+
action = () => {
|
|
65632
|
+
for (const id of newIDs) {
|
|
65633
|
+
if (id) {
|
|
65634
|
+
layer.insert(parent, key, "end", id);
|
|
65635
|
+
}
|
|
65636
|
+
}
|
|
65637
|
+
};
|
|
65638
|
+
}
|
|
65559
65639
|
} else if (update === "replace") {
|
|
65560
65640
|
linkedIDs = newIDs;
|
|
65561
65641
|
}
|
|
@@ -65574,7 +65654,7 @@ var CacheInternal = class {
|
|
|
65574
65654
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
65575
65655
|
}
|
|
65576
65656
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
65577
|
-
|
|
65657
|
+
action();
|
|
65578
65658
|
}
|
|
65579
65659
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
65580
65660
|
if (id == null) {
|
|
@@ -65629,6 +65709,9 @@ var CacheInternal = class {
|
|
|
65629
65709
|
if (!targetID) {
|
|
65630
65710
|
continue;
|
|
65631
65711
|
}
|
|
65712
|
+
toNotify.push(
|
|
65713
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
65714
|
+
);
|
|
65632
65715
|
this.cache.delete(targetID, layer);
|
|
65633
65716
|
}
|
|
65634
65717
|
}
|
|
@@ -66050,7 +66133,6 @@ function variableValue(value, args) {
|
|
|
66050
66133
|
);
|
|
66051
66134
|
}
|
|
66052
66135
|
}
|
|
66053
|
-
var rootID = "_ROOT_";
|
|
66054
66136
|
function defaultComponentField({
|
|
66055
66137
|
cache,
|
|
66056
66138
|
component,
|
|
@@ -66731,7 +66813,9 @@ var optimisticKeys = (cache, callbackCache = callbacks, keyCache = keys, objectI
|
|
|
66731
66813
|
});
|
|
66732
66814
|
delete callbackCache[optimisticValue];
|
|
66733
66815
|
},
|
|
66734
|
-
onIDChange: (optimisticValue, realValue) =>
|
|
66816
|
+
onIDChange: (optimisticValue, realValue) => {
|
|
66817
|
+
cache.registerKeyMap(optimisticValue, realValue);
|
|
66818
|
+
}
|
|
66735
66819
|
}
|
|
66736
66820
|
);
|
|
66737
66821
|
}
|