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
@@ -2,31 +2,28 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_universal_constants = require('../../universal/constants.js');
3
3
  const require_universal_file = require('../../universal/file.js');
4
4
  const require_utils = require('../../utils.js');
5
+ const require_error = require('../../error.js');
6
+ const require_adapter_web_standard_handler = require('../../adapter/web-standard/handler.js');
5
7
  const require_compile_aot = require('../aot.js');
6
8
  const require_generation = require('../../generation.js');
9
+ const require_compile_utils = require('../utils.js');
10
+ const require_handler_utils = require('../../handler/utils.js');
11
+ const require_compile_handler_utils = require('./utils.js');
7
12
  const require_compile_handler_params = require('./params.js');
8
13
  const require_compile_handler_jit = require('./jit.js');
9
- const require_compile_handler_descriptor = require('./descriptor.js');
14
+ const require_compile_handler_frozen_validator = require('./frozen-validator.js');
10
15
  const require_compile_handler_reconstruct = require('./reconstruct.js');
16
+ const require_compile_handler_descriptor = require('./descriptor.js');
11
17
  const require_adapter_constants = require('../../adapter/constants.js');
12
18
 
13
19
  //#region src/compile/handler/index.ts
14
- function resolveMountHandler(meta, path) {
15
- const { handle, suffixLen } = meta;
16
- const rawRoot = suffixLen ? path.slice(0, path.length - suffixLen) : path;
17
- const encRoot = encodeURI(rawRoot);
18
- const rawLen = rawRoot.length;
19
- const encLen = encRoot.length;
20
- return (c) => handle(new Request(require_utils.replaceUrlPath(c.request.url, c.path.slice(c.path.startsWith(encRoot) ? encLen : rawLen) || "/"), c.request));
21
- }
22
- function applyHook(localHook, appHook, rootHook, appHookFresh = false) {
20
+ function applyHook(localHook, appHook, rootHook) {
23
21
  let hook;
24
22
  if (localHook && appHook) hook = require_utils.mergeHook(require_utils.cloneHook(localHook), appHook, true);
25
23
  else {
26
- const base = localHook ?? appHook;
27
- const ownsBase = appHookFresh && !localHook && base !== void 0;
28
- if (!rootHook) return ownsBase ? base : base ? require_utils.cloneHook(base) : base;
29
- hook = ownsBase ? base : base ? require_utils.cloneHook(base) : require_utils.nullObject();
24
+ const base = localHook ? require_utils.cloneHook(localHook) : appHook;
25
+ if (!rootHook) return base;
26
+ hook = base ?? require_utils.nullObject();
30
27
  }
31
28
  if (rootHook) require_utils.mergeHook(hook, rootHook, true, true);
32
29
  return hook;
@@ -78,21 +75,6 @@ function dropHooksByOrigin(hook, skip) {
78
75
  }
79
76
  return out;
80
77
  }
81
- function reconstructNeedsHookState(names) {
82
- for (let i = 0; i < names.length; i++) switch (names[i]) {
83
- case "ho":
84
- case "tf":
85
- case "bf":
86
- case "af":
87
- case "mr":
88
- case "er":
89
- case "ar":
90
- case "va":
91
- case "cc":
92
- case "tr": return true;
93
- }
94
- return false;
95
- }
96
78
  function promoteDerive(hook) {
97
79
  const derive = hook.derive;
98
80
  if (derive === void 0) return;
@@ -121,30 +103,33 @@ function memoScope(memos, root, scope) {
121
103
  }
122
104
  return perScope;
123
105
  }
106
+ function hasMacroKey(hook, scopeMacro, rootMacro) {
107
+ if (scopeMacro || rootMacro) {
108
+ for (const key in hook) if (scopeMacro && key in scopeMacro || rootMacro && key in rootMacro) return true;
109
+ }
110
+ return false;
111
+ }
112
+ function applyMacros(hook, scope, frozenRoot, scopeMacro, rootMacro) {
113
+ if (scopeMacro) {
114
+ require_generation.frozenRootOf(scope)["~applyMacro"](hook);
115
+ if (rootMacro) {
116
+ for (const k in hook) if (k in scopeMacro) delete hook[k];
117
+ }
118
+ }
119
+ if (rootMacro) frozenRoot["~applyMacro"](hook);
120
+ }
124
121
  const localHookMemos = /* @__PURE__ */ new WeakMap();
125
122
  function resolveLocalHook(scope, hook, root = scope) {
126
123
  if (!hook) return hook;
127
124
  const frozenRoot = require_generation.frozenRootOf(root);
128
125
  const scopeMacro = require_generation.frozenRootOf(scope)["~ext"]?.macro;
129
126
  const rootMacro = root === scope ? void 0 : frozenRoot["~ext"]?.macro;
130
- if (!scopeMacro && !rootMacro) return hook;
131
- let hasMacroKey = false;
132
- for (const key in hook) if (scopeMacro && key in scopeMacro || rootMacro && key in rootMacro) {
133
- hasMacroKey = true;
134
- break;
135
- }
136
- if (!hasMacroKey) return hook;
127
+ if (!hasMacroKey(hook, scopeMacro, rootMacro)) return hook;
137
128
  const perScope = memoScope(localHookMemos, root, scope);
138
129
  let resolved = perScope.get(hook);
139
130
  if (resolved === void 0) {
140
131
  resolved = require_utils.cloneHook(hook);
141
- if (scopeMacro) {
142
- require_generation.frozenRootOf(scope)["~applyMacro"](resolved);
143
- if (rootMacro) {
144
- for (const k in resolved) if (k in scopeMacro) delete resolved[k];
145
- }
146
- }
147
- if (rootMacro) frozenRoot["~applyMacro"](resolved);
132
+ applyMacros(resolved, scope, frozenRoot, scopeMacro, rootMacro);
148
133
  perScope.set(hook, resolved);
149
134
  }
150
135
  return resolved;
@@ -172,84 +157,110 @@ function resolveChainNode(root, node) {
172
157
  const frozenRoot = require_generation.frozenRootOf(root);
173
158
  const scopeMacro = require_generation.frozenRootOf(scope)["~ext"]?.macro;
174
159
  const rootMacro = root === scope ? void 0 : frozenRoot["~ext"]?.macro;
175
- let needsMacro = false;
176
- if (scopeMacro || rootMacro) {
177
- for (const key in added) if (scopeMacro && key in scopeMacro || rootMacro && key in rootMacro) {
178
- needsMacro = true;
179
- break;
180
- }
181
- }
160
+ const needsMacro = hasMacroKey(added, scopeMacro, rootMacro);
182
161
  if (!needsMacro && added.derive === void 0) return added;
183
162
  const perScope = memoScope(chainNodeMemos, root, scope);
184
163
  let resolved = perScope.get(added);
185
164
  if (resolved === void 0) {
186
165
  resolved = require_utils.cloneHook(added);
187
- if (needsMacro) {
188
- if (scopeMacro) {
189
- require_generation.frozenRootOf(scope)["~applyMacro"](resolved);
190
- if (rootMacro) {
191
- for (const k in resolved) if (k in scopeMacro) delete resolved[k];
192
- }
193
- }
194
- if (rootMacro) frozenRoot["~applyMacro"](resolved);
195
- }
166
+ if (needsMacro) applyMacros(resolved, scope, frozenRoot, scopeMacro, rootMacro);
196
167
  promoteDerive(resolved);
197
168
  perScope.set(added, resolved);
198
169
  }
199
170
  return resolved;
200
171
  }
201
- const chainResolver = (root) => {
172
+ function chainResolver(root) {
202
173
  const frozenRoot = require_generation.frozenRootOf(root);
203
174
  return frozenRoot["~ext"]?.macro || frozenRoot["~scopeChildren"] ? (node) => resolveChainNode(root, node) : void 0;
204
- };
175
+ }
205
176
  const localMacroRoot = (instance, root) => instance !== root && instance["~scopeChild"] === true && require_generation.frozenRootOf(instance)["~ext"]?.macro ? instance : root;
206
- function composeRootHook(root, inheritedChain) {
207
- const resolve = chainResolver(root);
208
- const locals = require_utils.flattenChain(require_generation.frozenRootOf(root)["~hookChain"], require_utils.isLocalScope, inheritedChain, resolve);
209
- const inherited = locals ? require_utils.flattenChainMemo(root, inheritedChain, resolve) : require_utils.flattenChainMemoReadonly(root, inheritedChain, resolve);
210
- if (!inherited) return locals;
211
- if (!locals) return inherited;
212
- return require_utils.mergeHook(inherited, locals);
177
+ /** Whether a hook can be skipped by a native static response. */
178
+ function isEmptyPipelineHook(hook) {
179
+ if (!hook) return true;
180
+ for (const key in hook) {
181
+ if (key === "detail" || key === "tags" || key === "error") continue;
182
+ const value = hook[key];
183
+ if (value !== void 0 && value !== false && (!Array.isArray(value) || value.length)) return false;
184
+ }
185
+ return true;
213
186
  }
214
- function buildNativeStaticResponse([, , handler, instance, localHook, appHook, inheritedChain, macroScope], root) {
187
+ function mapStaticValue(response, map, set, value) {
188
+ const mapped = map === require_adapter_web_standard_handler.mapResponse ? require_adapter_web_standard_handler.mapResponse(value, set, null) : Reflect.apply(map, response, [value, set]);
189
+ if (!(mapped instanceof Response)) return;
190
+ const body = value instanceof require_error.ElysiaStatus ? value.response : value;
191
+ if ((typeof body === "string" || typeof body === "number" || typeof body === "boolean") && !mapped.headers.has("content-type")) mapped.headers.set("content-type", "text/plain;charset=utf-8");
192
+ return mapped;
193
+ }
194
+ function afterUseHooks(node, resolve) {
195
+ let after;
196
+ while (node && "combine" in node) {
197
+ if (node.tail) {
198
+ const own = require_utils.flattenChain(node.tail, require_utils.isLocalScope, require_utils.rootSnapshot(node.combine), resolve);
199
+ if (own) after = after ? require_utils.mergeHook(own, after, false, true) : own;
200
+ }
201
+ node = node.combine;
202
+ }
203
+ return after;
204
+ }
205
+ function buildNativeStaticResponse(route, root) {
206
+ const [, , handler, instance, localHook, appHook, inheritedChain, macroScope] = route;
215
207
  if (typeof handler === "function" || handler instanceof Error || handler instanceof Promise) return;
216
208
  const frozenRoot = require_generation.frozenRootOf(root);
217
209
  const adapter = frozenRoot["~config"]?.adapter ?? require_adapter_constants.defaultAdapter;
218
- const hook = applyHook(resolveLocalHook(localMacroRoot(macroScope ?? instance, root), localHook, root), require_utils.flattenChainMemo(root, appHook, chainResolver(root)), instance !== root ? composeRootHook(root, inheritedChain) : void 0, true);
219
- if (hook && !require_compile_handler_descriptor.isEmptyPipelineHook(hook)) return;
210
+ const ownedHook = resolveLocalHook(localMacroRoot(macroScope ?? instance, root), localHook, root);
211
+ const resolve = chainResolver(root);
212
+ const flatAppHook = require_utils.flattenChainMemo(root, appHook, resolve);
213
+ let rootHook;
214
+ if (instance !== root) {
215
+ const locals = require_utils.flattenChain(require_generation.frozenRootOf(root)["~hookChain"], require_utils.isLocalScope, require_utils.rootSnapshot(inheritedChain), resolve);
216
+ const inherited = locals ? require_utils.flattenChainMemo(root, inheritedChain, resolve) : require_utils.flattenChainMemoReadonly(root, inheritedChain, resolve);
217
+ if (!inherited) rootHook = locals;
218
+ else if (!locals) rootHook = inherited;
219
+ else rootHook = require_utils.mergeHook(inherited, locals);
220
+ const after = afterUseHooks(inheritedChain, resolve);
221
+ if (after) rootHook = rootHook ? require_utils.mergeHook(after, rootHook) : after;
222
+ }
223
+ const hook = applyHook(ownedHook, flatAppHook, rootHook);
224
+ if (hook && !isEmptyPipelineHook(hook)) return;
225
+ if (require_handler_utils.returnedErrorClasses(hook, root)?.some((C) => handler instanceof C)) return;
220
226
  const rootHeaders = frozenRoot["~ext"]?.headers;
221
227
  if (handler instanceof Response && !rootHeaders) return handler;
222
- const mapped = adapter.response.map(handler, { headers: rootHeaders ? Object.assign(require_utils.nullObject(), rootHeaders) : require_utils.nullObject() });
223
- if (mapped instanceof Response) {
224
- if (!mapped.headers.has("content-type") && (typeof handler === "string" || typeof handler === "number" || typeof handler === "boolean")) mapped.headers.set("content-type", "text/plain;charset=utf-8");
225
- return mapped;
226
- }
228
+ const response = adapter.response;
229
+ const map = response.map;
230
+ return mapStaticValue(response, map, { headers: rootHeaders ? Object.assign(require_utils.nullObject(), rootHeaders) : require_utils.nullObject() }, handler);
227
231
  }
228
232
  function toArray(name, hook) {
229
233
  if (typeof hook[name] === "function") hook[name] = [hook[name]];
230
234
  }
231
- function composeRouteHook(instance, localHook, appHook, inheritedChain, root, macroScope) {
235
+ function composeRouteHook(instance, localHook, appHook, inheritedChain, root, macroScope, allowCompactPrefix = false) {
232
236
  const resolve = chainResolver(root);
233
237
  localHook = resolveLocalHook(localMacroRoot(macroScope ?? instance, root), localHook, root);
238
+ if (localHook && localHook.derive !== void 0) {
239
+ localHook = require_utils.cloneHook(localHook);
240
+ promoteDerive(localHook);
241
+ }
234
242
  const flatAppHook = appHook ? require_utils.flattenChainMemo(root, appHook, resolve) : void 0;
235
- let locals = instance !== root ? require_utils.flattenChain(require_generation.frozenRootOf(root)["~hookChain"], require_utils.isLocalScope, inheritedChain, resolve) : void 0;
243
+ let locals = instance !== root ? require_utils.flattenChain(require_generation.frozenRootOf(root)["~hookChain"], require_utils.isLocalScope, require_utils.rootSnapshot(inheritedChain), resolve) : void 0;
236
244
  const instanceLocal = instance !== root ? require_utils.flattenChain(instance["~hookChain"], require_utils.isLocalScope) : void 0;
237
- const compactPrefix = instance !== root && !require_compile_aot.Capture.isCapturing() && !require_compile_aot.Capture.isAotBuildEnv() && resolve === void 0 && require_utils.isCompactBeforeHandleOnly(localHook) && require_utils.isCompactBeforeHandleOnly(flatAppHook) && require_utils.isCompactBeforeHandleOnly(locals) && !instanceLocal?.error ? require_utils.compactBeforeHandlePrefix(inheritedChain) : void 0;
245
+ const compactPrefix = allowCompactPrefix && instance !== root && !require_compile_aot.Capture.isCapturing() && !require_compile_aot.Capture.isAotBuildEnv() && resolve === void 0 && require_utils.isCompactBeforeHandleOnly(localHook) && require_utils.isCompactBeforeHandleOnly(flatAppHook) && require_utils.isCompactBeforeHandleOnly(locals) && !instanceLocal?.error ? require_utils.compactBeforeHandlePrefix(inheritedChain) : void 0;
238
246
  let present = collectHookOrigins(localHook, void 0);
239
247
  present = collectHookOrigins(flatAppHook, present);
240
248
  if (compactPrefix && !present?.size && !require_utils.compactBeforeHandleConflicts(localHook) && !require_utils.compactBeforeHandleConflicts(flatAppHook) && !require_utils.compactBeforeHandleConflicts(locals)) {
241
- let hook = applyHook(localHook, flatAppHook, void 0, true);
249
+ let hook = applyHook(localHook, flatAppHook, void 0);
242
250
  if (locals) hook = hook ? require_utils.mergeHook(hook, locals, false, true) : locals;
243
251
  hook ??= require_utils.nullObject();
244
252
  hook["~beforeHandlePrefix"] = compactPrefix;
245
253
  return hook;
246
254
  }
247
255
  let inherited = instance !== root ? require_utils.flattenChainMemoReadonly(root, inheritedChain, resolve) : void 0;
248
- if ((inherited || locals) && (flatAppHook || localHook) && present?.size) {
256
+ let after = instance !== root ? afterUseHooks(inheritedChain, resolve) : void 0;
257
+ if ((inherited || after || locals) && (flatAppHook || localHook) && present?.size) {
249
258
  if (inherited) inherited = dropHooksByOrigin(inherited, present);
259
+ if (after) after = dropHooksByOrigin(after, present);
250
260
  if (locals) locals = dropHooksByOrigin(locals, present);
251
261
  }
252
- let hook = applyHook(localHook, flatAppHook, inherited ? require_utils.cloneHook(inherited) : void 0, true);
262
+ let hook = applyHook(localHook, flatAppHook, inherited ? require_utils.cloneHook(inherited) : void 0);
263
+ if (after) hook = hook ? require_utils.mergeHook(hook, after, false, true) : after;
253
264
  if (locals) hook = hook ? require_utils.mergeHook(hook, locals, false, true) : locals;
254
265
  if (instance !== root) {
255
266
  const errors = instanceLocal?.error;
@@ -266,30 +277,148 @@ function composeRouteHook(instance, localHook, appHook, inheritedChain, root, ma
266
277
  }
267
278
  return hook;
268
279
  }
280
+ const shapeEvents = [
281
+ "parse",
282
+ "transform",
283
+ "beforeHandle",
284
+ "afterHandle",
285
+ "mapResponse",
286
+ "afterResponse",
287
+ "error",
288
+ "trace"
289
+ ];
290
+ const shapeSlots = [
291
+ "body",
292
+ "headers",
293
+ "params",
294
+ "query",
295
+ "cookie",
296
+ "response"
297
+ ];
298
+ const isCookieAt = (at) => at === "cookie" || at === "field";
299
+ function childAt(at, k, value, deferred) {
300
+ if (at.endsWith("*")) return at.slice(0, -1);
301
+ if (at.endsWith("^")) return k === "0" ? at.slice(0, -1) + (Array.isArray(value) ? "*" : "") : "";
302
+ if (!isCookieAt(at)) return "";
303
+ switch (k) {
304
+ case "$ref": return at;
305
+ case "properties": return at === "cookie" ? "field*" : "";
306
+ case "parameters": return deferred ? at + "^" : "";
307
+ }
308
+ return k === "$defs" || require_utils.compositionKeys.includes(k) ? at + "*" : "";
309
+ }
310
+ function routeShape(hook, handler, root) {
311
+ const frozenRoot = require_generation.frozenRootOf(root);
312
+ const config = frozenRoot["~config"];
313
+ const models = frozenRoot["~ext"]?.models;
314
+ const refs = /* @__PURE__ */ new Map();
315
+ const addRef = (name, at = "") => {
316
+ if (!isCookieAt(at)) at = "";
317
+ if (at === "cookie" || !refs.get(name)) refs.set(name, at);
318
+ };
319
+ const ids = /* @__PURE__ */ new Map();
320
+ const visiting = /* @__PURE__ */ new Set();
321
+ let unsupported = false;
322
+ for (const _ in []) return;
323
+ const shape = (v, at = "") => {
324
+ switch (typeof v) {
325
+ case "string": return JSON.stringify(v);
326
+ case "number": return "n" + (Object.is(v, -0) ? "-0" : v);
327
+ case "bigint": return "b" + v;
328
+ case "boolean": return v ? "T" : "F";
329
+ case "undefined": return "U";
330
+ case "function":
331
+ if (ids.has(v)) return "#" + ids.get(v);
332
+ ids.set(v, ids.size);
333
+ return require_compile_utils.isAsyncFunction(v) ? "fa" : "fs";
334
+ case "symbol":
335
+ unsupported = true;
336
+ return "";
337
+ }
338
+ if (v === null) return "N";
339
+ if ("~standard" in v) return "S";
340
+ if (visiting.has(v)) {
341
+ unsupported = true;
342
+ return "";
343
+ }
344
+ let tag = "";
345
+ const list = Array.isArray(v);
346
+ const proto = Object.getPrototypeOf(v);
347
+ if (list ? proto !== Array.prototype : proto !== null && proto !== Object.prototype) {
348
+ const kind = proto && Object.getOwnPropertyDescriptor(proto, "~kind");
349
+ if (!kind || !("value" in kind) || Reflect.ownKeys(proto).length !== 1 || Object.getPrototypeOf(proto) !== Object.prototype) {
350
+ unsupported = true;
351
+ return "";
352
+ }
353
+ tag = shape(kind.value);
354
+ }
355
+ visiting.add(v);
356
+ const map = at === "response" && require_compile_handler_frozen_validator.isResponseMap(v);
357
+ const deferred = v["~kind"] === "Deferred";
358
+ let s = (list ? "[" : "{") + tag;
359
+ for (const k of Reflect.ownKeys(v)) {
360
+ const d = Object.getOwnPropertyDescriptor(v, k);
361
+ if (typeof k === "symbol" || !("value" in d)) {
362
+ unsupported = true;
363
+ break;
364
+ }
365
+ const value = d.value;
366
+ if (k === "$ref" && typeof value === "string") addRef(value, at);
367
+ s += "," + (d.enumerable ? "" : "!") + JSON.stringify(k) + ":";
368
+ if (map) s += named(value);
369
+ else if (k === "config" && isCookieAt(at)) s += shape([value?.sign, !!value?.secrets]);
370
+ else if (k === "secrets" && (typeof value === "string" || Array.isArray(value))) s += shape(!!value);
371
+ else s += shape(value, childAt(at, k, value, deferred));
372
+ }
373
+ visiting.delete(v);
374
+ return s + (list ? "]" : "}");
375
+ };
376
+ const named = (v, at) => {
377
+ if (typeof v === "string") addRef(v, at);
378
+ return shape(v, at);
379
+ };
380
+ let s = typeof handler === "function" || handler == null ? shape(handler) : handler instanceof Response ? "R" : handler instanceof Promise ? "P" : typeof handler === "object" ? "O" : "V";
381
+ for (const event of shapeEvents) {
382
+ s += "|";
383
+ const fns = hook?.[event];
384
+ if (fns) for (const fn of Array.isArray(fns) ? fns : [fns]) s += shape(fn);
385
+ }
386
+ const bf = hook?.beforeHandle;
387
+ s += "|" + JSON.stringify(bf && require_compile_handler_utils.deriveModes(Array.isArray(bf) ? bf : [bf], hook["~deriveEntries"]));
388
+ for (const from of [hook, ...hook?.schemas || []]) for (const slot of shapeSlots) s += "|" + named(from?.[slot], slot);
389
+ let targets;
390
+ for (const [ref, at] of refs) for (const target of at ? (targets ??= require_utils.refTargets([], models))(ref) : [models?.[ref]]) s += "|" + JSON.stringify(ref) + shape(target, at);
391
+ s += "|" + JSON.stringify([
392
+ config?.cookie?.sign,
393
+ config?.cookie?.verify,
394
+ config?.normalize,
395
+ !!config?.allowUnsafeValidationDetails,
396
+ config?.abortSignal !== false,
397
+ require_utils.isNotEmpty(frozenRoot["~ext"]?.headers),
398
+ !!(config?.adapter ?? require_adapter_constants.defaultAdapter).response.supportsDefaultHeaderSink,
399
+ !!require_handler_utils.returnedErrorClasses(hook, root)
400
+ ]) + shape(config?.sanitize);
401
+ return unsupported ? void 0 : require_utils.fnv1a(s);
402
+ }
269
403
  const isBareArrow = /^(?:async\s*)?\(\s*\)\s*=>/;
270
404
  const isSucroseOpaque = /arguments|eval|\[native code\]/;
271
- function isContextFreeHandler(handler) {
272
- if (Object.hasOwn(handler, "toString")) return false;
273
- const source = Function.prototype.toString.call(handler);
274
- return isBareArrow.test(source) && !isSucroseOpaque.test(source);
275
- }
276
- function compileHandler([_method, path, handler, instance, localHook, appHook, inheritedChain, macroScope], root, precomputedStatic) {
405
+ function compileHandler(route, root, liveOnly = false) {
406
+ let [_method, path, handler, instance, localHook, appHook, inheritedChain, macroScope] = route;
277
407
  const frozenRoot = require_generation.frozenRootOf(root);
278
408
  const adapter = frozenRoot["~config"]?.adapter ?? require_adapter_constants.defaultAdapter;
279
409
  const method = _method;
280
410
  const mountMeta = typeof handler === "function" ? handler["~mount"] : void 0;
281
- if (mountMeta) handler = resolveMountHandler(mountMeta, path);
282
- const reconstructed = require_compile_aot.Compiled.getHandler(frozenRoot["~programId"], method, path);
283
- if (reconstructed && !precomputedStatic && typeof handler === "function" && !frozenRoot["~ext"]?.macro && !require_generation.frozenRootOf(localMacroRoot(macroScope ?? instance, root))["~ext"]?.macro && !reconstructNeedsHookState(reconstructed.a)) return reconstructed.f(handler, ...require_compile_handler_params.resolveHandlerParams(reconstructed.a, {
284
- root,
285
- parse: adapter.parse,
286
- res: adapter.response,
287
- hook: require_utils.nullObject(),
288
- vali: void 0,
289
- cookieConfig: void 0,
290
- tracers: void 0
291
- }));
292
- const hook = composeRouteHook(instance, localHook, appHook, inheritedChain, root, macroScope);
411
+ if (mountMeta) {
412
+ const { handle, suffixLen } = mountMeta;
413
+ const rawRoot = suffixLen ? path.slice(0, path.length - suffixLen) : path;
414
+ const encRoot = encodeURI(rawRoot);
415
+ const rawLen = rawRoot.length;
416
+ const encLen = encRoot.length;
417
+ handler = (c) => handle(new Request(require_utils.replaceUrlPath(c.request.url, c.path.slice(c.path.startsWith(encRoot) ? encLen : rawLen) || "/"), c.request));
418
+ }
419
+ const reconstructed = liveOnly ? void 0 : require_compile_aot.Compiled.getHandler(frozenRoot["~programId"], method, path);
420
+ if (!reconstructed) liveOnly ||= require_compile_aot.Compiled.hasProgram(frozenRoot["~programId"]);
421
+ const hook = composeRouteHook(instance, localHook, appHook, inheritedChain, root, macroScope, !reconstructed);
293
422
  if (hook) {
294
423
  promoteDerive(hook);
295
424
  toArray("parse", hook);
@@ -300,20 +429,24 @@ function compileHandler([_method, path, handler, instance, localHook, appHook, i
300
429
  toArray("afterResponse", hook);
301
430
  toArray("error", hook);
302
431
  }
303
- const buildValidator = () => hook ? require_compile_handler_reconstruct.Reconstrct.validator(hook, root, method, path) : void 0;
304
- if (handler instanceof Error) {
432
+ const buildValidator = () => hook ? require_compile_handler_reconstruct.Reconstrct.validator(hook, root, method, path, liveOnly) : void 0;
433
+ const errorClasses = require_handler_utils.returnedErrorClasses(hook, root);
434
+ if (handler instanceof Error || typeof handler !== "function" && errorClasses?.some((C) => handler instanceof C)) {
305
435
  const error = handler;
306
436
  handler = () => {
307
437
  throw error;
308
438
  };
309
- }
439
+ } else if (require_utils.isHTMLBundle(handler)) handler = () => {
440
+ throw new Error(`[Elysia] ${method} ${path} is an HTML bundle, only Bun's native router serves it`);
441
+ };
442
+ const declaresResponse = !!hook && (hook.response != null || !!hook.schemas?.some((schema) => schema?.response));
310
443
  const isHandleFunction = typeof handler === "function";
311
- if (precomputedStatic) handler = precomputedStatic;
312
- else if (!isHandleFunction && !(handler instanceof Promise) && !(!require_universal_constants.isBun && handler instanceof require_universal_file.ElysiaFile)) {
444
+ if (!isHandleFunction && !(handler instanceof Promise) && !(!require_universal_constants.isBun && handler instanceof require_universal_file.ElysiaFile) && !declaresResponse) {
313
445
  const rootHeaders = frozenRoot["~ext"]?.headers;
314
446
  const set = { headers: rootHeaders ? Object.assign(require_utils.nullObject(), rootHeaders) : require_utils.nullObject() };
315
- const mapped = adapter.response.map(handler, set);
316
- if (mapped instanceof Response) handler = mapped;
447
+ const response = adapter.response;
448
+ const mapped = mapStaticValue(response, response.map, set, handler);
449
+ if (mapped) handler = mapped;
317
450
  }
318
451
  const isStaticResponse = !isHandleFunction && handler instanceof Response;
319
452
  const isPromiseHandler = !isHandleFunction && handler instanceof Promise;
@@ -322,6 +455,20 @@ function compileHandler([_method, path, handler, instance, localHook, appHook, i
322
455
  const resolve = (p) => typeof p === "string" && p in namedParsers ? namedParsers[p] : p;
323
456
  hook.parse = Array.isArray(hook.parse) ? hook.parse.map(resolve) : resolve(hook.parse);
324
457
  }
458
+ let shape;
459
+ if (reconstructed || require_compile_aot.Capture.isCapturing()) {
460
+ shape = routeShape(hook, handler, root);
461
+ if (reconstructed && (!shape || reconstructed.k !== shape)) {
462
+ let live;
463
+ try {
464
+ live = compileHandler(route, root, true);
465
+ } catch (cause) {
466
+ throw new Error(require_compile_aot.aotDrift(method, path), { cause });
467
+ }
468
+ require_compile_aot.warnAotDrift(method, path);
469
+ return live;
470
+ }
471
+ }
325
472
  if (reconstructed) return reconstructed.f(handler, ...require_compile_handler_params.resolveHandlerParams(reconstructed.a, {
326
473
  root,
327
474
  parse: adapter.parse,
@@ -331,10 +478,19 @@ function compileHandler([_method, path, handler, instance, localHook, appHook, i
331
478
  cookieConfig: reconstructed.a.includes("cc") ? require_compile_handler_reconstruct.Reconstrct.cookie(hook, root) : void 0,
332
479
  tracers: reconstructed.a.includes("tr") ? require_compile_handler_reconstruct.Reconstrct.trace(hook, root) : void 0
333
480
  }));
334
- if (hook === void 0 && isHandleFunction && !precomputedStatic && !mountMeta && (method === "GET" || method === "HEAD") && !root["~hasTrace"] && root["~introspect"] !== true && root["~config"]?.introspect !== true && !require_utils.isNotEmpty(frozenRoot["~ext"]?.headers) && !require_compile_aot.Capture.isAotBuildEnv() && !require_compile_aot.Capture.isCapturing() && isContextFreeHandler(handler)) return require_compile_handler_jit.createInlineHandler(adapter.response.compact ?? adapter.response.map, handler);
481
+ if (hook === void 0 && !errorClasses && isHandleFunction && !mountMeta && (method === "GET" || method === "HEAD") && !root["~hasTrace"] && root["~introspect"] !== true && root["~config"]?.introspect !== true && !require_utils.isNotEmpty(frozenRoot["~ext"]?.headers) && !require_compile_aot.Capture.isAotBuildEnv() && !require_compile_aot.Capture.isCapturing()) {
482
+ let isContextFree = false;
483
+ if (!Object.hasOwn(handler, "toString")) {
484
+ const source = Function.prototype.toString.call(handler);
485
+ isContextFree = isBareArrow.test(source) && !isSucroseOpaque.test(source);
486
+ }
487
+ if (isContextFree) {
488
+ const compact = adapter.response.compact;
489
+ if (compact) return require_compile_handler_jit.createInlineHandler(compact, handler);
490
+ }
491
+ }
335
492
  const state = require_compile_handler_descriptor.describeRoute({
336
493
  method,
337
- path,
338
494
  handler,
339
495
  root,
340
496
  adapter,
@@ -356,7 +512,6 @@ function compileHandler([_method, path, handler, instance, localHook, appHook, i
356
512
  method,
357
513
  path,
358
514
  handler,
359
- instance,
360
515
  root: frozenRoot,
361
516
  errorRoot: root,
362
517
  hook,
@@ -364,16 +519,20 @@ function compileHandler([_method, path, handler, instance, localHook, appHook, i
364
519
  isHandleFunction,
365
520
  isStaticResponse,
366
521
  isPromiseHandler,
367
- state
522
+ errorClasses,
523
+ state,
524
+ shape
368
525
  });
369
526
  }
370
527
 
371
528
  //#endregion
372
529
  exports.buildNativeStaticResponse = buildNativeStaticResponse;
530
+ exports.chainResolver = chainResolver;
373
531
  exports.clearHandlerAnalysisCaches = clearHandlerAnalysisCaches;
374
532
  exports.compileHandler = compileHandler;
375
533
  exports.composeRouteHook = composeRouteHook;
376
534
  exports.localMacroRoot = localMacroRoot;
377
535
  exports.resolveLocalHook = resolveLocalHook;
378
536
  exports.resolveWSLocalHook = resolveWSLocalHook;
537
+ exports.routeShape = routeShape;
379
538
  exports.setCaptureHeaderShorthand = require_compile_handler_jit.setCaptureHeaderShorthand;