houdini-svelte 1.2.1 → 1.2.3
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 +206 -90
- package/build/plugin-esm/index.js +206 -90
- package/build/preprocess-cjs/index.js +206 -90
- package/build/preprocess-esm/index.js +206 -90
- package/build/test-cjs/index.js +456 -237
- package/build/test-esm/index.js +456 -237
- package/package.json +2 -2
package/build/test-cjs/index.js
CHANGED
|
@@ -90574,10 +90574,10 @@ var ListManager = class {
|
|
|
90574
90574
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
90575
90575
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
90576
90576
|
}
|
|
90577
|
-
removeIDFromAllLists(id2) {
|
|
90577
|
+
removeIDFromAllLists(id2, layer) {
|
|
90578
90578
|
for (const fieldMap of this.lists.values()) {
|
|
90579
90579
|
for (const list of fieldMap.values()) {
|
|
90580
|
-
list.removeID(id2);
|
|
90580
|
+
list.removeID(id2, void 0, layer);
|
|
90581
90581
|
}
|
|
90582
90582
|
}
|
|
90583
90583
|
}
|
|
@@ -90734,7 +90734,7 @@ var List = class {
|
|
|
90734
90734
|
layer: layer?.id
|
|
90735
90735
|
});
|
|
90736
90736
|
}
|
|
90737
|
-
removeID(id2, variables = {}) {
|
|
90737
|
+
removeID(id2, variables = {}, layer) {
|
|
90738
90738
|
if (!this.validateWhen()) {
|
|
90739
90739
|
return;
|
|
90740
90740
|
}
|
|
@@ -90781,7 +90781,7 @@ var List = class {
|
|
|
90781
90781
|
subscribers.map((sub) => sub[0]),
|
|
90782
90782
|
variables
|
|
90783
90783
|
);
|
|
90784
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
90784
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
90785
90785
|
for (const [spec] of subscribers) {
|
|
90786
90786
|
spec.set(
|
|
90787
90787
|
this.cache._internal_unstable.getSelection({
|
|
@@ -90794,12 +90794,12 @@ var List = class {
|
|
|
90794
90794
|
}
|
|
90795
90795
|
return true;
|
|
90796
90796
|
}
|
|
90797
|
-
remove(data2, variables = {}) {
|
|
90797
|
+
remove(data2, variables = {}, layer) {
|
|
90798
90798
|
const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
|
|
90799
90799
|
if (!targetID) {
|
|
90800
90800
|
return;
|
|
90801
90801
|
}
|
|
90802
|
-
return this.removeID(targetID, variables);
|
|
90802
|
+
return this.removeID(targetID, variables, layer);
|
|
90803
90803
|
}
|
|
90804
90804
|
listType(data2) {
|
|
90805
90805
|
return data2.__typename || this.type;
|
|
@@ -90831,7 +90831,7 @@ var List = class {
|
|
|
90831
90831
|
layer,
|
|
90832
90832
|
where
|
|
90833
90833
|
}) {
|
|
90834
|
-
if (!this.remove(data2, variables)) {
|
|
90834
|
+
if (!this.remove(data2, variables, layer)) {
|
|
90835
90835
|
this.addToList(selection, data2, variables, where, layer);
|
|
90836
90836
|
}
|
|
90837
90837
|
}
|
|
@@ -90964,7 +90964,7 @@ var StaleManager = class {
|
|
|
90964
90964
|
};
|
|
90965
90965
|
var InMemoryStorage = class {
|
|
90966
90966
|
data;
|
|
90967
|
-
idCount =
|
|
90967
|
+
idCount = 1;
|
|
90968
90968
|
rank = 0;
|
|
90969
90969
|
constructor() {
|
|
90970
90970
|
this.data = [];
|
|
@@ -90984,11 +90984,11 @@ var InMemoryStorage = class {
|
|
|
90984
90984
|
insert(id2, field, location, target) {
|
|
90985
90985
|
return this.topLayer.insert(id2, field, location, target);
|
|
90986
90986
|
}
|
|
90987
|
-
remove(id2, field, target) {
|
|
90988
|
-
return
|
|
90987
|
+
remove(id2, field, target, layerToUser = this.topLayer) {
|
|
90988
|
+
return layerToUser.remove(id2, field, target);
|
|
90989
90989
|
}
|
|
90990
|
-
delete(id2) {
|
|
90991
|
-
return
|
|
90990
|
+
delete(id2, layerToUser = this.topLayer) {
|
|
90991
|
+
return layerToUser.delete(id2);
|
|
90992
90992
|
}
|
|
90993
90993
|
deleteField(id2, field) {
|
|
90994
90994
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -91356,6 +91356,9 @@ var InMemorySubscriptions = class {
|
|
|
91356
91356
|
subscribers = {};
|
|
91357
91357
|
referenceCounts = {};
|
|
91358
91358
|
keyVersions = {};
|
|
91359
|
+
activeFields(parent2) {
|
|
91360
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
91361
|
+
}
|
|
91359
91362
|
add({
|
|
91360
91363
|
parent: parent2,
|
|
91361
91364
|
spec,
|
|
@@ -91622,20 +91625,7 @@ var Cache = class {
|
|
|
91622
91625
|
}) {
|
|
91623
91626
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
91624
91627
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
91625
|
-
|
|
91626
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
91627
|
-
if (!notified.includes(spec.set)) {
|
|
91628
|
-
notified.push(spec.set);
|
|
91629
|
-
spec.set(
|
|
91630
|
-
this._internal_unstable.getSelection({
|
|
91631
|
-
parent: spec.parentID || rootID,
|
|
91632
|
-
selection: spec.selection,
|
|
91633
|
-
variables: spec.variables?.() || {},
|
|
91634
|
-
ignoreMasking: false
|
|
91635
|
-
}).data
|
|
91636
|
-
);
|
|
91637
|
-
}
|
|
91638
|
-
}
|
|
91628
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
91639
91629
|
return subscribers;
|
|
91640
91630
|
}
|
|
91641
91631
|
read(...args) {
|
|
@@ -91674,10 +91664,10 @@ var Cache = class {
|
|
|
91674
91664
|
}
|
|
91675
91665
|
return handler;
|
|
91676
91666
|
}
|
|
91677
|
-
delete(id2) {
|
|
91667
|
+
delete(id2, layer) {
|
|
91678
91668
|
this._internal_unstable.subscriptions.removeAllSubscribers(id2);
|
|
91679
|
-
this._internal_unstable.lists.removeIDFromAllLists(id2);
|
|
91680
|
-
this._internal_unstable.storage.delete(id2);
|
|
91669
|
+
this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
|
|
91670
|
+
this._internal_unstable.storage.delete(id2, layer);
|
|
91681
91671
|
}
|
|
91682
91672
|
setConfig(config5) {
|
|
91683
91673
|
this._internal_unstable.setConfig(config5);
|
|
@@ -91709,6 +91699,70 @@ var Cache = class {
|
|
|
91709
91699
|
config() {
|
|
91710
91700
|
return this._internal_unstable.config;
|
|
91711
91701
|
}
|
|
91702
|
+
clearLayer(layerID) {
|
|
91703
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
91704
|
+
if (!layer) {
|
|
91705
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
91706
|
+
}
|
|
91707
|
+
const toNotify = [];
|
|
91708
|
+
const allFields = [];
|
|
91709
|
+
for (const target of [layer.fields, layer.links]) {
|
|
91710
|
+
for (const [id2, fields] of Object.entries(target)) {
|
|
91711
|
+
allFields.push(
|
|
91712
|
+
...Object.entries(fields).map(([field, value2]) => ({ id: id2, field, value: value2 }))
|
|
91713
|
+
);
|
|
91714
|
+
}
|
|
91715
|
+
}
|
|
91716
|
+
const displayFields = [];
|
|
91717
|
+
for (const pair of allFields) {
|
|
91718
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
91719
|
+
if (!displayLayers.includes(layerID)) {
|
|
91720
|
+
continue;
|
|
91721
|
+
}
|
|
91722
|
+
displayFields.push(pair);
|
|
91723
|
+
}
|
|
91724
|
+
for (const [id2, operation] of Object.entries(layer.operations)) {
|
|
91725
|
+
if (operation.deleted) {
|
|
91726
|
+
displayFields.push(
|
|
91727
|
+
...this._internal_unstable.subscriptions.activeFields(id2).map((field) => ({ id: id2, field }))
|
|
91728
|
+
);
|
|
91729
|
+
}
|
|
91730
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
91731
|
+
if (fields.length > 0) {
|
|
91732
|
+
displayFields.push(...fields.map((field) => ({ id: id2, field })));
|
|
91733
|
+
}
|
|
91734
|
+
}
|
|
91735
|
+
layer.clear();
|
|
91736
|
+
for (const display of displayFields) {
|
|
91737
|
+
const { field, id: id2 } = display;
|
|
91738
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id2, field).value !== display.value;
|
|
91739
|
+
if (notify) {
|
|
91740
|
+
toNotify.push(
|
|
91741
|
+
...this._internal_unstable.subscriptions.get(id2, field).map((sub) => sub[0])
|
|
91742
|
+
);
|
|
91743
|
+
}
|
|
91744
|
+
}
|
|
91745
|
+
this.#notifySubscribers(toNotify);
|
|
91746
|
+
}
|
|
91747
|
+
#notifySubscribers(subs) {
|
|
91748
|
+
if (subs.length === 0) {
|
|
91749
|
+
return;
|
|
91750
|
+
}
|
|
91751
|
+
const notified = [];
|
|
91752
|
+
for (const spec of subs) {
|
|
91753
|
+
if (!notified.includes(spec.set)) {
|
|
91754
|
+
notified.push(spec.set);
|
|
91755
|
+
spec.set(
|
|
91756
|
+
this._internal_unstable.getSelection({
|
|
91757
|
+
parent: spec.parentID || rootID,
|
|
91758
|
+
selection: spec.selection,
|
|
91759
|
+
variables: spec.variables?.() || {},
|
|
91760
|
+
ignoreMasking: false
|
|
91761
|
+
}).data
|
|
91762
|
+
);
|
|
91763
|
+
}
|
|
91764
|
+
}
|
|
91765
|
+
}
|
|
91712
91766
|
};
|
|
91713
91767
|
var CacheInternal = class {
|
|
91714
91768
|
_disabled = false;
|
|
@@ -91996,8 +92050,16 @@ var CacheInternal = class {
|
|
|
91996
92050
|
operation.position || "last",
|
|
91997
92051
|
layer
|
|
91998
92052
|
);
|
|
92053
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
92054
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
92055
|
+
selection: fieldSelection,
|
|
92056
|
+
data: target,
|
|
92057
|
+
variables,
|
|
92058
|
+
where: operation.position || "last",
|
|
92059
|
+
layer
|
|
92060
|
+
});
|
|
91999
92061
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
92000
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
92062
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
92001
92063
|
} else if (operation.action === "delete" && operation.type) {
|
|
92002
92064
|
if (typeof target !== "string") {
|
|
92003
92065
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -92006,15 +92068,7 @@ var CacheInternal = class {
|
|
|
92006
92068
|
if (!targetID) {
|
|
92007
92069
|
continue;
|
|
92008
92070
|
}
|
|
92009
|
-
this.cache.delete(targetID);
|
|
92010
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
92011
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
92012
|
-
selection: fieldSelection,
|
|
92013
|
-
data: target,
|
|
92014
|
-
variables,
|
|
92015
|
-
where: operation.position || "last",
|
|
92016
|
-
layer
|
|
92017
|
-
});
|
|
92071
|
+
this.cache.delete(targetID, layer);
|
|
92018
92072
|
}
|
|
92019
92073
|
}
|
|
92020
92074
|
}
|
|
@@ -92537,7 +92591,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
92537
92591
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
92538
92592
|
return {
|
|
92539
92593
|
async start(ctx, { next, marshalVariables: marshalVariables2 }) {
|
|
92540
|
-
const
|
|
92594
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
92541
92595
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
92542
92596
|
let toNotify = [];
|
|
92543
92597
|
if (optimisticResponse) {
|
|
@@ -92548,25 +92602,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
92548
92602
|
data: optimisticResponse
|
|
92549
92603
|
}),
|
|
92550
92604
|
variables: marshalVariables2(ctx),
|
|
92551
|
-
layer:
|
|
92605
|
+
layer: layerOptimistic.id
|
|
92552
92606
|
});
|
|
92553
92607
|
}
|
|
92554
92608
|
ctx.cacheParams = {
|
|
92555
92609
|
...ctx.cacheParams,
|
|
92556
|
-
layer,
|
|
92610
|
+
layer: layerOptimistic,
|
|
92557
92611
|
notifySubscribers: toNotify,
|
|
92558
92612
|
forceNotify: true
|
|
92559
92613
|
};
|
|
92560
92614
|
next(ctx);
|
|
92561
92615
|
},
|
|
92562
92616
|
afterNetwork(ctx, { resolve: resolve22 }) {
|
|
92563
|
-
ctx.cacheParams?.layer
|
|
92617
|
+
if (ctx.cacheParams?.layer) {
|
|
92618
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
92619
|
+
}
|
|
92564
92620
|
resolve22(ctx);
|
|
92565
92621
|
},
|
|
92566
92622
|
end(ctx, { resolve: resolve22, value: value2 }) {
|
|
92567
92623
|
const hasErrors = value2.errors && value2.errors.length > 0;
|
|
92568
92624
|
if (hasErrors) {
|
|
92569
|
-
ctx.cacheParams?.layer
|
|
92625
|
+
if (ctx.cacheParams?.layer) {
|
|
92626
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
92627
|
+
}
|
|
92570
92628
|
}
|
|
92571
92629
|
if (ctx.cacheParams?.layer) {
|
|
92572
92630
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -92576,7 +92634,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
92576
92634
|
catch(ctx, { error: error2 }) {
|
|
92577
92635
|
if (ctx.cacheParams?.layer) {
|
|
92578
92636
|
const { layer } = ctx.cacheParams;
|
|
92579
|
-
layer.
|
|
92637
|
+
cache_default.clearLayer(layer.id);
|
|
92580
92638
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
92581
92639
|
}
|
|
92582
92640
|
throw error2;
|
|
@@ -147167,10 +147225,10 @@ var ListManager2 = class {
|
|
|
147167
147225
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
147168
147226
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
147169
147227
|
}
|
|
147170
|
-
removeIDFromAllLists(id2) {
|
|
147228
|
+
removeIDFromAllLists(id2, layer) {
|
|
147171
147229
|
for (const fieldMap of this.lists.values()) {
|
|
147172
147230
|
for (const list of fieldMap.values()) {
|
|
147173
|
-
list.removeID(id2);
|
|
147231
|
+
list.removeID(id2, void 0, layer);
|
|
147174
147232
|
}
|
|
147175
147233
|
}
|
|
147176
147234
|
}
|
|
@@ -147327,7 +147385,7 @@ var List2 = class {
|
|
|
147327
147385
|
layer: layer?.id
|
|
147328
147386
|
});
|
|
147329
147387
|
}
|
|
147330
|
-
removeID(id2, variables = {}) {
|
|
147388
|
+
removeID(id2, variables = {}, layer) {
|
|
147331
147389
|
if (!this.validateWhen()) {
|
|
147332
147390
|
return;
|
|
147333
147391
|
}
|
|
@@ -147374,7 +147432,7 @@ var List2 = class {
|
|
|
147374
147432
|
subscribers.map((sub) => sub[0]),
|
|
147375
147433
|
variables
|
|
147376
147434
|
);
|
|
147377
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
147435
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
147378
147436
|
for (const [spec] of subscribers) {
|
|
147379
147437
|
spec.set(
|
|
147380
147438
|
this.cache._internal_unstable.getSelection({
|
|
@@ -147387,12 +147445,12 @@ var List2 = class {
|
|
|
147387
147445
|
}
|
|
147388
147446
|
return true;
|
|
147389
147447
|
}
|
|
147390
|
-
remove(data2, variables = {}) {
|
|
147448
|
+
remove(data2, variables = {}, layer) {
|
|
147391
147449
|
const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
|
|
147392
147450
|
if (!targetID) {
|
|
147393
147451
|
return;
|
|
147394
147452
|
}
|
|
147395
|
-
return this.removeID(targetID, variables);
|
|
147453
|
+
return this.removeID(targetID, variables, layer);
|
|
147396
147454
|
}
|
|
147397
147455
|
listType(data2) {
|
|
147398
147456
|
return data2.__typename || this.type;
|
|
@@ -147424,7 +147482,7 @@ var List2 = class {
|
|
|
147424
147482
|
layer,
|
|
147425
147483
|
where
|
|
147426
147484
|
}) {
|
|
147427
|
-
if (!this.remove(data2, variables)) {
|
|
147485
|
+
if (!this.remove(data2, variables, layer)) {
|
|
147428
147486
|
this.addToList(selection, data2, variables, where, layer);
|
|
147429
147487
|
}
|
|
147430
147488
|
}
|
|
@@ -147557,7 +147615,7 @@ var StaleManager2 = class {
|
|
|
147557
147615
|
};
|
|
147558
147616
|
var InMemoryStorage2 = class {
|
|
147559
147617
|
data;
|
|
147560
|
-
idCount =
|
|
147618
|
+
idCount = 1;
|
|
147561
147619
|
rank = 0;
|
|
147562
147620
|
constructor() {
|
|
147563
147621
|
this.data = [];
|
|
@@ -147577,11 +147635,11 @@ var InMemoryStorage2 = class {
|
|
|
147577
147635
|
insert(id2, field, location, target) {
|
|
147578
147636
|
return this.topLayer.insert(id2, field, location, target);
|
|
147579
147637
|
}
|
|
147580
|
-
remove(id2, field, target) {
|
|
147581
|
-
return
|
|
147638
|
+
remove(id2, field, target, layerToUser = this.topLayer) {
|
|
147639
|
+
return layerToUser.remove(id2, field, target);
|
|
147582
147640
|
}
|
|
147583
|
-
delete(id2) {
|
|
147584
|
-
return
|
|
147641
|
+
delete(id2, layerToUser = this.topLayer) {
|
|
147642
|
+
return layerToUser.delete(id2);
|
|
147585
147643
|
}
|
|
147586
147644
|
deleteField(id2, field) {
|
|
147587
147645
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -147949,6 +148007,9 @@ var InMemorySubscriptions2 = class {
|
|
|
147949
148007
|
subscribers = {};
|
|
147950
148008
|
referenceCounts = {};
|
|
147951
148009
|
keyVersions = {};
|
|
148010
|
+
activeFields(parent2) {
|
|
148011
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
148012
|
+
}
|
|
147952
148013
|
add({
|
|
147953
148014
|
parent: parent2,
|
|
147954
148015
|
spec,
|
|
@@ -148215,20 +148276,7 @@ var Cache2 = class {
|
|
|
148215
148276
|
}) {
|
|
148216
148277
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
148217
148278
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
148218
|
-
|
|
148219
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
148220
|
-
if (!notified.includes(spec.set)) {
|
|
148221
|
-
notified.push(spec.set);
|
|
148222
|
-
spec.set(
|
|
148223
|
-
this._internal_unstable.getSelection({
|
|
148224
|
-
parent: spec.parentID || rootID2,
|
|
148225
|
-
selection: spec.selection,
|
|
148226
|
-
variables: spec.variables?.() || {},
|
|
148227
|
-
ignoreMasking: false
|
|
148228
|
-
}).data
|
|
148229
|
-
);
|
|
148230
|
-
}
|
|
148231
|
-
}
|
|
148279
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
148232
148280
|
return subscribers;
|
|
148233
148281
|
}
|
|
148234
148282
|
read(...args) {
|
|
@@ -148267,10 +148315,10 @@ var Cache2 = class {
|
|
|
148267
148315
|
}
|
|
148268
148316
|
return handler;
|
|
148269
148317
|
}
|
|
148270
|
-
delete(id2) {
|
|
148318
|
+
delete(id2, layer) {
|
|
148271
148319
|
this._internal_unstable.subscriptions.removeAllSubscribers(id2);
|
|
148272
|
-
this._internal_unstable.lists.removeIDFromAllLists(id2);
|
|
148273
|
-
this._internal_unstable.storage.delete(id2);
|
|
148320
|
+
this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
|
|
148321
|
+
this._internal_unstable.storage.delete(id2, layer);
|
|
148274
148322
|
}
|
|
148275
148323
|
setConfig(config22) {
|
|
148276
148324
|
this._internal_unstable.setConfig(config22);
|
|
@@ -148302,6 +148350,70 @@ var Cache2 = class {
|
|
|
148302
148350
|
config() {
|
|
148303
148351
|
return this._internal_unstable.config;
|
|
148304
148352
|
}
|
|
148353
|
+
clearLayer(layerID) {
|
|
148354
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
148355
|
+
if (!layer) {
|
|
148356
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
148357
|
+
}
|
|
148358
|
+
const toNotify = [];
|
|
148359
|
+
const allFields = [];
|
|
148360
|
+
for (const target of [layer.fields, layer.links]) {
|
|
148361
|
+
for (const [id2, fields] of Object.entries(target)) {
|
|
148362
|
+
allFields.push(
|
|
148363
|
+
...Object.entries(fields).map(([field, value2]) => ({ id: id2, field, value: value2 }))
|
|
148364
|
+
);
|
|
148365
|
+
}
|
|
148366
|
+
}
|
|
148367
|
+
const displayFields = [];
|
|
148368
|
+
for (const pair of allFields) {
|
|
148369
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
148370
|
+
if (!displayLayers.includes(layerID)) {
|
|
148371
|
+
continue;
|
|
148372
|
+
}
|
|
148373
|
+
displayFields.push(pair);
|
|
148374
|
+
}
|
|
148375
|
+
for (const [id2, operation] of Object.entries(layer.operations)) {
|
|
148376
|
+
if (operation.deleted) {
|
|
148377
|
+
displayFields.push(
|
|
148378
|
+
...this._internal_unstable.subscriptions.activeFields(id2).map((field) => ({ id: id2, field }))
|
|
148379
|
+
);
|
|
148380
|
+
}
|
|
148381
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
148382
|
+
if (fields.length > 0) {
|
|
148383
|
+
displayFields.push(...fields.map((field) => ({ id: id2, field })));
|
|
148384
|
+
}
|
|
148385
|
+
}
|
|
148386
|
+
layer.clear();
|
|
148387
|
+
for (const display of displayFields) {
|
|
148388
|
+
const { field, id: id2 } = display;
|
|
148389
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id2, field).value !== display.value;
|
|
148390
|
+
if (notify) {
|
|
148391
|
+
toNotify.push(
|
|
148392
|
+
...this._internal_unstable.subscriptions.get(id2, field).map((sub) => sub[0])
|
|
148393
|
+
);
|
|
148394
|
+
}
|
|
148395
|
+
}
|
|
148396
|
+
this.#notifySubscribers(toNotify);
|
|
148397
|
+
}
|
|
148398
|
+
#notifySubscribers(subs) {
|
|
148399
|
+
if (subs.length === 0) {
|
|
148400
|
+
return;
|
|
148401
|
+
}
|
|
148402
|
+
const notified = [];
|
|
148403
|
+
for (const spec of subs) {
|
|
148404
|
+
if (!notified.includes(spec.set)) {
|
|
148405
|
+
notified.push(spec.set);
|
|
148406
|
+
spec.set(
|
|
148407
|
+
this._internal_unstable.getSelection({
|
|
148408
|
+
parent: spec.parentID || rootID2,
|
|
148409
|
+
selection: spec.selection,
|
|
148410
|
+
variables: spec.variables?.() || {},
|
|
148411
|
+
ignoreMasking: false
|
|
148412
|
+
}).data
|
|
148413
|
+
);
|
|
148414
|
+
}
|
|
148415
|
+
}
|
|
148416
|
+
}
|
|
148305
148417
|
};
|
|
148306
148418
|
var CacheInternal2 = class {
|
|
148307
148419
|
_disabled = false;
|
|
@@ -148589,8 +148701,16 @@ var CacheInternal2 = class {
|
|
|
148589
148701
|
operation.position || "last",
|
|
148590
148702
|
layer
|
|
148591
148703
|
);
|
|
148704
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
148705
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
148706
|
+
selection: fieldSelection,
|
|
148707
|
+
data: target,
|
|
148708
|
+
variables,
|
|
148709
|
+
where: operation.position || "last",
|
|
148710
|
+
layer
|
|
148711
|
+
});
|
|
148592
148712
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
148593
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
148713
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
148594
148714
|
} else if (operation.action === "delete" && operation.type) {
|
|
148595
148715
|
if (typeof target !== "string") {
|
|
148596
148716
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -148599,15 +148719,7 @@ var CacheInternal2 = class {
|
|
|
148599
148719
|
if (!targetID) {
|
|
148600
148720
|
continue;
|
|
148601
148721
|
}
|
|
148602
|
-
this.cache.delete(targetID);
|
|
148603
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
148604
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
148605
|
-
selection: fieldSelection,
|
|
148606
|
-
data: target,
|
|
148607
|
-
variables,
|
|
148608
|
-
where: operation.position || "last",
|
|
148609
|
-
layer
|
|
148610
|
-
});
|
|
148722
|
+
this.cache.delete(targetID, layer);
|
|
148611
148723
|
}
|
|
148612
148724
|
}
|
|
148613
148725
|
}
|
|
@@ -149130,7 +149242,7 @@ var fragment2 = documentPlugin2(ArtifactKind2.Fragment, function() {
|
|
|
149130
149242
|
var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
149131
149243
|
return {
|
|
149132
149244
|
async start(ctx, { next, marshalVariables }) {
|
|
149133
|
-
const
|
|
149245
|
+
const layerOptimistic = cache_default2._internal_unstable.storage.createLayer(true);
|
|
149134
149246
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
149135
149247
|
let toNotify = [];
|
|
149136
149248
|
if (optimisticResponse) {
|
|
@@ -149141,25 +149253,29 @@ var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
|
149141
149253
|
data: optimisticResponse
|
|
149142
149254
|
}),
|
|
149143
149255
|
variables: marshalVariables(ctx),
|
|
149144
|
-
layer:
|
|
149256
|
+
layer: layerOptimistic.id
|
|
149145
149257
|
});
|
|
149146
149258
|
}
|
|
149147
149259
|
ctx.cacheParams = {
|
|
149148
149260
|
...ctx.cacheParams,
|
|
149149
|
-
layer,
|
|
149261
|
+
layer: layerOptimistic,
|
|
149150
149262
|
notifySubscribers: toNotify,
|
|
149151
149263
|
forceNotify: true
|
|
149152
149264
|
};
|
|
149153
149265
|
next(ctx);
|
|
149154
149266
|
},
|
|
149155
149267
|
afterNetwork(ctx, { resolve: resolve22 }) {
|
|
149156
|
-
ctx.cacheParams?.layer
|
|
149268
|
+
if (ctx.cacheParams?.layer) {
|
|
149269
|
+
cache_default2.clearLayer(ctx.cacheParams.layer.id);
|
|
149270
|
+
}
|
|
149157
149271
|
resolve22(ctx);
|
|
149158
149272
|
},
|
|
149159
149273
|
end(ctx, { resolve: resolve22, value: value2 }) {
|
|
149160
149274
|
const hasErrors = value2.errors && value2.errors.length > 0;
|
|
149161
149275
|
if (hasErrors) {
|
|
149162
|
-
ctx.cacheParams?.layer
|
|
149276
|
+
if (ctx.cacheParams?.layer) {
|
|
149277
|
+
cache_default2.clearLayer(ctx.cacheParams.layer.id);
|
|
149278
|
+
}
|
|
149163
149279
|
}
|
|
149164
149280
|
if (ctx.cacheParams?.layer) {
|
|
149165
149281
|
cache_default2._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -149169,7 +149285,7 @@ var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
|
149169
149285
|
catch(ctx, { error: error2 }) {
|
|
149170
149286
|
if (ctx.cacheParams?.layer) {
|
|
149171
149287
|
const { layer } = ctx.cacheParams;
|
|
149172
|
-
layer.
|
|
149288
|
+
cache_default2.clearLayer(layer.id);
|
|
149173
149289
|
cache_default2._internal_unstable.storage.resolveLayer(layer.id);
|
|
149174
149290
|
}
|
|
149175
149291
|
throw error2;
|
|
@@ -149450,18 +149566,14 @@ function flattenSelections({
|
|
|
149450
149566
|
filepath,
|
|
149451
149567
|
selections,
|
|
149452
149568
|
fragmentDefinitions,
|
|
149453
|
-
|
|
149454
|
-
keepFragmentSpreadNodes,
|
|
149455
|
-
hoistFragments
|
|
149569
|
+
applyFragments
|
|
149456
149570
|
}) {
|
|
149457
149571
|
const fields = new FieldCollection({
|
|
149458
149572
|
config: config22,
|
|
149459
149573
|
filepath,
|
|
149460
149574
|
selections,
|
|
149461
149575
|
fragmentDefinitions,
|
|
149462
|
-
|
|
149463
|
-
keepFragmentSpreadNodes: !!keepFragmentSpreadNodes,
|
|
149464
|
-
hoistFragments
|
|
149576
|
+
applyFragments: !!applyFragments
|
|
149465
149577
|
});
|
|
149466
149578
|
return fields.toSelectionSet();
|
|
149467
149579
|
}
|
|
@@ -149472,18 +149584,14 @@ var FieldCollection = class {
|
|
|
149472
149584
|
fields;
|
|
149473
149585
|
inlineFragments;
|
|
149474
149586
|
fragmentSpreads;
|
|
149475
|
-
|
|
149476
|
-
keepFragmentSpreadNodes;
|
|
149477
|
-
hoistFragments;
|
|
149587
|
+
applyFragments;
|
|
149478
149588
|
constructor(args) {
|
|
149479
149589
|
this.config = args.config;
|
|
149480
149590
|
this.fragmentDefinitions = args.fragmentDefinitions;
|
|
149481
|
-
this.
|
|
149482
|
-
this.keepFragmentSpreadNodes = args.keepFragmentSpreadNodes;
|
|
149591
|
+
this.applyFragments = args.applyFragments;
|
|
149483
149592
|
this.fields = {};
|
|
149484
149593
|
this.inlineFragments = {};
|
|
149485
149594
|
this.fragmentSpreads = {};
|
|
149486
|
-
this.hoistFragments = !!args.hoistFragments;
|
|
149487
149595
|
this.filepath = args.filepath;
|
|
149488
149596
|
for (const selection of args.selections) {
|
|
149489
149597
|
this.add({ selection });
|
|
@@ -149493,21 +149601,18 @@ var FieldCollection = class {
|
|
|
149493
149601
|
return Object.keys(this.fields).length + Object.keys(this.inlineFragments).length + Object.keys(this.fragmentSpreads).length;
|
|
149494
149602
|
}
|
|
149495
149603
|
add({ selection, external }) {
|
|
149496
|
-
let
|
|
149604
|
+
let include = this.config.defaultFragmentMasking === "disable";
|
|
149497
149605
|
const maskEnableDirective = selection.directives?.find(
|
|
149498
149606
|
({ name }) => name.value === this.config.maskEnableDirective
|
|
149499
149607
|
);
|
|
149500
149608
|
if (maskEnableDirective) {
|
|
149501
|
-
|
|
149609
|
+
include = false;
|
|
149502
149610
|
}
|
|
149503
149611
|
const maskDisableDirective = selection.directives?.find(
|
|
149504
149612
|
({ name }) => name.value === this.config.maskDisableDirective
|
|
149505
149613
|
);
|
|
149506
149614
|
if (maskDisableDirective) {
|
|
149507
|
-
|
|
149508
|
-
}
|
|
149509
|
-
if (this.ignoreMaskDisable) {
|
|
149510
|
-
includeFragments = true;
|
|
149615
|
+
include = true;
|
|
149511
149616
|
}
|
|
149512
149617
|
if (selection.kind === "Field") {
|
|
149513
149618
|
const key = selection.alias?.value || selection.name.value;
|
|
@@ -149523,7 +149628,7 @@ var FieldCollection = class {
|
|
|
149523
149628
|
external
|
|
149524
149629
|
});
|
|
149525
149630
|
}
|
|
149526
|
-
if (
|
|
149631
|
+
if (this.applyFragments && !external) {
|
|
149527
149632
|
this.fields[key].selection.fragmentSpreads = {
|
|
149528
149633
|
...this.collectFragmentSpreads(selection.selectionSet?.selections ?? []),
|
|
149529
149634
|
...this.fields[key].selection.fragmentSpreads
|
|
@@ -149537,16 +149642,13 @@ var FieldCollection = class {
|
|
|
149537
149642
|
}
|
|
149538
149643
|
}
|
|
149539
149644
|
if (selection.kind === "InlineFragment" && selection.typeCondition) {
|
|
149540
|
-
this.walkInlineFragment({ selection, external
|
|
149645
|
+
this.walkInlineFragment({ selection, external });
|
|
149541
149646
|
return;
|
|
149542
149647
|
}
|
|
149543
149648
|
if (selection.kind === "FragmentSpread") {
|
|
149544
|
-
if (
|
|
149649
|
+
if (!external || include) {
|
|
149545
149650
|
this.fragmentSpreads[selection.name.value] = selection;
|
|
149546
149651
|
}
|
|
149547
|
-
if (!includeFragments) {
|
|
149548
|
-
return;
|
|
149549
|
-
}
|
|
149550
149652
|
const definition = this.fragmentDefinitions[selection.name.value];
|
|
149551
149653
|
if (!definition) {
|
|
149552
149654
|
throw new HoudiniError2({
|
|
@@ -149554,23 +149656,25 @@ var FieldCollection = class {
|
|
|
149554
149656
|
message: "Could not find referenced fragment definition: " + selection.name.value + "\n" + JSON.stringify(Object.keys(this.fragmentDefinitions), null, 4)
|
|
149555
149657
|
});
|
|
149556
149658
|
}
|
|
149557
|
-
this.
|
|
149558
|
-
|
|
149559
|
-
|
|
149560
|
-
|
|
149561
|
-
|
|
149562
|
-
|
|
149563
|
-
|
|
149564
|
-
|
|
149659
|
+
if (this.applyFragments || include) {
|
|
149660
|
+
this.add({
|
|
149661
|
+
selection: {
|
|
149662
|
+
kind: "InlineFragment",
|
|
149663
|
+
typeCondition: {
|
|
149664
|
+
kind: "NamedType",
|
|
149665
|
+
name: {
|
|
149666
|
+
kind: "Name",
|
|
149667
|
+
value: definition.typeCondition.name.value
|
|
149668
|
+
}
|
|
149669
|
+
},
|
|
149670
|
+
selectionSet: {
|
|
149671
|
+
kind: "SelectionSet",
|
|
149672
|
+
selections: [...definition.selectionSet.selections]
|
|
149565
149673
|
}
|
|
149566
149674
|
},
|
|
149567
|
-
|
|
149568
|
-
|
|
149569
|
-
|
|
149570
|
-
}
|
|
149571
|
-
},
|
|
149572
|
-
external
|
|
149573
|
-
});
|
|
149675
|
+
external: !include
|
|
149676
|
+
});
|
|
149677
|
+
}
|
|
149574
149678
|
}
|
|
149575
149679
|
}
|
|
149576
149680
|
collectFragmentSpreads(selections, result = {}) {
|
|
@@ -149627,8 +149731,7 @@ var FieldCollection = class {
|
|
|
149627
149731
|
}
|
|
149628
149732
|
walkInlineFragment({
|
|
149629
149733
|
selection,
|
|
149630
|
-
external
|
|
149631
|
-
hoistFragments
|
|
149734
|
+
external
|
|
149632
149735
|
}) {
|
|
149633
149736
|
const key = selection.typeCondition.name.value;
|
|
149634
149737
|
if (!this.inlineFragments[key]) {
|
|
@@ -149638,7 +149741,7 @@ var FieldCollection = class {
|
|
|
149638
149741
|
};
|
|
149639
149742
|
}
|
|
149640
149743
|
for (const subselect of selection.selectionSet.selections || []) {
|
|
149641
|
-
if (subselect.kind === "
|
|
149744
|
+
if (subselect.kind === "Field" || subselect.kind === "InlineFragment" && !subselect.typeCondition) {
|
|
149642
149745
|
this.inlineFragments[key].selection.add({
|
|
149643
149746
|
selection: subselect,
|
|
149644
149747
|
external
|
|
@@ -149647,11 +149750,11 @@ var FieldCollection = class {
|
|
|
149647
149750
|
} else if (subselect.kind === "FragmentSpread") {
|
|
149648
149751
|
this.add({
|
|
149649
149752
|
selection: subselect,
|
|
149650
|
-
external
|
|
149753
|
+
external
|
|
149651
149754
|
});
|
|
149652
149755
|
continue;
|
|
149653
149756
|
} else {
|
|
149654
|
-
this.walkInlineFragment({ selection: subselect, external
|
|
149757
|
+
this.walkInlineFragment({ selection: subselect, external });
|
|
149655
149758
|
}
|
|
149656
149759
|
}
|
|
149657
149760
|
}
|
|
@@ -149661,9 +149764,7 @@ var FieldCollection = class {
|
|
|
149661
149764
|
fragmentDefinitions: this.fragmentDefinitions,
|
|
149662
149765
|
selections: [],
|
|
149663
149766
|
filepath: this.filepath,
|
|
149664
|
-
|
|
149665
|
-
keepFragmentSpreadNodes: this.keepFragmentSpreadNodes,
|
|
149666
|
-
hoistFragments: this.hoistFragments
|
|
149767
|
+
applyFragments: this.applyFragments
|
|
149667
149768
|
});
|
|
149668
149769
|
}
|
|
149669
149770
|
};
|
|
@@ -150564,7 +150665,7 @@ function operationObject({
|
|
|
150564
150665
|
if (operationKind === "insert" || operationKind === "toggle") {
|
|
150565
150666
|
operation.position = position;
|
|
150566
150667
|
}
|
|
150567
|
-
if (operationKind
|
|
150668
|
+
if (allLists && operationKind !== "delete") {
|
|
150568
150669
|
operation.target = "all";
|
|
150569
150670
|
}
|
|
150570
150671
|
if (parentID) {
|
|
@@ -151539,7 +151640,8 @@ function prepareSelection({
|
|
|
151539
151640
|
inConnection,
|
|
151540
151641
|
typeMap,
|
|
151541
151642
|
abstractTypes,
|
|
151542
|
-
globalLoading
|
|
151643
|
+
globalLoading,
|
|
151644
|
+
includeFragments
|
|
151543
151645
|
}) {
|
|
151544
151646
|
let object = {};
|
|
151545
151647
|
const loadingTypes = [];
|
|
@@ -151559,7 +151661,8 @@ function prepareSelection({
|
|
|
151559
151661
|
document: document2,
|
|
151560
151662
|
typeMap,
|
|
151561
151663
|
abstractTypes,
|
|
151562
|
-
globalLoading
|
|
151664
|
+
globalLoading,
|
|
151665
|
+
includeFragments
|
|
151563
151666
|
}).fields || {}
|
|
151564
151667
|
);
|
|
151565
151668
|
} else {
|
|
@@ -151607,7 +151710,8 @@ function prepareSelection({
|
|
|
151607
151710
|
document: document2,
|
|
151608
151711
|
typeMap,
|
|
151609
151712
|
abstractTypes,
|
|
151610
|
-
globalLoading
|
|
151713
|
+
globalLoading,
|
|
151714
|
+
includeFragments
|
|
151611
151715
|
}).fields
|
|
151612
151716
|
};
|
|
151613
151717
|
if (field.directives?.find((d) => d.name.value === config22.loadingDirective)) {
|
|
@@ -151725,7 +151829,8 @@ function prepareSelection({
|
|
|
151725
151829
|
inConnection: connectionState,
|
|
151726
151830
|
typeMap,
|
|
151727
151831
|
abstractTypes,
|
|
151728
|
-
globalLoading: forceLoading
|
|
151832
|
+
globalLoading: forceLoading,
|
|
151833
|
+
includeFragments
|
|
151729
151834
|
});
|
|
151730
151835
|
if (Object.values(fieldObj.selection.fields ?? {}).some((field2) => field2.required)) {
|
|
151731
151836
|
fieldObj.nullable = true;
|
|
@@ -152056,14 +152161,13 @@ function artifactGenerator(stats) {
|
|
|
152056
152161
|
document: doc,
|
|
152057
152162
|
rootType,
|
|
152058
152163
|
globalLoading,
|
|
152164
|
+
includeFragments: doc.kind !== ArtifactKind2.Fragment,
|
|
152059
152165
|
selections: flattenSelections({
|
|
152060
152166
|
config: config22,
|
|
152061
152167
|
filepath: doc.filename,
|
|
152062
152168
|
selections: selectionSet.selections,
|
|
152063
152169
|
fragmentDefinitions,
|
|
152064
|
-
|
|
152065
|
-
keepFragmentSpreadNodes: true,
|
|
152066
|
-
hoistFragments: true
|
|
152170
|
+
applyFragments: doc.kind !== ArtifactKind2.Fragment
|
|
152067
152171
|
}),
|
|
152068
152172
|
operations: operationsByPath(
|
|
152069
152173
|
config22,
|
|
@@ -153000,8 +153104,7 @@ async function generateDocumentTypes(config22, docs) {
|
|
|
153000
153104
|
config: config22,
|
|
153001
153105
|
filepath: filename,
|
|
153002
153106
|
selections: definition.selectionSet.selections,
|
|
153003
|
-
fragmentDefinitions
|
|
153004
|
-
keepFragmentSpreadNodes: true
|
|
153107
|
+
fragmentDefinitions
|
|
153005
153108
|
});
|
|
153006
153109
|
if (definition?.kind === "OperationDefinition") {
|
|
153007
153110
|
await generateOperationTypeDefs(
|
|
@@ -209411,10 +209514,10 @@ var ListManager3 = class {
|
|
|
209411
209514
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
209412
209515
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
209413
209516
|
}
|
|
209414
|
-
removeIDFromAllLists(id2) {
|
|
209517
|
+
removeIDFromAllLists(id2, layer) {
|
|
209415
209518
|
for (const fieldMap of this.lists.values()) {
|
|
209416
209519
|
for (const list of fieldMap.values()) {
|
|
209417
|
-
list.removeID(id2);
|
|
209520
|
+
list.removeID(id2, void 0, layer);
|
|
209418
209521
|
}
|
|
209419
209522
|
}
|
|
209420
209523
|
}
|
|
@@ -209571,7 +209674,7 @@ var List3 = class {
|
|
|
209571
209674
|
layer: layer?.id
|
|
209572
209675
|
});
|
|
209573
209676
|
}
|
|
209574
|
-
removeID(id2, variables = {}) {
|
|
209677
|
+
removeID(id2, variables = {}, layer) {
|
|
209575
209678
|
if (!this.validateWhen()) {
|
|
209576
209679
|
return;
|
|
209577
209680
|
}
|
|
@@ -209618,7 +209721,7 @@ var List3 = class {
|
|
|
209618
209721
|
subscribers.map((sub) => sub[0]),
|
|
209619
209722
|
variables
|
|
209620
209723
|
);
|
|
209621
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
209724
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
209622
209725
|
for (const [spec] of subscribers) {
|
|
209623
209726
|
spec.set(
|
|
209624
209727
|
this.cache._internal_unstable.getSelection({
|
|
@@ -209631,12 +209734,12 @@ var List3 = class {
|
|
|
209631
209734
|
}
|
|
209632
209735
|
return true;
|
|
209633
209736
|
}
|
|
209634
|
-
remove(data2, variables = {}) {
|
|
209737
|
+
remove(data2, variables = {}, layer) {
|
|
209635
209738
|
const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
|
|
209636
209739
|
if (!targetID) {
|
|
209637
209740
|
return;
|
|
209638
209741
|
}
|
|
209639
|
-
return this.removeID(targetID, variables);
|
|
209742
|
+
return this.removeID(targetID, variables, layer);
|
|
209640
209743
|
}
|
|
209641
209744
|
listType(data2) {
|
|
209642
209745
|
return data2.__typename || this.type;
|
|
@@ -209668,7 +209771,7 @@ var List3 = class {
|
|
|
209668
209771
|
layer,
|
|
209669
209772
|
where
|
|
209670
209773
|
}) {
|
|
209671
|
-
if (!this.remove(data2, variables)) {
|
|
209774
|
+
if (!this.remove(data2, variables, layer)) {
|
|
209672
209775
|
this.addToList(selection, data2, variables, where, layer);
|
|
209673
209776
|
}
|
|
209674
209777
|
}
|
|
@@ -209801,7 +209904,7 @@ var StaleManager3 = class {
|
|
|
209801
209904
|
};
|
|
209802
209905
|
var InMemoryStorage3 = class {
|
|
209803
209906
|
data;
|
|
209804
|
-
idCount =
|
|
209907
|
+
idCount = 1;
|
|
209805
209908
|
rank = 0;
|
|
209806
209909
|
constructor() {
|
|
209807
209910
|
this.data = [];
|
|
@@ -209821,11 +209924,11 @@ var InMemoryStorage3 = class {
|
|
|
209821
209924
|
insert(id2, field, location, target) {
|
|
209822
209925
|
return this.topLayer.insert(id2, field, location, target);
|
|
209823
209926
|
}
|
|
209824
|
-
remove(id2, field, target) {
|
|
209825
|
-
return
|
|
209927
|
+
remove(id2, field, target, layerToUser = this.topLayer) {
|
|
209928
|
+
return layerToUser.remove(id2, field, target);
|
|
209826
209929
|
}
|
|
209827
|
-
delete(id2) {
|
|
209828
|
-
return
|
|
209930
|
+
delete(id2, layerToUser = this.topLayer) {
|
|
209931
|
+
return layerToUser.delete(id2);
|
|
209829
209932
|
}
|
|
209830
209933
|
deleteField(id2, field) {
|
|
209831
209934
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -210193,6 +210296,9 @@ var InMemorySubscriptions3 = class {
|
|
|
210193
210296
|
subscribers = {};
|
|
210194
210297
|
referenceCounts = {};
|
|
210195
210298
|
keyVersions = {};
|
|
210299
|
+
activeFields(parent2) {
|
|
210300
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
210301
|
+
}
|
|
210196
210302
|
add({
|
|
210197
210303
|
parent: parent2,
|
|
210198
210304
|
spec,
|
|
@@ -210459,20 +210565,7 @@ var Cache3 = class {
|
|
|
210459
210565
|
}) {
|
|
210460
210566
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
210461
210567
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
210462
|
-
|
|
210463
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
210464
|
-
if (!notified.includes(spec.set)) {
|
|
210465
|
-
notified.push(spec.set);
|
|
210466
|
-
spec.set(
|
|
210467
|
-
this._internal_unstable.getSelection({
|
|
210468
|
-
parent: spec.parentID || rootID3,
|
|
210469
|
-
selection: spec.selection,
|
|
210470
|
-
variables: spec.variables?.() || {},
|
|
210471
|
-
ignoreMasking: false
|
|
210472
|
-
}).data
|
|
210473
|
-
);
|
|
210474
|
-
}
|
|
210475
|
-
}
|
|
210568
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
210476
210569
|
return subscribers;
|
|
210477
210570
|
}
|
|
210478
210571
|
read(...args) {
|
|
@@ -210511,10 +210604,10 @@ var Cache3 = class {
|
|
|
210511
210604
|
}
|
|
210512
210605
|
return handler;
|
|
210513
210606
|
}
|
|
210514
|
-
delete(id2) {
|
|
210607
|
+
delete(id2, layer) {
|
|
210515
210608
|
this._internal_unstable.subscriptions.removeAllSubscribers(id2);
|
|
210516
|
-
this._internal_unstable.lists.removeIDFromAllLists(id2);
|
|
210517
|
-
this._internal_unstable.storage.delete(id2);
|
|
210609
|
+
this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
|
|
210610
|
+
this._internal_unstable.storage.delete(id2, layer);
|
|
210518
210611
|
}
|
|
210519
210612
|
setConfig(config22) {
|
|
210520
210613
|
this._internal_unstable.setConfig(config22);
|
|
@@ -210546,6 +210639,70 @@ var Cache3 = class {
|
|
|
210546
210639
|
config() {
|
|
210547
210640
|
return this._internal_unstable.config;
|
|
210548
210641
|
}
|
|
210642
|
+
clearLayer(layerID) {
|
|
210643
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
210644
|
+
if (!layer) {
|
|
210645
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
210646
|
+
}
|
|
210647
|
+
const toNotify = [];
|
|
210648
|
+
const allFields = [];
|
|
210649
|
+
for (const target of [layer.fields, layer.links]) {
|
|
210650
|
+
for (const [id2, fields] of Object.entries(target)) {
|
|
210651
|
+
allFields.push(
|
|
210652
|
+
...Object.entries(fields).map(([field, value2]) => ({ id: id2, field, value: value2 }))
|
|
210653
|
+
);
|
|
210654
|
+
}
|
|
210655
|
+
}
|
|
210656
|
+
const displayFields = [];
|
|
210657
|
+
for (const pair of allFields) {
|
|
210658
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
210659
|
+
if (!displayLayers.includes(layerID)) {
|
|
210660
|
+
continue;
|
|
210661
|
+
}
|
|
210662
|
+
displayFields.push(pair);
|
|
210663
|
+
}
|
|
210664
|
+
for (const [id2, operation] of Object.entries(layer.operations)) {
|
|
210665
|
+
if (operation.deleted) {
|
|
210666
|
+
displayFields.push(
|
|
210667
|
+
...this._internal_unstable.subscriptions.activeFields(id2).map((field) => ({ id: id2, field }))
|
|
210668
|
+
);
|
|
210669
|
+
}
|
|
210670
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
210671
|
+
if (fields.length > 0) {
|
|
210672
|
+
displayFields.push(...fields.map((field) => ({ id: id2, field })));
|
|
210673
|
+
}
|
|
210674
|
+
}
|
|
210675
|
+
layer.clear();
|
|
210676
|
+
for (const display of displayFields) {
|
|
210677
|
+
const { field, id: id2 } = display;
|
|
210678
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id2, field).value !== display.value;
|
|
210679
|
+
if (notify) {
|
|
210680
|
+
toNotify.push(
|
|
210681
|
+
...this._internal_unstable.subscriptions.get(id2, field).map((sub) => sub[0])
|
|
210682
|
+
);
|
|
210683
|
+
}
|
|
210684
|
+
}
|
|
210685
|
+
this.#notifySubscribers(toNotify);
|
|
210686
|
+
}
|
|
210687
|
+
#notifySubscribers(subs) {
|
|
210688
|
+
if (subs.length === 0) {
|
|
210689
|
+
return;
|
|
210690
|
+
}
|
|
210691
|
+
const notified = [];
|
|
210692
|
+
for (const spec of subs) {
|
|
210693
|
+
if (!notified.includes(spec.set)) {
|
|
210694
|
+
notified.push(spec.set);
|
|
210695
|
+
spec.set(
|
|
210696
|
+
this._internal_unstable.getSelection({
|
|
210697
|
+
parent: spec.parentID || rootID3,
|
|
210698
|
+
selection: spec.selection,
|
|
210699
|
+
variables: spec.variables?.() || {},
|
|
210700
|
+
ignoreMasking: false
|
|
210701
|
+
}).data
|
|
210702
|
+
);
|
|
210703
|
+
}
|
|
210704
|
+
}
|
|
210705
|
+
}
|
|
210549
210706
|
};
|
|
210550
210707
|
var CacheInternal3 = class {
|
|
210551
210708
|
_disabled = false;
|
|
@@ -210833,8 +210990,16 @@ var CacheInternal3 = class {
|
|
|
210833
210990
|
operation.position || "last",
|
|
210834
210991
|
layer
|
|
210835
210992
|
);
|
|
210993
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
210994
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
210995
|
+
selection: fieldSelection,
|
|
210996
|
+
data: target,
|
|
210997
|
+
variables,
|
|
210998
|
+
where: operation.position || "last",
|
|
210999
|
+
layer
|
|
211000
|
+
});
|
|
210836
211001
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
210837
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
211002
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
210838
211003
|
} else if (operation.action === "delete" && operation.type) {
|
|
210839
211004
|
if (typeof target !== "string") {
|
|
210840
211005
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -210843,15 +211008,7 @@ var CacheInternal3 = class {
|
|
|
210843
211008
|
if (!targetID) {
|
|
210844
211009
|
continue;
|
|
210845
211010
|
}
|
|
210846
|
-
this.cache.delete(targetID);
|
|
210847
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
210848
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
210849
|
-
selection: fieldSelection,
|
|
210850
|
-
data: target,
|
|
210851
|
-
variables,
|
|
210852
|
-
where: operation.position || "last",
|
|
210853
|
-
layer
|
|
210854
|
-
});
|
|
211011
|
+
this.cache.delete(targetID, layer);
|
|
210855
211012
|
}
|
|
210856
211013
|
}
|
|
210857
211014
|
}
|
|
@@ -211374,7 +211531,7 @@ var fragment3 = documentPlugin3(ArtifactKind3.Fragment, function() {
|
|
|
211374
211531
|
var mutation3 = documentPlugin3(ArtifactKind3.Mutation, () => {
|
|
211375
211532
|
return {
|
|
211376
211533
|
async start(ctx, { next, marshalVariables }) {
|
|
211377
|
-
const
|
|
211534
|
+
const layerOptimistic = cache_default3._internal_unstable.storage.createLayer(true);
|
|
211378
211535
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
211379
211536
|
let toNotify = [];
|
|
211380
211537
|
if (optimisticResponse) {
|
|
@@ -211385,25 +211542,29 @@ var mutation3 = documentPlugin3(ArtifactKind3.Mutation, () => {
|
|
|
211385
211542
|
data: optimisticResponse
|
|
211386
211543
|
}),
|
|
211387
211544
|
variables: marshalVariables(ctx),
|
|
211388
|
-
layer:
|
|
211545
|
+
layer: layerOptimistic.id
|
|
211389
211546
|
});
|
|
211390
211547
|
}
|
|
211391
211548
|
ctx.cacheParams = {
|
|
211392
211549
|
...ctx.cacheParams,
|
|
211393
|
-
layer,
|
|
211550
|
+
layer: layerOptimistic,
|
|
211394
211551
|
notifySubscribers: toNotify,
|
|
211395
211552
|
forceNotify: true
|
|
211396
211553
|
};
|
|
211397
211554
|
next(ctx);
|
|
211398
211555
|
},
|
|
211399
211556
|
afterNetwork(ctx, { resolve: resolve22 }) {
|
|
211400
|
-
ctx.cacheParams?.layer
|
|
211557
|
+
if (ctx.cacheParams?.layer) {
|
|
211558
|
+
cache_default3.clearLayer(ctx.cacheParams.layer.id);
|
|
211559
|
+
}
|
|
211401
211560
|
resolve22(ctx);
|
|
211402
211561
|
},
|
|
211403
211562
|
end(ctx, { resolve: resolve22, value: value2 }) {
|
|
211404
211563
|
const hasErrors = value2.errors && value2.errors.length > 0;
|
|
211405
211564
|
if (hasErrors) {
|
|
211406
|
-
ctx.cacheParams?.layer
|
|
211565
|
+
if (ctx.cacheParams?.layer) {
|
|
211566
|
+
cache_default3.clearLayer(ctx.cacheParams.layer.id);
|
|
211567
|
+
}
|
|
211407
211568
|
}
|
|
211408
211569
|
if (ctx.cacheParams?.layer) {
|
|
211409
211570
|
cache_default3._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -211413,7 +211574,7 @@ var mutation3 = documentPlugin3(ArtifactKind3.Mutation, () => {
|
|
|
211413
211574
|
catch(ctx, { error: error2 }) {
|
|
211414
211575
|
if (ctx.cacheParams?.layer) {
|
|
211415
211576
|
const { layer } = ctx.cacheParams;
|
|
211416
|
-
layer.
|
|
211577
|
+
cache_default3.clearLayer(layer.id);
|
|
211417
211578
|
cache_default3._internal_unstable.storage.resolveLayer(layer.id);
|
|
211418
211579
|
}
|
|
211419
211580
|
throw error2;
|
|
@@ -275494,10 +275655,10 @@ var ListManager4 = class {
|
|
|
275494
275655
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
275495
275656
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
275496
275657
|
}
|
|
275497
|
-
removeIDFromAllLists(id2) {
|
|
275658
|
+
removeIDFromAllLists(id2, layer) {
|
|
275498
275659
|
for (const fieldMap of this.lists.values()) {
|
|
275499
275660
|
for (const list of fieldMap.values()) {
|
|
275500
|
-
list.removeID(id2);
|
|
275661
|
+
list.removeID(id2, void 0, layer);
|
|
275501
275662
|
}
|
|
275502
275663
|
}
|
|
275503
275664
|
}
|
|
@@ -275654,7 +275815,7 @@ var List4 = class {
|
|
|
275654
275815
|
layer: layer?.id
|
|
275655
275816
|
});
|
|
275656
275817
|
}
|
|
275657
|
-
removeID(id2, variables = {}) {
|
|
275818
|
+
removeID(id2, variables = {}, layer) {
|
|
275658
275819
|
if (!this.validateWhen()) {
|
|
275659
275820
|
return;
|
|
275660
275821
|
}
|
|
@@ -275701,7 +275862,7 @@ var List4 = class {
|
|
|
275701
275862
|
subscribers.map((sub) => sub[0]),
|
|
275702
275863
|
variables
|
|
275703
275864
|
);
|
|
275704
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
275865
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
275705
275866
|
for (const [spec] of subscribers) {
|
|
275706
275867
|
spec.set(
|
|
275707
275868
|
this.cache._internal_unstable.getSelection({
|
|
@@ -275714,12 +275875,12 @@ var List4 = class {
|
|
|
275714
275875
|
}
|
|
275715
275876
|
return true;
|
|
275716
275877
|
}
|
|
275717
|
-
remove(data2, variables = {}) {
|
|
275878
|
+
remove(data2, variables = {}, layer) {
|
|
275718
275879
|
const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
|
|
275719
275880
|
if (!targetID) {
|
|
275720
275881
|
return;
|
|
275721
275882
|
}
|
|
275722
|
-
return this.removeID(targetID, variables);
|
|
275883
|
+
return this.removeID(targetID, variables, layer);
|
|
275723
275884
|
}
|
|
275724
275885
|
listType(data2) {
|
|
275725
275886
|
return data2.__typename || this.type;
|
|
@@ -275751,7 +275912,7 @@ var List4 = class {
|
|
|
275751
275912
|
layer,
|
|
275752
275913
|
where
|
|
275753
275914
|
}) {
|
|
275754
|
-
if (!this.remove(data2, variables)) {
|
|
275915
|
+
if (!this.remove(data2, variables, layer)) {
|
|
275755
275916
|
this.addToList(selection, data2, variables, where, layer);
|
|
275756
275917
|
}
|
|
275757
275918
|
}
|
|
@@ -275884,7 +276045,7 @@ var StaleManager4 = class {
|
|
|
275884
276045
|
};
|
|
275885
276046
|
var InMemoryStorage4 = class {
|
|
275886
276047
|
data;
|
|
275887
|
-
idCount =
|
|
276048
|
+
idCount = 1;
|
|
275888
276049
|
rank = 0;
|
|
275889
276050
|
constructor() {
|
|
275890
276051
|
this.data = [];
|
|
@@ -275904,11 +276065,11 @@ var InMemoryStorage4 = class {
|
|
|
275904
276065
|
insert(id2, field, location, target) {
|
|
275905
276066
|
return this.topLayer.insert(id2, field, location, target);
|
|
275906
276067
|
}
|
|
275907
|
-
remove(id2, field, target) {
|
|
275908
|
-
return
|
|
276068
|
+
remove(id2, field, target, layerToUser = this.topLayer) {
|
|
276069
|
+
return layerToUser.remove(id2, field, target);
|
|
275909
276070
|
}
|
|
275910
|
-
delete(id2) {
|
|
275911
|
-
return
|
|
276071
|
+
delete(id2, layerToUser = this.topLayer) {
|
|
276072
|
+
return layerToUser.delete(id2);
|
|
275912
276073
|
}
|
|
275913
276074
|
deleteField(id2, field) {
|
|
275914
276075
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -276276,6 +276437,9 @@ var InMemorySubscriptions4 = class {
|
|
|
276276
276437
|
subscribers = {};
|
|
276277
276438
|
referenceCounts = {};
|
|
276278
276439
|
keyVersions = {};
|
|
276440
|
+
activeFields(parent2) {
|
|
276441
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
276442
|
+
}
|
|
276279
276443
|
add({
|
|
276280
276444
|
parent: parent2,
|
|
276281
276445
|
spec,
|
|
@@ -276542,20 +276706,7 @@ var Cache4 = class {
|
|
|
276542
276706
|
}) {
|
|
276543
276707
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
276544
276708
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
276545
|
-
|
|
276546
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
276547
|
-
if (!notified.includes(spec.set)) {
|
|
276548
|
-
notified.push(spec.set);
|
|
276549
|
-
spec.set(
|
|
276550
|
-
this._internal_unstable.getSelection({
|
|
276551
|
-
parent: spec.parentID || rootID4,
|
|
276552
|
-
selection: spec.selection,
|
|
276553
|
-
variables: spec.variables?.() || {},
|
|
276554
|
-
ignoreMasking: false
|
|
276555
|
-
}).data
|
|
276556
|
-
);
|
|
276557
|
-
}
|
|
276558
|
-
}
|
|
276709
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
276559
276710
|
return subscribers;
|
|
276560
276711
|
}
|
|
276561
276712
|
read(...args) {
|
|
@@ -276594,10 +276745,10 @@ var Cache4 = class {
|
|
|
276594
276745
|
}
|
|
276595
276746
|
return handler;
|
|
276596
276747
|
}
|
|
276597
|
-
delete(id2) {
|
|
276748
|
+
delete(id2, layer) {
|
|
276598
276749
|
this._internal_unstable.subscriptions.removeAllSubscribers(id2);
|
|
276599
|
-
this._internal_unstable.lists.removeIDFromAllLists(id2);
|
|
276600
|
-
this._internal_unstable.storage.delete(id2);
|
|
276750
|
+
this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
|
|
276751
|
+
this._internal_unstable.storage.delete(id2, layer);
|
|
276601
276752
|
}
|
|
276602
276753
|
setConfig(config42) {
|
|
276603
276754
|
this._internal_unstable.setConfig(config42);
|
|
@@ -276629,6 +276780,70 @@ var Cache4 = class {
|
|
|
276629
276780
|
config() {
|
|
276630
276781
|
return this._internal_unstable.config;
|
|
276631
276782
|
}
|
|
276783
|
+
clearLayer(layerID) {
|
|
276784
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
276785
|
+
if (!layer) {
|
|
276786
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
276787
|
+
}
|
|
276788
|
+
const toNotify = [];
|
|
276789
|
+
const allFields = [];
|
|
276790
|
+
for (const target of [layer.fields, layer.links]) {
|
|
276791
|
+
for (const [id2, fields] of Object.entries(target)) {
|
|
276792
|
+
allFields.push(
|
|
276793
|
+
...Object.entries(fields).map(([field, value2]) => ({ id: id2, field, value: value2 }))
|
|
276794
|
+
);
|
|
276795
|
+
}
|
|
276796
|
+
}
|
|
276797
|
+
const displayFields = [];
|
|
276798
|
+
for (const pair of allFields) {
|
|
276799
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
276800
|
+
if (!displayLayers.includes(layerID)) {
|
|
276801
|
+
continue;
|
|
276802
|
+
}
|
|
276803
|
+
displayFields.push(pair);
|
|
276804
|
+
}
|
|
276805
|
+
for (const [id2, operation] of Object.entries(layer.operations)) {
|
|
276806
|
+
if (operation.deleted) {
|
|
276807
|
+
displayFields.push(
|
|
276808
|
+
...this._internal_unstable.subscriptions.activeFields(id2).map((field) => ({ id: id2, field }))
|
|
276809
|
+
);
|
|
276810
|
+
}
|
|
276811
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
276812
|
+
if (fields.length > 0) {
|
|
276813
|
+
displayFields.push(...fields.map((field) => ({ id: id2, field })));
|
|
276814
|
+
}
|
|
276815
|
+
}
|
|
276816
|
+
layer.clear();
|
|
276817
|
+
for (const display of displayFields) {
|
|
276818
|
+
const { field, id: id2 } = display;
|
|
276819
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id2, field).value !== display.value;
|
|
276820
|
+
if (notify) {
|
|
276821
|
+
toNotify.push(
|
|
276822
|
+
...this._internal_unstable.subscriptions.get(id2, field).map((sub) => sub[0])
|
|
276823
|
+
);
|
|
276824
|
+
}
|
|
276825
|
+
}
|
|
276826
|
+
this.#notifySubscribers(toNotify);
|
|
276827
|
+
}
|
|
276828
|
+
#notifySubscribers(subs) {
|
|
276829
|
+
if (subs.length === 0) {
|
|
276830
|
+
return;
|
|
276831
|
+
}
|
|
276832
|
+
const notified = [];
|
|
276833
|
+
for (const spec of subs) {
|
|
276834
|
+
if (!notified.includes(spec.set)) {
|
|
276835
|
+
notified.push(spec.set);
|
|
276836
|
+
spec.set(
|
|
276837
|
+
this._internal_unstable.getSelection({
|
|
276838
|
+
parent: spec.parentID || rootID4,
|
|
276839
|
+
selection: spec.selection,
|
|
276840
|
+
variables: spec.variables?.() || {},
|
|
276841
|
+
ignoreMasking: false
|
|
276842
|
+
}).data
|
|
276843
|
+
);
|
|
276844
|
+
}
|
|
276845
|
+
}
|
|
276846
|
+
}
|
|
276632
276847
|
};
|
|
276633
276848
|
var CacheInternal4 = class {
|
|
276634
276849
|
_disabled = false;
|
|
@@ -276916,8 +277131,16 @@ var CacheInternal4 = class {
|
|
|
276916
277131
|
operation.position || "last",
|
|
276917
277132
|
layer
|
|
276918
277133
|
);
|
|
277134
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
277135
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
277136
|
+
selection: fieldSelection,
|
|
277137
|
+
data: target,
|
|
277138
|
+
variables,
|
|
277139
|
+
where: operation.position || "last",
|
|
277140
|
+
layer
|
|
277141
|
+
});
|
|
276919
277142
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
276920
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
277143
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
276921
277144
|
} else if (operation.action === "delete" && operation.type) {
|
|
276922
277145
|
if (typeof target !== "string") {
|
|
276923
277146
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -276926,15 +277149,7 @@ var CacheInternal4 = class {
|
|
|
276926
277149
|
if (!targetID) {
|
|
276927
277150
|
continue;
|
|
276928
277151
|
}
|
|
276929
|
-
this.cache.delete(targetID);
|
|
276930
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
276931
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
276932
|
-
selection: fieldSelection,
|
|
276933
|
-
data: target,
|
|
276934
|
-
variables,
|
|
276935
|
-
where: operation.position || "last",
|
|
276936
|
-
layer
|
|
276937
|
-
});
|
|
277152
|
+
this.cache.delete(targetID, layer);
|
|
276938
277153
|
}
|
|
276939
277154
|
}
|
|
276940
277155
|
}
|
|
@@ -277457,7 +277672,7 @@ var fragment4 = documentPlugin4(ArtifactKind4.Fragment, function() {
|
|
|
277457
277672
|
var mutation4 = documentPlugin4(ArtifactKind4.Mutation, () => {
|
|
277458
277673
|
return {
|
|
277459
277674
|
async start(ctx, { next, marshalVariables }) {
|
|
277460
|
-
const
|
|
277675
|
+
const layerOptimistic = cache_default4._internal_unstable.storage.createLayer(true);
|
|
277461
277676
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
277462
277677
|
let toNotify = [];
|
|
277463
277678
|
if (optimisticResponse) {
|
|
@@ -277468,25 +277683,29 @@ var mutation4 = documentPlugin4(ArtifactKind4.Mutation, () => {
|
|
|
277468
277683
|
data: optimisticResponse
|
|
277469
277684
|
}),
|
|
277470
277685
|
variables: marshalVariables(ctx),
|
|
277471
|
-
layer:
|
|
277686
|
+
layer: layerOptimistic.id
|
|
277472
277687
|
});
|
|
277473
277688
|
}
|
|
277474
277689
|
ctx.cacheParams = {
|
|
277475
277690
|
...ctx.cacheParams,
|
|
277476
|
-
layer,
|
|
277691
|
+
layer: layerOptimistic,
|
|
277477
277692
|
notifySubscribers: toNotify,
|
|
277478
277693
|
forceNotify: true
|
|
277479
277694
|
};
|
|
277480
277695
|
next(ctx);
|
|
277481
277696
|
},
|
|
277482
277697
|
afterNetwork(ctx, { resolve: resolve22 }) {
|
|
277483
|
-
ctx.cacheParams?.layer
|
|
277698
|
+
if (ctx.cacheParams?.layer) {
|
|
277699
|
+
cache_default4.clearLayer(ctx.cacheParams.layer.id);
|
|
277700
|
+
}
|
|
277484
277701
|
resolve22(ctx);
|
|
277485
277702
|
},
|
|
277486
277703
|
end(ctx, { resolve: resolve22, value: value2 }) {
|
|
277487
277704
|
const hasErrors = value2.errors && value2.errors.length > 0;
|
|
277488
277705
|
if (hasErrors) {
|
|
277489
|
-
ctx.cacheParams?.layer
|
|
277706
|
+
if (ctx.cacheParams?.layer) {
|
|
277707
|
+
cache_default4.clearLayer(ctx.cacheParams.layer.id);
|
|
277708
|
+
}
|
|
277490
277709
|
}
|
|
277491
277710
|
if (ctx.cacheParams?.layer) {
|
|
277492
277711
|
cache_default4._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -277496,7 +277715,7 @@ var mutation4 = documentPlugin4(ArtifactKind4.Mutation, () => {
|
|
|
277496
277715
|
catch(ctx, { error: error2 }) {
|
|
277497
277716
|
if (ctx.cacheParams?.layer) {
|
|
277498
277717
|
const { layer } = ctx.cacheParams;
|
|
277499
|
-
layer.
|
|
277718
|
+
cache_default4.clearLayer(layer.id);
|
|
277500
277719
|
cache_default4._internal_unstable.storage.resolveLayer(layer.id);
|
|
277501
277720
|
}
|
|
277502
277721
|
throw error2;
|