@nuxt/nitro-server 3.21.0 → 3.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/dist/THIRD-PARTY-LICENSES.md +3826 -0
  3. package/dist/_chunks/libs/@babel/parser.d.mts +1536 -0
  4. package/dist/_chunks/libs/@jridgewell/trace-mapping.d.mts +82 -0
  5. package/dist/_chunks/libs/@types/estree.d.mts +525 -0
  6. package/dist/_chunks/libs/@types/pug.d.mts +123 -0
  7. package/dist/_chunks/libs/@vitejs/plugin-vue-jsx.d.mts +17996 -0
  8. package/dist/_chunks/libs/@vitejs/plugin-vue.d.mts +83 -0
  9. package/dist/_chunks/libs/@volar/language-core.d.mts +56 -0
  10. package/dist/_chunks/libs/@volar/source-map.d.mts +10 -0
  11. package/dist/_chunks/libs/@vue/compiler-dom.d.mts +45 -0
  12. package/dist/_chunks/libs/@vue/language-core.d.mts +194 -0
  13. package/dist/_chunks/libs/autoprefixer.d.mts +83 -0
  14. package/dist/_chunks/libs/c12.d.mts +146 -0
  15. package/dist/_chunks/libs/compatx.d.mts +47 -0
  16. package/dist/_chunks/libs/css-minimizer-webpack-plugin.d.mts +9 -0
  17. package/dist/_chunks/libs/esbuild-loader.d.mts +16 -0
  18. package/dist/_chunks/libs/mini-css-extract-plugin.d.mts +1 -0
  19. package/dist/_chunks/libs/mlly.d.mts +57 -0
  20. package/dist/_chunks/libs/ofetch.d.mts +870 -0
  21. package/dist/_chunks/libs/open.d.mts +1 -0
  22. package/dist/_chunks/libs/oxc-transform.d.mts +422 -0
  23. package/dist/_chunks/libs/rollup-plugin-visualizer.d.mts +90 -0
  24. package/dist/_chunks/libs/scule.d.mts +15 -0
  25. package/dist/_chunks/libs/unimport.d.mts +386 -0
  26. package/dist/_chunks/libs/untyped.d.mts +44 -0
  27. package/dist/_chunks/libs/vue-loader.d.mts +31 -0
  28. package/dist/_chunks/libs/vue-router.d.mts +1413 -0
  29. package/dist/_chunks/libs/webpack-dev-middleware.d.mts +2 -0
  30. package/dist/_chunks/rolldown-runtime.mjs +12 -0
  31. package/dist/index.d.mts +3143 -4
  32. package/dist/index.mjs +43 -70
  33. package/dist/runtime/handlers/error.mjs +2 -2
  34. package/dist/runtime/utils/renderer/app.mjs +1 -2
  35. package/dist/runtime/utils/renderer/build-files.d.mts +0 -2
  36. package/package.json +8 -8
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 = "3.21.0";
25
-
26
- //#endregion
27
- //#region src/utils.ts
22
+ var version = "3.21.1";
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([/* @__PURE__ */ new RegExp(`^${escapeRE(mod.entryPath)}$`), "Importing directly from module entry-points is not allowed."]);
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([/* @__PURE__ */ 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}.`]);
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 }) {
@@ -77,12 +63,9 @@ const nitroSchemaTemplate = {
77
63
  references,
78
64
  declarations
79
65
  });
80
- const sourceDir = join(nuxt.options.buildDir, "types");
66
+ const typesDir = join(nuxt.options.buildDir, "types");
81
67
  return `
82
- ${[...references.map((ref) => {
83
- if ("path" in ref && isAbsolute(ref.path)) ref.path = relative(sourceDir, ref.path);
84
- return `/// <reference ${renderAttrs(ref)} />`;
85
- }), ...declarations].join("\n")}
68
+ ${[...references.map((ref) => renderReference(ref, typesDir)), ...declarations].join("\n")}
86
69
  /// <reference path="./schema.d.ts" />
87
70
 
88
71
  import type { RuntimeConfig } from 'nuxt/schema'
@@ -119,17 +102,9 @@ declare module 'nitropack' {
119
102
  `;
120
103
  }
121
104
  };
122
- function renderAttr(key, value) {
123
- return value ? `${key}="${value}"` : "";
124
- }
125
- function renderAttrs(obj) {
126
- const attrs = [];
127
- for (const key in obj) attrs.push(renderAttr(key, obj[key]));
128
- return attrs.join(" ");
105
+ function renderReference(ref, baseDir) {
106
+ return `/// <reference ${"path" in ref ? `path="${isAbsolute(ref.path) ? relative(baseDir, ref.path) : ref.path}"` : `types="${ref.types}"`} />`;
129
107
  }
130
-
131
- //#endregion
132
- //#region src/index.ts
133
108
  const logLevelMapReverse = {
134
109
  silent: 0,
135
110
  info: 3,
@@ -146,7 +121,7 @@ async function bundle(nuxt) {
146
121
  }
147
122
  const layerPublicAssetsDirs = [];
148
123
  for (const dirs of layerDirs) if (existsSync(dirs.public)) layerPublicAssetsDirs.push({ dir: dirs.public });
149
- const excludePattern = excludePaths.length ? [/* @__PURE__ */ new RegExp(`node_modules\\/(?!${excludePaths.join("|")})`)] : [/node_modules/];
124
+ const excludePattern = excludePaths.length ? [new RegExp(`node_modules\\/(?!${excludePaths.join("|")})`)] : [/node_modules/];
150
125
  const rootDirWithSlash = withTrailingSlash(nuxt.options.rootDir);
151
126
  const moduleEntryPaths = [];
152
127
  for (const m of nuxt.options._installedModules) {
@@ -425,18 +400,18 @@ async function bundle(nuxt) {
425
400
  }
426
401
  });
427
402
  if (nuxt.options.experimental.payloadExtraction) {
428
- if (nuxt.options.dev) nuxt.hook("nitro:config", (nitroConfig$1) => {
429
- nitroConfig$1.prerender ||= {};
430
- nitroConfig$1.prerender.routes ||= [];
431
- nitroConfig$1.routeRules ||= {};
432
- for (const route of nitroConfig$1.prerender.routes) {
403
+ if (nuxt.options.dev) nuxt.hook("nitro:config", (nitroConfig) => {
404
+ nitroConfig.prerender ||= {};
405
+ nitroConfig.prerender.routes ||= [];
406
+ nitroConfig.routeRules ||= {};
407
+ for (const route of nitroConfig.prerender.routes) {
433
408
  if (!route) continue;
434
- nitroConfig$1.routeRules[route] = defu(nitroConfig$1.routeRules[route], { prerender: true });
409
+ nitroConfig.routeRules[route] = defu(nitroConfig.routeRules[route], { prerender: true });
435
410
  }
436
411
  });
437
- nuxt.hook("nitro:init", (nitro$1) => {
438
- nitro$1.hooks.hook("build:before", (nitro$2) => {
439
- for (const [route, value] of Object.entries(nitro$2.options.routeRules)) if (!route.endsWith("*") && !route.endsWith("/_payload.json")) {
412
+ nuxt.hook("nitro:init", (nitro) => {
413
+ nitro.hooks.hook("build:before", (nitro) => {
414
+ for (const [route, value] of Object.entries(nitro.options.routeRules)) if (!route.endsWith("*") && !route.endsWith("/_payload.json")) {
440
415
  if (value.isr || value.cache || value.prerender && nuxt.options.dev) {
441
416
  const payloadKey = route + "/_payload.json";
442
417
  const defaults = {};
@@ -445,7 +420,7 @@ async function bundle(nuxt) {
445
420
  "cache",
446
421
  ...nuxt.options.dev ? ["prerender"] : []
447
422
  ]) if (key in value) defaults[key] = value[key];
448
- nitro$2.options.routeRules[payloadKey] = defu(nitro$2.options.routeRules[payloadKey], defaults);
423
+ nitro.options.routeRules[payloadKey] = defu(nitro.options.routeRules[payloadKey], defaults);
449
424
  }
450
425
  }
451
426
  });
@@ -483,13 +458,13 @@ async function bundle(nuxt) {
483
458
  config.alias ||= {};
484
459
  config.alias["#app-manifest"] = join(tempDir, `meta/${buildId}.json`);
485
460
  });
486
- nuxt.hook("nitro:init", (nitro$1) => {
487
- nitro$1.hooks.hook("rollup:before", async (nitro$2) => {
461
+ nuxt.hook("nitro:init", (nitro) => {
462
+ nitro.hooks.hook("rollup:before", async (nitro) => {
488
463
  const prerenderedRoutes = /* @__PURE__ */ new Set();
489
464
  const routeRulesMatcher = getRouteRulesRouter();
490
- if (nitro$2._prerenderedRoutes?.length) {
465
+ if (nitro._prerenderedRoutes?.length) {
491
466
  const payloadSuffix = nuxt.options.experimental.renderJsonPayloads ? "/_payload.json" : "/_payload.js";
492
- for (const route of nitro$2._prerenderedRoutes) if (!route.error && route.route.endsWith(payloadSuffix)) {
467
+ for (const route of nitro._prerenderedRoutes) if (!route.error && route.route.endsWith(payloadSuffix)) {
493
468
  const url = route.route.slice(0, -payloadSuffix.length) || "/";
494
469
  if (!defu({}, ...findAllRoutes(routeRulesMatcher, void 0, url).reverse()).prerender) prerenderedRoutes.add(url);
495
470
  }
@@ -531,8 +506,8 @@ async function bundle(nuxt) {
531
506
  const relativeSharedDir = withTrailingSlash(relative(nuxt.options.rootDir, resolve(nuxt.options.rootDir, nuxt.options.dir.shared)));
532
507
  const sharedPatterns = [
533
508
  /^#shared\//,
534
- /* @__PURE__ */ new RegExp("^" + escapeRE(sharedDir)),
535
- /* @__PURE__ */ new RegExp("^" + escapeRE(relativeSharedDir))
509
+ new RegExp("^" + escapeRE(sharedDir)),
510
+ new RegExp("^" + escapeRE(relativeSharedDir))
536
511
  ];
537
512
  nitroConfig.rollupConfig.plugins.push(ImpoundPlugin.rollup({
538
513
  cwd: nuxt.options.rootDir,
@@ -656,12 +631,12 @@ async function bundle(nuxt) {
656
631
  handler: resolve(distDir, "runtime/handlers/renderer")
657
632
  });
658
633
  if (nuxt.options.experimental.chromeDevtoolsProjectSettings) {
659
- const cacheDir$1 = resolve(nuxt.options.rootDir, "node_modules/.cache/nuxt");
660
- let projectConfiguration = await readFile(join(cacheDir$1, "chrome-workspace.json"), "utf-8").then((r) => JSON.parse(r)).catch(() => null);
634
+ const cacheDir = resolve(nuxt.options.rootDir, "node_modules/.cache/nuxt");
635
+ let projectConfiguration = await readFile(join(cacheDir, "chrome-workspace.json"), "utf-8").then((r) => JSON.parse(r)).catch(() => null);
661
636
  if (!projectConfiguration) {
662
637
  projectConfiguration = { uuid: randomUUID() };
663
- await mkdir(cacheDir$1, { recursive: true });
664
- await writeFile(join(cacheDir$1, "chrome-workspace.json"), JSON.stringify(projectConfiguration), "utf-8");
638
+ await mkdir(cacheDir, { recursive: true });
639
+ await writeFile(join(cacheDir, "chrome-workspace.json"), JSON.stringify(projectConfiguration), "utf-8");
665
640
  }
666
641
  nitro.options.devHandlers.push({
667
642
  route: "/.well-known/appspecific/com.chrome.devtools.json",
@@ -671,12 +646,12 @@ async function bundle(nuxt) {
671
646
  } }))
672
647
  });
673
648
  }
674
- if (!nuxt.options.dev && nuxt.options.experimental.noVueServer) nitro.hooks.hook("rollup:before", (nitro$1) => {
675
- if (nitro$1.options.preset === "nitro-prerender") return;
676
- const nuxtErrorHandler = nitro$1.options.handlers.findIndex((h) => h.route === "/__nuxt_error");
677
- if (nuxtErrorHandler >= 0) nitro$1.options.handlers.splice(nuxtErrorHandler, 1);
678
- nitro$1.options.renderer = void 0;
679
- nitro$1.options.errorHandler = "nitropack/runtime/error";
649
+ if (!nuxt.options.dev && nuxt.options.experimental.noVueServer) nitro.hooks.hook("rollup:before", (nitro) => {
650
+ if (nitro.options.preset === "nitro-prerender") return;
651
+ const nuxtErrorHandler = nitro.options.handlers.findIndex((h) => h.route === "/__nuxt_error");
652
+ if (nuxtErrorHandler >= 0) nitro.options.handlers.splice(nuxtErrorHandler, 1);
653
+ nitro.options.renderer = void 0;
654
+ nitro.options.errorHandler = "nitropack/runtime/error";
680
655
  });
681
656
  nuxt.hook("prepare:types", async (opts) => {
682
657
  if (!nuxt.options.dev) {
@@ -691,14 +666,14 @@ async function bundle(nuxt) {
691
666
  for (const route of ["/200.html", "/404.html"]) routes.add(route);
692
667
  if (!nuxt.options.ssr) routes.add("/index.html");
693
668
  });
694
- if (!nuxt.options.dev) nitro.hooks.hook("rollup:before", async (nitro$1) => {
695
- await copyPublicAssets(nitro$1);
696
- await nuxt.callHook("nitro:build:public-assets", nitro$1);
669
+ if (!nuxt.options.dev) nitro.hooks.hook("rollup:before", async (nitro) => {
670
+ await copyPublicAssets(nitro);
671
+ await nuxt.callHook("nitro:build:public-assets", nitro);
697
672
  });
698
673
  async function symlinkDist() {
699
674
  if (nitro.options.static) {
700
- const distDir$1 = resolve(nuxt.options.rootDir, "dist");
701
- if (!existsSync(distDir$1)) await promises.symlink(nitro.options.output.publicDir, distDir$1, "junction").catch(() => {});
675
+ const distDir = resolve(nuxt.options.rootDir, "dist");
676
+ if (!existsSync(distDir)) await promises.symlink(nitro.options.output.publicDir, distDir, "junction").catch(() => {});
702
677
  }
703
678
  }
704
679
  nuxt.hook("build:done", async () => {
@@ -736,7 +711,7 @@ async function bundle(nuxt) {
736
711
  }));
737
712
  });
738
713
  nuxt.server = createDevServer(nitro);
739
- const waitUntilCompile = new Promise((resolve$1) => nitro.hooks.hook("compiled", () => resolve$1()));
714
+ const waitUntilCompile = new Promise((resolve) => nitro.hooks.hook("compiled", () => resolve()));
740
715
  nuxt.hook("build:done", () => waitUntilCompile);
741
716
  }
742
717
  }
@@ -750,14 +725,12 @@ async function spaLoadingTemplatePath(nuxt) {
750
725
  }
751
726
  async function spaLoadingTemplate(nuxt) {
752
727
  if (nuxt.options.spaLoadingTemplate === false) return "";
753
- const spaLoadingTemplate$1 = await spaLoadingTemplatePath(nuxt);
728
+ const spaLoadingTemplate = await spaLoadingTemplatePath(nuxt);
754
729
  try {
755
- if (existsSync(spaLoadingTemplate$1)) return readFileSync(spaLoadingTemplate$1, "utf-8").trim();
730
+ if (existsSync(spaLoadingTemplate)) return readFileSync(spaLoadingTemplate, "utf-8").trim();
756
731
  } catch {}
757
732
  if (nuxt.options.spaLoadingTemplate === true) return template();
758
733
  if (nuxt.options.spaLoadingTemplate) logger.warn(`Could not load custom \`spaLoadingTemplate\` path as it does not exist: \`${nuxt.options.spaLoadingTemplate}\`.`);
759
734
  return "";
760
735
  }
761
-
762
- //#endregion
763
- export { bundle };
736
+ export { bundle };
@@ -26,8 +26,8 @@ export default (async function errorhandler(error, event, { defaultHandler }) {
26
26
  // remove proto/hostname/port from URL
27
27
  const url = new URL(errorObject.url);
28
28
  errorObject.url = withoutBase(url.pathname, useRuntimeConfig(event).app.baseURL) + url.search + url.hash;
29
- // add default server message
30
- errorObject.message ||= "Server Error";
29
+ // add default server message (keep sanitized for unhandled errors)
30
+ errorObject.message = error.unhandled ? errorObject.message || "Server Error" : error.message || errorObject.message || "Server Error";
31
31
  // we will be rendering this error internally so we can pass along the error.data safely
32
32
  errorObject.data ||= error.data;
33
33
  errorObject.statusText ||= error.statusText || error.statusMessage;
@@ -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";
@@ -13,7 +12,7 @@ const PRERENDER_NO_SSR_ROUTES = new Set([
13
12
  ]);
14
13
  export function createSSRContext(event) {
15
14
  const ssrContext = {
16
- url: decodePath(event.path),
15
+ url: event.path,
17
16
  event,
18
17
  runtimeConfig: useRuntimeConfig(event),
19
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
- // -- SSR Renderer --
14
13
  export declare const getSSRRenderer: unknown;
15
14
  export declare function getRenderer(ssrContext: NuxtSSRContext): Promise<Renderer>;
16
- // @ts-expect-error file will be produced after app build
17
15
  export declare const getSSRStyles: unknown;
18
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/nitro-server",
3
- "version": "3.21.0",
3
+ "version": "3.21.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@nuxt/devalue": "^2.0.2",
22
- "@unhead/vue": "^2.1.2",
22
+ "@unhead/vue": "^2.1.3",
23
23
  "@vue/shared": "^3.5.27",
24
24
  "consola": "^3.4.2",
25
25
  "defu": "^6.1.4",
@@ -44,16 +44,16 @@
44
44
  "vue": "^3.5.27",
45
45
  "vue-bundle-renderer": "^2.2.0",
46
46
  "vue-devtools-stub": "^0.1.0",
47
- "@nuxt/kit": "3.21.0"
47
+ "@nuxt/kit": "3.21.1"
48
48
  },
49
49
  "peerDependencies": {
50
- "nuxt": "^3.21.0"
50
+ "nuxt": "^3.21.1"
51
51
  },
52
52
  "devDependencies": {
53
- "obuild": "0.4.14",
54
- "vitest": "3.2.4",
55
- "nuxt": "3.21.0",
56
- "@nuxt/schema": "3.21.0"
53
+ "obuild": "0.4.27",
54
+ "vitest": "4.0.18",
55
+ "nuxt": "3.21.1",
56
+ "@nuxt/schema": "3.21.1"
57
57
  },
58
58
  "engines": {
59
59
  "node": "^20.19.0 || >=22.12.0"