houdini-svelte 2.2.0-next.2 → 2.2.0-next.4

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.
@@ -87140,20 +87140,21 @@ var CacheInternal = class {
87140
87140
  } else if (Array.isArray(value) && // make typescript happy
87141
87141
  (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
87142
87142
  let oldIDs = [...previousValue || []];
87143
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
87144
- if (!id) {
87145
- return "";
87146
- }
87147
- const { value: cursorField } = this.storage.get(id, "cursor");
87148
- if (cursorField) {
87149
- return "";
87150
- }
87151
- const { value: node } = this.storage.get(id, "node");
87152
- if (!node) {
87153
- return "";
87154
- }
87155
- return node;
87156
- });
87143
+ if (updates?.includes("append") || updates?.includes("prepend")) {
87144
+ oldIDs = oldIDs.filter((id) => {
87145
+ for (const layer2 of this.storage.data) {
87146
+ for (const operation of Object.values(layer2.operations)) {
87147
+ if (operation.fields?.[key])
87148
+ for (const listOperation of operation.fields[key]) {
87149
+ if ("id" in listOperation && listOperation.id === id) {
87150
+ return false;
87151
+ }
87152
+ }
87153
+ }
87154
+ }
87155
+ return true;
87156
+ });
87157
+ }
87157
87158
  let linkedIDs = [];
87158
87159
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
87159
87160
  value,
@@ -87172,39 +87173,45 @@ var CacheInternal = class {
87172
87173
  layer.writeLink(parent2, key, linkedIDs);
87173
87174
  };
87174
87175
  if (applyUpdates && updates) {
87175
- if (key === "edges") {
87176
- const newNodeIDs = [];
87177
- for (const id of newIDs) {
87176
+ const filterIDs = (keep, insert) => {
87177
+ const existingIDs = /* @__PURE__ */ new Set();
87178
+ for (const id of keep) {
87178
87179
  if (!id) {
87179
87180
  continue;
87180
87181
  }
87181
87182
  const { value: node } = this.storage.get(id, "node");
87182
- if (typeof node !== "string") {
87183
+ if (!node) {
87183
87184
  continue;
87184
87185
  }
87185
- if (!node || !this.storage.get(node, "__typename")) {
87186
+ const nodeID = this.storage.get(node, "id");
87187
+ if (!nodeID) {
87186
87188
  continue;
87187
87189
  }
87188
- newNodeIDs.push(node);
87190
+ existingIDs.add(nodeID.value);
87189
87191
  }
87190
- oldIDs = oldIDs.filter((id) => {
87192
+ return insert.filter((id) => {
87191
87193
  if (!id) {
87192
87194
  return true;
87193
87195
  }
87194
- const { value: value2 } = this.storage.get(id, "node");
87195
- const node = value2;
87196
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
87197
- return false;
87196
+ const { value: node } = this.storage.get(id, "node");
87197
+ if (!node) {
87198
+ return true;
87198
87199
  }
87199
- return true;
87200
+ const nodeID = this.storage.get(node, "id");
87201
+ if (!nodeID) {
87202
+ return true;
87203
+ }
87204
+ return !existingIDs.has(nodeID.value);
87200
87205
  });
87201
- }
87206
+ };
87202
87207
  for (const update of applyUpdates) {
87203
87208
  if (update !== "replace" && !updates.includes(update)) {
87204
87209
  continue;
87205
87210
  }
87206
87211
  if (update === "prepend") {
87207
- linkedIDs = newIDs.concat(oldIDs);
87212
+ linkedIDs = newIDs.concat(
87213
+ filterIDs(newIDs, oldIDs)
87214
+ );
87208
87215
  if (layer?.optimistic) {
87209
87216
  action = () => {
87210
87217
  for (const id of newIDs) {
@@ -87215,7 +87222,7 @@ var CacheInternal = class {
87215
87222
  };
87216
87223
  }
87217
87224
  } else if (update === "append") {
87218
- linkedIDs = oldIDs.concat(newIDs);
87225
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
87219
87226
  if (layer?.optimistic) {
87220
87227
  action = () => {
87221
87228
  for (const id of newIDs) {
@@ -152660,20 +152667,21 @@ var CacheInternal2 = class {
152660
152667
  } else if (Array.isArray(value) && // make typescript happy
152661
152668
  (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
152662
152669
  let oldIDs = [...previousValue || []];
152663
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
152664
- if (!id) {
152665
- return "";
152666
- }
152667
- const { value: cursorField } = this.storage.get(id, "cursor");
152668
- if (cursorField) {
152669
- return "";
152670
- }
152671
- const { value: node } = this.storage.get(id, "node");
152672
- if (!node) {
152673
- return "";
152674
- }
152675
- return node;
152676
- });
152670
+ if (updates?.includes("append") || updates?.includes("prepend")) {
152671
+ oldIDs = oldIDs.filter((id) => {
152672
+ for (const layer2 of this.storage.data) {
152673
+ for (const operation of Object.values(layer2.operations)) {
152674
+ if (operation.fields?.[key])
152675
+ for (const listOperation of operation.fields[key]) {
152676
+ if ("id" in listOperation && listOperation.id === id) {
152677
+ return false;
152678
+ }
152679
+ }
152680
+ }
152681
+ }
152682
+ return true;
152683
+ });
152684
+ }
152677
152685
  let linkedIDs = [];
152678
152686
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
152679
152687
  value,
@@ -152692,39 +152700,45 @@ var CacheInternal2 = class {
152692
152700
  layer.writeLink(parent2, key, linkedIDs);
152693
152701
  };
152694
152702
  if (applyUpdates && updates) {
152695
- if (key === "edges") {
152696
- const newNodeIDs = [];
152697
- for (const id of newIDs) {
152703
+ const filterIDs = (keep, insert) => {
152704
+ const existingIDs = /* @__PURE__ */ new Set();
152705
+ for (const id of keep) {
152698
152706
  if (!id) {
152699
152707
  continue;
152700
152708
  }
152701
152709
  const { value: node } = this.storage.get(id, "node");
152702
- if (typeof node !== "string") {
152710
+ if (!node) {
152703
152711
  continue;
152704
152712
  }
152705
- if (!node || !this.storage.get(node, "__typename")) {
152713
+ const nodeID = this.storage.get(node, "id");
152714
+ if (!nodeID) {
152706
152715
  continue;
152707
152716
  }
152708
- newNodeIDs.push(node);
152717
+ existingIDs.add(nodeID.value);
152709
152718
  }
152710
- oldIDs = oldIDs.filter((id) => {
152719
+ return insert.filter((id) => {
152711
152720
  if (!id) {
152712
152721
  return true;
152713
152722
  }
152714
- const { value: value2 } = this.storage.get(id, "node");
152715
- const node = value2;
152716
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
152717
- return false;
152723
+ const { value: node } = this.storage.get(id, "node");
152724
+ if (!node) {
152725
+ return true;
152718
152726
  }
152719
- return true;
152727
+ const nodeID = this.storage.get(node, "id");
152728
+ if (!nodeID) {
152729
+ return true;
152730
+ }
152731
+ return !existingIDs.has(nodeID.value);
152720
152732
  });
152721
- }
152733
+ };
152722
152734
  for (const update of applyUpdates) {
152723
152735
  if (update !== "replace" && !updates.includes(update)) {
152724
152736
  continue;
152725
152737
  }
152726
152738
  if (update === "prepend") {
152727
- linkedIDs = newIDs.concat(oldIDs);
152739
+ linkedIDs = newIDs.concat(
152740
+ filterIDs(newIDs, oldIDs)
152741
+ );
152728
152742
  if (layer?.optimistic) {
152729
152743
  action = () => {
152730
152744
  for (const id of newIDs) {
@@ -152735,7 +152749,7 @@ var CacheInternal2 = class {
152735
152749
  };
152736
152750
  }
152737
152751
  } else if (update === "append") {
152738
- linkedIDs = oldIDs.concat(newIDs);
152752
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
152739
152753
  if (layer?.optimistic) {
152740
152754
  action = () => {
152741
152755
  for (const id of newIDs) {
@@ -225779,20 +225793,21 @@ var CacheInternal3 = class {
225779
225793
  } else if (Array.isArray(value) && // make typescript happy
225780
225794
  (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
225781
225795
  let oldIDs = [...previousValue || []];
225782
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
225783
- if (!id) {
225784
- return "";
225785
- }
225786
- const { value: cursorField } = this.storage.get(id, "cursor");
225787
- if (cursorField) {
225788
- return "";
225789
- }
225790
- const { value: node } = this.storage.get(id, "node");
225791
- if (!node) {
225792
- return "";
225793
- }
225794
- return node;
225795
- });
225796
+ if (updates?.includes("append") || updates?.includes("prepend")) {
225797
+ oldIDs = oldIDs.filter((id) => {
225798
+ for (const layer2 of this.storage.data) {
225799
+ for (const operation of Object.values(layer2.operations)) {
225800
+ if (operation.fields?.[key])
225801
+ for (const listOperation of operation.fields[key]) {
225802
+ if ("id" in listOperation && listOperation.id === id) {
225803
+ return false;
225804
+ }
225805
+ }
225806
+ }
225807
+ }
225808
+ return true;
225809
+ });
225810
+ }
225796
225811
  let linkedIDs = [];
225797
225812
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
225798
225813
  value,
@@ -225811,39 +225826,45 @@ var CacheInternal3 = class {
225811
225826
  layer.writeLink(parent2, key, linkedIDs);
225812
225827
  };
225813
225828
  if (applyUpdates && updates) {
225814
- if (key === "edges") {
225815
- const newNodeIDs = [];
225816
- for (const id of newIDs) {
225829
+ const filterIDs = (keep, insert) => {
225830
+ const existingIDs = /* @__PURE__ */ new Set();
225831
+ for (const id of keep) {
225817
225832
  if (!id) {
225818
225833
  continue;
225819
225834
  }
225820
225835
  const { value: node } = this.storage.get(id, "node");
225821
- if (typeof node !== "string") {
225836
+ if (!node) {
225822
225837
  continue;
225823
225838
  }
225824
- if (!node || !this.storage.get(node, "__typename")) {
225839
+ const nodeID = this.storage.get(node, "id");
225840
+ if (!nodeID) {
225825
225841
  continue;
225826
225842
  }
225827
- newNodeIDs.push(node);
225843
+ existingIDs.add(nodeID.value);
225828
225844
  }
225829
- oldIDs = oldIDs.filter((id) => {
225845
+ return insert.filter((id) => {
225830
225846
  if (!id) {
225831
225847
  return true;
225832
225848
  }
225833
- const { value: value2 } = this.storage.get(id, "node");
225834
- const node = value2;
225835
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
225836
- return false;
225849
+ const { value: node } = this.storage.get(id, "node");
225850
+ if (!node) {
225851
+ return true;
225837
225852
  }
225838
- return true;
225853
+ const nodeID = this.storage.get(node, "id");
225854
+ if (!nodeID) {
225855
+ return true;
225856
+ }
225857
+ return !existingIDs.has(nodeID.value);
225839
225858
  });
225840
- }
225859
+ };
225841
225860
  for (const update of applyUpdates) {
225842
225861
  if (update !== "replace" && !updates.includes(update)) {
225843
225862
  continue;
225844
225863
  }
225845
225864
  if (update === "prepend") {
225846
- linkedIDs = newIDs.concat(oldIDs);
225865
+ linkedIDs = newIDs.concat(
225866
+ filterIDs(newIDs, oldIDs)
225867
+ );
225847
225868
  if (layer?.optimistic) {
225848
225869
  action = () => {
225849
225870
  for (const id of newIDs) {
@@ -225854,7 +225875,7 @@ var CacheInternal3 = class {
225854
225875
  };
225855
225876
  }
225856
225877
  } else if (update === "append") {
225857
- linkedIDs = oldIDs.concat(newIDs);
225878
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
225858
225879
  if (layer?.optimistic) {
225859
225880
  action = () => {
225860
225881
  for (const id of newIDs) {
@@ -298576,20 +298597,21 @@ var CacheInternal4 = class {
298576
298597
  } else if (Array.isArray(value) && // make typescript happy
298577
298598
  (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
298578
298599
  let oldIDs = [...previousValue || []];
298579
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
298580
- if (!id) {
298581
- return "";
298582
- }
298583
- const { value: cursorField } = this.storage.get(id, "cursor");
298584
- if (cursorField) {
298585
- return "";
298586
- }
298587
- const { value: node } = this.storage.get(id, "node");
298588
- if (!node) {
298589
- return "";
298590
- }
298591
- return node;
298592
- });
298600
+ if (updates?.includes("append") || updates?.includes("prepend")) {
298601
+ oldIDs = oldIDs.filter((id) => {
298602
+ for (const layer2 of this.storage.data) {
298603
+ for (const operation of Object.values(layer2.operations)) {
298604
+ if (operation.fields?.[key])
298605
+ for (const listOperation of operation.fields[key]) {
298606
+ if ("id" in listOperation && listOperation.id === id) {
298607
+ return false;
298608
+ }
298609
+ }
298610
+ }
298611
+ }
298612
+ return true;
298613
+ });
298614
+ }
298593
298615
  let linkedIDs = [];
298594
298616
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
298595
298617
  value,
@@ -298608,39 +298630,45 @@ var CacheInternal4 = class {
298608
298630
  layer.writeLink(parent2, key, linkedIDs);
298609
298631
  };
298610
298632
  if (applyUpdates && updates) {
298611
- if (key === "edges") {
298612
- const newNodeIDs = [];
298613
- for (const id of newIDs) {
298633
+ const filterIDs = (keep, insert) => {
298634
+ const existingIDs = /* @__PURE__ */ new Set();
298635
+ for (const id of keep) {
298614
298636
  if (!id) {
298615
298637
  continue;
298616
298638
  }
298617
298639
  const { value: node } = this.storage.get(id, "node");
298618
- if (typeof node !== "string") {
298640
+ if (!node) {
298619
298641
  continue;
298620
298642
  }
298621
- if (!node || !this.storage.get(node, "__typename")) {
298643
+ const nodeID = this.storage.get(node, "id");
298644
+ if (!nodeID) {
298622
298645
  continue;
298623
298646
  }
298624
- newNodeIDs.push(node);
298647
+ existingIDs.add(nodeID.value);
298625
298648
  }
298626
- oldIDs = oldIDs.filter((id) => {
298649
+ return insert.filter((id) => {
298627
298650
  if (!id) {
298628
298651
  return true;
298629
298652
  }
298630
- const { value: value2 } = this.storage.get(id, "node");
298631
- const node = value2;
298632
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
298633
- return false;
298653
+ const { value: node } = this.storage.get(id, "node");
298654
+ if (!node) {
298655
+ return true;
298634
298656
  }
298635
- return true;
298657
+ const nodeID = this.storage.get(node, "id");
298658
+ if (!nodeID) {
298659
+ return true;
298660
+ }
298661
+ return !existingIDs.has(nodeID.value);
298636
298662
  });
298637
- }
298663
+ };
298638
298664
  for (const update of applyUpdates) {
298639
298665
  if (update !== "replace" && !updates.includes(update)) {
298640
298666
  continue;
298641
298667
  }
298642
298668
  if (update === "prepend") {
298643
- linkedIDs = newIDs.concat(oldIDs);
298669
+ linkedIDs = newIDs.concat(
298670
+ filterIDs(newIDs, oldIDs)
298671
+ );
298644
298672
  if (layer?.optimistic) {
298645
298673
  action = () => {
298646
298674
  for (const id of newIDs) {
@@ -298651,7 +298679,7 @@ var CacheInternal4 = class {
298651
298679
  };
298652
298680
  }
298653
298681
  } else if (update === "append") {
298654
- linkedIDs = oldIDs.concat(newIDs);
298682
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
298655
298683
  if (layer?.optimistic) {
298656
298684
  action = () => {
298657
298685
  for (const id of newIDs) {
@@ -300734,9 +300762,7 @@ import type { ${functionImportsToBring.join(
300734
300762
  ", "
300735
300763
  )} } from '${houdiniRelative}/plugins/houdini-svelte/runtime/types';` : "";
300736
300764
  typeImports = typeImports.concat(functionImports).concat(layoutTypeImports).concat(pageTypeImports).concat(componentQueryTypeImports);
300737
- const layoutParams = `${layoutQueries.length > 0 && !utilityTypes.includes("LayoutParams") ? "\ntype LayoutParams = LayoutLoadEvent['params'];" : ""}`;
300738
- const pageParams = `${pageQueries.length > 0 && !utilityTypes.includes("PageParams") ? "\ntype PageParams = PageLoadEvent['params'];" : ""}`;
300739
- utilityTypes = utilityTypes.concat(layoutParams).concat(pageParams).replaceAll(/\$types\.js/gm, "$houdini");
300765
+ utilityTypes = utilityTypes.replaceAll(/\$types\.js/gm, "$houdini");
300740
300766
  typeExports = typeExports.concat(append_loadInput([...layoutQueries, ...pageQueries])).concat(layout_append_beforeLoad).concat(page_append_beforeLoad).concat(layout_append_afterLoad).concat(page_append_afterLoad).concat(layout_append_onError).concat(page_append_onError).concat(layout_append_VariablesFunction).concat(page_append_VariablesFunction).concat(component_append_VariablesFunction).replace(
300741
300767
  //regex to append our generated stores to the existing
300742
300768
  //match all between 'LayoutData =' and ';' and combine additional types
@@ -300821,7 +300847,7 @@ function append_VariablesFunction(type, filepath, config, queries) {
300821
300847
  return `
300822
300848
  export type ${config.variableFunctionName(
300823
300849
  name
300824
- )} = VariableFunction<${type}Params, ${input_type}>;`;
300850
+ )} = VariableFunction<${type}LoadEvent, ${input_type}>;`;
300825
300851
  }).join("\n");
300826
300852
  }
300827
300853
  function append_ComponentVariablesFunction(filepath, config, queries) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "2.2.0-next.2",
3
+ "version": "2.2.0-next.4",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -30,7 +30,7 @@
30
30
  "graphql": "^16.10.0",
31
31
  "recast": "^0.23.1",
32
32
  "rollup": "^4.39.0",
33
- "houdini": "^2.0.0-next.1"
33
+ "houdini": "^2.0.0-next.2"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@sveltejs/kit": "^2.9.0",