elysia 2.0.0-beta.21 → 2.0.0-beta.23

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 (217) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +1 -0
  2. package/dist/adapter/bun/index.d.ts +6 -8
  3. package/dist/adapter/bun/index.js +6 -8
  4. package/dist/adapter/bun/index.mjs +7 -8
  5. package/dist/adapter/constants.mjs +1 -0
  6. package/dist/adapter/default-headers.mjs +1 -0
  7. package/dist/adapter/index.mjs +1 -0
  8. package/dist/adapter/origin.mjs +1 -0
  9. package/dist/adapter/response-ownership.mjs +1 -0
  10. package/dist/adapter/skip-clone.mjs +1 -0
  11. package/dist/adapter/types.mjs +1 -0
  12. package/dist/adapter/utils.d.ts +5 -8
  13. package/dist/adapter/utils.js +24 -18
  14. package/dist/adapter/utils.mjs +25 -18
  15. package/dist/adapter/web-standard/handler.mjs +2 -1
  16. package/dist/adapter/web-standard/index.mjs +1 -0
  17. package/dist/adapter/web-standard/utils.mjs +1 -0
  18. package/dist/base.d.ts +118 -69
  19. package/dist/base.js +214 -194
  20. package/dist/base.mjs +221 -200
  21. package/dist/compile/aot-capture.js +2 -2
  22. package/dist/compile/aot-capture.mjs +4 -3
  23. package/dist/compile/aot-emit.js +7 -8
  24. package/dist/compile/aot-emit.mjs +8 -8
  25. package/dist/compile/aot-reconstruct.mjs +3 -2
  26. package/dist/compile/aot.d.ts +3 -3
  27. package/dist/compile/aot.js +5 -5
  28. package/dist/compile/aot.mjs +6 -5
  29. package/dist/compile/handler/descriptor.d.ts +2 -5
  30. package/dist/compile/handler/descriptor.js +12 -17
  31. package/dist/compile/handler/descriptor.mjs +16 -21
  32. package/dist/compile/handler/frozen-validator.d.ts +2 -2
  33. package/dist/compile/handler/frozen-validator.js +3 -3
  34. package/dist/compile/handler/frozen-validator.mjs +4 -3
  35. package/dist/compile/handler/index.d.ts +3 -1
  36. package/dist/compile/handler/index.js +78 -118
  37. package/dist/compile/handler/index.mjs +84 -125
  38. package/dist/compile/handler/jit.d.ts +12 -12
  39. package/dist/compile/handler/jit.js +60 -43
  40. package/dist/compile/handler/jit.mjs +63 -47
  41. package/dist/compile/handler/params.d.ts +5 -1
  42. package/dist/compile/handler/params.js +14 -5
  43. package/dist/compile/handler/params.mjs +16 -7
  44. package/dist/compile/handler/reconstruct.d.ts +2 -2
  45. package/dist/compile/handler/reconstruct.js +2 -2
  46. package/dist/compile/handler/reconstruct.mjs +3 -2
  47. package/dist/compile/handler/static-clone-resolver.mjs +1 -0
  48. package/dist/compile/handler/utils.d.ts +13 -7
  49. package/dist/compile/handler/utils.js +75 -52
  50. package/dist/compile/handler/utils.mjs +77 -54
  51. package/dist/compile/jit-probe.mjs +1 -0
  52. package/dist/compile/lexer.js +4 -4
  53. package/dist/compile/lexer.mjs +5 -4
  54. package/dist/compile/utils.d.ts +2 -1
  55. package/dist/compile/utils.js +8 -3
  56. package/dist/compile/utils.mjs +8 -3
  57. package/dist/compiled.mjs +1 -0
  58. package/dist/constants.mjs +1 -0
  59. package/dist/context.d.ts +1 -1
  60. package/dist/context.js +1 -0
  61. package/dist/context.mjs +3 -1
  62. package/dist/cookie/config.d.ts +2 -2
  63. package/dist/cookie/config.js +21 -26
  64. package/dist/cookie/config.mjs +22 -26
  65. package/dist/cookie/cookie.mjs +1 -0
  66. package/dist/cookie/crypto.mjs +1 -0
  67. package/dist/cookie/error.mjs +1 -0
  68. package/dist/cookie/lib.mjs +1 -0
  69. package/dist/cookie/serialize.mjs +1 -0
  70. package/dist/cookie/types.mjs +1 -0
  71. package/dist/cookie/utils.d.ts +1 -1
  72. package/dist/cookie/utils.js +64 -45
  73. package/dist/cookie/utils.mjs +66 -46
  74. package/dist/error.d.ts +10 -6
  75. package/dist/error.js +22 -6
  76. package/dist/error.mjs +25 -9
  77. package/dist/generation.mjs +1 -0
  78. package/dist/handler/error.d.ts +12 -15
  79. package/dist/handler/error.js +43 -40
  80. package/dist/handler/error.mjs +45 -41
  81. package/dist/handler/fetch.js +59 -21
  82. package/dist/handler/fetch.mjs +61 -22
  83. package/dist/handler/utils.d.ts +16 -3
  84. package/dist/handler/utils.js +14 -13
  85. package/dist/handler/utils.mjs +16 -15
  86. package/dist/index.d.ts +9 -9
  87. package/dist/index.js +1 -0
  88. package/dist/index.mjs +3 -2
  89. package/dist/memory.mjs +1 -0
  90. package/dist/package.js +1 -1
  91. package/dist/package.mjs +2 -1
  92. package/dist/parse-query.js +76 -76
  93. package/dist/parse-query.mjs +77 -76
  94. package/dist/plugin/aot/bun.mjs +1 -0
  95. package/dist/plugin/aot/core.d.ts +1 -1
  96. package/dist/plugin/aot/core.js +7 -4
  97. package/dist/plugin/aot/core.mjs +8 -5
  98. package/dist/plugin/aot/esbuild.mjs +1 -0
  99. package/dist/plugin/aot/rspack-loader.mjs +1 -0
  100. package/dist/plugin/aot/rspack.mjs +1 -0
  101. package/dist/plugin/aot/treeshake.mjs +1 -0
  102. package/dist/plugin/aot/unplugin.mjs +4 -3
  103. package/dist/plugin/aot/vite.mjs +1 -0
  104. package/dist/plugin/aot/worker.mjs +1 -0
  105. package/dist/plugin/auto-head.mjs +1 -0
  106. package/dist/plugin/trace.mjs +1 -0
  107. package/dist/plugin/websocket.mjs +1 -0
  108. package/dist/route-table.mjs +1 -0
  109. package/dist/schema-snapshot.js +28 -3
  110. package/dist/schema-snapshot.mjs +29 -3
  111. package/dist/sucrose.d.ts +2 -2
  112. package/dist/sucrose.js +11 -11
  113. package/dist/sucrose.mjs +12 -11
  114. package/dist/trace.js +8 -10
  115. package/dist/trace.mjs +10 -11
  116. package/dist/type/bridge-live.d.ts +1 -1
  117. package/dist/type/bridge-live.mjs +1 -0
  118. package/dist/type/bridge.d.ts +1 -1
  119. package/dist/type/bridge.mjs +1 -0
  120. package/dist/type/coerce-plan.mjs +1 -0
  121. package/dist/type/coerce.d.ts +1 -1
  122. package/dist/type/coerce.mjs +1 -0
  123. package/dist/type/compat.mjs +1 -0
  124. package/dist/type/constants.d.ts +1 -1
  125. package/dist/type/constants.mjs +1 -0
  126. package/dist/type/elysia/accelerate.mjs +1 -0
  127. package/dist/type/elysia/array-buffer.d.ts +3 -2
  128. package/dist/type/elysia/array-buffer.js +5 -5
  129. package/dist/type/elysia/array-buffer.mjs +6 -5
  130. package/dist/type/elysia/array-string.mjs +1 -0
  131. package/dist/type/elysia/array.mjs +1 -0
  132. package/dist/type/elysia/boolean-string.mjs +1 -0
  133. package/dist/type/elysia/boolean.mjs +1 -0
  134. package/dist/type/elysia/cookie.mjs +1 -0
  135. package/dist/type/elysia/date.mjs +1 -0
  136. package/dist/type/elysia/file-type.mjs +1 -0
  137. package/dist/type/elysia/file.mjs +1 -0
  138. package/dist/type/elysia/files.mjs +1 -0
  139. package/dist/type/elysia/form.mjs +1 -0
  140. package/dist/type/elysia/integer-string.mjs +1 -0
  141. package/dist/type/elysia/integer.mjs +1 -0
  142. package/dist/type/elysia/intersect.mjs +1 -0
  143. package/dist/type/elysia/json-string.mjs +1 -0
  144. package/dist/type/elysia/keep-config.js +8 -8
  145. package/dist/type/elysia/keep-config.mjs +9 -8
  146. package/dist/type/elysia/maybe-empty.mjs +1 -0
  147. package/dist/type/elysia/no-validate.mjs +1 -0
  148. package/dist/type/elysia/nullable.mjs +1 -0
  149. package/dist/type/elysia/number.mjs +1 -0
  150. package/dist/type/elysia/numeric-enum.d.ts +4 -2
  151. package/dist/type/elysia/numeric-enum.mjs +1 -0
  152. package/dist/type/elysia/numeric.mjs +1 -0
  153. package/dist/type/elysia/object-string.mjs +1 -0
  154. package/dist/type/elysia/object.mjs +1 -0
  155. package/dist/type/elysia/optional.mjs +1 -0
  156. package/dist/type/elysia/problem.mjs +1 -0
  157. package/dist/type/elysia/string.mjs +1 -0
  158. package/dist/type/elysia/uint8-array.d.ts +2 -1
  159. package/dist/type/elysia/uint8-array.js +2 -2
  160. package/dist/type/elysia/uint8-array.mjs +3 -2
  161. package/dist/type/elysia/union-enum.mjs +1 -0
  162. package/dist/type/elysia/union.mjs +1 -0
  163. package/dist/type/elysia/utils.js +3 -3
  164. package/dist/type/elysia/utils.mjs +4 -3
  165. package/dist/type/exports.mjs +1 -0
  166. package/dist/type/index.mjs +2 -1
  167. package/dist/type/shared.mjs +1 -0
  168. package/dist/type/sync-require.mjs +1 -0
  169. package/dist/type/typebox-system-lite.mjs +1 -0
  170. package/dist/type/typebox-system-require.mjs +1 -0
  171. package/dist/type/typebox-type-live.mjs +1 -0
  172. package/dist/type/typebox-value-live.mjs +1 -0
  173. package/dist/type/typebox-value-ops.mjs +1 -0
  174. package/dist/type/typebox-value.mjs +1 -0
  175. package/dist/type/types.d.ts +1 -1
  176. package/dist/type/types.mjs +1 -0
  177. package/dist/type/utils.mjs +1 -0
  178. package/dist/type/validator/clean-safe.mjs +1 -0
  179. package/dist/type/validator/custom-error.js +41 -33
  180. package/dist/type/validator/custom-error.mjs +42 -33
  181. package/dist/type/validator/default-precompute.d.ts +2 -2
  182. package/dist/type/validator/default-precompute.js +10 -11
  183. package/dist/type/validator/default-precompute.mjs +13 -13
  184. package/dist/type/validator/exact-mirror.mjs +1 -0
  185. package/dist/type/validator/frozen-check.js +7 -7
  186. package/dist/type/validator/frozen-check.mjs +8 -7
  187. package/dist/type/validator/index.d.ts +2 -2
  188. package/dist/type/validator/index.js +4 -8
  189. package/dist/type/validator/index.mjs +5 -8
  190. package/dist/type/validator/string-codec-aot.d.ts +1 -1
  191. package/dist/type/validator/string-codec-aot.mjs +1 -0
  192. package/dist/type/validator/validator-cache.js +18 -18
  193. package/dist/type/validator/validator-cache.mjs +19 -18
  194. package/dist/types.d.ts +108 -70
  195. package/dist/types.mjs +1 -0
  196. package/dist/universal/constants.mjs +1 -0
  197. package/dist/universal/file.mjs +1 -0
  198. package/dist/universal/index.mjs +1 -0
  199. package/dist/universal/is-production.mjs +1 -0
  200. package/dist/universal/server.mjs +1 -0
  201. package/dist/utils.d.ts +49 -31
  202. package/dist/utils.js +221 -109
  203. package/dist/utils.mjs +215 -106
  204. package/dist/validator/index.d.ts +3 -3
  205. package/dist/validator/index.js +4 -4
  206. package/dist/validator/index.mjs +5 -4
  207. package/dist/validator/route.d.ts +2 -2
  208. package/dist/validator/route.mjs +1 -0
  209. package/dist/ws/context.js +1 -1
  210. package/dist/ws/context.mjs +2 -1
  211. package/dist/ws/index.mjs +1 -0
  212. package/dist/ws/parser.mjs +1 -0
  213. package/dist/ws/route.js +34 -25
  214. package/dist/ws/route.mjs +40 -30
  215. package/dist/ws/types.d.ts +2 -3
  216. package/dist/ws/types.mjs +1 -0
  217. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
+ // @bun
1
2
  import { isCloudflareWorker, isFastly } from "../universal/constants.mjs";
2
- import { flattenChain, isDisposable, isSingleton } from "../utils.mjs";
3
+ import { isDisposable, isSingleton } from "../utils.mjs";
3
4
  import { env } from "../universal/env.mjs";
4
5
  import { HTTPError, PROBLEM_JSON, problemTypeOf } from "../error.mjs";
5
6
  import { isAsyncFunction, mayReturnPromise } from "../compile/utils.mjs";
@@ -37,32 +38,32 @@ function forwardError(value) {
37
38
  if (value instanceof Error) throw value;
38
39
  return value;
39
40
  }
40
- const chainErrorClasses = /* @__PURE__ */ new WeakMap();
41
- function collectErrorClasses(error, into) {
42
- if (!error) return into;
41
+ /**
42
+ * Non-Error classes the route's own error hooks register: like any hook, a
43
+ * class registered after the route doesn't reach it
44
+ */
45
+ function returnedErrorClasses(hook) {
46
+ const error = hook?.error;
47
+ if (!error) return;
48
+ let into;
43
49
  const list = Array.isArray(error) ? error : [error];
44
50
  for (let i = 0; i < list.length; i++) {
45
- const C = list[i]?.["~errorClass"];
46
- if (C && !into?.includes(C)) (into ??= []).push(C);
51
+ const errorClass = list[i]?.["~errorClass"];
52
+ if (errorClass && !into?.includes(errorClass)) (into ??= []).push(errorClass);
47
53
  }
48
54
  return into;
49
55
  }
50
- function returnedErrorClasses(hook, root) {
51
- const head = root["~hookChain"];
52
- let rootClasses = head && chainErrorClasses.get(head);
53
- if (head && rootClasses === void 0) chainErrorClasses.set(head, rootClasses = collectErrorClasses(flattenChain(head)?.error, void 0) ?? null);
54
- return collectErrorClasses(hook?.error, rootClasses?.slice());
55
- }
56
56
  const forwardErrorOf = (classes) => (value) => {
57
57
  if (value instanceof Error) throw value;
58
58
  for (let i = 0; i < classes.length; i++) if (value instanceof classes[i]) throw value;
59
59
  return value;
60
60
  };
61
- function finalizeRouteError(app, context, error, sign) {
61
+ function finalizeRouteError(app, context, error, sign, route) {
62
62
  const finalize = app["~finalizeError"];
63
63
  if (!finalize) throw error;
64
- return finalize(context, error, sign);
64
+ return finalize(context, error, sign, false, route);
65
65
  }
66
+ const finalizeRouteErrorOf = (route) => route?.error?.length || route?.mapResponse?.length ? (app, context, error, sign) => finalizeRouteError(app, context, error, sign, route) : finalizeRouteError;
66
67
  function registerDeriveDisposable(context, value, scan = context) {
67
68
  if (!isDisposable(value)) return;
68
69
  if (isSingleton(value)) return;
@@ -91,4 +92,4 @@ async function drainDisposables(context) {
91
92
  const hasAsync = (fns) => fns.some((fn) => isAsyncFunction(fn) || mayReturnPromise(fn));
92
93
 
93
94
  //#endregion
94
- export { drainDisposables, emptyResponse, finalizeRouteError, forwardError, forwardErrorOf, getNotFound, getNotFoundBody, hasAsync, registerDeriveDisposable, returnedErrorClasses };
95
+ export { drainDisposables, emptyResponse, finalizeRouteError, finalizeRouteErrorOf, forwardError, forwardErrorOf, getNotFound, getNotFoundBody, hasAsync, registerDeriveDisposable, returnedErrorClasses };
package/dist/index.d.ts CHANGED
@@ -1,23 +1,23 @@
1
- import { BaseCookie, CookieOptions } from "./cookie/types.js";
2
- import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
3
- import { TCookieField, TCookieObject } from "./type/elysia/cookie.js";
4
- import { TFiles } from "./type/elysia/files.js";
5
1
  import { StatusMap, StatusMapBack } from "./constants.js";
6
2
  import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, NumericStatus, ParseError, Problem, SelectiveProblem, SelectiveStatus, StatusResponse, TaggedHTTPError, ValidationError, ValidationErrorResponse, problem, status, validationDetail } from "./error.js";
7
- import { bytes, form, prefix, redirect, sse } from "./utils.js";
3
+ import { bytes, form, macroType, prefix, redirect, sse } from "./utils.js";
8
4
  import { Server } from "./universal/server.js";
5
+ import { BaseCookie, CookieOptions } from "./cookie/types.js";
9
6
  import { Cookie } from "./cookie/cookie.js";
10
7
  import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
11
8
  import { ElysiaFile, file } from "./universal/file.js";
12
- import { env } from "./universal/env.js";
13
- import { DefaultEphemeral, DefaultMetadata, DefaultSingleton, HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, MacroTypeLambda, RouteSchema, SSEPayload, UnwrapModels, UnwrapRoute, UnwrapSchema } from "./types.js";
9
+ import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
10
+ import { TCookieField, TCookieObject } from "./type/elysia/cookie.js";
11
+ import { TFiles } from "./type/elysia/files.js";
14
12
  import { setupTypebox } from "./type/compat.js";
15
13
  import { FileTypeDetector, fileType, setFileTypeDetector } from "./type/elysia/file-type.js";
14
+ import { AotFingerprint, Capture, Compiled, CompilerSession, ProgramId } from "./compile/aot.js";
16
15
  import { MultiValidator, StandardValidator, Validator } from "./validator/index.js";
17
16
  import { TypeBoxValidator } from "./type/validator/index.js";
18
17
  import { TypeSystem, t } from "./type/index.js";
19
- import { AotFingerprint, Capture, Compiled, CompilerSession, ProgramId } from "./compile/aot.js";
18
+ import { env } from "./universal/env.js";
19
+ import { DefaultEphemeral, DefaultMetadata, DefaultSingleton, HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, MacroTypeLambda, RouteSchema, SSEPayload, UnwrapModels, UnwrapRoute, UnwrapSchema } from "./types.js";
20
20
  import { AnyElysia, Elysia } from "./base.js";
21
21
  import { borrow } from "./adapter/response-ownership.js";
22
22
  import { InvalidCookie } from "./cookie/error.js";
23
- export { AnyElysia, type AnySchema, type AotFingerprint, type BaseCookie, type BaseSchema, Compiled, type CompilerSession, type Context, type Cookie, type CookieOptions, type DefaultEphemeral, type DefaultMetadata, type DefaultSingleton, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, HTTPError, type HTTPHeaders, type InputSchema, InternalServerError, InvalidCookie, type Macro, type MacroToContext, type MacroToProperty, type MacroTypeLambda, Capture as Manifest, MultiValidator, NotFound, type NumericStatus, ParseError, type Problem, type ProgramId, type RouteSchema, type SSEPayload, type SelectiveProblem, type SelectiveStatus, type Server, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type StatusResponse, type TCookieField, type TCookieObject, type TFiles, type TaggedHTTPError, TypeBoxValidator, TypeSystem, type UnwrapModels, type UnwrapRoute, type UnwrapSchema, ValidationError, type ValidationErrorResponse, Validator, borrow, bytes, createBaseContext, createContext, env, file, fileType, form, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
23
+ export { AnyElysia, type AnySchema, type AotFingerprint, type BaseCookie, type BaseSchema, Compiled, type CompilerSession, type Context, type Cookie, type CookieOptions, type DefaultEphemeral, type DefaultMetadata, type DefaultSingleton, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, HTTPError, type HTTPHeaders, type InputSchema, InternalServerError, InvalidCookie, type Macro, type MacroToContext, type MacroToProperty, type MacroTypeLambda, Capture as Manifest, MultiValidator, NotFound, type NumericStatus, ParseError, type Problem, type ProgramId, type RouteSchema, type SSEPayload, type SelectiveProblem, type SelectiveStatus, type Server, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type StatusResponse, type TCookieField, type TCookieObject, type TFiles, type TaggedHTTPError, TypeBoxValidator, TypeSystem, type UnwrapModels, type UnwrapRoute, type UnwrapSchema, ValidationError, type ValidationErrorResponse, Validator, borrow, bytes, createBaseContext, createContext, env, file, fileType, form, macroType, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
package/dist/index.js CHANGED
@@ -47,6 +47,7 @@ exports.env = require_universal_env.env;
47
47
  exports.file = require_universal_file.file;
48
48
  exports.fileType = require_type_elysia_file_type.fileType;
49
49
  exports.form = require_utils.form;
50
+ exports.macroType = require_utils.macroType;
50
51
  exports.prefix = require_utils.prefix;
51
52
  exports.problem = require_error.problem;
52
53
  exports.redirect = require_utils.redirect;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
+ // @bun
1
2
  import { StatusMap, StatusMapBack } from "./constants.mjs";
2
3
  import { ElysiaFile, file } from "./universal/file.mjs";
3
- import { bytes, form, prefix, redirect, sse } from "./utils.mjs";
4
+ import { bytes, form, macroType, prefix, redirect, sse } from "./utils.mjs";
4
5
  import { env } from "./universal/env.mjs";
5
6
  import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, ParseError, ValidationError, problem, status, validationDetail } from "./error.mjs";
6
7
  import { InvalidCookie } from "./cookie/error.mjs";
@@ -18,4 +19,4 @@ import { TypeSystem, t } from "./type/index.mjs";
18
19
  var src_default = Elysia;
19
20
 
20
21
  //#endregion
21
- export { Compiled, Elysia, ElysiaError, ElysiaFile, ElysiaStatus, HTTPError, InternalServerError, InvalidCookie, Capture as Manifest, MultiValidator, NotFound, ParseError, StandardValidator, StatusMap, StatusMapBack, TypeBoxValidator, TypeSystem, ValidationError, Validator, borrow, bytes, createBaseContext, createContext, src_default as default, env, file, fileType, form, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
22
+ export { Compiled, Elysia, ElysiaError, ElysiaFile, ElysiaStatus, HTTPError, InternalServerError, InvalidCookie, Capture as Manifest, MultiValidator, NotFound, ParseError, StandardValidator, StatusMap, StatusMapBack, TypeBoxValidator, TypeSystem, ValidationError, Validator, borrow, bytes, createBaseContext, createContext, src_default as default, env, file, fileType, form, macroType, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
package/dist/memory.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isBun } from "./universal/constants.mjs";
2
3
  import { clearSucroseCache } from "./sucrose.mjs";
3
4
  import { Validator } from "./validator/index.mjs";
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.0.0-beta.21";
3
+ var version = "2.0.0-beta.23";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.mjs CHANGED
@@ -1,5 +1,6 @@
1
+ // @bun
1
2
  //#region package.json
2
- var version = "2.0.0-beta.21";
3
+ var version = "2.0.0-beta.23";
3
4
 
4
5
  //#endregion
5
6
  export { version };
@@ -22,7 +22,7 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
22
22
  let equalityIndex = startingIndex;
23
23
  for (let i = startIndex + 1; i < inputLength; i++) switch (input.charCodeAt(i)) {
24
24
  case 38:
25
- processKeyValuePair(input, i);
25
+ processKeyValuePairFromURL(input, i, result, startingIndex, equalityIndex, flags, array, object);
26
26
  startingIndex = i;
27
27
  equalityIndex = i;
28
28
  flags = 0;
@@ -40,64 +40,64 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
40
40
  else flags |= KEY_NEEDS_DECODE;
41
41
  break;
42
42
  }
43
- if (startingIndex < inputLength) processKeyValuePair(input, inputLength);
43
+ if (startingIndex < inputLength) processKeyValuePairFromURL(input, inputLength, result, startingIndex, equalityIndex, flags, array, object);
44
44
  return result;
45
- function processKeyValuePair(input, endIndex) {
46
- const hasBothKeyValuePair = equalityIndex > startingIndex;
47
- const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
48
- const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
49
- if (!hasBothKeyValuePair && keySlice.length === 0) return;
50
- let finalKey = keySlice;
51
- if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
52
- if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
53
- let finalValue = "";
54
- if (hasBothKeyValuePair) {
55
- let valueSlice = input.slice(equalityIndex + 1, endIndex);
56
- if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
57
- if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
58
- finalValue = valueSlice;
59
- }
60
- const currentValue = result[finalKey];
61
- if (array && array?.[finalKey]) {
62
- let rawValue = hasBothKeyValuePair ? input.slice(equalityIndex + 1, endIndex) : "";
63
- if (flags & VALUE_HAS_PLUS) rawValue = rawValue.replace(/\+/g, " ");
64
- const rawBracket = rawValue.charCodeAt(0) === 91 && rawValue.charCodeAt(rawValue.length - 1) === 93;
65
- const decodedBracket = !rawBracket && finalValue.charCodeAt(0) === 91 && finalValue.charCodeAt(finalValue.length - 1) === 93;
66
- if (rawBracket || decodedBracket) {
67
- let toBracketArray;
68
- if (rawBracket) toBracketArray = rawValue.length === 2 ? [] : splitRawParts(rawValue.slice(1, -1), flags);
69
- else {
70
- const inner = finalValue.slice(1, -1);
71
- toBracketArray = inner === "" ? [] : inner.split(",");
72
- }
73
- if (object && object?.[finalKey]) try {
74
- finalValue = JSON.parse(finalValue);
75
- } catch {
76
- finalValue = toBracketArray;
77
- }
78
- else finalValue = toBracketArray;
79
- if (currentValue === void 0) result[finalKey] = finalValue;
80
- else if (Array.isArray(currentValue)) for (let i = 0; i < finalValue.length; i++) currentValue.push(finalValue[i]);
81
- else {
82
- result[finalKey] = finalValue;
83
- result[finalKey].unshift(currentValue);
84
- }
85
- } else {
86
- if (object && object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
87
- finalValue = JSON.parse(finalValue);
88
- } catch {}
89
- else if (currentValue === void 0 && !(object && object?.[finalKey]) && rawValue.indexOf(",") !== -1) finalValue = splitRawParts(rawValue, flags);
90
- if (currentValue === void 0) result[finalKey] = Array.isArray(finalValue) ? finalValue : [finalValue];
91
- else if (Array.isArray(currentValue)) currentValue.push(finalValue);
92
- else result[finalKey] = [currentValue, finalValue];
45
+ }
46
+ function processKeyValuePairFromURL(input, endIndex, result, startingIndex, equalityIndex, flags, array, object) {
47
+ const hasBothKeyValuePair = equalityIndex > startingIndex;
48
+ const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
49
+ const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
50
+ if (!hasBothKeyValuePair && keySlice.length === 0) return;
51
+ let finalKey = keySlice;
52
+ if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
53
+ if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
54
+ let finalValue = "";
55
+ if (hasBothKeyValuePair) {
56
+ let valueSlice = input.slice(equalityIndex + 1, endIndex);
57
+ if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
58
+ if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
59
+ finalValue = valueSlice;
60
+ }
61
+ const currentValue = result[finalKey];
62
+ if (array && array?.[finalKey]) {
63
+ let rawValue = hasBothKeyValuePair ? input.slice(equalityIndex + 1, endIndex) : "";
64
+ if (flags & VALUE_HAS_PLUS) rawValue = rawValue.replace(/\+/g, " ");
65
+ const rawBracket = rawValue.charCodeAt(0) === 91 && rawValue.charCodeAt(rawValue.length - 1) === 93;
66
+ const decodedBracket = !rawBracket && finalValue.charCodeAt(0) === 91 && finalValue.charCodeAt(finalValue.length - 1) === 93;
67
+ if (rawBracket || decodedBracket) {
68
+ let toBracketArray;
69
+ if (rawBracket) toBracketArray = rawValue.length === 2 ? [] : splitRawParts(rawValue.slice(1, -1), flags);
70
+ else {
71
+ const inner = finalValue.slice(1, -1);
72
+ toBracketArray = inner === "" ? [] : inner.split(",");
73
+ }
74
+ if (object && object?.[finalKey]) try {
75
+ finalValue = JSON.parse(finalValue);
76
+ } catch {
77
+ finalValue = toBracketArray;
93
78
  }
94
- } else if (object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
95
- result[finalKey] = JSON.parse(finalValue);
96
- } catch {
97
- result[finalKey] = finalValue;
79
+ else finalValue = toBracketArray;
80
+ if (currentValue === void 0) result[finalKey] = finalValue;
81
+ else if (Array.isArray(currentValue)) for (let i = 0; i < finalValue.length; i++) currentValue.push(finalValue[i]);
82
+ else {
83
+ result[finalKey] = finalValue;
84
+ result[finalKey].unshift(currentValue);
85
+ }
86
+ } else {
87
+ if (object && object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
88
+ finalValue = JSON.parse(finalValue);
89
+ } catch {}
90
+ else if (currentValue === void 0 && !(object && object?.[finalKey]) && rawValue.indexOf(",") !== -1) finalValue = splitRawParts(rawValue, flags);
91
+ if (currentValue === void 0) result[finalKey] = Array.isArray(finalValue) ? finalValue : [finalValue];
92
+ else if (Array.isArray(currentValue)) currentValue.push(finalValue);
93
+ else result[finalKey] = [currentValue, finalValue];
98
94
  }
99
- else result[finalKey] = finalValue;
95
+ } else if (object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
96
+ result[finalKey] = JSON.parse(finalValue);
97
+ } catch {
98
+ result[finalKey] = finalValue;
100
99
  }
100
+ else result[finalKey] = finalValue;
101
101
  }
102
102
  /**
103
103
  * @callback parse
@@ -111,7 +111,7 @@ function parseQuery(input) {
111
111
  let equalityIndex = -1;
112
112
  for (let i = 0; i < inputLength; i++) switch (input.charCodeAt(i)) {
113
113
  case 38:
114
- processKeyValuePair(input, i);
114
+ processKeyValuePair(input, i, result, startingIndex, equalityIndex, flags);
115
115
  startingIndex = i;
116
116
  equalityIndex = i;
117
117
  flags = 0;
@@ -129,28 +129,28 @@ function parseQuery(input) {
129
129
  else flags |= KEY_NEEDS_DECODE;
130
130
  break;
131
131
  }
132
- if (startingIndex < inputLength) processKeyValuePair(input, inputLength);
132
+ if (startingIndex < inputLength) processKeyValuePair(input, inputLength, result, startingIndex, equalityIndex, flags);
133
133
  return result;
134
- function processKeyValuePair(input, endIndex) {
135
- const hasBothKeyValuePair = equalityIndex > startingIndex;
136
- const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
137
- const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
138
- if (!hasBothKeyValuePair && keySlice.length === 0) return;
139
- let finalKey = keySlice;
140
- if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
141
- if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
142
- let finalValue = "";
143
- if (hasBothKeyValuePair) {
144
- let valueSlice = input.slice(equalityIndex + 1, endIndex);
145
- if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
146
- if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
147
- finalValue = valueSlice;
148
- }
149
- const currentValue = result[finalKey];
150
- if (currentValue === void 0) result[finalKey] = finalValue;
151
- else if (Array.isArray(currentValue)) currentValue.push(finalValue);
152
- else result[finalKey] = [currentValue, finalValue];
134
+ }
135
+ function processKeyValuePair(input, endIndex, result, startingIndex, equalityIndex, flags) {
136
+ const hasBothKeyValuePair = equalityIndex > startingIndex;
137
+ const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
138
+ const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
139
+ if (!hasBothKeyValuePair && keySlice.length === 0) return;
140
+ let finalKey = keySlice;
141
+ if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
142
+ if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
143
+ let finalValue = "";
144
+ if (hasBothKeyValuePair) {
145
+ let valueSlice = input.slice(equalityIndex + 1, endIndex);
146
+ if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
147
+ if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
148
+ finalValue = valueSlice;
153
149
  }
150
+ const currentValue = result[finalKey];
151
+ if (currentValue === void 0) result[finalKey] = finalValue;
152
+ else if (Array.isArray(currentValue)) currentValue.push(finalValue);
153
+ else result[finalKey] = [currentValue, finalValue];
154
154
  }
155
155
 
156
156
  //#endregion
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import decodeComponent from "deuri";
2
3
 
3
4
  //#region src/parse-query.ts
@@ -19,7 +20,7 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
19
20
  let equalityIndex = startingIndex;
20
21
  for (let i = startIndex + 1; i < inputLength; i++) switch (input.charCodeAt(i)) {
21
22
  case 38:
22
- processKeyValuePair(input, i);
23
+ processKeyValuePairFromURL(input, i, result, startingIndex, equalityIndex, flags, array, object);
23
24
  startingIndex = i;
24
25
  equalityIndex = i;
25
26
  flags = 0;
@@ -37,64 +38,64 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
37
38
  else flags |= KEY_NEEDS_DECODE;
38
39
  break;
39
40
  }
40
- if (startingIndex < inputLength) processKeyValuePair(input, inputLength);
41
+ if (startingIndex < inputLength) processKeyValuePairFromURL(input, inputLength, result, startingIndex, equalityIndex, flags, array, object);
41
42
  return result;
42
- function processKeyValuePair(input, endIndex) {
43
- const hasBothKeyValuePair = equalityIndex > startingIndex;
44
- const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
45
- const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
46
- if (!hasBothKeyValuePair && keySlice.length === 0) return;
47
- let finalKey = keySlice;
48
- if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
49
- if (flags & KEY_NEEDS_DECODE) finalKey = decodeComponent(finalKey) || finalKey;
50
- let finalValue = "";
51
- if (hasBothKeyValuePair) {
52
- let valueSlice = input.slice(equalityIndex + 1, endIndex);
53
- if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
54
- if (flags & VALUE_NEEDS_DECODE) valueSlice = decodeComponent(valueSlice) || valueSlice;
55
- finalValue = valueSlice;
56
- }
57
- const currentValue = result[finalKey];
58
- if (array && array?.[finalKey]) {
59
- let rawValue = hasBothKeyValuePair ? input.slice(equalityIndex + 1, endIndex) : "";
60
- if (flags & VALUE_HAS_PLUS) rawValue = rawValue.replace(/\+/g, " ");
61
- const rawBracket = rawValue.charCodeAt(0) === 91 && rawValue.charCodeAt(rawValue.length - 1) === 93;
62
- const decodedBracket = !rawBracket && finalValue.charCodeAt(0) === 91 && finalValue.charCodeAt(finalValue.length - 1) === 93;
63
- if (rawBracket || decodedBracket) {
64
- let toBracketArray;
65
- if (rawBracket) toBracketArray = rawValue.length === 2 ? [] : splitRawParts(rawValue.slice(1, -1), flags);
66
- else {
67
- const inner = finalValue.slice(1, -1);
68
- toBracketArray = inner === "" ? [] : inner.split(",");
69
- }
70
- if (object && object?.[finalKey]) try {
71
- finalValue = JSON.parse(finalValue);
72
- } catch {
73
- finalValue = toBracketArray;
74
- }
75
- else finalValue = toBracketArray;
76
- if (currentValue === void 0) result[finalKey] = finalValue;
77
- else if (Array.isArray(currentValue)) for (let i = 0; i < finalValue.length; i++) currentValue.push(finalValue[i]);
78
- else {
79
- result[finalKey] = finalValue;
80
- result[finalKey].unshift(currentValue);
81
- }
82
- } else {
83
- if (object && object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
84
- finalValue = JSON.parse(finalValue);
85
- } catch {}
86
- else if (currentValue === void 0 && !(object && object?.[finalKey]) && rawValue.indexOf(",") !== -1) finalValue = splitRawParts(rawValue, flags);
87
- if (currentValue === void 0) result[finalKey] = Array.isArray(finalValue) ? finalValue : [finalValue];
88
- else if (Array.isArray(currentValue)) currentValue.push(finalValue);
89
- else result[finalKey] = [currentValue, finalValue];
43
+ }
44
+ function processKeyValuePairFromURL(input, endIndex, result, startingIndex, equalityIndex, flags, array, object) {
45
+ const hasBothKeyValuePair = equalityIndex > startingIndex;
46
+ const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
47
+ const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
48
+ if (!hasBothKeyValuePair && keySlice.length === 0) return;
49
+ let finalKey = keySlice;
50
+ if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
51
+ if (flags & KEY_NEEDS_DECODE) finalKey = decodeComponent(finalKey) || finalKey;
52
+ let finalValue = "";
53
+ if (hasBothKeyValuePair) {
54
+ let valueSlice = input.slice(equalityIndex + 1, endIndex);
55
+ if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
56
+ if (flags & VALUE_NEEDS_DECODE) valueSlice = decodeComponent(valueSlice) || valueSlice;
57
+ finalValue = valueSlice;
58
+ }
59
+ const currentValue = result[finalKey];
60
+ if (array && array?.[finalKey]) {
61
+ let rawValue = hasBothKeyValuePair ? input.slice(equalityIndex + 1, endIndex) : "";
62
+ if (flags & VALUE_HAS_PLUS) rawValue = rawValue.replace(/\+/g, " ");
63
+ const rawBracket = rawValue.charCodeAt(0) === 91 && rawValue.charCodeAt(rawValue.length - 1) === 93;
64
+ const decodedBracket = !rawBracket && finalValue.charCodeAt(0) === 91 && finalValue.charCodeAt(finalValue.length - 1) === 93;
65
+ if (rawBracket || decodedBracket) {
66
+ let toBracketArray;
67
+ if (rawBracket) toBracketArray = rawValue.length === 2 ? [] : splitRawParts(rawValue.slice(1, -1), flags);
68
+ else {
69
+ const inner = finalValue.slice(1, -1);
70
+ toBracketArray = inner === "" ? [] : inner.split(",");
71
+ }
72
+ if (object && object?.[finalKey]) try {
73
+ finalValue = JSON.parse(finalValue);
74
+ } catch {
75
+ finalValue = toBracketArray;
90
76
  }
91
- } else if (object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
92
- result[finalKey] = JSON.parse(finalValue);
93
- } catch {
94
- result[finalKey] = finalValue;
77
+ else finalValue = toBracketArray;
78
+ if (currentValue === void 0) result[finalKey] = finalValue;
79
+ else if (Array.isArray(currentValue)) for (let i = 0; i < finalValue.length; i++) currentValue.push(finalValue[i]);
80
+ else {
81
+ result[finalKey] = finalValue;
82
+ result[finalKey].unshift(currentValue);
83
+ }
84
+ } else {
85
+ if (object && object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
86
+ finalValue = JSON.parse(finalValue);
87
+ } catch {}
88
+ else if (currentValue === void 0 && !(object && object?.[finalKey]) && rawValue.indexOf(",") !== -1) finalValue = splitRawParts(rawValue, flags);
89
+ if (currentValue === void 0) result[finalKey] = Array.isArray(finalValue) ? finalValue : [finalValue];
90
+ else if (Array.isArray(currentValue)) currentValue.push(finalValue);
91
+ else result[finalKey] = [currentValue, finalValue];
95
92
  }
96
- else result[finalKey] = finalValue;
93
+ } else if (object?.[finalKey] && finalValue.charCodeAt(0) === 123) try {
94
+ result[finalKey] = JSON.parse(finalValue);
95
+ } catch {
96
+ result[finalKey] = finalValue;
97
97
  }
98
+ else result[finalKey] = finalValue;
98
99
  }
99
100
  /**
100
101
  * @callback parse
@@ -108,7 +109,7 @@ function parseQuery(input) {
108
109
  let equalityIndex = -1;
109
110
  for (let i = 0; i < inputLength; i++) switch (input.charCodeAt(i)) {
110
111
  case 38:
111
- processKeyValuePair(input, i);
112
+ processKeyValuePair(input, i, result, startingIndex, equalityIndex, flags);
112
113
  startingIndex = i;
113
114
  equalityIndex = i;
114
115
  flags = 0;
@@ -126,28 +127,28 @@ function parseQuery(input) {
126
127
  else flags |= KEY_NEEDS_DECODE;
127
128
  break;
128
129
  }
129
- if (startingIndex < inputLength) processKeyValuePair(input, inputLength);
130
+ if (startingIndex < inputLength) processKeyValuePair(input, inputLength, result, startingIndex, equalityIndex, flags);
130
131
  return result;
131
- function processKeyValuePair(input, endIndex) {
132
- const hasBothKeyValuePair = equalityIndex > startingIndex;
133
- const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
134
- const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
135
- if (!hasBothKeyValuePair && keySlice.length === 0) return;
136
- let finalKey = keySlice;
137
- if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
138
- if (flags & KEY_NEEDS_DECODE) finalKey = decodeComponent(finalKey) || finalKey;
139
- let finalValue = "";
140
- if (hasBothKeyValuePair) {
141
- let valueSlice = input.slice(equalityIndex + 1, endIndex);
142
- if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
143
- if (flags & VALUE_NEEDS_DECODE) valueSlice = decodeComponent(valueSlice) || valueSlice;
144
- finalValue = valueSlice;
145
- }
146
- const currentValue = result[finalKey];
147
- if (currentValue === void 0) result[finalKey] = finalValue;
148
- else if (Array.isArray(currentValue)) currentValue.push(finalValue);
149
- else result[finalKey] = [currentValue, finalValue];
132
+ }
133
+ function processKeyValuePair(input, endIndex, result, startingIndex, equalityIndex, flags) {
134
+ const hasBothKeyValuePair = equalityIndex > startingIndex;
135
+ const effectiveEqualityIndex = hasBothKeyValuePair ? equalityIndex : endIndex;
136
+ const keySlice = input.slice(startingIndex + 1, effectiveEqualityIndex);
137
+ if (!hasBothKeyValuePair && keySlice.length === 0) return;
138
+ let finalKey = keySlice;
139
+ if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
140
+ if (flags & KEY_NEEDS_DECODE) finalKey = decodeComponent(finalKey) || finalKey;
141
+ let finalValue = "";
142
+ if (hasBothKeyValuePair) {
143
+ let valueSlice = input.slice(equalityIndex + 1, endIndex);
144
+ if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
145
+ if (flags & VALUE_NEEDS_DECODE) valueSlice = decodeComponent(valueSlice) || valueSlice;
146
+ finalValue = valueSlice;
150
147
  }
148
+ const currentValue = result[finalKey];
149
+ if (currentValue === void 0) result[finalKey] = finalValue;
150
+ else if (Array.isArray(currentValue)) currentValue.push(finalValue);
151
+ else result[finalKey] = [currentValue, finalValue];
151
152
  }
152
153
 
153
154
  //#endregion
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { createAotPluginHooks, createTypeboxWiringHooks, setupAotOnLoad } from "./hooks.mjs";
2
3
 
3
4
  //#region src/plugin/aot/bun.ts
@@ -100,7 +100,7 @@ interface ElysiaAotOptions {
100
100
  }
101
101
  declare const resolveEntry: (entry: string) => string;
102
102
  /** @internal Resolve the package condition used to evaluate an AOT entry. */
103
- declare const resolveEntryModuleKind: (entry: string) => "esm" | "cjs";
103
+ declare const resolveEntryModuleKind: (entry: string) => "cjs" | "esm";
104
104
  /** Runtime handler-JIT module a strip build can replace with a throwing stub. */
105
105
  interface StubPlan {
106
106
  /** Stub the internal handler codegen module. */
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_compile_handler_params = require('../../compile/handler/params.js');
3
4
  const require_compile_handler_frozen_validator = require('../../compile/handler/frozen-validator.js');
4
5
  const require_compile_handler_index = require('../../compile/handler/index.js');
5
6
  const require_plugin_aot_source = require('./source.js');
@@ -142,7 +143,7 @@ const STUB_SOURCES = {
142
143
  source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function compileHandlerJit(){return e()}\nexport function createInlineHandler(){return e()}\nexport function setCaptureHeaderShorthand(){}\n"
143
144
  }, {
144
145
  filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]descriptor\.(m?js|ts)$/,
145
- source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function describeRoute(){return e()}\nexport const routeDescriptors=new WeakMap()\n"
146
+ source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function describeRoute(){return e()}\nexport function releaseAnalysisCaches(){}\nexport const routeDescriptors=new WeakMap()\n"
146
147
  }],
147
148
  ws: [{
148
149
  filter: /[\\/]elysia[\\/](dist|src)[\\/]ws[\\/]route\.(m?js|ts)$/,
@@ -150,7 +151,7 @@ const STUB_SOURCES = {
150
151
  }],
151
152
  reconstruct: [{
152
153
  filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]reconstruct\.(m?js|ts)$/,
153
- source: "const e=()=>{throw new Error(\"[elysia-aot] handler reconstruction was stripped (strip mode) but a route needed it. Rebuild with strip:false.\")}\nexport class Reconstrct {\n static validator(){return e()}\n static cookie(){return e()}\n static trace(){return e()}\n}\n"
154
+ source: "const e=()=>{throw new Error(\"[elysia-aot] handler reconstruction was stripped (strip mode) but a route needed it. Rebuild with strip:false.\")}\nexport class Reconstruct {\n static validator(){return e()}\n static cookie(){return e()}\n static trace(){return e()}\n}\n"
154
155
  }],
155
156
  cookie: [
156
157
  {
@@ -491,7 +492,7 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
491
492
  const artifacts = await require_plugin_aot_source.captureArtifacts(typedApp, sourceOptions);
492
493
  const report = require_plugin_aot_source.replayStubbability(typedApp, artifacts.handlers);
493
494
  const aliases = /* @__PURE__ */ new Set();
494
- for (const handler of artifacts.handlers) if (handler.alias) for (const name of handler.alias.split(",")) aliases.add(name);
495
+ for (const handler of artifacts.handlers) if (handler.alias) for (const name of handler.alias.split(",")) aliases.add(require_compile_handler_params.isResponseParam(name) ? "va" : name);
495
496
  const history = typedApp["~routes"];
496
497
  const hasWS = !!typedApp["~hasWS"] || history.some((route) => route[0] === "WS");
497
498
  const mayTrace = !!typedApp["~hasTrace"] || history.some((route) => (route?.[4])?.trace?.length || route?.[2]?.["~mount"]);
@@ -517,6 +518,7 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
517
518
  };
518
519
  const [, , , instance, hook, appHook, inheritedChain, macroScope] = route;
519
520
  const hooks = require_compile_handler_index.composeRouteHook(instance, hook, appHook, inheritedChain, typedApp, macroScope);
521
+ require_compile_handler_index.runIntrospect(hooks);
520
522
  if (method === "WS" && (hook?.cookie !== void 0 || hooks?.cookie !== void 0)) wsCookie = true;
521
523
  if (!hooks) continue;
522
524
  let routeHasTypeBoxDirectSlot = false;
@@ -545,7 +547,8 @@ async function generateCompiledArtifacts(file, options, moduleCondition = resolv
545
547
  }
546
548
  if (typedApp["~config"]?.normalize === "typebox") routesForbidSeal = true;
547
549
  const validatorSlotsMatch = validatorSlotSetsMatch(expectedSlots, artifacts.validators);
548
- const { plan: stub, mode } = planFromReport(strip, report, hasWS, mayTrace, aliases, (artifacts.handlers.some((h) => h.code) || artifacts.validators.length > 0) && !routesForbidSeal && validatorSlotsMatch && artifacts.validators.every((v) => v.bridgeFree === true), !artifacts.handlers.some((h) => h.code) && artifacts.validators.length === 0, adapterStub, productionStub, wsCookie, exactMirror);
550
+ const hasReplayableCapture = artifacts.handlers.some((h) => h.code) || artifacts.validators.length > 0;
551
+ const { plan: stub, mode } = planFromReport(strip, report, hasWS, mayTrace, aliases, hasReplayableCapture && !routesForbidSeal && validatorSlotsMatch && artifacts.validators.every((v) => v.bridgeFree === true), !hasReplayableCapture, adapterStub, productionStub, wsCookie, exactMirror);
549
552
  if (options?.target === "workerd") {
550
553
  if (!report.jit) throw new Error(`[elysia-aot] target 'workerd' but handler JIT is still reachable (${report.reasons.join(", ") || "unknown"}). Every route must be captured into the AOT manifest.`);
551
554
  if (!validatorSlotsMatch) console.warn("[elysia-aot] target 'workerd': captured validator slots do not exactly match declared slots; unfrozen slots compile at runtime and will fail on workerd.");