elysia 2.0.0-beta.21 → 2.0.0-beta.22

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 (215) 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 +213 -193
  20. package/dist/base.mjs +220 -199
  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 +77 -118
  37. package/dist/compile/handler/index.mjs +83 -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.js +7 -4
  96. package/dist/plugin/aot/core.mjs +8 -5
  97. package/dist/plugin/aot/esbuild.mjs +1 -0
  98. package/dist/plugin/aot/rspack-loader.mjs +1 -0
  99. package/dist/plugin/aot/rspack.mjs +1 -0
  100. package/dist/plugin/aot/treeshake.mjs +1 -0
  101. package/dist/plugin/aot/unplugin.mjs +4 -3
  102. package/dist/plugin/aot/vite.mjs +1 -0
  103. package/dist/plugin/aot/worker.mjs +1 -0
  104. package/dist/plugin/auto-head.mjs +1 -0
  105. package/dist/plugin/trace.mjs +1 -0
  106. package/dist/plugin/websocket.mjs +1 -0
  107. package/dist/route-table.mjs +1 -0
  108. package/dist/schema-snapshot.mjs +1 -0
  109. package/dist/sucrose.d.ts +2 -2
  110. package/dist/sucrose.js +11 -11
  111. package/dist/sucrose.mjs +12 -11
  112. package/dist/trace.js +8 -10
  113. package/dist/trace.mjs +10 -11
  114. package/dist/type/bridge-live.d.ts +1 -1
  115. package/dist/type/bridge-live.mjs +1 -0
  116. package/dist/type/bridge.d.ts +1 -1
  117. package/dist/type/bridge.mjs +1 -0
  118. package/dist/type/coerce-plan.mjs +1 -0
  119. package/dist/type/coerce.d.ts +1 -1
  120. package/dist/type/coerce.mjs +1 -0
  121. package/dist/type/compat.mjs +1 -0
  122. package/dist/type/constants.d.ts +1 -1
  123. package/dist/type/constants.mjs +1 -0
  124. package/dist/type/elysia/accelerate.mjs +1 -0
  125. package/dist/type/elysia/array-buffer.d.ts +3 -2
  126. package/dist/type/elysia/array-buffer.js +5 -5
  127. package/dist/type/elysia/array-buffer.mjs +6 -5
  128. package/dist/type/elysia/array-string.mjs +1 -0
  129. package/dist/type/elysia/array.mjs +1 -0
  130. package/dist/type/elysia/boolean-string.mjs +1 -0
  131. package/dist/type/elysia/boolean.mjs +1 -0
  132. package/dist/type/elysia/cookie.mjs +1 -0
  133. package/dist/type/elysia/date.mjs +1 -0
  134. package/dist/type/elysia/file-type.mjs +1 -0
  135. package/dist/type/elysia/file.mjs +1 -0
  136. package/dist/type/elysia/files.mjs +1 -0
  137. package/dist/type/elysia/form.mjs +1 -0
  138. package/dist/type/elysia/integer-string.mjs +1 -0
  139. package/dist/type/elysia/integer.mjs +1 -0
  140. package/dist/type/elysia/intersect.mjs +1 -0
  141. package/dist/type/elysia/json-string.mjs +1 -0
  142. package/dist/type/elysia/keep-config.js +8 -8
  143. package/dist/type/elysia/keep-config.mjs +9 -8
  144. package/dist/type/elysia/maybe-empty.mjs +1 -0
  145. package/dist/type/elysia/no-validate.mjs +1 -0
  146. package/dist/type/elysia/nullable.mjs +1 -0
  147. package/dist/type/elysia/number.mjs +1 -0
  148. package/dist/type/elysia/numeric-enum.d.ts +4 -2
  149. package/dist/type/elysia/numeric-enum.mjs +1 -0
  150. package/dist/type/elysia/numeric.mjs +1 -0
  151. package/dist/type/elysia/object-string.mjs +1 -0
  152. package/dist/type/elysia/object.mjs +1 -0
  153. package/dist/type/elysia/optional.mjs +1 -0
  154. package/dist/type/elysia/problem.mjs +1 -0
  155. package/dist/type/elysia/string.mjs +1 -0
  156. package/dist/type/elysia/uint8-array.d.ts +2 -1
  157. package/dist/type/elysia/uint8-array.js +2 -2
  158. package/dist/type/elysia/uint8-array.mjs +3 -2
  159. package/dist/type/elysia/union-enum.mjs +1 -0
  160. package/dist/type/elysia/union.mjs +1 -0
  161. package/dist/type/elysia/utils.js +3 -3
  162. package/dist/type/elysia/utils.mjs +4 -3
  163. package/dist/type/exports.mjs +1 -0
  164. package/dist/type/index.mjs +2 -1
  165. package/dist/type/shared.mjs +1 -0
  166. package/dist/type/sync-require.mjs +1 -0
  167. package/dist/type/typebox-system-lite.mjs +1 -0
  168. package/dist/type/typebox-system-require.mjs +1 -0
  169. package/dist/type/typebox-type-live.mjs +1 -0
  170. package/dist/type/typebox-value-live.mjs +1 -0
  171. package/dist/type/typebox-value-ops.mjs +1 -0
  172. package/dist/type/typebox-value.mjs +1 -0
  173. package/dist/type/types.d.ts +1 -1
  174. package/dist/type/types.mjs +1 -0
  175. package/dist/type/utils.mjs +1 -0
  176. package/dist/type/validator/clean-safe.mjs +1 -0
  177. package/dist/type/validator/custom-error.js +41 -33
  178. package/dist/type/validator/custom-error.mjs +42 -33
  179. package/dist/type/validator/default-precompute.d.ts +2 -2
  180. package/dist/type/validator/default-precompute.js +10 -11
  181. package/dist/type/validator/default-precompute.mjs +13 -13
  182. package/dist/type/validator/exact-mirror.mjs +1 -0
  183. package/dist/type/validator/frozen-check.js +7 -7
  184. package/dist/type/validator/frozen-check.mjs +8 -7
  185. package/dist/type/validator/index.d.ts +2 -2
  186. package/dist/type/validator/index.js +4 -8
  187. package/dist/type/validator/index.mjs +5 -8
  188. package/dist/type/validator/string-codec-aot.d.ts +1 -1
  189. package/dist/type/validator/string-codec-aot.mjs +1 -0
  190. package/dist/type/validator/validator-cache.js +18 -18
  191. package/dist/type/validator/validator-cache.mjs +19 -18
  192. package/dist/types.d.ts +105 -69
  193. package/dist/types.mjs +1 -0
  194. package/dist/universal/constants.mjs +1 -0
  195. package/dist/universal/file.mjs +1 -0
  196. package/dist/universal/index.mjs +1 -0
  197. package/dist/universal/is-production.mjs +1 -0
  198. package/dist/universal/server.mjs +1 -0
  199. package/dist/utils.d.ts +49 -31
  200. package/dist/utils.js +221 -109
  201. package/dist/utils.mjs +215 -106
  202. package/dist/validator/index.d.ts +3 -3
  203. package/dist/validator/index.js +4 -4
  204. package/dist/validator/index.mjs +5 -4
  205. package/dist/validator/route.d.ts +2 -2
  206. package/dist/validator/route.mjs +1 -0
  207. package/dist/ws/context.js +1 -1
  208. package/dist/ws/context.mjs +2 -1
  209. package/dist/ws/index.mjs +1 -0
  210. package/dist/ws/parser.mjs +1 -0
  211. package/dist/ws/route.js +34 -25
  212. package/dist/ws/route.mjs +40 -30
  213. package/dist/ws/types.d.ts +2 -3
  214. package/dist/ws/types.mjs +1 -0
  215. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isElysiaForm } from "../../utils.mjs";
2
3
  import { ELYSIA_TYPES } from "../constants.mjs";
3
4
  import { Decode, Refine, Unsafe } from "../typebox-type.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { ELYSIA_TYPES } from "../constants.mjs";
2
3
  import { pureRefine } from "../shared.mjs";
3
4
  import { Refine } from "../typebox-type.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { primitive } from "./number.mjs";
2
3
 
3
4
  //#region src/type/elysia/integer.ts
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { noEnumerable } from "../constants.mjs";
2
3
 
3
4
  //#region src/type/elysia/intersect.ts
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { Check, Compile, Decode } from "../bridge.mjs";
2
3
  import { dropCompiledSource } from "../shared.mjs";
3
4
  import { Decode as Decode$1, Refine } from "../typebox-type.mjs";
@@ -3,16 +3,16 @@ const require_utils = require('../../utils.js');
3
3
  const require_type_typebox_type = require('../typebox-type.js');
4
4
 
5
5
  //#region src/type/elysia/keep-config.ts
6
- const carries = (schema, field = false, seen = /* @__PURE__ */ new Set()) => {
6
+ const mayCarryCookieConfig = (schema, isProperty = false, seen = /* @__PURE__ */ new Set()) => {
7
7
  if (!schema || typeof schema !== "object" || seen.has(schema)) return false;
8
8
  seen.add(schema);
9
- if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || require_utils.compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => carries(member, field, seen)))) return true;
10
- if (!field) {
11
- for (const name in schema.properties) if (carries(schema.properties[name], true)) return true;
9
+ if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || require_utils.compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => mayCarryCookieConfig(member, isProperty, seen)))) return true;
10
+ if (!isProperty) {
11
+ for (const name in schema.properties) if (mayCarryCookieConfig(schema.properties[name], true)) return true;
12
12
  }
13
13
  return false;
14
14
  };
15
- const from = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
15
+ const withSources = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
16
16
  value: sources,
17
17
  writable: true,
18
18
  configurable: true
@@ -20,13 +20,13 @@ const from = (schema, sources) => Object.defineProperty(Object.create(Object.get
20
20
  const keep = (build, sourcesOf) => ((...args) => {
21
21
  const sources = sourcesOf(...args);
22
22
  const result = build(...args);
23
- if (!sources.some((source) => carries(source))) return result;
24
- const built = from(result, sources);
23
+ if (!sources.some((source) => mayCarryCookieConfig(source))) return result;
24
+ const built = withSources(result, sources);
25
25
  const ref = built.$ref;
26
26
  const replaced = sources[0]?.$defs?.[ref];
27
27
  if (replaced && built.$defs?.[ref] && built.$defs[ref] !== replaced) built.$defs = {
28
28
  ...built.$defs,
29
- [ref]: from(built.$defs[ref], [replaced])
29
+ [ref]: withSources(built.$defs[ref], [replaced])
30
30
  };
31
31
  return built;
32
32
  });
@@ -1,17 +1,18 @@
1
+ // @bun
1
2
  import { compositionKeys } from "../../utils.mjs";
2
3
  import { Composite, Evaluate, Interface, Mapped, Omit, Partial, Pick, ReadonlyObject, Required } from "../typebox-type.mjs";
3
4
 
4
5
  //#region src/type/elysia/keep-config.ts
5
- const carries = (schema, field = false, seen = /* @__PURE__ */ new Set()) => {
6
+ const mayCarryCookieConfig = (schema, isProperty = false, seen = /* @__PURE__ */ new Set()) => {
6
7
  if (!schema || typeof schema !== "object" || seen.has(schema)) return false;
7
8
  seen.add(schema);
8
- if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => carries(member, field, seen)))) return true;
9
- if (!field) {
10
- for (const name in schema.properties) if (carries(schema.properties[name], true)) return true;
9
+ if (schema.config !== void 0 || schema.$ref !== void 0 || schema["~kind"] === "Deferred" || compositionKeys.some((key) => Array.isArray(schema[key]) && schema[key].some((member) => mayCarryCookieConfig(member, isProperty, seen)))) return true;
10
+ if (!isProperty) {
11
+ for (const name in schema.properties) if (mayCarryCookieConfig(schema.properties[name], true)) return true;
11
12
  }
12
13
  return false;
13
14
  };
14
- const from = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
15
+ const withSources = (schema, sources) => Object.defineProperty(Object.create(Object.getPrototypeOf(schema), Object.getOwnPropertyDescriptors(schema)), "~cookieFrom", {
15
16
  value: sources,
16
17
  writable: true,
17
18
  configurable: true
@@ -19,13 +20,13 @@ const from = (schema, sources) => Object.defineProperty(Object.create(Object.get
19
20
  const keep = (build, sourcesOf) => ((...args) => {
20
21
  const sources = sourcesOf(...args);
21
22
  const result = build(...args);
22
- if (!sources.some((source) => carries(source))) return result;
23
- const built = from(result, sources);
23
+ if (!sources.some((source) => mayCarryCookieConfig(source))) return result;
24
+ const built = withSources(result, sources);
24
25
  const ref = built.$ref;
25
26
  const replaced = sources[0]?.$defs?.[ref];
26
27
  if (replaced && built.$defs?.[ref] && built.$defs[ref] !== replaced) built.$defs = {
27
28
  ...built.$defs,
28
- [ref]: from(built.$defs[ref], [replaced])
29
+ [ref]: withSources(built.$defs[ref], [replaced])
29
30
  };
30
31
  return built;
31
32
  });
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { ELYSIA_TYPES } from "../constants.mjs";
2
3
  import { Null, Undefined } from "../typebox-type.mjs";
3
4
  import { Union } from "./union.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { ELYSIA_TYPES } from "../constants.mjs";
2
3
  import { elyType } from "./utils.mjs";
3
4
 
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { ELYSIA_TYPES } from "../constants.mjs";
2
3
  import { Null } from "../typebox-type.mjs";
3
4
  import { Union } from "./union.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isEmpty } from "../../utils.mjs";
2
3
  import { noEnumerable } from "../constants.mjs";
3
4
 
@@ -1,11 +1,13 @@
1
- import { TSchemaOptions } from "typebox";
1
+ import { TSchemaOptions, Type } from "typebox";
2
2
 
3
3
  //#region src/type/elysia/numeric-enum.d.ts
4
4
  type AssertNumericEnum<T extends Record<string, string | number>> = { [K in keyof T]: K extends number ? string : K extends `${number}` ? string : K extends string ? number : never };
5
+ type NumericEnumValue<T> = Extract<T[keyof T], number>;
6
+ type NumericEnumSchema<T> = Type.TCodec<Type.TRefine<Type.TUnsafe<NumericEnumValue<T> | `${NumericEnumValue<T>}`>>, NumericEnumValue<T>>;
5
7
  /**
6
8
  * Numeric enum: accepts a numeric string or a number, decodes to the
7
9
  * matching enum value.
8
10
  */
9
- declare function NumericEnum<T extends AssertNumericEnum<T>>(item: T, property?: TSchemaOptions): any;
11
+ declare function NumericEnum<T extends AssertNumericEnum<T>>(item: T, property?: TSchemaOptions): Readonly<NumericEnumSchema<T>>;
10
12
  //#endregion
11
13
  export { AssertNumericEnum, NumericEnum };
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { ELYSIA_TYPES } from "../constants.mjs";
2
3
  import { Decode, Refine } from "../typebox-type.mjs";
3
4
  import { StringType } from "./string.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isEmpty } from "../../utils.mjs";
2
3
  import { ELYSIA_TYPES } from "../constants.mjs";
3
4
  import { pureRefine } from "../shared.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { nullObject } from "../../utils.mjs";
2
3
  import { ELYSIA_TYPES } from "../constants.mjs";
3
4
  import { jsonString } from "./json-string.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isEmpty } from "../../utils.mjs";
2
3
 
3
4
  //#region src/type/elysia/object.ts
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { copyNonEnumerable } from "../shared.mjs";
2
3
 
3
4
  //#region src/type/elysia/optional.ts
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { StringType } from "./string.mjs";
2
3
  import { ObjectType } from "./object.mjs";
3
4
  import { Integer } from "./integer.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { evictOldestHalf } from "../../utils.mjs";
2
3
  import { noEnumerable } from "../constants.mjs";
3
4
  import { SHARED_REFERENCE_CACHE_LIMIT, referenceCache } from "../shared.mjs";
@@ -1,6 +1,7 @@
1
1
  import { ArrayBufferOptions } from "../types.js";
2
+ import * as _$typebox from "typebox";
2
3
 
3
4
  //#region src/type/elysia/uint8-array.d.ts
4
- declare const Uint8ArrayType: (property?: ArrayBufferOptions) => any;
5
+ declare const Uint8ArrayType: (property?: ArrayBufferOptions) => Readonly<_$typebox.TCodec<_$typebox.TRefine<_$typebox.TUnsafe<Uint8Array<ArrayBufferLike>>>, Uint8Array<ArrayBufferLike>>>;
5
6
  //#endregion
6
7
  export { Uint8ArrayType };
@@ -4,8 +4,8 @@ const require_type_typebox_type = require('../typebox-type.js');
4
4
  const require_type_elysia_array_buffer = require('./array-buffer.js');
5
5
 
6
6
  //#region src/type/elysia/uint8-array.ts
7
- const isUint8Array = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
8
- const uint8Array = /* @__PURE__ */ require_type_elysia_array_buffer.bufferType(require_type_constants.ELYSIA_TYPES.Uint8Array, () => require_type_typebox_type.Codec(require_type_typebox_type.Refine(require_type_typebox_type.Unsafe({ "~kind": "Uint8Array" }), isUint8Array, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value));
7
+ const isUint8ArrayOrArrayBuffer = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
8
+ const uint8Array = /* @__PURE__ */ require_type_elysia_array_buffer.bufferType(require_type_constants.ELYSIA_TYPES.Uint8Array, () => require_type_typebox_type.Codec(require_type_typebox_type.Refine(require_type_typebox_type.Unsafe({ "~kind": "Uint8Array" }), isUint8ArrayOrArrayBuffer, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value));
9
9
  const Uint8ArrayType = (property) => uint8Array(property);
10
10
 
11
11
  //#endregion
@@ -1,10 +1,11 @@
1
+ // @bun
1
2
  import { ELYSIA_TYPES } from "../constants.mjs";
2
3
  import { Codec, Refine, Unsafe } from "../typebox-type.mjs";
3
4
  import { bufferType } from "./array-buffer.mjs";
4
5
 
5
6
  //#region src/type/elysia/uint8-array.ts
6
- const isUint8Array = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
7
- const uint8Array = /* @__PURE__ */ bufferType(ELYSIA_TYPES.Uint8Array, () => Codec(Refine(Unsafe({ "~kind": "Uint8Array" }), isUint8Array, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value));
7
+ const isUint8ArrayOrArrayBuffer = (value) => value instanceof Uint8Array || value instanceof ArrayBuffer;
8
+ const uint8Array = /* @__PURE__ */ bufferType(ELYSIA_TYPES.Uint8Array, () => Codec(Refine(Unsafe({ "~kind": "Uint8Array" }), isUint8ArrayOrArrayBuffer, () => "must be Uint8Array")).Decode((value) => value instanceof Uint8Array ? value : new Uint8Array(value)).Encode((value) => value));
8
9
  const Uint8ArrayType = (property) => uint8Array(property);
9
10
 
10
11
  //#endregion
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { ELYSIA_TYPES } from "../constants.mjs";
2
3
  import { Unsafe } from "../typebox-type.mjs";
3
4
  import { elyType } from "./utils.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { noEnumerable } from "../constants.mjs";
2
3
 
3
4
  //#region src/type/elysia/union.ts
@@ -25,9 +25,9 @@ function createSharedReference(createType) {
25
25
  const hash = propertyChecksum(property);
26
26
  if (hash[1]) return createType(property);
27
27
  const h = hash[0];
28
- const canonicalKey = JSON.stringify(property);
28
+ const serialized = JSON.stringify(property);
29
29
  const bucket = shared.get(h);
30
- if (bucket?.key === canonicalKey) {
30
+ if (bucket?.key === serialized) {
31
31
  if (shared.size >= 1024) {
32
32
  shared.delete(h);
33
33
  shared.set(h, bucket);
@@ -37,7 +37,7 @@ function createSharedReference(createType) {
37
37
  const schema = Object.freeze(createType(property));
38
38
  if (!bucket && shared.size >= 1024) require_utils.evictOldestHalf(shared);
39
39
  shared.set(h, {
40
- key: canonicalKey,
40
+ key: serialized,
41
41
  schema
42
42
  });
43
43
  return schema;
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { evictOldestHalf, fnv1a } from "../../utils.mjs";
2
3
  import { SHARED_REFERENCE_CACHE_LIMIT, copyNonEnumerable, referenceCache } from "../shared.mjs";
3
4
  import { Refine } from "../typebox-type.mjs";
@@ -24,9 +25,9 @@ function createSharedReference(createType) {
24
25
  const hash = propertyChecksum(property);
25
26
  if (hash[1]) return createType(property);
26
27
  const h = hash[0];
27
- const canonicalKey = JSON.stringify(property);
28
+ const serialized = JSON.stringify(property);
28
29
  const bucket = shared.get(h);
29
- if (bucket?.key === canonicalKey) {
30
+ if (bucket?.key === serialized) {
30
31
  if (shared.size >= 1024) {
31
32
  shared.delete(h);
32
33
  shared.set(h, bucket);
@@ -36,7 +37,7 @@ function createSharedReference(createType) {
36
37
  const schema = Object.freeze(createType(property));
37
38
  if (!bucket && shared.size >= 1024) evictOldestHalf(shared);
38
39
  shared.set(h, {
39
- key: canonicalKey,
40
+ key: serialized,
40
41
  schema
41
42
  });
42
43
  return schema;
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { injectTypeboxType } from "./typebox-type.mjs";
2
3
  import { ArrayType } from "./elysia/array.mjs";
3
4
  import { StringType } from "./elysia/string.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { loadTypeNamespace, markTypeUsed } from "./typebox-type.mjs";
2
3
  import { ArrayType } from "./elysia/array.mjs";
3
4
  import { StringType } from "./elysia/string.mjs";
@@ -113,7 +114,7 @@ const t = lazyNamespace(() => loadTypeNamespace().type, {
113
114
  * `typebox/system` is a subgraph of `typebox/type`, so a static re-export here
114
115
  * would pin ~231 KB of the deferral back into the eager graph. The proxy also
115
116
  * guarantees Elysia's own `Settings` default lands BEFORE the namespace is
116
- * handed out, keeping a user's explicit `TypeSystem.Settings.Set(...)` last —
117
+ * handed out, keeping a user's explicit `TypeSystem.Settings.Set(...)` last \u2014
117
118
  * the ordering the eager `setupTypebox()` used to provide
118
119
  */
119
120
  const TypeSystem = lazyNamespace(() => typeSystem(loadTypeNamespace().system), Object.create(null));
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { noEnumerable } from "./constants.mjs";
2
3
 
3
4
  //#region src/type/shared.ts
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  //#region src/type/sync-require.ts
2
3
  /**
3
4
  * Synchronous `require` resolving from the CALLER's module: pass its own
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { Arguments, Environment, Hashing, Memory, Settings } from "typebox/system";
2
3
 
3
4
  export { Arguments, Environment, Hashing, Memory, Settings };
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { syncRequire } from "./sync-require.mjs";
2
3
 
3
4
  //#region src/type/typebox-system-require.ts
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import * as type from "typebox/type";
2
3
  import { Codec, Composite, Decode, Evaluate, Interface, Intersect, Mapped, Module, Null, Omit, Partial, Pick, ReadonlyObject, Ref, Refine, Required, Undefined, Unsafe } from "typebox/type";
3
4
  import * as system from "./typebox-system-lite.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { Build, Compile as SchemaCompile } from "typebox/schema";
2
3
  import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
3
4
  import { Compile } from "typebox/compile";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { Build, Compile as SchemaCompile } from "typebox/schema";
2
3
  import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
3
4
  import { Compile } from "typebox/compile";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { syncRequire } from "./sync-require.mjs";
2
3
  import { injectTypeboxType, isTypeNamespaceLoaded, isTypeUsed, loadTypeNamespace } from "./typebox-type.mjs";
3
4
  import { importTypebox, requireTypebox } from "./typebox-value-require.mjs";
@@ -1,5 +1,5 @@
1
- import { ELYSIA_TYPES } from "./constants.js";
2
1
  import { CookieOptions } from "../cookie/types.js";
2
+ import { ELYSIA_TYPES } from "./constants.js";
3
3
  import { TObjectOptions, TSchemaOptions } from "typebox";
4
4
  import { TLocalizedValidationError } from "typebox/error";
5
5
 
@@ -1 +1,2 @@
1
+ // @bun
1
2
  export { };
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { ELYSIA_TYPES, primitiveElysiaTypes } from "./constants.mjs";
2
3
  import { schemaSome } from "./validator/clean-safe.mjs";
3
4
 
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { dangerousKeys } from "../../constants.mjs";
2
3
 
3
4
  //#region src/type/validator/clean-safe.ts
@@ -1,6 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils = require('../../utils.js');
3
- const require_error = require('../../error.js');
4
3
  const require_compile_aot = require('../../compile/aot.js');
5
4
  const require_type_typebox_value = require('../typebox-value.js');
6
5
  const require_type_validator_frozen_check = require('./frozen-check.js');
@@ -8,10 +7,10 @@ const require_type_validator_frozen_check = require('./frozen-check.js');
8
7
  //#region src/type/validator/custom-error.ts
9
8
  function encodePointer(segments) {
10
9
  let out = "";
11
- for (const s of segments) out += "/" + s.replace(/~/g, "~0").replace(/\//g, "~1");
10
+ for (const s of segments) out += "/" + (typeof s === "object" ? "[]" : String(s).replace(/~/g, "~0").replace(/\//g, "~1"));
12
11
  return out;
13
12
  }
14
- function collectCustomErrorNodes(schema, segments, out, seen, union) {
13
+ function collectCustomErrorNodes(schema, segments, out, seen, union, required) {
15
14
  if (!schema || typeof schema !== "object") return out;
16
15
  if (seen.has(schema)) return out;
17
16
  seen.add(schema);
@@ -19,22 +18,16 @@ function collectCustomErrorNodes(schema, segments, out, seen, union) {
19
18
  path: encodePointer(segments),
20
19
  node: schema,
21
20
  segments,
21
+ required,
22
22
  union
23
23
  });
24
- if (schema.properties) for (const k in schema.properties) collectCustomErrorNodes(schema.properties[k], [...segments, k], out, seen, union);
25
- const items = schema.items;
26
- if (Array.isArray(items)) for (let i = 0; i < items.length; i++) collectCustomErrorNodes(items[i], [...segments, String(i)], out, seen, union);
27
- else if (items && typeof items === "object") {
28
- const inner = [];
29
- collectCustomErrorNodes(items, [], inner, seen, union);
30
- for (const child of inner) out.push({
31
- path: encodePointer(segments) + "/[]" + child.path,
32
- node: child.node,
33
- segments,
34
- each: { itemSegments: child.segments },
35
- union: child.union
36
- });
24
+ if (schema.properties) {
25
+ const keys = union?.segments !== segments && Array.isArray(schema.required) ? schema.required : void 0;
26
+ for (const k in schema.properties) collectCustomErrorNodes(schema.properties[k], [...segments, k], out, seen, union, keys?.includes(k));
37
27
  }
28
+ const items = schema.items;
29
+ if (Array.isArray(items)) for (let i = 0; i < items.length; i++) collectCustomErrorNodes(items[i], [...segments, i], out, seen, union);
30
+ else if (items && typeof items === "object") collectCustomErrorNodes(items, [...segments, { items }], out, seen, union);
38
31
  const branches = schema.anyOf ?? schema.oneOf;
39
32
  if (Array.isArray(branches)) for (let i = 0; i < branches.length; i++) collectCustomErrorNodes(branches[i], segments, out, seen, {
40
33
  node: schema,
@@ -77,26 +70,43 @@ function buildFindCustomError(schema, frozen) {
77
70
  const nodes = collectCustomErrorNodes(schema, [], [], /* @__PURE__ */ new WeakSet());
78
71
  if (!nodes.length) return;
79
72
  const frozenByPath = frozen?.ce ? new Map(frozen.ce.map((e) => [e.p, e])) : void 0;
80
- const unionCheckCache = /* @__PURE__ */ new WeakMap();
73
+ const checkCache = /* @__PURE__ */ new WeakMap();
81
74
  const discriminatorCache = /* @__PURE__ */ new WeakMap();
82
- const compileUnion = (node) => {
83
- const cached = unionCheckCache.get(node);
75
+ const compileOnce = (node) => {
76
+ const cached = checkCache.get(node);
84
77
  if (cached) return cached;
85
78
  try {
86
79
  const uc = require_type_typebox_value.SchemaCompile(node);
87
80
  const fn = (v) => uc.Check(v);
88
- unionCheckCache.set(node, fn);
81
+ checkCache.set(node, fn);
89
82
  return fn;
90
83
  } catch {
91
84
  return;
92
85
  }
93
86
  };
87
+ let found;
88
+ const reach = (value, segments) => {
89
+ let current = value;
90
+ for (let i = 0; i < segments.length; i++) {
91
+ const s = segments[i];
92
+ if (current === null || typeof current !== "object" || Array.isArray(current) === (typeof s === "string")) return -1;
93
+ if (typeof s === "object") {
94
+ const check = compileOnce(s.items);
95
+ const at = check ? current.findIndex((x) => !check(x)) : -1;
96
+ if (at < 0) return -1;
97
+ current = current[at];
98
+ } else if (s in current) current = current[s];
99
+ else return i === segments.length - 1 ? 0 : -1;
100
+ }
101
+ found = current;
102
+ return 1;
103
+ };
94
104
  const discriminatorsOf = (node, branches) => {
95
105
  if (!discriminatorCache.has(node)) discriminatorCache.set(node, findDiscriminators(branches));
96
106
  return discriminatorCache.get(node) ?? void 0;
97
107
  };
98
108
  const checks = [];
99
- for (const { path, node, each, segments, union } of nodes) {
109
+ for (const { path, node, segments, required, union } of nodes) {
100
110
  let check;
101
111
  const fe = union ? void 0 : frozenByPath?.get(path);
102
112
  if (fe) try {
@@ -107,23 +117,19 @@ function buildFindCustomError(schema, frozen) {
107
117
  check = (v) => c.Check(v);
108
118
  } catch {}
109
119
  if (!check) continue;
110
- if (each) {
111
- const leafCheck = check;
112
- const itemSegments = each.itemSegments;
113
- check = (v) => !Array.isArray(v) || v.every((x) => leafCheck(require_error.subValueAt(x, itemSegments)));
114
- }
115
120
  let gate;
116
121
  if (union) {
117
122
  const branches = union.node.anyOf ?? union.node.oneOf ?? [];
118
123
  const discriminators = discriminatorsOf(union.node, branches);
119
124
  if (!discriminators) gate = () => true;
120
125
  else {
121
- const unionCheck = compileUnion(union.node);
126
+ const unionCheck = compileOnce(union.node);
122
127
  if (!unionCheck) continue;
123
128
  const unionSegments = union.segments;
124
129
  const branchIndex = union.branchIndex;
125
130
  gate = (root) => {
126
- const unionValue = require_error.subValueAt(root, unionSegments);
131
+ if (reach(root, unionSegments) < 1) return true;
132
+ const unionValue = found;
127
133
  if (unionCheck(unionValue)) return true;
128
134
  if (unionValue === null || typeof unionValue !== "object") return true;
129
135
  let matches = 0;
@@ -146,7 +152,7 @@ function buildFindCustomError(schema, frozen) {
146
152
  }
147
153
  checks.push({
148
154
  segments,
149
- each,
155
+ required,
150
156
  check,
151
157
  gate,
152
158
  path,
@@ -154,11 +160,13 @@ function buildFindCustomError(schema, frozen) {
154
160
  });
155
161
  }
156
162
  if (!checks.length) return;
157
- checks.sort((a, b) => b.segments.length - a.segments.length || b.path.length - a.path.length);
163
+ checks.sort((a, b) => b.segments.length - a.segments.length);
158
164
  return (value) => {
159
165
  for (const c of checks) {
160
166
  if (c.gate && c.gate(value)) continue;
161
- if (!c.check(require_error.subValueAt(value, c.segments))) return {
167
+ const at = reach(value, c.segments);
168
+ if (at < 0 || !at && !c.required) continue;
169
+ if (!at || !c.check(found)) return {
162
170
  instancePath: c.path,
163
171
  error: c.error
164
172
  };
@@ -169,8 +177,8 @@ function captureCustomErrors(schema) {
169
177
  const ceNodes = collectCustomErrorNodes(schema, [], [], /* @__PURE__ */ new WeakSet());
170
178
  if (!ceNodes.length) return;
171
179
  const entries = [];
172
- for (const { path, node, union, each } of ceNodes) {
173
- if (union || each) continue;
180
+ for (const { path, node, union, segments } of ceNodes) {
181
+ if (union || segments.some((s) => typeof s === "object")) continue;
174
182
  try {
175
183
  const cf = require_type_validator_frozen_check.buildFrozenCheck(require_type_typebox_value.Build(node), node);
176
184
  if (cf) entries.push({