houdini 1.2.34 → 1.2.36
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 +44 -38
- package/build/cmd-esm/index.js +44 -38
- package/build/codegen-cjs/index.js +42 -36
- package/build/codegen-esm/index.js +42 -36
- package/build/lib-cjs/index.js +33 -32
- package/build/lib-esm/index.js +33 -32
- package/build/runtime/cache/subscription.d.ts +0 -1
- package/build/runtime-cjs/cache/subscription.d.ts +0 -1
- package/build/runtime-cjs/cache/subscription.js +32 -31
- package/build/runtime-esm/cache/subscription.d.ts +0 -1
- package/build/runtime-esm/cache/subscription.js +32 -31
- package/build/test-cjs/index.js +42 -36
- package/build/test-esm/index.js +42 -36
- package/build/vite-cjs/index.js +42 -36
- package/build/vite-esm/index.js +42 -36
- package/package.json +1 -1
|
@@ -55862,11 +55862,10 @@ var InMemorySubscriptions = class {
|
|
|
55862
55862
|
constructor(cache) {
|
|
55863
55863
|
this.cache = cache;
|
|
55864
55864
|
}
|
|
55865
|
-
subscribers =
|
|
55866
|
-
referenceCounts = {};
|
|
55865
|
+
subscribers = /* @__PURE__ */ new Map();
|
|
55867
55866
|
keyVersions = {};
|
|
55868
55867
|
activeFields(parent2) {
|
|
55869
|
-
return Object.keys(this.subscribers
|
|
55868
|
+
return Object.keys(this.subscribers.get(parent2) || {});
|
|
55870
55869
|
}
|
|
55871
55870
|
add({
|
|
55872
55871
|
parent: parent2,
|
|
@@ -55940,27 +55939,28 @@ var InMemorySubscriptions = class {
|
|
|
55940
55939
|
type
|
|
55941
55940
|
}) {
|
|
55942
55941
|
const spec = selection[0];
|
|
55943
|
-
if (!this.subscribers
|
|
55944
|
-
this.subscribers
|
|
55945
|
-
}
|
|
55946
|
-
|
|
55947
|
-
|
|
55942
|
+
if (!this.subscribers.has(id)) {
|
|
55943
|
+
this.subscribers.set(id, /* @__PURE__ */ new Map());
|
|
55944
|
+
}
|
|
55945
|
+
const subscriber = this.subscribers.get(id);
|
|
55946
|
+
if (!subscriber.has(key)) {
|
|
55947
|
+
subscriber.set(key, {
|
|
55948
|
+
selections: [],
|
|
55949
|
+
referenceCounts: /* @__PURE__ */ new Map()
|
|
55950
|
+
});
|
|
55948
55951
|
}
|
|
55952
|
+
const subscriberField = subscriber.get(key);
|
|
55949
55953
|
if (!this.keyVersions[key]) {
|
|
55950
55954
|
this.keyVersions[key] = /* @__PURE__ */ new Set();
|
|
55951
55955
|
}
|
|
55952
55956
|
this.keyVersions[key].add(key);
|
|
55953
|
-
if (!
|
|
55954
|
-
|
|
55955
|
-
}
|
|
55956
|
-
if (!this.referenceCounts[id]) {
|
|
55957
|
-
this.referenceCounts[id] = {};
|
|
55957
|
+
if (!subscriberField.selections.some(([{ set }]) => set === spec.set)) {
|
|
55958
|
+
subscriberField.selections.push([spec, selection[1]]);
|
|
55958
55959
|
}
|
|
55959
|
-
|
|
55960
|
-
|
|
55961
|
-
|
|
55962
|
-
|
|
55963
|
-
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
55960
|
+
subscriberField.referenceCounts.set(
|
|
55961
|
+
spec.set,
|
|
55962
|
+
(subscriberField.referenceCounts.get(spec.set) || 0) + 1
|
|
55963
|
+
);
|
|
55964
55964
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
55965
55965
|
}
|
|
55966
55966
|
registerList({
|
|
@@ -56047,7 +56047,7 @@ var InMemorySubscriptions = class {
|
|
|
56047
56047
|
}
|
|
56048
56048
|
}
|
|
56049
56049
|
get(id, field) {
|
|
56050
|
-
return this.subscribers
|
|
56050
|
+
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
56051
56051
|
}
|
|
56052
56052
|
remove(id, selection, targets, variables, visited = []) {
|
|
56053
56053
|
visited.push(id);
|
|
@@ -56073,24 +56073,24 @@ var InMemorySubscriptions = class {
|
|
|
56073
56073
|
}
|
|
56074
56074
|
}
|
|
56075
56075
|
reset() {
|
|
56076
|
-
const subscribers =
|
|
56077
|
-
([id]) => !id.startsWith(rootID)
|
|
56078
|
-
);
|
|
56076
|
+
const subscribers = [...this.subscribers.entries()].filter(([id]) => !id.startsWith(rootID));
|
|
56079
56077
|
for (const [id, _fields] of subscribers) {
|
|
56080
|
-
|
|
56078
|
+
this.subscribers.delete(id);
|
|
56081
56079
|
}
|
|
56082
56080
|
const subscriptionSpecs = subscribers.flatMap(
|
|
56083
|
-
([_id, fields]) =>
|
|
56081
|
+
([_id, fields]) => [...fields.values()].flatMap((field) => field.selections.map(([spec]) => spec))
|
|
56084
56082
|
);
|
|
56085
56083
|
return subscriptionSpecs;
|
|
56086
56084
|
}
|
|
56087
56085
|
removeSubscribers(id, fieldName, specs) {
|
|
56088
56086
|
let targets = [];
|
|
56087
|
+
const subscriber = this.subscribers.get(id);
|
|
56088
|
+
const subscriberField = subscriber?.get(fieldName);
|
|
56089
56089
|
for (const spec of specs) {
|
|
56090
|
-
|
|
56090
|
+
const counts = subscriber?.get(fieldName)?.referenceCounts;
|
|
56091
|
+
if (!counts?.has(spec.set)) {
|
|
56091
56092
|
continue;
|
|
56092
56093
|
}
|
|
56093
|
-
const counts = this.referenceCounts[id][fieldName];
|
|
56094
56094
|
const newVal = (counts.get(spec.set) || 0) - 1;
|
|
56095
56095
|
counts.set(spec.set, newVal);
|
|
56096
56096
|
if (newVal <= 0) {
|
|
@@ -56098,18 +56098,19 @@ var InMemorySubscriptions = class {
|
|
|
56098
56098
|
counts.delete(spec.set);
|
|
56099
56099
|
}
|
|
56100
56100
|
}
|
|
56101
|
-
if (
|
|
56102
|
-
|
|
56101
|
+
if (subscriberField) {
|
|
56102
|
+
subscriberField.selections = this.get(id, fieldName).filter(
|
|
56103
56103
|
([{ set }]) => !targets.includes(set)
|
|
56104
56104
|
);
|
|
56105
56105
|
}
|
|
56106
56106
|
}
|
|
56107
56107
|
removeAllSubscribers(id, targets, visited = []) {
|
|
56108
56108
|
visited.push(id);
|
|
56109
|
-
|
|
56110
|
-
|
|
56111
|
-
|
|
56112
|
-
|
|
56109
|
+
const subscriber = this.subscribers.get(id);
|
|
56110
|
+
for (const [key, val] of subscriber?.entries() ?? []) {
|
|
56111
|
+
const subscribers = targets || val.selections.map(([spec]) => spec);
|
|
56112
|
+
this.removeSubscribers(id, key, subscribers);
|
|
56113
|
+
const { value, kind } = this.cache._internal_unstable.storage.get(id, key);
|
|
56113
56114
|
if (kind === "scalar") {
|
|
56114
56115
|
continue;
|
|
56115
56116
|
}
|
|
@@ -57913,7 +57914,7 @@ var FieldCollection = class {
|
|
|
57913
57914
|
return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
|
|
57914
57915
|
}
|
|
57915
57916
|
add({ selection, external }) {
|
|
57916
|
-
let include = this.config.defaultFragmentMasking === "disable";
|
|
57917
|
+
let include = this.applyFragments || this.config.defaultFragmentMasking === "disable";
|
|
57917
57918
|
const maskEnableDirective = selection.directives?.find(
|
|
57918
57919
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
57919
57920
|
);
|
|
@@ -60247,7 +60248,12 @@ function prepareSelection({
|
|
|
60247
60248
|
object.fragments = {
|
|
60248
60249
|
...object.fragments,
|
|
60249
60250
|
[fragment2]: {
|
|
60250
|
-
arguments: args ?? {}
|
|
60251
|
+
arguments: args && Object.keys(args ?? {}).length > 0 ? args : Object.fromEntries(
|
|
60252
|
+
withArguments(config, field).map((arg) => [
|
|
60253
|
+
arg.name.value,
|
|
60254
|
+
arg.value
|
|
60255
|
+
])
|
|
60256
|
+
)
|
|
60251
60257
|
}
|
|
60252
60258
|
};
|
|
60253
60259
|
if (globalLoading || field.directives?.find((d) => d.name.value === config.loadingDirective)) {
|
|
@@ -60574,7 +60580,7 @@ function artifactGenerator(stats) {
|
|
|
60574
60580
|
document: doc,
|
|
60575
60581
|
rootType,
|
|
60576
60582
|
globalLoading,
|
|
60577
|
-
includeFragments:
|
|
60583
|
+
includeFragments: true,
|
|
60578
60584
|
hasComponents: () => {
|
|
60579
60585
|
hasComponents = true;
|
|
60580
60586
|
},
|
|
@@ -60583,7 +60589,7 @@ function artifactGenerator(stats) {
|
|
|
60583
60589
|
filepath: doc.filename,
|
|
60584
60590
|
selections: selectionSet.selections,
|
|
60585
60591
|
fragmentDefinitions,
|
|
60586
|
-
applyFragments:
|
|
60592
|
+
applyFragments: true
|
|
60587
60593
|
}),
|
|
60588
60594
|
operations: operationsByPath(
|
|
60589
60595
|
config,
|
package/build/lib-cjs/index.js
CHANGED
|
@@ -64954,11 +64954,10 @@ var InMemorySubscriptions = class {
|
|
|
64954
64954
|
constructor(cache) {
|
|
64955
64955
|
this.cache = cache;
|
|
64956
64956
|
}
|
|
64957
|
-
subscribers =
|
|
64958
|
-
referenceCounts = {};
|
|
64957
|
+
subscribers = /* @__PURE__ */ new Map();
|
|
64959
64958
|
keyVersions = {};
|
|
64960
64959
|
activeFields(parent) {
|
|
64961
|
-
return Object.keys(this.subscribers
|
|
64960
|
+
return Object.keys(this.subscribers.get(parent) || {});
|
|
64962
64961
|
}
|
|
64963
64962
|
add({
|
|
64964
64963
|
parent,
|
|
@@ -65032,27 +65031,28 @@ var InMemorySubscriptions = class {
|
|
|
65032
65031
|
type
|
|
65033
65032
|
}) {
|
|
65034
65033
|
const spec = selection[0];
|
|
65035
|
-
if (!this.subscribers
|
|
65036
|
-
this.subscribers
|
|
65037
|
-
}
|
|
65038
|
-
|
|
65039
|
-
|
|
65034
|
+
if (!this.subscribers.has(id)) {
|
|
65035
|
+
this.subscribers.set(id, /* @__PURE__ */ new Map());
|
|
65036
|
+
}
|
|
65037
|
+
const subscriber = this.subscribers.get(id);
|
|
65038
|
+
if (!subscriber.has(key)) {
|
|
65039
|
+
subscriber.set(key, {
|
|
65040
|
+
selections: [],
|
|
65041
|
+
referenceCounts: /* @__PURE__ */ new Map()
|
|
65042
|
+
});
|
|
65040
65043
|
}
|
|
65044
|
+
const subscriberField = subscriber.get(key);
|
|
65041
65045
|
if (!this.keyVersions[key]) {
|
|
65042
65046
|
this.keyVersions[key] = /* @__PURE__ */ new Set();
|
|
65043
65047
|
}
|
|
65044
65048
|
this.keyVersions[key].add(key);
|
|
65045
|
-
if (!
|
|
65046
|
-
|
|
65047
|
-
}
|
|
65048
|
-
if (!this.referenceCounts[id]) {
|
|
65049
|
-
this.referenceCounts[id] = {};
|
|
65049
|
+
if (!subscriberField.selections.some(([{ set }]) => set === spec.set)) {
|
|
65050
|
+
subscriberField.selections.push([spec, selection[1]]);
|
|
65050
65051
|
}
|
|
65051
|
-
|
|
65052
|
-
|
|
65053
|
-
|
|
65054
|
-
|
|
65055
|
-
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
65052
|
+
subscriberField.referenceCounts.set(
|
|
65053
|
+
spec.set,
|
|
65054
|
+
(subscriberField.referenceCounts.get(spec.set) || 0) + 1
|
|
65055
|
+
);
|
|
65056
65056
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
65057
65057
|
}
|
|
65058
65058
|
registerList({
|
|
@@ -65139,7 +65139,7 @@ var InMemorySubscriptions = class {
|
|
|
65139
65139
|
}
|
|
65140
65140
|
}
|
|
65141
65141
|
get(id, field) {
|
|
65142
|
-
return this.subscribers
|
|
65142
|
+
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
65143
65143
|
}
|
|
65144
65144
|
remove(id, selection, targets, variables, visited = []) {
|
|
65145
65145
|
visited.push(id);
|
|
@@ -65165,24 +65165,24 @@ var InMemorySubscriptions = class {
|
|
|
65165
65165
|
}
|
|
65166
65166
|
}
|
|
65167
65167
|
reset() {
|
|
65168
|
-
const subscribers =
|
|
65169
|
-
([id]) => !id.startsWith(rootID)
|
|
65170
|
-
);
|
|
65168
|
+
const subscribers = [...this.subscribers.entries()].filter(([id]) => !id.startsWith(rootID));
|
|
65171
65169
|
for (const [id, _fields] of subscribers) {
|
|
65172
|
-
|
|
65170
|
+
this.subscribers.delete(id);
|
|
65173
65171
|
}
|
|
65174
65172
|
const subscriptionSpecs = subscribers.flatMap(
|
|
65175
|
-
([_id, fields]) =>
|
|
65173
|
+
([_id, fields]) => [...fields.values()].flatMap((field) => field.selections.map(([spec]) => spec))
|
|
65176
65174
|
);
|
|
65177
65175
|
return subscriptionSpecs;
|
|
65178
65176
|
}
|
|
65179
65177
|
removeSubscribers(id, fieldName, specs) {
|
|
65180
65178
|
let targets = [];
|
|
65179
|
+
const subscriber = this.subscribers.get(id);
|
|
65180
|
+
const subscriberField = subscriber?.get(fieldName);
|
|
65181
65181
|
for (const spec of specs) {
|
|
65182
|
-
|
|
65182
|
+
const counts = subscriber?.get(fieldName)?.referenceCounts;
|
|
65183
|
+
if (!counts?.has(spec.set)) {
|
|
65183
65184
|
continue;
|
|
65184
65185
|
}
|
|
65185
|
-
const counts = this.referenceCounts[id][fieldName];
|
|
65186
65186
|
const newVal = (counts.get(spec.set) || 0) - 1;
|
|
65187
65187
|
counts.set(spec.set, newVal);
|
|
65188
65188
|
if (newVal <= 0) {
|
|
@@ -65190,18 +65190,19 @@ var InMemorySubscriptions = class {
|
|
|
65190
65190
|
counts.delete(spec.set);
|
|
65191
65191
|
}
|
|
65192
65192
|
}
|
|
65193
|
-
if (
|
|
65194
|
-
|
|
65193
|
+
if (subscriberField) {
|
|
65194
|
+
subscriberField.selections = this.get(id, fieldName).filter(
|
|
65195
65195
|
([{ set }]) => !targets.includes(set)
|
|
65196
65196
|
);
|
|
65197
65197
|
}
|
|
65198
65198
|
}
|
|
65199
65199
|
removeAllSubscribers(id, targets, visited = []) {
|
|
65200
65200
|
visited.push(id);
|
|
65201
|
-
|
|
65202
|
-
|
|
65203
|
-
|
|
65204
|
-
|
|
65201
|
+
const subscriber = this.subscribers.get(id);
|
|
65202
|
+
for (const [key, val] of subscriber?.entries() ?? []) {
|
|
65203
|
+
const subscribers = targets || val.selections.map(([spec]) => spec);
|
|
65204
|
+
this.removeSubscribers(id, key, subscribers);
|
|
65205
|
+
const { value, kind } = this.cache._internal_unstable.storage.get(id, key);
|
|
65205
65206
|
if (kind === "scalar") {
|
|
65206
65207
|
continue;
|
|
65207
65208
|
}
|
package/build/lib-esm/index.js
CHANGED
|
@@ -64876,11 +64876,10 @@ var InMemorySubscriptions = class {
|
|
|
64876
64876
|
constructor(cache) {
|
|
64877
64877
|
this.cache = cache;
|
|
64878
64878
|
}
|
|
64879
|
-
subscribers =
|
|
64880
|
-
referenceCounts = {};
|
|
64879
|
+
subscribers = /* @__PURE__ */ new Map();
|
|
64881
64880
|
keyVersions = {};
|
|
64882
64881
|
activeFields(parent) {
|
|
64883
|
-
return Object.keys(this.subscribers
|
|
64882
|
+
return Object.keys(this.subscribers.get(parent) || {});
|
|
64884
64883
|
}
|
|
64885
64884
|
add({
|
|
64886
64885
|
parent,
|
|
@@ -64954,27 +64953,28 @@ var InMemorySubscriptions = class {
|
|
|
64954
64953
|
type
|
|
64955
64954
|
}) {
|
|
64956
64955
|
const spec = selection[0];
|
|
64957
|
-
if (!this.subscribers
|
|
64958
|
-
this.subscribers
|
|
64959
|
-
}
|
|
64960
|
-
|
|
64961
|
-
|
|
64956
|
+
if (!this.subscribers.has(id)) {
|
|
64957
|
+
this.subscribers.set(id, /* @__PURE__ */ new Map());
|
|
64958
|
+
}
|
|
64959
|
+
const subscriber = this.subscribers.get(id);
|
|
64960
|
+
if (!subscriber.has(key)) {
|
|
64961
|
+
subscriber.set(key, {
|
|
64962
|
+
selections: [],
|
|
64963
|
+
referenceCounts: /* @__PURE__ */ new Map()
|
|
64964
|
+
});
|
|
64962
64965
|
}
|
|
64966
|
+
const subscriberField = subscriber.get(key);
|
|
64963
64967
|
if (!this.keyVersions[key]) {
|
|
64964
64968
|
this.keyVersions[key] = /* @__PURE__ */ new Set();
|
|
64965
64969
|
}
|
|
64966
64970
|
this.keyVersions[key].add(key);
|
|
64967
|
-
if (!
|
|
64968
|
-
|
|
64969
|
-
}
|
|
64970
|
-
if (!this.referenceCounts[id]) {
|
|
64971
|
-
this.referenceCounts[id] = {};
|
|
64971
|
+
if (!subscriberField.selections.some(([{ set }]) => set === spec.set)) {
|
|
64972
|
+
subscriberField.selections.push([spec, selection[1]]);
|
|
64972
64973
|
}
|
|
64973
|
-
|
|
64974
|
-
|
|
64975
|
-
|
|
64976
|
-
|
|
64977
|
-
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
64974
|
+
subscriberField.referenceCounts.set(
|
|
64975
|
+
spec.set,
|
|
64976
|
+
(subscriberField.referenceCounts.get(spec.set) || 0) + 1
|
|
64977
|
+
);
|
|
64978
64978
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
64979
64979
|
}
|
|
64980
64980
|
registerList({
|
|
@@ -65061,7 +65061,7 @@ var InMemorySubscriptions = class {
|
|
|
65061
65061
|
}
|
|
65062
65062
|
}
|
|
65063
65063
|
get(id, field) {
|
|
65064
|
-
return this.subscribers
|
|
65064
|
+
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
65065
65065
|
}
|
|
65066
65066
|
remove(id, selection, targets, variables, visited = []) {
|
|
65067
65067
|
visited.push(id);
|
|
@@ -65087,24 +65087,24 @@ var InMemorySubscriptions = class {
|
|
|
65087
65087
|
}
|
|
65088
65088
|
}
|
|
65089
65089
|
reset() {
|
|
65090
|
-
const subscribers =
|
|
65091
|
-
([id]) => !id.startsWith(rootID)
|
|
65092
|
-
);
|
|
65090
|
+
const subscribers = [...this.subscribers.entries()].filter(([id]) => !id.startsWith(rootID));
|
|
65093
65091
|
for (const [id, _fields] of subscribers) {
|
|
65094
|
-
|
|
65092
|
+
this.subscribers.delete(id);
|
|
65095
65093
|
}
|
|
65096
65094
|
const subscriptionSpecs = subscribers.flatMap(
|
|
65097
|
-
([_id, fields]) =>
|
|
65095
|
+
([_id, fields]) => [...fields.values()].flatMap((field) => field.selections.map(([spec]) => spec))
|
|
65098
65096
|
);
|
|
65099
65097
|
return subscriptionSpecs;
|
|
65100
65098
|
}
|
|
65101
65099
|
removeSubscribers(id, fieldName, specs) {
|
|
65102
65100
|
let targets = [];
|
|
65101
|
+
const subscriber = this.subscribers.get(id);
|
|
65102
|
+
const subscriberField = subscriber?.get(fieldName);
|
|
65103
65103
|
for (const spec of specs) {
|
|
65104
|
-
|
|
65104
|
+
const counts = subscriber?.get(fieldName)?.referenceCounts;
|
|
65105
|
+
if (!counts?.has(spec.set)) {
|
|
65105
65106
|
continue;
|
|
65106
65107
|
}
|
|
65107
|
-
const counts = this.referenceCounts[id][fieldName];
|
|
65108
65108
|
const newVal = (counts.get(spec.set) || 0) - 1;
|
|
65109
65109
|
counts.set(spec.set, newVal);
|
|
65110
65110
|
if (newVal <= 0) {
|
|
@@ -65112,18 +65112,19 @@ var InMemorySubscriptions = class {
|
|
|
65112
65112
|
counts.delete(spec.set);
|
|
65113
65113
|
}
|
|
65114
65114
|
}
|
|
65115
|
-
if (
|
|
65116
|
-
|
|
65115
|
+
if (subscriberField) {
|
|
65116
|
+
subscriberField.selections = this.get(id, fieldName).filter(
|
|
65117
65117
|
([{ set }]) => !targets.includes(set)
|
|
65118
65118
|
);
|
|
65119
65119
|
}
|
|
65120
65120
|
}
|
|
65121
65121
|
removeAllSubscribers(id, targets, visited = []) {
|
|
65122
65122
|
visited.push(id);
|
|
65123
|
-
|
|
65124
|
-
|
|
65125
|
-
|
|
65126
|
-
|
|
65123
|
+
const subscriber = this.subscribers.get(id);
|
|
65124
|
+
for (const [key, val] of subscriber?.entries() ?? []) {
|
|
65125
|
+
const subscribers = targets || val.selections.map(([spec]) => spec);
|
|
65126
|
+
this.removeSubscribers(id, key, subscribers);
|
|
65127
|
+
const { value, kind } = this.cache._internal_unstable.storage.get(id, key);
|
|
65127
65128
|
if (kind === "scalar") {
|
|
65128
65129
|
continue;
|
|
65129
65130
|
}
|
|
@@ -8,7 +8,6 @@ export declare class InMemorySubscriptions {
|
|
|
8
8
|
private cache;
|
|
9
9
|
constructor(cache: Cache);
|
|
10
10
|
private subscribers;
|
|
11
|
-
private referenceCounts;
|
|
12
11
|
private keyVersions;
|
|
13
12
|
activeFields(parent: string): string[];
|
|
14
13
|
add({ parent, spec, selection, variables, parentType, }: {
|
|
@@ -8,7 +8,6 @@ export declare class InMemorySubscriptions {
|
|
|
8
8
|
private cache;
|
|
9
9
|
constructor(cache: Cache);
|
|
10
10
|
private subscribers;
|
|
11
|
-
private referenceCounts;
|
|
12
11
|
private keyVersions;
|
|
13
12
|
activeFields(parent: string): string[];
|
|
14
13
|
add({ parent, spec, selection, variables, parentType, }: {
|
|
@@ -30,11 +30,10 @@ class InMemorySubscriptions {
|
|
|
30
30
|
constructor(cache) {
|
|
31
31
|
this.cache = cache;
|
|
32
32
|
}
|
|
33
|
-
subscribers =
|
|
34
|
-
referenceCounts = {};
|
|
33
|
+
subscribers = /* @__PURE__ */ new Map();
|
|
35
34
|
keyVersions = {};
|
|
36
35
|
activeFields(parent) {
|
|
37
|
-
return Object.keys(this.subscribers
|
|
36
|
+
return Object.keys(this.subscribers.get(parent) || {});
|
|
38
37
|
}
|
|
39
38
|
add({
|
|
40
39
|
parent,
|
|
@@ -108,27 +107,28 @@ class InMemorySubscriptions {
|
|
|
108
107
|
type
|
|
109
108
|
}) {
|
|
110
109
|
const spec = selection[0];
|
|
111
|
-
if (!this.subscribers
|
|
112
|
-
this.subscribers
|
|
110
|
+
if (!this.subscribers.has(id)) {
|
|
111
|
+
this.subscribers.set(id, /* @__PURE__ */ new Map());
|
|
113
112
|
}
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
const subscriber = this.subscribers.get(id);
|
|
114
|
+
if (!subscriber.has(key)) {
|
|
115
|
+
subscriber.set(key, {
|
|
116
|
+
selections: [],
|
|
117
|
+
referenceCounts: /* @__PURE__ */ new Map()
|
|
118
|
+
});
|
|
116
119
|
}
|
|
120
|
+
const subscriberField = subscriber.get(key);
|
|
117
121
|
if (!this.keyVersions[key]) {
|
|
118
122
|
this.keyVersions[key] = /* @__PURE__ */ new Set();
|
|
119
123
|
}
|
|
120
124
|
this.keyVersions[key].add(key);
|
|
121
|
-
if (!
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
if (!this.referenceCounts[id]) {
|
|
125
|
-
this.referenceCounts[id] = {};
|
|
126
|
-
}
|
|
127
|
-
if (!this.referenceCounts[id][key]) {
|
|
128
|
-
this.referenceCounts[id][key] = /* @__PURE__ */ new Map();
|
|
125
|
+
if (!subscriberField.selections.some(([{ set }]) => set === spec.set)) {
|
|
126
|
+
subscriberField.selections.push([spec, selection[1]]);
|
|
129
127
|
}
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
subscriberField.referenceCounts.set(
|
|
129
|
+
spec.set,
|
|
130
|
+
(subscriberField.referenceCounts.get(spec.set) || 0) + 1
|
|
131
|
+
);
|
|
132
132
|
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
133
133
|
}
|
|
134
134
|
registerList({
|
|
@@ -215,7 +215,7 @@ class InMemorySubscriptions {
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
get(id, field) {
|
|
218
|
-
return this.subscribers
|
|
218
|
+
return this.subscribers.get(id)?.get(field)?.selections || [];
|
|
219
219
|
}
|
|
220
220
|
remove(id, selection, targets, variables, visited = []) {
|
|
221
221
|
visited.push(id);
|
|
@@ -241,24 +241,24 @@ class InMemorySubscriptions {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
reset() {
|
|
244
|
-
const subscribers =
|
|
245
|
-
([id]) => !id.startsWith(import_cache.rootID)
|
|
246
|
-
);
|
|
244
|
+
const subscribers = [...this.subscribers.entries()].filter(([id]) => !id.startsWith(import_cache.rootID));
|
|
247
245
|
for (const [id, _fields] of subscribers) {
|
|
248
|
-
|
|
246
|
+
this.subscribers.delete(id);
|
|
249
247
|
}
|
|
250
248
|
const subscriptionSpecs = subscribers.flatMap(
|
|
251
|
-
([_id, fields]) =>
|
|
249
|
+
([_id, fields]) => [...fields.values()].flatMap((field) => field.selections.map(([spec]) => spec))
|
|
252
250
|
);
|
|
253
251
|
return subscriptionSpecs;
|
|
254
252
|
}
|
|
255
253
|
removeSubscribers(id, fieldName, specs) {
|
|
256
254
|
let targets = [];
|
|
255
|
+
const subscriber = this.subscribers.get(id);
|
|
256
|
+
const subscriberField = subscriber?.get(fieldName);
|
|
257
257
|
for (const spec of specs) {
|
|
258
|
-
|
|
258
|
+
const counts = subscriber?.get(fieldName)?.referenceCounts;
|
|
259
|
+
if (!counts?.has(spec.set)) {
|
|
259
260
|
continue;
|
|
260
261
|
}
|
|
261
|
-
const counts = this.referenceCounts[id][fieldName];
|
|
262
262
|
const newVal = (counts.get(spec.set) || 0) - 1;
|
|
263
263
|
counts.set(spec.set, newVal);
|
|
264
264
|
if (newVal <= 0) {
|
|
@@ -266,18 +266,19 @@ class InMemorySubscriptions {
|
|
|
266
266
|
counts.delete(spec.set);
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
if (
|
|
270
|
-
|
|
269
|
+
if (subscriberField) {
|
|
270
|
+
subscriberField.selections = this.get(id, fieldName).filter(
|
|
271
271
|
([{ set }]) => !targets.includes(set)
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
removeAllSubscribers(id, targets, visited = []) {
|
|
276
276
|
visited.push(id);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
277
|
+
const subscriber = this.subscribers.get(id);
|
|
278
|
+
for (const [key, val] of subscriber?.entries() ?? []) {
|
|
279
|
+
const subscribers = targets || val.selections.map(([spec]) => spec);
|
|
280
|
+
this.removeSubscribers(id, key, subscribers);
|
|
281
|
+
const { value, kind } = this.cache._internal_unstable.storage.get(id, key);
|
|
281
282
|
if (kind === "scalar") {
|
|
282
283
|
continue;
|
|
283
284
|
}
|
|
@@ -8,7 +8,6 @@ export declare class InMemorySubscriptions {
|
|
|
8
8
|
private cache;
|
|
9
9
|
constructor(cache: Cache);
|
|
10
10
|
private subscribers;
|
|
11
|
-
private referenceCounts;
|
|
12
11
|
private keyVersions;
|
|
13
12
|
activeFields(parent: string): string[];
|
|
14
13
|
add({ parent, spec, selection, variables, parentType, }: {
|