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/_chunks/nitro3.mjs
CHANGED
|
@@ -1,129 +1,136 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import { ct as join } from "../_build/common.mjs";
|
|
2
|
+
import { a as findRoute, i as findAllRoutes, n as addRoute, r as createRouter, t as compileRouterToString } from "../_libs/rou3.mjs";
|
|
3
|
+
import { runtimeDir } from "nitro/meta";
|
|
4
|
+
import { hash } from "ohash";
|
|
5
|
+
const isGlobalMiddleware = (h) => !h.method && (!h.route || h.route === "/**");
|
|
6
|
+
function initNitroRouting(nitro) {
|
|
7
|
+
const envConditions = new Set([
|
|
8
|
+
nitro.options.dev ? "dev" : "prod",
|
|
9
|
+
nitro.options.preset,
|
|
10
|
+
nitro.options.preset === "nitro-prerender" ? "prerender" : void 0
|
|
11
|
+
].filter(Boolean));
|
|
12
|
+
const matchesEnv = (h) => {
|
|
13
|
+
const envs = (Array.isArray(h.env) ? h.env : [h.env]).filter(Boolean);
|
|
14
|
+
return envs.length === 0 || envs.some((env) => envConditions.has(env));
|
|
15
|
+
};
|
|
16
|
+
const routes = new Router(nitro.options.baseURL);
|
|
17
|
+
const routeRules = new Router(nitro.options.baseURL);
|
|
18
|
+
const globalMiddleware = [];
|
|
19
|
+
const routedMiddleware = new Router(nitro.options.baseURL);
|
|
20
|
+
const sync = () => {
|
|
21
|
+
routeRules._update(Object.entries(nitro.options.routeRules).map(([route, data]) => ({
|
|
22
|
+
route,
|
|
23
|
+
method: "",
|
|
24
|
+
data: {
|
|
25
|
+
...data,
|
|
26
|
+
_route: route
|
|
27
|
+
}
|
|
28
|
+
})));
|
|
29
|
+
const _routes = [
|
|
30
|
+
...Object.entries(nitro.options.routes).flatMap(([route, handler]) => {
|
|
31
|
+
if (typeof handler === "string") handler = { handler };
|
|
32
|
+
return {
|
|
33
|
+
...handler,
|
|
34
|
+
route,
|
|
35
|
+
middleware: false
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
...nitro.options.handlers,
|
|
39
|
+
...nitro.scannedHandlers
|
|
40
|
+
].filter((h) => h && !h.middleware && matchesEnv(h));
|
|
41
|
+
if (nitro.options.serverEntry && nitro.options.serverEntry.handler) _routes.push({
|
|
42
|
+
route: "/**",
|
|
43
|
+
lazy: false,
|
|
44
|
+
format: nitro.options.serverEntry.format,
|
|
45
|
+
handler: nitro.options.serverEntry.handler
|
|
35
46
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const { loadServerEntry } = await import("srvx/loader");
|
|
41
|
-
const entry = await loadServerEntry({
|
|
42
|
-
entry: resolve(outputDir, buildInfo.serverEntry),
|
|
43
|
-
...opts.loader
|
|
47
|
+
if (nitro.options.renderer?.handler) _routes.push({
|
|
48
|
+
route: "/**",
|
|
49
|
+
lazy: true,
|
|
50
|
+
handler: nitro.options.renderer?.handler
|
|
44
51
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
routes._update(_routes.map((h) => ({
|
|
53
|
+
...h,
|
|
54
|
+
method: h.method || "",
|
|
55
|
+
data: handlerWithImportHash(h)
|
|
56
|
+
})), { merge: true });
|
|
57
|
+
const _middleware = [...nitro.scannedHandlers, ...nitro.options.handlers].filter((h) => h && h.middleware && matchesEnv(h));
|
|
58
|
+
if (nitro.options.serveStatic) _middleware.unshift({
|
|
59
|
+
route: "/**",
|
|
60
|
+
middleware: true,
|
|
61
|
+
handler: join(runtimeDir, "internal/static")
|
|
62
|
+
});
|
|
63
|
+
globalMiddleware.splice(0, globalMiddleware.length, ..._middleware.filter((h) => isGlobalMiddleware(h)).map((m) => handlerWithImportHash(m)));
|
|
64
|
+
routedMiddleware._update(_middleware.filter((h) => !isGlobalMiddleware(h)).map((h) => ({
|
|
65
|
+
...h,
|
|
66
|
+
method: h.method || "",
|
|
67
|
+
data: handlerWithImportHash(h)
|
|
68
|
+
})));
|
|
60
69
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
".env.preview",
|
|
68
|
-
".env.production",
|
|
69
|
-
".env"
|
|
70
|
-
]
|
|
70
|
+
nitro.routing = Object.freeze({
|
|
71
|
+
sync,
|
|
72
|
+
routes,
|
|
73
|
+
routeRules,
|
|
74
|
+
globalMiddleware,
|
|
75
|
+
routedMiddleware
|
|
71
76
|
});
|
|
72
|
-
return Object.entries(env).filter(([_key, val]) => val);
|
|
73
77
|
}
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
consola.info(`Spawning preview server...`);
|
|
77
|
-
consola.info(opts.command);
|
|
78
|
-
console.log("");
|
|
79
|
-
const { getRandomPort, waitForPort } = await import("get-port-please");
|
|
80
|
-
const randomPort = await getRandomPort();
|
|
81
|
-
const child = spawn(arg0, [
|
|
82
|
-
...args,
|
|
83
|
-
"--port",
|
|
84
|
-
String(randomPort),
|
|
85
|
-
"--host",
|
|
86
|
-
"localhost"
|
|
87
|
-
], {
|
|
88
|
-
stdio: "inherit",
|
|
89
|
-
cwd: opts.rootDir,
|
|
90
|
-
env: {
|
|
91
|
-
...process.env,
|
|
92
|
-
...Object.fromEntries(opts.env ?? []),
|
|
93
|
-
PORT: String(randomPort)
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
const killChild = (signal) => {
|
|
97
|
-
if (child && !child.killed) child.kill(signal);
|
|
98
|
-
};
|
|
99
|
-
for (const sig of ["SIGINT", "SIGHUP"]) process.once(sig, () => {
|
|
100
|
-
killChild(sig);
|
|
101
|
-
});
|
|
102
|
-
child.once("exit", (code) => {
|
|
103
|
-
if (code && code !== 0) consola.error(`[nitro] Preview server exited with code ${code}`);
|
|
104
|
-
});
|
|
105
|
-
await waitForPort(randomPort, {
|
|
106
|
-
retries: 20,
|
|
107
|
-
delay: 500,
|
|
108
|
-
host: "localhost"
|
|
109
|
-
});
|
|
78
|
+
function handlerWithImportHash(h) {
|
|
79
|
+
const id = (h.lazy ? "_lazy_" : "_") + hash(h.handler).replace(/-/g, "").slice(0, 6);
|
|
110
80
|
return {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
port: randomPort,
|
|
114
|
-
host: "localhost"
|
|
115
|
-
}, req);
|
|
116
|
-
},
|
|
117
|
-
async upgrade(req, socket, head, opts) {
|
|
118
|
-
await proxyUpgrade({
|
|
119
|
-
port: randomPort,
|
|
120
|
-
host: "localhost"
|
|
121
|
-
}, req, socket, head, opts);
|
|
122
|
-
},
|
|
123
|
-
async close() {
|
|
124
|
-
killChild("SIGTERM");
|
|
125
|
-
}
|
|
81
|
+
...h,
|
|
82
|
+
_importHash: id
|
|
126
83
|
};
|
|
127
84
|
}
|
|
128
|
-
|
|
129
|
-
|
|
85
|
+
var Router = class {
|
|
86
|
+
_routes;
|
|
87
|
+
_router;
|
|
88
|
+
_compiled;
|
|
89
|
+
_baseURL;
|
|
90
|
+
constructor(baseURL) {
|
|
91
|
+
this._update([]);
|
|
92
|
+
this._baseURL = baseURL || "";
|
|
93
|
+
if (this._baseURL.endsWith("/")) this._baseURL = this._baseURL.slice(0, -1);
|
|
94
|
+
}
|
|
95
|
+
get routes() {
|
|
96
|
+
return this._routes;
|
|
97
|
+
}
|
|
98
|
+
_update(routes, opts) {
|
|
99
|
+
this._routes = routes;
|
|
100
|
+
this._router = createRouter();
|
|
101
|
+
this._compiled = void 0;
|
|
102
|
+
for (const route of routes) addRoute(this._router, route.method, this._baseURL + route.route, route.data);
|
|
103
|
+
if (opts?.merge) mergeCatchAll(this._router);
|
|
104
|
+
}
|
|
105
|
+
hasRoutes() {
|
|
106
|
+
return this._routes.length > 0;
|
|
107
|
+
}
|
|
108
|
+
compileToString(opts) {
|
|
109
|
+
const key = opts ? hash(opts) : "";
|
|
110
|
+
this._compiled ||= {};
|
|
111
|
+
if (this._compiled[key]) return this._compiled[key];
|
|
112
|
+
this._compiled[key] = compileRouterToString(this._router, void 0, opts);
|
|
113
|
+
if (this.routes.length === 1 && this.routes[0].route === "/**" && this.routes[0].method === "") {
|
|
114
|
+
const data = (opts?.serialize || JSON.stringify)(this.routes[0].data);
|
|
115
|
+
let retCode = `{data,params:{"_":p.slice(1)}}`;
|
|
116
|
+
if (opts?.matchAll) retCode = `[${retCode}]`;
|
|
117
|
+
this._compiled[key] = `/* @__PURE__ */ (() => {const data=${data};return ((_m, p)=>{return ${retCode};})})()`;
|
|
118
|
+
}
|
|
119
|
+
return this._compiled[key];
|
|
120
|
+
}
|
|
121
|
+
match(method, path) {
|
|
122
|
+
return findRoute(this._router, method, path)?.data;
|
|
123
|
+
}
|
|
124
|
+
matchAll(method, path) {
|
|
125
|
+
return findAllRoutes(this._router, method, path).map((route) => route.data);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
function mergeCatchAll(router) {
|
|
129
|
+
const handlers = router.root?.wildcard?.methods?.[""];
|
|
130
|
+
if (!handlers || handlers.length < 2) return;
|
|
131
|
+
handlers.splice(0, handlers.length, {
|
|
132
|
+
...handlers[0],
|
|
133
|
+
data: handlers.map((h) => h.data)
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
export { initNitroRouting as n, Router as t };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { F as prettyPath, ct as join, dt as resolve, m as getBuildInfo } from "../_build/common.mjs";
|
|
2
|
+
import { n as proxyFetch, r as proxyUpgrade } from "../_libs/httpxy.mjs";
|
|
3
|
+
import consola from "consola";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
async function startPreview(opts) {
|
|
6
|
+
const { outputDir, buildInfo } = await getBuildInfo(opts.rootDir);
|
|
7
|
+
if (!buildInfo) throw new Error("Cannot load nitro build info. Make sure to build first.");
|
|
8
|
+
const info = [
|
|
9
|
+
["Build Directory:", prettyPath(outputDir)],
|
|
10
|
+
["Date:", buildInfo.date && new Date(buildInfo.date).toLocaleString()],
|
|
11
|
+
["Nitro Version:", buildInfo.versions.nitro],
|
|
12
|
+
["Nitro Preset:", buildInfo.preset],
|
|
13
|
+
buildInfo.framework?.name !== "nitro" && ["Framework:", buildInfo.framework?.name + (buildInfo.framework?.version ? ` (v${buildInfo.framework.version})` : "")]
|
|
14
|
+
].filter((i) => i && i[1]);
|
|
15
|
+
consola.box({
|
|
16
|
+
title: " [Build Info] ",
|
|
17
|
+
message: info.map((i) => `- ${i[0]} ${i[1]}`).join("\n")
|
|
18
|
+
});
|
|
19
|
+
const dotEnvEntries = await loadPreviewDotEnv(opts.rootDir);
|
|
20
|
+
if (dotEnvEntries.length > 0) consola.box({
|
|
21
|
+
title: " [Environment Variables] ",
|
|
22
|
+
message: [
|
|
23
|
+
"Loaded variables from .env files (preview mode only).",
|
|
24
|
+
"Set platform environment variables for production:",
|
|
25
|
+
...dotEnvEntries.map(([key, val]) => ` - ${key}`)
|
|
26
|
+
].join("\n")
|
|
27
|
+
});
|
|
28
|
+
if (buildInfo.preset.includes("cloudflare")) {
|
|
29
|
+
if (!buildInfo.commands?.preview) throw new Error(`No nitro build preview command found for the "${buildInfo.preset}" preset.`);
|
|
30
|
+
return await runPreviewCommand({
|
|
31
|
+
command: buildInfo.commands.preview,
|
|
32
|
+
rootDir: opts.rootDir,
|
|
33
|
+
env: dotEnvEntries
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
let fetchHandler = () => Promise.resolve(new Response("Not Found", { status: 404 }));
|
|
37
|
+
if (buildInfo.serverEntry) {
|
|
38
|
+
for (const [key, val] of dotEnvEntries) if (!process.env[key]) process.env[key] = val;
|
|
39
|
+
const { loadServerEntry } = await import("srvx/loader");
|
|
40
|
+
const entry = await loadServerEntry({
|
|
41
|
+
entry: resolve(outputDir, buildInfo.serverEntry),
|
|
42
|
+
...opts.loader
|
|
43
|
+
});
|
|
44
|
+
if (entry.fetch) fetchHandler = entry.fetch;
|
|
45
|
+
}
|
|
46
|
+
if (buildInfo.publicDir) {
|
|
47
|
+
const { serveStatic } = await import("srvx/static");
|
|
48
|
+
const staticHandler = serveStatic({ dir: join(outputDir, buildInfo.publicDir) });
|
|
49
|
+
const originalFetchHandler = fetchHandler;
|
|
50
|
+
fetchHandler = async (req) => {
|
|
51
|
+
const staticRes = await staticHandler(req, () => void 0);
|
|
52
|
+
if (staticRes) return staticRes;
|
|
53
|
+
return originalFetchHandler(req);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
fetch: fetchHandler,
|
|
58
|
+
async close() {}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function loadPreviewDotEnv(root) {
|
|
62
|
+
const { loadDotenv } = await import("../_libs/_.mjs");
|
|
63
|
+
const env = await loadDotenv({
|
|
64
|
+
cwd: root,
|
|
65
|
+
fileName: [
|
|
66
|
+
".env.preview",
|
|
67
|
+
".env.production",
|
|
68
|
+
".env"
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
return Object.entries(env).filter(([_key, val]) => val);
|
|
72
|
+
}
|
|
73
|
+
async function runPreviewCommand(opts) {
|
|
74
|
+
const [arg0, ...args] = opts.command.split(" ");
|
|
75
|
+
consola.info(`Spawning preview server...`);
|
|
76
|
+
consola.info(opts.command);
|
|
77
|
+
console.log("");
|
|
78
|
+
const { getRandomPort, waitForPort } = await import("get-port-please");
|
|
79
|
+
const randomPort = await getRandomPort();
|
|
80
|
+
const child = spawn(arg0, [
|
|
81
|
+
...args,
|
|
82
|
+
"--port",
|
|
83
|
+
String(randomPort),
|
|
84
|
+
"--host",
|
|
85
|
+
"localhost"
|
|
86
|
+
], {
|
|
87
|
+
stdio: "inherit",
|
|
88
|
+
cwd: opts.rootDir,
|
|
89
|
+
env: {
|
|
90
|
+
...process.env,
|
|
91
|
+
...Object.fromEntries(opts.env ?? []),
|
|
92
|
+
PORT: String(randomPort)
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const killChild = (signal) => {
|
|
96
|
+
if (child && !child.killed) child.kill(signal);
|
|
97
|
+
};
|
|
98
|
+
for (const sig of ["SIGINT", "SIGHUP"]) process.once(sig, () => {
|
|
99
|
+
killChild(sig);
|
|
100
|
+
});
|
|
101
|
+
child.once("exit", (code) => {
|
|
102
|
+
if (code && code !== 0) consola.error(`[nitro] Preview server exited with code ${code}`);
|
|
103
|
+
});
|
|
104
|
+
await waitForPort(randomPort, {
|
|
105
|
+
retries: 20,
|
|
106
|
+
delay: 500,
|
|
107
|
+
host: "localhost"
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
fetch(req) {
|
|
111
|
+
return proxyFetch({
|
|
112
|
+
port: randomPort,
|
|
113
|
+
host: "localhost"
|
|
114
|
+
}, req);
|
|
115
|
+
},
|
|
116
|
+
async upgrade(req, socket, head, opts) {
|
|
117
|
+
await proxyUpgrade({
|
|
118
|
+
port: randomPort,
|
|
119
|
+
host: "localhost"
|
|
120
|
+
}, req, socket, head, opts);
|
|
121
|
+
},
|
|
122
|
+
async close() {
|
|
123
|
+
killChild("SIGTERM");
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export { startPreview as t };
|
package/dist/_chunks/utils.mjs
CHANGED
|
@@ -79,8 +79,6 @@ async function gzipSize(input, options) {
|
|
|
79
79
|
if (!input) return 0;
|
|
80
80
|
return (await gzip(input, getOptions(options))).length;
|
|
81
81
|
}
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region node_modules/.pnpm/pretty-bytes@7.1.0/node_modules/pretty-bytes/index.js
|
|
84
82
|
const BYTE_UNITS = [
|
|
85
83
|
"B",
|
|
86
84
|
"kB",
|
|
@@ -193,8 +191,6 @@ function prettyBytes(number, options) {
|
|
|
193
191
|
}
|
|
194
192
|
return applyFixedWidth(result, options.fixedWidth);
|
|
195
193
|
}
|
|
196
|
-
//#endregion
|
|
197
|
-
//#region src/utils/fs-tree.ts
|
|
198
194
|
async function generateFSTree(dir, options = {}) {
|
|
199
195
|
if (v) return;
|
|
200
196
|
const files = await glob("**/*.*", {
|
|
@@ -241,8 +237,6 @@ async function generateFSTree(dir, options = {}) {
|
|
|
241
237
|
treeText += "\n";
|
|
242
238
|
return treeText;
|
|
243
239
|
}
|
|
244
|
-
//#endregion
|
|
245
|
-
//#region src/utils/dep.ts
|
|
246
240
|
async function importDep(opts, _retry) {
|
|
247
241
|
const resolved = resolveModulePath(opts.id, {
|
|
248
242
|
from: [opts.dir, import.meta.url],
|
|
@@ -268,5 +262,4 @@ async function importDep(opts, _retry) {
|
|
|
268
262
|
consola$1.success(`Installed \`${opts.id}\` in ${opts.dir} (${Date.now() - start}ms).`);
|
|
269
263
|
return importDep(opts, true);
|
|
270
264
|
}
|
|
271
|
-
//#endregion
|
|
272
265
|
export { generateFSTree as n, importDep as t };
|
package/dist/_common.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -31,5 +30,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
30
|
enumerable: true
|
|
32
31
|
}) : target, mod));
|
|
33
32
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
34
|
-
//#endregion
|
|
35
33
|
export { __toESM as i, __exportAll as n, __require as r, __commonJSMin as t };
|
package/dist/_dev.d.mts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { HTTPHandler } from "h3";
|
|
2
2
|
import { Nitro } from "nitro/types";
|
|
3
|
-
|
|
4
|
-
//#region src/dev/app.d.ts
|
|
5
3
|
declare class NitroDevApp {
|
|
6
4
|
#private;
|
|
7
5
|
nitro: Nitro;
|
|
8
6
|
fetch: (req: Request) => Response | Promise<Response>;
|
|
9
7
|
constructor(nitro: Nitro, catchAllHandler?: HTTPHandler);
|
|
10
8
|
}
|
|
11
|
-
//#endregion
|
|
12
9
|
export { NitroDevApp as t };
|
package/dist/_dev.mjs
CHANGED
|
@@ -12,7 +12,6 @@ import { RunnerManager, loadRunner } from "env-runner";
|
|
|
12
12
|
import { H3, HTTPError, defineHandler, fromNodeHandler, getRequestIP, getRequestURL, serveStatic, toEventHandler } from "h3";
|
|
13
13
|
import { serve } from "srvx/node";
|
|
14
14
|
import { FastResponse } from "srvx";
|
|
15
|
-
//#region src/dev/vfs.ts
|
|
16
15
|
function createVFSHandler(nitro) {
|
|
17
16
|
return defineHandler(async (event) => {
|
|
18
17
|
const { socket } = event.runtime?.node?.req || {};
|
|
@@ -142,13 +141,9 @@ const editorTemplate = (options) => `
|
|
|
142
141
|
}, 0);
|
|
143
142
|
<\/script>
|
|
144
143
|
`;
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/runtime/internal/error/utils.ts
|
|
147
144
|
function defineNitroErrorHandler(handler) {
|
|
148
145
|
return handler;
|
|
149
146
|
}
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/runtime/internal/error/dev.ts
|
|
152
147
|
const errorHandler = defineNitroErrorHandler(async function defaultNitroErrorHandler(error, event) {
|
|
153
148
|
const res = await defaultHandler(error, event);
|
|
154
149
|
return new FastResponse(typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2), res);
|
|
@@ -241,8 +236,6 @@ function fmtFrame(frame) {
|
|
|
241
236
|
const src = `${frame.fileName || ""}:${frame.lineNumber}:${frame.columnNumber})`;
|
|
242
237
|
return frame.functionName ? `at ${frame.functionName} (${src}` : `at ${src}`;
|
|
243
238
|
}
|
|
244
|
-
//#endregion
|
|
245
|
-
//#region src/dev/app.ts
|
|
246
239
|
var NitroDevApp = class {
|
|
247
240
|
nitro;
|
|
248
241
|
fetch;
|
|
@@ -354,8 +347,6 @@ function createHTTPProxy(defaults = {}) {
|
|
|
354
347
|
}
|
|
355
348
|
};
|
|
356
349
|
}
|
|
357
|
-
//#endregion
|
|
358
|
-
//#region src/dev/server.ts
|
|
359
350
|
function createDevServer(nitro) {
|
|
360
351
|
return new NitroDevServer(nitro);
|
|
361
352
|
}
|
|
@@ -515,5 +506,4 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
515
506
|
});
|
|
516
507
|
}
|
|
517
508
|
};
|
|
518
|
-
//#endregion
|
|
519
509
|
export { createDevServer as n, NitroDevApp as r, NitroDevServer as t };
|
package/dist/_libs/_.mjs
CHANGED
package/dist/_libs/_3.mjs
CHANGED
package/dist/_libs/_5.mjs
CHANGED
package/dist/_libs/_6.mjs
CHANGED
package/dist/_libs/_7.mjs
CHANGED
package/dist/_libs/c12+rc9.mjs
CHANGED
|
@@ -8,7 +8,6 @@ import { resolve } from "node:path";
|
|
|
8
8
|
import destr from "destr";
|
|
9
9
|
import { defu } from "defu";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
|
-
//#region node_modules/.pnpm/c12@4.0.0-beta.3_chokidar@5.0.0_dotenv@17.3.1_giget@3.1.2_jiti@2.6.1_magicast@0.5.2/node_modules/c12/dist/_chunks/libs/perfect-debounce.mjs
|
|
12
11
|
const DEBOUNCE_DEFAULTS = { trailing: true };
|
|
13
12
|
function debounce(fn, wait = 25, options = {}) {
|
|
14
13
|
options = {
|
|
@@ -76,8 +75,6 @@ function debounce(fn, wait = 25, options = {}) {
|
|
|
76
75
|
async function _applyPromised(fn, _this, args) {
|
|
77
76
|
return await fn.apply(_this, args);
|
|
78
77
|
}
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region node_modules/.pnpm/rc9@3.0.0/node_modules/rc9/dist/_chunks/libs/flat.mjs
|
|
81
78
|
function isBuffer(obj) {
|
|
82
79
|
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
83
80
|
}
|
|
@@ -159,8 +156,6 @@ function unflatten(target, opts) {
|
|
|
159
156
|
});
|
|
160
157
|
return result;
|
|
161
158
|
}
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region node_modules/.pnpm/rc9@3.0.0/node_modules/rc9/dist/index.mjs
|
|
164
159
|
const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
|
|
165
160
|
const RE_LINES = /\n|\r|\r\n/;
|
|
166
161
|
const defaults = {
|
|
@@ -206,8 +201,6 @@ function readUser(options) {
|
|
|
206
201
|
options.dir = process.env.XDG_CONFIG_HOME || homedir();
|
|
207
202
|
return read(options);
|
|
208
203
|
}
|
|
209
|
-
//#endregion
|
|
210
|
-
//#region node_modules/.pnpm/c12@4.0.0-beta.3_chokidar@5.0.0_dotenv@17.3.1_giget@3.1.2_jiti@2.6.1_magicast@0.5.2/node_modules/c12/dist/index.mjs
|
|
211
204
|
async function setupDotenv(options) {
|
|
212
205
|
const targetEnvironment = options.env ?? process.env;
|
|
213
206
|
const environment = await loadDotenv({
|
|
@@ -301,6 +294,7 @@ function getDotEnvVars(targetEnvironment) {
|
|
|
301
294
|
return globalRegistry.get(targetEnvironment);
|
|
302
295
|
}
|
|
303
296
|
const _normalize = (p) => p?.replace(/\\/g, "/");
|
|
297
|
+
let importCounter = 0;
|
|
304
298
|
const ASYNC_LOADERS = {
|
|
305
299
|
".yaml": () => import("../_build/common.mjs").then((n) => n.Q).then((r) => r.parseYAML),
|
|
306
300
|
".yml": () => import("../_build/common.mjs").then((n) => n.Q).then((r) => r.parseYAML),
|
|
@@ -509,7 +503,7 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
509
503
|
}
|
|
510
504
|
if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || source;
|
|
511
505
|
const ext = extname$1(source);
|
|
512
|
-
const isDir = !ext || ext === basename$1(source);
|
|
506
|
+
const isDir = _isDirectory(resolve$1(options.cwd, source)) ?? (!ext || ext === basename$1(source));
|
|
513
507
|
const cwd = resolve$1(options.cwd, isDir ? source : dirname$1(source));
|
|
514
508
|
if (isDir) source = options.configFile;
|
|
515
509
|
const res = {
|
|
@@ -527,18 +521,22 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
527
521
|
else {
|
|
528
522
|
const _resolveModule = options.resolveModule || ((mod) => mod.default || mod);
|
|
529
523
|
if (options.import) res.config = _resolveModule(await options.import(res.configFile));
|
|
530
|
-
else
|
|
531
|
-
const
|
|
532
|
-
|
|
524
|
+
else {
|
|
525
|
+
const _configURL = pathToFileURL(res.configFile);
|
|
526
|
+
_configURL.search = `_${++importCounter}`;
|
|
527
|
+
res.config = await import(_configURL.href).then(_resolveModule, async (error) => {
|
|
528
|
+
const { createJiti } = await import("jiti").catch(() => {
|
|
529
|
+
throw new Error(`Failed to load config file \`${res.configFile}\`: ${error?.message}. Hint install \`jiti\` for compatibility.`, { cause: error });
|
|
530
|
+
});
|
|
531
|
+
const jiti = createJiti(join$1(options.cwd || ".", options.configFile || "/"), {
|
|
532
|
+
interopDefault: true,
|
|
533
|
+
moduleCache: false,
|
|
534
|
+
extensions: [...SUPPORTED_EXTENSIONS]
|
|
535
|
+
});
|
|
536
|
+
options.import = (id) => jiti.import(id);
|
|
537
|
+
return _resolveModule(await options.import(res.configFile));
|
|
533
538
|
});
|
|
534
|
-
|
|
535
|
-
interopDefault: true,
|
|
536
|
-
moduleCache: false,
|
|
537
|
-
extensions: [...SUPPORTED_EXTENSIONS]
|
|
538
|
-
});
|
|
539
|
-
options.import = (id) => jiti.import(id);
|
|
540
|
-
return _resolveModule(await options.import(res.configFile));
|
|
541
|
-
});
|
|
539
|
+
}
|
|
542
540
|
}
|
|
543
541
|
if (typeof res.config === "function") res.config = await res.config(options.context);
|
|
544
542
|
if (options.envName) {
|
|
@@ -565,6 +563,13 @@ function tryResolve(id, options) {
|
|
|
565
563
|
});
|
|
566
564
|
return res ? normalize$1(res) : void 0;
|
|
567
565
|
}
|
|
566
|
+
function _isDirectory(path) {
|
|
567
|
+
try {
|
|
568
|
+
return statSync(path).isDirectory();
|
|
569
|
+
} catch {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
568
573
|
const eventMap = {
|
|
569
574
|
add: "created",
|
|
570
575
|
change: "updated",
|
|
@@ -627,8 +632,6 @@ async function watchConfig(options) {
|
|
|
627
632
|
return config[prop];
|
|
628
633
|
} });
|
|
629
634
|
}
|
|
630
|
-
//#endregion
|
|
631
|
-
//#region node_modules/.pnpm/c12@4.0.0-beta.3_chokidar@5.0.0_dotenv@17.3.1_giget@3.1.2_jiti@2.6.1_magicast@0.5.2/node_modules/c12/dist/_chunks/libs/ohash.mjs
|
|
632
635
|
var __defProp = Object.defineProperty;
|
|
633
636
|
var __exportAll = (all, no_symbols) => {
|
|
634
637
|
let target = {};
|
|
@@ -808,5 +811,4 @@ var DiffHashedObject = class {
|
|
|
808
811
|
return `${k}(${this.value})`;
|
|
809
812
|
}
|
|
810
813
|
};
|
|
811
|
-
//#endregion
|
|
812
814
|
export { loadDotenv as a, loadConfig as i, utils_exports as n, setupDotenv as o, SUPPORTED_EXTENSIONS as r, watchConfig as s, dist_exports as t };
|
|
@@ -2,8 +2,6 @@ import { Stats } from "node:fs";
|
|
|
2
2
|
import { EventEmitter } from "node:events";
|
|
3
3
|
import { Readable } from "node:stream";
|
|
4
4
|
import { DownloadTemplateOptions } from "giget";
|
|
5
|
-
|
|
6
|
-
//#region node_modules/.pnpm/c12@4.0.0-beta.3_chokidar@5.0.0_dotenv@17.3.1_giget@3.1.2_jiti@2.6.1_magicast@0.5.2/node_modules/c12/dist/_chunks/libs/ohash.d.mts
|
|
7
5
|
//#region node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/utils/index.d.mts
|
|
8
6
|
/**
|
|
9
7
|
* Calculates the difference between two objects and returns a list of differences.
|
|
@@ -32,8 +30,6 @@ declare class DiffHashedObject {
|
|
|
32
30
|
toString(): string;
|
|
33
31
|
toJSON(): string;
|
|
34
32
|
} //#endregion
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.d.ts
|
|
37
33
|
type AWF = {
|
|
38
34
|
stabilityThreshold: number;
|
|
39
35
|
pollInterval: number;
|
|
@@ -61,8 +57,6 @@ interface MatcherObject {
|
|
|
61
57
|
recursive?: boolean;
|
|
62
58
|
}
|
|
63
59
|
type Matcher = string | RegExp | MatchFunction | MatcherObject;
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region node_modules/.pnpm/c12@4.0.0-beta.3_chokidar@5.0.0_dotenv@17.3.1_giget@3.1.2_jiti@2.6.1_magicast@0.5.2/node_modules/c12/dist/index.d.mts
|
|
66
60
|
//#region src/dotenv.d.ts
|
|
67
61
|
interface DotenvOptions {
|
|
68
62
|
/**
|
|
@@ -226,5 +220,4 @@ interface WatchConfigOptions<T extends UserInputConfig = UserInputConfig, MT ext
|
|
|
226
220
|
oldConfig: ResolvedConfig<T, MT>;
|
|
227
221
|
}) => void | Promise<void>;
|
|
228
222
|
}
|
|
229
|
-
//#endregion
|
|
230
223
|
export { WatchConfigOptions as a, ResolvedConfig as i, ConfigWatcher as n, ChokidarOptions as o, DotenvOptions as r, C12InputConfig as t };
|