@depup/nitro 3.0.260311-beta-depup.0
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/LICENSE +27 -0
- package/README.md +32 -0
- package/changes.json +14 -0
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +29361 -0
- package/dist/_build/rolldown.mjs +173 -0
- package/dist/_build/rollup.mjs +194 -0
- package/dist/_build/vite.build.mjs +18 -0
- package/dist/_chunks/nitro.mjs +1159 -0
- package/dist/_chunks/nitro2.mjs +102 -0
- package/dist/_chunks/nitro3.mjs +129 -0
- package/dist/_chunks/utils.mjs +272 -0
- package/dist/_common.mjs +35 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +519 -0
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +3 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +4 -0
- package/dist/_libs/_7.mjs +5 -0
- package/dist/_libs/c12+rc9.mjs +812 -0
- package/dist/_libs/c12+readdirp+chokidar.d.mts +230 -0
- package/dist/_libs/citty.mjs +361 -0
- package/dist/_libs/commondir+is-reference.mjs +1311 -0
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/compatx.mjs +45 -0
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/escape-string-regexp.mjs +7 -0
- package/dist/_libs/estree+pluginutils.d.mts +241 -0
- package/dist/_libs/estree-walker.mjs +184 -0
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +1949 -0
- package/dist/_libs/httpxy.d.mts +82 -0
- package/dist/_libs/httpxy.mjs +671 -0
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +37 -0
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/nypm+tinyexec.mjs +845 -0
- package/dist/_libs/perfect-debounce.mjs +88 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-inject.mjs +131 -0
- package/dist/_libs/plugin-json.mjs +34 -0
- package/dist/_libs/pluginutils.mjs +646 -0
- package/dist/_libs/readdirp+chokidar.mjs +1606 -0
- package/dist/_libs/remapping.mjs +115 -0
- package/dist/_libs/resolve-uri+gen-mapping.mjs +442 -0
- package/dist/_libs/rou3.d.mts +44 -0
- package/dist/_libs/rou3.mjs +496 -0
- package/dist/_libs/std-env.d.mts +12 -0
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +813 -0
- package/dist/_libs/ultrahtml.mjs +127 -0
- package/dist/_libs/unimport+unplugin.mjs +1684 -0
- package/dist/_libs/unplugin+unimport.d.mts +423 -0
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +1759 -0
- package/dist/builder.d.mts +64 -0
- package/dist/builder.mjs +15 -0
- package/dist/cli/_chunks/build.mjs +47 -0
- package/dist/cli/_chunks/common.mjs +14 -0
- package/dist/cli/_chunks/deploy.mjs +40 -0
- package/dist/cli/_chunks/dev.mjs +62 -0
- package/dist/cli/_chunks/docs.mjs +30 -0
- package/dist/cli/_chunks/list.mjs +25 -0
- package/dist/cli/_chunks/prepare.mjs +17 -0
- package/dist/cli/_chunks/preview.mjs +51 -0
- package/dist/cli/_chunks/run.mjs +53 -0
- package/dist/cli/_chunks/task.mjs +14 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +22 -0
- package/dist/node_modules/@poppinss/colors/build/index.js +139 -0
- package/dist/node_modules/@poppinss/colors/package.json +118 -0
- package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +725 -0
- package/dist/node_modules/@poppinss/dumper/package.json +122 -0
- package/dist/node_modules/@poppinss/exception/build/index.js +44 -0
- package/dist/node_modules/@poppinss/exception/package.json +109 -0
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +1354 -0
- package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
- package/dist/node_modules/@sindresorhus/is/package.json +81 -0
- package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
- package/dist/node_modules/@speed-highlight/core/package.json +94 -0
- package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
- package/dist/node_modules/cookie-es/package.json +37 -0
- package/dist/node_modules/croner/dist/croner.js +1 -0
- package/dist/node_modules/croner/package.json +73 -0
- package/dist/node_modules/defu/dist/defu.mjs +69 -0
- package/dist/node_modules/defu/package.json +43 -0
- package/dist/node_modules/destr/dist/index.mjs +72 -0
- package/dist/node_modules/destr/package.json +47 -0
- package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
- package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
- package/dist/node_modules/error-stack-parser-es/package.json +83 -0
- package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
- package/dist/node_modules/get-port-please/package.json +39 -0
- package/dist/node_modules/kleur/index.mjs +110 -0
- package/dist/node_modules/kleur/package.json +51 -0
- package/dist/node_modules/rendu/dist/index.mjs +380 -0
- package/dist/node_modules/rendu/package.json +47 -0
- package/dist/node_modules/scule/dist/index.mjs +80 -0
- package/dist/node_modules/scule/package.json +43 -0
- package/dist/node_modules/source-map/lib/array-set.js +100 -0
- package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
- package/dist/node_modules/source-map/lib/base64.js +19 -0
- package/dist/node_modules/source-map/lib/binary-search.js +113 -0
- package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
- package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
- package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
- package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
- package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
- package/dist/node_modules/source-map/lib/source-node.js +430 -0
- package/dist/node_modules/source-map/lib/url.js +13 -0
- package/dist/node_modules/source-map/lib/util.js +444 -0
- package/dist/node_modules/source-map/lib/wasm.js +138 -0
- package/dist/node_modules/source-map/package.json +79 -0
- package/dist/node_modules/source-map/source-map.js +10 -0
- package/dist/node_modules/supports-color/index.js +202 -0
- package/dist/node_modules/supports-color/package.json +64 -0
- package/dist/node_modules/ufo/dist/index.mjs +645 -0
- package/dist/node_modules/ufo/package.json +48 -0
- package/dist/node_modules/unctx/dist/index.mjs +131 -0
- package/dist/node_modules/unctx/package.json +67 -0
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +212 -0
- package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
- package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
- package/dist/node_modules/youch/build/public/error_info/style.css +145 -0
- package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
- package/dist/node_modules/youch/build/public/error_stack/script.js +72 -0
- package/dist/node_modules/youch/build/public/error_stack/style.css +219 -0
- package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
- package/dist/node_modules/youch/build/public/header/script.js +14 -0
- package/dist/node_modules/youch/build/public/header/style.css +56 -0
- package/dist/node_modules/youch/build/public/layout/script.js +12 -0
- package/dist/node_modules/youch/build/public/layout/style.css +435 -0
- package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
- package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
- package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
- package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
- package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
- package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
- package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
- package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
- package/dist/node_modules/youch/package.json +135 -0
- package/dist/node_modules/youch-core/build/index.js +316 -0
- package/dist/node_modules/youch-core/package.json +124 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +20 -0
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +15 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +23 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +14 -0
- package/dist/presets/aws-lambda/runtime/_utils.mjs +116 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +31 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
- package/dist/presets/azure/runtime/_utils.mjs +50 -0
- package/dist/presets/azure/runtime/azure-swa.mjs +30 -0
- package/dist/presets/bun/runtime/bun.mjs +40 -0
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +87 -0
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +72 -0
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +17 -0
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +39 -0
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +96 -0
- package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +19 -0
- package/dist/presets/deno/runtime/deno-server.mjs +39 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +20 -0
- package/dist/presets/netlify/runtime/netlify.mjs +20 -0
- package/dist/presets/node/runtime/node-cluster.mjs +54 -0
- package/dist/presets/node/runtime/node-middleware.mjs +14 -0
- package/dist/presets/node/runtime/node-server.mjs +47 -0
- package/dist/presets/standard/runtime/server.mjs +4 -0
- package/dist/presets/stormkit/runtime/stormkit.mjs +27 -0
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/isr.mjs +19 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +24 -0
- package/dist/presets/vercel/runtime/vercel.web.mjs +23 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +91 -0
- package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/app.d.mts +1 -0
- package/dist/runtime/app.mjs +1 -0
- package/dist/runtime/cache.d.mts +1 -0
- package/dist/runtime/cache.mjs +1 -0
- package/dist/runtime/config.d.mts +3 -0
- package/dist/runtime/config.mjs +4 -0
- package/dist/runtime/context.d.mts +1 -0
- package/dist/runtime/context.mjs +1 -0
- package/dist/runtime/database.d.mts +1 -0
- package/dist/runtime/database.mjs +1 -0
- package/dist/runtime/internal/app.d.mts +16 -0
- package/dist/runtime/internal/app.mjs +208 -0
- package/dist/runtime/internal/cache.d.mts +7 -0
- package/dist/runtime/internal/cache.mjs +41 -0
- package/dist/runtime/internal/context.d.mts +14 -0
- package/dist/runtime/internal/context.mjs +24 -0
- package/dist/runtime/internal/database.d.mts +2 -0
- package/dist/runtime/internal/database.mjs +12 -0
- package/dist/runtime/internal/empty.mjs +0 -0
- package/dist/runtime/internal/error/dev.d.mts +10 -0
- package/dist/runtime/internal/error/dev.mjs +121 -0
- package/dist/runtime/internal/error/hooks.d.mts +1 -0
- package/dist/runtime/internal/error/hooks.mjs +9 -0
- package/dist/runtime/internal/error/prod.d.mts +6 -0
- package/dist/runtime/internal/error/prod.mjs +40 -0
- package/dist/runtime/internal/error/utils.d.mts +8 -0
- package/dist/runtime/internal/error/utils.mjs +3 -0
- package/dist/runtime/internal/meta.d.mts +2 -0
- package/dist/runtime/internal/meta.mjs +3 -0
- package/dist/runtime/internal/plugin.d.mts +3 -0
- package/dist/runtime/internal/plugin.mjs +4 -0
- package/dist/runtime/internal/route-rules.d.mts +9 -0
- package/dist/runtime/internal/route-rules.mjs +72 -0
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
- package/dist/runtime/internal/routes/dev-tasks.mjs +25 -0
- package/dist/runtime/internal/routes/openapi.d.mts +3 -0
- package/dist/runtime/internal/routes/openapi.mjs +94 -0
- package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +19 -0
- package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
- package/dist/runtime/internal/routes/scalar.d.mts +3 -0
- package/dist/runtime/internal/routes/scalar.mjs +193 -0
- package/dist/runtime/internal/routes/swagger.d.mts +3 -0
- package/dist/runtime/internal/routes/swagger.mjs +42 -0
- package/dist/runtime/internal/runtime-config.d.mts +9 -0
- package/dist/runtime/internal/runtime-config.mjs +54 -0
- package/dist/runtime/internal/static.d.mts +3 -0
- package/dist/runtime/internal/static.mjs +67 -0
- package/dist/runtime/internal/storage.d.mts +2 -0
- package/dist/runtime/internal/storage.mjs +6 -0
- package/dist/runtime/internal/task.d.mts +19 -0
- package/dist/runtime/internal/task.mjs +69 -0
- package/dist/runtime/internal/vite/dev-entry.mjs +18 -0
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/internal/vite/ssr-renderer.mjs +6 -0
- package/dist/runtime/meta.d.mts +5 -0
- package/dist/runtime/meta.mjs +27 -0
- package/dist/runtime/nitro.d.mts +11 -0
- package/dist/runtime/nitro.mjs +34 -0
- package/dist/runtime/runtime-config.d.mts +1 -0
- package/dist/runtime/runtime-config.mjs +1 -0
- package/dist/runtime/storage.d.mts +1 -0
- package/dist/runtime/storage.mjs +1 -0
- package/dist/runtime/task.d.mts +1 -0
- package/dist/runtime/task.mjs +1 -0
- package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
- package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
- package/dist/runtime/virtual/database.d.mts +8 -0
- package/dist/runtime/virtual/database.mjs +2 -0
- package/dist/runtime/virtual/error-handler.d.mts +6 -0
- package/dist/runtime/virtual/error-handler.mjs +9 -0
- package/dist/runtime/virtual/feature-flags.d.mts +7 -0
- package/dist/runtime/virtual/feature-flags.mjs +7 -0
- package/dist/runtime/virtual/plugins.d.mts +3 -0
- package/dist/runtime/virtual/plugins.mjs +2 -0
- package/dist/runtime/virtual/polyfills.d.mts +3 -0
- package/dist/runtime/virtual/polyfills.mjs +2 -0
- package/dist/runtime/virtual/public-assets.d.mts +9 -0
- package/dist/runtime/virtual/public-assets.mjs +8 -0
- package/dist/runtime/virtual/renderer-template.d.mts +4 -0
- package/dist/runtime/virtual/renderer-template.mjs +7 -0
- package/dist/runtime/virtual/routing-meta.d.mts +7 -0
- package/dist/runtime/virtual/routing-meta.mjs +2 -0
- package/dist/runtime/virtual/routing.d.mts +8 -0
- package/dist/runtime/virtual/routing.mjs +11 -0
- package/dist/runtime/virtual/runtime-config.d.mts +3 -0
- package/dist/runtime/virtual/runtime-config.mjs +5 -0
- package/dist/runtime/virtual/server-assets.d.mts +7 -0
- package/dist/runtime/virtual/server-assets.mjs +12 -0
- package/dist/runtime/virtual/storage.d.mts +3 -0
- package/dist/runtime/virtual/storage.mjs +5 -0
- package/dist/runtime/virtual/tasks.d.mts +10 -0
- package/dist/runtime/virtual/tasks.mjs +3 -0
- package/dist/runtime/vite.d.mts +8 -0
- package/dist/runtime/vite.mjs +9 -0
- package/dist/types/index.d.mts +3010 -0
- package/dist/types/index.mjs +1 -0
- package/dist/vite.d.mts +52 -0
- package/dist/vite.mjs +740 -0
- package/lib/h3.d.mts +1 -0
- package/lib/h3.mjs +1 -0
- package/lib/tsconfig.json +27 -0
- package/lib/vite.types.d.mts +26 -0
- package/lib/vite.types.mjs +2 -0
- package/package.json +256 -0
- package/skills/nitro/SKILL.md +10 -0
- package/skills/nitro/docs/TOC.md +83 -0
- package/skills/nitro/docs/_navigation.json +679 -0
- package/skills/nitro/docs/config/index.md +1147 -0
- package/skills/nitro/docs/deploy/index.md +64 -0
- package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
- package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
- package/skills/nitro/docs/deploy/providers/aws.md +47 -0
- package/skills/nitro/docs/deploy/providers/azure.md +72 -0
- package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
- package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
- package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
- package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
- package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
- package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
- package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
- package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
- package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
- package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
- package/skills/nitro/docs/deploy/providers/iis.md +38 -0
- package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
- package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
- package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
- package/skills/nitro/docs/deploy/providers/render.md +37 -0
- package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
- package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
- package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
- package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
- package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
- package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
- package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
- package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
- package/skills/nitro/docs/docs/assets.md +166 -0
- package/skills/nitro/docs/docs/cache.md +408 -0
- package/skills/nitro/docs/docs/configuration.md +256 -0
- package/skills/nitro/docs/docs/database.md +185 -0
- package/skills/nitro/docs/docs/index.md +56 -0
- package/skills/nitro/docs/docs/lifecycle.md +204 -0
- package/skills/nitro/docs/docs/migration.md +215 -0
- package/skills/nitro/docs/docs/nightly.md +31 -0
- package/skills/nitro/docs/docs/plugins.md +164 -0
- package/skills/nitro/docs/docs/quick-start.md +110 -0
- package/skills/nitro/docs/docs/renderer.md +322 -0
- package/skills/nitro/docs/docs/routing.md +711 -0
- package/skills/nitro/docs/docs/server-entry.md +239 -0
- package/skills/nitro/docs/docs/storage.md +261 -0
- package/skills/nitro/docs/docs/tasks.md +277 -0
- package/skills/nitro/docs/examples/api-routes.md +145 -0
- package/skills/nitro/docs/examples/auto-imports.md +93 -0
- package/skills/nitro/docs/examples/cached-handler.md +81 -0
- package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
- package/skills/nitro/docs/examples/database.md +157 -0
- package/skills/nitro/docs/examples/elysia.md +70 -0
- package/skills/nitro/docs/examples/express.md +78 -0
- package/skills/nitro/docs/examples/fastify.md +79 -0
- package/skills/nitro/docs/examples/hello-world.md +68 -0
- package/skills/nitro/docs/examples/hono.md +74 -0
- package/skills/nitro/docs/examples/import-alias.md +100 -0
- package/skills/nitro/docs/examples/index.md +3 -0
- package/skills/nitro/docs/examples/middleware.md +91 -0
- package/skills/nitro/docs/examples/mono-jsx.md +68 -0
- package/skills/nitro/docs/examples/nano-jsx.md +70 -0
- package/skills/nitro/docs/examples/plugins.md +91 -0
- package/skills/nitro/docs/examples/renderer.md +113 -0
- package/skills/nitro/docs/examples/runtime-config.md +97 -0
- package/skills/nitro/docs/examples/server-fetch.md +87 -0
- package/skills/nitro/docs/examples/shiki.md +198 -0
- package/skills/nitro/docs/examples/virtual-routes.md +74 -0
- package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
- package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
- package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
- package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
- package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
- package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
- package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
- package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
- package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
- package/skills/nitro/docs/examples/vite-trpc.md +335 -0
- package/skills/nitro/docs/examples/websocket.md +282 -0
- package/skills/nitro/docs/index.md +121 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { M as glob, ct as join, ut as relative } from "../_build/common.mjs";
|
|
2
|
+
import { withBase, withLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
3
|
+
//#region src/scan.ts
|
|
4
|
+
const GLOB_SCAN_PATTERN = "**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}";
|
|
5
|
+
const suffixRegex = /(\.(?<method>connect|delete|get|head|options|patch|post|put|trace))?(\.(?<env>dev|prod|prerender))?$/;
|
|
6
|
+
async function scanAndSyncOptions(nitro) {
|
|
7
|
+
const scannedPlugins = await scanPlugins(nitro);
|
|
8
|
+
for (const plugin of scannedPlugins) if (!nitro.options.plugins.includes(plugin)) nitro.options.plugins.push(plugin);
|
|
9
|
+
if (nitro.options.experimental.tasks) {
|
|
10
|
+
const scannedTasks = await scanTasks(nitro);
|
|
11
|
+
for (const scannedTask of scannedTasks) if (scannedTask.name in nitro.options.tasks) {
|
|
12
|
+
if (!nitro.options.tasks[scannedTask.name].handler) nitro.options.tasks[scannedTask.name].handler = scannedTask.handler;
|
|
13
|
+
} else nitro.options.tasks[scannedTask.name] = {
|
|
14
|
+
handler: scannedTask.handler,
|
|
15
|
+
description: ""
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const scannedModules = await scanModules(nitro);
|
|
19
|
+
nitro.options.modules = nitro.options.modules || [];
|
|
20
|
+
for (const modPath of scannedModules) if (!nitro.options.modules.includes(modPath)) nitro.options.modules.push(modPath);
|
|
21
|
+
}
|
|
22
|
+
async function scanHandlers(nitro) {
|
|
23
|
+
const middleware = await scanMiddleware(nitro);
|
|
24
|
+
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());
|
|
25
|
+
const seenHandlers = /* @__PURE__ */ new Set();
|
|
26
|
+
nitro.scannedHandlers = [...middleware, ...handlers.filter((h) => {
|
|
27
|
+
const key = `${h.route}\0${h.method}\0${h.env}`;
|
|
28
|
+
return seenHandlers.has(key) ? false : (seenHandlers.add(key), true);
|
|
29
|
+
})];
|
|
30
|
+
nitro.routing.sync();
|
|
31
|
+
return handlers;
|
|
32
|
+
}
|
|
33
|
+
async function scanMiddleware(nitro) {
|
|
34
|
+
return (await scanFiles(nitro, "middleware")).map((file) => {
|
|
35
|
+
return {
|
|
36
|
+
route: "/**",
|
|
37
|
+
middleware: true,
|
|
38
|
+
handler: file.fullPath
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async function scanServerRoutes(nitro, dir, prefix = "/") {
|
|
43
|
+
return (await scanFiles(nitro, dir)).map((file) => {
|
|
44
|
+
let route = file.path.replace(/\.[A-Za-z]+$/, "").replace(/\(([^(/\\]+)\)[/\\]/g, "").replace(/\[\.{3}]/g, "**").replace(/\[\.{3}([^\]]+)]/g, (_, p) => "**:" + p.replace(/[^\w-]/g, "_")).replace(/\[([^/\]]+)]/g, (_, p) => ":" + p.replace(/[^\w-]/g, "_"));
|
|
45
|
+
route = withLeadingSlash(withoutTrailingSlash(withBase(route, prefix)));
|
|
46
|
+
const suffixMatch = route.match(suffixRegex);
|
|
47
|
+
let method;
|
|
48
|
+
let env;
|
|
49
|
+
if (suffixMatch?.index && suffixMatch?.index >= 0) {
|
|
50
|
+
route = route.slice(0, suffixMatch.index);
|
|
51
|
+
method = suffixMatch.groups?.method;
|
|
52
|
+
env = suffixMatch.groups?.env;
|
|
53
|
+
}
|
|
54
|
+
route = route.replace(/\/index$/, "") || "/";
|
|
55
|
+
return {
|
|
56
|
+
handler: file.fullPath,
|
|
57
|
+
lazy: true,
|
|
58
|
+
middleware: false,
|
|
59
|
+
route,
|
|
60
|
+
method,
|
|
61
|
+
env
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async function scanPlugins(nitro) {
|
|
66
|
+
return (await scanFiles(nitro, "plugins")).map((f) => f.fullPath);
|
|
67
|
+
}
|
|
68
|
+
async function scanTasks(nitro) {
|
|
69
|
+
return (await scanFiles(nitro, "tasks")).map((f) => {
|
|
70
|
+
return {
|
|
71
|
+
name: f.path.replace(/\/index$/, "").replace(/\.[A-Za-z]+$/, "").replace(/\//g, ":"),
|
|
72
|
+
handler: f.fullPath
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async function scanModules(nitro) {
|
|
77
|
+
return (await scanFiles(nitro, "modules")).map((f) => f.fullPath);
|
|
78
|
+
}
|
|
79
|
+
async function scanFiles(nitro, name) {
|
|
80
|
+
return await Promise.all(nitro.options.scanDirs.map((dir) => scanDir(nitro, dir, name))).then((r) => r.flat());
|
|
81
|
+
}
|
|
82
|
+
async function scanDir(nitro, dir, name) {
|
|
83
|
+
return (await glob(join(name, GLOB_SCAN_PATTERN), {
|
|
84
|
+
cwd: dir,
|
|
85
|
+
dot: true,
|
|
86
|
+
ignore: nitro.options.ignore,
|
|
87
|
+
absolute: true
|
|
88
|
+
}).catch((error) => {
|
|
89
|
+
if (error?.code === "ENOTDIR") {
|
|
90
|
+
nitro.logger.warn(`Ignoring \`${join(dir, name)}\`. It must be a directory.`);
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
})).map((fullPath) => {
|
|
95
|
+
return {
|
|
96
|
+
fullPath,
|
|
97
|
+
path: relative(join(dir, name), fullPath)
|
|
98
|
+
};
|
|
99
|
+
}).sort((a, b) => a.path.localeCompare(b.path));
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { scanHandlers as n, scanAndSyncOptions as t };
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
//#region src/preview.ts
|
|
6
|
+
async function startPreview(opts) {
|
|
7
|
+
const { outputDir, buildInfo } = await getBuildInfo(opts.rootDir);
|
|
8
|
+
if (!buildInfo) throw new Error("Cannot load nitro build info. Make sure to build first.");
|
|
9
|
+
const info = [
|
|
10
|
+
["Build Directory:", prettyPath(outputDir)],
|
|
11
|
+
["Date:", buildInfo.date && new Date(buildInfo.date).toLocaleString()],
|
|
12
|
+
["Nitro Version:", buildInfo.versions.nitro],
|
|
13
|
+
["Nitro Preset:", buildInfo.preset],
|
|
14
|
+
buildInfo.framework?.name !== "nitro" && ["Framework:", buildInfo.framework?.name + (buildInfo.framework?.version ? ` (v${buildInfo.framework.version})` : "")]
|
|
15
|
+
].filter((i) => i && i[1]);
|
|
16
|
+
consola.box({
|
|
17
|
+
title: " [Build Info] ",
|
|
18
|
+
message: info.map((i) => `- ${i[0]} ${i[1]}`).join("\n")
|
|
19
|
+
});
|
|
20
|
+
const dotEnvEntries = await loadPreviewDotEnv(opts.rootDir);
|
|
21
|
+
if (dotEnvEntries.length > 0) consola.box({
|
|
22
|
+
title: " [Environment Variables] ",
|
|
23
|
+
message: [
|
|
24
|
+
"Loaded variables from .env files (preview mode only).",
|
|
25
|
+
"Set platform environment variables for production:",
|
|
26
|
+
...dotEnvEntries.map(([key, val]) => ` - ${key}`)
|
|
27
|
+
].join("\n")
|
|
28
|
+
});
|
|
29
|
+
if (buildInfo.preset.includes("cloudflare")) {
|
|
30
|
+
if (!buildInfo.commands?.preview) throw new Error(`No nitro build preview command found for the "${buildInfo.preset}" preset.`);
|
|
31
|
+
return await runPreviewCommand({
|
|
32
|
+
command: buildInfo.commands.preview,
|
|
33
|
+
rootDir: opts.rootDir,
|
|
34
|
+
env: dotEnvEntries
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
let fetchHandler = () => Promise.resolve(new Response("Not Found", { status: 404 }));
|
|
38
|
+
if (buildInfo.serverEntry) {
|
|
39
|
+
for (const [key, val] of dotEnvEntries) if (!process.env[key]) process.env[key] = val;
|
|
40
|
+
const { loadServerEntry } = await import("srvx/loader");
|
|
41
|
+
const entry = await loadServerEntry({
|
|
42
|
+
entry: resolve(outputDir, buildInfo.serverEntry),
|
|
43
|
+
...opts.loader
|
|
44
|
+
});
|
|
45
|
+
if (entry.fetch) fetchHandler = entry.fetch;
|
|
46
|
+
}
|
|
47
|
+
if (buildInfo.publicDir) {
|
|
48
|
+
const { serveStatic } = await import("srvx/static");
|
|
49
|
+
const staticHandler = serveStatic({ dir: join(outputDir, buildInfo.publicDir) });
|
|
50
|
+
const originalFetchHandler = fetchHandler;
|
|
51
|
+
fetchHandler = async (req) => {
|
|
52
|
+
const staticRes = await staticHandler(req, () => void 0);
|
|
53
|
+
if (staticRes) return staticRes;
|
|
54
|
+
return originalFetchHandler(req);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
fetch: fetchHandler,
|
|
59
|
+
async close() {}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function loadPreviewDotEnv(root) {
|
|
63
|
+
const { loadDotenv } = await import("../_libs/_.mjs");
|
|
64
|
+
const env = await loadDotenv({
|
|
65
|
+
cwd: root,
|
|
66
|
+
fileName: [
|
|
67
|
+
".env.preview",
|
|
68
|
+
".env.production",
|
|
69
|
+
".env"
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
return Object.entries(env).filter(([_key, val]) => val);
|
|
73
|
+
}
|
|
74
|
+
async function runPreviewCommand(opts) {
|
|
75
|
+
const [arg0, ...args] = opts.command.split(" ");
|
|
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
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
fetch(req) {
|
|
112
|
+
return proxyFetch({
|
|
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
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { startPreview as t };
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { r as __require, t as __commonJSMin } from "../_common.mjs";
|
|
2
|
+
import { H as v, M as glob, V as m, at as dirname, dt as resolve, nt as resolveModulePath, p as runParallel, ut as relative } from "../_build/common.mjs";
|
|
3
|
+
import { consola as consola$1 } from "consola";
|
|
4
|
+
import { promises } from "node:fs";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import { colors } from "consola/utils";
|
|
7
|
+
import zlib from "node:zlib";
|
|
8
|
+
(/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9
|
+
var Stream = __require("stream");
|
|
10
|
+
var writeMethods = [
|
|
11
|
+
"write",
|
|
12
|
+
"end",
|
|
13
|
+
"destroy"
|
|
14
|
+
];
|
|
15
|
+
var readMethods = ["resume", "pause"];
|
|
16
|
+
var readEvents = ["data", "close"];
|
|
17
|
+
var slice = Array.prototype.slice;
|
|
18
|
+
module.exports = duplex;
|
|
19
|
+
function forEach(arr, fn) {
|
|
20
|
+
if (arr.forEach) return arr.forEach(fn);
|
|
21
|
+
for (var i = 0; i < arr.length; i++) fn(arr[i], i);
|
|
22
|
+
}
|
|
23
|
+
function duplex(writer, reader) {
|
|
24
|
+
var stream = new Stream();
|
|
25
|
+
var ended = false;
|
|
26
|
+
forEach(writeMethods, proxyWriter);
|
|
27
|
+
forEach(readMethods, proxyReader);
|
|
28
|
+
forEach(readEvents, proxyStream);
|
|
29
|
+
reader.on("end", handleEnd);
|
|
30
|
+
writer.on("drain", function() {
|
|
31
|
+
stream.emit("drain");
|
|
32
|
+
});
|
|
33
|
+
writer.on("error", reemit);
|
|
34
|
+
reader.on("error", reemit);
|
|
35
|
+
stream.writable = writer.writable;
|
|
36
|
+
stream.readable = reader.readable;
|
|
37
|
+
return stream;
|
|
38
|
+
function proxyWriter(methodName) {
|
|
39
|
+
stream[methodName] = method;
|
|
40
|
+
function method() {
|
|
41
|
+
return writer[methodName].apply(writer, arguments);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function proxyReader(methodName) {
|
|
45
|
+
stream[methodName] = method;
|
|
46
|
+
function method() {
|
|
47
|
+
stream.emit(methodName);
|
|
48
|
+
var func = reader[methodName];
|
|
49
|
+
if (func) return func.apply(reader, arguments);
|
|
50
|
+
reader.emit(methodName);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function proxyStream(methodName) {
|
|
54
|
+
reader.on(methodName, reemit);
|
|
55
|
+
function reemit() {
|
|
56
|
+
var args = slice.call(arguments);
|
|
57
|
+
args.unshift(methodName);
|
|
58
|
+
stream.emit.apply(stream, args);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function handleEnd() {
|
|
62
|
+
if (ended) return;
|
|
63
|
+
ended = true;
|
|
64
|
+
var args = slice.call(arguments);
|
|
65
|
+
args.unshift("end");
|
|
66
|
+
stream.emit.apply(stream, args);
|
|
67
|
+
}
|
|
68
|
+
function reemit(err) {
|
|
69
|
+
stream.emit("error", err);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
})))();
|
|
73
|
+
const getOptions = (options) => ({
|
|
74
|
+
level: 9,
|
|
75
|
+
...options
|
|
76
|
+
});
|
|
77
|
+
const gzip = promisify(zlib.gzip);
|
|
78
|
+
async function gzipSize(input, options) {
|
|
79
|
+
if (!input) return 0;
|
|
80
|
+
return (await gzip(input, getOptions(options))).length;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region node_modules/.pnpm/pretty-bytes@7.1.0/node_modules/pretty-bytes/index.js
|
|
84
|
+
const BYTE_UNITS = [
|
|
85
|
+
"B",
|
|
86
|
+
"kB",
|
|
87
|
+
"MB",
|
|
88
|
+
"GB",
|
|
89
|
+
"TB",
|
|
90
|
+
"PB",
|
|
91
|
+
"EB",
|
|
92
|
+
"ZB",
|
|
93
|
+
"YB"
|
|
94
|
+
];
|
|
95
|
+
const BIBYTE_UNITS = [
|
|
96
|
+
"B",
|
|
97
|
+
"KiB",
|
|
98
|
+
"MiB",
|
|
99
|
+
"GiB",
|
|
100
|
+
"TiB",
|
|
101
|
+
"PiB",
|
|
102
|
+
"EiB",
|
|
103
|
+
"ZiB",
|
|
104
|
+
"YiB"
|
|
105
|
+
];
|
|
106
|
+
const BIT_UNITS = [
|
|
107
|
+
"b",
|
|
108
|
+
"kbit",
|
|
109
|
+
"Mbit",
|
|
110
|
+
"Gbit",
|
|
111
|
+
"Tbit",
|
|
112
|
+
"Pbit",
|
|
113
|
+
"Ebit",
|
|
114
|
+
"Zbit",
|
|
115
|
+
"Ybit"
|
|
116
|
+
];
|
|
117
|
+
const BIBIT_UNITS = [
|
|
118
|
+
"b",
|
|
119
|
+
"kibit",
|
|
120
|
+
"Mibit",
|
|
121
|
+
"Gibit",
|
|
122
|
+
"Tibit",
|
|
123
|
+
"Pibit",
|
|
124
|
+
"Eibit",
|
|
125
|
+
"Zibit",
|
|
126
|
+
"Yibit"
|
|
127
|
+
];
|
|
128
|
+
const toLocaleString = (number, locale, options) => {
|
|
129
|
+
let result = number;
|
|
130
|
+
if (typeof locale === "string" || Array.isArray(locale)) result = number.toLocaleString(locale, options);
|
|
131
|
+
else if (locale === true || options !== void 0) result = number.toLocaleString(void 0, options);
|
|
132
|
+
return result;
|
|
133
|
+
};
|
|
134
|
+
const log10 = (numberOrBigInt) => {
|
|
135
|
+
if (typeof numberOrBigInt === "number") return Math.log10(numberOrBigInt);
|
|
136
|
+
const string = numberOrBigInt.toString(10);
|
|
137
|
+
return string.length + Math.log10(`0.${string.slice(0, 15)}`);
|
|
138
|
+
};
|
|
139
|
+
const log = (numberOrBigInt) => {
|
|
140
|
+
if (typeof numberOrBigInt === "number") return Math.log(numberOrBigInt);
|
|
141
|
+
return log10(numberOrBigInt) * Math.log(10);
|
|
142
|
+
};
|
|
143
|
+
const divide = (numberOrBigInt, divisor) => {
|
|
144
|
+
if (typeof numberOrBigInt === "number") return numberOrBigInt / divisor;
|
|
145
|
+
const integerPart = numberOrBigInt / BigInt(divisor);
|
|
146
|
+
const remainder = numberOrBigInt % BigInt(divisor);
|
|
147
|
+
return Number(integerPart) + Number(remainder) / divisor;
|
|
148
|
+
};
|
|
149
|
+
const applyFixedWidth = (result, fixedWidth) => {
|
|
150
|
+
if (fixedWidth === void 0) return result;
|
|
151
|
+
if (typeof fixedWidth !== "number" || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
|
|
152
|
+
if (fixedWidth === 0) return result;
|
|
153
|
+
return result.length < fixedWidth ? result.padStart(fixedWidth, " ") : result;
|
|
154
|
+
};
|
|
155
|
+
const buildLocaleOptions = (options) => {
|
|
156
|
+
const { minimumFractionDigits, maximumFractionDigits } = options;
|
|
157
|
+
if (minimumFractionDigits === void 0 && maximumFractionDigits === void 0) return;
|
|
158
|
+
return {
|
|
159
|
+
...minimumFractionDigits !== void 0 && { minimumFractionDigits },
|
|
160
|
+
...maximumFractionDigits !== void 0 && { maximumFractionDigits },
|
|
161
|
+
roundingMode: "trunc"
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
function prettyBytes(number, options) {
|
|
165
|
+
if (typeof number !== "bigint" && !Number.isFinite(number)) throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
166
|
+
options = {
|
|
167
|
+
bits: false,
|
|
168
|
+
binary: false,
|
|
169
|
+
space: true,
|
|
170
|
+
nonBreakingSpace: false,
|
|
171
|
+
...options
|
|
172
|
+
};
|
|
173
|
+
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
174
|
+
const separator = options.space ? options.nonBreakingSpace ? "\xA0" : " " : "";
|
|
175
|
+
const isZero = typeof number === "number" ? number === 0 : number === 0n;
|
|
176
|
+
if (options.signed && isZero) return applyFixedWidth(` 0${separator}${UNITS[0]}`, options.fixedWidth);
|
|
177
|
+
const isNegative = number < 0;
|
|
178
|
+
const prefix = isNegative ? "-" : options.signed ? "+" : "";
|
|
179
|
+
if (isNegative) number = -number;
|
|
180
|
+
const localeOptions = buildLocaleOptions(options);
|
|
181
|
+
let result;
|
|
182
|
+
if (number < 1) result = prefix + toLocaleString(number, options.locale, localeOptions) + separator + UNITS[0];
|
|
183
|
+
else {
|
|
184
|
+
const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
|
|
185
|
+
number = divide(number, (options.binary ? 1024 : 1e3) ** exponent);
|
|
186
|
+
if (!localeOptions) {
|
|
187
|
+
const minPrecision = Math.max(3, Math.floor(number).toString().length);
|
|
188
|
+
number = number.toPrecision(minPrecision);
|
|
189
|
+
}
|
|
190
|
+
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
|
|
191
|
+
const unit = UNITS[exponent];
|
|
192
|
+
result = prefix + numberString + separator + unit;
|
|
193
|
+
}
|
|
194
|
+
return applyFixedWidth(result, options.fixedWidth);
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/utils/fs-tree.ts
|
|
198
|
+
async function generateFSTree(dir, options = {}) {
|
|
199
|
+
if (v) return;
|
|
200
|
+
const files = await glob("**/*.*", {
|
|
201
|
+
cwd: dir,
|
|
202
|
+
ignore: ["*.map"]
|
|
203
|
+
});
|
|
204
|
+
const items = [];
|
|
205
|
+
await runParallel(new Set(files), async (file) => {
|
|
206
|
+
const path = resolve(dir, file);
|
|
207
|
+
const src = await promises.readFile(path);
|
|
208
|
+
const size = src.byteLength;
|
|
209
|
+
const gzip = options.compressedSizes ? await gzipSize(src) : 0;
|
|
210
|
+
items.push({
|
|
211
|
+
file,
|
|
212
|
+
path,
|
|
213
|
+
size,
|
|
214
|
+
gzip
|
|
215
|
+
});
|
|
216
|
+
}, { concurrency: 10 });
|
|
217
|
+
items.sort((a, b) => a.path.localeCompare(b.path));
|
|
218
|
+
let totalSize = 0;
|
|
219
|
+
let totalGzip = 0;
|
|
220
|
+
let totalNodeModulesSize = 0;
|
|
221
|
+
let totalNodeModulesGzip = 0;
|
|
222
|
+
let treeText = "";
|
|
223
|
+
for (const [index, item] of items.entries()) {
|
|
224
|
+
let dir = dirname(item.file);
|
|
225
|
+
if (dir === ".") dir = "";
|
|
226
|
+
const rpath = relative(process.cwd(), item.path);
|
|
227
|
+
const treeChar = index === items.length - 1 ? "└─" : "├─";
|
|
228
|
+
if (item.file.includes("node_modules")) {
|
|
229
|
+
totalNodeModulesSize += item.size;
|
|
230
|
+
totalNodeModulesGzip += item.gzip;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
treeText += colors.gray(` ${treeChar} ${rpath} (${prettyBytes(item.size)})`);
|
|
234
|
+
if (options.compressedSizes) treeText += colors.gray(` (${prettyBytes(item.gzip)} gzip)`);
|
|
235
|
+
treeText += "\n";
|
|
236
|
+
totalSize += item.size;
|
|
237
|
+
totalGzip += item.gzip;
|
|
238
|
+
}
|
|
239
|
+
treeText += `${colors.cyan("Σ Total size:")} ${prettyBytes(totalSize + totalNodeModulesSize)}`;
|
|
240
|
+
if (options.compressedSizes) treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
|
|
241
|
+
treeText += "\n";
|
|
242
|
+
return treeText;
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/utils/dep.ts
|
|
246
|
+
async function importDep(opts, _retry) {
|
|
247
|
+
const resolved = resolveModulePath(opts.id, {
|
|
248
|
+
from: [opts.dir, import.meta.url],
|
|
249
|
+
cache: _retry ? false : true,
|
|
250
|
+
try: true
|
|
251
|
+
});
|
|
252
|
+
if (resolved) return await import(resolved);
|
|
253
|
+
let shouldInstall;
|
|
254
|
+
if (_retry || v) shouldInstall = false;
|
|
255
|
+
else if (m) {
|
|
256
|
+
consola$1.info(`\`${opts.id}\` is required for ${opts.reason}. Installing automatically in CI environment...`);
|
|
257
|
+
shouldInstall = true;
|
|
258
|
+
} else shouldInstall = await consola$1.prompt(`\`${opts.id}\` is required for ${opts.reason}, but it is not installed. Would you like to install it?`, {
|
|
259
|
+
type: "confirm",
|
|
260
|
+
default: true,
|
|
261
|
+
cancel: "undefined"
|
|
262
|
+
});
|
|
263
|
+
if (!shouldInstall) throw new Error(`\`${opts.id}\` is not installed. Please add it to your dependencies for ${opts.reason}.`);
|
|
264
|
+
const start = Date.now();
|
|
265
|
+
consola$1.start(`Installing \`${opts.id}\` in \`${opts.dir}\`...`);
|
|
266
|
+
const { addDevDependency } = await import("../_libs/_5.mjs");
|
|
267
|
+
await addDevDependency(opts.id, { cwd: opts.dir });
|
|
268
|
+
consola$1.success(`Installed \`${opts.id}\` in ${opts.dir} (${Date.now() - start}ms).`);
|
|
269
|
+
return importDep(opts, true);
|
|
270
|
+
}
|
|
271
|
+
//#endregion
|
|
272
|
+
export { generateFSTree as n, importDep as t };
|
package/dist/_common.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
10
|
+
var __exportAll = (all, no_symbols) => {
|
|
11
|
+
let target = {};
|
|
12
|
+
for (var name in all) __defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
|
+
key = keys[i];
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
23
|
+
get: ((k) => from[k]).bind(null, key),
|
|
24
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
34
|
+
//#endregion
|
|
35
|
+
export { __toESM as i, __exportAll as n, __require as r, __commonJSMin 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 };
|