elysia 2.0.0-beta.2 → 2.0.0-beta.20

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 (337) 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 +11 -13
  25. package/dist/compile/aot.js +34 -46
  26. package/dist/compile/aot.mjs +35 -45
  27. package/dist/compile/handler/descriptor.d.ts +9 -12
  28. package/dist/compile/handler/descriptor.js +17 -41
  29. package/dist/compile/handler/descriptor.mjs +18 -39
  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 +6 -5
  34. package/dist/compile/handler/index.js +148 -109
  35. package/dist/compile/handler/index.mjs +149 -111
  36. package/dist/compile/handler/jit.d.ts +17 -17
  37. package/dist/compile/handler/jit.js +220 -148
  38. package/dist/compile/handler/jit.mjs +222 -151
  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 +4 -3
  44. package/dist/compile/handler/reconstruct.mjs +4 -3
  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 +1 -0
  66. package/dist/cookie/config.js +9 -9
  67. package/dist/cookie/config.mjs +9 -9
  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 +47 -60
  108. package/dist/plugin/aot/core.js +172 -109
  109. package/dist/plugin/aot/core.mjs +169 -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 +47 -62
  122. package/dist/plugin/aot/source.mjs +48 -63
  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 +29 -47
  139. package/dist/schema-snapshot.mjs +29 -47
  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 +2 -6
  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/constants.d.ts +1 -1
  162. package/dist/type/elysia/array-buffer.d.ts +4 -1
  163. package/dist/type/elysia/array-buffer.js +17 -17
  164. package/dist/type/elysia/array-buffer.mjs +17 -17
  165. package/dist/type/elysia/array-string.js +2 -40
  166. package/dist/type/elysia/array-string.mjs +2 -39
  167. package/dist/type/elysia/array.js +5 -9
  168. package/dist/type/elysia/array.mjs +5 -9
  169. package/dist/type/elysia/boolean-string.js +2 -3
  170. package/dist/type/elysia/boolean-string.mjs +1 -1
  171. package/dist/type/elysia/boolean.js +3 -12
  172. package/dist/type/elysia/boolean.mjs +3 -11
  173. package/dist/type/elysia/cookie.d.ts +3 -4
  174. package/dist/type/elysia/cookie.js +5 -15
  175. package/dist/type/elysia/cookie.mjs +5 -15
  176. package/dist/type/elysia/date.js +13 -20
  177. package/dist/type/elysia/date.mjs +10 -16
  178. package/dist/type/elysia/file-type.d.ts +11 -4
  179. package/dist/type/elysia/file-type.js +17 -2
  180. package/dist/type/elysia/file-type.mjs +17 -3
  181. package/dist/type/elysia/file.d.ts +1 -3
  182. package/dist/type/elysia/file.js +11 -27
  183. package/dist/type/elysia/file.mjs +11 -12
  184. package/dist/type/elysia/files.js +7 -11
  185. package/dist/type/elysia/files.mjs +7 -10
  186. package/dist/type/elysia/form.js +2 -3
  187. package/dist/type/elysia/form.mjs +3 -3
  188. package/dist/type/elysia/integer-string.d.ts +1 -1
  189. package/dist/type/elysia/integer-string.js +4 -30
  190. package/dist/type/elysia/integer-string.mjs +5 -30
  191. package/dist/type/elysia/integer.js +3 -12
  192. package/dist/type/elysia/integer.mjs +3 -11
  193. package/dist/type/elysia/intersect.js +0 -5
  194. package/dist/type/elysia/intersect.mjs +0 -5
  195. package/dist/type/elysia/json-string.d.ts +7 -0
  196. package/dist/type/elysia/json-string.js +47 -0
  197. package/dist/type/elysia/json-string.mjs +46 -0
  198. package/dist/type/elysia/maybe-empty.js +3 -4
  199. package/dist/type/elysia/maybe-empty.mjs +1 -1
  200. package/dist/type/elysia/nullable.js +2 -3
  201. package/dist/type/elysia/nullable.mjs +1 -1
  202. package/dist/type/elysia/number.d.ts +2 -1
  203. package/dist/type/elysia/number.js +19 -11
  204. package/dist/type/elysia/number.mjs +18 -10
  205. package/dist/type/elysia/numeric-enum.d.ts +1 -1
  206. package/dist/type/elysia/numeric-enum.js +4 -5
  207. package/dist/type/elysia/numeric-enum.mjs +3 -3
  208. package/dist/type/elysia/numeric.d.ts +4 -2
  209. package/dist/type/elysia/numeric.js +20 -17
  210. package/dist/type/elysia/numeric.mjs +19 -16
  211. package/dist/type/elysia/object-string.js +2 -37
  212. package/dist/type/elysia/object-string.mjs +2 -36
  213. package/dist/type/elysia/object.js +5 -9
  214. package/dist/type/elysia/object.mjs +5 -9
  215. package/dist/type/elysia/optional.js +8 -8
  216. package/dist/type/elysia/optional.mjs +7 -7
  217. package/dist/type/elysia/problem.d.ts +20 -0
  218. package/dist/type/elysia/problem.js +25 -0
  219. package/dist/type/elysia/problem.mjs +24 -0
  220. package/dist/type/elysia/string.js +4 -3
  221. package/dist/type/elysia/string.mjs +4 -2
  222. package/dist/type/elysia/uint8-array.d.ts +1 -1
  223. package/dist/type/elysia/uint8-array.js +5 -20
  224. package/dist/type/elysia/uint8-array.mjs +5 -19
  225. package/dist/type/elysia/union-enum.js +7 -8
  226. package/dist/type/elysia/union-enum.mjs +6 -6
  227. package/dist/type/elysia/union.js +0 -5
  228. package/dist/type/elysia/union.mjs +0 -5
  229. package/dist/type/elysia/utils.d.ts +2 -4
  230. package/dist/type/elysia/utils.js +10 -21
  231. package/dist/type/elysia/utils.mjs +7 -15
  232. package/dist/type/exports.d.ts +3 -2
  233. package/dist/type/exports.js +13 -2
  234. package/dist/type/exports.mjs +10 -2
  235. package/dist/type/index.d.ts +10 -2
  236. package/dist/type/index.js +52 -15
  237. package/dist/type/index.mjs +55 -11
  238. package/dist/type/shared.d.ts +3 -9
  239. package/dist/type/shared.js +44 -97
  240. package/dist/type/shared.mjs +43 -97
  241. package/dist/type/sync-require.d.ts +11 -0
  242. package/dist/type/sync-require.js +14 -0
  243. package/dist/type/sync-require.mjs +12 -0
  244. package/dist/type/typebox-system-lite.d.ts +2 -0
  245. package/dist/type/typebox-system-lite.js +34 -0
  246. package/dist/type/typebox-system-lite.mjs +3 -0
  247. package/dist/type/typebox-system-require.d.ts +7 -0
  248. package/dist/type/typebox-system-require.js +24 -0
  249. package/dist/type/typebox-system-require.mjs +23 -0
  250. package/dist/type/typebox-type-live.d.ts +11 -0
  251. package/dist/type/typebox-type-live.js +37 -0
  252. package/dist/type/typebox-type-live.mjs +20 -0
  253. package/dist/type/typebox-type.d.ts +26 -0
  254. package/dist/type/typebox-type.js +135 -0
  255. package/dist/type/typebox-type.mjs +70 -0
  256. package/dist/type/typebox-value-live.d.ts +11 -0
  257. package/dist/type/typebox-value-live.js +31 -0
  258. package/dist/type/typebox-value-live.mjs +13 -0
  259. package/dist/type/typebox-value-ops.d.ts +4 -0
  260. package/dist/type/typebox-value-ops.js +90 -0
  261. package/dist/type/typebox-value-ops.mjs +5 -0
  262. package/dist/type/typebox-value-require.d.ts +8 -0
  263. package/dist/type/typebox-value-require.js +28 -0
  264. package/dist/type/typebox-value-require.mjs +25 -0
  265. package/dist/type/typebox-value.d.ts +35 -0
  266. package/dist/type/typebox-value.js +161 -0
  267. package/dist/type/typebox-value.mjs +74 -0
  268. package/dist/type/utils.js +1 -10
  269. package/dist/type/utils.mjs +1 -10
  270. package/dist/type/validator/clean-safe.d.ts +2 -4
  271. package/dist/type/validator/clean-safe.js +15 -11
  272. package/dist/type/validator/clean-safe.mjs +16 -10
  273. package/dist/type/validator/custom-error.js +12 -16
  274. package/dist/type/validator/custom-error.mjs +11 -14
  275. package/dist/type/validator/default-precompute.d.ts +9 -1
  276. package/dist/type/validator/default-precompute.js +40 -77
  277. package/dist/type/validator/default-precompute.mjs +37 -74
  278. package/dist/type/validator/exact-mirror-live.d.ts +8 -0
  279. package/dist/type/validator/exact-mirror-live.js +22 -0
  280. package/dist/type/validator/exact-mirror-live.mjs +17 -0
  281. package/dist/type/validator/exact-mirror-require.d.ts +4 -0
  282. package/dist/type/validator/exact-mirror-require.js +11 -0
  283. package/dist/type/validator/exact-mirror-require.mjs +9 -0
  284. package/dist/type/validator/exact-mirror.js +8 -8
  285. package/dist/type/validator/exact-mirror.mjs +9 -8
  286. package/dist/type/validator/frozen-check.js +5 -6
  287. package/dist/type/validator/frozen-check.mjs +6 -7
  288. package/dist/type/validator/index.d.ts +1 -0
  289. package/dist/type/validator/index.js +169 -166
  290. package/dist/type/validator/index.mjs +162 -158
  291. package/dist/type/validator/string-codec-aot.d.ts +2 -1
  292. package/dist/type/validator/string-codec-aot.js +8 -2
  293. package/dist/type/validator/string-codec-aot.mjs +7 -2
  294. package/dist/type/validator/validator-cache.d.ts +5 -4
  295. package/dist/type/validator/validator-cache.js +41 -24
  296. package/dist/type/validator/validator-cache.mjs +40 -22
  297. package/dist/types.d.ts +261 -94
  298. package/dist/universal/constants.d.ts +2 -1
  299. package/dist/universal/constants.js +3 -1
  300. package/dist/universal/constants.mjs +2 -1
  301. package/dist/universal/env.js +2 -3
  302. package/dist/universal/env.mjs +2 -3
  303. package/dist/universal/file.d.ts +6 -4
  304. package/dist/universal/file.js +11 -16
  305. package/dist/universal/file.mjs +12 -16
  306. package/dist/universal/index.d.ts +2 -2
  307. package/dist/universal/is-production.d.ts +1 -2
  308. package/dist/universal/is-production.js +1 -3
  309. package/dist/universal/is-production.mjs +2 -3
  310. package/dist/universal/server.d.ts +0 -272
  311. package/dist/utils.d.ts +41 -7
  312. package/dist/utils.js +158 -126
  313. package/dist/utils.mjs +147 -126
  314. package/dist/validator/index.d.ts +1 -1
  315. package/dist/validator/index.js +17 -30
  316. package/dist/validator/index.mjs +18 -31
  317. package/dist/validator/route.js +2 -1
  318. package/dist/validator/route.mjs +2 -1
  319. package/dist/ws/context.d.ts +8 -1
  320. package/dist/ws/context.js +68 -44
  321. package/dist/ws/context.mjs +67 -44
  322. package/dist/ws/parser.js +10 -20
  323. package/dist/ws/parser.mjs +10 -20
  324. package/dist/ws/route.d.ts +2 -2
  325. package/dist/ws/route.js +219 -139
  326. package/dist/ws/route.mjs +223 -143
  327. package/dist/ws/types.d.ts +2 -2
  328. package/package.json +23 -49
  329. package/dist/compile/analysis-cache.d.ts +0 -6
  330. package/dist/compile/analysis-cache.js +0 -12
  331. package/dist/compile/analysis-cache.mjs +0 -11
  332. package/dist/cookie/index.d.ts +0 -7
  333. package/dist/cookie/index.js +0 -13
  334. package/dist/cookie/index.mjs +0 -7
  335. package/dist/handler/index.d.ts +0 -2
  336. package/dist/handler/index.js +0 -5
  337. 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.20";
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.20";
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,5 +1,6 @@
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
5
6
  interface ElysiaAotOptions {
@@ -93,10 +94,14 @@ interface ElysiaAotOptions {
93
94
  verbose?: boolean;
94
95
  }
95
96
  declare const resolveEntry: (entry: string) => string;
97
+ /** @internal Resolve the package condition used to evaluate an AOT entry. */
98
+ declare const resolveEntryModuleKind: (entry: string) => "esm" | "cjs";
96
99
  /** Runtime handler-JIT module a strip build can replace with a throwing stub. */
97
100
  interface StubPlan {
98
101
  /** Stub the internal handler codegen module. */
99
102
  jit: boolean;
103
+ /** Omit the static-clone resolver when no captured handler aliases scl. */
104
+ staticClone: boolean;
100
105
  /** Stub internal WS route builders when the app declares no WS routes. */
101
106
  ws: boolean;
102
107
  /**
@@ -118,18 +123,8 @@ interface StubPlan {
118
123
  * codegen, frozen reconstruct) only calls in when trace handlers exist, so
119
124
  * a throwing stub is unreachable once detection proves trace is unused
120
125
  *
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.
126
+ * Also applies when `.use(trace())` is registered but no `.trace(fn)`
127
+ * exists: `unionTracePhases` stays a non-throwing `new Set()`
133
128
  */
134
129
  trace: boolean;
135
130
  /**
@@ -137,7 +132,7 @@ interface StubPlan {
137
132
  * stubbed. Sucrose never runs in a precompiled app, so its caches are always
138
133
  * empty and the flush is a no-op. Dropping the import lets the Sucrose
139
134
  * analyzer tree-shake. `flushMemory`'s other clears are preserved, and the
140
- * public `elysia/sucrose` module is left untouched
135
+ * `sucrose` module itself is not stubbed
141
136
  */
142
137
  sucrose: boolean;
143
138
  /**
@@ -156,6 +151,23 @@ interface StubPlan {
156
151
  * least one validator that is not bridge-free, so the bridge is still needed
157
152
  */
158
153
  bridge: boolean;
154
+ /**
155
+ * Re-route `type/typebox-value` -> its statically-imported `-live` mirror
156
+ * (bundlers can't follow the runtime `require`)
157
+ * Every mode except sealed, there the unresolvable `require` is what lets TypeBox collapse
158
+ */
159
+ typeboxValue: boolean;
160
+ /**
161
+ * Re-route `type/validator/exact-mirror` -> its statically-imported `-live`
162
+ * mirror so the bundler embeds `exact-mirror` instead of leaving the runtime
163
+ * `require('exact-mirror')` unresolvable, which is what breaks normalization
164
+ * and sanitize inside a compiled binary
165
+ *
166
+ * Set whenever `exact-mirror` resolves at build time, except in sealed mode:
167
+ * there every mirror is emitted into the manifest, so wiring it would only
168
+ * add ~15KB of dead code to the bundle the mode exists to shrink
169
+ */
170
+ exactMirror: boolean;
159
171
  /**
160
172
  * Replace `adapter/constants` with a target-specific stub that hard-selects
161
173
  * either `BunAdapter` or `WebStandardAdapter`, letting the bundler DCE the
@@ -202,52 +214,29 @@ declare const NO_STUB: StubPlan;
202
214
  * is not active, so the bridge must stay wired the ordinary way. No compat
203
215
  * stub, no reroute.
204
216
  */
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): {
217
+ 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,
218
+ /**
219
+ * A WS route declares a `cookie` schema. Its upgrade path handles cookies
220
+ * outside the handler JIT, so it emits no `cc` alias — stubbing on that
221
+ * alias alone would hand `src/ws/route.ts` a throwing `parseCookieRaw`
222
+ */
223
+ wsCookie?: boolean, /** `exact-mirror` resolves from the elysia package at build time. */exactMirror?: boolean): {
206
224
  plan: StubPlan;
207
225
  mode: BridgeMode;
208
226
  };
209
227
  declare function adapterConstantsSource(target: 'bun' | 'web-standard'): string;
210
- /** Filter matching elysia's own `adapter/constants` module (src + dist). */
211
228
  declare const ADAPTER_CONSTANTS_FILTER: RegExp;
212
229
  declare const ADAPTER_BUN_FILTER: RegExp;
213
230
  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
- */
231
+ declare const TYPEBOX_TYPE_FILTER: RegExp;
232
+ declare const TYPEBOX_SYSTEM_LITE_FILTER: RegExp;
233
+ declare const TYPEBOX_REQUIRE_FILTER: RegExp;
234
+ declare const EXACT_MIRROR_REQUIRE_FILTER: RegExp;
225
235
  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
- */
236
+ declare function resolveElysiaRoot(from: string): string;
237
+ declare function resolveExactMirror(from: string): boolean;
242
238
  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;
239
+ declare const rewriteIsProductionCalls: (code: string) => string;
251
240
  declare const bunAdapterStubSource: string;
252
241
  declare const STUB_SOURCES: Record<Exclude<keyof StubPlan, 'adapter' | 'isProduction'>, Array<{
253
242
  filter: RegExp;
@@ -258,7 +247,7 @@ declare const OVERRIDE_MAP: Record<string, {
258
247
  leaf: string;
259
248
  export: string;
260
249
  }>;
261
- declare function generateVirtualType(typeSpecifier?: string): Promise<string>;
250
+ declare function generateVirtualType(moduleCondition?: AotModuleCondition): Promise<string>;
262
251
  interface CompiledArtifacts {
263
252
  source: string;
264
253
  /** Handler-JIT modules detection proved safe to stub for this app. */
@@ -272,11 +261,6 @@ interface CompiledArtifacts {
272
261
  */
273
262
  virtualType?: string;
274
263
  }
275
- /** @internal Test diagnostic for deterministic worker cleanup. */
276
- declare const getAotWorkerDiagnostics: () => {
277
- activeWorkers: number;
278
- lastExit: Promise<number> | undefined;
279
- };
280
264
  /**
281
265
  * Extension mirroring the running module's own build output, so a sibling
282
266
  * source file can be resolved from `import.meta.url` in `.mjs`/`.js`/`.ts`
@@ -284,9 +268,12 @@ declare const getAotWorkerDiagnostics: () => {
284
268
  */
285
269
  declare function siblingModuleExt(moduleUrl: string): '.mjs' | '.js' | '.ts';
286
270
  /** @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>;
271
+ declare function generateCompiledArtifactsIsolated(file: string, options?: ElysiaAotOptions, moduleCondition?: string): Promise<CompiledArtifacts>;
272
+ type ValidatorSlotIdentity = Pick<CapturedValidator, 'method' | 'path' | 'slot'>;
273
+ /** @internal Exact logical-slot gate used by AOT mode selection. */
274
+ declare function validatorSlotSetsMatch(expected: readonly ValidatorSlotIdentity[], captured: readonly ValidatorSlotIdentity[]): boolean;
275
+ declare function generateCompiledArtifacts(file: string, options?: ElysiaAotOptions, moduleCondition?: string): Promise<CompiledArtifacts>;
289
276
  declare const SOURCE_REGEX: RegExp;
290
277
  declare const realPath: (path: string) => string;
291
278
  //#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 };
279
+ 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 };