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.
@@ -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 = 0;
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 this.topLayer.remove(id2, field, target);
90987
+ remove(id2, field, target, layerToUser = this.topLayer) {
90988
+ return layerToUser.remove(id2, field, target);
90989
90989
  }
90990
- delete(id2) {
90991
- return this.topLayer.delete(id2);
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
- const notified = [];
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 layer = cache_default._internal_unstable.storage.createLayer(true);
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: layer.id
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?.clear();
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?.clear();
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.clear();
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 = 0;
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 this.topLayer.remove(id2, field, target);
147638
+ remove(id2, field, target, layerToUser = this.topLayer) {
147639
+ return layerToUser.remove(id2, field, target);
147582
147640
  }
147583
- delete(id2) {
147584
- return this.topLayer.delete(id2);
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
- const notified = [];
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 layer = cache_default2._internal_unstable.storage.createLayer(true);
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: layer.id
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?.clear();
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?.clear();
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.clear();
149288
+ cache_default2.clearLayer(layer.id);
149173
149289
  cache_default2._internal_unstable.storage.resolveLayer(layer.id);
149174
149290
  }
149175
149291
  throw error2;
@@ -150549,7 +150665,7 @@ function operationObject({
150549
150665
  if (operationKind === "insert" || operationKind === "toggle") {
150550
150666
  operation.position = position;
150551
150667
  }
150552
- if (operationKind === "insert" && allLists) {
150668
+ if (allLists && operationKind !== "delete") {
150553
150669
  operation.target = "all";
150554
150670
  }
150555
150671
  if (parentID) {
@@ -209398,10 +209514,10 @@ var ListManager3 = class {
209398
209514
  this.lists.get(list.name).get(parentID).lists.push(handler);
209399
209515
  this.listsByField.get(parentID).get(list.key).push(handler);
209400
209516
  }
209401
- removeIDFromAllLists(id2) {
209517
+ removeIDFromAllLists(id2, layer) {
209402
209518
  for (const fieldMap of this.lists.values()) {
209403
209519
  for (const list of fieldMap.values()) {
209404
- list.removeID(id2);
209520
+ list.removeID(id2, void 0, layer);
209405
209521
  }
209406
209522
  }
209407
209523
  }
@@ -209558,7 +209674,7 @@ var List3 = class {
209558
209674
  layer: layer?.id
209559
209675
  });
209560
209676
  }
209561
- removeID(id2, variables = {}) {
209677
+ removeID(id2, variables = {}, layer) {
209562
209678
  if (!this.validateWhen()) {
209563
209679
  return;
209564
209680
  }
@@ -209605,7 +209721,7 @@ var List3 = class {
209605
209721
  subscribers.map((sub) => sub[0]),
209606
209722
  variables
209607
209723
  );
209608
- this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
209724
+ this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
209609
209725
  for (const [spec] of subscribers) {
209610
209726
  spec.set(
209611
209727
  this.cache._internal_unstable.getSelection({
@@ -209618,12 +209734,12 @@ var List3 = class {
209618
209734
  }
209619
209735
  return true;
209620
209736
  }
209621
- remove(data2, variables = {}) {
209737
+ remove(data2, variables = {}, layer) {
209622
209738
  const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
209623
209739
  if (!targetID) {
209624
209740
  return;
209625
209741
  }
209626
- return this.removeID(targetID, variables);
209742
+ return this.removeID(targetID, variables, layer);
209627
209743
  }
209628
209744
  listType(data2) {
209629
209745
  return data2.__typename || this.type;
@@ -209655,7 +209771,7 @@ var List3 = class {
209655
209771
  layer,
209656
209772
  where
209657
209773
  }) {
209658
- if (!this.remove(data2, variables)) {
209774
+ if (!this.remove(data2, variables, layer)) {
209659
209775
  this.addToList(selection, data2, variables, where, layer);
209660
209776
  }
209661
209777
  }
@@ -209788,7 +209904,7 @@ var StaleManager3 = class {
209788
209904
  };
209789
209905
  var InMemoryStorage3 = class {
209790
209906
  data;
209791
- idCount = 0;
209907
+ idCount = 1;
209792
209908
  rank = 0;
209793
209909
  constructor() {
209794
209910
  this.data = [];
@@ -209808,11 +209924,11 @@ var InMemoryStorage3 = class {
209808
209924
  insert(id2, field, location, target) {
209809
209925
  return this.topLayer.insert(id2, field, location, target);
209810
209926
  }
209811
- remove(id2, field, target) {
209812
- return this.topLayer.remove(id2, field, target);
209927
+ remove(id2, field, target, layerToUser = this.topLayer) {
209928
+ return layerToUser.remove(id2, field, target);
209813
209929
  }
209814
- delete(id2) {
209815
- return this.topLayer.delete(id2);
209930
+ delete(id2, layerToUser = this.topLayer) {
209931
+ return layerToUser.delete(id2);
209816
209932
  }
209817
209933
  deleteField(id2, field) {
209818
209934
  return this.topLayer.deleteField(id2, field);
@@ -210180,6 +210296,9 @@ var InMemorySubscriptions3 = class {
210180
210296
  subscribers = {};
210181
210297
  referenceCounts = {};
210182
210298
  keyVersions = {};
210299
+ activeFields(parent2) {
210300
+ return Object.keys(this.subscribers[parent2] || {});
210301
+ }
210183
210302
  add({
210184
210303
  parent: parent2,
210185
210304
  spec,
@@ -210446,20 +210565,7 @@ var Cache3 = class {
210446
210565
  }) {
210447
210566
  const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
210448
210567
  const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
210449
- const notified = [];
210450
- for (const spec of subscribers.concat(notifySubscribers)) {
210451
- if (!notified.includes(spec.set)) {
210452
- notified.push(spec.set);
210453
- spec.set(
210454
- this._internal_unstable.getSelection({
210455
- parent: spec.parentID || rootID3,
210456
- selection: spec.selection,
210457
- variables: spec.variables?.() || {},
210458
- ignoreMasking: false
210459
- }).data
210460
- );
210461
- }
210462
- }
210568
+ this.#notifySubscribers(subscribers.concat(notifySubscribers));
210463
210569
  return subscribers;
210464
210570
  }
210465
210571
  read(...args) {
@@ -210498,10 +210604,10 @@ var Cache3 = class {
210498
210604
  }
210499
210605
  return handler;
210500
210606
  }
210501
- delete(id2) {
210607
+ delete(id2, layer) {
210502
210608
  this._internal_unstable.subscriptions.removeAllSubscribers(id2);
210503
- this._internal_unstable.lists.removeIDFromAllLists(id2);
210504
- this._internal_unstable.storage.delete(id2);
210609
+ this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
210610
+ this._internal_unstable.storage.delete(id2, layer);
210505
210611
  }
210506
210612
  setConfig(config22) {
210507
210613
  this._internal_unstable.setConfig(config22);
@@ -210533,6 +210639,70 @@ var Cache3 = class {
210533
210639
  config() {
210534
210640
  return this._internal_unstable.config;
210535
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
+ }
210536
210706
  };
210537
210707
  var CacheInternal3 = class {
210538
210708
  _disabled = false;
@@ -210820,8 +210990,16 @@ var CacheInternal3 = class {
210820
210990
  operation.position || "last",
210821
210991
  layer
210822
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
+ });
210823
211001
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
210824
- 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);
210825
211003
  } else if (operation.action === "delete" && operation.type) {
210826
211004
  if (typeof target !== "string") {
210827
211005
  throw new Error("Cannot delete a record with a non-string ID");
@@ -210830,15 +211008,7 @@ var CacheInternal3 = class {
210830
211008
  if (!targetID) {
210831
211009
  continue;
210832
211010
  }
210833
- this.cache.delete(targetID);
210834
- } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
210835
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
210836
- selection: fieldSelection,
210837
- data: target,
210838
- variables,
210839
- where: operation.position || "last",
210840
- layer
210841
- });
211011
+ this.cache.delete(targetID, layer);
210842
211012
  }
210843
211013
  }
210844
211014
  }
@@ -211361,7 +211531,7 @@ var fragment3 = documentPlugin3(ArtifactKind3.Fragment, function() {
211361
211531
  var mutation3 = documentPlugin3(ArtifactKind3.Mutation, () => {
211362
211532
  return {
211363
211533
  async start(ctx, { next, marshalVariables }) {
211364
- const layer = cache_default3._internal_unstable.storage.createLayer(true);
211534
+ const layerOptimistic = cache_default3._internal_unstable.storage.createLayer(true);
211365
211535
  const optimisticResponse = ctx.stuff.optimisticResponse;
211366
211536
  let toNotify = [];
211367
211537
  if (optimisticResponse) {
@@ -211372,25 +211542,29 @@ var mutation3 = documentPlugin3(ArtifactKind3.Mutation, () => {
211372
211542
  data: optimisticResponse
211373
211543
  }),
211374
211544
  variables: marshalVariables(ctx),
211375
- layer: layer.id
211545
+ layer: layerOptimistic.id
211376
211546
  });
211377
211547
  }
211378
211548
  ctx.cacheParams = {
211379
211549
  ...ctx.cacheParams,
211380
- layer,
211550
+ layer: layerOptimistic,
211381
211551
  notifySubscribers: toNotify,
211382
211552
  forceNotify: true
211383
211553
  };
211384
211554
  next(ctx);
211385
211555
  },
211386
211556
  afterNetwork(ctx, { resolve: resolve22 }) {
211387
- ctx.cacheParams?.layer?.clear();
211557
+ if (ctx.cacheParams?.layer) {
211558
+ cache_default3.clearLayer(ctx.cacheParams.layer.id);
211559
+ }
211388
211560
  resolve22(ctx);
211389
211561
  },
211390
211562
  end(ctx, { resolve: resolve22, value: value2 }) {
211391
211563
  const hasErrors = value2.errors && value2.errors.length > 0;
211392
211564
  if (hasErrors) {
211393
- ctx.cacheParams?.layer?.clear();
211565
+ if (ctx.cacheParams?.layer) {
211566
+ cache_default3.clearLayer(ctx.cacheParams.layer.id);
211567
+ }
211394
211568
  }
211395
211569
  if (ctx.cacheParams?.layer) {
211396
211570
  cache_default3._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
@@ -211400,7 +211574,7 @@ var mutation3 = documentPlugin3(ArtifactKind3.Mutation, () => {
211400
211574
  catch(ctx, { error: error2 }) {
211401
211575
  if (ctx.cacheParams?.layer) {
211402
211576
  const { layer } = ctx.cacheParams;
211403
- layer.clear();
211577
+ cache_default3.clearLayer(layer.id);
211404
211578
  cache_default3._internal_unstable.storage.resolveLayer(layer.id);
211405
211579
  }
211406
211580
  throw error2;
@@ -275481,10 +275655,10 @@ var ListManager4 = class {
275481
275655
  this.lists.get(list.name).get(parentID).lists.push(handler);
275482
275656
  this.listsByField.get(parentID).get(list.key).push(handler);
275483
275657
  }
275484
- removeIDFromAllLists(id2) {
275658
+ removeIDFromAllLists(id2, layer) {
275485
275659
  for (const fieldMap of this.lists.values()) {
275486
275660
  for (const list of fieldMap.values()) {
275487
- list.removeID(id2);
275661
+ list.removeID(id2, void 0, layer);
275488
275662
  }
275489
275663
  }
275490
275664
  }
@@ -275641,7 +275815,7 @@ var List4 = class {
275641
275815
  layer: layer?.id
275642
275816
  });
275643
275817
  }
275644
- removeID(id2, variables = {}) {
275818
+ removeID(id2, variables = {}, layer) {
275645
275819
  if (!this.validateWhen()) {
275646
275820
  return;
275647
275821
  }
@@ -275688,7 +275862,7 @@ var List4 = class {
275688
275862
  subscribers.map((sub) => sub[0]),
275689
275863
  variables
275690
275864
  );
275691
- this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
275865
+ this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
275692
275866
  for (const [spec] of subscribers) {
275693
275867
  spec.set(
275694
275868
  this.cache._internal_unstable.getSelection({
@@ -275701,12 +275875,12 @@ var List4 = class {
275701
275875
  }
275702
275876
  return true;
275703
275877
  }
275704
- remove(data2, variables = {}) {
275878
+ remove(data2, variables = {}, layer) {
275705
275879
  const targetID = this.cache._internal_unstable.id(this.listType(data2), data2);
275706
275880
  if (!targetID) {
275707
275881
  return;
275708
275882
  }
275709
- return this.removeID(targetID, variables);
275883
+ return this.removeID(targetID, variables, layer);
275710
275884
  }
275711
275885
  listType(data2) {
275712
275886
  return data2.__typename || this.type;
@@ -275738,7 +275912,7 @@ var List4 = class {
275738
275912
  layer,
275739
275913
  where
275740
275914
  }) {
275741
- if (!this.remove(data2, variables)) {
275915
+ if (!this.remove(data2, variables, layer)) {
275742
275916
  this.addToList(selection, data2, variables, where, layer);
275743
275917
  }
275744
275918
  }
@@ -275871,7 +276045,7 @@ var StaleManager4 = class {
275871
276045
  };
275872
276046
  var InMemoryStorage4 = class {
275873
276047
  data;
275874
- idCount = 0;
276048
+ idCount = 1;
275875
276049
  rank = 0;
275876
276050
  constructor() {
275877
276051
  this.data = [];
@@ -275891,11 +276065,11 @@ var InMemoryStorage4 = class {
275891
276065
  insert(id2, field, location, target) {
275892
276066
  return this.topLayer.insert(id2, field, location, target);
275893
276067
  }
275894
- remove(id2, field, target) {
275895
- return this.topLayer.remove(id2, field, target);
276068
+ remove(id2, field, target, layerToUser = this.topLayer) {
276069
+ return layerToUser.remove(id2, field, target);
275896
276070
  }
275897
- delete(id2) {
275898
- return this.topLayer.delete(id2);
276071
+ delete(id2, layerToUser = this.topLayer) {
276072
+ return layerToUser.delete(id2);
275899
276073
  }
275900
276074
  deleteField(id2, field) {
275901
276075
  return this.topLayer.deleteField(id2, field);
@@ -276263,6 +276437,9 @@ var InMemorySubscriptions4 = class {
276263
276437
  subscribers = {};
276264
276438
  referenceCounts = {};
276265
276439
  keyVersions = {};
276440
+ activeFields(parent2) {
276441
+ return Object.keys(this.subscribers[parent2] || {});
276442
+ }
276266
276443
  add({
276267
276444
  parent: parent2,
276268
276445
  spec,
@@ -276529,20 +276706,7 @@ var Cache4 = class {
276529
276706
  }) {
276530
276707
  const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
276531
276708
  const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
276532
- const notified = [];
276533
- for (const spec of subscribers.concat(notifySubscribers)) {
276534
- if (!notified.includes(spec.set)) {
276535
- notified.push(spec.set);
276536
- spec.set(
276537
- this._internal_unstable.getSelection({
276538
- parent: spec.parentID || rootID4,
276539
- selection: spec.selection,
276540
- variables: spec.variables?.() || {},
276541
- ignoreMasking: false
276542
- }).data
276543
- );
276544
- }
276545
- }
276709
+ this.#notifySubscribers(subscribers.concat(notifySubscribers));
276546
276710
  return subscribers;
276547
276711
  }
276548
276712
  read(...args) {
@@ -276581,10 +276745,10 @@ var Cache4 = class {
276581
276745
  }
276582
276746
  return handler;
276583
276747
  }
276584
- delete(id2) {
276748
+ delete(id2, layer) {
276585
276749
  this._internal_unstable.subscriptions.removeAllSubscribers(id2);
276586
- this._internal_unstable.lists.removeIDFromAllLists(id2);
276587
- this._internal_unstable.storage.delete(id2);
276750
+ this._internal_unstable.lists.removeIDFromAllLists(id2, layer);
276751
+ this._internal_unstable.storage.delete(id2, layer);
276588
276752
  }
276589
276753
  setConfig(config42) {
276590
276754
  this._internal_unstable.setConfig(config42);
@@ -276616,6 +276780,70 @@ var Cache4 = class {
276616
276780
  config() {
276617
276781
  return this._internal_unstable.config;
276618
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
+ }
276619
276847
  };
276620
276848
  var CacheInternal4 = class {
276621
276849
  _disabled = false;
@@ -276903,8 +277131,16 @@ var CacheInternal4 = class {
276903
277131
  operation.position || "last",
276904
277132
  layer
276905
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
+ });
276906
277142
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
276907
- 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);
276908
277144
  } else if (operation.action === "delete" && operation.type) {
276909
277145
  if (typeof target !== "string") {
276910
277146
  throw new Error("Cannot delete a record with a non-string ID");
@@ -276913,15 +277149,7 @@ var CacheInternal4 = class {
276913
277149
  if (!targetID) {
276914
277150
  continue;
276915
277151
  }
276916
- this.cache.delete(targetID);
276917
- } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
276918
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
276919
- selection: fieldSelection,
276920
- data: target,
276921
- variables,
276922
- where: operation.position || "last",
276923
- layer
276924
- });
277152
+ this.cache.delete(targetID, layer);
276925
277153
  }
276926
277154
  }
276927
277155
  }
@@ -277444,7 +277672,7 @@ var fragment4 = documentPlugin4(ArtifactKind4.Fragment, function() {
277444
277672
  var mutation4 = documentPlugin4(ArtifactKind4.Mutation, () => {
277445
277673
  return {
277446
277674
  async start(ctx, { next, marshalVariables }) {
277447
- const layer = cache_default4._internal_unstable.storage.createLayer(true);
277675
+ const layerOptimistic = cache_default4._internal_unstable.storage.createLayer(true);
277448
277676
  const optimisticResponse = ctx.stuff.optimisticResponse;
277449
277677
  let toNotify = [];
277450
277678
  if (optimisticResponse) {
@@ -277455,25 +277683,29 @@ var mutation4 = documentPlugin4(ArtifactKind4.Mutation, () => {
277455
277683
  data: optimisticResponse
277456
277684
  }),
277457
277685
  variables: marshalVariables(ctx),
277458
- layer: layer.id
277686
+ layer: layerOptimistic.id
277459
277687
  });
277460
277688
  }
277461
277689
  ctx.cacheParams = {
277462
277690
  ...ctx.cacheParams,
277463
- layer,
277691
+ layer: layerOptimistic,
277464
277692
  notifySubscribers: toNotify,
277465
277693
  forceNotify: true
277466
277694
  };
277467
277695
  next(ctx);
277468
277696
  },
277469
277697
  afterNetwork(ctx, { resolve: resolve22 }) {
277470
- ctx.cacheParams?.layer?.clear();
277698
+ if (ctx.cacheParams?.layer) {
277699
+ cache_default4.clearLayer(ctx.cacheParams.layer.id);
277700
+ }
277471
277701
  resolve22(ctx);
277472
277702
  },
277473
277703
  end(ctx, { resolve: resolve22, value: value2 }) {
277474
277704
  const hasErrors = value2.errors && value2.errors.length > 0;
277475
277705
  if (hasErrors) {
277476
- ctx.cacheParams?.layer?.clear();
277706
+ if (ctx.cacheParams?.layer) {
277707
+ cache_default4.clearLayer(ctx.cacheParams.layer.id);
277708
+ }
277477
277709
  }
277478
277710
  if (ctx.cacheParams?.layer) {
277479
277711
  cache_default4._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
@@ -277483,7 +277715,7 @@ var mutation4 = documentPlugin4(ArtifactKind4.Mutation, () => {
277483
277715
  catch(ctx, { error: error2 }) {
277484
277716
  if (ctx.cacheParams?.layer) {
277485
277717
  const { layer } = ctx.cacheParams;
277486
- layer.clear();
277718
+ cache_default4.clearLayer(layer.id);
277487
277719
  cache_default4._internal_unstable.storage.resolveLayer(layer.id);
277488
277720
  }
277489
277721
  throw error2;