nitro 3.0.260311-beta → 3.0.260429-beta
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/THIRD-PARTY-LICENSES.md +32 -2
- package/dist/_build/common.mjs +669 -1627
- package/dist/_build/rolldown.mjs +1 -12
- package/dist/_build/rollup.mjs +2 -15
- package/dist/_build/vite.build.mjs +1 -3
- package/dist/_chunks/nitro.mjs +28 -221
- package/dist/_chunks/nitro2.mjs +1 -3
- package/dist/_chunks/nitro3.mjs +128 -121
- package/dist/_chunks/nitro4.mjs +127 -0
- package/dist/_chunks/utils.mjs +2 -9
- package/dist/_common.mjs +1 -3
- package/dist/_dev.d.mts +0 -3
- package/dist/_dev.mjs +3 -12
- package/dist/_libs/c12+rc9.mjs +45 -31
- package/dist/_libs/c12+readdirp+chokidar.d.mts +0 -7
- package/dist/_libs/citty.mjs +134 -31
- package/dist/_libs/commondir+is-reference.mjs +2 -9
- package/dist/_libs/compatx.d.mts +0 -2
- package/dist/_libs/compatx.mjs +0 -2
- package/dist/_libs/esbuild.d.mts +0 -1
- package/dist/_libs/estree+pluginutils.d.mts +0 -5
- package/dist/_libs/estree-walker.mjs +3 -88
- package/dist/_libs/hasown+resolve+deepmerge.mjs +69 -119
- package/dist/_libs/httpxy.d.mts +6 -4
- package/dist/_libs/httpxy.mjs +286 -118
- package/dist/_libs/klona.mjs +0 -2
- package/dist/_libs/magic-string.d.mts +0 -2
- package/dist/_libs/mlly.d.mts +0 -2
- package/dist/_libs/nypm+tinyexec.mjs +161 -153
- package/dist/_libs/perfect-debounce.mjs +0 -20
- package/dist/_libs/pkg-types.d.mts +7 -7
- package/dist/_libs/plugin-alias.mjs +0 -2
- package/dist/_libs/plugin-inject.mjs +3 -3
- package/dist/_libs/plugin-json.mjs +0 -2
- package/dist/_libs/pluginutils.mjs +4 -28
- package/dist/_libs/readdirp+chokidar.mjs +2 -174
- package/dist/_libs/remapping.mjs +0 -2
- package/dist/_libs/resolve-uri+gen-mapping.mjs +0 -32
- package/dist/_libs/rou3.d.mts +0 -4
- package/dist/_libs/rou3.mjs +0 -29
- package/dist/_libs/std-env.d.mts +1 -3
- package/dist/_libs/tsconfck.mjs +0 -294
- package/dist/_libs/ultrahtml.mjs +0 -2
- package/dist/_libs/{unimport+unplugin.mjs → unimport+unplugin+oxc-parser.mjs} +50 -81
- package/dist/_libs/unplugin+unimport.d.mts +1 -8
- package/dist/_libs/unwasm.d.mts +0 -3
- package/dist/_presets.mjs +213 -81
- package/dist/builder.d.mts +1 -22
- package/dist/builder.mjs +0 -11
- package/dist/cli/_chunks/build.mjs +1 -3
- package/dist/cli/_chunks/common.mjs +0 -2
- package/dist/cli/_chunks/deploy.mjs +1 -4
- package/dist/cli/_chunks/dev.mjs +1 -6
- package/dist/cli/_chunks/docs.mjs +1 -3
- package/dist/cli/_chunks/list.mjs +1 -3
- package/dist/cli/_chunks/prepare.mjs +1 -3
- package/dist/cli/_chunks/preview.mjs +2 -5
- package/dist/cli/_chunks/run.mjs +1 -3
- package/dist/cli/_chunks/task.mjs +0 -2
- package/dist/cli/index.mjs +0 -2
- package/{skills/nitro/docs/docs/quick-start.md → dist/docs/0.docs/1.quick-start.md} +4 -4
- package/{skills/nitro/docs/docs/lifecycle.md → dist/docs/0.docs/10.lifecycle.md} +4 -4
- package/dist/docs/0.docs/11.openapi.md +291 -0
- package/{skills/nitro/docs/docs/plugins.md → dist/docs/0.docs/12.plugins.md} +2 -2
- package/{skills/nitro/docs/docs/tasks.md → dist/docs/0.docs/13.tasks.md} +6 -6
- package/dist/docs/0.docs/14.websocket.md +386 -0
- package/{skills/nitro/docs/docs/migration.md → dist/docs/0.docs/15.migration.md} +2 -4
- package/{skills/nitro/docs/docs/renderer.md → dist/docs/0.docs/2.renderer.md} +8 -8
- package/{skills/nitro/docs/docs/routing.md → dist/docs/0.docs/3.routing.md} +34 -34
- package/{skills/nitro/docs/docs/server-entry.md → dist/docs/0.docs/4.server-entry.md} +6 -6
- package/{skills/nitro/docs/docs/cache.md → dist/docs/0.docs/5.cache.md} +65 -21
- package/{skills/nitro/docs/docs/storage.md → dist/docs/0.docs/6.storage.md} +6 -6
- package/{skills/nitro/docs/docs/assets.md → dist/docs/0.docs/7.assets.md} +8 -8
- package/{skills/nitro/docs/docs/configuration.md → dist/docs/0.docs/8.configuration.md} +16 -16
- package/{skills/nitro/docs/docs/database.md → dist/docs/0.docs/9.database.md} +6 -6
- package/{skills/nitro/docs/deploy → dist/docs/1.deploy/0.index}/index.md +3 -3
- package/{skills/nitro/docs/deploy/providers/aws.md → dist/docs/1.deploy/2.providers/1.aws.md} +4 -4
- package/{skills/nitro/docs/deploy/providers/iis.md → dist/docs/1.deploy/2.providers/15.iis.md} +2 -2
- package/{skills/nitro/docs/deploy/providers/aws-amplify.md → dist/docs/1.deploy/2.providers/2.aws-amplify.md} +2 -2
- package/{skills/nitro/docs/deploy/providers/vercel.md → dist/docs/1.deploy/2.providers/21.vercel.md} +98 -7
- package/{skills/nitro/docs/deploy/providers/zephyr.md → dist/docs/1.deploy/2.providers/23.zephyr.md} +2 -2
- package/{skills/nitro/docs/deploy/providers/cloudflare.md → dist/docs/1.deploy/2.providers/5.cloudflare.md} +9 -15
- package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
- package/{skills/nitro/docs/config → dist/docs/2.config/0.index}/index.md +165 -91
- package/{skills/nitro/docs/examples/hono.md → dist/docs/3.examples/10.hono.md} +1 -1
- package/{skills/nitro/docs/examples/import-alias.md → dist/docs/3.examples/11.import-alias.md} +1 -4
- package/{skills/nitro/docs/examples/mono-jsx.md → dist/docs/3.examples/13.mono-jsx.md} +2 -2
- package/{skills/nitro/docs/examples/plugins.md → dist/docs/3.examples/15.plugins.md} +4 -4
- package/{skills/nitro/docs/examples/shiki.md → dist/docs/3.examples/19.shiki.md} +1 -1
- package/{skills/nitro/docs/examples/auto-imports.md → dist/docs/3.examples/2.auto-imports.md} +0 -1
- package/{skills/nitro/docs/examples/vite-nitro-plugin.md → dist/docs/3.examples/21.vite-nitro-plugin.md} +1 -1
- package/{skills/nitro/docs/examples/vite-rsc.md → dist/docs/3.examples/22.vite-rsc.md} +4 -4
- package/{skills/nitro/docs/examples/vite-ssr-html.md → dist/docs/3.examples/23.vite-ssr-html.md} +3 -3
- package/{skills/nitro/docs/examples/vite-ssr-preact.md → dist/docs/3.examples/24.vite-ssr-preact.md} +6 -6
- package/{skills/nitro/docs/examples/vite-ssr-react.md → dist/docs/3.examples/25.vite-ssr-react.md} +3 -3
- package/{skills/nitro/docs/examples/vite-ssr-solid.md → dist/docs/3.examples/26.vite-ssr-solid.md} +3 -3
- package/{skills/nitro/docs/examples/vite-ssr-tsr-react.md → dist/docs/3.examples/27.vite-ssr-tsr-react.md} +6 -6
- package/{skills/nitro/docs/examples/vite-ssr-tss-react.md → dist/docs/3.examples/28.vite-ssr-tss-react.md} +11 -11
- package/{skills/nitro/docs/examples/vite-ssr-vue-router.md → dist/docs/3.examples/29.vite-ssr-vue-router.md} +6 -5
- package/{skills/nitro/docs/examples/vite-trpc.md → dist/docs/3.examples/30.vite-trpc.md} +3 -3
- package/{skills/nitro/docs/examples/elysia.md → dist/docs/3.examples/6.elysia.md} +1 -1
- package/{skills/nitro/docs/examples/fastify.md → dist/docs/3.examples/8.fastify.md} +1 -1
- package/dist/docs/README.md +86 -0
- package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -4
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
- package/dist/node_modules/@speed-highlight/core/package.json +1 -1
- package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
- package/dist/node_modules/cookie-es/package.json +26 -23
- package/dist/node_modules/defu/dist/defu.mjs +2 -2
- package/dist/node_modules/defu/package.json +33 -28
- package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
- package/dist/node_modules/rendu/dist/index.mjs +5 -112
- package/dist/node_modules/rendu/package.json +25 -24
- package/dist/node_modules/ufo/dist/index.mjs +2 -2
- package/dist/node_modules/ufo/package.json +9 -9
- package/dist/node_modules/youch/package.json +2 -2
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +3 -1
- package/dist/presets/_nitro/runtime/service-worker.mjs +1 -1
- package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
- package/dist/presets/azure/runtime/_utils.mjs +5 -5
- package/dist/presets/azure/runtime/azure-swa.mjs +7 -5
- package/dist/presets/bun/runtime/bun.mjs +5 -3
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
- package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
- package/dist/presets/deno/runtime/deno-server.mjs +5 -3
- package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -2
- package/dist/presets/node/runtime/node-cluster.mjs +2 -2
- package/dist/presets/node/runtime/node-middleware.mjs +1 -1
- package/dist/presets/node/runtime/node-server.mjs +5 -3
- package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
- package/dist/presets/vercel/runtime/cron-handler.mjs +1 -1
- package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
- package/dist/presets/vercel/runtime/vercel.web.mjs +1 -1
- package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
- package/dist/runtime/internal/app.mjs +12 -11
- package/dist/runtime/internal/context.mjs +1 -9
- package/dist/runtime/internal/error/dev.mjs +10 -10
- package/dist/runtime/internal/route-rules.d.mts +4 -1
- package/dist/runtime/internal/route-rules.mjs +38 -8
- package/dist/runtime/internal/routes/dev-tasks.mjs +13 -12
- package/dist/runtime/internal/routes/openapi.mjs +2 -2
- package/dist/runtime/internal/routes/scalar.mjs +4 -3
- package/dist/runtime/internal/routes/swagger.mjs +7 -4
- package/dist/runtime/internal/runtime-config.mjs +2 -2
- package/dist/runtime/internal/task.mjs +5 -5
- package/dist/runtime/meta.d.mts +1 -0
- package/dist/runtime/meta.mjs +1 -0
- package/dist/runtime/nitro.mjs +3 -3
- package/dist/runtime/virtual/renderer-template.mjs +1 -1
- package/dist/runtime/virtual/tracing.d.mts +5 -0
- package/dist/runtime/virtual/tracing.mjs +1 -0
- package/dist/types/index.d.mts +1074 -147
- package/dist/vite.d.mts +1 -6
- package/dist/vite.mjs +67 -32
- package/lib/tsconfig.json +3 -5
- package/package.json +62 -59
- package/dist/_libs/_.mjs +0 -3
- package/dist/_libs/_2.mjs +0 -2
- package/dist/_libs/_3.mjs +0 -3
- package/dist/_libs/_4.mjs +0 -2
- package/dist/_libs/_5.mjs +0 -3
- package/dist/_libs/_6.mjs +0 -4
- package/dist/_libs/_7.mjs +0 -5
- package/dist/_libs/escape-string-regexp.mjs +0 -7
- package/skills/nitro/SKILL.md +0 -10
- package/skills/nitro/docs/TOC.md +0 -83
- package/skills/nitro/docs/_navigation.json +0 -679
- /package/{skills/nitro/docs/docs → dist/docs/0.docs/0.index}/index.md +0 -0
- /package/{skills/nitro/docs/docs/nightly.md → dist/docs/0.docs/16.nightly.md} +0 -0
- /package/{skills/nitro/docs/deploy/runtimes/node.md → dist/docs/1.deploy/1.runtimes/0.node.md} +0 -0
- /package/{skills/nitro/docs/deploy/runtimes/bun.md → dist/docs/1.deploy/1.runtimes/1.bun.md} +0 -0
- /package/{skills/nitro/docs/deploy/runtimes/deno.md → dist/docs/1.deploy/1.runtimes/2.deno.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/alwaysdata.md → dist/docs/1.deploy/2.providers/0.alwaysdata.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/flightcontrol.md → dist/docs/1.deploy/2.providers/10.flightcontrol.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/genezio.md → dist/docs/1.deploy/2.providers/11.genezio.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/github-pages.md → dist/docs/1.deploy/2.providers/12.github-pages.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/gitlab-pages.md → dist/docs/1.deploy/2.providers/13.gitlab-pages.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/heroku.md → dist/docs/1.deploy/2.providers/14.heroku.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/koyeb.md → dist/docs/1.deploy/2.providers/16.koyeb.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/netlify.md → dist/docs/1.deploy/2.providers/17.netlify.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/platform-sh.md → dist/docs/1.deploy/2.providers/18.platform-sh.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/render.md → dist/docs/1.deploy/2.providers/19.render.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/stormkit.md → dist/docs/1.deploy/2.providers/20.stormkit.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/zeabur.md → dist/docs/1.deploy/2.providers/22.zeabur.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/zerops.md → dist/docs/1.deploy/2.providers/24.zerops.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/azure.md → dist/docs/1.deploy/2.providers/3.azure.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/cleavr.md → dist/docs/1.deploy/2.providers/4.cleavr.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/deno-deploy.md → dist/docs/1.deploy/2.providers/6.deno-deploy.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/digitalocean.md → dist/docs/1.deploy/2.providers/7.digitalocean.md} +0 -0
- /package/{skills/nitro/docs/deploy/providers/firebase.md → dist/docs/1.deploy/2.providers/9.firebase.md} +0 -0
- /package/{skills/nitro/docs/examples → dist/docs/3.examples/0.index}/index.md +0 -0
- /package/{skills/nitro/docs/examples/api-routes.md → dist/docs/3.examples/1.api-routes.md} +0 -0
- /package/{skills/nitro/docs/examples/middleware.md → dist/docs/3.examples/12.middleware.md} +0 -0
- /package/{skills/nitro/docs/examples/nano-jsx.md → dist/docs/3.examples/14.nano-jsx.md} +0 -0
- /package/{skills/nitro/docs/examples/renderer.md → dist/docs/3.examples/16.renderer.md} +0 -0
- /package/{skills/nitro/docs/examples/runtime-config.md → dist/docs/3.examples/17.runtime-config.md} +0 -0
- /package/{skills/nitro/docs/examples/server-fetch.md → dist/docs/3.examples/18.server-fetch.md} +0 -0
- /package/{skills/nitro/docs/examples/virtual-routes.md → dist/docs/3.examples/20.virtual-routes.md} +0 -0
- /package/{skills/nitro/docs/examples/cached-handler.md → dist/docs/3.examples/3.cached-handler.md} +0 -0
- /package/{skills/nitro/docs/examples/websocket.md → dist/docs/3.examples/31.websocket.md} +0 -0
- /package/{skills/nitro/docs/examples/custom-error-handler.md → dist/docs/3.examples/4.custom-error-handler.md} +0 -0
- /package/{skills/nitro/docs/examples/database.md → dist/docs/3.examples/5.database.md} +0 -0
- /package/{skills/nitro/docs/examples/express.md → dist/docs/3.examples/7.express.md} +0 -0
- /package/{skills/nitro/docs/examples/hello-world.md → dist/docs/3.examples/9.hello-world.md} +0 -0
- /package/{skills/nitro → dist}/docs/index.md +0 -0
package/dist/_build/rolldown.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as writeTypes,
|
|
1
|
+
import { _ as writeTypes, at as basename, d as libChunkName, dt as relative, f as baseBuildConfig, h as writeBuildInfo, l as NODE_MODULES_RE, lt as join, n as baseBuildPlugins, u as getChunkName } from "./common.mjs";
|
|
2
2
|
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
3
3
|
import { n as scanHandlers } from "../_chunks/nitro2.mjs";
|
|
4
4
|
import { n as watch } from "../_libs/readdirp+chokidar.mjs";
|
|
@@ -6,7 +6,6 @@ import { t as debounce } from "../_libs/perfect-debounce.mjs";
|
|
|
6
6
|
import { n as generateFSTree } from "../_chunks/utils.mjs";
|
|
7
7
|
import { builtinModules } from "node:module";
|
|
8
8
|
import { defu } from "defu";
|
|
9
|
-
//#region src/build/rolldown/config.ts
|
|
10
9
|
const getRolldownConfig = async (nitro) => {
|
|
11
10
|
const base = baseBuildConfig(nitro);
|
|
12
11
|
const tsc = nitro.options.typescript.tsConfig?.compilerOptions;
|
|
@@ -41,9 +40,6 @@ const getRolldownConfig = async (nitro) => {
|
|
|
41
40
|
warn(warning);
|
|
42
41
|
}
|
|
43
42
|
},
|
|
44
|
-
treeshake: { moduleSideEffects(id) {
|
|
45
|
-
return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
|
|
46
|
-
} },
|
|
47
43
|
optimization: { inlineConst: true },
|
|
48
44
|
output: {
|
|
49
45
|
format: "esm",
|
|
@@ -70,8 +66,6 @@ const getRolldownConfig = async (nitro) => {
|
|
|
70
66
|
}
|
|
71
67
|
return config;
|
|
72
68
|
};
|
|
73
|
-
//#endregion
|
|
74
|
-
//#region src/build/rolldown/dev.ts
|
|
75
69
|
async function watchDev(nitro, config) {
|
|
76
70
|
const rolldown = await import("rolldown");
|
|
77
71
|
let watcher;
|
|
@@ -136,8 +130,6 @@ async function watchDev(nitro, config) {
|
|
|
136
130
|
return watcher;
|
|
137
131
|
}
|
|
138
132
|
}
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/build/rolldown/prod.ts
|
|
141
133
|
async function buildProduction(nitro, config) {
|
|
142
134
|
const rolldown = await import("rolldown");
|
|
143
135
|
const buildStartTime = Date.now();
|
|
@@ -161,13 +153,10 @@ async function buildProduction(nitro, config) {
|
|
|
161
153
|
nitro.logger.success("You can preview this build using `npx nitro preview`");
|
|
162
154
|
if (buildInfo.commands.deploy) nitro.logger.success(rewriteRelativePaths("You can deploy this build using `npx nitro deploy --prebuilt`"));
|
|
163
155
|
}
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region src/build/rolldown/build.ts
|
|
166
156
|
async function rolldownBuild(nitro) {
|
|
167
157
|
await nitro.hooks.callHook("build:before", nitro);
|
|
168
158
|
const config = await getRolldownConfig(nitro);
|
|
169
159
|
await nitro.hooks.callHook("rollup:before", nitro, config);
|
|
170
160
|
return nitro.options.dev ? watchDev(nitro, config) : buildProduction(nitro, config);
|
|
171
161
|
}
|
|
172
|
-
//#endregion
|
|
173
162
|
export { rolldownBuild };
|
package/dist/_build/rollup.mjs
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { _ as writeTypes, ct as
|
|
1
|
+
import { _ as writeTypes, at as basename, ct as isAbsolute, d as libChunkName, dt as relative, f as baseBuildConfig, h as writeBuildInfo, l as NODE_MODULES_RE, lt as join, n as baseBuildPlugins, t as oxc, u as getChunkName } from "./common.mjs";
|
|
2
2
|
import { t as formatCompatibilityDate } from "../_libs/compatx.mjs";
|
|
3
3
|
import { n as scanHandlers } from "../_chunks/nitro2.mjs";
|
|
4
4
|
import { n as watch } from "../_libs/readdirp+chokidar.mjs";
|
|
5
5
|
import { t as debounce } from "../_libs/perfect-debounce.mjs";
|
|
6
6
|
import { t as alias } from "../_libs/plugin-alias.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { n as inject } from "../_libs/plugin-inject.mjs";
|
|
8
8
|
import { n as generateFSTree } from "../_chunks/utils.mjs";
|
|
9
9
|
import { t as commonjs } from "../_libs/commondir+is-reference.mjs";
|
|
10
10
|
import { t as json } from "../_libs/plugin-json.mjs";
|
|
11
11
|
import { t as nodeResolve } from "../_libs/hasown+resolve+deepmerge.mjs";
|
|
12
12
|
import { defu } from "defu";
|
|
13
|
-
//#region src/build/rollup/config.ts
|
|
14
13
|
const getRollupConfig = async (nitro) => {
|
|
15
14
|
const base = baseBuildConfig(nitro);
|
|
16
15
|
const tsc = nitro.options.typescript.tsConfig?.compilerOptions;
|
|
@@ -50,9 +49,6 @@ const getRollupConfig = async (nitro) => {
|
|
|
50
49
|
onwarn(warning, rollupWarn) {
|
|
51
50
|
if (!base.ignoreWarningCodes.has(warning.code || "")) rollupWarn(warning);
|
|
52
51
|
},
|
|
53
|
-
treeshake: { moduleSideEffects(id) {
|
|
54
|
-
return nitro.options.moduleSideEffects.some((p) => id.startsWith(p));
|
|
55
|
-
} },
|
|
56
52
|
output: {
|
|
57
53
|
format: "esm",
|
|
58
54
|
entryFileNames: "index.mjs",
|
|
@@ -73,8 +69,6 @@ const getRollupConfig = async (nitro) => {
|
|
|
73
69
|
if (outputConfig.inlineDynamicImports || outputConfig.format === "iife") delete outputConfig.manualChunks;
|
|
74
70
|
return config;
|
|
75
71
|
};
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/build/rollup/error.ts
|
|
78
72
|
function formatRollupError(_error) {
|
|
79
73
|
try {
|
|
80
74
|
const logs = [_error.toString()];
|
|
@@ -92,8 +86,6 @@ function formatRollupError(_error) {
|
|
|
92
86
|
return _error?.toString();
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/build/rollup/dev.ts
|
|
97
89
|
async function watchDev(nitro, rollupConfig) {
|
|
98
90
|
const rollup = await import("rollup");
|
|
99
91
|
let rollupWatcher;
|
|
@@ -158,8 +150,6 @@ async function watchDev(nitro, rollupConfig) {
|
|
|
158
150
|
return watcher;
|
|
159
151
|
}
|
|
160
152
|
}
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/build/rollup/prod.ts
|
|
163
153
|
async function buildProduction(nitro, rollupConfig) {
|
|
164
154
|
const rollup = await import("rollup");
|
|
165
155
|
const buildStartTime = Date.now();
|
|
@@ -182,13 +172,10 @@ async function buildProduction(nitro, rollupConfig) {
|
|
|
182
172
|
nitro.logger.success("You can preview this build using `npx nitro preview`");
|
|
183
173
|
if (buildInfo.commands.deploy) nitro.logger.success("You can deploy this build using `npx nitro deploy --prebuilt`");
|
|
184
174
|
}
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/build/rollup/build.ts
|
|
187
175
|
async function rollupBuild(nitro) {
|
|
188
176
|
await nitro.hooks.callHook("build:before", nitro);
|
|
189
177
|
const config = await getRollupConfig(nitro);
|
|
190
178
|
await nitro.hooks.callHook("rollup:before", nitro, config);
|
|
191
179
|
return nitro.options.dev ? watchDev(nitro, config) : buildProduction(nitro, config);
|
|
192
180
|
}
|
|
193
|
-
//#endregion
|
|
194
181
|
export { rollupBuild };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as v } from "./common.mjs";
|
|
2
2
|
import { nitro } from "nitro/vite";
|
|
3
|
-
//#region src/build/vite/build.ts
|
|
4
3
|
async function viteBuild(nitro$1) {
|
|
5
4
|
if (nitro$1.options.dev) throw new Error("Nitro dev CLI does not supports vite. Please use `vite dev` instead.");
|
|
6
5
|
const { createBuilder } = await import(nitro$1.options.__vitePkg__ || "vite");
|
|
@@ -14,5 +13,4 @@ async function viteBuild(nitro$1) {
|
|
|
14
13
|
delete globalThis.__nitro_build__;
|
|
15
14
|
await builder.buildApp();
|
|
16
15
|
}
|
|
17
|
-
//#endregion
|
|
18
16
|
export { viteBuild };
|
package/dist/_chunks/nitro.mjs
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import { A as src_default,
|
|
1
|
+
import { i as watchConfig, r as loadConfig } from "../_libs/c12+rc9.mjs";
|
|
2
|
+
import { A as src_default, B as _, F as prettyPath, I as resolveNitroPath, L as writeFile$1, O as scanUnprefixedPublicAssets, R as escapeRegExp, U as v, dt as relative, ft as resolve, it as resolveModuleURL, j as build, k as compressPublicAssets, lt as join, p as runParallel, q as findWorkspaceDir, rt as resolveModulePath } from "../_build/common.mjs";
|
|
3
3
|
import { n as resolveCompatibilityDates, r as resolveCompatibilityDatesFromEnv } from "../_libs/compatx.mjs";
|
|
4
4
|
import { t as klona } from "../_libs/klona.mjs";
|
|
5
|
-
import { t as escapeStringRegexp } from "../_libs/escape-string-regexp.mjs";
|
|
6
5
|
import { n as parse, t as TSConfckCache } from "../_libs/tsconfck.mjs";
|
|
7
6
|
import { n as scanHandlers, t as scanAndSyncOptions } from "./nitro2.mjs";
|
|
8
|
-
import {
|
|
7
|
+
import { i as findAllRoutes, n as addRoute, r as createRouter } from "../_libs/rou3.mjs";
|
|
8
|
+
import { n as initNitroRouting } from "./nitro3.mjs";
|
|
9
|
+
import "../_dev.mjs";
|
|
9
10
|
import { n as z, t as P } from "../_libs/ultrahtml.mjs";
|
|
10
11
|
import { createRequire } from "node:module";
|
|
11
12
|
import consola, { consola as consola$1 } from "consola";
|
|
12
13
|
import { Hookable, createDebugger } from "hookable";
|
|
14
|
+
import { runtimeDir, version } from "nitro/meta";
|
|
13
15
|
import { existsSync, readFileSync } from "node:fs";
|
|
14
16
|
import { readFile } from "node:fs/promises";
|
|
15
17
|
import { pathToFileURL } from "node:url";
|
|
16
18
|
import { defu } from "defu";
|
|
17
|
-
import { runtimeDir, version } from "nitro/meta";
|
|
18
19
|
import { joinURL, parseURL, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutTrailingSlash } from "ufo";
|
|
19
20
|
import { colors } from "consola/utils";
|
|
20
|
-
import { hash } from "ohash";
|
|
21
21
|
import { toRequest } from "h3";
|
|
22
22
|
import http from "node:http";
|
|
23
|
-
//#region src/config/defaults.ts
|
|
24
23
|
const NitroDefaults = {
|
|
25
24
|
compatibilityDate: "latest",
|
|
26
25
|
debug: _,
|
|
@@ -78,7 +77,6 @@ const NitroDefaults = {
|
|
|
78
77
|
routes: []
|
|
79
78
|
},
|
|
80
79
|
builder: void 0,
|
|
81
|
-
moduleSideEffects: ["unenv/polyfill/"],
|
|
82
80
|
replace: {},
|
|
83
81
|
node: true,
|
|
84
82
|
sourcemap: false,
|
|
@@ -97,8 +95,6 @@ const NitroDefaults = {
|
|
|
97
95
|
version
|
|
98
96
|
}
|
|
99
97
|
};
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/config/resolvers/assets.ts
|
|
102
98
|
async function resolveAssetsOptions(options) {
|
|
103
99
|
for (const publicAsset of options.publicAssets) {
|
|
104
100
|
publicAsset.dir = resolve(options.rootDir, publicAsset.dir);
|
|
@@ -124,13 +120,9 @@ async function resolveAssetsOptions(options) {
|
|
|
124
120
|
if (asset.maxAge && !asset.fallthrough) options.routeRules[asset.baseURL + "/**"] = defu(routeRule, { headers: { "cache-control": `public, max-age=${asset.maxAge}, immutable` } });
|
|
125
121
|
}
|
|
126
122
|
}
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/config/resolvers/compatibility.ts
|
|
129
123
|
async function resolveCompatibilityOptions(options) {
|
|
130
124
|
options.compatibilityDate = resolveCompatibilityDatesFromEnv(options.compatibilityDate);
|
|
131
125
|
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/config/resolvers/database.ts
|
|
134
126
|
async function resolveDatabaseOptions(options) {
|
|
135
127
|
if (options.experimental.database && options.imports) {
|
|
136
128
|
options.imports.presets ??= [];
|
|
@@ -148,8 +140,6 @@ async function resolveDatabaseOptions(options) {
|
|
|
148
140
|
} };
|
|
149
141
|
}
|
|
150
142
|
}
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/config/resolvers/export-conditions.ts
|
|
153
143
|
async function resolveExportConditionsOptions(options) {
|
|
154
144
|
options.exportConditions = _resolveExportConditions(options.exportConditions || [], {
|
|
155
145
|
dev: options.dev,
|
|
@@ -165,8 +155,6 @@ function _resolveExportConditions(userConditions, opts) {
|
|
|
165
155
|
const negated = new Set(userConditions.filter((c) => c.startsWith("!")).map((c) => c.slice(1)));
|
|
166
156
|
return [...new Set(conditions)].filter((c) => !negated.has(c));
|
|
167
157
|
}
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/config/resolvers/imports.ts
|
|
170
158
|
async function resolveImportsOptions(options) {
|
|
171
159
|
if (options.imports === false) return;
|
|
172
160
|
options.imports.presets ??= [];
|
|
@@ -176,11 +164,9 @@ async function resolveImportsOptions(options) {
|
|
|
176
164
|
options.imports.exclude.push(/[/\\]\.git[/\\]/);
|
|
177
165
|
options.imports.exclude.push(options.buildDir);
|
|
178
166
|
const scanDirsInNodeModules = options.scanDirs.map((dir) => dir.match(/(?<=\/)node_modules\/(.+)$/)?.[1]).filter(Boolean);
|
|
179
|
-
options.imports.exclude.push(scanDirsInNodeModules.length > 0 ? new RegExp(`node_modules\\/(?!${scanDirsInNodeModules.map((dir) =>
|
|
167
|
+
options.imports.exclude.push(scanDirsInNodeModules.length > 0 ? new RegExp(`node_modules\\/(?!${scanDirsInNodeModules.map((dir) => escapeRegExp(dir)).join("|")})`) : /[/\\]node_modules[/\\]/);
|
|
180
168
|
}
|
|
181
169
|
}
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/config/resolvers/open-api.ts
|
|
184
170
|
async function resolveOpenAPIOptions(options) {
|
|
185
171
|
if (!options.experimental.openAPI) return;
|
|
186
172
|
if (!options.dev && !options.openAPI?.production) return;
|
|
@@ -218,15 +204,9 @@ async function resolveOpenAPIOptions(options) {
|
|
|
218
204
|
options.prerender.routes.push(...prerenderRoutes);
|
|
219
205
|
}
|
|
220
206
|
}
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/config/resolvers/tsconfig.ts
|
|
223
207
|
async function resolveTsconfig(options) {
|
|
224
208
|
const root = resolve(options.rootDir || ".") + "/";
|
|
225
209
|
if (!options.typescript.tsConfig) options.typescript.tsConfig = await loadTsconfig(root);
|
|
226
|
-
if (options.experimental.tsconfigPaths && options.typescript.tsConfig.compilerOptions?.paths) options.alias = {
|
|
227
|
-
...tsConfigToAliasObj(options.typescript.tsConfig, root),
|
|
228
|
-
...options.alias
|
|
229
|
-
};
|
|
230
210
|
}
|
|
231
211
|
async function loadTsconfig(root) {
|
|
232
212
|
const opts = {
|
|
@@ -241,30 +221,6 @@ async function loadTsconfig(root) {
|
|
|
241
221
|
if (!tsconfig.compilerOptions.baseUrl) tsconfig.compilerOptions.baseUrl = resolve(tsconfigFile, "..");
|
|
242
222
|
return tsconfig;
|
|
243
223
|
}
|
|
244
|
-
function tsConfigToAliasObj(tsconfig, root) {
|
|
245
|
-
const compilerOptions = tsconfig?.compilerOptions;
|
|
246
|
-
if (!compilerOptions?.paths) return {};
|
|
247
|
-
const paths = compilerOptions.paths;
|
|
248
|
-
const alias = {};
|
|
249
|
-
for (const [key, targets] of Object.entries(paths)) {
|
|
250
|
-
let source = key;
|
|
251
|
-
let target = targets?.[0];
|
|
252
|
-
if (!target) continue;
|
|
253
|
-
if (source.includes("*") || target.includes("*")) {
|
|
254
|
-
source = source.replace(/\/\*$/, "");
|
|
255
|
-
target = target.replace(/\/\*$/, "");
|
|
256
|
-
if (source.includes("*") || target.includes("*")) continue;
|
|
257
|
-
}
|
|
258
|
-
if (target.startsWith(".")) {
|
|
259
|
-
if (!compilerOptions.baseUrl) continue;
|
|
260
|
-
target = resolve(root, compilerOptions.baseUrl, target) + (key.endsWith("*") ? "/" : "");
|
|
261
|
-
}
|
|
262
|
-
alias[source] = target;
|
|
263
|
-
}
|
|
264
|
-
return alias;
|
|
265
|
-
}
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region src/config/resolvers/paths.ts
|
|
268
224
|
const RESOLVE_EXTENSIONS = [
|
|
269
225
|
".ts",
|
|
270
226
|
".js",
|
|
@@ -354,8 +310,6 @@ async function resolvePathOptions(options) {
|
|
|
354
310
|
}
|
|
355
311
|
}
|
|
356
312
|
}
|
|
357
|
-
//#endregion
|
|
358
|
-
//#region src/config/resolvers/route-rules.ts
|
|
359
313
|
async function resolveRouteRulesOptions(options) {
|
|
360
314
|
options.routeRules = normalizeRouteRules(options);
|
|
361
315
|
}
|
|
@@ -388,7 +342,7 @@ function normalizeRouteRules(config) {
|
|
|
388
342
|
"access-control-max-age": "0",
|
|
389
343
|
...routeRules.headers
|
|
390
344
|
};
|
|
391
|
-
if (routeConfig.swr) {
|
|
345
|
+
if (routeConfig.swr !== void 0 && routeConfig.swr !== false) {
|
|
392
346
|
routeRules.cache = routeRules.cache || {};
|
|
393
347
|
routeRules.cache.swr = true;
|
|
394
348
|
if (typeof routeConfig.swr === "number") routeRules.cache.maxAge = routeConfig.swr;
|
|
@@ -398,8 +352,6 @@ function normalizeRouteRules(config) {
|
|
|
398
352
|
}
|
|
399
353
|
return normalizedRules;
|
|
400
354
|
}
|
|
401
|
-
//#endregion
|
|
402
|
-
//#region src/config/resolvers/runtime-config.ts
|
|
403
355
|
async function resolveRuntimeConfigOptions(options) {
|
|
404
356
|
options.runtimeConfig = normalizeRuntimeConfig(options);
|
|
405
357
|
}
|
|
@@ -434,24 +386,16 @@ function checkSerializableRuntimeConfig(obj, path = []) {
|
|
|
434
386
|
function isPrimitiveValue(value) {
|
|
435
387
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
436
388
|
}
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/config/resolvers/storage.ts
|
|
439
389
|
async function resolveStorageOptions(options) {}
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region src/config/resolvers/url.ts
|
|
442
390
|
async function resolveURLOptions(options) {
|
|
443
391
|
options.baseURL = withLeadingSlash(withTrailingSlash(options.baseURL));
|
|
444
392
|
}
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region src/config/resolvers/error.ts
|
|
447
393
|
async function resolveErrorOptions(options) {
|
|
448
394
|
if (!options.errorHandler) options.errorHandler = [];
|
|
449
395
|
else if (!Array.isArray(options.errorHandler)) options.errorHandler = [options.errorHandler];
|
|
450
396
|
options.errorHandler = options.errorHandler.map((h) => resolveNitroPath(h, options));
|
|
451
397
|
options.errorHandler.push(join(runtimeDir, `internal/error/${options.dev ? "dev" : "prod"}`));
|
|
452
398
|
}
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/config/resolvers/unenv.ts
|
|
455
399
|
const common = {
|
|
456
400
|
meta: {
|
|
457
401
|
name: "nitro-common",
|
|
@@ -494,8 +438,6 @@ async function resolveUnenv(options) {
|
|
|
494
438
|
if (!options.node) options.unenv.unshift(nodeless);
|
|
495
439
|
options.unenv.unshift(common);
|
|
496
440
|
}
|
|
497
|
-
//#endregion
|
|
498
|
-
//#region src/config/resolvers/builder.ts
|
|
499
441
|
const VALID_BUILDERS = [
|
|
500
442
|
"rolldown",
|
|
501
443
|
"rollup",
|
|
@@ -532,7 +474,7 @@ function isPkgInstalled(pkg, root) {
|
|
|
532
474
|
}
|
|
533
475
|
}
|
|
534
476
|
async function installPkg(pkg, root) {
|
|
535
|
-
const { addDevDependency } = await import("../_libs/
|
|
477
|
+
const { addDevDependency } = await import("../_libs/nypm+tinyexec.mjs").then((n) => n.t);
|
|
536
478
|
return addDevDependency(pkg, { cwd: root });
|
|
537
479
|
}
|
|
538
480
|
function hasNitroViteConfig(options) {
|
|
@@ -549,8 +491,17 @@ function hasNitroViteConfig(options) {
|
|
|
549
491
|
}
|
|
550
492
|
return false;
|
|
551
493
|
}
|
|
552
|
-
|
|
553
|
-
|
|
494
|
+
async function resolveTracingOptions(options) {
|
|
495
|
+
if (!options.tracingChannel) return;
|
|
496
|
+
options.tracingChannel = {
|
|
497
|
+
srvx: true,
|
|
498
|
+
h3: true,
|
|
499
|
+
unstorage: true,
|
|
500
|
+
...typeof options.tracingChannel === "object" ? options.tracingChannel : {}
|
|
501
|
+
};
|
|
502
|
+
options.plugins = options.plugins || [];
|
|
503
|
+
options.plugins.push("#nitro/virtual/tracing");
|
|
504
|
+
}
|
|
554
505
|
const configResolvers = [
|
|
555
506
|
resolveCompatibilityOptions,
|
|
556
507
|
resolveTsconfig,
|
|
@@ -566,7 +517,8 @@ const configResolvers = [
|
|
|
566
517
|
resolveStorageOptions,
|
|
567
518
|
resolveErrorOptions,
|
|
568
519
|
resolveUnenv,
|
|
569
|
-
resolveBuilder
|
|
520
|
+
resolveBuilder,
|
|
521
|
+
resolveTracingOptions
|
|
570
522
|
];
|
|
571
523
|
async function loadOptions(configOverrides = {}, opts = {}) {
|
|
572
524
|
const options = await _loadUserConfig(configOverrides, opts);
|
|
@@ -632,16 +584,12 @@ async function _loadUserConfig(configOverrides = {}, opts = {}) {
|
|
|
632
584
|
if (options.dev && options.preset !== "nitro-dev") consola.info(`Using \`${options.preset}\` emulation in development mode.`);
|
|
633
585
|
return options;
|
|
634
586
|
}
|
|
635
|
-
//#endregion
|
|
636
|
-
//#region src/config/update.ts
|
|
637
587
|
async function updateNitroConfig(nitro, config) {
|
|
638
588
|
nitro.options.routeRules = normalizeRouteRules(config.routeRules ? config : nitro.options);
|
|
639
589
|
nitro.options.runtimeConfig = normalizeRuntimeConfig(config.runtimeConfig ? config : nitro.options);
|
|
640
590
|
await nitro.hooks.callHook("rollup:reload");
|
|
641
591
|
consola.success("Nitro config hot reloaded!");
|
|
642
592
|
}
|
|
643
|
-
//#endregion
|
|
644
|
-
//#region src/module.ts
|
|
645
593
|
async function installModules(nitro) {
|
|
646
594
|
const _modules = [...nitro.options.modules || []];
|
|
647
595
|
const modules = await Promise.all(_modules.map((mod) => _resolveNitroModule(mod, nitro.options)));
|
|
@@ -678,141 +626,6 @@ async function _resolveNitroModule(mod, nitroOptions) {
|
|
|
678
626
|
...mod
|
|
679
627
|
};
|
|
680
628
|
}
|
|
681
|
-
//#endregion
|
|
682
|
-
//#region src/routing.ts
|
|
683
|
-
const isGlobalMiddleware = (h) => !h.method && (!h.route || h.route === "/**");
|
|
684
|
-
function initNitroRouting(nitro) {
|
|
685
|
-
const envConditions = new Set([
|
|
686
|
-
nitro.options.dev ? "dev" : "prod",
|
|
687
|
-
nitro.options.preset,
|
|
688
|
-
nitro.options.preset === "nitro-prerender" ? "prerender" : void 0
|
|
689
|
-
].filter(Boolean));
|
|
690
|
-
const matchesEnv = (h) => {
|
|
691
|
-
const envs = (Array.isArray(h.env) ? h.env : [h.env]).filter(Boolean);
|
|
692
|
-
return envs.length === 0 || envs.some((env) => envConditions.has(env));
|
|
693
|
-
};
|
|
694
|
-
const routes = new Router(nitro.options.baseURL);
|
|
695
|
-
const routeRules = new Router(nitro.options.baseURL);
|
|
696
|
-
const globalMiddleware = [];
|
|
697
|
-
const routedMiddleware = new Router(nitro.options.baseURL);
|
|
698
|
-
const sync = () => {
|
|
699
|
-
routeRules._update(Object.entries(nitro.options.routeRules).map(([route, data]) => ({
|
|
700
|
-
route,
|
|
701
|
-
method: "",
|
|
702
|
-
data: {
|
|
703
|
-
...data,
|
|
704
|
-
_route: route
|
|
705
|
-
}
|
|
706
|
-
})));
|
|
707
|
-
const _routes = [
|
|
708
|
-
...Object.entries(nitro.options.routes).flatMap(([route, handler]) => {
|
|
709
|
-
if (typeof handler === "string") handler = { handler };
|
|
710
|
-
return {
|
|
711
|
-
...handler,
|
|
712
|
-
route,
|
|
713
|
-
middleware: false
|
|
714
|
-
};
|
|
715
|
-
}),
|
|
716
|
-
...nitro.options.handlers,
|
|
717
|
-
...nitro.scannedHandlers
|
|
718
|
-
].filter((h) => h && !h.middleware && matchesEnv(h));
|
|
719
|
-
if (nitro.options.serverEntry && nitro.options.serverEntry.handler) _routes.push({
|
|
720
|
-
route: "/**",
|
|
721
|
-
lazy: false,
|
|
722
|
-
format: nitro.options.serverEntry.format,
|
|
723
|
-
handler: nitro.options.serverEntry.handler
|
|
724
|
-
});
|
|
725
|
-
if (nitro.options.renderer?.handler) _routes.push({
|
|
726
|
-
route: "/**",
|
|
727
|
-
lazy: true,
|
|
728
|
-
handler: nitro.options.renderer?.handler
|
|
729
|
-
});
|
|
730
|
-
routes._update(_routes.map((h) => ({
|
|
731
|
-
...h,
|
|
732
|
-
method: h.method || "",
|
|
733
|
-
data: handlerWithImportHash(h)
|
|
734
|
-
})), { merge: true });
|
|
735
|
-
const _middleware = [...nitro.scannedHandlers, ...nitro.options.handlers].filter((h) => h && h.middleware && matchesEnv(h));
|
|
736
|
-
if (nitro.options.serveStatic) _middleware.unshift({
|
|
737
|
-
route: "/**",
|
|
738
|
-
middleware: true,
|
|
739
|
-
handler: join(runtimeDir, "internal/static")
|
|
740
|
-
});
|
|
741
|
-
globalMiddleware.splice(0, globalMiddleware.length, ..._middleware.filter((h) => isGlobalMiddleware(h)).map((m) => handlerWithImportHash(m)));
|
|
742
|
-
routedMiddleware._update(_middleware.filter((h) => !isGlobalMiddleware(h)).map((h) => ({
|
|
743
|
-
...h,
|
|
744
|
-
method: h.method || "",
|
|
745
|
-
data: handlerWithImportHash(h)
|
|
746
|
-
})));
|
|
747
|
-
};
|
|
748
|
-
nitro.routing = Object.freeze({
|
|
749
|
-
sync,
|
|
750
|
-
routes,
|
|
751
|
-
routeRules,
|
|
752
|
-
globalMiddleware,
|
|
753
|
-
routedMiddleware
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
function handlerWithImportHash(h) {
|
|
757
|
-
const id = (h.lazy ? "_lazy_" : "_") + hash(h.handler).replace(/-/g, "").slice(0, 6);
|
|
758
|
-
return {
|
|
759
|
-
...h,
|
|
760
|
-
_importHash: id
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
var Router = class {
|
|
764
|
-
_routes;
|
|
765
|
-
_router;
|
|
766
|
-
_compiled;
|
|
767
|
-
_baseURL;
|
|
768
|
-
constructor(baseURL) {
|
|
769
|
-
this._update([]);
|
|
770
|
-
this._baseURL = baseURL || "";
|
|
771
|
-
if (this._baseURL.endsWith("/")) this._baseURL = this._baseURL.slice(0, -1);
|
|
772
|
-
}
|
|
773
|
-
get routes() {
|
|
774
|
-
return this._routes;
|
|
775
|
-
}
|
|
776
|
-
_update(routes, opts) {
|
|
777
|
-
this._routes = routes;
|
|
778
|
-
this._router = createRouter();
|
|
779
|
-
this._compiled = void 0;
|
|
780
|
-
for (const route of routes) addRoute(this._router, route.method, this._baseURL + route.route, route.data);
|
|
781
|
-
if (opts?.merge) mergeCatchAll(this._router);
|
|
782
|
-
}
|
|
783
|
-
hasRoutes() {
|
|
784
|
-
return this._routes.length > 0;
|
|
785
|
-
}
|
|
786
|
-
compileToString(opts) {
|
|
787
|
-
const key = opts ? hash(opts) : "";
|
|
788
|
-
this._compiled ||= {};
|
|
789
|
-
if (this._compiled[key]) return this._compiled[key];
|
|
790
|
-
this._compiled[key] = compileRouterToString(this._router, void 0, opts);
|
|
791
|
-
if (this.routes.length === 1 && this.routes[0].route === "/**" && this.routes[0].method === "") {
|
|
792
|
-
const data = (opts?.serialize || JSON.stringify)(this.routes[0].data);
|
|
793
|
-
let retCode = `{data,params:{"_":p.slice(1)}}`;
|
|
794
|
-
if (opts?.matchAll) retCode = `[${retCode}]`;
|
|
795
|
-
this._compiled[key] = `/* @__PURE__ */ (() => {const data=${data};return ((_m, p)=>{return ${retCode};})})()`;
|
|
796
|
-
}
|
|
797
|
-
return this._compiled[key];
|
|
798
|
-
}
|
|
799
|
-
match(method, path) {
|
|
800
|
-
return findRoute(this._router, method, path)?.data;
|
|
801
|
-
}
|
|
802
|
-
matchAll(method, path) {
|
|
803
|
-
return findAllRoutes(this._router, method, path).map((route) => route.data);
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
function mergeCatchAll(router) {
|
|
807
|
-
const handlers = router.root?.wildcard?.methods?.[""];
|
|
808
|
-
if (!handlers || handlers.length < 2) return;
|
|
809
|
-
handlers.splice(0, handlers.length, {
|
|
810
|
-
...handlers[0],
|
|
811
|
-
data: handlers.map((h) => h.data)
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
//#endregion
|
|
815
|
-
//#region src/global.ts
|
|
816
629
|
const nitroInstances = globalThis.__nitro_instances__ ||= [];
|
|
817
630
|
const globalKey = "__nitro_builder__";
|
|
818
631
|
function registerNitroInstance(nitro) {
|
|
@@ -833,11 +646,14 @@ function globalInit() {
|
|
|
833
646
|
return nitro.fetch(req);
|
|
834
647
|
} };
|
|
835
648
|
}
|
|
836
|
-
//#endregion
|
|
837
|
-
//#region src/nitro.ts
|
|
838
649
|
async function createNitro(config = {}, opts = {}) {
|
|
650
|
+
const options = await loadOptions(config, opts);
|
|
839
651
|
const nitro = {
|
|
840
|
-
|
|
652
|
+
meta: {
|
|
653
|
+
version,
|
|
654
|
+
majorVersion: 3
|
|
655
|
+
},
|
|
656
|
+
options,
|
|
841
657
|
hooks: new Hookable(),
|
|
842
658
|
vfs: /* @__PURE__ */ new Map(),
|
|
843
659
|
routing: {},
|
|
@@ -869,8 +685,6 @@ async function createNitro(config = {}, opts = {}) {
|
|
|
869
685
|
nitro.routing.sync();
|
|
870
686
|
return nitro;
|
|
871
687
|
}
|
|
872
|
-
//#endregion
|
|
873
|
-
//#region src/prerender/utils.ts
|
|
874
688
|
const allowedExtensions = new Set(["", ".json"]);
|
|
875
689
|
const linkParents = /* @__PURE__ */ new Map();
|
|
876
690
|
const HTML_ENTITIES = {
|
|
@@ -931,8 +745,6 @@ function matchesIgnorePattern(path, pattern) {
|
|
|
931
745
|
if (pattern instanceof RegExp) return pattern.test(path);
|
|
932
746
|
return false;
|
|
933
747
|
}
|
|
934
|
-
//#endregion
|
|
935
|
-
//#region src/prerender/prerender.ts
|
|
936
748
|
const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
937
749
|
async function prerender(nitro) {
|
|
938
750
|
if (nitro.options.noPublicDir) {
|
|
@@ -1096,16 +908,12 @@ async function prerender(nitro) {
|
|
|
1096
908
|
nitro.logger.info(`Prerendered ${nitro._prerenderedRoutes.length} routes in ${prerenderTimeInMs / 1e3} seconds`);
|
|
1097
909
|
if (nitro.options.compressPublicAssets) await compressPublicAssets(nitro);
|
|
1098
910
|
}
|
|
1099
|
-
//#endregion
|
|
1100
|
-
//#region src/task.ts
|
|
1101
|
-
/** @experimental */
|
|
1102
911
|
async function runTask(taskEvent, opts) {
|
|
1103
912
|
return await (await _getTasksContext(opts)).devFetch(`/_nitro/tasks/${taskEvent.name}`, {
|
|
1104
913
|
method: "POST",
|
|
1105
914
|
body: taskEvent
|
|
1106
915
|
});
|
|
1107
916
|
}
|
|
1108
|
-
/** @experimental */
|
|
1109
917
|
async function listTasks(opts) {
|
|
1110
918
|
return (await (await _getTasksContext(opts)).devFetch("/_nitro/tasks")).tasks;
|
|
1111
919
|
}
|
|
@@ -1155,5 +963,4 @@ function _pidIsRunning(pid) {
|
|
|
1155
963
|
return false;
|
|
1156
964
|
}
|
|
1157
965
|
}
|
|
1158
|
-
//#endregion
|
|
1159
966
|
export { loadOptions as a, createNitro as i, runTask as n, prerender as r, listTasks as t };
|
package/dist/_chunks/nitro2.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { M as glob,
|
|
1
|
+
import { M as glob, dt as relative, lt as join } from "../_build/common.mjs";
|
|
2
2
|
import { withBase, withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
3
|
-
//#region src/scan.ts
|
|
4
3
|
const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
5
4
|
const suffixRegex = /(\.(?<method>connect|delete|get|head|options|patch|post|put|trace))?(\.(?<env>dev|prod|prerender))?$/;
|
|
6
5
|
async function scanAndSyncOptions(nitro) {
|
|
@@ -98,5 +97,4 @@ async function scanDir(nitro, dir, name) {
|
|
|
98
97
|
};
|
|
99
98
|
}).sort((a, b) => a.path.localeCompare(b.path));
|
|
100
99
|
}
|
|
101
|
-
//#endregion
|
|
102
100
|
export { scanHandlers as n, scanAndSyncOptions as t };
|