nitro 3.0.260311-beta → 3.0.260415-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/_build/common.mjs +630 -1602
- package/dist/_build/rolldown.mjs +0 -11
- package/dist/_build/rollup.mjs +0 -13
- package/dist/_build/vite.build.mjs +0 -2
- package/dist/_chunks/nitro.mjs +23 -216
- package/dist/_chunks/nitro2.mjs +0 -2
- package/dist/_chunks/nitro3.mjs +128 -121
- package/dist/_chunks/nitro4.mjs +127 -0
- package/dist/_chunks/utils.mjs +0 -7
- package/dist/_common.mjs +0 -2
- package/dist/_dev.d.mts +0 -3
- package/dist/_dev.mjs +0 -10
- package/dist/_libs/_.mjs +0 -1
- package/dist/_libs/_3.mjs +0 -1
- package/dist/_libs/_5.mjs +0 -1
- package/dist/_libs/_6.mjs +0 -2
- package/dist/_libs/_7.mjs +0 -3
- package/dist/_libs/c12+rc9.mjs +24 -22
- 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/escape-string-regexp.mjs +0 -2
- package/dist/_libs/estree+pluginutils.d.mts +0 -5
- package/dist/_libs/estree-walker.mjs +3 -88
- package/dist/_libs/hasown+resolve+deepmerge.mjs +22 -85
- package/dist/_libs/httpxy.d.mts +9 -5
- package/dist/_libs/httpxy.mjs +284 -116
- 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 +111 -134
- package/dist/_libs/perfect-debounce.mjs +0 -20
- package/dist/_libs/pkg-types.d.mts +0 -3
- package/dist/_libs/plugin-alias.mjs +0 -2
- package/dist/_libs/plugin-inject.mjs +0 -2
- package/dist/_libs/plugin-json.mjs +0 -2
- package/dist/_libs/pluginutils.mjs +0 -26
- package/dist/_libs/readdirp+chokidar.mjs +0 -173
- 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 +1 -44
- package/dist/_libs/unplugin+unimport.d.mts +0 -7
- package/dist/_libs/unwasm.d.mts +0 -3
- package/dist/_presets.mjs +211 -80
- package/dist/builder.d.mts +1 -22
- package/dist/builder.mjs +0 -11
- package/dist/cli/_chunks/build.mjs +0 -2
- package/dist/cli/_chunks/common.mjs +0 -2
- package/dist/cli/_chunks/deploy.mjs +0 -3
- package/dist/cli/_chunks/dev.mjs +0 -5
- package/dist/cli/_chunks/docs.mjs +1 -3
- package/dist/cli/_chunks/list.mjs +0 -2
- package/dist/cli/_chunks/prepare.mjs +0 -2
- package/dist/cli/_chunks/preview.mjs +1 -4
- package/dist/cli/_chunks/run.mjs +0 -2
- 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} +12 -12
- 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/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 +5 -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 +3 -1
- package/dist/runtime/internal/route-rules.mjs +9 -7
- 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 +3 -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 +155 -86
- package/dist/vite.d.mts +0 -5
- package/dist/vite.mjs +57 -28
- package/lib/tsconfig.json +3 -5
- package/package.json +56 -54
- 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
|
@@ -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
|
@@ -10,7 +10,6 @@ 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
1
|
import { H 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
|
@@ -5,22 +5,22 @@ import { t as klona } from "../_libs/klona.mjs";
|
|
|
5
5
|
import { t as escapeStringRegexp } from "../_libs/escape-string-regexp.mjs";
|
|
6
6
|
import { n as parse, t as TSConfckCache } from "../_libs/tsconfck.mjs";
|
|
7
7
|
import { n as scanHandlers, t as scanAndSyncOptions } from "./nitro2.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { i as findAllRoutes, n as addRoute, r as createRouter } from "../_libs/rou3.mjs";
|
|
9
|
+
import { n as initNitroRouting } from "./nitro3.mjs";
|
|
10
|
+
import "../_dev.mjs";
|
|
9
11
|
import { n as z, t as P } from "../_libs/ultrahtml.mjs";
|
|
10
12
|
import { createRequire } from "node:module";
|
|
11
13
|
import consola, { consola as consola$1 } from "consola";
|
|
12
14
|
import { Hookable, createDebugger } from "hookable";
|
|
15
|
+
import { runtimeDir, version } from "nitro/meta";
|
|
13
16
|
import { existsSync, readFileSync } from "node:fs";
|
|
14
17
|
import { readFile } from "node:fs/promises";
|
|
15
18
|
import { pathToFileURL } from "node:url";
|
|
16
19
|
import { defu } from "defu";
|
|
17
|
-
import { runtimeDir, version } from "nitro/meta";
|
|
18
20
|
import { joinURL, parseURL, withBase, withLeadingSlash, withQuery, withTrailingSlash, withoutBase, withoutTrailingSlash } from "ufo";
|
|
19
21
|
import { colors } from "consola/utils";
|
|
20
|
-
import { hash } from "ohash";
|
|
21
22
|
import { toRequest } from "h3";
|
|
22
23
|
import http from "node:http";
|
|
23
|
-
//#region src/config/defaults.ts
|
|
24
24
|
const NitroDefaults = {
|
|
25
25
|
compatibilityDate: "latest",
|
|
26
26
|
debug: _,
|
|
@@ -78,7 +78,6 @@ const NitroDefaults = {
|
|
|
78
78
|
routes: []
|
|
79
79
|
},
|
|
80
80
|
builder: void 0,
|
|
81
|
-
moduleSideEffects: ["unenv/polyfill/"],
|
|
82
81
|
replace: {},
|
|
83
82
|
node: true,
|
|
84
83
|
sourcemap: false,
|
|
@@ -97,8 +96,6 @@ const NitroDefaults = {
|
|
|
97
96
|
version
|
|
98
97
|
}
|
|
99
98
|
};
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/config/resolvers/assets.ts
|
|
102
99
|
async function resolveAssetsOptions(options) {
|
|
103
100
|
for (const publicAsset of options.publicAssets) {
|
|
104
101
|
publicAsset.dir = resolve(options.rootDir, publicAsset.dir);
|
|
@@ -124,13 +121,9 @@ async function resolveAssetsOptions(options) {
|
|
|
124
121
|
if (asset.maxAge && !asset.fallthrough) options.routeRules[asset.baseURL + "/**"] = defu(routeRule, { headers: { "cache-control": `public, max-age=${asset.maxAge}, immutable` } });
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/config/resolvers/compatibility.ts
|
|
129
124
|
async function resolveCompatibilityOptions(options) {
|
|
130
125
|
options.compatibilityDate = resolveCompatibilityDatesFromEnv(options.compatibilityDate);
|
|
131
126
|
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/config/resolvers/database.ts
|
|
134
127
|
async function resolveDatabaseOptions(options) {
|
|
135
128
|
if (options.experimental.database && options.imports) {
|
|
136
129
|
options.imports.presets ??= [];
|
|
@@ -148,8 +141,6 @@ async function resolveDatabaseOptions(options) {
|
|
|
148
141
|
} };
|
|
149
142
|
}
|
|
150
143
|
}
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/config/resolvers/export-conditions.ts
|
|
153
144
|
async function resolveExportConditionsOptions(options) {
|
|
154
145
|
options.exportConditions = _resolveExportConditions(options.exportConditions || [], {
|
|
155
146
|
dev: options.dev,
|
|
@@ -165,8 +156,6 @@ function _resolveExportConditions(userConditions, opts) {
|
|
|
165
156
|
const negated = new Set(userConditions.filter((c) => c.startsWith("!")).map((c) => c.slice(1)));
|
|
166
157
|
return [...new Set(conditions)].filter((c) => !negated.has(c));
|
|
167
158
|
}
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/config/resolvers/imports.ts
|
|
170
159
|
async function resolveImportsOptions(options) {
|
|
171
160
|
if (options.imports === false) return;
|
|
172
161
|
options.imports.presets ??= [];
|
|
@@ -179,8 +168,6 @@ async function resolveImportsOptions(options) {
|
|
|
179
168
|
options.imports.exclude.push(scanDirsInNodeModules.length > 0 ? new RegExp(`node_modules\\/(?!${scanDirsInNodeModules.map((dir) => escapeStringRegexp(dir)).join("|")})`) : /[/\\]node_modules[/\\]/);
|
|
180
169
|
}
|
|
181
170
|
}
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/config/resolvers/open-api.ts
|
|
184
171
|
async function resolveOpenAPIOptions(options) {
|
|
185
172
|
if (!options.experimental.openAPI) return;
|
|
186
173
|
if (!options.dev && !options.openAPI?.production) return;
|
|
@@ -218,15 +205,9 @@ async function resolveOpenAPIOptions(options) {
|
|
|
218
205
|
options.prerender.routes.push(...prerenderRoutes);
|
|
219
206
|
}
|
|
220
207
|
}
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/config/resolvers/tsconfig.ts
|
|
223
208
|
async function resolveTsconfig(options) {
|
|
224
209
|
const root = resolve(options.rootDir || ".") + "/";
|
|
225
210
|
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
211
|
}
|
|
231
212
|
async function loadTsconfig(root) {
|
|
232
213
|
const opts = {
|
|
@@ -241,30 +222,6 @@ async function loadTsconfig(root) {
|
|
|
241
222
|
if (!tsconfig.compilerOptions.baseUrl) tsconfig.compilerOptions.baseUrl = resolve(tsconfigFile, "..");
|
|
242
223
|
return tsconfig;
|
|
243
224
|
}
|
|
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
225
|
const RESOLVE_EXTENSIONS = [
|
|
269
226
|
".ts",
|
|
270
227
|
".js",
|
|
@@ -354,8 +311,6 @@ async function resolvePathOptions(options) {
|
|
|
354
311
|
}
|
|
355
312
|
}
|
|
356
313
|
}
|
|
357
|
-
//#endregion
|
|
358
|
-
//#region src/config/resolvers/route-rules.ts
|
|
359
314
|
async function resolveRouteRulesOptions(options) {
|
|
360
315
|
options.routeRules = normalizeRouteRules(options);
|
|
361
316
|
}
|
|
@@ -388,7 +343,7 @@ function normalizeRouteRules(config) {
|
|
|
388
343
|
"access-control-max-age": "0",
|
|
389
344
|
...routeRules.headers
|
|
390
345
|
};
|
|
391
|
-
if (routeConfig.swr) {
|
|
346
|
+
if (routeConfig.swr !== void 0 && routeConfig.swr !== false) {
|
|
392
347
|
routeRules.cache = routeRules.cache || {};
|
|
393
348
|
routeRules.cache.swr = true;
|
|
394
349
|
if (typeof routeConfig.swr === "number") routeRules.cache.maxAge = routeConfig.swr;
|
|
@@ -398,8 +353,6 @@ function normalizeRouteRules(config) {
|
|
|
398
353
|
}
|
|
399
354
|
return normalizedRules;
|
|
400
355
|
}
|
|
401
|
-
//#endregion
|
|
402
|
-
//#region src/config/resolvers/runtime-config.ts
|
|
403
356
|
async function resolveRuntimeConfigOptions(options) {
|
|
404
357
|
options.runtimeConfig = normalizeRuntimeConfig(options);
|
|
405
358
|
}
|
|
@@ -434,24 +387,16 @@ function checkSerializableRuntimeConfig(obj, path = []) {
|
|
|
434
387
|
function isPrimitiveValue(value) {
|
|
435
388
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
436
389
|
}
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/config/resolvers/storage.ts
|
|
439
390
|
async function resolveStorageOptions(options) {}
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region src/config/resolvers/url.ts
|
|
442
391
|
async function resolveURLOptions(options) {
|
|
443
392
|
options.baseURL = withLeadingSlash(withTrailingSlash(options.baseURL));
|
|
444
393
|
}
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region src/config/resolvers/error.ts
|
|
447
394
|
async function resolveErrorOptions(options) {
|
|
448
395
|
if (!options.errorHandler) options.errorHandler = [];
|
|
449
396
|
else if (!Array.isArray(options.errorHandler)) options.errorHandler = [options.errorHandler];
|
|
450
397
|
options.errorHandler = options.errorHandler.map((h) => resolveNitroPath(h, options));
|
|
451
398
|
options.errorHandler.push(join(runtimeDir, `internal/error/${options.dev ? "dev" : "prod"}`));
|
|
452
399
|
}
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/config/resolvers/unenv.ts
|
|
455
400
|
const common = {
|
|
456
401
|
meta: {
|
|
457
402
|
name: "nitro-common",
|
|
@@ -494,8 +439,6 @@ async function resolveUnenv(options) {
|
|
|
494
439
|
if (!options.node) options.unenv.unshift(nodeless);
|
|
495
440
|
options.unenv.unshift(common);
|
|
496
441
|
}
|
|
497
|
-
//#endregion
|
|
498
|
-
//#region src/config/resolvers/builder.ts
|
|
499
442
|
const VALID_BUILDERS = [
|
|
500
443
|
"rolldown",
|
|
501
444
|
"rollup",
|
|
@@ -549,8 +492,16 @@ function hasNitroViteConfig(options) {
|
|
|
549
492
|
}
|
|
550
493
|
return false;
|
|
551
494
|
}
|
|
552
|
-
|
|
553
|
-
|
|
495
|
+
async function resolveTracingOptions(options) {
|
|
496
|
+
if (!options.tracingChannel) return;
|
|
497
|
+
options.tracingChannel = {
|
|
498
|
+
srvx: true,
|
|
499
|
+
h3: 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
1
|
import { M as glob, ct as join, ut as relative } 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 };
|