@nuxt/nitro-server-nightly 4.5.1-29752449.30d24817 → 4.5.2-2610052030-052d82e

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 (34) hide show
  1. package/dist/augments.d.mts +82 -230
  2. package/dist/index.d.mts +2 -3
  3. package/dist/index.mjs +559 -228
  4. package/dist/request-types.d.mts +23 -0
  5. package/dist/request-types.mjs +1 -0
  6. package/dist/runtime/diagnostics.mjs +7 -16
  7. package/dist/runtime/handlers/error-channel.mjs +17 -0
  8. package/dist/runtime/handlers/error.mjs +110 -23
  9. package/dist/runtime/handlers/island.mjs +107 -27
  10. package/dist/runtime/handlers/renderer.mjs +19 -542
  11. package/dist/runtime/nitro-server/src/h3.mjs +3 -0
  12. package/dist/runtime/nuxt/src/app/error.mjs +32 -0
  13. package/dist/runtime/nuxt/src/app/internal/tracing.mjs +1 -1
  14. package/dist/runtime/plugins/dev-errors.mjs +62 -0
  15. package/dist/runtime/plugins/dev-server-logs.mjs +2 -2
  16. package/dist/runtime/server.mjs +231 -0
  17. package/dist/runtime/utils/cache-driver.mjs +8 -7
  18. package/dist/runtime/utils/cache.mjs +1 -1
  19. package/dist/runtime/utils/error-channel.mjs +104 -0
  20. package/dist/runtime/utils/event.mjs +235 -0
  21. package/dist/runtime/utils/island-props.mjs +12 -2
  22. package/dist/runtime/utils/paths.mjs +1 -1
  23. package/dist/runtime/utils/prerender.mjs +32 -0
  24. package/dist/runtime/utils/renderer/options.mjs +64 -0
  25. package/dist/runtime/utils/response.mjs +22 -0
  26. package/package.json +27 -24
  27. package/dist/runtime/templates/error-500.mjs +0 -18
  28. package/dist/runtime/utils/dev.mjs +0 -988
  29. package/dist/runtime/utils/renderer/app.mjs +0 -44
  30. package/dist/runtime/utils/renderer/build-files.mjs +0 -71
  31. package/dist/runtime/utils/renderer/cache.mjs +0 -13
  32. package/dist/runtime/utils/renderer/inline-styles.mjs +0 -12
  33. package/dist/runtime/utils/renderer/islands.mjs +0 -127
  34. package/dist/runtime/utils/renderer/payload.mjs +0 -77
@@ -1,31 +1,44 @@
1
1
  import { EventHandler, H3Event } from "h3";
2
- import { Nitro, NitroConfig, NitroDevEventHandler, NitroEventHandler, NitroOptions, NitroRouteConfig, NitroRuntimeConfig, NitroRuntimeConfigApp } from "nitropack/types";
3
- import { LogObject } from "consola";
4
- import { NuxtIslandContext, NuxtIslandResponse, NuxtRenderChunkContext, NuxtRenderCloseContext, NuxtRenderHTMLContext, NuxtRenderRouteContext } from "#app/types";
5
- import { HookResult, RuntimeConfig, TSReference } from "nuxt/schema";
6
-
2
+ import { Nitro, NitroConfig, NitroDevEventHandler, NitroEventHandler, NitroOptions, NitroRouteConfig, NitroRouteRules, NitroRuntimeConfig } from "nitropack/types";
3
+ import { DevServerLog, NuxtIslandContext, NuxtIslandResponse, NuxtRenderChunkContext, NuxtRenderCloseContext, NuxtRenderHTMLContext, NuxtRenderRouteContext } from "#app/types";
4
+ import { NuxtRequestContext, NuxtRequestContext as NuxtRequestContext$1, RouteRuleConfigExtensions, RuntimeConfig, RuntimeConfigApp, TracingChannelOptions } from "nuxt/schema";
7
5
  //#region src/augments.d.ts
8
- /**
9
- * Per-channel toggles for `tracingChannel`, with a `nuxt` key for Nuxt-owned
10
- * channels (`nuxt.render`, `nuxt.island`, `nuxt.data`, `nuxt.plugin`). Channel
11
- * names follow the [untracing](https://github.com/unjs/untracing) naming
12
- * convention (`{namespace}.{operation}`).
13
- *
14
- * @experimental Channel names, payload shapes, and option keys may change.
15
- */
16
- interface NuxtTracingChannelOptions {
17
- /** Enable Nuxt-owned channels (`nuxt.render`, `nuxt.island`, `nuxt.data`, `nuxt.plugin`). */
18
- nuxt?: boolean;
6
+ /** The channels this package's runtime forwards, alongside the Nuxt-owned ones. */
7
+ interface NitroTracingChannels {
19
8
  srvx?: boolean;
20
9
  h3?: boolean;
21
10
  unstorage?: boolean;
22
11
  }
23
- declare module "nitropack" {
24
- interface NitroRuntimeConfigApp {
25
- buildAssetsDir: string;
26
- cdnURL: string;
27
- buildId: string;
12
+ /**
13
+ * Per-channel toggles for `tracingChannel`: the channels this runtime forwards, plus the
14
+ * Nuxt-owned channels.
15
+ *
16
+ * @experimental Channel names, payload shapes, and option keys may change.
17
+ */
18
+ export type NuxtTracingChannelOptions = TracingChannelOptions;
19
+ /**
20
+ * Dev-only access to the SSR bundle's transformed modules, registered by the bundler that
21
+ * evaluates them in the Nitro process.
22
+ *
23
+ * @experimental
24
+ */
25
+ export interface SSRSourceMaps {
26
+ /** Transformed code of an SSR module as it was evaluated. */
27
+ getCode: (file: string) => string | undefined;
28
+ /** Position in generated code a source position was mapped from. */
29
+ getCompiledPosition?: (file: string, line: number, column?: number) => {
30
+ file: string;
31
+ line: number;
32
+ column: number;
33
+ } | undefined;
34
+ }
35
+ declare global {
36
+ interface ImportMeta {
37
+ dev: boolean;
38
+ test: boolean;
28
39
  }
40
+ }
41
+ declare module "nitropack" {
29
42
  interface NitroRouteRules {
30
43
  ssr?: boolean;
31
44
  streaming?: boolean;
@@ -39,11 +52,6 @@ declare module "nitropack" {
39
52
  }
40
53
  }
41
54
  declare module "nitropack/types" {
42
- interface NitroRuntimeConfigApp {
43
- buildAssetsDir: string;
44
- cdnURL: string;
45
- buildId: string;
46
- }
47
55
  interface NitroRouteRules {
48
56
  ssr?: boolean;
49
57
  streaming?: boolean;
@@ -57,7 +65,18 @@ declare module "nitropack/types" {
57
65
  }
58
66
  }
59
67
  declare module "nitropack" {
68
+ interface NitroApp {
69
+ /**
70
+ * Only set in development, by bundlers that evaluate the SSR bundle within
71
+ * the Nitro process.
72
+ *
73
+ * @experimental
74
+ */
75
+ ssrSourceMaps?: SSRSourceMaps;
76
+ }
60
77
  interface NitroRuntimeConfig extends RuntimeConfig {}
78
+ interface NitroRuntimeConfigApp extends RuntimeConfigApp {}
79
+ interface NitroRouteConfig extends RouteRuleConfigExtensions {}
61
80
  interface NitroRouteConfig {
62
81
  ssr?: boolean;
63
82
  streaming?: boolean;
@@ -67,7 +86,7 @@ declare module "nitropack" {
67
86
  }
68
87
  interface NitroRuntimeHooks {
69
88
  "dev:ssr-logs": (ctx: {
70
- logs: LogObject[];
89
+ logs: DevServerLog[];
71
90
  path: string;
72
91
  }) => void | Promise<void>;
73
92
  "render:html": (htmlContext: NuxtRenderHTMLContext, context: {
@@ -90,7 +109,18 @@ declare module "nitropack" {
90
109
  }
91
110
  }
92
111
  declare module "nitropack/types" {
112
+ interface NitroApp {
113
+ /**
114
+ * Only set in development, by bundlers that evaluate the SSR bundle within
115
+ * the Nitro process.
116
+ *
117
+ * @experimental
118
+ */
119
+ ssrSourceMaps?: SSRSourceMaps;
120
+ }
93
121
  interface NitroRuntimeConfig extends RuntimeConfig {}
122
+ interface NitroRuntimeConfigApp extends RuntimeConfigApp {}
123
+ interface NitroRouteConfig extends RouteRuleConfigExtensions {}
94
124
  interface NitroRouteConfig {
95
125
  ssr?: boolean;
96
126
  streaming?: boolean;
@@ -100,7 +130,7 @@ declare module "nitropack/types" {
100
130
  }
101
131
  interface NitroRuntimeHooks {
102
132
  "dev:ssr-logs": (ctx: {
103
- logs: LogObject[];
133
+ logs: DevServerLog[];
104
134
  path: string;
105
135
  }) => void | Promise<void>;
106
136
  "render:html": (htmlContext: NuxtRenderHTMLContext, context: {
@@ -122,106 +152,25 @@ declare module "nitropack/types" {
122
152
  }) => void | Promise<void>;
123
153
  }
124
154
  }
155
+ /** The types this package contributes to Nuxt's build-time registry. */
156
+ interface NitroSchemaTypes {
157
+ instance: Nitro;
158
+ config: NitroConfig;
159
+ handler: NitroEventHandler;
160
+ devHandler: NitroDevEventHandler;
161
+ routeRuleConfig: NitroRouteConfig;
162
+ tracingChannels: NitroTracingChannels;
163
+ }
164
+ /** The types this package's runtime contributes to the app layer. */
165
+ interface NitroServerTypes {
166
+ event: H3Event;
167
+ eventHandler: EventHandler;
168
+ routeRules: NitroRouteRules;
169
+ }
125
170
  declare module "@nuxt/schema" {
126
- interface NuxtHooks {
127
- /**
128
- * Called when the dev middleware is being registered on the Nitro dev server.
129
- * @param handler the Vite or Webpack event handler
130
- * @returns Promise
131
- */
132
- "server:devHandler": (handler: EventHandler, options: {
133
- cors: (path: string) => boolean;
134
- }) => HookResult;
135
- /**
136
- * Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
137
- * @param options Objects containing `references`, `declarations`
138
- * @param options.references Array of TypeScript references to add
139
- * @param options.declarations Array of declaration strings to add
140
- * @returns Promise
141
- */
142
- "nitro:prepare:types": (options: {
143
- references: TSReference[];
144
- declarations: string[];
145
- }) => HookResult;
146
- /**
147
- * Called before initializing Nitro, allowing customization of Nitro's configuration.
148
- * @param nitroConfig The nitro config to be extended
149
- * @returns Promise
150
- */
151
- "nitro:config": (nitroConfig: NitroConfig) => HookResult;
152
- /**
153
- * Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
154
- * @param nitro The created nitro object
155
- * @returns Promise
156
- */
157
- "nitro:init": (nitro: Nitro) => HookResult;
158
- /**
159
- * Called before building the Nitro instance.
160
- * @param nitro The created nitro object
161
- * @returns Promise
162
- */
163
- "nitro:build:before": (nitro: Nitro) => HookResult;
164
- /**
165
- * Called after copying public assets. Allows modifying public assets before Nitro server is built.
166
- * @param nitro The created nitro object
167
- * @returns Promise
168
- */
169
- "nitro:build:public-assets": (nitro: Nitro) => HookResult;
170
- }
171
- interface ConfigSchema {
172
- /**
173
- * Configuration for Nitro.
174
- *
175
- * @see [Nitro configuration docs](https://nitro.build/config)
176
- */
177
- nitro: NitroConfig;
178
- /**
179
- * Global route options applied to matching server routes.
180
- *
181
- * @experimental This is an experimental feature and API may change in the future.
182
- *
183
- * @see [Nitro route rules documentation](https://nitro.build/config#routerules)
184
- */
185
- routeRules: NitroConfig["routeRules"];
186
- /**
187
- * Nitro server handlers.
188
- *
189
- * Each handler accepts the following options:
190
- * - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
191
- *
192
- * @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
193
- *
194
- * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
195
- *
196
- * @example
197
- * ```js
198
- * serverHandlers: [
199
- * { route: '/path/foo/**:name', handler: '#server/foohandler.ts' }
200
- * ]
201
- * ```
202
- */
203
- serverHandlers: NitroEventHandler[];
204
- /**
205
- * Nitro development-only server handlers.
206
- *
207
- * @see [Nitro server routes documentation](https://nitro.build/guide/routing)
208
- */
209
- devServerHandlers: NitroDevEventHandler[];
210
- /**
211
- * Enable [diagnostics-channel](https://nodejs.org/api/diagnostics_channel.html)
212
- * tracing for Nuxt-owned subsystems (the `nuxt.*` channels).
213
- *
214
- * @experimental Channel names, payload shapes, and option keys may change.
215
- *
216
- * @see [Untracing naming registry](https://github.com/unjs/untracing)
217
- */
218
- tracingChannel: boolean | NuxtTracingChannelOptions;
219
- }
220
- interface NuxtConfig {
221
- nitro?: NitroConfig;
222
- }
171
+ interface NitroTypes extends NitroSchemaTypes {}
172
+ interface ServerTypes extends NitroServerTypes {}
223
173
  interface RuntimeConfig {
224
- app: NitroRuntimeConfigApp;
225
174
  /** Only available on the server. */
226
175
  nitro?: NitroRuntimeConfig["nitro"];
227
176
  }
@@ -229,110 +178,11 @@ declare module "@nuxt/schema" {
229
178
  /** Debug options for Nitro */
230
179
  nitro?: NitroOptions["debug"];
231
180
  }
232
- interface NuxtPage {
233
- rules?: NitroRouteConfig;
234
- }
235
181
  }
236
182
  declare module "nuxt/schema" {
237
- interface NuxtHooks {
238
- /**
239
- * Called when the dev middleware is being registered on the Nitro dev server.
240
- * @param handler the Vite or Webpack event handler
241
- * @returns Promise
242
- */
243
- "server:devHandler": (handler: EventHandler, options: {
244
- cors: (path: string) => boolean;
245
- }) => HookResult;
246
- /**
247
- * Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
248
- * @param options Objects containing `references`, `declarations`
249
- * @param options.references Array of TypeScript references to add
250
- * @param options.declarations Array of declaration strings to add
251
- * @returns Promise
252
- */
253
- "nitro:prepare:types": (options: {
254
- references: TSReference[];
255
- declarations: string[];
256
- }) => HookResult;
257
- /**
258
- * Called before initializing Nitro, allowing customization of Nitro's configuration.
259
- * @param nitroConfig The nitro config to be extended
260
- * @returns Promise
261
- */
262
- "nitro:config": (nitroConfig: NitroConfig) => HookResult;
263
- /**
264
- * Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
265
- * @param nitro The created nitro object
266
- * @returns Promise
267
- */
268
- "nitro:init": (nitro: Nitro) => HookResult;
269
- /**
270
- * Called before building the Nitro instance.
271
- * @param nitro The created nitro object
272
- * @returns Promise
273
- */
274
- "nitro:build:before": (nitro: Nitro) => HookResult;
275
- /**
276
- * Called after copying public assets. Allows modifying public assets before Nitro server is built.
277
- * @param nitro The created nitro object
278
- * @returns Promise
279
- */
280
- "nitro:build:public-assets": (nitro: Nitro) => HookResult;
281
- }
282
- interface ConfigSchema {
283
- /**
284
- * Configuration for Nitro.
285
- *
286
- * @see [Nitro configuration docs](https://nitro.build/config)
287
- */
288
- nitro: NitroConfig;
289
- /**
290
- * Global route options applied to matching server routes.
291
- *
292
- * @experimental This is an experimental feature and API may change in the future.
293
- *
294
- * @see [Nitro route rules documentation](https://nitro.build/config#routerules)
295
- */
296
- routeRules: NitroConfig["routeRules"];
297
- /**
298
- * Nitro server handlers.
299
- *
300
- * Each handler accepts the following options:
301
- * - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
302
- *
303
- * @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
304
- *
305
- * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
306
- *
307
- * @example
308
- * ```js
309
- * serverHandlers: [
310
- * { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
311
- * ]
312
- * ```
313
- */
314
- serverHandlers: NitroEventHandler[];
315
- /**
316
- * Nitro development-only server handlers.
317
- *
318
- * @see [Nitro server routes documentation](https://nitro.build/guide/routing)
319
- */
320
- devServerHandlers: NitroDevEventHandler[];
321
- /**
322
- * Enable [diagnostics-channel](https://nodejs.org/api/diagnostics_channel.html)
323
- * tracing for Nuxt-owned subsystems (the `nuxt.*` channels).
324
- *
325
- * @experimental Channel names, payload shapes, and option keys may change.
326
- *
327
- * @see [Untracing naming registry](https://github.com/unjs/untracing)
328
- */
329
- tracingChannel: boolean | NuxtTracingChannelOptions;
330
- }
331
- interface NuxtConfig {
332
- nitro?: NitroConfig;
333
- }
183
+ interface NitroTypes extends NitroSchemaTypes {}
184
+ interface ServerTypes extends NitroServerTypes {}
334
185
  interface RuntimeConfig {
335
- app: NitroRuntimeConfigApp;
336
186
  /** Only available on the server. */
337
187
  nitro?: NitroRuntimeConfig["nitro"];
338
188
  }
@@ -340,9 +190,11 @@ declare module "nuxt/schema" {
340
190
  /** Debug options for Nitro */
341
191
  nitro?: NitroOptions["debug"];
342
192
  }
343
- interface NuxtPage {
344
- rules?: NitroRouteConfig;
193
+ }
194
+ declare module "h3" {
195
+ interface H3EventContext {
196
+ nuxt?: NuxtRequestContext$1;
345
197
  }
346
198
  }
347
199
  //#endregion
348
- export { NuxtTracingChannelOptions };
200
+ export type { NuxtRequestContext };
package/dist/index.d.mts CHANGED
@@ -1,10 +1,9 @@
1
1
  import { NuxtTracingChannelOptions } from "./augments.mjs";
2
2
  import { Nitro } from "nitropack/types";
3
3
  import { Nuxt } from "@nuxt/schema";
4
-
5
4
  //#region src/index.d.ts
6
- declare function bundle(nuxt: Nuxt & {
5
+ export declare function bundle(nuxt: Nuxt & {
7
6
  _nitro?: Nitro;
8
7
  }): Promise<void>;
9
8
  //#endregion
10
- export { type NuxtTracingChannelOptions, bundle };
9
+ export type { NuxtTracingChannelOptions };