elysia 2.0.0-beta.2 → 2.0.0-beta.21

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.
Files changed (339) hide show
  1. package/dist/adapter/bun/index.d.ts +18 -2
  2. package/dist/adapter/bun/index.js +467 -110
  3. package/dist/adapter/bun/index.mjs +467 -112
  4. package/dist/adapter/types.d.ts +2 -21
  5. package/dist/adapter/utils.d.ts +14 -3
  6. package/dist/adapter/utils.js +146 -87
  7. package/dist/adapter/utils.mjs +148 -90
  8. package/dist/adapter/web-standard/handler.d.ts +1 -1
  9. package/dist/adapter/web-standard/handler.js +47 -36
  10. package/dist/adapter/web-standard/handler.mjs +48 -37
  11. package/dist/adapter/web-standard/index.js +2 -30
  12. package/dist/adapter/web-standard/index.mjs +2 -30
  13. package/dist/adapter/web-standard/utils.js +5 -18
  14. package/dist/adapter/web-standard/utils.mjs +5 -18
  15. package/dist/base.d.ts +99 -67
  16. package/dist/base.js +678 -510
  17. package/dist/base.mjs +682 -514
  18. package/dist/compile/aot-capture.d.ts +2 -13
  19. package/dist/compile/aot-capture.js +26 -69
  20. package/dist/compile/aot-capture.mjs +28 -67
  21. package/dist/compile/aot-emit.d.ts +9 -7
  22. package/dist/compile/aot-emit.js +42 -19
  23. package/dist/compile/aot-emit.mjs +42 -20
  24. package/dist/compile/aot.d.ts +17 -19
  25. package/dist/compile/aot.js +41 -51
  26. package/dist/compile/aot.mjs +39 -49
  27. package/dist/compile/handler/descriptor.d.ts +9 -12
  28. package/dist/compile/handler/descriptor.js +19 -44
  29. package/dist/compile/handler/descriptor.mjs +20 -42
  30. package/dist/compile/handler/frozen-validator.d.ts +5 -10
  31. package/dist/compile/handler/frozen-validator.js +55 -105
  32. package/dist/compile/handler/frozen-validator.mjs +53 -105
  33. package/dist/compile/handler/index.d.ts +7 -5
  34. package/dist/compile/handler/index.js +270 -111
  35. package/dist/compile/handler/index.mjs +270 -113
  36. package/dist/compile/handler/jit.d.ts +19 -17
  37. package/dist/compile/handler/jit.js +222 -149
  38. package/dist/compile/handler/jit.mjs +224 -152
  39. package/dist/compile/handler/params.d.ts +1 -4
  40. package/dist/compile/handler/params.js +10 -5
  41. package/dist/compile/handler/params.mjs +14 -8
  42. package/dist/compile/handler/reconstruct.d.ts +2 -2
  43. package/dist/compile/handler/reconstruct.js +6 -4
  44. package/dist/compile/handler/reconstruct.mjs +6 -4
  45. package/dist/compile/handler/static-clone-resolver.d.ts +6 -0
  46. package/dist/compile/handler/static-clone-resolver.js +8 -0
  47. package/dist/compile/handler/static-clone-resolver.mjs +7 -0
  48. package/dist/compile/handler/utils.d.ts +22 -11
  49. package/dist/compile/handler/utils.js +159 -253
  50. package/dist/compile/handler/utils.mjs +155 -252
  51. package/dist/compile/jit-probe.d.ts +2 -2
  52. package/dist/compile/jit-probe.js +2 -3
  53. package/dist/compile/jit-probe.mjs +2 -3
  54. package/dist/compile/lexer.d.ts +7 -4
  55. package/dist/compile/lexer.js +268 -6
  56. package/dist/compile/lexer.mjs +268 -4
  57. package/dist/compile/utils.js +7 -4
  58. package/dist/compile/utils.mjs +7 -4
  59. package/dist/compiled.d.ts +0 -1
  60. package/dist/compiled.js +0 -1
  61. package/dist/compiled.mjs +0 -1
  62. package/dist/context.d.ts +14 -4
  63. package/dist/context.js +17 -32
  64. package/dist/context.mjs +19 -34
  65. package/dist/cookie/config.d.ts +7 -2
  66. package/dist/cookie/config.js +76 -16
  67. package/dist/cookie/config.mjs +77 -18
  68. package/dist/cookie/cookie.d.ts +1 -1
  69. package/dist/cookie/cookie.js +8 -10
  70. package/dist/cookie/cookie.mjs +8 -10
  71. package/dist/cookie/crypto.d.ts +8 -7
  72. package/dist/cookie/crypto.js +51 -40
  73. package/dist/cookie/crypto.mjs +51 -41
  74. package/dist/cookie/error.d.ts +1 -2
  75. package/dist/cookie/error.js +6 -4
  76. package/dist/cookie/error.mjs +6 -4
  77. package/dist/cookie/lib.js +7 -2
  78. package/dist/cookie/lib.mjs +7 -2
  79. package/dist/cookie/serialize.js +1 -1
  80. package/dist/cookie/serialize.mjs +1 -1
  81. package/dist/cookie/types.d.ts +10 -0
  82. package/dist/cookie/utils.d.ts +4 -8
  83. package/dist/cookie/utils.js +86 -52
  84. package/dist/cookie/utils.mjs +89 -54
  85. package/dist/error.d.ts +113 -103
  86. package/dist/error.js +181 -117
  87. package/dist/error.mjs +179 -118
  88. package/dist/generation.d.ts +2 -2
  89. package/dist/handler/error.d.ts +26 -15
  90. package/dist/handler/error.js +77 -96
  91. package/dist/handler/error.mjs +74 -97
  92. package/dist/handler/fetch.js +87 -108
  93. package/dist/handler/fetch.mjs +89 -110
  94. package/dist/handler/utils.d.ts +12 -6
  95. package/dist/handler/utils.js +84 -28
  96. package/dist/handler/utils.mjs +80 -28
  97. package/dist/index.d.ts +12 -12
  98. package/dist/index.js +2 -9
  99. package/dist/index.mjs +1 -1
  100. package/dist/memory.js +1 -1
  101. package/dist/memory.mjs +1 -1
  102. package/dist/package.js +1 -1
  103. package/dist/package.mjs +1 -1
  104. package/dist/plugin/aot/bun.d.ts +8 -1
  105. package/dist/plugin/aot/bun.js +16 -9
  106. package/dist/plugin/aot/bun.mjs +17 -10
  107. package/dist/plugin/aot/core.d.ts +52 -60
  108. package/dist/plugin/aot/core.js +208 -109
  109. package/dist/plugin/aot/core.mjs +205 -111
  110. package/dist/plugin/aot/esbuild.js +8 -5
  111. package/dist/plugin/aot/esbuild.mjs +9 -6
  112. package/dist/plugin/aot/hooks.d.ts +6 -17
  113. package/dist/plugin/aot/hooks.js +36 -14
  114. package/dist/plugin/aot/hooks.mjs +37 -16
  115. package/dist/plugin/aot/rspack-loader.d.ts +1 -5
  116. package/dist/plugin/aot/rspack-loader.js +1 -10
  117. package/dist/plugin/aot/rspack-loader.mjs +1 -10
  118. package/dist/plugin/aot/rspack.js +2 -5
  119. package/dist/plugin/aot/rspack.mjs +3 -6
  120. package/dist/plugin/aot/source.d.ts +6 -42
  121. package/dist/plugin/aot/source.js +71 -71
  122. package/dist/plugin/aot/source.mjs +72 -72
  123. package/dist/plugin/aot/treeshake.js +2 -6
  124. package/dist/plugin/aot/treeshake.mjs +2 -6
  125. package/dist/plugin/aot/unplugin.d.ts +1 -4
  126. package/dist/plugin/aot/unplugin.js +4 -13
  127. package/dist/plugin/aot/unplugin.mjs +4 -13
  128. package/dist/plugin/aot/vite.d.ts +2 -6
  129. package/dist/plugin/aot/worker.js +2 -2
  130. package/dist/plugin/aot/worker.mjs +2 -2
  131. package/dist/plugin/auto-head.js +1 -10
  132. package/dist/plugin/auto-head.mjs +1 -10
  133. package/dist/plugin/trace.d.ts +2 -1
  134. package/dist/route-table.d.ts +3 -0
  135. package/dist/route-table.js +16 -11
  136. package/dist/route-table.mjs +16 -11
  137. package/dist/schema-snapshot.d.ts +0 -4
  138. package/dist/schema-snapshot.js +32 -49
  139. package/dist/schema-snapshot.mjs +32 -49
  140. package/dist/sucrose.d.ts +6 -55
  141. package/dist/sucrose.js +103 -731
  142. package/dist/sucrose.mjs +102 -724
  143. package/dist/trace.d.ts +5 -8
  144. package/dist/trace.js +23 -134
  145. package/dist/trace.mjs +24 -135
  146. package/dist/type/bridge-live.d.ts +4 -2
  147. package/dist/type/bridge-live.js +6 -3
  148. package/dist/type/bridge-live.mjs +4 -2
  149. package/dist/type/bridge.d.ts +6 -4
  150. package/dist/type/bridge.js +17 -9
  151. package/dist/type/bridge.mjs +5 -3
  152. package/dist/type/coerce-plan.d.ts +5 -5
  153. package/dist/type/coerce-plan.js +41 -39
  154. package/dist/type/coerce-plan.mjs +43 -39
  155. package/dist/type/coerce.d.ts +3 -7
  156. package/dist/type/coerce.js +18 -75
  157. package/dist/type/coerce.mjs +19 -76
  158. package/dist/type/compat.d.ts +3 -0
  159. package/dist/type/compat.js +23 -14
  160. package/dist/type/compat.mjs +20 -10
  161. package/dist/type/elysia/array-buffer.d.ts +4 -1
  162. package/dist/type/elysia/array-buffer.js +17 -17
  163. package/dist/type/elysia/array-buffer.mjs +17 -17
  164. package/dist/type/elysia/array-string.js +2 -40
  165. package/dist/type/elysia/array-string.mjs +2 -39
  166. package/dist/type/elysia/array.js +5 -9
  167. package/dist/type/elysia/array.mjs +5 -9
  168. package/dist/type/elysia/boolean-string.js +2 -3
  169. package/dist/type/elysia/boolean-string.mjs +1 -1
  170. package/dist/type/elysia/boolean.js +3 -12
  171. package/dist/type/elysia/boolean.mjs +3 -11
  172. package/dist/type/elysia/cookie.d.ts +3 -4
  173. package/dist/type/elysia/cookie.js +5 -15
  174. package/dist/type/elysia/cookie.mjs +5 -15
  175. package/dist/type/elysia/date.js +13 -20
  176. package/dist/type/elysia/date.mjs +10 -16
  177. package/dist/type/elysia/file-type.d.ts +11 -4
  178. package/dist/type/elysia/file-type.js +17 -2
  179. package/dist/type/elysia/file-type.mjs +17 -3
  180. package/dist/type/elysia/file.d.ts +1 -3
  181. package/dist/type/elysia/file.js +11 -27
  182. package/dist/type/elysia/file.mjs +11 -12
  183. package/dist/type/elysia/files.js +7 -11
  184. package/dist/type/elysia/files.mjs +7 -10
  185. package/dist/type/elysia/form.js +2 -3
  186. package/dist/type/elysia/form.mjs +3 -3
  187. package/dist/type/elysia/integer-string.d.ts +1 -1
  188. package/dist/type/elysia/integer-string.js +4 -30
  189. package/dist/type/elysia/integer-string.mjs +5 -30
  190. package/dist/type/elysia/integer.js +3 -12
  191. package/dist/type/elysia/integer.mjs +3 -11
  192. package/dist/type/elysia/intersect.js +0 -5
  193. package/dist/type/elysia/intersect.mjs +0 -5
  194. package/dist/type/elysia/json-string.d.ts +7 -0
  195. package/dist/type/elysia/json-string.js +47 -0
  196. package/dist/type/elysia/json-string.mjs +46 -0
  197. package/dist/type/elysia/keep-config.d.ts +14 -0
  198. package/dist/type/elysia/keep-config.js +62 -0
  199. package/dist/type/elysia/keep-config.mjs +53 -0
  200. package/dist/type/elysia/maybe-empty.js +3 -4
  201. package/dist/type/elysia/maybe-empty.mjs +1 -1
  202. package/dist/type/elysia/nullable.js +2 -3
  203. package/dist/type/elysia/nullable.mjs +1 -1
  204. package/dist/type/elysia/number.d.ts +2 -1
  205. package/dist/type/elysia/number.js +19 -11
  206. package/dist/type/elysia/number.mjs +18 -10
  207. package/dist/type/elysia/numeric-enum.d.ts +1 -1
  208. package/dist/type/elysia/numeric-enum.js +4 -5
  209. package/dist/type/elysia/numeric-enum.mjs +3 -3
  210. package/dist/type/elysia/numeric.d.ts +4 -2
  211. package/dist/type/elysia/numeric.js +20 -17
  212. package/dist/type/elysia/numeric.mjs +19 -16
  213. package/dist/type/elysia/object-string.js +2 -37
  214. package/dist/type/elysia/object-string.mjs +2 -36
  215. package/dist/type/elysia/object.js +5 -9
  216. package/dist/type/elysia/object.mjs +5 -9
  217. package/dist/type/elysia/optional.js +8 -8
  218. package/dist/type/elysia/optional.mjs +7 -7
  219. package/dist/type/elysia/problem.d.ts +20 -0
  220. package/dist/type/elysia/problem.js +25 -0
  221. package/dist/type/elysia/problem.mjs +24 -0
  222. package/dist/type/elysia/string.js +4 -3
  223. package/dist/type/elysia/string.mjs +4 -2
  224. package/dist/type/elysia/uint8-array.d.ts +1 -1
  225. package/dist/type/elysia/uint8-array.js +5 -20
  226. package/dist/type/elysia/uint8-array.mjs +5 -19
  227. package/dist/type/elysia/union-enum.js +7 -8
  228. package/dist/type/elysia/union-enum.mjs +6 -6
  229. package/dist/type/elysia/union.js +0 -5
  230. package/dist/type/elysia/union.mjs +0 -5
  231. package/dist/type/elysia/utils.d.ts +2 -4
  232. package/dist/type/elysia/utils.js +10 -21
  233. package/dist/type/elysia/utils.mjs +7 -15
  234. package/dist/type/exports.d.ts +4 -2
  235. package/dist/type/exports.js +23 -2
  236. package/dist/type/exports.mjs +11 -2
  237. package/dist/type/index.d.ts +10 -2
  238. package/dist/type/index.js +62 -15
  239. package/dist/type/index.mjs +65 -11
  240. package/dist/type/shared.d.ts +3 -9
  241. package/dist/type/shared.js +44 -97
  242. package/dist/type/shared.mjs +43 -97
  243. package/dist/type/sync-require.d.ts +11 -0
  244. package/dist/type/sync-require.js +14 -0
  245. package/dist/type/sync-require.mjs +12 -0
  246. package/dist/type/typebox-system-lite.d.ts +2 -0
  247. package/dist/type/typebox-system-lite.js +34 -0
  248. package/dist/type/typebox-system-lite.mjs +3 -0
  249. package/dist/type/typebox-system-require.d.ts +7 -0
  250. package/dist/type/typebox-system-require.js +24 -0
  251. package/dist/type/typebox-system-require.mjs +23 -0
  252. package/dist/type/typebox-type-live.d.ts +11 -0
  253. package/dist/type/typebox-type-live.js +45 -0
  254. package/dist/type/typebox-type-live.mjs +20 -0
  255. package/dist/type/typebox-type.d.ts +34 -0
  256. package/dist/type/typebox-type.js +199 -0
  257. package/dist/type/typebox-type.mjs +86 -0
  258. package/dist/type/typebox-value-live.d.ts +11 -0
  259. package/dist/type/typebox-value-live.js +31 -0
  260. package/dist/type/typebox-value-live.mjs +13 -0
  261. package/dist/type/typebox-value-ops.d.ts +4 -0
  262. package/dist/type/typebox-value-ops.js +90 -0
  263. package/dist/type/typebox-value-ops.mjs +5 -0
  264. package/dist/type/typebox-value-require.d.ts +8 -0
  265. package/dist/type/typebox-value-require.js +28 -0
  266. package/dist/type/typebox-value-require.mjs +25 -0
  267. package/dist/type/typebox-value.d.ts +35 -0
  268. package/dist/type/typebox-value.js +161 -0
  269. package/dist/type/typebox-value.mjs +74 -0
  270. package/dist/type/utils.js +1 -10
  271. package/dist/type/utils.mjs +1 -10
  272. package/dist/type/validator/clean-safe.d.ts +2 -4
  273. package/dist/type/validator/clean-safe.js +15 -11
  274. package/dist/type/validator/clean-safe.mjs +16 -10
  275. package/dist/type/validator/custom-error.js +12 -16
  276. package/dist/type/validator/custom-error.mjs +11 -14
  277. package/dist/type/validator/default-precompute.d.ts +9 -1
  278. package/dist/type/validator/default-precompute.js +40 -77
  279. package/dist/type/validator/default-precompute.mjs +37 -74
  280. package/dist/type/validator/exact-mirror-live.d.ts +8 -0
  281. package/dist/type/validator/exact-mirror-live.js +22 -0
  282. package/dist/type/validator/exact-mirror-live.mjs +17 -0
  283. package/dist/type/validator/exact-mirror-require.d.ts +4 -0
  284. package/dist/type/validator/exact-mirror-require.js +11 -0
  285. package/dist/type/validator/exact-mirror-require.mjs +9 -0
  286. package/dist/type/validator/exact-mirror.js +8 -8
  287. package/dist/type/validator/exact-mirror.mjs +9 -8
  288. package/dist/type/validator/frozen-check.js +5 -6
  289. package/dist/type/validator/frozen-check.mjs +6 -7
  290. package/dist/type/validator/index.d.ts +1 -0
  291. package/dist/type/validator/index.js +169 -166
  292. package/dist/type/validator/index.mjs +162 -158
  293. package/dist/type/validator/string-codec-aot.d.ts +2 -1
  294. package/dist/type/validator/string-codec-aot.js +8 -2
  295. package/dist/type/validator/string-codec-aot.mjs +7 -2
  296. package/dist/type/validator/validator-cache.d.ts +5 -4
  297. package/dist/type/validator/validator-cache.js +41 -24
  298. package/dist/type/validator/validator-cache.mjs +40 -22
  299. package/dist/types.d.ts +263 -95
  300. package/dist/universal/constants.d.ts +2 -1
  301. package/dist/universal/constants.js +3 -1
  302. package/dist/universal/constants.mjs +2 -1
  303. package/dist/universal/env.js +2 -3
  304. package/dist/universal/env.mjs +2 -3
  305. package/dist/universal/file.d.ts +6 -4
  306. package/dist/universal/file.js +11 -16
  307. package/dist/universal/file.mjs +12 -16
  308. package/dist/universal/index.d.ts +2 -2
  309. package/dist/universal/is-production.d.ts +1 -2
  310. package/dist/universal/is-production.js +1 -3
  311. package/dist/universal/is-production.mjs +2 -3
  312. package/dist/universal/server.d.ts +0 -272
  313. package/dist/utils.d.ts +43 -7
  314. package/dist/utils.js +181 -126
  315. package/dist/utils.mjs +168 -126
  316. package/dist/validator/index.d.ts +1 -1
  317. package/dist/validator/index.js +17 -30
  318. package/dist/validator/index.mjs +18 -31
  319. package/dist/validator/route.js +2 -1
  320. package/dist/validator/route.mjs +2 -1
  321. package/dist/ws/context.d.ts +8 -1
  322. package/dist/ws/context.js +68 -44
  323. package/dist/ws/context.mjs +67 -44
  324. package/dist/ws/parser.js +10 -20
  325. package/dist/ws/parser.mjs +10 -20
  326. package/dist/ws/route.d.ts +2 -2
  327. package/dist/ws/route.js +249 -141
  328. package/dist/ws/route.mjs +254 -146
  329. package/dist/ws/types.d.ts +2 -2
  330. package/package.json +23 -49
  331. package/dist/compile/analysis-cache.d.ts +0 -6
  332. package/dist/compile/analysis-cache.js +0 -12
  333. package/dist/compile/analysis-cache.mjs +0 -11
  334. package/dist/cookie/index.d.ts +0 -7
  335. package/dist/cookie/index.js +0 -13
  336. package/dist/cookie/index.mjs +0 -7
  337. package/dist/handler/index.d.ts +0 -2
  338. package/dist/handler/index.js +0 -5
  339. package/dist/handler/index.mjs +0 -3
@@ -1,15 +1,13 @@
1
- import { CoercePlan } from "../type/coerce-plan.js";
1
+ import { CoerceNode } from "../type/coerce-plan.js";
2
2
  //#region src/compile/aot.d.ts
3
- declare const AOT_MANIFEST_FORMAT = 3;
4
- declare const AOT_ABI: string;
3
+ declare const AOT_MANIFEST_FORMAT = 6;
5
4
  interface AotFingerprint {
6
5
  abi: string;
7
6
  }
8
7
  interface ProgramId {
9
8
  readonly _: unique symbol;
10
9
  }
11
- declare const createProgramId: () => ProgramId;
12
- declare function createAotFingerprint(): AotFingerprint;
10
+ declare const createAotFingerprint: () => AotFingerprint;
13
11
  interface CompilerSession {
14
12
  readonly sucroseCache: Map<number, {
15
13
  content: string;
@@ -73,7 +71,7 @@ interface FrozenValidator {
73
71
  x?: 1;
74
72
  };
75
73
  }>;
76
- cp?: CoercePlan;
74
+ cp?: CoerceNode;
77
75
  }
78
76
  interface ValidatorManifest {
79
77
  [method: string]: {
@@ -81,8 +79,9 @@ interface ValidatorManifest {
81
79
  };
82
80
  }
83
81
  interface FrozenHandler {
84
- a: string[];
85
- f: (...deps: unknown[]) => unknown;
82
+ a?: string[];
83
+ f?: (...deps: unknown[]) => unknown;
84
+ k?: number;
86
85
  }
87
86
  interface HandlerManifest {
88
87
  [method: string]: {
@@ -91,17 +90,16 @@ interface HandlerManifest {
91
90
  }
92
91
  interface CompiledSnapshot {
93
92
  registered: CompiledProgramRegistration | undefined;
94
- claimed: boolean;
93
+ claimed: WeakRef<ProgramId> | undefined;
95
94
  programs: WeakMap<ProgramId, CompiledProgram>;
96
95
  }
97
96
  interface CompiledProgramRegistration {
98
- bf: 1;
99
97
  fingerprint: AotFingerprint;
100
98
  validators?: ValidatorManifest;
101
99
  handlers?: HandlerManifest;
102
100
  lazyGroups?: Array<() => ValidatorManifest>;
103
101
  lazyGroupOf?: Record<string, Record<string, number>>;
104
- planRebuilder?: (original: unknown, plan: CoercePlan) => any;
102
+ planRebuilder?: (original: unknown, plan: CoerceNode) => any;
105
103
  }
106
104
  interface CompiledProgram extends CompiledProgramRegistration {
107
105
  builtGroups: Set<number>;
@@ -128,19 +126,18 @@ interface ReconstructImpl {
128
126
  reconstructInnerCodecs(ic: NonNullable<FrozenValidator['ic']>, schema: any): void;
129
127
  }
130
128
  declare function reconstruct(): ReconstructImpl;
129
+ declare const aotDrift: (method: string, path: string) => string;
130
+ declare function warnAotDrift(method: string, path: string): void;
131
131
  declare abstract class Compiled {
132
132
  static register(manifest: CompiledProgramRegistration): void;
133
133
  static claim(id: ProgramId, fingerprint: AotFingerprint): boolean;
134
- static get reconstruct(): ReconstructImpl | undefined;
134
+ static assertUncontested(id: ProgramId): void;
135
135
  static set reconstruct(impl: ReconstructImpl | undefined);
136
136
  static getHandler(id: ProgramId | undefined, method: string, path: string): FrozenHandler | undefined;
137
+ static hasProgram(id: ProgramId | undefined): boolean;
137
138
  static getValidator(method: string, path: string, slot: ValidatorSlot, id?: ProgramId): FrozenValidator | undefined;
138
139
  static hasValidator(method: string, path: string, slot: ValidatorSlot, id?: ProgramId): boolean;
139
- static getPlanRebuilder(id?: ProgramId): ((original: unknown, plan: CoercePlan) => any) | undefined;
140
- /**
141
- * Drop a fully consumed program registration after an eager production
142
- * build publishes. Safe only when every route compiled before publish
143
- */
140
+ static getPlanRebuilder(id?: ProgramId): ((original: unknown, plan: CoerceNode) => any) | undefined;
144
141
  static release(id: ProgramId): void;
145
142
  /** @internal test isolation */
146
143
  static clear(): void;
@@ -213,7 +210,7 @@ interface CapturedValidator {
213
210
  external: boolean;
214
211
  decode: CapturedMirror;
215
212
  }>;
216
- coercePlan?: CoercePlan;
213
+ coercePlan?: CoerceNode;
217
214
  bridgeFree?: boolean;
218
215
  }
219
216
  /** @internal shared with `aot-capture.ts` (`beginValidatorCapture`). */
@@ -223,6 +220,7 @@ interface CapturedHandler {
223
220
  path: string;
224
221
  alias: string;
225
222
  code: string;
223
+ k: number | undefined;
226
224
  }
227
225
  declare function captureHandler(v: CapturedHandler): void;
228
226
  declare function captureSet(loc: {
@@ -284,4 +282,4 @@ interface CaptureImpl {
284
282
  declare let captureImpl: CaptureImpl | undefined;
285
283
  declare function setCaptureImpl(impl: CaptureImpl | undefined): void;
286
284
  //#endregion
287
- export { AOT_ABI, 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, beginCompilerSession, captureImpl, createAotFingerprint, createProgramId, endCompilerSession, getCompilerSession, reconstruct, setCaptureImpl };
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, aotDrift, beginCompilerSession, captureImpl, createAotFingerprint, endCompilerSession, getCompilerSession, reconstruct, setCaptureImpl, warnAotDrift };
@@ -4,13 +4,10 @@ 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 = 3;
8
- const AOT_ABI = `${require_package.version}:${3}`;
9
- const createProgramId = () => ({});
7
+ const AOT_MANIFEST_FORMAT = 6;
8
+ const AOT_ABI = `${require_package.version}:${6}`;
10
9
  const sharedAotFingerprint = Object.freeze({ abi: AOT_ABI });
11
- function createAotFingerprint() {
12
- return sharedAotFingerprint;
13
- }
10
+ const createAotFingerprint = () => sharedAotFingerprint;
14
11
  let activeSession;
15
12
  const newCompilerSession = () => ({ sucroseCache: /* @__PURE__ */ new Map() });
16
13
  function beginCompilerSession(app) {
@@ -40,28 +37,29 @@ function reconstruct() {
40
37
  if (reconstructImpl === void 0) throw new Error("Elysia AOT reconstruct module is not activated");
41
38
  return reconstructImpl;
42
39
  }
40
+ let drifted;
41
+ const aotDrift = (method, path) => `[elysia-aot] ${method} ${path} differs from the AOT build`;
42
+ function warnAotDrift(method, path) {
43
+ const key = method + " " + path;
44
+ if (drifted?.has(key)) return;
45
+ drifted ??= /* @__PURE__ */ new Set();
46
+ drifted.add(key);
47
+ console.warn(aotDrift(method, path) + ", compiled at runtime");
48
+ }
43
49
  let registered;
44
- let claimed = false;
50
+ let claimed;
45
51
  let programs = /* @__PURE__ */ new WeakMap();
46
52
  const programFor = (id) => id ? programs.get(id) : void 0;
47
- const fingerprintMismatch = (manifest, actual) => {
48
- const differences = [];
49
- const expected = manifest.fingerprint;
50
- if (manifest.bf !== 1) differences.push(`bf (manifest ${manifest.bf}, app 1)`);
51
- if (expected.abi !== actual.abi) differences.push(`abi (manifest ${expected.abi}, app ${actual.abi})`);
52
- return differences;
53
- };
54
53
  var Compiled = class {
55
54
  static register(manifest) {
56
55
  registered = manifest;
57
- claimed = false;
56
+ claimed = void 0;
58
57
  }
59
58
  static claim(id, fingerprint) {
60
59
  if (!registered || claimed) return false;
61
60
  const manifest = registered;
62
- const differences = fingerprintMismatch(manifest, fingerprint);
63
- if (differences.length) throw new Error(`[elysia-aot] Registered manifest fingerprint mismatch: ${differences.join("; ")}.`);
64
- claimed = true;
61
+ if (manifest.fingerprint.abi !== fingerprint.abi) throw new Error(`[elysia-aot] Mismatch fingerprint`);
62
+ claimed = new WeakRef(id);
65
63
  registered = void 0;
66
64
  programs.set(id, {
67
65
  ...manifest,
@@ -69,8 +67,9 @@ var Compiled = class {
69
67
  });
70
68
  return true;
71
69
  }
72
- static get reconstruct() {
73
- return reconstructImpl;
70
+ static assertUncontested(id) {
71
+ if (claimed === void 0 || claimed.deref() === id || isAotBuildEnv()) return;
72
+ throw new Error("[elysia-aot] A second Elysia app built a router in this process. An AOT build seals one app per process.");
74
73
  }
75
74
  static set reconstruct(impl) {
76
75
  reconstructImpl = impl;
@@ -78,6 +77,9 @@ var Compiled = class {
78
77
  static getHandler(id, method, path) {
79
78
  return programFor(id)?.handlers?.[method]?.[path];
80
79
  }
80
+ static hasProgram(id) {
81
+ return programFor(id) !== void 0;
82
+ }
81
83
  static getValidator(method, path, slot, id) {
82
84
  const program = programFor(id);
83
85
  if (!program) return void 0;
@@ -106,18 +108,15 @@ var Compiled = class {
106
108
  static getPlanRebuilder(id) {
107
109
  return programFor(id)?.planRebuilder;
108
110
  }
109
- /**
110
- * Drop a fully consumed program registration after an eager production
111
- * build publishes. Safe only when every route compiled before publish
112
- */
113
111
  static release(id) {
114
112
  programs.delete(id);
115
113
  }
116
114
  /** @internal test isolation */
117
115
  static clear() {
118
116
  registered = void 0;
119
- claimed = false;
117
+ claimed = void 0;
120
118
  programs = /* @__PURE__ */ new WeakMap();
119
+ drifted?.clear();
121
120
  }
122
121
  };
123
122
  /**
@@ -146,7 +145,16 @@ const CompilerState = {
146
145
  }
147
146
  };
148
147
  const EMPTY_EXTERNALS = Object.freeze([]);
149
- function captureEntry({ method, path, slot }) {
148
+ /** @internal shared with `aot-capture.ts` (`beginValidatorCapture`). */
149
+ const aotActivationError = () => /* @__PURE__ */ new Error("Elysia AOT capture module is not activated.");
150
+ function captureHandler(v) {
151
+ if (!isValidatorCapturing()) return;
152
+ const session = activeSession;
153
+ if (!session) return;
154
+ (session.handlerCapture ??= /* @__PURE__ */ new Map()).set(`${v.method}\0${v.path}`, v);
155
+ }
156
+ function captureSet(loc, partial) {
157
+ const { method, path, slot } = loc;
150
158
  if (!isValidatorCapturing()) return;
151
159
  const capture = activeSession?.capture;
152
160
  if (!capture) return;
@@ -157,32 +165,14 @@ function captureEntry({ method, path, slot }) {
157
165
  path,
158
166
  slot
159
167
  });
160
- return e;
161
- }
162
- /** @internal shared with `aot-capture.ts` (`beginValidatorCapture`). */
163
- const aotActivationError = () => /* @__PURE__ */ new Error("Elysia AOT capture module is not activated.");
164
- function captureHandler(v) {
165
- if (!isValidatorCapturing()) return;
166
- const session = activeSession;
167
- if (!session) return;
168
- (session.handlerCapture ??= /* @__PURE__ */ new Map()).set(`${v.method}\0${v.path}`, v);
169
- }
170
- function captureSet(loc, partial) {
171
- const e = captureEntry(loc);
172
- if (e) Object.assign(e, partial);
168
+ Object.assign(e, partial);
173
169
  }
174
170
  const captureGet = (loc) => activeSession?.capture?.get(`${loc.method}_${loc.path}_${loc.slot}`);
175
171
  const isAotBuildEnv = () => !!require_universal_env.env.ELYSIA_AOT_BUILD;
176
172
  const isValidatorCapturing = () => {
177
- if (activeSession?.capture !== void 0) {
178
- if (captureImpl === void 0) throw aotActivationError();
179
- return true;
180
- }
181
- if (isAotBuildEnv()) {
182
- if (captureImpl === void 0) throw aotActivationError();
183
- return true;
184
- }
185
- return false;
173
+ if (activeSession?.capture === void 0 && !isAotBuildEnv()) return false;
174
+ if (captureImpl === void 0) throw aotActivationError();
175
+ return true;
186
176
  };
187
177
  const Capture = {
188
178
  set: captureSet,
@@ -198,13 +188,13 @@ function setCaptureImpl(impl) {
198
188
  }
199
189
 
200
190
  //#endregion
201
- exports.AOT_ABI = AOT_ABI;
202
191
  exports.AOT_MANIFEST_FORMAT = AOT_MANIFEST_FORMAT;
203
192
  exports.Capture = Capture;
204
193
  exports.Compiled = Compiled;
205
194
  exports.CompilerState = CompilerState;
206
195
  exports.EMPTY_EXTERNALS = EMPTY_EXTERNALS;
207
196
  exports.aotActivationError = aotActivationError;
197
+ exports.aotDrift = aotDrift;
208
198
  exports.beginCompilerSession = beginCompilerSession;
209
199
  Object.defineProperty(exports, 'captureImpl', {
210
200
  enumerable: true,
@@ -213,8 +203,8 @@ Object.defineProperty(exports, 'captureImpl', {
213
203
  }
214
204
  });
215
205
  exports.createAotFingerprint = createAotFingerprint;
216
- exports.createProgramId = createProgramId;
217
206
  exports.endCompilerSession = endCompilerSession;
218
207
  exports.getCompilerSession = getCompilerSession;
219
208
  exports.reconstruct = reconstruct;
220
- exports.setCaptureImpl = setCaptureImpl;
209
+ exports.setCaptureImpl = setCaptureImpl;
210
+ exports.warnAotDrift = warnAotDrift;
@@ -3,13 +3,10 @@ import { env } from "../universal/env.mjs";
3
3
  import { version } from "../package.mjs";
4
4
 
5
5
  //#region src/compile/aot.ts
6
- const AOT_MANIFEST_FORMAT = 3;
7
- const AOT_ABI = `${version}:${3}`;
8
- const createProgramId = () => ({});
6
+ const AOT_MANIFEST_FORMAT = 6;
7
+ const AOT_ABI = `${version}:${6}`;
9
8
  const sharedAotFingerprint = Object.freeze({ abi: AOT_ABI });
10
- function createAotFingerprint() {
11
- return sharedAotFingerprint;
12
- }
9
+ const createAotFingerprint = () => sharedAotFingerprint;
13
10
  let activeSession;
14
11
  const newCompilerSession = () => ({ sucroseCache: /* @__PURE__ */ new Map() });
15
12
  function beginCompilerSession(app) {
@@ -39,28 +36,29 @@ function reconstruct() {
39
36
  if (reconstructImpl === void 0) throw new Error("Elysia AOT reconstruct module is not activated");
40
37
  return reconstructImpl;
41
38
  }
39
+ let drifted;
40
+ const aotDrift = (method, path) => `[elysia-aot] ${method} ${path} differs from the AOT build`;
41
+ function warnAotDrift(method, path) {
42
+ const key = method + " " + path;
43
+ if (drifted?.has(key)) return;
44
+ drifted ??= /* @__PURE__ */ new Set();
45
+ drifted.add(key);
46
+ console.warn(aotDrift(method, path) + ", compiled at runtime");
47
+ }
42
48
  let registered;
43
- let claimed = false;
49
+ let claimed;
44
50
  let programs = /* @__PURE__ */ new WeakMap();
45
51
  const programFor = (id) => id ? programs.get(id) : void 0;
46
- const fingerprintMismatch = (manifest, actual) => {
47
- const differences = [];
48
- const expected = manifest.fingerprint;
49
- if (manifest.bf !== 1) differences.push(`bf (manifest ${manifest.bf}, app 1)`);
50
- if (expected.abi !== actual.abi) differences.push(`abi (manifest ${expected.abi}, app ${actual.abi})`);
51
- return differences;
52
- };
53
52
  var Compiled = class {
54
53
  static register(manifest) {
55
54
  registered = manifest;
56
- claimed = false;
55
+ claimed = void 0;
57
56
  }
58
57
  static claim(id, fingerprint) {
59
58
  if (!registered || claimed) return false;
60
59
  const manifest = registered;
61
- const differences = fingerprintMismatch(manifest, fingerprint);
62
- if (differences.length) throw new Error(`[elysia-aot] Registered manifest fingerprint mismatch: ${differences.join("; ")}.`);
63
- claimed = true;
60
+ if (manifest.fingerprint.abi !== fingerprint.abi) throw new Error(`[elysia-aot] Mismatch fingerprint`);
61
+ claimed = new WeakRef(id);
64
62
  registered = void 0;
65
63
  programs.set(id, {
66
64
  ...manifest,
@@ -68,8 +66,9 @@ var Compiled = class {
68
66
  });
69
67
  return true;
70
68
  }
71
- static get reconstruct() {
72
- return reconstructImpl;
69
+ static assertUncontested(id) {
70
+ if (claimed === void 0 || claimed.deref() === id || isAotBuildEnv()) return;
71
+ throw new Error("[elysia-aot] A second Elysia app built a router in this process. An AOT build seals one app per process.");
73
72
  }
74
73
  static set reconstruct(impl) {
75
74
  reconstructImpl = impl;
@@ -77,6 +76,9 @@ var Compiled = class {
77
76
  static getHandler(id, method, path) {
78
77
  return programFor(id)?.handlers?.[method]?.[path];
79
78
  }
79
+ static hasProgram(id) {
80
+ return programFor(id) !== void 0;
81
+ }
80
82
  static getValidator(method, path, slot, id) {
81
83
  const program = programFor(id);
82
84
  if (!program) return void 0;
@@ -105,18 +107,15 @@ var Compiled = class {
105
107
  static getPlanRebuilder(id) {
106
108
  return programFor(id)?.planRebuilder;
107
109
  }
108
- /**
109
- * Drop a fully consumed program registration after an eager production
110
- * build publishes. Safe only when every route compiled before publish
111
- */
112
110
  static release(id) {
113
111
  programs.delete(id);
114
112
  }
115
113
  /** @internal test isolation */
116
114
  static clear() {
117
115
  registered = void 0;
118
- claimed = false;
116
+ claimed = void 0;
119
117
  programs = /* @__PURE__ */ new WeakMap();
118
+ drifted?.clear();
120
119
  }
121
120
  };
122
121
  /**
@@ -145,7 +144,16 @@ const CompilerState = {
145
144
  }
146
145
  };
147
146
  const EMPTY_EXTERNALS = Object.freeze([]);
148
- function captureEntry({ method, path, slot }) {
147
+ /** @internal shared with `aot-capture.ts` (`beginValidatorCapture`). */
148
+ const aotActivationError = () => /* @__PURE__ */ new Error("Elysia AOT capture module is not activated.");
149
+ function captureHandler(v) {
150
+ if (!isValidatorCapturing()) return;
151
+ const session = activeSession;
152
+ if (!session) return;
153
+ (session.handlerCapture ??= /* @__PURE__ */ new Map()).set(`${v.method}\0${v.path}`, v);
154
+ }
155
+ function captureSet(loc, partial) {
156
+ const { method, path, slot } = loc;
149
157
  if (!isValidatorCapturing()) return;
150
158
  const capture = activeSession?.capture;
151
159
  if (!capture) return;
@@ -156,32 +164,14 @@ function captureEntry({ method, path, slot }) {
156
164
  path,
157
165
  slot
158
166
  });
159
- return e;
160
- }
161
- /** @internal shared with `aot-capture.ts` (`beginValidatorCapture`). */
162
- const aotActivationError = () => /* @__PURE__ */ new Error("Elysia AOT capture module is not activated.");
163
- function captureHandler(v) {
164
- if (!isValidatorCapturing()) return;
165
- const session = activeSession;
166
- if (!session) return;
167
- (session.handlerCapture ??= /* @__PURE__ */ new Map()).set(`${v.method}\0${v.path}`, v);
168
- }
169
- function captureSet(loc, partial) {
170
- const e = captureEntry(loc);
171
- if (e) Object.assign(e, partial);
167
+ Object.assign(e, partial);
172
168
  }
173
169
  const captureGet = (loc) => activeSession?.capture?.get(`${loc.method}_${loc.path}_${loc.slot}`);
174
170
  const isAotBuildEnv = () => !!env.ELYSIA_AOT_BUILD;
175
171
  const isValidatorCapturing = () => {
176
- if (activeSession?.capture !== void 0) {
177
- if (captureImpl === void 0) throw aotActivationError();
178
- return true;
179
- }
180
- if (isAotBuildEnv()) {
181
- if (captureImpl === void 0) throw aotActivationError();
182
- return true;
183
- }
184
- return false;
172
+ if (activeSession?.capture === void 0 && !isAotBuildEnv()) return false;
173
+ if (captureImpl === void 0) throw aotActivationError();
174
+ return true;
185
175
  };
186
176
  const Capture = {
187
177
  set: captureSet,
@@ -197,4 +187,4 @@ function setCaptureImpl(impl) {
197
187
  }
198
188
 
199
189
  //#endregion
200
- export { AOT_ABI, AOT_MANIFEST_FORMAT, Capture, Compiled, CompilerState, EMPTY_EXTERNALS, aotActivationError, beginCompilerSession, captureImpl, createAotFingerprint, createProgramId, endCompilerSession, getCompilerSession, reconstruct, setCaptureImpl };
190
+ export { AOT_MANIFEST_FORMAT, Capture, Compiled, CompilerState, EMPTY_EXTERNALS, aotActivationError, aotDrift, beginCompilerSession, captureImpl, createAotFingerprint, endCompilerSession, getCompilerSession, reconstruct, setCaptureImpl, warnAotDrift };
@@ -1,16 +1,21 @@
1
- import { TraceEvent } from "../../trace.js";
1
+ import { TraceEvent } from "../../constants.js";
2
2
  import { CompactBeforeHandlePrefix } from "../../utils.js";
3
- import { AnyLocalHook, MaybeArray } from "../../types.js";
4
- import { CompiledCookieConfig } from "../../cookie/config.js";
3
+ import { AnyLocalHook } from "../../types.js";
5
4
  import { AnyElysia } from "../../base.js";
6
5
  import { ElysiaAdapter } from "../../adapter/index.js";
7
6
  import { Sucrose } from "../../sucrose.js";
8
7
  import { RouteValidator } from "../../validator/route.js";
8
+ import { CompiledCookieConfig } from "../../cookie/config.js";
9
9
 
10
10
  //#region src/compile/handler/descriptor.d.ts
11
11
  interface RouteDescriptor {
12
12
  handlerKind: 'function' | 'response' | 'promise' | 'static-value';
13
13
  async: boolean;
14
+ /**
15
+ * `async` only on a maybe-promise: compiled as a sync route that hands
16
+ * off to an async tail at the first thenable
17
+ */
18
+ tail: boolean;
14
19
  responseMode: 'compact' | 'default-headers' | 'set' | 'set-with-default-headers';
15
20
  hasBeforeHandle: boolean;
16
21
  hasAfterHandle: boolean;
@@ -50,7 +55,6 @@ interface RouteCompileState {
50
55
  }
51
56
  interface DescribeRouteInput {
52
57
  method: string;
53
- path: string;
54
58
  handler: unknown;
55
59
  root: AnyElysia;
56
60
  adapter: ElysiaAdapter;
@@ -65,13 +69,6 @@ interface DescribeRouteInput {
65
69
  * Populated on each JIT compile, and read only by tests and introspection
66
70
  */
67
71
  declare const routeDescriptors: WeakMap<AnyElysia, Map<string, RouteDescriptor>>;
68
- declare function mayReturnIdentifier(fn: Function): boolean;
69
- declare const lifecycleMayReturnPromise: (handlers: MaybeArray<Function> | undefined, observed: boolean) => boolean;
70
- /**
71
- * Extracted from `buildNativeStaticResponse`'s for-in check so the native
72
- * static promotion predicate
73
- */
74
- declare function isEmptyPipelineHook(hook: AnyLocalHook | undefined): boolean;
75
72
  declare function describeRoute(input: DescribeRouteInput): RouteCompileState;
76
73
  //#endregion
77
- export { DescribeRouteInput, RouteCompileState, RouteDescriptor, describeRoute, isEmptyPipelineHook, lifecycleMayReturnPromise, mayReturnIdentifier, routeDescriptors };
74
+ export { DescribeRouteInput, RouteCompileState, RouteDescriptor, describeRoute, routeDescriptors };
@@ -1,12 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils = require('../../utils.js');
3
+ const require_cookie_crypto = require('../../cookie/crypto.js');
3
4
  const require_compile_aot = require('../aot.js');
4
5
  const require_generation = require('../../generation.js');
5
- const require_cookie_crypto = require('../../cookie/crypto.js');
6
- const require_cookie_config = require('../../cookie/config.js');
7
6
  const require_compile_utils = require('../utils.js');
8
7
  const require_compile_jit_probe = require('../jit-probe.js');
9
8
  const require_sucrose = require('../../sucrose.js');
9
+ const require_compile_handler_reconstruct = require('./reconstruct.js');
10
10
 
11
11
  //#region src/compile/handler/descriptor.ts
12
12
  /**
@@ -15,16 +15,7 @@ const require_sucrose = require('../../sucrose.js');
15
15
  */
16
16
  const routeDescriptors = /* @__PURE__ */ new WeakMap();
17
17
  const noTracePhases = /* @__PURE__ */ new Set();
18
- const matchReturnIdentifier = /(?:=>\s*|\breturn\s+)(?!(?:true|false|null|undefined|void|new|typeof|async|await|function|class)\b)[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*(?![\w$([])/;
19
- const mayReturnIdentifierCache = /* @__PURE__ */ new WeakMap();
20
- function mayReturnIdentifier(fn) {
21
- let result = mayReturnIdentifierCache.get(fn);
22
- if (result !== void 0) return result;
23
- result = matchReturnIdentifier.test(fn.toString());
24
- mayReturnIdentifierCache.set(fn, result);
25
- return result;
26
- }
27
- const lifecycleMayReturnPromise = (handlers, observed) => handlers ? Array.isArray(handlers) ? handlers.some((fn) => !require_compile_utils.isAsyncFunction(fn) && (require_compile_utils.mayReturnPromise(fn) || observed && mayReturnIdentifier(fn))) : !require_compile_utils.isAsyncFunction(handlers) && (require_compile_utils.mayReturnPromise(handlers) || observed && mayReturnIdentifier(handlers)) : false;
18
+ const lifecycleMayReturnPromise = (handlers) => handlers ? Array.isArray(handlers) ? handlers.some(require_compile_utils.mayReturnPromise) : require_compile_utils.mayReturnPromise(handlers) : false;
28
19
  const compactPrefixInference = /* @__PURE__ */ new WeakMap();
29
20
  const compactPrefixAsync = /* @__PURE__ */ new WeakMap();
30
21
  const inferCompactPrefix = (prefix) => {
@@ -66,27 +57,13 @@ function compactPrefixForcesAsync(prefix) {
66
57
  const item = pending[i];
67
58
  for (let j = 0; !value && j < item.added.length; j++) {
68
59
  const fn = item.added[j];
69
- value = require_compile_utils.isAsyncFunction(fn) || !require_compile_utils.isAsyncFunction(fn) && (require_compile_utils.mayReturnPromise(fn) || mayReturnIdentifier(fn));
60
+ value = require_compile_utils.mayReturnPromise(fn);
70
61
  }
71
62
  compactPrefixAsync.set(item, value);
72
63
  }
73
64
  return value;
74
65
  }
75
- const isAsyncValidator = (vali) => vali?.isAsync ?? true;
76
- const mayReturnPromiseValidator = (vali) => vali?.mayReturnPromise === true;
77
- /**
78
- * Extracted from `buildNativeStaticResponse`'s for-in check so the native
79
- * static promotion predicate
80
- */
81
- function isEmptyPipelineHook(hook) {
82
- if (!hook) return true;
83
- for (const key in hook) {
84
- if (key === "detail" || key === "tags") continue;
85
- const value = hook[key];
86
- if (value !== void 0 && value !== false && (!Array.isArray(value) || value.length)) return false;
87
- }
88
- return true;
89
- }
66
+ const isAsyncValidator = (vali) => (vali?.isAsync ?? true) || vali?.mayReturnPromise === true;
90
67
  function describeRoute(input) {
91
68
  const { method, handler, root, adapter, hook, buildValidator, isHandleFunction, isStaticResponse, isPromiseHandler } = input;
92
69
  const vali = buildValidator();
@@ -100,14 +77,13 @@ function describeRoute(input) {
100
77
  const hasMergeBody = !!hook?.schemas?.some((s) => s?.body);
101
78
  const bodylessMethod = method === "GET" || method === "HEAD";
102
79
  const hasBody = !!hook?.body || hasMergeBody || !bodylessMethod && (parseLength > 0 || inference.body) && parseFirst !== "none";
103
- const bodyValiIsAsync = hasBody && (isAsyncValidator(vali?.body) || mayReturnPromiseValidator(vali?.body));
104
- const headersValiIsAsync = vali?.headers && (isAsyncValidator(vali?.headers) || mayReturnPromiseValidator(vali?.headers));
105
- const paramsValiIsAsync = vali?.params && (isAsyncValidator(vali?.params) || mayReturnPromiseValidator(vali?.params));
106
- const queryValiIsAsync = vali?.query && (isAsyncValidator(vali?.query) || mayReturnPromiseValidator(vali?.query));
107
- const cookieValidIsAsync = vali?.cookie && (isAsyncValidator(vali?.cookie) || mayReturnPromiseValidator(vali?.cookie));
108
- const appCookieConfig = require_generation.frozenRootOf(root)["~config"]?.cookie;
80
+ const bodyValiIsAsync = hasBody && isAsyncValidator(vali?.body);
81
+ const headersValiIsAsync = vali?.headers && isAsyncValidator(vali.headers);
82
+ const paramsValiIsAsync = vali?.params && isAsyncValidator(vali.params);
83
+ const queryValiIsAsync = vali?.query && isAsyncValidator(vali.query);
84
+ const cookieValidIsAsync = vali?.cookie && isAsyncValidator(vali.cookie);
109
85
  const needsCookie = !!vali?.cookie || !!inference.cookie;
110
- const cookieConfig = needsCookie ? require_cookie_config.compileCookieConfig(hook?.cookie, appCookieConfig) : void 0;
86
+ const cookieConfig = needsCookie ? require_compile_handler_reconstruct.Reconstrct.cookie(hook, root) : void 0;
111
87
  const hasCookieSign = !!cookieConfig?.hasSign;
112
88
  const syncCookieSign = hasCookieSign && require_cookie_crypto.hasSyncHmac && !require_compile_aot.Capture.isCapturing();
113
89
  const asyncCookieSign = hasCookieSign && !syncCookieSign;
@@ -131,19 +107,20 @@ function describeRoute(input) {
131
107
  const traceHandleOn = phaseOn("handle");
132
108
  let responseValiAsync = false;
133
109
  if (vali?.response) {
134
- for (const code in vali.response) if (isAsyncValidator(vali.response[code]) || mayReturnPromiseValidator(vali.response[code])) {
110
+ for (const code in vali.response) if (isAsyncValidator(vali.response[code])) {
135
111
  responseValiAsync = true;
136
112
  break;
137
113
  }
138
114
  }
139
115
  const handlerIsAsync = isHandleFunction && require_compile_utils.isAsyncFunction(handler);
140
- const errorHookForcesAsync = hasErrorHook && (hasAfterHandle || hasMapResponse || hasResponseValidator || require_compile_utils.isAsyncLifecycle(hook?.error) || lifecycleMayReturnPromise(hook?.error, false));
116
+ const errorHookForcesAsync = hasErrorHook && (hasAfterHandle || hasMapResponse || hasResponseValidator || require_compile_utils.isAsyncLifecycle(hook?.error) || lifecycleMayReturnPromise(hook?.error));
141
117
  const afterResponseForcesAsync = hasStaticAfterResponse && require_compile_utils.isAsyncLifecycle(hook?.afterResponse) || hasAfterResponse && (hasAfterHandle || hasMapResponse || hasResponseValidator || hasErrorHook);
142
- const traceForcesAsync = (traceHandleOn || phaseOn("error") || phaseOn("afterResponse")) && isHandleFunction && !handlerIsAsync && (require_compile_utils.mayReturnPromise(handler) || mayReturnIdentifier(handler));
143
- const handlerResultObserved = isHandleFunction && !handlerIsAsync && (hasResponseValidator || hasAfterHandle || hasMapResponse) && (require_compile_utils.mayReturnPromise(handler) || mayReturnIdentifier(handler));
144
- const lifecycleForcesAsync = !!hook && ((beforeHandlePrefix ? compactPrefixForcesAsync(beforeHandlePrefix) : false) || lifecycleMayReturnPromise(hook.beforeHandle, true) || lifecycleMayReturnPromise(hook.transform, false) || lifecycleMayReturnPromise(hook.afterHandle, true) || lifecycleMayReturnPromise(hook.mapResponse, true));
145
- const isAsync = hasBody || handlerIsAsync || errorHookForcesAsync || traceForcesAsync || afterResponseForcesAsync || handlerResultObserved || lifecycleForcesAsync || asyncCookieSign || responseValiAsync || 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) || bodyValiIsAsync || headersValiIsAsync || paramsValiIsAsync || queryValiIsAsync || cookieValidIsAsync);
118
+ const traceForcesAsync = (traceHandleOn || phaseOn("error") || phaseOn("afterResponse")) && isHandleFunction && !handlerIsAsync && require_compile_utils.mayReturnPromise(handler);
119
+ const handlerResultObserved = isHandleFunction && !handlerIsAsync && (hasResponseValidator || hasAfterHandle || hasMapResponse) && require_compile_utils.mayReturnPromise(handler);
120
+ 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 || cookieValidIsAsync;
146
122
  const callHandlerSyncOnAsync = isAsync && isHandleFunction && !handlerIsAsync;
123
+ const tail = isAsync && !(hasErrorHook && hasMapResponse) && !hasBody && !handlerIsAsync && !asyncCookieSign && !responseValiAsync && !hasTrace && !beforeHandlePrefix?.length && !bodyValiIsAsync && !headersValiIsAsync && !paramsValiIsAsync && !queryValiIsAsync && !cookieValidIsAsync && !(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)));
147
124
  const syncErrorHook = hasErrorHook && !isAsync && !hasTrace;
148
125
  const syncAfterResponse = hasAfterResponse && !isAsync && !hasTrace && !hasErrorHook;
149
126
  const handlerKind = isHandleFunction ? "function" : isStaticResponse ? "response" : isPromiseHandler ? "promise" : "static-value";
@@ -154,6 +131,7 @@ function describeRoute(input) {
154
131
  descriptor: {
155
132
  handlerKind,
156
133
  async: !!isAsync,
134
+ tail,
157
135
  responseMode,
158
136
  hasBeforeHandle,
159
137
  hasAfterHandle,
@@ -193,7 +171,4 @@ function describeRoute(input) {
193
171
 
194
172
  //#endregion
195
173
  exports.describeRoute = describeRoute;
196
- exports.isEmptyPipelineHook = isEmptyPipelineHook;
197
- exports.lifecycleMayReturnPromise = lifecycleMayReturnPromise;
198
- exports.mayReturnIdentifier = mayReturnIdentifier;
199
174
  exports.routeDescriptors = routeDescriptors;