@nifrajs/web 2.2.0 → 2.4.0

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.
Files changed (179) hide show
  1. package/README.md +3 -3
  2. package/dist/build-vite.d.ts +4 -4
  3. package/dist/build-vite.d.ts.map +1 -1
  4. package/dist/build-vite.js +20 -74
  5. package/dist/build-vite.js.map +1 -1
  6. package/dist/build.d.ts +64 -42
  7. package/dist/build.d.ts.map +1 -1
  8. package/dist/build.js +100 -78
  9. package/dist/build.js.map +1 -1
  10. package/dist/bun-dev-entry.d.ts +1 -1
  11. package/dist/bun-dev-entry.js +1 -1
  12. package/dist/chunk-names.js +1 -1
  13. package/dist/client.d.ts +3 -9
  14. package/dist/client.d.ts.map +1 -1
  15. package/dist/client.js +201 -29
  16. package/dist/client.js.map +1 -1
  17. package/dist/conformance.d.ts +2 -2
  18. package/dist/conformance.js +3 -3
  19. package/dist/deferred.d.ts +11 -11
  20. package/dist/deferred.d.ts.map +1 -1
  21. package/dist/deferred.js +16 -16
  22. package/dist/dev-diagnostics.d.ts +20 -0
  23. package/dist/dev-diagnostics.d.ts.map +1 -0
  24. package/dist/dev-diagnostics.js +34 -0
  25. package/dist/dev-diagnostics.js.map +1 -0
  26. package/dist/dev-error.d.ts +10 -13
  27. package/dist/dev-error.d.ts.map +1 -1
  28. package/dist/dev-error.js +51 -37
  29. package/dist/dev-error.js.map +1 -1
  30. package/dist/dev-port.d.ts +3 -3
  31. package/dist/dev-port.d.ts.map +1 -1
  32. package/dist/dev-port.js +10 -4
  33. package/dist/dev-port.js.map +1 -1
  34. package/dist/dev.d.ts +4 -4
  35. package/dist/dev.d.ts.map +1 -1
  36. package/dist/dev.js +28 -12
  37. package/dist/dev.js.map +1 -1
  38. package/dist/diagnostic.d.ts +93 -0
  39. package/dist/diagnostic.d.ts.map +1 -0
  40. package/dist/diagnostic.js +205 -0
  41. package/dist/diagnostic.js.map +1 -0
  42. package/dist/draft.d.ts +12 -12
  43. package/dist/draft.js +11 -11
  44. package/dist/fn-state.d.ts +56 -0
  45. package/dist/fn-state.d.ts.map +1 -0
  46. package/dist/fn-state.js +77 -0
  47. package/dist/fn-state.js.map +1 -0
  48. package/dist/fn.d.ts +111 -0
  49. package/dist/fn.d.ts.map +1 -0
  50. package/dist/fn.js +125 -0
  51. package/dist/fn.js.map +1 -0
  52. package/dist/fonts-google.d.ts +9 -9
  53. package/dist/fonts-google.js +10 -10
  54. package/dist/fonts.d.ts +7 -7
  55. package/dist/fonts.js +1 -1
  56. package/dist/forms.d.ts +8 -8
  57. package/dist/fs.d.ts +1 -1
  58. package/dist/fs.js +1 -1
  59. package/dist/index.d.ts +151 -70
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +317 -139
  62. package/dist/index.js.map +1 -1
  63. package/dist/internal/head-attributes.d.ts +15 -0
  64. package/dist/internal/head-attributes.d.ts.map +1 -0
  65. package/dist/internal/head-attributes.js +99 -0
  66. package/dist/internal/head-attributes.js.map +1 -0
  67. package/dist/internal/script-types.d.ts +14 -0
  68. package/dist/internal/script-types.d.ts.map +1 -0
  69. package/dist/internal/script-types.js +17 -0
  70. package/dist/internal/script-types.js.map +1 -0
  71. package/dist/internal/server-boundary.d.ts +60 -0
  72. package/dist/internal/server-boundary.d.ts.map +1 -0
  73. package/dist/internal/server-boundary.js +174 -0
  74. package/dist/internal/server-boundary.js.map +1 -0
  75. package/dist/internal/timing-safe-equal.d.ts +1 -1
  76. package/dist/internal/timing-safe-equal.js +1 -1
  77. package/dist/internal/vite-import.d.ts +63 -0
  78. package/dist/internal/vite-import.d.ts.map +1 -0
  79. package/dist/internal/vite-import.js +94 -0
  80. package/dist/internal/vite-import.js.map +1 -0
  81. package/dist/islands.d.ts +5 -5
  82. package/dist/islands.js +5 -5
  83. package/dist/isr.d.ts +15 -15
  84. package/dist/isr.js +7 -7
  85. package/dist/manifest.d.ts +73 -35
  86. package/dist/manifest.d.ts.map +1 -1
  87. package/dist/manifest.js +10 -16
  88. package/dist/manifest.js.map +1 -1
  89. package/dist/module-graph.d.ts +5 -5
  90. package/dist/module-graph.js +4 -4
  91. package/dist/navigation.d.ts +120 -5
  92. package/dist/navigation.d.ts.map +1 -1
  93. package/dist/navigation.js +37 -5
  94. package/dist/navigation.js.map +1 -1
  95. package/dist/plugins/css-modules.d.ts +3 -3
  96. package/dist/plugins/css-modules.js +0 -0
  97. package/dist/plugins/kit.d.ts +8 -8
  98. package/dist/plugins/kit.js +9 -9
  99. package/dist/plugins/scss.js +3 -3
  100. package/dist/plugins/vite-leak-guard.d.ts +1 -1
  101. package/dist/plugins/vite-leak-guard.js +1 -1
  102. package/dist/plugins/vite-server-fn.d.ts +23 -0
  103. package/dist/plugins/vite-server-fn.d.ts.map +1 -0
  104. package/dist/plugins/vite-server-fn.js +51 -0
  105. package/dist/plugins/vite-server-fn.js.map +1 -0
  106. package/dist/plugins/vite-server-only.d.ts +49 -0
  107. package/dist/plugins/vite-server-only.d.ts.map +1 -0
  108. package/dist/plugins/vite-server-only.js +57 -0
  109. package/dist/plugins/vite-server-only.js.map +1 -0
  110. package/dist/prerender.d.ts +5 -5
  111. package/dist/prerender.js +7 -7
  112. package/dist/query.d.ts +10 -10
  113. package/dist/query.js +15 -15
  114. package/dist/route-manifest.d.ts +1 -1
  115. package/dist/route-manifest.js +2 -2
  116. package/dist/router.d.ts +30 -21
  117. package/dist/router.d.ts.map +1 -1
  118. package/dist/router.js +62 -32
  119. package/dist/router.js.map +1 -1
  120. package/dist/search.d.ts +94 -0
  121. package/dist/search.d.ts.map +1 -0
  122. package/dist/search.js +232 -0
  123. package/dist/search.js.map +1 -0
  124. package/dist/server-only.d.ts +6 -6
  125. package/dist/server-only.js +7 -7
  126. package/dist/service-worker.d.ts +56 -0
  127. package/dist/service-worker.d.ts.map +1 -0
  128. package/dist/service-worker.js +127 -0
  129. package/dist/service-worker.js.map +1 -0
  130. package/dist/vite.d.ts +16 -14
  131. package/dist/vite.d.ts.map +1 -1
  132. package/dist/vite.js +51 -24
  133. package/dist/vite.js.map +1 -1
  134. package/package.json +38 -4
  135. package/server-manifest.d.ts +31 -0
  136. package/src/build-vite.ts +24 -77
  137. package/src/build.ts +137 -105
  138. package/src/bun-dev-entry.ts +1 -1
  139. package/src/chunk-names.ts +1 -1
  140. package/src/client.ts +215 -32
  141. package/src/conformance.ts +3 -3
  142. package/src/deferred.ts +17 -17
  143. package/src/dev-diagnostics.ts +47 -0
  144. package/src/dev-error.ts +64 -33
  145. package/src/dev-port.ts +17 -5
  146. package/src/dev.ts +36 -20
  147. package/src/diagnostic.ts +284 -0
  148. package/src/draft.ts +15 -15
  149. package/src/fn-state.ts +107 -0
  150. package/src/fn.ts +199 -0
  151. package/src/fonts-google.ts +13 -13
  152. package/src/fonts.ts +7 -7
  153. package/src/forms.ts +8 -8
  154. package/src/fs.ts +2 -2
  155. package/src/index.ts +460 -181
  156. package/src/internal/head-attributes.ts +109 -0
  157. package/src/internal/script-types.ts +18 -0
  158. package/src/internal/server-boundary.ts +187 -0
  159. package/src/internal/timing-safe-equal.ts +1 -1
  160. package/src/internal/vite-import.ts +92 -0
  161. package/src/islands.ts +7 -7
  162. package/src/isr.ts +17 -17
  163. package/src/manifest.ts +83 -42
  164. package/src/module-graph.ts +6 -6
  165. package/src/navigation.ts +151 -5
  166. package/src/plugins/css-modules.ts +0 -0
  167. package/src/plugins/kit.ts +11 -11
  168. package/src/plugins/scss.ts +3 -3
  169. package/src/plugins/vite-leak-guard.ts +2 -2
  170. package/src/plugins/vite-server-fn.ts +67 -0
  171. package/src/plugins/vite-server-only.ts +75 -0
  172. package/src/prerender.ts +10 -10
  173. package/src/query.ts +22 -22
  174. package/src/route-manifest.ts +3 -3
  175. package/src/router.ts +98 -45
  176. package/src/search.ts +297 -0
  177. package/src/server-only.ts +7 -7
  178. package/src/service-worker.ts +165 -0
  179. package/src/vite.ts +61 -32
package/dist/dev.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { type BuildClientOptions } from "./build.js";
2
- /** Minimal app surface the dev server needs — `createWebApp(...)` satisfies it. */
2
+ export { LAST_ERROR_PATH } from "./diagnostic.js";
3
+ /** Minimal app surface the dev server needs - `createWebApp(...)` satisfies it. */
3
4
  interface FetchApp {
4
5
  fetch(request: Request): Response | Promise<Response>;
5
6
  }
6
7
  export interface DevServerOptions extends Omit<BuildClientOptions, "minify"> {
7
8
  /**
8
- * Build the nifra app for the current client entry. `importQuery` changes on every reload — pass it to
9
+ * Build the nifra app for the current client entry. `importQuery` changes on every reload - pass it to
9
10
  * `discoverRoutes(routesDir, { importQuery })` so SSR re-imports edited route modules instead of Bun's
10
11
  * cached copies.
11
12
  */
@@ -30,7 +31,7 @@ export interface DevServerOptions extends Omit<BuildClientOptions, "minify"> {
30
31
  export interface DevServer {
31
32
  readonly port: number;
32
33
  /**
33
- * The URL pages point their client entry at — always {@link CLIENT_ENTRY_PATH}, never Bun's hashed
34
+ * The URL pages point their client entry at - always {@link CLIENT_ENTRY_PATH}, never Bun's hashed
34
35
  * chunk. Deliberately not the underlying chunk URL: that one moves on every rebuild, and anything
35
36
  * holding onto it is holding onto a URL that will stop working.
36
37
  */
@@ -78,5 +79,4 @@ export declare function styleTags(styles: readonly string[]): string;
78
79
  export declare function injectStyles(html: string, styles: readonly string[]): string;
79
80
  /** Start the Bun dev server: generate → bundle → serve → watch → hot-reload on change. */
80
81
  export declare function createDevServer(options: DevServerOptions): Promise<DevServer>;
81
- export {};
82
82
  //# sourceMappingURL=dev.d.ts.map
package/dist/dev.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAsDA,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,YAAY,CAAA;AAQjE,mFAAmF;AACnF,UAAU,QAAQ;IAChB,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;CACtD;AAED,MAAM,WAAW,g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AAS,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAsBjE;AAED,wGAAwG;AACxG,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAQ3D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAM5E;AAED,0FAA0F;AAC1F,wBAAsB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAoPnF"}
package/dist/dev.js CHANGED
@@ -7,7 +7,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
7
7
  return path;
8
8
  };
9
9
  /**
10
- * `@nifrajs/web/dev` — the **Bun pipeline's** dev server: one toolchain, no Vite in the process.
10
+ * `@nifrajs/web/dev` - the **Bun pipeline's** dev server: one toolchain, no Vite in the process.
11
11
  *
12
12
  * nifra ships two dev pipelines and the rule between them is that a pipeline owns a whole phase. The
13
13
  * Vite server (`@nifrajs/web/vite`) is the default - mature framework plugins, and it resolves SSR as
@@ -15,12 +15,12 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
15
15
  * and hot-reloads the client while Bun's runtime resolves SSR. Only one toolchain is present, so the two
16
16
  * cannot disagree.
17
17
  *
18
- * What you get: React Fast Refresh WITH state preserved — Bun's dev server applies it natively, no plugin
18
+ * What you get: React Fast Refresh WITH state preserved - Bun's dev server applies it natively, no plugin
19
19
  * (verified: editing a component-only module swaps its markup while a `useState` counter keeps its value,
20
20
  * no reload). The usual boundary rule still applies, and it is the same rule Vite has: a module whose
21
21
  * exports are all components is a refresh boundary, so a ROUTE file that also exports `loader`/`meta` is
22
22
  * not, and saving it does a clean full reload. Plus no Vite dependency and ONE bundler across dev and
23
- * production, which is the real prize — the dev/prod seam disappears.
23
+ * production, which is the real prize - the dev/prod seam disappears.
24
24
  *
25
25
  * What you give up: `*.module.css`. Bun's DEV-server bundler has no CSS-Modules transform (its production
26
26
  * `Bun.build` does), so the import compiles to a dangling reference. Plain CSS and Tailwind are fine. The
@@ -54,11 +54,12 @@ import { mkdirSync, readdirSync, readFileSync, rmSync, unwatchFile, watchFile, w
54
54
  import { dirname, relative, resolve } from "node:path";
55
55
  import { buildClient } from "./build.js";
56
56
  import { resolveDevEntry } from "./bun-dev-entry.js";
57
- import { renderDevErrorOverlay } from "./dev-error.js";
57
+ import { createDevDiagnostics } from "./dev-diagnostics.js";
58
58
  import { explainBindFailure } from "./dev-port.js";
59
59
  import { discoverRoutes } from "./fs.js";
60
60
  import { DEFAULT_DEV_PORT, generateClientEntry } from "./index.js";
61
61
  import { servePublicDir } from "./public-dir.js";
62
+ export { LAST_ERROR_PATH } from "./diagnostic.js";
62
63
  /**
63
64
  * Where the generated dev files live. A dot-directory inside the project, not a temp dir: Bun's bundler
64
65
  * resolves the entry's imports the way the runtime does, so it has to sit where the app's routes and
@@ -94,7 +95,7 @@ function writeIfChanged(path, content) {
94
95
  return;
95
96
  }
96
97
  catch {
97
- // missing or unreadable — fall through and write
98
+ // missing or unreadable - fall through and write
98
99
  }
99
100
  writeFileSync(path, content);
100
101
  }
@@ -125,13 +126,13 @@ export function writeDevFiles(options) {
125
126
  // A bare relative path reads as a PACKAGE specifier to a bundler; `./` is what makes it a file.
126
127
  return rel.startsWith(".") ? rel : `./${rel}`;
127
128
  };
128
- // No `import.meta.hot.accept` here, deliberately. When an edit lands OUTSIDE a Fast Refresh boundary —
129
- // a route file, which also exports `loader`/`meta` — Bun walks up to this generated entry, finds no
129
+ // No `import.meta.hot.accept` here, deliberately. When an edit lands OUTSIDE a Fast Refresh boundary -
130
+ // a route file, which also exports `loader`/`meta` - Bun walks up to this generated entry, finds no
130
131
  // `accept`, logs "hot update was not accepted" and does a full reload. That reload is correct: the route
131
132
  // module's non-component exports changed, so patching it into the live tree would be wrong. Accepting
132
133
  // here is worse than the warning: Bun re-evaluates the module BEFORE the accept callback runs, so the
133
134
  // entry re-executes against a container React already mounted ("createRoot() on a container that has
134
- // already been passed to createRoot()") and only then does the callback get to reload — trading an
135
+ // already been passed to createRoot()") and only then does the callback get to reload - trading an
135
136
  // accurate warning for a real error. Editing a component-only module never reaches this path: Bun
136
137
  // applies React Fast Refresh there and state is preserved.
137
138
  writeIfChanged(entryPath, generateClientEntry(manifest, { clientModule, resolve: toSpecifier }));
@@ -171,6 +172,10 @@ export async function createDevServer(options) {
171
172
  // The app root. `routesDir` is `<app>/routes` by convention, so its parent is the project - the one
172
173
  // place a generated entry can sit and still resolve the app's imports.
173
174
  const root = resolve(routesDir, "..");
175
+ // The most recent SSR failure as a structured Diagnostic, scoped to THIS server. Served at
176
+ // LAST_ERROR_PATH so an agent driving the dev server reads the exact failure (code, codeframe, fix) as
177
+ // JSON instead of scraping the overlay. Shared with the Vite adapter so the endpoint can't drift.
178
+ const devDiagnostics = createDevDiagnostics(root);
174
179
  const devDir = resolve(root, DEV_DIR);
175
180
  const entryPath = resolve(devDir, "entry.tsx");
176
181
  const htmlPath = resolve(devDir, "entry.html");
@@ -186,9 +191,9 @@ export async function createDevServer(options) {
186
191
  // Bun resolves and bundles the HTML, and everything it references, at import time.
187
192
  const htmlModule = (await import(__rewriteRelativeImportExtension(htmlPath)));
188
193
  let server;
189
- // The last resolved entry, with the time it was resolved. Deliberately short-lived — see `currentEntry`.
194
+ // The last resolved entry, with the time it was resolved. Deliberately short-lived - see `currentEntry`.
190
195
  let cache;
191
- // The app, tagged with the entry hash it was built against — see `appFor`.
196
+ // The app, tagged with the entry hash it was built against - see `appFor`.
192
197
  let built;
193
198
  let building;
194
199
  let version = 0;
@@ -263,6 +268,7 @@ export async function createDevServer(options) {
263
268
  try {
264
269
  server = serve({
265
270
  port,
271
+ hostname: "127.0.0.1",
266
272
  development: { hmr: true },
267
273
  // The probe route is the ONLY path Bun owns; everything else falls through to nifra's SSR.
268
274
  routes: { [PROBE_PATH]: htmlModule.default },
@@ -278,6 +284,11 @@ export async function createDevServer(options) {
278
284
  const entry = await currentEntry();
279
285
  return new Response(null, { status: 307, headers: { location: entry.src } });
280
286
  }
287
+ if (devDiagnostics.isLastErrorPath(url.pathname)) {
288
+ // The structured form of the overlay, for an agent driving the dev server (shared surface).
289
+ const { body, headers } = devDiagnostics.lastError();
290
+ return new Response(body, { headers });
291
+ }
281
292
  // Static probe before routing; a miss returns undefined and falls through, so no route is
282
293
  // shadowed and a page render never pays a filesystem stat (extension-less paths skip it).
283
294
  const staticFile = await servePublic(req);
@@ -300,10 +311,15 @@ export async function createDevServer(options) {
300
311
  });
301
312
  }
302
313
  catch (err) {
303
- return new Response(renderDevErrorOverlay(err, {
314
+ // One Diagnostic drives both surfaces: the overlay returned here and the JSON at LAST_ERROR_PATH.
315
+ const html = devDiagnostics.capture(err, {
304
316
  method: req.method,
305
317
  url: `${url.pathname}${url.search}`,
306
- }), { status: 500, headers: { "content-type": "text/html; charset=utf-8" } });
318
+ });
319
+ return new Response(html, {
320
+ status: 500,
321
+ headers: { "content-type": "text/html; charset=utf-8" },
322
+ });
307
323
  }
308
324
  },
309
325
  });
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,WAAW,EACX,SAAS,EACT,aAAa,GACd,MAAM,SAAS,CA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,MAAM,IAAI,IAAI,OAAO;gBAAE,WAAW,CAAC,IAAI,CAAC,CAAA;YAC7C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjB,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAClD,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,SAAS,CAAC,OAAyB;IAC1C,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,MAAM,GAAG,GAAG,GAAS,EAAE;QACrB,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,CAAA;YACb,OAAM;QACR,CAAC;QACD,OAAO,GAAG,IAAI,CAAA;QACd,WAAW,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;aACvC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;YACtB,OAAO,CAAC,KAAK,CACX,gDAAgD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI;gBAClG,oEAAoE,CACvE,CAAA;QACH,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,OAAO,GAAG,KAAK,CAAA;YACf,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,GAAG,KAAK,CAAA;gBACd,GAAG,EAAE,CAAA;YACP,CAAC;QACH,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,93 @@
1
+ /** Shared endpoint name used by both dev pipelines and the agent-facing MCP tools. */
2
+ export declare const LAST_ERROR_PATH = "/__nifra/last-error";
3
+ /** One parsed stack frame. `file`/`line`/`column` are present only when the frame could be located. */
4
+ export interface DiagnosticFrame {
5
+ readonly raw: string;
6
+ readonly file?: string;
7
+ readonly line?: number;
8
+ readonly column?: number;
9
+ }
10
+ /** A source window around the offending line. `caret` marks the exact line the top frame points at. */
11
+ export interface Codeframe {
12
+ readonly file: string;
13
+ readonly line: number;
14
+ readonly column?: number | undefined;
15
+ readonly lines: ReadonlyArray<{
16
+ readonly number: number;
17
+ readonly text: string;
18
+ readonly caret: boolean;
19
+ }>;
20
+ }
21
+ /** The structured failure. Serialisable as-is to JSON for the agent surfaces. */
22
+ export interface Diagnostic {
23
+ /** Stable, greppable identifier, e.g. `NIFRA_SERVER_ONLY_IN_CLIENT`. `NIFRA_UNHANDLED` when unrecognised. */
24
+ readonly code: string;
25
+ readonly name: string;
26
+ readonly message: string;
27
+ readonly request?: {
28
+ readonly method: string;
29
+ readonly url: string;
30
+ } | undefined;
31
+ readonly frames: readonly DiagnosticFrame[];
32
+ readonly codeframe?: Codeframe | undefined;
33
+ /** Plain-language "why this happened", when the failure is recognised. */
34
+ readonly cause?: string | undefined;
35
+ /** Plain-language "do this", when the failure is recognised. */
36
+ readonly fix?: string | undefined;
37
+ /** Docs section anchor for the code, e.g. `errors#server-only-in-client`. */
38
+ readonly docsAnchor?: string | undefined;
39
+ }
40
+ /** Reads a source file's text, or returns undefined if it cannot (missing, binary, permission). */
41
+ export type SourceReader = (file: string) => string | undefined;
42
+ /**
43
+ * Parse a V8/Node stack into structured frames. Handles the `at fn (path:line:col)`, bare
44
+ * `at path:line:col`, and `at async fn (...)` shapes; a frame that doesn't match keeps its raw text
45
+ * with no location (so nothing is silently dropped).
46
+ */
47
+ export declare function parseFrames(stack: string): DiagnosticFrame[];
48
+ /** The first frame that points at the user's own source - what the codeframe should show. */
49
+ export declare function topUserFrame(frames: readonly DiagnosticFrame[], root: string | undefined): DiagnosticFrame | undefined;
50
+ /**
51
+ * Build a source codeframe: `radius` lines either side of `line`, each tagged with its 1-based number
52
+ * and whether it is the offending line. Returns undefined if the source can't be read or the line is
53
+ * out of range - a diagnostic without a codeframe is still useful, so this never throws.
54
+ */
55
+ export declare function buildCodeframe(file: string, line: number, column: number | undefined, read?: SourceReader, radius?: number): Codeframe | undefined;
56
+ /** A recognised failure shape: a stable code plus the plain-language cause/fix/anchor to attach. */
57
+ interface CatalogEntry {
58
+ readonly code: string;
59
+ readonly match: (name: string, message: string) => boolean;
60
+ readonly cause: string;
61
+ readonly fix: string;
62
+ readonly docsAnchor: string;
63
+ }
64
+ /**
65
+ * The recognised-failure catalog. Seeded with the highest-signal nifra failures; extend it as new
66
+ * classes of error earn a stable code. Order matters only in that the first match wins.
67
+ */
68
+ export declare const DIAGNOSTIC_CATALOG: readonly CatalogEntry[];
69
+ /** Classify an error name+message against the catalog; falls back to the generic unhandled code. */
70
+ export declare function classify(name: string, message: string): {
71
+ code: string;
72
+ cause?: string;
73
+ fix?: string;
74
+ docsAnchor?: string;
75
+ };
76
+ export interface BuildDiagnosticOptions {
77
+ readonly request?: {
78
+ readonly method: string;
79
+ readonly url: string;
80
+ };
81
+ /** Project root; frames outside it are treated as non-user. Defaults to `process.cwd()`. */
82
+ readonly root?: string;
83
+ /** Injectable source reader (tests pass a fake; production reads the filesystem). */
84
+ readonly read?: SourceReader;
85
+ }
86
+ /**
87
+ * Resolve any thrown value into a `Diagnostic`: parse the (already source-mapped) stack, locate the top
88
+ * user frame, attach a codeframe, and classify the failure for a cause/fix. The caller is responsible
89
+ * for running Vite's `ssrFixStacktrace` first so the frames point at real source.
90
+ */
91
+ export declare function buildDiagnostic(err: unknown, options?: BuildDiagnosticOptions): Diagnostic;
92
+ export {};
93
+ //# sourceMappingURL=diagnostic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAgBA,sFAAsF;AACtF,eAAO,MAAM,eAAe,wBAAwB,CAAA;AAEpD,uGAAuG;AACvG,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CA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,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACpE,4FAA4F;IAC5F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,qFAAqF;IACrF,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAA;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,sBAA2B,GAAG,UAAU,CAsB9F"}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * The structured diagnostic that every nifra failure resolves to - the single source both the human
3
+ * dev overlay ([dev-error.ts]) and the agent-facing surfaces (`/__nifra/last-error`, `nifra_explain`)
4
+ * render from. A stack trace is a wall of text; a `Diagnostic` is queryable: a stable `code`, the top
5
+ * USER frame (file/line/column), a source codeframe around it, and - when the failure is one nifra
6
+ * recognises - a plain-language `cause` + `fix` + docs anchor.
7
+ *
8
+ * This is the "AI-native" half of error reporting: the same object a person reads in the overlay is the
9
+ * JSON an agent reads to apply the fix, so neither has to scrape the other's format.
10
+ *
11
+ * Pure + DOM-free by construction (it only parses strings and reads source text through an injected
12
+ * reader), so it lives in the root typecheck program and is unit-testable without a dev server or disk.
13
+ */
14
+ import { readFileSync, realpathSync } from "node:fs";
15
+ import { isAbsolute, relative, resolve } from "node:path";
16
+ /** Shared endpoint name used by both dev pipelines and the agent-facing MCP tools. */
17
+ export const LAST_ERROR_PATH = "/__nifra/last-error";
18
+ const defaultReader = (file) => {
19
+ try {
20
+ return readFileSync(file, "utf8");
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ };
26
+ // Turns a raw frame path into an absolute filesystem path, or undefined if it isn't one. Handles the
27
+ // `file://` URL form Vite/Node emit and strips the `?v=hash` / `#` suffixes a bundler appends.
28
+ function cleanFramePath(path) {
29
+ let p = path.trim();
30
+ if (p.startsWith("file://")) {
31
+ try {
32
+ p = decodeURIComponent(new URL(p).pathname);
33
+ }
34
+ catch {
35
+ return undefined;
36
+ }
37
+ }
38
+ // Strip the `?v=hash` / `#` suffix without a `.*` regex (ReDoS-safe): cut at the first `?` or `#`.
39
+ const cut = p.search(/[?#]/);
40
+ if (cut !== -1)
41
+ p = p.slice(0, cut);
42
+ const isAbsolute = p.startsWith("/") || /^[A-Za-z]:[\\/]/.test(p);
43
+ return isAbsolute ? p : undefined;
44
+ }
45
+ /**
46
+ * Parse a V8/Node stack into structured frames. Handles the `at fn (path:line:col)`, bare
47
+ * `at path:line:col`, and `at async fn (...)` shapes; a frame that doesn't match keeps its raw text
48
+ * with no location (so nothing is silently dropped).
49
+ */
50
+ export function parseFrames(stack) {
51
+ const frames = [];
52
+ for (const line of stack.split("\n")) {
53
+ const raw = line.trim();
54
+ if (!/^at\s/.test(raw))
55
+ continue;
56
+ // Prefer the parenthesised location; fall back to a trailing `path:line:col`.
57
+ const paren = raw.match(/\(([^()]+):(\d+):(\d+)\)\s*$/);
58
+ const bare = raw.match(/^at\s+(?:async\s+)?(\S.*):(\d+):(\d+)\s*$/);
59
+ const m = paren ?? bare;
60
+ if (!m) {
61
+ frames.push({ raw });
62
+ continue;
63
+ }
64
+ const file = cleanFramePath(m[1]);
65
+ frames.push(file === undefined ? { raw } : { raw, file, line: Number(m[2]), column: Number(m[3]) });
66
+ }
67
+ return frames;
68
+ }
69
+ /** Frames inside dependencies or the runtime are noise for a first look; the user's own code is the signal. */
70
+ function isUserFrame(file, root) {
71
+ if (file.includes("/node_modules/") || file.includes("\\node_modules\\"))
72
+ return false;
73
+ if (file.startsWith("node:"))
74
+ return false;
75
+ if (root !== undefined) {
76
+ // A string prefix is not a path boundary (`/app-evil` starts with `/app`) and leaves `..` and
77
+ // symlink escapes unresolved. Resolve lexically first, then realpath existing paths so a codeframe
78
+ // can never read a source file outside the project root merely because a stack frame was crafted.
79
+ const rootPath = canonicalPath(root);
80
+ const framePath = canonicalPath(file);
81
+ const rel = relative(rootPath, framePath);
82
+ if (rel === ".." || rel.startsWith(`..${sepForPath(rel)}`) || isAbsolute(rel))
83
+ return false;
84
+ }
85
+ return true;
86
+ }
87
+ function sepForPath(path) {
88
+ return path.includes("\\") ? "\\" : "/";
89
+ }
90
+ function canonicalPath(path) {
91
+ const lexical = resolve(path);
92
+ try {
93
+ return realpathSync.native(lexical);
94
+ }
95
+ catch {
96
+ return lexical;
97
+ }
98
+ }
99
+ /** The first frame that points at the user's own source - what the codeframe should show. */
100
+ export function topUserFrame(frames, root) {
101
+ return frames.find((f) => f.file !== undefined && isUserFrame(f.file, root));
102
+ }
103
+ /**
104
+ * Build a source codeframe: `radius` lines either side of `line`, each tagged with its 1-based number
105
+ * and whether it is the offending line. Returns undefined if the source can't be read or the line is
106
+ * out of range - a diagnostic without a codeframe is still useful, so this never throws.
107
+ */
108
+ export function buildCodeframe(file, line, column, read = defaultReader, radius = 3) {
109
+ const source = read(file);
110
+ if (source === undefined)
111
+ return undefined;
112
+ const all = source.split("\n");
113
+ if (line < 1 || line > all.length)
114
+ return undefined;
115
+ const start = Math.max(1, line - radius);
116
+ const end = Math.min(all.length, line + radius);
117
+ const lines = [];
118
+ for (let n = start; n <= end; n++) {
119
+ lines.push({ number: n, text: all[n - 1] ?? "", caret: n === line });
120
+ }
121
+ return { file, line, column, lines };
122
+ }
123
+ /**
124
+ * The recognised-failure catalog. Seeded with the highest-signal nifra failures; extend it as new
125
+ * classes of error earn a stable code. Order matters only in that the first match wins.
126
+ */
127
+ export const DIAGNOSTIC_CATALOG = [
128
+ {
129
+ code: "NIFRA_SERVER_ONLY_IN_CLIENT",
130
+ match: (_n, m) => m.includes("server-only module(s) in the client bundle"),
131
+ cause: "A module marked server-only was reachable from a client entry, so it would ship to the browser.",
132
+ fix: "Follow the import chain in the message and move the server-only use behind a loader/action or a `*.server.ts` boundary, so it never enters a client component.",
133
+ docsAnchor: "errors#server-only-in-client",
134
+ },
135
+ {
136
+ code: "NIFRA_NODE_BUILTIN_IN_CLIENT",
137
+ match: (_n, m) => m.includes("Node built-in(s) in the client bundle"),
138
+ cause: "A `node:` built-in was reached from a client entry; it has no browser implementation.",
139
+ fix: "Move the code using the built-in to the server (loader/action or `*.server.ts`); the message lists the import chain that pulled it in.",
140
+ docsAnchor: "errors#node-builtin-in-client",
141
+ },
142
+ {
143
+ code: "NIFRA_SCHEMA_PARSE",
144
+ match: (n, m) => n === "SchemaError" ||
145
+ /failed to (parse|validate)|invalid_type|expected .* received/i.test(m),
146
+ cause: "Data crossing a boundary did not match its declared schema.",
147
+ fix: "Check the value against the schema at the failing boundary (loader input, search params, or request body); parse-don't-cast means the shape must match exactly.",
148
+ docsAnchor: "errors#schema-parse",
149
+ },
150
+ ];
151
+ /** Classify an error name+message against the catalog; falls back to the generic unhandled code. */
152
+ export function classify(name, message) {
153
+ const hit = DIAGNOSTIC_CATALOG.find((e) => e.match(name, message));
154
+ if (hit === undefined)
155
+ return { code: "NIFRA_UNHANDLED" };
156
+ return { code: hit.code, cause: hit.cause, fix: hit.fix, docsAnchor: hit.docsAnchor };
157
+ }
158
+ /** Split an Error's `stack` into its leading message block and its frame lines. */
159
+ function messageAndStack(err) {
160
+ const stack = err.stack ?? `${err.name}: ${err.message}`;
161
+ const lines = stack.split("\n");
162
+ const firstFrame = lines.findIndex((l) => /^\s*at\s/.test(l));
163
+ if (firstFrame === -1)
164
+ return { message: err.message || stack.trim(), stack: "" };
165
+ return {
166
+ message: lines.slice(0, firstFrame).join("\n").trim(),
167
+ stack: lines.slice(firstFrame).join("\n"),
168
+ };
169
+ }
170
+ /**
171
+ * Resolve any thrown value into a `Diagnostic`: parse the (already source-mapped) stack, locate the top
172
+ * user frame, attach a codeframe, and classify the failure for a cause/fix. The caller is responsible
173
+ * for running Vite's `ssrFixStacktrace` first so the frames point at real source.
174
+ */
175
+ export function buildDiagnostic(err, options = {}) {
176
+ const error = err instanceof Error ? err : new Error(String(err));
177
+ const root = options.root ?? safeCwd();
178
+ const { message } = messageAndStack(error);
179
+ const frames = parseFrames(error.stack ?? "");
180
+ const top = topUserFrame(frames, root);
181
+ const codeframe = top?.file !== undefined && top.line !== undefined
182
+ ? buildCodeframe(canonicalPath(top.file), top.line, top.column, options.read)
183
+ : undefined;
184
+ const { code, cause, fix, docsAnchor } = classify(error.name || "Error", message);
185
+ return {
186
+ code,
187
+ name: error.name || "Error",
188
+ message,
189
+ request: options.request,
190
+ frames,
191
+ codeframe,
192
+ cause,
193
+ fix,
194
+ docsAnchor,
195
+ };
196
+ }
197
+ function safeCwd() {
198
+ try {
199
+ return process.cwd();
200
+ }
201
+ catch {
202
+ return undefined;
203
+ }
204
+ }
205
+ //# sourceMappingURL=diagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEzD,sFAAsF;AACtF,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAA;AA0CpD,MAAM,aAAa,GAAiB,CAAC,IAAI,EAAE,EAAE;IAC3C,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC,CAAA;AAED,qGAAqG;AACrG,+FAA+F;AAC/F,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IACnB,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,CAAC,GAAG,kBAAkB,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC7C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC;IAC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AAI,GAAG,CAAC,IAAI,KAAK,SAAS;QAC/C,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC;QAC7E,CAAC,CAAC,SAAS,CAAA;IACf,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,EAAE,OAAO,CAAC,CAAA;IACjF,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,OAAO;QAC3B,OAAO;QACP,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM;QACN,SAAS;QACT,KAAK;QACL,GAAG;QACH,UAAU;KACX,CAAA;AACH,CAAC;AAED,SAAS,OAAO;IACd,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,GAAG,EAAE,CAAA;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
package/dist/draft.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Draft / preview mode — let an editor see unpublished content by flipping a signed cookie that
2
+ * Draft / preview mode - let an editor see unpublished content by flipping a signed cookie that
3
3
  * loaders read (`ctx.draft`) and ISR bypasses (fresh render, never cached). The cookie is **HMAC-signed**
4
- * (so a visitor can't forge it) and **HttpOnly** (JS can't read it). You gate `enableDraft` yourself —
5
- * behind an editor login or a `?token=` check — exactly like Next's `draftMode().enable()`.
4
+ * (so a visitor can't forge it) and **HttpOnly** (JS can't read it). You gate `enableDraft` yourself -
5
+ * behind an editor login or a `?token=` check - exactly like Next's `draftMode().enable()`.
6
6
  *
7
7
  * // a route you've protected (e.g. checked ?token= against a secret):
8
8
  * app.get("/api/draft", async (c) => {
@@ -17,7 +17,7 @@
17
17
  import { type CookieOptions } from "@nifrajs/core/server";
18
18
  /** The cookie name nifra uses for draft/preview mode. */
19
19
  export declare const DRAFT_COOKIE = "__nifra_draft";
20
- /** The response-cookie surface `enableDraft`/`disableDraft` need — nifra's `c.set`. Structural, so any
20
+ /** The response-cookie surface `enableDraft`/`disableDraft` need - nifra's `c.set`. Structural, so any
21
21
  * nifra handler context satisfies it without importing the full `Context`. */
22
22
  export interface DraftCookieControls {
23
23
  cookie(name: string, value: string, options?: CookieOptions): void;
@@ -27,17 +27,17 @@ export interface DraftCookieControls {
27
27
  }): void;
28
28
  }
29
29
  export interface EnableDraftOptions {
30
- /** Cookie lifetime in **seconds** (default `3600` = 1h). Keep it short — draft is an editor session. */
30
+ /** Cookie lifetime in **seconds** (default `3600` = 1h). Keep it short - draft is an editor session. */
31
31
  readonly maxAgeSeconds?: number;
32
32
  /** Cookie `Path` (default `"/"`). */
33
33
  readonly path?: string;
34
- /** Override the `Secure` attribute (defaults to `true` — secure-by-default). Pass `false` only for
34
+ /** Override the `Secure` attribute (defaults to `true` - secure-by-default). Pass `false` only for
35
35
  * local `http://` dev, where a `Secure` cookie isn't stored. */
36
36
  readonly secure?: boolean;
37
37
  }
38
38
  /**
39
39
  * Turn draft mode **on** for this client by setting a signed, HttpOnly `__nifra_draft` cookie. Call it
40
- * from a route you've already authorized. `secret` signs the cookie — pass the SAME secret to
40
+ * from a route you've already authorized. `secret` signs the cookie - pass the SAME secret to
41
41
  * `createWebApp({ draftSecret })` and `withISR({ draftSecret })` so the framework can verify it.
42
42
  */
43
43
  export declare function enableDraft(c: {
@@ -59,7 +59,7 @@ export declare function isDraftEnabled(request: Request, secret: string): Promis
59
59
  export interface PreviewEndpointOptions {
60
60
  /** Shared secret the preview link must carry. Compared in **constant time**. */
61
61
  readonly secret: string;
62
- /** Secret that **signs** the draft cookie — the same one passed to `createWebApp({ draftSecret })`
62
+ /** Secret that **signs** the draft cookie - the same one passed to `createWebApp({ draftSecret })`
63
63
  * and `withISR({ draftSecret })`. Keep it distinct from {@link secret}: that one travels in URLs
64
64
  * (logs, `Referer`, browser history), this one never leaves the server. */
65
65
  readonly draftSecret: string;
@@ -74,17 +74,17 @@ export interface PreviewEndpointOptions {
74
74
  readonly cookie?: EnableDraftOptions;
75
75
  }
76
76
  /**
77
- * A **preview / draft-mode entry point** — a `fetch` handler that checks a preview token, turns draft
77
+ * A **preview / draft-mode entry point** - a `fetch` handler that checks a preview token, turns draft
78
78
  * mode on, and redirects the editor to the page they wanted. `GET` with `?token=<secret>&to=/some/path`;
79
79
  * mount it on a nifra route, e.g. `app.get("/api/preview", (c) => handler(c.req))`.
80
80
  *
81
- * This is the link-borne sibling of `revalidateEndpoint`. It exists because the alternative — telling
82
- * you to gate the route yourself — means hand-rolling two checks that are easy to get subtly wrong and
81
+ * This is the link-borne sibling of `revalidateEndpoint`. It exists because the alternative - telling
82
+ * you to gate the route yourself - means hand-rolling two checks that are easy to get subtly wrong and
83
83
  * that fail silently when you do: the token compare must not exit early on the first wrong character,
84
84
  * and the `?to=` destination must not be allowed to point off-site. Both are handled here.
85
85
  *
86
86
  * A CMS "Preview" button is a plain link, so the token has to ride the query string. That has a cost
87
- * no endpoint can remove — the secret lands in server logs, the `Referer` header, and browser history.
87
+ * no endpoint can remove - the secret lands in server logs, the `Referer` header, and browser history.
88
88
  * Use a preview token minted for that purpose, rotate it, and never reuse a token that grants anything
89
89
  * beyond draft mode.
90
90
  *