houdini 2.0.1 → 2.0.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.
package/build/cmd/init.js CHANGED
@@ -472,7 +472,7 @@ async function packageJSON(targetPath, frameworkInfo) {
472
472
  }
473
473
  packageJSON2.devDependencies = {
474
474
  ...packageJSON2.devDependencies,
475
- houdini: "^2.0.1"
475
+ houdini: "^2.0.3"
476
476
  };
477
477
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
478
478
  packageJSON2.devDependencies = {
@@ -29,6 +29,23 @@ export type ConfigFile = {
29
29
  * An object describing custom scalars for your project. For more information: https://www.houdinigraphql.com/api/config#custom-scalars
30
30
  */
31
31
  scalars?: ScalarMap;
32
+ /**
33
+ * Client-side router behavior (houdini-react).
34
+ */
35
+ router?: {
36
+ /**
37
+ * How long (ms) a navigation transition may stay pending before the route's
38
+ * @loading state is shown. Fast navigations resolve first and never show it.
39
+ * @default 200
40
+ */
41
+ loadingDelay?: number;
42
+ /**
43
+ * Once the @loading state is shown, keep it visible at least this long (ms) so a
44
+ * response that lands just after `loadingDelay` doesn't cause a skeleton flicker.
45
+ * @default 400
46
+ */
47
+ minDuration?: number;
48
+ };
32
49
  /**
33
50
  * A path that the generator will use to write schema.graphql and documents.gql files containing all of the internal fragment and directive definitions used in the project.
34
51
  */
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
package/build/vite/hmr.js CHANGED
@@ -11,6 +11,51 @@ function document_hmr(ctx) {
11
11
  function isManifestFile(filepath) {
12
12
  return (filepath.split("/").pop() ?? "").startsWith("+");
13
13
  }
14
+ function flushClientUpdates(server, updated_modules) {
15
+ const seenUrls = /* @__PURE__ */ new Set();
16
+ const artifactDir = `${generatedDir}/artifacts/`;
17
+ const changed_artifacts = /* @__PURE__ */ new Map();
18
+ const updates = updated_modules.flatMap((module_path) => {
19
+ const resolvedPath = module_path.startsWith("$houdini/") ? module_path.replace("$houdini", generatedDir) : module_path;
20
+ const mods = [...server.moduleGraph.getModulesByFile(resolvedPath) ?? []];
21
+ return mods.flatMap((mod) => {
22
+ if (seenUrls.has(mod.url)) return [];
23
+ seenUrls.add(mod.url);
24
+ server.moduleGraph.invalidateModule(mod);
25
+ if (resolvedPath.startsWith(artifactDir)) {
26
+ const filename = path.basename(resolvedPath);
27
+ const dot = filename.lastIndexOf(".");
28
+ const name = dot === -1 ? filename : filename.slice(0, dot);
29
+ if (!changed_artifacts.has(name)) {
30
+ changed_artifacts.set(name, mod.url);
31
+ }
32
+ }
33
+ return [
34
+ {
35
+ type: "js-update",
36
+ path: mod.url,
37
+ acceptedPath: mod.url,
38
+ timestamp: Date.now()
39
+ }
40
+ ];
41
+ });
42
+ });
43
+ if (updates.length > 0) {
44
+ server.ws.send({ type: "update", updates });
45
+ }
46
+ if (changed_artifacts.size > 0) {
47
+ server.ws.send({
48
+ type: "custom",
49
+ event: "houdini:artifact-update",
50
+ data: {
51
+ artifacts: [...changed_artifacts.entries()].map(([name, url]) => ({
52
+ name,
53
+ url
54
+ }))
55
+ }
56
+ });
57
+ }
58
+ }
14
59
  return {
15
60
  name: "houdini",
16
61
  enforce: "pre",
@@ -91,6 +136,9 @@ function document_hmr(ctx) {
91
136
  }
92
137
  }
93
138
  debounceHmr.queueUpdate(opts, preReadContent, batchCallback);
139
+ if (opts.file.endsWith(".gql") || opts.file.endsWith(".graphql")) {
140
+ return opts.modules.filter((mod) => mod.type === "js");
141
+ }
94
142
  async function batchCallback(files, deletedFiles, task_id) {
95
143
  if (!compiler) return;
96
144
  await compiler.pipeline_lock(async () => {
@@ -153,29 +201,7 @@ function document_hmr(ctx) {
153
201
  ...Object.values(results2.GenerateDocuments || {}).flat(),
154
202
  ...Object.values(results2.GenerateRuntime || {}).flat()
155
203
  ];
156
- const seenUrls2 = /* @__PURE__ */ new Set();
157
- const updates2 = updated_modules2.flatMap((module_path) => {
158
- const resolvedPath = module_path.startsWith("$houdini/") ? module_path.replace("$houdini", generatedDir) : module_path;
159
- const mods = [
160
- ...server.moduleGraph.getModulesByFile(resolvedPath) ?? []
161
- ];
162
- return mods.flatMap((mod) => {
163
- if (seenUrls2.has(mod.url)) return [];
164
- seenUrls2.add(mod.url);
165
- server.moduleGraph.invalidateModule(mod);
166
- return [
167
- {
168
- type: "js-update",
169
- path: mod.url,
170
- acceptedPath: mod.url,
171
- timestamp: Date.now()
172
- }
173
- ];
174
- });
175
- });
176
- if (updates2.length > 0) {
177
- server.ws.send({ type: "update", updates: updates2 });
178
- }
204
+ flushClientUpdates(server, updated_modules2);
179
205
  } catch (err) {
180
206
  console.error("[houdini] pipeline error after deletion:", err);
181
207
  }
@@ -302,27 +328,7 @@ function document_hmr(ctx) {
302
328
  ...Object.values(results.GenerateDocuments || {}).flat(),
303
329
  ...Object.values(results.GenerateRuntime || {}).flat()
304
330
  ];
305
- const seenUrls = /* @__PURE__ */ new Set();
306
- const updates = updated_modules.flatMap((module_path) => {
307
- const resolvedPath = module_path.startsWith("$houdini/") ? module_path.replace("$houdini", generatedDir) : module_path;
308
- const mods = [...server.moduleGraph.getModulesByFile(resolvedPath) ?? []];
309
- return mods.flatMap((mod) => {
310
- if (seenUrls.has(mod.url)) return [];
311
- seenUrls.add(mod.url);
312
- server.moduleGraph.invalidateModule(mod);
313
- return [
314
- {
315
- type: "js-update",
316
- path: mod.url,
317
- acceptedPath: mod.url,
318
- timestamp: Date.now()
319
- }
320
- ];
321
- });
322
- });
323
- if (updates.length > 0) {
324
- server.ws.send({ type: "update", updates });
325
- }
331
+ flushClientUpdates(server, updated_modules);
326
332
  });
327
333
  }
328
334
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
@@ -52,7 +52,7 @@
52
52
  "recast": "^0.23.11",
53
53
  "sql.js": "^1.14.1",
54
54
  "ws": "^8.21.0",
55
- "houdini-core": "^2.0.1"
55
+ "houdini-core": "^2.0.2"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "graphql": ">=16",