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-esm/index.js
CHANGED
|
@@ -63855,6 +63855,35 @@ var GarbageCollector = class {
|
|
|
63855
63855
|
}
|
|
63856
63856
|
};
|
|
63857
63857
|
|
|
63858
|
+
// src/runtime/cache/stuff.ts
|
|
63859
|
+
function evaluateKey(key, variables = null) {
|
|
63860
|
+
let evaluated = "";
|
|
63861
|
+
let varName = "";
|
|
63862
|
+
let inString = false;
|
|
63863
|
+
for (const char of key) {
|
|
63864
|
+
if (varName) {
|
|
63865
|
+
if (varChars.includes(char)) {
|
|
63866
|
+
varName += char;
|
|
63867
|
+
continue;
|
|
63868
|
+
}
|
|
63869
|
+
const value = variables?.[varName.slice(1)];
|
|
63870
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
63871
|
+
varName = "";
|
|
63872
|
+
}
|
|
63873
|
+
if (char === "$" && !inString) {
|
|
63874
|
+
varName = "$";
|
|
63875
|
+
continue;
|
|
63876
|
+
}
|
|
63877
|
+
if (char === '"') {
|
|
63878
|
+
inString = !inString;
|
|
63879
|
+
}
|
|
63880
|
+
evaluated += char;
|
|
63881
|
+
}
|
|
63882
|
+
return evaluated;
|
|
63883
|
+
}
|
|
63884
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
63885
|
+
var rootID = "_ROOT_";
|
|
63886
|
+
|
|
63858
63887
|
// src/runtime/cache/lists.ts
|
|
63859
63888
|
var ListManager = class {
|
|
63860
63889
|
rootID;
|
|
@@ -63921,11 +63950,15 @@ var ListManager = class {
|
|
|
63921
63950
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
63922
63951
|
}
|
|
63923
63952
|
removeIDFromAllLists(id, layer) {
|
|
63953
|
+
let removed = false;
|
|
63924
63954
|
for (const fieldMap of this.lists.values()) {
|
|
63925
63955
|
for (const list of fieldMap.values()) {
|
|
63926
|
-
list.removeID(id, void 0, layer)
|
|
63956
|
+
if (list.removeID(id, void 0, layer)) {
|
|
63957
|
+
removed = true;
|
|
63958
|
+
}
|
|
63927
63959
|
}
|
|
63928
63960
|
}
|
|
63961
|
+
return removed;
|
|
63929
63962
|
}
|
|
63930
63963
|
deleteField(parentID, field) {
|
|
63931
63964
|
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
@@ -64228,7 +64261,13 @@ var ListCollection = class {
|
|
|
64228
64261
|
this.lists.forEach((list) => list.addToList(...args));
|
|
64229
64262
|
}
|
|
64230
64263
|
removeID(...args) {
|
|
64231
|
-
|
|
64264
|
+
let removed = false;
|
|
64265
|
+
this.lists.forEach((list) => {
|
|
64266
|
+
if (list.removeID(...args)) {
|
|
64267
|
+
removed = true;
|
|
64268
|
+
}
|
|
64269
|
+
});
|
|
64270
|
+
return removed;
|
|
64232
64271
|
}
|
|
64233
64272
|
remove(...args) {
|
|
64234
64273
|
this.lists.forEach((list) => list.remove(...args));
|
|
@@ -64347,6 +64386,7 @@ var InMemoryStorage = class {
|
|
|
64347
64386
|
}
|
|
64348
64387
|
registerIDMapping(from, to) {
|
|
64349
64388
|
this.idMaps[from] = to;
|
|
64389
|
+
this.idMaps[to] = from;
|
|
64350
64390
|
}
|
|
64351
64391
|
createLayer(optimistic = false) {
|
|
64352
64392
|
const layer = new Layer(this.idCount++);
|
|
@@ -64357,11 +64397,11 @@ var InMemoryStorage = class {
|
|
|
64357
64397
|
insert(id, field, location, target) {
|
|
64358
64398
|
return this.topLayer.insert(id, field, location, target);
|
|
64359
64399
|
}
|
|
64360
|
-
remove(id, field, target,
|
|
64361
|
-
return
|
|
64400
|
+
remove(id, field, target, layer = this.topLayer) {
|
|
64401
|
+
return layer.remove(id, field, target);
|
|
64362
64402
|
}
|
|
64363
|
-
delete(id,
|
|
64364
|
-
return
|
|
64403
|
+
delete(id, layer = this.topLayer) {
|
|
64404
|
+
return layer.delete(id);
|
|
64365
64405
|
}
|
|
64366
64406
|
deleteField(id, field) {
|
|
64367
64407
|
return this.topLayer.deleteField(id, field);
|
|
@@ -64399,6 +64439,9 @@ var InMemoryStorage = class {
|
|
|
64399
64439
|
return;
|
|
64400
64440
|
}
|
|
64401
64441
|
operations.remove.add(v);
|
|
64442
|
+
if (this.idMaps[v]) {
|
|
64443
|
+
operations.remove.add(this.idMaps[v]);
|
|
64444
|
+
}
|
|
64402
64445
|
});
|
|
64403
64446
|
if (typeof layerValue === "undefined" && defaultValue) {
|
|
64404
64447
|
const targetLayer = this.topLayer;
|
|
@@ -64425,7 +64468,11 @@ var InMemoryStorage = class {
|
|
|
64425
64468
|
operations.remove.add(op.id);
|
|
64426
64469
|
}
|
|
64427
64470
|
if (isInsertOperation(op)) {
|
|
64428
|
-
|
|
64471
|
+
if (op.location === OperationLocation.end) {
|
|
64472
|
+
operations.insert[op.location].unshift(op.id);
|
|
64473
|
+
} else {
|
|
64474
|
+
operations.insert[op.location].push(op.id);
|
|
64475
|
+
}
|
|
64429
64476
|
}
|
|
64430
64477
|
if (isDeleteOperation(op)) {
|
|
64431
64478
|
return {
|
|
@@ -64671,7 +64718,7 @@ var Layer = class {
|
|
|
64671
64718
|
}
|
|
64672
64719
|
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
64673
64720
|
const fields = {};
|
|
64674
|
-
for (const opMap of [
|
|
64721
|
+
for (const opMap of [layer.operations[id], this.operations[id]].filter(Boolean)) {
|
|
64675
64722
|
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
64676
64723
|
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
64677
64724
|
}
|
|
@@ -64711,6 +64758,7 @@ var Layer = class {
|
|
|
64711
64758
|
[id]: {
|
|
64712
64759
|
...this.operations[id],
|
|
64713
64760
|
fields: {
|
|
64761
|
+
...this.operations[id]?.fields,
|
|
64714
64762
|
[field]: [...this.operations[id]?.fields[field] || [], operation]
|
|
64715
64763
|
}
|
|
64716
64764
|
}
|
|
@@ -64736,34 +64784,6 @@ var OperationKind = {
|
|
|
64736
64784
|
remove: "remove"
|
|
64737
64785
|
};
|
|
64738
64786
|
|
|
64739
|
-
// src/runtime/cache/stuff.ts
|
|
64740
|
-
function evaluateKey(key, variables = null) {
|
|
64741
|
-
let evaluated = "";
|
|
64742
|
-
let varName = "";
|
|
64743
|
-
let inString = false;
|
|
64744
|
-
for (const char of key) {
|
|
64745
|
-
if (varName) {
|
|
64746
|
-
if (varChars.includes(char)) {
|
|
64747
|
-
varName += char;
|
|
64748
|
-
continue;
|
|
64749
|
-
}
|
|
64750
|
-
const value = variables?.[varName.slice(1)];
|
|
64751
|
-
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
64752
|
-
varName = "";
|
|
64753
|
-
}
|
|
64754
|
-
if (char === "$" && !inString) {
|
|
64755
|
-
varName = "$";
|
|
64756
|
-
continue;
|
|
64757
|
-
}
|
|
64758
|
-
if (char === '"') {
|
|
64759
|
-
inString = !inString;
|
|
64760
|
-
}
|
|
64761
|
-
evaluated += char;
|
|
64762
|
-
}
|
|
64763
|
-
return evaluated;
|
|
64764
|
-
}
|
|
64765
|
-
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
64766
|
-
|
|
64767
64787
|
// src/runtime/cache/subscription.ts
|
|
64768
64788
|
var InMemorySubscriptions = class {
|
|
64769
64789
|
cache;
|
|
@@ -64775,6 +64795,9 @@ var InMemorySubscriptions = class {
|
|
|
64775
64795
|
activeFields(parent) {
|
|
64776
64796
|
return Object.keys(this.subscribers.get(parent) || {});
|
|
64777
64797
|
}
|
|
64798
|
+
copySubscribers(from, to) {
|
|
64799
|
+
this.subscribers.set(to, this.subscribers.get(from) || /* @__PURE__ */ new Map());
|
|
64800
|
+
}
|
|
64778
64801
|
add({
|
|
64779
64802
|
parent,
|
|
64780
64803
|
spec,
|
|
@@ -64957,6 +64980,11 @@ var InMemorySubscriptions = class {
|
|
|
64957
64980
|
get(id, field) {
|
|
64958
64981
|
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
64959
64982
|
}
|
|
64983
|
+
getAll(id) {
|
|
64984
|
+
return [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
64985
|
+
(fieldSub) => fieldSub.selections
|
|
64986
|
+
);
|
|
64987
|
+
}
|
|
64960
64988
|
remove(id, selection, targets, variables, visited = []) {
|
|
64961
64989
|
visited.push(id);
|
|
64962
64990
|
const linkedIDs = [];
|
|
@@ -64998,7 +65026,7 @@ var InMemorySubscriptions = class {
|
|
|
64998
65026
|
}
|
|
64999
65027
|
const subscriberField = subscriber.get(fieldName);
|
|
65000
65028
|
for (const spec of specs) {
|
|
65001
|
-
const counts =
|
|
65029
|
+
const counts = subscriberField?.referenceCounts;
|
|
65002
65030
|
if (!counts?.has(spec.set)) {
|
|
65003
65031
|
continue;
|
|
65004
65032
|
}
|
|
@@ -65021,24 +65049,23 @@ var InMemorySubscriptions = class {
|
|
|
65021
65049
|
this.subscribers.delete(id);
|
|
65022
65050
|
}
|
|
65023
65051
|
}
|
|
65024
|
-
removeAllSubscribers(id, targets
|
|
65025
|
-
|
|
65026
|
-
|
|
65027
|
-
|
|
65028
|
-
|
|
65029
|
-
|
|
65030
|
-
|
|
65031
|
-
|
|
65032
|
-
|
|
65033
|
-
|
|
65034
|
-
|
|
65035
|
-
|
|
65036
|
-
|
|
65037
|
-
|
|
65038
|
-
}
|
|
65039
|
-
this.removeAllSubscribers(id2, subscribers, visited);
|
|
65052
|
+
removeAllSubscribers(id, targets) {
|
|
65053
|
+
if (!targets) {
|
|
65054
|
+
targets = [...this.subscribers.get(id)?.values() || []].flatMap(
|
|
65055
|
+
(spec) => spec.selections.flatMap((sel) => sel[0])
|
|
65056
|
+
);
|
|
65057
|
+
}
|
|
65058
|
+
for (const target of targets) {
|
|
65059
|
+
for (const subselection of this.findSubSelections(
|
|
65060
|
+
target.parentID || rootID,
|
|
65061
|
+
target.selection,
|
|
65062
|
+
target.variables || {},
|
|
65063
|
+
id
|
|
65064
|
+
)) {
|
|
65065
|
+
this.remove(id, subselection, targets, target.variables || {});
|
|
65040
65066
|
}
|
|
65041
65067
|
}
|
|
65068
|
+
return;
|
|
65042
65069
|
}
|
|
65043
65070
|
get size() {
|
|
65044
65071
|
let size = 0;
|
|
@@ -65049,6 +65076,32 @@ var InMemorySubscriptions = class {
|
|
|
65049
65076
|
}
|
|
65050
65077
|
return size;
|
|
65051
65078
|
}
|
|
65079
|
+
findSubSelections(parentID, selection, variables, searchTarget, selections = []) {
|
|
65080
|
+
const __typename = this.cache._internal_unstable.storage.get(parentID, "__typename").value;
|
|
65081
|
+
let targetSelection = getFieldsForType(selection, __typename, false);
|
|
65082
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
65083
|
+
if (!fieldSelection.selection) {
|
|
65084
|
+
continue;
|
|
65085
|
+
}
|
|
65086
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables || {});
|
|
65087
|
+
const linkedRecord = this.cache._internal_unstable.storage.get(parentID, key);
|
|
65088
|
+
const links = !Array.isArray(linkedRecord.value) ? [linkedRecord.value] : flatten(linkedRecord.value);
|
|
65089
|
+
if (links.includes(searchTarget)) {
|
|
65090
|
+
selections.push(fieldSelection.selection);
|
|
65091
|
+
} else {
|
|
65092
|
+
for (const link of links) {
|
|
65093
|
+
this.findSubSelections(
|
|
65094
|
+
link,
|
|
65095
|
+
fieldSelection.selection,
|
|
65096
|
+
variables,
|
|
65097
|
+
searchTarget,
|
|
65098
|
+
selections
|
|
65099
|
+
);
|
|
65100
|
+
}
|
|
65101
|
+
}
|
|
65102
|
+
}
|
|
65103
|
+
return selections;
|
|
65104
|
+
}
|
|
65052
65105
|
};
|
|
65053
65106
|
|
|
65054
65107
|
// src/runtime/cache/cache.ts
|
|
@@ -65126,11 +65179,17 @@ var Cache = class {
|
|
|
65126
65179
|
}
|
|
65127
65180
|
registerKeyMap(source, mapped) {
|
|
65128
65181
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
65182
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
65129
65183
|
}
|
|
65130
65184
|
delete(id, layer) {
|
|
65131
|
-
this._internal_unstable.
|
|
65132
|
-
|
|
65133
|
-
|
|
65185
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
65186
|
+
Boolean
|
|
65187
|
+
);
|
|
65188
|
+
for (const recordID of recordIDs) {
|
|
65189
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
65190
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
65191
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
65192
|
+
}
|
|
65134
65193
|
}
|
|
65135
65194
|
setConfig(config) {
|
|
65136
65195
|
this._internal_unstable.setConfig(config);
|
|
@@ -65436,6 +65495,9 @@ var CacheInternal = class {
|
|
|
65436
65495
|
layer,
|
|
65437
65496
|
forceNotify
|
|
65438
65497
|
});
|
|
65498
|
+
let action = () => {
|
|
65499
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
65500
|
+
};
|
|
65439
65501
|
if (applyUpdates && updates) {
|
|
65440
65502
|
if (key === "edges") {
|
|
65441
65503
|
const newNodeIDs = [];
|
|
@@ -65470,8 +65532,26 @@ var CacheInternal = class {
|
|
|
65470
65532
|
}
|
|
65471
65533
|
if (update === "prepend") {
|
|
65472
65534
|
linkedIDs = newIDs.concat(oldIDs);
|
|
65535
|
+
if (layer?.optimistic) {
|
|
65536
|
+
action = () => {
|
|
65537
|
+
for (const id of newIDs) {
|
|
65538
|
+
if (id) {
|
|
65539
|
+
layer.insert(parent, key, "start", id);
|
|
65540
|
+
}
|
|
65541
|
+
}
|
|
65542
|
+
};
|
|
65543
|
+
}
|
|
65473
65544
|
} else if (update === "append") {
|
|
65474
65545
|
linkedIDs = oldIDs.concat(newIDs);
|
|
65546
|
+
if (layer?.optimistic) {
|
|
65547
|
+
action = () => {
|
|
65548
|
+
for (const id of newIDs) {
|
|
65549
|
+
if (id) {
|
|
65550
|
+
layer.insert(parent, key, "end", id);
|
|
65551
|
+
}
|
|
65552
|
+
}
|
|
65553
|
+
};
|
|
65554
|
+
}
|
|
65475
65555
|
} else if (update === "replace") {
|
|
65476
65556
|
linkedIDs = newIDs;
|
|
65477
65557
|
}
|
|
@@ -65490,7 +65570,7 @@ var CacheInternal = class {
|
|
|
65490
65570
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
65491
65571
|
}
|
|
65492
65572
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
65493
|
-
|
|
65573
|
+
action();
|
|
65494
65574
|
}
|
|
65495
65575
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
65496
65576
|
if (id == null) {
|
|
@@ -65545,6 +65625,9 @@ var CacheInternal = class {
|
|
|
65545
65625
|
if (!targetID) {
|
|
65546
65626
|
continue;
|
|
65547
65627
|
}
|
|
65628
|
+
toNotify.push(
|
|
65629
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
65630
|
+
);
|
|
65548
65631
|
this.cache.delete(targetID, layer);
|
|
65549
65632
|
}
|
|
65550
65633
|
}
|
|
@@ -65966,7 +66049,6 @@ function variableValue(value, args) {
|
|
|
65966
66049
|
);
|
|
65967
66050
|
}
|
|
65968
66051
|
}
|
|
65969
|
-
var rootID = "_ROOT_";
|
|
65970
66052
|
function defaultComponentField({
|
|
65971
66053
|
cache,
|
|
65972
66054
|
component,
|
|
@@ -66647,7 +66729,9 @@ var optimisticKeys = (cache, callbackCache = callbacks, keyCache = keys, objectI
|
|
|
66647
66729
|
});
|
|
66648
66730
|
delete callbackCache[optimisticValue];
|
|
66649
66731
|
},
|
|
66650
|
-
onIDChange: (optimisticValue, realValue) =>
|
|
66732
|
+
onIDChange: (optimisticValue, realValue) => {
|
|
66733
|
+
cache.registerKeyMap(optimisticValue, realValue);
|
|
66734
|
+
}
|
|
66651
66735
|
}
|
|
66652
66736
|
);
|
|
66653
66737
|
}
|
|
@@ -36,7 +36,7 @@ export declare class Cache {
|
|
|
36
36
|
subscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
37
37
|
unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
38
38
|
list(name: string, parentID?: string, allLists?: boolean): ListCollection;
|
|
39
|
-
registerKeyMap(source: string
|
|
39
|
+
registerKeyMap(source: string, mapped: string): void;
|
|
40
40
|
delete(id: string, layer?: Layer): void;
|
|
41
41
|
setConfig(config: ConfigFile): void;
|
|
42
42
|
markTypeStale(options?: {
|
|
@@ -153,7 +153,6 @@ export declare function evaluateVariables(variables: ValueMap, args: GraphQLObje
|
|
|
153
153
|
[k: string]: GraphQLValue;
|
|
154
154
|
};
|
|
155
155
|
export declare function variableValue(value: ValueNode, args: GraphQLObject): GraphQLValue;
|
|
156
|
-
export declare const rootID = "_ROOT_";
|
|
157
156
|
export declare function fragmentReference({ component, prop, }: {
|
|
158
157
|
component: {
|
|
159
158
|
name: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const rootID = "_ROOT_";
|
|
@@ -21,7 +21,7 @@ export declare class ListManager {
|
|
|
21
21
|
filters?: List['filters'];
|
|
22
22
|
abstract?: boolean;
|
|
23
23
|
}): void;
|
|
24
|
-
removeIDFromAllLists(id: string, layer?: Layer):
|
|
24
|
+
removeIDFromAllLists(id: string, layer?: Layer): boolean;
|
|
25
25
|
deleteField(parentID: string, field: string): void;
|
|
26
26
|
reset(): void;
|
|
27
27
|
}
|
|
@@ -77,7 +77,7 @@ export declare class ListCollection {
|
|
|
77
77
|
append(...args: Parameters<List['append']>): void;
|
|
78
78
|
prepend(...args: Parameters<List['prepend']>): void;
|
|
79
79
|
addToList(...args: Parameters<List['addToList']>): void;
|
|
80
|
-
removeID(...args: Parameters<List['removeID']>):
|
|
80
|
+
removeID(...args: Parameters<List['removeID']>): boolean;
|
|
81
81
|
remove(...args: Parameters<List['remove']>): void;
|
|
82
82
|
toggleElement(...args: Parameters<List['toggleElement']>): void;
|
|
83
83
|
when(when?: ListWhen): ListCollection;
|
|
@@ -3,15 +3,15 @@ export declare class InMemoryStorage {
|
|
|
3
3
|
data: Layer[];
|
|
4
4
|
private idCount;
|
|
5
5
|
private rank;
|
|
6
|
-
|
|
6
|
+
idMaps: Record<string, string>;
|
|
7
7
|
constructor();
|
|
8
8
|
get layerCount(): number;
|
|
9
9
|
get nextRank(): number;
|
|
10
|
-
registerIDMapping(from: string
|
|
10
|
+
registerIDMapping(from: string, to: string): void;
|
|
11
11
|
createLayer(optimistic?: boolean): Layer;
|
|
12
12
|
insert(id: string, field: string, location: OperationLocations, target: string): void;
|
|
13
|
-
remove(id: string, field: string, target: string,
|
|
14
|
-
delete(id: string,
|
|
13
|
+
remove(id: string, field: string, target: string, layer?: Layer): void;
|
|
14
|
+
delete(id: string, layer?: Layer): void;
|
|
15
15
|
deleteField(id: string, field: string): void;
|
|
16
16
|
getLayer(id: number): Layer;
|
|
17
17
|
replaceID(replacement: {
|
|
@@ -10,6 +10,7 @@ export declare class InMemorySubscriptions {
|
|
|
10
10
|
private subscribers;
|
|
11
11
|
private keyVersions;
|
|
12
12
|
activeFields(parent: string): string[];
|
|
13
|
+
copySubscribers(from: string, to: string): void;
|
|
13
14
|
add({ parent, spec, selection, variables, parentType, }: {
|
|
14
15
|
parent: string;
|
|
15
16
|
parentType?: string;
|
|
@@ -41,9 +42,11 @@ export declare class InMemorySubscriptions {
|
|
|
41
42
|
parentType: string;
|
|
42
43
|
}): void;
|
|
43
44
|
get(id: string, field: string): FieldSelection[];
|
|
45
|
+
getAll(id: string): FieldSelection[];
|
|
44
46
|
remove(id: string, selection: SubscriptionSelection, targets: SubscriptionSpec[], variables: {}, visited?: string[]): void;
|
|
45
47
|
reset(): SubscriptionSpec[];
|
|
46
48
|
private removeSubscribers;
|
|
47
|
-
removeAllSubscribers(id: string, targets?: SubscriptionSpec[]
|
|
49
|
+
removeAllSubscribers(id: string, targets?: SubscriptionSpec[]): void;
|
|
48
50
|
get size(): number;
|
|
51
|
+
findSubSelections(parentID: string, selection: SubscriptionSelection, variables: {}, searchTarget: string, selections?: SubscriptionSelection[]): Array<SubscriptionSelection>;
|
|
49
52
|
}
|
|
@@ -36,7 +36,7 @@ export declare class Cache {
|
|
|
36
36
|
subscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
37
37
|
unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
|
|
38
38
|
list(name: string, parentID?: string, allLists?: boolean): ListCollection;
|
|
39
|
-
registerKeyMap(source: string
|
|
39
|
+
registerKeyMap(source: string, mapped: string): void;
|
|
40
40
|
delete(id: string, layer?: Layer): void;
|
|
41
41
|
setConfig(config: ConfigFile): void;
|
|
42
42
|
markTypeStale(options?: {
|
|
@@ -153,7 +153,6 @@ export declare function evaluateVariables(variables: ValueMap, args: GraphQLObje
|
|
|
153
153
|
[k: string]: GraphQLValue;
|
|
154
154
|
};
|
|
155
155
|
export declare function variableValue(value: ValueNode, args: GraphQLObject): GraphQLValue;
|
|
156
|
-
export declare const rootID = "_ROOT_";
|
|
157
156
|
export declare function fragmentReference({ component, prop, }: {
|
|
158
157
|
component: {
|
|
159
158
|
name: string;
|
|
@@ -22,7 +22,6 @@ __export(cache_exports, {
|
|
|
22
22
|
defaultComponentField: () => defaultComponentField,
|
|
23
23
|
evaluateVariables: () => evaluateVariables,
|
|
24
24
|
fragmentReference: () => fragmentReference,
|
|
25
|
-
rootID: () => rootID,
|
|
26
25
|
variableValue: () => variableValue
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(cache_exports);
|
|
@@ -50,7 +49,7 @@ class Cache {
|
|
|
50
49
|
cache: this,
|
|
51
50
|
storage: new import_storage.InMemoryStorage(),
|
|
52
51
|
subscriptions: new import_subscription.InMemorySubscriptions(this),
|
|
53
|
-
lists: new import_lists.ListManager(this, rootID),
|
|
52
|
+
lists: new import_lists.ListManager(this, import_stuff.rootID),
|
|
54
53
|
lifetimes: new import_gc.GarbageCollector(this),
|
|
55
54
|
staleManager: new import_staleManager.StaleManager(this),
|
|
56
55
|
disabled: disabled ?? typeof globalThis.window === "undefined",
|
|
@@ -87,7 +86,7 @@ class Cache {
|
|
|
87
86
|
return;
|
|
88
87
|
}
|
|
89
88
|
return this._internal_unstable.subscriptions.add({
|
|
90
|
-
parent: spec.parentID || rootID,
|
|
89
|
+
parent: spec.parentID || import_stuff.rootID,
|
|
91
90
|
spec,
|
|
92
91
|
selection: spec.selection,
|
|
93
92
|
variables
|
|
@@ -95,7 +94,7 @@ class Cache {
|
|
|
95
94
|
}
|
|
96
95
|
unsubscribe(spec, variables = {}) {
|
|
97
96
|
return this._internal_unstable.subscriptions.remove(
|
|
98
|
-
spec.parentID || rootID,
|
|
97
|
+
spec.parentID || import_stuff.rootID,
|
|
99
98
|
spec.selection,
|
|
100
99
|
[spec],
|
|
101
100
|
variables
|
|
@@ -112,11 +111,17 @@ class Cache {
|
|
|
112
111
|
}
|
|
113
112
|
registerKeyMap(source, mapped) {
|
|
114
113
|
this._internal_unstable.storage.registerIDMapping(source, mapped);
|
|
114
|
+
this._internal_unstable.subscriptions.copySubscribers(source, mapped);
|
|
115
115
|
}
|
|
116
116
|
delete(id, layer) {
|
|
117
|
-
this._internal_unstable.
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const recordIDs = [this._internal_unstable.storage.idMaps[id], id].filter(
|
|
118
|
+
Boolean
|
|
119
|
+
);
|
|
120
|
+
for (const recordID of recordIDs) {
|
|
121
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(recordID);
|
|
122
|
+
this._internal_unstable.lists.removeIDFromAllLists(recordID, layer);
|
|
123
|
+
this._internal_unstable.storage.delete(recordID, layer);
|
|
124
|
+
}
|
|
120
125
|
}
|
|
121
126
|
setConfig(config) {
|
|
122
127
|
this._internal_unstable.setConfig(config);
|
|
@@ -217,7 +222,7 @@ class Cache {
|
|
|
217
222
|
notified.push(spec.set);
|
|
218
223
|
spec.set(
|
|
219
224
|
this._internal_unstable.getSelection({
|
|
220
|
-
parent: spec.parentID || rootID,
|
|
225
|
+
parent: spec.parentID || import_stuff.rootID,
|
|
221
226
|
selection: spec.selection,
|
|
222
227
|
variables: spec.variables?.() || {},
|
|
223
228
|
ignoreMasking: false
|
|
@@ -277,7 +282,7 @@ class CacheInternal {
|
|
|
277
282
|
data,
|
|
278
283
|
selection,
|
|
279
284
|
variables = {},
|
|
280
|
-
parent = rootID,
|
|
285
|
+
parent = import_stuff.rootID,
|
|
281
286
|
applyUpdates,
|
|
282
287
|
layer,
|
|
283
288
|
toNotify = [],
|
|
@@ -422,6 +427,9 @@ class CacheInternal {
|
|
|
422
427
|
layer,
|
|
423
428
|
forceNotify
|
|
424
429
|
});
|
|
430
|
+
let action = () => {
|
|
431
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
432
|
+
};
|
|
425
433
|
if (applyUpdates && updates) {
|
|
426
434
|
if (key === "edges") {
|
|
427
435
|
const newNodeIDs = [];
|
|
@@ -456,8 +464,26 @@ class CacheInternal {
|
|
|
456
464
|
}
|
|
457
465
|
if (update === "prepend") {
|
|
458
466
|
linkedIDs = newIDs.concat(oldIDs);
|
|
467
|
+
if (layer?.optimistic) {
|
|
468
|
+
action = () => {
|
|
469
|
+
for (const id of newIDs) {
|
|
470
|
+
if (id) {
|
|
471
|
+
layer.insert(parent, key, "start", id);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
459
476
|
} else if (update === "append") {
|
|
460
477
|
linkedIDs = oldIDs.concat(newIDs);
|
|
478
|
+
if (layer?.optimistic) {
|
|
479
|
+
action = () => {
|
|
480
|
+
for (const id of newIDs) {
|
|
481
|
+
if (id) {
|
|
482
|
+
layer.insert(parent, key, "end", id);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
461
487
|
} else if (update === "replace") {
|
|
462
488
|
linkedIDs = newIDs;
|
|
463
489
|
}
|
|
@@ -476,7 +502,7 @@ class CacheInternal {
|
|
|
476
502
|
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
477
503
|
}
|
|
478
504
|
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
479
|
-
|
|
505
|
+
action();
|
|
480
506
|
}
|
|
481
507
|
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
482
508
|
if (id == null) {
|
|
@@ -531,6 +557,9 @@ class CacheInternal {
|
|
|
531
557
|
if (!targetID) {
|
|
532
558
|
continue;
|
|
533
559
|
}
|
|
560
|
+
toNotify.push(
|
|
561
|
+
...this.subscriptions.getAll(targetID).filter((sub) => sub[0].parentID !== targetID)
|
|
562
|
+
);
|
|
534
563
|
this.cache.delete(targetID, layer);
|
|
535
564
|
}
|
|
536
565
|
}
|
|
@@ -540,7 +569,7 @@ class CacheInternal {
|
|
|
540
569
|
}
|
|
541
570
|
getSelection({
|
|
542
571
|
selection,
|
|
543
|
-
parent = rootID,
|
|
572
|
+
parent = import_stuff.rootID,
|
|
544
573
|
variables,
|
|
545
574
|
stepsFromConnection = null,
|
|
546
575
|
ignoreMasking,
|
|
@@ -884,7 +913,7 @@ class CacheInternal {
|
|
|
884
913
|
}
|
|
885
914
|
}
|
|
886
915
|
this.writeSelection({
|
|
887
|
-
root: rootID,
|
|
916
|
+
root: import_stuff.rootID,
|
|
888
917
|
selection: fields,
|
|
889
918
|
parent: linkedID,
|
|
890
919
|
data: entryObj,
|
|
@@ -952,7 +981,6 @@ function variableValue(value, args) {
|
|
|
952
981
|
);
|
|
953
982
|
}
|
|
954
983
|
}
|
|
955
|
-
const rootID = "_ROOT_";
|
|
956
984
|
function fragmentReference({
|
|
957
985
|
component,
|
|
958
986
|
prop
|
|
@@ -991,6 +1019,5 @@ function defaultComponentField({
|
|
|
991
1019
|
defaultComponentField,
|
|
992
1020
|
evaluateVariables,
|
|
993
1021
|
fragmentReference,
|
|
994
|
-
rootID,
|
|
995
1022
|
variableValue
|
|
996
1023
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const rootID = "_ROOT_";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
rootID: () => rootID
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(constants_exports);
|
|
24
|
+
const rootID = "_ROOT_";
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
rootID
|
|
28
|
+
});
|
|
@@ -21,7 +21,7 @@ export declare class ListManager {
|
|
|
21
21
|
filters?: List['filters'];
|
|
22
22
|
abstract?: boolean;
|
|
23
23
|
}): void;
|
|
24
|
-
removeIDFromAllLists(id: string, layer?: Layer):
|
|
24
|
+
removeIDFromAllLists(id: string, layer?: Layer): boolean;
|
|
25
25
|
deleteField(parentID: string, field: string): void;
|
|
26
26
|
reset(): void;
|
|
27
27
|
}
|
|
@@ -77,7 +77,7 @@ export declare class ListCollection {
|
|
|
77
77
|
append(...args: Parameters<List['append']>): void;
|
|
78
78
|
prepend(...args: Parameters<List['prepend']>): void;
|
|
79
79
|
addToList(...args: Parameters<List['addToList']>): void;
|
|
80
|
-
removeID(...args: Parameters<List['removeID']>):
|
|
80
|
+
removeID(...args: Parameters<List['removeID']>): boolean;
|
|
81
81
|
remove(...args: Parameters<List['remove']>): void;
|
|
82
82
|
toggleElement(...args: Parameters<List['toggleElement']>): void;
|
|
83
83
|
when(when?: ListWhen): ListCollection;
|