@nuxt/nitro-server-nightly 5.0.0-29807919.2cbde35e → 5.0.0-29809859.f0ca99e9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/augments-BYb8I0N-.d.mts +365 -0
- package/dist/augments.d.mts +1 -336
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +268 -172
- package/dist/runtime/utils/renderer/early-404.mjs +1 -1
- package/package.json +10 -8
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { EventHandler, H3Event } from "nitro/h3";
|
|
2
|
+
import { Import } from "unimport";
|
|
3
|
+
import { Nitro, NitroConfig, NitroDevEventHandler, NitroEventHandler, NitroOptions, NitroRuntimeConfig, NitroRuntimeConfigApp, NormalizedRouteRules, RouteRuleConfig, TracingOptions } from "nitro/types";
|
|
4
|
+
import { Nuxt } from "@nuxt/schema";
|
|
5
|
+
import { LogObject } from "consola";
|
|
6
|
+
import { NuxtIslandContext, NuxtIslandResponse, NuxtRenderChunkContext, NuxtRenderCloseContext, NuxtRenderHTMLContext, NuxtRenderRouteContext } from "#app/types";
|
|
7
|
+
import { HookResult, RuntimeConfig, SharedAppConfig, TSReference } from "nuxt/schema";
|
|
8
|
+
//#region src/auto-imports.d.ts
|
|
9
|
+
/** Options accepted on `nitro.imports`. */
|
|
10
|
+
interface ServerImportsOptions {
|
|
11
|
+
autoImport?: boolean;
|
|
12
|
+
dirs?: string[];
|
|
13
|
+
imports?: Import[];
|
|
14
|
+
presets?: Array<{
|
|
15
|
+
from: string;
|
|
16
|
+
imports: Array<string | {
|
|
17
|
+
name: string;
|
|
18
|
+
as?: string;
|
|
19
|
+
}>;
|
|
20
|
+
typeFrom?: string;
|
|
21
|
+
}>;
|
|
22
|
+
exclude?: Array<string | RegExp>;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/augments.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* Per-channel toggles for `tracingChannel`. Extends Nitro's own
|
|
28
|
+
* {@link TracingOptions} with a `nuxt` key for Nuxt-owned channels
|
|
29
|
+
* (`nuxt.render`, `nuxt.island`, `nuxt.data`, `nuxt.plugin`). Channel names
|
|
30
|
+
* follow the [untracing](https://github.com/unjs/untracing) naming convention
|
|
31
|
+
* (`{namespace}.{operation}`).
|
|
32
|
+
*
|
|
33
|
+
* @experimental Channel names, payload shapes, and option keys may change.
|
|
34
|
+
*/
|
|
35
|
+
interface NuxtTracingChannelOptions extends TracingOptions {
|
|
36
|
+
/** Enable Nuxt-owned channels (`nuxt.render`, `nuxt.island`, `nuxt.data`, `nuxt.plugin`). */
|
|
37
|
+
nuxt?: boolean;
|
|
38
|
+
}
|
|
39
|
+
declare module "nitro/types" {
|
|
40
|
+
interface NitroRuntimeConfigApp {
|
|
41
|
+
baseURL: string;
|
|
42
|
+
buildAssetsDir: string;
|
|
43
|
+
cdnURL: string;
|
|
44
|
+
buildId: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Server auto-imports, applied by `@nuxt/nitro-server`. Declared here because this is the
|
|
48
|
+
* channel `addServerImports()` and `addServerImportsDir()` write to through `nitro:config`.
|
|
49
|
+
*/
|
|
50
|
+
interface NitroConfig {
|
|
51
|
+
imports?: false | ServerImportsOptions;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
declare module "h3/rules" {
|
|
55
|
+
interface RouteRuleConfig {
|
|
56
|
+
ssr?: boolean;
|
|
57
|
+
streaming?: boolean;
|
|
58
|
+
noScripts?: boolean;
|
|
59
|
+
/** @deprecated Use `noScripts` instead */
|
|
60
|
+
experimentalNoScripts?: boolean;
|
|
61
|
+
}
|
|
62
|
+
interface RouteRules {
|
|
63
|
+
ssr?: boolean;
|
|
64
|
+
streaming?: boolean;
|
|
65
|
+
noScripts?: boolean;
|
|
66
|
+
/** @deprecated Use `noScripts` instead */
|
|
67
|
+
experimentalNoScripts?: boolean;
|
|
68
|
+
appMiddleware?: Record<string, boolean>;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
declare module "nitro/types" {
|
|
72
|
+
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
73
|
+
interface NitroRuntimeHooks {
|
|
74
|
+
"dev:ssr-logs": (ctx: {
|
|
75
|
+
logs: LogObject[];
|
|
76
|
+
path: string;
|
|
77
|
+
}) => void | Promise<void>;
|
|
78
|
+
"render:html": (htmlContext: NuxtRenderHTMLContext, context: {
|
|
79
|
+
event: H3Event;
|
|
80
|
+
streaming?: boolean;
|
|
81
|
+
}) => void | Promise<void>;
|
|
82
|
+
"render:html:chunk": (chunkContext: NuxtRenderChunkContext, context: {
|
|
83
|
+
event: H3Event;
|
|
84
|
+
}) => void | Promise<void>;
|
|
85
|
+
"render:html:close": (closeContext: NuxtRenderCloseContext, context: {
|
|
86
|
+
event: H3Event;
|
|
87
|
+
}) => void | Promise<void>;
|
|
88
|
+
"render:route": (renderRouteContext: NuxtRenderRouteContext, context: {
|
|
89
|
+
event: H3Event;
|
|
90
|
+
}) => void | Promise<void>;
|
|
91
|
+
"render:island": (islandResponse: NuxtIslandResponse, context: {
|
|
92
|
+
event: H3Event;
|
|
93
|
+
islandContext: NuxtIslandContext;
|
|
94
|
+
}) => void | Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
type _NitroOnlyRuntimeConfig = Omit<NonNullable<NitroRuntimeConfig["nitro"]>, "envPrefix"> & {
|
|
98
|
+
envPrefix: string;
|
|
99
|
+
};
|
|
100
|
+
declare module "@nuxt/schema" {
|
|
101
|
+
interface NitroTypes {
|
|
102
|
+
instance: Nitro;
|
|
103
|
+
}
|
|
104
|
+
interface ServerTypes {
|
|
105
|
+
event: H3Event;
|
|
106
|
+
routeRules: NormalizedRouteRules;
|
|
107
|
+
}
|
|
108
|
+
interface NuxtHooks {
|
|
109
|
+
/**
|
|
110
|
+
* Called when the dev middleware is being registered on the Nitro dev server.
|
|
111
|
+
* @param handler the Vite or Webpack event handler
|
|
112
|
+
* @returns Promise
|
|
113
|
+
*/
|
|
114
|
+
"server:devHandler": (handler: EventHandler, options: {
|
|
115
|
+
cors: (path: string) => boolean;
|
|
116
|
+
}) => HookResult;
|
|
117
|
+
/**
|
|
118
|
+
* Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
|
|
119
|
+
* @param options Objects containing `references`, `declarations`
|
|
120
|
+
* @param options.references Array of TypeScript references to add
|
|
121
|
+
* @param options.declarations Array of declaration strings to add
|
|
122
|
+
* @returns Promise
|
|
123
|
+
*/
|
|
124
|
+
"nitro:prepare:types": (options: {
|
|
125
|
+
references: TSReference[];
|
|
126
|
+
declarations: string[];
|
|
127
|
+
}) => HookResult;
|
|
128
|
+
/**
|
|
129
|
+
* Called before initializing Nitro, allowing customization of Nitro's configuration.
|
|
130
|
+
* @param nitroConfig The nitro config to be extended
|
|
131
|
+
* @returns Promise
|
|
132
|
+
*/
|
|
133
|
+
"nitro:config": (nitroConfig: NitroConfig) => HookResult;
|
|
134
|
+
/**
|
|
135
|
+
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
|
|
136
|
+
* @param nitro The created nitro object
|
|
137
|
+
* @returns Promise
|
|
138
|
+
*/
|
|
139
|
+
"nitro:init": (nitro: Nitro) => HookResult;
|
|
140
|
+
/**
|
|
141
|
+
* Called before building the Nitro instance.
|
|
142
|
+
* @param nitro The created nitro object
|
|
143
|
+
* @returns Promise
|
|
144
|
+
*/
|
|
145
|
+
"nitro:build:before": (nitro: Nitro) => HookResult;
|
|
146
|
+
/**
|
|
147
|
+
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
|
|
148
|
+
* @param nitro The created nitro object
|
|
149
|
+
* @returns Promise
|
|
150
|
+
*/
|
|
151
|
+
"nitro:build:public-assets": (nitro: Nitro) => HookResult;
|
|
152
|
+
}
|
|
153
|
+
interface ConfigSchema {
|
|
154
|
+
/**
|
|
155
|
+
* Configuration for Nitro.
|
|
156
|
+
*
|
|
157
|
+
* @see [Nitro configuration docs](https://nitro.build/config)
|
|
158
|
+
*/
|
|
159
|
+
nitro: NitroConfig;
|
|
160
|
+
/**
|
|
161
|
+
* Global route options applied to matching server routes.
|
|
162
|
+
*
|
|
163
|
+
* @experimental This is an experimental feature and API may change in the future.
|
|
164
|
+
*
|
|
165
|
+
* @see [Nitro route rules documentation](https://nitro.build/config#routerules)
|
|
166
|
+
*/
|
|
167
|
+
routeRules: NitroConfig["routeRules"];
|
|
168
|
+
/**
|
|
169
|
+
* Nitro server handlers.
|
|
170
|
+
*
|
|
171
|
+
* Each handler accepts the following options:
|
|
172
|
+
* - 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.
|
|
173
|
+
*
|
|
174
|
+
* @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
|
|
175
|
+
*
|
|
176
|
+
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```js
|
|
180
|
+
* serverHandlers: [
|
|
181
|
+
* { route: '/path/foo/**:name', handler: '#server/foohandler.ts' }
|
|
182
|
+
* ]
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
serverHandlers: NitroEventHandler[];
|
|
186
|
+
/**
|
|
187
|
+
* Nitro development-only server handlers.
|
|
188
|
+
*
|
|
189
|
+
* @see [Nitro server routes documentation](https://nitro.build/guide/routing)
|
|
190
|
+
*/
|
|
191
|
+
devServerHandlers: NitroDevEventHandler[];
|
|
192
|
+
/**
|
|
193
|
+
* Enable [diagnostics-channel](https://nodejs.org/api/diagnostics_channel.html)
|
|
194
|
+
* tracing for Nuxt-owned subsystems and forward the corresponding Nitro-level
|
|
195
|
+
* channels (`srvx.request`, `h3.request`, `unstorage.*`).
|
|
196
|
+
*
|
|
197
|
+
* @experimental Channel names, payload shapes, and option keys may change.
|
|
198
|
+
*
|
|
199
|
+
* @see [Untracing naming registry](https://github.com/unjs/untracing)
|
|
200
|
+
*/
|
|
201
|
+
tracingChannel: boolean | NuxtTracingChannelOptions;
|
|
202
|
+
}
|
|
203
|
+
interface NuxtConfig {
|
|
204
|
+
nitro?: NitroConfig;
|
|
205
|
+
}
|
|
206
|
+
interface RuntimeConfig {
|
|
207
|
+
app: NitroRuntimeConfigApp;
|
|
208
|
+
/** Only available on the server. */
|
|
209
|
+
nitro?: _NitroOnlyRuntimeConfig;
|
|
210
|
+
}
|
|
211
|
+
interface NuxtDebugOptions {
|
|
212
|
+
/** Debug options for Nitro */
|
|
213
|
+
nitro?: NitroOptions["debug"];
|
|
214
|
+
}
|
|
215
|
+
interface NuxtPage {
|
|
216
|
+
rules?: RouteRuleConfig;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
declare module "nuxt/schema" {
|
|
220
|
+
interface NitroTypes {
|
|
221
|
+
instance: Nitro;
|
|
222
|
+
}
|
|
223
|
+
interface ServerTypes {
|
|
224
|
+
event: H3Event;
|
|
225
|
+
routeRules: NormalizedRouteRules;
|
|
226
|
+
}
|
|
227
|
+
interface NuxtHooks {
|
|
228
|
+
/**
|
|
229
|
+
* Called when the dev middleware is being registered on the Nitro dev server.
|
|
230
|
+
* @param handler the Vite or Webpack event handler
|
|
231
|
+
* @returns Promise
|
|
232
|
+
*/
|
|
233
|
+
"server:devHandler": (handler: EventHandler, options: {
|
|
234
|
+
cors: (path: string) => boolean;
|
|
235
|
+
}) => HookResult;
|
|
236
|
+
/**
|
|
237
|
+
* Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
|
|
238
|
+
* @param options Objects containing `references`, `declarations`
|
|
239
|
+
* @param options.references Array of TypeScript references to add
|
|
240
|
+
* @param options.declarations Array of declaration strings to add
|
|
241
|
+
* @returns Promise
|
|
242
|
+
*/
|
|
243
|
+
"nitro:prepare:types": (options: {
|
|
244
|
+
references: TSReference[];
|
|
245
|
+
declarations: string[];
|
|
246
|
+
}) => HookResult;
|
|
247
|
+
/**
|
|
248
|
+
* Called before initializing Nitro, allowing customization of Nitro's configuration.
|
|
249
|
+
* @param nitroConfig The nitro config to be extended
|
|
250
|
+
* @returns Promise
|
|
251
|
+
*/
|
|
252
|
+
"nitro:config": (nitroConfig: NitroConfig) => HookResult;
|
|
253
|
+
/**
|
|
254
|
+
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
|
|
255
|
+
* @param nitro The created nitro object
|
|
256
|
+
* @returns Promise
|
|
257
|
+
*/
|
|
258
|
+
"nitro:init": (nitro: Nitro) => HookResult;
|
|
259
|
+
/**
|
|
260
|
+
* Called before building the Nitro instance.
|
|
261
|
+
* @param nitro The created nitro object
|
|
262
|
+
* @returns Promise
|
|
263
|
+
*/
|
|
264
|
+
"nitro:build:before": (nitro: Nitro) => HookResult;
|
|
265
|
+
/**
|
|
266
|
+
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
|
|
267
|
+
* @param nitro The created nitro object
|
|
268
|
+
* @returns Promise
|
|
269
|
+
*/
|
|
270
|
+
"nitro:build:public-assets": (nitro: Nitro) => HookResult;
|
|
271
|
+
}
|
|
272
|
+
interface ConfigSchema {
|
|
273
|
+
/**
|
|
274
|
+
* Configuration for Nitro.
|
|
275
|
+
*
|
|
276
|
+
* @see [Nitro configuration docs](https://nitro.build/config)
|
|
277
|
+
*/
|
|
278
|
+
nitro: NitroConfig;
|
|
279
|
+
/**
|
|
280
|
+
* Global route options applied to matching server routes.
|
|
281
|
+
*
|
|
282
|
+
* @experimental This is an experimental feature and API may change in the future.
|
|
283
|
+
*
|
|
284
|
+
* @see [Nitro route rules documentation](https://nitro.build/config#routerules)
|
|
285
|
+
*/
|
|
286
|
+
routeRules: NitroConfig["routeRules"];
|
|
287
|
+
/**
|
|
288
|
+
* Nitro server handlers.
|
|
289
|
+
*
|
|
290
|
+
* Each handler accepts the following options:
|
|
291
|
+
* - 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.
|
|
292
|
+
*
|
|
293
|
+
* @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
|
|
294
|
+
*
|
|
295
|
+
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```js
|
|
299
|
+
* serverHandlers: [
|
|
300
|
+
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
|
|
301
|
+
* ]
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
serverHandlers: NitroEventHandler[];
|
|
305
|
+
/**
|
|
306
|
+
* Nitro development-only server handlers.
|
|
307
|
+
*
|
|
308
|
+
* @see [Nitro server routes documentation](https://nitro.build/guide/routing)
|
|
309
|
+
*/
|
|
310
|
+
devServerHandlers: NitroDevEventHandler[];
|
|
311
|
+
/**
|
|
312
|
+
* Enable [diagnostics-channel](https://nodejs.org/api/diagnostics_channel.html)
|
|
313
|
+
* tracing for Nuxt-owned subsystems and forward the corresponding Nitro-level
|
|
314
|
+
* channels (`srvx.request`, `h3.request`, `unstorage.*`).
|
|
315
|
+
*
|
|
316
|
+
* @experimental Channel names, payload shapes, and option keys may change.
|
|
317
|
+
*
|
|
318
|
+
* @see [Untracing naming registry](https://github.com/unjs/untracing)
|
|
319
|
+
*/
|
|
320
|
+
tracingChannel: boolean | NuxtTracingChannelOptions;
|
|
321
|
+
}
|
|
322
|
+
interface NuxtConfig {
|
|
323
|
+
nitro?: NitroConfig;
|
|
324
|
+
}
|
|
325
|
+
interface RuntimeConfig {
|
|
326
|
+
app: NitroRuntimeConfigApp;
|
|
327
|
+
/** Only available on the server. */
|
|
328
|
+
nitro?: _NitroOnlyRuntimeConfig;
|
|
329
|
+
}
|
|
330
|
+
interface NuxtDebugOptions {
|
|
331
|
+
/** Debug options for Nitro */
|
|
332
|
+
nitro?: NitroOptions["debug"];
|
|
333
|
+
}
|
|
334
|
+
interface NuxtPage {
|
|
335
|
+
rules?: RouteRuleConfig;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
interface NuxtRequestContext {
|
|
339
|
+
"appConfig"?: SharedAppConfig;
|
|
340
|
+
"noSSR"?: boolean;
|
|
341
|
+
/** @internal */
|
|
342
|
+
"~internal"?: boolean;
|
|
343
|
+
/** @internal */
|
|
344
|
+
"~rendering-error"?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Dev-only: CSS module URLs the builder has loaded for this request, provided
|
|
347
|
+
* by a dev integration so the SSR renderer can emit the right stylesheet
|
|
348
|
+
* links / inline styles. @internal
|
|
349
|
+
*/
|
|
350
|
+
"~devClientCss"?: string[];
|
|
351
|
+
/** @internal */
|
|
352
|
+
"~error-cause"?: unknown;
|
|
353
|
+
}
|
|
354
|
+
declare module "srvx" {
|
|
355
|
+
interface ServerRequestContext {
|
|
356
|
+
nuxt?: NuxtRequestContext;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
declare module "h3" {
|
|
360
|
+
interface H3EventContext {
|
|
361
|
+
nuxt?: NuxtRequestContext;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
export { NuxtTracingChannelOptions as n, NuxtRequestContext as t };
|
package/dist/augments.d.mts
CHANGED
|
@@ -1,337 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Nitro, NitroConfig, NitroDevEventHandler, NitroEventHandler, NitroOptions, NitroRouteConfig, NitroRouteRules, NitroRuntimeConfig, NitroRuntimeConfigApp, TracingOptions } from "nitro/types";
|
|
3
|
-
import { LogObject } from "consola";
|
|
4
|
-
import { NuxtIslandContext, NuxtIslandResponse, NuxtRenderChunkContext, NuxtRenderCloseContext, NuxtRenderHTMLContext, NuxtRenderRouteContext } from "#app/types";
|
|
5
|
-
import { HookResult, RuntimeConfig, SharedAppConfig, TSReference } from "nuxt/schema";
|
|
6
|
-
//#region src/augments.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Per-channel toggles for `tracingChannel`. Extends Nitro's own
|
|
9
|
-
* {@link TracingOptions} with a `nuxt` key for Nuxt-owned channels
|
|
10
|
-
* (`nuxt.render`, `nuxt.island`, `nuxt.data`, `nuxt.plugin`). Channel names
|
|
11
|
-
* follow the [untracing](https://github.com/unjs/untracing) naming convention
|
|
12
|
-
* (`{namespace}.{operation}`).
|
|
13
|
-
*
|
|
14
|
-
* @experimental Channel names, payload shapes, and option keys may change.
|
|
15
|
-
*/
|
|
16
|
-
interface NuxtTracingChannelOptions extends TracingOptions {
|
|
17
|
-
/** Enable Nuxt-owned channels (`nuxt.render`, `nuxt.island`, `nuxt.data`, `nuxt.plugin`). */
|
|
18
|
-
nuxt?: boolean;
|
|
19
|
-
}
|
|
20
|
-
declare module "nitro/types" {
|
|
21
|
-
interface NitroRuntimeConfigApp {
|
|
22
|
-
baseURL: string;
|
|
23
|
-
buildAssetsDir: string;
|
|
24
|
-
cdnURL: string;
|
|
25
|
-
buildId: string;
|
|
26
|
-
}
|
|
27
|
-
interface NitroRouteRules {
|
|
28
|
-
ssr?: boolean;
|
|
29
|
-
streaming?: boolean;
|
|
30
|
-
noScripts?: boolean;
|
|
31
|
-
/** @deprecated Use `noScripts` instead */
|
|
32
|
-
experimentalNoScripts?: boolean;
|
|
33
|
-
appMiddleware?: Record<string, boolean>;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
declare module "nitro/types" {
|
|
37
|
-
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
38
|
-
interface NitroRouteConfig {
|
|
39
|
-
ssr?: boolean;
|
|
40
|
-
streaming?: 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
|
-
streaming?: boolean;
|
|
53
|
-
}) => void | Promise<void>;
|
|
54
|
-
"render:html:chunk": (chunkContext: NuxtRenderChunkContext, context: {
|
|
55
|
-
event: H3Event;
|
|
56
|
-
}) => void | Promise<void>;
|
|
57
|
-
"render:html:close": (closeContext: NuxtRenderCloseContext, context: {
|
|
58
|
-
event: H3Event;
|
|
59
|
-
}) => void | Promise<void>;
|
|
60
|
-
"render:route": (renderRouteContext: NuxtRenderRouteContext, context: {
|
|
61
|
-
event: H3Event;
|
|
62
|
-
}) => void | Promise<void>;
|
|
63
|
-
"render:island": (islandResponse: NuxtIslandResponse, context: {
|
|
64
|
-
event: H3Event;
|
|
65
|
-
islandContext: NuxtIslandContext;
|
|
66
|
-
}) => void | Promise<void>;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
type _NitroOnlyRuntimeConfig = Omit<NonNullable<NitroRuntimeConfig["nitro"]>, "envPrefix"> & {
|
|
70
|
-
envPrefix: string;
|
|
71
|
-
};
|
|
72
|
-
declare module "@nuxt/schema" {
|
|
73
|
-
interface NitroTypes {
|
|
74
|
-
instance: Nitro;
|
|
75
|
-
}
|
|
76
|
-
interface ServerTypes {
|
|
77
|
-
event: H3Event;
|
|
78
|
-
routeRules: NitroRouteRules;
|
|
79
|
-
}
|
|
80
|
-
interface NuxtHooks {
|
|
81
|
-
/**
|
|
82
|
-
* Called when the dev middleware is being registered on the Nitro dev server.
|
|
83
|
-
* @param handler the Vite or Webpack event handler
|
|
84
|
-
* @returns Promise
|
|
85
|
-
*/
|
|
86
|
-
"server:devHandler": (handler: EventHandler, options: {
|
|
87
|
-
cors: (path: string) => boolean;
|
|
88
|
-
}) => HookResult;
|
|
89
|
-
/**
|
|
90
|
-
* Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
|
|
91
|
-
* @param options Objects containing `references`, `declarations`
|
|
92
|
-
* @param options.references Array of TypeScript references to add
|
|
93
|
-
* @param options.declarations Array of declaration strings to add
|
|
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
|
-
* Enable [diagnostics-channel](https://nodejs.org/api/diagnostics_channel.html)
|
|
166
|
-
* tracing for Nuxt-owned subsystems and forward the corresponding Nitro-level
|
|
167
|
-
* channels (`srvx.request`, `h3.request`, `unstorage.*`).
|
|
168
|
-
*
|
|
169
|
-
* @experimental Channel names, payload shapes, and option keys may change.
|
|
170
|
-
*
|
|
171
|
-
* @see [Untracing naming registry](https://github.com/unjs/untracing)
|
|
172
|
-
*/
|
|
173
|
-
tracingChannel: boolean | NuxtTracingChannelOptions;
|
|
174
|
-
}
|
|
175
|
-
interface NuxtConfig {
|
|
176
|
-
nitro?: NitroConfig;
|
|
177
|
-
}
|
|
178
|
-
interface RuntimeConfig {
|
|
179
|
-
app: NitroRuntimeConfigApp;
|
|
180
|
-
/** Only available on the server. */
|
|
181
|
-
nitro?: _NitroOnlyRuntimeConfig;
|
|
182
|
-
}
|
|
183
|
-
interface NuxtDebugOptions {
|
|
184
|
-
/** Debug options for Nitro */
|
|
185
|
-
nitro?: NitroOptions["debug"];
|
|
186
|
-
}
|
|
187
|
-
interface NuxtPage {
|
|
188
|
-
rules?: NitroRouteConfig;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
declare module "nuxt/schema" {
|
|
192
|
-
interface NitroTypes {
|
|
193
|
-
instance: Nitro;
|
|
194
|
-
}
|
|
195
|
-
interface ServerTypes {
|
|
196
|
-
event: H3Event;
|
|
197
|
-
routeRules: NitroRouteRules;
|
|
198
|
-
}
|
|
199
|
-
interface NuxtHooks {
|
|
200
|
-
/**
|
|
201
|
-
* Called when the dev middleware is being registered on the Nitro dev server.
|
|
202
|
-
* @param handler the Vite or Webpack event handler
|
|
203
|
-
* @returns Promise
|
|
204
|
-
*/
|
|
205
|
-
"server:devHandler": (handler: EventHandler, options: {
|
|
206
|
-
cors: (path: string) => boolean;
|
|
207
|
-
}) => HookResult;
|
|
208
|
-
/**
|
|
209
|
-
* Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
|
|
210
|
-
* @param options Objects containing `references`, `declarations`
|
|
211
|
-
* @param options.references Array of TypeScript references to add
|
|
212
|
-
* @param options.declarations Array of declaration strings to add
|
|
213
|
-
* @returns Promise
|
|
214
|
-
*/
|
|
215
|
-
"nitro:prepare:types": (options: {
|
|
216
|
-
references: TSReference[];
|
|
217
|
-
declarations: string[];
|
|
218
|
-
}) => HookResult;
|
|
219
|
-
/**
|
|
220
|
-
* Called before initializing Nitro, allowing customization of Nitro's configuration.
|
|
221
|
-
* @param nitroConfig The nitro config to be extended
|
|
222
|
-
* @returns Promise
|
|
223
|
-
*/
|
|
224
|
-
"nitro:config": (nitroConfig: NitroConfig) => HookResult;
|
|
225
|
-
/**
|
|
226
|
-
* Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
|
|
227
|
-
* @param nitro The created nitro object
|
|
228
|
-
* @returns Promise
|
|
229
|
-
*/
|
|
230
|
-
"nitro:init": (nitro: Nitro) => HookResult;
|
|
231
|
-
/**
|
|
232
|
-
* Called before building the Nitro instance.
|
|
233
|
-
* @param nitro The created nitro object
|
|
234
|
-
* @returns Promise
|
|
235
|
-
*/
|
|
236
|
-
"nitro:build:before": (nitro: Nitro) => HookResult;
|
|
237
|
-
/**
|
|
238
|
-
* Called after copying public assets. Allows modifying public assets before Nitro server is built.
|
|
239
|
-
* @param nitro The created nitro object
|
|
240
|
-
* @returns Promise
|
|
241
|
-
*/
|
|
242
|
-
"nitro:build:public-assets": (nitro: Nitro) => HookResult;
|
|
243
|
-
}
|
|
244
|
-
interface ConfigSchema {
|
|
245
|
-
/**
|
|
246
|
-
* Configuration for Nitro.
|
|
247
|
-
*
|
|
248
|
-
* @see [Nitro configuration docs](https://nitro.build/config)
|
|
249
|
-
*/
|
|
250
|
-
nitro: NitroConfig;
|
|
251
|
-
/**
|
|
252
|
-
* Global route options applied to matching server routes.
|
|
253
|
-
*
|
|
254
|
-
* @experimental This is an experimental feature and API may change in the future.
|
|
255
|
-
*
|
|
256
|
-
* @see [Nitro route rules documentation](https://nitro.build/config#routerules)
|
|
257
|
-
*/
|
|
258
|
-
routeRules: NitroConfig["routeRules"];
|
|
259
|
-
/**
|
|
260
|
-
* Nitro server handlers.
|
|
261
|
-
*
|
|
262
|
-
* Each handler accepts the following options:
|
|
263
|
-
* - 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.
|
|
264
|
-
*
|
|
265
|
-
* @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
|
|
266
|
-
*
|
|
267
|
-
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* ```js
|
|
271
|
-
* serverHandlers: [
|
|
272
|
-
* { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
|
|
273
|
-
* ]
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
|
-
serverHandlers: NitroEventHandler[];
|
|
277
|
-
/**
|
|
278
|
-
* Nitro development-only server handlers.
|
|
279
|
-
*
|
|
280
|
-
* @see [Nitro server routes documentation](https://nitro.build/guide/routing)
|
|
281
|
-
*/
|
|
282
|
-
devServerHandlers: NitroDevEventHandler[];
|
|
283
|
-
/**
|
|
284
|
-
* Enable [diagnostics-channel](https://nodejs.org/api/diagnostics_channel.html)
|
|
285
|
-
* tracing for Nuxt-owned subsystems and forward the corresponding Nitro-level
|
|
286
|
-
* channels (`srvx.request`, `h3.request`, `unstorage.*`).
|
|
287
|
-
*
|
|
288
|
-
* @experimental Channel names, payload shapes, and option keys may change.
|
|
289
|
-
*
|
|
290
|
-
* @see [Untracing naming registry](https://github.com/unjs/untracing)
|
|
291
|
-
*/
|
|
292
|
-
tracingChannel: boolean | NuxtTracingChannelOptions;
|
|
293
|
-
}
|
|
294
|
-
interface NuxtConfig {
|
|
295
|
-
nitro?: NitroConfig;
|
|
296
|
-
}
|
|
297
|
-
interface RuntimeConfig {
|
|
298
|
-
app: NitroRuntimeConfigApp;
|
|
299
|
-
/** Only available on the server. */
|
|
300
|
-
nitro?: _NitroOnlyRuntimeConfig;
|
|
301
|
-
}
|
|
302
|
-
interface NuxtDebugOptions {
|
|
303
|
-
/** Debug options for Nitro */
|
|
304
|
-
nitro?: NitroOptions["debug"];
|
|
305
|
-
}
|
|
306
|
-
interface NuxtPage {
|
|
307
|
-
rules?: NitroRouteConfig;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
interface NuxtRequestContext {
|
|
311
|
-
"appConfig"?: SharedAppConfig;
|
|
312
|
-
"noSSR"?: boolean;
|
|
313
|
-
/** @internal */
|
|
314
|
-
"~internal"?: boolean;
|
|
315
|
-
/** @internal */
|
|
316
|
-
"~rendering-error"?: boolean;
|
|
317
|
-
/**
|
|
318
|
-
* Dev-only: CSS module URLs the builder has loaded for this request, provided
|
|
319
|
-
* by a dev integration so the SSR renderer can emit the right stylesheet
|
|
320
|
-
* links / inline styles. @internal
|
|
321
|
-
*/
|
|
322
|
-
"~devClientCss"?: string[];
|
|
323
|
-
/** @internal */
|
|
324
|
-
"~error-cause"?: unknown;
|
|
325
|
-
}
|
|
326
|
-
declare module "srvx" {
|
|
327
|
-
interface ServerRequestContext {
|
|
328
|
-
nuxt?: NuxtRequestContext;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
declare module "h3" {
|
|
332
|
-
interface H3EventContext {
|
|
333
|
-
nuxt?: NuxtRequestContext;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
//#endregion
|
|
1
|
+
import { n as NuxtTracingChannelOptions, t as NuxtRequestContext } from "./augments-BYb8I0N-.mjs";
|
|
337
2
|
export { NuxtRequestContext, NuxtTracingChannelOptions };
|
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -7,8 +7,8 @@ import { randomBytes, randomUUID } from "node:crypto";
|
|
|
7
7
|
import { dirname, isAbsolute, join, normalize, relative, resolve } from "pathe";
|
|
8
8
|
import { getQuery, joinURL, withTrailingSlash, withoutTrailingSlash } from "ufo";
|
|
9
9
|
import nuxtPkg from "nuxt/package.json" with { type: "json" };
|
|
10
|
-
import { build, copyPublicAssets, createDevServer, createNitro, prepare, prerender
|
|
11
|
-
import { addPlugin, addTemplate, addVitePlugin, createIsIgnored, directoryToURL, ensureDependencyInstalled, findPath, getAddDependencyCommand,
|
|
10
|
+
import { build, copyPublicAssets, createDevServer, createNitro, prepare, prerender } from "nitro/builder";
|
|
11
|
+
import { addPlugin, addTemplate, addVitePlugin, createIsIgnored, directoryToURL, ensureDependencyInstalled, findPath, getAddDependencyCommand, getLayerDirectories, logger, resolveAlias, resolveIgnorePatterns } from "@nuxt/kit";
|
|
12
12
|
import { bundlerDiagnostics, resolveModuleExportNames, setServerBuild } from "@nuxt/kit/internal";
|
|
13
13
|
import escapeRE from "escape-string-regexp";
|
|
14
14
|
import { defu } from "defu";
|
|
@@ -24,8 +24,10 @@ import MagicString from "magic-string";
|
|
|
24
24
|
import remapping from "@ampproject/remapping";
|
|
25
25
|
import { addRoute, createRouter, routeNodeKeys } from "rou3";
|
|
26
26
|
import { compileRouterToString } from "rou3/compiler";
|
|
27
|
+
import { createUnimport, scanDirExports, toExports } from "unimport";
|
|
28
|
+
import { createUnplugin } from "unplugin";
|
|
27
29
|
//#region package.json
|
|
28
|
-
var version = "5.0.0-
|
|
30
|
+
var version = "5.0.0-29809859.f0ca99e9";
|
|
29
31
|
//#endregion
|
|
30
32
|
//#region src/utils.ts
|
|
31
33
|
function toArray(value) {
|
|
@@ -167,10 +169,6 @@ function setupNitroViteEnvironment(nuxt, nitro$1) {
|
|
|
167
169
|
"}"
|
|
168
170
|
].join("\n");
|
|
169
171
|
}
|
|
170
|
-
if (nuxt.options.dev) {
|
|
171
|
-
nuxt.options.vite.server ||= {};
|
|
172
|
-
nuxt.options.vite.server.perEnvironmentStartEndDuringDev = true;
|
|
173
|
-
}
|
|
174
172
|
nuxt.options.vite.plugins ||= [];
|
|
175
173
|
nuxt.options.vite.plugins.push(nitro({
|
|
176
174
|
_nitro: nitro$1,
|
|
@@ -688,14 +686,25 @@ declare module 'nitro/types' {
|
|
|
688
686
|
cdnURL: string
|
|
689
687
|
}
|
|
690
688
|
interface NitroRuntimeConfig extends RuntimeConfig {}
|
|
691
|
-
interface
|
|
689
|
+
interface NitroRuntimeHooks {
|
|
690
|
+
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
|
|
691
|
+
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event, streaming?: boolean }) => void | Promise<void>
|
|
692
|
+
'render:html:chunk': (chunkContext: NuxtRenderChunkContext, context: { event: H3Event }) => void | Promise<void>
|
|
693
|
+
'render:html:close': (closeContext: NuxtRenderCloseContext, context: { event: H3Event }) => void | Promise<void>
|
|
694
|
+
'render:route': (renderRouteContext: NuxtRenderRouteContext, context: { event: H3Event }) => void | Promise<void>
|
|
695
|
+
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
declare module 'h3/rules' {
|
|
700
|
+
interface RouteRuleConfig {
|
|
692
701
|
ssr?: boolean
|
|
693
702
|
streaming?: boolean
|
|
694
703
|
noScripts?: boolean
|
|
695
704
|
/** @deprecated Use \`noScripts\` instead */
|
|
696
705
|
experimentalNoScripts?: boolean
|
|
697
706
|
}
|
|
698
|
-
interface
|
|
707
|
+
interface RouteRules {
|
|
699
708
|
ssr?: boolean
|
|
700
709
|
streaming?: boolean
|
|
701
710
|
noScripts?: boolean
|
|
@@ -704,14 +713,6 @@ declare module 'nitro/types' {
|
|
|
704
713
|
appMiddleware?: Record<string, boolean>
|
|
705
714
|
appLayout?: string | false
|
|
706
715
|
}
|
|
707
|
-
interface NitroRuntimeHooks {
|
|
708
|
-
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
|
|
709
|
-
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event, streaming?: boolean }) => void | Promise<void>
|
|
710
|
-
'render:html:chunk': (chunkContext: NuxtRenderChunkContext, context: { event: H3Event }) => void | Promise<void>
|
|
711
|
-
'render:html:close': (closeContext: NuxtRenderCloseContext, context: { event: H3Event }) => void | Promise<void>
|
|
712
|
-
'render:route': (renderRouteContext: NuxtRenderRouteContext, context: { event: H3Event }) => void | Promise<void>
|
|
713
|
-
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
|
|
714
|
-
}
|
|
715
716
|
}
|
|
716
717
|
`;
|
|
717
718
|
}
|
|
@@ -782,52 +783,188 @@ async function getH3ImportsPreset() {
|
|
|
782
783
|
imports: (await resolveModuleExportNames("nitro/h3", { url: import.meta.url })).filter((n) => !/^[A-Z]/.test(n) && n !== "use")
|
|
783
784
|
};
|
|
784
785
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
const
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region src/auto-imports.ts
|
|
788
|
+
/** Creates and applies the auto-imports available to the modules the server builder bundles. */
|
|
789
|
+
function createServerAutoImports(nuxt, options, typesDir) {
|
|
790
|
+
const enabled = options.autoImport !== false;
|
|
791
|
+
const importsModulePath = join(typesDir, "types/server-imports");
|
|
792
|
+
const importsModuleDir = dirname(importsModulePath);
|
|
793
|
+
const ctx = createUnimport({
|
|
794
|
+
parser: "oxc",
|
|
795
|
+
injectAtEnd: true,
|
|
796
|
+
presets: options.presets ?? [],
|
|
797
|
+
imports: options.imports ?? [],
|
|
798
|
+
addons: { addons: [] }
|
|
799
|
+
});
|
|
800
|
+
const isIgnored = createIsIgnored(nuxt);
|
|
801
|
+
const scanDirs = options.dirs ?? [];
|
|
802
|
+
let initialised;
|
|
803
|
+
function init() {
|
|
804
|
+
initialised ??= (async () => {
|
|
805
|
+
await ctx.init();
|
|
806
|
+
await scan();
|
|
807
|
+
})();
|
|
808
|
+
return initialised;
|
|
809
|
+
}
|
|
810
|
+
async function scan() {
|
|
811
|
+
if (scanDirs.length === 0) return;
|
|
812
|
+
await ctx.modifyDynamicImports(async (imports) => {
|
|
813
|
+
const scanned = await scanDirExports(scanDirs, { fileFilter: (file) => !isIgnored(file) });
|
|
814
|
+
imports.push(...scanned);
|
|
815
|
+
return imports;
|
|
805
816
|
});
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Resolve the module an import's types are read from to a specifier the generated declaration
|
|
820
|
+
* file can name.
|
|
821
|
+
*
|
|
822
|
+
* A bare specifier is left as written so it resolves through the package's `exports` map: an
|
|
823
|
+
* extensionless relative path cannot reach a subpath shipping only `foo.d.mts`, and under
|
|
824
|
+
* `skipLibCheck` that silently widens every symbol from it to `any`.
|
|
825
|
+
*/
|
|
826
|
+
const resolvedTypePaths = /* @__PURE__ */ new Map();
|
|
827
|
+
function resolveTypePaths(imports) {
|
|
828
|
+
for (const i of imports) {
|
|
829
|
+
const from = i.typeFrom || i.from;
|
|
830
|
+
if (resolvedTypePaths.has(from)) continue;
|
|
831
|
+
resolvedTypePaths.set(from, isAbsolute(from) ? relativeWithDot$1(importsModuleDir, from).replace(/\.[cm]?[jt]sx?$/, "") : from);
|
|
809
832
|
}
|
|
810
|
-
const shim = join(shimDir, preset.from.replace(/\W/g, "_") + ".ts");
|
|
811
|
-
const specifier = relative(shimDir, normalize(resolved));
|
|
812
|
-
shims.push([shim, `export * from '${specifier.startsWith(".") ? specifier : "./" + specifier}'\n`]);
|
|
813
|
-
shimmed.push({
|
|
814
|
-
...preset,
|
|
815
|
-
typeFrom: shim
|
|
816
|
-
});
|
|
817
833
|
}
|
|
818
834
|
return {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
await
|
|
835
|
+
enabled,
|
|
836
|
+
importsModulePath,
|
|
837
|
+
async injectImports(code, id, injectOptions) {
|
|
838
|
+
if (!enabled) return;
|
|
839
|
+
await init();
|
|
840
|
+
return ctx.injectImports(code, id, {
|
|
841
|
+
autoImport: true,
|
|
842
|
+
id,
|
|
843
|
+
...injectOptions
|
|
844
|
+
});
|
|
845
|
+
},
|
|
846
|
+
async getImports() {
|
|
847
|
+
if (!enabled) return [];
|
|
848
|
+
await init();
|
|
849
|
+
return ctx.getImports();
|
|
850
|
+
},
|
|
851
|
+
async refresh() {
|
|
852
|
+
if (!enabled) return;
|
|
853
|
+
await init();
|
|
854
|
+
resolvedTypePaths.clear();
|
|
855
|
+
await ctx.modifyDynamicImports((imports) => {
|
|
856
|
+
imports.length = 0;
|
|
857
|
+
return imports;
|
|
858
|
+
});
|
|
859
|
+
await scan();
|
|
860
|
+
},
|
|
861
|
+
async writeTypes() {
|
|
862
|
+
await mkdir(join(typesDir, "types"), { recursive: true });
|
|
863
|
+
if (!enabled) {
|
|
864
|
+
await writeFile(importsModulePath + ".d.ts", "export {}\n", "utf8");
|
|
865
|
+
await writeFile(importsModulePath + ".mjs", "export {}\n", "utf8");
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
await init();
|
|
869
|
+
const imports = await ctx.getImports();
|
|
870
|
+
resolveTypePaths(imports);
|
|
871
|
+
const declarations = await ctx.generateTypeDeclarations({
|
|
872
|
+
exportHelper: false,
|
|
873
|
+
resolvePath: (i) => resolvedTypePaths.get(i.typeFrom || i.from) ?? i.from
|
|
874
|
+
});
|
|
875
|
+
const reExports = toExports(imports, importsModuleDir, true);
|
|
876
|
+
await Promise.all([writeFile(importsModulePath + ".d.ts", [
|
|
877
|
+
declarations.trim(),
|
|
878
|
+
reExports.trim() || "export {}",
|
|
879
|
+
""
|
|
880
|
+
].join("\n"), "utf8"), writeFile(importsModulePath + ".mjs", (toExports(imports, importsModuleDir).trim() || "export {}") + "\n", "utf8")]);
|
|
824
881
|
}
|
|
825
882
|
};
|
|
826
883
|
}
|
|
884
|
+
/** Resolve the directories scanned for server auto-imports across all layers. */
|
|
885
|
+
function resolveServerImportDirs(nuxt) {
|
|
886
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
887
|
+
if (nuxt.options.imports.scan === false) return [];
|
|
888
|
+
for (const layer of nuxt.options._layers) {
|
|
889
|
+
if (layer.config?.imports?.scan === false) continue;
|
|
890
|
+
const shared = layer.config.dir?.shared ?? "shared";
|
|
891
|
+
dirs.add(join(layer.config.rootDir, shared, "utils"));
|
|
892
|
+
dirs.add(join(layer.config.rootDir, shared, "types"));
|
|
893
|
+
dirs.add(join(layer.config.serverDir ?? join(layer.config.rootDir, "server"), "utils"));
|
|
894
|
+
dirs.add(join(layer.config.serverDir ?? join(layer.config.rootDir, "server"), "types"));
|
|
895
|
+
}
|
|
896
|
+
return [...dirs];
|
|
897
|
+
}
|
|
898
|
+
const RELATIVE_RE$1 = /^\.{1,2}\//;
|
|
899
|
+
function relativeWithDot$1(from, to) {
|
|
900
|
+
const rel = relative(from, to);
|
|
901
|
+
return RELATIVE_RE$1.test(rel) ? rel : "./" + rel;
|
|
902
|
+
}
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region src/route-rules.ts
|
|
905
|
+
/**
|
|
906
|
+
* Rewrites `redirect.statusCode` to `redirect.status`, warning once per route.
|
|
907
|
+
*
|
|
908
|
+
* The nitro v2 spelling is silently ignored by the version Nuxt now builds on, which would turn
|
|
909
|
+
* a configured redirect status into a default without any indication.
|
|
910
|
+
*/
|
|
911
|
+
function normalizeLegacyRouteRules(routeRules) {
|
|
912
|
+
for (const route in routeRules) {
|
|
913
|
+
const redirect = routeRules[route]?.redirect;
|
|
914
|
+
if (!redirect || typeof redirect !== "object" || !("statusCode" in redirect)) continue;
|
|
915
|
+
const { statusCode, ...rest } = redirect;
|
|
916
|
+
routeRules[route].redirect = {
|
|
917
|
+
...rest,
|
|
918
|
+
status: rest.status ?? statusCode
|
|
919
|
+
};
|
|
920
|
+
bundlerDiagnostics.NUXT_B7026({ route });
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
//#endregion
|
|
924
|
+
//#region src/auto-imports-plugin.ts
|
|
925
|
+
const EXCLUDE_RE = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/];
|
|
926
|
+
const INCLUDE_RE = /\.[cm]?[jt]sx?$/;
|
|
927
|
+
/**
|
|
928
|
+
* Injects the server auto-imports.
|
|
929
|
+
*
|
|
930
|
+
* Registered on both the Rollup config and the `nitro` Vite environment, as either may build the
|
|
931
|
+
* server bundle depending on `experimental.nitroViteEnvironment`.
|
|
932
|
+
*/
|
|
933
|
+
const ServerAutoImportsPlugin = createUnplugin(({ autoImports, sourcemap }) => {
|
|
934
|
+
return {
|
|
935
|
+
name: "nuxt:server-auto-imports",
|
|
936
|
+
enforce: "post",
|
|
937
|
+
transformInclude(id) {
|
|
938
|
+
const path = normalize(id);
|
|
939
|
+
return INCLUDE_RE.test(path.split("?")[0]) && !EXCLUDE_RE.some((re) => re.test(path));
|
|
940
|
+
},
|
|
941
|
+
async transform(code, id) {
|
|
942
|
+
const result = await autoImports.injectImports(code, id);
|
|
943
|
+
if (!result?.s.hasChanged()) return;
|
|
944
|
+
return {
|
|
945
|
+
code: result.s.toString(),
|
|
946
|
+
map: sourcemap ? result.s.generateMap({ hires: true }) : void 0
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
});
|
|
827
951
|
//#endregion
|
|
828
952
|
//#region src/index.ts
|
|
829
953
|
/** Subpath the request-shape extractors are imported from in generated declarations. */
|
|
830
954
|
const REQUEST_TYPES_MODULE = "@nuxt/nitro-server/request-types";
|
|
955
|
+
const excludedServerAlias = [
|
|
956
|
+
/^@vue\/.*$/,
|
|
957
|
+
"vue",
|
|
958
|
+
/vue-router/,
|
|
959
|
+
"vite/client",
|
|
960
|
+
/^#imports/,
|
|
961
|
+
"vue-demi",
|
|
962
|
+
/^#app/,
|
|
963
|
+
"~",
|
|
964
|
+
"@",
|
|
965
|
+
"~~",
|
|
966
|
+
"@@"
|
|
967
|
+
];
|
|
831
968
|
const logLevelMapReverse = {
|
|
832
969
|
silent: 0,
|
|
833
970
|
info: 3,
|
|
@@ -843,21 +980,9 @@ async function bundle(nuxt) {
|
|
|
843
980
|
dir: dirs.public,
|
|
844
981
|
maxAge: 0
|
|
845
982
|
});
|
|
846
|
-
const rootDirWithSlash = withTrailingSlash(nuxt.options.rootDir);
|
|
847
|
-
const moduleEntryPaths = [];
|
|
848
|
-
for (const m of nuxt.options._installedModules) {
|
|
849
|
-
const path = m.meta?.rawPath || m.entryPath;
|
|
850
|
-
if (path) moduleEntryPaths.push(getDirectory(path));
|
|
851
|
-
}
|
|
852
|
-
const modules = await resolveNuxtModule(rootDirWithSlash, moduleEntryPaths);
|
|
853
983
|
addTemplate(nitroSchemaTemplate);
|
|
854
984
|
const importDirs = /* @__PURE__ */ new Set();
|
|
855
|
-
if (nuxt.options.nitro.imports !== false
|
|
856
|
-
if (layer.config?.imports?.scan === false) continue;
|
|
857
|
-
importDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? "shared", "utils"));
|
|
858
|
-
importDirs.add(resolve(layer.config.rootDir, layer.config.dir?.shared ?? "shared", "types"));
|
|
859
|
-
importDirs.add(resolve(layer.config.serverDir ?? resolve(layer.config.rootDir, "server"), "types"));
|
|
860
|
-
}
|
|
985
|
+
if (nuxt.options.nitro.imports !== false) for (const dir of resolveServerImportDirs(nuxt)) importDirs.add(dir);
|
|
861
986
|
nuxt.options.nitro.plugins ||= [];
|
|
862
987
|
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins.map((plugin) => plugin ? resolveAlias(plugin, nuxt.options.alias) : plugin);
|
|
863
988
|
for (const asset of [...nuxt.options.nitro.publicAssets || [], ...nuxt.options.nitro.serverAssets || []]) if (asset?.dir) asset.dir = resolveAlias(asset.dir, nuxt.options.alias);
|
|
@@ -897,15 +1022,8 @@ async function bundle(nuxt) {
|
|
|
897
1022
|
}
|
|
898
1023
|
const mockProxy = resolveModulePath("mocked-exports/proxy", { from: import.meta.url });
|
|
899
1024
|
const typesDir = nuxt.options.typesDir || nuxt.options.buildDir;
|
|
900
|
-
const
|
|
901
|
-
|
|
902
|
-
writeShims: () => Promise.resolve()
|
|
903
|
-
};
|
|
904
|
-
const globalCompilerOptions = { ...nuxt.options.typescript?.tsConfig?.compilerOptions };
|
|
905
|
-
delete globalCompilerOptions.types;
|
|
906
|
-
delete globalCompilerOptions.paths;
|
|
907
|
-
delete globalCompilerOptions.noEmit;
|
|
908
|
-
const nitroConfig = defu(nuxt.options.nitro, { typescript: { tsConfig: { compilerOptions: globalCompilerOptions } } }, {
|
|
1025
|
+
const autoImportPresets = nuxt.options.experimental.nitroAutoImports ? [...v2ImportsPreset, await getH3ImportsPreset()] : [];
|
|
1026
|
+
const nitroConfig = defu(nuxt.options.nitro, {
|
|
909
1027
|
debug: nuxt.options.debug ? nuxt.options.debug.nitro : false,
|
|
910
1028
|
rootDir: nuxt.options.rootDir,
|
|
911
1029
|
workspaceDir: nuxt.options.workspaceDir,
|
|
@@ -923,7 +1041,7 @@ async function bundle(nuxt) {
|
|
|
923
1041
|
imports: {
|
|
924
1042
|
autoImport: nuxt.options.imports.autoImport,
|
|
925
1043
|
dirs: [...importDirs],
|
|
926
|
-
presets:
|
|
1044
|
+
presets: autoImportPresets,
|
|
927
1045
|
imports: [
|
|
928
1046
|
{
|
|
929
1047
|
as: "__buildAssetsURL",
|
|
@@ -997,35 +1115,6 @@ async function bundle(nuxt) {
|
|
|
997
1115
|
"/__nuxt_error": { cache: false }
|
|
998
1116
|
},
|
|
999
1117
|
rolldownConfig: { tsconfig: false },
|
|
1000
|
-
typescript: {
|
|
1001
|
-
generateTsConfig: true,
|
|
1002
|
-
tsconfigPath: join(typesDir, "tsconfig.server.json"),
|
|
1003
|
-
generatedTypesDir: join(typesDir, "types/nitro"),
|
|
1004
|
-
tsConfig: {
|
|
1005
|
-
compilerOptions: {
|
|
1006
|
-
lib: [
|
|
1007
|
-
"esnext",
|
|
1008
|
-
"webworker",
|
|
1009
|
-
"dom.iterable"
|
|
1010
|
-
],
|
|
1011
|
-
skipLibCheck: true,
|
|
1012
|
-
noEmit: true,
|
|
1013
|
-
moduleResolution: "bundler",
|
|
1014
|
-
noUncheckedIndexedAccess: true,
|
|
1015
|
-
allowArbitraryExtensions: true
|
|
1016
|
-
},
|
|
1017
|
-
include: [
|
|
1018
|
-
join(typesDir, "types/nitro-nuxt.d.ts"),
|
|
1019
|
-
...modules.flatMap((m) => {
|
|
1020
|
-
const moduleDir = relativeWithDot(typesDir, m);
|
|
1021
|
-
return [join(moduleDir, "runtime/server"), join(moduleDir, "dist/runtime/server")];
|
|
1022
|
-
}),
|
|
1023
|
-
...layerDirs.map((dirs) => relativeWithDot(typesDir, join(dirs.server, "**/*"))),
|
|
1024
|
-
...layerDirs.map((dirs) => relativeWithDot(typesDir, join(dirs.shared, "**/*.d.ts")))
|
|
1025
|
-
],
|
|
1026
|
-
exclude: [...nuxt.options.modulesDir.map((m) => relativeWithDot(typesDir, m)), relativeWithDot(typesDir, resolve(nuxt.options.rootDir, "dist"))]
|
|
1027
|
-
}
|
|
1028
|
-
},
|
|
1029
1118
|
publicAssets: [nuxt.options.dev ? {
|
|
1030
1119
|
dir: resolve(nuxt.options.buildDir, "dist/client"),
|
|
1031
1120
|
maxAge: 0
|
|
@@ -1279,67 +1368,36 @@ async function bundle(nuxt) {
|
|
|
1279
1368
|
};
|
|
1280
1369
|
const cacheDriverPath = join(distDir, "runtime/utils/cache-driver.mjs");
|
|
1281
1370
|
const cacheDriverOption = isWindows ? pathToFileURL(cacheDriverPath).href : cacheDriverPath;
|
|
1282
|
-
nuxt.options.typescript.hoist.push("nitro", "nitro/app", "nitro/builder", "nitro/cache", "nitro/config", "nitro/context", "nitro/database", "nitro/h3", "nitro/meta", "nitro/runtime-config", "nitro/storage", "nitro/task", "nitro/types", "nitropack/types", "nitropack/runtime", "nitropack", "srvx", "defu", "h3", "consola", "ofetch", "crossws");
|
|
1371
|
+
nuxt.options.typescript.hoist.push("nitro", "nitro/app", "nitro/builder", "nitro/cache", "nitro/config", "nitro/context", "nitro/database", "nitro/h3", "nitro/meta", "nitro/runtime-config", "nitro/storage", "nitro/task", "nitro/types", "nitropack/types", "nitropack/runtime", "nitropack", "srvx", "defu", "h3", "h3/rules", "consola", "ofetch", "crossws");
|
|
1283
1372
|
await nuxt.callHook("nitro:config", nitroConfig);
|
|
1373
|
+
normalizeLegacyRouteRules(nitroConfig.routeRules);
|
|
1374
|
+
const autoImports = createServerAutoImports(nuxt, nitroConfig.imports || { autoImport: false }, typesDir);
|
|
1375
|
+
nitroConfig.alias ||= {};
|
|
1376
|
+
nitroConfig.alias["#imports/server"] = autoImports.importsModulePath;
|
|
1377
|
+
nitroConfig.alias["#imports"] = autoImports.importsModulePath;
|
|
1378
|
+
if (autoImports.enabled) {
|
|
1379
|
+
const autoImportsPluginOptions = {
|
|
1380
|
+
autoImports,
|
|
1381
|
+
sourcemap: !!nuxt.options.sourcemap.server
|
|
1382
|
+
};
|
|
1383
|
+
nitroConfig.rollupConfig.plugins.push(ServerAutoImportsPlugin.rollup(autoImportsPluginOptions));
|
|
1384
|
+
if (nuxt.options.experimental.nitroViteEnvironment) {
|
|
1385
|
+
nuxt.options.vite.plugins ||= [];
|
|
1386
|
+
for (const plugin of [ServerAutoImportsPlugin.vite(autoImportsPluginOptions)].flat()) nuxt.options.vite.plugins.push(Object.assign(plugin, { applyToEnvironment: (env) => env.name === "nitro" }));
|
|
1387
|
+
}
|
|
1388
|
+
const scannedDirs = nitroConfig.imports.dirs ?? [];
|
|
1389
|
+
nuxt.hook("builder:watch", async (event, relativePath) => {
|
|
1390
|
+
if (event !== "add" && event !== "unlink") return;
|
|
1391
|
+
const path = resolve(nuxt.options.srcDir, relativePath);
|
|
1392
|
+
if (!scannedDirs.some((dir) => path === dir || path.startsWith(dir + "/"))) return;
|
|
1393
|
+
await autoImports.refresh();
|
|
1394
|
+
await autoImports.writeTypes();
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1284
1397
|
if (nitroConfig.static && nuxt.options.dev) {
|
|
1285
1398
|
nitroConfig.routeRules ||= {};
|
|
1286
1399
|
nitroConfig.routeRules["/**"] = defu(nitroConfig.routeRules["/**"], { prerender: true });
|
|
1287
1400
|
}
|
|
1288
|
-
const excludedAlias = [
|
|
1289
|
-
/^@vue\/.*$/,
|
|
1290
|
-
"vue",
|
|
1291
|
-
/vue-router/,
|
|
1292
|
-
"vite/client",
|
|
1293
|
-
"#imports",
|
|
1294
|
-
"vue-demi",
|
|
1295
|
-
/^#app/,
|
|
1296
|
-
"~",
|
|
1297
|
-
"@",
|
|
1298
|
-
"~~",
|
|
1299
|
-
"@@"
|
|
1300
|
-
];
|
|
1301
|
-
const isV5OrHigher = nuxt.options.future.compatibilityVersion >= 5;
|
|
1302
|
-
const baseUrl = isV5OrHigher ? void 0 : nitroConfig.typescript.tsConfig.compilerOptions?.baseUrl;
|
|
1303
|
-
const basePath = baseUrl ? resolve(typesDir, baseUrl) : typesDir;
|
|
1304
|
-
const aliases = nitroConfig.alias;
|
|
1305
|
-
const importPaths = nuxt.options.modulesDir.map((d) => pathToFileURL(withTrailingSlash(d)));
|
|
1306
|
-
const tsConfig = nitroConfig.typescript.tsConfig;
|
|
1307
|
-
tsConfig.compilerOptions ||= {};
|
|
1308
|
-
if (isV5OrHigher) Reflect.deleteProperty(tsConfig.compilerOptions, "baseUrl");
|
|
1309
|
-
tsConfig.compilerOptions.paths ||= {};
|
|
1310
|
-
for (const _alias in aliases) {
|
|
1311
|
-
const alias = _alias;
|
|
1312
|
-
if (excludedAlias.some((pattern) => typeof pattern === "string" ? alias === pattern : pattern.test(alias))) continue;
|
|
1313
|
-
if (alias in tsConfig.compilerOptions.paths) continue;
|
|
1314
|
-
let absolutePath = resolve(basePath, aliases[alias]);
|
|
1315
|
-
let stats = await promises.stat(absolutePath).catch(() => null);
|
|
1316
|
-
if (!stats) {
|
|
1317
|
-
const resolvedModule = resolveModulePath(aliases[alias], {
|
|
1318
|
-
try: true,
|
|
1319
|
-
from: importPaths,
|
|
1320
|
-
extensions: [
|
|
1321
|
-
...nuxt.options.extensions,
|
|
1322
|
-
".d.ts",
|
|
1323
|
-
".d.mts",
|
|
1324
|
-
".d.cts"
|
|
1325
|
-
]
|
|
1326
|
-
});
|
|
1327
|
-
if (resolvedModule) {
|
|
1328
|
-
absolutePath = resolvedModule;
|
|
1329
|
-
stats = await promises.stat(resolvedModule).catch(() => null);
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
const isDirectory = aliases[alias].endsWith("/") || stats?.isDirectory();
|
|
1333
|
-
tsConfig.compilerOptions.paths[alias] = [absolutePath];
|
|
1334
|
-
if (isDirectory) tsConfig.compilerOptions.paths[`${alias}/*`] = [`${absolutePath}/*`];
|
|
1335
|
-
}
|
|
1336
|
-
const appDir = nuxt.options.alias["#app"];
|
|
1337
|
-
if (appDir) {
|
|
1338
|
-
tsConfig.compilerOptions.paths["#app/island-hash"] ||= [resolve(appDir, "island-hash")];
|
|
1339
|
-
tsConfig.compilerOptions.paths["#app/island-props"] ||= [resolve(appDir, "island-props")];
|
|
1340
|
-
tsConfig.compilerOptions.paths["#app/internal/*"] ||= [resolve(appDir, "internal/*")];
|
|
1341
|
-
tsConfig.compilerOptions.paths["#app/types"] ||= [resolve(appDir, "types")];
|
|
1342
|
-
}
|
|
1343
1401
|
if (nuxt.options.experimental.nitroViteEnvironment) nitroConfig.renderer = void 0;
|
|
1344
1402
|
nuxt._perf?.startPhase("nitro:createNitro");
|
|
1345
1403
|
const nitro = await createNitro(nitroConfig, {
|
|
@@ -1380,6 +1438,7 @@ async function bundle(nuxt) {
|
|
|
1380
1438
|
dev: true
|
|
1381
1439
|
},
|
|
1382
1440
|
buildsSeparately: !nuxt.options.experimental.nitroViteEnvironment,
|
|
1441
|
+
imports: () => autoImports.getImports(),
|
|
1383
1442
|
preview: { command: () => nitro.options.commands.preview }
|
|
1384
1443
|
}, nuxt);
|
|
1385
1444
|
await nuxt.callHook("nitro:init", nitro);
|
|
@@ -1522,21 +1581,58 @@ async function bundle(nuxt) {
|
|
|
1522
1581
|
});
|
|
1523
1582
|
}
|
|
1524
1583
|
});
|
|
1525
|
-
if (nuxt.options.dev) nitro.hooks.hook("types:extend", async () => {
|
|
1526
|
-
await nuxt.callHook("builder:generateApp", { filter: (template) => template.filename === "server-routes.d.ts" });
|
|
1527
|
-
});
|
|
1528
|
-
nitro.hooks.hook("types:extend", (types) => {
|
|
1529
|
-
types.tsConfig ||= {};
|
|
1530
|
-
const rootDirGlob = relativeWithDot(typesDir, join(nuxt.options.rootDir, "**/*"));
|
|
1531
|
-
types.tsConfig.include = types.tsConfig.include?.filter((i) => i !== rootDirGlob);
|
|
1532
|
-
});
|
|
1533
1584
|
nuxt.hook("prepare:types", async (opts) => {
|
|
1534
|
-
await autoImports.
|
|
1535
|
-
|
|
1585
|
+
await autoImports.writeTypes();
|
|
1586
|
+
opts.serverTsConfig.compilerOptions ||= {};
|
|
1587
|
+
opts.serverTsConfig.compilerOptions.paths ||= {};
|
|
1588
|
+
opts.serverTsConfig.compilerOptions.paths["#imports/server"] = [relativeWithDot(typesDir, autoImports.importsModulePath)];
|
|
1589
|
+
opts.tsConfig.compilerOptions ||= {};
|
|
1590
|
+
opts.tsConfig.compilerOptions.paths ||= {};
|
|
1591
|
+
opts.tsConfig.compilerOptions.paths["#imports/server"] = [relativeWithDot(typesDir, autoImports.importsModulePath)];
|
|
1592
|
+
opts.serverReferences.push({ path: autoImports.importsModulePath + ".d.ts" });
|
|
1593
|
+
opts.references.push({ path: autoImports.importsModulePath + ".d.ts" });
|
|
1536
1594
|
opts.tsConfig.exclude ||= [];
|
|
1537
1595
|
opts.tsConfig.exclude.push(relative(typesDir, resolve(nuxt.options.rootDir, nitro.options.output.dir)));
|
|
1538
|
-
opts.
|
|
1539
|
-
opts.
|
|
1596
|
+
opts.serverTsConfig.exclude ||= [];
|
|
1597
|
+
opts.serverTsConfig.exclude.push(relative(typesDir, resolve(nuxt.options.rootDir, nitro.options.output.dir)));
|
|
1598
|
+
opts.serverReferences.push({ path: resolve(typesDir, "types/nitro-nuxt.d.ts") });
|
|
1599
|
+
opts.serverTsConfig.compilerOptions ||= {};
|
|
1600
|
+
opts.serverTsConfig.compilerOptions.paths ||= {};
|
|
1601
|
+
const serverPaths = opts.serverTsConfig.compilerOptions.paths;
|
|
1602
|
+
const serverBaseUrl = nuxt.options.future.compatibilityVersion >= 5 ? void 0 : opts.serverTsConfig.compilerOptions.baseUrl;
|
|
1603
|
+
const aliasBasePath = serverBaseUrl ? resolve(typesDir, serverBaseUrl) : typesDir;
|
|
1604
|
+
for (const alias in nitro.options.alias) {
|
|
1605
|
+
if (alias in nuxt.options.alias || alias in serverPaths) continue;
|
|
1606
|
+
if (excludedServerAlias.some((pattern) => typeof pattern === "string" ? alias === pattern : pattern.test(alias))) continue;
|
|
1607
|
+
const target = nitro.options.alias[alias];
|
|
1608
|
+
let absolutePath = resolve(aliasBasePath, target);
|
|
1609
|
+
let stats = await promises.stat(absolutePath).catch(() => null);
|
|
1610
|
+
if (!stats) {
|
|
1611
|
+
const resolvedModule = resolveModulePath(target, {
|
|
1612
|
+
try: true,
|
|
1613
|
+
from: nuxt.options.modulesDir.map((d) => pathToFileURL(withTrailingSlash(d))),
|
|
1614
|
+
extensions: [
|
|
1615
|
+
...nuxt.options.extensions,
|
|
1616
|
+
".d.ts",
|
|
1617
|
+
".d.mts",
|
|
1618
|
+
".d.cts"
|
|
1619
|
+
]
|
|
1620
|
+
});
|
|
1621
|
+
if (resolvedModule) {
|
|
1622
|
+
absolutePath = resolvedModule;
|
|
1623
|
+
stats = await promises.stat(resolvedModule).catch(() => null);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
serverPaths[alias] = [absolutePath];
|
|
1627
|
+
if (target.endsWith("/") || stats?.isDirectory()) serverPaths[`${alias}/*`] = [`${absolutePath}/*`];
|
|
1628
|
+
}
|
|
1629
|
+
const appDir = nuxt.options.alias["#app"];
|
|
1630
|
+
if (appDir) {
|
|
1631
|
+
serverPaths["#app/island-hash"] ||= [resolve(appDir, "island-hash")];
|
|
1632
|
+
serverPaths["#app/island-props"] ||= [resolve(appDir, "island-props")];
|
|
1633
|
+
serverPaths["#app/internal/*"] ||= [resolve(appDir, "internal/*")];
|
|
1634
|
+
serverPaths["#app/types"] ||= [resolve(appDir, "types")];
|
|
1635
|
+
}
|
|
1540
1636
|
opts.tsConfig.compilerOptions ||= {};
|
|
1541
1637
|
opts.tsConfig.compilerOptions.paths ||= {};
|
|
1542
1638
|
opts.tsConfig.compilerOptions.paths[REQUEST_TYPES_MODULE] = [resolve(distDir, "request-types")];
|
|
@@ -29,7 +29,7 @@ function matchesPageRoute(pathname) {
|
|
|
29
29
|
function throwIfUnmatchedPagePath(event, routeOptions) {
|
|
30
30
|
if (matchesPageRoute(event.url.pathname)) return;
|
|
31
31
|
const path = event.url.pathname + event.url.search;
|
|
32
|
-
const maxAge = routeOptions.cache?.
|
|
32
|
+
const maxAge = routeOptions.cache?.maxAge;
|
|
33
33
|
const cacheable = !!maxAge && maxAge > 0 && (event.req.method === "GET" || event.req.method === "HEAD");
|
|
34
34
|
throw new HTTPError({
|
|
35
35
|
status: 404,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/nitro-server-nightly",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-29809859.f0ca99e9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ampproject/remapping": "^2.3.0",
|
|
39
|
-
"@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-
|
|
39
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-29809859.f0ca99e9",
|
|
40
40
|
"@unhead/vue": "^3.4.0",
|
|
41
41
|
"@vue/shared": "^3.5.42",
|
|
42
42
|
"consola": "^3.4.2",
|
|
@@ -51,17 +51,19 @@
|
|
|
51
51
|
"lru-cache": "^11.5.2",
|
|
52
52
|
"magic-string": "^1.2.3",
|
|
53
53
|
"mocked-exports": "^0.1.1",
|
|
54
|
-
"nitro": "^3.0.
|
|
54
|
+
"nitro": "^3.0.260903-beta",
|
|
55
55
|
"nostics": "^1.2.0",
|
|
56
56
|
"ohash": "^2.0.12",
|
|
57
57
|
"pathe": "^2.0.3",
|
|
58
58
|
"rou3": "^0.9.2",
|
|
59
|
-
"srvx": "0.
|
|
59
|
+
"srvx": "^1.0.3",
|
|
60
60
|
"std-env": "^4.2.0",
|
|
61
61
|
"ufo": "^1.6.4",
|
|
62
62
|
"unctx": "^3.0.1",
|
|
63
|
+
"unimport": "6.4.0",
|
|
64
|
+
"unplugin": "^3.3.0",
|
|
63
65
|
"unrouting": "^0.2.3",
|
|
64
|
-
"unstorage": "2.0.0-alpha.
|
|
66
|
+
"unstorage": "^2.0.0-alpha.10",
|
|
65
67
|
"vue": "^3.5.42",
|
|
66
68
|
"vue-bundle-renderer": "^2.3.2",
|
|
67
69
|
"vue-devtools-stub": "^0.1.0"
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
"@babel/plugin-proposal-decorators": "^7.25.0 || ^8.0.0",
|
|
71
73
|
"@babel/plugin-syntax-typescript": "^7.25.0 || ^8.0.0",
|
|
72
74
|
"@rollup/plugin-babel": "^6.0.0 || ^7.0.0",
|
|
73
|
-
"nuxt": "npm:nuxt-nightly@5.0.0-
|
|
75
|
+
"nuxt": "npm:nuxt-nightly@5.0.0-29809859.f0ca99e9"
|
|
74
76
|
},
|
|
75
77
|
"peerDependenciesMeta": {
|
|
76
78
|
"@babel/plugin-proposal-decorators": {
|
|
@@ -86,10 +88,10 @@
|
|
|
86
88
|
"devDependencies": {
|
|
87
89
|
"@babel/plugin-proposal-decorators": "8.0.2",
|
|
88
90
|
"@babel/plugin-syntax-typescript": "8.0.3",
|
|
89
|
-
"@nuxt/schema": "npm:@nuxt/schema-nightly@5.0.0-
|
|
91
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@5.0.0-29809859.f0ca99e9",
|
|
90
92
|
"@rollup/plugin-babel": "7.1.0",
|
|
91
93
|
"hookable": "^6.1.1",
|
|
92
|
-
"nuxt": "npm:nuxt-nightly@5.0.0-
|
|
94
|
+
"nuxt": "npm:nuxt-nightly@5.0.0-29809859.f0ca99e9",
|
|
93
95
|
"tsdown": "0.22.14",
|
|
94
96
|
"vitest": "4.1.11"
|
|
95
97
|
},
|