houdini-react 2.0.0-next.1 → 2.0.0-next.10

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.
@@ -85518,7 +85518,8 @@ async function load_manifest(args) {
85518
85518
  const name = child.isDirectory() ? child.name : parse32(child.name).name;
85519
85519
  if (name === "+schema") {
85520
85520
  manifest2.local_schema = true;
85521
- } else if (name === "+yoga") {
85521
+ }
85522
+ if (name === "+yoga") {
85522
85523
  manifest2.local_yoga = true;
85523
85524
  }
85524
85525
  }
@@ -87469,20 +87470,21 @@ var CacheInternal = class {
87469
87470
  } else if (Array.isArray(value) && // make typescript happy
87470
87471
  (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
87471
87472
  let oldIDs = [...previousValue || []];
87472
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
87473
- if (!id) {
87474
- return "";
87475
- }
87476
- const { value: cursorField } = this.storage.get(id, "cursor");
87477
- if (cursorField) {
87478
- return "";
87479
- }
87480
- const { value: node } = this.storage.get(id, "node");
87481
- if (!node) {
87482
- return "";
87483
- }
87484
- return node;
87485
- });
87473
+ if (updates?.includes("append") || updates?.includes("prepend")) {
87474
+ oldIDs = oldIDs.filter((id) => {
87475
+ for (const layer2 of this.storage.data) {
87476
+ for (const operation of Object.values(layer2.operations)) {
87477
+ if (operation.fields?.[key])
87478
+ for (const listOperation of operation.fields[key]) {
87479
+ if ("id" in listOperation && listOperation.id === id) {
87480
+ return false;
87481
+ }
87482
+ }
87483
+ }
87484
+ }
87485
+ return true;
87486
+ });
87487
+ }
87486
87488
  let linkedIDs = [];
87487
87489
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
87488
87490
  value,
@@ -87501,39 +87503,45 @@ var CacheInternal = class {
87501
87503
  layer.writeLink(parent, key, linkedIDs);
87502
87504
  };
87503
87505
  if (applyUpdates && updates) {
87504
- if (key === "edges") {
87505
- const newNodeIDs = [];
87506
- for (const id of newIDs) {
87506
+ const filterIDs = (keep, insert) => {
87507
+ const existingIDs = /* @__PURE__ */ new Set();
87508
+ for (const id of keep) {
87507
87509
  if (!id) {
87508
87510
  continue;
87509
87511
  }
87510
87512
  const { value: node } = this.storage.get(id, "node");
87511
- if (typeof node !== "string") {
87513
+ if (!node) {
87512
87514
  continue;
87513
87515
  }
87514
- if (!node || !this.storage.get(node, "__typename")) {
87516
+ const nodeID = this.storage.get(node, "id");
87517
+ if (!nodeID) {
87515
87518
  continue;
87516
87519
  }
87517
- newNodeIDs.push(node);
87520
+ existingIDs.add(nodeID.value);
87518
87521
  }
87519
- oldIDs = oldIDs.filter((id) => {
87522
+ return insert.filter((id) => {
87520
87523
  if (!id) {
87521
87524
  return true;
87522
87525
  }
87523
- const { value: value2 } = this.storage.get(id, "node");
87524
- const node = value2;
87525
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
87526
- return false;
87526
+ const { value: node } = this.storage.get(id, "node");
87527
+ if (!node) {
87528
+ return true;
87527
87529
  }
87528
- return true;
87530
+ const nodeID = this.storage.get(node, "id");
87531
+ if (!nodeID) {
87532
+ return true;
87533
+ }
87534
+ return !existingIDs.has(nodeID.value);
87529
87535
  });
87530
- }
87536
+ };
87531
87537
  for (const update of applyUpdates) {
87532
87538
  if (update !== "replace" && !updates.includes(update)) {
87533
87539
  continue;
87534
87540
  }
87535
87541
  if (update === "prepend") {
87536
- linkedIDs = newIDs.concat(oldIDs);
87542
+ linkedIDs = newIDs.concat(
87543
+ filterIDs(newIDs, oldIDs)
87544
+ );
87537
87545
  if (layer?.optimistic) {
87538
87546
  action = () => {
87539
87547
  for (const id of newIDs) {
@@ -87544,7 +87552,7 @@ var CacheInternal = class {
87544
87552
  };
87545
87553
  }
87546
87554
  } else if (update === "append") {
87547
- linkedIDs = oldIDs.concat(newIDs);
87555
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
87548
87556
  if (layer?.optimistic) {
87549
87557
  action = () => {
87550
87558
  for (const id of newIDs) {
@@ -88183,10 +88191,10 @@ var AST3 = recast2.types.builders;
88183
88191
  function unwrappedTsTypeReference(config, filepath, missingScalars, {
88184
88192
  type,
88185
88193
  wrappers
88186
- }, body) {
88194
+ }, body, input) {
88187
88195
  let result;
88188
88196
  if (graphql6.isScalarType(type)) {
88189
- result = scalarPropertyValue(config, filepath, missingScalars, type, body, null);
88197
+ result = scalarPropertyValue(config, filepath, missingScalars, type, body, null, input);
88190
88198
  } else if (graphql6.isEnumType(type)) {
88191
88199
  result = enumReference(config, body, type.name);
88192
88200
  } else {
@@ -88223,7 +88231,7 @@ function nullableField(inner, input = false) {
88223
88231
  }
88224
88232
  return AST3.tsUnionType(members);
88225
88233
  }
88226
- function scalarPropertyValue(config, filepath, missingScalars, target, body, field) {
88234
+ function scalarPropertyValue(config, filepath, missingScalars, target, body, field, input) {
88227
88235
  if (config.configFile.features?.componentFields && target.name === config.componentScalar) {
88228
88236
  if (!field) {
88229
88237
  return AST3.tsNeverKeyword();
@@ -88282,6 +88290,9 @@ function scalarPropertyValue(config, filepath, missingScalars, target, body, fie
88282
88290
  return AST3.tsBooleanKeyword();
88283
88291
  }
88284
88292
  case "ID": {
88293
+ if (input) {
88294
+ return AST3.tsUnionType([AST3.tsStringKeyword(), AST3.tsNumberKeyword()]);
88295
+ }
88285
88296
  return AST3.tsStringKeyword();
88286
88297
  }
88287
88298
  default: {
@@ -88292,7 +88303,8 @@ function scalarPropertyValue(config, filepath, missingScalars, target, body, fie
88292
88303
  missingScalars,
88293
88304
  target.ofType,
88294
88305
  body,
88295
- field
88306
+ field,
88307
+ input
88296
88308
  );
88297
88309
  }
88298
88310
  if (config.scalars?.[target.name]) {
@@ -89127,7 +89139,7 @@ export function createServerAdapter(options) {
89127
89139
  }).join("\n")}
89128
89140
 
89129
89141
  ${manifest2.local_schema ? `import schema from '../../../../../src/api/+schema'` : " const schema = null"}
89130
- ${manifest2.local_yoga ? `import yoga from '.../../../../../src/api/+yoga'` : " const yoga = null"}
89142
+ ${manifest2.local_yoga ? `import yoga from '../../../../../src/api/+yoga'` : " const yoga = null"}
89131
89143
 
89132
89144
  export const endpoint = ${JSON.stringify(localApiEndpoint(config.configFile))}
89133
89145
 
@@ -89245,7 +89257,8 @@ function paramsType(config, params) {
89245
89257
  type: config.schema.getType(typeInfo.type),
89246
89258
  wrappers: typeInfo.wrappers
89247
89259
  },
89248
- []
89260
+ [],
89261
+ false
89249
89262
  )
89250
89263
  ).code;
89251
89264
  }
@@ -89543,11 +89556,11 @@ var vite_default = {
89543
89556
  }
89544
89557
  return id.substring(id.indexOf("virtual:houdini"));
89545
89558
  },
89546
- async closeBundle(config) {
89559
+ async buildEnd(_, config) {
89547
89560
  if (isSecondaryBuild() || viteEnv.mode !== "production" || devServer) {
89548
89561
  return;
89549
89562
  }
89550
- if (config.adapter?.disableServer) {
89563
+ if (!config || config.adapter?.disableServer) {
89551
89564
  return;
89552
89565
  }
89553
89566
  console.log("\u{1F3A9} Generating Server Assets...");
@@ -90041,13 +90054,7 @@ function addOverload({
90041
90054
  }
90042
90055
  const docImports = documents.filter((doc) => doc.generateStore).map(
90043
90056
  (doc) => `
90044
- import type { ${importIdentifiers(doc).join(", ")} } from '${import_node_path3.default.relative(
90045
- import_node_path3.default.relative(
90046
- config.projectRoot,
90047
- import_node_path3.default.join(config.pluginRuntimeDirectory("houdini-react"), "hooks")
90048
- ),
90049
- config.artifactImportPath(doc.name)
90050
- )}'
90057
+ import type { ${importIdentifiers(doc).join(", ")} } from '$houdini/artifacts/${doc.name}'
90051
90058
  `
90052
90059
  ).join("\n");
90053
90060
  return `${docImports}
@@ -85514,7 +85514,8 @@ async function load_manifest(args) {
85514
85514
  const name = child.isDirectory() ? child.name : parse32(child.name).name;
85515
85515
  if (name === "+schema") {
85516
85516
  manifest2.local_schema = true;
85517
- } else if (name === "+yoga") {
85517
+ }
85518
+ if (name === "+yoga") {
85518
85519
  manifest2.local_yoga = true;
85519
85520
  }
85520
85521
  }
@@ -87465,20 +87466,21 @@ var CacheInternal = class {
87465
87466
  } else if (Array.isArray(value) && // make typescript happy
87466
87467
  (typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
87467
87468
  let oldIDs = [...previousValue || []];
87468
- const emptyEdges = !updates ? [] : oldIDs.map((id) => {
87469
- if (!id) {
87470
- return "";
87471
- }
87472
- const { value: cursorField } = this.storage.get(id, "cursor");
87473
- if (cursorField) {
87474
- return "";
87475
- }
87476
- const { value: node } = this.storage.get(id, "node");
87477
- if (!node) {
87478
- return "";
87479
- }
87480
- return node;
87481
- });
87469
+ if (updates?.includes("append") || updates?.includes("prepend")) {
87470
+ oldIDs = oldIDs.filter((id) => {
87471
+ for (const layer2 of this.storage.data) {
87472
+ for (const operation of Object.values(layer2.operations)) {
87473
+ if (operation.fields?.[key])
87474
+ for (const listOperation of operation.fields[key]) {
87475
+ if ("id" in listOperation && listOperation.id === id) {
87476
+ return false;
87477
+ }
87478
+ }
87479
+ }
87480
+ }
87481
+ return true;
87482
+ });
87483
+ }
87482
87484
  let linkedIDs = [];
87483
87485
  const { newIDs, nestedIDs } = this.extractNestedListIDs({
87484
87486
  value,
@@ -87497,39 +87499,45 @@ var CacheInternal = class {
87497
87499
  layer.writeLink(parent, key, linkedIDs);
87498
87500
  };
87499
87501
  if (applyUpdates && updates) {
87500
- if (key === "edges") {
87501
- const newNodeIDs = [];
87502
- for (const id of newIDs) {
87502
+ const filterIDs = (keep, insert) => {
87503
+ const existingIDs = /* @__PURE__ */ new Set();
87504
+ for (const id of keep) {
87503
87505
  if (!id) {
87504
87506
  continue;
87505
87507
  }
87506
87508
  const { value: node } = this.storage.get(id, "node");
87507
- if (typeof node !== "string") {
87509
+ if (!node) {
87508
87510
  continue;
87509
87511
  }
87510
- if (!node || !this.storage.get(node, "__typename")) {
87512
+ const nodeID = this.storage.get(node, "id");
87513
+ if (!nodeID) {
87511
87514
  continue;
87512
87515
  }
87513
- newNodeIDs.push(node);
87516
+ existingIDs.add(nodeID.value);
87514
87517
  }
87515
- oldIDs = oldIDs.filter((id) => {
87518
+ return insert.filter((id) => {
87516
87519
  if (!id) {
87517
87520
  return true;
87518
87521
  }
87519
- const { value: value2 } = this.storage.get(id, "node");
87520
- const node = value2;
87521
- if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
87522
- return false;
87522
+ const { value: node } = this.storage.get(id, "node");
87523
+ if (!node) {
87524
+ return true;
87523
87525
  }
87524
- return true;
87526
+ const nodeID = this.storage.get(node, "id");
87527
+ if (!nodeID) {
87528
+ return true;
87529
+ }
87530
+ return !existingIDs.has(nodeID.value);
87525
87531
  });
87526
- }
87532
+ };
87527
87533
  for (const update of applyUpdates) {
87528
87534
  if (update !== "replace" && !updates.includes(update)) {
87529
87535
  continue;
87530
87536
  }
87531
87537
  if (update === "prepend") {
87532
- linkedIDs = newIDs.concat(oldIDs);
87538
+ linkedIDs = newIDs.concat(
87539
+ filterIDs(newIDs, oldIDs)
87540
+ );
87533
87541
  if (layer?.optimistic) {
87534
87542
  action = () => {
87535
87543
  for (const id of newIDs) {
@@ -87540,7 +87548,7 @@ var CacheInternal = class {
87540
87548
  };
87541
87549
  }
87542
87550
  } else if (update === "append") {
87543
- linkedIDs = oldIDs.concat(newIDs);
87551
+ linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
87544
87552
  if (layer?.optimistic) {
87545
87553
  action = () => {
87546
87554
  for (const id of newIDs) {
@@ -88179,10 +88187,10 @@ var AST3 = recast2.types.builders;
88179
88187
  function unwrappedTsTypeReference(config, filepath, missingScalars, {
88180
88188
  type,
88181
88189
  wrappers
88182
- }, body) {
88190
+ }, body, input) {
88183
88191
  let result;
88184
88192
  if (graphql6.isScalarType(type)) {
88185
- result = scalarPropertyValue(config, filepath, missingScalars, type, body, null);
88193
+ result = scalarPropertyValue(config, filepath, missingScalars, type, body, null, input);
88186
88194
  } else if (graphql6.isEnumType(type)) {
88187
88195
  result = enumReference(config, body, type.name);
88188
88196
  } else {
@@ -88219,7 +88227,7 @@ function nullableField(inner, input = false) {
88219
88227
  }
88220
88228
  return AST3.tsUnionType(members);
88221
88229
  }
88222
- function scalarPropertyValue(config, filepath, missingScalars, target, body, field) {
88230
+ function scalarPropertyValue(config, filepath, missingScalars, target, body, field, input) {
88223
88231
  if (config.configFile.features?.componentFields && target.name === config.componentScalar) {
88224
88232
  if (!field) {
88225
88233
  return AST3.tsNeverKeyword();
@@ -88278,6 +88286,9 @@ function scalarPropertyValue(config, filepath, missingScalars, target, body, fie
88278
88286
  return AST3.tsBooleanKeyword();
88279
88287
  }
88280
88288
  case "ID": {
88289
+ if (input) {
88290
+ return AST3.tsUnionType([AST3.tsStringKeyword(), AST3.tsNumberKeyword()]);
88291
+ }
88281
88292
  return AST3.tsStringKeyword();
88282
88293
  }
88283
88294
  default: {
@@ -88288,7 +88299,8 @@ function scalarPropertyValue(config, filepath, missingScalars, target, body, fie
88288
88299
  missingScalars,
88289
88300
  target.ofType,
88290
88301
  body,
88291
- field
88302
+ field,
88303
+ input
88292
88304
  );
88293
88305
  }
88294
88306
  if (config.scalars?.[target.name]) {
@@ -89123,7 +89135,7 @@ export function createServerAdapter(options) {
89123
89135
  }).join("\n")}
89124
89136
 
89125
89137
  ${manifest2.local_schema ? `import schema from '../../../../../src/api/+schema'` : " const schema = null"}
89126
- ${manifest2.local_yoga ? `import yoga from '.../../../../../src/api/+yoga'` : " const yoga = null"}
89138
+ ${manifest2.local_yoga ? `import yoga from '../../../../../src/api/+yoga'` : " const yoga = null"}
89127
89139
 
89128
89140
  export const endpoint = ${JSON.stringify(localApiEndpoint(config.configFile))}
89129
89141
 
@@ -89241,7 +89253,8 @@ function paramsType(config, params) {
89241
89253
  type: config.schema.getType(typeInfo.type),
89242
89254
  wrappers: typeInfo.wrappers
89243
89255
  },
89244
- []
89256
+ [],
89257
+ false
89245
89258
  )
89246
89259
  ).code;
89247
89260
  }
@@ -89539,11 +89552,11 @@ var vite_default = {
89539
89552
  }
89540
89553
  return id.substring(id.indexOf("virtual:houdini"));
89541
89554
  },
89542
- async closeBundle(config) {
89555
+ async buildEnd(_, config) {
89543
89556
  if (isSecondaryBuild() || viteEnv.mode !== "production" || devServer) {
89544
89557
  return;
89545
89558
  }
89546
- if (config.adapter?.disableServer) {
89559
+ if (!config || config.adapter?.disableServer) {
89547
89560
  return;
89548
89561
  }
89549
89562
  console.log("\u{1F3A9} Generating Server Assets...");
@@ -90037,13 +90050,7 @@ function addOverload({
90037
90050
  }
90038
90051
  const docImports = documents.filter((doc) => doc.generateStore).map(
90039
90052
  (doc) => `
90040
- import type { ${importIdentifiers(doc).join(", ")} } from '${path3.relative(
90041
- path3.relative(
90042
- config.projectRoot,
90043
- path3.join(config.pluginRuntimeDirectory("houdini-react"), "hooks")
90044
- ),
90045
- config.artifactImportPath(doc.name)
90046
- )}'
90053
+ import type { ${importIdentifiers(doc).join(", ")} } from '$houdini/artifacts/${doc.name}'
90047
90054
  `
90048
90055
  ).join("\n");
90049
90056
  return `${docImports}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-react",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.10",
4
4
  "description": "The React plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -42,7 +42,7 @@
42
42
  "recast": "^0.23.1",
43
43
  "rollup": "^4.39.0",
44
44
  "use-deep-compare-effect": "^1.8.1",
45
- "houdini": "^2.0.0-next.1"
45
+ "houdini": "^2.0.0-next.8"
46
46
  },
47
47
  "files": [
48
48
  "build"