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
package/dist/index.d.ts CHANGED
@@ -1,23 +1,23 @@
1
1
  import { BaseCookie, CookieOptions } from "./cookie/types.js";
2
- import { Cookie } from "./cookie/cookie.js";
3
- import { ElysiaFile, file } from "./universal/file.js";
4
- import { StatusMap, StatusMapBack } from "./constants.js";
5
- import { env } from "./universal/env.js";
6
- import { Server } from "./universal/server.js";
7
- import { bytes, form, prefix, redirect, sse } from "./utils.js";
8
- import { HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, RouteSchema, SSEPayload, UnwrapRoute, UnwrapSchema } from "./types.js";
9
- import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, ParseError, Problem, SelectiveStatus, TaggedHTTPError, ValidationError, problem, status, validationDetail } from "./error.js";
10
- import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
11
- import { InvalidCookie } from "./cookie/error.js";
12
2
  import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
13
3
  import { TCookieField, TCookieObject } from "./type/elysia/cookie.js";
14
- import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
15
4
  import { TFiles } from "./type/elysia/files.js";
5
+ import { StatusMap, StatusMapBack } from "./constants.js";
6
+ import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, NumericStatus, ParseError, Problem, SelectiveProblem, SelectiveStatus, StatusResponse, TaggedHTTPError, ValidationError, ValidationErrorResponse, problem, status, validationDetail } from "./error.js";
7
+ import { bytes, form, prefix, redirect, sse } from "./utils.js";
8
+ import { Server } from "./universal/server.js";
9
+ import { Cookie } from "./cookie/cookie.js";
10
+ import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
11
+ import { ElysiaFile, file } from "./universal/file.js";
12
+ import { env } from "./universal/env.js";
13
+ import { DefaultEphemeral, DefaultMetadata, DefaultSingleton, HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, MacroTypeLambda, RouteSchema, SSEPayload, UnwrapModels, UnwrapRoute, UnwrapSchema } from "./types.js";
16
14
  import { setupTypebox } from "./type/compat.js";
15
+ import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
17
16
  import { MultiValidator, StandardValidator, Validator } from "./validator/index.js";
18
17
  import { TypeBoxValidator } from "./type/validator/index.js";
19
18
  import { TypeSystem, t } from "./type/index.js";
20
19
  import { AotFingerprint, Capture, Compiled, CompilerSession, ProgramId } from "./compile/aot.js";
21
20
  import { AnyElysia, Elysia } from "./base.js";
22
21
  import { borrow } from "./adapter/response-ownership.js";
23
- export { AnyElysia, type AnySchema, type AotFingerprint, type BaseCookie, type BaseSchema, Compiled, type CompilerSession, type Context, type Cookie, type CookieOptions, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, HTTPError, type HTTPHeaders, type InputSchema, InternalServerError, InvalidCookie, type Macro, type MacroToContext, type MacroToProperty, Capture as Manifest, MultiValidator, NotFound, ParseError, type Problem, type ProgramId, type RouteSchema, type SSEPayload, type SelectiveStatus, type Server, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type TCookieField, type TCookieObject, type TFiles, type TaggedHTTPError, TypeBoxValidator, TypeSystem, type UnwrapRoute, type UnwrapSchema, ValidationError, Validator, borrow, bytes, createBaseContext, createContext, env, file, fileType, form, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
22
+ import { InvalidCookie } from "./cookie/error.js";
23
+ export { AnyElysia, type AnySchema, type AotFingerprint, type BaseCookie, type BaseSchema, Compiled, type CompilerSession, type Context, type Cookie, type CookieOptions, type DefaultEphemeral, type DefaultMetadata, type DefaultSingleton, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, HTTPError, type HTTPHeaders, type InputSchema, InternalServerError, InvalidCookie, type Macro, type MacroToContext, type MacroToProperty, type MacroTypeLambda, Capture as Manifest, MultiValidator, NotFound, type NumericStatus, ParseError, type Problem, type ProgramId, type RouteSchema, type SSEPayload, type SelectiveProblem, type SelectiveStatus, type Server, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type StatusResponse, type TCookieField, type TCookieObject, type TFiles, type TaggedHTTPError, TypeBoxValidator, TypeSystem, type UnwrapModels, type UnwrapRoute, type UnwrapSchema, ValidationError, type ValidationErrorResponse, Validator, borrow, bytes, createBaseContext, createContext, env, file, fileType, form, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.js');
3
2
  const require_constants = require('./constants.js');
4
3
  const require_universal_file = require('./universal/file.js');
5
4
  const require_utils = require('./utils.js');
@@ -8,14 +7,13 @@ const require_error = require('./error.js');
8
7
  const require_cookie_error = require('./cookie/error.js');
9
8
  const require_adapter_response_ownership = require('./adapter/response-ownership.js');
10
9
  const require_compile_aot = require('./compile/aot.js');
11
- const require_type_elysia_file_type = require('./type/elysia/file-type.js');
12
10
  const require_validator_index = require('./validator/index.js');
13
11
  const require_context = require('./context.js');
14
12
  const require_base = require('./base.js');
13
+ const require_type_elysia_file_type = require('./type/elysia/file-type.js');
15
14
  const require_type_validator_index = require('./type/validator/index.js');
16
15
  const require_type_compat = require('./type/compat.js');
17
16
  const require_type_index = require('./type/index.js');
18
- let typebox_system = require("typebox/system");
19
17
 
20
18
  //#region src/index.ts
21
19
  var src_default = require_base.Elysia;
@@ -37,12 +35,7 @@ exports.StandardValidator = require_validator_index.StandardValidator;
37
35
  exports.StatusMap = require_constants.StatusMap;
38
36
  exports.StatusMapBack = require_constants.StatusMapBack;
39
37
  exports.TypeBoxValidator = require_type_validator_index.TypeBoxValidator;
40
- Object.defineProperty(exports, 'TypeSystem', {
41
- enumerable: true,
42
- get: function () {
43
- return typebox_system.System;
44
- }
45
- });
38
+ exports.TypeSystem = require_type_index.TypeSystem;
46
39
  exports.ValidationError = require_error.ValidationError;
47
40
  exports.Validator = require_validator_index.Validator;
48
41
  exports.borrow = require_adapter_response_ownership.borrow;
package/dist/index.mjs CHANGED
@@ -6,10 +6,10 @@ import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, Pa
6
6
  import { InvalidCookie } from "./cookie/error.mjs";
7
7
  import { borrow } from "./adapter/response-ownership.mjs";
8
8
  import { Capture, Compiled } from "./compile/aot.mjs";
9
- import { fileType, setFileTypeDetector } from "./type/elysia/file-type.mjs";
10
9
  import { MultiValidator, StandardValidator, Validator } from "./validator/index.mjs";
11
10
  import { createBaseContext, createContext } from "./context.mjs";
12
11
  import { Elysia } from "./base.mjs";
12
+ import { fileType, setFileTypeDetector } from "./type/elysia/file-type.mjs";
13
13
  import { TypeBoxValidator } from "./type/validator/index.mjs";
14
14
  import { setupTypebox } from "./type/compat.mjs";
15
15
  import { TypeSystem, t } from "./type/index.mjs";
package/dist/memory.js CHANGED
@@ -6,7 +6,7 @@ const require_context = require('./context.js');
6
6
 
7
7
  //#region src/memory.ts
8
8
  function flushMemory() {
9
- require_sucrose.clearSucroseCache(0);
9
+ require_sucrose.clearSucroseCache();
10
10
  require_context.clearContextCache();
11
11
  require_validator_index.Validator.clear();
12
12
  if (require_universal_constants.isBun) Bun.gc();
package/dist/memory.mjs CHANGED
@@ -5,7 +5,7 @@ import { clearContextCache } from "./context.mjs";
5
5
 
6
6
  //#region src/memory.ts
7
7
  function flushMemory() {
8
- clearSucroseCache(0);
8
+ clearSucroseCache();
9
9
  clearContextCache();
10
10
  Validator.clear();
11
11
  if (isBun) Bun.gc();
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.0.0-beta.2";
3
+ var version = "2.0.0-beta.21";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2.0.0-beta.2";
2
+ var version = "2.0.0-beta.21";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -20,7 +20,14 @@ import { BunPlugin } from "bun";
20
20
  *
21
21
  * process.exit(0)
22
22
  * ```
23
+ *
24
+ * Skip precompilation and only wire TypeBox statically for a faster plain bundle.
25
+ * `TypeSystem.Locale` stays opt-in, as in a plain bundle.
26
+ *
27
+ * ```ts
28
+ * plugins: [aot()]
29
+ * ```
23
30
  */
24
- declare const aot: (entry: string, options?: ElysiaAotOptions) => BunPlugin;
31
+ declare const aot: (entry?: string, options?: ElysiaAotOptions) => BunPlugin;
25
32
  //#endregion
26
33
  export { aot };
@@ -20,16 +20,23 @@ const require_plugin_aot_hooks = require('./hooks.js');
20
20
  *
21
21
  * process.exit(0)
22
22
  * ```
23
+ *
24
+ * Skip precompilation and only wire TypeBox statically for a faster plain bundle.
25
+ * `TypeSystem.Locale` stays opt-in, as in a plain bundle.
26
+ *
27
+ * ```ts
28
+ * plugins: [aot()]
29
+ * ```
23
30
  */
24
- const aot = (entry, options) => ({
25
- name: "elysia-aot",
26
- async setup(build) {
27
- await require_plugin_aot_hooks.setupAotOnLoad(build, require_plugin_aot_hooks.createAotPluginHooks(entry, options), {
28
- readText: (path) => Bun.file(path).text(),
29
- resolveDir: void 0
30
- });
31
- }
32
- });
31
+ const aot = (entry, options) => {
32
+ if (entry === void 0 && options !== void 0) throw new Error("[elysia-aot] options require an entry");
33
+ return {
34
+ name: "elysia-aot",
35
+ async setup(build) {
36
+ await require_plugin_aot_hooks.setupAotOnLoad(build, entry === void 0 ? require_plugin_aot_hooks.createTypeboxWiringHooks() : require_plugin_aot_hooks.createAotPluginHooks(entry, options), (path) => Bun.file(path).text());
37
+ }
38
+ };
39
+ };
33
40
 
34
41
  //#endregion
35
42
  exports.aot = aot;
@@ -1,4 +1,4 @@
1
- import { createAotPluginHooks, setupAotOnLoad } from "./hooks.mjs";
1
+ import { createAotPluginHooks, createTypeboxWiringHooks, setupAotOnLoad } from "./hooks.mjs";
2
2
 
3
3
  //#region src/plugin/aot/bun.ts
4
4
  /**
@@ -19,16 +19,23 @@ import { createAotPluginHooks, setupAotOnLoad } from "./hooks.mjs";
19
19
  *
20
20
  * process.exit(0)
21
21
  * ```
22
+ *
23
+ * Skip precompilation and only wire TypeBox statically for a faster plain bundle.
24
+ * `TypeSystem.Locale` stays opt-in, as in a plain bundle.
25
+ *
26
+ * ```ts
27
+ * plugins: [aot()]
28
+ * ```
22
29
  */
23
- const aot = (entry, options) => ({
24
- name: "elysia-aot",
25
- async setup(build) {
26
- await setupAotOnLoad(build, createAotPluginHooks(entry, options), {
27
- readText: (path) => Bun.file(path).text(),
28
- resolveDir: void 0
29
- });
30
- }
31
- });
30
+ const aot = (entry, options) => {
31
+ if (entry === void 0 && options !== void 0) throw new Error("[elysia-aot] options require an entry");
32
+ return {
33
+ name: "elysia-aot",
34
+ async setup(build) {
35
+ await setupAotOnLoad(build, entry === void 0 ? createTypeboxWiringHooks() : createAotPluginHooks(entry, options), (path) => Bun.file(path).text());
36
+ }
37
+ };
38
+ };
32
39
 
33
40
  //#endregion
34
41
  export { aot };
@@ -1,7 +1,13 @@
1
+ import { CapturedValidator } from "../../compile/aot.js";
1
2
  import { JITProbeResult } from "../../compile/jit-probe.js";
2
- import { AotTarget } from "./source.js";
3
+ import { AotModuleCondition, AotTarget } from "./source.js";
3
4
 
4
5
  //#region src/plugin/aot/core.d.ts
6
+ /**
7
+ * A route that differs from the build compiles live with a warning, or fails
8
+ * when the JIT is stripped. A conditional hook must change the hook list
9
+ * (`isProd ? [auth] : []`), not swap functions. Keep `async` native
10
+ */
5
11
  interface ElysiaAotOptions {
6
12
  /**
7
13
  * Specifier the generated module imports `Compiled` from
@@ -93,10 +99,14 @@ interface ElysiaAotOptions {
93
99
  verbose?: boolean;
94
100
  }
95
101
  declare const resolveEntry: (entry: string) => string;
102
+ /** @internal Resolve the package condition used to evaluate an AOT entry. */
103
+ declare const resolveEntryModuleKind: (entry: string) => "esm" | "cjs";
96
104
  /** Runtime handler-JIT module a strip build can replace with a throwing stub. */
97
105
  interface StubPlan {
98
106
  /** Stub the internal handler codegen module. */
99
107
  jit: boolean;
108
+ /** Omit the static-clone resolver when no captured handler aliases scl. */
109
+ staticClone: boolean;
100
110
  /** Stub internal WS route builders when the app declares no WS routes. */
101
111
  ws: boolean;
102
112
  /**
@@ -118,18 +128,8 @@ interface StubPlan {
118
128
  * codegen, frozen reconstruct) only calls in when trace handlers exist, so
119
129
  * a throwing stub is unreachable once detection proves trace is unused
120
130
  *
121
- * NOT moot after the `elysia/trace` capability severance. The reachable
122
- * post-severance case is: an app that `.use(trace())` (so the capability
123
- * is registered and `dist/trace.mjs` IS in the bundle graph via
124
- * `dist/plugin/trace.mjs`) but never attaches `.trace(fn)` (no trace
125
- * hooks, so `tr` is unaliased and `mayTrace` is false). Under the frozen
126
- * path (`jit`) this flag is still `true`, so the stub replaces the real
127
- * trace module with the non-throwing `unionTracePhases(){return new Set()}`
128
- * fallback (+ throwing `createTracer`, unreachable with zero hooks).
129
- * Measured saving for that shape: ~18KB severing trace also tree-shakes
130
- * sucrose's `separateFunction`, which trace is the sole importer of. A
131
- * traceless app that never imports the capability (Fixture B) has no
132
- * trace module in the graph, so the stub is a no-op there.
131
+ * Also applies when `.use(trace())` is registered but no `.trace(fn)`
132
+ * exists: `unionTracePhases` stays a non-throwing `new Set()`
133
133
  */
134
134
  trace: boolean;
135
135
  /**
@@ -137,7 +137,7 @@ interface StubPlan {
137
137
  * stubbed. Sucrose never runs in a precompiled app, so its caches are always
138
138
  * empty and the flush is a no-op. Dropping the import lets the Sucrose
139
139
  * analyzer tree-shake. `flushMemory`'s other clears are preserved, and the
140
- * public `elysia/sucrose` module is left untouched
140
+ * `sucrose` module itself is not stubbed
141
141
  */
142
142
  sucrose: boolean;
143
143
  /**
@@ -156,6 +156,23 @@ interface StubPlan {
156
156
  * least one validator that is not bridge-free, so the bridge is still needed
157
157
  */
158
158
  bridge: boolean;
159
+ /**
160
+ * Re-route `type/typebox-value` -> its statically-imported `-live` mirror
161
+ * (bundlers can't follow the runtime `require`)
162
+ * Every mode except sealed, there the unresolvable `require` is what lets TypeBox collapse
163
+ */
164
+ typeboxValue: boolean;
165
+ /**
166
+ * Re-route `type/validator/exact-mirror` -> its statically-imported `-live`
167
+ * mirror so the bundler embeds `exact-mirror` instead of leaving the runtime
168
+ * `require('exact-mirror')` unresolvable, which is what breaks normalization
169
+ * and sanitize inside a compiled binary
170
+ *
171
+ * Set whenever `exact-mirror` resolves at build time, except in sealed mode:
172
+ * there every mirror is emitted into the manifest, so wiring it would only
173
+ * add ~15KB of dead code to the bundle the mode exists to shrink
174
+ */
175
+ exactMirror: boolean;
159
176
  /**
160
177
  * Replace `adapter/constants` with a target-specific stub that hard-selects
161
178
  * either `BunAdapter` or `WebStandardAdapter`, letting the bundler DCE the
@@ -202,52 +219,29 @@ declare const NO_STUB: StubPlan;
202
219
  * is not active, so the bridge must stay wired the ordinary way. No compat
203
220
  * stub, no reroute.
204
221
  */
205
- declare function planFromReport(strip: boolean | 'auto', report: JITProbeResult, hasWS: boolean, mayTrace: boolean, aliases: Set<string>, allBridgeFree: boolean, zeroCapture: boolean, adapterStub?: 'bun' | 'web-standard' | false, productionStub?: boolean): {
222
+ declare function planFromReport(strip: boolean | 'auto', report: JITProbeResult, hasWS: boolean, mayTrace: boolean, aliases: Set<string>, allBridgeFree: boolean, zeroCapture: boolean, adapterStub?: 'bun' | 'web-standard' | false, productionStub?: boolean,
223
+ /**
224
+ * A WS route declares a `cookie` schema. Its upgrade path handles cookies
225
+ * outside the handler JIT, so it emits no `cc` alias — stubbing on that
226
+ * alias alone would hand `src/ws/route.ts` a throwing `parseCookieRaw`
227
+ */
228
+ wsCookie?: boolean, /** `exact-mirror` resolves from the elysia package at build time. */exactMirror?: boolean): {
206
229
  plan: StubPlan;
207
230
  mode: BridgeMode;
208
231
  };
209
232
  declare function adapterConstantsSource(target: 'bun' | 'web-standard'): string;
210
- /** Filter matching elysia's own `adapter/constants` module (src + dist). */
211
233
  declare const ADAPTER_CONSTANTS_FILTER: RegExp;
212
234
  declare const ADAPTER_BUN_FILTER: RegExp;
213
235
  declare const IS_PRODUCTION_FILTER: RegExp;
214
- /**
215
- * Loose fallback filter
216
- *
217
- * Matches the `/elysia/(dist|src)/` segment anywhere in a path (node_modules layouts,
218
- * monorepos, linked installs). Used by esbuild as a broad pre-filter
219
- *
220
- * The caller must further check that the path is under the resolved elysia package root
221
- * to avoid matching user code in a directory that happens to be named "elysia"
222
- *
223
- * @internal
224
- */
236
+ declare const TYPEBOX_TYPE_FILTER: RegExp;
237
+ declare const TYPEBOX_SYSTEM_LITE_FILTER: RegExp;
238
+ declare const TYPEBOX_REQUIRE_FILTER: RegExp;
239
+ declare const EXACT_MIRROR_REQUIRE_FILTER: RegExp;
225
240
  declare const ELYSIA_MODULE_FILTER: RegExp;
226
- /**
227
- * Build a predicate that returns `true` only for modules that are under the
228
- * resolved elysia package root (i.e. actually elysia's own files).
229
- *
230
- * Anchoring to the real package root prevents user projects rooted in a
231
- * directory named `elysia` (like this repo itself) from having their code
232
- * rewritten.
233
- *
234
- * Pass the result to both the esbuild `filter` (convert to RegExp via
235
- * `makeElysiaModuleFilterRegex`) and the Vite transform (`isElysiaModule`).
236
- */
237
- declare function resolveElysiaRoot(from?: string): string;
238
- /**
239
- * Returns a predicate that is `true` only when the given module path is under
240
- * the resolved elysia package root AND matches the broad module filter.
241
- */
241
+ declare function resolveElysiaRoot(from: string): string;
242
+ declare function resolveExactMirror(from: string): boolean;
242
243
  declare function makeIsElysiaModule(elysiaRoot: string): (path: string) => boolean;
243
- /**
244
- * Build an esbuild-compatible RegExp that anchors to the resolved elysia root
245
- * so the `onLoad` pre-filter is as tight as possible. esbuild uses this as an
246
- * initial path filter before calling the callback, so we still double-check
247
- * with `makeIsElysiaModule` inside the callback.
248
- */
249
- declare function makeElysiaModuleFilterRegex(elysiaRoot: string): RegExp;
250
- declare function rewriteIsProductionCalls(code: string): string;
244
+ declare const rewriteIsProductionCalls: (code: string) => string;
251
245
  declare const bunAdapterStubSource: string;
252
246
  declare const STUB_SOURCES: Record<Exclude<keyof StubPlan, 'adapter' | 'isProduction'>, Array<{
253
247
  filter: RegExp;
@@ -258,7 +252,7 @@ declare const OVERRIDE_MAP: Record<string, {
258
252
  leaf: string;
259
253
  export: string;
260
254
  }>;
261
- declare function generateVirtualType(typeSpecifier?: string): Promise<string>;
255
+ declare function generateVirtualType(moduleCondition?: AotModuleCondition): Promise<string>;
262
256
  interface CompiledArtifacts {
263
257
  source: string;
264
258
  /** Handler-JIT modules detection proved safe to stub for this app. */
@@ -272,11 +266,6 @@ interface CompiledArtifacts {
272
266
  */
273
267
  virtualType?: string;
274
268
  }
275
- /** @internal Test diagnostic for deterministic worker cleanup. */
276
- declare const getAotWorkerDiagnostics: () => {
277
- activeWorkers: number;
278
- lastExit: Promise<number> | undefined;
279
- };
280
269
  /**
281
270
  * Extension mirroring the running module's own build output, so a sibling
282
271
  * source file can be resolved from `import.meta.url` in `.mjs`/`.js`/`.ts`
@@ -284,9 +273,12 @@ declare const getAotWorkerDiagnostics: () => {
284
273
  */
285
274
  declare function siblingModuleExt(moduleUrl: string): '.mjs' | '.js' | '.ts';
286
275
  /** @internal Re-evaluate an entry in a disposable worker for watch rebuilds. */
287
- declare function generateCompiledArtifactsIsolated(file: string, options?: ElysiaAotOptions): Promise<CompiledArtifacts>;
288
- declare function generateCompiledArtifacts(file: string, options?: ElysiaAotOptions): Promise<CompiledArtifacts>;
276
+ declare function generateCompiledArtifactsIsolated(file: string, options?: ElysiaAotOptions, moduleCondition?: string): Promise<CompiledArtifacts>;
277
+ type ValidatorSlotIdentity = Pick<CapturedValidator, 'method' | 'path' | 'slot'>;
278
+ /** @internal Exact logical-slot gate used by AOT mode selection. */
279
+ declare function validatorSlotSetsMatch(expected: readonly ValidatorSlotIdentity[], captured: readonly ValidatorSlotIdentity[]): boolean;
280
+ declare function generateCompiledArtifacts(file: string, options?: ElysiaAotOptions, moduleCondition?: string): Promise<CompiledArtifacts>;
289
281
  declare const SOURCE_REGEX: RegExp;
290
282
  declare const realPath: (path: string) => string;
291
283
  //#endregion
292
- export { ADAPTER_BUN_FILTER, ADAPTER_CONSTANTS_FILTER, BridgeMode, CompiledArtifacts, ELYSIA_MODULE_FILTER, ElysiaAotOptions, IS_PRODUCTION_FILTER, NO_STUB, OVERRIDE_MAP, SOURCE_REGEX, STUB_SOURCES, StubPlan, adapterConstantsSource, alignStubExtensions, bunAdapterStubSource, generateCompiledArtifacts, generateCompiledArtifactsIsolated, generateVirtualType, getAotWorkerDiagnostics, makeElysiaModuleFilterRegex, makeIsElysiaModule, planFromReport, realPath, resolveElysiaRoot, resolveEntry, rewriteIsProductionCalls, siblingModuleExt };
284
+ export { ADAPTER_BUN_FILTER, ADAPTER_CONSTANTS_FILTER, BridgeMode, CompiledArtifacts, ELYSIA_MODULE_FILTER, EXACT_MIRROR_REQUIRE_FILTER, ElysiaAotOptions, IS_PRODUCTION_FILTER, NO_STUB, OVERRIDE_MAP, SOURCE_REGEX, STUB_SOURCES, StubPlan, TYPEBOX_REQUIRE_FILTER, TYPEBOX_SYSTEM_LITE_FILTER, TYPEBOX_TYPE_FILTER, adapterConstantsSource, alignStubExtensions, bunAdapterStubSource, generateCompiledArtifacts, generateCompiledArtifactsIsolated, generateVirtualType, makeIsElysiaModule, planFromReport, realPath, resolveElysiaRoot, resolveEntry, resolveEntryModuleKind, resolveExactMirror, rewriteIsProductionCalls, siblingModuleExt, validatorSlotSetsMatch };