houdini-svelte 1.2.2 → 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 +413 -181
- package/build/test-esm/index.js +413 -181
- package/package.json +2 -2
|
@@ -90571,10 +90571,10 @@ var ListManager = class {
|
|
|
90571
90571
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
90572
90572
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
90573
90573
|
}
|
|
90574
|
-
removeIDFromAllLists(id2) {
|
|
90574
|
+
removeIDFromAllLists(id2, layer) {
|
|
90575
90575
|
for (const fieldMap of this.lists.values()) {
|
|
90576
90576
|
for (const list of fieldMap.values()) {
|
|
90577
|
-
list.removeID(id2);
|
|
90577
|
+
list.removeID(id2, void 0, layer);
|
|
90578
90578
|
}
|
|
90579
90579
|
}
|
|
90580
90580
|
}
|
|
@@ -90731,7 +90731,7 @@ var List = class {
|
|
|
90731
90731
|
layer: layer?.id
|
|
90732
90732
|
});
|
|
90733
90733
|
}
|
|
90734
|
-
removeID(id2, variables = {}) {
|
|
90734
|
+
removeID(id2, variables = {}, layer) {
|
|
90735
90735
|
if (!this.validateWhen()) {
|
|
90736
90736
|
return;
|
|
90737
90737
|
}
|
|
@@ -90778,7 +90778,7 @@ var List = class {
|
|
|
90778
90778
|
subscribers.map((sub) => sub[0]),
|
|
90779
90779
|
variables
|
|
90780
90780
|
);
|
|
90781
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
90781
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
90782
90782
|
for (const [spec] of subscribers) {
|
|
90783
90783
|
spec.set(
|
|
90784
90784
|
this.cache._internal_unstable.getSelection({
|
|
@@ -90791,12 +90791,12 @@ var List = class {
|
|
|
90791
90791
|
}
|
|
90792
90792
|
return true;
|
|
90793
90793
|
}
|
|
90794
|
-
remove(data2, variables = {}) {
|
|
90794
|
+
remove(data2, variables = {}, layer) {
|
|
90795
90795
|
const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
|
|
90796
90796
|
if (!targetID) {
|
|
90797
90797
|
return;
|
|
90798
90798
|
}
|
|
90799
|
-
return this.removeID(targetID, variables);
|
|
90799
|
+
return this.removeID(targetID, variables, layer);
|
|
90800
90800
|
}
|
|
90801
90801
|
listType(data2) {
|
|
90802
90802
|
return data2.__typename || this.type;
|
|
@@ -90828,7 +90828,7 @@ var List = class {
|
|
|
90828
90828
|
layer,
|
|
90829
90829
|
where
|
|
90830
90830
|
}) {
|
|
90831
|
-
if (!this.remove(data2, variables)) {
|
|
90831
|
+
if (!this.remove(data2, variables, layer)) {
|
|
90832
90832
|
this.addToList(selection, data2, variables, where, layer);
|
|
90833
90833
|
}
|
|
90834
90834
|
}
|
|
@@ -90961,7 +90961,7 @@ var StaleManager = class {
|
|
|
90961
90961
|
};
|
|
90962
90962
|
var InMemoryStorage = class {
|
|
90963
90963
|
data;
|
|
90964
|
-
idCount =
|
|
90964
|
+
idCount = 1;
|
|
90965
90965
|
rank = 0;
|
|
90966
90966
|
constructor() {
|
|
90967
90967
|
this.data = [];
|
|
@@ -90981,11 +90981,11 @@ var InMemoryStorage = class {
|
|
|
90981
90981
|
insert(id2, field, location, target) {
|
|
90982
90982
|
return this.topLayer.insert(id2, field, location, target);
|
|
90983
90983
|
}
|
|
90984
|
-
remove(id2, field, target) {
|
|
90985
|
-
return
|
|
90984
|
+
remove(id2, field, target, layerToUser = this.topLayer) {
|
|
90985
|
+
return layerToUser.remove(id2, field, target);
|
|
90986
90986
|
}
|
|
90987
|
-
delete(id2) {
|
|
90988
|
-
return
|
|
90987
|
+
delete(id2, layerToUser = this.topLayer) {
|
|
90988
|
+
return layerToUser.delete(id2);
|
|
90989
90989
|
}
|
|
90990
90990
|
deleteField(id2, field) {
|
|
90991
90991
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -91353,6 +91353,9 @@ var InMemorySubscriptions = class {
|
|
|
91353
91353
|
subscribers = {};
|
|
91354
91354
|
referenceCounts = {};
|
|
91355
91355
|
keyVersions = {};
|
|
91356
|
+
activeFields(parent2) {
|
|
91357
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
91358
|
+
}
|
|
91356
91359
|
add({
|
|
91357
91360
|
parent: parent2,
|
|
91358
91361
|
spec,
|
|
@@ -91619,20 +91622,7 @@ var Cache = class {
|
|
|
91619
91622
|
}) {
|
|
91620
91623
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
91621
91624
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
91622
|
-
|
|
91623
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
91624
|
-
if (!notified.includes(spec.set)) {
|
|
91625
|
-
notified.push(spec.set);
|
|
91626
|
-
spec.set(
|
|
91627
|
-
this._internal_unstable.getSelection({
|
|
91628
|
-
parent: spec.parentID || rootID,
|
|
91629
|
-
selection: spec.selection,
|
|
91630
|
-
variables: spec.variables?.() || {},
|
|
91631
|
-
ignoreMasking: false
|
|
91632
|
-
}).data
|
|
91633
|
-
);
|
|
91634
|
-
}
|
|
91635
|
-
}
|
|
91625
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
91636
91626
|
return subscribers;
|
|
91637
91627
|
}
|
|
91638
91628
|
read(...args) {
|
|
@@ -91671,10 +91661,10 @@ var Cache = class {
|
|
|
91671
91661
|
}
|
|
91672
91662
|
return handler;
|
|
91673
91663
|
}
|
|
91674
|
-
delete(id2) {
|
|
91664
|
+
delete(id2, layer) {
|
|
91675
91665
|
this._internal_unstable.subscriptions.removeAllSubscribers(id2);
|
|
91676
|
-
this._internal_unstable.lists.removeIDFromAllLists(id2);
|
|
91677
|
-
this._internal_unstable.storage.delete(id2);
|
|
91666
|
+
this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
|
|
91667
|
+
this._internal_unstable.storage.delete(id2, layer);
|
|
91678
91668
|
}
|
|
91679
91669
|
setConfig(config4) {
|
|
91680
91670
|
this._internal_unstable.setConfig(config4);
|
|
@@ -91706,6 +91696,70 @@ var Cache = class {
|
|
|
91706
91696
|
config() {
|
|
91707
91697
|
return this._internal_unstable.config;
|
|
91708
91698
|
}
|
|
91699
|
+
clearLayer(layerID) {
|
|
91700
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
91701
|
+
if (!layer) {
|
|
91702
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
91703
|
+
}
|
|
91704
|
+
const toNotify = [];
|
|
91705
|
+
const allFields = [];
|
|
91706
|
+
for (const target of [layer.fields, layer.links]) {
|
|
91707
|
+
for (const [id2, fields] of Object.entries(target)) {
|
|
91708
|
+
allFields.push(
|
|
91709
|
+
...Object.entries(fields).map(([field, value2]) => ({ id: id2, field, value: value2 }))
|
|
91710
|
+
);
|
|
91711
|
+
}
|
|
91712
|
+
}
|
|
91713
|
+
const displayFields = [];
|
|
91714
|
+
for (const pair of allFields) {
|
|
91715
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
91716
|
+
if (!displayLayers.includes(layerID)) {
|
|
91717
|
+
continue;
|
|
91718
|
+
}
|
|
91719
|
+
displayFields.push(pair);
|
|
91720
|
+
}
|
|
91721
|
+
for (const [id2, operation] of Object.entries(layer.operations)) {
|
|
91722
|
+
if (operation.deleted) {
|
|
91723
|
+
displayFields.push(
|
|
91724
|
+
...this._internal_unstable.subscriptions.activeFields(id2).map((field) => ({ id: id2, field }))
|
|
91725
|
+
);
|
|
91726
|
+
}
|
|
91727
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
91728
|
+
if (fields.length > 0) {
|
|
91729
|
+
displayFields.push(...fields.map((field) => ({ id: id2, field })));
|
|
91730
|
+
}
|
|
91731
|
+
}
|
|
91732
|
+
layer.clear();
|
|
91733
|
+
for (const display of displayFields) {
|
|
91734
|
+
const { field, id: id2 } = display;
|
|
91735
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id2, field).value !== display.value;
|
|
91736
|
+
if (notify) {
|
|
91737
|
+
toNotify.push(
|
|
91738
|
+
...this._internal_unstable.subscriptions.get(id2, field).map((sub) => sub[0])
|
|
91739
|
+
);
|
|
91740
|
+
}
|
|
91741
|
+
}
|
|
91742
|
+
this.#notifySubscribers(toNotify);
|
|
91743
|
+
}
|
|
91744
|
+
#notifySubscribers(subs) {
|
|
91745
|
+
if (subs.length === 0) {
|
|
91746
|
+
return;
|
|
91747
|
+
}
|
|
91748
|
+
const notified = [];
|
|
91749
|
+
for (const spec of subs) {
|
|
91750
|
+
if (!notified.includes(spec.set)) {
|
|
91751
|
+
notified.push(spec.set);
|
|
91752
|
+
spec.set(
|
|
91753
|
+
this._internal_unstable.getSelection({
|
|
91754
|
+
parent: spec.parentID || rootID,
|
|
91755
|
+
selection: spec.selection,
|
|
91756
|
+
variables: spec.variables?.() || {},
|
|
91757
|
+
ignoreMasking: false
|
|
91758
|
+
}).data
|
|
91759
|
+
);
|
|
91760
|
+
}
|
|
91761
|
+
}
|
|
91762
|
+
}
|
|
91709
91763
|
};
|
|
91710
91764
|
var CacheInternal = class {
|
|
91711
91765
|
_disabled = false;
|
|
@@ -91993,8 +92047,16 @@ var CacheInternal = class {
|
|
|
91993
92047
|
operation.position || "last",
|
|
91994
92048
|
layer
|
|
91995
92049
|
);
|
|
92050
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
92051
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
92052
|
+
selection: fieldSelection,
|
|
92053
|
+
data: target,
|
|
92054
|
+
variables,
|
|
92055
|
+
where: operation.position || "last",
|
|
92056
|
+
layer
|
|
92057
|
+
});
|
|
91996
92058
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
91997
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
92059
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
91998
92060
|
} else if (operation.action === "delete" && operation.type) {
|
|
91999
92061
|
if (typeof target !== "string") {
|
|
92000
92062
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -92003,15 +92065,7 @@ var CacheInternal = class {
|
|
|
92003
92065
|
if (!targetID) {
|
|
92004
92066
|
continue;
|
|
92005
92067
|
}
|
|
92006
|
-
this.cache.delete(targetID);
|
|
92007
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
92008
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
92009
|
-
selection: fieldSelection,
|
|
92010
|
-
data: target,
|
|
92011
|
-
variables,
|
|
92012
|
-
where: operation.position || "last",
|
|
92013
|
-
layer
|
|
92014
|
-
});
|
|
92068
|
+
this.cache.delete(targetID, layer);
|
|
92015
92069
|
}
|
|
92016
92070
|
}
|
|
92017
92071
|
}
|
|
@@ -92534,7 +92588,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
92534
92588
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
92535
92589
|
return {
|
|
92536
92590
|
async start(ctx, { next, marshalVariables: marshalVariables2 }) {
|
|
92537
|
-
const
|
|
92591
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
92538
92592
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
92539
92593
|
let toNotify = [];
|
|
92540
92594
|
if (optimisticResponse) {
|
|
@@ -92545,25 +92599,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
92545
92599
|
data: optimisticResponse
|
|
92546
92600
|
}),
|
|
92547
92601
|
variables: marshalVariables2(ctx),
|
|
92548
|
-
layer:
|
|
92602
|
+
layer: layerOptimistic.id
|
|
92549
92603
|
});
|
|
92550
92604
|
}
|
|
92551
92605
|
ctx.cacheParams = {
|
|
92552
92606
|
...ctx.cacheParams,
|
|
92553
|
-
layer,
|
|
92607
|
+
layer: layerOptimistic,
|
|
92554
92608
|
notifySubscribers: toNotify,
|
|
92555
92609
|
forceNotify: true
|
|
92556
92610
|
};
|
|
92557
92611
|
next(ctx);
|
|
92558
92612
|
},
|
|
92559
92613
|
afterNetwork(ctx, { resolve: resolve22 }) {
|
|
92560
|
-
ctx.cacheParams?.layer
|
|
92614
|
+
if (ctx.cacheParams?.layer) {
|
|
92615
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
92616
|
+
}
|
|
92561
92617
|
resolve22(ctx);
|
|
92562
92618
|
},
|
|
92563
92619
|
end(ctx, { resolve: resolve22, value: value2 }) {
|
|
92564
92620
|
const hasErrors = value2.errors && value2.errors.length > 0;
|
|
92565
92621
|
if (hasErrors) {
|
|
92566
|
-
ctx.cacheParams?.layer
|
|
92622
|
+
if (ctx.cacheParams?.layer) {
|
|
92623
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
92624
|
+
}
|
|
92567
92625
|
}
|
|
92568
92626
|
if (ctx.cacheParams?.layer) {
|
|
92569
92627
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -92573,7 +92631,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
92573
92631
|
catch(ctx, { error: error2 }) {
|
|
92574
92632
|
if (ctx.cacheParams?.layer) {
|
|
92575
92633
|
const { layer } = ctx.cacheParams;
|
|
92576
|
-
layer.
|
|
92634
|
+
cache_default.clearLayer(layer.id);
|
|
92577
92635
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
92578
92636
|
}
|
|
92579
92637
|
throw error2;
|
|
@@ -155929,10 +155987,10 @@ var ListManager2 = class {
|
|
|
155929
155987
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
155930
155988
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
155931
155989
|
}
|
|
155932
|
-
removeIDFromAllLists(id2) {
|
|
155990
|
+
removeIDFromAllLists(id2, layer) {
|
|
155933
155991
|
for (const fieldMap of this.lists.values()) {
|
|
155934
155992
|
for (const list of fieldMap.values()) {
|
|
155935
|
-
list.removeID(id2);
|
|
155993
|
+
list.removeID(id2, void 0, layer);
|
|
155936
155994
|
}
|
|
155937
155995
|
}
|
|
155938
155996
|
}
|
|
@@ -156089,7 +156147,7 @@ var List2 = class {
|
|
|
156089
156147
|
layer: layer?.id
|
|
156090
156148
|
});
|
|
156091
156149
|
}
|
|
156092
|
-
removeID(id2, variables = {}) {
|
|
156150
|
+
removeID(id2, variables = {}, layer) {
|
|
156093
156151
|
if (!this.validateWhen()) {
|
|
156094
156152
|
return;
|
|
156095
156153
|
}
|
|
@@ -156136,7 +156194,7 @@ var List2 = class {
|
|
|
156136
156194
|
subscribers.map((sub) => sub[0]),
|
|
156137
156195
|
variables
|
|
156138
156196
|
);
|
|
156139
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
156197
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
156140
156198
|
for (const [spec] of subscribers) {
|
|
156141
156199
|
spec.set(
|
|
156142
156200
|
this.cache._internal_unstable.getSelection({
|
|
@@ -156149,12 +156207,12 @@ var List2 = class {
|
|
|
156149
156207
|
}
|
|
156150
156208
|
return true;
|
|
156151
156209
|
}
|
|
156152
|
-
remove(data2, variables = {}) {
|
|
156210
|
+
remove(data2, variables = {}, layer) {
|
|
156153
156211
|
const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
|
|
156154
156212
|
if (!targetID) {
|
|
156155
156213
|
return;
|
|
156156
156214
|
}
|
|
156157
|
-
return this.removeID(targetID, variables);
|
|
156215
|
+
return this.removeID(targetID, variables, layer);
|
|
156158
156216
|
}
|
|
156159
156217
|
listType(data2) {
|
|
156160
156218
|
return data2.__typename || this.type;
|
|
@@ -156186,7 +156244,7 @@ var List2 = class {
|
|
|
156186
156244
|
layer,
|
|
156187
156245
|
where
|
|
156188
156246
|
}) {
|
|
156189
|
-
if (!this.remove(data2, variables)) {
|
|
156247
|
+
if (!this.remove(data2, variables, layer)) {
|
|
156190
156248
|
this.addToList(selection, data2, variables, where, layer);
|
|
156191
156249
|
}
|
|
156192
156250
|
}
|
|
@@ -156319,7 +156377,7 @@ var StaleManager2 = class {
|
|
|
156319
156377
|
};
|
|
156320
156378
|
var InMemoryStorage2 = class {
|
|
156321
156379
|
data;
|
|
156322
|
-
idCount =
|
|
156380
|
+
idCount = 1;
|
|
156323
156381
|
rank = 0;
|
|
156324
156382
|
constructor() {
|
|
156325
156383
|
this.data = [];
|
|
@@ -156339,11 +156397,11 @@ var InMemoryStorage2 = class {
|
|
|
156339
156397
|
insert(id2, field, location, target) {
|
|
156340
156398
|
return this.topLayer.insert(id2, field, location, target);
|
|
156341
156399
|
}
|
|
156342
|
-
remove(id2, field, target) {
|
|
156343
|
-
return
|
|
156400
|
+
remove(id2, field, target, layerToUser = this.topLayer) {
|
|
156401
|
+
return layerToUser.remove(id2, field, target);
|
|
156344
156402
|
}
|
|
156345
|
-
delete(id2) {
|
|
156346
|
-
return
|
|
156403
|
+
delete(id2, layerToUser = this.topLayer) {
|
|
156404
|
+
return layerToUser.delete(id2);
|
|
156347
156405
|
}
|
|
156348
156406
|
deleteField(id2, field) {
|
|
156349
156407
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -156711,6 +156769,9 @@ var InMemorySubscriptions2 = class {
|
|
|
156711
156769
|
subscribers = {};
|
|
156712
156770
|
referenceCounts = {};
|
|
156713
156771
|
keyVersions = {};
|
|
156772
|
+
activeFields(parent2) {
|
|
156773
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
156774
|
+
}
|
|
156714
156775
|
add({
|
|
156715
156776
|
parent: parent2,
|
|
156716
156777
|
spec,
|
|
@@ -156977,20 +157038,7 @@ var Cache2 = class {
|
|
|
156977
157038
|
}) {
|
|
156978
157039
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
156979
157040
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
156980
|
-
|
|
156981
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
156982
|
-
if (!notified.includes(spec.set)) {
|
|
156983
|
-
notified.push(spec.set);
|
|
156984
|
-
spec.set(
|
|
156985
|
-
this._internal_unstable.getSelection({
|
|
156986
|
-
parent: spec.parentID || rootID2,
|
|
156987
|
-
selection: spec.selection,
|
|
156988
|
-
variables: spec.variables?.() || {},
|
|
156989
|
-
ignoreMasking: false
|
|
156990
|
-
}).data
|
|
156991
|
-
);
|
|
156992
|
-
}
|
|
156993
|
-
}
|
|
157041
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
156994
157042
|
return subscribers;
|
|
156995
157043
|
}
|
|
156996
157044
|
read(...args) {
|
|
@@ -157029,10 +157077,10 @@ var Cache2 = class {
|
|
|
157029
157077
|
}
|
|
157030
157078
|
return handler;
|
|
157031
157079
|
}
|
|
157032
|
-
delete(id2) {
|
|
157080
|
+
delete(id2, layer) {
|
|
157033
157081
|
this._internal_unstable.subscriptions.removeAllSubscribers(id2);
|
|
157034
|
-
this._internal_unstable.lists.removeIDFromAllLists(id2);
|
|
157035
|
-
this._internal_unstable.storage.delete(id2);
|
|
157082
|
+
this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
|
|
157083
|
+
this._internal_unstable.storage.delete(id2, layer);
|
|
157036
157084
|
}
|
|
157037
157085
|
setConfig(config4) {
|
|
157038
157086
|
this._internal_unstable.setConfig(config4);
|
|
@@ -157064,6 +157112,70 @@ var Cache2 = class {
|
|
|
157064
157112
|
config() {
|
|
157065
157113
|
return this._internal_unstable.config;
|
|
157066
157114
|
}
|
|
157115
|
+
clearLayer(layerID) {
|
|
157116
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
157117
|
+
if (!layer) {
|
|
157118
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
157119
|
+
}
|
|
157120
|
+
const toNotify = [];
|
|
157121
|
+
const allFields = [];
|
|
157122
|
+
for (const target of [layer.fields, layer.links]) {
|
|
157123
|
+
for (const [id2, fields] of Object.entries(target)) {
|
|
157124
|
+
allFields.push(
|
|
157125
|
+
...Object.entries(fields).map(([field, value2]) => ({ id: id2, field, value: value2 }))
|
|
157126
|
+
);
|
|
157127
|
+
}
|
|
157128
|
+
}
|
|
157129
|
+
const displayFields = [];
|
|
157130
|
+
for (const pair of allFields) {
|
|
157131
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
157132
|
+
if (!displayLayers.includes(layerID)) {
|
|
157133
|
+
continue;
|
|
157134
|
+
}
|
|
157135
|
+
displayFields.push(pair);
|
|
157136
|
+
}
|
|
157137
|
+
for (const [id2, operation] of Object.entries(layer.operations)) {
|
|
157138
|
+
if (operation.deleted) {
|
|
157139
|
+
displayFields.push(
|
|
157140
|
+
...this._internal_unstable.subscriptions.activeFields(id2).map((field) => ({ id: id2, field }))
|
|
157141
|
+
);
|
|
157142
|
+
}
|
|
157143
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
157144
|
+
if (fields.length > 0) {
|
|
157145
|
+
displayFields.push(...fields.map((field) => ({ id: id2, field })));
|
|
157146
|
+
}
|
|
157147
|
+
}
|
|
157148
|
+
layer.clear();
|
|
157149
|
+
for (const display of displayFields) {
|
|
157150
|
+
const { field, id: id2 } = display;
|
|
157151
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id2, field).value !== display.value;
|
|
157152
|
+
if (notify) {
|
|
157153
|
+
toNotify.push(
|
|
157154
|
+
...this._internal_unstable.subscriptions.get(id2, field).map((sub) => sub[0])
|
|
157155
|
+
);
|
|
157156
|
+
}
|
|
157157
|
+
}
|
|
157158
|
+
this.#notifySubscribers(toNotify);
|
|
157159
|
+
}
|
|
157160
|
+
#notifySubscribers(subs) {
|
|
157161
|
+
if (subs.length === 0) {
|
|
157162
|
+
return;
|
|
157163
|
+
}
|
|
157164
|
+
const notified = [];
|
|
157165
|
+
for (const spec of subs) {
|
|
157166
|
+
if (!notified.includes(spec.set)) {
|
|
157167
|
+
notified.push(spec.set);
|
|
157168
|
+
spec.set(
|
|
157169
|
+
this._internal_unstable.getSelection({
|
|
157170
|
+
parent: spec.parentID || rootID2,
|
|
157171
|
+
selection: spec.selection,
|
|
157172
|
+
variables: spec.variables?.() || {},
|
|
157173
|
+
ignoreMasking: false
|
|
157174
|
+
}).data
|
|
157175
|
+
);
|
|
157176
|
+
}
|
|
157177
|
+
}
|
|
157178
|
+
}
|
|
157067
157179
|
};
|
|
157068
157180
|
var CacheInternal2 = class {
|
|
157069
157181
|
_disabled = false;
|
|
@@ -157351,8 +157463,16 @@ var CacheInternal2 = class {
|
|
|
157351
157463
|
operation.position || "last",
|
|
157352
157464
|
layer
|
|
157353
157465
|
);
|
|
157466
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
157467
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
157468
|
+
selection: fieldSelection,
|
|
157469
|
+
data: target,
|
|
157470
|
+
variables,
|
|
157471
|
+
where: operation.position || "last",
|
|
157472
|
+
layer
|
|
157473
|
+
});
|
|
157354
157474
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
157355
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
157475
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
157356
157476
|
} else if (operation.action === "delete" && operation.type) {
|
|
157357
157477
|
if (typeof target !== "string") {
|
|
157358
157478
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -157361,15 +157481,7 @@ var CacheInternal2 = class {
|
|
|
157361
157481
|
if (!targetID) {
|
|
157362
157482
|
continue;
|
|
157363
157483
|
}
|
|
157364
|
-
this.cache.delete(targetID);
|
|
157365
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
157366
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
157367
|
-
selection: fieldSelection,
|
|
157368
|
-
data: target,
|
|
157369
|
-
variables,
|
|
157370
|
-
where: operation.position || "last",
|
|
157371
|
-
layer
|
|
157372
|
-
});
|
|
157484
|
+
this.cache.delete(targetID, layer);
|
|
157373
157485
|
}
|
|
157374
157486
|
}
|
|
157375
157487
|
}
|
|
@@ -157892,7 +158004,7 @@ var fragment2 = documentPlugin2(ArtifactKind2.Fragment, function() {
|
|
|
157892
158004
|
var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
157893
158005
|
return {
|
|
157894
158006
|
async start(ctx, { next, marshalVariables }) {
|
|
157895
|
-
const
|
|
158007
|
+
const layerOptimistic = cache_default2._internal_unstable.storage.createLayer(true);
|
|
157896
158008
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
157897
158009
|
let toNotify = [];
|
|
157898
158010
|
if (optimisticResponse) {
|
|
@@ -157903,25 +158015,29 @@ var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
|
157903
158015
|
data: optimisticResponse
|
|
157904
158016
|
}),
|
|
157905
158017
|
variables: marshalVariables(ctx),
|
|
157906
|
-
layer:
|
|
158018
|
+
layer: layerOptimistic.id
|
|
157907
158019
|
});
|
|
157908
158020
|
}
|
|
157909
158021
|
ctx.cacheParams = {
|
|
157910
158022
|
...ctx.cacheParams,
|
|
157911
|
-
layer,
|
|
158023
|
+
layer: layerOptimistic,
|
|
157912
158024
|
notifySubscribers: toNotify,
|
|
157913
158025
|
forceNotify: true
|
|
157914
158026
|
};
|
|
157915
158027
|
next(ctx);
|
|
157916
158028
|
},
|
|
157917
158029
|
afterNetwork(ctx, { resolve: resolve22 }) {
|
|
157918
|
-
ctx.cacheParams?.layer
|
|
158030
|
+
if (ctx.cacheParams?.layer) {
|
|
158031
|
+
cache_default2.clearLayer(ctx.cacheParams.layer.id);
|
|
158032
|
+
}
|
|
157919
158033
|
resolve22(ctx);
|
|
157920
158034
|
},
|
|
157921
158035
|
end(ctx, { resolve: resolve22, value: value2 }) {
|
|
157922
158036
|
const hasErrors = value2.errors && value2.errors.length > 0;
|
|
157923
158037
|
if (hasErrors) {
|
|
157924
|
-
ctx.cacheParams?.layer
|
|
158038
|
+
if (ctx.cacheParams?.layer) {
|
|
158039
|
+
cache_default2.clearLayer(ctx.cacheParams.layer.id);
|
|
158040
|
+
}
|
|
157925
158041
|
}
|
|
157926
158042
|
if (ctx.cacheParams?.layer) {
|
|
157927
158043
|
cache_default2._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -157931,7 +158047,7 @@ var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
|
157931
158047
|
catch(ctx, { error: error2 }) {
|
|
157932
158048
|
if (ctx.cacheParams?.layer) {
|
|
157933
158049
|
const { layer } = ctx.cacheParams;
|
|
157934
|
-
layer.
|
|
158050
|
+
cache_default2.clearLayer(layer.id);
|
|
157935
158051
|
cache_default2._internal_unstable.storage.resolveLayer(layer.id);
|
|
157936
158052
|
}
|
|
157937
158053
|
throw error2;
|