@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,121 @@
|
|
|
1
|
+
import { HTTPError } from "h3";
|
|
2
|
+
import { getRequestURL } from "h3";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { resolve, dirname } from "node:path";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { defineNitroErrorHandler } from "./utils.mjs";
|
|
7
|
+
import { FastResponse } from "srvx";
|
|
8
|
+
const errorHandler = defineNitroErrorHandler(async function defaultNitroErrorHandler(error, event) {
|
|
9
|
+
const res = await defaultHandler(error, event);
|
|
10
|
+
return new FastResponse(typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2), res);
|
|
11
|
+
});
|
|
12
|
+
export default errorHandler;
|
|
13
|
+
export async function defaultHandler(error, event, opts) {
|
|
14
|
+
const unhandled = error.unhandled ?? !HTTPError.isError(error);
|
|
15
|
+
const { status = 500, statusText = "" } = unhandled ? {} : error;
|
|
16
|
+
const url = getRequestURL(event, {
|
|
17
|
+
xForwardedHost: true,
|
|
18
|
+
xForwardedProto: true
|
|
19
|
+
});
|
|
20
|
+
// Redirects with base URL
|
|
21
|
+
if (status === 404) {
|
|
22
|
+
const baseURL = import.meta.baseURL || "/";
|
|
23
|
+
if (/^\/[^/]/.test(baseURL) && !url.pathname.startsWith(baseURL)) {
|
|
24
|
+
return {
|
|
25
|
+
status: 302,
|
|
26
|
+
statusText: "Found",
|
|
27
|
+
headers: new Headers({ location: `${baseURL}${url.pathname.slice(1)}${url.search}` }),
|
|
28
|
+
body: `Redirecting...`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Load stack trace with source maps
|
|
33
|
+
await loadStackTrace(error).catch(consola.error);
|
|
34
|
+
const { Youch } = await import("youch");
|
|
35
|
+
// https://github.com/poppinss/youch
|
|
36
|
+
const youch = new Youch();
|
|
37
|
+
// Console output
|
|
38
|
+
if (unhandled && !opts?.silent) {
|
|
39
|
+
const ansiError = (await youch.toANSI(error)).replaceAll(process.cwd(), ".");
|
|
40
|
+
consola.error(`[request error] [${event.req.method}] ${url}\n\n`, ansiError);
|
|
41
|
+
}
|
|
42
|
+
// Use HTML response only when user-agent expects it (browsers)
|
|
43
|
+
const useJSON = opts?.json ?? !event.req.headers.get("accept")?.includes("text/html");
|
|
44
|
+
const headers = new Headers(unhandled ? {} : error.headers);
|
|
45
|
+
if (useJSON) {
|
|
46
|
+
headers.set("Content-Type", "application/json; charset=utf-8");
|
|
47
|
+
const jsonBody = typeof error.toJSON === "function" ? error.toJSON() : {
|
|
48
|
+
status,
|
|
49
|
+
statusText,
|
|
50
|
+
message: error.message
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
status,
|
|
54
|
+
statusText,
|
|
55
|
+
headers,
|
|
56
|
+
body: {
|
|
57
|
+
error: true,
|
|
58
|
+
stack: error.stack?.split("\n").map((line) => line.trim()),
|
|
59
|
+
...jsonBody
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// HTML response
|
|
64
|
+
headers.set("Content-Type", "text/html; charset=utf-8");
|
|
65
|
+
return {
|
|
66
|
+
status,
|
|
67
|
+
statusText: unhandled ? "" : error.statusText,
|
|
68
|
+
headers,
|
|
69
|
+
body: await youch.toHTML(error, { request: {
|
|
70
|
+
url: url.href,
|
|
71
|
+
method: event.req.method,
|
|
72
|
+
headers: Object.fromEntries(event.req.headers.entries())
|
|
73
|
+
} })
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// ---- Source Map support ----
|
|
77
|
+
export async function loadStackTrace(error) {
|
|
78
|
+
if (!(error instanceof Error)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const { ErrorParser } = await import("youch-core");
|
|
82
|
+
const parsed = await new ErrorParser().defineSourceLoader(sourceLoader).parse(error);
|
|
83
|
+
const stack = error.message + "\n" + parsed.frames.map((frame) => fmtFrame(frame)).join("\n");
|
|
84
|
+
Object.defineProperty(error, "stack", { value: stack });
|
|
85
|
+
if (error.cause) {
|
|
86
|
+
await loadStackTrace(error.cause).catch(consola.error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function sourceLoader(frame) {
|
|
90
|
+
if (!frame.fileName || frame.fileType !== "fs" || frame.type === "native") {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (frame.type === "app") {
|
|
94
|
+
// prettier-ignore
|
|
95
|
+
const rawSourceMap = await readFile(`${frame.fileName}.map`, "utf8").catch(() => {});
|
|
96
|
+
if (rawSourceMap) {
|
|
97
|
+
const { SourceMapConsumer } = await import("source-map");
|
|
98
|
+
const consumer = await new SourceMapConsumer(rawSourceMap);
|
|
99
|
+
// prettier-ignore
|
|
100
|
+
const originalPosition = consumer.originalPositionFor({
|
|
101
|
+
line: frame.lineNumber,
|
|
102
|
+
column: frame.columnNumber
|
|
103
|
+
});
|
|
104
|
+
if (originalPosition.source && originalPosition.line) {
|
|
105
|
+
// prettier-ignore
|
|
106
|
+
frame.fileName = resolve(dirname(frame.fileName), originalPosition.source);
|
|
107
|
+
frame.lineNumber = originalPosition.line;
|
|
108
|
+
frame.columnNumber = originalPosition.column || 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const contents = await readFile(frame.fileName, "utf8").catch(() => {});
|
|
113
|
+
return contents ? { contents } : undefined;
|
|
114
|
+
}
|
|
115
|
+
function fmtFrame(frame) {
|
|
116
|
+
if (frame.type === "native") {
|
|
117
|
+
return frame.raw;
|
|
118
|
+
}
|
|
119
|
+
const src = `${frame.fileName || ""}:${frame.lineNumber}:${frame.columnNumber})`;
|
|
120
|
+
return frame.functionName ? `at ${frame.functionName} (${src}` : `at ${src}`;
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function trapUnhandledErrors(): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useNitroApp } from "../app.mjs";
|
|
2
|
+
function _captureError(error, type) {
|
|
3
|
+
console.error(`[${type}]`, error);
|
|
4
|
+
useNitroApp().captureError?.(error, { tags: [type] });
|
|
5
|
+
}
|
|
6
|
+
export function trapUnhandledErrors() {
|
|
7
|
+
process.on("unhandledRejection", (error) => _captureError(error, "unhandledRejection"));
|
|
8
|
+
process.on("uncaughtException", (error) => _captureError(error, "uncaughtException"));
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HTTPError, type HTTPEvent } from "h3";
|
|
2
|
+
import type { InternalHandlerResponse } from "./utils.mjs";
|
|
3
|
+
import type { NitroErrorHandler } from "nitro/types";
|
|
4
|
+
declare const errorHandler: NitroErrorHandler;
|
|
5
|
+
export default errorHandler;
|
|
6
|
+
export declare function defaultHandler(error: HTTPError, event: HTTPEvent): InternalHandlerResponse;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HTTPError } from "h3";
|
|
2
|
+
import { FastResponse } from "srvx";
|
|
3
|
+
const errorHandler = (error, event) => {
|
|
4
|
+
const res = defaultHandler(error, event);
|
|
5
|
+
return new FastResponse(typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2), res);
|
|
6
|
+
};
|
|
7
|
+
export default errorHandler;
|
|
8
|
+
export function defaultHandler(error, event) {
|
|
9
|
+
const unhandled = error.unhandled ?? !HTTPError.isError(error);
|
|
10
|
+
const { status = 500, statusText = "" } = unhandled ? {} : error;
|
|
11
|
+
if (status === 404) {
|
|
12
|
+
const url = event.url || new URL(event.req.url);
|
|
13
|
+
const baseURL = import.meta.baseURL || "/";
|
|
14
|
+
if (/^\/[^/]/.test(baseURL) && !url.pathname.startsWith(baseURL)) {
|
|
15
|
+
return {
|
|
16
|
+
status: 302,
|
|
17
|
+
headers: new Headers({ location: `${baseURL}${url.pathname.slice(1)}${url.search}` })
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const headers = new Headers(unhandled ? {} : error.headers);
|
|
22
|
+
headers.set("content-type", "application/json; charset=utf-8");
|
|
23
|
+
const jsonBody = unhandled ? {
|
|
24
|
+
status,
|
|
25
|
+
unhandled: true
|
|
26
|
+
} : typeof error.toJSON === "function" ? error.toJSON() : {
|
|
27
|
+
status,
|
|
28
|
+
statusText,
|
|
29
|
+
message: error.message
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
status,
|
|
33
|
+
statusText,
|
|
34
|
+
headers,
|
|
35
|
+
body: {
|
|
36
|
+
error: true,
|
|
37
|
+
...jsonBody
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NitroErrorHandler } from "nitro/types";
|
|
2
|
+
export declare function defineNitroErrorHandler(handler: NitroErrorHandler): NitroErrorHandler;
|
|
3
|
+
export type InternalHandlerResponse = {
|
|
4
|
+
status?: number;
|
|
5
|
+
statusText?: string | undefined;
|
|
6
|
+
headers?: HeadersInit;
|
|
7
|
+
body?: string | Record<string, any>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Middleware } from "h3";
|
|
2
|
+
import type { MatchedRouteRule, NitroRouteRules } from "nitro/types";
|
|
3
|
+
type RouteRuleCtor<T extends keyof NitroRouteRules> = (m: MatchedRouteRule<T>) => Middleware;
|
|
4
|
+
export declare const headers: RouteRuleCtor<"headers">;
|
|
5
|
+
export declare const redirect: RouteRuleCtor<"redirect">;
|
|
6
|
+
export declare const proxy: RouteRuleCtor<"proxy">;
|
|
7
|
+
export declare const cache: RouteRuleCtor<"cache">;
|
|
8
|
+
export declare const basicAuth: RouteRuleCtor<"auth">;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { proxyRequest, redirect as sendRedirect, requireBasicAuth } from "h3";
|
|
2
|
+
import { joinURL, withQuery, withoutBase } from "ufo";
|
|
3
|
+
import { defineCachedHandler } from "./cache.mjs";
|
|
4
|
+
// Headers route rule
|
|
5
|
+
export const headers = ((m) => function headersRouteRule(event) {
|
|
6
|
+
for (const [key, value] of Object.entries(m.options || {})) {
|
|
7
|
+
event.res.headers.set(key, value);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
// Redirect route rule
|
|
11
|
+
export const redirect = ((m) => function redirectRouteRule(event) {
|
|
12
|
+
let target = m.options?.to;
|
|
13
|
+
if (!target) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (target.endsWith("/**")) {
|
|
17
|
+
let targetPath = event.url.pathname + event.url.search;
|
|
18
|
+
const strpBase = m.options._redirectStripBase;
|
|
19
|
+
if (strpBase) {
|
|
20
|
+
targetPath = withoutBase(targetPath, strpBase);
|
|
21
|
+
}
|
|
22
|
+
target = joinURL(target.slice(0, -3), targetPath);
|
|
23
|
+
} else if (event.url.search) {
|
|
24
|
+
target = withQuery(target, Object.fromEntries(event.url.searchParams));
|
|
25
|
+
}
|
|
26
|
+
return sendRedirect(target, m.options?.status);
|
|
27
|
+
});
|
|
28
|
+
// Proxy route rule
|
|
29
|
+
export const proxy = ((m) => function proxyRouteRule(event) {
|
|
30
|
+
let target = m.options?.to;
|
|
31
|
+
if (!target) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (target.endsWith("/**")) {
|
|
35
|
+
let targetPath = event.url.pathname + event.url.search;
|
|
36
|
+
const strpBase = m.options._proxyStripBase;
|
|
37
|
+
if (strpBase) {
|
|
38
|
+
targetPath = withoutBase(targetPath, strpBase);
|
|
39
|
+
}
|
|
40
|
+
target = joinURL(target.slice(0, -3), targetPath);
|
|
41
|
+
} else if (event.url.search) {
|
|
42
|
+
target = withQuery(target, Object.fromEntries(event.url.searchParams));
|
|
43
|
+
}
|
|
44
|
+
return proxyRequest(event, target, { ...m.options });
|
|
45
|
+
});
|
|
46
|
+
// Cache route rule
|
|
47
|
+
export const cache = ((m) => function cacheRouteRule(event, next) {
|
|
48
|
+
if (!event.context.matchedRoute) {
|
|
49
|
+
return next();
|
|
50
|
+
}
|
|
51
|
+
const cachedHandlers = globalThis.__nitroCachedHandlers ??= new Map();
|
|
52
|
+
const { handler, route } = event.context.matchedRoute;
|
|
53
|
+
const key = `${m.route}:${route}`;
|
|
54
|
+
let cachedHandler = cachedHandlers.get(key);
|
|
55
|
+
if (!cachedHandler) {
|
|
56
|
+
cachedHandler = defineCachedHandler(handler, {
|
|
57
|
+
group: "nitro/route-rules",
|
|
58
|
+
name: key,
|
|
59
|
+
...m.options
|
|
60
|
+
});
|
|
61
|
+
cachedHandlers.set(key, cachedHandler);
|
|
62
|
+
}
|
|
63
|
+
return cachedHandler(event);
|
|
64
|
+
});
|
|
65
|
+
// basicAuth auth route rule
|
|
66
|
+
export const basicAuth = ((m) => async function authRouteRule(event, next) {
|
|
67
|
+
if (!m.options) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await requireBasicAuth(event, m.options);
|
|
71
|
+
return next();
|
|
72
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { H3 } from "h3";
|
|
2
|
+
import { runTask } from "../task.mjs";
|
|
3
|
+
import { scheduledTasks, tasks } from "#nitro/virtual/tasks";
|
|
4
|
+
const app = new H3().get("/_nitro/tasks", async () => {
|
|
5
|
+
const _tasks = await Promise.all(Object.entries(tasks).map(async ([name, task]) => {
|
|
6
|
+
const _task = await task.resolve?.();
|
|
7
|
+
return [name, { description: _task?.meta?.description }];
|
|
8
|
+
}));
|
|
9
|
+
return {
|
|
10
|
+
tasks: Object.fromEntries(_tasks),
|
|
11
|
+
scheduledTasks
|
|
12
|
+
};
|
|
13
|
+
}).get("/_nitro/tasks/:name", async (event) => {
|
|
14
|
+
const name = event.context.params?.name;
|
|
15
|
+
const body = await event.req.json().catch(() => ({}));
|
|
16
|
+
const payload = {
|
|
17
|
+
...Object.fromEntries(event.url.searchParams.entries()),
|
|
18
|
+
...body
|
|
19
|
+
};
|
|
20
|
+
return await runTask(name, {
|
|
21
|
+
context: { waitUntil: event.req.waitUntil },
|
|
22
|
+
payload
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
export default app;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { defineHandler, getRequestURL } from "h3";
|
|
2
|
+
import { joinURL } from "ufo";
|
|
3
|
+
import { defu } from "defu";
|
|
4
|
+
import { handlersMeta } from "#nitro/virtual/routing-meta";
|
|
5
|
+
import { useRuntimeConfig } from "../runtime-config.mjs";
|
|
6
|
+
// Served as /_openapi.json
|
|
7
|
+
export default defineHandler((event) => {
|
|
8
|
+
const runtimeConfig = useRuntimeConfig();
|
|
9
|
+
const base = runtimeConfig.app?.baseURL;
|
|
10
|
+
const url = joinURL(getRequestURL(event).origin, base);
|
|
11
|
+
const meta = {
|
|
12
|
+
title: "Nitro Server Routes",
|
|
13
|
+
...runtimeConfig.nitro?.openAPI?.meta
|
|
14
|
+
};
|
|
15
|
+
const { paths, globals: { components, ...globalsRest } } = getHandlersMeta();
|
|
16
|
+
const extensible = Object.fromEntries(Object.entries(globalsRest).filter(([key]) => key.startsWith("x-")));
|
|
17
|
+
return {
|
|
18
|
+
openapi: "3.1.0",
|
|
19
|
+
info: {
|
|
20
|
+
title: meta?.title,
|
|
21
|
+
version: meta?.version || "1.0.0",
|
|
22
|
+
description: meta?.description
|
|
23
|
+
},
|
|
24
|
+
servers: [{
|
|
25
|
+
url,
|
|
26
|
+
description: "Local Development Server",
|
|
27
|
+
variables: {}
|
|
28
|
+
}],
|
|
29
|
+
paths,
|
|
30
|
+
components,
|
|
31
|
+
...extensible
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
function getHandlersMeta() {
|
|
35
|
+
const paths = {};
|
|
36
|
+
let globals = {};
|
|
37
|
+
for (const h of handlersMeta) {
|
|
38
|
+
const { route, parameters } = normalizeRoute(h.route || "");
|
|
39
|
+
const tags = defaultTags(h.route || "");
|
|
40
|
+
const method = (h.method || "get").toLowerCase();
|
|
41
|
+
const { $global, ...openAPI } = h.meta?.openAPI || {};
|
|
42
|
+
const item = { [method]: {
|
|
43
|
+
tags,
|
|
44
|
+
parameters,
|
|
45
|
+
responses: { 200: { description: "OK" } },
|
|
46
|
+
...openAPI
|
|
47
|
+
} };
|
|
48
|
+
if ($global) {
|
|
49
|
+
// TODO: Warn on conflicting global definitions?
|
|
50
|
+
globals = defu($global, globals);
|
|
51
|
+
}
|
|
52
|
+
if (paths[route] === undefined) {
|
|
53
|
+
paths[route] = item;
|
|
54
|
+
} else {
|
|
55
|
+
Object.assign(paths[route], item);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
paths,
|
|
60
|
+
globals
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function normalizeRoute(_route) {
|
|
64
|
+
const parameters = [];
|
|
65
|
+
let anonymousCtr = 0;
|
|
66
|
+
const route = _route.replace(/:(\w+)/g, (_, name) => `{${name}}`).replace(/\/(\*)\//g, () => `/{param${++anonymousCtr}}/`).replace(/\*\*{/, "{").replace(/\/(\*\*)$/g, () => `/{*param${++anonymousCtr}}`);
|
|
67
|
+
const paramMatches = route.matchAll(/{(\*?\w+)}/g);
|
|
68
|
+
for (const match of paramMatches) {
|
|
69
|
+
const name = match[1];
|
|
70
|
+
if (!parameters.some((p) => p.name === name)) {
|
|
71
|
+
parameters.push({
|
|
72
|
+
name,
|
|
73
|
+
in: "path",
|
|
74
|
+
required: true,
|
|
75
|
+
schema: { type: "string" }
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
route,
|
|
81
|
+
parameters
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function defaultTags(route) {
|
|
85
|
+
const tags = [];
|
|
86
|
+
if (route.startsWith("/api/")) {
|
|
87
|
+
tags.push("API Routes");
|
|
88
|
+
} else if (route.startsWith("/_")) {
|
|
89
|
+
tags.push("Internal");
|
|
90
|
+
} else {
|
|
91
|
+
tags.push("App Routes");
|
|
92
|
+
}
|
|
93
|
+
return tags;
|
|
94
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { serverFetch } from "../app.mjs";
|
|
2
|
+
import { rendererTemplate, rendererTemplateFile, isStaticTemplate } from "#nitro/virtual/renderer-template";
|
|
3
|
+
import { HTTPResponse } from "h3";
|
|
4
|
+
import { hasTemplateSyntax, renderToResponse, compileTemplate } from "rendu";
|
|
5
|
+
export default async function renderIndexHTML(event) {
|
|
6
|
+
let html = await rendererTemplate(event.req);
|
|
7
|
+
if (globalThis.__transform_html__) {
|
|
8
|
+
html = await globalThis.__transform_html__(html);
|
|
9
|
+
}
|
|
10
|
+
const isStatic = isStaticTemplate ?? !hasTemplateSyntax(html);
|
|
11
|
+
if (isStatic) {
|
|
12
|
+
return new HTTPResponse(html, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
13
|
+
}
|
|
14
|
+
const template = compileTemplate(html, { filename: rendererTemplateFile });
|
|
15
|
+
return renderToResponse(template, {
|
|
16
|
+
request: event.req,
|
|
17
|
+
context: { serverFetch }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { defineHandler } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "../runtime-config.mjs";
|
|
3
|
+
// Served as /_scalar
|
|
4
|
+
export default defineHandler((event) => {
|
|
5
|
+
const runtimeConfig = useRuntimeConfig();
|
|
6
|
+
const title = runtimeConfig.nitro?.openAPI?.meta?.title || "API Reference";
|
|
7
|
+
const description = runtimeConfig.nitro?.openAPI?.meta?.description || "";
|
|
8
|
+
const openAPIEndpoint = runtimeConfig.nitro?.openAPI?.route || "./_openapi.json";
|
|
9
|
+
// https://github.com/scalar/scalar
|
|
10
|
+
const _config = runtimeConfig.nitro?.openAPI?.ui?.scalar;
|
|
11
|
+
const scalarConfig = {
|
|
12
|
+
..._config,
|
|
13
|
+
url: openAPIEndpoint,
|
|
14
|
+
spec: {
|
|
15
|
+
url: openAPIEndpoint,
|
|
16
|
+
..._config?.spec
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// The default page title
|
|
20
|
+
event.res.headers.set("Content-Type", "text/html");
|
|
21
|
+
return `<!doctype html>
|
|
22
|
+
<html lang="en">
|
|
23
|
+
<head>
|
|
24
|
+
<meta charset="utf-8" />
|
|
25
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
26
|
+
<meta name="description" content="${description}" />
|
|
27
|
+
<title>${title}</title>
|
|
28
|
+
<style>
|
|
29
|
+
${scalarConfig.theme ? null : customTheme}
|
|
30
|
+
</style>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<script
|
|
34
|
+
id="api-reference"
|
|
35
|
+
data-configuration="${JSON.stringify(scalarConfig).split("\"").join(""")}"
|
|
36
|
+
><\/script>
|
|
37
|
+
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"><\/script>
|
|
38
|
+
</body>
|
|
39
|
+
</html>`;
|
|
40
|
+
});
|
|
41
|
+
const customTheme = `/* basic theme */
|
|
42
|
+
.light-mode,
|
|
43
|
+
.light-mode .dark-mode {
|
|
44
|
+
--theme-background-1: #fff;
|
|
45
|
+
--theme-background-2: #fafafa;
|
|
46
|
+
--theme-background-3: rgb(245 245 245);
|
|
47
|
+
|
|
48
|
+
--theme-color-1: #2a2f45;
|
|
49
|
+
--theme-color-2: #757575;
|
|
50
|
+
--theme-color-3: #8e8e8e;
|
|
51
|
+
|
|
52
|
+
--theme-color-accent: #ef4444;
|
|
53
|
+
--theme-background-accent: transparent;
|
|
54
|
+
|
|
55
|
+
--theme-border-color: rgba(0, 0, 0, 0.1);
|
|
56
|
+
}
|
|
57
|
+
.dark-mode {
|
|
58
|
+
--theme-background-1: #171717;
|
|
59
|
+
--theme-background-2: #262626;
|
|
60
|
+
--theme-background-3: #2e2e2e;
|
|
61
|
+
|
|
62
|
+
--theme-color-1: rgba(255, 255, 255, 0.9);
|
|
63
|
+
--theme-color-2: rgba(255, 255, 255, 0.62);
|
|
64
|
+
--theme-color-3: rgba(255, 255, 255, 0.44);
|
|
65
|
+
|
|
66
|
+
--theme-color-accent: #f87171;
|
|
67
|
+
--theme-background-accent: transparent;
|
|
68
|
+
|
|
69
|
+
--theme-border-color: rgba(255, 255, 255, 0.1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* Document Sidebar */
|
|
73
|
+
.light-mode .t-doc__sidebar,
|
|
74
|
+
.dark-mode .t-doc__sidebar {
|
|
75
|
+
--sidebar-background-1: var(--theme-background-1);
|
|
76
|
+
--sidebar-color-1: var(--theme-color-1);
|
|
77
|
+
--sidebar-color-2: var(--theme-color-2);
|
|
78
|
+
--sidebar-border-color: var(--theme-border-color);
|
|
79
|
+
|
|
80
|
+
--sidebar-item-hover-background: transparent;
|
|
81
|
+
--sidebar-item-hover-color: var(--sidebar-color-1);
|
|
82
|
+
|
|
83
|
+
--sidebar-item-active-background: var(--theme-background-accent);
|
|
84
|
+
--sidebar-color-active: var(--theme-color-accent);
|
|
85
|
+
|
|
86
|
+
--sidebar-search-background: transparent;
|
|
87
|
+
--sidebar-search-color: var(--theme-color-3);
|
|
88
|
+
--sidebar-search-border-color: var(--theme-border-color);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* advanced */
|
|
92
|
+
.light-mode .dark-mode,
|
|
93
|
+
.light-mode {
|
|
94
|
+
--theme-color-green: #91b859;
|
|
95
|
+
--theme-color-red: #e53935;
|
|
96
|
+
--theme-color-yellow: #e2931d;
|
|
97
|
+
--theme-color-blue: #6182b8;
|
|
98
|
+
--theme-color-orange: #f76d47;
|
|
99
|
+
--theme-color-purple: #9c3eda;
|
|
100
|
+
}
|
|
101
|
+
.dark-mode {
|
|
102
|
+
--theme-color-green: #c3e88d;
|
|
103
|
+
--theme-color-red: #f07178;
|
|
104
|
+
--theme-color-yellow: #ffcb6b;
|
|
105
|
+
--theme-color-blue: #82aaff;
|
|
106
|
+
--theme-color-orange: #f78c6c;
|
|
107
|
+
--theme-color-purple: #c792ea;
|
|
108
|
+
}
|
|
109
|
+
/* custom-theme */
|
|
110
|
+
.section-container:nth-of-type(2)
|
|
111
|
+
~ .section-container
|
|
112
|
+
.scalar-card
|
|
113
|
+
.scalar-card-header {
|
|
114
|
+
--theme-background-2: var(--theme-background-1) !important;
|
|
115
|
+
}
|
|
116
|
+
.section-flare {
|
|
117
|
+
width: 100%;
|
|
118
|
+
height: 100%;
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 0;
|
|
121
|
+
left: 0;
|
|
122
|
+
animation: spin 39s linear infinite;
|
|
123
|
+
transition: all 0.3s ease-in-out;
|
|
124
|
+
opacity: 1;
|
|
125
|
+
}
|
|
126
|
+
.section-flare-item:nth-of-type(1),
|
|
127
|
+
.section-flare-item:nth-of-type(2),
|
|
128
|
+
.section-flare-item:nth-of-type(3) {
|
|
129
|
+
content: "";
|
|
130
|
+
width: 1000px;
|
|
131
|
+
height: 1000px;
|
|
132
|
+
position: absolute;
|
|
133
|
+
top: 0;
|
|
134
|
+
right: 0;
|
|
135
|
+
border-radius: 50%;
|
|
136
|
+
background: var(--default-theme-background-1);
|
|
137
|
+
display: block;
|
|
138
|
+
opacity: 1;
|
|
139
|
+
filter: blur(48px);
|
|
140
|
+
-webkit-backface-visibility: hidden;
|
|
141
|
+
-webkit-perspective: 1000;
|
|
142
|
+
-webkit-transform: translate3d(0, 0, 0);
|
|
143
|
+
-webkit-transform: translateZ(0);
|
|
144
|
+
perspective: 1000;
|
|
145
|
+
transform: translate3d(0, 0, 0);
|
|
146
|
+
transform: translateZ(0);
|
|
147
|
+
}
|
|
148
|
+
.section-flare-item:nth-of-type(2) {
|
|
149
|
+
top: initial;
|
|
150
|
+
right: initial;
|
|
151
|
+
background: #ef4444;
|
|
152
|
+
width: 700px;
|
|
153
|
+
height: 700px;
|
|
154
|
+
opacity: 0.3;
|
|
155
|
+
animation: sectionflare 37s linear infinite;
|
|
156
|
+
}
|
|
157
|
+
.section-flare-item:nth-of-type(1) {
|
|
158
|
+
top: initial;
|
|
159
|
+
right: initial;
|
|
160
|
+
bottom: 0;
|
|
161
|
+
left: -20px;
|
|
162
|
+
background: #ef4444;
|
|
163
|
+
width: 500px;
|
|
164
|
+
height: 500px;
|
|
165
|
+
opacity: 0.3;
|
|
166
|
+
animation: sectionflare2 38s linear infinite;
|
|
167
|
+
}
|
|
168
|
+
@keyframes sectionflare {
|
|
169
|
+
0%,
|
|
170
|
+
100% {
|
|
171
|
+
transform: translate3d(0, 0, 0);
|
|
172
|
+
}
|
|
173
|
+
50% {
|
|
174
|
+
transform: translate3d(525px, 525px, 0);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
@keyframes sectionflare2 {
|
|
178
|
+
0%,
|
|
179
|
+
100% {
|
|
180
|
+
transform: translate3d(700px, 700px, 0);
|
|
181
|
+
}
|
|
182
|
+
50% {
|
|
183
|
+
transform: translate3d(0, 0, 0);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
@keyframes spin {
|
|
187
|
+
100% {
|
|
188
|
+
transform: rotate(360deg);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
.section-container:nth-of-type(2) {
|
|
192
|
+
overflow: hidden;
|
|
193
|
+
}`;
|