elysia 2.0.0-beta.11 → 2.0.0-beta.13

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 (99) hide show
  1. package/dist/adapter/bun/index.js +36 -21
  2. package/dist/adapter/bun/index.mjs +36 -21
  3. package/dist/adapter/utils.js +1 -0
  4. package/dist/adapter/utils.mjs +1 -0
  5. package/dist/adapter/web-standard/handler.js +8 -2
  6. package/dist/adapter/web-standard/handler.mjs +8 -2
  7. package/dist/base.d.ts +5 -0
  8. package/dist/base.js +109 -4
  9. package/dist/base.mjs +111 -6
  10. package/dist/compile/aot-capture.d.ts +2 -13
  11. package/dist/compile/aot-capture.js +5 -27
  12. package/dist/compile/aot-capture.mjs +6 -24
  13. package/dist/compile/aot-emit.js +1 -1
  14. package/dist/compile/aot-emit.mjs +1 -1
  15. package/dist/compile/aot.d.ts +1 -1
  16. package/dist/compile/aot.js +2 -2
  17. package/dist/compile/aot.mjs +2 -2
  18. package/dist/compile/handler/descriptor.d.ts +4 -8
  19. package/dist/compile/handler/descriptor.js +8 -21
  20. package/dist/compile/handler/descriptor.mjs +9 -21
  21. package/dist/compile/handler/index.d.ts +4 -3
  22. package/dist/compile/handler/index.js +16 -6
  23. package/dist/compile/handler/index.mjs +16 -7
  24. package/dist/compile/handler/jit.js +82 -76
  25. package/dist/compile/handler/jit.mjs +83 -77
  26. package/dist/compile/handler/params.d.ts +1 -4
  27. package/dist/compile/handler/params.js +3 -4
  28. package/dist/compile/handler/params.mjs +5 -5
  29. package/dist/compile/handler/reconstruct.d.ts +1 -1
  30. package/dist/compile/handler/static-clone-resolver.d.ts +6 -0
  31. package/dist/compile/handler/static-clone-resolver.js +8 -0
  32. package/dist/compile/handler/static-clone-resolver.mjs +7 -0
  33. package/dist/compile/handler/utils.d.ts +7 -7
  34. package/dist/compile/handler/utils.js +24 -20
  35. package/dist/compile/handler/utils.mjs +24 -20
  36. package/dist/compile/utils.js +7 -4
  37. package/dist/compile/utils.mjs +7 -4
  38. package/dist/context.js +3 -21
  39. package/dist/context.mjs +4 -22
  40. package/dist/cookie/index.d.ts +1 -2
  41. package/dist/cookie/index.js +0 -2
  42. package/dist/cookie/index.mjs +1 -2
  43. package/dist/cookie/lib.js +2 -1
  44. package/dist/cookie/lib.mjs +2 -1
  45. package/dist/cookie/utils.d.ts +3 -7
  46. package/dist/cookie/utils.js +9 -28
  47. package/dist/cookie/utils.mjs +11 -29
  48. package/dist/error.d.ts +40 -83
  49. package/dist/error.js +18 -19
  50. package/dist/error.mjs +18 -20
  51. package/dist/handler/error.js +4 -5
  52. package/dist/handler/error.mjs +4 -5
  53. package/dist/handler/fetch.js +31 -17
  54. package/dist/handler/fetch.mjs +32 -18
  55. package/dist/handler/utils.d.ts +3 -3
  56. package/dist/handler/utils.js +28 -17
  57. package/dist/handler/utils.mjs +28 -17
  58. package/dist/index.d.ts +3 -3
  59. package/dist/package.js +1 -1
  60. package/dist/package.mjs +1 -1
  61. package/dist/plugin/aot/core.d.ts +3 -7
  62. package/dist/plugin/aot/core.js +8 -18
  63. package/dist/plugin/aot/core.mjs +9 -17
  64. package/dist/plugin/aot/hooks.js +5 -1
  65. package/dist/plugin/aot/hooks.mjs +5 -1
  66. package/dist/trace.js +23 -10
  67. package/dist/trace.mjs +23 -10
  68. package/dist/type/bridge-live.d.ts +3 -2
  69. package/dist/type/bridge-live.js +4 -2
  70. package/dist/type/bridge-live.mjs +3 -2
  71. package/dist/type/bridge.d.ts +6 -4
  72. package/dist/type/bridge.js +9 -1
  73. package/dist/type/bridge.mjs +3 -1
  74. package/dist/type/coerce-plan.d.ts +2 -2
  75. package/dist/type/coerce-plan.js +0 -1
  76. package/dist/type/coerce-plan.mjs +2 -2
  77. package/dist/type/compat.js +2 -1
  78. package/dist/type/compat.mjs +3 -2
  79. package/dist/type/constants.d.ts +1 -1
  80. package/dist/type/shared.d.ts +1 -3
  81. package/dist/type/shared.js +0 -3
  82. package/dist/type/shared.mjs +1 -3
  83. package/dist/type/typebox-value-live.d.ts +4 -3
  84. package/dist/type/typebox-value-live.js +5 -3
  85. package/dist/type/typebox-value-live.mjs +4 -3
  86. package/dist/type/typebox-value.d.ts +11 -7
  87. package/dist/type/typebox-value.js +2 -1
  88. package/dist/type/typebox-value.mjs +1 -1
  89. package/dist/type/validator/index.d.ts +1 -1
  90. package/dist/type/validator/validator-cache.d.ts +1 -1
  91. package/dist/types.d.ts +10 -17
  92. package/dist/universal/file.d.ts +1 -3
  93. package/dist/universal/file.js +0 -2
  94. package/dist/universal/file.mjs +1 -2
  95. package/dist/universal/is-production.d.ts +1 -2
  96. package/dist/universal/is-production.js +1 -3
  97. package/dist/universal/is-production.mjs +2 -3
  98. package/dist/utils.d.ts +0 -1
  99. package/package.json +13 -6
package/dist/trace.js CHANGED
@@ -4,6 +4,15 @@ const require_compile_lexer = require('./compile/lexer.js');
4
4
  const require_sucrose = require('./sucrose.js');
5
5
 
6
6
  //#region src/trace.ts
7
+ const withResolvers = typeof Promise.withResolvers === "function" ? Promise.withResolvers.bind(Promise) : function withResolvers() {
8
+ let resolve;
9
+ return {
10
+ promise: new Promise((r) => {
11
+ resolve = r;
12
+ }),
13
+ resolve
14
+ };
15
+ };
7
16
  const phaseGetter = {
8
17
  onRequest: "request",
9
18
  onParse: "parse",
@@ -146,6 +155,10 @@ function unionTracePhases(handlers) {
146
155
  }
147
156
  return union;
148
157
  }
158
+ /** Prevent rejected trace callbacks from becoming unhandled rejections. */
159
+ function fire(result) {
160
+ if (typeof result?.then === "function") result.then(void 0, (error) => console.error(error));
161
+ }
149
162
  var TraceRecorder = class {
150
163
  constructor() {
151
164
  this.remaining = 0;
@@ -158,7 +171,7 @@ var TraceRecorder = class {
158
171
  listen() {
159
172
  if (this.listenFn) return this.listenFn;
160
173
  if (this.begun) return this.listenFn = (_callback) => Promise.resolve(this.#result());
161
- const { promise, resolve } = Promise.withResolvers();
174
+ const { promise, resolve } = withResolvers();
162
175
  this.pendingPromise = promise;
163
176
  this.pendingResolve = resolve;
164
177
  return this.listenFn = (callback) => {
@@ -189,7 +202,7 @@ var TraceRecorder = class {
189
202
  #end() {
190
203
  if (this.endPromise) return this.endPromise;
191
204
  if (this.ended) return this.endPromise = Promise.resolve(this.endTime);
192
- const { promise, resolve } = Promise.withResolvers();
205
+ const { promise, resolve } = withResolvers();
193
206
  this.endPromise = promise;
194
207
  this.endResolve = resolve;
195
208
  return promise;
@@ -197,7 +210,7 @@ var TraceRecorder = class {
197
210
  #error() {
198
211
  if (this.errorPromise) return this.errorPromise;
199
212
  if (this.ended) return this.errorPromise = Promise.resolve(this.endError);
200
- const { promise, resolve } = Promise.withResolvers();
213
+ const { promise, resolve } = withResolvers();
201
214
  this.errorPromise = promise;
202
215
  this.errorResolve = resolve;
203
216
  return promise;
@@ -211,7 +224,7 @@ var TraceRecorder = class {
211
224
  const result = this.#result();
212
225
  resolve(result);
213
226
  const callbacks = this.callbacksBegin;
214
- if (callbacks) for (let i = 0; i < callbacks.length; i++) callbacks[i](result);
227
+ if (callbacks) for (let i = 0; i < callbacks.length; i++) fire(callbacks[i](result));
215
228
  }
216
229
  return this;
217
230
  }
@@ -228,8 +241,8 @@ var TraceRecorder = class {
228
241
  const index = this.childIndex++;
229
242
  const recorder = this;
230
243
  return (process) => {
231
- const { promise: end, resolve: resolveEnd } = Promise.withResolvers();
232
- const { promise: error, resolve: resolveError } = Promise.withResolvers();
244
+ const { promise: end, resolve: resolveEnd } = withResolvers();
245
+ const { promise: error, resolve: resolveError } = withResolvers();
233
246
  const callbacksEnd = [];
234
247
  const result = {
235
248
  ...process,
@@ -241,7 +254,7 @@ var TraceRecorder = class {
241
254
  return end;
242
255
  }
243
256
  };
244
- for (let i = 0; i < children.length; i++) children[i](result);
257
+ for (let i = 0; i < children.length; i++) fire(children[i](result));
245
258
  let resolved = false;
246
259
  return (err = null) => {
247
260
  if (resolved) return;
@@ -255,7 +268,7 @@ var TraceRecorder = class {
255
268
  return endAt - process.begin;
256
269
  }
257
270
  };
258
- for (let i = 0; i < callbacksEnd.length; i++) callbacksEnd[i](detail);
271
+ for (let i = 0; i < callbacksEnd.length; i++) fire(callbacksEnd[i](detail));
259
272
  resolveEnd(endAt);
260
273
  resolveError(err);
261
274
  };
@@ -278,7 +291,7 @@ var TraceRecorder = class {
278
291
  return end - begun.begin;
279
292
  }
280
293
  };
281
- for (let i = 0; i < callbacks.length; i++) callbacks[i](detail);
294
+ for (let i = 0; i < callbacks.length; i++) fire(callbacks[i](detail));
282
295
  }
283
296
  this.endResolve?.(end);
284
297
  this.errorResolve?.(error);
@@ -380,7 +393,7 @@ var TracerLifecycle = class {
380
393
  const createTracer = (traceListener) => (context) => {
381
394
  const handle = new TracerHandle();
382
395
  handle.rid = context.rid ?? "";
383
- traceListener(new TracerLifecycle(handle, context));
396
+ fire(traceListener(new TracerLifecycle(handle, context)));
384
397
  return handle;
385
398
  };
386
399
 
package/dist/trace.mjs CHANGED
@@ -3,6 +3,15 @@ import { isIdentCharCode } from "./compile/lexer.mjs";
3
3
  import { findAlias, retrieveRootparameters, separateFunction } from "./sucrose.mjs";
4
4
 
5
5
  //#region src/trace.ts
6
+ const withResolvers = typeof Promise.withResolvers === "function" ? Promise.withResolvers.bind(Promise) : function withResolvers() {
7
+ let resolve;
8
+ return {
9
+ promise: new Promise((r) => {
10
+ resolve = r;
11
+ }),
12
+ resolve
13
+ };
14
+ };
6
15
  const phaseGetter = {
7
16
  onRequest: "request",
8
17
  onParse: "parse",
@@ -145,6 +154,10 @@ function unionTracePhases(handlers) {
145
154
  }
146
155
  return union;
147
156
  }
157
+ /** Prevent rejected trace callbacks from becoming unhandled rejections. */
158
+ function fire(result) {
159
+ if (typeof result?.then === "function") result.then(void 0, (error) => console.error(error));
160
+ }
148
161
  var TraceRecorder = class {
149
162
  constructor() {
150
163
  this.remaining = 0;
@@ -157,7 +170,7 @@ var TraceRecorder = class {
157
170
  listen() {
158
171
  if (this.listenFn) return this.listenFn;
159
172
  if (this.begun) return this.listenFn = (_callback) => Promise.resolve(this.#result());
160
- const { promise, resolve } = Promise.withResolvers();
173
+ const { promise, resolve } = withResolvers();
161
174
  this.pendingPromise = promise;
162
175
  this.pendingResolve = resolve;
163
176
  return this.listenFn = (callback) => {
@@ -188,7 +201,7 @@ var TraceRecorder = class {
188
201
  #end() {
189
202
  if (this.endPromise) return this.endPromise;
190
203
  if (this.ended) return this.endPromise = Promise.resolve(this.endTime);
191
- const { promise, resolve } = Promise.withResolvers();
204
+ const { promise, resolve } = withResolvers();
192
205
  this.endPromise = promise;
193
206
  this.endResolve = resolve;
194
207
  return promise;
@@ -196,7 +209,7 @@ var TraceRecorder = class {
196
209
  #error() {
197
210
  if (this.errorPromise) return this.errorPromise;
198
211
  if (this.ended) return this.errorPromise = Promise.resolve(this.endError);
199
- const { promise, resolve } = Promise.withResolvers();
212
+ const { promise, resolve } = withResolvers();
200
213
  this.errorPromise = promise;
201
214
  this.errorResolve = resolve;
202
215
  return promise;
@@ -210,7 +223,7 @@ var TraceRecorder = class {
210
223
  const result = this.#result();
211
224
  resolve(result);
212
225
  const callbacks = this.callbacksBegin;
213
- if (callbacks) for (let i = 0; i < callbacks.length; i++) callbacks[i](result);
226
+ if (callbacks) for (let i = 0; i < callbacks.length; i++) fire(callbacks[i](result));
214
227
  }
215
228
  return this;
216
229
  }
@@ -227,8 +240,8 @@ var TraceRecorder = class {
227
240
  const index = this.childIndex++;
228
241
  const recorder = this;
229
242
  return (process) => {
230
- const { promise: end, resolve: resolveEnd } = Promise.withResolvers();
231
- const { promise: error, resolve: resolveError } = Promise.withResolvers();
243
+ const { promise: end, resolve: resolveEnd } = withResolvers();
244
+ const { promise: error, resolve: resolveError } = withResolvers();
232
245
  const callbacksEnd = [];
233
246
  const result = {
234
247
  ...process,
@@ -240,7 +253,7 @@ var TraceRecorder = class {
240
253
  return end;
241
254
  }
242
255
  };
243
- for (let i = 0; i < children.length; i++) children[i](result);
256
+ for (let i = 0; i < children.length; i++) fire(children[i](result));
244
257
  let resolved = false;
245
258
  return (err = null) => {
246
259
  if (resolved) return;
@@ -254,7 +267,7 @@ var TraceRecorder = class {
254
267
  return endAt - process.begin;
255
268
  }
256
269
  };
257
- for (let i = 0; i < callbacksEnd.length; i++) callbacksEnd[i](detail);
270
+ for (let i = 0; i < callbacksEnd.length; i++) fire(callbacksEnd[i](detail));
258
271
  resolveEnd(endAt);
259
272
  resolveError(err);
260
273
  };
@@ -277,7 +290,7 @@ var TraceRecorder = class {
277
290
  return end - begun.begin;
278
291
  }
279
292
  };
280
- for (let i = 0; i < callbacks.length; i++) callbacks[i](detail);
293
+ for (let i = 0; i < callbacks.length; i++) fire(callbacks[i](detail));
281
294
  }
282
295
  this.endResolve?.(end);
283
296
  this.errorResolve?.(error);
@@ -379,7 +392,7 @@ var TracerLifecycle = class {
379
392
  const createTracer = (traceListener) => (context) => {
380
393
  const handle = new TracerHandle();
381
394
  handle.rid = context.rid ?? "";
382
- traceListener(new TracerLifecycle(handle, context));
395
+ fire(traceListener(new TracerLifecycle(handle, context)));
383
396
  return handle;
384
397
  };
385
398
 
@@ -4,12 +4,13 @@ import { useTypebox as useTypebox$1 } from "./bridge.js";
4
4
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-cache.js";
5
5
  import { TypeBoxValidator } from "./validator/index.js";
6
6
  import { applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure } from "./coerce.js";
7
- import { Check, Clone, Create, Decode, Default, HasCodec } from "typebox/value";
8
7
  import { Compile } from "typebox/compile";
9
8
  import { Ref } from "typebox/type";
9
+ import { Check, Clone, Create, Decode, Default, HasCodec } from "typebox/value";
10
10
 
11
11
  //#region src/type/bridge-live.d.ts
12
12
  declare function useTypebox(_mod?: Parameters<typeof useTypebox$1>[0]): void;
13
+ declare function warmTypebox(): void;
13
14
  declare const isBridgeLive: () => boolean;
14
15
  //#endregion
15
- export { Check, Clone, Compile, Create, Decode, Default, HasCodec, Intersect, Ref, TypeBoxValidator, TypeBoxValidatorCache, applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure, hasTypes, isBridgeLive, mayHaveFileType, useTypebox };
16
+ export { Check, Clone, Compile, Create, Decode, Default, HasCodec, Intersect, Ref, TypeBoxValidator, TypeBoxValidatorCache, applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure, hasTypes, isBridgeLive, mayHaveFileType, useTypebox, warmTypebox };
@@ -5,14 +5,15 @@ const require_type_coerce = require('./coerce.js');
5
5
  const require_type_validator_validator_cache = require('./validator/validator-cache.js');
6
6
  const require_type_validator_index = require('./validator/index.js');
7
7
  const require_type_elysia_intersect = require('./elysia/intersect.js');
8
- let typebox_value = require("typebox/value");
9
8
  let typebox_compile = require("typebox/compile");
10
9
  let typebox_type = require("typebox/type");
10
+ let typebox_value = require("typebox/value");
11
11
  let typebox_system = require("typebox/system");
12
12
 
13
13
  //#region src/type/bridge-live.ts
14
14
  typebox_system.Settings.Set({ unionPrioritySort: false });
15
15
  function useTypebox(_mod) {}
16
+ function warmTypebox() {}
16
17
  const isBridgeLive = () => true;
17
18
 
18
19
  //#endregion
@@ -36,4 +37,5 @@ exports.coerceStringToStructure = require_type_coerce.coerceStringToStructure;
36
37
  exports.hasTypes = require_type_utils.hasTypes;
37
38
  exports.isBridgeLive = isBridgeLive;
38
39
  exports.mayHaveFileType = require_type_validator_validator_cache.mayHaveFileType;
39
- exports.useTypebox = useTypebox;
40
+ exports.useTypebox = useTypebox;
41
+ exports.warmTypebox = warmTypebox;
@@ -3,15 +3,16 @@ import { applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, co
3
3
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-cache.mjs";
4
4
  import { TypeBoxValidator } from "./validator/index.mjs";
5
5
  import { Intersect } from "./elysia/intersect.mjs";
6
- import { Check, Clone, Create, Decode, Default, HasCodec } from "typebox/value";
7
6
  import { Compile } from "typebox/compile";
8
7
  import { Ref } from "typebox/type";
8
+ import { Check, Clone, Create, Decode, Default, HasCodec } from "typebox/value";
9
9
  import { Settings } from "typebox/system";
10
10
 
11
11
  //#region src/type/bridge-live.ts
12
12
  Settings.Set({ unionPrioritySort: false });
13
13
  function useTypebox(_mod) {}
14
+ function warmTypebox() {}
14
15
  const isBridgeLive = () => true;
15
16
 
16
17
  //#endregion
17
- export { Check, Clone, Compile, Create, Decode, Default, HasCodec, Intersect, Ref, TypeBoxValidator, TypeBoxValidatorCache, applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure, hasTypes, isBridgeLive, mayHaveFileType, useTypebox };
18
+ export { Check, Clone, Compile, Create, Decode, Default, HasCodec, Intersect, Ref, TypeBoxValidator, TypeBoxValidatorCache, applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure, hasTypes, isBridgeLive, mayHaveFileType, useTypebox, warmTypebox };
@@ -3,15 +3,15 @@ import { hasTypes as hasTypes$1 } from "./utils.js";
3
3
  import { TypeBoxValidatorCache as TypeBoxValidatorCache$1, mayHaveFileType as mayHaveFileType$1 } from "./validator/validator-cache.js";
4
4
  import { TypeBoxValidator as TypeBoxValidator$1 } from "./validator/index.js";
5
5
  import { applyCoercions as applyCoercions$1, coerceBody as coerceBody$1, coerceFormData as coerceFormData$1, coerceQuery as coerceQuery$1, coerceRoot as coerceRoot$1, coerceStringToStructure as coerceStringToStructure$1 } from "./coerce.js";
6
- import { Check as Check$1, Clone as Clone$1, Create as Create$1, Decode as Decode$1, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
7
6
  import { Compile as Compile$1 } from "typebox/compile";
8
7
  import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
8
+ import { Check as Check$1, Clone as Clone$1, Create as Create$1, Decode as Decode$2, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
9
9
 
10
10
  //#region src/type/bridge.d.ts
11
11
  interface TypeboxModule {
12
12
  Compile: typeof Compile$1;
13
13
  Create: typeof Create$1;
14
- Decode: typeof Decode$1;
14
+ Decode: typeof Decode$2;
15
15
  applyCoercions: typeof applyCoercions$1;
16
16
  TypeBoxValidator: TypeBoxValidator$1;
17
17
  TypeBoxValidatorCache: TypeBoxValidatorCache$1;
@@ -28,10 +28,11 @@ interface TypeboxModule {
28
28
  Ref: typeof Ref$1;
29
29
  Clone: typeof Clone$1;
30
30
  Check: typeof Check$1;
31
+ warmTypebox: () => void;
31
32
  }
32
33
  declare let Compile: typeof Compile$1;
33
34
  declare let Create: typeof Create$1;
34
- declare let Decode: typeof Decode$1;
35
+ declare let Decode: typeof Decode$2;
35
36
  declare let applyCoercions: typeof applyCoercions$1;
36
37
  declare let TypeBoxValidator: TypeBoxValidator$1;
37
38
  type TypeBoxValidator<T extends TSchema = TAny> = TypeBoxValidator$1<T>;
@@ -50,7 +51,8 @@ declare let Default: typeof Default$1;
50
51
  declare let Ref: typeof Ref$1;
51
52
  declare let Clone: typeof Clone$1;
52
53
  declare let Check: typeof Check$1;
54
+ declare let warmTypebox: () => void;
53
55
  declare const isBridgeLive: () => boolean;
54
56
  declare function useTypebox(mod: TypeboxModule): void;
55
57
  //#endregion
56
- export { Check, Clone, Compile, Create, Decode, Default, HasCodec, Intersect, Ref, TypeBoxValidator, TypeBoxValidatorCache, applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure, hasTypes, isBridgeLive, mayHaveFileType, useTypebox };
58
+ export { Check, Clone, Compile, Create, Decode, Default, HasCodec, Intersect, Ref, TypeBoxValidator, TypeBoxValidatorCache, applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure, hasTypes, isBridgeLive, mayHaveFileType, useTypebox, warmTypebox };
@@ -37,6 +37,7 @@ let Default = stub("Default");
37
37
  let Ref = stub("Ref");
38
38
  let Clone = stub("Clone");
39
39
  let Check = stub("Check");
40
+ let warmTypebox = stub("warmTypebox");
40
41
  const isBridgeLive = () => live !== void 0;
41
42
  function useTypebox(mod) {
42
43
  live = mod;
@@ -59,6 +60,7 @@ function useTypebox(mod) {
59
60
  Ref = mod.Ref;
60
61
  Clone = mod.Clone;
61
62
  Check = mod.Check;
63
+ warmTypebox = mod.warmTypebox;
62
64
  }
63
65
 
64
66
  //#endregion
@@ -177,4 +179,10 @@ Object.defineProperty(exports, 'mayHaveFileType', {
177
179
  return mayHaveFileType;
178
180
  }
179
181
  });
180
- exports.useTypebox = useTypebox;
182
+ exports.useTypebox = useTypebox;
183
+ Object.defineProperty(exports, 'warmTypebox', {
184
+ enumerable: true,
185
+ get: function () {
186
+ return warmTypebox;
187
+ }
188
+ });
@@ -35,6 +35,7 @@ let Default = stub("Default");
35
35
  let Ref = stub("Ref");
36
36
  let Clone = stub("Clone");
37
37
  let Check = stub("Check");
38
+ let warmTypebox = stub("warmTypebox");
38
39
  const isBridgeLive = () => live !== void 0;
39
40
  function useTypebox(mod) {
40
41
  live = mod;
@@ -57,7 +58,8 @@ function useTypebox(mod) {
57
58
  Ref = mod.Ref;
58
59
  Clone = mod.Clone;
59
60
  Check = mod.Check;
61
+ warmTypebox = mod.warmTypebox;
60
62
  }
61
63
 
62
64
  //#endregion
63
- export { Check, Clone, Compile, Create, Decode, Default, HasCodec, Intersect, Ref, TypeBoxValidator, TypeBoxValidatorCache, applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure, hasTypes, isBridgeLive, mayHaveFileType, useTypebox };
65
+ export { Check, Clone, Compile, Create, Decode, Default, HasCodec, Intersect, Ref, TypeBoxValidator, TypeBoxValidatorCache, applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure, hasTypes, isBridgeLive, mayHaveFileType, useTypebox, warmTypebox };
@@ -1,7 +1,7 @@
1
1
  import { BooleanString } from "./elysia/boolean-string.js";
2
2
  import { IntegerString } from "./elysia/integer-string.js";
3
3
  import { Numeric } from "./elysia/numeric.js";
4
- import { clearCoerceLeafCache, coerceLeafCacheSize } from "./shared.js";
4
+ import { clearCoerceLeafCache } from "./shared.js";
5
5
 
6
6
  //#region src/type/coerce-plan.d.ts
7
7
  declare const COERCE_LEAF_CTOR: {
@@ -35,4 +35,4 @@ type RebuildObjStr = (original: any, site: CoerceObjStr) => any;
35
35
  declare const COERCE_LEAF_CACHE_LIMIT = 1024;
36
36
  declare function buildCoercedFromPlan(original: any, plan: CoerceNode, seen?: Set<string>, objStr?: RebuildObjStr): any;
37
37
  //#endregion
38
- export { COERCE_LEAF_CACHE_LIMIT, COERCE_LEAF_CTOR, CoerceLeaf, CoerceNode, CoerceObjStr, CoercePlan, CoerceUnion, RebuildObjStr, buildCoercedFromPlan, clearCoerceLeafCache, coerceLeafCacheSize, isCoerceLeaf, isCoerceObjStr, isCoerceUnion };
38
+ export { COERCE_LEAF_CACHE_LIMIT, COERCE_LEAF_CTOR, CoerceLeaf, CoerceNode, CoerceObjStr, CoercePlan, CoerceUnion, RebuildObjStr, buildCoercedFromPlan, clearCoerceLeafCache, isCoerceLeaf, isCoerceObjStr, isCoerceUnion };
@@ -101,7 +101,6 @@ exports.COERCE_LEAF_CACHE_LIMIT = COERCE_LEAF_CACHE_LIMIT;
101
101
  exports.COERCE_LEAF_CTOR = COERCE_LEAF_CTOR;
102
102
  exports.buildCoercedFromPlan = buildCoercedFromPlan;
103
103
  exports.clearCoerceLeafCache = require_type_shared.clearCoerceLeafCache;
104
- exports.coerceLeafCacheSize = require_type_shared.coerceLeafCacheSize;
105
104
  exports.isCoerceLeaf = isCoerceLeaf;
106
105
  exports.isCoerceObjStr = isCoerceObjStr;
107
106
  exports.isCoerceUnion = isCoerceUnion;
@@ -1,6 +1,6 @@
1
1
  import { evictOldestHalf, nullObject } from "../utils.mjs";
2
2
  import { ELYSIA_TYPES } from "./constants.mjs";
3
- import { clearCoerceLeafCache, coerceLeafCache, coerceLeafCacheSize } from "./shared.mjs";
3
+ import { clearCoerceLeafCache, coerceLeafCache } from "./shared.mjs";
4
4
  import { Decode, Refine } from "./typebox-type.mjs";
5
5
  import { ArrayType } from "./elysia/array.mjs";
6
6
  import { StringType } from "./elysia/string.mjs";
@@ -96,4 +96,4 @@ function buildCoercedFromPlan(original, plan, seen = /* @__PURE__ */ new Set(),
96
96
  }
97
97
 
98
98
  //#endregion
99
- export { COERCE_LEAF_CACHE_LIMIT, COERCE_LEAF_CTOR, buildCoercedFromPlan, clearCoerceLeafCache, coerceLeafCacheSize, isCoerceLeaf, isCoerceObjStr, isCoerceUnion };
99
+ export { COERCE_LEAF_CACHE_LIMIT, COERCE_LEAF_CTOR, buildCoercedFromPlan, clearCoerceLeafCache, isCoerceLeaf, isCoerceObjStr, isCoerceUnion };
@@ -56,7 +56,8 @@ function setupTypebox(options) {
56
56
  Default: require_type_typebox_value.Default,
57
57
  Ref: require_type_typebox_type.Ref,
58
58
  Clone: require_type_typebox_value.Clone,
59
- Check: require_type_typebox_value.Check
59
+ Check: require_type_typebox_value.Check,
60
+ warmTypebox: require_type_typebox_value.warmTypebox
60
61
  });
61
62
  }
62
63
 
@@ -1,7 +1,7 @@
1
1
  import { useTypebox } from "./bridge.mjs";
2
2
  import { hasTypes } from "./utils.mjs";
3
3
  import { Ref, injectTypeboxType } from "./typebox-type.mjs";
4
- import { Check, Clone, Compile, Create, Decode, Default, HasCodec, injectTypebox } from "./typebox-value.mjs";
4
+ import { Check, Clone, Compile, Create, Decode, Default, HasCodec, injectTypebox, warmTypebox as load } from "./typebox-value.mjs";
5
5
  import { applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure } from "./coerce.mjs";
6
6
  import { setExactMirror } from "./validator/exact-mirror.mjs";
7
7
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-cache.mjs";
@@ -55,7 +55,8 @@ function setupTypebox(options) {
55
55
  Default,
56
56
  Ref,
57
57
  Clone,
58
- Check
58
+ Check,
59
+ warmTypebox: load
59
60
  });
60
61
  }
61
62
 
@@ -17,7 +17,7 @@ declare const ELYSIA_TYPES: {
17
17
  readonly NoValidate: 15;
18
18
  };
19
19
  type ELYSIA_TYPES = typeof ELYSIA_TYPES;
20
- declare const primitiveElysiaTypes: Set<1 | 2 | 6 | 3 | 10 | 11 | 13 | 14>;
20
+ declare const primitiveElysiaTypes: Set<2 | 1 | 6 | 3 | 10 | 11 | 13 | 14>;
21
21
  declare const noEnumerable: {
22
22
  readonly enumerable: false;
23
23
  };
@@ -18,10 +18,8 @@ declare const isPureRefinement: (refinement: object) => boolean;
18
18
  /** @internal */
19
19
  declare const coerceLeafCache: Map<string, any>;
20
20
  /** @internal test isolation */
21
- declare const coerceLeafCacheSize: () => number;
22
- /** @internal test isolation */
23
21
  declare function clearCoerceLeafCache(): void;
24
22
  declare function cloneNode(node: BaseSchema, out: any): any;
25
23
  declare function nonAdditionalProperties(node: BaseSchema, seen?: WeakSet<object>): BaseSchema;
26
24
  //#endregion
27
- export { SHARED_REFERENCE_CACHE_LIMIT, clearCoerceLeafCache, clearSharedReferenceCaches, cloneNode, coerceLeafCache, coerceLeafCacheSize, isPureRefinement, nonAdditionalProperties, pureRefine, referenceCache };
25
+ export { SHARED_REFERENCE_CACHE_LIMIT, clearCoerceLeafCache, clearSharedReferenceCaches, cloneNode, coerceLeafCache, isPureRefinement, nonAdditionalProperties, pureRefine, referenceCache };
@@ -32,8 +32,6 @@ const isPureRefinement = (refinement) => pureRefinements.has(refinement);
32
32
  /** @internal */
33
33
  const coerceLeafCache = /* @__PURE__ */ new Map();
34
34
  /** @internal test isolation */
35
- const coerceLeafCacheSize = () => coerceLeafCache.size;
36
- /** @internal test isolation */
37
35
  function clearCoerceLeafCache() {
38
36
  coerceLeafCache.clear();
39
37
  }
@@ -164,7 +162,6 @@ exports.clearCoerceLeafCache = clearCoerceLeafCache;
164
162
  exports.clearSharedReferenceCaches = clearSharedReferenceCaches;
165
163
  exports.cloneNode = cloneNode;
166
164
  exports.coerceLeafCache = coerceLeafCache;
167
- exports.coerceLeafCacheSize = coerceLeafCacheSize;
168
165
  exports.isPureRefinement = isPureRefinement;
169
166
  exports.nonAdditionalProperties = nonAdditionalProperties;
170
167
  exports.pureRefine = pureRefine;
@@ -31,8 +31,6 @@ const isPureRefinement = (refinement) => pureRefinements.has(refinement);
31
31
  /** @internal */
32
32
  const coerceLeafCache = /* @__PURE__ */ new Map();
33
33
  /** @internal test isolation */
34
- const coerceLeafCacheSize = () => coerceLeafCache.size;
35
- /** @internal test isolation */
36
34
  function clearCoerceLeafCache() {
37
35
  coerceLeafCache.clear();
38
36
  }
@@ -158,4 +156,4 @@ function nonAdditionalProperties(node, seen = /* @__PURE__ */ new WeakSet()) {
158
156
  }
159
157
 
160
158
  //#endregion
161
- export { SHARED_REFERENCE_CACHE_LIMIT, clearCoerceLeafCache, clearSharedReferenceCaches, cloneNode, coerceLeafCache, coerceLeafCacheSize, isPureRefinement, nonAdditionalProperties, pureRefine, referenceCache };
159
+ export { SHARED_REFERENCE_CACHE_LIMIT, clearCoerceLeafCache, clearSharedReferenceCaches, cloneNode, coerceLeafCache, isPureRefinement, nonAdditionalProperties, pureRefine, referenceCache };
@@ -1,9 +1,10 @@
1
1
  import { TypeboxNamespaces } from "./typebox-value.js";
2
- import { Build, Compile as SchemaCompile } from "typebox/schema";
3
- import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
4
2
  import { Compile } from "typebox/compile";
3
+ import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
4
+ import { Build, Compile as SchemaCompile } from "typebox/schema";
5
5
 
6
6
  //#region src/type/typebox-value-live.d.ts
7
7
  declare function injectTypebox(_typebox?: TypeboxNamespaces): void;
8
+ declare function warmTypebox(): void;
8
9
  //#endregion
9
- export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, type TypeboxNamespaces, injectTypebox };
10
+ export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, type TypeboxNamespaces, injectTypebox, warmTypebox };
@@ -1,13 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.js');
3
- let typebox_schema = require("typebox/schema");
4
- let typebox_value = require("typebox/value");
5
3
  let typebox_compile = require("typebox/compile");
4
+ let typebox_value = require("typebox/value");
6
5
  let typebox_system = require("typebox/system");
6
+ let typebox_schema = require("typebox/schema");
7
7
 
8
8
  //#region src/type/typebox-value-live.ts
9
9
  typebox_system.Settings.Set({ unionPrioritySort: false });
10
10
  function injectTypebox(_typebox) {}
11
+ function warmTypebox() {}
11
12
 
12
13
  //#endregion
13
14
  exports.Build = typebox_schema.Build;
@@ -24,4 +25,5 @@ exports.EncodeUnsafe = typebox_value.EncodeUnsafe;
24
25
  exports.Errors = typebox_value.Errors;
25
26
  exports.HasCodec = typebox_value.HasCodec;
26
27
  exports.SchemaCompile = typebox_schema.Compile;
27
- exports.injectTypebox = injectTypebox;
28
+ exports.injectTypebox = injectTypebox;
29
+ exports.warmTypebox = warmTypebox;
@@ -1,11 +1,12 @@
1
- import { Build, Compile as SchemaCompile } from "typebox/schema";
2
- import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
3
1
  import { Compile } from "typebox/compile";
2
+ import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
4
3
  import { Settings } from "typebox/system";
4
+ import { Build, Compile as SchemaCompile } from "typebox/schema";
5
5
 
6
6
  //#region src/type/typebox-value-live.ts
7
7
  Settings.Set({ unionPrioritySort: false });
8
8
  function injectTypebox(_typebox) {}
9
+ function warmTypebox() {}
9
10
 
10
11
  //#endregion
11
- export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, injectTypebox };
12
+ export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, injectTypebox, warmTypebox };
@@ -1,9 +1,9 @@
1
- import * as _$typebox_schema0 from "typebox/schema";
2
- import { Build as Build$1, Compile as Compile$1 } from "typebox/schema";
1
+ import * as _$typebox_compile0 from "typebox/compile";
2
+ import { Compile as Compile$1 } from "typebox/compile";
3
3
  import * as _$typebox_value0 from "typebox/value";
4
4
  import { Check as Check$1, Clean as Clean$1, Clone as Clone$1, Create as Create$1, Decode as Decode$1, DecodeUnsafe as DecodeUnsafe$1, Default as Default$1, Encode as Encode$1, EncodeUnsafe as EncodeUnsafe$1, Errors as Errors$1, HasCodec as HasCodec$1 } from "typebox/value";
5
- import * as _$typebox_compile0 from "typebox/compile";
6
- import { Compile as Compile$2 } from "typebox/compile";
5
+ import * as _$typebox_schema0 from "typebox/schema";
6
+ import { Build as Build$1, Compile as Compile$2 } from "typebox/schema";
7
7
 
8
8
  //#region src/type/typebox-value.d.ts
9
9
  interface TypeboxNamespaces {
@@ -11,6 +11,10 @@ interface TypeboxNamespaces {
11
11
  schema: typeof _$typebox_schema0;
12
12
  compile: typeof _$typebox_compile0;
13
13
  }
14
+ /**
15
+ * Loads `typebox/value` + `typebox/schema` + `typebox/compile` on first use
16
+ */
17
+ declare function load(): void;
14
18
  declare let Check: typeof Check$1;
15
19
  declare let Clean: typeof Clean$1;
16
20
  declare let Clone: typeof Clone$1;
@@ -22,9 +26,9 @@ declare let Encode: typeof Encode$1;
22
26
  declare let EncodeUnsafe: typeof EncodeUnsafe$1;
23
27
  declare let Errors: typeof Errors$1;
24
28
  declare let HasCodec: typeof HasCodec$1;
25
- declare let SchemaCompile: typeof Compile$1;
29
+ declare let SchemaCompile: typeof Compile$2;
26
30
  declare let Build: typeof Build$1;
27
- declare let Compile: typeof Compile$2;
31
+ declare let Compile: typeof Compile$1;
28
32
  declare function injectTypebox(typebox: TypeboxNamespaces): void;
29
33
  //#endregion
30
- export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, TypeboxNamespaces, injectTypebox };
34
+ export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, TypeboxNamespaces, injectTypebox, load as warmTypebox };
@@ -144,4 +144,5 @@ Object.defineProperty(exports, 'SchemaCompile', {
144
144
  return SchemaCompile;
145
145
  }
146
146
  });
147
- exports.injectTypebox = injectTypebox;
147
+ exports.injectTypebox = injectTypebox;
148
+ exports.warmTypebox = load;
@@ -59,4 +59,4 @@ function injectTypebox(typebox) {
59
59
  }
60
60
 
61
61
  //#endregion
62
- export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, injectTypebox };
62
+ export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, injectTypebox, load as warmTypebox };
@@ -1,8 +1,8 @@
1
1
  import { MaybePromise } from "../../types.js";
2
2
  import { Validator as Validator$1, ValidatorOptions } from "../../validator/index.js";
3
3
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator-cache.js";
4
- import { Validator } from "typebox/schema";
5
4
  import { Static, StaticDecode, StaticEncode, TAny, TSchema } from "typebox/type";
5
+ import { Validator } from "typebox/schema";
6
6
  import { TLocalizedValidationError } from "typebox/error";
7
7
 
8
8
  //#region src/type/validator/index.d.ts
@@ -1,7 +1,7 @@
1
1
  import { CoerceOption } from "../coerce.js";
2
+ import { TSchema } from "typebox/type";
2
3
  import * as _$typebox_schema0 from "typebox/schema";
3
4
  import { Validator } from "typebox/schema";
4
- import { TSchema } from "typebox/type";
5
5
 
6
6
  //#region src/type/validator/validator-cache.d.ts
7
7
  interface SchemaMeta {