@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,496 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/rou3@0.8.1/node_modules/rou3/dist/index.mjs
|
|
2
|
+
const NullProtoObj = /* @__PURE__ */ (() => {
|
|
3
|
+
const e = function() {};
|
|
4
|
+
return e.prototype = Object.create(null), Object.freeze(e.prototype), e;
|
|
5
|
+
})();
|
|
6
|
+
/**
|
|
7
|
+
* Create a new router context.
|
|
8
|
+
*/
|
|
9
|
+
function createRouter() {
|
|
10
|
+
return {
|
|
11
|
+
root: { key: "" },
|
|
12
|
+
static: new NullProtoObj()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function expandGroupDelimiters(path) {
|
|
16
|
+
let i = 0;
|
|
17
|
+
let depth = 0;
|
|
18
|
+
for (; i < path.length; i++) {
|
|
19
|
+
const c = path.charCodeAt(i);
|
|
20
|
+
if (c === 92) {
|
|
21
|
+
i++;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (c === 40) {
|
|
25
|
+
depth++;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (c === 41 && depth > 0) {
|
|
29
|
+
depth--;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (c === 123 && depth === 0) break;
|
|
33
|
+
}
|
|
34
|
+
if (i >= path.length) return;
|
|
35
|
+
let j = i + 1;
|
|
36
|
+
depth = 0;
|
|
37
|
+
for (; j < path.length; j++) {
|
|
38
|
+
const c = path.charCodeAt(j);
|
|
39
|
+
if (c === 92) {
|
|
40
|
+
j++;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (c === 40) {
|
|
44
|
+
depth++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (c === 41 && depth > 0) {
|
|
48
|
+
depth--;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (c === 125 && depth === 0) break;
|
|
52
|
+
}
|
|
53
|
+
if (j >= path.length) return;
|
|
54
|
+
const mod = path[j + 1];
|
|
55
|
+
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
56
|
+
const pre = path.slice(0, i);
|
|
57
|
+
const body = path.slice(i + 1, j);
|
|
58
|
+
const suf = path.slice(j + (hasMod ? 2 : 1));
|
|
59
|
+
if (!hasMod) return [pre + body + suf];
|
|
60
|
+
if (mod === "?") return [pre + body + suf, pre + suf];
|
|
61
|
+
if (body.includes("/")) throw new Error("unsupported group repetition across segments");
|
|
62
|
+
return [`${pre}(?:${body})${mod}${suf}`];
|
|
63
|
+
}
|
|
64
|
+
const UNNAMED_GROUP_PREFIX$1 = "__rou3_unnamed_";
|
|
65
|
+
const _unnamedGroupPrefixLength = 15;
|
|
66
|
+
function hasSegmentWildcard(segment) {
|
|
67
|
+
let depth = 0;
|
|
68
|
+
for (let i = 0; i < segment.length; i++) {
|
|
69
|
+
const ch = segment.charCodeAt(i);
|
|
70
|
+
if (ch === 92) {
|
|
71
|
+
i++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (ch === 40) {
|
|
75
|
+
depth++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (ch === 41 && depth > 0) {
|
|
79
|
+
depth--;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (ch === 42 && depth === 0) return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGroupKey) {
|
|
87
|
+
let depth = 0;
|
|
88
|
+
let nextIndex = unnamedStart;
|
|
89
|
+
let replaced = "";
|
|
90
|
+
for (let i = 0; i < segment.length; i++) {
|
|
91
|
+
const ch = segment.charCodeAt(i);
|
|
92
|
+
if (ch === 92) {
|
|
93
|
+
replaced += segment[i];
|
|
94
|
+
if (i + 1 < segment.length) replaced += segment[++i];
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (ch === 40) {
|
|
98
|
+
depth++;
|
|
99
|
+
replaced += segment[i];
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (ch === 41 && depth > 0) {
|
|
103
|
+
depth--;
|
|
104
|
+
replaced += segment[i];
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (ch === 42 && depth === 0) {
|
|
108
|
+
replaced += `(?<${toGroupKey(nextIndex++)}>[^/]*)`;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
replaced += segment[i];
|
|
112
|
+
}
|
|
113
|
+
return [replaced, nextIndex];
|
|
114
|
+
}
|
|
115
|
+
function toUnnamedGroupKey(index) {
|
|
116
|
+
return `${UNNAMED_GROUP_PREFIX$1}${index}`;
|
|
117
|
+
}
|
|
118
|
+
function normalizeUnnamedGroupKey(key) {
|
|
119
|
+
return key.startsWith("__rou3_unnamed_") ? key.slice(_unnamedGroupPrefixLength) : key;
|
|
120
|
+
}
|
|
121
|
+
function encodeEscapes(path) {
|
|
122
|
+
return path.replace(/\\:/g, "�A").replace(/\\\(/g, "�B").replace(/\\\)/g, "�C").replace(/\\\{/g, "�D").replace(/\\\}/g, "�E");
|
|
123
|
+
}
|
|
124
|
+
function decodeEscaped(segment) {
|
|
125
|
+
return segment.replace(/\uFFFD([A-E])/g, (_, c) => c === "A" ? ":" : c === "B" ? "(" : c === "C" ? ")" : c === "D" ? "{" : "}");
|
|
126
|
+
}
|
|
127
|
+
function expandModifiers(segments) {
|
|
128
|
+
for (let i = 0; i < segments.length; i++) {
|
|
129
|
+
const m = segments[i].match(/^(.*:[\w-]+(?:\([^)]*\))?)([?+*])$/);
|
|
130
|
+
if (!m) continue;
|
|
131
|
+
const pre = segments.slice(0, i);
|
|
132
|
+
const suf = segments.slice(i + 1);
|
|
133
|
+
if (m[2] === "?") return ["/" + pre.concat(m[1]).concat(suf).join("/"), "/" + pre.concat(suf).join("/")];
|
|
134
|
+
const name = m[1].match(/:([\w-]+)/)?.[1] || "_";
|
|
135
|
+
const wc = "/" + [
|
|
136
|
+
...pre,
|
|
137
|
+
`**:${name}`,
|
|
138
|
+
...suf
|
|
139
|
+
].join("/");
|
|
140
|
+
const without = "/" + [...pre, ...suf].join("/");
|
|
141
|
+
return m[2] === "+" ? [wc] : [wc, without];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function normalizePath(path) {
|
|
145
|
+
if (!path.includes("/.")) return path;
|
|
146
|
+
const r = [];
|
|
147
|
+
for (const s of path.split("/")) if (s === ".") continue;
|
|
148
|
+
else if (s === ".." && r.length > 1) r.pop();
|
|
149
|
+
else r.push(s);
|
|
150
|
+
return r.join("/") || "/";
|
|
151
|
+
}
|
|
152
|
+
function splitPath(path) {
|
|
153
|
+
const [_, ...s] = path.split("/");
|
|
154
|
+
return s[s.length - 1] === "" ? s.slice(0, -1) : s;
|
|
155
|
+
}
|
|
156
|
+
function getMatchParams(segments, paramsMap) {
|
|
157
|
+
const params = new NullProtoObj();
|
|
158
|
+
for (const [index, name] of paramsMap) {
|
|
159
|
+
const segment = index < 0 ? segments.slice(-(index + 1)).join("/") : segments[index];
|
|
160
|
+
if (typeof name === "string") params[name] = segment;
|
|
161
|
+
else {
|
|
162
|
+
const match = segment.match(name);
|
|
163
|
+
if (match) for (const key in match.groups) params[normalizeUnnamedGroupKey(key)] = match.groups[key];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return params;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Add a route to the router context.
|
|
170
|
+
*/
|
|
171
|
+
function addRoute(ctx, method = "", path, data) {
|
|
172
|
+
method = method.toUpperCase();
|
|
173
|
+
if (path.charCodeAt(0) !== 47) path = `/${path}`;
|
|
174
|
+
const groupExpanded = expandGroupDelimiters(path);
|
|
175
|
+
if (groupExpanded) {
|
|
176
|
+
for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
path = encodeEscapes(path);
|
|
180
|
+
const segments = splitPath(path);
|
|
181
|
+
const expanded = expandModifiers(segments);
|
|
182
|
+
if (expanded) {
|
|
183
|
+
for (const p of expanded) addRoute(ctx, method, p, data);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
let node = ctx.root;
|
|
187
|
+
let _unnamedParamIndex = 0;
|
|
188
|
+
const paramsMap = [];
|
|
189
|
+
const paramsRegexp = [];
|
|
190
|
+
for (let i = 0; i < segments.length; i++) {
|
|
191
|
+
let segment = segments[i];
|
|
192
|
+
if (segment.startsWith("**")) {
|
|
193
|
+
if (!node.wildcard) node.wildcard = { key: "**" };
|
|
194
|
+
node = node.wildcard;
|
|
195
|
+
paramsMap.push([
|
|
196
|
+
-(i + 1),
|
|
197
|
+
segment.split(":")[1] || "_",
|
|
198
|
+
segment.length === 2
|
|
199
|
+
]);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
if (segment === "*" || segment.includes(":") || segment.includes("(") || hasSegmentWildcard(segment)) {
|
|
203
|
+
if (!node.param) node.param = { key: "*" };
|
|
204
|
+
node = node.param;
|
|
205
|
+
if (segment === "*") paramsMap.push([
|
|
206
|
+
i,
|
|
207
|
+
String(_unnamedParamIndex++),
|
|
208
|
+
true
|
|
209
|
+
]);
|
|
210
|
+
else if (segment.includes(":", 1) || segment.includes("(") || hasSegmentWildcard(segment) || !/^:[\w-]+$/.test(segment)) {
|
|
211
|
+
const [regexp, nextIndex] = getParamRegexp(segment, _unnamedParamIndex);
|
|
212
|
+
_unnamedParamIndex = nextIndex;
|
|
213
|
+
paramsRegexp[i] = regexp;
|
|
214
|
+
node.hasRegexParam = true;
|
|
215
|
+
paramsMap.push([
|
|
216
|
+
i,
|
|
217
|
+
regexp,
|
|
218
|
+
false
|
|
219
|
+
]);
|
|
220
|
+
} else paramsMap.push([
|
|
221
|
+
i,
|
|
222
|
+
segment.slice(1),
|
|
223
|
+
false
|
|
224
|
+
]);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (segment === "\\*") segment = segments[i] = "*";
|
|
228
|
+
else if (segment === "\\*\\*") segment = segments[i] = "**";
|
|
229
|
+
segment = segments[i] = decodeEscaped(segment);
|
|
230
|
+
const child = node.static?.[segment];
|
|
231
|
+
if (child) node = child;
|
|
232
|
+
else {
|
|
233
|
+
const staticNode = { key: segment };
|
|
234
|
+
if (!node.static) node.static = new NullProtoObj();
|
|
235
|
+
node.static[segment] = staticNode;
|
|
236
|
+
node = staticNode;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const hasParams = paramsMap.length > 0;
|
|
240
|
+
if (!node.methods) node.methods = new NullProtoObj();
|
|
241
|
+
node.methods[method] ??= [];
|
|
242
|
+
node.methods[method].push({
|
|
243
|
+
data: data || null,
|
|
244
|
+
paramsRegexp,
|
|
245
|
+
paramsMap: hasParams ? paramsMap : void 0
|
|
246
|
+
});
|
|
247
|
+
if (!hasParams) ctx.static["/" + segments.join("/")] = node;
|
|
248
|
+
}
|
|
249
|
+
function getParamRegexp(segment, unnamedStart = 0) {
|
|
250
|
+
let _i = unnamedStart;
|
|
251
|
+
let _s = "", _d = 0;
|
|
252
|
+
for (let j = 0; j < segment.length; j++) {
|
|
253
|
+
const c = segment.charCodeAt(j);
|
|
254
|
+
if (c === 40) _d++;
|
|
255
|
+
else if (c === 41 && _d > 0) _d--;
|
|
256
|
+
else if (c === 92 && _d === 0 && j + 1 < segment.length) {
|
|
257
|
+
const n = segment[j + 1];
|
|
258
|
+
if (n !== ":" && n !== "(" && n !== "*" && n !== "\\") {
|
|
259
|
+
_s += "" + n;
|
|
260
|
+
j++;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
_s += segment[j];
|
|
265
|
+
}
|
|
266
|
+
[_s, _i] = replaceSegmentWildcards(_s, _i);
|
|
267
|
+
const regex = _s.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id, p) => `(?<${id}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i++)}>`).replace(/\./g, "\\.").replace(/\uFFFE(.)/g, (_, c) => /[.*+?^${}()|[\]\\]/.test(c) ? `\\${c}` : c);
|
|
268
|
+
return [new RegExp(`^${regex}$`), _i];
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Find a route by path.
|
|
272
|
+
*/
|
|
273
|
+
function findRoute(ctx, method = "", path, opts) {
|
|
274
|
+
if (opts?.normalize) path = normalizePath(path);
|
|
275
|
+
if (path.charCodeAt(path.length - 1) === 47) path = path.slice(0, -1);
|
|
276
|
+
const staticNode = ctx.static[path];
|
|
277
|
+
if (staticNode && staticNode.methods) {
|
|
278
|
+
const staticMatch = staticNode.methods[method] || staticNode.methods[""];
|
|
279
|
+
if (staticMatch !== void 0) return staticMatch[0];
|
|
280
|
+
}
|
|
281
|
+
const segments = splitPath(path);
|
|
282
|
+
const match = _lookupTree(ctx.root, method, segments, 0)?.[0];
|
|
283
|
+
if (match === void 0) return;
|
|
284
|
+
if (opts?.params === false) return match;
|
|
285
|
+
return {
|
|
286
|
+
data: match.data,
|
|
287
|
+
params: match.paramsMap ? getMatchParams(segments, match.paramsMap) : void 0
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function _lookupTree(node, method, segments, index) {
|
|
291
|
+
if (index === segments.length) {
|
|
292
|
+
if (node.methods) {
|
|
293
|
+
const match = node.methods[method] || node.methods[""];
|
|
294
|
+
if (match) return match;
|
|
295
|
+
}
|
|
296
|
+
if (node.param && node.param.methods) {
|
|
297
|
+
const match = node.param.methods[method] || node.param.methods[""];
|
|
298
|
+
if (match) {
|
|
299
|
+
const pMap = match[0].paramsMap;
|
|
300
|
+
if (pMap?.[pMap?.length - 1]?.[2]) return match;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (node.wildcard && node.wildcard.methods) {
|
|
304
|
+
const match = node.wildcard.methods[method] || node.wildcard.methods[""];
|
|
305
|
+
if (match) {
|
|
306
|
+
const pMap = match[0].paramsMap;
|
|
307
|
+
if (pMap?.[pMap?.length - 1]?.[2]) return match;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const segment = segments[index];
|
|
313
|
+
if (node.static) {
|
|
314
|
+
const staticChild = node.static[segment];
|
|
315
|
+
if (staticChild) {
|
|
316
|
+
const match = _lookupTree(staticChild, method, segments, index + 1);
|
|
317
|
+
if (match) return match;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (node.param) {
|
|
321
|
+
const match = _lookupTree(node.param, method, segments, index + 1);
|
|
322
|
+
if (match) {
|
|
323
|
+
if (node.param.hasRegexParam) {
|
|
324
|
+
const exactMatch = match.find((m) => m.paramsRegexp[index]?.test(segment)) || match.find((m) => !m.paramsRegexp[index]);
|
|
325
|
+
return exactMatch ? [exactMatch] : void 0;
|
|
326
|
+
}
|
|
327
|
+
return match;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (node.wildcard && node.wildcard.methods) return node.wildcard.methods[method] || node.wildcard.methods[""];
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Find all route patterns that match the given path.
|
|
334
|
+
*/
|
|
335
|
+
function findAllRoutes(ctx, method = "", path, opts) {
|
|
336
|
+
if (opts?.normalize) path = normalizePath(path);
|
|
337
|
+
if (path.charCodeAt(path.length - 1) === 47) path = path.slice(0, -1);
|
|
338
|
+
const segments = splitPath(path);
|
|
339
|
+
const matches = _findAll(ctx.root, method, segments, 0);
|
|
340
|
+
if (opts?.params === false) return matches;
|
|
341
|
+
return matches.map((m) => {
|
|
342
|
+
return {
|
|
343
|
+
data: m.data,
|
|
344
|
+
params: m.paramsMap ? getMatchParams(segments, m.paramsMap) : void 0
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
function _findAll(node, method, segments, index, matches = []) {
|
|
349
|
+
const segment = segments[index];
|
|
350
|
+
if (node.wildcard && node.wildcard.methods) {
|
|
351
|
+
const match = node.wildcard.methods[method] || node.wildcard.methods[""];
|
|
352
|
+
if (match) matches.push(...match);
|
|
353
|
+
}
|
|
354
|
+
if (node.param) {
|
|
355
|
+
_findAll(node.param, method, segments, index + 1, matches);
|
|
356
|
+
if (index === segments.length && node.param.methods) {
|
|
357
|
+
const match = node.param.methods[method] || node.param.methods[""];
|
|
358
|
+
if (match) {
|
|
359
|
+
const pMap = match[0].paramsMap;
|
|
360
|
+
if (pMap?.[pMap?.length - 1]?.[2]) matches.push(...match);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
const staticChild = node.static?.[segment];
|
|
365
|
+
if (staticChild) _findAll(staticChild, method, segments, index + 1, matches);
|
|
366
|
+
if (index === segments.length && node.methods) {
|
|
367
|
+
const match = node.methods[method] || node.methods[""];
|
|
368
|
+
if (match) matches.push(...match);
|
|
369
|
+
}
|
|
370
|
+
return matches;
|
|
371
|
+
}
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region node_modules/.pnpm/rou3@0.8.1/node_modules/rou3/dist/compiler.mjs
|
|
374
|
+
const UNNAMED_GROUP_PREFIX = "__rou3_unnamed_";
|
|
375
|
+
/**
|
|
376
|
+
* Compile the router instance into a compact runnable code.
|
|
377
|
+
*
|
|
378
|
+
* **IMPORTANT:** Route data must be serializable to JSON (i.e., no functions or classes) or implement the `toJSON()` method to render custom code or you can pass custom `serialize` function in options.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* import { createRouter, addRoute } from "rou3";
|
|
382
|
+
* import { compileRouterToString } from "rou3/compiler";
|
|
383
|
+
* const router = createRouter();
|
|
384
|
+
* // [add some routes with serializable data]
|
|
385
|
+
* const compilerCode = compileRouterToString(router, "findRoute");
|
|
386
|
+
* // "const findRoute=(m, p) => {}"
|
|
387
|
+
*/
|
|
388
|
+
function compileRouterToString(router, functionName, opts) {
|
|
389
|
+
const ctx = {
|
|
390
|
+
opts: opts || {},
|
|
391
|
+
router,
|
|
392
|
+
data: [],
|
|
393
|
+
compileToString: true
|
|
394
|
+
};
|
|
395
|
+
let compiled = `(m,p)=>{${compileRouteMatch(ctx)}}`;
|
|
396
|
+
if (ctx.data.length > 0) compiled = `/* @__PURE__ */ (() => { ${`const ${ctx.data.map((v, i) => `$${i}=${v}`).join(",")};`}; return ${compiled}})()`;
|
|
397
|
+
return functionName ? `const ${functionName}=${compiled};` : compiled;
|
|
398
|
+
}
|
|
399
|
+
function compileRouteMatch(ctx) {
|
|
400
|
+
let code = "";
|
|
401
|
+
{
|
|
402
|
+
let hasIf = false;
|
|
403
|
+
for (const key in ctx.router.static) {
|
|
404
|
+
const node = ctx.router.static[key];
|
|
405
|
+
if (node?.methods) {
|
|
406
|
+
code += `${hasIf ? "else " : ""}if(p===${JSON.stringify(key.replace(/\/$/, "") || "/")}){${compileMethodMatch(ctx, node.methods, [], -1)}}`;
|
|
407
|
+
hasIf = true;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
const match = compileNode(ctx, ctx.router.root, [], 1);
|
|
412
|
+
if (match) code += `let s=p.split("/"),l=s.length;${match}`;
|
|
413
|
+
if (!code) return ctx.opts?.matchAll ? `return [];` : "";
|
|
414
|
+
const normalizeHelper = code.includes("_normalizeGroups(") ? `const _prefix=${JSON.stringify(UNNAMED_GROUP_PREFIX)},_prefixLen=15;const _normalizeGroups=(g)=>{if(!g)return g;for(const k in g){if(k.startsWith(_prefix)){g[k.slice(_prefixLen)]=g[k];delete g[k]}}return g;};` : "";
|
|
415
|
+
const normalizePathHelper = ctx.opts?.normalize ? `if(p.includes("/.")){let _r=[];for(let _v of p.split("/")){if(_v===".")continue;_v===".."&&_r.length>1?_r.pop():_r.push(_v)}p=_r.join("/")||"/"}` : "";
|
|
416
|
+
return `${ctx.opts?.matchAll ? `let r=[];` : ""}${normalizeHelper}${normalizePathHelper}if(p.charCodeAt(p.length-1)===47)p=p.slice(0,-1)||"/";${code}${ctx.opts?.matchAll ? "return r;" : ""}`;
|
|
417
|
+
}
|
|
418
|
+
function compileMethodMatch(ctx, methods, params, currentIdx) {
|
|
419
|
+
let code = "";
|
|
420
|
+
for (const key in methods) {
|
|
421
|
+
const matchers = methods[key];
|
|
422
|
+
if (matchers && matchers.length > 0) {
|
|
423
|
+
if (key !== "") code += `if(m==="${key}")${matchers.length > 1 ? "{" : ""}`;
|
|
424
|
+
const _matchers = matchers.map((m) => compileFinalMatch(ctx, m, currentIdx, params)).sort((a, b) => b.weight - a.weight);
|
|
425
|
+
for (const matcher of _matchers) code += matcher.code;
|
|
426
|
+
if (key !== "") code += matchers.length > 1 ? "}" : "";
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return code;
|
|
430
|
+
}
|
|
431
|
+
function compileFinalMatch(ctx, data, currentIdx, params) {
|
|
432
|
+
let ret = `{data:${serializeData(ctx, data.data)}`;
|
|
433
|
+
const conditions = [];
|
|
434
|
+
const { paramsMap, paramsRegexp } = data;
|
|
435
|
+
if (paramsMap && paramsMap.length > 0) {
|
|
436
|
+
if (!paramsMap[paramsMap.length - 1][2] && currentIdx !== -1) conditions.push(`l>${currentIdx}`);
|
|
437
|
+
for (let i = 0; i < paramsRegexp.length; i++) {
|
|
438
|
+
const regexp = paramsRegexp[i];
|
|
439
|
+
if (!regexp) continue;
|
|
440
|
+
conditions.push(`${regexp.toString()}.test(s[${i + 1}])`);
|
|
441
|
+
}
|
|
442
|
+
ret += ",params:{";
|
|
443
|
+
for (let i = 0; i < paramsMap.length; i++) {
|
|
444
|
+
const map = paramsMap[i];
|
|
445
|
+
ret += typeof map[1] === "string" ? `${JSON.stringify(map[1])}:${params[i]},` : `..._normalizeGroups((${map[1].toString()}.exec(${params[i]}))?.groups),`;
|
|
446
|
+
}
|
|
447
|
+
ret += "}";
|
|
448
|
+
}
|
|
449
|
+
return {
|
|
450
|
+
code: (conditions.length > 0 ? `if(${conditions.join("&&")})` : "") + (ctx.opts?.matchAll ? `r.unshift(${ret}});` : `return ${ret}};`),
|
|
451
|
+
weight: conditions.length
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function compileNode(ctx, node, params, currentIdx) {
|
|
455
|
+
const hasLastOptionalParam = node.key === "*";
|
|
456
|
+
let code = "", hasIf = false;
|
|
457
|
+
if (node.methods && params.length > 0) {
|
|
458
|
+
const match = compileMethodMatch(ctx, node.methods, params, hasLastOptionalParam ? currentIdx - 1 : -1);
|
|
459
|
+
if (match) {
|
|
460
|
+
code += `if(l===${currentIdx}${hasLastOptionalParam ? `||l===${currentIdx - 1}` : ""}){${match}}`;
|
|
461
|
+
hasIf = true;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (node.static) {
|
|
465
|
+
let staticCode = "";
|
|
466
|
+
const notNeedBoundCheck = hasIf;
|
|
467
|
+
for (const key in node.static) {
|
|
468
|
+
const match = compileNode(ctx, node.static[key], params, currentIdx + 1);
|
|
469
|
+
if (match) {
|
|
470
|
+
staticCode += `${hasIf ? "else " : ""}if(s[${currentIdx}]===${JSON.stringify(key)}){${match}}`;
|
|
471
|
+
hasIf = true;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (staticCode) code += notNeedBoundCheck ? staticCode : `if(l>${currentIdx}){${staticCode}}`;
|
|
475
|
+
}
|
|
476
|
+
if (node.param) code += compileNode(ctx, node.param, params.concat(`s[${currentIdx}]`), currentIdx + 1);
|
|
477
|
+
if (node.wildcard) {
|
|
478
|
+
const { wildcard } = node;
|
|
479
|
+
if (wildcard.static || wildcard.param || wildcard.wildcard) throw new Error("Compiler mode does not support patterns after wildcard");
|
|
480
|
+
if (wildcard.methods) code += compileMethodMatch(ctx, wildcard.methods, params.concat(`s.slice(${currentIdx}).join('/')`), currentIdx);
|
|
481
|
+
}
|
|
482
|
+
return code;
|
|
483
|
+
}
|
|
484
|
+
function serializeData(ctx, value) {
|
|
485
|
+
if (ctx.compileToString) if (ctx.opts?.serialize) value = ctx.opts.serialize(value);
|
|
486
|
+
else if (typeof value?.toJSON === "function") value = value.toJSON();
|
|
487
|
+
else value = JSON.stringify(value);
|
|
488
|
+
let index = ctx.data.indexOf(value);
|
|
489
|
+
if (index === -1) {
|
|
490
|
+
ctx.data.push(value);
|
|
491
|
+
index = ctx.data.length - 1;
|
|
492
|
+
}
|
|
493
|
+
return `$${index}`;
|
|
494
|
+
}
|
|
495
|
+
//#endregion
|
|
496
|
+
export { findRoute as a, findAllRoutes as i, addRoute as n, createRouter as r, compileRouterToString as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/std-env@4.0.0/node_modules/std-env/dist/index.d.mts
|
|
2
|
+
//#endregion
|
|
3
|
+
//#region src/providers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Represents the name of a CI/CD or Deployment provider.
|
|
6
|
+
*/
|
|
7
|
+
type ProviderName = (string & {}) | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "cloudflare_workers" | "google_cloudrun" | "google_cloudrun_job" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting";
|
|
8
|
+
/**
|
|
9
|
+
* Provides information about a CI/CD or Deployment provider, including its name and possibly other metadata.
|
|
10
|
+
*/
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ProviderName as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|