@nuxt/nitro-server 4.2.2 → 4.3.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 (67) hide show
  1. package/README.md +4 -2
  2. package/dist/index.d.mts +280 -78
  3. package/dist/index.mjs +696 -745
  4. package/dist/runtime/handlers/{error.d.ts → error.d.mts} +1 -1
  5. package/dist/runtime/handlers/error.mjs +77 -0
  6. package/dist/runtime/handlers/island.d.mts +2 -0
  7. package/dist/runtime/handlers/island.mjs +120 -0
  8. package/dist/runtime/handlers/renderer.d.mts +2 -0
  9. package/dist/runtime/handlers/renderer.mjs +305 -0
  10. package/dist/runtime/middleware/no-ssr.d.mts +2 -0
  11. package/dist/runtime/middleware/no-ssr.mjs +7 -0
  12. package/dist/runtime/plugins/dev-server-logs.d.mts +2 -0
  13. package/dist/runtime/plugins/dev-server-logs.mjs +94 -0
  14. package/dist/runtime/templates/error-500.d.mts +2 -0
  15. package/dist/runtime/templates/error-500.mjs +15 -0
  16. package/dist/runtime/utils/app-config.d.mts +3 -0
  17. package/dist/runtime/utils/app-config.mjs +31 -0
  18. package/dist/runtime/utils/cache.d.mts +5 -0
  19. package/dist/runtime/utils/cache.mjs +20 -0
  20. package/dist/runtime/utils/config.d.mts +1 -0
  21. package/dist/runtime/utils/{dev.d.ts → dev.d.mts} +1 -1
  22. package/dist/runtime/utils/dev.mjs +985 -0
  23. package/dist/runtime/utils/error.d.mts +6 -0
  24. package/dist/runtime/utils/error.mjs +15 -0
  25. package/dist/runtime/utils/paths.mjs +19 -0
  26. package/dist/runtime/utils/renderer/{app.d.ts → app.d.mts} +4 -4
  27. package/dist/runtime/utils/renderer/app.mjs +39 -0
  28. package/dist/runtime/utils/renderer/build-files.d.mts +18 -0
  29. package/dist/runtime/utils/renderer/build-files.mjs +100 -0
  30. package/dist/runtime/utils/renderer/{inline-styles.d.ts → inline-styles.d.mts} +1 -1
  31. package/dist/runtime/utils/renderer/inline-styles.mjs +13 -0
  32. package/dist/runtime/utils/renderer/{islands.d.ts → islands.d.mts} +5 -5
  33. package/dist/runtime/utils/renderer/islands.mjs +87 -0
  34. package/dist/runtime/utils/renderer/payload.d.mts +24 -0
  35. package/dist/runtime/utils/renderer/payload.mjs +64 -0
  36. package/package.json +19 -17
  37. package/dist/index.d.ts +0 -85
  38. package/dist/runtime/handlers/error.js +0 -63
  39. package/dist/runtime/handlers/island.d.ts +0 -4
  40. package/dist/runtime/handlers/island.js +0 -100
  41. package/dist/runtime/handlers/renderer.d.ts +0 -8
  42. package/dist/runtime/handlers/renderer.js +0 -238
  43. package/dist/runtime/middleware/no-ssr.d.ts +0 -2
  44. package/dist/runtime/middleware/no-ssr.js +0 -7
  45. package/dist/runtime/plugins/dev-server-logs.d.ts +0 -3
  46. package/dist/runtime/plugins/dev-server-logs.js +0 -82
  47. package/dist/runtime/templates/error-500.d.ts +0 -2
  48. package/dist/runtime/templates/error-500.js +0 -6
  49. package/dist/runtime/utils/app-config.d.ts +0 -2
  50. package/dist/runtime/utils/app-config.js +0 -25
  51. package/dist/runtime/utils/cache-driver.d.ts +0 -6
  52. package/dist/runtime/utils/cache.d.ts +0 -8
  53. package/dist/runtime/utils/cache.js +0 -19
  54. package/dist/runtime/utils/config.d.ts +0 -1
  55. package/dist/runtime/utils/dev.js +0 -334
  56. package/dist/runtime/utils/error.d.ts +0 -6
  57. package/dist/runtime/utils/error.js +0 -11
  58. package/dist/runtime/utils/paths.js +0 -16
  59. package/dist/runtime/utils/renderer/app.js +0 -33
  60. package/dist/runtime/utils/renderer/build-files.d.ts +0 -22
  61. package/dist/runtime/utils/renderer/build-files.js +0 -85
  62. package/dist/runtime/utils/renderer/inline-styles.js +0 -13
  63. package/dist/runtime/utils/renderer/islands.js +0 -82
  64. package/dist/runtime/utils/renderer/payload.d.ts +0 -37
  65. package/dist/runtime/utils/renderer/payload.js +0 -67
  66. /package/dist/runtime/utils/{config.js → config.mjs} +0 -0
  67. /package/dist/runtime/utils/{paths.d.ts → paths.d.mts} +0 -0
package/README.md CHANGED
@@ -6,9 +6,11 @@
6
6
  <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
7
7
  <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
8
8
  <a href="https://github.com/nuxt/nuxt/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
9
+ <a href="https://nuxt.com/modules"><img src="https://img.shields.io/badge/dynamic/json?url=https://nuxt.com/api/v1/modules&query=$.stats.modules&label=Modules&style=flat&colorA=18181B&colorB=28CF8D" alt="Modules"></a>
9
10
  <a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
10
11
  <a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
11
12
  <a href="https://securityscorecards.dev/"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
13
+ <a href="https://deepwiki.com/nuxt/nuxt"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
12
14
  </p>
13
15
 
14
16
  Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
@@ -21,14 +23,14 @@ It provides a number of features that make it easy to build fast, SEO-friendly,
21
23
  - Auto imports of components, composables and utils
22
24
  - TypeScript with zero configuration
23
25
  - Go full-stack with our server/ directory
24
- - Extensible with [200+ modules](https://nuxt.com/modules)
26
+ - Extensible with [300+ modules](https://nuxt.com/modules)
25
27
  - Deployment to a variety of [hosting platforms](https://nuxt.com/deploy)
26
28
  - ...[and much more](https://nuxt.com) 🚀
27
29
 
28
30
  ### Table of Contents
29
31
 
30
32
  - 🚀 [Getting Started](#getting-started)
31
- - 💻 [ Vue Development](#vue-development)
33
+ - 💻 [Vue Development](#vue-development)
32
34
  - 📖 [Documentation](#documentation)
33
35
  - 🧩 [Modules](#modules)
34
36
  - ❤️ [Contribute](#contribute)
package/dist/index.d.mts CHANGED
@@ -1,85 +1,287 @@
1
- import { Nuxt } from '@nuxt/schema';
2
- import { Nitro } from 'nitropack/types';
3
- import { H3Event } from 'h3';
4
- import { LogObject } from 'consola';
5
- import { NuxtRenderHTMLContext, NuxtIslandResponse, NuxtIslandContext } from 'nuxt/app';
6
- import { RuntimeConfig } from 'nuxt/schema';
1
+ import { EventHandler, H3Event } from "h3";
2
+ import { Nuxt } from "@nuxt/schema";
3
+ import { Nitro, NitroConfig, NitroDevEventHandler, NitroEventHandler, NitroOptions, NitroRouteConfig, NitroRuntimeConfig, NitroRuntimeConfigApp } from "nitropack/types";
4
+ import { LogObject } from "consola";
5
+ import { NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext } from "nuxt/app";
6
+ import { HookResult, RuntimeConfig, TSReference } from "nuxt/schema";
7
7
 
8
- declare module 'nitropack' {
9
- interface NitroRuntimeConfigApp {
10
- buildAssetsDir: string;
11
- cdnURL: string;
12
- }
13
- interface NitroRouteRules {
14
- ssr?: boolean;
15
- noScripts?: boolean;
16
- /** @deprecated Use `noScripts` instead */
17
- experimentalNoScripts?: boolean;
18
- appMiddleware?: Record<string, boolean>;
19
- }
8
+ //#region src/augments.d.ts
9
+ declare module "nitropack" {
10
+ interface NitroRuntimeConfigApp {
11
+ buildAssetsDir: string;
12
+ cdnURL: string;
13
+ }
14
+ interface NitroRouteRules {
15
+ ssr?: boolean;
16
+ noScripts?: boolean;
17
+ /** @deprecated Use `noScripts` instead */
18
+ experimentalNoScripts?: boolean;
19
+ appMiddleware?: Record<string, boolean>;
20
+ appLayout?: string | false;
21
+ }
20
22
  }
21
- declare module 'nitropack' {
22
- interface NitroRuntimeConfig extends RuntimeConfig {
23
- }
24
- interface NitroRouteConfig {
25
- ssr?: boolean;
26
- noScripts?: boolean;
27
- /** @deprecated Use `noScripts` instead */
28
- experimentalNoScripts?: boolean;
29
- }
30
- interface NitroRuntimeHooks {
31
- 'dev:ssr-logs': (ctx: {
32
- logs: LogObject[];
33
- path: string;
34
- }) => void | Promise<void>;
35
- 'render:html': (htmlContext: NuxtRenderHTMLContext, context: {
36
- event: H3Event;
37
- }) => void | Promise<void>;
38
- 'render:island': (islandResponse: NuxtIslandResponse, context: {
39
- event: H3Event;
40
- islandContext: NuxtIslandContext;
41
- }) => void | Promise<void>;
42
- }
23
+ declare module "nitropack/types" {
24
+ interface NitroRuntimeConfigApp {
25
+ buildAssetsDir: string;
26
+ cdnURL: string;
27
+ }
28
+ interface NitroRouteRules {
29
+ ssr?: boolean;
30
+ noScripts?: boolean;
31
+ /** @deprecated Use `noScripts` instead */
32
+ experimentalNoScripts?: boolean;
33
+ appMiddleware?: Record<string, boolean>;
34
+ appLayout?: string | false;
35
+ }
43
36
  }
44
- declare module 'nitropack/types' {
45
- interface NitroRuntimeConfigApp {
46
- buildAssetsDir: string;
47
- cdnURL: string;
48
- }
49
- interface NitroRouteRules {
50
- ssr?: boolean;
51
- noScripts?: boolean;
52
- /** @deprecated Use `noScripts` instead */
53
- experimentalNoScripts?: boolean;
54
- appMiddleware?: Record<string, boolean>;
55
- }
37
+ declare module "nitropack" {
38
+ interface NitroRuntimeConfig extends RuntimeConfig {}
39
+ interface NitroRouteConfig {
40
+ ssr?: boolean;
41
+ noScripts?: boolean;
42
+ /** @deprecated Use `noScripts` instead */
43
+ experimentalNoScripts?: boolean;
44
+ }
45
+ interface NitroRuntimeHooks {
46
+ "dev:ssr-logs": (ctx: {
47
+ logs: LogObject[];
48
+ path: string;
49
+ }) => void | Promise<void>;
50
+ "render:html": (htmlContext: NuxtRenderHTMLContext, context: {
51
+ event: H3Event;
52
+ }) => void | Promise<void>;
53
+ "render:island": (islandResponse: NuxtIslandResponse, context: {
54
+ event: H3Event;
55
+ islandContext: NuxtIslandContext;
56
+ }) => void | Promise<void>;
57
+ }
56
58
  }
57
- declare module 'nitropack/types' {
58
- interface NitroRuntimeConfig extends RuntimeConfig {
59
- }
60
- interface NitroRouteConfig {
61
- ssr?: boolean;
62
- noScripts?: boolean;
63
- /** @deprecated Use `noScripts` instead */
64
- experimentalNoScripts?: boolean;
65
- }
66
- interface NitroRuntimeHooks {
67
- 'dev:ssr-logs': (ctx: {
68
- logs: LogObject[];
69
- path: string;
70
- }) => void | Promise<void>;
71
- 'render:html': (htmlContext: NuxtRenderHTMLContext, context: {
72
- event: H3Event;
73
- }) => void | Promise<void>;
74
- 'render:island': (islandResponse: NuxtIslandResponse, context: {
75
- event: H3Event;
76
- islandContext: NuxtIslandContext;
77
- }) => void | Promise<void>;
78
- }
59
+ declare module "nitropack/types" {
60
+ interface NitroRuntimeConfig extends RuntimeConfig {}
61
+ interface NitroRouteConfig {
62
+ ssr?: boolean;
63
+ noScripts?: boolean;
64
+ /** @deprecated Use `noScripts` instead */
65
+ experimentalNoScripts?: boolean;
66
+ }
67
+ interface NitroRuntimeHooks {
68
+ "dev:ssr-logs": (ctx: {
69
+ logs: LogObject[];
70
+ path: string;
71
+ }) => void | Promise<void>;
72
+ "render:html": (htmlContext: NuxtRenderHTMLContext, context: {
73
+ event: H3Event;
74
+ }) => void | Promise<void>;
75
+ "render:island": (islandResponse: NuxtIslandResponse, context: {
76
+ event: H3Event;
77
+ islandContext: NuxtIslandContext;
78
+ }) => void | Promise<void>;
79
+ }
79
80
  }
80
-
81
+ declare module "@nuxt/schema" {
82
+ interface NuxtHooks {
83
+ /**
84
+ * Called when the dev middleware is being registered on the Nitro dev server.
85
+ * @param handler the Vite or Webpack event handler
86
+ * @returns Promise
87
+ */
88
+ "server:devHandler": (handler: EventHandler, options: {
89
+ cors: (path: string) => boolean;
90
+ }) => HookResult;
91
+ /**
92
+ * Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
93
+ * @param options Objects containing `references`, `declarations`
94
+ * @returns Promise
95
+ */
96
+ "nitro:prepare:types": (options: {
97
+ references: TSReference[];
98
+ declarations: string[];
99
+ }) => HookResult;
100
+ /**
101
+ * Called before initializing Nitro, allowing customization of Nitro's configuration.
102
+ * @param nitroConfig The nitro config to be extended
103
+ * @returns Promise
104
+ */
105
+ "nitro:config": (nitroConfig: NitroConfig) => HookResult;
106
+ /**
107
+ * Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
108
+ * @param nitro The created nitro object
109
+ * @returns Promise
110
+ */
111
+ "nitro:init": (nitro: Nitro) => HookResult;
112
+ /**
113
+ * Called before building the Nitro instance.
114
+ * @param nitro The created nitro object
115
+ * @returns Promise
116
+ */
117
+ "nitro:build:before": (nitro: Nitro) => HookResult;
118
+ /**
119
+ * Called after copying public assets. Allows modifying public assets before Nitro server is built.
120
+ * @param nitro The created nitro object
121
+ * @returns Promise
122
+ */
123
+ "nitro:build:public-assets": (nitro: Nitro) => HookResult;
124
+ }
125
+ interface ConfigSchema {
126
+ /**
127
+ * Configuration for Nitro.
128
+ *
129
+ * @see [Nitro configuration docs](https://nitro.build/config)
130
+ */
131
+ nitro: NitroConfig;
132
+ /**
133
+ * Global route options applied to matching server routes.
134
+ *
135
+ * @experimental This is an experimental feature and API may change in the future.
136
+ *
137
+ * @see [Nitro route rules documentation](https://nitro.build/config#routerules)
138
+ */
139
+ routeRules: NitroConfig["routeRules"];
140
+ /**
141
+ * Nitro server handlers.
142
+ *
143
+ * Each handler accepts the following options:
144
+ * - 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.
145
+ *
146
+ * @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
147
+ *
148
+ * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
149
+ *
150
+ * @example
151
+ * ```js
152
+ * serverHandlers: [
153
+ * { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
154
+ * ]
155
+ * ```
156
+ */
157
+ serverHandlers: NitroEventHandler[];
158
+ /**
159
+ * Nitro development-only server handlers.
160
+ *
161
+ * @see [Nitro server routes documentation](https://nitro.build/guide/routing)
162
+ */
163
+ devServerHandlers: NitroDevEventHandler[];
164
+ }
165
+ interface NuxtConfig {
166
+ nitro?: NitroConfig;
167
+ }
168
+ interface RuntimeConfig {
169
+ app: NitroRuntimeConfigApp;
170
+ /** Only available on the server. */
171
+ nitro?: NitroRuntimeConfig["nitro"];
172
+ }
173
+ interface NuxtDebugOptions {
174
+ /** Debug options for Nitro */
175
+ nitro?: NitroOptions["debug"];
176
+ }
177
+ interface NuxtPage {
178
+ rules?: NitroRouteConfig;
179
+ }
180
+ }
181
+ declare module "nuxt/schema" {
182
+ interface NuxtHooks {
183
+ /**
184
+ * Called when the dev middleware is being registered on the Nitro dev server.
185
+ * @param handler the Vite or Webpack event handler
186
+ * @returns Promise
187
+ */
188
+ "server:devHandler": (handler: EventHandler, options: {
189
+ cors: (path: string) => boolean;
190
+ }) => HookResult;
191
+ /**
192
+ * Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
193
+ * @param options Objects containing `references`, `declarations`
194
+ * @returns Promise
195
+ */
196
+ "nitro:prepare:types": (options: {
197
+ references: TSReference[];
198
+ declarations: string[];
199
+ }) => HookResult;
200
+ /**
201
+ * Called before initializing Nitro, allowing customization of Nitro's configuration.
202
+ * @param nitroConfig The nitro config to be extended
203
+ * @returns Promise
204
+ */
205
+ "nitro:config": (nitroConfig: NitroConfig) => HookResult;
206
+ /**
207
+ * Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
208
+ * @param nitro The created nitro object
209
+ * @returns Promise
210
+ */
211
+ "nitro:init": (nitro: Nitro) => HookResult;
212
+ /**
213
+ * Called before building the Nitro instance.
214
+ * @param nitro The created nitro object
215
+ * @returns Promise
216
+ */
217
+ "nitro:build:before": (nitro: Nitro) => HookResult;
218
+ /**
219
+ * Called after copying public assets. Allows modifying public assets before Nitro server is built.
220
+ * @param nitro The created nitro object
221
+ * @returns Promise
222
+ */
223
+ "nitro:build:public-assets": (nitro: Nitro) => HookResult;
224
+ }
225
+ interface ConfigSchema {
226
+ /**
227
+ * Configuration for Nitro.
228
+ *
229
+ * @see [Nitro configuration docs](https://nitro.build/config)
230
+ */
231
+ nitro: NitroConfig;
232
+ /**
233
+ * Global route options applied to matching server routes.
234
+ *
235
+ * @experimental This is an experimental feature and API may change in the future.
236
+ *
237
+ * @see [Nitro route rules documentation](https://nitro.build/config#routerules)
238
+ */
239
+ routeRules: NitroConfig["routeRules"];
240
+ /**
241
+ * Nitro server handlers.
242
+ *
243
+ * Each handler accepts the following options:
244
+ * - 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.
245
+ *
246
+ * @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
247
+ *
248
+ * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
249
+ *
250
+ * @example
251
+ * ```js
252
+ * serverHandlers: [
253
+ * { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
254
+ * ]
255
+ * ```
256
+ */
257
+ serverHandlers: NitroEventHandler[];
258
+ /**
259
+ * Nitro development-only server handlers.
260
+ *
261
+ * @see [Nitro server routes documentation](https://nitro.build/guide/routing)
262
+ */
263
+ devServerHandlers: NitroDevEventHandler[];
264
+ }
265
+ interface NuxtConfig {
266
+ nitro?: NitroConfig;
267
+ }
268
+ interface RuntimeConfig {
269
+ app: NitroRuntimeConfigApp;
270
+ /** Only available on the server. */
271
+ nitro?: NitroRuntimeConfig["nitro"];
272
+ }
273
+ interface NuxtDebugOptions {
274
+ /** Debug options for Nitro */
275
+ nitro?: NitroOptions["debug"];
276
+ }
277
+ interface NuxtPage {
278
+ rules?: NitroRouteConfig;
279
+ }
280
+ }
281
+ //#endregion
282
+ //#region src/index.d.ts
81
283
  declare function bundle(nuxt: Nuxt & {
82
- _nitro?: Nitro;
284
+ _nitro?: Nitro;
83
285
  }): Promise<void>;
84
-
85
- export { bundle };
286
+ //#endregion
287
+ export { bundle };