elysia 2.0.0-exp.40 → 2.0.0-exp.41

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 (54) hide show
  1. package/dist/adapter/bun/index.js +3 -3
  2. package/dist/adapter/bun/index.mjs +4 -4
  3. package/dist/base.d.ts +1 -9
  4. package/dist/base.js +72 -207
  5. package/dist/base.mjs +75 -210
  6. package/dist/compile/aot.d.ts +42 -1
  7. package/dist/compile/aot.js +18 -0
  8. package/dist/compile/aot.mjs +17 -1
  9. package/dist/compile/build-router.d.ts +14 -0
  10. package/dist/compile/build-router.js +212 -0
  11. package/dist/compile/build-router.mjs +208 -0
  12. package/dist/compile/handler/index.d.ts +5 -1
  13. package/dist/compile/handler/index.js +6 -3
  14. package/dist/compile/handler/index.mjs +5 -4
  15. package/dist/compile/handler/jit.js +2 -1
  16. package/dist/compile/handler/jit.mjs +2 -1
  17. package/dist/compile/handler/params.js +2 -1
  18. package/dist/compile/handler/params.mjs +2 -1
  19. package/dist/compile/lexer.d.ts +1 -1
  20. package/dist/constants.d.ts +1 -25
  21. package/dist/constants.js +0 -14
  22. package/dist/constants.mjs +1 -13
  23. package/dist/error.d.ts +1 -1
  24. package/dist/error.js +6 -7
  25. package/dist/error.mjs +1 -2
  26. package/dist/handler/error.js +2 -1
  27. package/dist/handler/error.mjs +2 -1
  28. package/dist/handler/fetch.js +3 -2
  29. package/dist/handler/fetch.mjs +2 -1
  30. package/dist/plugin/core.d.ts +59 -3
  31. package/dist/plugin/core.js +107 -18
  32. package/dist/plugin/core.mjs +99 -20
  33. package/dist/plugin/source.d.ts +13 -2
  34. package/dist/plugin/source.js +173 -1
  35. package/dist/plugin/source.mjs +175 -5
  36. package/dist/plugin/vite.js +10 -1
  37. package/dist/plugin/vite.mjs +11 -2
  38. package/dist/sucrose.js +2 -2
  39. package/dist/sucrose.mjs +1 -1
  40. package/dist/type/coerce.d.ts +1 -1
  41. package/dist/type/constants.d.ts +1 -1
  42. package/dist/types.d.ts +2 -2
  43. package/dist/universal/index.d.ts +2 -1
  44. package/dist/universal/index.js +3 -1
  45. package/dist/universal/index.mjs +2 -1
  46. package/dist/universal/is-production.d.ts +4 -0
  47. package/dist/universal/is-production.js +8 -0
  48. package/dist/universal/is-production.mjs +7 -0
  49. package/dist/utils.d.ts +1 -3
  50. package/dist/utils.js +0 -2
  51. package/dist/utils.mjs +2 -3
  52. package/dist/ws/route.js +2 -1
  53. package/dist/ws/route.mjs +2 -1
  54. package/package.json +2 -1
@@ -21,7 +21,7 @@ function collectStaticRoutes(app) {
21
21
  const seen = /* @__PURE__ */ new Map();
22
22
  for (let i = 0; i < history.length; i++) {
23
23
  const route = history[i];
24
- const method = route[0] === "WS" ? "WS" : require_utils.mapMethodBack(route[0]);
24
+ const method = route[0];
25
25
  seen.set(method + " " + route[1], i);
26
26
  }
27
27
  let explicitPaths;
@@ -29,7 +29,7 @@ function collectStaticRoutes(app) {
29
29
  explicitPaths = /* @__PURE__ */ new Map();
30
30
  for (let i = 0; i < history.length; i++) {
31
31
  const route = history[i];
32
- const method = route[0] === "WS" ? "WS" : require_utils.mapMethodBack(route[0]);
32
+ const method = route[0];
33
33
  const path = route[1];
34
34
  let set = explicitPaths.get(method);
35
35
  if (!set) explicitPaths.set(method, set = /* @__PURE__ */ new Set());
@@ -52,7 +52,7 @@ function collectStaticRoutes(app) {
52
52
  for (let i = 0; i < history.length; i++) {
53
53
  const route = history[i];
54
54
  if (route[0] === "WS") continue;
55
- const method = require_utils.mapMethodBack(route[0]);
55
+ const method = route[0];
56
56
  const path = route[1];
57
57
  if (seen.get(method + " " + path) !== i) continue;
58
58
  const value = require_compile_handler_index.buildNativeStaticResponse(route, app);
@@ -1,6 +1,6 @@
1
1
  import { createAdapter } from "../index.mjs";
2
2
  import { isDynamicRegex, needEncodeRegex } from "../../constants.mjs";
3
- import { flattenChain, getLoosePath, mapMethodBack, nullObject } from "../../utils.mjs";
3
+ import { flattenChain, getLoosePath, nullObject } from "../../utils.mjs";
4
4
  import { WebStandardAdapter } from "../web-standard/index.mjs";
5
5
  import { buildNativeStaticResponse } from "../../compile/handler/index.mjs";
6
6
  import { flushMemory } from "../../memory.mjs";
@@ -20,7 +20,7 @@ function collectStaticRoutes(app) {
20
20
  const seen = /* @__PURE__ */ new Map();
21
21
  for (let i = 0; i < history.length; i++) {
22
22
  const route = history[i];
23
- const method = route[0] === "WS" ? "WS" : mapMethodBack(route[0]);
23
+ const method = route[0];
24
24
  seen.set(method + " " + route[1], i);
25
25
  }
26
26
  let explicitPaths;
@@ -28,7 +28,7 @@ function collectStaticRoutes(app) {
28
28
  explicitPaths = /* @__PURE__ */ new Map();
29
29
  for (let i = 0; i < history.length; i++) {
30
30
  const route = history[i];
31
- const method = route[0] === "WS" ? "WS" : mapMethodBack(route[0]);
31
+ const method = route[0];
32
32
  const path = route[1];
33
33
  let set = explicitPaths.get(method);
34
34
  if (!set) explicitPaths.set(method, set = /* @__PURE__ */ new Set());
@@ -51,7 +51,7 @@ function collectStaticRoutes(app) {
51
51
  for (let i = 0; i < history.length; i++) {
52
52
  const route = history[i];
53
53
  if (route[0] === "WS") continue;
54
- const method = mapMethodBack(route[0]);
54
+ const method = route[0];
55
55
  const path = route[1];
56
56
  if (seen.get(method + " " + path) !== i) continue;
57
57
  const value = buildNativeStaticResponse(route, app);
package/dist/base.d.ts CHANGED
@@ -57,14 +57,6 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
57
57
  '~scopeChild'?: boolean;
58
58
  '~scopeChildren'?: AnyElysia[];
59
59
  constructor(config?: ElysiaConfig<BasePath, Scope>);
60
- /**
61
- * @deprecated use `app.history` instead
62
- *
63
- * Elysia changes it store route internally
64
- * This API is provided as compatibility
65
- *
66
- * Will remove in 2.1
67
- */
68
60
  get routes(): PublicRoute[];
69
61
  /**
70
62
  * ### decorate
@@ -868,4 +860,4 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
868
860
  stop(closeActiveConnections?: boolean): Promise<void> | void;
869
861
  }
870
862
  //#endregion
871
- export { AnyElysia, Elysia };
863
+ export { AnyElysia, Elysia, StaticMapAliases };
package/dist/base.js CHANGED
@@ -6,9 +6,9 @@ const require_utils = require('./utils.js');
6
6
  const require_type_bridge = require('./type/bridge.js');
7
7
  const require_compile_aot = require('./compile/aot.js');
8
8
  const require_compile_handler_index = require('./compile/handler/index.js');
9
- const require_ws_route = require('./ws/route.js');
10
9
  const require_adapter_bun_index = require('./adapter/bun/index.js');
11
10
  const require_handler_fetch = require('./handler/fetch.js');
11
+ const require_compile_build_router = require('./compile/build-router.js');
12
12
  let memoirist = require("memoirist");
13
13
  memoirist = require_runtime.__toESM(memoirist);
14
14
 
@@ -54,14 +54,6 @@ var Elysia = class Elysia {
54
54
  if (this["~Prefix"] && !this["~Prefix"].startsWith("/")) this["~Prefix"] = `/${this["~Prefix"]}`;
55
55
  if (config?.name) this.#hash = require_utils.fnv1a(config.seed ? `${config.name}_${typeof config.seed === "object" ? JSON.stringify(config.seed) : config.seed}` : config.name);
56
56
  }
57
- /**
58
- * @deprecated use `app.history` instead
59
- *
60
- * Elysia changes it store route internally
61
- * This API is provided as compatibility
62
- *
63
- * Will remove in 2.1
64
- */
65
57
  get routes() {
66
58
  if (!this.#history) return [];
67
59
  if (this.#cachedRoutes) return this.#cachedRoutes;
@@ -73,7 +65,7 @@ var Elysia = class Elysia {
73
65
  }
74
66
  if (merged?.response && !require_utils.isRecordNumber(merged.response)) merged.response = { 200: merged.response };
75
67
  return {
76
- method: require_utils.mapMethodBack(method),
68
+ method,
77
69
  path,
78
70
  handler,
79
71
  hooks: merged
@@ -851,25 +843,25 @@ var Elysia = class Elysia {
851
843
  return require_type_bridge.Ref(key);
852
844
  }
853
845
  get(path, hookOrFn, fn) {
854
- return this.#add(require_constants.MethodMap.GET, path, hookOrFn, fn);
846
+ return this.#add("GET", path, hookOrFn, fn);
855
847
  }
856
848
  post(path, hookOrFn, fn) {
857
- return this.#add(require_constants.MethodMap.POST, path, hookOrFn, fn);
849
+ return this.#add("POST", path, hookOrFn, fn);
858
850
  }
859
851
  put(path, hookOrFn, fn) {
860
- return this.#add(require_constants.MethodMap.PUT, path, hookOrFn, fn);
852
+ return this.#add("PUT", path, hookOrFn, fn);
861
853
  }
862
854
  patch(path, hookOrFn, fn) {
863
- return this.#add(require_constants.MethodMap.PATCH, path, hookOrFn, fn);
855
+ return this.#add("PATCH", path, hookOrFn, fn);
864
856
  }
865
857
  delete(path, hookOrFn, fn) {
866
- return this.#add(require_constants.MethodMap.DELETE, path, hookOrFn, fn);
858
+ return this.#add("DELETE", path, hookOrFn, fn);
867
859
  }
868
860
  options(path, hookOrFn, fn) {
869
- return this.#add(require_constants.MethodMap.OPTIONS, path, hookOrFn, fn);
861
+ return this.#add("OPTIONS", path, hookOrFn, fn);
870
862
  }
871
863
  head(path, hookOrFn, fn) {
872
- return this.#add(require_constants.MethodMap.HEAD, path, hookOrFn, fn);
864
+ return this.#add("HEAD", path, hookOrFn, fn);
873
865
  }
874
866
  method(method, path, hookOrFn, fn) {
875
867
  return this.#add(method, path, hookOrFn, fn);
@@ -959,7 +951,7 @@ var Elysia = class Elysia {
959
951
  try {
960
952
  handler = require_compile_handler_index.compileHandler(this.#history[index], this, precomputedStatic);
961
953
  } catch (error) {
962
- throw new Error(`[Elysia] Failed to compile route ${require_utils.mapMethodBack(route[0])} ${route[1]}: ${error?.message ?? error}`, { cause: error });
954
+ throw new Error(`[Elysia] Failed to compile route ${route[0]} ${route[1]}: ${error?.message ?? error}`, { cause: error });
963
955
  }
964
956
  compiled[index] = handler;
965
957
  this.#saveHandler(route[0], route[1], handler);
@@ -974,7 +966,7 @@ var Elysia = class Elysia {
974
966
  try {
975
967
  handler = require_compile_handler_index.compileHandler(this.#history[index], this, precomputedStatic);
976
968
  } catch (error) {
977
- throw new Error(`[Elysia] Failed to compile route ${require_utils.mapMethodBack(route[0])} ${route[1]}: ${error?.message ?? error}`, { cause: error });
969
+ throw new Error(`[Elysia] Failed to compile route ${route[0]} ${route[1]}: ${error?.message ?? error}`, { cause: error });
978
970
  }
979
971
  this.#compiled[index] = handler;
980
972
  if (aliases) {
@@ -993,7 +985,7 @@ var Elysia = class Elysia {
993
985
  #saveHandler(method, path, handler) {
994
986
  if (require_constants.isDynamicRegex.test(path)) return;
995
987
  this.#initMap();
996
- const map = this["~map"][require_utils.mapMethodBack(method)] ??= require_utils.nullObject();
988
+ const map = this["~map"][method] ??= require_utils.nullObject();
997
989
  map[path] = handler;
998
990
  }
999
991
  static #toHeadResponse(response) {
@@ -1021,203 +1013,76 @@ var Elysia = class Elysia {
1021
1013
  return r instanceof Promise ? r.then(Elysia.#toHeadResponse) : Elysia.#toHeadResponse(r);
1022
1014
  });
1023
1015
  }
1024
- #chainRefMemo;
1025
- static #slotHasString(h) {
1026
- if (!h || typeof h !== "object") return false;
1027
- for (const key of require_utils.schemaProperties) {
1028
- const v = h[key];
1029
- if (typeof v === "string") return true;
1030
- if (key === "response" && v && typeof v === "object") {
1031
- const record = v;
1032
- if ("~kind" in record || "~elyAcl" in record || "~standard" in record) continue;
1033
- for (const status in record) if (typeof record[status] === "string") return true;
1034
- }
1016
+ #replayRouter(routeTableManifest) {
1017
+ if (routeTableManifest.v !== 1) return false;
1018
+ const history = this.#history;
1019
+ if (require_compile_aot.computeRouteTableShape(history, this["~config"]) !== routeTableManifest.shape) throw new Error(`[elysia-aot] frozen route-table shape mismatch`);
1020
+ this.#initMap();
1021
+ const methods = this["~map"];
1022
+ this.#compiled ??= new Array(history.length);
1023
+ const indexOf = /* @__PURE__ */ new Map();
1024
+ for (let i = 0; i < history.length; i++) {
1025
+ const route = history[i];
1026
+ indexOf.set(route[0] + "\0" + route[1], i);
1035
1027
  }
1036
- return false;
1037
- }
1038
- static #hookHasString(h) {
1039
- if (Elysia.#slotHasString(h)) return true;
1040
- const schemas = h?.schemas;
1041
- if (Array.isArray(schemas)) {
1042
- for (let s = 0; s < schemas.length; s++) if (Elysia.#slotHasString(schemas[s])) return true;
1028
+ const handlerFor = (slot) => {
1029
+ const i = indexOf.get(slot.m + "\0" + slot.p);
1030
+ if (i === void 0) return;
1031
+ return this.handler(i, true, history[i]);
1032
+ };
1033
+ let bound = 0;
1034
+ let expected = 0;
1035
+ const staticTree = routeTableManifest.static;
1036
+ for (const method in staticTree) {
1037
+ const paths = staticTree[method];
1038
+ const map = methods[method] ??= require_utils.nullObject();
1039
+ for (const served in paths) {
1040
+ expected++;
1041
+ const handler = handlerFor(paths[served]);
1042
+ if (handler === void 0) continue;
1043
+ map[served] = handler;
1044
+ bound++;
1045
+ }
1043
1046
  }
1044
- return false;
1045
- }
1046
- #chainHasModelRef(start) {
1047
- if (!start) return false;
1048
- const memo = this.#chainRefMemo ??= /* @__PURE__ */ new WeakMap();
1049
- const cached = memo.get(start);
1050
- if (cached !== void 0) return cached;
1051
- let found = false;
1052
- const stack = [start];
1053
- while (stack.length) {
1054
- const node = stack.pop();
1055
- if (!node) continue;
1056
- if ("combine" in node) {
1057
- stack.push(node.combine);
1058
- stack.push(node.over);
1059
- } else {
1060
- if (Elysia.#hookHasString(node.added)) {
1061
- found = true;
1062
- break;
1063
- }
1064
- stack.push(node.parent);
1047
+ const headTree = routeTableManifest.head;
1048
+ if (headTree) {
1049
+ const head = methods["HEAD"] ??= require_utils.nullObject();
1050
+ for (const served in headTree) {
1051
+ expected++;
1052
+ const handler = handlerFor(headTree[served]);
1053
+ if (handler === void 0) continue;
1054
+ head[served] = Elysia.#wrapHeadHandler(handler);
1055
+ bound++;
1065
1056
  }
1066
1057
  }
1067
- memo.set(start, found);
1068
- return found;
1069
- }
1070
- #routeMayHaveModelRef(route) {
1071
- if (this["~ext"]?.macro || this["~scopeChildren"]) return true;
1072
- if (require_compile_handler_index.localMacroRoot(route[7] ?? route[3] ?? this, this)["~ext"]?.macro) return true;
1073
- if (Elysia.#hookHasString(route[4])) return true;
1074
- return this.#chainHasModelRef(route[5]) || this.#chainHasModelRef(route[6]) || this.#chainHasModelRef(this["~hookChain"]);
1075
- }
1076
- #assertRouteModelRefs(route, method) {
1077
- const models = this["~ext"]?.models;
1078
- const path = route[1];
1079
- const checkSlots = (hook) => {
1080
- if (!hook) return;
1081
- for (const key in hook) {
1082
- if (!require_utils.schemaProperties.has(key)) continue;
1083
- const v = hook[key];
1084
- if (typeof v === "string") {
1085
- if (!models || !(v in models)) throw new Error(`[Elysia] Unknown model reference "${v}" for ${key} on route ${method} ${path}.`);
1086
- } else if (key === "response" && v && typeof v === "object") {
1087
- const record = v;
1088
- if ("~kind" in record || "~elyAcl" in record || "~standard" in record) continue;
1089
- for (const status in record) {
1090
- const r = record[status];
1091
- if (typeof r === "string" && (!models || !(r in models))) throw new Error(`[Elysia] Unknown model reference "${r}" for response ${status} on route ${method} ${path}.`);
1092
- }
1093
- }
1058
+ const dynamicList = routeTableManifest.dynamic;
1059
+ if (dynamicList) {
1060
+ const router = this["~router"] ??= new memoirist.default({ loosePath: this["~config"]?.strictPath !== true });
1061
+ for (let d = 0; d < dynamicList.length; d++) {
1062
+ expected++;
1063
+ const entry = dynamicList[d];
1064
+ const base = handlerFor(entry.slot);
1065
+ if (base === void 0) continue;
1066
+ router.add(entry.m, entry.s, entry.h ? Elysia.#wrapHeadHandler(base) : base, false);
1067
+ bound++;
1094
1068
  }
1095
- };
1096
- const hook = require_compile_handler_index.composeRouteHook(route[3], route[4], route[5], route[6], this, route[7]);
1097
- checkSlots(hook);
1098
- const schemas = hook?.schemas;
1099
- if (Array.isArray(schemas)) for (let s = 0; s < schemas.length; s++) checkSlots(schemas[s]);
1069
+ }
1070
+ if (bound < expected) throw new Error(`[elysia-aot] frozen route-table bound ${bound}/${expected} routes`);
1071
+ this.#routerBuilt = true;
1072
+ return true;
1100
1073
  }
1101
1074
  #routerBuilt = false;
1102
1075
  #buildRouter() {
1103
1076
  if (!this.#history || this.#routerBuilt) return;
1077
+ const routeTableManifest = require_compile_aot.Capture.isAotBuildEnv() ? void 0 : require_compile_aot.Compiled.routeTable;
1078
+ if (routeTableManifest && this.#replayRouter(routeTableManifest)) return;
1104
1079
  this.#routerBuilt = true;
1105
- const precompile = this["~config"]?.precompile;
1106
- const enableAutoHead = this["~config"]?.autoHead === true;
1107
- this.#initMap();
1108
- const methods = this["~map"];
1109
- const length = this.#history.length;
1110
- const wrapHeadHandler = Elysia.#wrapHeadHandler;
1111
- const isLoose = this["~config"]?.strictPath !== true;
1112
- let explicitHead;
1113
- let explicitPaths;
1114
- if (isLoose) explicitPaths = /* @__PURE__ */ new Map();
1115
- if (enableAutoHead || isLoose) for (let i = 0; i < length; i++) {
1116
- const route = this.#history[i];
1117
- const isWS = route[0] === "WS";
1118
- const m = isWS ? "WS" : require_utils.mapMethodBack(route[0]);
1119
- const p = route[1];
1120
- if (enableAutoHead && !isWS && m === "HEAD") (explicitHead ??= /* @__PURE__ */ new Set()).add(p);
1121
- if (explicitPaths) {
1122
- let set = explicitPaths.get(m);
1123
- if (!set) explicitPaths.set(m, set = /* @__PURE__ */ new Set());
1124
- set.add(p);
1125
- if (require_constants.needEncodeRegex.test(p)) {
1126
- const encoded = encodeURI(p);
1127
- if (encoded !== p) set.add(encoded);
1128
- }
1129
- }
1130
- }
1131
- for (let i = 0; i < length; i++) {
1132
- const route = this.#history[i];
1133
- const method = require_utils.mapMethodBack(route[0]);
1134
- const path = route[1];
1135
- if (this.#routeMayHaveModelRef(route)) this.#assertRouteModelRefs(route, method);
1136
- if (route[0] === "WS") {
1137
- const ws = require_ws_route.buildWSRoute(route, this);
1138
- const handler = ws[0];
1139
- const options = ws[1];
1140
- if (require_constants.isDynamicRegex.test(path)) {
1141
- (this["~router"] ??= new memoirist.default({ loosePath: isLoose })).add("WS", path, handler, false);
1142
- this["~hasDynamicWS"] = true;
1143
- } else {
1144
- this.#initMap();
1145
- const wsMap = this["~map"]["WS"] ??= require_utils.nullObject();
1146
- wsMap[path] = handler;
1147
- if (isLoose) {
1148
- const loose = require_utils.getLoosePath(path);
1149
- if (loose !== path && !explicitPaths?.get("WS")?.has(loose)) wsMap[loose] = handler;
1150
- }
1151
- }
1152
- if (options && require_utils.isNotEmpty(options)) {
1153
- this["~config"] ??= require_utils.nullObject();
1154
- const existing = this["~config"].websocket;
1155
- if (existing && require_universal_constants.isBun) {
1156
- for (const key in options) if (key in existing && existing[key] !== options[key]) {
1157
- console.warn(`[Elysia] Conflicting per-route WebSocket option '${key}'\nBun uses one global WebSocket config per server, per-route values are not enforced (the last-registered route wins).`);
1158
- console.warn((/* @__PURE__ */ new Error()).stack);
1159
- }
1160
- Object.assign(existing, options);
1161
- } else this["~config"].websocket = options;
1162
- }
1163
- continue;
1164
- }
1165
- const autoHead = enableAutoHead && method === "GET" && !explicitHead?.has(path);
1166
- const isDynamic = require_constants.isDynamicRegex.test(path);
1167
- const needsEncode = require_constants.needEncodeRegex.test(path);
1168
- const registerLoose = !isDynamic && isLoose && (path.length === 0 || path.charCodeAt(path.length - 1) === 47);
1169
- const explicitMain = registerLoose ? explicitPaths?.get(method) : void 0;
1170
- if (!isDynamic && !needsEncode && !registerLoose) {
1171
- const map = methods[method] ??= require_utils.nullObject();
1172
- const handler = this.handler(i, precompile, route, void 0, autoHead ? {
1173
- method,
1174
- paths: [path],
1175
- head: true
1176
- } : void 0);
1177
- map[path] = handler;
1178
- if (autoHead) {
1179
- const head = methods["HEAD"] ??= require_utils.nullObject();
1180
- head[path] = wrapHeadHandler(handler);
1181
- }
1182
- continue;
1183
- }
1184
- const variants = [path];
1185
- if (needsEncode) {
1186
- const encoded = encodeURI(path);
1187
- if (encoded !== path) variants.push(encoded);
1188
- }
1189
- const paths = [];
1190
- for (let v = 0; v < variants.length; v++) {
1191
- const p = variants[v];
1192
- paths.push(p);
1193
- if (registerLoose) {
1194
- const loose = require_utils.getLoosePath(p);
1195
- if (loose !== p && !explicitMain?.has(loose)) paths.push(loose);
1196
- }
1197
- }
1198
- if (isDynamic) {
1199
- const router = this["~router"] ??= new memoirist.default({ loosePath: isLoose });
1200
- const handler = this.handler(i, precompile, void 0, void 0);
1201
- const headHandler = autoHead ? wrapHeadHandler(handler) : void 0;
1202
- for (let p = 0; p < paths.length; p++) {
1203
- router.add(method, paths[p], handler, false);
1204
- if (headHandler) router.add("HEAD", paths[p], headHandler, false);
1205
- }
1206
- } else {
1207
- const map = methods[method] ??= require_utils.nullObject();
1208
- const handler = this.handler(i, precompile, route, void 0, {
1209
- method,
1210
- paths,
1211
- head: autoHead
1212
- });
1213
- const headHandler = autoHead ? wrapHeadHandler(handler) : void 0;
1214
- const head = autoHead ? methods["HEAD"] ??= require_utils.nullObject() : void 0;
1215
- for (let p = 0; p < paths.length; p++) {
1216
- map[paths[p]] = handler;
1217
- if (headHandler) head[paths[p]] = headHandler;
1218
- }
1219
- }
1220
- }
1080
+ require_compile_build_router.buildRouter(this, {
1081
+ history: this.#history,
1082
+ handler: (index, immediate, route, precomputedStatic, aliases) => this.handler(index, immediate, route, precomputedStatic, aliases),
1083
+ initMap: () => this.#initMap(),
1084
+ wrapHeadHandler: Elysia.#wrapHeadHandler
1085
+ });
1221
1086
  }
1222
1087
  #fetchFn;
1223
1088
  get fetch() {