nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-121649-98b56dfe
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 +763 -0
- package/dist/_build/rolldown.mjs +216 -0
- package/dist/_build/rollup.mjs +359 -0
- package/dist/_build/vite.build.mjs +67 -0
- package/dist/_build/vite.plugin.mjs +747 -0
- package/dist/_chunks/B-7HiF0V.mjs +1303 -0
- package/dist/_chunks/B3asVbT4.mjs +151 -0
- package/dist/_chunks/B5ooyfLk.mjs +372 -0
- package/dist/_chunks/DXMHy5ca.mjs +43 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +675 -0
- package/dist/_libs/acorn.mjs +5034 -0
- package/dist/_libs/c12.mjs +2798 -0
- package/dist/_libs/chokidar.mjs +1560 -0
- package/dist/_libs/citty.mjs +333 -0
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/compatx.mjs +46 -0
- package/dist/_libs/confbox.mjs +2920 -0
- package/dist/_libs/debug.mjs +848 -0
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/depd.mjs +314 -0
- package/dist/_libs/dot-prop.mjs +138 -0
- package/dist/_libs/duplexer.mjs +71 -0
- package/dist/_libs/ee-first.mjs +68 -0
- package/dist/_libs/encodeurl.mjs +49 -0
- package/dist/_libs/escape-html.mjs +58 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +330 -0
- package/dist/_libs/etag.mjs +75 -0
- package/dist/{_chunks/_deps → _libs}/fdir.mjs +49 -104
- package/dist/_libs/fresh.mjs +85 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/gen-mapping.mjs +612 -0
- package/dist/_libs/giget.mjs +19076 -0
- package/dist/_libs/gzip-size.mjs +21 -0
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/http-errors.mjs +436 -0
- package/dist/_libs/httpxy.mjs +410 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +32 -0
- package/dist/{_chunks/_deps → _libs}/js-tokens.mjs +83 -112
- package/dist/_libs/klona.mjs +90 -0
- package/dist/_libs/knitwork.mjs +124 -0
- package/dist/_libs/local-pkg.mjs +1686 -0
- package/dist/{_chunks/_deps → _libs}/magic-string.mjs +272 -629
- package/dist/_libs/mime-db.mjs +7642 -0
- package/dist/_libs/mime-types.mjs +162 -0
- package/dist/_libs/mime.mjs +1391 -0
- package/dist/_libs/node-fetch-native.mjs +173 -0
- package/dist/_libs/on-finished.mjs +170 -0
- package/dist/_libs/parseurl.mjs +103 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +41 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-commonjs.mjs +1489 -0
- package/dist/_libs/plugin-inject.mjs +135 -0
- package/dist/_libs/plugin-json.mjs +36 -0
- package/dist/_libs/plugin-node-resolve.mjs +1553 -0
- package/dist/_libs/plugin-replace.mjs +104 -0
- package/dist/_libs/pretty-bytes.mjs +116 -0
- package/dist/_libs/range-parser.mjs +102 -0
- package/dist/_libs/remapping.mjs +117 -0
- package/dist/{_chunks/_deps → _libs}/rou3.mjs +7 -22
- package/dist/_libs/send.mjs +857 -0
- package/dist/_libs/serve-static.mjs +124 -0
- package/dist/_libs/std-env.mjs +158 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/{_chunks/_deps → _libs}/tinyglobby.mjs +32 -33
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/unimport.mjs +3520 -0
- package/dist/_libs/untyped.mjs +271 -0
- package/dist/_libs/unwasm.mjs +5825 -0
- package/dist/{_chunks/_deps/@pi0 → _libs}/vite-plugin-fullstack.mjs +28 -42
- package/dist/_presets.mjs +1723 -0
- package/dist/builder.d.mts +37 -35
- package/dist/builder.mjs +45 -117
- package/dist/cli/_chunks/build.mjs +43 -0
- package/dist/cli/_chunks/common.mjs +15 -0
- package/dist/cli/_chunks/detect-acorn.mjs +12 -0
- package/dist/cli/_chunks/dev.mjs +79 -0
- package/dist/cli/_chunks/dist.mjs +3 -0
- package/dist/cli/_chunks/dist2.mjs +4 -0
- package/dist/cli/_chunks/esm.mjs +3 -0
- package/dist/cli/_chunks/json5.mjs +4 -0
- package/dist/cli/_chunks/jsonc.mjs +4 -0
- package/dist/cli/_chunks/list.mjs +27 -0
- package/dist/cli/_chunks/multipart-parser.mjs +6 -0
- package/dist/cli/_chunks/prepare.mjs +19 -0
- package/dist/cli/_chunks/run.mjs +55 -0
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/_chunks/toml.mjs +4 -0
- package/dist/cli/_chunks/yaml.mjs +4 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +19 -18
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +42 -33
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -8
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
- package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
- package/dist/presets/azure/runtime/_utils.mjs +43 -43
- package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
- package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
- package/dist/presets/bun/runtime/bun.d.mts +1 -0
- package/dist/presets/bun/runtime/bun.mjs +18 -17
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +78 -87
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +53 -58
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +86 -76
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
- package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
- package/dist/presets/deno/runtime/deno-server.mjs +31 -39
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
- package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
- package/dist/presets/netlify/runtime/netlify.mjs +11 -17
- package/dist/presets/node/runtime/node-cluster.mjs +49 -48
- package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
- package/dist/presets/node/runtime/node-middleware.mjs +7 -6
- package/dist/presets/node/runtime/node-server.mjs +33 -23
- package/dist/presets/standard/runtime/server.d.mts +1 -3
- package/dist/presets/standard/runtime/server.mjs +1 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
- package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
- package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
- package/dist/presets/vercel/runtime/vercel.mjs +15 -14
- package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/runtime/index.d.mts +12 -1
- package/dist/runtime/index.mjs +12 -7
- package/dist/runtime/internal/app.mjs +175 -162
- package/dist/runtime/internal/cache.d.mts +10 -4
- package/dist/runtime/internal/cache.mjs +247 -216
- package/dist/runtime/internal/context.d.mts +9 -9
- package/dist/runtime/internal/context.mjs +17 -10
- package/dist/runtime/internal/database.mjs +8 -10
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +106 -105
- package/dist/runtime/internal/error/prod.d.mts +2 -2
- package/dist/runtime/internal/error/prod.mjs +48 -52
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/error/utils.mjs +1 -1
- package/dist/runtime/internal/index.d.mts +2 -0
- package/dist/runtime/internal/index.mjs +2 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/meta.mjs +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/plugin.mjs +1 -1
- package/dist/runtime/internal/renderer.mjs +39 -31
- package/dist/runtime/internal/route-rules.d.mts +8 -8
- package/dist/runtime/internal/route-rules.mjs +53 -51
- package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -30
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
- package/dist/runtime/internal/routes/openapi.d.mts +1 -0
- package/dist/runtime/internal/routes/openapi.mjs +81 -87
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +1 -0
- package/dist/runtime/internal/routes/scalar.mjs +22 -23
- package/dist/runtime/internal/routes/swagger.d.mts +1 -0
- package/dist/runtime/internal/routes/swagger.mjs +9 -11
- package/dist/runtime/internal/runtime-config.d.mts +4 -4
- package/dist/runtime/internal/runtime-config.mjs +40 -35
- package/dist/runtime/internal/shutdown.d.mts +2 -7
- package/dist/runtime/internal/shutdown.mjs +30 -29
- package/dist/runtime/internal/static.mjs +63 -74
- package/dist/runtime/internal/storage.mjs +2 -2
- package/dist/runtime/internal/task.d.mts +6 -6
- package/dist/runtime/internal/task.mjs +56 -59
- package/dist/runtime/internal/utils.d.mts +1 -1
- package/dist/runtime/internal/utils.mjs +4 -10
- package/dist/types/index.d.mts +2566 -3851
- package/dist/types/index.mjs +1 -1
- package/dist/vite.d.mts +56 -52
- package/dist/vite.mjs +55 -132
- package/package.json +10 -10
- package/dist/_build/build.mjs +0 -368
- package/dist/_build/build2.mjs +0 -556
- package/dist/_build/info.mjs +0 -1002
- package/dist/_build/prepare.mjs +0 -1511
- package/dist/_build/snapshot.mjs +0 -185
- package/dist/_build/vite.mjs +0 -959
- package/dist/_build/vite2.mjs +0 -149
- package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +0 -189
- package/dist/_chunks/_deps/@jridgewell/remapping.mjs +0 -137
- package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +0 -231
- package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +0 -173
- package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +0 -170
- package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +0 -89
- package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +0 -2376
- package/dist/_chunks/_deps/@rollup/plugin-inject.mjs +0 -212
- package/dist/_chunks/_deps/@rollup/plugin-json.mjs +0 -37
- package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +0 -1386
- package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +0 -133
- package/dist/_chunks/_deps/@rollup/pluginutils.mjs +0 -346
- package/dist/_chunks/_deps/acorn.mjs +0 -6225
- package/dist/_chunks/_deps/c12.mjs +0 -510
- package/dist/_chunks/_deps/chokidar.mjs +0 -1428
- package/dist/_chunks/_deps/citty.mjs +0 -460
- package/dist/_chunks/_deps/commondir.mjs +0 -77
- package/dist/_chunks/_deps/compatx.mjs +0 -76
- package/dist/_chunks/_deps/confbox.mjs +0 -300
- package/dist/_chunks/_deps/debug.mjs +0 -885
- package/dist/_chunks/_deps/deepmerge.mjs +0 -147
- package/dist/_chunks/_deps/depd.mjs +0 -550
- package/dist/_chunks/_deps/dot-prop.mjs +0 -282
- package/dist/_chunks/_deps/dotenv.mjs +0 -555
- package/dist/_chunks/_deps/duplexer.mjs +0 -1
- package/dist/_chunks/_deps/ee-first.mjs +0 -104
- package/dist/_chunks/_deps/encodeurl.mjs +0 -69
- package/dist/_chunks/_deps/escape-html.mjs +0 -87
- package/dist/_chunks/_deps/escape-string-regexp.mjs +0 -13
- package/dist/_chunks/_deps/estree-walker.mjs +0 -433
- package/dist/_chunks/_deps/etag.mjs +0 -147
- package/dist/_chunks/_deps/exsolve.mjs +0 -1416
- package/dist/_chunks/_deps/fresh.mjs +0 -145
- package/dist/_chunks/_deps/function-bind.mjs +0 -106
- package/dist/_chunks/_deps/giget.mjs +0 -451
- package/dist/_chunks/_deps/gzip-size.mjs +0 -19
- package/dist/_chunks/_deps/hasown.mjs +0 -19
- package/dist/_chunks/_deps/http-errors.mjs +0 -307
- package/dist/_chunks/_deps/httpxy.mjs +0 -580
- package/dist/_chunks/_deps/inherits.mjs +0 -57
- package/dist/_chunks/_deps/is-core-module.mjs +0 -596
- package/dist/_chunks/_deps/is-module.mjs +0 -25
- package/dist/_chunks/_deps/is-reference.mjs +0 -31
- package/dist/_chunks/_deps/klona.mjs +0 -137
- package/dist/_chunks/_deps/knitwork.mjs +0 -172
- package/dist/_chunks/_deps/local-pkg.mjs +0 -163
- package/dist/_chunks/_deps/mime-db.mjs +0 -11685
- package/dist/_chunks/_deps/mime-types.mjs +0 -287
- package/dist/_chunks/_deps/mime.mjs +0 -1172
- package/dist/_chunks/_deps/mlly.mjs +0 -2413
- package/dist/_chunks/_deps/ms.mjs +0 -172
- package/dist/_chunks/_deps/node-fetch-native.mjs +0 -3
- package/dist/_chunks/_deps/nypm.mjs +0 -219
- package/dist/_chunks/_deps/on-finished.mjs +0 -246
- package/dist/_chunks/_deps/parseurl.mjs +0 -168
- package/dist/_chunks/_deps/path-parse.mjs +0 -85
- package/dist/_chunks/_deps/pathe.mjs +0 -251
- package/dist/_chunks/_deps/perfect-debounce.mjs +0 -88
- package/dist/_chunks/_deps/picomatch.mjs +0 -2144
- package/dist/_chunks/_deps/pkg-types.mjs +0 -247
- package/dist/_chunks/_deps/pretty-bytes.mjs +0 -180
- package/dist/_chunks/_deps/quansync.mjs +0 -99
- package/dist/_chunks/_deps/range-parser.mjs +0 -171
- package/dist/_chunks/_deps/rc9.mjs +0 -219
- package/dist/_chunks/_deps/readdirp.mjs +0 -245
- package/dist/_chunks/_deps/resolve.mjs +0 -1260
- package/dist/_chunks/_deps/send.mjs +0 -1022
- package/dist/_chunks/_deps/serve-static.mjs +0 -228
- package/dist/_chunks/_deps/setprototypeof.mjs +0 -26
- package/dist/_chunks/_deps/statuses.mjs +0 -457
- package/dist/_chunks/_deps/std-env.mjs +0 -3
- package/dist/_chunks/_deps/strip-literal.mjs +0 -67
- package/dist/_chunks/_deps/supports-color.mjs +0 -44
- package/dist/_chunks/_deps/tinyexec.mjs +0 -552
- package/dist/_chunks/_deps/toidentifier.mjs +0 -41
- package/dist/_chunks/_deps/ultrahtml.mjs +0 -3
- package/dist/_chunks/_deps/unimport.mjs +0 -2267
- package/dist/_chunks/_deps/unplugin-utils.mjs +0 -65
- package/dist/_chunks/_deps/unplugin.mjs +0 -1294
- package/dist/_chunks/_deps/untyped.mjs +0 -375
- package/dist/_chunks/_deps/unwasm.mjs +0 -6959
- package/dist/_chunks/_deps/webpack-virtual-modules.mjs +0 -360
- package/dist/_chunks/_presets/_all.mjs +0 -59
- package/dist/_chunks/_presets/_nitro.mjs +0 -74
- package/dist/_chunks/_presets/_resolve.mjs +0 -64
- package/dist/_chunks/_presets/_static.mjs +0 -69
- package/dist/_chunks/_presets/_types.mjs +0 -3
- package/dist/_chunks/_presets/_utils.mjs +0 -31
- package/dist/_chunks/_presets/alwaysdata.mjs +0 -17
- package/dist/_chunks/_presets/aws-amplify.mjs +0 -111
- package/dist/_chunks/_presets/aws-lambda.mjs +0 -23
- package/dist/_chunks/_presets/azure.mjs +0 -162
- package/dist/_chunks/_presets/bun.mjs +0 -19
- package/dist/_chunks/_presets/cleavr.mjs +0 -15
- package/dist/_chunks/_presets/cloudflare.mjs +0 -608
- package/dist/_chunks/_presets/deno.mjs +0 -196
- package/dist/_chunks/_presets/digitalocean.mjs +0 -14
- package/dist/_chunks/_presets/firebase.mjs +0 -47
- package/dist/_chunks/_presets/flightcontrol.mjs +0 -14
- package/dist/_chunks/_presets/genezio.mjs +0 -13
- package/dist/_chunks/_presets/heroku.mjs +0 -14
- package/dist/_chunks/_presets/iis.mjs +0 -194
- package/dist/_chunks/_presets/index.mjs +0 -62
- package/dist/_chunks/_presets/koyeb.mjs +0 -14
- package/dist/_chunks/_presets/netlify.mjs +0 -241
- package/dist/_chunks/_presets/node.mjs +0 -54
- package/dist/_chunks/_presets/platform.mjs +0 -14
- package/dist/_chunks/_presets/render.mjs +0 -14
- package/dist/_chunks/_presets/standard.mjs +0 -23
- package/dist/_chunks/_presets/stormkit.mjs +0 -18
- package/dist/_chunks/_presets/vercel.mjs +0 -375
- package/dist/_chunks/_presets/winterjs.mjs +0 -22
- package/dist/_chunks/_presets/zeabur.mjs +0 -69
- package/dist/_chunks/_presets/zerops.mjs +0 -27
- package/dist/_chunks/app.mjs +0 -600
- package/dist/_chunks/builder.mjs +0 -648
- package/dist/_chunks/server.mjs +0 -256
- package/dist/_cli/build.mjs +0 -49
- package/dist/_cli/common.mjs +0 -13
- package/dist/_cli/dev.mjs +0 -121
- package/dist/_cli/index.mjs +0 -16
- package/dist/_cli/list.mjs +0 -33
- package/dist/_cli/prepare.mjs +0 -23
- package/dist/_cli/run.mjs +0 -59
- package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +0 -21
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
- package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
- package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
- /package/lib/{indexd.mts → index.d.mts} +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { T as resolve, _ as dirname, b as join, v as extname, w as relative } from "../_libs/c12.mjs";
|
|
2
|
+
import { t as glob } from "../_libs/tinyglobby.mjs";
|
|
3
|
+
import { n as a } from "../_libs/std-env.mjs";
|
|
4
|
+
import { i as snapshotStorage, t as runParallel } from "./B5ooyfLk.mjs";
|
|
5
|
+
import { t as src_default } from "../_libs/mime.mjs";
|
|
6
|
+
import { t as gzipSize } from "../_libs/gzip-size.mjs";
|
|
7
|
+
import { t as prettyBytes } from "../_libs/pretty-bytes.mjs";
|
|
8
|
+
import { upperFirst } from "scule";
|
|
9
|
+
import { promises } from "node:fs";
|
|
10
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
11
|
+
import { colors } from "consola/utils";
|
|
12
|
+
|
|
13
|
+
//#region src/build/plugins/raw.ts
|
|
14
|
+
const HELPER_ID = "\0raw-helpers";
|
|
15
|
+
function raw(opts = {}) {
|
|
16
|
+
const extensions = new Set([
|
|
17
|
+
".md",
|
|
18
|
+
".mdx",
|
|
19
|
+
".txt",
|
|
20
|
+
".css",
|
|
21
|
+
".htm",
|
|
22
|
+
".html",
|
|
23
|
+
".sql",
|
|
24
|
+
...opts.extensions || []
|
|
25
|
+
]);
|
|
26
|
+
return {
|
|
27
|
+
name: "raw",
|
|
28
|
+
async resolveId(id, importer, resolveOpts) {
|
|
29
|
+
if (id === HELPER_ID) return id;
|
|
30
|
+
if (id[0] === "\0") return;
|
|
31
|
+
const withRawSpecifier = id.startsWith("raw:");
|
|
32
|
+
if (withRawSpecifier) id = id.slice(4);
|
|
33
|
+
if (!withRawSpecifier && !extensions.has(extname(id))) return;
|
|
34
|
+
const resolvedId = (await this.resolve(id, importer, resolveOpts))?.id;
|
|
35
|
+
if (!resolvedId || resolvedId.startsWith("\0")) return resolvedId;
|
|
36
|
+
if (!withRawSpecifier && !extensions.has(extname(resolvedId))) return;
|
|
37
|
+
return { id: "\0raw:" + resolvedId };
|
|
38
|
+
},
|
|
39
|
+
load(id) {
|
|
40
|
+
if (id === HELPER_ID) return getHelpers();
|
|
41
|
+
if (id.startsWith("\0raw:")) return promises.readFile(id.slice(5), isBinary(id) ? "binary" : "utf8");
|
|
42
|
+
},
|
|
43
|
+
transform(code, id) {
|
|
44
|
+
if (!id.startsWith("\0raw:")) return;
|
|
45
|
+
if (isBinary(id)) return {
|
|
46
|
+
code: `// ROLLUP_NO_REPLACE \n import {base64ToUint8Array } from "${HELPER_ID}" \n export default base64ToUint8Array("${Buffer.from(code, "binary").toString("base64")}")`,
|
|
47
|
+
map: null
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
code: `// ROLLUP_NO_REPLACE \n export default ${JSON.stringify(code)}`,
|
|
51
|
+
map: null,
|
|
52
|
+
moduleType: "js"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function isBinary(id) {
|
|
58
|
+
const idMime = src_default.getType(id) || "";
|
|
59
|
+
if (idMime.startsWith("text/")) return false;
|
|
60
|
+
if (/application\/(json|sql|xml|yaml)/.test(idMime)) return false;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
function getHelpers() {
|
|
64
|
+
return String.raw`
|
|
65
|
+
export function base64ToUint8Array(str) {
|
|
66
|
+
const data = atob(str);
|
|
67
|
+
const size = data.length;
|
|
68
|
+
const bytes = new Uint8Array(size);
|
|
69
|
+
for (let i = 0; i < size; i++) {
|
|
70
|
+
bytes[i] = data.charCodeAt(i);
|
|
71
|
+
}
|
|
72
|
+
return bytes;
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/utils/nitro.ts
|
|
79
|
+
function nitroServerName(nitro) {
|
|
80
|
+
return nitro.options.framework.name === "nitro" ? "Nitro Server" : `${upperFirst(nitro.options.framework.name)} Nitro server`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/utils/fs-tree.ts
|
|
85
|
+
async function generateFSTree(dir, options = {}) {
|
|
86
|
+
if (a) return;
|
|
87
|
+
const files = await glob("**/*.*", {
|
|
88
|
+
cwd: dir,
|
|
89
|
+
ignore: ["*.map"]
|
|
90
|
+
});
|
|
91
|
+
const items = [];
|
|
92
|
+
await runParallel(new Set(files), async (file) => {
|
|
93
|
+
const path = resolve(dir, file);
|
|
94
|
+
const src = await promises.readFile(path);
|
|
95
|
+
const size = src.byteLength;
|
|
96
|
+
const gzip = options.compressedSizes ? await gzipSize(src) : 0;
|
|
97
|
+
items.push({
|
|
98
|
+
file,
|
|
99
|
+
path,
|
|
100
|
+
size,
|
|
101
|
+
gzip
|
|
102
|
+
});
|
|
103
|
+
}, { concurrency: 10 });
|
|
104
|
+
items.sort((a$1, b) => a$1.path.localeCompare(b.path));
|
|
105
|
+
let totalSize = 0;
|
|
106
|
+
let totalGzip = 0;
|
|
107
|
+
let totalNodeModulesSize = 0;
|
|
108
|
+
let totalNodeModulesGzip = 0;
|
|
109
|
+
let treeText = "";
|
|
110
|
+
for (const [index, item] of items.entries()) {
|
|
111
|
+
let dir$1 = dirname(item.file);
|
|
112
|
+
if (dir$1 === ".") dir$1 = "";
|
|
113
|
+
const rpath = relative(process.cwd(), item.path);
|
|
114
|
+
const treeChar = index === items.length - 1 ? "└─" : "├─";
|
|
115
|
+
if (item.file.includes("node_modules")) {
|
|
116
|
+
totalNodeModulesSize += item.size;
|
|
117
|
+
totalNodeModulesGzip += item.gzip;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
treeText += colors.gray(` ${treeChar} ${rpath} (${prettyBytes(item.size)})`);
|
|
121
|
+
if (options.compressedSizes) treeText += colors.gray(` (${prettyBytes(item.gzip)} gzip)`);
|
|
122
|
+
treeText += "\n";
|
|
123
|
+
totalSize += item.size;
|
|
124
|
+
totalGzip += item.gzip;
|
|
125
|
+
}
|
|
126
|
+
treeText += `${colors.cyan("Σ Total size:")} ${prettyBytes(totalSize + totalNodeModulesSize)}`;
|
|
127
|
+
if (options.compressedSizes) treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
|
|
128
|
+
treeText += "\n";
|
|
129
|
+
return treeText;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/build/snapshot.ts
|
|
134
|
+
async function snapshot(nitro) {
|
|
135
|
+
if (nitro.options.bundledStorage.length === 0 || nitro.options.preset === "nitro-prerender") return;
|
|
136
|
+
const storageDir = resolve(nitro.options.buildDir, "snapshot");
|
|
137
|
+
nitro.options.serverAssets.push({
|
|
138
|
+
baseName: "nitro:bundled",
|
|
139
|
+
dir: storageDir
|
|
140
|
+
});
|
|
141
|
+
const data = await snapshotStorage(nitro);
|
|
142
|
+
await Promise.all(Object.entries(data).map(async ([path, contents]) => {
|
|
143
|
+
if (typeof contents !== "string") contents = JSON.stringify(contents);
|
|
144
|
+
const fsPath = join(storageDir, path.replace(/:/g, "/"));
|
|
145
|
+
await mkdir(dirname(fsPath), { recursive: true });
|
|
146
|
+
await writeFile(fsPath, contents, "utf8");
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
export { raw as i, generateFSTree as n, nitroServerName as r, snapshot as t };
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { s as __toESM } from "./DXMHy5ca.mjs";
|
|
2
|
+
import { T as resolve, _ as dirname, b as join, f as resolveModulePath, w as relative, y as isAbsolute } from "../_libs/c12.mjs";
|
|
3
|
+
import { c as parseNodeModulePath, s as lookupNodeModuleSubpath } from "../_libs/local-pkg.mjs";
|
|
4
|
+
import { c as toExports } from "../_libs/unimport.mjs";
|
|
5
|
+
import { t as glob } from "../_libs/tinyglobby.mjs";
|
|
6
|
+
import { t as klona } from "../_libs/klona.mjs";
|
|
7
|
+
import { t as getProperty } from "../_libs/dot-prop.mjs";
|
|
8
|
+
import { t as resolveAlias } from "../_libs/pathe.mjs";
|
|
9
|
+
import { n as resolveSchema, t as generateTypes } from "../_libs/untyped.mjs";
|
|
10
|
+
import consola$1 from "consola";
|
|
11
|
+
import { existsSync, promises } from "node:fs";
|
|
12
|
+
import { withBase, withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
13
|
+
import { mkdir, stat, writeFile } from "node:fs/promises";
|
|
14
|
+
import { defu } from "defu";
|
|
15
|
+
import { runtimeDir } from "nitro/runtime/meta";
|
|
16
|
+
import { colors } from "consola/utils";
|
|
17
|
+
import { builtinDrivers, createStorage } from "unstorage";
|
|
18
|
+
|
|
19
|
+
//#region src/utils/fs.ts
|
|
20
|
+
function prettyPath(p, highlight = true) {
|
|
21
|
+
p = relative(process.cwd(), p);
|
|
22
|
+
return highlight ? colors.cyan(p) : p;
|
|
23
|
+
}
|
|
24
|
+
function resolveNitroPath(path, nitroOptions, base) {
|
|
25
|
+
if (typeof path !== "string") throw new TypeError("Invalid path: " + path);
|
|
26
|
+
path = _compilePathTemplate(path)(nitroOptions);
|
|
27
|
+
for (const base$1 in nitroOptions.alias) if (path.startsWith(base$1)) path = nitroOptions.alias[base$1] + path.slice(base$1.length);
|
|
28
|
+
return resolve(base || nitroOptions.srcDir, path);
|
|
29
|
+
}
|
|
30
|
+
function _compilePathTemplate(contents) {
|
|
31
|
+
return (params) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
|
|
32
|
+
const val = getProperty(params, match);
|
|
33
|
+
if (!val) consola$1.warn(`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`);
|
|
34
|
+
return val || `${match}`;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async function writeFile$1(file, contents, log = false) {
|
|
38
|
+
await mkdir(dirname(file), { recursive: true });
|
|
39
|
+
await writeFile(file, contents, typeof contents === "string" ? "utf8" : void 0);
|
|
40
|
+
if (log) consola$1.info("Generated", prettyPath(file));
|
|
41
|
+
}
|
|
42
|
+
async function isDirectory(path) {
|
|
43
|
+
try {
|
|
44
|
+
return (await stat(path)).isDirectory();
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/scan.ts
|
|
52
|
+
const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
53
|
+
const suffixRegex = /(\.(?<method>connect|delete|get|head|options|patch|post|put|trace))?(\.(?<env>dev|prod|prerender))?$/;
|
|
54
|
+
async function scanAndSyncOptions(nitro) {
|
|
55
|
+
const scannedPlugins = await scanPlugins(nitro);
|
|
56
|
+
for (const plugin of scannedPlugins) if (!nitro.options.plugins.includes(plugin)) nitro.options.plugins.push(plugin);
|
|
57
|
+
if (nitro.options.experimental.tasks) {
|
|
58
|
+
const scannedTasks = await scanTasks(nitro);
|
|
59
|
+
for (const scannedTask of scannedTasks) if (scannedTask.name in nitro.options.tasks) {
|
|
60
|
+
if (!nitro.options.tasks[scannedTask.name].handler) nitro.options.tasks[scannedTask.name].handler = scannedTask.handler;
|
|
61
|
+
} else nitro.options.tasks[scannedTask.name] = {
|
|
62
|
+
handler: scannedTask.handler,
|
|
63
|
+
description: ""
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const scannedModules = await scanModules(nitro);
|
|
67
|
+
nitro.options.modules = nitro.options.modules || [];
|
|
68
|
+
for (const modPath of scannedModules) if (!nitro.options.modules.includes(modPath)) nitro.options.modules.push(modPath);
|
|
69
|
+
}
|
|
70
|
+
async function scanHandlers(nitro) {
|
|
71
|
+
const middleware = await scanMiddleware(nitro);
|
|
72
|
+
const handlers = await Promise.all([scanServerRoutes(nitro, nitro.options.apiDir || "api", nitro.options.apiBaseURL || "/api"), scanServerRoutes(nitro, nitro.options.routesDir || "routes")]).then((r) => r.flat());
|
|
73
|
+
nitro.scannedHandlers = [...middleware, ...handlers.filter((h, index, array) => {
|
|
74
|
+
return array.findIndex((h2) => h.route === h2.route && h.method === h2.method && h.env === h2.env) === index;
|
|
75
|
+
})];
|
|
76
|
+
return handlers;
|
|
77
|
+
}
|
|
78
|
+
async function scanMiddleware(nitro) {
|
|
79
|
+
return (await scanFiles(nitro, "middleware")).map((file) => {
|
|
80
|
+
return {
|
|
81
|
+
route: "/**",
|
|
82
|
+
middleware: true,
|
|
83
|
+
handler: file.fullPath
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async function scanServerRoutes(nitro, dir, prefix = "/") {
|
|
88
|
+
return (await scanFiles(nitro, dir)).map((file) => {
|
|
89
|
+
let route = file.path.replace(/\.[A-Za-z]+$/, "").replace(/\(([^(/\\]+)\)[/\\]/g, "").replace(/\[\.{3}]/g, "**").replace(/\[\.{3}(\w+)]/g, "**:$1").replace(/\[([^/\]]+)]/g, ":$1");
|
|
90
|
+
route = withLeadingSlash(withoutTrailingSlash(withBase(route, prefix)));
|
|
91
|
+
const suffixMatch = route.match(suffixRegex);
|
|
92
|
+
let method;
|
|
93
|
+
let env;
|
|
94
|
+
if (suffixMatch?.index && suffixMatch?.index >= 0) {
|
|
95
|
+
route = route.slice(0, suffixMatch.index);
|
|
96
|
+
method = suffixMatch.groups?.method;
|
|
97
|
+
env = suffixMatch.groups?.env;
|
|
98
|
+
}
|
|
99
|
+
route = route.replace(/\/index$/, "") || "/";
|
|
100
|
+
return {
|
|
101
|
+
handler: file.fullPath,
|
|
102
|
+
lazy: true,
|
|
103
|
+
middleware: false,
|
|
104
|
+
route,
|
|
105
|
+
method,
|
|
106
|
+
env
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async function scanPlugins(nitro) {
|
|
111
|
+
return (await scanFiles(nitro, "plugins")).map((f) => f.fullPath);
|
|
112
|
+
}
|
|
113
|
+
async function scanTasks(nitro) {
|
|
114
|
+
return (await scanFiles(nitro, "tasks")).map((f) => {
|
|
115
|
+
return {
|
|
116
|
+
name: f.path.replace(/\/index$/, "").replace(/\.[A-Za-z]+$/, "").replace(/\//g, ":"),
|
|
117
|
+
handler: f.fullPath
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
async function scanModules(nitro) {
|
|
122
|
+
return (await scanFiles(nitro, "modules")).map((f) => f.fullPath);
|
|
123
|
+
}
|
|
124
|
+
async function scanFiles(nitro, name) {
|
|
125
|
+
return await Promise.all(nitro.options.scanDirs.map((dir) => scanDir(nitro, dir, name))).then((r) => r.flat());
|
|
126
|
+
}
|
|
127
|
+
async function scanDir(nitro, dir, name) {
|
|
128
|
+
return (await glob(join(name, GLOB_SCAN_PATTERN), {
|
|
129
|
+
cwd: dir,
|
|
130
|
+
dot: true,
|
|
131
|
+
ignore: nitro.options.ignore,
|
|
132
|
+
absolute: true
|
|
133
|
+
}).catch((error) => {
|
|
134
|
+
if (error?.code === "ENOTDIR") {
|
|
135
|
+
nitro.logger.warn(`Ignoring \`${join(dir, name)}\`. It must be a directory.`);
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
})).map((fullPath) => {
|
|
140
|
+
return {
|
|
141
|
+
fullPath,
|
|
142
|
+
path: relative(join(dir, name), fullPath)
|
|
143
|
+
};
|
|
144
|
+
}).sort((a, b) => a.path.localeCompare(b.path));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/utils/storage.ts
|
|
149
|
+
async function createStorage$1(nitro) {
|
|
150
|
+
const storage = createStorage();
|
|
151
|
+
const mounts = klona({
|
|
152
|
+
...nitro.options.storage,
|
|
153
|
+
...nitro.options.devStorage
|
|
154
|
+
});
|
|
155
|
+
for (const [path, opts] of Object.entries(mounts)) if (opts.driver) {
|
|
156
|
+
const driver = await import(builtinDrivers[opts.driver] || opts.driver).then((r) => r.default || r);
|
|
157
|
+
storage.mount(path, driver(opts));
|
|
158
|
+
} else nitro.logger.warn(`No \`driver\` set for storage mount point "${path}".`);
|
|
159
|
+
return storage;
|
|
160
|
+
}
|
|
161
|
+
async function snapshotStorage(nitro) {
|
|
162
|
+
const data = {};
|
|
163
|
+
const allKeys = [...new Set(await Promise.all(nitro.options.bundledStorage.map((base) => nitro.storage.getKeys(base))).then((r) => r.flat()))];
|
|
164
|
+
await Promise.all(allKeys.map(async (key) => {
|
|
165
|
+
data[key] = await nitro.storage.getItem(key);
|
|
166
|
+
}));
|
|
167
|
+
return data;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/build/types.ts
|
|
172
|
+
async function writeTypes(nitro) {
|
|
173
|
+
const types = { routes: {} };
|
|
174
|
+
const typesDir = resolve(nitro.options.buildDir, "types");
|
|
175
|
+
const middleware = [...nitro.scannedHandlers, ...nitro.options.handlers];
|
|
176
|
+
for (const mw of middleware) {
|
|
177
|
+
if (typeof mw.handler !== "string" || !mw.route) continue;
|
|
178
|
+
const relativePath = relative(typesDir, resolveNitroPath(mw.handler, nitro.options)).replace(/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/, "");
|
|
179
|
+
const method = mw.method || "default";
|
|
180
|
+
types.routes[mw.route] ??= {};
|
|
181
|
+
types.routes[mw.route][method] ??= [];
|
|
182
|
+
types.routes[mw.route][method].push(`Simplify<Serialize<Awaited<ReturnType<typeof import('${relativePath}').default>>>>`);
|
|
183
|
+
}
|
|
184
|
+
let autoImportedTypes = [];
|
|
185
|
+
let autoImportExports = "";
|
|
186
|
+
if (nitro.unimport) {
|
|
187
|
+
await nitro.unimport.init();
|
|
188
|
+
const allImports = await nitro.unimport.getImports();
|
|
189
|
+
autoImportExports = toExports(allImports).replace(/#internal\/nitro/g, relative(typesDir, runtimeDir));
|
|
190
|
+
const resolvedImportPathMap = /* @__PURE__ */ new Map();
|
|
191
|
+
for (const i of allImports) {
|
|
192
|
+
const from = i.typeFrom || i.from;
|
|
193
|
+
if (resolvedImportPathMap.has(from)) continue;
|
|
194
|
+
let path = resolveAlias(from, nitro.options.alias);
|
|
195
|
+
if (!isAbsolute(path)) {
|
|
196
|
+
const resolvedPath = resolveModulePath(from, {
|
|
197
|
+
try: true,
|
|
198
|
+
from: nitro.options.nodeModulesDirs,
|
|
199
|
+
conditions: [
|
|
200
|
+
"type",
|
|
201
|
+
"node",
|
|
202
|
+
"import"
|
|
203
|
+
],
|
|
204
|
+
suffixes: ["", "/index"],
|
|
205
|
+
extensions: [
|
|
206
|
+
".mjs",
|
|
207
|
+
".cjs",
|
|
208
|
+
".js",
|
|
209
|
+
".mts",
|
|
210
|
+
".cts",
|
|
211
|
+
".ts"
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
if (resolvedPath) {
|
|
215
|
+
const { dir, name } = parseNodeModulePath(resolvedPath);
|
|
216
|
+
if (!dir || !name) path = resolvedPath;
|
|
217
|
+
else path = join(dir, name, await lookupNodeModuleSubpath(resolvedPath) || "");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (existsSync(path) && !await isDirectory(path)) path = path.replace(/\.[a-z]+$/, "");
|
|
221
|
+
if (isAbsolute(path)) path = relative(typesDir, path);
|
|
222
|
+
resolvedImportPathMap.set(from, path);
|
|
223
|
+
}
|
|
224
|
+
autoImportedTypes = [nitro.options.imports && nitro.options.imports.autoImport !== false ? (await nitro.unimport.generateTypeDeclarations({
|
|
225
|
+
exportHelper: false,
|
|
226
|
+
resolvePath: (i) => {
|
|
227
|
+
const from = i.typeFrom || i.from;
|
|
228
|
+
return resolvedImportPathMap.get(from) ?? from;
|
|
229
|
+
}
|
|
230
|
+
})).trim() : ""];
|
|
231
|
+
}
|
|
232
|
+
const generateRoutes = () => [
|
|
233
|
+
"// Generated by nitro",
|
|
234
|
+
"import type { Serialize, Simplify } from \"nitro/types\";",
|
|
235
|
+
"declare module \"nitro/types\" {",
|
|
236
|
+
" type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T",
|
|
237
|
+
" interface InternalApi {",
|
|
238
|
+
...Object.entries(types.routes).map(([path, methods]) => [
|
|
239
|
+
` '${path}': {`,
|
|
240
|
+
...Object.entries(methods).map(([method, types$1]) => ` '${method}': ${types$1.join(" | ")}`),
|
|
241
|
+
" }"
|
|
242
|
+
].join("\n")),
|
|
243
|
+
" }",
|
|
244
|
+
"}",
|
|
245
|
+
"export {}"
|
|
246
|
+
];
|
|
247
|
+
const config = [
|
|
248
|
+
"// Generated by nitro",
|
|
249
|
+
`declare module "nitro/types" {`,
|
|
250
|
+
nitro.options.typescript.generateRuntimeConfigTypes ? generateTypes(await resolveSchema(Object.fromEntries(Object.entries(nitro.options.runtimeConfig).filter(([key]) => !["app", "nitro"].includes(key)))), {
|
|
251
|
+
interfaceName: "NitroRuntimeConfig",
|
|
252
|
+
addExport: false,
|
|
253
|
+
addDefaults: false,
|
|
254
|
+
allowExtraKeys: false,
|
|
255
|
+
indentation: 2
|
|
256
|
+
}) : "",
|
|
257
|
+
`}`,
|
|
258
|
+
"export {}"
|
|
259
|
+
];
|
|
260
|
+
const declarations = [
|
|
261
|
+
"/// <reference path=\"./nitro-routes.d.ts\" />",
|
|
262
|
+
"/// <reference path=\"./nitro-config.d.ts\" />",
|
|
263
|
+
"/// <reference path=\"./nitro-imports.d.ts\" />"
|
|
264
|
+
];
|
|
265
|
+
const buildFiles = [];
|
|
266
|
+
buildFiles.push({
|
|
267
|
+
path: join(typesDir, "nitro-routes.d.ts"),
|
|
268
|
+
contents: () => generateRoutes().join("\n")
|
|
269
|
+
});
|
|
270
|
+
buildFiles.push({
|
|
271
|
+
path: join(typesDir, "nitro-config.d.ts"),
|
|
272
|
+
contents: config.join("\n")
|
|
273
|
+
});
|
|
274
|
+
buildFiles.push({
|
|
275
|
+
path: join(typesDir, "nitro-imports.d.ts"),
|
|
276
|
+
contents: [...autoImportedTypes, autoImportExports || "export {}"].join("\n")
|
|
277
|
+
});
|
|
278
|
+
buildFiles.push({
|
|
279
|
+
path: join(typesDir, "nitro.d.ts"),
|
|
280
|
+
contents: declarations.join("\n")
|
|
281
|
+
});
|
|
282
|
+
if (nitro.options.typescript.generateTsConfig) {
|
|
283
|
+
const tsConfigPath = resolve(nitro.options.buildDir, nitro.options.typescript.tsconfigPath);
|
|
284
|
+
const tsconfigDir = dirname(tsConfigPath);
|
|
285
|
+
const tsConfig = defu(nitro.options.typescript.tsConfig, {
|
|
286
|
+
compilerOptions: {
|
|
287
|
+
esModuleInterop: true,
|
|
288
|
+
allowSyntheticDefaultImports: true,
|
|
289
|
+
skipLibCheck: true,
|
|
290
|
+
target: "ESNext",
|
|
291
|
+
allowJs: true,
|
|
292
|
+
resolveJsonModule: true,
|
|
293
|
+
moduleDetection: "force",
|
|
294
|
+
isolatedModules: true,
|
|
295
|
+
verbatimModuleSyntax: true,
|
|
296
|
+
allowImportingTsExtensions: true,
|
|
297
|
+
strict: nitro.options.typescript.strict,
|
|
298
|
+
noUncheckedIndexedAccess: true,
|
|
299
|
+
noImplicitOverride: true,
|
|
300
|
+
forceConsistentCasingInFileNames: true,
|
|
301
|
+
module: "Preserve",
|
|
302
|
+
jsx: "preserve",
|
|
303
|
+
jsxFactory: "h",
|
|
304
|
+
jsxFragmentFactory: "Fragment",
|
|
305
|
+
paths: {
|
|
306
|
+
"#imports": [relativeWithDot(tsconfigDir, join(typesDir, "nitro-imports"))],
|
|
307
|
+
...nitro.options.typescript.internalPaths ? {
|
|
308
|
+
"nitro/runtime": [relativeWithDot(tsconfigDir, join(runtimeDir, "index"))],
|
|
309
|
+
"#internal/nitro": [relativeWithDot(tsconfigDir, join(runtimeDir, "index"))],
|
|
310
|
+
"nitro/runtime/*": [relativeWithDot(tsconfigDir, join(runtimeDir, "*"))],
|
|
311
|
+
"#internal/nitro/*": [relativeWithDot(tsconfigDir, join(runtimeDir, "*"))]
|
|
312
|
+
} : {}
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
include: [
|
|
316
|
+
relativeWithDot(tsconfigDir, join(typesDir, "nitro.d.ts")).replace(/^(?=[^.])/, "./"),
|
|
317
|
+
join(relativeWithDot(tsconfigDir, nitro.options.rootDir), "**/*"),
|
|
318
|
+
...nitro.options.srcDir === nitro.options.rootDir ? [] : [join(relativeWithDot(tsconfigDir, nitro.options.srcDir), "**/*")]
|
|
319
|
+
]
|
|
320
|
+
});
|
|
321
|
+
for (const alias in tsConfig.compilerOptions.paths) {
|
|
322
|
+
const paths = await Promise.all(tsConfig.compilerOptions.paths[alias].map(async (path) => {
|
|
323
|
+
if (!isAbsolute(path)) return path;
|
|
324
|
+
return relativeWithDot(tsconfigDir, (await promises.stat(path).catch(() => null))?.isFile() ? path.replace(/(?<=\w)\.\w+$/g, "") : path);
|
|
325
|
+
}));
|
|
326
|
+
tsConfig.compilerOptions.paths[alias] = [...new Set(paths)];
|
|
327
|
+
}
|
|
328
|
+
tsConfig.include = [...new Set(tsConfig.include.map((p) => isAbsolute(p) ? relativeWithDot(tsconfigDir, p) : p))];
|
|
329
|
+
if (tsConfig.exclude) tsConfig.exclude = [...new Set(tsConfig.exclude.map((p) => isAbsolute(p) ? relativeWithDot(tsconfigDir, p) : p))];
|
|
330
|
+
types.tsConfig = tsConfig;
|
|
331
|
+
buildFiles.push({
|
|
332
|
+
path: tsConfigPath,
|
|
333
|
+
contents: () => JSON.stringify(tsConfig, null, 2)
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
await nitro.hooks.callHook("types:extend", types);
|
|
337
|
+
await Promise.all(buildFiles.map(async (file) => {
|
|
338
|
+
await writeFile$1(resolve(nitro.options.buildDir, file.path), typeof file.contents === "string" ? file.contents : file.contents());
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
const RELATIVE_RE = /^\.{1,2}\//;
|
|
342
|
+
function relativeWithDot(from, to) {
|
|
343
|
+
const rel = relative(from, to);
|
|
344
|
+
return RELATIVE_RE.test(rel) ? rel : "./" + rel;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/utils/parallel.ts
|
|
349
|
+
async function runParallel(inputs, cb, opts) {
|
|
350
|
+
const tasks = /* @__PURE__ */ new Set();
|
|
351
|
+
function queueNext() {
|
|
352
|
+
const route = inputs.values().next().value;
|
|
353
|
+
if (!route) return;
|
|
354
|
+
inputs.delete(route);
|
|
355
|
+
const task = (opts.interval ? new Promise((resolve$1) => setTimeout(resolve$1, opts.interval)) : Promise.resolve()).then(() => cb(route)).catch((error) => {
|
|
356
|
+
console.error(error);
|
|
357
|
+
});
|
|
358
|
+
tasks.add(task);
|
|
359
|
+
return task.then(() => {
|
|
360
|
+
tasks.delete(task);
|
|
361
|
+
if (inputs.size > 0) return refillQueue();
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function refillQueue() {
|
|
365
|
+
const workers = Math.min(opts.concurrency - tasks.size, inputs.size);
|
|
366
|
+
return Promise.all(Array.from({ length: workers }, () => queueNext()));
|
|
367
|
+
}
|
|
368
|
+
await refillQueue();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
//#endregion
|
|
372
|
+
export { scanAndSyncOptions as a, prettyPath as c, snapshotStorage as i, resolveNitroPath as l, writeTypes as n, scanHandlers as o, createStorage$1 as r, isDirectory as s, runParallel as t, writeFile$1 as u };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __esm = (fn, res) => function() {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
};
|
|
13
|
+
var __commonJS = (cb, mod) => function() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __export = (all) => {
|
|
17
|
+
let target = {};
|
|
18
|
+
for (var name in all) __defProp(target, name, {
|
|
19
|
+
get: all[name],
|
|
20
|
+
enumerable: true
|
|
21
|
+
});
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
26
|
+
key = keys[i];
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
28
|
+
get: ((k) => from[k]).bind(null, key),
|
|
29
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
35
|
+
value: mod,
|
|
36
|
+
enumerable: true
|
|
37
|
+
}) : target, mod));
|
|
38
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
+
var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
|
|
40
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { __toCommonJS as a, __require as i, __esm as n, __toDynamicImportESM as o, __export as r, __toESM as s, __commonJS as t };
|
package/dist/_dev.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTTPHandler } from "h3";
|
|
2
|
+
import { Nitro } from "nitro/types";
|
|
3
|
+
|
|
4
|
+
//#region src/dev/app.d.ts
|
|
5
|
+
declare class NitroDevApp {
|
|
6
|
+
#private;
|
|
7
|
+
nitro: Nitro;
|
|
8
|
+
fetch: (req: Request) => Response | Promise<Response>;
|
|
9
|
+
constructor(nitro: Nitro, catchAllHandler?: HTTPHandler);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { NitroDevApp as t };
|