elysia 2.0.0-beta.23 → 2.0.0-beta.24

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
@@ -669,7 +669,7 @@ var Elysia = class Elysia {
669
669
  return this;
670
670
  }
671
671
  has(plugin) {
672
- return this.childrenHash?.has(plugin.hash ?? require_utils.pluginId(plugin)) ?? false;
672
+ return this.childrenHash?.has(plugin.hash) ?? false;
673
673
  }
674
674
  #useFn(app) {
675
675
  const prevBaseline = this.macroBaseline;
@@ -712,13 +712,12 @@ var Elysia = class Elysia {
712
712
  const config = app["~config"];
713
713
  if (app["~introspect"] || config?.introspect) this["~introspect"] = true;
714
714
  const name = config?.name;
715
- const childKey = name ? app.hash : require_utils.pluginId(app);
716
- const exists = this.childrenHash?.has(childKey);
717
- if (name && exists) return;
718
- if (!exists) {
715
+ if (name) {
716
+ const hash = app.hash;
717
+ if (this.childrenHash?.has(hash)) return;
719
718
  this.childrenHash ??= /* @__PURE__ */ new Set();
720
- this.childrenHash.add(childKey);
721
- (addedByThisCall ??= /* @__PURE__ */ new Set()).add(childKey);
719
+ this.childrenHash.add(hash);
720
+ (addedByThisCall ??= /* @__PURE__ */ new Set()).add(hash);
722
721
  }
723
722
  if (app.childrenHash && !app["~scopeChild"]) addedByThisCall = this.#absorbChildrenHash(app, addedByThisCall);
724
723
  if (app["~ext"]) this.#assertMacroUnique(app, addedByThisCall);
@@ -737,9 +736,8 @@ var Elysia = class Elysia {
737
736
  if (hookChain) this.#propagateHooks(app, hookChain, addedByThisCall);
738
737
  }
739
738
  #absorbChildrenHash(app, addedByThisCall) {
740
- const childrenHash = this.childrenHash;
741
- for (let h of app.childrenHash) {
742
- if (typeof h === "object") h = require_utils.pluginId(h);
739
+ const childrenHash = this.childrenHash ??= /* @__PURE__ */ new Set();
740
+ for (const h of app.childrenHash) {
743
741
  if (childrenHash.has(h)) continue;
744
742
  childrenHash.add(h);
745
743
  (addedByThisCall ??= /* @__PURE__ */ new Set()).add(h);
@@ -820,7 +818,7 @@ var Elysia = class Elysia {
820
818
  const fn = hoc[i];
821
819
  const registration = source.hocOrigin?.[i] ?? app.hash;
822
820
  const origin = typeof registration === "object" ? registration.origin ??= app.hash : registration;
823
- if (origin !== void 0 && childrenHash.has(origin) && !addedByThisCall?.has(origin)) continue;
821
+ if (origin !== void 0 && childrenHash?.has(origin) && !addedByThisCall?.has(origin)) continue;
824
822
  if (target.some((f, j) => f === fn && hocOriginOf(origins[j]) === origin)) continue;
825
823
  origins.push(registration);
826
824
  target.push(fn);
package/dist/base.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  import { isBun } from "./universal/constants.mjs";
3
- import { clearFlattenChainMemo, clonePlainDecorators, clonePlainDeep, coalesceSchemas, createErrorEventHandler, eventProperties, getLoosePath, guardNonPlainLeaves, hookToGuard, invalidateMacroEpoch, isEmpty, isHTMLBundle, isNotEmpty, isPlainObject, isRecordNumber, joinPath, macroOrigin, mapDeriveEntry, markPropertySingletons, markSingletons, mergeDeep, mergeResponse, nullObject, pluginHash, pluginId, schemaProperties, serializeMacroSeed, throwLifecycleErrors } from "./utils.mjs";
3
+ import { clearFlattenChainMemo, clonePlainDecorators, clonePlainDeep, coalesceSchemas, createErrorEventHandler, eventProperties, getLoosePath, guardNonPlainLeaves, hookToGuard, invalidateMacroEpoch, isEmpty, isHTMLBundle, isNotEmpty, isPlainObject, isRecordNumber, joinPath, macroOrigin, mapDeriveEntry, markPropertySingletons, markSingletons, mergeDeep, mergeResponse, nullObject, pluginHash, schemaProperties, serializeMacroSeed, throwLifecycleErrors } from "./utils.mjs";
4
4
  import { Ref, warmTypebox } from "./type/bridge.mjs";
5
5
  import { isProduction } from "./universal/is-production.mjs";
6
6
  import { Capture, Compiled, beginCompilerSession, createAotFingerprint, endCompilerSession } from "./compile/aot.mjs";
@@ -667,7 +667,7 @@ var Elysia = class Elysia {
667
667
  return this;
668
668
  }
669
669
  has(plugin) {
670
- return this.childrenHash?.has(plugin.hash ?? pluginId(plugin)) ?? false;
670
+ return this.childrenHash?.has(plugin.hash) ?? false;
671
671
  }
672
672
  #useFn(app) {
673
673
  const prevBaseline = this.macroBaseline;
@@ -710,13 +710,12 @@ var Elysia = class Elysia {
710
710
  const config = app["~config"];
711
711
  if (app["~introspect"] || config?.introspect) this["~introspect"] = true;
712
712
  const name = config?.name;
713
- const childKey = name ? app.hash : pluginId(app);
714
- const exists = this.childrenHash?.has(childKey);
715
- if (name && exists) return;
716
- if (!exists) {
713
+ if (name) {
714
+ const hash = app.hash;
715
+ if (this.childrenHash?.has(hash)) return;
717
716
  this.childrenHash ??= /* @__PURE__ */ new Set();
718
- this.childrenHash.add(childKey);
719
- (addedByThisCall ??= /* @__PURE__ */ new Set()).add(childKey);
717
+ this.childrenHash.add(hash);
718
+ (addedByThisCall ??= /* @__PURE__ */ new Set()).add(hash);
720
719
  }
721
720
  if (app.childrenHash && !app["~scopeChild"]) addedByThisCall = this.#absorbChildrenHash(app, addedByThisCall);
722
721
  if (app["~ext"]) this.#assertMacroUnique(app, addedByThisCall);
@@ -735,9 +734,8 @@ var Elysia = class Elysia {
735
734
  if (hookChain) this.#propagateHooks(app, hookChain, addedByThisCall);
736
735
  }
737
736
  #absorbChildrenHash(app, addedByThisCall) {
738
- const childrenHash = this.childrenHash;
739
- for (let h of app.childrenHash) {
740
- if (typeof h === "object") h = pluginId(h);
737
+ const childrenHash = this.childrenHash ??= /* @__PURE__ */ new Set();
738
+ for (const h of app.childrenHash) {
741
739
  if (childrenHash.has(h)) continue;
742
740
  childrenHash.add(h);
743
741
  (addedByThisCall ??= /* @__PURE__ */ new Set()).add(h);
@@ -818,7 +816,7 @@ var Elysia = class Elysia {
818
816
  const fn = hoc[i];
819
817
  const registration = source.hocOrigin?.[i] ?? app.hash;
820
818
  const origin = typeof registration === "object" ? registration.origin ??= app.hash : registration;
821
- if (origin !== void 0 && childrenHash.has(origin) && !addedByThisCall?.has(origin)) continue;
819
+ if (origin !== void 0 && childrenHash?.has(origin) && !addedByThisCall?.has(origin)) continue;
822
820
  if (target.some((f, j) => f === fn && hocOriginOf(origins[j]) === origin)) continue;
823
821
  origins.push(registration);
824
822
  target.push(fn);
@@ -13,8 +13,8 @@ const require_type_validator_frozen_check = require('../type/validator/frozen-ch
13
13
  const require_type_validator_custom_error = require('../type/validator/custom-error.js');
14
14
  const require_type_validator_exact_mirror = require('../type/validator/exact-mirror.js');
15
15
  const require_type_validator_string_codec_aot = require('../type/validator/string-codec-aot.js');
16
- let typebox_schema = require("typebox/schema");
17
16
  let typebox_value = require("typebox/value");
17
+ let typebox_schema = require("typebox/schema");
18
18
 
19
19
  //#region src/compile/aot-capture.ts
20
20
  function emptyContainers(node, depth) {
@@ -12,8 +12,8 @@ import { buildFrozenCheck } from "../type/validator/frozen-check.mjs";
12
12
  import { captureCustomErrors } from "../type/validator/custom-error.mjs";
13
13
  import { getExactMirror } from "../type/validator/exact-mirror.mjs";
14
14
  import { captureStringCodecEntries, compileWithBuild } from "../type/validator/string-codec-aot.mjs";
15
- import { Build, Compile } from "typebox/schema";
16
15
  import { Default } from "typebox/value";
16
+ import { Build, Compile } from "typebox/schema";
17
17
 
18
18
  //#region src/compile/aot-capture.ts
19
19
  function emptyContainers(node, depth) {
@@ -274,42 +274,47 @@ function routeShape(hook, handler, root) {
274
274
  const visiting = /* @__PURE__ */ new Set();
275
275
  let unsupported = false;
276
276
  for (const _ in []) return;
277
+ let hash;
278
+ const feed = (s) => {
279
+ hash = require_utils.fnv1a(s, hash);
280
+ };
281
+ const quote = (s) => feed(JSON.stringify(s));
277
282
  const shape = (v, at = "") => {
278
283
  switch (typeof v) {
279
- case "string": return JSON.stringify(v);
280
- case "number": return "n" + (Object.is(v, -0) ? "-0" : v);
281
- case "bigint": return "b" + v;
282
- case "boolean": return v ? "T" : "F";
283
- case "undefined": return "U";
284
+ case "string": return quote(v);
285
+ case "number": return feed("n" + (Object.is(v, -0) ? "-0" : v));
286
+ case "bigint": return feed("b" + v);
287
+ case "boolean": return feed(v ? "T" : "F");
288
+ case "undefined": return feed("U");
284
289
  case "function":
285
- if (ids.has(v)) return "#" + ids.get(v);
290
+ if (ids.has(v)) return feed("#" + ids.get(v));
286
291
  ids.set(v, ids.size);
287
- return require_compile_utils.isAsyncFunction(v) ? "fa" : "fs";
292
+ return feed(require_compile_utils.isAsyncFunction(v) ? "fa" : "fs");
288
293
  case "symbol":
289
294
  unsupported = true;
290
- return "";
295
+ return;
291
296
  }
292
- if (v === null) return "N";
293
- if ("~standard" in v) return "S";
297
+ if (v === null) return feed("N");
298
+ if ("~standard" in v) return feed("S");
294
299
  if (visiting.has(v)) {
295
300
  unsupported = true;
296
- return "";
301
+ return;
297
302
  }
298
- let tag = "";
303
+ let kind;
299
304
  const list = Array.isArray(v);
300
305
  const proto = Object.getPrototypeOf(v);
301
306
  if (list ? proto !== Array.prototype : proto !== null && proto !== Object.prototype) {
302
- const kind = proto && Object.getOwnPropertyDescriptor(proto, "~kind");
307
+ kind = proto && Object.getOwnPropertyDescriptor(proto, "~kind");
303
308
  if (!kind || !("value" in kind) || Reflect.ownKeys(proto).length !== 1 || Object.getPrototypeOf(proto) !== Object.prototype) {
304
309
  unsupported = true;
305
- return "";
310
+ return;
306
311
  }
307
- tag = shape(kind.value);
308
312
  }
313
+ feed(list ? "[" : "{");
314
+ if (kind) shape(kind.value);
309
315
  visiting.add(v);
310
316
  const map = at === "response" && require_compile_handler_frozen_validator.isResponseMap(v);
311
317
  const deferred = v["~kind"] === "Deferred";
312
- let s = (list ? "[" : "{") + tag;
313
318
  for (const k of Reflect.ownKeys(v)) {
314
319
  const d = Object.getOwnPropertyDescriptor(v, k);
315
320
  if (typeof k === "symbol" || !("value" in d)) {
@@ -318,31 +323,41 @@ function routeShape(hook, handler, root) {
318
323
  }
319
324
  const value = d.value;
320
325
  if (k === "$ref" && typeof value === "string") addRef(value, at);
321
- s += "," + (d.enumerable ? "" : "!") + JSON.stringify(k) + ":";
322
- if (map) s += named(value);
323
- else if (k === "config" && isCookieAt(at)) s += shape([value?.sign, !!value?.secrets]);
324
- else if (k === "secrets" && (typeof value === "string" || Array.isArray(value))) s += shape(!!value);
325
- else s += shape(value, childAt(at, k, value, deferred));
326
+ feed(d.enumerable ? "," : ",!");
327
+ quote(k);
328
+ feed(":");
329
+ if (map) named(value);
330
+ else if (k === "config" && isCookieAt(at)) shape([value?.sign, !!value?.secrets]);
331
+ else if (k === "secrets" && (typeof value === "string" || Array.isArray(value))) shape(!!value);
332
+ else shape(value, childAt(at, k, value, deferred));
326
333
  }
327
334
  visiting.delete(v);
328
- return s + (list ? "]" : "}");
335
+ feed(list ? "]" : "}");
329
336
  };
330
337
  const named = (v, at) => {
331
338
  if (typeof v === "string") addRef(v, at);
332
- return shape(v, at);
339
+ shape(v, at);
333
340
  };
334
- let s = typeof handler === "function" || handler == null ? shape(handler) : handler instanceof Response ? "R" : handler instanceof Promise ? "P" : typeof handler === "object" ? "O" : "V";
341
+ if (typeof handler === "function" || handler == null) shape(handler);
342
+ else feed(handler instanceof Response ? "R" : handler instanceof Promise ? "P" : typeof handler === "object" ? "O" : "V");
335
343
  for (const event of shapeEvents) {
336
- s += "|";
344
+ feed("|");
337
345
  const fns = hook?.[event];
338
- if (fns) for (const fn of Array.isArray(fns) ? fns : [fns]) s += shape(fn);
346
+ if (fns) for (const fn of Array.isArray(fns) ? fns : [fns]) shape(fn);
339
347
  }
340
348
  const bf = hook?.beforeHandle;
341
- s += "|" + JSON.stringify(bf && require_compile_handler_utils.deriveModes(Array.isArray(bf) ? bf : [bf], hook["~deriveEntries"]));
342
- for (const from of [hook, ...hook?.schemas || []]) for (const slot of shapeSlots) s += "|" + named(from?.[slot], slot);
349
+ feed("|" + JSON.stringify(bf && require_compile_handler_utils.deriveModes(Array.isArray(bf) ? bf : [bf], hook["~deriveEntries"])));
350
+ for (const from of [hook, ...hook?.schemas || []]) for (const slot of shapeSlots) {
351
+ feed("|");
352
+ named(from?.[slot], slot);
353
+ }
343
354
  let targets;
344
- for (const [ref, at] of refs) for (const target of at ? (targets ??= require_utils.refTargets([], models))(ref) : [models?.[ref]]) s += "|" + JSON.stringify(ref) + shape(target, at);
345
- s += "|" + JSON.stringify([
355
+ for (const [ref, at] of refs) for (const target of at ? (targets ??= require_utils.refTargets([], models))(ref) : [models?.[ref]]) {
356
+ feed("|");
357
+ quote(ref);
358
+ shape(target, at);
359
+ }
360
+ feed("|" + JSON.stringify([
346
361
  config?.cookie?.sign,
347
362
  config?.cookie?.verify,
348
363
  config?.normalize,
@@ -351,8 +366,9 @@ function routeShape(hook, handler, root) {
351
366
  require_utils.isNotEmpty(frozenRoot["~ext"]?.headers),
352
367
  !!(config?.adapter ?? require_adapter_constants.defaultAdapter).response.supportsDefaultHeaderSink,
353
368
  !!require_handler_utils.returnedErrorClasses(hook)
354
- ]) + shape(config?.sanitize);
355
- return unsupported ? void 0 : require_utils.fnv1a(s);
369
+ ]));
370
+ shape(config?.sanitize);
371
+ return unsupported ? void 0 : hash;
356
372
  }
357
373
  const throwsOnCall = (error) => () => {
358
374
  throw error;
@@ -274,42 +274,47 @@ function routeShape(hook, handler, root) {
274
274
  const visiting = /* @__PURE__ */ new Set();
275
275
  let unsupported = false;
276
276
  for (const _ in []) return;
277
+ let hash;
278
+ const feed = (s) => {
279
+ hash = fnv1a(s, hash);
280
+ };
281
+ const quote = (s) => feed(JSON.stringify(s));
277
282
  const shape = (v, at = "") => {
278
283
  switch (typeof v) {
279
- case "string": return JSON.stringify(v);
280
- case "number": return "n" + (Object.is(v, -0) ? "-0" : v);
281
- case "bigint": return "b" + v;
282
- case "boolean": return v ? "T" : "F";
283
- case "undefined": return "U";
284
+ case "string": return quote(v);
285
+ case "number": return feed("n" + (Object.is(v, -0) ? "-0" : v));
286
+ case "bigint": return feed("b" + v);
287
+ case "boolean": return feed(v ? "T" : "F");
288
+ case "undefined": return feed("U");
284
289
  case "function":
285
- if (ids.has(v)) return "#" + ids.get(v);
290
+ if (ids.has(v)) return feed("#" + ids.get(v));
286
291
  ids.set(v, ids.size);
287
- return isAsyncFunction(v) ? "fa" : "fs";
292
+ return feed(isAsyncFunction(v) ? "fa" : "fs");
288
293
  case "symbol":
289
294
  unsupported = true;
290
- return "";
295
+ return;
291
296
  }
292
- if (v === null) return "N";
293
- if ("~standard" in v) return "S";
297
+ if (v === null) return feed("N");
298
+ if ("~standard" in v) return feed("S");
294
299
  if (visiting.has(v)) {
295
300
  unsupported = true;
296
- return "";
301
+ return;
297
302
  }
298
- let tag = "";
303
+ let kind;
299
304
  const list = Array.isArray(v);
300
305
  const proto = Object.getPrototypeOf(v);
301
306
  if (list ? proto !== Array.prototype : proto !== null && proto !== Object.prototype) {
302
- const kind = proto && Object.getOwnPropertyDescriptor(proto, "~kind");
307
+ kind = proto && Object.getOwnPropertyDescriptor(proto, "~kind");
303
308
  if (!kind || !("value" in kind) || Reflect.ownKeys(proto).length !== 1 || Object.getPrototypeOf(proto) !== Object.prototype) {
304
309
  unsupported = true;
305
- return "";
310
+ return;
306
311
  }
307
- tag = shape(kind.value);
308
312
  }
313
+ feed(list ? "[" : "{");
314
+ if (kind) shape(kind.value);
309
315
  visiting.add(v);
310
316
  const map = at === "response" && isResponseMap(v);
311
317
  const deferred = v["~kind"] === "Deferred";
312
- let s = (list ? "[" : "{") + tag;
313
318
  for (const k of Reflect.ownKeys(v)) {
314
319
  const d = Object.getOwnPropertyDescriptor(v, k);
315
320
  if (typeof k === "symbol" || !("value" in d)) {
@@ -318,31 +323,41 @@ function routeShape(hook, handler, root) {
318
323
  }
319
324
  const value = d.value;
320
325
  if (k === "$ref" && typeof value === "string") addRef(value, at);
321
- s += "," + (d.enumerable ? "" : "!") + JSON.stringify(k) + ":";
322
- if (map) s += named(value);
323
- else if (k === "config" && isCookieAt(at)) s += shape([value?.sign, !!value?.secrets]);
324
- else if (k === "secrets" && (typeof value === "string" || Array.isArray(value))) s += shape(!!value);
325
- else s += shape(value, childAt(at, k, value, deferred));
326
+ feed(d.enumerable ? "," : ",!");
327
+ quote(k);
328
+ feed(":");
329
+ if (map) named(value);
330
+ else if (k === "config" && isCookieAt(at)) shape([value?.sign, !!value?.secrets]);
331
+ else if (k === "secrets" && (typeof value === "string" || Array.isArray(value))) shape(!!value);
332
+ else shape(value, childAt(at, k, value, deferred));
326
333
  }
327
334
  visiting.delete(v);
328
- return s + (list ? "]" : "}");
335
+ feed(list ? "]" : "}");
329
336
  };
330
337
  const named = (v, at) => {
331
338
  if (typeof v === "string") addRef(v, at);
332
- return shape(v, at);
339
+ shape(v, at);
333
340
  };
334
- let s = typeof handler === "function" || handler == null ? shape(handler) : handler instanceof Response ? "R" : handler instanceof Promise ? "P" : typeof handler === "object" ? "O" : "V";
341
+ if (typeof handler === "function" || handler == null) shape(handler);
342
+ else feed(handler instanceof Response ? "R" : handler instanceof Promise ? "P" : typeof handler === "object" ? "O" : "V");
335
343
  for (const event of shapeEvents) {
336
- s += "|";
344
+ feed("|");
337
345
  const fns = hook?.[event];
338
- if (fns) for (const fn of Array.isArray(fns) ? fns : [fns]) s += shape(fn);
346
+ if (fns) for (const fn of Array.isArray(fns) ? fns : [fns]) shape(fn);
339
347
  }
340
348
  const bf = hook?.beforeHandle;
341
- s += "|" + JSON.stringify(bf && deriveModes(Array.isArray(bf) ? bf : [bf], hook["~deriveEntries"]));
342
- for (const from of [hook, ...hook?.schemas || []]) for (const slot of shapeSlots) s += "|" + named(from?.[slot], slot);
349
+ feed("|" + JSON.stringify(bf && deriveModes(Array.isArray(bf) ? bf : [bf], hook["~deriveEntries"])));
350
+ for (const from of [hook, ...hook?.schemas || []]) for (const slot of shapeSlots) {
351
+ feed("|");
352
+ named(from?.[slot], slot);
353
+ }
343
354
  let targets;
344
- for (const [ref, at] of refs) for (const target of at ? (targets ??= refTargets([], models))(ref) : [models?.[ref]]) s += "|" + JSON.stringify(ref) + shape(target, at);
345
- s += "|" + JSON.stringify([
355
+ for (const [ref, at] of refs) for (const target of at ? (targets ??= refTargets([], models))(ref) : [models?.[ref]]) {
356
+ feed("|");
357
+ quote(ref);
358
+ shape(target, at);
359
+ }
360
+ feed("|" + JSON.stringify([
346
361
  config?.cookie?.sign,
347
362
  config?.cookie?.verify,
348
363
  config?.normalize,
@@ -351,8 +366,9 @@ function routeShape(hook, handler, root) {
351
366
  isNotEmpty(frozenRoot["~ext"]?.headers),
352
367
  !!(config?.adapter ?? defaultAdapter).response.supportsDefaultHeaderSink,
353
368
  !!returnedErrorClasses(hook)
354
- ]) + shape(config?.sanitize);
355
- return unsupported ? void 0 : fnv1a(s);
369
+ ]));
370
+ shape(config?.sanitize);
371
+ return unsupported ? void 0 : hash;
356
372
  }
357
373
  const throwsOnCall = (error) => () => {
358
374
  throw error;
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.0.0-beta.23";
3
+ var version = "2.0.0-beta.24";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/package.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  //#region package.json
3
- var version = "2.0.0-beta.23";
3
+ var version = "2.0.0-beta.24";
4
4
 
5
5
  //#endregion
6
6
  export { version };
@@ -5,8 +5,8 @@ import { useTypebox as useTypebox$1 } from "./bridge.js";
5
5
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-cache.js";
6
6
  import { TypeBoxValidator } from "./validator/index.js";
7
7
  import { Ref } from "typebox/type";
8
- import { Check, Clone, Create, Decode, HasCodec } from "typebox/value";
9
8
  import { Compile } from "typebox/compile";
9
+ import { Check, Clone, Create, Decode, 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;
@@ -6,8 +6,8 @@ const require_type_validator_validator_cache = require('./validator/validator-ca
6
6
  const require_type_validator_index = require('./validator/index.js');
7
7
  const require_type_elysia_intersect = require('./elysia/intersect.js');
8
8
  let typebox_type = require("typebox/type");
9
- let typebox_value = require("typebox/value");
10
9
  let typebox_compile = require("typebox/compile");
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
@@ -5,8 +5,8 @@ import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-ca
5
5
  import { TypeBoxValidator } from "./validator/index.mjs";
6
6
  import { Intersect } from "./elysia/intersect.mjs";
7
7
  import { Ref } from "typebox/type";
8
- import { Check, Clone, Create, Decode, HasCodec } from "typebox/value";
9
8
  import { Compile } from "typebox/compile";
9
+ import { Check, Clone, Create, Decode, HasCodec } from "typebox/value";
10
10
  import { Settings } from "typebox/system";
11
11
 
12
12
  //#region src/type/bridge-live.ts
@@ -4,8 +4,8 @@ import { hasTypes as hasTypes$1 } from "./utils.js";
4
4
  import { TypeBoxValidatorCache as TypeBoxValidatorCache$1, mayHaveFileType as mayHaveFileType$1 } from "./validator/validator-cache.js";
5
5
  import { TypeBoxValidator as TypeBoxValidator$1 } from "./validator/index.js";
6
6
  import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
7
- import { Check as Check$1, Clone as Clone$1, Create as Create$1, Decode as Decode$2, HasCodec as HasCodec$1 } from "typebox/value";
8
7
  import { Compile as Compile$1 } from "typebox/compile";
8
+ import { Check as Check$1, Clone as Clone$1, Create as Create$1, Decode as Decode$2, HasCodec as HasCodec$1 } from "typebox/value";
9
9
 
10
10
  //#region src/type/bridge.d.ts
11
11
  interface TypeboxModule {
@@ -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<2 | 1 | 6 | 3 | 10 | 11 | 13 | 14>;
20
+ declare const primitiveElysiaTypes: Set<1 | 2 | 6 | 3 | 10 | 11 | 13 | 14>;
21
21
  declare const noEnumerable: {
22
22
  readonly enumerable: false;
23
23
  };
@@ -1,7 +1,7 @@
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;
@@ -1,9 +1,9 @@
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 });
@@ -1,8 +1,8 @@
1
1
  // @bun
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";
5
4
  import { Settings } from "typebox/system";
5
+ import { Build, Compile as SchemaCompile } from "typebox/schema";
6
6
 
7
7
  //#region src/type/typebox-value-live.ts
8
8
  Settings.Set({ unionPrioritySort: false });
@@ -1,4 +1,4 @@
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";
3
+ import { Build, Compile as SchemaCompile } from "typebox/schema";
4
4
  export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile };
@@ -1,8 +1,8 @@
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");
5
+ let typebox_schema = require("typebox/schema");
6
6
 
7
7
  Object.defineProperty(exports, 'Build', {
8
8
  enumerable: true,
@@ -1,6 +1,6 @@
1
1
  // @bun
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
  export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile };
@@ -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 {
@@ -27,9 +27,9 @@ declare let Encode: typeof Encode$1;
27
27
  declare let EncodeUnsafe: typeof EncodeUnsafe$1;
28
28
  declare let Errors: typeof Errors$1;
29
29
  declare let HasCodec: typeof HasCodec$1;
30
- declare let SchemaCompile: typeof Compile$1;
30
+ declare let SchemaCompile: typeof Compile$2;
31
31
  declare let Build: typeof Build$1;
32
- declare let Compile: typeof Compile$2;
32
+ declare let Compile: typeof Compile$1;
33
33
  declare function injectTypebox(typebox: TypeboxNamespaces): void;
34
34
  //#endregion
35
35
  export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, TypeboxNamespaces, injectTypebox, preloadTypebox, load as warmTypebox };
package/dist/utils.d.ts CHANGED
@@ -29,7 +29,7 @@ declare const isNotEmpty: <T extends Object>(obj?: T) => boolean | undefined;
29
29
  * amortizes to O(1) per insertion.
30
30
  */
31
31
  declare function evictOldestHalf(cache: Map<any, any>): void;
32
- declare function fnv1a(str: string): number;
32
+ declare function fnv1a(str: string, hash?: number): number;
33
33
  /**
34
34
  * 48-bit hash of a named plugin's key (fnv1a + 16 bits of a second hash): at
35
35
  * 32 bits two plugins collide by ~77k and the second is dropped. 48 keeps
@@ -39,11 +39,6 @@ declare function pluginHash(str: string): number;
39
39
  declare const compositionKeys: readonly string[];
40
40
  declare function refTargets(roots: unknown[], models?: Record<string, unknown>): (name: string) => Iterable<unknown>;
41
41
  declare const macroOrigin: WeakMap<object | Function, number>;
42
- /**
43
- * Id of an unnamed plugin in `childrenHash`, negative so it never collides
44
- * with a named plugin's unsigned hash
45
- */
46
- declare const pluginId: (plugin: object) => number;
47
42
  /**
48
43
  * Linked-list representation of the scope/global hook chain of a route
49
44
  *
@@ -229,4 +224,4 @@ declare const isSocketQuiet: (socket: {
229
224
  }) => boolean;
230
225
  declare const isHTMLBundle: (value: unknown) => value is BunHTMLBundlelike;
231
226
  //#endregion
232
- export { ChainInfo, ChainNode, CompactBeforeHandleChunk, CompactBeforeHandlePrefix, DeriveEntry, ELYSIA_FORM_PROTOTYPE, assignOwn, authorityEnd, bytes, clearFlattenChainMemo, cloneHook, clonePlainDecorators, clonePlainDeep, coalesceSchemas, compactBeforeHandleConflicts, compactBeforeHandlePrefix, compositionKeys, constantTimeEqual, createErrorEventHandler, deriveEntryFn, deriveQueues, eventProperties, evictOldestHalf, flattenChain, flattenChainInfo, flattenChainMemo, flattenChainMemoReadonly, fnv1a, form, formToFormData, getLoosePath, guardNonPlainLeaves, hookToGuard, invalidateMacroEpoch, isBlob, isByteStream, isCompactBeforeHandleOnly, isDisposable, isElysiaForm, isEmpty, isHTMLBundle, isMapDeriveEntry, isNotEmpty, isPlainDeriveEntry, isPlainObject, isRecordNumber, isSingleton, isSocketQuiet, joinPath, macroEpoch, macroOrigin, macroType, mapDeriveEntry, markPropertySingletons, markSingletons, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, occurrenceDeriveEntries, pluginHash, pluginId, prefix, redirect, refTargets, replaceUrlPath, requestId, schemaProperties, serializeMacroSeed, sse, sseData, throwLifecycleErrors };
227
+ export { ChainInfo, ChainNode, CompactBeforeHandleChunk, CompactBeforeHandlePrefix, DeriveEntry, ELYSIA_FORM_PROTOTYPE, assignOwn, authorityEnd, bytes, clearFlattenChainMemo, cloneHook, clonePlainDecorators, clonePlainDeep, coalesceSchemas, compactBeforeHandleConflicts, compactBeforeHandlePrefix, compositionKeys, constantTimeEqual, createErrorEventHandler, deriveEntryFn, deriveQueues, eventProperties, evictOldestHalf, flattenChain, flattenChainInfo, flattenChainMemo, flattenChainMemoReadonly, fnv1a, form, formToFormData, getLoosePath, guardNonPlainLeaves, hookToGuard, invalidateMacroEpoch, isBlob, isByteStream, isCompactBeforeHandleOnly, isDisposable, isElysiaForm, isEmpty, isHTMLBundle, isMapDeriveEntry, isNotEmpty, isPlainDeriveEntry, isPlainObject, isRecordNumber, isSingleton, isSocketQuiet, joinPath, macroEpoch, macroOrigin, macroType, mapDeriveEntry, markPropertySingletons, markSingletons, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, occurrenceDeriveEntries, pluginHash, prefix, redirect, refTargets, replaceUrlPath, requestId, schemaProperties, serializeMacroSeed, sse, sseData, throwLifecycleErrors };
package/dist/utils.js CHANGED
@@ -49,8 +49,7 @@ function evictOldestHalf(cache) {
49
49
  cache.clear();
50
50
  for (const entry of keep) cache.set(entry[0], entry[1]);
51
51
  }
52
- function fnv1a(str) {
53
- let hash = FNV_OFFSET_BASIS;
52
+ function fnv1a(str, hash = FNV_OFFSET_BASIS) {
54
53
  const len = str.length;
55
54
  for (let i = 0; i < len; i++) {
56
55
  hash ^= str.charCodeAt(i);
@@ -95,13 +94,13 @@ function refTargets(roots, models = {}) {
95
94
  }
96
95
  const macroOrigin = /* @__PURE__ */ new WeakMap();
97
96
  /**
98
- * Id of `ref` in the registry at `globalThis[key]`, `next` being the last id
99
- * handed out. Weak so it doesn't retain `ref`, realm-wide so every installed
100
- * Elysia copy agrees
97
+ * Id of `ref` in the registry at `globalThis['~elysiaSeedIds']`, `next` being
98
+ * the last id handed out. Weak so it doesn't retain `ref`, realm-wide so every
99
+ * installed Elysia copy agrees
101
100
  */
102
- function realmId(key, ref) {
101
+ function realmId(ref) {
103
102
  const realm = globalThis;
104
- const registry = realm[key] ??= {
103
+ const registry = realm["~elysiaSeedIds"] ??= {
105
104
  ids: /* @__PURE__ */ new WeakMap(),
106
105
  next: 0
107
106
  };
@@ -109,11 +108,6 @@ function realmId(key, ref) {
109
108
  if (id === void 0) registry.ids.set(ref, id = ++registry.next);
110
109
  return id;
111
110
  }
112
- /**
113
- * Id of an unnamed plugin in `childrenHash`, negative so it never collides
114
- * with a named plugin's unsigned hash
115
- */
116
- const pluginId = (plugin) => -realmId("~elysiaPluginIds", plugin);
117
111
  const COMPACT_CHUNK_SIZE = 32;
118
112
  const emptyCompactBeforeHandlePrefix = {
119
113
  length: 0,
@@ -757,11 +751,11 @@ prefix.capitalize = function prefixModelsCapitalize(prefix, models) {
757
751
  };
758
752
  function serializeMacroSeed(_key, value) {
759
753
  switch (typeof value) {
760
- case "function": return "\0ref:" + realmId("~elysiaSeedIds", value);
754
+ case "function": return "\0ref:" + realmId(value);
761
755
  case "bigint": return "\0bigint:" + value.toString();
762
756
  case "symbol": {
763
757
  const key = Symbol.keyFor(value);
764
- return key === void 0 ? "\0ref:" + realmId("~elysiaSeedIds", value) : "\0symfor:" + key;
758
+ return key === void 0 ? "\0ref:" + realmId(value) : "\0symfor:" + key;
765
759
  }
766
760
  case "undefined": return "\0undefined";
767
761
  default: return value;
@@ -888,7 +882,6 @@ exports.mergeResponse = mergeResponse;
888
882
  exports.nullObject = nullObject;
889
883
  exports.occurrenceDeriveEntries = occurrenceDeriveEntries;
890
884
  exports.pluginHash = pluginHash;
891
- exports.pluginId = pluginId;
892
885
  exports.prefix = prefix;
893
886
  exports.redirect = redirect;
894
887
  exports.refTargets = refTargets;
package/dist/utils.mjs CHANGED
@@ -49,8 +49,7 @@ function evictOldestHalf(cache) {
49
49
  cache.clear();
50
50
  for (const entry of keep) cache.set(entry[0], entry[1]);
51
51
  }
52
- function fnv1a(str) {
53
- let hash = FNV_OFFSET_BASIS;
52
+ function fnv1a(str, hash = FNV_OFFSET_BASIS) {
54
53
  const len = str.length;
55
54
  for (let i = 0; i < len; i++) {
56
55
  hash ^= str.charCodeAt(i);
@@ -95,13 +94,13 @@ function refTargets(roots, models = {}) {
95
94
  }
96
95
  const macroOrigin = /* @__PURE__ */ new WeakMap();
97
96
  /**
98
- * Id of `ref` in the registry at `globalThis[key]`, `next` being the last id
99
- * handed out. Weak so it doesn't retain `ref`, realm-wide so every installed
100
- * Elysia copy agrees
97
+ * Id of `ref` in the registry at `globalThis['~elysiaSeedIds']`, `next` being
98
+ * the last id handed out. Weak so it doesn't retain `ref`, realm-wide so every
99
+ * installed Elysia copy agrees
101
100
  */
102
- function realmId(key, ref) {
101
+ function realmId(ref) {
103
102
  const realm = globalThis;
104
- const registry = realm[key] ??= {
103
+ const registry = realm["~elysiaSeedIds"] ??= {
105
104
  ids: /* @__PURE__ */ new WeakMap(),
106
105
  next: 0
107
106
  };
@@ -109,11 +108,6 @@ function realmId(key, ref) {
109
108
  if (id === void 0) registry.ids.set(ref, id = ++registry.next);
110
109
  return id;
111
110
  }
112
- /**
113
- * Id of an unnamed plugin in `childrenHash`, negative so it never collides
114
- * with a named plugin's unsigned hash
115
- */
116
- const pluginId = (plugin) => -realmId("~elysiaPluginIds", plugin);
117
111
  const COMPACT_CHUNK_SIZE = 32;
118
112
  const emptyCompactBeforeHandlePrefix = {
119
113
  length: 0,
@@ -757,11 +751,11 @@ prefix.capitalize = function prefixModelsCapitalize(prefix, models) {
757
751
  };
758
752
  function serializeMacroSeed(_key, value) {
759
753
  switch (typeof value) {
760
- case "function": return "\0ref:" + realmId("~elysiaSeedIds", value);
754
+ case "function": return "\0ref:" + realmId(value);
761
755
  case "bigint": return "\0bigint:" + value.toString();
762
756
  case "symbol": {
763
757
  const key = Symbol.keyFor(value);
764
- return key === void 0 ? "\0ref:" + realmId("~elysiaSeedIds", value) : "\0symfor:" + key;
758
+ return key === void 0 ? "\0ref:" + realmId(value) : "\0symfor:" + key;
765
759
  }
766
760
  case "undefined": return "\0undefined";
767
761
  default: return value;
@@ -831,4 +825,4 @@ const isSocketQuiet = (socket) => socket.readyState === 3 && !socket.data.inflig
831
825
  const isHTMLBundle = (value) => Object.prototype.toString.call(value) === "[object HTMLBundle]" || typeof value?.index === "string" && Array.isArray(value.files);
832
826
 
833
827
  //#endregion
834
- export { ELYSIA_FORM_PROTOTYPE, assignOwn, authorityEnd, bytes, clearFlattenChainMemo, cloneHook, clonePlainDecorators, clonePlainDeep, coalesceSchemas, compactBeforeHandleConflicts, compactBeforeHandlePrefix, compositionKeys, constantTimeEqual, createErrorEventHandler, deriveEntryFn, deriveQueues, eventProperties, evictOldestHalf, flattenChain, flattenChainInfo, flattenChainMemo, flattenChainMemoReadonly, fnv1a, form, formToFormData, getLoosePath, guardNonPlainLeaves, hookToGuard, invalidateMacroEpoch, isBlob, isByteStream, isCompactBeforeHandleOnly, isDisposable, isElysiaForm, isEmpty, isHTMLBundle, isMapDeriveEntry, isNotEmpty, isPlainDeriveEntry, isPlainObject, isRecordNumber, isSingleton, isSocketQuiet, joinPath, macroEpoch, macroOrigin, macroType, mapDeriveEntry, markPropertySingletons, markSingletons, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, occurrenceDeriveEntries, pluginHash, pluginId, prefix, redirect, refTargets, replaceUrlPath, requestId, schemaProperties, serializeMacroSeed, sse, sseData, throwLifecycleErrors };
828
+ export { ELYSIA_FORM_PROTOTYPE, assignOwn, authorityEnd, bytes, clearFlattenChainMemo, cloneHook, clonePlainDecorators, clonePlainDeep, coalesceSchemas, compactBeforeHandleConflicts, compactBeforeHandlePrefix, compositionKeys, constantTimeEqual, createErrorEventHandler, deriveEntryFn, deriveQueues, eventProperties, evictOldestHalf, flattenChain, flattenChainInfo, flattenChainMemo, flattenChainMemoReadonly, fnv1a, form, formToFormData, getLoosePath, guardNonPlainLeaves, hookToGuard, invalidateMacroEpoch, isBlob, isByteStream, isCompactBeforeHandleOnly, isDisposable, isElysiaForm, isEmpty, isHTMLBundle, isMapDeriveEntry, isNotEmpty, isPlainDeriveEntry, isPlainObject, isRecordNumber, isSingleton, isSocketQuiet, joinPath, macroEpoch, macroOrigin, macroType, mapDeriveEntry, markPropertySingletons, markSingletons, mergeArray, mergeDeep, mergeHook, mergeResponse, nullObject, occurrenceDeriveEntries, pluginHash, prefix, redirect, refTargets, replaceUrlPath, requestId, schemaProperties, serializeMacroSeed, sse, sseData, throwLifecycleErrors };
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-beta.23",
4
+ "version": "2.0.0-beta.24",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",