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/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { AnyLocalHook, AppHook, ElysiaFormData, EventFn, EventScope, GuardSchemaType, InputSchema, Macro, MaybeArray, Prettify, SSEPayload } from "./types.js";
2
- import { Context } from "./context.js";
3
1
  import { AnySchema, StandardSchemaV1Like } from "./type/types.js";
2
+ import { Context } from "./context.js";
3
+ import { AnyLocalHook, AppHook, BunHTMLBundlelike, ElysiaFormData, EventFn, EventScope, GuardSchemaType, InputSchema, Macro, MaybeArray, Prettify, SSEPayload } from "./types.js";
4
4
 
5
5
  //#region src/utils.d.ts
6
6
  type DeriveEntry = Function | readonly [Function, 'mapDerive'];
@@ -20,6 +20,8 @@ declare const isNotEmpty: <T extends Object>(obj?: T) => boolean | undefined;
20
20
  */
21
21
  declare function evictOldestHalf(cache: Map<any, any>): void;
22
22
  declare function fnv1a(str: string): number;
23
+ declare const compositionKeys: readonly string[];
24
+ declare function refTargets(roots: unknown[], models?: Record<string, unknown>): (name: string) => Iterable<unknown>;
23
25
  /**
24
26
  * Maps each lifecycle/derive function to the hash of the named plugin it was
25
27
  * first registered on. Used by `.use()` to dedup absorbed hooks: if a fn's
@@ -49,6 +51,11 @@ declare const isLocalScope: (s: EventScope | undefined) => s is "local" | undefi
49
51
  * without flattening - `over` is walked first (older / outer context),
50
52
  * then `combine` (newer / inner context)
51
53
  *
54
+ * `tail` is the child's own chain head at that `.use()`. Its local hooks
55
+ * registered after the child absorbed the route run after the route's own
56
+ * hooks, as they would with the child as the root (`afterUseHooks` in
57
+ * `compile/handler`)
58
+ *
52
59
  * Use with {@link flattenChain} to walk tail-first and reconstruct
53
60
  * flat `Partial<AppHook>` at compile time
54
61
  */
@@ -60,10 +67,17 @@ type ChainNode = {
60
67
  propagated?: boolean;
61
68
  owner?: object;
62
69
  } | {
63
- combine: ChainNode;
70
+ combine: ChainNode | undefined;
64
71
  over: ChainNode | undefined;
72
+ tail?: ChainNode;
65
73
  refs: boolean;
66
74
  };
75
+ /**
76
+ * The absorbing instance's chain as it stood at `.use()`: the `over` of a
77
+ * combine node, or the node itself. A combine node is never on an instance's
78
+ * own chain, so it can't serve as a `stopAt` directly
79
+ */
80
+ declare const rootSnapshot: (node: ChainNode | undefined) => ChainNode | undefined;
67
81
  interface CompactBeforeHandleChunk {
68
82
  parent?: CompactBeforeHandleChunk;
69
83
  values: readonly Function[];
@@ -88,8 +102,8 @@ declare const macroEpoch: () => number;
88
102
  declare const invalidateMacroEpoch: () => void;
89
103
  /** Drop this root's flattened-chain memo. Recomputable on next compile. */
90
104
  declare function clearFlattenChainMemo(root: object): void;
91
- declare function flattenChainMemo(root: object, start: ChainNode | undefined, resolveAdded?: (node: ChainNode) => Partial<AppHook> | undefined): Partial<AppHook> | undefined;
92
105
  declare function flattenChainMemoReadonly(root: object, start: ChainNode | undefined, resolveAdded?: (node: ChainNode) => Partial<AppHook> | undefined): Partial<AppHook> | undefined;
106
+ declare function flattenChainMemo(root: object, start: ChainNode | undefined, resolveAdded?: (node: ChainNode) => Partial<AppHook> | undefined): Partial<AppHook> | undefined;
93
107
  /**
94
108
  *
95
109
  * @param url URL to redirect to
@@ -116,6 +130,7 @@ declare function formToFormData(value: Record<keyof any, unknown>): FormData;
116
130
  * ```
117
131
  */
118
132
  declare const form: <const T extends Record<keyof any, unknown>>(value: T) => ElysiaFormData<T>;
133
+ declare const assignOwn: <T extends object>(target: T, source: any) => T;
119
134
  declare const getLoosePath: (path: string) => string;
120
135
  /**
121
136
  * Certify a byte stream for direct Response body pass-through.
@@ -129,6 +144,7 @@ declare const isByteStream: (value: unknown) => value is ReadableStream<Uint8Arr
129
144
  type FormatSSEPayload<T = unknown> = T extends string ? {
130
145
  readonly data: T;
131
146
  } : Prettify<SSEPayload<T>>;
147
+ declare const sseData: (value: string) => string;
132
148
  declare const sse: <const T extends string | SSEPayload | Generator | AsyncGenerator | ReadableStream>(_payload: T) => T extends string ? {
133
149
  readonly data: T;
134
150
  } : T extends SSEPayload ? T : T extends ReadableStream<infer A> ? ReadableStream<FormatSSEPayload<A>> : T extends Generator<infer A, infer B, infer C> ? Generator<FormatSSEPayload<A>, B, C> : T extends AsyncGenerator<infer A, infer B_1, infer C_1> ? AsyncGenerator<FormatSSEPayload<A>, B_1, C_1> : T;
@@ -165,14 +181,34 @@ declare function cloneHook<T extends Partial<AnyLocalHook> | Partial<AppHook>>(s
165
181
  declare function clonePlainDeep<T>(value: T, seen?: WeakMap<object, any>): T;
166
182
  declare function guardNonPlainLeaves(target: Record<string, unknown>, source: Record<string, unknown>): void;
167
183
  declare function joinPath(base: string, path: string): string;
168
- declare function pushField<K extends keyof any>(target: Record<K, unknown>, key: K, item: unknown, defaultArray?: boolean): void;
169
- declare const requestId: any;
184
+ declare function pushField<K extends keyof any>(target: Record<K, unknown>, key: K, item: unknown): void;
185
+ declare const requestId: typeof Bun.randomUUIDv7 | (() => `${string}-${string}-${string}-${string}-${string}`);
186
+ /**
187
+ * Offset of the first byte after `://`, so the authority is never scanned as
188
+ * path. A fixed offset would let the client-supplied `Host` decide how many
189
+ * leading path bytes are dropped
190
+ */
191
+ declare const authorityEnd: (url: string) => number;
170
192
  declare function replaceUrlPath(url: string, path: string): string;
193
+ declare function isPlainObject(v: unknown): v is Record<string, unknown>;
171
194
  declare function clonePlainDecorators<T extends Record<string, unknown>>(source: T, seen?: WeakMap<object, any>): T;
172
195
  declare function prefix<T extends string, Models extends Record<string, AnySchema>>(prefix: T, models: Models): { [k in keyof Models as `${T}.${k & string}`]: Models[k] };
173
196
  declare namespace prefix {
174
197
  var capitalize: <T extends string, Models extends Record<string, AnySchema>>(prefix: T, models: Models) => { [k in keyof Models as `${T}.${Capitalize<k & string>}`]: Models[k] };
175
198
  }
176
199
  declare function serializeMacroSeed(_key: string, value: unknown): unknown;
200
+ declare const throwLifecycleErrors: (errors: unknown[]) => void;
201
+ declare const isDisposable: (value: any) => boolean;
202
+ declare const isSingleton: (value: object) => boolean;
203
+ declare const markSingletons: (value: unknown, depth?: number, seen?: Set<object>) => void;
204
+ declare const isSocketQuiet: (socket: {
205
+ readyState: number;
206
+ data: {
207
+ inflight?: number;
208
+ opening?: unknown;
209
+ settling?: number;
210
+ };
211
+ }) => boolean;
212
+ declare const isHTMLBundle: (value: unknown) => value is BunHTMLBundlelike;
177
213
  //#endregion
178
- export { ChainNode, CompactBeforeHandleChunk, CompactBeforeHandlePrefix, DeriveEntry, ELYSIA_FORM_PROTOTYPE, bytes, clearFlattenChainMemo, cloneHook, clonePlainDecorators, clonePlainDeep, coalesceSchemas, compactBeforeHandleConflicts, compactBeforeHandlePrefix, constantTimeEqual, createErrorEventHandler, deriveEntryFn, eventProperties, evictOldestHalf, flattenChain, flattenChainMemo, flattenChainMemoReadonly, fnOrigin, fnv1a, form, formToFormData, getLoosePath, guardNonPlainLeaves, hookToGuard, invalidateMacroEpoch, isBlob, isByteStream, isCompactBeforeHandleOnly, isElysiaForm, isEmpty, isLocalScope, isMapDeriveEntry, isNotEmpty, isRecordNumber, joinPath, macroEpoch, macroOrigin, mapDeriveEntry, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, prefix, pushField, redirect, replaceUrlPath, requestId, schemaProperties, serializeMacroSeed, sse };
214
+ export { ChainNode, CompactBeforeHandleChunk, CompactBeforeHandlePrefix, DeriveEntry, ELYSIA_FORM_PROTOTYPE, assignOwn, authorityEnd, bytes, clearFlattenChainMemo, cloneHook, clonePlainDecorators, clonePlainDeep, coalesceSchemas, compactBeforeHandleConflicts, compactBeforeHandlePrefix, compositionKeys, constantTimeEqual, createErrorEventHandler, deriveEntryFn, eventProperties, evictOldestHalf, flattenChain, flattenChainMemo, flattenChainMemoReadonly, fnOrigin, fnv1a, form, formToFormData, getLoosePath, guardNonPlainLeaves, hookToGuard, invalidateMacroEpoch, isBlob, isByteStream, isCompactBeforeHandleOnly, isDisposable, isElysiaForm, isEmpty, isHTMLBundle, isLocalScope, isMapDeriveEntry, isNotEmpty, isPlainObject, isRecordNumber, isSingleton, isSocketQuiet, joinPath, macroEpoch, macroOrigin, mapDeriveEntry, markSingletons, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, prefix, pushField, redirect, refTargets, replaceUrlPath, requestId, rootSnapshot, schemaProperties, serializeMacroSeed, sse, sseData, throwLifecycleErrors };
package/dist/utils.js CHANGED
@@ -37,6 +37,27 @@ function fnv1a(str) {
37
37
  }
38
38
  return hash >>> 0;
39
39
  }
40
+ const compositionKeys = Object.freeze([
41
+ "allOf",
42
+ "anyOf",
43
+ "oneOf",
44
+ "~cookieFrom"
45
+ ]);
46
+ function refTargets(roots, models = {}) {
47
+ const targets = nullObject();
48
+ const add = (name, schema) => (targets[name] ??= /* @__PURE__ */ new Set()).add(schema);
49
+ const seen = /* @__PURE__ */ new Set();
50
+ const index = (node) => {
51
+ if (!node || typeof node !== "object" || seen.has(node)) return;
52
+ seen.add(node);
53
+ if (typeof node.$id === "string") add(node.$id.slice(node.$id.lastIndexOf("/") + 1), node);
54
+ for (const key in node) index(node[key]);
55
+ index(node["~cookieFrom"]);
56
+ };
57
+ for (const name in models) add(name, models[name]);
58
+ roots.concat(Object.values(models)).forEach(index);
59
+ return (name) => targets[name] ?? [];
60
+ }
40
61
  /**
41
62
  * Maps each lifecycle/derive function to the hash of the named plugin it was
42
63
  * first registered on. Used by `.use()` to dedup absorbed hooks: if a fn's
@@ -49,6 +70,12 @@ function fnv1a(str) {
49
70
  const fnOrigin = /* @__PURE__ */ new WeakMap();
50
71
  const macroOrigin = /* @__PURE__ */ new WeakMap();
51
72
  const isLocalScope = (s) => s === "local" || s === void 0;
73
+ /**
74
+ * The absorbing instance's chain as it stood at `.use()`: the `over` of a
75
+ * combine node, or the node itself. A combine node is never on an instance's
76
+ * own chain, so it can't serve as a `stopAt` directly
77
+ */
78
+ const rootSnapshot = (node) => node && "combine" in node ? node.over : node;
52
79
  const COMPACT_CHUNK_SIZE = 32;
53
80
  const emptyCompactBeforeHandlePrefix = {
54
81
  length: 0,
@@ -73,30 +100,6 @@ function compactBeforeHandleConflicts(hook) {
73
100
  for (let i = 0; i < values.length; i++) if (compactBeforeHandleFunctions.has(values[i])) return true;
74
101
  return false;
75
102
  }
76
- function appendCompactBeforeHandle(previous, added) {
77
- if (!added.length) return previous;
78
- let tail = previous.tail;
79
- let length = previous.length;
80
- for (let i = 0; i < added.length; i++) {
81
- const fn = added[i];
82
- compactBeforeHandleFunctions.add(fn);
83
- if (tail && tail.values.length < COMPACT_CHUNK_SIZE) tail = {
84
- parent: tail.parent,
85
- values: [...tail.values, fn]
86
- };
87
- else tail = {
88
- parent: tail,
89
- values: [fn]
90
- };
91
- length++;
92
- }
93
- return {
94
- tail,
95
- length,
96
- previous: previous.length ? previous : void 0,
97
- added
98
- };
99
- }
100
103
  function compactBeforeHandlePrefix(start) {
101
104
  if (!start) return;
102
105
  const pending = [];
@@ -104,34 +107,51 @@ function compactBeforeHandlePrefix(start) {
104
107
  let prefix = emptyCompactBeforeHandlePrefix;
105
108
  while (node) {
106
109
  const cached = compactBeforeHandleMemos.get(node);
107
- if (cached !== void 0) {
108
- if (cached === false) {
109
- for (let i = 0; i < pending.length; i++) compactBeforeHandleMemos.set(pending[i].node, false);
110
- return;
111
- }
110
+ if (cached) {
112
111
  prefix = cached;
113
112
  break;
114
113
  }
115
- if ("combine" in node) {
116
- compactBeforeHandleMemos.set(node, false);
117
- for (let i = 0; i < pending.length; i++) compactBeforeHandleMemos.set(pending[i].node, false);
118
- return;
119
- }
120
- const values = compactBeforeHandleValues(node.added);
121
- if (values === false) {
122
- compactBeforeHandleMemos.set(node, false);
123
- for (let i = 0; i < pending.length; i++) compactBeforeHandleMemos.set(pending[i].node, false);
124
- return;
114
+ if (cached === void 0 && !("combine" in node)) {
115
+ const values = compactBeforeHandleValues(node.added);
116
+ if (values !== false) {
117
+ pending.push({
118
+ node,
119
+ values
120
+ });
121
+ node = node.parent;
122
+ continue;
123
+ }
125
124
  }
126
- pending.push({
127
- node,
128
- values
129
- });
130
- node = node.parent;
125
+ compactBeforeHandleMemos.set(node, false);
126
+ for (let i = 0; i < pending.length; i++) compactBeforeHandleMemos.set(pending[i].node, false);
127
+ return;
131
128
  }
132
129
  for (let i = pending.length - 1; i >= 0; i--) {
133
130
  const item = pending[i];
134
- prefix = appendCompactBeforeHandle(prefix, item.values);
131
+ const added = item.values;
132
+ if (added.length) {
133
+ let tail = prefix.tail;
134
+ let length = prefix.length;
135
+ for (let j = 0; j < added.length; j++) {
136
+ const fn = added[j];
137
+ compactBeforeHandleFunctions.add(fn);
138
+ if (tail && tail.values.length < COMPACT_CHUNK_SIZE) tail = {
139
+ parent: tail.parent,
140
+ values: [...tail.values, fn]
141
+ };
142
+ else tail = {
143
+ parent: tail,
144
+ values: [fn]
145
+ };
146
+ length++;
147
+ }
148
+ prefix = {
149
+ tail,
150
+ length,
151
+ previous: prefix.length ? prefix : void 0,
152
+ added
153
+ };
154
+ }
135
155
  compactBeforeHandleMemos.set(item.node, prefix);
136
156
  }
137
157
  return prefix.length ? prefix : void 0;
@@ -157,13 +177,30 @@ function flattenChain(start, keep, stopAt, resolveAdded) {
157
177
  const node = nodes.pop();
158
178
  if (phases.pop() === 1) {
159
179
  const added = resolveAdded ? resolveAdded(node) : node.added;
160
- if (added) appendInto(result, added, keep, node.scope);
180
+ if (added) {
181
+ const nodeScope = node.scope;
182
+ if (!(keep && !keep(nodeScope))) for (const key in added) {
183
+ const v = added[key];
184
+ if (v === void 0 || v === null) continue;
185
+ if (eventProperties.has(key) || key === "schemas" || key === "~deriveEntries") {
186
+ const existing = result[key];
187
+ if (Array.isArray(v)) if (existing) {
188
+ const arr = existing;
189
+ for (let i = 0; i < v.length; i++) arr.push(v[i]);
190
+ } else result[key] = v.slice();
191
+ else if (existing) existing.push(v);
192
+ else result[key] = [v];
193
+ } else result[key] = v;
194
+ }
195
+ }
161
196
  continue;
162
197
  }
163
198
  if (stopAt && node === stopAt) continue;
164
199
  if ("combine" in node) {
165
- nodes.push(node.combine);
166
- phases.push(0);
200
+ if (node.combine) {
201
+ nodes.push(node.combine);
202
+ phases.push(0);
203
+ }
167
204
  if (node.over) {
168
205
  nodes.push(node.over);
169
206
  phases.push(0);
@@ -197,7 +234,8 @@ function clearFlattenChainMemo(root) {
197
234
  flattenChainMemos.delete(root);
198
235
  }
199
236
  const emptyFlatten = Object.freeze(nullObject());
200
- function flattenChainCached(root, start, resolveAdded) {
237
+ function flattenChainMemoReadonly(root, start, resolveAdded) {
238
+ if (!start) return;
201
239
  let bucket = flattenChainMemos.get(root);
202
240
  if (!bucket || bucket.e !== macroTableEpoch) {
203
241
  bucket = {
@@ -216,30 +254,8 @@ function flattenChainCached(root, start, resolveAdded) {
216
254
  return cached;
217
255
  }
218
256
  function flattenChainMemo(root, start, resolveAdded) {
219
- if (!start) return;
220
- const cached = flattenChainCached(root, start, resolveAdded);
221
- if (cached === void 0) return;
222
- return cloneHook(cached);
223
- }
224
- function flattenChainMemoReadonly(root, start, resolveAdded) {
225
- if (!start) return;
226
- return flattenChainCached(root, start, resolveAdded);
227
- }
228
- function appendInto(target, src, keep, nodeScope) {
229
- if (keep && !keep(nodeScope)) return;
230
- for (const key in src) {
231
- const v = src[key];
232
- if (v === void 0 || v === null) continue;
233
- if (eventProperties.has(key) || key === "schemas" || key === "~deriveEntries") {
234
- const existing = target[key];
235
- if (Array.isArray(v)) if (existing) {
236
- const arr = existing;
237
- for (let i = 0; i < v.length; i++) arr.push(v[i]);
238
- } else target[key] = v.slice();
239
- else if (existing) existing.push(v);
240
- else target[key] = [v];
241
- } else target[key] = v;
242
- }
257
+ const cached = flattenChainMemoReadonly(root, start, resolveAdded);
258
+ if (cached) return cloneHook(cached);
243
259
  }
244
260
  const notLatin = /[^\x00-\xFF]/;
245
261
  /**
@@ -287,6 +303,7 @@ function formToFormData(value) {
287
303
  * ```
288
304
  */
289
305
  const form = (value) => Object.setPrototypeOf({ ...value }, ELYSIA_FORM_PROTOTYPE);
306
+ const assignOwn = (target, source) => source != null && Object.hasOwn(source, "__proto__") ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : Object.assign(target, source);
290
307
  const getLoosePath = (path) => path.charCodeAt(path.length - 1) === 47 ? path.slice(0, -1) : path + "/";
291
308
  const byteStreams = /* @__PURE__ */ new WeakSet();
292
309
  /**
@@ -322,6 +339,7 @@ const sse = (_payload) => {
322
339
  if (payload.data === null) s += "data: null\n";
323
340
  else if (typeof payload.data === "string") s += sseData(payload.data);
324
341
  else if (typeof payload.data === "object") s += `data: ${JSON.stringify(payload.data)}\n`;
342
+ else if (payload.data !== void 0) s += sseData(String(payload.data));
325
343
  if (s) s += "\n";
326
344
  return s;
327
345
  };
@@ -331,11 +349,11 @@ const _enc = new TextEncoder();
331
349
  let _constantTimeEqual;
332
350
  const _resolveConstantTimeEqual = () => {
333
351
  let native;
334
- try {
352
+ if (require_universal_constants.isBun && typeof crypto?.timingSafeEqual === "function") native = (a, b) => crypto.timingSafeEqual(a, b);
353
+ else try {
335
354
  const _crypto = globalThis.process?.getBuiltinModule?.("node:crypto");
336
355
  if (typeof _crypto?.timingSafeEqual === "function") native = _crypto.timingSafeEqual;
337
356
  } catch {}
338
- if (!native && typeof crypto?.timingSafeEqual === "function") native = (a, b) => crypto.timingSafeEqual(a, b);
339
357
  if (!native) return (a, b) => {
340
358
  if (a.length !== b.length) return false;
341
359
  let mismatch = 0;
@@ -429,14 +447,26 @@ function dedupedMergeArray(a, b, reverse = false) {
429
447
  for (let i = 0; i < aArr.length; i++) if (!seen.has(aArr[i])) filtered.push(aArr[i]);
430
448
  return reverse ? bArr.concat(filtered) : filtered.concat(bArr);
431
449
  }
432
- const schemaProperties = new Set([
450
+ const hookSchemaKeys = [
433
451
  "body",
434
452
  "headers",
435
453
  "params",
436
454
  "query",
437
455
  "cookie",
438
456
  "response"
439
- ]);
457
+ ];
458
+ const schemaProperties = new Set(hookSchemaKeys);
459
+ const hookEventKeys = [
460
+ "parse",
461
+ "transform",
462
+ "derive",
463
+ "beforeHandle",
464
+ "afterHandle",
465
+ "mapResponse",
466
+ "afterResponse",
467
+ "error",
468
+ "trace"
469
+ ];
440
470
  const eventProperties = new Set([
441
471
  "start",
442
472
  "stop",
@@ -451,33 +481,16 @@ const eventProperties = new Set([
451
481
  "error"
452
482
  ]);
453
483
  function hookToGuard(a) {
454
- if (a.schema !== "merge") return a;
484
+ if (a.schema !== "merge") {
485
+ if (a.schema !== void 0 && a.schema !== "override") throw new Error(`[Elysia] Invalid guard schema ${JSON.stringify(a.schema)}, expected 'merge' or 'override' (1.x 'standalone' is 'merge')`);
486
+ return a;
487
+ }
455
488
  if (a.body || a.headers || a.params || a.query || a.cookie || a.response) {
456
489
  a.schemas ??= [];
457
490
  const schema = Object.create(null);
458
- if (a.body) {
459
- schema.body = a.body;
460
- a.body = void 0;
461
- }
462
- if (a.headers) {
463
- schema.headers = a.headers;
464
- a.headers = void 0;
465
- }
466
- if (a.params) {
467
- schema.params = a.params;
468
- a.params = void 0;
469
- }
470
- if (a.query) {
471
- schema.query = a.query;
472
- a.query = void 0;
473
- }
474
- if (a.cookie) {
475
- schema.cookie = a.cookie;
476
- a.cookie = void 0;
477
- }
478
- if (a.response) {
479
- schema.response = a.response;
480
- a.response = void 0;
491
+ for (const key of hookSchemaKeys) if (a[key]) {
492
+ schema[key] = a[key];
493
+ a[key] = void 0;
481
494
  }
482
495
  a.schemas.push(schema);
483
496
  }
@@ -507,30 +520,22 @@ function mergeHook(a, b, reverse = false, dedup = false) {
507
520
  if (!b) return a;
508
521
  if (!a) return b;
509
522
  const merge = dedup ? dedupedMergeArray : mergeArray;
510
- if (!a.body && b.body) a.body = b.body;
511
- if (!a.headers && b.headers) a.headers = b.headers;
512
- if (!a.params && b.params) a.params = b.params;
513
- if (!a.query && b.query) a.query = b.query;
514
- if (!a.cookie && b.cookie) a.cookie = b.cookie;
515
- if (!a.response && b.response) a.response = b.response;
516
- else if (a.response && b.response) a.response = mergeResponse(b.response, a.response);
517
- if (a.parse || b.parse) a.parse = merge(a.parse, b.parse, reverse);
518
- if (a.transform || b.transform) a.transform = merge(a.transform, b.transform, reverse);
519
- if (a.derive || b.derive) a.derive = merge(a.derive, b.derive, reverse);
520
- if (a.beforeHandle || b.beforeHandle) a.beforeHandle = merge(a.beforeHandle, b.beforeHandle, reverse);
521
- if (a.afterHandle || b.afterHandle) a.afterHandle = merge(a.afterHandle, b.afterHandle, reverse);
522
- if (a.mapResponse || b.mapResponse) a.mapResponse = merge(a.mapResponse, b.mapResponse, reverse);
523
- if (a.afterResponse || b.afterResponse) a.afterResponse = merge(a.afterResponse, b.afterResponse, reverse);
524
- if (a.error || b.error) a.error = merge(a.error, b.error, reverse);
525
- if (a.trace || b.trace) a.trace = merge(a.trace, b.trace, reverse);
523
+ for (const key of hookSchemaKeys) if (!a[key] && b[key]) a[key] = b[key];
524
+ else if (key === "response" && a.response && b.response) a.response = mergeResponse(b.response, a.response);
525
+ for (const key of hookEventKeys) if (a[key] || b[key]) a[key] = merge(a[key], b[key], reverse);
526
526
  if (a.schemas || b.schemas) a.schemas = mergeArray(a.schemas, b.schemas, reverse);
527
527
  const aDerive = a["~deriveEntries"];
528
528
  const bDerive = b["~deriveEntries"];
529
529
  if (aDerive || bDerive) a["~deriveEntries"] = mergeArray(aDerive, bDerive, reverse);
530
530
  return a;
531
531
  }
532
- const createErrorEventHandler = (fn, error) => (context) => {
533
- if (context.error instanceof error) return fn(context);
532
+ const createErrorEventHandler = (fn, error) => {
533
+ const handler = (context) => {
534
+ if (context.error instanceof error) return fn(context);
535
+ };
536
+ const p = error?.prototype;
537
+ if (typeof p === "object" && p !== null && p !== Error.prototype && !(p instanceof Error)) handler["~errorClass"] = error;
538
+ return handler;
534
539
  };
535
540
  const isObject = (item) => item && typeof item === "object" && !Array.isArray(item);
536
541
  const isClassRegex = /^\s*class\s+/;
@@ -619,15 +624,21 @@ function joinPath(base, path) {
619
624
  if (!baseEndsWithSlash && !pathStartsWithSlash) return base + "/" + path;
620
625
  return base + path;
621
626
  }
622
- function pushField(target, key, item, defaultArray = false) {
627
+ function pushField(target, key, item) {
623
628
  const v = target[key];
624
629
  if (v) if (Array.isArray(v)) target[key].push(item);
625
630
  else target[key] = [v, item];
626
- else target[key] = defaultArray ? [item] : item;
631
+ else target[key] = item;
627
632
  }
628
- const requestId = require_universal_constants.isBun ? Bun.randomUUIDv7 : crypto.randomUUIDv7?.bind(crypto) ?? crypto.randomUUID?.bind(crypto);
633
+ const requestId = require_universal_constants.isBun ? Bun.randomUUIDv7 : crypto.randomUUID.bind(crypto);
634
+ /**
635
+ * Offset of the first byte after `://`, so the authority is never scanned as
636
+ * path. A fixed offset would let the client-supplied `Host` decide how many
637
+ * leading path bytes are dropped
638
+ */
639
+ const authorityEnd = (url) => url.charCodeAt(4) === 58 ? 7 : url.charCodeAt(5) === 58 ? 8 : url.indexOf("://") + 3;
629
640
  function replaceUrlPath(url, path) {
630
- const i = url.indexOf("/", 11);
641
+ const i = url.indexOf("/", authorityEnd(url));
631
642
  const qs = url.indexOf("?", i);
632
643
  return `${url.slice(0, i)}${path.charCodeAt(0) === 47 ? "" : "/"}${path}${qs === -1 ? "" : url.slice(qs)}`;
633
644
  }
@@ -652,7 +663,6 @@ function clonePlainDecorators(source, seen) {
652
663
  }
653
664
  return out;
654
665
  }
655
- const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
656
666
  function prefix(prefix, models) {
657
667
  const prefixed = nullObject();
658
668
  for (const key in models) prefixed[`${prefix}.${key}`] = models[key];
@@ -660,7 +670,7 @@ function prefix(prefix, models) {
660
670
  }
661
671
  prefix.capitalize = function prefixModelsCapitalize(prefix, models) {
662
672
  const prefixed = nullObject();
663
- for (const key in models) prefixed[`${prefix}.${capitalize(key)}`] = models[key];
673
+ for (const key in models) prefixed[`${prefix}.${key.charAt(0).toUpperCase() + key.slice(1)}`] = models[key];
664
674
  return prefixed;
665
675
  };
666
676
  const macroSeedRefIds = /* @__PURE__ */ new WeakMap();
@@ -679,9 +689,43 @@ function serializeMacroSeed(_key, value) {
679
689
  default: return value;
680
690
  }
681
691
  }
692
+ const throwLifecycleErrors = (errors) => {
693
+ if (errors.length === 1) throw errors[0];
694
+ if (errors.length) throw new AggregateError(errors, "Multiple lifecycle failures");
695
+ };
696
+ const isDisposable = (value) => {
697
+ if (value == null) return false;
698
+ const kind = typeof value;
699
+ if (kind !== "object" && kind !== "function") return false;
700
+ try {
701
+ return typeof value[Symbol.asyncDispose] === "function" || typeof value[Symbol.dispose] === "function";
702
+ } catch {
703
+ return false;
704
+ }
705
+ };
706
+ const singletons = /* @__PURE__ */ new WeakSet();
707
+ const isSingleton = (value) => singletons.has(value);
708
+ const markSingletons = (value, depth = 4, seen = /* @__PURE__ */ new Set()) => {
709
+ if (value == null) return;
710
+ const kind = typeof value;
711
+ if (kind !== "object" && kind !== "function") return;
712
+ const object = value;
713
+ if (seen.has(object)) return;
714
+ seen.add(object);
715
+ singletons.add(object);
716
+ if (depth <= 0) return;
717
+ for (const key of Object.keys(object)) {
718
+ const descriptor = Object.getOwnPropertyDescriptor(object, key);
719
+ if (descriptor && "value" in descriptor) markSingletons(descriptor.value, depth - 1, seen);
720
+ }
721
+ };
722
+ const isSocketQuiet = (socket) => socket.readyState === 3 && !socket.data.inflight && !socket.data.opening && !socket.data.settling;
723
+ const isHTMLBundle = (value) => Object.prototype.toString.call(value) === "[object HTMLBundle]" || typeof value?.index === "string" && Array.isArray(value.files);
682
724
 
683
725
  //#endregion
684
726
  exports.ELYSIA_FORM_PROTOTYPE = ELYSIA_FORM_PROTOTYPE;
727
+ exports.assignOwn = assignOwn;
728
+ exports.authorityEnd = authorityEnd;
685
729
  exports.bytes = bytes;
686
730
  exports.clearFlattenChainMemo = clearFlattenChainMemo;
687
731
  exports.cloneHook = cloneHook;
@@ -690,6 +734,7 @@ exports.clonePlainDeep = clonePlainDeep;
690
734
  exports.coalesceSchemas = coalesceSchemas;
691
735
  exports.compactBeforeHandleConflicts = compactBeforeHandleConflicts;
692
736
  exports.compactBeforeHandlePrefix = compactBeforeHandlePrefix;
737
+ exports.compositionKeys = compositionKeys;
693
738
  exports.constantTimeEqual = constantTimeEqual;
694
739
  exports.createErrorEventHandler = createErrorEventHandler;
695
740
  exports.deriveEntryFn = deriveEntryFn;
@@ -709,16 +754,22 @@ exports.invalidateMacroEpoch = invalidateMacroEpoch;
709
754
  exports.isBlob = isBlob;
710
755
  exports.isByteStream = isByteStream;
711
756
  exports.isCompactBeforeHandleOnly = isCompactBeforeHandleOnly;
757
+ exports.isDisposable = isDisposable;
712
758
  exports.isElysiaForm = isElysiaForm;
713
759
  exports.isEmpty = isEmpty;
760
+ exports.isHTMLBundle = isHTMLBundle;
714
761
  exports.isLocalScope = isLocalScope;
715
762
  exports.isMapDeriveEntry = isMapDeriveEntry;
716
763
  exports.isNotEmpty = isNotEmpty;
764
+ exports.isPlainObject = isPlainObject;
717
765
  exports.isRecordNumber = isRecordNumber;
766
+ exports.isSingleton = isSingleton;
767
+ exports.isSocketQuiet = isSocketQuiet;
718
768
  exports.joinPath = joinPath;
719
769
  exports.macroEpoch = macroEpoch;
720
770
  exports.macroOrigin = macroOrigin;
721
771
  exports.mapDeriveEntry = mapDeriveEntry;
772
+ exports.markSingletons = markSingletons;
722
773
  exports.mergeArray = mergeArray;
723
774
  exports.mergeDeep = mergeDeep;
724
775
  exports.mergeHook = mergeHook;
@@ -727,8 +778,12 @@ exports.nullObject = nullObject;
727
778
  exports.prefix = prefix;
728
779
  exports.pushField = pushField;
729
780
  exports.redirect = redirect;
781
+ exports.refTargets = refTargets;
730
782
  exports.replaceUrlPath = replaceUrlPath;
731
783
  exports.requestId = requestId;
784
+ exports.rootSnapshot = rootSnapshot;
732
785
  exports.schemaProperties = schemaProperties;
733
786
  exports.serializeMacroSeed = serializeMacroSeed;
734
- exports.sse = sse;
787
+ exports.sse = sse;
788
+ exports.sseData = sseData;
789
+ exports.throwLifecycleErrors = throwLifecycleErrors;