houdini 2.0.0-next.1 → 2.0.0-next.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.
@@ -74997,20 +74997,21 @@ var CacheInternal = class {
74997
74997
  } else if (Array.isArray(value) && // make typescript happy
74998
74998
  (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
74999
74999
  let oldIDs = [...previousValue || []];
75000
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
75001
- if (!id) {
75002
- return "";
75003
- }
75004
- const { value: cursorField } = this.storage.get(id, "cursor");
75005
- if (cursorField) {
75006
- return "";
75007
- }
75008
- const { value: node } = this.storage.get(id, "node");
75009
- if (!node) {
75010
- return "";
75011
- }
75012
- return node;
75013
- });
75000
+ if (updates?.includes("append") || updates?.includes("prepend")) {
75001
+ oldIDs = oldIDs.filter((id) => {
75002
+ for (const layer2 of this.storage.data) {
75003
+ for (const operation of Object.values(layer2.operations)) {
75004
+ if (operation.fields?.[key])
75005
+ for (const listOperation of operation.fields[key]) {
75006
+ if ("id" in listOperation && listOperation.id === id) {
75007
+ return false;
75008
+ }
75009
+ }
75010
+ }
75011
+ }
75012
+ return true;
75013
+ });
75014
+ }
75014
75015
  let linkedIDs = [];
75015
75016
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
75016
75017
  value,
@@ -75029,39 +75030,45 @@ var CacheInternal = class {
75029
75030
  layer.writeLink(parent2, key, linkedIDs);
75030
75031
  };
75031
75032
  if (applyUpdates && updates) {
75032
- if (key === "edges") {
75033
- const newNodeIDs = [];
75034
- for (const id of newIDs) {
75033
+ const filterIDs = (keep, insert) => {
75034
+ const existingIDs = /* @__PURE__ */ new Set();
75035
+ for (const id of keep) {
75035
75036
  if (!id) {
75036
75037
  continue;
75037
75038
  }
75038
75039
  const { value: node } = this.storage.get(id, "node");
75039
- if (typeof node !== "string") {
75040
+ if (!node) {
75040
75041
  continue;
75041
75042
  }
75042
- if (!node || !this.storage.get(node, "__typename")) {
75043
+ const nodeID = this.storage.get(node, "id");
75044
+ if (!nodeID) {
75043
75045
  continue;
75044
75046
  }
75045
- newNodeIDs.push(node);
75047
+ existingIDs.add(nodeID.value);
75046
75048
  }
75047
- oldIDs = oldIDs.filter((id) => {
75049
+ return insert.filter((id) => {
75048
75050
  if (!id) {
75049
75051
  return true;
75050
75052
  }
75051
- const { value: value2 } = this.storage.get(id, "node");
75052
- const node = value2;
75053
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
75054
- return false;
75053
+ const { value: node } = this.storage.get(id, "node");
75054
+ if (!node) {
75055
+ return true;
75055
75056
  }
75056
- return true;
75057
+ const nodeID = this.storage.get(node, "id");
75058
+ if (!nodeID) {
75059
+ return true;
75060
+ }
75061
+ return !existingIDs.has(nodeID.value);
75057
75062
  });
75058
- }
75063
+ };
75059
75064
  for (const update of applyUpdates) {
75060
75065
  if (update !== "replace" && !updates.includes(update)) {
75061
75066
  continue;
75062
75067
  }
75063
75068
  if (update === "prepend") {
75064
- linkedIDs = newIDs.concat(oldIDs);
75069
+ linkedIDs = newIDs.concat(
75070
+ filterIDs(newIDs, oldIDs)
75071
+ );
75065
75072
  if (layer?.optimistic) {
75066
75073
  action = () => {
75067
75074
  for (const id of newIDs) {
@@ -75072,7 +75079,7 @@ var CacheInternal = class {
75072
75079
  };
75073
75080
  }
75074
75081
  } else if (update === "append") {
75075
- linkedIDs = oldIDs.concat(newIDs);
75082
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
75076
75083
  if (layer?.optimistic) {
75077
75084
  action = () => {
75078
75085
  for (const id of newIDs) {
@@ -85749,7 +85756,7 @@ function Plugin(opts = {}) {
85749
85756
  const runtimeDir = path_exports.join(config2.projectRoot, config2.runtimeDir ?? "$houdini");
85750
85757
  const isGqlFile = isGraphQLFile(file);
85751
85758
  if (!(shouldReact && (fileDependsOnHoudini(modules, runtimeDir) || isGqlFile))) {
85752
- return [];
85759
+ return modules;
85753
85760
  }
85754
85761
  if (config2.localSchema) {
85755
85762
  config2.schema = (await server.ssrLoadModule(config2.localSchemaPath)).default;
@@ -85769,7 +85776,7 @@ function Plugin(opts = {}) {
85769
85776
  timestamp
85770
85777
  };
85771
85778
  if (!artifactStats) {
85772
- return [];
85779
+ return modules;
85773
85780
  }
85774
85781
  console.log("\u{1F3A9} \u2B06\uFE0F bundle changed, triggering HMR update");
85775
85782
  const taintedModules = [];
@@ -85779,7 +85786,7 @@ function Plugin(opts = {}) {
85779
85786
  taintedModules.push(module2);
85780
85787
  }
85781
85788
  }
85782
- return taintedModules;
85789
+ return taintedModules.concat(modules);
85783
85790
  },
85784
85791
  // add watch-and-run to their vite config
85785
85792
  async config(userConfig, env2) {
@@ -74990,20 +74990,21 @@ var CacheInternal = class {
74990
74990
  } else if (Array.isArray(value) && // make typescript happy
74991
74991
  (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
74992
74992
  let oldIDs = [...previousValue || []];
74993
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
74994
- if (!id) {
74995
- return "";
74996
- }
74997
- const { value: cursorField } = this.storage.get(id, "cursor");
74998
- if (cursorField) {
74999
- return "";
75000
- }
75001
- const { value: node } = this.storage.get(id, "node");
75002
- if (!node) {
75003
- return "";
75004
- }
75005
- return node;
75006
- });
74993
+ if (updates?.includes("append") || updates?.includes("prepend")) {
74994
+ oldIDs = oldIDs.filter((id) => {
74995
+ for (const layer2 of this.storage.data) {
74996
+ for (const operation of Object.values(layer2.operations)) {
74997
+ if (operation.fields?.[key])
74998
+ for (const listOperation of operation.fields[key]) {
74999
+ if ("id" in listOperation && listOperation.id === id) {
75000
+ return false;
75001
+ }
75002
+ }
75003
+ }
75004
+ }
75005
+ return true;
75006
+ });
75007
+ }
75007
75008
  let linkedIDs = [];
75008
75009
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
75009
75010
  value,
@@ -75022,39 +75023,45 @@ var CacheInternal = class {
75022
75023
  layer.writeLink(parent2, key, linkedIDs);
75023
75024
  };
75024
75025
  if (applyUpdates && updates) {
75025
- if (key === "edges") {
75026
- const newNodeIDs = [];
75027
- for (const id of newIDs) {
75026
+ const filterIDs = (keep, insert) => {
75027
+ const existingIDs = /* @__PURE__ */ new Set();
75028
+ for (const id of keep) {
75028
75029
  if (!id) {
75029
75030
  continue;
75030
75031
  }
75031
75032
  const { value: node } = this.storage.get(id, "node");
75032
- if (typeof node !== "string") {
75033
+ if (!node) {
75033
75034
  continue;
75034
75035
  }
75035
- if (!node || !this.storage.get(node, "__typename")) {
75036
+ const nodeID = this.storage.get(node, "id");
75037
+ if (!nodeID) {
75036
75038
  continue;
75037
75039
  }
75038
- newNodeIDs.push(node);
75040
+ existingIDs.add(nodeID.value);
75039
75041
  }
75040
- oldIDs = oldIDs.filter((id) => {
75042
+ return insert.filter((id) => {
75041
75043
  if (!id) {
75042
75044
  return true;
75043
75045
  }
75044
- const { value: value2 } = this.storage.get(id, "node");
75045
- const node = value2;
75046
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
75047
- return false;
75046
+ const { value: node } = this.storage.get(id, "node");
75047
+ if (!node) {
75048
+ return true;
75048
75049
  }
75049
- return true;
75050
+ const nodeID = this.storage.get(node, "id");
75051
+ if (!nodeID) {
75052
+ return true;
75053
+ }
75054
+ return !existingIDs.has(nodeID.value);
75050
75055
  });
75051
- }
75056
+ };
75052
75057
  for (const update of applyUpdates) {
75053
75058
  if (update !== "replace" && !updates.includes(update)) {
75054
75059
  continue;
75055
75060
  }
75056
75061
  if (update === "prepend") {
75057
- linkedIDs = newIDs.concat(oldIDs);
75062
+ linkedIDs = newIDs.concat(
75063
+ filterIDs(newIDs, oldIDs)
75064
+ );
75058
75065
  if (layer?.optimistic) {
75059
75066
  action = () => {
75060
75067
  for (const id of newIDs) {
@@ -75065,7 +75072,7 @@ var CacheInternal = class {
75065
75072
  };
75066
75073
  }
75067
75074
  } else if (update === "append") {
75068
- linkedIDs = oldIDs.concat(newIDs);
75075
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
75069
75076
  if (layer?.optimistic) {
75070
75077
  action = () => {
75071
75078
  for (const id of newIDs) {
@@ -85741,7 +85748,7 @@ function Plugin(opts = {}) {
85741
85748
  const runtimeDir = path_exports.join(config2.projectRoot, config2.runtimeDir ?? "$houdini");
85742
85749
  const isGqlFile = isGraphQLFile(file);
85743
85750
  if (!(shouldReact && (fileDependsOnHoudini(modules, runtimeDir) || isGqlFile))) {
85744
- return [];
85751
+ return modules;
85745
85752
  }
85746
85753
  if (config2.localSchema) {
85747
85754
  config2.schema = (await server.ssrLoadModule(config2.localSchemaPath)).default;
@@ -85761,7 +85768,7 @@ function Plugin(opts = {}) {
85761
85768
  timestamp
85762
85769
  };
85763
85770
  if (!artifactStats) {
85764
- return [];
85771
+ return modules;
85765
85772
  }
85766
85773
  console.log("\u{1F3A9} \u2B06\uFE0F bundle changed, triggering HMR update");
85767
85774
  const taintedModules = [];
@@ -85771,7 +85778,7 @@ function Plugin(opts = {}) {
85771
85778
  taintedModules.push(module);
85772
85779
  }
85773
85780
  }
85774
- return taintedModules;
85781
+ return taintedModules.concat(modules);
85775
85782
  },
85776
85783
  // add watch-and-run to their vite config
85777
85784
  async config(userConfig, env2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.3",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",