nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-121649-98b56dfe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_build/common.mjs +763 -0
- package/dist/_build/rolldown.mjs +216 -0
- package/dist/_build/rollup.mjs +359 -0
- package/dist/_build/vite.build.mjs +67 -0
- package/dist/_build/vite.plugin.mjs +747 -0
- package/dist/_chunks/B-7HiF0V.mjs +1303 -0
- package/dist/_chunks/B3asVbT4.mjs +151 -0
- package/dist/_chunks/B5ooyfLk.mjs +372 -0
- package/dist/_chunks/DXMHy5ca.mjs +43 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +675 -0
- package/dist/_libs/acorn.mjs +5034 -0
- package/dist/_libs/c12.mjs +2798 -0
- package/dist/_libs/chokidar.mjs +1560 -0
- package/dist/_libs/citty.mjs +333 -0
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/compatx.mjs +46 -0
- package/dist/_libs/confbox.mjs +2920 -0
- package/dist/_libs/debug.mjs +848 -0
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/depd.mjs +314 -0
- package/dist/_libs/dot-prop.mjs +138 -0
- package/dist/_libs/duplexer.mjs +71 -0
- package/dist/_libs/ee-first.mjs +68 -0
- package/dist/_libs/encodeurl.mjs +49 -0
- package/dist/_libs/escape-html.mjs +58 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +330 -0
- package/dist/_libs/etag.mjs +75 -0
- package/dist/{_chunks/_deps → _libs}/fdir.mjs +49 -104
- package/dist/_libs/fresh.mjs +85 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/gen-mapping.mjs +612 -0
- package/dist/_libs/giget.mjs +19076 -0
- package/dist/_libs/gzip-size.mjs +21 -0
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/http-errors.mjs +436 -0
- package/dist/_libs/httpxy.mjs +410 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +32 -0
- package/dist/{_chunks/_deps → _libs}/js-tokens.mjs +83 -112
- package/dist/_libs/klona.mjs +90 -0
- package/dist/_libs/knitwork.mjs +124 -0
- package/dist/_libs/local-pkg.mjs +1686 -0
- package/dist/{_chunks/_deps → _libs}/magic-string.mjs +272 -629
- package/dist/_libs/mime-db.mjs +7642 -0
- package/dist/_libs/mime-types.mjs +162 -0
- package/dist/_libs/mime.mjs +1391 -0
- package/dist/_libs/node-fetch-native.mjs +173 -0
- package/dist/_libs/on-finished.mjs +170 -0
- package/dist/_libs/parseurl.mjs +103 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +41 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-commonjs.mjs +1489 -0
- package/dist/_libs/plugin-inject.mjs +135 -0
- package/dist/_libs/plugin-json.mjs +36 -0
- package/dist/_libs/plugin-node-resolve.mjs +1553 -0
- package/dist/_libs/plugin-replace.mjs +104 -0
- package/dist/_libs/pretty-bytes.mjs +116 -0
- package/dist/_libs/range-parser.mjs +102 -0
- package/dist/_libs/remapping.mjs +117 -0
- package/dist/{_chunks/_deps → _libs}/rou3.mjs +7 -22
- package/dist/_libs/send.mjs +857 -0
- package/dist/_libs/serve-static.mjs +124 -0
- package/dist/_libs/std-env.mjs +158 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/{_chunks/_deps → _libs}/tinyglobby.mjs +32 -33
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/unimport.mjs +3520 -0
- package/dist/_libs/untyped.mjs +271 -0
- package/dist/_libs/unwasm.mjs +5825 -0
- package/dist/{_chunks/_deps/@pi0 → _libs}/vite-plugin-fullstack.mjs +28 -42
- package/dist/_presets.mjs +1723 -0
- package/dist/builder.d.mts +37 -35
- package/dist/builder.mjs +45 -117
- package/dist/cli/_chunks/build.mjs +43 -0
- package/dist/cli/_chunks/common.mjs +15 -0
- package/dist/cli/_chunks/detect-acorn.mjs +12 -0
- package/dist/cli/_chunks/dev.mjs +79 -0
- package/dist/cli/_chunks/dist.mjs +3 -0
- package/dist/cli/_chunks/dist2.mjs +4 -0
- package/dist/cli/_chunks/esm.mjs +3 -0
- package/dist/cli/_chunks/json5.mjs +4 -0
- package/dist/cli/_chunks/jsonc.mjs +4 -0
- package/dist/cli/_chunks/list.mjs +27 -0
- package/dist/cli/_chunks/multipart-parser.mjs +6 -0
- package/dist/cli/_chunks/prepare.mjs +19 -0
- package/dist/cli/_chunks/run.mjs +55 -0
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/_chunks/toml.mjs +4 -0
- package/dist/cli/_chunks/yaml.mjs +4 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +19 -18
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +42 -33
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -8
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
- package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
- package/dist/presets/azure/runtime/_utils.mjs +43 -43
- package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
- package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
- package/dist/presets/bun/runtime/bun.d.mts +1 -0
- package/dist/presets/bun/runtime/bun.mjs +18 -17
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +78 -87
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +53 -58
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +86 -76
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
- package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
- package/dist/presets/deno/runtime/deno-server.mjs +31 -39
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
- package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
- package/dist/presets/netlify/runtime/netlify.mjs +11 -17
- package/dist/presets/node/runtime/node-cluster.mjs +49 -48
- package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
- package/dist/presets/node/runtime/node-middleware.mjs +7 -6
- package/dist/presets/node/runtime/node-server.mjs +33 -23
- package/dist/presets/standard/runtime/server.d.mts +1 -3
- package/dist/presets/standard/runtime/server.mjs +1 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
- package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
- package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
- package/dist/presets/vercel/runtime/vercel.mjs +15 -14
- package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/runtime/index.d.mts +12 -1
- package/dist/runtime/index.mjs +12 -7
- package/dist/runtime/internal/app.mjs +175 -162
- package/dist/runtime/internal/cache.d.mts +10 -4
- package/dist/runtime/internal/cache.mjs +247 -216
- package/dist/runtime/internal/context.d.mts +9 -9
- package/dist/runtime/internal/context.mjs +17 -10
- package/dist/runtime/internal/database.mjs +8 -10
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +106 -105
- package/dist/runtime/internal/error/prod.d.mts +2 -2
- package/dist/runtime/internal/error/prod.mjs +48 -52
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/error/utils.mjs +1 -1
- package/dist/runtime/internal/index.d.mts +2 -0
- package/dist/runtime/internal/index.mjs +2 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/meta.mjs +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/plugin.mjs +1 -1
- package/dist/runtime/internal/renderer.mjs +39 -31
- package/dist/runtime/internal/route-rules.d.mts +8 -8
- package/dist/runtime/internal/route-rules.mjs +53 -51
- package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -30
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
- package/dist/runtime/internal/routes/openapi.d.mts +1 -0
- package/dist/runtime/internal/routes/openapi.mjs +81 -87
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +1 -0
- package/dist/runtime/internal/routes/scalar.mjs +22 -23
- package/dist/runtime/internal/routes/swagger.d.mts +1 -0
- package/dist/runtime/internal/routes/swagger.mjs +9 -11
- package/dist/runtime/internal/runtime-config.d.mts +4 -4
- package/dist/runtime/internal/runtime-config.mjs +40 -35
- package/dist/runtime/internal/shutdown.d.mts +2 -7
- package/dist/runtime/internal/shutdown.mjs +30 -29
- package/dist/runtime/internal/static.mjs +63 -74
- package/dist/runtime/internal/storage.mjs +2 -2
- package/dist/runtime/internal/task.d.mts +6 -6
- package/dist/runtime/internal/task.mjs +56 -59
- package/dist/runtime/internal/utils.d.mts +1 -1
- package/dist/runtime/internal/utils.mjs +4 -10
- package/dist/types/index.d.mts +2566 -3851
- package/dist/types/index.mjs +1 -1
- package/dist/vite.d.mts +56 -52
- package/dist/vite.mjs +55 -132
- package/package.json +10 -10
- package/dist/_build/build.mjs +0 -368
- package/dist/_build/build2.mjs +0 -556
- package/dist/_build/info.mjs +0 -1002
- package/dist/_build/prepare.mjs +0 -1511
- package/dist/_build/snapshot.mjs +0 -185
- package/dist/_build/vite.mjs +0 -959
- package/dist/_build/vite2.mjs +0 -149
- package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +0 -189
- package/dist/_chunks/_deps/@jridgewell/remapping.mjs +0 -137
- package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +0 -231
- package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +0 -173
- package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +0 -170
- package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +0 -89
- package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +0 -2376
- package/dist/_chunks/_deps/@rollup/plugin-inject.mjs +0 -212
- package/dist/_chunks/_deps/@rollup/plugin-json.mjs +0 -37
- package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +0 -1386
- package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +0 -133
- package/dist/_chunks/_deps/@rollup/pluginutils.mjs +0 -346
- package/dist/_chunks/_deps/acorn.mjs +0 -6225
- package/dist/_chunks/_deps/c12.mjs +0 -510
- package/dist/_chunks/_deps/chokidar.mjs +0 -1428
- package/dist/_chunks/_deps/citty.mjs +0 -460
- package/dist/_chunks/_deps/commondir.mjs +0 -77
- package/dist/_chunks/_deps/compatx.mjs +0 -76
- package/dist/_chunks/_deps/confbox.mjs +0 -300
- package/dist/_chunks/_deps/debug.mjs +0 -885
- package/dist/_chunks/_deps/deepmerge.mjs +0 -147
- package/dist/_chunks/_deps/depd.mjs +0 -550
- package/dist/_chunks/_deps/dot-prop.mjs +0 -282
- package/dist/_chunks/_deps/dotenv.mjs +0 -555
- package/dist/_chunks/_deps/duplexer.mjs +0 -1
- package/dist/_chunks/_deps/ee-first.mjs +0 -104
- package/dist/_chunks/_deps/encodeurl.mjs +0 -69
- package/dist/_chunks/_deps/escape-html.mjs +0 -87
- package/dist/_chunks/_deps/escape-string-regexp.mjs +0 -13
- package/dist/_chunks/_deps/estree-walker.mjs +0 -433
- package/dist/_chunks/_deps/etag.mjs +0 -147
- package/dist/_chunks/_deps/exsolve.mjs +0 -1416
- package/dist/_chunks/_deps/fresh.mjs +0 -145
- package/dist/_chunks/_deps/function-bind.mjs +0 -106
- package/dist/_chunks/_deps/giget.mjs +0 -451
- package/dist/_chunks/_deps/gzip-size.mjs +0 -19
- package/dist/_chunks/_deps/hasown.mjs +0 -19
- package/dist/_chunks/_deps/http-errors.mjs +0 -307
- package/dist/_chunks/_deps/httpxy.mjs +0 -580
- package/dist/_chunks/_deps/inherits.mjs +0 -57
- package/dist/_chunks/_deps/is-core-module.mjs +0 -596
- package/dist/_chunks/_deps/is-module.mjs +0 -25
- package/dist/_chunks/_deps/is-reference.mjs +0 -31
- package/dist/_chunks/_deps/klona.mjs +0 -137
- package/dist/_chunks/_deps/knitwork.mjs +0 -172
- package/dist/_chunks/_deps/local-pkg.mjs +0 -163
- package/dist/_chunks/_deps/mime-db.mjs +0 -11685
- package/dist/_chunks/_deps/mime-types.mjs +0 -287
- package/dist/_chunks/_deps/mime.mjs +0 -1172
- package/dist/_chunks/_deps/mlly.mjs +0 -2413
- package/dist/_chunks/_deps/ms.mjs +0 -172
- package/dist/_chunks/_deps/node-fetch-native.mjs +0 -3
- package/dist/_chunks/_deps/nypm.mjs +0 -219
- package/dist/_chunks/_deps/on-finished.mjs +0 -246
- package/dist/_chunks/_deps/parseurl.mjs +0 -168
- package/dist/_chunks/_deps/path-parse.mjs +0 -85
- package/dist/_chunks/_deps/pathe.mjs +0 -251
- package/dist/_chunks/_deps/perfect-debounce.mjs +0 -88
- package/dist/_chunks/_deps/picomatch.mjs +0 -2144
- package/dist/_chunks/_deps/pkg-types.mjs +0 -247
- package/dist/_chunks/_deps/pretty-bytes.mjs +0 -180
- package/dist/_chunks/_deps/quansync.mjs +0 -99
- package/dist/_chunks/_deps/range-parser.mjs +0 -171
- package/dist/_chunks/_deps/rc9.mjs +0 -219
- package/dist/_chunks/_deps/readdirp.mjs +0 -245
- package/dist/_chunks/_deps/resolve.mjs +0 -1260
- package/dist/_chunks/_deps/send.mjs +0 -1022
- package/dist/_chunks/_deps/serve-static.mjs +0 -228
- package/dist/_chunks/_deps/setprototypeof.mjs +0 -26
- package/dist/_chunks/_deps/statuses.mjs +0 -457
- package/dist/_chunks/_deps/std-env.mjs +0 -3
- package/dist/_chunks/_deps/strip-literal.mjs +0 -67
- package/dist/_chunks/_deps/supports-color.mjs +0 -44
- package/dist/_chunks/_deps/tinyexec.mjs +0 -552
- package/dist/_chunks/_deps/toidentifier.mjs +0 -41
- package/dist/_chunks/_deps/ultrahtml.mjs +0 -3
- package/dist/_chunks/_deps/unimport.mjs +0 -2267
- package/dist/_chunks/_deps/unplugin-utils.mjs +0 -65
- package/dist/_chunks/_deps/unplugin.mjs +0 -1294
- package/dist/_chunks/_deps/untyped.mjs +0 -375
- package/dist/_chunks/_deps/unwasm.mjs +0 -6959
- package/dist/_chunks/_deps/webpack-virtual-modules.mjs +0 -360
- package/dist/_chunks/_presets/_all.mjs +0 -59
- package/dist/_chunks/_presets/_nitro.mjs +0 -74
- package/dist/_chunks/_presets/_resolve.mjs +0 -64
- package/dist/_chunks/_presets/_static.mjs +0 -69
- package/dist/_chunks/_presets/_types.mjs +0 -3
- package/dist/_chunks/_presets/_utils.mjs +0 -31
- package/dist/_chunks/_presets/alwaysdata.mjs +0 -17
- package/dist/_chunks/_presets/aws-amplify.mjs +0 -111
- package/dist/_chunks/_presets/aws-lambda.mjs +0 -23
- package/dist/_chunks/_presets/azure.mjs +0 -162
- package/dist/_chunks/_presets/bun.mjs +0 -19
- package/dist/_chunks/_presets/cleavr.mjs +0 -15
- package/dist/_chunks/_presets/cloudflare.mjs +0 -608
- package/dist/_chunks/_presets/deno.mjs +0 -196
- package/dist/_chunks/_presets/digitalocean.mjs +0 -14
- package/dist/_chunks/_presets/firebase.mjs +0 -47
- package/dist/_chunks/_presets/flightcontrol.mjs +0 -14
- package/dist/_chunks/_presets/genezio.mjs +0 -13
- package/dist/_chunks/_presets/heroku.mjs +0 -14
- package/dist/_chunks/_presets/iis.mjs +0 -194
- package/dist/_chunks/_presets/index.mjs +0 -62
- package/dist/_chunks/_presets/koyeb.mjs +0 -14
- package/dist/_chunks/_presets/netlify.mjs +0 -241
- package/dist/_chunks/_presets/node.mjs +0 -54
- package/dist/_chunks/_presets/platform.mjs +0 -14
- package/dist/_chunks/_presets/render.mjs +0 -14
- package/dist/_chunks/_presets/standard.mjs +0 -23
- package/dist/_chunks/_presets/stormkit.mjs +0 -18
- package/dist/_chunks/_presets/vercel.mjs +0 -375
- package/dist/_chunks/_presets/winterjs.mjs +0 -22
- package/dist/_chunks/_presets/zeabur.mjs +0 -69
- package/dist/_chunks/_presets/zerops.mjs +0 -27
- package/dist/_chunks/app.mjs +0 -600
- package/dist/_chunks/builder.mjs +0 -648
- package/dist/_chunks/server.mjs +0 -256
- package/dist/_cli/build.mjs +0 -49
- package/dist/_cli/common.mjs +0 -13
- package/dist/_cli/dev.mjs +0 -121
- package/dist/_cli/index.mjs +0 -16
- package/dist/_cli/list.mjs +0 -33
- package/dist/_cli/prepare.mjs +0 -23
- package/dist/_cli/run.mjs +0 -59
- package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +0 -21
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
- package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
- package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
- /package/lib/{indexd.mts → index.d.mts} +0 -0
|
@@ -0,0 +1,857 @@
|
|
|
1
|
+
import { i as __require, t as __commonJS } from "../_chunks/DXMHy5ca.mjs";
|
|
2
|
+
import { t as require_encodeurl } from "./encodeurl.mjs";
|
|
3
|
+
import { t as require_escape_html } from "./escape-html.mjs";
|
|
4
|
+
import { t as require_http_errors } from "./http-errors.mjs";
|
|
5
|
+
import { n as require_ms, t as require_src } from "./debug.mjs";
|
|
6
|
+
import { t as require_etag } from "./etag.mjs";
|
|
7
|
+
import { t as require_fresh } from "./fresh.mjs";
|
|
8
|
+
import { t as require_mime_types } from "./mime-types.mjs";
|
|
9
|
+
import { t as require_on_finished } from "./on-finished.mjs";
|
|
10
|
+
import { t as require_range_parser } from "./range-parser.mjs";
|
|
11
|
+
|
|
12
|
+
//#region node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/codes.json
|
|
13
|
+
var require_codes = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/codes.json": ((exports, module) => {
|
|
14
|
+
module.exports = {
|
|
15
|
+
"100": "Continue",
|
|
16
|
+
"101": "Switching Protocols",
|
|
17
|
+
"102": "Processing",
|
|
18
|
+
"103": "Early Hints",
|
|
19
|
+
"200": "OK",
|
|
20
|
+
"201": "Created",
|
|
21
|
+
"202": "Accepted",
|
|
22
|
+
"203": "Non-Authoritative Information",
|
|
23
|
+
"204": "No Content",
|
|
24
|
+
"205": "Reset Content",
|
|
25
|
+
"206": "Partial Content",
|
|
26
|
+
"207": "Multi-Status",
|
|
27
|
+
"208": "Already Reported",
|
|
28
|
+
"226": "IM Used",
|
|
29
|
+
"300": "Multiple Choices",
|
|
30
|
+
"301": "Moved Permanently",
|
|
31
|
+
"302": "Found",
|
|
32
|
+
"303": "See Other",
|
|
33
|
+
"304": "Not Modified",
|
|
34
|
+
"305": "Use Proxy",
|
|
35
|
+
"307": "Temporary Redirect",
|
|
36
|
+
"308": "Permanent Redirect",
|
|
37
|
+
"400": "Bad Request",
|
|
38
|
+
"401": "Unauthorized",
|
|
39
|
+
"402": "Payment Required",
|
|
40
|
+
"403": "Forbidden",
|
|
41
|
+
"404": "Not Found",
|
|
42
|
+
"405": "Method Not Allowed",
|
|
43
|
+
"406": "Not Acceptable",
|
|
44
|
+
"407": "Proxy Authentication Required",
|
|
45
|
+
"408": "Request Timeout",
|
|
46
|
+
"409": "Conflict",
|
|
47
|
+
"410": "Gone",
|
|
48
|
+
"411": "Length Required",
|
|
49
|
+
"412": "Precondition Failed",
|
|
50
|
+
"413": "Payload Too Large",
|
|
51
|
+
"414": "URI Too Long",
|
|
52
|
+
"415": "Unsupported Media Type",
|
|
53
|
+
"416": "Range Not Satisfiable",
|
|
54
|
+
"417": "Expectation Failed",
|
|
55
|
+
"418": "I'm a Teapot",
|
|
56
|
+
"421": "Misdirected Request",
|
|
57
|
+
"422": "Unprocessable Entity",
|
|
58
|
+
"423": "Locked",
|
|
59
|
+
"424": "Failed Dependency",
|
|
60
|
+
"425": "Too Early",
|
|
61
|
+
"426": "Upgrade Required",
|
|
62
|
+
"428": "Precondition Required",
|
|
63
|
+
"429": "Too Many Requests",
|
|
64
|
+
"431": "Request Header Fields Too Large",
|
|
65
|
+
"451": "Unavailable For Legal Reasons",
|
|
66
|
+
"500": "Internal Server Error",
|
|
67
|
+
"501": "Not Implemented",
|
|
68
|
+
"502": "Bad Gateway",
|
|
69
|
+
"503": "Service Unavailable",
|
|
70
|
+
"504": "Gateway Timeout",
|
|
71
|
+
"505": "HTTP Version Not Supported",
|
|
72
|
+
"506": "Variant Also Negotiates",
|
|
73
|
+
"507": "Insufficient Storage",
|
|
74
|
+
"508": "Loop Detected",
|
|
75
|
+
"509": "Bandwidth Limit Exceeded",
|
|
76
|
+
"510": "Not Extended",
|
|
77
|
+
"511": "Network Authentication Required"
|
|
78
|
+
};
|
|
79
|
+
}) });
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/index.js
|
|
83
|
+
var require_statuses = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/index.js": ((exports, module) => {
|
|
84
|
+
/**
|
|
85
|
+
* Module dependencies.
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
var codes = require_codes();
|
|
89
|
+
/**
|
|
90
|
+
* Module exports.
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
module.exports = status;
|
|
94
|
+
status.message = codes;
|
|
95
|
+
status.code = createMessageToStatusCodeMap(codes);
|
|
96
|
+
status.codes = createStatusCodeList(codes);
|
|
97
|
+
status.redirect = {
|
|
98
|
+
300: true,
|
|
99
|
+
301: true,
|
|
100
|
+
302: true,
|
|
101
|
+
303: true,
|
|
102
|
+
305: true,
|
|
103
|
+
307: true,
|
|
104
|
+
308: true
|
|
105
|
+
};
|
|
106
|
+
status.empty = {
|
|
107
|
+
204: true,
|
|
108
|
+
205: true,
|
|
109
|
+
304: true
|
|
110
|
+
};
|
|
111
|
+
status.retry = {
|
|
112
|
+
502: true,
|
|
113
|
+
503: true,
|
|
114
|
+
504: true
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Create a map of message to status code.
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
function createMessageToStatusCodeMap(codes$1) {
|
|
121
|
+
var map = {};
|
|
122
|
+
Object.keys(codes$1).forEach(function forEachCode(code) {
|
|
123
|
+
var message = codes$1[code];
|
|
124
|
+
var status$1 = Number(code);
|
|
125
|
+
map[message.toLowerCase()] = status$1;
|
|
126
|
+
});
|
|
127
|
+
return map;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Create a list of all status codes.
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
function createStatusCodeList(codes$1) {
|
|
134
|
+
return Object.keys(codes$1).map(function mapCode(code) {
|
|
135
|
+
return Number(code);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get the status code for given message.
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
142
|
+
function getStatusCode(message) {
|
|
143
|
+
var msg = message.toLowerCase();
|
|
144
|
+
if (!Object.prototype.hasOwnProperty.call(status.code, msg)) throw new Error("invalid status message: \"" + message + "\"");
|
|
145
|
+
return status.code[msg];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get the status message for given code.
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
function getStatusMessage(code) {
|
|
152
|
+
if (!Object.prototype.hasOwnProperty.call(status.message, code)) throw new Error("invalid status code: " + code);
|
|
153
|
+
return status.message[code];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get the status code.
|
|
157
|
+
*
|
|
158
|
+
* Given a number, this will throw if it is not a known status
|
|
159
|
+
* code, otherwise the code will be returned. Given a string,
|
|
160
|
+
* the string will be parsed for a number and return the code
|
|
161
|
+
* if valid, otherwise will lookup the code assuming this is
|
|
162
|
+
* the status message.
|
|
163
|
+
*
|
|
164
|
+
* @param {string|number} code
|
|
165
|
+
* @returns {number}
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
function status(code) {
|
|
169
|
+
if (typeof code === "number") return getStatusMessage(code);
|
|
170
|
+
if (typeof code !== "string") throw new TypeError("code must be a number or string");
|
|
171
|
+
var n = parseInt(code, 10);
|
|
172
|
+
if (!isNaN(n)) return getStatusMessage(n);
|
|
173
|
+
return getStatusCode(code);
|
|
174
|
+
}
|
|
175
|
+
}) });
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region node_modules/.pnpm/send@1.2.0/node_modules/send/index.js
|
|
179
|
+
var require_send = /* @__PURE__ */ __commonJS({ "node_modules/.pnpm/send@1.2.0/node_modules/send/index.js": ((exports, module) => {
|
|
180
|
+
/**
|
|
181
|
+
* Module dependencies.
|
|
182
|
+
* @private
|
|
183
|
+
*/
|
|
184
|
+
var createError = require_http_errors();
|
|
185
|
+
var debug = require_src()("send");
|
|
186
|
+
var encodeUrl = require_encodeurl();
|
|
187
|
+
var escapeHtml = require_escape_html();
|
|
188
|
+
var etag = require_etag();
|
|
189
|
+
var fresh = require_fresh();
|
|
190
|
+
var fs = __require("fs");
|
|
191
|
+
var mime = require_mime_types();
|
|
192
|
+
var ms = require_ms();
|
|
193
|
+
var onFinished = require_on_finished();
|
|
194
|
+
var parseRange = require_range_parser();
|
|
195
|
+
var path = __require("path");
|
|
196
|
+
var statuses = require_statuses();
|
|
197
|
+
var Stream = __require("stream");
|
|
198
|
+
var util = __require("util");
|
|
199
|
+
/**
|
|
200
|
+
* Path function references.
|
|
201
|
+
* @private
|
|
202
|
+
*/
|
|
203
|
+
var extname = path.extname;
|
|
204
|
+
var join = path.join;
|
|
205
|
+
var normalize = path.normalize;
|
|
206
|
+
var resolve = path.resolve;
|
|
207
|
+
var sep = path.sep;
|
|
208
|
+
/**
|
|
209
|
+
* Regular expression for identifying a bytes Range header.
|
|
210
|
+
* @private
|
|
211
|
+
*/
|
|
212
|
+
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
213
|
+
/**
|
|
214
|
+
* Maximum value allowed for the max age.
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
217
|
+
var MAX_MAXAGE = 3600 * 24 * 365 * 1e3;
|
|
218
|
+
/**
|
|
219
|
+
* Regular expression to match a path with a directory up component.
|
|
220
|
+
* @private
|
|
221
|
+
*/
|
|
222
|
+
var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
|
223
|
+
/**
|
|
224
|
+
* Module exports.
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
module.exports = send;
|
|
228
|
+
/**
|
|
229
|
+
* Return a `SendStream` for `req` and `path`.
|
|
230
|
+
*
|
|
231
|
+
* @param {object} req
|
|
232
|
+
* @param {string} path
|
|
233
|
+
* @param {object} [options]
|
|
234
|
+
* @return {SendStream}
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
function send(req, path$1, options) {
|
|
238
|
+
return new SendStream(req, path$1, options);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Initialize a `SendStream` with the given `path`.
|
|
242
|
+
*
|
|
243
|
+
* @param {Request} req
|
|
244
|
+
* @param {String} path
|
|
245
|
+
* @param {object} [options]
|
|
246
|
+
* @private
|
|
247
|
+
*/
|
|
248
|
+
function SendStream(req, path$1, options) {
|
|
249
|
+
Stream.call(this);
|
|
250
|
+
var opts = options || {};
|
|
251
|
+
this.options = opts;
|
|
252
|
+
this.path = path$1;
|
|
253
|
+
this.req = req;
|
|
254
|
+
this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
|
|
255
|
+
this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
|
|
256
|
+
this._etag = opts.etag !== void 0 ? Boolean(opts.etag) : true;
|
|
257
|
+
this._dotfiles = opts.dotfiles !== void 0 ? opts.dotfiles : "ignore";
|
|
258
|
+
if (this._dotfiles !== "ignore" && this._dotfiles !== "allow" && this._dotfiles !== "deny") throw new TypeError("dotfiles option must be \"allow\", \"deny\", or \"ignore\"");
|
|
259
|
+
this._extensions = opts.extensions !== void 0 ? normalizeList(opts.extensions, "extensions option") : [];
|
|
260
|
+
this._immutable = opts.immutable !== void 0 ? Boolean(opts.immutable) : false;
|
|
261
|
+
this._index = opts.index !== void 0 ? normalizeList(opts.index, "index option") : ["index.html"];
|
|
262
|
+
this._lastModified = opts.lastModified !== void 0 ? Boolean(opts.lastModified) : true;
|
|
263
|
+
this._maxage = opts.maxAge || opts.maxage;
|
|
264
|
+
this._maxage = typeof this._maxage === "string" ? ms(this._maxage) : Number(this._maxage);
|
|
265
|
+
this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
|
|
266
|
+
this._root = opts.root ? resolve(opts.root) : null;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Inherits from `Stream`.
|
|
270
|
+
*/
|
|
271
|
+
util.inherits(SendStream, Stream);
|
|
272
|
+
/**
|
|
273
|
+
* Emit error with `status`.
|
|
274
|
+
*
|
|
275
|
+
* @param {number} status
|
|
276
|
+
* @param {Error} [err]
|
|
277
|
+
* @private
|
|
278
|
+
*/
|
|
279
|
+
SendStream.prototype.error = function error(status$1, err) {
|
|
280
|
+
if (hasListeners(this, "error")) return this.emit("error", createHttpError(status$1, err));
|
|
281
|
+
var res = this.res;
|
|
282
|
+
var doc = createHtmlDocument("Error", escapeHtml(statuses.message[status$1] || String(status$1)));
|
|
283
|
+
clearHeaders(res);
|
|
284
|
+
if (err && err.headers) setHeaders(res, err.headers);
|
|
285
|
+
res.statusCode = status$1;
|
|
286
|
+
res.setHeader("Content-Type", "text/html; charset=UTF-8");
|
|
287
|
+
res.setHeader("Content-Length", Buffer.byteLength(doc));
|
|
288
|
+
res.setHeader("Content-Security-Policy", "default-src 'none'");
|
|
289
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
290
|
+
res.end(doc);
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Check if the pathname ends with "/".
|
|
294
|
+
*
|
|
295
|
+
* @return {boolean}
|
|
296
|
+
* @private
|
|
297
|
+
*/
|
|
298
|
+
SendStream.prototype.hasTrailingSlash = function hasTrailingSlash() {
|
|
299
|
+
return this.path[this.path.length - 1] === "/";
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Check if this is a conditional GET request.
|
|
303
|
+
*
|
|
304
|
+
* @return {Boolean}
|
|
305
|
+
* @api private
|
|
306
|
+
*/
|
|
307
|
+
SendStream.prototype.isConditionalGET = function isConditionalGET() {
|
|
308
|
+
return this.req.headers["if-match"] || this.req.headers["if-unmodified-since"] || this.req.headers["if-none-match"] || this.req.headers["if-modified-since"];
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Check if the request preconditions failed.
|
|
312
|
+
*
|
|
313
|
+
* @return {boolean}
|
|
314
|
+
* @private
|
|
315
|
+
*/
|
|
316
|
+
SendStream.prototype.isPreconditionFailure = function isPreconditionFailure() {
|
|
317
|
+
var req = this.req;
|
|
318
|
+
var res = this.res;
|
|
319
|
+
var match = req.headers["if-match"];
|
|
320
|
+
if (match) {
|
|
321
|
+
var etag$1 = res.getHeader("ETag");
|
|
322
|
+
return !etag$1 || match !== "*" && parseTokenList(match).every(function(match$1) {
|
|
323
|
+
return match$1 !== etag$1 && match$1 !== "W/" + etag$1 && "W/" + match$1 !== etag$1;
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
var unmodifiedSince = parseHttpDate(req.headers["if-unmodified-since"]);
|
|
327
|
+
if (!isNaN(unmodifiedSince)) {
|
|
328
|
+
var lastModified = parseHttpDate(res.getHeader("Last-Modified"));
|
|
329
|
+
return isNaN(lastModified) || lastModified > unmodifiedSince;
|
|
330
|
+
}
|
|
331
|
+
return false;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Strip various content header fields for a change in entity.
|
|
335
|
+
*
|
|
336
|
+
* @private
|
|
337
|
+
*/
|
|
338
|
+
SendStream.prototype.removeContentHeaderFields = function removeContentHeaderFields() {
|
|
339
|
+
var res = this.res;
|
|
340
|
+
res.removeHeader("Content-Encoding");
|
|
341
|
+
res.removeHeader("Content-Language");
|
|
342
|
+
res.removeHeader("Content-Length");
|
|
343
|
+
res.removeHeader("Content-Range");
|
|
344
|
+
res.removeHeader("Content-Type");
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Respond with 304 not modified.
|
|
348
|
+
*
|
|
349
|
+
* @api private
|
|
350
|
+
*/
|
|
351
|
+
SendStream.prototype.notModified = function notModified() {
|
|
352
|
+
var res = this.res;
|
|
353
|
+
debug("not modified");
|
|
354
|
+
this.removeContentHeaderFields();
|
|
355
|
+
res.statusCode = 304;
|
|
356
|
+
res.end();
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Raise error that headers already sent.
|
|
360
|
+
*
|
|
361
|
+
* @api private
|
|
362
|
+
*/
|
|
363
|
+
SendStream.prototype.headersAlreadySent = function headersAlreadySent() {
|
|
364
|
+
var err = /* @__PURE__ */ new Error("Can't set headers after they are sent.");
|
|
365
|
+
debug("headers already sent");
|
|
366
|
+
this.error(500, err);
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Check if the request is cacheable, aka
|
|
370
|
+
* responded with 2xx or 304 (see RFC 2616 section 14.2{5,6}).
|
|
371
|
+
*
|
|
372
|
+
* @return {Boolean}
|
|
373
|
+
* @api private
|
|
374
|
+
*/
|
|
375
|
+
SendStream.prototype.isCachable = function isCachable() {
|
|
376
|
+
var statusCode = this.res.statusCode;
|
|
377
|
+
return statusCode >= 200 && statusCode < 300 || statusCode === 304;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Handle stat() error.
|
|
381
|
+
*
|
|
382
|
+
* @param {Error} error
|
|
383
|
+
* @private
|
|
384
|
+
*/
|
|
385
|
+
SendStream.prototype.onStatError = function onStatError(error) {
|
|
386
|
+
switch (error.code) {
|
|
387
|
+
case "ENAMETOOLONG":
|
|
388
|
+
case "ENOENT":
|
|
389
|
+
case "ENOTDIR":
|
|
390
|
+
this.error(404, error);
|
|
391
|
+
break;
|
|
392
|
+
default:
|
|
393
|
+
this.error(500, error);
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
/**
|
|
398
|
+
* Check if the cache is fresh.
|
|
399
|
+
*
|
|
400
|
+
* @return {Boolean}
|
|
401
|
+
* @api private
|
|
402
|
+
*/
|
|
403
|
+
SendStream.prototype.isFresh = function isFresh() {
|
|
404
|
+
return fresh(this.req.headers, {
|
|
405
|
+
etag: this.res.getHeader("ETag"),
|
|
406
|
+
"last-modified": this.res.getHeader("Last-Modified")
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* Check if the range is fresh.
|
|
411
|
+
*
|
|
412
|
+
* @return {Boolean}
|
|
413
|
+
* @api private
|
|
414
|
+
*/
|
|
415
|
+
SendStream.prototype.isRangeFresh = function isRangeFresh() {
|
|
416
|
+
var ifRange = this.req.headers["if-range"];
|
|
417
|
+
if (!ifRange) return true;
|
|
418
|
+
if (ifRange.indexOf("\"") !== -1) {
|
|
419
|
+
var etag$1 = this.res.getHeader("ETag");
|
|
420
|
+
return Boolean(etag$1 && ifRange.indexOf(etag$1) !== -1);
|
|
421
|
+
}
|
|
422
|
+
return parseHttpDate(this.res.getHeader("Last-Modified")) <= parseHttpDate(ifRange);
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* Redirect to path.
|
|
426
|
+
*
|
|
427
|
+
* @param {string} path
|
|
428
|
+
* @private
|
|
429
|
+
*/
|
|
430
|
+
SendStream.prototype.redirect = function redirect(path$1) {
|
|
431
|
+
var res = this.res;
|
|
432
|
+
if (hasListeners(this, "directory")) {
|
|
433
|
+
this.emit("directory", res, path$1);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
if (this.hasTrailingSlash()) {
|
|
437
|
+
this.error(403);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
var loc = encodeUrl(collapseLeadingSlashes(this.path + "/"));
|
|
441
|
+
var doc = createHtmlDocument("Redirecting", "Redirecting to " + escapeHtml(loc));
|
|
442
|
+
res.statusCode = 301;
|
|
443
|
+
res.setHeader("Content-Type", "text/html; charset=UTF-8");
|
|
444
|
+
res.setHeader("Content-Length", Buffer.byteLength(doc));
|
|
445
|
+
res.setHeader("Content-Security-Policy", "default-src 'none'");
|
|
446
|
+
res.setHeader("X-Content-Type-Options", "nosniff");
|
|
447
|
+
res.setHeader("Location", loc);
|
|
448
|
+
res.end(doc);
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* Pipe to `res.
|
|
452
|
+
*
|
|
453
|
+
* @param {Stream} res
|
|
454
|
+
* @return {Stream} res
|
|
455
|
+
* @api public
|
|
456
|
+
*/
|
|
457
|
+
SendStream.prototype.pipe = function pipe(res) {
|
|
458
|
+
var root = this._root;
|
|
459
|
+
this.res = res;
|
|
460
|
+
var path$1 = decode(this.path);
|
|
461
|
+
if (path$1 === -1) {
|
|
462
|
+
this.error(400);
|
|
463
|
+
return res;
|
|
464
|
+
}
|
|
465
|
+
if (~path$1.indexOf("\0")) {
|
|
466
|
+
this.error(400);
|
|
467
|
+
return res;
|
|
468
|
+
}
|
|
469
|
+
var parts;
|
|
470
|
+
if (root !== null) {
|
|
471
|
+
if (path$1) path$1 = normalize("." + sep + path$1);
|
|
472
|
+
if (UP_PATH_REGEXP.test(path$1)) {
|
|
473
|
+
debug("malicious path \"%s\"", path$1);
|
|
474
|
+
this.error(403);
|
|
475
|
+
return res;
|
|
476
|
+
}
|
|
477
|
+
parts = path$1.split(sep);
|
|
478
|
+
path$1 = normalize(join(root, path$1));
|
|
479
|
+
} else {
|
|
480
|
+
if (UP_PATH_REGEXP.test(path$1)) {
|
|
481
|
+
debug("malicious path \"%s\"", path$1);
|
|
482
|
+
this.error(403);
|
|
483
|
+
return res;
|
|
484
|
+
}
|
|
485
|
+
parts = normalize(path$1).split(sep);
|
|
486
|
+
path$1 = resolve(path$1);
|
|
487
|
+
}
|
|
488
|
+
if (containsDotFile(parts)) {
|
|
489
|
+
debug("%s dotfile \"%s\"", this._dotfiles, path$1);
|
|
490
|
+
switch (this._dotfiles) {
|
|
491
|
+
case "allow": break;
|
|
492
|
+
case "deny":
|
|
493
|
+
this.error(403);
|
|
494
|
+
return res;
|
|
495
|
+
case "ignore":
|
|
496
|
+
default:
|
|
497
|
+
this.error(404);
|
|
498
|
+
return res;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (this._index.length && this.hasTrailingSlash()) {
|
|
502
|
+
this.sendIndex(path$1);
|
|
503
|
+
return res;
|
|
504
|
+
}
|
|
505
|
+
this.sendFile(path$1);
|
|
506
|
+
return res;
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Transfer `path`.
|
|
510
|
+
*
|
|
511
|
+
* @param {String} path
|
|
512
|
+
* @api public
|
|
513
|
+
*/
|
|
514
|
+
SendStream.prototype.send = function send$1(path$1, stat) {
|
|
515
|
+
var len = stat.size;
|
|
516
|
+
var options = this.options;
|
|
517
|
+
var opts = {};
|
|
518
|
+
var res = this.res;
|
|
519
|
+
var req = this.req;
|
|
520
|
+
var ranges = req.headers.range;
|
|
521
|
+
var offset = options.start || 0;
|
|
522
|
+
if (res.headersSent) {
|
|
523
|
+
this.headersAlreadySent();
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
debug("pipe \"%s\"", path$1);
|
|
527
|
+
this.setHeader(path$1, stat);
|
|
528
|
+
this.type(path$1);
|
|
529
|
+
if (this.isConditionalGET()) {
|
|
530
|
+
if (this.isPreconditionFailure()) {
|
|
531
|
+
this.error(412);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (this.isCachable() && this.isFresh()) {
|
|
535
|
+
this.notModified();
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
len = Math.max(0, len - offset);
|
|
540
|
+
if (options.end !== void 0) {
|
|
541
|
+
var bytes = options.end - offset + 1;
|
|
542
|
+
if (len > bytes) len = bytes;
|
|
543
|
+
}
|
|
544
|
+
if (this._acceptRanges && BYTES_RANGE_REGEXP.test(ranges)) {
|
|
545
|
+
ranges = parseRange(len, ranges, { combine: true });
|
|
546
|
+
if (!this.isRangeFresh()) {
|
|
547
|
+
debug("range stale");
|
|
548
|
+
ranges = -2;
|
|
549
|
+
}
|
|
550
|
+
if (ranges === -1) {
|
|
551
|
+
debug("range unsatisfiable");
|
|
552
|
+
res.setHeader("Content-Range", contentRange("bytes", len));
|
|
553
|
+
return this.error(416, { headers: { "Content-Range": res.getHeader("Content-Range") } });
|
|
554
|
+
}
|
|
555
|
+
if (ranges !== -2 && ranges.length === 1) {
|
|
556
|
+
debug("range %j", ranges);
|
|
557
|
+
res.statusCode = 206;
|
|
558
|
+
res.setHeader("Content-Range", contentRange("bytes", len, ranges[0]));
|
|
559
|
+
offset += ranges[0].start;
|
|
560
|
+
len = ranges[0].end - ranges[0].start + 1;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
for (var prop in options) opts[prop] = options[prop];
|
|
564
|
+
opts.start = offset;
|
|
565
|
+
opts.end = Math.max(offset, offset + len - 1);
|
|
566
|
+
res.setHeader("Content-Length", len);
|
|
567
|
+
if (req.method === "HEAD") {
|
|
568
|
+
res.end();
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
this.stream(path$1, opts);
|
|
572
|
+
};
|
|
573
|
+
/**
|
|
574
|
+
* Transfer file for `path`.
|
|
575
|
+
*
|
|
576
|
+
* @param {String} path
|
|
577
|
+
* @api private
|
|
578
|
+
*/
|
|
579
|
+
SendStream.prototype.sendFile = function sendFile(path$1) {
|
|
580
|
+
var i = 0;
|
|
581
|
+
var self = this;
|
|
582
|
+
debug("stat \"%s\"", path$1);
|
|
583
|
+
fs.stat(path$1, function onstat(err, stat) {
|
|
584
|
+
var pathEndsWithSep = path$1[path$1.length - 1] === sep;
|
|
585
|
+
if (err && err.code === "ENOENT" && !extname(path$1) && !pathEndsWithSep) return next(err);
|
|
586
|
+
if (err) return self.onStatError(err);
|
|
587
|
+
if (stat.isDirectory()) return self.redirect(path$1);
|
|
588
|
+
if (pathEndsWithSep) return self.error(404);
|
|
589
|
+
self.emit("file", path$1, stat);
|
|
590
|
+
self.send(path$1, stat);
|
|
591
|
+
});
|
|
592
|
+
function next(err) {
|
|
593
|
+
if (self._extensions.length <= i) return err ? self.onStatError(err) : self.error(404);
|
|
594
|
+
var p = path$1 + "." + self._extensions[i++];
|
|
595
|
+
debug("stat \"%s\"", p);
|
|
596
|
+
fs.stat(p, function(err$1, stat) {
|
|
597
|
+
if (err$1) return next(err$1);
|
|
598
|
+
if (stat.isDirectory()) return next();
|
|
599
|
+
self.emit("file", p, stat);
|
|
600
|
+
self.send(p, stat);
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
/**
|
|
605
|
+
* Transfer index for `path`.
|
|
606
|
+
*
|
|
607
|
+
* @param {String} path
|
|
608
|
+
* @api private
|
|
609
|
+
*/
|
|
610
|
+
SendStream.prototype.sendIndex = function sendIndex(path$1) {
|
|
611
|
+
var i = -1;
|
|
612
|
+
var self = this;
|
|
613
|
+
function next(err) {
|
|
614
|
+
if (++i >= self._index.length) {
|
|
615
|
+
if (err) return self.onStatError(err);
|
|
616
|
+
return self.error(404);
|
|
617
|
+
}
|
|
618
|
+
var p = join(path$1, self._index[i]);
|
|
619
|
+
debug("stat \"%s\"", p);
|
|
620
|
+
fs.stat(p, function(err$1, stat) {
|
|
621
|
+
if (err$1) return next(err$1);
|
|
622
|
+
if (stat.isDirectory()) return next();
|
|
623
|
+
self.emit("file", p, stat);
|
|
624
|
+
self.send(p, stat);
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
next();
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* Stream `path` to the response.
|
|
631
|
+
*
|
|
632
|
+
* @param {String} path
|
|
633
|
+
* @param {Object} options
|
|
634
|
+
* @api private
|
|
635
|
+
*/
|
|
636
|
+
SendStream.prototype.stream = function stream(path$1, options) {
|
|
637
|
+
var self = this;
|
|
638
|
+
var res = this.res;
|
|
639
|
+
var stream$1 = fs.createReadStream(path$1, options);
|
|
640
|
+
this.emit("stream", stream$1);
|
|
641
|
+
stream$1.pipe(res);
|
|
642
|
+
function cleanup() {
|
|
643
|
+
stream$1.destroy();
|
|
644
|
+
}
|
|
645
|
+
onFinished(res, cleanup);
|
|
646
|
+
stream$1.on("error", function onerror(err) {
|
|
647
|
+
cleanup();
|
|
648
|
+
self.onStatError(err);
|
|
649
|
+
});
|
|
650
|
+
stream$1.on("end", function onend() {
|
|
651
|
+
self.emit("end");
|
|
652
|
+
});
|
|
653
|
+
};
|
|
654
|
+
/**
|
|
655
|
+
* Set content-type based on `path`
|
|
656
|
+
* if it hasn't been explicitly set.
|
|
657
|
+
*
|
|
658
|
+
* @param {String} path
|
|
659
|
+
* @api private
|
|
660
|
+
*/
|
|
661
|
+
SendStream.prototype.type = function type(path$1) {
|
|
662
|
+
var res = this.res;
|
|
663
|
+
if (res.getHeader("Content-Type")) return;
|
|
664
|
+
var ext = extname(path$1);
|
|
665
|
+
var type$1 = mime.contentType(ext) || "application/octet-stream";
|
|
666
|
+
debug("content-type %s", type$1);
|
|
667
|
+
res.setHeader("Content-Type", type$1);
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* Set response header fields, most
|
|
671
|
+
* fields may be pre-defined.
|
|
672
|
+
*
|
|
673
|
+
* @param {String} path
|
|
674
|
+
* @param {Object} stat
|
|
675
|
+
* @api private
|
|
676
|
+
*/
|
|
677
|
+
SendStream.prototype.setHeader = function setHeader(path$1, stat) {
|
|
678
|
+
var res = this.res;
|
|
679
|
+
this.emit("headers", res, path$1, stat);
|
|
680
|
+
if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
|
|
681
|
+
debug("accept ranges");
|
|
682
|
+
res.setHeader("Accept-Ranges", "bytes");
|
|
683
|
+
}
|
|
684
|
+
if (this._cacheControl && !res.getHeader("Cache-Control")) {
|
|
685
|
+
var cacheControl = "public, max-age=" + Math.floor(this._maxage / 1e3);
|
|
686
|
+
if (this._immutable) cacheControl += ", immutable";
|
|
687
|
+
debug("cache-control %s", cacheControl);
|
|
688
|
+
res.setHeader("Cache-Control", cacheControl);
|
|
689
|
+
}
|
|
690
|
+
if (this._lastModified && !res.getHeader("Last-Modified")) {
|
|
691
|
+
var modified = stat.mtime.toUTCString();
|
|
692
|
+
debug("modified %s", modified);
|
|
693
|
+
res.setHeader("Last-Modified", modified);
|
|
694
|
+
}
|
|
695
|
+
if (this._etag && !res.getHeader("ETag")) {
|
|
696
|
+
var val = etag(stat);
|
|
697
|
+
debug("etag %s", val);
|
|
698
|
+
res.setHeader("ETag", val);
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
702
|
+
* Clear all headers from a response.
|
|
703
|
+
*
|
|
704
|
+
* @param {object} res
|
|
705
|
+
* @private
|
|
706
|
+
*/
|
|
707
|
+
function clearHeaders(res) {
|
|
708
|
+
for (const header of res.getHeaderNames()) res.removeHeader(header);
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Collapse all leading slashes into a single slash
|
|
712
|
+
*
|
|
713
|
+
* @param {string} str
|
|
714
|
+
* @private
|
|
715
|
+
*/
|
|
716
|
+
function collapseLeadingSlashes(str) {
|
|
717
|
+
for (var i = 0; i < str.length; i++) if (str[i] !== "/") break;
|
|
718
|
+
return i > 1 ? "/" + str.substr(i) : str;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Determine if path parts contain a dotfile.
|
|
722
|
+
*
|
|
723
|
+
* @api private
|
|
724
|
+
*/
|
|
725
|
+
function containsDotFile(parts) {
|
|
726
|
+
for (var i = 0; i < parts.length; i++) {
|
|
727
|
+
var part = parts[i];
|
|
728
|
+
if (part.length > 1 && part[0] === ".") return true;
|
|
729
|
+
}
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Create a Content-Range header.
|
|
734
|
+
*
|
|
735
|
+
* @param {string} type
|
|
736
|
+
* @param {number} size
|
|
737
|
+
* @param {array} [range]
|
|
738
|
+
*/
|
|
739
|
+
function contentRange(type, size, range) {
|
|
740
|
+
return type + " " + (range ? range.start + "-" + range.end : "*") + "/" + size;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Create a minimal HTML document.
|
|
744
|
+
*
|
|
745
|
+
* @param {string} title
|
|
746
|
+
* @param {string} body
|
|
747
|
+
* @private
|
|
748
|
+
*/
|
|
749
|
+
function createHtmlDocument(title, body) {
|
|
750
|
+
return "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>" + title + "</title>\n</head>\n<body>\n<pre>" + body + "</pre>\n</body>\n</html>\n";
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Create a HttpError object from simple arguments.
|
|
754
|
+
*
|
|
755
|
+
* @param {number} status
|
|
756
|
+
* @param {Error|object} err
|
|
757
|
+
* @private
|
|
758
|
+
*/
|
|
759
|
+
function createHttpError(status$1, err) {
|
|
760
|
+
if (!err) return createError(status$1);
|
|
761
|
+
return err instanceof Error ? createError(status$1, err, { expose: false }) : createError(status$1, err);
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* decodeURIComponent.
|
|
765
|
+
*
|
|
766
|
+
* Allows V8 to only deoptimize this fn instead of all
|
|
767
|
+
* of send().
|
|
768
|
+
*
|
|
769
|
+
* @param {String} path
|
|
770
|
+
* @api private
|
|
771
|
+
*/
|
|
772
|
+
function decode(path$1) {
|
|
773
|
+
try {
|
|
774
|
+
return decodeURIComponent(path$1);
|
|
775
|
+
} catch (err) {
|
|
776
|
+
return -1;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Determine if emitter has listeners of a given type.
|
|
781
|
+
*
|
|
782
|
+
* The way to do this check is done three different ways in Node.js >= 0.10
|
|
783
|
+
* so this consolidates them into a minimal set using instance methods.
|
|
784
|
+
*
|
|
785
|
+
* @param {EventEmitter} emitter
|
|
786
|
+
* @param {string} type
|
|
787
|
+
* @returns {boolean}
|
|
788
|
+
* @private
|
|
789
|
+
*/
|
|
790
|
+
function hasListeners(emitter, type) {
|
|
791
|
+
return (typeof emitter.listenerCount !== "function" ? emitter.listeners(type).length : emitter.listenerCount(type)) > 0;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Normalize the index option into an array.
|
|
795
|
+
*
|
|
796
|
+
* @param {boolean|string|array} val
|
|
797
|
+
* @param {string} name
|
|
798
|
+
* @private
|
|
799
|
+
*/
|
|
800
|
+
function normalizeList(val, name) {
|
|
801
|
+
var list = [].concat(val || []);
|
|
802
|
+
for (var i = 0; i < list.length; i++) if (typeof list[i] !== "string") throw new TypeError(name + " must be array of strings or false");
|
|
803
|
+
return list;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Parse an HTTP Date into a number.
|
|
807
|
+
*
|
|
808
|
+
* @param {string} date
|
|
809
|
+
* @private
|
|
810
|
+
*/
|
|
811
|
+
function parseHttpDate(date) {
|
|
812
|
+
var timestamp = date && Date.parse(date);
|
|
813
|
+
return typeof timestamp === "number" ? timestamp : NaN;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Parse a HTTP token list.
|
|
817
|
+
*
|
|
818
|
+
* @param {string} str
|
|
819
|
+
* @private
|
|
820
|
+
*/
|
|
821
|
+
function parseTokenList(str) {
|
|
822
|
+
var end = 0;
|
|
823
|
+
var list = [];
|
|
824
|
+
var start = 0;
|
|
825
|
+
for (var i = 0, len = str.length; i < len; i++) switch (str.charCodeAt(i)) {
|
|
826
|
+
case 32:
|
|
827
|
+
if (start === end) start = end = i + 1;
|
|
828
|
+
break;
|
|
829
|
+
case 44:
|
|
830
|
+
if (start !== end) list.push(str.substring(start, end));
|
|
831
|
+
start = end = i + 1;
|
|
832
|
+
break;
|
|
833
|
+
default:
|
|
834
|
+
end = i + 1;
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
if (start !== end) list.push(str.substring(start, end));
|
|
838
|
+
return list;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Set an object of headers on a response.
|
|
842
|
+
*
|
|
843
|
+
* @param {object} res
|
|
844
|
+
* @param {object} headers
|
|
845
|
+
* @private
|
|
846
|
+
*/
|
|
847
|
+
function setHeaders(res, headers) {
|
|
848
|
+
var keys = Object.keys(headers);
|
|
849
|
+
for (var i = 0; i < keys.length; i++) {
|
|
850
|
+
var key = keys[i];
|
|
851
|
+
res.setHeader(key, headers[key]);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}) });
|
|
855
|
+
|
|
856
|
+
//#endregion
|
|
857
|
+
export { require_send as t };
|