elysia 2.0.0-exp.53 → 2.0.0-exp.55

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.
package/dist/base.js CHANGED
@@ -210,7 +210,7 @@ var Elysia = class Elysia {
210
210
  return this;
211
211
  }
212
212
  #on(type, fn, scope = this["~config"]?.as) {
213
- this.#assertMutable("on" + (type[0].toUpperCase() + type.slice(1)));
213
+ if (this["~generation"] !== void 0) this.#assertMutable("on" + (type[0].toUpperCase() + type.slice(1)));
214
214
  const added = require_utils.nullObject();
215
215
  added[type] = fn;
216
216
  if (type === "trace") this["~hasTrace"] = true;
package/dist/base.mjs CHANGED
@@ -207,7 +207,7 @@ var Elysia = class Elysia {
207
207
  return this;
208
208
  }
209
209
  #on(type, fn, scope = this["~config"]?.as) {
210
- this.#assertMutable("on" + (type[0].toUpperCase() + type.slice(1)));
210
+ if (this["~generation"] !== void 0) this.#assertMutable("on" + (type[0].toUpperCase() + type.slice(1)));
211
211
  const added = nullObject();
212
212
  added[type] = fn;
213
213
  if (type === "trace") this["~hasTrace"] = true;
@@ -11,11 +11,10 @@ const require_compile_aot_reconstruct = require('./aot-reconstruct.js');
11
11
  const require_compile_aot_emit = require('./aot-emit.js');
12
12
  const require_type_validator_frozen_check = require('../type/validator/frozen-check.js');
13
13
  const require_type_validator_custom_error = require('../type/validator/custom-error.js');
14
+ const require_type_validator_exact_mirror = require('../type/validator/exact-mirror.js');
14
15
  const require_type_validator_string_codec_aot = require('../type/validator/string-codec-aot.js');
15
16
  let typebox_value = require("typebox/value");
16
17
  let typebox_schema = require("typebox/schema");
17
- let exact_mirror = require("exact-mirror");
18
- exact_mirror = require_runtime.__toESM(exact_mirror);
19
18
 
20
19
  //#region src/compile/aot-capture.ts
21
20
  function emptyContainers(node, depth) {
@@ -184,8 +183,10 @@ function maybeCapture(args) {
184
183
  });
185
184
  }
186
185
  function captureMirror(schema, aot, slot, sanitize) {
186
+ const createMirror = require_type_validator_exact_mirror.getExactMirror();
187
+ if (!createMirror) return;
187
188
  try {
188
- const emitted = (0, exact_mirror.default)(schema, {
189
+ const emitted = createMirror(schema, {
189
190
  Compile: typebox_schema.Compile,
190
191
  sanitize,
191
192
  emit: true
@@ -216,9 +217,11 @@ function captureMirror(schema, aot, slot, sanitize) {
216
217
  } catch {}
217
218
  }
218
219
  function captureCodecMirror(schema, aot, slot, sanitize, dir) {
220
+ const createMirror = require_type_validator_exact_mirror.getExactMirror();
221
+ if (!createMirror) return;
219
222
  const dirOpt = dir === "decode" ? { decode: true } : { encode: true };
220
223
  try {
221
- const emitted = (0, exact_mirror.default)(schema, {
224
+ const emitted = createMirror(schema, {
222
225
  Compile: typebox_schema.Compile,
223
226
  sanitize,
224
227
  ...dirOpt,
@@ -9,10 +9,10 @@ import { collectExternals } from "./aot-reconstruct.mjs";
9
9
  import { captureMirrorCodecs, captureMirrorUnions, installReconstructImpl } from "./aot-emit.mjs";
10
10
  import { buildFrozenCheck } from "../type/validator/frozen-check.mjs";
11
11
  import { captureCustomErrors } from "../type/validator/custom-error.mjs";
12
+ import { getExactMirror } from "../type/validator/exact-mirror.mjs";
12
13
  import { captureStringCodecEntries } from "../type/validator/string-codec-aot.mjs";
13
14
  import { Default } from "typebox/value";
14
15
  import { Build, Compile } from "typebox/schema";
15
- import createMirror from "exact-mirror";
16
16
 
17
17
  //#region src/compile/aot-capture.ts
18
18
  function emptyContainers(node, depth) {
@@ -181,6 +181,8 @@ function maybeCapture(args) {
181
181
  });
182
182
  }
183
183
  function captureMirror(schema, aot, slot, sanitize) {
184
+ const createMirror = getExactMirror();
185
+ if (!createMirror) return;
184
186
  try {
185
187
  const emitted = createMirror(schema, {
186
188
  Compile,
@@ -213,6 +215,8 @@ function captureMirror(schema, aot, slot, sanitize) {
213
215
  } catch {}
214
216
  }
215
217
  function captureCodecMirror(schema, aot, slot, sanitize, dir) {
218
+ const createMirror = getExactMirror();
219
+ if (!createMirror) return;
216
220
  const dirOpt = dir === "decode" ? { decode: true } : { encode: true };
217
221
  try {
218
222
  const emitted = createMirror(schema, {
@@ -1,5 +1,5 @@
1
1
  //#region src/compile/lexer.d.ts
2
- declare const isSpace: (ch: string) => ch is " " | "\n" | "\t" | "\r";
2
+ declare const isSpace: (ch: string) => ch is "\n" | " " | "\t" | "\r";
3
3
  declare const isIdentChar: (ch: string) => boolean;
4
4
  declare const isIdentCharCode: (code: number) => boolean;
5
5
  declare function skipString(src: string, start: number): number;
@@ -7,6 +7,7 @@ const require_cookie_crypto = require('./crypto.js');
7
7
  const require_cookie_cookie = require('./cookie.js');
8
8
  const require_cookie_config = require('./config.js');
9
9
  let deuri = require("deuri");
10
+ deuri = require_runtime.__toESM(deuri);
10
11
 
11
12
  //#region src/cookie/utils.ts
12
13
  async function parseCookie(set, cookieString, options) {
@@ -21,7 +22,7 @@ function parseCookieRawSync(cookieString, _config) {
21
22
  if (require_constants.dangerousKeys.has(name)) continue;
22
23
  const v = cookies[name];
23
24
  if (v === void 0) continue;
24
- out[name] = require_cookie_crypto.maybeJsonDecode((0, deuri.decodeComponent)(v) ?? v);
25
+ out[name] = require_cookie_crypto.maybeJsonDecode((0, deuri.default)(v) ?? v);
25
26
  }
26
27
  return out;
27
28
  }
@@ -51,7 +52,7 @@ function parseCookieRawLazy(cookieString, config) {
51
52
  if (require_constants.dangerousKeys.has(name)) continue;
52
53
  const v = cookies[name];
53
54
  if (v === void 0) continue;
54
- const decoded = (0, deuri.decodeComponent)(v) ?? v;
55
+ const decoded = (0, deuri.default)(v) ?? v;
55
56
  out[name] = require_cookie_config.resolveSignSecrets(name, config) !== void 0 ? decoded : require_cookie_crypto.maybeJsonDecode(decoded);
56
57
  }
57
58
  return out;
@@ -66,7 +67,7 @@ async function parseCookieRaw(cookieString, config) {
66
67
  if (require_constants.dangerousKeys.has(name)) continue;
67
68
  const v = cookies[name];
68
69
  if (v === void 0) continue;
69
- let value = (0, deuri.decodeComponent)(v) ?? v;
70
+ let value = (0, deuri.default)(v) ?? v;
70
71
  const signCheck = require_cookie_config.resolveSignSecrets(name, config);
71
72
  if (signCheck !== void 0) value = await require_cookie_crypto.unsignWithSecrets(name, value, signCheck);
72
73
  out[name] = require_cookie_crypto.maybeJsonDecode(value);
@@ -82,7 +83,7 @@ function parseCookieRawSigned(cookieString, config) {
82
83
  if (require_constants.dangerousKeys.has(name)) continue;
83
84
  const v = cookies[name];
84
85
  if (v === void 0) continue;
85
- let value = (0, deuri.decodeComponent)(v) ?? v;
86
+ let value = (0, deuri.default)(v) ?? v;
86
87
  const signCheck = require_cookie_config.resolveSignSecrets(name, config);
87
88
  if (signCheck !== void 0) value = require_cookie_crypto.unsignWithSecretsSync(name, value, signCheck);
88
89
  out[name] = require_cookie_crypto.maybeJsonDecode(value);
@@ -96,7 +97,7 @@ function buildCookieJar(set, raw, config, lazySign, deferDecode) {
96
97
  if (materialized[name]) return store[name];
97
98
  const rawValue = store[name];
98
99
  const fieldDefaults = config.fields[name]?.defaults;
99
- const entry = Object.assign(require_utils.nullObject(), config.defaults, fieldDefaults, { value: deferDecode ? require_cookie_crypto.maybeJsonDecode((0, deuri.decodeComponent)(rawValue) ?? rawValue) : rawValue });
100
+ const entry = Object.assign(require_utils.nullObject(), config.defaults, fieldDefaults, { value: deferDecode ? require_cookie_crypto.maybeJsonDecode((0, deuri.default)(rawValue) ?? rawValue) : rawValue });
100
101
  if (entry.expires instanceof Date) entry.expires = new Date(entry.expires.getTime());
101
102
  if (lazySign && typeof entry.value === "string") {
102
103
  const secrets = require_cookie_config.resolveSignSecrets(name, config);
@@ -4,7 +4,7 @@ import { parse } from "./lib.mjs";
4
4
  import { hasSyncHmac, maybeJsonDecode, rawJsonValue, resolvePendingCookie, signCookie, signCookieSyncImpl, unsignWithSecrets, unsignWithSecretsSync } from "./crypto.mjs";
5
5
  import { Cookie } from "./cookie.mjs";
6
6
  import { compileCookieConfig, isCookieSigned, resolveSignSecrets } from "./config.mjs";
7
- import { decodeComponent } from "deuri";
7
+ import decodeComponent from "deuri";
8
8
 
9
9
  //#region src/cookie/utils.ts
10
10
  async function parseCookie(set, cookieString, options) {
@@ -10,6 +10,7 @@ const require_adapter_constants = require('../adapter/constants.js');
10
10
  const require_context = require('../context.js');
11
11
  const require_handler_error = require('./error.js');
12
12
  let deuri = require("deuri");
13
+ deuri = require_runtime.__toESM(deuri);
13
14
 
14
15
  //#region src/handler/fetch.ts
15
16
  function extractPath(url, context, pathStart) {
@@ -31,7 +32,7 @@ function notFound(context) {
31
32
  function decodeParams(params) {
32
33
  for (const key in params) {
33
34
  const value = params[key];
34
- if (value.indexOf("%") !== -1) params[key] = (0, deuri.decodeComponent)(value) ?? value;
35
+ if (value.indexOf("%") !== -1) params[key] = (0, deuri.default)(value) ?? value;
35
36
  }
36
37
  return params;
37
38
  }
@@ -7,7 +7,7 @@ import { origin } from "../adapter/origin.mjs";
7
7
  import { defaultAdapter } from "../adapter/constants.mjs";
8
8
  import { createContext } from "../context.mjs";
9
9
  import { createErrorHandler } from "./error.mjs";
10
- import { decodeComponent } from "deuri";
10
+ import decodeComponent from "deuri";
11
11
 
12
12
  //#region src/handler/fetch.ts
13
13
  function extractPath(url, context, pathStart) {
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.0.0-exp.53";
3
+ var version = "2.0.0-exp.55";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2.0.0-exp.53";
2
+ var version = "2.0.0-exp.55";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.js');
3
3
  let deuri = require("deuri");
4
+ deuri = require_runtime.__toESM(deuri);
4
5
 
5
6
  //#region src/parse-query.ts
6
7
  const KEY_HAS_PLUS = 1;
@@ -9,7 +10,7 @@ const VALUE_HAS_PLUS = 4;
9
10
  const VALUE_NEEDS_DECODE = 8;
10
11
  function splitRawParts(raw, flags) {
11
12
  const parts = raw.split(",");
12
- if (flags & VALUE_NEEDS_DECODE) for (let i = 0; i < parts.length; i++) parts[i] = (0, deuri.decodeComponent)(parts[i]) ?? parts[i];
13
+ if (flags & VALUE_NEEDS_DECODE) for (let i = 0; i < parts.length; i++) parts[i] = (0, deuri.default)(parts[i]) ?? parts[i];
13
14
  return parts;
14
15
  }
15
16
  function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, object) {
@@ -48,12 +49,12 @@ function parseQueryFromURL(input, startIndex = input.indexOf("?", 11), array, ob
48
49
  if (!hasBothKeyValuePair && keySlice.length === 0) return;
49
50
  let finalKey = keySlice;
50
51
  if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
51
- if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.decodeComponent)(finalKey) || finalKey;
52
+ if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
52
53
  let finalValue = "";
53
54
  if (hasBothKeyValuePair) {
54
55
  let valueSlice = input.slice(equalityIndex + 1, endIndex);
55
56
  if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
56
- if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.decodeComponent)(valueSlice) || valueSlice;
57
+ if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
57
58
  finalValue = valueSlice;
58
59
  }
59
60
  const currentValue = result[finalKey];
@@ -137,12 +138,12 @@ function parseQuery(input) {
137
138
  if (!hasBothKeyValuePair && keySlice.length === 0) return;
138
139
  let finalKey = keySlice;
139
140
  if (flags & KEY_HAS_PLUS) finalKey = finalKey.replace(/\+/g, " ");
140
- if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.decodeComponent)(finalKey) || finalKey;
141
+ if (flags & KEY_NEEDS_DECODE) finalKey = (0, deuri.default)(finalKey) || finalKey;
141
142
  let finalValue = "";
142
143
  if (hasBothKeyValuePair) {
143
144
  let valueSlice = input.slice(equalityIndex + 1, endIndex);
144
145
  if (flags & VALUE_HAS_PLUS) valueSlice = valueSlice.replace(/\+/g, " ");
145
- if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.decodeComponent)(valueSlice) || valueSlice;
146
+ if (flags & VALUE_NEEDS_DECODE) valueSlice = (0, deuri.default)(valueSlice) || valueSlice;
146
147
  finalValue = valueSlice;
147
148
  }
148
149
  const currentValue = result[finalKey];
@@ -1,4 +1,4 @@
1
- import { decodeComponent } from "deuri";
1
+ import decodeComponent from "deuri";
2
2
 
3
3
  //#region src/parse-query.ts
4
4
  const KEY_HAS_PLUS = 1;
@@ -1,4 +1,8 @@
1
+ import { CreateMirror } from "./validator/exact-mirror.js";
2
+
1
3
  //#region src/type/compat.d.ts
2
- declare function setupTypebox(): void;
4
+ declare function setupTypebox(options?: {
5
+ exactMirror?: CreateMirror;
6
+ }): void;
3
7
  //#endregion
4
8
  export { setupTypebox };
@@ -3,6 +3,7 @@ const require_runtime = require('../_virtual/_rolldown/runtime.js');
3
3
  const require_type_bridge = require('./bridge.js');
4
4
  const require_type_utils = require('./utils.js');
5
5
  const require_type_coerce = require('./coerce.js');
6
+ const require_type_validator_exact_mirror = require('./validator/exact-mirror.js');
6
7
  const require_type_validator_validator_cache = require('./validator/validator-cache.js');
7
8
  const require_type_validator_index = require('./validator/index.js');
8
9
  const require_type_elysia_intersect = require('./elysia/intersect.js');
@@ -13,7 +14,8 @@ let typebox_system = require("typebox/system");
13
14
 
14
15
  //#region src/type/compat.ts
15
16
  let setup = false;
16
- function setupTypebox() {
17
+ function setupTypebox(options) {
18
+ if (options?.exactMirror) require_type_validator_exact_mirror.setExactMirror(options.exactMirror);
17
19
  if (setup) return;
18
20
  setup = true;
19
21
  typebox_system.Settings.Set({ unionPrioritySort: false });
@@ -1,6 +1,7 @@
1
1
  import { useTypebox } from "./bridge.mjs";
2
2
  import { hasTypes } from "./utils.mjs";
3
3
  import { applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure } from "./coerce.mjs";
4
+ import { setExactMirror } from "./validator/exact-mirror.mjs";
4
5
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-cache.mjs";
5
6
  import { TypeBoxValidator } from "./validator/index.mjs";
6
7
  import { Intersect as Intersect$1 } from "./elysia/intersect.mjs";
@@ -11,7 +12,8 @@ import { Settings } from "typebox/system";
11
12
 
12
13
  //#region src/type/compat.ts
13
14
  let setup = false;
14
- function setupTypebox() {
15
+ function setupTypebox(options) {
16
+ if (options?.exactMirror) setExactMirror(options.exactMirror);
15
17
  if (setup) return;
16
18
  setup = true;
17
19
  Settings.Set({ unionPrioritySort: false });
@@ -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<6 | 1 | 2 | 3 | 10 | 11 | 13 | 14>;
21
21
  declare const noEnumerable: {
22
22
  readonly enumerable: false;
23
23
  };
@@ -0,0 +1,7 @@
1
+ //#region src/type/validator/exact-mirror.d.ts
2
+ type CreateMirror = (schema: any, options?: any) => any;
3
+ declare const getExactMirror: () => CreateMirror | undefined;
4
+ declare const setExactMirror: (mirror: CreateMirror | undefined) => CreateMirror | undefined;
5
+ declare const exactMirrorRequired: () => Error;
6
+ //#endregion
7
+ export { CreateMirror, exactMirrorRequired, getExactMirror, setExactMirror };
@@ -0,0 +1,19 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/type/validator/exact-mirror.ts
4
+ function loadExactMirror() {
5
+ try {
6
+ const module = ({}.require ?? globalThis.process?.getBuiltinModule?.("module")?.createRequire(require("url").pathToFileURL(__filename).href))?.("exact-mirror");
7
+ const mirror = module?.default ?? module;
8
+ return typeof mirror === "function" ? mirror : void 0;
9
+ } catch {}
10
+ }
11
+ let exactMirror = loadExactMirror();
12
+ const getExactMirror = () => exactMirror;
13
+ const setExactMirror = (mirror) => exactMirror = mirror;
14
+ const exactMirrorRequired = () => /* @__PURE__ */ new Error("exact-mirror is required when using normalize: 'exactMirror' or sanitize. Install it and, if the runtime cannot load CommonJS modules, register it with setupTypebox({ exactMirror }); otherwise use normalize: 'typebox'.");
15
+
16
+ //#endregion
17
+ exports.exactMirrorRequired = exactMirrorRequired;
18
+ exports.getExactMirror = getExactMirror;
19
+ exports.setExactMirror = setExactMirror;
@@ -0,0 +1,15 @@
1
+ //#region src/type/validator/exact-mirror.ts
2
+ function loadExactMirror() {
3
+ try {
4
+ const module = (import.meta.require ?? globalThis.process?.getBuiltinModule?.("module")?.createRequire(import.meta.url))?.("exact-mirror");
5
+ const mirror = module?.default ?? module;
6
+ return typeof mirror === "function" ? mirror : void 0;
7
+ } catch {}
8
+ }
9
+ let exactMirror = loadExactMirror();
10
+ const getExactMirror = () => exactMirror;
11
+ const setExactMirror = (mirror) => exactMirror = mirror;
12
+ const exactMirrorRequired = () => /* @__PURE__ */ new Error("exact-mirror is required when using normalize: 'exactMirror' or sanitize. Install it and, if the runtime cannot load CommonJS modules, register it with setupTypebox({ exactMirror }); otherwise use normalize: 'typebox'.");
13
+
14
+ //#endregion
15
+ export { exactMirrorRequired, getExactMirror, setExactMirror };
@@ -12,12 +12,11 @@ const require_validator_index = require('../../validator/index.js');
12
12
  const require_type_coerce = require('../coerce.js');
13
13
  const require_type_validator_default_precompute = require('./default-precompute.js');
14
14
  const require_type_validator_custom_error = require('./custom-error.js');
15
+ const require_type_validator_exact_mirror = require('./exact-mirror.js');
15
16
  const require_type_validator_validator_cache = require('./validator-cache.js');
16
17
  let typebox_type = require("typebox/type");
17
18
  let typebox_value = require("typebox/value");
18
19
  let typebox_schema = require("typebox/schema");
19
- let exact_mirror = require("exact-mirror");
20
- exact_mirror = require_runtime.__toESM(exact_mirror);
21
20
 
22
21
  //#region src/type/validator/index.ts
23
22
  const moduleCache = /* @__PURE__ */ new WeakMap();
@@ -322,6 +321,7 @@ var TypeBoxValidator = class extends require_validator_index.Validator {
322
321
  this.Clean = options?.normalize === false ? void 0 : require_type_validator_clean_safe.schemaHasDangerousProperties(this.schema) ? (value) => (0, typebox_value.Clean)(this.schema, value) : both.clean;
323
322
  } else {
324
323
  if (isFrozen) this.reconstructedCheck = frozen.c(frozen.e ? require_compile_aot.reconstruct().collectExternals(this.schema) : require_compile_aot.EMPTY_EXTERNALS);
324
+ if (!require_type_validator_exact_mirror.getExactMirror() && !frozen?.m && !require_type_validator_clean_safe.schemaHasDangerousProperties(this.schema) && options?.normalize !== false && options?.normalize !== "typebox" && (options?.normalize === true || options?.normalize === "exactMirror" || !!options?.sanitize)) throw require_type_validator_exact_mirror.exactMirrorRequired();
325
325
  try {
326
326
  this.Clean = options?.normalize === false ? void 0 : options?.normalize === "typebox" ? (value) => (0, typebox_value.Clean)(this.schema, value) : this.#setupMirror(schema, options, frozen);
327
327
  } catch (error) {
@@ -380,7 +380,9 @@ var TypeBoxValidator = class extends require_validator_index.Validator {
380
380
  };
381
381
  }
382
382
  if (aot && slot && require_compile_aot.Capture.isCapturing() && require_compile_aot.captureImpl) require_compile_aot.captureImpl.captureMirror(schema, aot, slot, options?.sanitize);
383
- return (0, exact_mirror.default)(schema, {
383
+ const createMirror = require_type_validator_exact_mirror.getExactMirror();
384
+ if (!createMirror) return (value) => (0, typebox_value.Clean)(this.schema, value);
385
+ return createMirror(schema, {
384
386
  Compile: typebox_schema.Compile,
385
387
  sanitize: options?.sanitize
386
388
  });
@@ -411,8 +413,10 @@ var TypeBoxValidator = class extends require_validator_index.Validator {
411
413
  const dirOpt = dir === "decode" ? { decode: true } : { encode: true };
412
414
  const captureSlot = dir === "decode" ? !slot?.startsWith("response") : !!slot?.startsWith("response");
413
415
  if (aot && slot && require_compile_aot.Capture.isCapturing() && captureSlot && require_compile_aot.captureImpl) require_compile_aot.captureImpl.captureCodecMirror(schema, aot, slot, options?.sanitize, dir);
416
+ const createMirror = require_type_validator_exact_mirror.getExactMirror();
417
+ if (!createMirror) return;
414
418
  try {
415
- return (0, exact_mirror.default)(schema, {
419
+ return createMirror(schema, {
416
420
  Compile: typebox_schema.Compile,
417
421
  sanitize: options?.sanitize,
418
422
  ...dirOpt
@@ -10,11 +10,11 @@ import { Validator as Validator$1 } from "../../validator/index.mjs";
10
10
  import { applyCoercions, buildCoercedFromPlan } from "../coerce.mjs";
11
11
  import { applyPrecomputed, createDefaultCloner, createMergerFromSource, createObjectDefaultMerger, verifyPreallocatableDefault } from "./default-precompute.mjs";
12
12
  import { buildFindCustomError } from "./custom-error.mjs";
13
+ import { exactMirrorRequired, getExactMirror } from "./exact-mirror.mjs";
13
14
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator-cache.mjs";
14
15
  import { Evaluate, Intersect, Module } from "typebox/type";
15
16
  import { Check, Clean, Decode as Decode$1, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
16
17
  import { Compile } from "typebox/schema";
17
- import createMirror from "exact-mirror";
18
18
 
19
19
  //#region src/type/validator/index.ts
20
20
  const moduleCache = /* @__PURE__ */ new WeakMap();
@@ -319,6 +319,7 @@ var TypeBoxValidator = class extends Validator$1 {
319
319
  this.Clean = options?.normalize === false ? void 0 : schemaHasDangerousProperties(this.schema) ? (value) => Clean(this.schema, value) : both.clean;
320
320
  } else {
321
321
  if (isFrozen) this.reconstructedCheck = frozen.c(frozen.e ? reconstruct().collectExternals(this.schema) : EMPTY_EXTERNALS);
322
+ if (!getExactMirror() && !frozen?.m && !schemaHasDangerousProperties(this.schema) && options?.normalize !== false && options?.normalize !== "typebox" && (options?.normalize === true || options?.normalize === "exactMirror" || !!options?.sanitize)) throw exactMirrorRequired();
322
323
  try {
323
324
  this.Clean = options?.normalize === false ? void 0 : options?.normalize === "typebox" ? (value) => Clean(this.schema, value) : this.#setupMirror(schema, options, frozen);
324
325
  } catch (error) {
@@ -377,6 +378,8 @@ var TypeBoxValidator = class extends Validator$1 {
377
378
  };
378
379
  }
379
380
  if (aot && slot && Capture.isCapturing() && captureImpl) captureImpl.captureMirror(schema, aot, slot, options?.sanitize);
381
+ const createMirror = getExactMirror();
382
+ if (!createMirror) return (value) => Clean(this.schema, value);
380
383
  return createMirror(schema, {
381
384
  Compile,
382
385
  sanitize: options?.sanitize
@@ -408,6 +411,8 @@ var TypeBoxValidator = class extends Validator$1 {
408
411
  const dirOpt = dir === "decode" ? { decode: true } : { encode: true };
409
412
  const captureSlot = dir === "decode" ? !slot?.startsWith("response") : !!slot?.startsWith("response");
410
413
  if (aot && slot && Capture.isCapturing() && captureSlot && captureImpl) captureImpl.captureCodecMirror(schema, aot, slot, options?.sanitize, dir);
414
+ const createMirror = getExactMirror();
415
+ if (!createMirror) return;
411
416
  try {
412
417
  return createMirror(schema, {
413
418
  Compile,
@@ -5,13 +5,14 @@ const require_type_utils = require('../utils.js');
5
5
  const require_compile_aot_reconstruct = require('../../compile/aot-reconstruct.js');
6
6
  const require_compile_aot_emit = require('../../compile/aot-emit.js');
7
7
  const require_type_validator_frozen_check = require('./frozen-check.js');
8
+ const require_type_validator_exact_mirror = require('./exact-mirror.js');
8
9
  let typebox_schema = require("typebox/schema");
9
- let exact_mirror = require("exact-mirror");
10
- exact_mirror = require_runtime.__toESM(exact_mirror);
11
10
 
12
11
  //#region src/type/validator/string-codec-aot.ts
13
12
  function captureInnerCodec(inner, open, sanitize) {
14
13
  if (require_type_validator_clean_safe.schemaHasDangerousProperties(inner)) return;
14
+ const createMirror = require_type_validator_exact_mirror.getExactMirror();
15
+ if (!createMirror) return;
15
16
  let cf;
16
17
  try {
17
18
  cf = require_type_validator_frozen_check.buildFrozenCheck((0, typebox_schema.Build)(inner), inner);
@@ -21,7 +22,7 @@ function captureInnerCodec(inner, open, sanitize) {
21
22
  }
22
23
  let decode;
23
24
  try {
24
- const emitted = (0, exact_mirror.default)(inner, {
25
+ const emitted = createMirror(inner, {
25
26
  Compile: typebox_schema.Compile,
26
27
  sanitize,
27
28
  decode: true,
@@ -3,12 +3,14 @@ import { hasProperty } from "../utils.mjs";
3
3
  import { collectStringCodecNodes } from "../../compile/aot-reconstruct.mjs";
4
4
  import { captureMirrorCodecs, captureMirrorUnions } from "../../compile/aot-emit.mjs";
5
5
  import { buildFrozenCheck } from "./frozen-check.mjs";
6
+ import { getExactMirror } from "./exact-mirror.mjs";
6
7
  import { Build, Compile } from "typebox/schema";
7
- import createMirror from "exact-mirror";
8
8
 
9
9
  //#region src/type/validator/string-codec-aot.ts
10
10
  function captureInnerCodec(inner, open, sanitize) {
11
11
  if (schemaHasDangerousProperties(inner)) return;
12
+ const createMirror = getExactMirror();
13
+ if (!createMirror) return;
12
14
  let cf;
13
15
  try {
14
16
  cf = buildFrozenCheck(Build(inner), inner);
package/dist/types.d.ts CHANGED
@@ -9,7 +9,6 @@ import { Context, ErrorContext, LifecycleContext, PreContext } from "./context.j
9
9
  import { AnySchema, StandardSchemaV1Like, TypeBoxSchema } from "./type/types.js";
10
10
  import { AnyElysia, Elysia } from "./base.js";
11
11
  import { ElysiaAdapter } from "./adapter/index.js";
12
- import { Instruction } from "exact-mirror";
13
12
  import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
14
13
  import { OpenAPIV3 } from "openapi-types";
15
14
 
@@ -158,7 +157,7 @@ interface ElysiaConfig<in out Prefix extends string | undefined, in out Scope ex
158
157
  * @default true
159
158
  * @since 1.3.0
160
159
  */
161
- sanitize?: Instruction['sanitize'];
160
+ sanitize?: ((value: string) => string) | ((value: string) => string)[];
162
161
  /**
163
162
  * Allow unsafe validation details in errors thrown by Elysia's schema validator (422 status code)
164
163
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elysia",
3
3
  "description": "Ergonomic Framework for Human",
4
- "version": "2.0.0-exp.53",
4
+ "version": "2.0.0-exp.55",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",
@@ -241,8 +241,7 @@
241
241
  "./dist/type/bridge-live.js"
242
242
  ],
243
243
  "dependencies": {
244
- "deuri": "^2.0.1",
245
- "exact-mirror": "1.2.2",
244
+ "deuri": "^3.0.0",
246
245
  "memoirist": "1.2.1"
247
246
  },
248
247
  "devDependencies": {
@@ -256,6 +255,7 @@
256
255
  "esbuild": "0.25.4",
257
256
  "eslint": "^9.24.0",
258
257
  "eslint-plugin-sonarjs": "^4.0.2",
258
+ "exact-mirror": "1.2.2",
259
259
  "expect-type": "^1.2.1",
260
260
  "file-type": "^22.0.0",
261
261
  "globals": "^17.4.0",
@@ -271,6 +271,7 @@
271
271
  },
272
272
  "peerDependencies": {
273
273
  "@types/bun": ">= 1.3.0",
274
+ "exact-mirror": ">= 1.2.2",
274
275
  "openapi-types": ">= 12.0.0",
275
276
  "typebox": ">= 1.3.0",
276
277
  "typescript": ">= 5.7.0"
@@ -279,9 +280,15 @@
279
280
  "@types/bun": {
280
281
  "optional": true
281
282
  },
283
+ "exact-mirror": {
284
+ "optional": true
285
+ },
282
286
  "openapi-types": {
283
287
  "optional": true
284
288
  },
289
+ "typebox": {
290
+ "optional": true
291
+ },
285
292
  "typescript": {
286
293
  "optional": true
287
294
  }