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,19 +1,20 @@
1
+ // @bun
1
2
  import { isEmpty } from "../../utils.mjs";
2
3
  import { ELYSIA_TYPES } from "../constants.mjs";
3
4
  import { Refine, Unsafe } from "../typebox-type.mjs";
4
5
  import { Refines, elyType, withMeta } from "./utils.mjs";
5
6
 
6
7
  //#region src/type/elysia/array-buffer.ts
7
- function bufferType(tag, base) {
8
- let Base;
8
+ function bufferType(tag, createBase) {
9
+ let base;
9
10
  let empty;
10
11
  return (property) => {
11
- Base ??= base();
12
- if (!property || isEmpty(property)) return empty ??= Object.freeze(elyType(tag, Base));
12
+ base ??= createBase();
13
+ if (!property || isEmpty(property)) return empty ??= Object.freeze(elyType(tag, base));
13
14
  const refines = [];
14
15
  if (property.minByteLength !== void 0) refines.push([(value) => value.byteLength >= property.minByteLength, `Expect byte to be more than ${property.minByteLength}`]);
15
16
  if (property.maxByteLength !== void 0) refines.push([(value) => value.byteLength <= property.maxByteLength, `Expect byte to be less than ${property.maxByteLength}`]);
16
- return elyType(tag, withMeta(Refines(Base, refines), property));
17
+ return elyType(tag, withMeta(Refines(base, refines), property));
17
18
  };
18
19
  }
19
20
  const arrayBuffer = /* @__PURE__ */ bufferType(ELYSIA_TYPES.ArrayBuffer, () => Refine(Unsafe({ "~kind": "ArrayBuffer" }), (value) => value instanceof ArrayBuffer, () => "must be ArrayBuffer"));
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { nullObject } from "../../utils.mjs";
2
3
  import { ELYSIA_TYPES } from "../constants.mjs";
3
4
  import { ArrayType } from "./array.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isEmpty } from "../../utils.mjs";
2
3
 
3
4
  //#region src/type/elysia/array.ts
@@ -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 { primitive } from "./number.mjs";
2
3
 
3
4
  //#region src/type/elysia/boolean.ts
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { ObjectType } from "./object.mjs";
2
3
 
3
4
  //#region src/type/elysia/cookie.ts
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isEmpty } from "../../utils.mjs";
2
3
  import { ELYSIA_TYPES } from "../constants.mjs";
3
4
  import { Codec, Refine, Unsafe } from "../typebox-type.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isProduction } from "../../universal/is-production.mjs";
2
3
  import { isAsyncFunction } from "../../compile/utils.mjs";
3
4
 
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isBlob, isEmpty } from "../../utils.mjs";
2
3
  import { ELYSIA_TYPES } from "../constants.mjs";
3
4
  import { Refine, Unsafe } from "../typebox-type.mjs";
@@ -1,3 +1,4 @@
1
+ // @bun
1
2
  import { isBlob, isEmpty } from "../../utils.mjs";
2
3
  import { ELYSIA_TYPES } from "../constants.mjs";
3
4
  import { Decode } from "../typebox-type.mjs";
@@ -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