@nuxt/nitro-server-nightly 4.4.0-29506647.0fa65fc3 → 4.4.0-29532345.7b49d0cc
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/README.md +3 -3
- package/dist/THIRD-PARTY-LICENSES.md +11 -0
- package/dist/index.d.mts +100 -0
- package/dist/index.mjs +55 -58
- package/dist/runtime/handlers/island.d.mts +3 -2
- package/dist/runtime/handlers/island.mjs +2 -1
- package/dist/runtime/handlers/renderer.d.mts +3 -2
- package/dist/runtime/handlers/renderer.mjs +4 -4
- package/dist/runtime/middleware/no-ssr.d.mts +3 -2
- package/dist/runtime/middleware/no-ssr.mjs +2 -1
- package/dist/runtime/plugins/dev-server-logs.d.mts +2 -1
- package/dist/runtime/utils/cache.d.mts +11 -5
- package/dist/runtime/utils/config.d.mts +1 -1
- package/dist/runtime/utils/error.d.mts +1 -1
- package/dist/runtime/utils/error.mjs +1 -1
- package/dist/runtime/utils/renderer/app.mjs +1 -9
- package/dist/runtime/utils/renderer/build-files.d.mts +2 -4
- package/dist/runtime/utils/renderer/payload.mjs +10 -2
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
<a href="https://nuxt.com"><img width="830" height="213" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/banner.svg" alt="Nuxt banner"></a>
|
|
2
2
|
|
|
3
3
|
# Nuxt
|
|
4
4
|
|
|
5
5
|
<p>
|
|
6
|
-
<a href="https://
|
|
7
|
-
<a href="https://
|
|
6
|
+
<a href="https://npmx.dev/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
|
|
7
|
+
<a href="https://npmx.dev/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
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>
|
|
10
10
|
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
|
package/dist/index.d.mts
CHANGED
|
@@ -178,6 +178,106 @@ declare module "@nuxt/schema" {
|
|
|
178
178
|
rules?: NitroRouteConfig;
|
|
179
179
|
}
|
|
180
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
|
+
}
|
|
181
281
|
//#endregion
|
|
182
282
|
//#region src/index.d.ts
|
|
183
283
|
declare function bundle(nuxt: Nuxt & {
|
package/dist/index.mjs
CHANGED
|
@@ -19,34 +19,23 @@ import { isWindows } from "std-env";
|
|
|
19
19
|
import { ImpoundPlugin } from "impound";
|
|
20
20
|
import { resolveModulePath } from "exsolve";
|
|
21
21
|
import { runtimeDependencies } from "nitropack/runtime/meta";
|
|
22
|
-
|
|
23
|
-
//#region package.json
|
|
24
|
-
var version = "4.4.0-29506647.0fa65fc3";
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/utils.ts
|
|
22
|
+
var version = "4.4.0-29532345.7b49d0cc";
|
|
28
23
|
function toArray(value) {
|
|
29
24
|
return Array.isArray(value) ? value : [value];
|
|
30
25
|
}
|
|
31
26
|
let _distDir = dirname(fileURLToPath(import.meta.url));
|
|
32
27
|
if (/(?:chunks|shared)$/.test(_distDir)) _distDir = dirname(_distDir);
|
|
33
28
|
const distDir = _distDir;
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region ../ui-templates/dist/templates/spa-loading-icon.ts
|
|
37
29
|
const template = () => {
|
|
38
30
|
return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"80\" fill=\"none\" class=\"nuxt-spa-loading\" viewBox=\"0 0 37 25\"><path d=\"M24.236 22.006h10.742L25.563 5.822l-8.979 14.31a4 4 0 0 1-3.388 1.874H2.978l11.631-20 5.897 10.567\"/></svg><style>.nuxt-spa-loading{left:50%;position:fixed;top:50%;transform:translate(-50%,-50%)}.nuxt-spa-loading>path{animation:nuxt-spa-loading-move 3s linear infinite;fill:none;stroke:#00dc82;stroke-dasharray:128;stroke-dashoffset:128;stroke-linecap:round;stroke-linejoin:round;stroke-width:4px}@keyframes nuxt-spa-loading-move{to{stroke-dashoffset:-128}}</style>";
|
|
39
31
|
};
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region ../nuxt/src/core/plugins/import-protection.ts
|
|
43
32
|
function createImportProtectionPatterns(nuxt, options) {
|
|
44
33
|
const patterns = [];
|
|
45
34
|
const context = contextFlags[options.context];
|
|
46
35
|
patterns.push([/^(nuxt|nuxt3|nuxt-nightly)$/, `\`nuxt\`, or \`nuxt-nightly\` cannot be imported directly in ${context}.` + (options.context === "nuxt-app" ? " Instead, import runtime Nuxt composables from `#app` or `#imports`." : "")]);
|
|
47
36
|
patterns.push([/^((~|~~|@|@@)?\/)?nuxt\.config(\.|$)/, "Importing directly from a `nuxt.config` file is not allowed. Instead, use runtime config or a module."]);
|
|
48
37
|
patterns.push([/(^|node_modules\/)@vue\/composition-api/]);
|
|
49
|
-
for (const mod of nuxt.options._installedModules) if (mod.entryPath) patterns.push([
|
|
38
|
+
for (const mod of nuxt.options._installedModules) if (mod.entryPath) patterns.push([new RegExp(`^${escapeRE(mod.entryPath)}$`), "Importing directly from module entry-points is not allowed."]);
|
|
50
39
|
for (const i of [
|
|
51
40
|
/(^|node_modules\/)@nuxt\/(cli|kit|test-utils)/,
|
|
52
41
|
/(^|node_modules\/)nuxi/,
|
|
@@ -55,7 +44,7 @@ function createImportProtectionPatterns(nuxt, options) {
|
|
|
55
44
|
]) patterns.push([i, `This module cannot be imported in ${context}.`]);
|
|
56
45
|
if (options.context === "nitro-app" || options.context === "shared") for (const i of ["#app", /^#build(\/|$)/]) patterns.push([i, `Vue app aliases are not allowed in ${context}.`]);
|
|
57
46
|
if (options.context === "nuxt-app" || options.context === "shared") {
|
|
58
|
-
patterns.push([
|
|
47
|
+
patterns.push([new RegExp(escapeRE(relative(nuxt.options.srcDir, resolve(nuxt.options.srcDir, nuxt.options.serverDir || "server"))) + "\\/(api|routes|middleware|plugins)\\/"), `Importing from server is not allowed in ${context}.`]);
|
|
59
48
|
patterns.push([/^#server(\/|$)/, `Server aliases are not allowed in ${context}.`]);
|
|
60
49
|
}
|
|
61
50
|
return patterns;
|
|
@@ -65,9 +54,6 @@ const contextFlags = {
|
|
|
65
54
|
"nuxt-app": "the Vue part of your app",
|
|
66
55
|
"shared": "the #shared directory"
|
|
67
56
|
};
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/templates.ts
|
|
71
57
|
const nitroSchemaTemplate = {
|
|
72
58
|
filename: "types/nitro-nuxt.d.ts",
|
|
73
59
|
async getContents({ nuxt }) {
|
|
@@ -144,9 +130,6 @@ declare module 'nitropack/types' {
|
|
|
144
130
|
function renderReference(ref, baseDir) {
|
|
145
131
|
return `/// <reference ${"path" in ref ? `path="${isAbsolute(ref.path) ? relative(baseDir, ref.path) : ref.path}"` : `types="${ref.types}"`} />`;
|
|
146
132
|
}
|
|
147
|
-
|
|
148
|
-
//#endregion
|
|
149
|
-
//#region src/index.ts
|
|
150
133
|
const logLevelMapReverse = {
|
|
151
134
|
silent: 0,
|
|
152
135
|
info: 3,
|
|
@@ -163,7 +146,7 @@ async function bundle(nuxt) {
|
|
|
163
146
|
}
|
|
164
147
|
const layerPublicAssetsDirs = [];
|
|
165
148
|
for (const dirs of layerDirs) if (existsSync(dirs.public)) layerPublicAssetsDirs.push({ dir: dirs.public });
|
|
166
|
-
const excludePattern = excludePaths.length ? [
|
|
149
|
+
const excludePattern = excludePaths.length ? [new RegExp(`node_modules\\/(?!${excludePaths.join("|")})`)] : [/node_modules/];
|
|
167
150
|
const rootDirWithSlash = withTrailingSlash(nuxt.options.rootDir);
|
|
168
151
|
const moduleEntryPaths = [];
|
|
169
152
|
for (const m of nuxt.options._installedModules) {
|
|
@@ -440,18 +423,18 @@ async function bundle(nuxt) {
|
|
|
440
423
|
}
|
|
441
424
|
});
|
|
442
425
|
if (nuxt.options.experimental.payloadExtraction) {
|
|
443
|
-
if (nuxt.options.dev) nuxt.hook("nitro:config", (nitroConfig
|
|
444
|
-
nitroConfig
|
|
445
|
-
nitroConfig
|
|
446
|
-
nitroConfig
|
|
447
|
-
for (const route of nitroConfig
|
|
426
|
+
if (nuxt.options.dev) nuxt.hook("nitro:config", (nitroConfig) => {
|
|
427
|
+
nitroConfig.prerender ||= {};
|
|
428
|
+
nitroConfig.prerender.routes ||= [];
|
|
429
|
+
nitroConfig.routeRules ||= {};
|
|
430
|
+
for (const route of nitroConfig.prerender.routes) {
|
|
448
431
|
if (!route) continue;
|
|
449
|
-
nitroConfig
|
|
432
|
+
nitroConfig.routeRules[route] = defu(nitroConfig.routeRules[route], { prerender: true });
|
|
450
433
|
}
|
|
451
434
|
});
|
|
452
|
-
nuxt.hook("nitro:init", (nitro
|
|
453
|
-
nitro
|
|
454
|
-
for (const [route, value] of Object.entries(nitro
|
|
435
|
+
nuxt.hook("nitro:init", (nitro) => {
|
|
436
|
+
nitro.hooks.hook("build:before", (nitro) => {
|
|
437
|
+
for (const [route, value] of Object.entries(nitro.options.routeRules)) if (!route.endsWith("*") && !route.endsWith("/_payload.json")) {
|
|
455
438
|
if (value.isr || value.cache || value.prerender && nuxt.options.dev) {
|
|
456
439
|
const payloadKey = route + "/_payload.json";
|
|
457
440
|
const defaults = {};
|
|
@@ -460,7 +443,7 @@ async function bundle(nuxt) {
|
|
|
460
443
|
"cache",
|
|
461
444
|
...nuxt.options.dev ? ["prerender"] : []
|
|
462
445
|
]) if (key in value) defaults[key] = value[key];
|
|
463
|
-
nitro
|
|
446
|
+
nitro.options.routeRules[payloadKey] = defu(nitro.options.routeRules[payloadKey], defaults);
|
|
464
447
|
}
|
|
465
448
|
}
|
|
466
449
|
});
|
|
@@ -492,13 +475,13 @@ async function bundle(nuxt) {
|
|
|
492
475
|
config.alias ||= {};
|
|
493
476
|
config.alias["#app-manifest"] = join(tempDir, `meta/${buildId}.json`);
|
|
494
477
|
});
|
|
495
|
-
nuxt.hook("nitro:init", (nitro
|
|
496
|
-
nitro
|
|
478
|
+
nuxt.hook("nitro:init", (nitro) => {
|
|
479
|
+
nitro.hooks.hook("rollup:before", async (nitro) => {
|
|
497
480
|
const prerenderedRoutes = /* @__PURE__ */ new Set();
|
|
498
481
|
const routeRulesMatcher = getRouteRulesRouter();
|
|
499
|
-
if (nitro
|
|
482
|
+
if (nitro._prerenderedRoutes?.length) {
|
|
500
483
|
const payloadSuffix = nuxt.options.experimental.renderJsonPayloads ? "/_payload.json" : "/_payload.js";
|
|
501
|
-
for (const route of nitro
|
|
484
|
+
for (const route of nitro._prerenderedRoutes) if (!route.error && route.route.endsWith(payloadSuffix)) {
|
|
502
485
|
const url = route.route.slice(0, -payloadSuffix.length) || "/";
|
|
503
486
|
if (!defu({}, ...findAllRoutes(routeRulesMatcher, void 0, url).reverse()).prerender) prerenderedRoutes.add(url);
|
|
504
487
|
}
|
|
@@ -533,8 +516,8 @@ async function bundle(nuxt) {
|
|
|
533
516
|
const relativeSharedDir = withTrailingSlash(relative(nuxt.options.rootDir, resolve(nuxt.options.rootDir, nuxt.options.dir.shared)));
|
|
534
517
|
const sharedPatterns = [
|
|
535
518
|
/^#shared\//,
|
|
536
|
-
|
|
537
|
-
|
|
519
|
+
new RegExp("^" + escapeRE(sharedDir)),
|
|
520
|
+
new RegExp("^" + escapeRE(relativeSharedDir))
|
|
538
521
|
];
|
|
539
522
|
nitroConfig.rollupConfig.plugins.push(ImpoundPlugin.rollup({
|
|
540
523
|
cwd: nuxt.options.rootDir,
|
|
@@ -625,6 +608,22 @@ async function bundle(nuxt) {
|
|
|
625
608
|
await nuxt.callHook("nitro:init", nitro);
|
|
626
609
|
nuxt["~runtimeDependencies"] ||= [];
|
|
627
610
|
nuxt["~runtimeDependencies"].push(...runtimeDependencies, "unhead", "@unhead/vue", "@nuxt/devalue", "unstorage", ...nitro.options.inlineDynamicImports ? ["vue", "@vue/server-renderer"] : []);
|
|
611
|
+
addVitePlugin({
|
|
612
|
+
name: "nuxt:nitro:ssr-conditions",
|
|
613
|
+
configEnvironment(name, config) {
|
|
614
|
+
if (name === "ssr") {
|
|
615
|
+
config.resolve ||= {};
|
|
616
|
+
config.resolve.conditions = [...nitro.options.exportConditions || [], "import"];
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
addVitePlugin({
|
|
621
|
+
name: "nuxt:nitro:vue-feature-flags",
|
|
622
|
+
applyToEnvironment: (environment) => environment.name === "ssr" && environment.config.isProduction,
|
|
623
|
+
configResolved(config) {
|
|
624
|
+
for (const key in config.define) if (key.startsWith("__VUE")) nitro.options.replace[key] = config.define[key];
|
|
625
|
+
}
|
|
626
|
+
});
|
|
628
627
|
nitro.vfs = nuxt.vfs = nitro.vfs || nuxt.vfs || {};
|
|
629
628
|
nuxt.hook("close", () => nitro.hooks.callHook("close"));
|
|
630
629
|
nitro.hooks.hook("prerender:routes", (routes) => {
|
|
@@ -658,12 +657,12 @@ async function bundle(nuxt) {
|
|
|
658
657
|
handler: resolve(distDir, "runtime/handlers/renderer")
|
|
659
658
|
});
|
|
660
659
|
if (nuxt.options.experimental.chromeDevtoolsProjectSettings) {
|
|
661
|
-
const cacheDir
|
|
662
|
-
let projectConfiguration = await readFile(join(cacheDir
|
|
660
|
+
const cacheDir = resolve(nuxt.options.rootDir, "node_modules/.cache/nuxt");
|
|
661
|
+
let projectConfiguration = await readFile(join(cacheDir, "chrome-workspace.json"), "utf-8").then((r) => JSON.parse(r)).catch(() => null);
|
|
663
662
|
if (!projectConfiguration) {
|
|
664
663
|
projectConfiguration = { uuid: randomUUID() };
|
|
665
|
-
await mkdir(cacheDir
|
|
666
|
-
await writeFile(join(cacheDir
|
|
664
|
+
await mkdir(cacheDir, { recursive: true });
|
|
665
|
+
await writeFile(join(cacheDir, "chrome-workspace.json"), JSON.stringify(projectConfiguration), "utf-8");
|
|
667
666
|
}
|
|
668
667
|
nitro.options.devHandlers.push({
|
|
669
668
|
route: "/.well-known/appspecific/com.chrome.devtools.json",
|
|
@@ -673,14 +672,14 @@ async function bundle(nuxt) {
|
|
|
673
672
|
} }))
|
|
674
673
|
});
|
|
675
674
|
}
|
|
676
|
-
if (!nuxt.options.dev && nuxt.options.experimental.noVueServer) nitro.hooks.hook("rollup:before", (nitro
|
|
677
|
-
if (nitro
|
|
678
|
-
nitro
|
|
675
|
+
if (!nuxt.options.dev && nuxt.options.experimental.noVueServer) nitro.hooks.hook("rollup:before", (nitro) => {
|
|
676
|
+
if (nitro.options.preset === "nitro-prerender") {
|
|
677
|
+
nitro.options.errorHandler = resolve(distDir, "runtime/handlers/error");
|
|
679
678
|
return;
|
|
680
679
|
}
|
|
681
|
-
const nuxtErrorHandler = nitro
|
|
682
|
-
if (nuxtErrorHandler >= 0) nitro
|
|
683
|
-
nitro
|
|
680
|
+
const nuxtErrorHandler = nitro.options.handlers.findIndex((h) => h.route === "/__nuxt_error");
|
|
681
|
+
if (nuxtErrorHandler >= 0) nitro.options.handlers.splice(nuxtErrorHandler, 1);
|
|
682
|
+
nitro.options.renderer = void 0;
|
|
684
683
|
});
|
|
685
684
|
nitro.hooks.hook("types:extend", (types) => {
|
|
686
685
|
types.tsConfig ||= {};
|
|
@@ -708,14 +707,14 @@ async function bundle(nuxt) {
|
|
|
708
707
|
for (const route of ["/200.html", "/404.html"]) routes.add(route);
|
|
709
708
|
if (!nuxt.options.ssr) routes.add("/index.html");
|
|
710
709
|
});
|
|
711
|
-
if (!nuxt.options.dev) nitro.hooks.hook("rollup:before", async (nitro
|
|
712
|
-
await copyPublicAssets(nitro
|
|
713
|
-
await nuxt.callHook("nitro:build:public-assets", nitro
|
|
710
|
+
if (!nuxt.options.dev) nitro.hooks.hook("rollup:before", async (nitro) => {
|
|
711
|
+
await copyPublicAssets(nitro);
|
|
712
|
+
await nuxt.callHook("nitro:build:public-assets", nitro);
|
|
714
713
|
});
|
|
715
714
|
async function symlinkDist() {
|
|
716
715
|
if (nitro.options.static) {
|
|
717
|
-
const distDir
|
|
718
|
-
if (!existsSync(distDir
|
|
716
|
+
const distDir = resolve(nuxt.options.rootDir, "dist");
|
|
717
|
+
if (!existsSync(distDir)) await promises.symlink(nitro.options.output.publicDir, distDir, "junction").catch(() => {});
|
|
719
718
|
}
|
|
720
719
|
}
|
|
721
720
|
nuxt.hook("build:done", async () => {
|
|
@@ -753,7 +752,7 @@ async function bundle(nuxt) {
|
|
|
753
752
|
}));
|
|
754
753
|
});
|
|
755
754
|
nuxt.server = createDevServer(nitro);
|
|
756
|
-
const waitUntilCompile = new Promise((resolve
|
|
755
|
+
const waitUntilCompile = new Promise((resolve) => nitro.hooks.hook("compiled", () => resolve()));
|
|
757
756
|
nuxt.hook("build:done", () => waitUntilCompile);
|
|
758
757
|
}
|
|
759
758
|
}
|
|
@@ -767,14 +766,12 @@ async function spaLoadingTemplatePath(nuxt) {
|
|
|
767
766
|
}
|
|
768
767
|
async function spaLoadingTemplate(nuxt) {
|
|
769
768
|
if (nuxt.options.spaLoadingTemplate === false) return "";
|
|
770
|
-
const spaLoadingTemplate
|
|
769
|
+
const spaLoadingTemplate = await spaLoadingTemplatePath(nuxt);
|
|
771
770
|
try {
|
|
772
|
-
if (existsSync(spaLoadingTemplate
|
|
771
|
+
if (existsSync(spaLoadingTemplate)) return readFileSync(spaLoadingTemplate, "utf-8").trim();
|
|
773
772
|
} catch {}
|
|
774
773
|
if (nuxt.options.spaLoadingTemplate === true) return template();
|
|
775
774
|
if (nuxt.options.spaLoadingTemplate) logger.warn(`Could not load custom \`spaLoadingTemplate\` path as it does not exist: \`${nuxt.options.spaLoadingTemplate}\`.`);
|
|
776
775
|
return "";
|
|
777
776
|
}
|
|
778
|
-
|
|
779
|
-
//#endregion
|
|
780
|
-
export { bundle };
|
|
777
|
+
export { bundle };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { EventHandler } from "h3";
|
|
2
|
+
declare const handler: EventHandler;
|
|
3
|
+
export default handler;
|
|
@@ -10,7 +10,7 @@ import { getSSRRenderer } from "../utils/renderer/build-files.mjs";
|
|
|
10
10
|
import { renderInlineStyles } from "../utils/renderer/inline-styles.mjs";
|
|
11
11
|
import { getClientIslandResponse, getServerComponentHTML, getSlotIslandResponse } from "../utils/renderer/islands.mjs";
|
|
12
12
|
const ISLAND_SUFFIX_RE = /\.json(?:\?.*)?$/;
|
|
13
|
-
|
|
13
|
+
const handler = defineEventHandler(async (event) => {
|
|
14
14
|
const nitroApp = useNitroApp();
|
|
15
15
|
setResponseHeaders(event, {
|
|
16
16
|
"content-type": "application/json;charset=utf-8",
|
|
@@ -95,6 +95,7 @@ export default defineEventHandler(async (event) => {
|
|
|
95
95
|
}
|
|
96
96
|
return islandResponse;
|
|
97
97
|
});
|
|
98
|
+
export default handler;
|
|
98
99
|
async function getIslandContext(event) {
|
|
99
100
|
// TODO: Strict validation for url
|
|
100
101
|
let url = event.path || "";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { EventHandler } from "h3";
|
|
2
|
+
declare const handler: EventHandler;
|
|
3
|
+
export default handler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { getPrefetchLinks, getPreloadLinks, getRequestDependencies, renderResourceHeaders } from "vue-bundle-renderer/runtime";
|
|
3
3
|
import { appendResponseHeader, createError, getQuery, getResponseStatus, getResponseStatusText, writeEarlyHints } from "h3";
|
|
4
|
-
import {
|
|
4
|
+
import { getQuery as getURLQuery, joinURL } from "ufo";
|
|
5
5
|
import { propsToString, renderSSRHead } from "@unhead/vue/server";
|
|
6
6
|
import destr from "destr";
|
|
7
7
|
import { defineRenderHandler, getRouteRules, useNitroApp } from "nitropack/runtime";
|
|
@@ -38,7 +38,7 @@ const APP_TELEPORT_CLOSE_TAG = HAS_APP_TELEPORTS ? `</${appTeleportTag}>` : "";
|
|
|
38
38
|
const PAYLOAD_URL_RE = NUXT_JSON_PAYLOADS ? /^[^?]*\/_payload.json(?:\?.*)?$/ : /^[^?]*\/_payload.js(?:\?.*)?$/;
|
|
39
39
|
const PAYLOAD_FILENAME = NUXT_JSON_PAYLOADS ? "_payload.json" : "_payload.js";
|
|
40
40
|
let entryPath;
|
|
41
|
-
|
|
41
|
+
const handler = defineRenderHandler(async (event) => {
|
|
42
42
|
const nitroApp = useNitroApp();
|
|
43
43
|
// Whether we're rendering an error page
|
|
44
44
|
const ssrError = event.path.startsWith("/__nuxt_error") ? getQuery(event) : null;
|
|
@@ -135,8 +135,7 @@ export default defineRenderHandler(async (event) => {
|
|
|
135
135
|
}
|
|
136
136
|
if (_PAYLOAD_EXTRACTION && import.meta.prerender) {
|
|
137
137
|
// Hint nitro to prerender payload for this route
|
|
138
|
-
|
|
139
|
-
appendResponseHeader(event, "x-nitro-prerender", encodePath(joinURL(ssrContext.url.replace(/\?.*$/, ""), PAYLOAD_FILENAME)));
|
|
138
|
+
appendResponseHeader(event, "x-nitro-prerender", joinURL(ssrContext.url.replace(/\?.*$/, ""), PAYLOAD_FILENAME));
|
|
140
139
|
// Use same ssr context to generate payload for this route
|
|
141
140
|
await payloadCache.setItem(ssrContext.url === "/" ? "/" : ssrContext.url.replace(/\/$/, ""), renderPayloadResponse(ssrContext));
|
|
142
141
|
}
|
|
@@ -282,6 +281,7 @@ export default defineRenderHandler(async (event) => {
|
|
|
282
281
|
}
|
|
283
282
|
};
|
|
284
283
|
});
|
|
284
|
+
export default handler;
|
|
285
285
|
function normalizeChunks(chunks) {
|
|
286
286
|
const result = [];
|
|
287
287
|
for (const _chunk of chunks) {
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { EventHandler } from "h3";
|
|
2
|
+
declare const handler: EventHandler;
|
|
3
|
+
export default handler;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defineEventHandler, getRequestHeader } from "h3";
|
|
2
|
-
|
|
2
|
+
const handler = defineEventHandler((event) => {
|
|
3
3
|
if (getRequestHeader(event, "x-nuxt-no-ssr")) {
|
|
4
4
|
event.context.nuxt ||= {};
|
|
5
5
|
event.context.nuxt.noSSR = true;
|
|
6
6
|
}
|
|
7
7
|
});
|
|
8
|
+
export default handler;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
1
|
+
import type { Storage } from "unstorage";
|
|
2
|
+
export declare const payloadCache: Storage | null;
|
|
3
|
+
export declare const islandCache: Storage | null;
|
|
4
|
+
export declare const islandPropCache: Storage | null;
|
|
5
|
+
export declare const sharedPrerenderPromises: Map<string, Promise<any>> | null;
|
|
6
|
+
interface SharedPrerenderCache {
|
|
7
|
+
get<T = unknown>(key: string): Promise<T> | undefined;
|
|
8
|
+
set<T>(key: string, value: Promise<T>): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const sharedPrerenderCache: SharedPrerenderCache | null;
|
|
11
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const defineAppConfig:
|
|
1
|
+
export declare const defineAppConfig: (config: any) => any;
|
|
@@ -3,4 +3,4 @@ import type { H3Event } from "h3";
|
|
|
3
3
|
* Nitro internal functions extracted from https://github.com/nitrojs/nitro/blob/v2/src/runtime/internal/utils.ts
|
|
4
4
|
*/
|
|
5
5
|
export declare function isJsonRequest(event: H3Event): boolean;
|
|
6
|
-
export declare function hasReqHeader(event: H3Event, name: string, includes: string);
|
|
6
|
+
export declare function hasReqHeader(event: H3Event, name: string, includes: string): boolean;
|
|
@@ -11,5 +11,5 @@ export function isJsonRequest(event) {
|
|
|
11
11
|
}
|
|
12
12
|
export function hasReqHeader(event, name, includes) {
|
|
13
13
|
const value = getRequestHeader(event, name);
|
|
14
|
-
return value && typeof value === "string" && value.toLowerCase().includes(includes);
|
|
14
|
+
return !!(value && typeof value === "string" && value.toLowerCase().includes(includes));
|
|
15
15
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { decodePath } from "ufo";
|
|
2
1
|
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
2
|
import { createHead } from "@unhead/vue/server";
|
|
4
3
|
import { sharedPrerenderCache } from "../cache.mjs";
|
|
@@ -11,16 +10,9 @@ const PRERENDER_NO_SSR_ROUTES = new Set([
|
|
|
11
10
|
"/200.html",
|
|
12
11
|
"/404.html"
|
|
13
12
|
]);
|
|
14
|
-
function decodeEventPath(path) {
|
|
15
|
-
const queryIndex = path.indexOf("?");
|
|
16
|
-
if (queryIndex === -1) {
|
|
17
|
-
return decodePath(path);
|
|
18
|
-
}
|
|
19
|
-
return decodePath(path.slice(0, queryIndex)) + path.slice(queryIndex);
|
|
20
|
-
}
|
|
21
13
|
export function createSSRContext(event) {
|
|
22
14
|
const ssrContext = {
|
|
23
|
-
url:
|
|
15
|
+
url: event.path,
|
|
24
16
|
event,
|
|
25
17
|
runtimeConfig: useRuntimeConfig(event),
|
|
26
18
|
noSSR: !!NUXT_NO_SSR || event.context.nuxt?.noSSR || (import.meta.prerender ? PRERENDER_NO_SSR_ROUTES.has(event.path) : false),
|
|
@@ -10,9 +10,7 @@ interface Renderer {
|
|
|
10
10
|
renderScripts: () => string;
|
|
11
11
|
}>;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
export declare const getSSRRenderer: unknown;
|
|
13
|
+
export declare const getSSRRenderer: () => Promise<Renderer>;
|
|
15
14
|
export declare function getRenderer(ssrContext: NuxtSSRContext): Promise<Renderer>;
|
|
16
|
-
|
|
17
|
-
export declare const getSSRStyles: unknown;
|
|
15
|
+
export declare const getSSRStyles: () => Promise<Record<string, () => Promise<string[]>>>;
|
|
18
16
|
export {};
|
|
@@ -7,7 +7,7 @@ import { appId, multiApp } from "#internal/nuxt.config.mjs";
|
|
|
7
7
|
import { NUXT_JSON_PAYLOADS, NUXT_NO_SSR, NUXT_PAYLOAD_EXTRACTION, NUXT_RUNTIME_PAYLOAD_EXTRACTION } from "#internal/nuxt/nitro-config.mjs";
|
|
8
8
|
export function renderPayloadResponse(ssrContext) {
|
|
9
9
|
return {
|
|
10
|
-
body: NUXT_JSON_PAYLOADS ? stringify(splitPayload(ssrContext).payload, ssrContext["~payloadReducers"]) : `export default ${devalue(splitPayload(ssrContext).payload)}`,
|
|
10
|
+
body: NUXT_JSON_PAYLOADS ? encodeForwardSlashes(stringify(splitPayload(ssrContext).payload, ssrContext["~payloadReducers"])) : `export default ${devalue(splitPayload(ssrContext).payload)}`,
|
|
11
11
|
statusCode: getResponseStatus(ssrContext.event),
|
|
12
12
|
statusMessage: getResponseStatusText(ssrContext.event),
|
|
13
13
|
headers: {
|
|
@@ -17,7 +17,7 @@ export function renderPayloadResponse(ssrContext) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export function renderPayloadJsonScript(opts) {
|
|
20
|
-
const contents = opts.data ? stringify(opts.data, opts.ssrContext["~payloadReducers"]) : "";
|
|
20
|
+
const contents = opts.data ? encodeForwardSlashes(stringify(opts.data, opts.ssrContext["~payloadReducers"])) : "";
|
|
21
21
|
const payload = {
|
|
22
22
|
"type": "application/json",
|
|
23
23
|
"innerHTML": contents,
|
|
@@ -33,6 +33,14 @@ export function renderPayloadJsonScript(opts) {
|
|
|
33
33
|
const config = uneval(opts.ssrContext.config);
|
|
34
34
|
return [payload, { innerHTML: multiApp ? `window.__NUXT__=window.__NUXT__||{};window.__NUXT__[${JSON.stringify(appId)}]={config:${config}}` : `window.__NUXT__={};window.__NUXT__.config=${config}` }];
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Encode forward slashes as unicode escape sequences to prevent
|
|
38
|
+
* Google from treating them as internal links and trying to crawl them.
|
|
39
|
+
* @see https://github.com/nuxt/nuxt/issues/24175
|
|
40
|
+
*/
|
|
41
|
+
function encodeForwardSlashes(str) {
|
|
42
|
+
return str.replaceAll("/", "\\u002F");
|
|
43
|
+
}
|
|
36
44
|
export function renderPayloadScript(opts) {
|
|
37
45
|
opts.data.config = opts.ssrContext.config;
|
|
38
46
|
const _PAYLOAD_EXTRACTION = !opts.ssrContext.noSSR && (import.meta.prerender && NUXT_PAYLOAD_EXTRACTION || NUXT_RUNTIME_PAYLOAD_EXTRACTION && (opts.routeOptions.isr || opts.routeOptions.cache));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/nitro-server-nightly",
|
|
3
|
-
"version": "4.4.0-
|
|
3
|
+
"version": "4.4.0-29532345.7b49d0cc",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@nuxt/devalue": "^2.0.2",
|
|
22
|
-
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.0-
|
|
23
|
-
"@unhead/vue": "^2.1.
|
|
24
|
-
"@vue/shared": "^3.5.
|
|
22
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.0-29532345.7b49d0cc",
|
|
23
|
+
"@unhead/vue": "^2.1.4",
|
|
24
|
+
"@vue/shared": "^3.5.28",
|
|
25
25
|
"consola": "^3.4.2",
|
|
26
26
|
"defu": "^6.1.4",
|
|
27
27
|
"destr": "^2.0.5",
|
|
28
|
-
"devalue": "^5.6.
|
|
28
|
+
"devalue": "^5.6.3",
|
|
29
29
|
"errx": "^0.1.0",
|
|
30
30
|
"escape-string-regexp": "^5.0.0",
|
|
31
31
|
"exsolve": "^1.0.8",
|
|
@@ -42,21 +42,21 @@
|
|
|
42
42
|
"ufo": "^1.6.3",
|
|
43
43
|
"unctx": "^2.5.0",
|
|
44
44
|
"unstorage": "^1.17.4",
|
|
45
|
-
"vue": "^3.5.
|
|
45
|
+
"vue": "^3.5.28",
|
|
46
46
|
"vue-bundle-renderer": "^2.2.0",
|
|
47
47
|
"vue-devtools-stub": "^0.1.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"nuxt": "npm:nuxt-nightly@4.4.0-
|
|
50
|
+
"nuxt": "npm:nuxt-nightly@4.4.0-29532345.7b49d0cc"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.0-
|
|
54
|
-
"nuxt": "npm:nuxt-nightly@4.4.0-
|
|
55
|
-
"obuild": "0.4.
|
|
56
|
-
"vitest": "
|
|
53
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.0-29532345.7b49d0cc",
|
|
54
|
+
"nuxt": "npm:nuxt-nightly@4.4.0-29532345.7b49d0cc",
|
|
55
|
+
"obuild": "0.4.31",
|
|
56
|
+
"vitest": "4.0.18"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
|
-
"node": "
|
|
59
|
+
"node": ">=22.12.0"
|
|
60
60
|
},
|
|
61
61
|
"_name": "@nuxt/nitro-server",
|
|
62
62
|
"scripts": {
|