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
|
@@ -90562,10 +90562,10 @@ var ListManager = class {
|
|
|
90562
90562
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
90563
90563
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
90564
90564
|
}
|
|
90565
|
-
removeIDFromAllLists(id2) {
|
|
90565
|
+
removeIDFromAllLists(id2, layer) {
|
|
90566
90566
|
for (const fieldMap of this.lists.values()) {
|
|
90567
90567
|
for (const list of fieldMap.values()) {
|
|
90568
|
-
list.removeID(id2);
|
|
90568
|
+
list.removeID(id2, void 0, layer);
|
|
90569
90569
|
}
|
|
90570
90570
|
}
|
|
90571
90571
|
}
|
|
@@ -90722,7 +90722,7 @@ var List = class {
|
|
|
90722
90722
|
layer: layer?.id
|
|
90723
90723
|
});
|
|
90724
90724
|
}
|
|
90725
|
-
removeID(id2, variables = {}) {
|
|
90725
|
+
removeID(id2, variables = {}, layer) {
|
|
90726
90726
|
if (!this.validateWhen()) {
|
|
90727
90727
|
return;
|
|
90728
90728
|
}
|
|
@@ -90769,7 +90769,7 @@ var List = class {
|
|
|
90769
90769
|
subscribers.map((sub) => sub[0]),
|
|
90770
90770
|
variables
|
|
90771
90771
|
);
|
|
90772
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
90772
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
90773
90773
|
for (const [spec] of subscribers) {
|
|
90774
90774
|
spec.set(
|
|
90775
90775
|
this.cache._internal_unstable.getSelection({
|
|
@@ -90782,12 +90782,12 @@ var List = class {
|
|
|
90782
90782
|
}
|
|
90783
90783
|
return true;
|
|
90784
90784
|
}
|
|
90785
|
-
remove(data2, variables = {}) {
|
|
90785
|
+
remove(data2, variables = {}, layer) {
|
|
90786
90786
|
const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
|
|
90787
90787
|
if (!targetID) {
|
|
90788
90788
|
return;
|
|
90789
90789
|
}
|
|
90790
|
-
return this.removeID(targetID, variables);
|
|
90790
|
+
return this.removeID(targetID, variables, layer);
|
|
90791
90791
|
}
|
|
90792
90792
|
listType(data2) {
|
|
90793
90793
|
return data2.__typename || this.type;
|
|
@@ -90819,7 +90819,7 @@ var List = class {
|
|
|
90819
90819
|
layer,
|
|
90820
90820
|
where
|
|
90821
90821
|
}) {
|
|
90822
|
-
if (!this.remove(data2, variables)) {
|
|
90822
|
+
if (!this.remove(data2, variables, layer)) {
|
|
90823
90823
|
this.addToList(selection, data2, variables, where, layer);
|
|
90824
90824
|
}
|
|
90825
90825
|
}
|
|
@@ -90952,7 +90952,7 @@ var StaleManager = class {
|
|
|
90952
90952
|
};
|
|
90953
90953
|
var InMemoryStorage = class {
|
|
90954
90954
|
data;
|
|
90955
|
-
idCount =
|
|
90955
|
+
idCount = 1;
|
|
90956
90956
|
rank = 0;
|
|
90957
90957
|
constructor() {
|
|
90958
90958
|
this.data = [];
|
|
@@ -90972,11 +90972,11 @@ var InMemoryStorage = class {
|
|
|
90972
90972
|
insert(id2, field, location, target) {
|
|
90973
90973
|
return this.topLayer.insert(id2, field, location, target);
|
|
90974
90974
|
}
|
|
90975
|
-
remove(id2, field, target) {
|
|
90976
|
-
return
|
|
90975
|
+
remove(id2, field, target, layerToUser = this.topLayer) {
|
|
90976
|
+
return layerToUser.remove(id2, field, target);
|
|
90977
90977
|
}
|
|
90978
|
-
delete(id2) {
|
|
90979
|
-
return
|
|
90978
|
+
delete(id2, layerToUser = this.topLayer) {
|
|
90979
|
+
return layerToUser.delete(id2);
|
|
90980
90980
|
}
|
|
90981
90981
|
deleteField(id2, field) {
|
|
90982
90982
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -91344,6 +91344,9 @@ var InMemorySubscriptions = class {
|
|
|
91344
91344
|
subscribers = {};
|
|
91345
91345
|
referenceCounts = {};
|
|
91346
91346
|
keyVersions = {};
|
|
91347
|
+
activeFields(parent2) {
|
|
91348
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
91349
|
+
}
|
|
91347
91350
|
add({
|
|
91348
91351
|
parent: parent2,
|
|
91349
91352
|
spec,
|
|
@@ -91610,20 +91613,7 @@ var Cache = class {
|
|
|
91610
91613
|
}) {
|
|
91611
91614
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
91612
91615
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
91613
|
-
|
|
91614
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
91615
|
-
if (!notified.includes(spec.set)) {
|
|
91616
|
-
notified.push(spec.set);
|
|
91617
|
-
spec.set(
|
|
91618
|
-
this._internal_unstable.getSelection({
|
|
91619
|
-
parent: spec.parentID || rootID,
|
|
91620
|
-
selection: spec.selection,
|
|
91621
|
-
variables: spec.variables?.() || {},
|
|
91622
|
-
ignoreMasking: false
|
|
91623
|
-
}).data
|
|
91624
|
-
);
|
|
91625
|
-
}
|
|
91626
|
-
}
|
|
91616
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
91627
91617
|
return subscribers;
|
|
91628
91618
|
}
|
|
91629
91619
|
read(...args) {
|
|
@@ -91662,10 +91652,10 @@ var Cache = class {
|
|
|
91662
91652
|
}
|
|
91663
91653
|
return handler;
|
|
91664
91654
|
}
|
|
91665
|
-
delete(id2) {
|
|
91655
|
+
delete(id2, layer) {
|
|
91666
91656
|
this._internal_unstable.subscriptions.removeAllSubscribers(id2);
|
|
91667
|
-
this._internal_unstable.lists.removeIDFromAllLists(id2);
|
|
91668
|
-
this._internal_unstable.storage.delete(id2);
|
|
91657
|
+
this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
|
|
91658
|
+
this._internal_unstable.storage.delete(id2, layer);
|
|
91669
91659
|
}
|
|
91670
91660
|
setConfig(config4) {
|
|
91671
91661
|
this._internal_unstable.setConfig(config4);
|
|
@@ -91697,6 +91687,70 @@ var Cache = class {
|
|
|
91697
91687
|
config() {
|
|
91698
91688
|
return this._internal_unstable.config;
|
|
91699
91689
|
}
|
|
91690
|
+
clearLayer(layerID) {
|
|
91691
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
91692
|
+
if (!layer) {
|
|
91693
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
91694
|
+
}
|
|
91695
|
+
const toNotify = [];
|
|
91696
|
+
const allFields = [];
|
|
91697
|
+
for (const target of [layer.fields, layer.links]) {
|
|
91698
|
+
for (const [id2, fields] of Object.entries(target)) {
|
|
91699
|
+
allFields.push(
|
|
91700
|
+
...Object.entries(fields).map(([field, value2]) => ({ id: id2, field, value: value2 }))
|
|
91701
|
+
);
|
|
91702
|
+
}
|
|
91703
|
+
}
|
|
91704
|
+
const displayFields = [];
|
|
91705
|
+
for (const pair of allFields) {
|
|
91706
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
91707
|
+
if (!displayLayers.includes(layerID)) {
|
|
91708
|
+
continue;
|
|
91709
|
+
}
|
|
91710
|
+
displayFields.push(pair);
|
|
91711
|
+
}
|
|
91712
|
+
for (const [id2, operation] of Object.entries(layer.operations)) {
|
|
91713
|
+
if (operation.deleted) {
|
|
91714
|
+
displayFields.push(
|
|
91715
|
+
...this._internal_unstable.subscriptions.activeFields(id2).map((field) => ({ id: id2, field }))
|
|
91716
|
+
);
|
|
91717
|
+
}
|
|
91718
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
91719
|
+
if (fields.length > 0) {
|
|
91720
|
+
displayFields.push(...fields.map((field) => ({ id: id2, field })));
|
|
91721
|
+
}
|
|
91722
|
+
}
|
|
91723
|
+
layer.clear();
|
|
91724
|
+
for (const display of displayFields) {
|
|
91725
|
+
const { field, id: id2 } = display;
|
|
91726
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id2, field).value !== display.value;
|
|
91727
|
+
if (notify) {
|
|
91728
|
+
toNotify.push(
|
|
91729
|
+
...this._internal_unstable.subscriptions.get(id2, field).map((sub) => sub[0])
|
|
91730
|
+
);
|
|
91731
|
+
}
|
|
91732
|
+
}
|
|
91733
|
+
this.#notifySubscribers(toNotify);
|
|
91734
|
+
}
|
|
91735
|
+
#notifySubscribers(subs) {
|
|
91736
|
+
if (subs.length === 0) {
|
|
91737
|
+
return;
|
|
91738
|
+
}
|
|
91739
|
+
const notified = [];
|
|
91740
|
+
for (const spec of subs) {
|
|
91741
|
+
if (!notified.includes(spec.set)) {
|
|
91742
|
+
notified.push(spec.set);
|
|
91743
|
+
spec.set(
|
|
91744
|
+
this._internal_unstable.getSelection({
|
|
91745
|
+
parent: spec.parentID || rootID,
|
|
91746
|
+
selection: spec.selection,
|
|
91747
|
+
variables: spec.variables?.() || {},
|
|
91748
|
+
ignoreMasking: false
|
|
91749
|
+
}).data
|
|
91750
|
+
);
|
|
91751
|
+
}
|
|
91752
|
+
}
|
|
91753
|
+
}
|
|
91700
91754
|
};
|
|
91701
91755
|
var CacheInternal = class {
|
|
91702
91756
|
_disabled = false;
|
|
@@ -91984,8 +92038,16 @@ var CacheInternal = class {
|
|
|
91984
92038
|
operation.position || "last",
|
|
91985
92039
|
layer
|
|
91986
92040
|
);
|
|
92041
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
92042
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
92043
|
+
selection: fieldSelection,
|
|
92044
|
+
data: target,
|
|
92045
|
+
variables,
|
|
92046
|
+
where: operation.position || "last",
|
|
92047
|
+
layer
|
|
92048
|
+
});
|
|
91987
92049
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
91988
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
92050
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
91989
92051
|
} else if (operation.action === "delete" && operation.type) {
|
|
91990
92052
|
if (typeof target !== "string") {
|
|
91991
92053
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -91994,15 +92056,7 @@ var CacheInternal = class {
|
|
|
91994
92056
|
if (!targetID) {
|
|
91995
92057
|
continue;
|
|
91996
92058
|
}
|
|
91997
|
-
this.cache.delete(targetID);
|
|
91998
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
91999
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
92000
|
-
selection: fieldSelection,
|
|
92001
|
-
data: target,
|
|
92002
|
-
variables,
|
|
92003
|
-
where: operation.position || "last",
|
|
92004
|
-
layer
|
|
92005
|
-
});
|
|
92059
|
+
this.cache.delete(targetID, layer);
|
|
92006
92060
|
}
|
|
92007
92061
|
}
|
|
92008
92062
|
}
|
|
@@ -92525,7 +92579,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
|
|
|
92525
92579
|
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
92526
92580
|
return {
|
|
92527
92581
|
async start(ctx, { next, marshalVariables: marshalVariables2 }) {
|
|
92528
|
-
const
|
|
92582
|
+
const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
|
|
92529
92583
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
92530
92584
|
let toNotify = [];
|
|
92531
92585
|
if (optimisticResponse) {
|
|
@@ -92536,25 +92590,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
92536
92590
|
data: optimisticResponse
|
|
92537
92591
|
}),
|
|
92538
92592
|
variables: marshalVariables2(ctx),
|
|
92539
|
-
layer:
|
|
92593
|
+
layer: layerOptimistic.id
|
|
92540
92594
|
});
|
|
92541
92595
|
}
|
|
92542
92596
|
ctx.cacheParams = {
|
|
92543
92597
|
...ctx.cacheParams,
|
|
92544
|
-
layer,
|
|
92598
|
+
layer: layerOptimistic,
|
|
92545
92599
|
notifySubscribers: toNotify,
|
|
92546
92600
|
forceNotify: true
|
|
92547
92601
|
};
|
|
92548
92602
|
next(ctx);
|
|
92549
92603
|
},
|
|
92550
92604
|
afterNetwork(ctx, { resolve: resolve22 }) {
|
|
92551
|
-
ctx.cacheParams?.layer
|
|
92605
|
+
if (ctx.cacheParams?.layer) {
|
|
92606
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
92607
|
+
}
|
|
92552
92608
|
resolve22(ctx);
|
|
92553
92609
|
},
|
|
92554
92610
|
end(ctx, { resolve: resolve22, value: value2 }) {
|
|
92555
92611
|
const hasErrors = value2.errors && value2.errors.length > 0;
|
|
92556
92612
|
if (hasErrors) {
|
|
92557
|
-
ctx.cacheParams?.layer
|
|
92613
|
+
if (ctx.cacheParams?.layer) {
|
|
92614
|
+
cache_default.clearLayer(ctx.cacheParams.layer.id);
|
|
92615
|
+
}
|
|
92558
92616
|
}
|
|
92559
92617
|
if (ctx.cacheParams?.layer) {
|
|
92560
92618
|
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -92564,7 +92622,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
|
92564
92622
|
catch(ctx, { error: error2 }) {
|
|
92565
92623
|
if (ctx.cacheParams?.layer) {
|
|
92566
92624
|
const { layer } = ctx.cacheParams;
|
|
92567
|
-
layer.
|
|
92625
|
+
cache_default.clearLayer(layer.id);
|
|
92568
92626
|
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
92569
92627
|
}
|
|
92570
92628
|
throw error2;
|
|
@@ -155919,10 +155977,10 @@ var ListManager2 = class {
|
|
|
155919
155977
|
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
155920
155978
|
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
155921
155979
|
}
|
|
155922
|
-
removeIDFromAllLists(id2) {
|
|
155980
|
+
removeIDFromAllLists(id2, layer) {
|
|
155923
155981
|
for (const fieldMap of this.lists.values()) {
|
|
155924
155982
|
for (const list of fieldMap.values()) {
|
|
155925
|
-
list.removeID(id2);
|
|
155983
|
+
list.removeID(id2, void 0, layer);
|
|
155926
155984
|
}
|
|
155927
155985
|
}
|
|
155928
155986
|
}
|
|
@@ -156079,7 +156137,7 @@ var List2 = class {
|
|
|
156079
156137
|
layer: layer?.id
|
|
156080
156138
|
});
|
|
156081
156139
|
}
|
|
156082
|
-
removeID(id2, variables = {}) {
|
|
156140
|
+
removeID(id2, variables = {}, layer) {
|
|
156083
156141
|
if (!this.validateWhen()) {
|
|
156084
156142
|
return;
|
|
156085
156143
|
}
|
|
@@ -156126,7 +156184,7 @@ var List2 = class {
|
|
|
156126
156184
|
subscribers.map((sub) => sub[0]),
|
|
156127
156185
|
variables
|
|
156128
156186
|
);
|
|
156129
|
-
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
156187
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
|
|
156130
156188
|
for (const [spec] of subscribers) {
|
|
156131
156189
|
spec.set(
|
|
156132
156190
|
this.cache._internal_unstable.getSelection({
|
|
@@ -156139,12 +156197,12 @@ var List2 = class {
|
|
|
156139
156197
|
}
|
|
156140
156198
|
return true;
|
|
156141
156199
|
}
|
|
156142
|
-
remove(data2, variables = {}) {
|
|
156200
|
+
remove(data2, variables = {}, layer) {
|
|
156143
156201
|
const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
|
|
156144
156202
|
if (!targetID) {
|
|
156145
156203
|
return;
|
|
156146
156204
|
}
|
|
156147
|
-
return this.removeID(targetID, variables);
|
|
156205
|
+
return this.removeID(targetID, variables, layer);
|
|
156148
156206
|
}
|
|
156149
156207
|
listType(data2) {
|
|
156150
156208
|
return data2.__typename || this.type;
|
|
@@ -156176,7 +156234,7 @@ var List2 = class {
|
|
|
156176
156234
|
layer,
|
|
156177
156235
|
where
|
|
156178
156236
|
}) {
|
|
156179
|
-
if (!this.remove(data2, variables)) {
|
|
156237
|
+
if (!this.remove(data2, variables, layer)) {
|
|
156180
156238
|
this.addToList(selection, data2, variables, where, layer);
|
|
156181
156239
|
}
|
|
156182
156240
|
}
|
|
@@ -156309,7 +156367,7 @@ var StaleManager2 = class {
|
|
|
156309
156367
|
};
|
|
156310
156368
|
var InMemoryStorage2 = class {
|
|
156311
156369
|
data;
|
|
156312
|
-
idCount =
|
|
156370
|
+
idCount = 1;
|
|
156313
156371
|
rank = 0;
|
|
156314
156372
|
constructor() {
|
|
156315
156373
|
this.data = [];
|
|
@@ -156329,11 +156387,11 @@ var InMemoryStorage2 = class {
|
|
|
156329
156387
|
insert(id2, field, location, target) {
|
|
156330
156388
|
return this.topLayer.insert(id2, field, location, target);
|
|
156331
156389
|
}
|
|
156332
|
-
remove(id2, field, target) {
|
|
156333
|
-
return
|
|
156390
|
+
remove(id2, field, target, layerToUser = this.topLayer) {
|
|
156391
|
+
return layerToUser.remove(id2, field, target);
|
|
156334
156392
|
}
|
|
156335
|
-
delete(id2) {
|
|
156336
|
-
return
|
|
156393
|
+
delete(id2, layerToUser = this.topLayer) {
|
|
156394
|
+
return layerToUser.delete(id2);
|
|
156337
156395
|
}
|
|
156338
156396
|
deleteField(id2, field) {
|
|
156339
156397
|
return this.topLayer.deleteField(id2, field);
|
|
@@ -156701,6 +156759,9 @@ var InMemorySubscriptions2 = class {
|
|
|
156701
156759
|
subscribers = {};
|
|
156702
156760
|
referenceCounts = {};
|
|
156703
156761
|
keyVersions = {};
|
|
156762
|
+
activeFields(parent2) {
|
|
156763
|
+
return Object.keys(this.subscribers[parent2] || {});
|
|
156764
|
+
}
|
|
156704
156765
|
add({
|
|
156705
156766
|
parent: parent2,
|
|
156706
156767
|
spec,
|
|
@@ -156967,20 +157028,7 @@ var Cache2 = class {
|
|
|
156967
157028
|
}) {
|
|
156968
157029
|
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
156969
157030
|
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
156970
|
-
|
|
156971
|
-
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
156972
|
-
if (!notified.includes(spec.set)) {
|
|
156973
|
-
notified.push(spec.set);
|
|
156974
|
-
spec.set(
|
|
156975
|
-
this._internal_unstable.getSelection({
|
|
156976
|
-
parent: spec.parentID || rootID2,
|
|
156977
|
-
selection: spec.selection,
|
|
156978
|
-
variables: spec.variables?.() || {},
|
|
156979
|
-
ignoreMasking: false
|
|
156980
|
-
}).data
|
|
156981
|
-
);
|
|
156982
|
-
}
|
|
156983
|
-
}
|
|
157031
|
+
this.#notifySubscribers(subscribers.concat(notifySubscribers));
|
|
156984
157032
|
return subscribers;
|
|
156985
157033
|
}
|
|
156986
157034
|
read(...args) {
|
|
@@ -157019,10 +157067,10 @@ var Cache2 = class {
|
|
|
157019
157067
|
}
|
|
157020
157068
|
return handler;
|
|
157021
157069
|
}
|
|
157022
|
-
delete(id2) {
|
|
157070
|
+
delete(id2, layer) {
|
|
157023
157071
|
this._internal_unstable.subscriptions.removeAllSubscribers(id2);
|
|
157024
|
-
this._internal_unstable.lists.removeIDFromAllLists(id2);
|
|
157025
|
-
this._internal_unstable.storage.delete(id2);
|
|
157072
|
+
this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
|
|
157073
|
+
this._internal_unstable.storage.delete(id2, layer);
|
|
157026
157074
|
}
|
|
157027
157075
|
setConfig(config4) {
|
|
157028
157076
|
this._internal_unstable.setConfig(config4);
|
|
@@ -157054,6 +157102,70 @@ var Cache2 = class {
|
|
|
157054
157102
|
config() {
|
|
157055
157103
|
return this._internal_unstable.config;
|
|
157056
157104
|
}
|
|
157105
|
+
clearLayer(layerID) {
|
|
157106
|
+
const layer = this._internal_unstable.storage.getLayer(layerID);
|
|
157107
|
+
if (!layer) {
|
|
157108
|
+
throw new Error("Cannot find layer with id: " + layerID);
|
|
157109
|
+
}
|
|
157110
|
+
const toNotify = [];
|
|
157111
|
+
const allFields = [];
|
|
157112
|
+
for (const target of [layer.fields, layer.links]) {
|
|
157113
|
+
for (const [id2, fields] of Object.entries(target)) {
|
|
157114
|
+
allFields.push(
|
|
157115
|
+
...Object.entries(fields).map(([field, value2]) => ({ id: id2, field, value: value2 }))
|
|
157116
|
+
);
|
|
157117
|
+
}
|
|
157118
|
+
}
|
|
157119
|
+
const displayFields = [];
|
|
157120
|
+
for (const pair of allFields) {
|
|
157121
|
+
const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
|
|
157122
|
+
if (!displayLayers.includes(layerID)) {
|
|
157123
|
+
continue;
|
|
157124
|
+
}
|
|
157125
|
+
displayFields.push(pair);
|
|
157126
|
+
}
|
|
157127
|
+
for (const [id2, operation] of Object.entries(layer.operations)) {
|
|
157128
|
+
if (operation.deleted) {
|
|
157129
|
+
displayFields.push(
|
|
157130
|
+
...this._internal_unstable.subscriptions.activeFields(id2).map((field) => ({ id: id2, field }))
|
|
157131
|
+
);
|
|
157132
|
+
}
|
|
157133
|
+
const fields = Object.keys(operation.fields ?? {});
|
|
157134
|
+
if (fields.length > 0) {
|
|
157135
|
+
displayFields.push(...fields.map((field) => ({ id: id2, field })));
|
|
157136
|
+
}
|
|
157137
|
+
}
|
|
157138
|
+
layer.clear();
|
|
157139
|
+
for (const display of displayFields) {
|
|
157140
|
+
const { field, id: id2 } = display;
|
|
157141
|
+
const notify = !("value" in display) || this._internal_unstable.storage.get(id2, field).value !== display.value;
|
|
157142
|
+
if (notify) {
|
|
157143
|
+
toNotify.push(
|
|
157144
|
+
...this._internal_unstable.subscriptions.get(id2, field).map((sub) => sub[0])
|
|
157145
|
+
);
|
|
157146
|
+
}
|
|
157147
|
+
}
|
|
157148
|
+
this.#notifySubscribers(toNotify);
|
|
157149
|
+
}
|
|
157150
|
+
#notifySubscribers(subs) {
|
|
157151
|
+
if (subs.length === 0) {
|
|
157152
|
+
return;
|
|
157153
|
+
}
|
|
157154
|
+
const notified = [];
|
|
157155
|
+
for (const spec of subs) {
|
|
157156
|
+
if (!notified.includes(spec.set)) {
|
|
157157
|
+
notified.push(spec.set);
|
|
157158
|
+
spec.set(
|
|
157159
|
+
this._internal_unstable.getSelection({
|
|
157160
|
+
parent: spec.parentID || rootID2,
|
|
157161
|
+
selection: spec.selection,
|
|
157162
|
+
variables: spec.variables?.() || {},
|
|
157163
|
+
ignoreMasking: false
|
|
157164
|
+
}).data
|
|
157165
|
+
);
|
|
157166
|
+
}
|
|
157167
|
+
}
|
|
157168
|
+
}
|
|
157057
157169
|
};
|
|
157058
157170
|
var CacheInternal2 = class {
|
|
157059
157171
|
_disabled = false;
|
|
@@ -157341,8 +157453,16 @@ var CacheInternal2 = class {
|
|
|
157341
157453
|
operation.position || "last",
|
|
157342
157454
|
layer
|
|
157343
157455
|
);
|
|
157456
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
157457
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
157458
|
+
selection: fieldSelection,
|
|
157459
|
+
data: target,
|
|
157460
|
+
variables,
|
|
157461
|
+
where: operation.position || "last",
|
|
157462
|
+
layer
|
|
157463
|
+
});
|
|
157344
157464
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
157345
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
157465
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
|
|
157346
157466
|
} else if (operation.action === "delete" && operation.type) {
|
|
157347
157467
|
if (typeof target !== "string") {
|
|
157348
157468
|
throw new Error("Cannot delete a record with a non-string ID");
|
|
@@ -157351,15 +157471,7 @@ var CacheInternal2 = class {
|
|
|
157351
157471
|
if (!targetID) {
|
|
157352
157472
|
continue;
|
|
157353
157473
|
}
|
|
157354
|
-
this.cache.delete(targetID);
|
|
157355
|
-
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
157356
|
-
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
|
|
157357
|
-
selection: fieldSelection,
|
|
157358
|
-
data: target,
|
|
157359
|
-
variables,
|
|
157360
|
-
where: operation.position || "last",
|
|
157361
|
-
layer
|
|
157362
|
-
});
|
|
157474
|
+
this.cache.delete(targetID, layer);
|
|
157363
157475
|
}
|
|
157364
157476
|
}
|
|
157365
157477
|
}
|
|
@@ -157882,7 +157994,7 @@ var fragment2 = documentPlugin2(ArtifactKind2.Fragment, function() {
|
|
|
157882
157994
|
var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
157883
157995
|
return {
|
|
157884
157996
|
async start(ctx, { next, marshalVariables }) {
|
|
157885
|
-
const
|
|
157997
|
+
const layerOptimistic = cache_default2._internal_unstable.storage.createLayer(true);
|
|
157886
157998
|
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
157887
157999
|
let toNotify = [];
|
|
157888
158000
|
if (optimisticResponse) {
|
|
@@ -157893,25 +158005,29 @@ var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
|
157893
158005
|
data: optimisticResponse
|
|
157894
158006
|
}),
|
|
157895
158007
|
variables: marshalVariables(ctx),
|
|
157896
|
-
layer:
|
|
158008
|
+
layer: layerOptimistic.id
|
|
157897
158009
|
});
|
|
157898
158010
|
}
|
|
157899
158011
|
ctx.cacheParams = {
|
|
157900
158012
|
...ctx.cacheParams,
|
|
157901
|
-
layer,
|
|
158013
|
+
layer: layerOptimistic,
|
|
157902
158014
|
notifySubscribers: toNotify,
|
|
157903
158015
|
forceNotify: true
|
|
157904
158016
|
};
|
|
157905
158017
|
next(ctx);
|
|
157906
158018
|
},
|
|
157907
158019
|
afterNetwork(ctx, { resolve: resolve22 }) {
|
|
157908
|
-
ctx.cacheParams?.layer
|
|
158020
|
+
if (ctx.cacheParams?.layer) {
|
|
158021
|
+
cache_default2.clearLayer(ctx.cacheParams.layer.id);
|
|
158022
|
+
}
|
|
157909
158023
|
resolve22(ctx);
|
|
157910
158024
|
},
|
|
157911
158025
|
end(ctx, { resolve: resolve22, value: value2 }) {
|
|
157912
158026
|
const hasErrors = value2.errors && value2.errors.length > 0;
|
|
157913
158027
|
if (hasErrors) {
|
|
157914
|
-
ctx.cacheParams?.layer
|
|
158028
|
+
if (ctx.cacheParams?.layer) {
|
|
158029
|
+
cache_default2.clearLayer(ctx.cacheParams.layer.id);
|
|
158030
|
+
}
|
|
157915
158031
|
}
|
|
157916
158032
|
if (ctx.cacheParams?.layer) {
|
|
157917
158033
|
cache_default2._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
@@ -157921,7 +158037,7 @@ var mutation2 = documentPlugin2(ArtifactKind2.Mutation, () => {
|
|
|
157921
158037
|
catch(ctx, { error: error2 }) {
|
|
157922
158038
|
if (ctx.cacheParams?.layer) {
|
|
157923
158039
|
const { layer } = ctx.cacheParams;
|
|
157924
|
-
layer.
|
|
158040
|
+
cache_default2.clearLayer(layer.id);
|
|
157925
158041
|
cache_default2._internal_unstable.storage.resolveLayer(layer.id);
|
|
157926
158042
|
}
|
|
157927
158043
|
throw error2;
|