@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/vite.js CHANGED
@@ -1,22 +1,27 @@
1
1
  /**
2
- * `@nifrajs/web/vite` — a **dev-only** server with true HMR, backed by Vite in middleware mode. nifra's
2
+ * `@nifrajs/web/vite` - a **dev-only** server with true HMR, backed by Vite in middleware mode. nifra's
3
3
  * production pipeline stays Bun-native (`@nifrajs/web/build` → `Bun.build`); this is purely for the dev
4
4
  * loop. Bun's own HMR is dev-server-only and DCE's `import.meta.hot` under `Bun.build` (nifra's bundler),
5
5
  * so HMR comes from Vite + the framework's official Vite plugin (React Fast Refresh, Vue/Svelte/Solid
6
- * HMR) — which you inject via `plugins` (the same structural-injection idiom as the Bun/codec plugins).
6
+ * HMR) - which you inject via `plugins` (the same structural-injection idiom as the Bun/codec plugins).
7
7
  *
8
8
  * Flow: Vite serves + HMR-swaps the client modules (nifra's codegen'd entry + the route files); nifra
9
9
  * still **SSRs** each request, and the rendered HTML is run through `vite.transformIndexHtml` so Vite
10
10
  * injects its HMR client + the framework's refresh preamble. Node `http` (not `Bun.serve`) because
11
- * Vite's `middlewares` are Connect-style — it runs fine under Bun.
11
+ * Vite's `middlewares` are Connect-style - it runs fine under Bun.
12
12
  */
13
13
  import { writeFileSync } from "node:fs";
14
14
  import { createServer as createHttpServer, } from "node:http";
15
15
  import { relative, resolve as resolvePath } from "node:path";
16
- import { renderDevErrorOverlay } from "./dev-error.js";
16
+ import { createDevDiagnostics } from "./dev-diagnostics.js";
17
17
  import { listenOrExplain } from "./dev-port.js";
18
18
  import { discoverRoutes } from "./fs.js";
19
19
  import { DEFAULT_DEV_PORT, generateClientEntry } from "./index.js";
20
+ import { vitePublicEnvPrefix } from "./internal/server-boundary.js";
21
+ import { importVite } from "./internal/vite-import.js";
22
+ import { viteServerFnStub } from "./plugins/vite-server-fn.js";
23
+ import { viteServerOnlyEmpty } from "./plugins/vite-server-only.js";
24
+ export { LAST_ERROR_PATH } from "./diagnostic.js";
20
25
  // The codegen'd client entry is written here (at the Vite root) so Vite serves + HMRs it.
21
26
  const DEV_ENTRY = ".nifra-vite-entry.tsx";
22
27
  const readNodeBody = async (req) => {
@@ -52,7 +57,7 @@ function toWebRequest(req, body) {
52
57
  }
53
58
  /**
54
59
  * Copy a Web `Response`'s headers onto a Node response, emitting EACH `Set-Cookie` as its own header. The
55
- * `Headers` iterator (and `.get`) join multiple set-cookie values with ", ", which corrupts cookies — e.g.
60
+ * `Headers` iterator (and `.get`) join multiple set-cookie values with ", ", which corrupts cookies - e.g.
56
61
  * better-auth's `session_token` + `session_data` collapse into one unparseable cookie and the session is
57
62
  * silently lost. `getSetCookie()` returns them split; Node's `setHeader` emits one header per array element.
58
63
  */
@@ -68,7 +73,7 @@ export function applyResponseHeaders(headers, res) {
68
73
  }
69
74
  /**
70
75
  * Stream a Web `Response` body to a Node response chunk-by-chunk. Buffering the whole body (e.g.
71
- * `arrayBuffer()`) waits for the stream to END — which an open-ended SSE (`text/event-stream`) body never
76
+ * `arrayBuffer()`) waits for the stream to END - which an open-ended SSE (`text/event-stream`) body never
72
77
  * does, so it hung `nifra dev` (the Bun production server streamed it fine). This flushes each chunk as it
73
78
  * arrives and cancels the reader if the client disconnects; a finite body just streams its chunk(s) + ends.
74
79
  */
@@ -89,22 +94,22 @@ export async function pipeWebBodyToNode(body, res) {
89
94
  }
90
95
  }
91
96
  catch {
92
- // client disconnected mid-stream — the `close` handler already cancelled the reader
97
+ // client disconnected mid-stream - the `close` handler already cancelled the reader
93
98
  }
94
99
  res.end();
95
100
  }
96
101
  /**
97
102
  * Strip `optimizeDeps.rollupOptions.jsx` from a plugin's `config` hook output when running under
98
- * rolldown-vite — the source of the scary, harmless `Warning: Invalid input options … "jsx" Invalid
103
+ * rolldown-vite - the source of the scary, harmless `Warning: Invalid input options … "jsx" Invalid
99
104
  * key: Expected never but received "jsx"` on `nifra dev`.
100
105
  *
101
106
  * Why it happens: `@vitejs/plugin-react@4.x` (and peers) target an *older* rolldown-vite optimizeDeps
102
- * API — they inject `optimizeDeps.rollupOptions.jsx` to tell the dep pre-bundler to transform JSX. Vite
107
+ * API - they inject `optimizeDeps.rollupOptions.jsx` to tell the dep pre-bundler to transform JSX. Vite
103
108
  * 8's rolldown dep-optimizer renamed that surface to `optimizeDeps.rolldownOptions` (and moved jsx under
104
109
  * `transform.jsx`), so the stale `rollupOptions.jsx` is an unrecognized input option → the warning. It's
105
110
  * a version-skew artifact, not a real misconfig: the route source JSX transform runs through the
106
111
  * plugin's own `transform` hook (untouched here), and node_modules deps that get pre-bundled almost
107
- * never contain raw JSX — so dropping the dead key changes no behavior and keeps HMR/Fast Refresh
112
+ * never contain raw JSX - so dropping the dead key changes no behavior and keeps HMR/Fast Refresh
108
113
  * intact. We *strip* (rather than translate to `rolldownOptions`) so the fix is version-agnostic: a
109
114
  * plugin already emitting the correct `rolldownOptions` is left untouched, and a future plugin bump that
110
115
  * stops emitting `rollupOptions.jsx` makes this a no-op.
@@ -112,12 +117,12 @@ export async function pipeWebBodyToNode(body, res) {
112
117
  * Scoped narrowly: only the `optimizeDeps.rollupOptions.jsx` key is removed, only under rolldown-vite,
113
118
  * and only from the value a plugin's `config` hook returns. Non-rolldown Vite is passed through verbatim.
114
119
  *
115
- * FLATTEN FIRST: a Vite plugin factory may return an ARRAY of plugins — `@vitejs/plugin-react`'s `react()`
120
+ * FLATTEN FIRST: a Vite plugin factory may return an ARRAY of plugins - `@vitejs/plugin-react`'s `react()`
116
121
  * returns `[vite:react-babel, vite:react-refresh]`, and it's `react:react-babel`'s `config` hook that emits
117
122
  * the offending `optimizeDeps.rollupOptions.jsx`. `nifra.config.ts` writes `vitePlugins = [react()]`, so the
118
123
  * plugin list arrives NESTED (`[[babel, refresh]]`). Without flattening, `.map` sees the inner array (which
119
- * has no `config`), leaves it untouched, and Vite — which flattens plugin arrays itself before running them
120
- * — then executes the un-stripped babel hook, so the warning survives. Flattening here (Vite accepts a flat
124
+ * has no `config`), leaves it untouched, and Vite - which flattens plugin arrays itself before running them
125
+ * - then executes the un-stripped babel hook, so the warning survives. Flattening here (Vite accepts a flat
121
126
  * list identically) is what lets the strip reach every real plugin.
122
127
  */
123
128
  export function normalizeRolldownPlugins(plugins, isRolldown) {
@@ -149,7 +154,7 @@ export function normalizeRolldownPlugins(plugins, isRolldown) {
149
154
  return plugin;
150
155
  const wrappedHandler = (config, env) => {
151
156
  const returned = handler(config, env);
152
- // The hook may return a promise — normalize both shapes.
157
+ // The hook may return a promise - normalize both shapes.
153
158
  return returned instanceof Promise ? returned.then(stripJsxKey) : stripJsxKey(returned);
154
159
  };
155
160
  // Preserve the ORIGINAL shape: a function stays a function; the object form keeps its `order`
@@ -177,13 +182,25 @@ export async function createViteDevServer(options) {
177
182
  writeClientEntry();
178
183
  const entryUrl = `/${DEV_ENTRY}`;
179
184
  // Create our HTTP server FIRST, then hand it to Vite as the HMR WebSocket host (`hmr.server`). In
180
- // middleware mode Vite would otherwise open a *separate* ws port (24678) — fragile: it conflicts
185
+ // middleware mode Vite would otherwise open a *separate* ws port (24678) - fragile: it conflicts
181
186
  // across restarts ("Port undefined is already in use" → the client never connects). Sharing one
182
187
  // port means HMR rides the same origin as the app, robust across restarts. The handler closes over
183
188
  // `vite`, which is assigned just below before the server starts listening.
184
189
  let vite;
185
190
  let app;
191
+ // The most recent SSR failure, served as JSON at LAST_ERROR_PATH. Shared with the Bun adapter so the
192
+ // endpoint and its headers can't drift between the two dev servers.
193
+ const devDiagnostics = createDevDiagnostics(root);
186
194
  const server = createHttpServer((req, res) => {
195
+ // Keep this before Vite's middleware: it is an agent endpoint owned by nifra, not a file or app route.
196
+ if (devDiagnostics.isLastErrorPath((req.url ?? "/").split("?", 1)[0] ?? "/")) {
197
+ const { body, headers } = devDiagnostics.lastError();
198
+ res.statusCode = 200;
199
+ for (const [key, value] of Object.entries(headers))
200
+ res.setHeader(key, value);
201
+ res.end(body);
202
+ return;
203
+ }
187
204
  vite.middlewares(req, res, () => {
188
205
  // Not a Vite asset → nifra SSR. (`next` runs after Vite declines, so the body is still readable.)
189
206
  void (async () => {
@@ -193,7 +210,7 @@ export async function createViteDevServer(options) {
193
210
  const contentType = nifraRes.headers.get("content-type") ?? "";
194
211
  res.statusCode = nifraRes.status;
195
212
  if (!contentType.includes("text/html")) {
196
- // Data / redirect / asset response — pass through untouched, streamed (SSE-safe). Set-Cookie is
213
+ // Data / redirect / asset response - pass through untouched, streamed (SSE-safe). Set-Cookie is
197
214
  // emitted per-header so multi-cookie responses (e.g. better-auth sessions) aren't collapsed.
198
215
  applyResponseHeaders(nifraRes.headers, res);
199
216
  await pipeWebBodyToNode(nifraRes.body, res);
@@ -206,26 +223,34 @@ export async function createViteDevServer(options) {
206
223
  }
207
224
  catch (err) {
208
225
  // Source-map the stack first (Vite maps the bundled frames back to your `.ts`), then render
209
- // the readable dev overlay instead of a bare text dump. Dev-only — production maps to `_error`.
226
+ // the readable dev overlay instead of a bare text dump. Dev-only - production maps to `_error`.
210
227
  if (err instanceof Error)
211
228
  vite.ssrFixStacktrace(err);
229
+ const html = devDiagnostics.capture(err, {
230
+ method: req.method ?? "GET",
231
+ url: req.url ?? "/",
232
+ });
212
233
  res.statusCode = 500;
213
234
  res.setHeader("content-type", "text/html; charset=utf-8");
214
- res.end(renderDevErrorOverlay(err, { method: req.method ?? "GET", url: req.url ?? "/" }));
235
+ res.end(html);
215
236
  }
216
237
  })();
217
238
  });
218
239
  });
219
240
  // `conditions: ["bun"]` makes Vite resolve nifra's workspace packages (`@nifrajs/web-react/client`, …) to
220
- // their TS **source** — so the dev server needs no prior `dist` build of the adapter packages.
241
+ // their TS **source** - so the dev server needs no prior `dist` build of the adapter packages.
221
242
  const usePolling = options.poll ?? process.env.CHOKIDAR_USEPOLLING === "1";
222
- const viteModule = (await import("vite"));
243
+ // Never `import("vite")` directly here: the guard in `importVite` has to run first, and the dev
244
+ // server importing vite unguarded is precisely what poisoned the module for the whole process.
245
+ const viteModule = await importVite();
223
246
  const { createServer } = viteModule;
224
247
  // Under rolldown-vite (Vite 8+), strip the stale `optimizeDeps.rollupOptions.jsx` some framework
225
- // plugins still emit — it triggers a noisy "Invalid key … jsx" warning but does nothing useful here.
248
+ // plugins still emit - it triggers a noisy "Invalid key … jsx" warning but does nothing useful here.
226
249
  const plugins = normalizeRolldownPlugins(options.plugins ?? [], viteModule.rolldownVersion !== undefined);
227
250
  vite = await createServer({
228
251
  root,
252
+ // Dev must not inherit Vite's default `VITE_*` exposure beside Nifra's documented boundary.
253
+ envPrefix: vitePublicEnvPrefix(options.publicEnvPrefix),
229
254
  ...(options.publicDir !== undefined ? { publicDir: options.publicDir } : {}),
230
255
  appType: "custom",
231
256
  server: {
@@ -234,13 +259,15 @@ export async function createViteDevServer(options) {
234
259
  // Explicit watch config; poll when native fs events aren't delivered (containers/sandboxes).
235
260
  watch: usePolling ? { usePolling: true, interval: 80 } : {},
236
261
  },
237
- plugins: [...plugins],
262
+ // Ahead of the user's plugins: a `*.fn` module must be replaced before anything else
263
+ // reads it, and the dev server is a client bundler like any other.
264
+ plugins: [viteServerFnStub(), viteServerOnlyEmpty(), ...plugins],
238
265
  resolve: {
239
266
  conditions: [...(options.conditions ?? []), "bun", "module", "browser", "development"],
240
267
  // Dedupe React to ONE copy. In a multi-root workspace a shared package can pull react/react-dom
241
268
  // from a SIBLING app's node_modules, so the dev server loads two React cores → a second hook
242
269
  // dispatcher → `resolveDispatcher().useState` null on any hook-using route (the error points at the
243
- // component, not the resolution — brutal to diagnose). Mirrors the build-time reactDedupePlugin so
270
+ // component, not the resolution - brutal to diagnose). Mirrors the build-time reactDedupePlugin so
244
271
  // dev matches prod. No-op for non-React apps (the package simply isn't present to dedupe).
245
272
  dedupe: ["react", "react-dom"],
246
273
  },
@@ -271,7 +298,7 @@ export async function createViteDevServer(options) {
271
298
  });
272
299
  }
273
300
  try {
274
- await listenOrExplain(server, port);
301
+ await listenOrExplain(server, port, "127.0.0.1");
275
302
  }
276
303
  catch (err) {
277
304
  // Nothing is listening, but Vite is fully up by now - watchers, the dep optimizer, its own sockets -
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA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AC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,qGAAqG;QACrG,qGAAqG;QACrG,sGAAsG;QACtG,0EAA0E;QAC1E,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAClC,MAAM,GAAG,CAAA;IACX,CAAC;IACD,qGAAqG;IACrG,sGAAsG;IACtG,gFAAgF;IAChF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IAChC,OAAO;QACL,IAAI,EAAE,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;QAC3E,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nifrajs/web",
3
- "version": "2.2.0",
4
- "description": "Framework-agnostic SSR core for nifra — the render seam + HTML document orchestration.",
3
+ "version": "2.4.0",
4
+ "description": "Framework-agnostic SSR core for nifra - the render seam + HTML document orchestration.",
5
5
  "keywords": [
6
6
  "bun",
7
7
  "typescript",
@@ -39,6 +39,11 @@
39
39
  "types": "./dist/client.d.ts",
40
40
  "default": "./dist/client.js"
41
41
  },
42
+ "./diagnostic": {
43
+ "bun": "./src/diagnostic.ts",
44
+ "types": "./dist/diagnostic.d.ts",
45
+ "default": "./dist/diagnostic.js"
46
+ },
42
47
  "./forms": {
43
48
  "bun": "./src/forms.ts",
44
49
  "types": "./dist/forms.d.ts",
@@ -54,6 +59,11 @@
54
59
  "types": "./dist/islands.d.ts",
55
60
  "default": "./dist/islands.js"
56
61
  },
62
+ "./service-worker": {
63
+ "bun": "./src/service-worker.ts",
64
+ "types": "./dist/service-worker.d.ts",
65
+ "default": "./dist/service-worker.js"
66
+ },
57
67
  "./server-only": {
58
68
  "bun": "./src/server-only.ts",
59
69
  "types": "./dist/server-only.d.ts",
@@ -121,12 +131,36 @@
121
131
  },
122
132
  "./css-modules": {
123
133
  "types": "./css-modules.d.ts"
134
+ },
135
+ "./server-manifest": {
136
+ "types": "./server-manifest.d.ts"
137
+ },
138
+ "./fn": {
139
+ "bun": "./src/fn.ts",
140
+ "types": "./dist/fn.d.ts",
141
+ "default": "./dist/fn.js"
142
+ },
143
+ "./plugins/vite-server-fn": {
144
+ "bun": "./src/plugins/vite-server-fn.ts",
145
+ "types": "./dist/plugins/vite-server-fn.d.ts",
146
+ "default": "./dist/plugins/vite-server-fn.js"
147
+ },
148
+ "./plugins/vite-server-only": {
149
+ "bun": "./src/plugins/vite-server-only.ts",
150
+ "types": "./dist/plugins/vite-server-only.d.ts",
151
+ "default": "./dist/plugins/vite-server-only.js"
152
+ },
153
+ "./fn-state": {
154
+ "bun": "./src/fn-state.ts",
155
+ "types": "./dist/fn-state.d.ts",
156
+ "default": "./dist/fn-state.js"
124
157
  }
125
158
  },
126
159
  "files": [
127
160
  "dist",
128
161
  "src",
129
- "css-modules.d.ts"
162
+ "css-modules.d.ts",
163
+ "server-manifest.d.ts"
130
164
  ],
131
165
  "sideEffects": false,
132
166
  "scripts": {
@@ -137,7 +171,7 @@
137
171
  "access": "public"
138
172
  },
139
173
  "dependencies": {
140
- "@nifrajs/core": "2.2.0"
174
+ "@nifrajs/core": "2.4.0"
141
175
  },
142
176
  "peerDependencies": {
143
177
  "sass": "^1.0.0",
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Ambient fallback types for a generated `server-manifest` module.
3
+ *
4
+ * `nifra build --target <t>` generates `server-manifest.ts` NEXT TO the server entry at build time, so a
5
+ * HAND-WRITTEN entry that imports `./server-manifest` has nothing to typecheck against until the first
6
+ * build - which is what forces a `@ts-nocheck` onto the very file that deploys. Reference this so the
7
+ * import is typed before then. Either from a `.d.ts` in your project:
8
+ *
9
+ * ```ts
10
+ * /// <reference types="@nifrajs/web/server-manifest" />
11
+ * ```
12
+ *
13
+ * or list it in `tsconfig.json` -> `compilerOptions.types: ["@nifrajs/web/server-manifest"]`.
14
+ *
15
+ * Once a build (or `nifra sync-manifest`) has written the real `server-manifest` next to your entry,
16
+ * TypeScript resolves the relative import to that file and its types win; this only fills the gap before
17
+ * then. Not needed with `nifra build --target`, which generates and bundles its own entry - a hand-written
18
+ * entry is the case this exists for.
19
+ */
20
+
21
+ declare module "*/server-manifest" {
22
+ import type { Manifest } from "@nifrajs/web"
23
+ /** Hashed client-bootstrap URL the entry passes to `createWebApp` (the hydration `<script src>`). */
24
+ export const clientEntry: string
25
+ /** Global stylesheet URLs, emitted as `<link rel="stylesheet">`. */
26
+ export const styles: readonly string[]
27
+ /** Per-route stylesheet URLs, keyed by route-relative source file. */
28
+ export const routeStyles: Readonly<Record<string, readonly string[]>>
29
+ /** The route manifest `createWebApp` renders. */
30
+ export const manifest: Manifest
31
+ }
package/src/build-vite.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `@nifrajs/web/build-vite` — the **Vite/Rollup production build**: the escape hatch, not the default.
2
+ * `@nifrajs/web/build-vite` - the **Vite/Rollup production build**: the escape hatch, not the default.
3
3
  *
4
4
  * nifra's production default is Bun (`@nifrajs/web/build`), and stays so - it is faster and Bun-native,
5
5
  * which is what nifra competes on. This exists for the one case that default cannot serve: an app whose
@@ -33,10 +33,14 @@ import {
33
33
  } from "./build.ts"
34
34
  import { discoverRoutes } from "./fs.ts"
35
35
  import { generateClientEntry, generateServerManifest } from "./index.ts"
36
+ import { vitePublicEnvPrefix } from "./internal/server-boundary.ts"
37
+ import { importVite, isViteUnresolved } from "./internal/vite-import.ts"
36
38
  import { viteLeakGuard } from "./plugins/vite-leak-guard.ts"
39
+ import { viteServerFnStub } from "./plugins/vite-server-fn.ts"
40
+ import { viteServerOnlyEmpty } from "./plugins/vite-server-only.ts"
37
41
 
38
42
  // ---------------------------------------------------------------------------------------------------
39
- // Structural Vite typings — no hard `vite` dependency (mirrors vite.ts). Only the build API is used.
43
+ // Structural Vite typings - no hard `vite` dependency (mirrors vite.ts). Only the build API is used.
40
44
  // ---------------------------------------------------------------------------------------------------
41
45
 
42
46
  /** One entry in Vite's `.vite/manifest.json`: its emitted file + transitive CSS + imported chunks. */
@@ -53,73 +57,14 @@ interface ViteModule {
53
57
  build(config: Record<string, unknown>): Promise<unknown>
54
58
  }
55
59
 
56
- /**
57
- * Restore V8's `Error.captureStackTrace` contract on a runtime that is stricter than it.
58
- *
59
- * `captureStackTrace` is a V8 API, and V8 decorates ANY object handed to it. Some runtimes instead
60
- * require a real Error - one with the internal slot, which `Object.create(Error.prototype)` and
61
- * `new SubclassWithErrorPrototype()` do NOT have - and throw "First argument must be an Error object".
62
- *
63
- * That breaks importing vite outright. Vite bundles `follow-redirects`, which builds its error types the
64
- * pre-class way:
65
- *
66
- * function CustomError(props) { Error.captureStackTrace(this, this.constructor); … }
67
- * CustomError.prototype = new (baseClass || Error)()
68
- *
69
- * The last line CONSTRUCTS `baseClass` while defining the subclass, so `this` is an object that inherits
70
- * from Error but was never built by it - and the throw happens at module evaluation, before vite exports
71
- * anything. Every Vite build then fails with a message about stack traces, naming nothing about vite.
72
- *
73
- * Decorating a stack is best-effort by definition, so swallowing the rejection loses nothing: the shim
74
- * delegates, and only suppresses the refusal. Installed once, and deliberately not restored - the strict
75
- * behaviour is the deviation, and a library evaluated later would hit the same wall.
76
- */
77
- function relaxCaptureStackTrace(): void {
78
- const strict = Error.captureStackTrace
79
- if (
80
- typeof strict !== "function" ||
81
- Object.prototype.toString.call(new Error()) !== "[object Error]"
82
- ) {
83
- return
84
- }
85
- // Probe rather than sniff a version: construct exactly what follow-redirects does and see if it is
86
- // refused. A runtime that already follows V8 keeps its own implementation untouched.
87
- const inherited = Object.create(Error.prototype)
88
- try {
89
- strict.call(Error, inherited)
90
- return // permissive already - nothing to fix
91
- } catch {
92
- // stricter than V8; fall through and wrap
93
- }
94
- try {
95
- Error.captureStackTrace = ((target: object, constructorOpt?: unknown) => {
96
- try {
97
- ;(strict as (t: object, c?: unknown) => void).call(Error, target, constructorOpt)
98
- } catch {
99
- // The runtime refused to decorate this object. A missing `.stack` is not worth failing over.
100
- }
101
- }) as typeof Error.captureStackTrace
102
- } catch {
103
- // The property is frozen or non-writable. Nothing can be done about the import that follows, but
104
- // failing HERE would replace vite's own error with an assignment error - strictly less informative
105
- // than letting the import fail and be reported by `loadVite`.
106
- }
107
- }
108
-
109
60
  /** Load the app's Vite. Resolved from `root` so it's the project's copy, not this package's. */
110
61
  async function loadVite(): Promise<ViteModule> {
111
- relaxCaptureStackTrace()
112
62
  try {
113
- return (await import("vite")) as unknown as ViteModule
63
+ return await importVite<ViteModule>()
114
64
  } catch (cause) {
115
- // Two different failures arrive here and must not be conflated. `vite` is an OPTIONAL peer, so a
116
- // project without it fails to RESOLVE - the common case, and the one worth naming. But vite can
117
- // also resolve and fail while EVALUATING, which is not a missing dependency at all: vite 8 loads
118
- // rolldown's native binding on import, and a binding that will not load surfaces here too. Telling
119
- // that user to install what they already installed sends them the wrong way, so only a resolution
120
- // failure claims a missing package; anything else is reported as what it is.
65
+ // The two failures must not be conflated - see `isViteUnresolved`.
121
66
  const message = cause instanceof Error ? cause.message : String(cause)
122
- const unresolved = /cannot find (?:package|module)|ERR_MODULE_NOT_FOUND/i.test(message)
67
+ const unresolved = isViteUnresolved(cause)
123
68
  throw new Error(
124
69
  unresolved
125
70
  ? "[nifra/web] the Vite production build needs `vite` installed in this project (it is an " +
@@ -160,7 +105,7 @@ async function withSerializedNodeEnv<T>(mode: string, run: () => Promise<T>): Pr
160
105
  }
161
106
  }
162
107
 
163
- /** Options for {@link buildClientVite} — the Bun {@link BuildClientOptions} minus Bun-plugin specifics,
108
+ /** Options for {@link buildClientVite} - the Bun {@link BuildClientOptions} minus Bun-plugin specifics,
164
109
  * plus the Vite plugin list the app injects for its transforms. */
165
110
  export interface BuildClientViteOptions extends Omit<BuildClientOptions, "plugins"> {
166
111
  /** Vite plugins for the app's client transforms (e.g. `react()`, `vue()`). */
@@ -195,7 +140,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
195
140
  `globalThis.process ??= { env: {} };\n${generateClientEntry(routeManifest, { clientModule, resolve })}`,
196
141
  )
197
142
 
198
- // Every unique route/layout/_404 file — each an additional entry so Vite emits a named chunk per file
143
+ // Every unique route/layout/_404 file - each an additional entry so Vite emits a named chunk per file
199
144
  // the bootstrap's lazy import dedupes to, giving the per-route chunk + CSS mapping below.
200
145
  const routeFiles = [
201
146
  ...new Set([
@@ -205,7 +150,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
205
150
  ]),
206
151
  ].sort()
207
152
 
208
- // Vite manifest keys are the input path RELATIVE TO ROOT — precompute them so the lookup below is exact
153
+ // Vite manifest keys are the input path RELATIVE TO ROOT - precompute them so the lookup below is exact
209
154
  // (survives same-basename collisions like `index.tsx` + `blog/index.tsx`).
210
155
  const keyOf = (absPath: string): string => relative(root, absPath).replaceAll("\\", "/")
211
156
  const entryKey = keyOf(entryFile)
@@ -214,7 +159,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
214
159
  for (const file of routeFiles) {
215
160
  const abs = resolvePath(resolve(file))
216
161
  // FLAT input names (no `/`), so Vite emits `routes_index_tsx-HASH.js` in `outDir` directly, not a
217
- // nested `routes/…` dir — the deploy assembly + size report map asset URLs by basename and expect a
162
+ // nested `routes/…` dir - the deploy assembly + size report map asset URLs by basename and expect a
218
163
  // flat layout. The manifest LOOKUP below is keyed by the src path (`keyOf`), independent of this name.
219
164
  input[keyOf(abs).replace(/[^\w]/g, "_")] = abs
220
165
  fileKey.set(file, keyOf(abs))
@@ -236,6 +181,8 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
236
181
  root,
237
182
  base: publicPath,
238
183
  mode,
184
+ // Override Vite's independent `VITE_*` boundary; Nifra has one public-env policy.
185
+ envPrefix: vitePublicEnvPrefix(options.publicEnvPrefix),
239
186
  logLevel: "silent",
240
187
  // Nifra owns publicDir copying so direct and target builds share symlink confinement and
241
188
  // deploy-root placement. Vite's automatic copy would put root files inside /assets.
@@ -265,8 +212,8 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
265
212
  // without this. External here means the guard fails the build (below) with the exact builtin.
266
213
  external: [/^node:/],
267
214
  input,
268
- // The leak guard is a Rollup plugin — last, so it sees the final graph.
269
- plugins: [leakGuard],
215
+ // The leak guard is a Rollup plugin - last, so it sees the final graph.
216
+ plugins: [viteServerFnStub(), viteServerOnlyEmpty(), leakGuard],
270
217
  output: {
271
218
  entryFileNames: "[name]-[hash].js",
272
219
  chunkFileNames: "[name]-[hash].js",
@@ -325,7 +272,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
325
272
  routes._404 = c !== undefined ? [c] : []
326
273
  }
327
274
 
328
- // CSS per route — Vite's manifest `css` is the transitive stylesheet set for that entry.
275
+ // CSS per route - Vite's manifest `css` is the transitive stylesheet set for that entry.
329
276
  const stylesFor = (files: readonly string[]): readonly string[] => {
330
277
  const urls = new Set<string>()
331
278
  for (const file of files) {
@@ -335,7 +282,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
335
282
  }
336
283
  return [...urls]
337
284
  }
338
- // CSS aggregate — every stylesheet the app emits, the always-safe fallback.
285
+ // CSS aggregate - every stylesheet the app emits, the always-safe fallback.
339
286
  const allCss = new Set<string>()
340
287
  for (const entry of Object.values(viteManifest)) {
341
288
  for (const css of entry.css ?? []) allCss.add(url(css))
@@ -347,7 +294,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
347
294
  if (routeManifest.notFound) routeStyles._404 = stylesFor([routeManifest.notFound.file])
348
295
  }
349
296
 
350
- // assets — every emitted file + stylesheet across the manifest (chunks, entries, css).
297
+ // assets - every emitted file + stylesheet across the manifest (chunks, entries, css).
351
298
  const assets = new Set<string>()
352
299
  for (const entry of Object.values(viteManifest)) {
353
300
  assets.add(url(entry.file))
@@ -371,7 +318,7 @@ export async function buildClientVite(options: BuildClientViteOptions): Promise<
371
318
  return manifest
372
319
  }
373
320
 
374
- /** Options for {@link buildServerVite} — the same surface as `buildServer` minus Bun-plugin specifics. */
321
+ /** Options for {@link buildServerVite} - the same surface as `buildServer` minus Bun-plugin specifics. */
375
322
  export interface BuildServerViteOptions {
376
323
  readonly routesDir: string
377
324
  readonly serverEntry: string
@@ -385,7 +332,7 @@ export interface BuildServerViteOptions {
385
332
  readonly conditions?: readonly string[]
386
333
  readonly define?: Readonly<Record<string, string>>
387
334
  readonly minify?: boolean
388
- /** The runtime the worker targets — mirrors `buildServer`. `browser` = the edge (workerd/edge-light). */
335
+ /** The runtime the worker targets - mirrors `buildServer`. `browser` = the edge (workerd/edge-light). */
389
336
  readonly target?: "browser" | "node" | "bun"
390
337
  /** Vite project root (default: the parent of `routesDir`). */
391
338
  readonly root?: string
@@ -490,7 +437,7 @@ export async function buildServerVite(options: BuildServerViteOptions): Promise<
490
437
  generateServerManifest(routeManifest, { resolve, clientEntry, styles, routeStyles }),
491
438
  )
492
439
 
493
- // Pin the mode to match NODE_ENV — the react plugin's JSX runtime (jsx vs jsxDEV) follows it, and a
440
+ // Pin the mode to match NODE_ENV - the react plugin's JSX runtime (jsx vs jsxDEV) follows it, and a
494
441
  // mismatch throws `jsxDEV is not a function` at SSR (see buildClientVite for the full reasoning).
495
442
  const mode = options.minify === false ? "development" : "production"
496
443
  const vite = await loadVite()
@@ -560,7 +507,7 @@ export async function buildServerVite(options: BuildServerViteOptions): Promise<
560
507
  }
561
508
 
562
509
  /**
563
- * The Vite build STRATEGY — plugged into `buildTargetWith`. `plugins` arriving through the shared
510
+ * The Vite build STRATEGY - plugged into `buildTargetWith`. `plugins` arriving through the shared
564
511
  * orchestrator are the app's Vite plugins (the escape hatch's whole reason), cast to Vite's plugin type.
565
512
  */
566
513
  export const viteBundler: Bundler = {