elysia 2.0.0-beta.3 → 2.0.0-beta.31
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/README.md +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +1 -0
- package/dist/adapter/bun/index.d.ts +16 -2
- package/dist/adapter/bun/index.js +458 -119
- package/dist/adapter/bun/index.mjs +459 -121
- package/dist/adapter/constants.mjs +1 -0
- package/dist/adapter/default-headers.mjs +1 -0
- package/dist/adapter/index.mjs +1 -0
- package/dist/adapter/origin.js +0 -57
- package/dist/adapter/origin.mjs +1 -57
- package/dist/adapter/response-ownership.mjs +1 -0
- package/dist/adapter/skip-clone.mjs +1 -0
- package/dist/adapter/types.d.ts +2 -21
- package/dist/adapter/types.mjs +1 -0
- package/dist/adapter/utils.d.ts +11 -3
- package/dist/adapter/utils.js +147 -112
- package/dist/adapter/utils.mjs +149 -114
- package/dist/adapter/web-standard/handler.d.ts +1 -1
- package/dist/adapter/web-standard/handler.js +39 -36
- package/dist/adapter/web-standard/handler.mjs +41 -37
- package/dist/adapter/web-standard/index.js +2 -30
- package/dist/adapter/web-standard/index.mjs +3 -30
- package/dist/adapter/web-standard/utils.js +5 -18
- package/dist/adapter/web-standard/utils.mjs +6 -18
- package/dist/base.d.ts +387 -207
- package/dist/base.js +742 -676
- package/dist/base.mjs +747 -680
- package/dist/compile/aot-capture.d.ts +2 -13
- package/dist/compile/aot-capture.js +39 -89
- package/dist/compile/aot-capture.mjs +43 -88
- package/dist/compile/aot-emit.d.ts +9 -8
- package/dist/compile/aot-emit.js +36 -38
- package/dist/compile/aot-emit.mjs +37 -38
- package/dist/compile/aot-reconstruct.js +7 -30
- package/dist/compile/aot-reconstruct.mjs +8 -30
- package/dist/compile/aot.d.ts +15 -17
- package/dist/compile/aot.js +36 -58
- package/dist/compile/aot.mjs +34 -57
- package/dist/compile/handler/descriptor.d.ts +10 -17
- package/dist/compile/handler/descriptor.js +25 -58
- package/dist/compile/handler/descriptor.mjs +29 -58
- package/dist/compile/handler/frozen-validator.d.ts +7 -12
- package/dist/compile/handler/frozen-validator.js +57 -118
- package/dist/compile/handler/frozen-validator.mjs +56 -118
- package/dist/compile/handler/index.d.ts +8 -4
- package/dist/compile/handler/index.js +322 -206
- package/dist/compile/handler/index.mjs +324 -211
- package/dist/compile/handler/jit.d.ts +28 -21
- package/dist/compile/handler/jit.js +232 -159
- package/dist/compile/handler/jit.mjs +235 -165
- package/dist/compile/handler/params.d.ts +5 -4
- package/dist/compile/handler/params.js +21 -9
- package/dist/compile/handler/params.mjs +25 -12
- package/dist/compile/handler/reconstruct.d.ts +4 -4
- package/dist/compile/handler/reconstruct.js +8 -6
- package/dist/compile/handler/reconstruct.mjs +9 -6
- package/dist/compile/handler/static-clone-resolver.d.ts +6 -0
- package/dist/compile/handler/static-clone-resolver.js +8 -0
- package/dist/compile/handler/static-clone-resolver.mjs +8 -0
- package/dist/compile/handler/utils.d.ts +29 -11
- package/dist/compile/handler/utils.js +184 -276
- package/dist/compile/handler/utils.mjs +179 -275
- package/dist/compile/jit-probe.d.ts +2 -2
- package/dist/compile/jit-probe.js +2 -3
- package/dist/compile/jit-probe.mjs +3 -3
- package/dist/compile/lexer.d.ts +7 -4
- package/dist/compile/lexer.js +268 -6
- package/dist/compile/lexer.mjs +269 -4
- package/dist/compile/utils.d.ts +2 -1
- package/dist/compile/utils.js +14 -6
- package/dist/compile/utils.mjs +14 -6
- package/dist/compiled.d.ts +0 -1
- package/dist/compiled.js +0 -10
- package/dist/compiled.mjs +1 -10
- package/dist/constants.js +19 -4
- package/dist/constants.mjs +20 -4
- package/dist/context.d.ts +15 -5
- package/dist/context.js +17 -36
- package/dist/context.mjs +20 -38
- package/dist/cookie/config.d.ts +6 -2
- package/dist/cookie/config.js +77 -23
- package/dist/cookie/config.mjs +79 -25
- package/dist/cookie/cookie.d.ts +7 -5
- package/dist/cookie/cookie.js +12 -10
- package/dist/cookie/cookie.mjs +13 -10
- package/dist/cookie/crypto.d.ts +1 -1
- package/dist/cookie/crypto.js +19 -14
- package/dist/cookie/crypto.mjs +20 -14
- package/dist/cookie/error.d.ts +1 -2
- package/dist/cookie/error.js +6 -3
- package/dist/cookie/error.mjs +7 -3
- package/dist/cookie/lib.js +2 -1
- package/dist/cookie/lib.mjs +3 -1
- package/dist/cookie/serialize.mjs +1 -0
- package/dist/cookie/types.d.ts +1 -1
- package/dist/cookie/types.mjs +1 -0
- package/dist/cookie/utils.d.ts +5 -9
- package/dist/cookie/utils.js +109 -83
- package/dist/cookie/utils.mjs +112 -84
- package/dist/error.d.ts +127 -111
- package/dist/error.js +187 -180
- package/dist/error.mjs +185 -181
- package/dist/generation.d.ts +2 -2
- package/dist/generation.mjs +1 -0
- package/dist/handler/error.d.ts +18 -18
- package/dist/handler/error.js +77 -120
- package/dist/handler/error.mjs +80 -122
- package/dist/handler/fetch.js +165 -153
- package/dist/handler/fetch.mjs +168 -155
- package/dist/handler/utils.d.ts +25 -6
- package/dist/handler/utils.js +81 -26
- package/dist/handler/utils.mjs +76 -25
- package/dist/index.d.ts +11 -11
- package/dist/index.js +3 -1
- package/dist/index.mjs +5 -4
- package/dist/memory.js +2 -2
- package/dist/memory.mjs +3 -2
- package/dist/package.js +1 -1
- package/dist/package.mjs +2 -1
- package/dist/parse-query.js +76 -80
- package/dist/parse-query.mjs +77 -80
- package/dist/plugin/aot/bun.d.ts +8 -1
- package/dist/plugin/aot/bun.js +9 -28
- package/dist/plugin/aot/bun.mjs +11 -29
- package/dist/plugin/aot/core.d.ts +37 -66
- package/dist/plugin/aot/core.js +197 -153
- package/dist/plugin/aot/core.mjs +195 -156
- package/dist/plugin/aot/esbuild.js +8 -24
- package/dist/plugin/aot/esbuild.mjs +10 -25
- package/dist/plugin/aot/hooks.d.ts +6 -17
- package/dist/plugin/aot/hooks.js +37 -17
- package/dist/plugin/aot/hooks.mjs +38 -19
- package/dist/plugin/aot/rspack-loader.d.ts +1 -5
- package/dist/plugin/aot/rspack-loader.js +1 -26
- package/dist/plugin/aot/rspack-loader.mjs +2 -26
- package/dist/plugin/aot/rspack.js +2 -19
- package/dist/plugin/aot/rspack.mjs +4 -20
- package/dist/plugin/aot/source.d.ts +7 -43
- package/dist/plugin/aot/source.js +73 -73
- package/dist/plugin/aot/source.mjs +74 -74
- package/dist/plugin/aot/treeshake.js +2 -6
- package/dist/plugin/aot/treeshake.mjs +3 -6
- package/dist/plugin/aot/unplugin.d.ts +1 -4
- package/dist/plugin/aot/unplugin.js +4 -32
- package/dist/plugin/aot/unplugin.mjs +5 -32
- package/dist/plugin/aot/vite.d.ts +2 -6
- package/dist/plugin/aot/vite.js +0 -14
- package/dist/plugin/aot/vite.mjs +1 -14
- package/dist/plugin/aot/worker.js +2 -2
- package/dist/plugin/aot/worker.mjs +3 -2
- package/dist/plugin/auto-head.js +1 -10
- package/dist/plugin/auto-head.mjs +2 -10
- package/dist/plugin/trace.d.ts +18 -1
- package/dist/plugin/trace.js +0 -16
- package/dist/plugin/trace.mjs +1 -16
- package/dist/plugin/websocket.d.ts +21 -0
- package/dist/plugin/websocket.js +0 -21
- package/dist/plugin/websocket.mjs +1 -21
- package/dist/route-table.d.ts +3 -0
- package/dist/route-table.js +4 -1
- package/dist/route-table.mjs +5 -1
- package/dist/schema-snapshot.d.ts +0 -4
- package/dist/schema-snapshot.js +60 -56
- package/dist/schema-snapshot.mjs +61 -56
- package/dist/sucrose.d.ts +7 -56
- package/dist/sucrose.js +103 -735
- package/dist/sucrose.mjs +103 -728
- package/dist/trace.d.ts +16 -10
- package/dist/trace.js +20 -134
- package/dist/trace.mjs +22 -135
- package/dist/type/bridge-live.d.ts +5 -3
- package/dist/type/bridge-live.js +6 -3
- package/dist/type/bridge-live.mjs +6 -3
- package/dist/type/bridge.d.ts +7 -5
- package/dist/type/bridge.js +38 -28
- package/dist/type/bridge.mjs +27 -22
- package/dist/type/coerce-plan.d.ts +5 -5
- package/dist/type/coerce-plan.js +53 -43
- package/dist/type/coerce-plan.mjs +56 -44
- package/dist/type/coerce.d.ts +3 -7
- package/dist/type/coerce.js +18 -79
- package/dist/type/coerce.mjs +20 -80
- package/dist/type/compat.js +10 -19
- package/dist/type/compat.mjs +12 -20
- package/dist/type/constants.d.ts +1 -1
- package/dist/type/constants.mjs +1 -0
- package/dist/type/elysia/accelerate.mjs +1 -0
- package/dist/type/elysia/array-buffer.d.ts +6 -2
- package/dist/type/elysia/array-buffer.js +16 -15
- package/dist/type/elysia/array-buffer.mjs +17 -16
- package/dist/type/elysia/array-string.js +2 -43
- package/dist/type/elysia/array-string.mjs +3 -43
- package/dist/type/elysia/array.js +5 -9
- package/dist/type/elysia/array.mjs +6 -9
- package/dist/type/elysia/boolean-string.mjs +1 -0
- package/dist/type/elysia/boolean.js +3 -13
- package/dist/type/elysia/boolean.mjs +4 -13
- package/dist/type/elysia/cookie.d.ts +3 -4
- package/dist/type/elysia/cookie.js +3 -14
- package/dist/type/elysia/cookie.mjs +4 -14
- package/dist/type/elysia/date.d.ts +2 -1
- package/dist/type/elysia/date.js +7 -14
- package/dist/type/elysia/date.mjs +8 -14
- package/dist/type/elysia/file-type.d.ts +2 -2
- package/dist/type/elysia/file-type.js +4 -3
- package/dist/type/elysia/file-type.mjs +5 -3
- package/dist/type/elysia/file.d.ts +1 -3
- package/dist/type/elysia/file.js +3 -23
- package/dist/type/elysia/file.mjs +5 -10
- package/dist/type/elysia/files.js +1 -7
- package/dist/type/elysia/files.mjs +3 -8
- package/dist/type/elysia/form.mjs +1 -0
- package/dist/type/elysia/integer-string.d.ts +1 -1
- package/dist/type/elysia/integer-string.js +3 -28
- package/dist/type/elysia/integer-string.mjs +5 -29
- package/dist/type/elysia/integer.js +3 -13
- package/dist/type/elysia/integer.mjs +4 -13
- package/dist/type/elysia/intersect.js +0 -5
- package/dist/type/elysia/intersect.mjs +1 -5
- package/dist/type/elysia/json-string.d.ts +7 -0
- package/dist/type/elysia/json-string.js +47 -0
- package/dist/type/elysia/json-string.mjs +47 -0
- package/dist/type/elysia/keep-config.d.ts +14 -0
- package/dist/type/elysia/keep-config.js +62 -0
- package/dist/type/elysia/keep-config.mjs +54 -0
- package/dist/type/elysia/maybe-empty.mjs +1 -0
- package/dist/type/elysia/no-validate.mjs +1 -0
- package/dist/type/elysia/nullable.mjs +1 -0
- package/dist/type/elysia/number.d.ts +2 -1
- package/dist/type/elysia/number.js +19 -12
- package/dist/type/elysia/number.mjs +19 -12
- package/dist/type/elysia/numeric-enum.d.ts +5 -3
- package/dist/type/elysia/numeric-enum.js +1 -5
- package/dist/type/elysia/numeric-enum.mjs +2 -5
- package/dist/type/elysia/numeric.d.ts +4 -2
- package/dist/type/elysia/numeric.js +17 -14
- package/dist/type/elysia/numeric.mjs +17 -14
- package/dist/type/elysia/object-string.js +2 -40
- package/dist/type/elysia/object-string.mjs +3 -40
- package/dist/type/elysia/object.js +5 -9
- package/dist/type/elysia/object.mjs +6 -9
- package/dist/type/elysia/optional.js +8 -8
- package/dist/type/elysia/optional.mjs +8 -7
- package/dist/type/elysia/problem.d.ts +20 -0
- package/dist/type/elysia/problem.js +19 -0
- package/dist/type/elysia/problem.mjs +19 -0
- package/dist/type/elysia/string.mjs +1 -0
- package/dist/type/elysia/uint8-array.d.ts +2 -1
- package/dist/type/elysia/uint8-array.js +4 -18
- package/dist/type/elysia/uint8-array.mjs +5 -18
- package/dist/type/elysia/union-enum.js +5 -6
- package/dist/type/elysia/union-enum.mjs +6 -6
- package/dist/type/elysia/union.js +0 -5
- package/dist/type/elysia/union.mjs +1 -5
- package/dist/type/elysia/utils.d.ts +4 -6
- package/dist/type/elysia/utils.js +16 -40
- package/dist/type/elysia/utils.mjs +15 -36
- package/dist/type/exports.d.ts +4 -2
- package/dist/type/exports.js +13 -1
- package/dist/type/exports.mjs +5 -2
- package/dist/type/index.d.ts +1 -1
- package/dist/type/index.js +31 -23
- package/dist/type/index.mjs +33 -24
- package/dist/type/shared.d.ts +12 -10
- package/dist/type/shared.js +75 -109
- package/dist/type/shared.mjs +72 -108
- package/dist/type/sync-require.d.ts +11 -0
- package/dist/type/sync-require.js +7 -0
- package/dist/type/sync-require.mjs +6 -0
- package/dist/type/typebox-system-lite.d.ts +2 -0
- package/dist/type/typebox-system-lite.js +34 -0
- package/dist/type/typebox-system-lite.mjs +4 -0
- package/dist/type/typebox-system-require.d.ts +7 -0
- package/dist/type/typebox-system-require.js +24 -0
- package/dist/type/typebox-system-require.mjs +24 -0
- package/dist/type/typebox-type-live.d.ts +6 -4
- package/dist/type/typebox-type-live.js +23 -9
- package/dist/type/typebox-type-live.mjs +11 -6
- package/dist/type/typebox-type.d.ts +14 -4
- package/dist/type/typebox-type.js +85 -22
- package/dist/type/typebox-type.mjs +35 -21
- package/dist/type/typebox-value-live.d.ts +3 -1
- package/dist/type/typebox-value-live.js +5 -1
- package/dist/type/typebox-value-live.mjs +4 -1
- package/dist/type/typebox-value-ops.d.ts +4 -0
- package/dist/type/typebox-value-ops.js +90 -0
- package/dist/type/typebox-value-ops.mjs +6 -0
- package/dist/type/typebox-value-require.d.ts +8 -0
- package/dist/type/typebox-value-require.js +28 -0
- package/dist/type/typebox-value-require.mjs +25 -0
- package/dist/type/typebox-value.d.ts +9 -4
- package/dist/type/typebox-value.js +19 -8
- package/dist/type/typebox-value.mjs +19 -9
- package/dist/type/types.d.ts +1 -1
- package/dist/type/types.mjs +1 -0
- package/dist/type/utils.js +1 -10
- package/dist/type/utils.mjs +2 -10
- package/dist/type/validator/clean-safe.d.ts +2 -4
- package/dist/type/validator/clean-safe.js +15 -11
- package/dist/type/validator/clean-safe.mjs +17 -10
- package/dist/type/validator/custom-error.js +50 -48
- package/dist/type/validator/custom-error.mjs +51 -48
- package/dist/type/validator/default-precompute.d.ts +10 -2
- package/dist/type/validator/default-precompute.js +33 -77
- package/dist/type/validator/default-precompute.mjs +33 -77
- package/dist/type/validator/exact-mirror-live.d.ts +8 -0
- package/dist/type/validator/exact-mirror-live.js +15 -0
- package/dist/type/validator/exact-mirror-live.mjs +11 -0
- package/dist/type/validator/exact-mirror-require.d.ts +4 -0
- package/dist/type/validator/exact-mirror-require.js +11 -0
- package/dist/type/validator/exact-mirror-require.mjs +9 -0
- package/dist/type/validator/exact-mirror.js +15 -7
- package/dist/type/validator/exact-mirror.mjs +17 -7
- package/dist/type/validator/frozen-check.js +7 -8
- package/dist/type/validator/frozen-check.mjs +9 -9
- package/dist/type/validator/index.d.ts +2 -1
- package/dist/type/validator/index.js +149 -168
- package/dist/type/validator/index.mjs +155 -173
- package/dist/type/validator/string-codec-aot.d.ts +3 -2
- package/dist/type/validator/string-codec-aot.js +11 -7
- package/dist/type/validator/string-codec-aot.mjs +11 -7
- package/dist/type/validator/validator-cache.d.ts +5 -4
- package/dist/type/validator/validator-cache.js +49 -37
- package/dist/type/validator/validator-cache.mjs +49 -36
- package/dist/types.d.ts +596 -187
- package/dist/types.mjs +1 -0
- package/dist/universal/constants.mjs +1 -0
- package/dist/universal/env.js +2 -3
- package/dist/universal/env.mjs +2 -3
- package/dist/universal/file.d.ts +6 -4
- package/dist/universal/file.js +7 -19
- package/dist/universal/file.mjs +9 -19
- package/dist/universal/index.d.ts +2 -2
- package/dist/universal/index.mjs +1 -0
- package/dist/universal/is-production.d.ts +1 -2
- package/dist/universal/is-production.js +1 -3
- package/dist/universal/is-production.mjs +3 -3
- package/dist/universal/server.d.ts +0 -272
- package/dist/universal/server.mjs +1 -0
- package/dist/utils.d.ts +62 -22
- package/dist/utils.js +342 -277
- package/dist/utils.mjs +327 -273
- package/dist/validator/index.d.ts +3 -3
- package/dist/validator/index.js +20 -34
- package/dist/validator/index.mjs +23 -36
- package/dist/validator/route.d.ts +3 -10
- package/dist/validator/route.js +2 -1
- package/dist/validator/route.mjs +3 -1
- package/dist/ws/context.d.ts +4 -1
- package/dist/ws/context.js +41 -36
- package/dist/ws/context.mjs +41 -36
- package/dist/ws/index.mjs +1 -0
- package/dist/ws/parser.js +12 -22
- package/dist/ws/parser.mjs +13 -22
- package/dist/ws/route.d.ts +2 -2
- package/dist/ws/route.js +295 -221
- package/dist/ws/route.mjs +302 -227
- package/dist/ws/types.d.ts +6 -7
- package/dist/ws/types.mjs +1 -0
- package/package.json +22 -55
- package/dist/compile/analysis-cache.d.ts +0 -6
- package/dist/compile/analysis-cache.js +0 -12
- package/dist/compile/analysis-cache.mjs +0 -11
- package/dist/cookie/index.d.ts +0 -7
- package/dist/cookie/index.js +0 -13
- package/dist/cookie/index.mjs +0 -7
- package/dist/handler/index.d.ts +0 -2
- package/dist/handler/index.js +0 -5
- package/dist/handler/index.mjs +0 -3
package/dist/handler/utils.mjs
CHANGED
|
@@ -1,44 +1,95 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { isCloudflareWorker, isFastly } from "../universal/constants.mjs";
|
|
3
|
+
import { isDisposable, isSingleton } from "../utils.mjs";
|
|
2
4
|
import { env } from "../universal/env.mjs";
|
|
3
|
-
import { PROBLEM_JSON } from "../error.mjs";
|
|
5
|
+
import { HTTPError, PROBLEM_JSON, problemTypeOf } from "../error.mjs";
|
|
4
6
|
import { isAsyncFunction, mayReturnPromise } from "../compile/utils.mjs";
|
|
5
7
|
|
|
6
8
|
//#region src/handler/utils.ts
|
|
7
9
|
const isPreallocateResponseUnsafe = isCloudflareWorker || isFastly || env.ELYSIA_PREALLOCATE_RESPONSE === "false";
|
|
8
10
|
const emptyResponse = isPreallocateResponseUnsafe ? { clone: () => new Response(null) } : new Response(null);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
let notFoundBase;
|
|
12
|
+
let notFoundBody;
|
|
13
|
+
let notFoundResponse;
|
|
14
|
+
function getNotFoundBody() {
|
|
15
|
+
const base = HTTPError.typeBase;
|
|
16
|
+
if (notFoundBody === void 0 || base !== notFoundBase) {
|
|
17
|
+
notFoundBase = base;
|
|
18
|
+
notFoundResponse = void 0;
|
|
19
|
+
notFoundBody = JSON.stringify({
|
|
20
|
+
type: problemTypeOf("not-found"),
|
|
21
|
+
code: "not-found",
|
|
22
|
+
status: 404,
|
|
23
|
+
title: "Not Found"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return notFoundBody;
|
|
27
|
+
}
|
|
28
|
+
const notFoundInit = {
|
|
29
|
+
status: 404,
|
|
30
|
+
headers: { "content-type": PROBLEM_JSON }
|
|
31
|
+
};
|
|
32
|
+
function getNotFound() {
|
|
33
|
+
const body = getNotFoundBody();
|
|
34
|
+
if (isPreallocateResponseUnsafe) return new Response(body, notFoundInit);
|
|
35
|
+
return (notFoundResponse ??= new Response(body, notFoundInit)).clone();
|
|
18
36
|
}
|
|
19
|
-
const NOT_FOUND_BODY = JSON.stringify({
|
|
20
|
-
type: "not-found",
|
|
21
|
-
title: "Not Found",
|
|
22
|
-
status: 404
|
|
23
|
-
});
|
|
24
|
-
const getNotFound = cachedResponse(NOT_FOUND_BODY, 404, { "content-type": PROBLEM_JSON });
|
|
25
37
|
function forwardError(value) {
|
|
26
38
|
if (value instanceof Error) throw value;
|
|
27
39
|
return value;
|
|
28
40
|
}
|
|
29
|
-
function
|
|
41
|
+
function returnedErrorClasses(hook) {
|
|
42
|
+
const error = hook?.error;
|
|
43
|
+
if (!error) return;
|
|
44
|
+
let into;
|
|
45
|
+
const list = Array.isArray(error) ? error : [error];
|
|
46
|
+
for (let i = 0; i < list.length; i++) {
|
|
47
|
+
const errorClass = list[i]?.["~errorClass"];
|
|
48
|
+
if (errorClass && !into?.includes(errorClass)) (into ??= []).push(errorClass);
|
|
49
|
+
}
|
|
50
|
+
return into;
|
|
51
|
+
}
|
|
52
|
+
const forwardErrorOf = (classes) => (value) => {
|
|
53
|
+
if (value instanceof Error) throw value;
|
|
54
|
+
for (let i = 0; i < classes.length; i++) if (value instanceof classes[i]) throw value;
|
|
55
|
+
return value;
|
|
56
|
+
};
|
|
57
|
+
function finalizeRouteError(app, context, error, sign, route) {
|
|
30
58
|
const finalize = app["~finalizeError"];
|
|
31
59
|
if (!finalize) throw error;
|
|
32
|
-
return finalize(context, error);
|
|
60
|
+
return finalize(context, error, sign, false, route);
|
|
61
|
+
}
|
|
62
|
+
const finalizeRouteErrorOf = (route) => route?.error?.length || route?.mapResponse?.length ? (app, context, error, sign) => finalizeRouteError(app, context, error, sign, route) : finalizeRouteError;
|
|
63
|
+
function registerDeriveDisposable(context, value, scan = context) {
|
|
64
|
+
if (!isDisposable(value)) return;
|
|
65
|
+
if (isSingleton(value)) return;
|
|
66
|
+
for (const key in scan) if (scan[key] === value) return;
|
|
67
|
+
const stack = context["~dispose"] ??= [];
|
|
68
|
+
for (const release of stack) if (release.value === value) return;
|
|
69
|
+
const disposable = value;
|
|
70
|
+
const asyncDispose = disposable[Symbol.asyncDispose];
|
|
71
|
+
const dispose = typeof asyncDispose === "function" ? asyncDispose : disposable[Symbol.dispose];
|
|
72
|
+
const release = () => dispose.call(value);
|
|
73
|
+
release.value = value;
|
|
74
|
+
stack.push(release);
|
|
33
75
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
76
|
+
async function drainDisposables(context) {
|
|
77
|
+
const stack = context["~dispose"];
|
|
78
|
+
if (!stack) return;
|
|
79
|
+
try {
|
|
80
|
+
if (!Array.isArray(stack)) throw new TypeError("Invalid disposable stack");
|
|
81
|
+
const errors = [];
|
|
82
|
+
while (stack.length) try {
|
|
83
|
+
await stack.pop()();
|
|
84
|
+
} catch (error) {
|
|
85
|
+
errors.push(error);
|
|
86
|
+
}
|
|
87
|
+
if (errors.length) throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Multiple disposers failed");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error(error);
|
|
39
90
|
}
|
|
40
|
-
return asyncIndexes;
|
|
41
91
|
}
|
|
92
|
+
const hasAsync = (fns) => fns.some((fn) => isAsyncFunction(fn) || mayReturnPromise(fn));
|
|
42
93
|
|
|
43
94
|
//#endregion
|
|
44
|
-
export {
|
|
95
|
+
export { drainDisposables, emptyResponse, finalizeRouteError, finalizeRouteErrorOf, forwardError, forwardErrorOf, getNotFound, getNotFoundBody, hasAsync, registerDeriveDisposable, returnedErrorClasses };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { BaseCookie, CookieOptions } from "./cookie/types.js";
|
|
2
|
-
import { Cookie } from "./cookie/cookie.js";
|
|
3
|
-
import { ElysiaFile, file } from "./universal/file.js";
|
|
4
1
|
import { StatusMap, StatusMapBack } from "./constants.js";
|
|
5
|
-
import {
|
|
2
|
+
import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, NumericStatus, ParseError, Problem, SelectiveProblem, SelectiveStatus, StatusResponse, TaggedHTTPError, ValidationError, ValidationErrorResponse, problem, status, validationDetail } from "./error.js";
|
|
3
|
+
import { bytes, form, macroType, prefix, redirect, sse } from "./utils.js";
|
|
6
4
|
import { Server } from "./universal/server.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, ParseError, Problem, SelectiveStatus, TaggedHTTPError, ValidationError, problem, status, validationDetail } from "./error.js";
|
|
5
|
+
import { BaseCookie, CookieOptions } from "./cookie/types.js";
|
|
6
|
+
import { Cookie } from "./cookie/cookie.js";
|
|
10
7
|
import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
|
|
11
|
-
import {
|
|
8
|
+
import { ElysiaFile, file } from "./universal/file.js";
|
|
12
9
|
import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
|
|
13
10
|
import { TCookieField, TCookieObject } from "./type/elysia/cookie.js";
|
|
14
|
-
import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
|
|
15
11
|
import { TFiles } from "./type/elysia/files.js";
|
|
16
12
|
import { setupTypebox } from "./type/compat.js";
|
|
13
|
+
import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
|
|
14
|
+
import { AotFingerprint, Capture, Compiled, CompilerSession, ProgramId, inAotBuild } from "./compile/aot.js";
|
|
17
15
|
import { MultiValidator, StandardValidator, Validator } from "./validator/index.js";
|
|
18
16
|
import { TypeBoxValidator } from "./type/validator/index.js";
|
|
19
17
|
import { TypeSystem, t } from "./type/index.js";
|
|
20
|
-
import {
|
|
18
|
+
import { env } from "./universal/env.js";
|
|
19
|
+
import { DefaultEphemeral, DefaultMetadata, DefaultSingleton, HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, MacroTypeLambda, RouteSchema, SSEPayload, UnwrapModels, UnwrapRoute, UnwrapSchema } from "./types.js";
|
|
21
20
|
import { AnyElysia, Elysia } from "./base.js";
|
|
22
21
|
import { borrow } from "./adapter/response-ownership.js";
|
|
23
|
-
|
|
22
|
+
import { InvalidCookie } from "./cookie/error.js";
|
|
23
|
+
export { AnyElysia, type AnySchema, type AotFingerprint, type BaseCookie, type BaseSchema, Compiled, type CompilerSession, type Context, type Cookie, type CookieOptions, type DefaultEphemeral, type DefaultMetadata, type DefaultSingleton, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, HTTPError, type HTTPHeaders, type InputSchema, InternalServerError, InvalidCookie, type Macro, type MacroToContext, type MacroToProperty, type MacroTypeLambda, Capture as Manifest, MultiValidator, NotFound, type NumericStatus, ParseError, type Problem, type ProgramId, type RouteSchema, type SSEPayload, type SelectiveProblem, type SelectiveStatus, type Server, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type StatusResponse, type TCookieField, type TCookieObject, type TFiles, type TaggedHTTPError, TypeBoxValidator, TypeSystem, type UnwrapModels, type UnwrapRoute, type UnwrapSchema, ValidationError, type ValidationErrorResponse, Validator, borrow, bytes, createBaseContext, createContext, env, file, fileType, form, inAotBuild, macroType, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
|
package/dist/index.js
CHANGED
|
@@ -7,10 +7,10 @@ const require_error = require('./error.js');
|
|
|
7
7
|
const require_cookie_error = require('./cookie/error.js');
|
|
8
8
|
const require_adapter_response_ownership = require('./adapter/response-ownership.js');
|
|
9
9
|
const require_compile_aot = require('./compile/aot.js');
|
|
10
|
-
const require_type_elysia_file_type = require('./type/elysia/file-type.js');
|
|
11
10
|
const require_validator_index = require('./validator/index.js');
|
|
12
11
|
const require_context = require('./context.js');
|
|
13
12
|
const require_base = require('./base.js');
|
|
13
|
+
const require_type_elysia_file_type = require('./type/elysia/file-type.js');
|
|
14
14
|
const require_type_validator_index = require('./type/validator/index.js');
|
|
15
15
|
const require_type_compat = require('./type/compat.js');
|
|
16
16
|
const require_type_index = require('./type/index.js');
|
|
@@ -47,6 +47,8 @@ exports.env = require_universal_env.env;
|
|
|
47
47
|
exports.file = require_universal_file.file;
|
|
48
48
|
exports.fileType = require_type_elysia_file_type.fileType;
|
|
49
49
|
exports.form = require_utils.form;
|
|
50
|
+
exports.inAotBuild = require_compile_aot.inAotBuild;
|
|
51
|
+
exports.macroType = require_utils.macroType;
|
|
50
52
|
exports.prefix = require_utils.prefix;
|
|
51
53
|
exports.problem = require_error.problem;
|
|
52
54
|
exports.redirect = require_utils.redirect;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { StatusMap, StatusMapBack } from "./constants.mjs";
|
|
2
3
|
import { ElysiaFile, file } from "./universal/file.mjs";
|
|
3
|
-
import { bytes, form, prefix, redirect, sse } from "./utils.mjs";
|
|
4
|
+
import { bytes, form, macroType, prefix, redirect, sse } from "./utils.mjs";
|
|
4
5
|
import { env } from "./universal/env.mjs";
|
|
5
6
|
import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, ParseError, ValidationError, problem, status, validationDetail } from "./error.mjs";
|
|
6
7
|
import { InvalidCookie } from "./cookie/error.mjs";
|
|
7
8
|
import { borrow } from "./adapter/response-ownership.mjs";
|
|
8
|
-
import { Capture, Compiled } from "./compile/aot.mjs";
|
|
9
|
-
import { fileType, setFileTypeDetector } from "./type/elysia/file-type.mjs";
|
|
9
|
+
import { Capture, Compiled, inAotBuild } from "./compile/aot.mjs";
|
|
10
10
|
import { MultiValidator, StandardValidator, Validator } from "./validator/index.mjs";
|
|
11
11
|
import { createBaseContext, createContext } from "./context.mjs";
|
|
12
12
|
import { Elysia } from "./base.mjs";
|
|
13
|
+
import { fileType, setFileTypeDetector } from "./type/elysia/file-type.mjs";
|
|
13
14
|
import { TypeBoxValidator } from "./type/validator/index.mjs";
|
|
14
15
|
import { setupTypebox } from "./type/compat.mjs";
|
|
15
16
|
import { TypeSystem, t } from "./type/index.mjs";
|
|
@@ -18,4 +19,4 @@ import { TypeSystem, t } from "./type/index.mjs";
|
|
|
18
19
|
var src_default = Elysia;
|
|
19
20
|
|
|
20
21
|
//#endregion
|
|
21
|
-
export { Compiled, Elysia, ElysiaError, ElysiaFile, ElysiaStatus, HTTPError, InternalServerError, InvalidCookie, Capture as Manifest, MultiValidator, NotFound, ParseError, StandardValidator, StatusMap, StatusMapBack, TypeBoxValidator, TypeSystem, ValidationError, Validator, borrow, bytes, createBaseContext, createContext, src_default as default, env, file, fileType, form, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
|
|
22
|
+
export { Compiled, Elysia, ElysiaError, ElysiaFile, ElysiaStatus, HTTPError, InternalServerError, InvalidCookie, Capture as Manifest, MultiValidator, NotFound, ParseError, StandardValidator, StatusMap, StatusMapBack, TypeBoxValidator, TypeSystem, ValidationError, Validator, borrow, bytes, createBaseContext, createContext, src_default as default, env, file, fileType, form, inAotBuild, macroType, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
|
package/dist/memory.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_universal_constants = require('./universal/constants.js');
|
|
3
|
-
const require_sucrose = require('./sucrose.js');
|
|
4
3
|
const require_validator_index = require('./validator/index.js');
|
|
4
|
+
const require_sucrose = require('./sucrose.js');
|
|
5
5
|
const require_context = require('./context.js');
|
|
6
6
|
|
|
7
7
|
//#region src/memory.ts
|
|
8
8
|
function flushMemory() {
|
|
9
|
-
require_sucrose.clearSucroseCache(
|
|
9
|
+
require_sucrose.clearSucroseCache();
|
|
10
10
|
require_context.clearContextCache();
|
|
11
11
|
require_validator_index.Validator.clear();
|
|
12
12
|
if (require_universal_constants.isBun) Bun.gc();
|
package/dist/memory.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { isBun } from "./universal/constants.mjs";
|
|
2
|
-
import { clearSucroseCache } from "./sucrose.mjs";
|
|
3
3
|
import { Validator } from "./validator/index.mjs";
|
|
4
|
+
import { clearSucroseCache } from "./sucrose.mjs";
|
|
4
5
|
import { clearContextCache } from "./context.mjs";
|
|
5
6
|
|
|
6
7
|
//#region src/memory.ts
|
|
7
8
|
function flushMemory() {
|
|
8
|
-
clearSucroseCache(
|
|
9
|
+
clearSucroseCache();
|
|
9
10
|
clearContextCache();
|
|
10
11
|
Validator.clear();
|
|
11
12
|
if (isBun) Bun.gc();
|
package/dist/package.js
CHANGED
package/dist/package.mjs
CHANGED
package/dist/parse-query.js
CHANGED
|
@@ -22,7 +22,7 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
|
|
|
22
22
|
let equalityIndex = startingIndex;
|
|
23
23
|
for (let i = startIndex + 1; i < inputLength; i++) switch (input.charCodeAt(i)) {
|
|
24
24
|
case 38:
|
|
25
|
-
|
|
25
|
+
processKeyValuePairFromURL(input, i, result, startingIndex, equalityIndex, flags, array, object);
|
|
26
26
|
startingIndex = i;
|
|
27
27
|
equalityIndex = i;
|
|
28
28
|
flags = 0;
|
|
@@ -40,69 +40,65 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
|
|
|
40
40
|
else flags |= KEY_NEEDS_DECODE;
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
|
-
if (startingIndex < inputLength)
|
|
43
|
+
if (startingIndex < inputLength) processKeyValuePairFromURL(input, inputLength, result, startingIndex, equalityIndex, flags, array, object);
|
|
44
44
|
return result;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
else finalValue = toBracketArray;
|
|
79
|
-
if (currentValue === void 0) result[finalKey] = finalValue;
|
|
80
|
-
else if (Array.isArray(currentValue)) for (let i = 0; i < finalValue.length; i++) currentValue.push(finalValue[i]);
|
|
81
|
-
else {
|
|
82
|
-
result[finalKey] = finalValue;
|
|
83
|
-
result[finalKey].unshift(currentValue);
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
if (object && object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
|
|
87
|
-
finalValue = JSON.parse(finalValue);
|
|
88
|
-
} catch {}
|
|
89
|
-
else if (currentValue === void 0 && !(object && object?.[finalKey]) && rawValue.indexOf(",") !== -1) finalValue = splitRawParts(rawValue, flags);
|
|
90
|
-
if (currentValue === void 0) result[finalKey] = Array.isArray(finalValue) ? finalValue : [finalValue];
|
|
91
|
-
else if (Array.isArray(currentValue)) currentValue.push(finalValue);
|
|
92
|
-
else result[finalKey] = [currentValue, finalValue];
|
|
45
|
+
}
|
|
46
|
+
function processKeyValuePairFromURL(input, endIndex, result, startingIndex, equalityIndex, flags, array, object) {
|
|
47
|
+
const hasBothKeyValuePair = equalityIndex > startingIndex;
|
|
48
|
+
const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
|
|
49
|
+
const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
|
|
50
|
+
if (!hasBothKeyValuePair && keySlice.length === 0) return;
|
|
51
|
+
let finalKey = keySlice;
|
|
52
|
+
if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
|
|
53
|
+
if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
|
|
54
|
+
let finalValue = "";
|
|
55
|
+
if (hasBothKeyValuePair) {
|
|
56
|
+
let valueSlice = input.slice(equalityIndex + 1, endIndex);
|
|
57
|
+
if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
|
|
58
|
+
if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
|
|
59
|
+
finalValue = valueSlice;
|
|
60
|
+
}
|
|
61
|
+
const currentValue = result[finalKey];
|
|
62
|
+
if (array && array?.[finalKey]) {
|
|
63
|
+
let rawValue = hasBothKeyValuePair ? input.slice(equalityIndex + 1, endIndex) : "";
|
|
64
|
+
if (flags & VALUE_HAS_PLUS) rawValue = rawValue.replace(/\+/g, " ");
|
|
65
|
+
const rawBracket = rawValue.charCodeAt(0) === 91 && rawValue.charCodeAt(rawValue.length - 1) === 93;
|
|
66
|
+
const decodedBracket = !rawBracket && finalValue.charCodeAt(0) === 91 && finalValue.charCodeAt(finalValue.length - 1) === 93;
|
|
67
|
+
if (rawBracket || decodedBracket) {
|
|
68
|
+
let toBracketArray;
|
|
69
|
+
if (rawBracket) toBracketArray = rawValue.length === 2 ? [] : splitRawParts(rawValue.slice(1, -1), flags);
|
|
70
|
+
else {
|
|
71
|
+
const inner = finalValue.slice(1, -1);
|
|
72
|
+
toBracketArray = inner === "" ? [] : inner.split(",");
|
|
73
|
+
}
|
|
74
|
+
if (object && object?.[finalKey]) try {
|
|
75
|
+
finalValue = JSON.parse(finalValue);
|
|
76
|
+
} catch {
|
|
77
|
+
finalValue = toBracketArray;
|
|
93
78
|
}
|
|
94
|
-
|
|
95
|
-
result[finalKey] =
|
|
96
|
-
|
|
97
|
-
|
|
79
|
+
else finalValue = toBracketArray;
|
|
80
|
+
if (currentValue === void 0) result[finalKey] = finalValue;
|
|
81
|
+
else if (Array.isArray(currentValue)) for (let i = 0; i < finalValue.length; i++) currentValue.push(finalValue[i]);
|
|
82
|
+
else {
|
|
83
|
+
result[finalKey] = finalValue;
|
|
84
|
+
result[finalKey].unshift(currentValue);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
if (object && object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
|
|
88
|
+
finalValue = JSON.parse(finalValue);
|
|
89
|
+
} catch {}
|
|
90
|
+
else if (currentValue === void 0 && !(object && object?.[finalKey]) && rawValue.indexOf(",") !== -1) finalValue = splitRawParts(rawValue, flags);
|
|
91
|
+
if (currentValue === void 0) result[finalKey] = Array.isArray(finalValue) ? finalValue : [finalValue];
|
|
92
|
+
else if (Array.isArray(currentValue)) currentValue.push(finalValue);
|
|
93
|
+
else result[finalKey] = [currentValue, finalValue];
|
|
98
94
|
}
|
|
99
|
-
|
|
95
|
+
} else if (object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
|
|
96
|
+
result[finalKey] = JSON.parse(finalValue);
|
|
97
|
+
} catch {
|
|
98
|
+
result[finalKey] = finalValue;
|
|
100
99
|
}
|
|
100
|
+
else result[finalKey] = finalValue;
|
|
101
101
|
}
|
|
102
|
-
/**
|
|
103
|
-
* @callback parse
|
|
104
|
-
* @param {string} input
|
|
105
|
-
*/
|
|
106
102
|
function parseQuery(input) {
|
|
107
103
|
const result = Object.create(null);
|
|
108
104
|
let flags = 0;
|
|
@@ -111,7 +107,7 @@ function parseQuery(input) {
|
|
|
111
107
|
let equalityIndex = -1;
|
|
112
108
|
for (let i = 0; i < inputLength; i++) switch (input.charCodeAt(i)) {
|
|
113
109
|
case 38:
|
|
114
|
-
processKeyValuePair(input, i);
|
|
110
|
+
processKeyValuePair(input, i, result, startingIndex, equalityIndex, flags);
|
|
115
111
|
startingIndex = i;
|
|
116
112
|
equalityIndex = i;
|
|
117
113
|
flags = 0;
|
|
@@ -129,28 +125,28 @@ function parseQuery(input) {
|
|
|
129
125
|
else flags |= KEY_NEEDS_DECODE;
|
|
130
126
|
break;
|
|
131
127
|
}
|
|
132
|
-
if (startingIndex < inputLength) processKeyValuePair(input, inputLength);
|
|
128
|
+
if (startingIndex < inputLength) processKeyValuePair(input, inputLength, result, startingIndex, equalityIndex, flags);
|
|
133
129
|
return result;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const currentValue = result[finalKey];
|
|
150
|
-
if (currentValue === void 0) result[finalKey] = finalValue;
|
|
151
|
-
else if (Array.isArray(currentValue)) currentValue.push(finalValue);
|
|
152
|
-
else result[finalKey] = [currentValue, finalValue];
|
|
130
|
+
}
|
|
131
|
+
function processKeyValuePair(input, endIndex, result, startingIndex, equalityIndex, flags) {
|
|
132
|
+
const hasBothKeyValuePair = equalityIndex > startingIndex;
|
|
133
|
+
const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
|
|
134
|
+
const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
|
|
135
|
+
if (!hasBothKeyValuePair && keySlice.length === 0) return;
|
|
136
|
+
let finalKey = keySlice;
|
|
137
|
+
if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
|
|
138
|
+
if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
|
|
139
|
+
let finalValue = "";
|
|
140
|
+
if (hasBothKeyValuePair) {
|
|
141
|
+
let valueSlice = input.slice(equalityIndex + 1, endIndex);
|
|
142
|
+
if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
|
|
143
|
+
if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
|
|
144
|
+
finalValue = valueSlice;
|
|
153
145
|
}
|
|
146
|
+
const currentValue = result[finalKey];
|
|
147
|
+
if (currentValue === void 0) result[finalKey] = finalValue;
|
|
148
|
+
else if (Array.isArray(currentValue)) currentValue.push(finalValue);
|
|
149
|
+
else result[finalKey] = [currentValue, finalValue];
|
|
154
150
|
}
|
|
155
151
|
|
|
156
152
|
//#endregion
|