elysia 2.0.0-exp.5 → 2.0.0-exp.51

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 (353) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +0 -14
  2. package/dist/_virtual/_rolldown/runtime.mjs +2 -0
  3. package/dist/adapter/bun/index.d.ts +3 -26
  4. package/dist/adapter/bun/index.js +197 -58
  5. package/dist/adapter/bun/index.mjs +198 -59
  6. package/dist/adapter/constants.d.ts +3 -26
  7. package/dist/adapter/default-headers.d.ts +4 -0
  8. package/dist/adapter/default-headers.js +7 -0
  9. package/dist/adapter/default-headers.mjs +5 -0
  10. package/dist/adapter/index.d.ts +1 -26
  11. package/dist/adapter/index.js +1 -19
  12. package/dist/adapter/index.mjs +1 -19
  13. package/dist/adapter/origin.d.ts +59 -0
  14. package/dist/adapter/origin.js +60 -0
  15. package/dist/adapter/origin.mjs +58 -0
  16. package/dist/adapter/response-ownership.d.ts +5 -0
  17. package/dist/adapter/response-ownership.js +13 -0
  18. package/dist/adapter/response-ownership.mjs +10 -0
  19. package/dist/adapter/skip-clone.d.ts +4 -0
  20. package/dist/adapter/skip-clone.js +7 -0
  21. package/dist/adapter/skip-clone.mjs +5 -0
  22. package/dist/adapter/types.d.ts +8 -34
  23. package/dist/adapter/utils.d.ts +22 -17
  24. package/dist/adapter/utils.js +352 -160
  25. package/dist/adapter/utils.mjs +352 -160
  26. package/dist/adapter/web-standard/handler.d.ts +3 -3
  27. package/dist/adapter/web-standard/handler.js +85 -84
  28. package/dist/adapter/web-standard/handler.mjs +86 -85
  29. package/dist/adapter/web-standard/index.d.ts +2 -26
  30. package/dist/adapter/web-standard/index.js +47 -2
  31. package/dist/adapter/web-standard/index.mjs +47 -2
  32. package/dist/adapter/web-standard/utils.js +9 -2
  33. package/dist/adapter/web-standard/utils.mjs +9 -2
  34. package/dist/base.d.ts +187 -338
  35. package/dist/base.js +913 -424
  36. package/dist/base.mjs +915 -426
  37. package/dist/compile/analysis-cache.d.ts +6 -0
  38. package/dist/compile/analysis-cache.js +12 -0
  39. package/dist/compile/analysis-cache.mjs +11 -0
  40. package/dist/compile/aot-capture.d.ts +24 -0
  41. package/dist/compile/aot-capture.js +373 -0
  42. package/dist/compile/aot-capture.mjs +361 -0
  43. package/dist/compile/aot-emit.d.ts +29 -0
  44. package/dist/compile/aot-emit.js +107 -0
  45. package/dist/compile/aot-emit.mjs +101 -0
  46. package/dist/compile/aot-reconstruct.d.ts +30 -0
  47. package/dist/compile/aot-reconstruct.js +156 -0
  48. package/dist/compile/aot-reconstruct.mjs +147 -0
  49. package/dist/compile/aot.d.ts +141 -60
  50. package/dist/compile/aot.js +170 -244
  51. package/dist/compile/aot.mjs +154 -234
  52. package/dist/compile/handler/descriptor.d.ts +77 -0
  53. package/dist/compile/handler/descriptor.js +198 -0
  54. package/dist/compile/handler/descriptor.mjs +193 -0
  55. package/dist/compile/handler/frozen-validator.d.ts +39 -0
  56. package/dist/compile/handler/frozen-validator.js +322 -0
  57. package/dist/compile/handler/frozen-validator.mjs +316 -0
  58. package/dist/compile/handler/index.d.ts +12 -4
  59. package/dist/compile/handler/index.js +202 -65
  60. package/dist/compile/handler/index.mjs +202 -69
  61. package/dist/compile/handler/jit.d.ts +15 -7
  62. package/dist/compile/handler/jit.js +239 -151
  63. package/dist/compile/handler/jit.mjs +242 -156
  64. package/dist/compile/handler/params.d.ts +5 -1
  65. package/dist/compile/handler/params.js +20 -3
  66. package/dist/compile/handler/params.mjs +22 -5
  67. package/dist/compile/handler/reconstruct.d.ts +3 -4
  68. package/dist/compile/handler/reconstruct.js +36 -15
  69. package/dist/compile/handler/reconstruct.mjs +36 -15
  70. package/dist/compile/handler/utils.d.ts +19 -12
  71. package/dist/compile/handler/utils.js +178 -128
  72. package/dist/compile/handler/utils.mjs +160 -113
  73. package/dist/compile/jit-probe.d.ts +0 -4
  74. package/dist/compile/jit-probe.js +1 -11
  75. package/dist/compile/jit-probe.mjs +1 -11
  76. package/dist/compile/lexer.d.ts +7 -0
  77. package/dist/compile/lexer.js +53 -0
  78. package/dist/compile/lexer.mjs +48 -0
  79. package/dist/compile/utils.js +8 -4
  80. package/dist/compile/utils.mjs +8 -4
  81. package/dist/constants.d.ts +4 -25
  82. package/dist/constants.js +17 -17
  83. package/dist/constants.mjs +15 -15
  84. package/dist/context.d.ts +14 -48
  85. package/dist/context.js +43 -20
  86. package/dist/context.mjs +44 -21
  87. package/dist/cookie/config.d.ts +5 -1
  88. package/dist/cookie/config.js +19 -22
  89. package/dist/cookie/config.mjs +18 -22
  90. package/dist/cookie/cookie.d.ts +3 -5
  91. package/dist/cookie/cookie.js +42 -23
  92. package/dist/cookie/cookie.mjs +43 -23
  93. package/dist/cookie/crypto.d.ts +20 -0
  94. package/dist/cookie/crypto.js +169 -0
  95. package/dist/cookie/crypto.mjs +152 -0
  96. package/dist/cookie/error.d.ts +17 -0
  97. package/dist/cookie/error.js +25 -0
  98. package/dist/cookie/error.mjs +24 -0
  99. package/dist/cookie/index.d.ts +5 -3
  100. package/dist/cookie/index.js +5 -3
  101. package/dist/cookie/index.mjs +4 -2
  102. package/dist/cookie/lib.d.ts +1 -1
  103. package/dist/cookie/lib.js +15 -13
  104. package/dist/cookie/lib.mjs +15 -13
  105. package/dist/cookie/serialize.js +5 -1
  106. package/dist/cookie/serialize.mjs +5 -1
  107. package/dist/cookie/types.d.ts +1 -3
  108. package/dist/cookie/utils.d.ts +14 -7
  109. package/dist/cookie/utils.js +107 -95
  110. package/dist/cookie/utils.mjs +102 -91
  111. package/dist/error.d.ts +100 -19
  112. package/dist/error.js +355 -120
  113. package/dist/error.mjs +347 -119
  114. package/dist/generation.d.ts +30 -0
  115. package/dist/generation.js +23 -0
  116. package/dist/generation.mjs +17 -0
  117. package/dist/handler/error.js +37 -6
  118. package/dist/handler/error.mjs +38 -7
  119. package/dist/handler/fetch.js +198 -130
  120. package/dist/handler/fetch.mjs +198 -130
  121. package/dist/handler/index.d.ts +1 -3
  122. package/dist/handler/index.js +1 -5
  123. package/dist/handler/index.mjs +1 -3
  124. package/dist/handler/utils.d.ts +11 -2
  125. package/dist/handler/utils.js +27 -5
  126. package/dist/handler/utils.mjs +24 -5
  127. package/dist/index.d.ts +17 -10
  128. package/dist/index.js +19 -7
  129. package/dist/index.mjs +11 -8
  130. package/dist/memory.js +2 -2
  131. package/dist/memory.mjs +2 -2
  132. package/dist/package.js +11 -0
  133. package/dist/package.mjs +5 -0
  134. package/dist/parse-query.js +38 -22
  135. package/dist/parse-query.mjs +38 -22
  136. package/dist/plugin/{bun.d.ts → aot/bun.d.ts} +4 -2
  137. package/dist/plugin/aot/bun.js +35 -0
  138. package/dist/plugin/aot/bun.mjs +34 -0
  139. package/dist/plugin/aot/core.d.ts +291 -0
  140. package/dist/plugin/aot/core.js +505 -0
  141. package/dist/plugin/aot/core.mjs +481 -0
  142. package/dist/plugin/{esbuild.d.ts → aot/esbuild.d.ts} +5 -3
  143. package/dist/plugin/aot/esbuild.js +48 -0
  144. package/dist/plugin/aot/esbuild.mjs +46 -0
  145. package/dist/plugin/aot/hooks.d.ts +28 -0
  146. package/dist/plugin/aot/hooks.js +114 -0
  147. package/dist/plugin/aot/hooks.mjs +112 -0
  148. package/dist/plugin/aot/rspack-loader.d.ts +23 -0
  149. package/dist/plugin/aot/rspack-loader.js +44 -0
  150. package/dist/plugin/aot/rspack-loader.mjs +40 -0
  151. package/dist/plugin/aot/rspack.d.ts +23 -0
  152. package/dist/plugin/aot/rspack.js +85 -0
  153. package/dist/plugin/aot/rspack.mjs +82 -0
  154. package/dist/plugin/aot/source.d.ts +60 -0
  155. package/dist/plugin/aot/source.js +422 -0
  156. package/dist/plugin/aot/source.mjs +418 -0
  157. package/dist/plugin/aot/treeshake.d.ts +4 -0
  158. package/dist/plugin/aot/treeshake.js +95 -0
  159. package/dist/plugin/aot/treeshake.mjs +94 -0
  160. package/dist/plugin/aot/unplugin.d.ts +54 -0
  161. package/dist/plugin/aot/unplugin.js +68 -0
  162. package/dist/plugin/aot/unplugin.mjs +66 -0
  163. package/dist/plugin/{vite.d.ts → aot/vite.d.ts} +4 -3
  164. package/dist/plugin/aot/vite.js +34 -0
  165. package/dist/plugin/aot/vite.mjs +33 -0
  166. package/dist/plugin/aot/worker.js +28 -0
  167. package/dist/plugin/aot/worker.mjs +27 -0
  168. package/dist/plugin/auto-head.d.ts +6 -0
  169. package/dist/plugin/auto-head.js +38 -0
  170. package/dist/plugin/auto-head.mjs +36 -0
  171. package/dist/plugin/trace.d.ts +10 -0
  172. package/dist/plugin/trace.js +39 -0
  173. package/dist/plugin/trace.mjs +36 -0
  174. package/dist/plugin/websocket.d.ts +6 -0
  175. package/dist/plugin/websocket.js +61 -0
  176. package/dist/plugin/websocket.mjs +60 -0
  177. package/dist/route-table.d.ts +25 -0
  178. package/dist/route-table.js +59 -0
  179. package/dist/route-table.mjs +56 -0
  180. package/dist/schema-snapshot.d.ts +9 -0
  181. package/dist/schema-snapshot.js +271 -0
  182. package/dist/schema-snapshot.mjs +269 -0
  183. package/dist/sucrose.d.ts +1 -23
  184. package/dist/sucrose.js +556 -219
  185. package/dist/sucrose.mjs +557 -217
  186. package/dist/trace.d.ts +27 -57
  187. package/dist/trace.js +256 -141
  188. package/dist/trace.mjs +256 -141
  189. package/dist/type/bridge-live.d.ts +15 -0
  190. package/dist/type/bridge-live.js +39 -0
  191. package/dist/type/bridge-live.mjs +17 -0
  192. package/dist/type/bridge.d.ts +20 -11
  193. package/dist/type/bridge.js +34 -0
  194. package/dist/type/bridge.mjs +10 -1
  195. package/dist/type/coerce-plan.d.ts +38 -0
  196. package/dist/type/coerce-plan.js +110 -0
  197. package/dist/type/coerce-plan.mjs +101 -0
  198. package/dist/type/coerce.d.ts +6 -24
  199. package/dist/type/coerce.js +49 -172
  200. package/dist/type/coerce.mjs +35 -158
  201. package/dist/type/compat.js +7 -3
  202. package/dist/type/compat.mjs +9 -5
  203. package/dist/type/constants.d.ts +1 -1
  204. package/dist/type/elysia/accelerate.js +2 -1
  205. package/dist/type/elysia/accelerate.mjs +2 -1
  206. package/dist/type/elysia/array-buffer.d.ts +1 -2
  207. package/dist/type/elysia/array-buffer.js +9 -3
  208. package/dist/type/elysia/array-buffer.mjs +10 -4
  209. package/dist/type/elysia/array-string.js +3 -3
  210. package/dist/type/elysia/array-string.mjs +1 -1
  211. package/dist/type/elysia/array.js +7 -4
  212. package/dist/type/elysia/array.mjs +7 -4
  213. package/dist/type/elysia/boolean-string.js +2 -1
  214. package/dist/type/elysia/boolean-string.mjs +2 -1
  215. package/dist/type/elysia/boolean.js +6 -3
  216. package/dist/type/elysia/boolean.mjs +6 -3
  217. package/dist/type/elysia/cookie.d.ts +2 -5
  218. package/dist/type/elysia/date.js +38 -7
  219. package/dist/type/elysia/date.mjs +39 -8
  220. package/dist/type/elysia/file-type.d.ts +2 -1
  221. package/dist/type/elysia/file-type.js +11 -13
  222. package/dist/type/elysia/file-type.mjs +12 -14
  223. package/dist/type/elysia/file.js +10 -4
  224. package/dist/type/elysia/file.mjs +10 -4
  225. package/dist/type/elysia/files.js +16 -6
  226. package/dist/type/elysia/files.mjs +18 -8
  227. package/dist/type/elysia/integer-string.js +6 -4
  228. package/dist/type/elysia/integer-string.mjs +6 -4
  229. package/dist/type/elysia/integer.js +6 -3
  230. package/dist/type/elysia/integer.mjs +6 -3
  231. package/dist/type/elysia/intersect.js +8 -5
  232. package/dist/type/elysia/intersect.mjs +7 -4
  233. package/dist/type/elysia/maybe-empty.js +4 -2
  234. package/dist/type/elysia/maybe-empty.mjs +5 -3
  235. package/dist/type/elysia/nullable.js +4 -1
  236. package/dist/type/elysia/nullable.mjs +5 -2
  237. package/dist/type/elysia/number.js +6 -3
  238. package/dist/type/elysia/number.mjs +6 -3
  239. package/dist/type/elysia/numeric.js +29 -3
  240. package/dist/type/elysia/numeric.mjs +29 -3
  241. package/dist/type/elysia/object-string.js +3 -3
  242. package/dist/type/elysia/object-string.mjs +1 -1
  243. package/dist/type/elysia/object.js +8 -5
  244. package/dist/type/elysia/object.mjs +8 -5
  245. package/dist/type/elysia/optional.js +11 -13
  246. package/dist/type/elysia/optional.mjs +12 -13
  247. package/dist/type/elysia/string.js +22 -6
  248. package/dist/type/elysia/string.mjs +22 -6
  249. package/dist/type/elysia/uint8-array.d.ts +1 -2
  250. package/dist/type/elysia/uint8-array.js +10 -4
  251. package/dist/type/elysia/uint8-array.mjs +11 -5
  252. package/dist/type/elysia/union-enum.js +3 -2
  253. package/dist/type/elysia/union-enum.mjs +4 -3
  254. package/dist/type/elysia/union.js +6 -3
  255. package/dist/type/elysia/union.mjs +6 -3
  256. package/dist/type/elysia/utils.d.ts +3 -2
  257. package/dist/type/elysia/utils.js +34 -34
  258. package/dist/type/elysia/utils.mjs +33 -34
  259. package/dist/type/exports.js +6 -2073
  260. package/dist/type/exports.mjs +3 -323
  261. package/dist/type/index.d.ts +6 -2
  262. package/dist/type/index.js +64 -2
  263. package/dist/type/index.mjs +62 -3
  264. package/dist/type/shared.d.ts +27 -0
  265. package/dist/type/shared.js +171 -0
  266. package/dist/type/shared.mjs +161 -0
  267. package/dist/type/types.d.ts +20 -8
  268. package/dist/type/utils.js +29 -63
  269. package/dist/type/utils.mjs +29 -63
  270. package/dist/type/validator/clean-safe.d.ts +8 -0
  271. package/dist/type/validator/clean-safe.js +82 -0
  272. package/dist/type/validator/clean-safe.mjs +77 -0
  273. package/dist/type/validator/custom-error.js +124 -46
  274. package/dist/type/validator/custom-error.mjs +125 -47
  275. package/dist/type/validator/default-precompute.d.ts +7 -3
  276. package/dist/type/validator/default-precompute.js +61 -105
  277. package/dist/type/validator/default-precompute.mjs +60 -104
  278. package/dist/type/validator/frozen-check.js +4 -3
  279. package/dist/type/validator/frozen-check.mjs +2 -1
  280. package/dist/type/validator/index.d.ts +4 -3
  281. package/dist/type/validator/index.js +324 -235
  282. package/dist/type/validator/index.mjs +328 -241
  283. package/dist/type/validator/string-codec-aot.d.ts +2 -3
  284. package/dist/type/validator/string-codec-aot.js +8 -47
  285. package/dist/type/validator/string-codec-aot.mjs +7 -45
  286. package/dist/type/validator/validator-cache.d.ts +14 -9
  287. package/dist/type/validator/validator-cache.js +165 -80
  288. package/dist/type/validator/validator-cache.mjs +162 -80
  289. package/dist/types.d.ts +191 -102
  290. package/dist/universal/constants.d.ts +1 -3
  291. package/dist/universal/constants.js +1 -5
  292. package/dist/universal/constants.mjs +1 -3
  293. package/dist/universal/env.d.ts +3 -2
  294. package/dist/universal/env.js +6 -2
  295. package/dist/universal/env.mjs +5 -2
  296. package/dist/universal/file.d.ts +12 -5
  297. package/dist/universal/file.js +76 -47
  298. package/dist/universal/file.mjs +76 -47
  299. package/dist/universal/index.d.ts +2 -1
  300. package/dist/universal/index.js +3 -1
  301. package/dist/universal/index.mjs +2 -1
  302. package/dist/universal/is-production.d.ts +5 -0
  303. package/dist/universal/is-production.js +10 -0
  304. package/dist/universal/is-production.mjs +8 -0
  305. package/dist/universal/server.d.ts +1 -0
  306. package/dist/utils.d.ts +51 -21
  307. package/dist/utils.js +293 -54
  308. package/dist/utils.mjs +278 -53
  309. package/dist/validator/index.d.ts +13 -12
  310. package/dist/validator/index.js +157 -68
  311. package/dist/validator/index.mjs +158 -69
  312. package/dist/validator/route.d.ts +0 -1
  313. package/dist/validator/route.js +5 -3
  314. package/dist/validator/route.mjs +6 -4
  315. package/dist/ws/context.d.ts +13 -12
  316. package/dist/ws/context.js +33 -67
  317. package/dist/ws/context.mjs +33 -67
  318. package/dist/ws/parser.d.ts +1 -4
  319. package/dist/ws/route.d.ts +8 -3
  320. package/dist/ws/route.js +343 -133
  321. package/dist/ws/route.mjs +341 -135
  322. package/dist/ws/types.d.ts +47 -5
  323. package/package.json +78 -32
  324. package/dist/adapter/bun/router.d.ts +0 -10
  325. package/dist/adapter/bun/router.js +0 -86
  326. package/dist/adapter/bun/router.mjs +0 -83
  327. package/dist/compile/handler/constants.js +0 -1
  328. package/dist/compile/handler/constants.mjs +0 -1
  329. package/dist/compile/index.d.ts +0 -3
  330. package/dist/compile/index.js +0 -8
  331. package/dist/compile/index.mjs +0 -4
  332. package/dist/compile/types.d.ts +0 -4
  333. package/dist/compile/types.js +0 -1
  334. package/dist/compile/types.mjs +0 -1
  335. package/dist/plugin/bun.js +0 -82
  336. package/dist/plugin/bun.mjs +0 -80
  337. package/dist/plugin/core.d.ts +0 -87
  338. package/dist/plugin/core.js +0 -109
  339. package/dist/plugin/core.mjs +0 -102
  340. package/dist/plugin/esbuild.js +0 -83
  341. package/dist/plugin/esbuild.mjs +0 -81
  342. package/dist/plugin/source.d.ts +0 -75
  343. package/dist/plugin/source.js +0 -354
  344. package/dist/plugin/source.mjs +0 -349
  345. package/dist/plugin/treeshake.d.ts +0 -10
  346. package/dist/plugin/treeshake.js +0 -63
  347. package/dist/plugin/treeshake.mjs +0 -61
  348. package/dist/plugin/vite.js +0 -61
  349. package/dist/plugin/vite.mjs +0 -60
  350. package/dist/universal/types.d.ts +0 -127
  351. package/dist/universal/types.js +0 -20
  352. package/dist/universal/types.mjs +0 -17
  353. /package/dist/{compile/handler/constants.d.ts → plugin/aot/worker.d.ts} +0 -0
@@ -5,19 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __exportAll = (all, no_symbols) => {
9
- let target = {};
10
- for (var name in all) {
11
- __defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- }
16
- if (!no_symbols) {
17
- __defProp(target, Symbol.toStringTag, { value: "Module" });
18
- }
19
- return target;
20
- };
21
8
  var __copyProps = (to, from, except, desc) => {
22
9
  if (from && typeof from === "object" || typeof from === "function") {
23
10
  for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -39,5 +26,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
26
 
40
27
  //#endregion
41
28
 
42
- exports.__exportAll = __exportAll;
43
29
  exports.__toESM = __toESM;
@@ -1,3 +1,5 @@
1
+ import { createRequire } from "node:module";
2
+
1
3
  //#region \0rolldown/runtime.js
2
4
  var __defProp = Object.defineProperty;
3
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,30 +1,7 @@
1
- import { ListenCallback, Serve } from "../../universal/server.js";
2
- import { AnyLocalHook, MaybePromise } from "../../types.js";
3
- import { Context } from "../../context.js";
4
1
  import { AnyElysia } from "../../base.js";
2
+ import { ElysiaAdapterOptions } from "../types.js";
5
3
  //#region src/adapter/bun/index.d.ts
6
- declare function collectStaticRoutes(app: AnyElysia): readonly [Record<string, Record<string, Response>>, Promise<void>[]] | undefined;
7
- declare const BunAdapter: {
8
- parse: {
9
- default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
10
- json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
11
- text: (context: Context) => MaybePromise<string>;
12
- urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
13
- arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
14
- formData: (context: Context) => MaybePromise<Record<string, unknown>>;
15
- };
16
- name: string;
17
- runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
18
- isWebStandard: boolean;
19
- listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
20
- stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
21
- response: {
22
- map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
23
- compact?(response: unknown, ...params: unknown[]): unknown;
24
- static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
25
- nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
26
- };
27
- fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
28
- };
4
+ declare function collectStaticRoutes(app: AnyElysia): readonly [Record<string, Record<string, Response>>, readonly []] | undefined;
5
+ declare const BunAdapter: ElysiaAdapterOptions;
29
6
  //#endregion
30
7
  export { BunAdapter, collectStaticRoutes };
@@ -1,84 +1,223 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_adapter_index = require('../index.js');
3
+ const require_constants = require('../../constants.js');
3
4
  const require_utils = require('../../utils.js');
4
5
  const require_adapter_web_standard_index = require('../web-standard/index.js');
5
- const require_memory = require('../../memory.js');
6
- const require_ws_route = require('../../ws/route.js');
6
+ const require_generation = require('../../generation.js');
7
+ const require_compile_handler_index = require('../../compile/handler/index.js');
8
+ const require_route_table = require('../../route-table.js');
9
+ const require_adapter_origin = require('../origin.js');
7
10
 
8
11
  //#region src/adapter/bun/index.ts
12
+ /**
13
+ * ! This may looks like it would cause race condition, but it is not
14
+ * Bun is single-threaded and synchronous, so the `finally` block will
15
+ * always run before the next request comes in
16
+ * @see ../origin.ts
17
+ *
18
+ * Publish the request `Bun.serve` handed us so `createFetchHandler` can prove,
19
+ * before its first suspension, that it holds the untouched original and may
20
+ * defer materializing `request.signal`
21
+ *
22
+ * `finally` runs on the synchronous return of `fetch` (the returned promise is
23
+ * not awaited), so the slot is live only for the handler's synchronous prologue.
24
+ */
25
+ const withOrigin = (fetch) => (request, server) => {
26
+ require_adapter_origin.origin.request = request;
27
+ try {
28
+ return fetch(request, server);
29
+ } finally {
30
+ require_adapter_origin.origin.request = void 0;
31
+ }
32
+ };
33
+ const nativeStaticMethods = new Set([
34
+ "GET",
35
+ "POST",
36
+ "PUT",
37
+ "DELETE",
38
+ "PATCH",
39
+ "HEAD",
40
+ "OPTIONS"
41
+ ]);
9
42
  function collectStaticRoutes(app) {
10
- if (app["~ext"]?.hoc?.length) return;
11
- const hook = require_utils.flattenChain(app["~hookChain"]);
12
- if (hook && (hook?.request?.length || hook?.mapResponse?.length || hook?.afterResponse?.length || hook?.trace?.length)) return;
43
+ if (app["~config"]?.nativeStaticResponse === false) return;
13
44
  app.fetch;
14
- const source = app["~staticResponse"];
15
- if (!source) return;
45
+ const frozenRoot = require_generation.frozenRootOf(app);
46
+ const fetchLevelHook = require_utils.flattenChain(frozenRoot["~hookChain"]);
47
+ if (fetchLevelHook?.request?.length || fetchLevelHook?.trace?.length || frozenRoot["~ext"]?.hoc?.length) return;
48
+ const table = app["~generation"]?.routeTable ?? app["~routeTable"];
49
+ const length = table?.length ?? 0;
50
+ if (!table || !length) return;
51
+ const methods = table.method;
52
+ const paths = table.path;
53
+ const handlers = table.handler;
54
+ let hasCandidate = false;
55
+ for (let i = 0; i < length; i++) {
56
+ const h = handlers[i];
57
+ if (typeof h === "function" || h instanceof Error || h instanceof Promise) continue;
58
+ if (!nativeStaticMethods.has(methods[i])) continue;
59
+ hasCandidate = true;
60
+ break;
61
+ }
62
+ if (!hasCandidate) return;
16
63
  const ready = require_utils.nullObject();
17
- const pending = [];
18
- for (const rawPath in source) {
19
- const path = encodeURI(rawPath);
20
- const methods = source[rawPath];
21
- for (const method in methods) {
22
- const value = methods[method];
23
- if (value instanceof Promise) pending.push(value.then((resolved) => {
24
- if (resolved instanceof Response) (ready[path] ??= require_utils.nullObject())[method] = resolved;
25
- }, (err) => {
26
- console.error(`[Elysia] Static route ${method} ${path} failed to resolve:`, err);
27
- }));
28
- else (ready[path] ??= require_utils.nullObject())[method] = value;
64
+ const strictPath = frozenRoot["~config"]?.strictPath === true;
65
+ const seen = /* @__PURE__ */ new Map();
66
+ for (let i = 0; i < length; i++) seen.set(methods[i] + " " + paths[i], i);
67
+ let explicitPaths;
68
+ if (!strictPath) {
69
+ explicitPaths = /* @__PURE__ */ new Map();
70
+ for (let i = 0; i < length; i++) {
71
+ const method = methods[i];
72
+ const path = paths[i];
73
+ let set = explicitPaths.get(method);
74
+ if (!set) explicitPaths.set(method, set = /* @__PURE__ */ new Set());
75
+ set.add(path);
76
+ if (require_constants.needEncodeRegex.test(path)) {
77
+ const encoded = encodeURI(path);
78
+ if (encoded !== path) set.add(encoded);
79
+ }
29
80
  }
30
81
  }
31
- return [ready, pending];
82
+ const add = (method, path, value) => {
83
+ if (require_constants.needEncodeRegex.test(path)) path = encodeURI(path);
84
+ (ready[path] ??= require_utils.nullObject())[method] = value;
85
+ };
86
+ for (let i = 0; i < length; i++) {
87
+ const method = methods[i];
88
+ if (method === "WS") continue;
89
+ const path = paths[i];
90
+ if (seen.get(method + " " + path) !== i) continue;
91
+ if (!nativeStaticMethods.has(method)) continue;
92
+ const h = handlers[i];
93
+ if (typeof h === "function" || h instanceof Error || h instanceof Promise) continue;
94
+ const value = require_compile_handler_index.buildNativeStaticResponse(require_route_table.routeRow(table, i), app);
95
+ if (!value) continue;
96
+ add(method, path, value);
97
+ if (!strictPath && !require_constants.isDynamicRegex.test(path)) {
98
+ const loose = require_utils.getLoosePath(path);
99
+ if (loose !== path && !explicitPaths?.get(method)?.has(loose)) add(method, loose, value);
100
+ }
101
+ }
102
+ if (!Object.keys(ready).length) return;
103
+ return [ready, []];
32
104
  }
33
105
  const BunAdapter = require_adapter_index.createAdapter({
34
- ...require_adapter_web_standard_index.WebStandardAdapter,
35
106
  name: "bun",
36
107
  runtime: "bun",
108
+ isWebStandard: true,
109
+ parse: require_adapter_web_standard_index.WebStandardAdapter.parse,
110
+ response: require_adapter_web_standard_index.WebStandardAdapter.response,
37
111
  listen(app, options, callback) {
38
112
  const _config = app["~config"]?.serve;
39
- const _options = typeof options === "object" ? options : { port: +options };
113
+ const optionsIsObject = typeof options === "object";
114
+ const _options = optionsIsObject ? { ...options } : {
115
+ port: +options,
116
+ fetch: (request, server) => app.fetch(request, server)
117
+ };
118
+ if (optionsIsObject) _options.fetch = (request, server) => app.fetch(request, server);
40
119
  const serve = _config ? {
41
120
  ..._config,
42
121
  ..._options
43
122
  } : _options;
44
- const hasWs = app["~hasWS"];
45
- serve.fetch = (request, server) => app.fetch(request, server);
46
- app.server = Bun.serve(serve);
47
- if (!hasWs) callback?.(app.server);
48
- queueMicrotask(() => {
49
- if (!app.pending) serve.fetch = app.fetch;
50
- const buildWebSocket = () => {
51
- const defaultConfig = app["~config"]?.websocket;
52
- serve.websocket = defaultConfig ? Object.assign(require_ws_route.buildGlobalWSHandler(), defaultConfig) : require_ws_route.buildGlobalWSHandler();
53
- };
54
- if (hasWs) buildWebSocket();
55
- const collectRoutes = () => {
56
- const staticRoutes = collectStaticRoutes(app);
57
- if (!staticRoutes) return;
58
- if (staticRoutes[1].length) return Promise.all(staticRoutes[1]).then(() => {
59
- serve.routes = staticRoutes[0];
60
- app.server.reload(serve);
61
- });
62
- if (Object.keys(staticRoutes[0]).length) serve.routes = staticRoutes[0];
123
+ const onSetup = app["~ext"]?.setup;
124
+ const needsGate = app.pending || !!onSetup?.length;
125
+ let ready;
126
+ const build = () => {
127
+ const fetch = app.fetch;
128
+ let routes;
129
+ try {
130
+ routes = collectStaticRoutes(app);
131
+ } catch (error) {
132
+ console.warn("[Elysia] Native static promotion was skipped:", error);
133
+ }
134
+ let websocket;
135
+ if (app["~hasWS"]) {
136
+ const resolved = require_generation.resolvedWsOf(app);
137
+ if (!resolved) throw new Error("[Elysia] internal: WebSocket routes are present but no capability provider was resolved.");
138
+ websocket = resolved.config ? Object.assign(resolved.provider.buildGlobalWSHandler(), resolved.config) : resolved.provider.buildGlobalWSHandler();
139
+ }
140
+ return {
141
+ fetch,
142
+ routes,
143
+ websocket
63
144
  };
64
- if (app.pending) {
65
- if (app.server) app.server.reload(serve);
66
- else app.server = Bun.serve(serve);
67
- const reloadAfterModules = () => {
68
- serve.fetch = app.fetch;
69
- if (hasWs || app["~hasWS"]) buildWebSocket();
70
- collectRoutes();
71
- app.server.reload(serve);
72
- };
73
- app.modules.then(reloadAfterModules, reloadAfterModules);
74
- } else {
75
- collectRoutes();
76
- if (app.server) app.server.reload(serve);
77
- else app.server = Bun.serve(serve);
145
+ };
146
+ let built;
147
+ if (!needsGate) built = build();
148
+ if (needsGate) serve.fetch = (request, server) => ready.then(() => app.fetch(request, server));
149
+ else serve.fetch = withOrigin(built.fetch);
150
+ const server = app.server = Bun.serve(serve);
151
+ const reload = () => {
152
+ try {
153
+ server.reload(serve);
154
+ } catch (error) {
155
+ if (!serve.routes) throw error;
156
+ delete serve.routes;
157
+ console.warn("[Elysia] Native static promotion was skipped:", error);
158
+ try {
159
+ server.reload(serve);
160
+ } catch (fallbackError) {
161
+ console.error("[Elysia] Failed to reload Bun server:", fallbackError);
162
+ throw fallbackError;
163
+ }
164
+ }
165
+ };
166
+ const setup = () => {
167
+ const onSetup = app["~ext"]?.setup;
168
+ if (!onSetup) return;
169
+ let pendingSetups;
170
+ for (let i = 0; i < onSetup.length; i++) {
171
+ const result = onSetup[i](app);
172
+ if (result && typeof result.then === "function") (pendingSetups ??= []).push(result);
173
+ }
174
+ if (pendingSetups) return Promise.all(pendingSetups);
175
+ };
176
+ const rollback = (error) => {
177
+ if (app.server !== server) return;
178
+ try {
179
+ server.stop(true);
180
+ } catch (stopError) {
181
+ console.error(stopError);
182
+ } finally {
183
+ app.server = void 0;
78
184
  }
79
- require_memory.flushMemory();
80
- if (hasWs) callback?.(app.server);
81
- });
185
+ const cleanup = app["~ext"]?.cleanup;
186
+ if (cleanup) for (let i = cleanup.length - 1; i >= 0; i--) try {
187
+ const result = cleanup[i](app);
188
+ if (result && typeof result.then === "function") Promise.resolve(result).catch(console.error);
189
+ } catch (cleanupError) {
190
+ console.error(cleanupError);
191
+ }
192
+ return error;
193
+ };
194
+ const publish = () => {
195
+ if (app.server !== server) return;
196
+ built ??= build();
197
+ serve.fetch = withOrigin(built.fetch);
198
+ if (built.websocket) serve.websocket = built.websocket;
199
+ if (built.routes) serve.routes = built.routes[0];
200
+ if (needsGate || built.websocket || built.routes) reload();
201
+ if (callback) callback(server);
202
+ };
203
+ const start = () => {
204
+ if (app.server !== server) return;
205
+ const setupReady = setup();
206
+ if (setupReady && typeof setupReady.then === "function") return Promise.resolve(setupReady).then(publish);
207
+ publish();
208
+ };
209
+ try {
210
+ if (app.pending) ready = app.modules.then(start);
211
+ else {
212
+ const result = start();
213
+ if (result && typeof result.then === "function") ready = result;
214
+ else if (needsGate) ready = Promise.resolve();
215
+ }
216
+ ready?.catch(rollback);
217
+ } catch (error) {
218
+ rollback(error);
219
+ throw error;
220
+ }
82
221
  }
83
222
  });
84
223
 
@@ -1,83 +1,222 @@
1
1
  import { createAdapter } from "../index.mjs";
2
- import { flattenChain, nullObject } from "../../utils.mjs";
2
+ import { isDynamicRegex, needEncodeRegex } from "../../constants.mjs";
3
+ import { flattenChain, getLoosePath, nullObject } from "../../utils.mjs";
3
4
  import { WebStandardAdapter } from "../web-standard/index.mjs";
4
- import { flushMemory } from "../../memory.mjs";
5
- import { buildGlobalWSHandler } from "../../ws/route.mjs";
5
+ import { frozenRootOf, resolvedWsOf } from "../../generation.mjs";
6
+ import { buildNativeStaticResponse } from "../../compile/handler/index.mjs";
7
+ import { routeRow } from "../../route-table.mjs";
8
+ import { origin } from "../origin.mjs";
6
9
 
7
10
  //#region src/adapter/bun/index.ts
11
+ /**
12
+ * ! This may looks like it would cause race condition, but it is not
13
+ * Bun is single-threaded and synchronous, so the `finally` block will
14
+ * always run before the next request comes in
15
+ * @see ../origin.ts
16
+ *
17
+ * Publish the request `Bun.serve` handed us so `createFetchHandler` can prove,
18
+ * before its first suspension, that it holds the untouched original and may
19
+ * defer materializing `request.signal`
20
+ *
21
+ * `finally` runs on the synchronous return of `fetch` (the returned promise is
22
+ * not awaited), so the slot is live only for the handler's synchronous prologue.
23
+ */
24
+ const withOrigin = (fetch) => (request, server) => {
25
+ origin.request = request;
26
+ try {
27
+ return fetch(request, server);
28
+ } finally {
29
+ origin.request = void 0;
30
+ }
31
+ };
32
+ const nativeStaticMethods = new Set([
33
+ "GET",
34
+ "POST",
35
+ "PUT",
36
+ "DELETE",
37
+ "PATCH",
38
+ "HEAD",
39
+ "OPTIONS"
40
+ ]);
8
41
  function collectStaticRoutes(app) {
9
- if (app["~ext"]?.hoc?.length) return;
10
- const hook = flattenChain(app["~hookChain"]);
11
- if (hook && (hook?.request?.length || hook?.mapResponse?.length || hook?.afterResponse?.length || hook?.trace?.length)) return;
42
+ if (app["~config"]?.nativeStaticResponse === false) return;
12
43
  app.fetch;
13
- const source = app["~staticResponse"];
14
- if (!source) return;
44
+ const frozenRoot = frozenRootOf(app);
45
+ const fetchLevelHook = flattenChain(frozenRoot["~hookChain"]);
46
+ if (fetchLevelHook?.request?.length || fetchLevelHook?.trace?.length || frozenRoot["~ext"]?.hoc?.length) return;
47
+ const table = app["~generation"]?.routeTable ?? app["~routeTable"];
48
+ const length = table?.length ?? 0;
49
+ if (!table || !length) return;
50
+ const methods = table.method;
51
+ const paths = table.path;
52
+ const handlers = table.handler;
53
+ let hasCandidate = false;
54
+ for (let i = 0; i < length; i++) {
55
+ const h = handlers[i];
56
+ if (typeof h === "function" || h instanceof Error || h instanceof Promise) continue;
57
+ if (!nativeStaticMethods.has(methods[i])) continue;
58
+ hasCandidate = true;
59
+ break;
60
+ }
61
+ if (!hasCandidate) return;
15
62
  const ready = nullObject();
16
- const pending = [];
17
- for (const rawPath in source) {
18
- const path = encodeURI(rawPath);
19
- const methods = source[rawPath];
20
- for (const method in methods) {
21
- const value = methods[method];
22
- if (value instanceof Promise) pending.push(value.then((resolved) => {
23
- if (resolved instanceof Response) (ready[path] ??= nullObject())[method] = resolved;
24
- }, (err) => {
25
- console.error(`[Elysia] Static route ${method} ${path} failed to resolve:`, err);
26
- }));
27
- else (ready[path] ??= nullObject())[method] = value;
63
+ const strictPath = frozenRoot["~config"]?.strictPath === true;
64
+ const seen = /* @__PURE__ */ new Map();
65
+ for (let i = 0; i < length; i++) seen.set(methods[i] + " " + paths[i], i);
66
+ let explicitPaths;
67
+ if (!strictPath) {
68
+ explicitPaths = /* @__PURE__ */ new Map();
69
+ for (let i = 0; i < length; i++) {
70
+ const method = methods[i];
71
+ const path = paths[i];
72
+ let set = explicitPaths.get(method);
73
+ if (!set) explicitPaths.set(method, set = /* @__PURE__ */ new Set());
74
+ set.add(path);
75
+ if (needEncodeRegex.test(path)) {
76
+ const encoded = encodeURI(path);
77
+ if (encoded !== path) set.add(encoded);
78
+ }
28
79
  }
29
80
  }
30
- return [ready, pending];
81
+ const add = (method, path, value) => {
82
+ if (needEncodeRegex.test(path)) path = encodeURI(path);
83
+ (ready[path] ??= nullObject())[method] = value;
84
+ };
85
+ for (let i = 0; i < length; i++) {
86
+ const method = methods[i];
87
+ if (method === "WS") continue;
88
+ const path = paths[i];
89
+ if (seen.get(method + " " + path) !== i) continue;
90
+ if (!nativeStaticMethods.has(method)) continue;
91
+ const h = handlers[i];
92
+ if (typeof h === "function" || h instanceof Error || h instanceof Promise) continue;
93
+ const value = buildNativeStaticResponse(routeRow(table, i), app);
94
+ if (!value) continue;
95
+ add(method, path, value);
96
+ if (!strictPath && !isDynamicRegex.test(path)) {
97
+ const loose = getLoosePath(path);
98
+ if (loose !== path && !explicitPaths?.get(method)?.has(loose)) add(method, loose, value);
99
+ }
100
+ }
101
+ if (!Object.keys(ready).length) return;
102
+ return [ready, []];
31
103
  }
32
104
  const BunAdapter = createAdapter({
33
- ...WebStandardAdapter,
34
105
  name: "bun",
35
106
  runtime: "bun",
107
+ isWebStandard: true,
108
+ parse: WebStandardAdapter.parse,
109
+ response: WebStandardAdapter.response,
36
110
  listen(app, options, callback) {
37
111
  const _config = app["~config"]?.serve;
38
- const _options = typeof options === "object" ? options : { port: +options };
112
+ const optionsIsObject = typeof options === "object";
113
+ const _options = optionsIsObject ? { ...options } : {
114
+ port: +options,
115
+ fetch: (request, server) => app.fetch(request, server)
116
+ };
117
+ if (optionsIsObject) _options.fetch = (request, server) => app.fetch(request, server);
39
118
  const serve = _config ? {
40
119
  ..._config,
41
120
  ..._options
42
121
  } : _options;
43
- const hasWs = app["~hasWS"];
44
- serve.fetch = (request, server) => app.fetch(request, server);
45
- app.server = Bun.serve(serve);
46
- if (!hasWs) callback?.(app.server);
47
- queueMicrotask(() => {
48
- if (!app.pending) serve.fetch = app.fetch;
49
- const buildWebSocket = () => {
50
- const defaultConfig = app["~config"]?.websocket;
51
- serve.websocket = defaultConfig ? Object.assign(buildGlobalWSHandler(), defaultConfig) : buildGlobalWSHandler();
52
- };
53
- if (hasWs) buildWebSocket();
54
- const collectRoutes = () => {
55
- const staticRoutes = collectStaticRoutes(app);
56
- if (!staticRoutes) return;
57
- if (staticRoutes[1].length) return Promise.all(staticRoutes[1]).then(() => {
58
- serve.routes = staticRoutes[0];
59
- app.server.reload(serve);
60
- });
61
- if (Object.keys(staticRoutes[0]).length) serve.routes = staticRoutes[0];
122
+ const onSetup = app["~ext"]?.setup;
123
+ const needsGate = app.pending || !!onSetup?.length;
124
+ let ready;
125
+ const build = () => {
126
+ const fetch = app.fetch;
127
+ let routes;
128
+ try {
129
+ routes = collectStaticRoutes(app);
130
+ } catch (error) {
131
+ console.warn("[Elysia] Native static promotion was skipped:", error);
132
+ }
133
+ let websocket;
134
+ if (app["~hasWS"]) {
135
+ const resolved = resolvedWsOf(app);
136
+ if (!resolved) throw new Error("[Elysia] internal: WebSocket routes are present but no capability provider was resolved.");
137
+ websocket = resolved.config ? Object.assign(resolved.provider.buildGlobalWSHandler(), resolved.config) : resolved.provider.buildGlobalWSHandler();
138
+ }
139
+ return {
140
+ fetch,
141
+ routes,
142
+ websocket
62
143
  };
63
- if (app.pending) {
64
- if (app.server) app.server.reload(serve);
65
- else app.server = Bun.serve(serve);
66
- const reloadAfterModules = () => {
67
- serve.fetch = app.fetch;
68
- if (hasWs || app["~hasWS"]) buildWebSocket();
69
- collectRoutes();
70
- app.server.reload(serve);
71
- };
72
- app.modules.then(reloadAfterModules, reloadAfterModules);
73
- } else {
74
- collectRoutes();
75
- if (app.server) app.server.reload(serve);
76
- else app.server = Bun.serve(serve);
144
+ };
145
+ let built;
146
+ if (!needsGate) built = build();
147
+ if (needsGate) serve.fetch = (request, server) => ready.then(() => app.fetch(request, server));
148
+ else serve.fetch = withOrigin(built.fetch);
149
+ const server = app.server = Bun.serve(serve);
150
+ const reload = () => {
151
+ try {
152
+ server.reload(serve);
153
+ } catch (error) {
154
+ if (!serve.routes) throw error;
155
+ delete serve.routes;
156
+ console.warn("[Elysia] Native static promotion was skipped:", error);
157
+ try {
158
+ server.reload(serve);
159
+ } catch (fallbackError) {
160
+ console.error("[Elysia] Failed to reload Bun server:", fallbackError);
161
+ throw fallbackError;
162
+ }
163
+ }
164
+ };
165
+ const setup = () => {
166
+ const onSetup = app["~ext"]?.setup;
167
+ if (!onSetup) return;
168
+ let pendingSetups;
169
+ for (let i = 0; i < onSetup.length; i++) {
170
+ const result = onSetup[i](app);
171
+ if (result && typeof result.then === "function") (pendingSetups ??= []).push(result);
172
+ }
173
+ if (pendingSetups) return Promise.all(pendingSetups);
174
+ };
175
+ const rollback = (error) => {
176
+ if (app.server !== server) return;
177
+ try {
178
+ server.stop(true);
179
+ } catch (stopError) {
180
+ console.error(stopError);
181
+ } finally {
182
+ app.server = void 0;
77
183
  }
78
- flushMemory();
79
- if (hasWs) callback?.(app.server);
80
- });
184
+ const cleanup = app["~ext"]?.cleanup;
185
+ if (cleanup) for (let i = cleanup.length - 1; i >= 0; i--) try {
186
+ const result = cleanup[i](app);
187
+ if (result && typeof result.then === "function") Promise.resolve(result).catch(console.error);
188
+ } catch (cleanupError) {
189
+ console.error(cleanupError);
190
+ }
191
+ return error;
192
+ };
193
+ const publish = () => {
194
+ if (app.server !== server) return;
195
+ built ??= build();
196
+ serve.fetch = withOrigin(built.fetch);
197
+ if (built.websocket) serve.websocket = built.websocket;
198
+ if (built.routes) serve.routes = built.routes[0];
199
+ if (needsGate || built.websocket || built.routes) reload();
200
+ if (callback) callback(server);
201
+ };
202
+ const start = () => {
203
+ if (app.server !== server) return;
204
+ const setupReady = setup();
205
+ if (setupReady && typeof setupReady.then === "function") return Promise.resolve(setupReady).then(publish);
206
+ publish();
207
+ };
208
+ try {
209
+ if (app.pending) ready = app.modules.then(start);
210
+ else {
211
+ const result = start();
212
+ if (result && typeof result.then === "function") ready = result;
213
+ else if (needsGate) ready = Promise.resolve();
214
+ }
215
+ ready?.catch(rollback);
216
+ } catch (error) {
217
+ rollback(error);
218
+ throw error;
219
+ }
81
220
  }
82
221
  });
83
222
 
@@ -1,29 +1,6 @@
1
- import { ListenCallback, Serve } from "../universal/server.js";
2
- import { AnyLocalHook, MaybePromise } from "../types.js";
3
- import { Context } from "../context.js";
4
- import { AnyElysia } from "../base.js";
1
+ import { ElysiaAdapterOptions } from "./types.js";
2
+
5
3
  //#region src/adapter/constants.d.ts
6
- declare const defaultAdapter: {
7
- parse: {
8
- default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
9
- json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
10
- text: (context: Context) => MaybePromise<string>;
11
- urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
12
- arrayBuffer: (context: Context) => MaybePromise<ArrayBuffer>;
13
- formData: (context: Context) => MaybePromise<Record<string, unknown>>;
14
- };
15
- name: string;
16
- runtime: "node" | "deno" | "bun" | "cloudflare-worker" | "browser" | "vercel" | "netlify" | "lambda" | "fastly" | "edge" | "unknown" | (string & {});
17
- isWebStandard: boolean;
18
- listen?(app: AnyElysia, options: string | number | Partial<Serve>, callback?: ListenCallback): void;
19
- stop?(app: AnyElysia, closeActiveConnections?: boolean): Promise<void>;
20
- response: {
21
- map(response: unknown, set: Context["set"], ...params: unknown[]): unknown;
22
- compact?(response: unknown, ...params: unknown[]): unknown;
23
- static?(handle: unknown, hooks: AnyLocalHook, setHeaders?: Context["set"]["headers"], ...params: unknown[]): (() => unknown) | undefined;
24
- nativeStatic?(handle: unknown, hooks: AnyLocalHook, set?: Context["set"]): (() => MaybePromise<Response>) | undefined;
25
- };
26
- fetch?(app: AnyElysia): (request: Request) => MaybePromise<Response>;
27
- };
4
+ declare const defaultAdapter: ElysiaAdapterOptions;
28
5
  //#endregion
29
6
  export { defaultAdapter };