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

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.
@@ -85495,7 +85495,7 @@ async function load_manifest(args) {
85495
85495
  layout_queries: {},
85496
85496
  artifacts: [],
85497
85497
  local_schema: false,
85498
- local_yoga: false
85498
+ local_server: false
85499
85499
  },
85500
85500
  queries: [],
85501
85501
  layouts: [],
@@ -85518,8 +85518,9 @@ 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") {
85522
- manifest2.local_yoga = true;
85521
+ }
85522
+ if (name === "+server") {
85523
+ manifest2.local_server = true;
85523
85524
  }
85524
85525
  }
85525
85526
  } catch {
@@ -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]) {
@@ -89027,7 +89039,7 @@ export default (props) => (
89027
89039
  `;
89028
89040
  let renderer = `
89029
89041
  import { Cache } from '$houdini/runtime/cache/cache'
89030
- import { serverAdapterFactory, _serverHandler } from '$houdini/runtime/router/server'
89042
+ import { serverAdapterFactory } from '$houdini/runtime/router/server'
89031
89043
  import { HoudiniClient } from '$houdini/runtime/client'
89032
89044
  import { renderToStream } from 'houdini-react/server'
89033
89045
  import React from 'react'
@@ -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_server ? `import server from '../../../../../src/api/+server'` : " const server = null"}
89131
89143
 
89132
89144
  export const endpoint = ${JSON.stringify(localApiEndpoint(config.configFile))}
89133
89145
 
@@ -89141,7 +89153,7 @@ export function createServerAdapter(options) {
89141
89153
  export function createServerAdapter(options) {
89142
89154
  return createAdapter({
89143
89155
  schema,
89144
- yoga,
89156
+ server,
89145
89157
  componentCache,
89146
89158
  graphqlEndpoint: endpoint,
89147
89159
  ...options,
@@ -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
  }
@@ -89447,7 +89460,10 @@ async function transformFile(page) {
89447
89460
  ensureImports({
89448
89461
  config: page.config,
89449
89462
  body: script.body,
89450
- sourceModule: path_exports.relative(page.config.projectRoot, entryPointPath),
89463
+ sourceModule: `$houdini/${path_exports.relative(
89464
+ page.config.runtimeDir,
89465
+ entryPointPath
89466
+ )}`,
89451
89467
  // we just want the side effects of the import so we don't need to assign it to a variable
89452
89468
  import: null
89453
89469
  });
@@ -89481,7 +89497,7 @@ var vite_default = {
89481
89497
  layout_queries: {},
89482
89498
  artifacts: [],
89483
89499
  local_schema: false,
89484
- local_yoga: false,
89500
+ local_server: false,
89485
89501
  component_fields: {}
89486
89502
  };
89487
89503
  }
@@ -89543,11 +89559,11 @@ var vite_default = {
89543
89559
  }
89544
89560
  return id.substring(id.indexOf("virtual:houdini"));
89545
89561
  },
89546
- async closeBundle(config) {
89562
+ async buildEnd(_, config) {
89547
89563
  if (isSecondaryBuild() || viteEnv.mode !== "production" || devServer) {
89548
89564
  return;
89549
89565
  }
89550
- if (config.adapter?.disableServer) {
89566
+ if (!config || config.adapter?.disableServer) {
89551
89567
  return;
89552
89568
  }
89553
89569
  console.log("\u{1F3A9} Generating Server Assets...");
@@ -90006,7 +90022,7 @@ export function useFragmentHandle(reference: { readonly "${fragmentKey}": { ${do
90006
90022
  const variableName = `${doc.name}$artifact`;
90007
90023
  ensure_import({
90008
90024
  identifier: variableName,
90009
- module: config.artifactImportPath(doc.name).replace(/\$houdini/g, "..")
90025
+ module: config.artifactImportPath(doc.name)
90010
90026
  });
90011
90027
  return `{ artifact: ${variableName} }`;
90012
90028
  }
@@ -90041,13 +90057,7 @@ function addOverload({
90041
90057
  }
90042
90058
  const docImports = documents.filter((doc) => doc.generateStore).map(
90043
90059
  (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
- )}'
90060
+ import type { ${importIdentifiers(doc).join(", ")} } from '$houdini/artifacts/${doc.name}'
90051
90061
  `
90052
90062
  ).join("\n");
90053
90063
  return `${docImports}
@@ -85491,7 +85491,7 @@ async function load_manifest(args) {
85491
85491
  layout_queries: {},
85492
85492
  artifacts: [],
85493
85493
  local_schema: false,
85494
- local_yoga: false
85494
+ local_server: false
85495
85495
  },
85496
85496
  queries: [],
85497
85497
  layouts: [],
@@ -85514,8 +85514,9 @@ 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") {
85518
- manifest2.local_yoga = true;
85517
+ }
85518
+ if (name === "+server") {
85519
+ manifest2.local_server = true;
85519
85520
  }
85520
85521
  }
85521
85522
  } catch {
@@ -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]) {
@@ -89023,7 +89035,7 @@ export default (props) => (
89023
89035
  `;
89024
89036
  let renderer = `
89025
89037
  import { Cache } from '$houdini/runtime/cache/cache'
89026
- import { serverAdapterFactory, _serverHandler } from '$houdini/runtime/router/server'
89038
+ import { serverAdapterFactory } from '$houdini/runtime/router/server'
89027
89039
  import { HoudiniClient } from '$houdini/runtime/client'
89028
89040
  import { renderToStream } from 'houdini-react/server'
89029
89041
  import React from 'react'
@@ -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_server ? `import server from '../../../../../src/api/+server'` : " const server = null"}
89127
89139
 
89128
89140
  export const endpoint = ${JSON.stringify(localApiEndpoint(config.configFile))}
89129
89141
 
@@ -89137,7 +89149,7 @@ export function createServerAdapter(options) {
89137
89149
  export function createServerAdapter(options) {
89138
89150
  return createAdapter({
89139
89151
  schema,
89140
- yoga,
89152
+ server,
89141
89153
  componentCache,
89142
89154
  graphqlEndpoint: endpoint,
89143
89155
  ...options,
@@ -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
  }
@@ -89443,7 +89456,10 @@ async function transformFile(page) {
89443
89456
  ensureImports({
89444
89457
  config: page.config,
89445
89458
  body: script.body,
89446
- sourceModule: path_exports.relative(page.config.projectRoot, entryPointPath),
89459
+ sourceModule: `$houdini/${path_exports.relative(
89460
+ page.config.runtimeDir,
89461
+ entryPointPath
89462
+ )}`,
89447
89463
  // we just want the side effects of the import so we don't need to assign it to a variable
89448
89464
  import: null
89449
89465
  });
@@ -89477,7 +89493,7 @@ var vite_default = {
89477
89493
  layout_queries: {},
89478
89494
  artifacts: [],
89479
89495
  local_schema: false,
89480
- local_yoga: false,
89496
+ local_server: false,
89481
89497
  component_fields: {}
89482
89498
  };
89483
89499
  }
@@ -89539,11 +89555,11 @@ var vite_default = {
89539
89555
  }
89540
89556
  return id.substring(id.indexOf("virtual:houdini"));
89541
89557
  },
89542
- async closeBundle(config) {
89558
+ async buildEnd(_, config) {
89543
89559
  if (isSecondaryBuild() || viteEnv.mode !== "production" || devServer) {
89544
89560
  return;
89545
89561
  }
89546
- if (config.adapter?.disableServer) {
89562
+ if (!config || config.adapter?.disableServer) {
89547
89563
  return;
89548
89564
  }
89549
89565
  console.log("\u{1F3A9} Generating Server Assets...");
@@ -90002,7 +90018,7 @@ export function useFragmentHandle(reference: { readonly "${fragmentKey}": { ${do
90002
90018
  const variableName = `${doc.name}$artifact`;
90003
90019
  ensure_import({
90004
90020
  identifier: variableName,
90005
- module: config.artifactImportPath(doc.name).replace(/\$houdini/g, "..")
90021
+ module: config.artifactImportPath(doc.name)
90006
90022
  });
90007
90023
  return `{ artifact: ${variableName} }`;
90008
90024
  }
@@ -90037,13 +90053,7 @@ function addOverload({
90037
90053
  }
90038
90054
  const docImports = documents.filter((doc) => doc.generateStore).map(
90039
90055
  (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
- )}'
90056
+ import type { ${importIdentifiers(doc).join(", ")} } from '$houdini/artifacts/${doc.name}'
90047
90057
  `
90048
90058
  ).join("\n");
90049
90059
  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.11",
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.9"
46
46
  },
47
47
  "files": [
48
48
  "build"