nitro 3.0.1-alpha.2 → 3.0.260415-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +6 -0
- package/README.md +2 -2
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +7261 -3812
- package/dist/_build/rolldown.mjs +32 -42
- package/dist/_build/rollup.mjs +28 -48
- package/dist/_build/vite.build.mjs +10 -10
- package/dist/_chunks/nitro.mjs +102 -327
- package/dist/_chunks/nitro2.mjs +8 -9
- package/dist/_chunks/nitro3.mjs +136 -0
- package/dist/_chunks/nitro4.mjs +127 -0
- package/dist/_chunks/utils.mjs +40 -29
- package/dist/_common.mjs +13 -25
- package/dist/_dev.d.mts +0 -3
- package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -330
- package/dist/_libs/_.mjs +2 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +2 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +2 -0
- package/dist/_libs/_6.mjs +2 -0
- package/dist/_libs/_7.mjs +2 -0
- package/dist/_libs/c12+rc9.mjs +814 -0
- package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +49 -40
- package/dist/_libs/citty.mjs +142 -41
- package/dist/_libs/commondir+is-reference.mjs +60 -56
- package/dist/_libs/compatx.d.mts +0 -2
- package/dist/_libs/compatx.mjs +1 -4
- package/dist/_libs/esbuild.d.mts +0 -1
- package/dist/_libs/escape-string-regexp.mjs +1 -4
- package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +0 -5
- package/dist/_libs/estree-walker.mjs +4 -92
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +160 -246
- package/dist/_libs/httpxy.d.mts +20 -13
- package/dist/_libs/httpxy.mjs +519 -95
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +1 -4
- package/dist/_libs/magic-string.d.mts +0 -2
- package/dist/_libs/mlly.d.mts +0 -2
- package/dist/_libs/nypm+tinyexec.mjs +822 -0
- package/dist/_libs/perfect-debounce.mjs +68 -0
- package/dist/_libs/pkg-types.d.mts +0 -3
- package/dist/_libs/plugin-alias.mjs +1 -5
- package/dist/_libs/plugin-inject.mjs +1 -7
- package/dist/_libs/plugin-json.mjs +1 -5
- package/dist/_libs/pluginutils.mjs +3 -35
- package/dist/_libs/readdirp+chokidar.mjs +187 -365
- package/dist/_libs/remapping.mjs +1 -5
- package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -53
- package/dist/_libs/rou3.d.mts +1 -4
- package/dist/_libs/rou3.mjs +223 -78
- package/dist/_libs/std-env.d.mts +8 -2
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +21 -334
- package/dist/_libs/ultrahtml.mjs +3 -16
- package/dist/_libs/unimport+unplugin.mjs +244 -388
- package/dist/_libs/unplugin+unimport.d.mts +5 -15
- package/dist/_libs/unwasm.d.mts +0 -3
- package/dist/_presets.mjs +576 -488
- package/dist/builder.d.mts +5 -25
- package/dist/builder.mjs +3 -8
- package/dist/cli/_chunks/build.mjs +22 -25
- package/dist/cli/_chunks/common.mjs +1 -4
- package/dist/cli/_chunks/deploy.mjs +37 -0
- package/dist/cli/_chunks/dev.mjs +6 -11
- package/dist/cli/_chunks/docs.mjs +28 -0
- package/dist/cli/_chunks/list.mjs +4 -8
- package/dist/cli/_chunks/prepare.mjs +2 -6
- package/dist/cli/_chunks/preview.mjs +48 -0
- package/dist/cli/_chunks/run.mjs +7 -11
- package/dist/cli/_chunks/task.mjs +1 -5
- package/dist/cli/index.mjs +5 -6
- package/dist/docs/0.docs/0.index/index.md +56 -0
- package/dist/docs/0.docs/1.quick-start.md +110 -0
- package/dist/docs/0.docs/10.lifecycle.md +204 -0
- package/dist/docs/0.docs/11.openapi.md +291 -0
- package/dist/docs/0.docs/12.plugins.md +164 -0
- package/dist/docs/0.docs/13.tasks.md +277 -0
- package/dist/docs/0.docs/14.websocket.md +386 -0
- package/dist/docs/0.docs/15.migration.md +213 -0
- package/dist/docs/0.docs/16.nightly.md +31 -0
- package/dist/docs/0.docs/2.renderer.md +322 -0
- package/dist/docs/0.docs/3.routing.md +711 -0
- package/dist/docs/0.docs/4.server-entry.md +239 -0
- package/dist/docs/0.docs/5.cache.md +408 -0
- package/dist/docs/0.docs/6.storage.md +261 -0
- package/dist/docs/0.docs/7.assets.md +166 -0
- package/dist/docs/0.docs/8.configuration.md +256 -0
- package/dist/docs/0.docs/9.database.md +185 -0
- package/dist/docs/1.deploy/0.index/index.md +64 -0
- package/dist/docs/1.deploy/1.runtimes/0.node.md +63 -0
- package/dist/docs/1.deploy/1.runtimes/1.bun.md +15 -0
- package/dist/docs/1.deploy/1.runtimes/2.deno.md +19 -0
- package/dist/docs/1.deploy/2.providers/0.alwaysdata.md +50 -0
- package/dist/docs/1.deploy/2.providers/1.aws.md +47 -0
- package/dist/docs/1.deploy/2.providers/10.flightcontrol.md +67 -0
- package/dist/docs/1.deploy/2.providers/11.genezio.md +67 -0
- package/dist/docs/1.deploy/2.providers/12.github-pages.md +68 -0
- package/dist/docs/1.deploy/2.providers/13.gitlab-pages.md +37 -0
- package/dist/docs/1.deploy/2.providers/14.heroku.md +84 -0
- package/dist/docs/1.deploy/2.providers/15.iis.md +38 -0
- package/dist/docs/1.deploy/2.providers/16.koyeb.md +109 -0
- package/dist/docs/1.deploy/2.providers/17.netlify.md +47 -0
- package/dist/docs/1.deploy/2.providers/18.platform-sh.md +37 -0
- package/dist/docs/1.deploy/2.providers/19.render.md +37 -0
- package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +81 -0
- package/dist/docs/1.deploy/2.providers/20.stormkit.md +24 -0
- package/dist/docs/1.deploy/2.providers/21.vercel.md +270 -0
- package/dist/docs/1.deploy/2.providers/22.zeabur.md +19 -0
- package/dist/docs/1.deploy/2.providers/23.zephyr.md +99 -0
- package/dist/docs/1.deploy/2.providers/24.zerops.md +102 -0
- package/dist/docs/1.deploy/2.providers/3.azure.md +72 -0
- package/dist/docs/1.deploy/2.providers/4.cleavr.md +33 -0
- package/dist/docs/1.deploy/2.providers/5.cloudflare.md +369 -0
- package/dist/docs/1.deploy/2.providers/6.deno-deploy.md +66 -0
- package/dist/docs/1.deploy/2.providers/7.digitalocean.md +46 -0
- package/dist/docs/1.deploy/2.providers/8.edgeone.md +20 -0
- package/dist/docs/1.deploy/2.providers/9.firebase.md +32 -0
- package/dist/docs/2.config/0.index/index.md +1221 -0
- package/dist/docs/3.examples/0.index/index.md +3 -0
- package/dist/docs/3.examples/1.api-routes.md +145 -0
- package/dist/docs/3.examples/10.hono.md +74 -0
- package/dist/docs/3.examples/11.import-alias.md +97 -0
- package/dist/docs/3.examples/12.middleware.md +91 -0
- package/dist/docs/3.examples/13.mono-jsx.md +68 -0
- package/dist/docs/3.examples/14.nano-jsx.md +70 -0
- package/dist/docs/3.examples/15.plugins.md +91 -0
- package/dist/docs/3.examples/16.renderer.md +113 -0
- package/dist/docs/3.examples/17.runtime-config.md +97 -0
- package/dist/docs/3.examples/18.server-fetch.md +87 -0
- package/dist/docs/3.examples/19.shiki.md +198 -0
- package/dist/docs/3.examples/2.auto-imports.md +92 -0
- package/dist/docs/3.examples/20.virtual-routes.md +74 -0
- package/dist/docs/3.examples/21.vite-nitro-plugin.md +79 -0
- package/dist/docs/3.examples/22.vite-rsc.md +1041 -0
- package/dist/docs/3.examples/23.vite-ssr-html.md +217 -0
- package/dist/docs/3.examples/24.vite-ssr-preact.md +247 -0
- package/dist/docs/3.examples/25.vite-ssr-react.md +226 -0
- package/dist/docs/3.examples/26.vite-ssr-solid.md +256 -0
- package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +442 -0
- package/dist/docs/3.examples/28.vite-ssr-tss-react.md +444 -0
- package/dist/docs/3.examples/29.vite-ssr-vue-router.md +617 -0
- package/dist/docs/3.examples/3.cached-handler.md +81 -0
- package/dist/docs/3.examples/30.vite-trpc.md +335 -0
- package/dist/docs/3.examples/31.websocket.md +282 -0
- package/dist/docs/3.examples/4.custom-error-handler.md +98 -0
- package/dist/docs/3.examples/5.database.md +157 -0
- package/dist/docs/3.examples/6.elysia.md +70 -0
- package/dist/docs/3.examples/7.express.md +78 -0
- package/dist/docs/3.examples/8.fastify.md +79 -0
- package/dist/docs/3.examples/9.hello-world.md +68 -0
- package/dist/docs/README.md +86 -0
- package/dist/docs/index.md +121 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -4
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
- package/dist/node_modules/@speed-highlight/core/package.json +1 -1
- package/dist/node_modules/cookie-es/dist/index.mjs +299 -250
- package/dist/node_modules/cookie-es/package.json +26 -23
- package/dist/node_modules/croner/dist/croner.js +1 -1
- package/dist/node_modules/croner/package.json +11 -1
- package/dist/node_modules/defu/dist/defu.mjs +2 -2
- package/dist/node_modules/defu/package.json +33 -28
- package/dist/node_modules/rendu/dist/_chunks/libs/cookie-es.mjs +151 -0
- package/dist/node_modules/rendu/dist/index.mjs +5 -112
- package/dist/node_modules/rendu/package.json +25 -24
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +204 -351
- package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
- 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 +35 -32
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +12 -57
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +1 -2
- package/dist/presets/aws-lambda/runtime/_utils.mjs +6 -6
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
- package/dist/presets/azure/runtime/_utils.mjs +5 -5
- package/dist/presets/azure/runtime/azure-swa.mjs +5 -5
- package/dist/presets/bun/runtime/bun.mjs +9 -6
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +4 -4
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +3 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +10 -21
- package/dist/presets/deno/runtime/deno-deploy.mjs +4 -4
- package/dist/presets/deno/runtime/deno-server.mjs +9 -6
- package/dist/presets/edgeone/runtime/edgeone.mjs +10 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +2 -3
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +5 -4
- package/dist/presets/node/runtime/node-middleware.mjs +1 -1
- package/dist/presets/node/runtime/node-server.mjs +8 -5
- package/dist/presets/stormkit/runtime/stormkit.mjs +1 -2
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/queue-handler.mjs +21 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +3 -3
- package/dist/presets/vercel/runtime/vercel.web.mjs +3 -5
- package/dist/presets/winterjs/runtime/winterjs.mjs +10 -10
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/internal/app.mjs +12 -11
- package/dist/runtime/internal/cache.d.mts +0 -4
- package/dist/runtime/internal/cache.mjs +32 -256
- package/dist/runtime/internal/context.d.mts +3 -1
- package/dist/runtime/internal/context.mjs +1 -9
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +47 -49
- package/dist/runtime/internal/error/hooks.d.mts +1 -1
- package/dist/runtime/internal/error/prod.d.mts +2 -5
- package/dist/runtime/internal/error/prod.mjs +19 -33
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/route-rules.d.mts +11 -4
- package/dist/runtime/internal/route-rules.mjs +15 -5
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -10
- package/dist/runtime/internal/routes/openapi.mjs +2 -2
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
- package/dist/runtime/internal/routes/scalar.mjs +3 -3
- package/dist/runtime/internal/routes/swagger.mjs +7 -4
- package/dist/runtime/internal/runtime-config.d.mts +1 -1
- package/dist/runtime/internal/runtime-config.mjs +2 -2
- package/dist/runtime/internal/static.mjs +5 -4
- package/dist/runtime/internal/task.d.mts +3 -1
- package/dist/runtime/internal/task.mjs +7 -7
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/meta.d.mts +1 -0
- package/dist/runtime/meta.mjs +2 -0
- package/dist/runtime/nitro.d.mts +2 -0
- package/dist/runtime/nitro.mjs +4 -2
- package/dist/runtime/virtual/error-handler.mjs +1 -1
- package/dist/runtime/virtual/renderer-template.mjs +1 -1
- package/dist/runtime/virtual/server-assets.d.mts +2 -1
- package/dist/runtime/virtual/tracing.d.mts +5 -0
- package/dist/runtime/virtual/tracing.mjs +1 -0
- package/dist/runtime/vite.d.mts +1 -1
- package/dist/types/index.d.mts +215 -195
- package/dist/types/index.mjs +1 -11
- package/dist/vite.d.mts +3 -8
- package/dist/vite.mjs +285 -253
- package/lib/tsconfig.json +3 -5
- package/package.json +97 -80
- package/dist/_libs/confbox.mjs +0 -2509
- package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
- package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
- package/dist/node_modules/hookable/dist/index.mjs +0 -266
- package/dist/node_modules/hookable/package.json +0 -52
- package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
- package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
- package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
- package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
- package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
- package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
- package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
- package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
- package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
- package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
- package/dist/presets/azure/runtime/_utils.d.mts +0 -2
- package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
- package/dist/presets/bun/runtime/bun.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
- package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
- package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
- package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
- package/dist/presets/node/runtime/node-server.d.mts +0 -3
- package/dist/presets/standard/runtime/server.d.mts +0 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
- package/dist/presets/vercel/runtime/isr.d.mts +0 -2
- package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
- package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
- package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
- package/dist/runtime/internal/vite/node-runner.mjs +0 -359
package/dist/_libs/remapping.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { a as toDecodedMap, c as decodedMappings, i as setSourceContent, l as traceSegment, n as maybeAddSegment, o as toEncodedMap, r as setIgnore, s as TraceMap, t as GenMapping } from "./resolve-uri+gen-mapping.mjs";
|
|
2
|
-
|
|
3
|
-
//#region node_modules/.pnpm/@jridgewell+remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.mjs
|
|
4
2
|
var SOURCELESS_MAPPING = /* @__PURE__ */ SegmentObject("", -1, -1, "", null, false);
|
|
5
3
|
var EMPTY_SOURCES = [];
|
|
6
4
|
function SegmentObject(source, line, column, name, content, ignore) {
|
|
@@ -112,6 +110,4 @@ function remapping(input, loader, options) {
|
|
|
112
110
|
};
|
|
113
111
|
return new SourceMap(traceMappings(buildSourceMapTree(input, loader)), opts);
|
|
114
112
|
}
|
|
115
|
-
|
|
116
|
-
//#endregion
|
|
117
|
-
export { remapping as t };
|
|
113
|
+
export { remapping as t };
|
|
@@ -1,27 +1,6 @@
|
|
|
1
1
|
import { C as decode, w as encode } from "../_build/common.mjs";
|
|
2
|
-
|
|
3
|
-
//#region node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
|
|
4
2
|
const schemeRegex = /^[\w+.-]+:\/\//;
|
|
5
|
-
/**
|
|
6
|
-
* Matches the parts of a URL:
|
|
7
|
-
* 1. Scheme, including ":", guaranteed.
|
|
8
|
-
* 2. User/password, including "@", optional.
|
|
9
|
-
* 3. Host, guaranteed.
|
|
10
|
-
* 4. Port, including ":", optional.
|
|
11
|
-
* 5. Path, including "/", optional.
|
|
12
|
-
* 6. Query, including "?", optional.
|
|
13
|
-
* 7. Hash, including "#", optional.
|
|
14
|
-
*/
|
|
15
3
|
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
16
|
-
/**
|
|
17
|
-
* File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
|
|
18
|
-
* with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
|
|
19
|
-
*
|
|
20
|
-
* 1. Host, optional.
|
|
21
|
-
* 2. Path, which may include "/", guaranteed.
|
|
22
|
-
* 3. Query, including "?", optional.
|
|
23
|
-
* 4. Hash, including "#", optional.
|
|
24
|
-
*/
|
|
25
4
|
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
26
5
|
function isAbsoluteUrl(input) {
|
|
27
6
|
return schemeRegex.test(input);
|
|
@@ -61,17 +40,17 @@ function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
|
61
40
|
}
|
|
62
41
|
function parseUrl(input) {
|
|
63
42
|
if (isSchemeRelativeUrl(input)) {
|
|
64
|
-
const url
|
|
65
|
-
url
|
|
66
|
-
url
|
|
67
|
-
return url
|
|
43
|
+
const url = parseAbsoluteUrl("http:" + input);
|
|
44
|
+
url.scheme = "";
|
|
45
|
+
url.type = 6;
|
|
46
|
+
return url;
|
|
68
47
|
}
|
|
69
48
|
if (isAbsolutePath(input)) {
|
|
70
|
-
const url
|
|
71
|
-
url
|
|
72
|
-
url
|
|
73
|
-
url
|
|
74
|
-
return url
|
|
49
|
+
const url = parseAbsoluteUrl("http://foo.com" + input);
|
|
50
|
+
url.scheme = "";
|
|
51
|
+
url.host = "";
|
|
52
|
+
url.type = 5;
|
|
53
|
+
return url;
|
|
75
54
|
}
|
|
76
55
|
if (isFileUrl(input)) return parseFileUrl(input);
|
|
77
56
|
if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
|
|
@@ -91,10 +70,6 @@ function mergePaths(url, base) {
|
|
|
91
70
|
if (url.path === "/") url.path = base.path;
|
|
92
71
|
else url.path = stripPathFilename(base.path) + url.path;
|
|
93
72
|
}
|
|
94
|
-
/**
|
|
95
|
-
* The path can have empty directories "//", unneeded parents "foo/..", or current directory
|
|
96
|
-
* "foo/.". We need to normalize to a standard representation.
|
|
97
|
-
*/
|
|
98
73
|
function normalizePath(url, type) {
|
|
99
74
|
const rel = type <= 4;
|
|
100
75
|
const pieces = url.path.split("/");
|
|
@@ -125,9 +100,6 @@ function normalizePath(url, type) {
|
|
|
125
100
|
if (!path || addTrailingSlash && !path.endsWith("/..")) path += "/";
|
|
126
101
|
url.path = path;
|
|
127
102
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Attempts to resolve `input` URL/path relative to `base`.
|
|
130
|
-
*/
|
|
131
103
|
function resolve(input, base) {
|
|
132
104
|
if (!input && !base) return "";
|
|
133
105
|
const url = parseUrl(input);
|
|
@@ -163,9 +135,6 @@ function resolve(input, base) {
|
|
|
163
135
|
default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
|
|
164
136
|
}
|
|
165
137
|
}
|
|
166
|
-
|
|
167
|
-
//#endregion
|
|
168
|
-
//#region node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
|
|
169
138
|
function stripFilename(path) {
|
|
170
139
|
if (!path) return "";
|
|
171
140
|
const index = path.lastIndexOf("/");
|
|
@@ -248,8 +217,6 @@ function memoizedBinarySearch(haystack, needle, state, key) {
|
|
|
248
217
|
function parse(map) {
|
|
249
218
|
return typeof map === "string" ? JSON.parse(map) : map;
|
|
250
219
|
}
|
|
251
|
-
var LEAST_UPPER_BOUND = -1;
|
|
252
|
-
var GREATEST_LOWER_BOUND = 1;
|
|
253
220
|
var TraceMap = class {
|
|
254
221
|
constructor(map, mapUrl) {
|
|
255
222
|
const isString = typeof map === "string";
|
|
@@ -263,8 +230,8 @@ var TraceMap = class {
|
|
|
263
230
|
this.sources = sources;
|
|
264
231
|
this.sourcesContent = sourcesContent;
|
|
265
232
|
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
266
|
-
const resolve
|
|
267
|
-
this.resolvedSources = sources.map(resolve
|
|
233
|
+
const resolve = resolver(mapUrl, sourceRoot);
|
|
234
|
+
this.resolvedSources = sources.map(resolve);
|
|
268
235
|
const { mappings } = parsed;
|
|
269
236
|
if (typeof mappings === "string") {
|
|
270
237
|
this._encoded = mappings;
|
|
@@ -290,19 +257,16 @@ function traceSegment(map, line, column) {
|
|
|
290
257
|
const decoded = decodedMappings(map);
|
|
291
258
|
if (line >= decoded.length) return null;
|
|
292
259
|
const segments = decoded[line];
|
|
293
|
-
const index = traceSegmentInternal(segments, cast$1(map)._decodedMemo, line, column,
|
|
260
|
+
const index = traceSegmentInternal(segments, cast$1(map)._decodedMemo, line, column, 1);
|
|
294
261
|
return index === -1 ? null : segments[index];
|
|
295
262
|
}
|
|
296
263
|
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
297
264
|
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
298
|
-
if (found) index = (bias ===
|
|
299
|
-
else if (bias ===
|
|
265
|
+
if (found) index = (bias === -1 ? upperBound : lowerBound)(segments, column, index);
|
|
266
|
+
else if (bias === -1) index++;
|
|
300
267
|
if (index === -1 || index === segments.length) return -1;
|
|
301
268
|
return index;
|
|
302
269
|
}
|
|
303
|
-
|
|
304
|
-
//#endregion
|
|
305
|
-
//#region node_modules/.pnpm/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
|
|
306
270
|
var SetArray = class {
|
|
307
271
|
constructor() {
|
|
308
272
|
this._indexes = { __proto__: null };
|
|
@@ -443,6 +407,4 @@ function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIn
|
|
|
443
407
|
if (prev.length === 1) return false;
|
|
444
408
|
return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME);
|
|
445
409
|
}
|
|
446
|
-
|
|
447
|
-
//#endregion
|
|
448
|
-
export { toDecodedMap as a, decodedMappings as c, setSourceContent as i, traceSegment as l, maybeAddSegment as n, toEncodedMap as o, setIgnore as r, TraceMap as s, GenMapping as t };
|
|
410
|
+
export { toDecodedMap as a, decodedMappings as c, setSourceContent as i, traceSegment as l, maybeAddSegment as n, toEncodedMap as o, setIgnore as r, TraceMap as s, GenMapping as t };
|
package/dist/_libs/rou3.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/rou3@0.7.12/node_modules/rou3/dist/index.d.mts
|
|
2
1
|
interface RouterContext<T = unknown> {
|
|
3
2
|
root: Node<T>;
|
|
4
3
|
static: Record<string, Node<T> | undefined>;
|
|
@@ -17,10 +16,9 @@ interface Node<T = unknown> {
|
|
|
17
16
|
hasRegexParam?: boolean;
|
|
18
17
|
methods?: Record<string, MethodData<T>[] | undefined>;
|
|
19
18
|
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region node_modules/.pnpm/rou3@0.7.12/node_modules/rou3/dist/compiler.d.mts
|
|
22
19
|
interface RouterCompilerOptions<T = any> {
|
|
23
20
|
matchAll?: boolean;
|
|
21
|
+
normalize?: boolean;
|
|
24
22
|
serialize?: (data: T) => string;
|
|
25
23
|
}
|
|
26
24
|
/**
|
|
@@ -39,5 +37,4 @@ interface RouterCompilerOptions<T = any> {
|
|
|
39
37
|
*
|
|
40
38
|
* @param router - The router context to compile.
|
|
41
39
|
*/
|
|
42
|
-
//#endregion
|
|
43
40
|
export { RouterContext as n, RouterCompilerOptions as t };
|
package/dist/_libs/rou3.mjs
CHANGED
|
@@ -1,17 +1,150 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/rou3@0.7.12/node_modules/rou3/dist/index.mjs
|
|
2
1
|
const NullProtoObj = /* @__PURE__ */ (() => {
|
|
3
2
|
const e = function() {};
|
|
4
3
|
return e.prototype = Object.create(null), Object.freeze(e.prototype), e;
|
|
5
4
|
})();
|
|
6
|
-
/**
|
|
7
|
-
* Create a new router context.
|
|
8
|
-
*/
|
|
9
5
|
function createRouter() {
|
|
10
6
|
return {
|
|
11
7
|
root: { key: "" },
|
|
12
8
|
static: new NullProtoObj()
|
|
13
9
|
};
|
|
14
10
|
}
|
|
11
|
+
function expandGroupDelimiters(path) {
|
|
12
|
+
let i = 0;
|
|
13
|
+
let depth = 0;
|
|
14
|
+
for (; i < path.length; i++) {
|
|
15
|
+
const c = path.charCodeAt(i);
|
|
16
|
+
if (c === 92) {
|
|
17
|
+
i++;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (c === 40) {
|
|
21
|
+
depth++;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (c === 41 && depth > 0) {
|
|
25
|
+
depth--;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (c === 123 && depth === 0) break;
|
|
29
|
+
}
|
|
30
|
+
if (i >= path.length) return;
|
|
31
|
+
let j = i + 1;
|
|
32
|
+
depth = 0;
|
|
33
|
+
for (; j < path.length; j++) {
|
|
34
|
+
const c = path.charCodeAt(j);
|
|
35
|
+
if (c === 92) {
|
|
36
|
+
j++;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (c === 40) {
|
|
40
|
+
depth++;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (c === 41 && depth > 0) {
|
|
44
|
+
depth--;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (c === 125 && depth === 0) break;
|
|
48
|
+
}
|
|
49
|
+
if (j >= path.length) return;
|
|
50
|
+
const mod = path[j + 1];
|
|
51
|
+
const hasMod = mod === "?" || mod === "+" || mod === "*";
|
|
52
|
+
const pre = path.slice(0, i);
|
|
53
|
+
const body = path.slice(i + 1, j);
|
|
54
|
+
const suf = path.slice(j + (hasMod ? 2 : 1));
|
|
55
|
+
if (!hasMod) return [pre + body + suf];
|
|
56
|
+
if (mod === "?") return [pre + body + suf, pre + suf];
|
|
57
|
+
if (body.includes("/")) throw new Error("unsupported group repetition across segments");
|
|
58
|
+
return [`${pre}(?:${body})${mod}${suf}`];
|
|
59
|
+
}
|
|
60
|
+
const UNNAMED_GROUP_PREFIX$1 = "__rou3_unnamed_";
|
|
61
|
+
const _unnamedGroupPrefixLength = 15;
|
|
62
|
+
function hasSegmentWildcard(segment) {
|
|
63
|
+
let depth = 0;
|
|
64
|
+
for (let i = 0; i < segment.length; i++) {
|
|
65
|
+
const ch = segment.charCodeAt(i);
|
|
66
|
+
if (ch === 92) {
|
|
67
|
+
i++;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (ch === 40) {
|
|
71
|
+
depth++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (ch === 41 && depth > 0) {
|
|
75
|
+
depth--;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (ch === 42 && depth === 0) return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGroupKey) {
|
|
83
|
+
let depth = 0;
|
|
84
|
+
let nextIndex = unnamedStart;
|
|
85
|
+
let replaced = "";
|
|
86
|
+
for (let i = 0; i < segment.length; i++) {
|
|
87
|
+
const ch = segment.charCodeAt(i);
|
|
88
|
+
if (ch === 92) {
|
|
89
|
+
replaced += segment[i];
|
|
90
|
+
if (i + 1 < segment.length) replaced += segment[++i];
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (ch === 40) {
|
|
94
|
+
depth++;
|
|
95
|
+
replaced += segment[i];
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (ch === 41 && depth > 0) {
|
|
99
|
+
depth--;
|
|
100
|
+
replaced += segment[i];
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (ch === 42 && depth === 0) {
|
|
104
|
+
replaced += `(?<${toGroupKey(nextIndex++)}>[^/]*)`;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
replaced += segment[i];
|
|
108
|
+
}
|
|
109
|
+
return [replaced, nextIndex];
|
|
110
|
+
}
|
|
111
|
+
function toUnnamedGroupKey(index) {
|
|
112
|
+
return `${UNNAMED_GROUP_PREFIX$1}${index}`;
|
|
113
|
+
}
|
|
114
|
+
function normalizeUnnamedGroupKey(key) {
|
|
115
|
+
return key.startsWith("__rou3_unnamed_") ? key.slice(_unnamedGroupPrefixLength) : key;
|
|
116
|
+
}
|
|
117
|
+
function encodeEscapes(path) {
|
|
118
|
+
return path.replace(/\\:/g, "�A").replace(/\\\(/g, "�B").replace(/\\\)/g, "�C").replace(/\\\{/g, "�D").replace(/\\\}/g, "�E");
|
|
119
|
+
}
|
|
120
|
+
function decodeEscaped(segment) {
|
|
121
|
+
return segment.replace(/\uFFFD([A-E])/g, (_, c) => c === "A" ? ":" : c === "B" ? "(" : c === "C" ? ")" : c === "D" ? "{" : "}");
|
|
122
|
+
}
|
|
123
|
+
function expandModifiers(segments) {
|
|
124
|
+
for (let i = 0; i < segments.length; i++) {
|
|
125
|
+
const m = segments[i].match(/^(.*:[\w-]+(?:\([^)]*\))?)([?+*])$/);
|
|
126
|
+
if (!m) continue;
|
|
127
|
+
const pre = segments.slice(0, i);
|
|
128
|
+
const suf = segments.slice(i + 1);
|
|
129
|
+
if (m[2] === "?") return ["/" + pre.concat(m[1]).concat(suf).join("/"), "/" + pre.concat(suf).join("/")];
|
|
130
|
+
const name = m[1].match(/:([\w-]+)/)?.[1] || "_";
|
|
131
|
+
const wc = "/" + [
|
|
132
|
+
...pre,
|
|
133
|
+
`**:${name}`,
|
|
134
|
+
...suf
|
|
135
|
+
].join("/");
|
|
136
|
+
const without = "/" + [...pre, ...suf].join("/");
|
|
137
|
+
return m[2] === "+" ? [wc] : [wc, without];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function normalizePath(path) {
|
|
141
|
+
if (!path.includes("/.")) return path;
|
|
142
|
+
const r = [];
|
|
143
|
+
for (const s of path.split("/")) if (s === ".") continue;
|
|
144
|
+
else if (s === ".." && r.length > 1) r.pop();
|
|
145
|
+
else r.push(s);
|
|
146
|
+
return r.join("/") || "/";
|
|
147
|
+
}
|
|
15
148
|
function splitPath(path) {
|
|
16
149
|
const [_, ...s] = path.split("/");
|
|
17
150
|
return s[s.length - 1] === "" ? s.slice(0, -1) : s;
|
|
@@ -23,19 +156,26 @@ function getMatchParams(segments, paramsMap) {
|
|
|
23
156
|
if (typeof name === "string") params[name] = segment;
|
|
24
157
|
else {
|
|
25
158
|
const match = segment.match(name);
|
|
26
|
-
if (match) for (const key in match.groups) params[key] = match.groups[key];
|
|
159
|
+
if (match) for (const key in match.groups) params[normalizeUnnamedGroupKey(key)] = match.groups[key];
|
|
27
160
|
}
|
|
28
161
|
}
|
|
29
162
|
return params;
|
|
30
163
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Add a route to the router context.
|
|
33
|
-
*/
|
|
34
164
|
function addRoute(ctx, method = "", path, data) {
|
|
35
165
|
method = method.toUpperCase();
|
|
36
166
|
if (path.charCodeAt(0) !== 47) path = `/${path}`;
|
|
37
|
-
|
|
167
|
+
const groupExpanded = expandGroupDelimiters(path);
|
|
168
|
+
if (groupExpanded) {
|
|
169
|
+
for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
path = encodeEscapes(path);
|
|
38
173
|
const segments = splitPath(path);
|
|
174
|
+
const expanded = expandModifiers(segments);
|
|
175
|
+
if (expanded) {
|
|
176
|
+
for (const p of expanded) addRoute(ctx, method, p, data);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
39
179
|
let node = ctx.root;
|
|
40
180
|
let _unnamedParamIndex = 0;
|
|
41
181
|
const paramsMap = [];
|
|
@@ -52,16 +192,17 @@ function addRoute(ctx, method = "", path, data) {
|
|
|
52
192
|
]);
|
|
53
193
|
break;
|
|
54
194
|
}
|
|
55
|
-
if (segment === "*" || segment.includes(":")) {
|
|
195
|
+
if (segment === "*" || segment.includes(":") || segment.includes("(") || hasSegmentWildcard(segment)) {
|
|
56
196
|
if (!node.param) node.param = { key: "*" };
|
|
57
197
|
node = node.param;
|
|
58
198
|
if (segment === "*") paramsMap.push([
|
|
59
199
|
i,
|
|
60
|
-
|
|
200
|
+
String(_unnamedParamIndex++),
|
|
61
201
|
true
|
|
62
202
|
]);
|
|
63
|
-
else if (segment.includes(":", 1)) {
|
|
64
|
-
const regexp = getParamRegexp(segment);
|
|
203
|
+
else if (segment.includes(":", 1) || segment.includes("(") || hasSegmentWildcard(segment) || !/^:[\w-]+$/.test(segment)) {
|
|
204
|
+
const [regexp, nextIndex] = getParamRegexp(segment, _unnamedParamIndex);
|
|
205
|
+
_unnamedParamIndex = nextIndex;
|
|
65
206
|
paramsRegexp[i] = regexp;
|
|
66
207
|
node.hasRegexParam = true;
|
|
67
208
|
paramsMap.push([
|
|
@@ -78,6 +219,7 @@ function addRoute(ctx, method = "", path, data) {
|
|
|
78
219
|
}
|
|
79
220
|
if (segment === "\\*") segment = segments[i] = "*";
|
|
80
221
|
else if (segment === "\\*\\*") segment = segments[i] = "**";
|
|
222
|
+
segment = segments[i] = decodeEscaped(segment);
|
|
81
223
|
const child = node.static?.[segment];
|
|
82
224
|
if (child) node = child;
|
|
83
225
|
else {
|
|
@@ -97,14 +239,29 @@ function addRoute(ctx, method = "", path, data) {
|
|
|
97
239
|
});
|
|
98
240
|
if (!hasParams) ctx.static["/" + segments.join("/")] = node;
|
|
99
241
|
}
|
|
100
|
-
function getParamRegexp(segment) {
|
|
101
|
-
|
|
102
|
-
|
|
242
|
+
function getParamRegexp(segment, unnamedStart = 0) {
|
|
243
|
+
let _i = unnamedStart;
|
|
244
|
+
let _s = "", _d = 0;
|
|
245
|
+
for (let j = 0; j < segment.length; j++) {
|
|
246
|
+
const c = segment.charCodeAt(j);
|
|
247
|
+
if (c === 40) _d++;
|
|
248
|
+
else if (c === 41 && _d > 0) _d--;
|
|
249
|
+
else if (c === 92 && _d === 0 && j + 1 < segment.length) {
|
|
250
|
+
const n = segment[j + 1];
|
|
251
|
+
if (n !== ":" && n !== "(" && n !== "*" && n !== "\\") {
|
|
252
|
+
_s += "" + n;
|
|
253
|
+
j++;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
_s += segment[j];
|
|
258
|
+
}
|
|
259
|
+
[_s, _i] = replaceSegmentWildcards(_s, _i);
|
|
260
|
+
const regex = _s.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id, p) => `(?<${id}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i++)}>`).replace(/\./g, "\\.").replace(/\uFFFE(.)/g, (_, c) => /[.*+?^${}()|[\]\\]/.test(c) ? `\\${c}` : c);
|
|
261
|
+
return [new RegExp(`^${regex}$`), _i];
|
|
103
262
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Find a route by path.
|
|
106
|
-
*/
|
|
107
263
|
function findRoute(ctx, method = "", path, opts) {
|
|
264
|
+
if (opts?.normalize) path = normalizePath(path);
|
|
108
265
|
if (path.charCodeAt(path.length - 1) === 47) path = path.slice(0, -1);
|
|
109
266
|
const staticNode = ctx.static[path];
|
|
110
267
|
if (staticNode && staticNode.methods) {
|
|
@@ -112,7 +269,7 @@ function findRoute(ctx, method = "", path, opts) {
|
|
|
112
269
|
if (staticMatch !== void 0) return staticMatch[0];
|
|
113
270
|
}
|
|
114
271
|
const segments = splitPath(path);
|
|
115
|
-
const match = _lookupTree(ctx
|
|
272
|
+
const match = _lookupTree(ctx.root, method, segments, 0)?.[0];
|
|
116
273
|
if (match === void 0) return;
|
|
117
274
|
if (opts?.params === false) return match;
|
|
118
275
|
return {
|
|
@@ -120,7 +277,7 @@ function findRoute(ctx, method = "", path, opts) {
|
|
|
120
277
|
params: match.paramsMap ? getMatchParams(segments, match.paramsMap) : void 0
|
|
121
278
|
};
|
|
122
279
|
}
|
|
123
|
-
function _lookupTree(
|
|
280
|
+
function _lookupTree(node, method, segments, index) {
|
|
124
281
|
if (index === segments.length) {
|
|
125
282
|
if (node.methods) {
|
|
126
283
|
const match = node.methods[method] || node.methods[""];
|
|
@@ -146,12 +303,12 @@ function _lookupTree(ctx, node, method, segments, index) {
|
|
|
146
303
|
if (node.static) {
|
|
147
304
|
const staticChild = node.static[segment];
|
|
148
305
|
if (staticChild) {
|
|
149
|
-
const match = _lookupTree(
|
|
306
|
+
const match = _lookupTree(staticChild, method, segments, index + 1);
|
|
150
307
|
if (match) return match;
|
|
151
308
|
}
|
|
152
309
|
}
|
|
153
310
|
if (node.param) {
|
|
154
|
-
const match = _lookupTree(
|
|
311
|
+
const match = _lookupTree(node.param, method, segments, index + 1);
|
|
155
312
|
if (match) {
|
|
156
313
|
if (node.param.hasRegexParam) {
|
|
157
314
|
const exactMatch = match.find((m) => m.paramsRegexp[index]?.test(segment)) || match.find((m) => !m.paramsRegexp[index]);
|
|
@@ -162,13 +319,11 @@ function _lookupTree(ctx, node, method, segments, index) {
|
|
|
162
319
|
}
|
|
163
320
|
if (node.wildcard && node.wildcard.methods) return node.wildcard.methods[method] || node.wildcard.methods[""];
|
|
164
321
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Find all route patterns that match the given path.
|
|
167
|
-
*/
|
|
168
322
|
function findAllRoutes(ctx, method = "", path, opts) {
|
|
323
|
+
if (opts?.normalize) path = normalizePath(path);
|
|
169
324
|
if (path.charCodeAt(path.length - 1) === 47) path = path.slice(0, -1);
|
|
170
325
|
const segments = splitPath(path);
|
|
171
|
-
const matches = _findAll(ctx
|
|
326
|
+
const matches = _findAll(ctx.root, method, segments, 0);
|
|
172
327
|
if (opts?.params === false) return matches;
|
|
173
328
|
return matches.map((m) => {
|
|
174
329
|
return {
|
|
@@ -177,14 +332,14 @@ function findAllRoutes(ctx, method = "", path, opts) {
|
|
|
177
332
|
};
|
|
178
333
|
});
|
|
179
334
|
}
|
|
180
|
-
function _findAll(
|
|
335
|
+
function _findAll(node, method, segments, index, matches = []) {
|
|
181
336
|
const segment = segments[index];
|
|
182
337
|
if (node.wildcard && node.wildcard.methods) {
|
|
183
338
|
const match = node.wildcard.methods[method] || node.wildcard.methods[""];
|
|
184
339
|
if (match) matches.push(...match);
|
|
185
340
|
}
|
|
186
341
|
if (node.param) {
|
|
187
|
-
_findAll(
|
|
342
|
+
_findAll(node.param, method, segments, index + 1, matches);
|
|
188
343
|
if (index === segments.length && node.param.methods) {
|
|
189
344
|
const match = node.param.methods[method] || node.param.methods[""];
|
|
190
345
|
if (match) {
|
|
@@ -194,29 +349,14 @@ function _findAll(ctx, node, method, segments, index, matches = []) {
|
|
|
194
349
|
}
|
|
195
350
|
}
|
|
196
351
|
const staticChild = node.static?.[segment];
|
|
197
|
-
if (staticChild) _findAll(
|
|
352
|
+
if (staticChild) _findAll(staticChild, method, segments, index + 1, matches);
|
|
198
353
|
if (index === segments.length && node.methods) {
|
|
199
354
|
const match = node.methods[method] || node.methods[""];
|
|
200
355
|
if (match) matches.push(...match);
|
|
201
356
|
}
|
|
202
357
|
return matches;
|
|
203
358
|
}
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region node_modules/.pnpm/rou3@0.7.12/node_modules/rou3/dist/compiler.mjs
|
|
207
|
-
/**
|
|
208
|
-
* Compile the router instance into a compact runnable code.
|
|
209
|
-
*
|
|
210
|
-
* **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.
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
* import { createRouter, addRoute } from "rou3";
|
|
214
|
-
* import { compileRouterToString } from "rou3/compiler";
|
|
215
|
-
* const router = createRouter();
|
|
216
|
-
* // [add some routes with serializable data]
|
|
217
|
-
* const compilerCode = compileRouterToString(router, "findRoute");
|
|
218
|
-
* // "const findRoute=(m, p) => {}"
|
|
219
|
-
*/
|
|
359
|
+
const UNNAMED_GROUP_PREFIX = "__rou3_unnamed_";
|
|
220
360
|
function compileRouterToString(router, functionName, opts) {
|
|
221
361
|
const ctx = {
|
|
222
362
|
opts: opts || {},
|
|
@@ -230,24 +370,28 @@ function compileRouterToString(router, functionName, opts) {
|
|
|
230
370
|
}
|
|
231
371
|
function compileRouteMatch(ctx) {
|
|
232
372
|
let code = "";
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
373
|
+
{
|
|
374
|
+
let hasIf = false;
|
|
375
|
+
for (const key in ctx.router.static) {
|
|
376
|
+
const node = ctx.router.static[key];
|
|
377
|
+
if (node?.methods) {
|
|
378
|
+
code += `${hasIf ? "else " : ""}if(p===${JSON.stringify(key.replace(/\/$/, "") || "/")}){${compileMethodMatch(ctx, node.methods, [], -1)}}`;
|
|
379
|
+
hasIf = true;
|
|
380
|
+
}
|
|
239
381
|
}
|
|
240
382
|
}
|
|
241
|
-
const match = compileNode(ctx, ctx.router.root, [],
|
|
242
|
-
if (match) code += `let s=p.split("/"),l=s.length
|
|
383
|
+
const match = compileNode(ctx, ctx.router.root, [], 1);
|
|
384
|
+
if (match) code += `let s=p.split("/"),l=s.length;${match}`;
|
|
243
385
|
if (!code) return ctx.opts?.matchAll ? `return [];` : "";
|
|
244
|
-
|
|
386
|
+
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;};` : "";
|
|
387
|
+
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("/")||"/"}` : "";
|
|
388
|
+
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;" : ""}`;
|
|
245
389
|
}
|
|
246
390
|
function compileMethodMatch(ctx, methods, params, currentIdx) {
|
|
247
391
|
let code = "";
|
|
248
392
|
for (const key in methods) {
|
|
249
393
|
const matchers = methods[key];
|
|
250
|
-
if (matchers && matchers
|
|
394
|
+
if (matchers && matchers.length > 0) {
|
|
251
395
|
if (key !== "") code += `if(m==="${key}")${matchers.length > 1 ? "{" : ""}`;
|
|
252
396
|
const _matchers = matchers.map((m) => compileFinalMatch(ctx, m, currentIdx, params)).sort((a, b) => b.weight - a.weight);
|
|
253
397
|
for (const matcher of _matchers) code += matcher.code;
|
|
@@ -261,7 +405,7 @@ function compileFinalMatch(ctx, data, currentIdx, params) {
|
|
|
261
405
|
const conditions = [];
|
|
262
406
|
const { paramsMap, paramsRegexp } = data;
|
|
263
407
|
if (paramsMap && paramsMap.length > 0) {
|
|
264
|
-
if (!paramsMap[paramsMap.length - 1][2] && currentIdx !== -1) conditions.push(`l
|
|
408
|
+
if (!paramsMap[paramsMap.length - 1][2] && currentIdx !== -1) conditions.push(`l>${currentIdx}`);
|
|
265
409
|
for (let i = 0; i < paramsRegexp.length; i++) {
|
|
266
410
|
const regexp = paramsRegexp[i];
|
|
267
411
|
if (!regexp) continue;
|
|
@@ -270,7 +414,7 @@ function compileFinalMatch(ctx, data, currentIdx, params) {
|
|
|
270
414
|
ret += ",params:{";
|
|
271
415
|
for (let i = 0; i < paramsMap.length; i++) {
|
|
272
416
|
const map = paramsMap[i];
|
|
273
|
-
ret += typeof map[1] === "string" ? `${JSON.stringify(map[1])}:${params[i]},` : `...(${map[1].toString()}.exec(${params[i]}))?.groups,`;
|
|
417
|
+
ret += typeof map[1] === "string" ? `${JSON.stringify(map[1])}:${params[i]},` : `..._normalizeGroups((${map[1].toString()}.exec(${params[i]}))?.groups),`;
|
|
274
418
|
}
|
|
275
419
|
ret += "}";
|
|
276
420
|
}
|
|
@@ -279,30 +423,33 @@ function compileFinalMatch(ctx, data, currentIdx, params) {
|
|
|
279
423
|
weight: conditions.length
|
|
280
424
|
};
|
|
281
425
|
}
|
|
282
|
-
function compileNode(ctx, node, params,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
426
|
+
function compileNode(ctx, node, params, currentIdx) {
|
|
427
|
+
const hasLastOptionalParam = node.key === "*";
|
|
428
|
+
let code = "", hasIf = false;
|
|
429
|
+
if (node.methods && params.length > 0) {
|
|
430
|
+
const match = compileMethodMatch(ctx, node.methods, params, hasLastOptionalParam ? currentIdx - 1 : -1);
|
|
286
431
|
if (match) {
|
|
287
|
-
|
|
288
|
-
|
|
432
|
+
code += `if(l===${currentIdx}${hasLastOptionalParam ? `||l===${currentIdx - 1}` : ""}){${match}}`;
|
|
433
|
+
hasIf = true;
|
|
289
434
|
}
|
|
290
435
|
}
|
|
291
|
-
if (node.static)
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
436
|
+
if (node.static) {
|
|
437
|
+
let staticCode = "";
|
|
438
|
+
const notNeedBoundCheck = hasIf;
|
|
439
|
+
for (const key in node.static) {
|
|
440
|
+
const match = compileNode(ctx, node.static[key], params, currentIdx + 1);
|
|
441
|
+
if (match) {
|
|
442
|
+
staticCode += `${hasIf ? "else " : ""}if(s[${currentIdx}]===${JSON.stringify(key)}){${match}}`;
|
|
443
|
+
hasIf = true;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
if (staticCode) code += notNeedBoundCheck ? staticCode : `if(l>${currentIdx}){${staticCode}}`;
|
|
298
447
|
}
|
|
448
|
+
if (node.param) code += compileNode(ctx, node.param, params.concat(`s[${currentIdx}]`), currentIdx + 1);
|
|
299
449
|
if (node.wildcard) {
|
|
300
450
|
const { wildcard } = node;
|
|
301
451
|
if (wildcard.static || wildcard.param || wildcard.wildcard) throw new Error("Compiler mode does not support patterns after wildcard");
|
|
302
|
-
if (wildcard.methods) {
|
|
303
|
-
const match = compileMethodMatch(ctx, wildcard.methods, [...params, `s.slice(${startIdx + 1}).join('/')`], startIdx);
|
|
304
|
-
if (match) code += match;
|
|
305
|
-
}
|
|
452
|
+
if (wildcard.methods) code += compileMethodMatch(ctx, wildcard.methods, params.concat(`s.slice(${currentIdx}).join('/')`), currentIdx);
|
|
306
453
|
}
|
|
307
454
|
return code;
|
|
308
455
|
}
|
|
@@ -317,6 +464,4 @@ function serializeData(ctx, value) {
|
|
|
317
464
|
}
|
|
318
465
|
return `$${index}`;
|
|
319
466
|
}
|
|
320
|
-
|
|
321
|
-
//#endregion
|
|
322
|
-
export { findRoute as a, findAllRoutes as i, addRoute as n, createRouter as r, compileRouterToString as t };
|
|
467
|
+
export { findRoute as a, findAllRoutes as i, addRoute as n, createRouter as r, compileRouterToString as t };
|
package/dist/_libs/std-env.d.mts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/std-env@3.10.0/node_modules/std-env/dist/index.d.ts
|
|
2
|
-
type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "cloudflare_workers" | "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";
|
|
3
1
|
//#endregion
|
|
2
|
+
//#region src/providers.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Represents the name of a CI/CD or Deployment provider.
|
|
5
|
+
*/
|
|
6
|
+
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" | "edgeone_pages";
|
|
7
|
+
/**
|
|
8
|
+
* Provides information about a CI/CD or Deployment provider, including its name and possibly other metadata.
|
|
9
|
+
*/
|
|
4
10
|
export { ProviderName as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|