elysia 2.0.0-beta.21 → 2.0.0-beta.22
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/_virtual/_rolldown/runtime.mjs +1 -0
- package/dist/adapter/bun/index.d.ts +6 -8
- package/dist/adapter/bun/index.js +6 -8
- package/dist/adapter/bun/index.mjs +7 -8
- 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.mjs +1 -0
- package/dist/adapter/response-ownership.mjs +1 -0
- package/dist/adapter/skip-clone.mjs +1 -0
- package/dist/adapter/types.mjs +1 -0
- package/dist/adapter/utils.d.ts +5 -8
- package/dist/adapter/utils.js +24 -18
- package/dist/adapter/utils.mjs +25 -18
- package/dist/adapter/web-standard/handler.mjs +2 -1
- package/dist/adapter/web-standard/index.mjs +1 -0
- package/dist/adapter/web-standard/utils.mjs +1 -0
- package/dist/base.d.ts +118 -69
- package/dist/base.js +213 -193
- package/dist/base.mjs +220 -199
- package/dist/compile/aot-capture.js +2 -2
- package/dist/compile/aot-capture.mjs +4 -3
- package/dist/compile/aot-emit.js +7 -8
- package/dist/compile/aot-emit.mjs +8 -8
- package/dist/compile/aot-reconstruct.mjs +3 -2
- package/dist/compile/aot.d.ts +3 -3
- package/dist/compile/aot.js +5 -5
- package/dist/compile/aot.mjs +6 -5
- package/dist/compile/handler/descriptor.d.ts +2 -5
- package/dist/compile/handler/descriptor.js +12 -17
- package/dist/compile/handler/descriptor.mjs +16 -21
- package/dist/compile/handler/frozen-validator.d.ts +2 -2
- package/dist/compile/handler/frozen-validator.js +3 -3
- package/dist/compile/handler/frozen-validator.mjs +4 -3
- package/dist/compile/handler/index.d.ts +3 -1
- package/dist/compile/handler/index.js +77 -118
- package/dist/compile/handler/index.mjs +83 -125
- package/dist/compile/handler/jit.d.ts +12 -12
- package/dist/compile/handler/jit.js +60 -43
- package/dist/compile/handler/jit.mjs +63 -47
- package/dist/compile/handler/params.d.ts +5 -1
- package/dist/compile/handler/params.js +14 -5
- package/dist/compile/handler/params.mjs +16 -7
- package/dist/compile/handler/reconstruct.d.ts +2 -2
- package/dist/compile/handler/reconstruct.js +2 -2
- package/dist/compile/handler/reconstruct.mjs +3 -2
- package/dist/compile/handler/static-clone-resolver.mjs +1 -0
- package/dist/compile/handler/utils.d.ts +13 -7
- package/dist/compile/handler/utils.js +75 -52
- package/dist/compile/handler/utils.mjs +77 -54
- package/dist/compile/jit-probe.mjs +1 -0
- package/dist/compile/lexer.js +4 -4
- package/dist/compile/lexer.mjs +5 -4
- package/dist/compile/utils.d.ts +2 -1
- package/dist/compile/utils.js +8 -3
- package/dist/compile/utils.mjs +8 -3
- package/dist/compiled.mjs +1 -0
- package/dist/constants.mjs +1 -0
- package/dist/context.d.ts +1 -1
- package/dist/context.js +1 -0
- package/dist/context.mjs +3 -1
- package/dist/cookie/config.d.ts +2 -2
- package/dist/cookie/config.js +21 -26
- package/dist/cookie/config.mjs +22 -26
- package/dist/cookie/cookie.mjs +1 -0
- package/dist/cookie/crypto.mjs +1 -0
- package/dist/cookie/error.mjs +1 -0
- package/dist/cookie/lib.mjs +1 -0
- package/dist/cookie/serialize.mjs +1 -0
- package/dist/cookie/types.mjs +1 -0
- package/dist/cookie/utils.d.ts +1 -1
- package/dist/cookie/utils.js +64 -45
- package/dist/cookie/utils.mjs +66 -46
- package/dist/error.d.ts +10 -6
- package/dist/error.js +22 -6
- package/dist/error.mjs +25 -9
- package/dist/generation.mjs +1 -0
- package/dist/handler/error.d.ts +12 -15
- package/dist/handler/error.js +43 -40
- package/dist/handler/error.mjs +45 -41
- package/dist/handler/fetch.js +59 -21
- package/dist/handler/fetch.mjs +61 -22
- package/dist/handler/utils.d.ts +16 -3
- package/dist/handler/utils.js +14 -13
- package/dist/handler/utils.mjs +16 -15
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -0
- package/dist/index.mjs +3 -2
- package/dist/memory.mjs +1 -0
- package/dist/package.js +1 -1
- package/dist/package.mjs +2 -1
- package/dist/parse-query.js +76 -76
- package/dist/parse-query.mjs +77 -76
- package/dist/plugin/aot/bun.mjs +1 -0
- package/dist/plugin/aot/core.js +7 -4
- package/dist/plugin/aot/core.mjs +8 -5
- package/dist/plugin/aot/esbuild.mjs +1 -0
- package/dist/plugin/aot/rspack-loader.mjs +1 -0
- package/dist/plugin/aot/rspack.mjs +1 -0
- package/dist/plugin/aot/treeshake.mjs +1 -0
- package/dist/plugin/aot/unplugin.mjs +4 -3
- package/dist/plugin/aot/vite.mjs +1 -0
- package/dist/plugin/aot/worker.mjs +1 -0
- package/dist/plugin/auto-head.mjs +1 -0
- package/dist/plugin/trace.mjs +1 -0
- package/dist/plugin/websocket.mjs +1 -0
- package/dist/route-table.mjs +1 -0
- package/dist/schema-snapshot.mjs +1 -0
- package/dist/sucrose.d.ts +2 -2
- package/dist/sucrose.js +11 -11
- package/dist/sucrose.mjs +12 -11
- package/dist/trace.js +8 -10
- package/dist/trace.mjs +10 -11
- package/dist/type/bridge-live.d.ts +1 -1
- package/dist/type/bridge-live.mjs +1 -0
- package/dist/type/bridge.d.ts +1 -1
- package/dist/type/bridge.mjs +1 -0
- package/dist/type/coerce-plan.mjs +1 -0
- package/dist/type/coerce.d.ts +1 -1
- package/dist/type/coerce.mjs +1 -0
- package/dist/type/compat.mjs +1 -0
- 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 +3 -2
- package/dist/type/elysia/array-buffer.js +5 -5
- package/dist/type/elysia/array-buffer.mjs +6 -5
- package/dist/type/elysia/array-string.mjs +1 -0
- package/dist/type/elysia/array.mjs +1 -0
- package/dist/type/elysia/boolean-string.mjs +1 -0
- package/dist/type/elysia/boolean.mjs +1 -0
- package/dist/type/elysia/cookie.mjs +1 -0
- package/dist/type/elysia/date.mjs +1 -0
- package/dist/type/elysia/file-type.mjs +1 -0
- package/dist/type/elysia/file.mjs +1 -0
- package/dist/type/elysia/files.mjs +1 -0
- package/dist/type/elysia/form.mjs +1 -0
- package/dist/type/elysia/integer-string.mjs +1 -0
- package/dist/type/elysia/integer.mjs +1 -0
- package/dist/type/elysia/intersect.mjs +1 -0
- package/dist/type/elysia/json-string.mjs +1 -0
- package/dist/type/elysia/keep-config.js +8 -8
- package/dist/type/elysia/keep-config.mjs +9 -8
- 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.mjs +1 -0
- package/dist/type/elysia/numeric-enum.d.ts +4 -2
- package/dist/type/elysia/numeric-enum.mjs +1 -0
- package/dist/type/elysia/numeric.mjs +1 -0
- package/dist/type/elysia/object-string.mjs +1 -0
- package/dist/type/elysia/object.mjs +1 -0
- package/dist/type/elysia/optional.mjs +1 -0
- package/dist/type/elysia/problem.mjs +1 -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 +2 -2
- package/dist/type/elysia/uint8-array.mjs +3 -2
- package/dist/type/elysia/union-enum.mjs +1 -0
- package/dist/type/elysia/union.mjs +1 -0
- package/dist/type/elysia/utils.js +3 -3
- package/dist/type/elysia/utils.mjs +4 -3
- package/dist/type/exports.mjs +1 -0
- package/dist/type/index.mjs +2 -1
- package/dist/type/shared.mjs +1 -0
- package/dist/type/sync-require.mjs +1 -0
- package/dist/type/typebox-system-lite.mjs +1 -0
- package/dist/type/typebox-system-require.mjs +1 -0
- package/dist/type/typebox-type-live.mjs +1 -0
- package/dist/type/typebox-value-live.mjs +1 -0
- package/dist/type/typebox-value-ops.mjs +1 -0
- package/dist/type/typebox-value.mjs +1 -0
- package/dist/type/types.d.ts +1 -1
- package/dist/type/types.mjs +1 -0
- package/dist/type/utils.mjs +1 -0
- package/dist/type/validator/clean-safe.mjs +1 -0
- package/dist/type/validator/custom-error.js +41 -33
- package/dist/type/validator/custom-error.mjs +42 -33
- package/dist/type/validator/default-precompute.d.ts +2 -2
- package/dist/type/validator/default-precompute.js +10 -11
- package/dist/type/validator/default-precompute.mjs +13 -13
- package/dist/type/validator/exact-mirror.mjs +1 -0
- package/dist/type/validator/frozen-check.js +7 -7
- package/dist/type/validator/frozen-check.mjs +8 -7
- package/dist/type/validator/index.d.ts +2 -2
- package/dist/type/validator/index.js +4 -8
- package/dist/type/validator/index.mjs +5 -8
- package/dist/type/validator/string-codec-aot.d.ts +1 -1
- package/dist/type/validator/string-codec-aot.mjs +1 -0
- package/dist/type/validator/validator-cache.js +18 -18
- package/dist/type/validator/validator-cache.mjs +19 -18
- package/dist/types.d.ts +105 -69
- package/dist/types.mjs +1 -0
- package/dist/universal/constants.mjs +1 -0
- package/dist/universal/file.mjs +1 -0
- package/dist/universal/index.mjs +1 -0
- package/dist/universal/is-production.mjs +1 -0
- package/dist/universal/server.mjs +1 -0
- package/dist/utils.d.ts +49 -31
- package/dist/utils.js +221 -109
- package/dist/utils.mjs +215 -106
- package/dist/validator/index.d.ts +3 -3
- package/dist/validator/index.js +4 -4
- package/dist/validator/index.mjs +5 -4
- package/dist/validator/route.d.ts +2 -2
- package/dist/validator/route.mjs +1 -0
- package/dist/ws/context.js +1 -1
- package/dist/ws/context.mjs +2 -1
- package/dist/ws/index.mjs +1 -0
- package/dist/ws/parser.mjs +1 -0
- package/dist/ws/route.js +34 -25
- package/dist/ws/route.mjs +40 -30
- package/dist/ws/types.d.ts +2 -3
- package/dist/ws/types.mjs +1 -0
- package/package.json +2 -2
package/dist/handler/utils.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { isCloudflareWorker, isFastly } from "../universal/constants.mjs";
|
|
2
|
-
import {
|
|
3
|
+
import { isDisposable, isSingleton } from "../utils.mjs";
|
|
3
4
|
import { env } from "../universal/env.mjs";
|
|
4
5
|
import { HTTPError, PROBLEM_JSON, problemTypeOf } from "../error.mjs";
|
|
5
6
|
import { isAsyncFunction, mayReturnPromise } from "../compile/utils.mjs";
|
|
@@ -37,32 +38,32 @@ function forwardError(value) {
|
|
|
37
38
|
if (value instanceof Error) throw value;
|
|
38
39
|
return value;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Non-Error classes the route's own error hooks register: like any hook, a
|
|
43
|
+
* class registered after the route doesn't reach it
|
|
44
|
+
*/
|
|
45
|
+
function returnedErrorClasses(hook) {
|
|
46
|
+
const error = hook?.error;
|
|
47
|
+
if (!error) return;
|
|
48
|
+
let into;
|
|
43
49
|
const list = Array.isArray(error) ? error : [error];
|
|
44
50
|
for (let i = 0; i < list.length; i++) {
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
51
|
+
const errorClass = list[i]?.["~errorClass"];
|
|
52
|
+
if (errorClass && !into?.includes(errorClass)) (into ??= []).push(errorClass);
|
|
47
53
|
}
|
|
48
54
|
return into;
|
|
49
55
|
}
|
|
50
|
-
function returnedErrorClasses(hook, root) {
|
|
51
|
-
const head = root["~hookChain"];
|
|
52
|
-
let rootClasses = head && chainErrorClasses.get(head);
|
|
53
|
-
if (head && rootClasses === void 0) chainErrorClasses.set(head, rootClasses = collectErrorClasses(flattenChain(head)?.error, void 0) ?? null);
|
|
54
|
-
return collectErrorClasses(hook?.error, rootClasses?.slice());
|
|
55
|
-
}
|
|
56
56
|
const forwardErrorOf = (classes) => (value) => {
|
|
57
57
|
if (value instanceof Error) throw value;
|
|
58
58
|
for (let i = 0; i < classes.length; i++) if (value instanceof classes[i]) throw value;
|
|
59
59
|
return value;
|
|
60
60
|
};
|
|
61
|
-
function finalizeRouteError(app, context, error, sign) {
|
|
61
|
+
function finalizeRouteError(app, context, error, sign, route) {
|
|
62
62
|
const finalize = app["~finalizeError"];
|
|
63
63
|
if (!finalize) throw error;
|
|
64
|
-
return finalize(context, error, sign);
|
|
64
|
+
return finalize(context, error, sign, false, route);
|
|
65
65
|
}
|
|
66
|
+
const finalizeRouteErrorOf = (route) => route?.error?.length || route?.mapResponse?.length ? (app, context, error, sign) => finalizeRouteError(app, context, error, sign, route) : finalizeRouteError;
|
|
66
67
|
function registerDeriveDisposable(context, value, scan = context) {
|
|
67
68
|
if (!isDisposable(value)) return;
|
|
68
69
|
if (isSingleton(value)) return;
|
|
@@ -91,4 +92,4 @@ async function drainDisposables(context) {
|
|
|
91
92
|
const hasAsync = (fns) => fns.some((fn) => isAsyncFunction(fn) || mayReturnPromise(fn));
|
|
92
93
|
|
|
93
94
|
//#endregion
|
|
94
|
-
export { drainDisposables, emptyResponse, finalizeRouteError, forwardError, forwardErrorOf, getNotFound, getNotFoundBody, hasAsync, registerDeriveDisposable, returnedErrorClasses };
|
|
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 { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
|
|
3
|
-
import { TCookieField, TCookieObject } from "./type/elysia/cookie.js";
|
|
4
|
-
import { TFiles } from "./type/elysia/files.js";
|
|
5
1
|
import { StatusMap, StatusMapBack } from "./constants.js";
|
|
6
2
|
import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, NumericStatus, ParseError, Problem, SelectiveProblem, SelectiveStatus, StatusResponse, TaggedHTTPError, ValidationError, ValidationErrorResponse, problem, status, validationDetail } from "./error.js";
|
|
7
|
-
import { bytes, form, prefix, redirect, sse } from "./utils.js";
|
|
3
|
+
import { bytes, form, macroType, prefix, redirect, sse } from "./utils.js";
|
|
8
4
|
import { Server } from "./universal/server.js";
|
|
5
|
+
import { BaseCookie, CookieOptions } from "./cookie/types.js";
|
|
9
6
|
import { Cookie } from "./cookie/cookie.js";
|
|
10
7
|
import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
|
|
11
8
|
import { ElysiaFile, file } from "./universal/file.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
9
|
+
import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
|
|
10
|
+
import { TCookieField, TCookieObject } from "./type/elysia/cookie.js";
|
|
11
|
+
import { TFiles } from "./type/elysia/files.js";
|
|
14
12
|
import { setupTypebox } from "./type/compat.js";
|
|
15
13
|
import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
|
|
14
|
+
import { AotFingerprint, Capture, Compiled, CompilerSession, ProgramId } from "./compile/aot.js";
|
|
16
15
|
import { MultiValidator, StandardValidator, Validator } from "./validator/index.js";
|
|
17
16
|
import { TypeBoxValidator } from "./type/validator/index.js";
|
|
18
17
|
import { TypeSystem, t } from "./type/index.js";
|
|
19
|
-
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";
|
|
20
20
|
import { AnyElysia, Elysia } from "./base.js";
|
|
21
21
|
import { borrow } from "./adapter/response-ownership.js";
|
|
22
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, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
|
|
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, macroType, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ 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.macroType = require_utils.macroType;
|
|
50
51
|
exports.prefix = require_utils.prefix;
|
|
51
52
|
exports.problem = require_error.problem;
|
|
52
53
|
exports.redirect = require_utils.redirect;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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";
|
|
@@ -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, macroType, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
|
package/dist/memory.mjs
CHANGED
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,64 +40,64 @@ 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
102
|
/**
|
|
103
103
|
* @callback parse
|
|
@@ -111,7 +111,7 @@ function parseQuery(input) {
|
|
|
111
111
|
let equalityIndex = -1;
|
|
112
112
|
for (let i = 0; i < inputLength; i++) switch (input.charCodeAt(i)) {
|
|
113
113
|
case 38:
|
|
114
|
-
processKeyValuePair(input, i);
|
|
114
|
+
processKeyValuePair(input, i, result, startingIndex, equalityIndex, flags);
|
|
115
115
|
startingIndex = i;
|
|
116
116
|
equalityIndex = i;
|
|
117
117
|
flags = 0;
|
|
@@ -129,28 +129,28 @@ function parseQuery(input) {
|
|
|
129
129
|
else flags |= KEY_NEEDS_DECODE;
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
132
|
-
if (startingIndex < inputLength) processKeyValuePair(input, inputLength);
|
|
132
|
+
if (startingIndex < inputLength) processKeyValuePair(input, inputLength, result, startingIndex, equalityIndex, flags);
|
|
133
133
|
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];
|
|
134
|
+
}
|
|
135
|
+
function processKeyValuePair(input, endIndex, result, startingIndex, equalityIndex, flags) {
|
|
136
|
+
const hasBothKeyValuePair = equalityIndex > startingIndex;
|
|
137
|
+
const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
|
|
138
|
+
const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
|
|
139
|
+
if (!hasBothKeyValuePair && keySlice.length === 0) return;
|
|
140
|
+
let finalKey = keySlice;
|
|
141
|
+
if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
|
|
142
|
+
if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
|
|
143
|
+
let finalValue = "";
|
|
144
|
+
if (hasBothKeyValuePair) {
|
|
145
|
+
let valueSlice = input.slice(equalityIndex + 1, endIndex);
|
|
146
|
+
if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
|
|
147
|
+
if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
|
|
148
|
+
finalValue = valueSlice;
|
|
153
149
|
}
|
|
150
|
+
const currentValue = result[finalKey];
|
|
151
|
+
if (currentValue === void 0) result[finalKey] = finalValue;
|
|
152
|
+
else if (Array.isArray(currentValue)) currentValue.push(finalValue);
|
|
153
|
+
else result[finalKey] = [currentValue, finalValue];
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
//#endregion
|
package/dist/parse-query.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import decodeComponent from "deuri";
|
|
2
3
|
|
|
3
4
|
//#region src/parse-query.ts
|
|
@@ -19,7 +20,7 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
|
|
|
19
20
|
let equalityIndex = startingIndex;
|
|
20
21
|
for (let i = startIndex + 1; i < inputLength; i++) switch (input.charCodeAt(i)) {
|
|
21
22
|
case 38:
|
|
22
|
-
|
|
23
|
+
processKeyValuePairFromURL(input, i, result, startingIndex, equalityIndex, flags, array, object);
|
|
23
24
|
startingIndex = i;
|
|
24
25
|
equalityIndex = i;
|
|
25
26
|
flags = 0;
|
|
@@ -37,64 +38,64 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
|
|
|
37
38
|
else flags |= KEY_NEEDS_DECODE;
|
|
38
39
|
break;
|
|
39
40
|
}
|
|
40
|
-
if (startingIndex < inputLength)
|
|
41
|
+
if (startingIndex < inputLength) processKeyValuePairFromURL(input, inputLength, result, startingIndex, equalityIndex, flags, array, object);
|
|
41
42
|
return result;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
else finalValue = toBracketArray;
|
|
76
|
-
if (currentValue === void 0) result[finalKey] = finalValue;
|
|
77
|
-
else if (Array.isArray(currentValue)) for (let i = 0; i < finalValue.length; i++) currentValue.push(finalValue[i]);
|
|
78
|
-
else {
|
|
79
|
-
result[finalKey] = finalValue;
|
|
80
|
-
result[finalKey].unshift(currentValue);
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
if (object && object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
|
|
84
|
-
finalValue = JSON.parse(finalValue);
|
|
85
|
-
} catch {}
|
|
86
|
-
else if (currentValue === void 0 && !(object && object?.[finalKey]) && rawValue.indexOf(",") !== -1) finalValue = splitRawParts(rawValue, flags);
|
|
87
|
-
if (currentValue === void 0) result[finalKey] = Array.isArray(finalValue) ? finalValue : [finalValue];
|
|
88
|
-
else if (Array.isArray(currentValue)) currentValue.push(finalValue);
|
|
89
|
-
else result[finalKey] = [currentValue, finalValue];
|
|
43
|
+
}
|
|
44
|
+
function processKeyValuePairFromURL(input, endIndex, result, startingIndex, equalityIndex, flags, array, object) {
|
|
45
|
+
const hasBothKeyValuePair = equalityIndex > startingIndex;
|
|
46
|
+
const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
|
|
47
|
+
const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
|
|
48
|
+
if (!hasBothKeyValuePair && keySlice.length === 0) return;
|
|
49
|
+
let finalKey = keySlice;
|
|
50
|
+
if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
|
|
51
|
+
if (flags & KEY_NEEDS_DECODE) finalKey = decodeComponent(finalKey) || finalKey;
|
|
52
|
+
let finalValue = "";
|
|
53
|
+
if (hasBothKeyValuePair) {
|
|
54
|
+
let valueSlice = input.slice(equalityIndex + 1, endIndex);
|
|
55
|
+
if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
|
|
56
|
+
if (flags & VALUE_NEEDS_DECODE) valueSlice = decodeComponent(valueSlice) || valueSlice;
|
|
57
|
+
finalValue = valueSlice;
|
|
58
|
+
}
|
|
59
|
+
const currentValue = result[finalKey];
|
|
60
|
+
if (array && array?.[finalKey]) {
|
|
61
|
+
let rawValue = hasBothKeyValuePair ? input.slice(equalityIndex + 1, endIndex) : "";
|
|
62
|
+
if (flags & VALUE_HAS_PLUS) rawValue = rawValue.replace(/\+/g, " ");
|
|
63
|
+
const rawBracket = rawValue.charCodeAt(0) === 91 && rawValue.charCodeAt(rawValue.length - 1) === 93;
|
|
64
|
+
const decodedBracket = !rawBracket && finalValue.charCodeAt(0) === 91 && finalValue.charCodeAt(finalValue.length - 1) === 93;
|
|
65
|
+
if (rawBracket || decodedBracket) {
|
|
66
|
+
let toBracketArray;
|
|
67
|
+
if (rawBracket) toBracketArray = rawValue.length === 2 ? [] : splitRawParts(rawValue.slice(1, -1), flags);
|
|
68
|
+
else {
|
|
69
|
+
const inner = finalValue.slice(1, -1);
|
|
70
|
+
toBracketArray = inner === "" ? [] : inner.split(",");
|
|
71
|
+
}
|
|
72
|
+
if (object && object?.[finalKey]) try {
|
|
73
|
+
finalValue = JSON.parse(finalValue);
|
|
74
|
+
} catch {
|
|
75
|
+
finalValue = toBracketArray;
|
|
90
76
|
}
|
|
91
|
-
|
|
92
|
-
result[finalKey] =
|
|
93
|
-
|
|
94
|
-
|
|
77
|
+
else finalValue = toBracketArray;
|
|
78
|
+
if (currentValue === void 0) result[finalKey] = finalValue;
|
|
79
|
+
else if (Array.isArray(currentValue)) for (let i = 0; i < finalValue.length; i++) currentValue.push(finalValue[i]);
|
|
80
|
+
else {
|
|
81
|
+
result[finalKey] = finalValue;
|
|
82
|
+
result[finalKey].unshift(currentValue);
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
if (object && object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
|
|
86
|
+
finalValue = JSON.parse(finalValue);
|
|
87
|
+
} catch {}
|
|
88
|
+
else if (currentValue === void 0 && !(object && object?.[finalKey]) && rawValue.indexOf(",") !== -1) finalValue = splitRawParts(rawValue, flags);
|
|
89
|
+
if (currentValue === void 0) result[finalKey] = Array.isArray(finalValue) ? finalValue : [finalValue];
|
|
90
|
+
else if (Array.isArray(currentValue)) currentValue.push(finalValue);
|
|
91
|
+
else result[finalKey] = [currentValue, finalValue];
|
|
95
92
|
}
|
|
96
|
-
|
|
93
|
+
} else if (object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
|
|
94
|
+
result[finalKey] = JSON.parse(finalValue);
|
|
95
|
+
} catch {
|
|
96
|
+
result[finalKey] = finalValue;
|
|
97
97
|
}
|
|
98
|
+
else result[finalKey] = finalValue;
|
|
98
99
|
}
|
|
99
100
|
/**
|
|
100
101
|
* @callback parse
|
|
@@ -108,7 +109,7 @@ function parseQuery(input) {
|
|
|
108
109
|
let equalityIndex = -1;
|
|
109
110
|
for (let i = 0; i < inputLength; i++) switch (input.charCodeAt(i)) {
|
|
110
111
|
case 38:
|
|
111
|
-
processKeyValuePair(input, i);
|
|
112
|
+
processKeyValuePair(input, i, result, startingIndex, equalityIndex, flags);
|
|
112
113
|
startingIndex = i;
|
|
113
114
|
equalityIndex = i;
|
|
114
115
|
flags = 0;
|
|
@@ -126,28 +127,28 @@ function parseQuery(input) {
|
|
|
126
127
|
else flags |= KEY_NEEDS_DECODE;
|
|
127
128
|
break;
|
|
128
129
|
}
|
|
129
|
-
if (startingIndex < inputLength) processKeyValuePair(input, inputLength);
|
|
130
|
+
if (startingIndex < inputLength) processKeyValuePair(input, inputLength, result, startingIndex, equalityIndex, flags);
|
|
130
131
|
return result;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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];
|
|
132
|
+
}
|
|
133
|
+
function processKeyValuePair(input, endIndex, result, startingIndex, equalityIndex, flags) {
|
|
134
|
+
const hasBothKeyValuePair = equalityIndex > startingIndex;
|
|
135
|
+
const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
|
|
136
|
+
const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
|
|
137
|
+
if (!hasBothKeyValuePair && keySlice.length === 0) return;
|
|
138
|
+
let finalKey = keySlice;
|
|
139
|
+
if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
|
|
140
|
+
if (flags & KEY_NEEDS_DECODE) finalKey = decodeComponent(finalKey) || finalKey;
|
|
141
|
+
let finalValue = "";
|
|
142
|
+
if (hasBothKeyValuePair) {
|
|
143
|
+
let valueSlice = input.slice(equalityIndex + 1, endIndex);
|
|
144
|
+
if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
|
|
145
|
+
if (flags & VALUE_NEEDS_DECODE) valueSlice = decodeComponent(valueSlice) || valueSlice;
|
|
146
|
+
finalValue = valueSlice;
|
|
150
147
|
}
|
|
148
|
+
const currentValue = result[finalKey];
|
|
149
|
+
if (currentValue === void 0) result[finalKey] = finalValue;
|
|
150
|
+
else if (Array.isArray(currentValue)) currentValue.push(finalValue);
|
|
151
|
+
else result[finalKey] = [currentValue, finalValue];
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
//#endregion
|
package/dist/plugin/aot/bun.mjs
CHANGED
package/dist/plugin/aot/core.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
|
3
|
+
const require_compile_handler_params = require('../../compile/handler/params.js');
|
|
3
4
|
const require_compile_handler_frozen_validator = require('../../compile/handler/frozen-validator.js');
|
|
4
5
|
const require_compile_handler_index = require('../../compile/handler/index.js');
|
|
5
6
|
const require_plugin_aot_source = require('./source.js');
|
|
@@ -142,7 +143,7 @@ const STUB_SOURCES = {
|
|
|
142
143
|
source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function compileHandlerJit(){return e()}\nexport function createInlineHandler(){return e()}\nexport function setCaptureHeaderShorthand(){}\n"
|
|
143
144
|
}, {
|
|
144
145
|
filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]descriptor\.(m?js|ts)$/,
|
|
145
|
-
source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function describeRoute(){return e()}\nexport const routeDescriptors=new WeakMap()\n"
|
|
146
|
+
source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function describeRoute(){return e()}\nexport function releaseAnalysisCaches(){}\nexport const routeDescriptors=new WeakMap()\n"
|
|
146
147
|
}],
|
|
147
148
|
ws: [{
|
|
148
149
|
filter: /[\\/]elysia[\\/](dist|src)[\\/]ws[\\/]route\.(m?js|ts)$/,
|
|
@@ -150,7 +151,7 @@ const STUB_SOURCES = {
|
|
|
150
151
|
}],
|
|
151
152
|
reconstruct: [{
|
|
152
153
|
filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]reconstruct\.(m?js|ts)$/,
|
|
153
|
-
source: "const e=()=>{throw new Error(\"[elysia-aot] handler reconstruction was stripped (strip mode) but a route needed it. Rebuild with strip:false.\")}\nexport class
|
|
154
|
+
source: "const e=()=>{throw new Error(\"[elysia-aot] handler reconstruction was stripped (strip mode) but a route needed it. Rebuild with strip:false.\")}\nexport class Reconstruct {\n static validator(){return e()}\n static cookie(){return e()}\n static trace(){return e()}\n}\n"
|
|
154
155
|
}],
|
|
155
156
|
cookie: [
|
|
156
157
|
{
|
|
@@ -491,7 +492,7 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
|
|
|
491
492
|
const artifacts = await require_plugin_aot_source.captureArtifacts(typedApp, sourceOptions);
|
|
492
493
|
const report = require_plugin_aot_source.replayStubbability(typedApp, artifacts.handlers);
|
|
493
494
|
const aliases = /* @__PURE__ */ new Set();
|
|
494
|
-
for (const handler of artifacts.handlers) if (handler.alias) for (const name of handler.alias.split(",")) aliases.add(name);
|
|
495
|
+
for (const handler of artifacts.handlers) if (handler.alias) for (const name of handler.alias.split(",")) aliases.add(require_compile_handler_params.isResponseParam(name) ? "va" : name);
|
|
495
496
|
const history = typedApp["~routes"];
|
|
496
497
|
const hasWS = !!typedApp["~hasWS"] || history.some((route) => route[0] === "WS");
|
|
497
498
|
const mayTrace = !!typedApp["~hasTrace"] || history.some((route) => (route?.[4])?.trace?.length || route?.[2]?.["~mount"]);
|
|
@@ -517,6 +518,7 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
|
|
|
517
518
|
};
|
|
518
519
|
const [, , , instance, hook, appHook, inheritedChain, macroScope] = route;
|
|
519
520
|
const hooks = require_compile_handler_index.composeRouteHook(instance, hook, appHook, inheritedChain, typedApp, macroScope);
|
|
521
|
+
require_compile_handler_index.runIntrospect(hooks);
|
|
520
522
|
if (method === "WS" && (hook?.cookie !== void 0 || hooks?.cookie !== void 0)) wsCookie = true;
|
|
521
523
|
if (!hooks) continue;
|
|
522
524
|
let routeHasTypeBoxDirectSlot = false;
|
|
@@ -545,7 +547,8 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
|
|
|
545
547
|
}
|
|
546
548
|
if (typedApp["~config"]?.normalize === "typebox") routesForbidSeal = true;
|
|
547
549
|
const validatorSlotsMatch = validatorSlotSetsMatch(expectedSlots, artifacts.validators);
|
|
548
|
-
const
|
|
550
|
+
const hasReplayableCapture = artifacts.handlers.some((h) => h.code) || artifacts.validators.length > 0;
|
|
551
|
+
const { plan: stub, mode } = planFromReport(strip, report, hasWS, mayTrace, aliases, hasReplayableCapture && !routesForbidSeal && validatorSlotsMatch && artifacts.validators.every((v) => v.bridgeFree === true), !hasReplayableCapture, adapterStub, productionStub, wsCookie, exactMirror);
|
|
549
552
|
if (options?.target === "workerd") {
|
|
550
553
|
if (!report.jit) throw new Error(`[elysia-aot] target 'workerd' but handler JIT is still reachable (${report.reasons.join(", ") || "unknown"}). Every route must be captured into the AOT manifest.`);
|
|
551
554
|
if (!validatorSlotsMatch) console.warn("[elysia-aot] target 'workerd': captured validator slots do not exactly match declared slots; unfrozen slots compile at runtime and will fail on workerd.");
|