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
|
@@ -70,7 +70,7 @@ function validateMergeSource(schema, source) {
|
|
|
70
70
|
} catch {
|
|
71
71
|
return false;
|
|
72
72
|
}
|
|
73
|
-
if (require_type_validator_default_precompute.
|
|
73
|
+
if (require_type_validator_default_precompute.stableStringify(expected) !== require_type_validator_default_precompute.stableStringify(actual)) return false;
|
|
74
74
|
}
|
|
75
75
|
return true;
|
|
76
76
|
}
|
|
@@ -99,7 +99,7 @@ function validateObjectDefault(schema, pod) {
|
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
101
|
const actual = require_type_validator_default_precompute.applyPrecomputed(pod, structuredClone(probe));
|
|
102
|
-
if (require_type_validator_default_precompute.
|
|
102
|
+
if (require_type_validator_default_precompute.stableStringify(expected) !== require_type_validator_default_precompute.stableStringify(actual)) return false;
|
|
103
103
|
}
|
|
104
104
|
return true;
|
|
105
105
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { nullObject } from "../utils.mjs";
|
|
2
3
|
import { env } from "../universal/env.mjs";
|
|
3
4
|
import { Capture, CompilerState, aotActivationError, captureImpl, setCaptureImpl } from "./aot.mjs";
|
|
4
5
|
import { isCapturedBridgeFree, isCompactWalkable } from "./handler/frozen-validator.mjs";
|
|
5
6
|
import { buildCoercedFromPlan, captureCoercePlan } from "../type/coerce.mjs";
|
|
6
7
|
import { isAsyncPredicate } from "../type/elysia/file-type.mjs";
|
|
7
|
-
import { applyPrecomputed, buildDefaultClonerSource, buildObjectDefaultMergeSource,
|
|
8
|
+
import { applyPrecomputed, buildDefaultClonerSource, buildObjectDefaultMergeSource, createMergerFromSource, setDefaultProbeImpl, stableStringify, verifyPreallocatableDefault } from "../type/validator/default-precompute.mjs";
|
|
8
9
|
import { collectExternals } from "./aot-reconstruct.mjs";
|
|
9
10
|
import { captureMirrorCodecs, captureMirrorUnions, installReconstructImpl } from "./aot-emit.mjs";
|
|
10
11
|
import { buildFrozenCheck } from "../type/validator/frozen-check.mjs";
|
|
@@ -68,7 +69,7 @@ function validateMergeSource(schema, source) {
|
|
|
68
69
|
} catch {
|
|
69
70
|
return false;
|
|
70
71
|
}
|
|
71
|
-
if (
|
|
72
|
+
if (stableStringify(expected) !== stableStringify(actual)) return false;
|
|
72
73
|
}
|
|
73
74
|
return true;
|
|
74
75
|
}
|
|
@@ -97,7 +98,7 @@ function validateObjectDefault(schema, pod) {
|
|
|
97
98
|
return false;
|
|
98
99
|
}
|
|
99
100
|
const actual = applyPrecomputed(pod, structuredClone(probe));
|
|
100
|
-
if (
|
|
101
|
+
if (stableStringify(expected) !== stableStringify(actual)) return false;
|
|
101
102
|
}
|
|
102
103
|
return true;
|
|
103
104
|
}
|
package/dist/compile/aot-emit.js
CHANGED
|
@@ -54,29 +54,28 @@ function externalsMatch(a, b) {
|
|
|
54
54
|
*/
|
|
55
55
|
function alignBuildExternals(build, schema) {
|
|
56
56
|
const variables = build.external.variables;
|
|
57
|
-
const
|
|
57
|
+
const expected = require_compile_aot_reconstruct.collectExternals(schema);
|
|
58
58
|
const id = build.external.identifier;
|
|
59
59
|
if (!/^[A-Za-z_$][\w$]*$/.test(id)) return;
|
|
60
60
|
const slots = [];
|
|
61
61
|
let j = 0;
|
|
62
|
-
let same = variables.length ===
|
|
63
|
-
for (
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
if (j < canonical.length && externalsMatch([c], [v])) slots.push(`${id}[${j++}]`);
|
|
62
|
+
let same = variables.length === expected.length;
|
|
63
|
+
for (const v of variables) {
|
|
64
|
+
const c = expected[j];
|
|
65
|
+
if (j < expected.length && externalsMatch([c], [v])) slots.push(`${id}[${j++}]`);
|
|
67
66
|
else if (Array.isArray(c) && c.length === 1 && c[0] === v) {
|
|
68
67
|
slots.push(`${id}[${j++}][0]`);
|
|
69
68
|
same = false;
|
|
70
69
|
} else return;
|
|
71
70
|
}
|
|
72
|
-
if (j !==
|
|
71
|
+
if (j !== expected.length) return;
|
|
73
72
|
if (same) return build;
|
|
74
73
|
return {
|
|
75
74
|
...build,
|
|
76
75
|
functions: [`${id}=[${slots.join(",")}]`, ...build.functions],
|
|
77
76
|
external: {
|
|
78
77
|
identifier: id,
|
|
79
|
-
variables:
|
|
78
|
+
variables: expected
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
81
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { Compiled } from "./aot.mjs";
|
|
2
3
|
import { Reconstruct, collectExternals, collectMirrorCodecs, collectMirrorUnions } from "./aot-reconstruct.mjs";
|
|
3
4
|
|
|
@@ -53,29 +54,28 @@ function externalsMatch(a, b) {
|
|
|
53
54
|
*/
|
|
54
55
|
function alignBuildExternals(build, schema) {
|
|
55
56
|
const variables = build.external.variables;
|
|
56
|
-
const
|
|
57
|
+
const expected = collectExternals(schema);
|
|
57
58
|
const id = build.external.identifier;
|
|
58
59
|
if (!/^[A-Za-z_$][\w$]*$/.test(id)) return;
|
|
59
60
|
const slots = [];
|
|
60
61
|
let j = 0;
|
|
61
|
-
let same = variables.length ===
|
|
62
|
-
for (
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
if (j < canonical.length && externalsMatch([c], [v])) slots.push(`${id}[${j++}]`);
|
|
62
|
+
let same = variables.length === expected.length;
|
|
63
|
+
for (const v of variables) {
|
|
64
|
+
const c = expected[j];
|
|
65
|
+
if (j < expected.length && externalsMatch([c], [v])) slots.push(`${id}[${j++}]`);
|
|
66
66
|
else if (Array.isArray(c) && c.length === 1 && c[0] === v) {
|
|
67
67
|
slots.push(`${id}[${j++}][0]`);
|
|
68
68
|
same = false;
|
|
69
69
|
} else return;
|
|
70
70
|
}
|
|
71
|
-
if (j !==
|
|
71
|
+
if (j !== expected.length) return;
|
|
72
72
|
if (same) return build;
|
|
73
73
|
return {
|
|
74
74
|
...build,
|
|
75
75
|
functions: [`${id}=[${slots.join(",")}]`, ...build.functions],
|
|
76
76
|
external: {
|
|
77
77
|
identifier: id,
|
|
78
|
-
variables:
|
|
78
|
+
variables: expected
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { ELYSIA_TYPES } from "../type/constants.mjs";
|
|
2
3
|
import { EMPTY_EXTERNALS } from "./aot.mjs";
|
|
3
4
|
|
|
@@ -18,8 +19,8 @@ import { EMPTY_EXTERNALS } from "./aot.mjs";
|
|
|
18
19
|
const isValueLikeExternal = (v) => v === null || typeof v !== "object" && typeof v !== "function";
|
|
19
20
|
/**
|
|
20
21
|
* Rebuild TypeBox `External[]` for `schema` in `BuildSchema` traversal order:
|
|
21
|
-
* object (patternProperties
|
|
22
|
-
* guard
|
|
22
|
+
* object (patternProperties \u2192 properties) \u2192 array (items) \u2192 string (pattern) \u2192
|
|
23
|
+
* guard \u2192 const \u2192 enum \u2192 not/allOf/anyOf/oneOf \u2192 refine LAST.
|
|
23
24
|
*/
|
|
24
25
|
function collectExternals(schema, out = []) {
|
|
25
26
|
if (!schema || typeof schema !== "object") return out;
|
package/dist/compile/aot.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CoerceNode } from "../type/coerce-plan.js";
|
|
2
2
|
//#region src/compile/aot.d.ts
|
|
3
|
-
declare const AOT_MANIFEST_FORMAT =
|
|
3
|
+
declare const AOT_MANIFEST_FORMAT = 7;
|
|
4
4
|
interface AotFingerprint {
|
|
5
5
|
abi: string;
|
|
6
6
|
}
|
|
@@ -126,7 +126,7 @@ interface ReconstructImpl {
|
|
|
126
126
|
reconstructInnerCodecs(ic: NonNullable<FrozenValidator['ic']>, schema: any): void;
|
|
127
127
|
}
|
|
128
128
|
declare function reconstruct(): ReconstructImpl;
|
|
129
|
-
declare const
|
|
129
|
+
declare const aotDriftMessage: (method: string, path: string) => string;
|
|
130
130
|
declare function warnAotDrift(method: string, path: string): void;
|
|
131
131
|
declare abstract class Compiled {
|
|
132
132
|
static register(manifest: CompiledProgramRegistration): void;
|
|
@@ -282,4 +282,4 @@ interface CaptureImpl {
|
|
|
282
282
|
declare let captureImpl: CaptureImpl | undefined;
|
|
283
283
|
declare function setCaptureImpl(impl: CaptureImpl | undefined): void;
|
|
284
284
|
//#endregion
|
|
285
|
-
export { AOT_MANIFEST_FORMAT, AotFingerprint, Capture, CaptureImpl, CapturedHandler, CapturedMirror, CapturedValidator, CheckBuildResult, Compiled, CompiledProgramRegistration, CompiledSnapshot, CompilerSession, CompilerState, EMPTY_EXTERNALS, FrozenBothFactory, FrozenCheckFactory, FrozenHandler, FrozenMirror, FrozenMirrorFactory, FrozenValidator, HandlerManifest, ProgramId, ReconstructImpl, StringCodecNode, ValidatorManifest, ValidatorSlot, aotActivationError,
|
|
285
|
+
export { AOT_MANIFEST_FORMAT, AotFingerprint, Capture, CaptureImpl, CapturedHandler, CapturedMirror, CapturedValidator, CheckBuildResult, Compiled, CompiledProgramRegistration, CompiledSnapshot, CompilerSession, CompilerState, EMPTY_EXTERNALS, FrozenBothFactory, FrozenCheckFactory, FrozenHandler, FrozenMirror, FrozenMirrorFactory, FrozenValidator, HandlerManifest, ProgramId, ReconstructImpl, StringCodecNode, ValidatorManifest, ValidatorSlot, aotActivationError, aotDriftMessage, beginCompilerSession, captureImpl, createAotFingerprint, endCompilerSession, getCompilerSession, reconstruct, setCaptureImpl, warnAotDrift };
|
package/dist/compile/aot.js
CHANGED
|
@@ -4,8 +4,8 @@ const require_universal_env = require('../universal/env.js');
|
|
|
4
4
|
const require_package = require('../package.js');
|
|
5
5
|
|
|
6
6
|
//#region src/compile/aot.ts
|
|
7
|
-
const AOT_MANIFEST_FORMAT =
|
|
8
|
-
const AOT_ABI = `${require_package.version}:${
|
|
7
|
+
const AOT_MANIFEST_FORMAT = 7;
|
|
8
|
+
const AOT_ABI = `${require_package.version}:${7}`;
|
|
9
9
|
const sharedAotFingerprint = Object.freeze({ abi: AOT_ABI });
|
|
10
10
|
const createAotFingerprint = () => sharedAotFingerprint;
|
|
11
11
|
let activeSession;
|
|
@@ -38,13 +38,13 @@ function reconstruct() {
|
|
|
38
38
|
return reconstructImpl;
|
|
39
39
|
}
|
|
40
40
|
let drifted;
|
|
41
|
-
const
|
|
41
|
+
const aotDriftMessage = (method, path) => `[elysia-aot] ${method} ${path} differs from the AOT build`;
|
|
42
42
|
function warnAotDrift(method, path) {
|
|
43
43
|
const key = method + " " + path;
|
|
44
44
|
if (drifted?.has(key)) return;
|
|
45
45
|
drifted ??= /* @__PURE__ */ new Set();
|
|
46
46
|
drifted.add(key);
|
|
47
|
-
console.warn(
|
|
47
|
+
console.warn(aotDriftMessage(method, path) + ", compiled at runtime");
|
|
48
48
|
}
|
|
49
49
|
let registered;
|
|
50
50
|
let claimed;
|
|
@@ -194,7 +194,7 @@ exports.Compiled = Compiled;
|
|
|
194
194
|
exports.CompilerState = CompilerState;
|
|
195
195
|
exports.EMPTY_EXTERNALS = EMPTY_EXTERNALS;
|
|
196
196
|
exports.aotActivationError = aotActivationError;
|
|
197
|
-
exports.
|
|
197
|
+
exports.aotDriftMessage = aotDriftMessage;
|
|
198
198
|
exports.beginCompilerSession = beginCompilerSession;
|
|
199
199
|
Object.defineProperty(exports, 'captureImpl', {
|
|
200
200
|
enumerable: true,
|
package/dist/compile/aot.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { nullObject } from "../utils.mjs";
|
|
2
3
|
import { env } from "../universal/env.mjs";
|
|
3
4
|
import { version } from "../package.mjs";
|
|
4
5
|
|
|
5
6
|
//#region src/compile/aot.ts
|
|
6
|
-
const AOT_MANIFEST_FORMAT =
|
|
7
|
-
const AOT_ABI = `${version}:${
|
|
7
|
+
const AOT_MANIFEST_FORMAT = 7;
|
|
8
|
+
const AOT_ABI = `${version}:${7}`;
|
|
8
9
|
const sharedAotFingerprint = Object.freeze({ abi: AOT_ABI });
|
|
9
10
|
const createAotFingerprint = () => sharedAotFingerprint;
|
|
10
11
|
let activeSession;
|
|
@@ -37,13 +38,13 @@ function reconstruct() {
|
|
|
37
38
|
return reconstructImpl;
|
|
38
39
|
}
|
|
39
40
|
let drifted;
|
|
40
|
-
const
|
|
41
|
+
const aotDriftMessage = (method, path) => `[elysia-aot] ${method} ${path} differs from the AOT build`;
|
|
41
42
|
function warnAotDrift(method, path) {
|
|
42
43
|
const key = method + " " + path;
|
|
43
44
|
if (drifted?.has(key)) return;
|
|
44
45
|
drifted ??= /* @__PURE__ */ new Set();
|
|
45
46
|
drifted.add(key);
|
|
46
|
-
console.warn(
|
|
47
|
+
console.warn(aotDriftMessage(method, path) + ", compiled at runtime");
|
|
47
48
|
}
|
|
48
49
|
let registered;
|
|
49
50
|
let claimed;
|
|
@@ -187,4 +188,4 @@ function setCaptureImpl(impl) {
|
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
//#endregion
|
|
190
|
-
export { AOT_MANIFEST_FORMAT, Capture, Compiled, CompilerState, EMPTY_EXTERNALS, aotActivationError,
|
|
191
|
+
export { AOT_MANIFEST_FORMAT, Capture, Compiled, CompilerState, EMPTY_EXTERNALS, aotActivationError, aotDriftMessage, beginCompilerSession, captureImpl, createAotFingerprint, endCompilerSession, getCompilerSession, reconstruct, setCaptureImpl, warnAotDrift };
|
|
@@ -64,11 +64,8 @@ interface DescribeRouteInput {
|
|
|
64
64
|
isStaticResponse: boolean;
|
|
65
65
|
isPromiseHandler: boolean;
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Route descriptors, keyed by root instance → `METHOD path` → descriptor
|
|
69
|
-
* Populated on each JIT compile, and read only by tests and introspection
|
|
70
|
-
*/
|
|
71
67
|
declare const routeDescriptors: WeakMap<AnyElysia, Map<string, RouteDescriptor>>;
|
|
68
|
+
declare function releaseAnalysisCaches(): void;
|
|
72
69
|
declare function describeRoute(input: DescribeRouteInput): RouteCompileState;
|
|
73
70
|
//#endregion
|
|
74
|
-
export { DescribeRouteInput, RouteCompileState, RouteDescriptor, describeRoute, routeDescriptors };
|
|
71
|
+
export { DescribeRouteInput, RouteCompileState, RouteDescriptor, describeRoute, releaseAnalysisCaches, routeDescriptors };
|
|
@@ -9,11 +9,11 @@ const require_sucrose = require('../../sucrose.js');
|
|
|
9
9
|
const require_compile_handler_reconstruct = require('./reconstruct.js');
|
|
10
10
|
|
|
11
11
|
//#region src/compile/handler/descriptor.ts
|
|
12
|
-
/**
|
|
13
|
-
* Route descriptors, keyed by root instance → `METHOD path` → descriptor
|
|
14
|
-
* Populated on each JIT compile, and read only by tests and introspection
|
|
15
|
-
*/
|
|
16
12
|
const routeDescriptors = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function releaseAnalysisCaches() {
|
|
14
|
+
require_sucrose.clearSucroseCache();
|
|
15
|
+
require_compile_utils.resetMayReturnPromiseCache();
|
|
16
|
+
}
|
|
17
17
|
const noTracePhases = /* @__PURE__ */ new Set();
|
|
18
18
|
const lifecycleMayReturnPromise = (handlers) => handlers ? Array.isArray(handlers) ? handlers.some(require_compile_utils.mayReturnPromise) : require_compile_utils.mayReturnPromise(handlers) : false;
|
|
19
19
|
const compactPrefixInference = /* @__PURE__ */ new WeakMap();
|
|
@@ -81,9 +81,9 @@ function describeRoute(input) {
|
|
|
81
81
|
const headersValiIsAsync = vali?.headers && isAsyncValidator(vali.headers);
|
|
82
82
|
const paramsValiIsAsync = vali?.params && isAsyncValidator(vali.params);
|
|
83
83
|
const queryValiIsAsync = vali?.query && isAsyncValidator(vali.query);
|
|
84
|
-
const
|
|
84
|
+
const cookieValiIsAsync = vali?.cookie && isAsyncValidator(vali.cookie);
|
|
85
85
|
const needsCookie = !!vali?.cookie || !!inference.cookie;
|
|
86
|
-
const cookieConfig = needsCookie ? require_compile_handler_reconstruct.
|
|
86
|
+
const cookieConfig = needsCookie ? require_compile_handler_reconstruct.Reconstruct.cookie(hook, root) : void 0;
|
|
87
87
|
const hasCookieSign = !!cookieConfig?.hasSign;
|
|
88
88
|
const syncCookieSign = hasCookieSign && require_cookie_crypto.hasSyncHmac && !require_compile_aot.Capture.isCapturing();
|
|
89
89
|
const asyncCookieSign = hasCookieSign && !syncCookieSign;
|
|
@@ -105,22 +105,16 @@ function describeRoute(input) {
|
|
|
105
105
|
const phaseOn = (phase) => hasTrace && (tracePhases === null || tracePhases.has(phase));
|
|
106
106
|
const hasAnyPhase = hasTrace && (tracePhases === null || tracePhases.size > 0);
|
|
107
107
|
const traceHandleOn = phaseOn("handle");
|
|
108
|
-
|
|
109
|
-
if (vali?.response) {
|
|
110
|
-
for (const code in vali.response) if (isAsyncValidator(vali.response[code])) {
|
|
111
|
-
responseValiAsync = true;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
108
|
+
const responseValiAsync = !!vali?.response && [...vali.response.values()].some(isAsyncValidator);
|
|
115
109
|
const handlerIsAsync = isHandleFunction && require_compile_utils.isAsyncFunction(handler);
|
|
116
110
|
const errorHookForcesAsync = hasErrorHook && (hasAfterHandle || hasMapResponse || hasResponseValidator || require_compile_utils.isAsyncLifecycle(hook?.error) || lifecycleMayReturnPromise(hook?.error));
|
|
117
111
|
const afterResponseForcesAsync = hasStaticAfterResponse && require_compile_utils.isAsyncLifecycle(hook?.afterResponse) || hasAfterResponse && (hasAfterHandle || hasMapResponse || hasResponseValidator || hasErrorHook);
|
|
118
112
|
const traceForcesAsync = (traceHandleOn || phaseOn("error") || phaseOn("afterResponse")) && isHandleFunction && !handlerIsAsync && require_compile_utils.mayReturnPromise(handler);
|
|
119
113
|
const handlerResultObserved = isHandleFunction && !handlerIsAsync && (hasResponseValidator || hasAfterHandle || hasMapResponse) && require_compile_utils.mayReturnPromise(handler);
|
|
120
114
|
const lifecycleForcesAsync = !!hook && ((beforeHandlePrefix ? compactPrefixForcesAsync(beforeHandlePrefix) : false) || lifecycleMayReturnPromise(hook.beforeHandle) || lifecycleMayReturnPromise(hook.transform) || lifecycleMayReturnPromise(hook.afterHandle) || lifecycleMayReturnPromise(hook.mapResponse));
|
|
121
|
-
const isAsync = hasBody || handlerIsAsync || errorHookForcesAsync || traceForcesAsync || afterResponseForcesAsync || handlerResultObserved || lifecycleForcesAsync || asyncCookieSign || responseValiAsync || headersValiIsAsync || paramsValiIsAsync || queryValiIsAsync ||
|
|
115
|
+
const isAsync = hasBody || handlerIsAsync || errorHookForcesAsync || traceForcesAsync || afterResponseForcesAsync || handlerResultObserved || lifecycleForcesAsync || asyncCookieSign || responseValiAsync || headersValiIsAsync || paramsValiIsAsync || queryValiIsAsync || cookieValiIsAsync;
|
|
122
116
|
const callHandlerSyncOnAsync = isAsync && isHandleFunction && !handlerIsAsync;
|
|
123
|
-
const tail = isAsync && !(hasErrorHook && hasMapResponse) && !hasBody && !handlerIsAsync && !asyncCookieSign && !responseValiAsync && !hasTrace && !beforeHandlePrefix?.length && !bodyValiIsAsync && !headersValiIsAsync && !paramsValiIsAsync && !queryValiIsAsync && !
|
|
117
|
+
const tail = isAsync && !(hasErrorHook && hasMapResponse) && !hasBody && !handlerIsAsync && !asyncCookieSign && !responseValiAsync && !hasTrace && !beforeHandlePrefix?.length && !bodyValiIsAsync && !headersValiIsAsync && !paramsValiIsAsync && !queryValiIsAsync && !cookieValiIsAsync && !(hook && (require_compile_utils.isAsyncLifecycle(hook.afterHandle) || require_compile_utils.isAsyncLifecycle(hook.beforeHandle) || require_compile_utils.isAsyncLifecycle(hook.transform) || require_compile_utils.isAsyncLifecycle(hook.mapResponse) || require_compile_utils.isAsyncLifecycle(hook.error)));
|
|
124
118
|
const syncErrorHook = hasErrorHook && !isAsync && !hasTrace;
|
|
125
119
|
const syncAfterResponse = hasAfterResponse && !isAsync && !hasTrace && !hasErrorHook;
|
|
126
120
|
const handlerKind = isHandleFunction ? "function" : isStaticResponse ? "response" : isPromiseHandler ? "promise" : "static-value";
|
|
@@ -131,7 +125,7 @@ function describeRoute(input) {
|
|
|
131
125
|
descriptor: {
|
|
132
126
|
handlerKind,
|
|
133
127
|
async: !!isAsync,
|
|
134
|
-
tail,
|
|
128
|
+
tail: !!tail,
|
|
135
129
|
responseMode,
|
|
136
130
|
hasBeforeHandle,
|
|
137
131
|
hasAfterHandle,
|
|
@@ -147,7 +141,7 @@ function describeRoute(input) {
|
|
|
147
141
|
headersValiIsAsync: !!headersValiIsAsync,
|
|
148
142
|
paramsValiIsAsync: !!paramsValiIsAsync,
|
|
149
143
|
queryValiIsAsync: !!queryValiIsAsync,
|
|
150
|
-
cookieValiIsAsync: !!
|
|
144
|
+
cookieValiIsAsync: !!cookieValiIsAsync,
|
|
151
145
|
responseValiAsync,
|
|
152
146
|
hasCookieSign,
|
|
153
147
|
syncCookieSign,
|
|
@@ -171,4 +165,5 @@ function describeRoute(input) {
|
|
|
171
165
|
|
|
172
166
|
//#endregion
|
|
173
167
|
exports.describeRoute = describeRoute;
|
|
168
|
+
exports.releaseAnalysisCaches = releaseAnalysisCaches;
|
|
174
169
|
exports.routeDescriptors = routeDescriptors;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { isNotEmpty } from "../../utils.mjs";
|
|
2
3
|
import { hasSyncHmac } from "../../cookie/crypto.mjs";
|
|
3
4
|
import { Capture } from "../aot.mjs";
|
|
4
5
|
import { frozenRootOf, resolvedTraceOf, traceCapabilityRequired } from "../../generation.mjs";
|
|
5
|
-
import { isAsyncFunction, isAsyncLifecycle, mayReturnPromise } from "../utils.mjs";
|
|
6
|
+
import { isAsyncFunction, isAsyncLifecycle, mayReturnPromise, resetMayReturnPromiseCache } from "../utils.mjs";
|
|
6
7
|
import { JITProbe } from "../jit-probe.mjs";
|
|
7
|
-
import { mergeInference, sucrose } from "../../sucrose.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { clearSucroseCache, mergeInference, sucrose } from "../../sucrose.mjs";
|
|
9
|
+
import { Reconstruct } from "./reconstruct.mjs";
|
|
9
10
|
|
|
10
11
|
//#region src/compile/handler/descriptor.ts
|
|
11
|
-
/**
|
|
12
|
-
* Route descriptors, keyed by root instance → `METHOD path` → descriptor
|
|
13
|
-
* Populated on each JIT compile, and read only by tests and introspection
|
|
14
|
-
*/
|
|
15
12
|
const routeDescriptors = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function releaseAnalysisCaches() {
|
|
14
|
+
clearSucroseCache();
|
|
15
|
+
resetMayReturnPromiseCache();
|
|
16
|
+
}
|
|
16
17
|
const noTracePhases = /* @__PURE__ */ new Set();
|
|
17
18
|
const lifecycleMayReturnPromise = (handlers) => handlers ? Array.isArray(handlers) ? handlers.some(mayReturnPromise) : mayReturnPromise(handlers) : false;
|
|
18
19
|
const compactPrefixInference = /* @__PURE__ */ new WeakMap();
|
|
@@ -80,9 +81,9 @@ function describeRoute(input) {
|
|
|
80
81
|
const headersValiIsAsync = vali?.headers && isAsyncValidator(vali.headers);
|
|
81
82
|
const paramsValiIsAsync = vali?.params && isAsyncValidator(vali.params);
|
|
82
83
|
const queryValiIsAsync = vali?.query && isAsyncValidator(vali.query);
|
|
83
|
-
const
|
|
84
|
+
const cookieValiIsAsync = vali?.cookie && isAsyncValidator(vali.cookie);
|
|
84
85
|
const needsCookie = !!vali?.cookie || !!inference.cookie;
|
|
85
|
-
const cookieConfig = needsCookie ?
|
|
86
|
+
const cookieConfig = needsCookie ? Reconstruct.cookie(hook, root) : void 0;
|
|
86
87
|
const hasCookieSign = !!cookieConfig?.hasSign;
|
|
87
88
|
const syncCookieSign = hasCookieSign && hasSyncHmac && !Capture.isCapturing();
|
|
88
89
|
const asyncCookieSign = hasCookieSign && !syncCookieSign;
|
|
@@ -104,22 +105,16 @@ function describeRoute(input) {
|
|
|
104
105
|
const phaseOn = (phase) => hasTrace && (tracePhases === null || tracePhases.has(phase));
|
|
105
106
|
const hasAnyPhase = hasTrace && (tracePhases === null || tracePhases.size > 0);
|
|
106
107
|
const traceHandleOn = phaseOn("handle");
|
|
107
|
-
|
|
108
|
-
if (vali?.response) {
|
|
109
|
-
for (const code in vali.response) if (isAsyncValidator(vali.response[code])) {
|
|
110
|
-
responseValiAsync = true;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
108
|
+
const responseValiAsync = !!vali?.response && [...vali.response.values()].some(isAsyncValidator);
|
|
114
109
|
const handlerIsAsync = isHandleFunction && isAsyncFunction(handler);
|
|
115
110
|
const errorHookForcesAsync = hasErrorHook && (hasAfterHandle || hasMapResponse || hasResponseValidator || isAsyncLifecycle(hook?.error) || lifecycleMayReturnPromise(hook?.error));
|
|
116
111
|
const afterResponseForcesAsync = hasStaticAfterResponse && isAsyncLifecycle(hook?.afterResponse) || hasAfterResponse && (hasAfterHandle || hasMapResponse || hasResponseValidator || hasErrorHook);
|
|
117
112
|
const traceForcesAsync = (traceHandleOn || phaseOn("error") || phaseOn("afterResponse")) && isHandleFunction && !handlerIsAsync && mayReturnPromise(handler);
|
|
118
113
|
const handlerResultObserved = isHandleFunction && !handlerIsAsync && (hasResponseValidator || hasAfterHandle || hasMapResponse) && mayReturnPromise(handler);
|
|
119
114
|
const lifecycleForcesAsync = !!hook && ((beforeHandlePrefix ? compactPrefixForcesAsync(beforeHandlePrefix) : false) || lifecycleMayReturnPromise(hook.beforeHandle) || lifecycleMayReturnPromise(hook.transform) || lifecycleMayReturnPromise(hook.afterHandle) || lifecycleMayReturnPromise(hook.mapResponse));
|
|
120
|
-
const isAsync = hasBody || handlerIsAsync || errorHookForcesAsync || traceForcesAsync || afterResponseForcesAsync || handlerResultObserved || lifecycleForcesAsync || asyncCookieSign || responseValiAsync || headersValiIsAsync || paramsValiIsAsync || queryValiIsAsync ||
|
|
115
|
+
const isAsync = hasBody || handlerIsAsync || errorHookForcesAsync || traceForcesAsync || afterResponseForcesAsync || handlerResultObserved || lifecycleForcesAsync || asyncCookieSign || responseValiAsync || headersValiIsAsync || paramsValiIsAsync || queryValiIsAsync || cookieValiIsAsync;
|
|
121
116
|
const callHandlerSyncOnAsync = isAsync && isHandleFunction && !handlerIsAsync;
|
|
122
|
-
const tail = isAsync && !(hasErrorHook && hasMapResponse) && !hasBody && !handlerIsAsync && !asyncCookieSign && !responseValiAsync && !hasTrace && !beforeHandlePrefix?.length && !bodyValiIsAsync && !headersValiIsAsync && !paramsValiIsAsync && !queryValiIsAsync && !
|
|
117
|
+
const tail = isAsync && !(hasErrorHook && hasMapResponse) && !hasBody && !handlerIsAsync && !asyncCookieSign && !responseValiAsync && !hasTrace && !beforeHandlePrefix?.length && !bodyValiIsAsync && !headersValiIsAsync && !paramsValiIsAsync && !queryValiIsAsync && !cookieValiIsAsync && !(hook && (isAsyncLifecycle(hook.afterHandle) || isAsyncLifecycle(hook.beforeHandle) || isAsyncLifecycle(hook.transform) || isAsyncLifecycle(hook.mapResponse) || isAsyncLifecycle(hook.error)));
|
|
123
118
|
const syncErrorHook = hasErrorHook && !isAsync && !hasTrace;
|
|
124
119
|
const syncAfterResponse = hasAfterResponse && !isAsync && !hasTrace && !hasErrorHook;
|
|
125
120
|
const handlerKind = isHandleFunction ? "function" : isStaticResponse ? "response" : isPromiseHandler ? "promise" : "static-value";
|
|
@@ -130,7 +125,7 @@ function describeRoute(input) {
|
|
|
130
125
|
descriptor: {
|
|
131
126
|
handlerKind,
|
|
132
127
|
async: !!isAsync,
|
|
133
|
-
tail,
|
|
128
|
+
tail: !!tail,
|
|
134
129
|
responseMode,
|
|
135
130
|
hasBeforeHandle,
|
|
136
131
|
hasAfterHandle,
|
|
@@ -146,7 +141,7 @@ function describeRoute(input) {
|
|
|
146
141
|
headersValiIsAsync: !!headersValiIsAsync,
|
|
147
142
|
paramsValiIsAsync: !!paramsValiIsAsync,
|
|
148
143
|
queryValiIsAsync: !!queryValiIsAsync,
|
|
149
|
-
cookieValiIsAsync: !!
|
|
144
|
+
cookieValiIsAsync: !!cookieValiIsAsync,
|
|
150
145
|
responseValiAsync,
|
|
151
146
|
hasCookieSign,
|
|
152
147
|
syncCookieSign,
|
|
@@ -169,4 +164,4 @@ function describeRoute(input) {
|
|
|
169
164
|
}
|
|
170
165
|
|
|
171
166
|
//#endregion
|
|
172
|
-
export { describeRoute, routeDescriptors };
|
|
167
|
+
export { describeRoute, releaseAnalysisCaches, routeDescriptors };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyLocalHook, HTTPMethod } from "../../types.js";
|
|
2
1
|
import { CapturedValidator, FrozenValidator } from "../aot.js";
|
|
2
|
+
import { AnyLocalHook, HTTPMethod } from "../../types.js";
|
|
3
3
|
import { AnyElysia } from "../../base.js";
|
|
4
4
|
|
|
5
5
|
//#region src/compile/handler/frozen-validator.d.ts
|
|
@@ -22,7 +22,7 @@ interface FrozenRouteValidatorShape {
|
|
|
22
22
|
query?: FrozenSlotValidator;
|
|
23
23
|
params?: FrozenSlotValidator;
|
|
24
24
|
cookie?: FrozenSlotValidator;
|
|
25
|
-
response?:
|
|
25
|
+
response?: Map<number, FrozenSlotValidator>;
|
|
26
26
|
}
|
|
27
27
|
declare const REQUEST_SLOTS: readonly ["body", "headers", "query", "params", "cookie"];
|
|
28
28
|
declare const isStandardSchema: (schema: unknown) => schema is object & Record<"~standard", unknown>;
|
|
@@ -243,19 +243,19 @@ function buildFrozenRouteValidator(hook, root, method, path) {
|
|
|
243
243
|
const resolved = resolveModelRef(response, root);
|
|
244
244
|
if (!resolved) return void 0;
|
|
245
245
|
const statuses = isResponseMap(resolved) ? resolved : { 200: resolved };
|
|
246
|
-
const responseOut =
|
|
246
|
+
const responseOut = /* @__PURE__ */ new Map();
|
|
247
247
|
for (const status in statuses) {
|
|
248
248
|
const raw = statuses[status];
|
|
249
249
|
if (!raw) continue;
|
|
250
250
|
const schema = resolveModelRef(raw, root);
|
|
251
251
|
if (!schema) return void 0;
|
|
252
252
|
if (isStandardSchema(schema)) {
|
|
253
|
-
responseOut
|
|
253
|
+
responseOut.set(+status, new require_validator_index.StandardValidator(schema));
|
|
254
254
|
continue;
|
|
255
255
|
}
|
|
256
256
|
const frozen = require_compile_aot.Compiled.getValidator(method, path, `response:${status}`, root["~programId"]);
|
|
257
257
|
if (!frozen || !isBridgeFreeComplete(frozen, schema, schema)) return void 0;
|
|
258
|
-
responseOut
|
|
258
|
+
responseOut.set(+status, new FrozenSlotValidator(frozen, schema, schema, normalize));
|
|
259
259
|
}
|
|
260
260
|
out.response = responseOut;
|
|
261
261
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
import { nullObject } from "../../utils.mjs";
|
|
2
3
|
import { ELYSIA_TYPES } from "../../type/constants.mjs";
|
|
3
4
|
import { ValidationError } from "../../error.mjs";
|
|
@@ -242,19 +243,19 @@ function buildFrozenRouteValidator(hook, root, method, path) {
|
|
|
242
243
|
const resolved = resolveModelRef(response, root);
|
|
243
244
|
if (!resolved) return void 0;
|
|
244
245
|
const statuses = isResponseMap(resolved) ? resolved : { 200: resolved };
|
|
245
|
-
const responseOut =
|
|
246
|
+
const responseOut = /* @__PURE__ */ new Map();
|
|
246
247
|
for (const status in statuses) {
|
|
247
248
|
const raw = statuses[status];
|
|
248
249
|
if (!raw) continue;
|
|
249
250
|
const schema = resolveModelRef(raw, root);
|
|
250
251
|
if (!schema) return void 0;
|
|
251
252
|
if (isStandardSchema(schema)) {
|
|
252
|
-
responseOut
|
|
253
|
+
responseOut.set(+status, new StandardValidator(schema));
|
|
253
254
|
continue;
|
|
254
255
|
}
|
|
255
256
|
const frozen = Compiled.getValidator(method, path, `response:${status}`, root["~programId"]);
|
|
256
257
|
if (!frozen || !isBridgeFreeComplete(frozen, schema, schema)) return void 0;
|
|
257
|
-
responseOut
|
|
258
|
+
responseOut.set(+status, new FrozenSlotValidator(frozen, schema, schema, normalize));
|
|
258
259
|
}
|
|
259
260
|
out.response = responseOut;
|
|
260
261
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ChainNode } from "../../utils.js";
|
|
2
2
|
import { AnyLocalHook, AppHook, CompiledHandler, InternalRoute } from "../../types.js";
|
|
3
3
|
import { AnyElysia } from "../../base.js";
|
|
4
|
+
import { releaseAnalysisCaches } from "./descriptor.js";
|
|
4
5
|
import { setCaptureHeaderShorthand } from "./jit.js";
|
|
5
6
|
|
|
6
7
|
//#region src/compile/handler/index.d.ts
|
|
8
|
+
declare function runIntrospect(hook: any): void;
|
|
7
9
|
declare function resolveLocalHook(scope: AnyElysia, hook: Partial<AnyLocalHook> | undefined, root?: AnyElysia): Partial<AnyLocalHook> | undefined;
|
|
8
10
|
declare function resolveWSLocalHook(scope: AnyElysia, hook: Partial<AnyLocalHook> | undefined, root?: AnyElysia): Partial<AnyLocalHook> | undefined;
|
|
9
11
|
/**
|
|
@@ -18,4 +20,4 @@ declare function composeRouteHook(instance: AnyElysia, localHook: Partial<AnyLoc
|
|
|
18
20
|
declare function routeShape(hook: AnyLocalHook | undefined, handler: unknown, root: AnyElysia): number | undefined;
|
|
19
21
|
declare function compileHandler(route: InternalRoute, root: AnyElysia, liveOnly?: boolean): CompiledHandler;
|
|
20
22
|
//#endregion
|
|
21
|
-
export { buildNativeStaticResponse, chainResolver, clearHandlerAnalysisCaches, compileHandler, composeRouteHook, localMacroRoot, resolveLocalHook, resolveWSLocalHook, routeShape, setCaptureHeaderShorthand };
|
|
23
|
+
export { buildNativeStaticResponse, chainResolver, clearHandlerAnalysisCaches, compileHandler, composeRouteHook, localMacroRoot, releaseAnalysisCaches, resolveLocalHook, resolveWSLocalHook, routeShape, runIntrospect, setCaptureHeaderShorthand };
|