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
@@ -1,7 +1,6 @@
1
1
  import { createAotPluginHooks } from "./hooks.mjs";
2
2
 
3
3
  //#region src/plugin/aot/unplugin.ts
4
- const cleanIdOf = (id) => id.split("?", 1)[0];
5
4
  const VIRTUAL_MANIFEST_RESOURCE = /%00elysia%2Fcompiled/;
6
5
  const forceManifestSideEffect = (compiler) => {
7
6
  compiler.options.module.rules.push({
@@ -36,18 +35,10 @@ const aotFactory = (options) => {
36
35
  enforce: "pre",
37
36
  buildStart: hooks.buildStart,
38
37
  buildEnd: hooks.buildEnd,
39
- resolveId(id) {
40
- return hooks.resolveId(id) ?? void 0;
41
- },
42
- load(id) {
43
- return hooks.load(id) ?? void 0;
44
- },
45
- transformInclude(id) {
46
- return hooks.isTransformCandidate(cleanIdOf(id));
47
- },
48
- transform(code, id) {
49
- return hooks.transform(code, id);
50
- },
38
+ resolveId: hooks.resolveId,
39
+ load: hooks.load,
40
+ transformInclude: hooks.isTransformCandidate,
41
+ transform: hooks.transform,
51
42
  vite: { apply: "build" },
52
43
  rspack(compiler) {
53
44
  forceManifestSideEffect(compiler);
@@ -1,15 +1,11 @@
1
1
  import { ElysiaAotOptions } from "./core.js";
2
+ import { AotPluginHooks } from "./hooks.js";
2
3
 
3
4
  //#region src/plugin/aot/vite.d.ts
4
- interface ElysiaAotVitePlugin {
5
+ interface ElysiaAotVitePlugin extends Omit<AotPluginHooks, 'isTransformCandidate'> {
5
6
  name: string;
6
7
  enforce?: 'pre';
7
8
  apply?: 'build';
8
- buildStart(): Promise<void>;
9
- buildEnd(): void;
10
- resolveId(id: string): string | undefined;
11
- load(id: string): string | undefined;
12
- transform(code: string, id: string): string | undefined | Promise<string | undefined>;
13
9
  }
14
10
  /**
15
11
  * Elysia AOT build plugin
@@ -6,8 +6,8 @@ let node_worker_threads = require("node:worker_threads");
6
6
  //#region src/plugin/aot/worker.ts
7
7
  const port = node_worker_threads.parentPort;
8
8
  if (!port) throw new Error("[elysia-aot] worker requires a parent port");
9
- const { file, options } = node_worker_threads.workerData;
10
- require_plugin_aot_core.generateCompiledArtifacts(file, options).then((artifacts) => port.postMessage({
9
+ const { file, options, moduleCondition } = node_worker_threads.workerData;
10
+ require_plugin_aot_core.generateCompiledArtifacts(file, options, moduleCondition).then((artifacts) => port.postMessage({
11
11
  ok: true,
12
12
  artifacts
13
13
  }), (error) => {
@@ -4,8 +4,8 @@ import { parentPort, workerData } from "node:worker_threads";
4
4
  //#region src/plugin/aot/worker.ts
5
5
  const port = parentPort;
6
6
  if (!port) throw new Error("[elysia-aot] worker requires a parent port");
7
- const { file, options } = workerData;
8
- generateCompiledArtifacts(file, options).then((artifacts) => port.postMessage({
7
+ const { file, options, moduleCondition } = workerData;
8
+ generateCompiledArtifacts(file, options, moduleCondition).then((artifacts) => port.postMessage({
9
9
  ok: true,
10
10
  artifacts
11
11
  }), (error) => {
@@ -21,16 +21,7 @@ const autoHead = () => async (app) => {
21
21
  for (let i = 0; i < routes.length; i++) if (routes[i][0] === "HEAD") explicitHead.add(routes[i][1]);
22
22
  for (let i = 0; i < routes.length; i++) {
23
23
  const route = routes[i];
24
- if (route[0] === "GET" && !explicitHead.has(route[1])) app["~addRoute"]([
25
- "HEAD",
26
- route[1],
27
- route[2],
28
- route[3],
29
- route[4],
30
- route[5],
31
- route[6],
32
- route[7]
33
- ]);
24
+ if (route[0] === "GET" && !explicitHead.has(route[1])) app["~addRoute"](route.with(0, "HEAD"));
34
25
  }
35
26
  };
36
27
 
@@ -19,16 +19,7 @@ const autoHead = () => async (app) => {
19
19
  for (let i = 0; i < routes.length; i++) if (routes[i][0] === "HEAD") explicitHead.add(routes[i][1]);
20
20
  for (let i = 0; i < routes.length; i++) {
21
21
  const route = routes[i];
22
- if (route[0] === "GET" && !explicitHead.has(route[1])) app["~addRoute"]([
23
- "HEAD",
24
- route[1],
25
- route[2],
26
- route[3],
27
- route[4],
28
- route[5],
29
- route[6],
30
- route[7]
31
- ]);
22
+ if (route[0] === "GET" && !explicitHead.has(route[1])) app["~addRoute"](route.with(0, "HEAD"));
32
23
  }
33
24
  };
34
25
 
@@ -1,4 +1,5 @@
1
- import { TraceCapability, TraceEndDetail, TraceEvent, TraceHandler, TraceListener, TraceProcess, TraceStream, createTracer, unionTracePhases } from "../trace.js";
1
+ import { TraceEvent } from "../constants.js";
2
+ import { TraceCapability, TraceEndDetail, TraceHandler, TraceListener, TraceProcess, TraceStream, createTracer, unionTracePhases } from "../trace.js";
2
3
  import { DefaultEphemeral, DefaultMetadata, DefaultSingleton } from "../types.js";
3
4
  import { Elysia } from "../base.js";
4
5
  //#region src/plugin/trace.d.ts
@@ -7,6 +7,9 @@ declare const RouteFlag: {
7
7
  readonly WS: 1;
8
8
  readonly Dynamic: 2;
9
9
  readonly Encode: 4;
10
+ readonly ExactDuplicate: 8;
11
+ readonly JITCold: 16;
12
+ readonly JITSatisfied: 32;
10
13
  };
11
14
  interface RouteTable {
12
15
  readonly length: number;
@@ -5,7 +5,10 @@ const require_constants = require('./constants.js');
5
5
  const RouteFlag = {
6
6
  WS: 1,
7
7
  Dynamic: 2,
8
- Encode: 4
8
+ Encode: 4,
9
+ ExactDuplicate: 8,
10
+ JITCold: 16,
11
+ JITSatisfied: 32
9
12
  };
10
13
  function buildRouteTable(declaredRoutes) {
11
14
  const length = declaredRoutes.length;
@@ -47,16 +50,18 @@ function buildRouteTable(declaredRoutes) {
47
50
  macroScope
48
51
  };
49
52
  }
50
- const routeRow = (table, id) => [
51
- table.method[id],
52
- table.path[id],
53
- table.handler[id],
54
- table.owner[id],
55
- table.localHook[id],
56
- table.appHook[id],
57
- table.inheritedChain[id],
58
- table.macroScope?.get(id)
59
- ];
53
+ const routeRow = (table, id) => {
54
+ return [
55
+ table.method[id],
56
+ table.path[id],
57
+ table.handler[id],
58
+ table.owner[id],
59
+ table.localHook[id],
60
+ table.appHook[id],
61
+ table.inheritedChain[id],
62
+ table.macroScope?.get(id)
63
+ ];
64
+ };
60
65
 
61
66
  //#endregion
62
67
  exports.RouteFlag = RouteFlag;
@@ -4,7 +4,10 @@ import { needEncodeRegex } from "./constants.mjs";
4
4
  const RouteFlag = {
5
5
  WS: 1,
6
6
  Dynamic: 2,
7
- Encode: 4
7
+ Encode: 4,
8
+ ExactDuplicate: 8,
9
+ JITCold: 16,
10
+ JITSatisfied: 32
8
11
  };
9
12
  function buildRouteTable(declaredRoutes) {
10
13
  const length = declaredRoutes.length;
@@ -46,16 +49,18 @@ function buildRouteTable(declaredRoutes) {
46
49
  macroScope
47
50
  };
48
51
  }
49
- const routeRow = (table, id) => [
50
- table.method[id],
51
- table.path[id],
52
- table.handler[id],
53
- table.owner[id],
54
- table.localHook[id],
55
- table.appHook[id],
56
- table.inheritedChain[id],
57
- table.macroScope?.get(id)
58
- ];
52
+ const routeRow = (table, id) => {
53
+ return [
54
+ table.method[id],
55
+ table.path[id],
56
+ table.handler[id],
57
+ table.owner[id],
58
+ table.localHook[id],
59
+ table.appHook[id],
60
+ table.inheritedChain[id],
61
+ table.macroScope?.get(id)
62
+ ];
63
+ };
59
64
 
60
65
  //#endregion
61
66
  export { RouteFlag, buildRouteTable, routeRow };
@@ -1,8 +1,4 @@
1
1
  //#region src/schema-snapshot.d.ts
2
- /**
3
- * The `.model()` snapshot: a private, MUTABLE clone. `base.ts` stamps `$id` onto
4
- * the node this returns, so it is never frozen and never interned.
5
- */
6
2
  declare function snapshotSchema<T>(schema: T): T;
7
3
  declare function snapshotHookSchemas<T extends Record<string, any> | undefined>(hook: T): T;
8
4
  //#endregion
@@ -52,8 +52,7 @@ function isImmutableNode(value) {
52
52
  immutableNodes.set(value, immutable);
53
53
  return immutable;
54
54
  }
55
- let freezeClones = false;
56
- function deepCloneSchema(value, seen, canShare = true) {
55
+ function deepCloneSchema(value, freeze, seen, canShare = true) {
57
56
  if (value === null || typeof value !== "object") return value;
58
57
  const cached = seen?.get(value);
59
58
  if (cached) return cached;
@@ -61,8 +60,8 @@ function deepCloneSchema(value, seen, canShare = true) {
61
60
  const out = [];
62
61
  seen ??= /* @__PURE__ */ new Map();
63
62
  seen.set(value, out);
64
- for (let i = 0; i < value.length; i++) out[i] = deepCloneSchema(value[i], seen);
65
- return freezeClones ? Object.freeze(out) : out;
63
+ for (let i = 0; i < value.length; i++) out[i] = deepCloneSchema(value[i], freeze, seen);
64
+ return freeze ? Object.freeze(out) : out;
66
65
  }
67
66
  if (canShare && isImmutableNode(value)) return value;
68
67
  const proto = Object.getPrototypeOf(value);
@@ -77,14 +76,14 @@ function deepCloneSchema(value, seen, canShare = true) {
77
76
  const property = value[key];
78
77
  if (!allEnumerable && !isEnumerable.call(value, key)) {
79
78
  Object.defineProperty(out, key, {
80
- value: property,
79
+ value: key === "~cookieFrom" ? deepCloneSchema(property, freeze, seen) : property,
81
80
  enumerable: false,
82
81
  writable: true,
83
82
  configurable: true
84
83
  });
85
84
  continue;
86
85
  }
87
- const cloned = deepCloneSchema(property, seen);
86
+ const cloned = deepCloneSchema(property, freeze, seen);
88
87
  if (key === "__proto__") Object.defineProperty(out, key, {
89
88
  value: cloned,
90
89
  enumerable: true,
@@ -97,7 +96,7 @@ function deepCloneSchema(value, seen, canShare = true) {
97
96
  for (let i = 0; i < symbols.length; i++) {
98
97
  const key = symbols[i];
99
98
  const property = value[key];
100
- if (isEnumerable.call(value, key)) out[key] = deepCloneSchema(property, seen);
99
+ if (isEnumerable.call(value, key)) out[key] = deepCloneSchema(property, freeze, seen);
101
100
  else Object.defineProperty(out, key, {
102
101
  value: property,
103
102
  enumerable: false,
@@ -105,7 +104,7 @@ function deepCloneSchema(value, seen, canShare = true) {
105
104
  configurable: true
106
105
  });
107
106
  }
108
- return freezeClones ? Object.freeze(out) : out;
107
+ return freeze ? Object.freeze(out) : out;
109
108
  }
110
109
  const refIds = /* @__PURE__ */ new WeakMap();
111
110
  let nextRefId = 0;
@@ -114,20 +113,19 @@ function refKey(value) {
114
113
  if (id === void 0) refIds.set(value, id = ++nextRefId);
115
114
  return "r" + id + ";";
116
115
  }
117
- let fingerprintBail = false;
118
- const byRefKey = (value) => value !== null && (typeof value === "object" || typeof value === "function") ? refKey(value) : fingerprint(value, void 0);
119
- function fingerprint(value, seen, canShare = true) {
116
+ const byRefKey = (value, state) => value !== null && (typeof value === "object" || typeof value === "function") ? refKey(value) : fingerprint(value, void 0, state);
117
+ function fingerprint(value, seen, state, canShare = true) {
120
118
  if (value === null) return "z;";
121
119
  const type = typeof value;
122
120
  if (type !== "object") switch (type) {
123
121
  case "string": return "s" + value.length + ":" + value;
124
- case "number": return "n" + value + ";";
122
+ case "number": return "n" + (Object.is(value, -0) ? "-0" : value) + ";";
125
123
  case "boolean": return value ? "T;" : "F;";
126
124
  case "function": return refKey(value);
127
125
  case "undefined": return "u;";
128
126
  case "bigint": return "g" + value + ";";
129
127
  default:
130
- fingerprintBail = true;
128
+ state.bail = true;
131
129
  return "y;";
132
130
  }
133
131
  const backReference = seen?.get(value);
@@ -136,7 +134,7 @@ function fingerprint(value, seen, canShare = true) {
136
134
  seen ??= /* @__PURE__ */ new Map();
137
135
  seen.set(value, seen.size);
138
136
  let out = "[";
139
- for (let i = 0; i < value.length; i++) out += fingerprint(value[i], seen);
137
+ for (let i = 0; i < value.length; i++) out += fingerprint(value[i], seen, state);
140
138
  return out + "];";
141
139
  }
142
140
  if (canShare && isImmutableNode(value)) return refKey(value);
@@ -151,15 +149,19 @@ function fingerprint(value, seen, canShare = true) {
151
149
  const key = keys[i];
152
150
  const property = value[key];
153
151
  out += "k" + key.length + ":" + key;
154
- out += !allEnumerable && !isEnumerable.call(value, key) ? "!" + byRefKey(property) : "=" + fingerprint(property, seen);
152
+ const hidden = !allEnumerable && !isEnumerable.call(value, key);
153
+ out += hidden && key !== "~cookieFrom" ? "!" + byRefKey(property, state) : (hidden ? "~" : "=") + fingerprint(property, seen, state);
155
154
  }
156
- if (Object.getOwnPropertySymbols(value).length) fingerprintBail = true;
155
+ if (Object.getOwnPropertySymbols(value).length) state.bail = true;
157
156
  return out + "};";
158
157
  }
159
- /**
160
- * The `.model()` snapshot: a private, MUTABLE clone. `base.ts` stamps `$id` onto
161
- * the node this returns, so it is never frozen and never interned.
162
- */
158
+ function cloneOrWarn(object, freeze) {
159
+ try {
160
+ return deepCloneSchema(object, freeze, void 0, false);
161
+ } catch (error) {
162
+ console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
163
+ }
164
+ }
163
165
  function snapshotSchema(schema) {
164
166
  if (schema === null || typeof schema !== "object") return schema;
165
167
  const object = schema;
@@ -167,13 +169,8 @@ function snapshotSchema(schema) {
167
169
  if (produced.has(object) && !Object.isFrozen(object)) return schema;
168
170
  const existing = modelSnapshots.get(object);
169
171
  if (existing) return existing;
170
- let cloned;
171
- try {
172
- cloned = deepCloneSchema(object, void 0, false);
173
- } catch (error) {
174
- console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
175
- return schema;
176
- }
172
+ const cloned = cloneOrWarn(object, false);
173
+ if (cloned === void 0) return schema;
177
174
  modelSnapshots.set(object, cloned);
178
175
  produced.add(cloned);
179
176
  return cloned;
@@ -193,11 +190,11 @@ function internSchema(schema, intern) {
193
190
  if (existing) return existing;
194
191
  let key;
195
192
  if (intern) {
196
- fingerprintBail = false;
193
+ const state = { bail: false };
197
194
  try {
198
- key = fingerprint(object, void 0, false);
195
+ key = fingerprint(object, void 0, state, false);
199
196
  } catch {}
200
- if (fingerprintBail) key = void 0;
197
+ if (state.bail) key = void 0;
201
198
  }
202
199
  if (key !== void 0) {
203
200
  const shared = interned.get(key);
@@ -210,16 +207,8 @@ function internSchema(schema, intern) {
210
207
  return shared;
211
208
  }
212
209
  }
213
- let cloned;
214
- freezeClones = true;
215
- try {
216
- cloned = deepCloneSchema(object, void 0, false);
217
- } catch (error) {
218
- console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
219
- return schema;
220
- } finally {
221
- freezeClones = false;
222
- }
210
+ const cloned = cloneOrWarn(object, true);
211
+ if (cloned === void 0) return schema;
223
212
  hookSnapshots.set(object, cloned);
224
213
  produced.add(cloned);
225
214
  if (key !== void 0) {
@@ -242,18 +231,12 @@ function isStatusMap(response) {
242
231
  for (const key in response) if (!Number.isInteger(Number(key))) return false;
243
232
  return true;
244
233
  }
234
+ const hasSlot = (target) => schemaSlots.some((slot) => target[slot] != null) || target.response != null;
245
235
  function snapshotHookSchemas(hook) {
246
236
  if (!hook) return hook;
247
- let needsCopy = false;
248
- if (schemaSlots.some((slot) => hook[slot] != null) || hook.response != null) needsCopy = true;
237
+ const needsCopy = hasSlot(hook);
249
238
  const schemas = hook.schemas;
250
- if (!needsCopy && Array.isArray(schemas)) {
251
- for (const entry of schemas) if (entry && (schemaSlots.some((slot) => entry[slot] != null) || entry.response != null)) {
252
- needsCopy = true;
253
- break;
254
- }
255
- }
256
- if (!needsCopy) return hook;
239
+ if (!needsCopy && !(Array.isArray(schemas) && schemas.some((e) => e && hasSlot(e)))) return hook;
257
240
  const intern = !require_universal_env.env.ELYSIA_AOT_BUILD;
258
241
  const copy = Object.assign(Object.create(Object.getPrototypeOf(hook)), hook);
259
242
  snapshotSlots(copy, intern);
@@ -51,8 +51,7 @@ function isImmutableNode(value) {
51
51
  immutableNodes.set(value, immutable);
52
52
  return immutable;
53
53
  }
54
- let freezeClones = false;
55
- function deepCloneSchema(value, seen, canShare = true) {
54
+ function deepCloneSchema(value, freeze, seen, canShare = true) {
56
55
  if (value === null || typeof value !== "object") return value;
57
56
  const cached = seen?.get(value);
58
57
  if (cached) return cached;
@@ -60,8 +59,8 @@ function deepCloneSchema(value, seen, canShare = true) {
60
59
  const out = [];
61
60
  seen ??= /* @__PURE__ */ new Map();
62
61
  seen.set(value, out);
63
- for (let i = 0; i < value.length; i++) out[i] = deepCloneSchema(value[i], seen);
64
- return freezeClones ? Object.freeze(out) : out;
62
+ for (let i = 0; i < value.length; i++) out[i] = deepCloneSchema(value[i], freeze, seen);
63
+ return freeze ? Object.freeze(out) : out;
65
64
  }
66
65
  if (canShare && isImmutableNode(value)) return value;
67
66
  const proto = Object.getPrototypeOf(value);
@@ -76,14 +75,14 @@ function deepCloneSchema(value, seen, canShare = true) {
76
75
  const property = value[key];
77
76
  if (!allEnumerable && !isEnumerable.call(value, key)) {
78
77
  Object.defineProperty(out, key, {
79
- value: property,
78
+ value: key === "~cookieFrom" ? deepCloneSchema(property, freeze, seen) : property,
80
79
  enumerable: false,
81
80
  writable: true,
82
81
  configurable: true
83
82
  });
84
83
  continue;
85
84
  }
86
- const cloned = deepCloneSchema(property, seen);
85
+ const cloned = deepCloneSchema(property, freeze, seen);
87
86
  if (key === "__proto__") Object.defineProperty(out, key, {
88
87
  value: cloned,
89
88
  enumerable: true,
@@ -96,7 +95,7 @@ function deepCloneSchema(value, seen, canShare = true) {
96
95
  for (let i = 0; i < symbols.length; i++) {
97
96
  const key = symbols[i];
98
97
  const property = value[key];
99
- if (isEnumerable.call(value, key)) out[key] = deepCloneSchema(property, seen);
98
+ if (isEnumerable.call(value, key)) out[key] = deepCloneSchema(property, freeze, seen);
100
99
  else Object.defineProperty(out, key, {
101
100
  value: property,
102
101
  enumerable: false,
@@ -104,7 +103,7 @@ function deepCloneSchema(value, seen, canShare = true) {
104
103
  configurable: true
105
104
  });
106
105
  }
107
- return freezeClones ? Object.freeze(out) : out;
106
+ return freeze ? Object.freeze(out) : out;
108
107
  }
109
108
  const refIds = /* @__PURE__ */ new WeakMap();
110
109
  let nextRefId = 0;
@@ -113,20 +112,19 @@ function refKey(value) {
113
112
  if (id === void 0) refIds.set(value, id = ++nextRefId);
114
113
  return "r" + id + ";";
115
114
  }
116
- let fingerprintBail = false;
117
- const byRefKey = (value) => value !== null && (typeof value === "object" || typeof value === "function") ? refKey(value) : fingerprint(value, void 0);
118
- function fingerprint(value, seen, canShare = true) {
115
+ const byRefKey = (value, state) => value !== null && (typeof value === "object" || typeof value === "function") ? refKey(value) : fingerprint(value, void 0, state);
116
+ function fingerprint(value, seen, state, canShare = true) {
119
117
  if (value === null) return "z;";
120
118
  const type = typeof value;
121
119
  if (type !== "object") switch (type) {
122
120
  case "string": return "s" + value.length + ":" + value;
123
- case "number": return "n" + value + ";";
121
+ case "number": return "n" + (Object.is(value, -0) ? "-0" : value) + ";";
124
122
  case "boolean": return value ? "T;" : "F;";
125
123
  case "function": return refKey(value);
126
124
  case "undefined": return "u;";
127
125
  case "bigint": return "g" + value + ";";
128
126
  default:
129
- fingerprintBail = true;
127
+ state.bail = true;
130
128
  return "y;";
131
129
  }
132
130
  const backReference = seen?.get(value);
@@ -135,7 +133,7 @@ function fingerprint(value, seen, canShare = true) {
135
133
  seen ??= /* @__PURE__ */ new Map();
136
134
  seen.set(value, seen.size);
137
135
  let out = "[";
138
- for (let i = 0; i < value.length; i++) out += fingerprint(value[i], seen);
136
+ for (let i = 0; i < value.length; i++) out += fingerprint(value[i], seen, state);
139
137
  return out + "];";
140
138
  }
141
139
  if (canShare && isImmutableNode(value)) return refKey(value);
@@ -150,15 +148,19 @@ function fingerprint(value, seen, canShare = true) {
150
148
  const key = keys[i];
151
149
  const property = value[key];
152
150
  out += "k" + key.length + ":" + key;
153
- out += !allEnumerable && !isEnumerable.call(value, key) ? "!" + byRefKey(property) : "=" + fingerprint(property, seen);
151
+ const hidden = !allEnumerable && !isEnumerable.call(value, key);
152
+ out += hidden && key !== "~cookieFrom" ? "!" + byRefKey(property, state) : (hidden ? "~" : "=") + fingerprint(property, seen, state);
154
153
  }
155
- if (Object.getOwnPropertySymbols(value).length) fingerprintBail = true;
154
+ if (Object.getOwnPropertySymbols(value).length) state.bail = true;
156
155
  return out + "};";
157
156
  }
158
- /**
159
- * The `.model()` snapshot: a private, MUTABLE clone. `base.ts` stamps `$id` onto
160
- * the node this returns, so it is never frozen and never interned.
161
- */
157
+ function cloneOrWarn(object, freeze) {
158
+ try {
159
+ return deepCloneSchema(object, freeze, void 0, false);
160
+ } catch (error) {
161
+ console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
162
+ }
163
+ }
162
164
  function snapshotSchema(schema) {
163
165
  if (schema === null || typeof schema !== "object") return schema;
164
166
  const object = schema;
@@ -166,13 +168,8 @@ function snapshotSchema(schema) {
166
168
  if (produced.has(object) && !Object.isFrozen(object)) return schema;
167
169
  const existing = modelSnapshots.get(object);
168
170
  if (existing) return existing;
169
- let cloned;
170
- try {
171
- cloned = deepCloneSchema(object, void 0, false);
172
- } catch (error) {
173
- console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
174
- return schema;
175
- }
171
+ const cloned = cloneOrWarn(object, false);
172
+ if (cloned === void 0) return schema;
176
173
  modelSnapshots.set(object, cloned);
177
174
  produced.add(cloned);
178
175
  return cloned;
@@ -192,11 +189,11 @@ function internSchema(schema, intern) {
192
189
  if (existing) return existing;
193
190
  let key;
194
191
  if (intern) {
195
- fingerprintBail = false;
192
+ const state = { bail: false };
196
193
  try {
197
- key = fingerprint(object, void 0, false);
194
+ key = fingerprint(object, void 0, state, false);
198
195
  } catch {}
199
- if (fingerprintBail) key = void 0;
196
+ if (state.bail) key = void 0;
200
197
  }
201
198
  if (key !== void 0) {
202
199
  const shared = interned.get(key);
@@ -209,16 +206,8 @@ function internSchema(schema, intern) {
209
206
  return shared;
210
207
  }
211
208
  }
212
- let cloned;
213
- freezeClones = true;
214
- try {
215
- cloned = deepCloneSchema(object, void 0, false);
216
- } catch (error) {
217
- console.warn("[Elysia] schema snapshot failed; schema kept by reference:", error);
218
- return schema;
219
- } finally {
220
- freezeClones = false;
221
- }
209
+ const cloned = cloneOrWarn(object, true);
210
+ if (cloned === void 0) return schema;
222
211
  hookSnapshots.set(object, cloned);
223
212
  produced.add(cloned);
224
213
  if (key !== void 0) {
@@ -241,18 +230,12 @@ function isStatusMap(response) {
241
230
  for (const key in response) if (!Number.isInteger(Number(key))) return false;
242
231
  return true;
243
232
  }
233
+ const hasSlot = (target) => schemaSlots.some((slot) => target[slot] != null) || target.response != null;
244
234
  function snapshotHookSchemas(hook) {
245
235
  if (!hook) return hook;
246
- let needsCopy = false;
247
- if (schemaSlots.some((slot) => hook[slot] != null) || hook.response != null) needsCopy = true;
236
+ const needsCopy = hasSlot(hook);
248
237
  const schemas = hook.schemas;
249
- if (!needsCopy && Array.isArray(schemas)) {
250
- for (const entry of schemas) if (entry && (schemaSlots.some((slot) => entry[slot] != null) || entry.response != null)) {
251
- needsCopy = true;
252
- break;
253
- }
254
- }
255
- if (!needsCopy) return hook;
238
+ if (!needsCopy && !(Array.isArray(schemas) && schemas.some((e) => e && hasSlot(e)))) return hook;
256
239
  const intern = !env.ELYSIA_AOT_BUILD;
257
240
  const copy = Object.assign(Object.create(Object.getPrototypeOf(hook)), hook);
258
241
  snapshotSlots(copy, intern);
package/dist/sucrose.d.ts CHANGED
@@ -13,62 +13,13 @@ declare namespace Sucrose {
13
13
  }
14
14
  type LifeCycle = Partial<Partial<AppHook>>;
15
15
  }
16
+ declare function clearSucroseCache(): void;
17
+ declare const mergeInference: (a: Sucrose.Inference, b: Sucrose.Inference) => Sucrose.Inference;
16
18
  /**
17
- * Separate stringified function body and parameter
18
- *
19
- * @example
20
- * ```typescript
21
- * separateFunction('async ({ hello }) => { return hello }') // => ['({ hello })', '{ return hello }']
22
- * ```
23
- */
24
- declare function separateFunction(code: string): [string, string];
25
- /**
26
- * Get range between bracket pair
27
- *
28
- * @example
29
- * ```typescript
30
- * bracketPairRange('hello: { world: { a } }, elysia') // [6, 20]
31
- * ```
32
- */
33
- declare function bracketPairRange(parameter: string): [number, number];
34
- /**
35
- * Similar to `bracketPairRange` but in reverse order
36
- * Get range between bracket pair from end to beginning
37
- *
38
- * @example
39
- * ```typescript
40
- * bracketPairRange('hello: { world: { a } }, elysia') // [6, 20]
41
- * ```
42
- */
43
- declare function bracketPairRangeReverse(parameter: string): [number, number];
44
- declare function removeColonAlias(parameter: string): string;
45
- /**
46
- * Retrieve only root parameters of a function
47
- *
48
- * @example
49
- * ```typescript
50
- * retrieveRootParameters('({ hello: { world: { a } }, elysia })') // => {
51
- * parameters: ['hello', 'elysia'],
52
- * hasParenthesis: true
53
- * }
54
- * ```
55
- */
56
- declare function retrieveRootparameters(parameter: string): {
57
- hasParenthesis: boolean;
58
- parameters: Record<string, true>;
59
- };
60
- /**
61
- * Find alias of variable from function body
62
- *
63
- * @example
64
- * ```typescript
65
- * findAlias('body', '{ const a = body, b = body }') // => ['a', 'b']
66
- * ```
19
+ * @internal Which `channelOf`-mapped members of a function's first parameter
20
+ * the function may read, or `null` when any member may be read
67
21
  */
68
- declare function findAlias(type: string, body: string, seen?: Set<string>): string[];
69
- declare function removeDefaultParameter(parameter: string): string;
70
- declare function clearSucroseCache(delay?: number | null): void;
71
- declare const mergeInference: (a: Sucrose.Inference, b: Sucrose.Inference) => Sucrose.Inference;
22
+ declare function inferFunction<K extends string>(source: string, channelOf: (value: string) => K | undefined, strict?: boolean): Set<K> | null;
72
23
  declare function sucrose(handler: Handler | undefined, lifeCycle: Sucrose.LifeCycle | undefined): Sucrose.Inference;
73
24
  //#endregion
74
- export { Sucrose, bracketPairRange, bracketPairRangeReverse, clearSucroseCache, findAlias, mergeInference, removeColonAlias, removeDefaultParameter, retrieveRootparameters, separateFunction, sucrose };
25
+ export { Sucrose, clearSucroseCache, inferFunction, mergeInference, sucrose };