elysia 2.0.0-exp.3 → 2.0.0-exp.5

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 (73) hide show
  1. package/dist/adapter/utils.d.ts +1 -4
  2. package/dist/adapter/utils.js +8 -7
  3. package/dist/adapter/utils.mjs +5 -4
  4. package/dist/adapter/web-standard/handler.js +1 -1
  5. package/dist/adapter/web-standard/handler.mjs +1 -1
  6. package/dist/base.d.ts +1 -1
  7. package/dist/base.js +24 -12
  8. package/dist/base.mjs +24 -12
  9. package/dist/compile/aot.d.ts +18 -1
  10. package/dist/compile/aot.js +19 -0
  11. package/dist/compile/aot.mjs +19 -0
  12. package/dist/compile/handler/index.d.ts +1 -1
  13. package/dist/compile/handler/index.js +16 -437
  14. package/dist/compile/handler/index.mjs +17 -438
  15. package/dist/compile/handler/jit.d.ts +35 -0
  16. package/dist/compile/handler/jit.js +445 -0
  17. package/dist/compile/handler/jit.mjs +443 -0
  18. package/dist/compile/handler/params.js +2 -2
  19. package/dist/compile/handler/params.mjs +2 -2
  20. package/dist/compile/handler/reconstruct.d.ts +13 -0
  21. package/dist/compile/handler/reconstruct.js +29 -0
  22. package/dist/compile/handler/reconstruct.mjs +28 -0
  23. package/dist/compile/handler/utils.js +3 -3
  24. package/dist/compile/handler/utils.mjs +3 -3
  25. package/dist/compile/jit-probe.d.ts +19 -0
  26. package/dist/compile/jit-probe.js +38 -0
  27. package/dist/compile/jit-probe.mjs +36 -0
  28. package/dist/cookie/index.d.ts +2 -1
  29. package/dist/cookie/index.js +2 -1
  30. package/dist/cookie/index.mjs +2 -1
  31. package/dist/cookie/serialize.d.ts +6 -0
  32. package/dist/cookie/serialize.js +28 -0
  33. package/dist/cookie/serialize.mjs +27 -0
  34. package/dist/cookie/utils.d.ts +1 -2
  35. package/dist/cookie/utils.js +1 -22
  36. package/dist/cookie/utils.mjs +4 -24
  37. package/dist/handler/fetch.js +21 -11
  38. package/dist/handler/fetch.mjs +22 -12
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +3 -3
  41. package/dist/index.mjs +2 -2
  42. package/dist/plugin/bun.js +8 -1
  43. package/dist/plugin/bun.mjs +9 -2
  44. package/dist/plugin/core.d.ts +46 -1
  45. package/dist/plugin/core.js +64 -2
  46. package/dist/plugin/core.mjs +64 -4
  47. package/dist/plugin/esbuild.js +8 -1
  48. package/dist/plugin/esbuild.mjs +9 -2
  49. package/dist/plugin/source.d.ts +38 -1
  50. package/dist/plugin/source.js +96 -9
  51. package/dist/plugin/source.mjs +93 -9
  52. package/dist/plugin/vite.js +13 -1
  53. package/dist/plugin/vite.mjs +14 -2
  54. package/dist/trace.d.ts +1 -1
  55. package/dist/trace.js +4 -6
  56. package/dist/trace.mjs +4 -6
  57. package/dist/type/coerce.d.ts +1 -1
  58. package/dist/type/constants.d.ts +1 -1
  59. package/dist/type/elysia/file-type.js +1 -1
  60. package/dist/type/elysia/file-type.mjs +1 -1
  61. package/dist/type/validator/default-precompute.d.ts +13 -2
  62. package/dist/type/validator/default-precompute.js +281 -21
  63. package/dist/type/validator/default-precompute.mjs +275 -22
  64. package/dist/type/validator/index.d.ts +1 -1
  65. package/dist/type/validator/index.js +67 -31
  66. package/dist/type/validator/index.mjs +68 -32
  67. package/dist/universal/file.js +5 -4
  68. package/dist/universal/file.mjs +5 -4
  69. package/dist/utils.js +6 -8
  70. package/dist/utils.mjs +6 -8
  71. package/dist/validator/index.js +2 -2
  72. package/dist/validator/index.mjs +2 -2
  73. package/package.json +3 -2
@@ -18,10 +18,7 @@ interface CreateHandlerParameter {
18
18
  mapResponse(response: unknown, set: Context['set'], request?: Request): Response;
19
19
  mapCompactResponse(response: unknown, request?: Request): Response;
20
20
  }
21
- declare const createStreamHandler: ({
22
- mapResponse,
23
- mapCompactResponse
24
- }: CreateHandlerParameter) => (generator: Generator | AsyncGenerator | ReadableStream, set?: Context["set"], request?: Request, skipFormat?: boolean) => Promise<Response>;
21
+ declare const createStreamHandler: (_: CreateHandlerParameter) => (generator: Generator | AsyncGenerator | ReadableStream, set?: Context["set"], request?: Request, skipFormat?: boolean) => Promise<Response>;
25
22
  declare function streamResponse(response: Response): AsyncGenerator<any, void, any>;
26
23
  declare function handleSet(set: Context['set']): void;
27
24
  declare function mergeHeaders(responseHeaders: Headers, setHeaders: Context['set']['headers']): Headers;
@@ -2,7 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_universal_constants = require('../universal/constants.js');
3
3
  const require_constants = require('../constants.js');
4
4
  const require_utils = require('../utils.js');
5
- const require_cookie_utils = require('../cookie/utils.js');
5
+ const require_cookie_serialize = require('../cookie/serialize.js');
6
+ const require_adapter_web_standard_handler = require('./web-standard/handler.js');
6
7
 
7
8
  //#region src/adapter/utils.ts
8
9
  const setCookie = "set-cookie";
@@ -101,7 +102,7 @@ function responseToSetHeaders(response, set) {
101
102
  } else if (set.headers["content-encoding"]) delete set.headers["content-encoding"];
102
103
  return set;
103
104
  }
104
- const enqueueBinaryChunk = (controller, chunk) => {
105
+ function enqueueBinaryChunk(controller, chunk) {
105
106
  if (chunk instanceof Blob) return chunk.arrayBuffer().then((buffer) => {
106
107
  controller.enqueue(new Uint8Array(buffer));
107
108
  return true;
@@ -119,15 +120,15 @@ const enqueueBinaryChunk = (controller, chunk) => {
119
120
  return true;
120
121
  }
121
122
  return false;
122
- };
123
- const createStreamHandler = ({ mapResponse, mapCompactResponse }) => async (generator, set, request, skipFormat) => {
123
+ }
124
+ const createStreamHandler = (_) => async (generator, set, request, skipFormat) => {
124
125
  let init = generator.next?.();
125
126
  if (set) handleSet(set);
126
127
  if (init instanceof Promise) init = await init;
127
128
  if (init?.value instanceof ReadableStream) generator = init.value;
128
129
  else if (init && (typeof init?.done === "undefined" || init?.done)) {
129
- if (set) return mapResponse(init.value, set, request);
130
- return mapCompactResponse(init.value, request);
130
+ if (set) return require_adapter_web_standard_handler.mapResponse(init.value, set, request);
131
+ return require_adapter_web_standard_handler.mapCompactResponse(init.value, request);
131
132
  }
132
133
  const isSSE = !skipFormat && (init?.value?.sse ?? generator?.sse ?? set?.headers["content-type"]?.startsWith("text/event-stream"));
133
134
  const format = isSSE ? (data) => `data: ${data}\n\n` : (data) => data;
@@ -217,7 +218,7 @@ function handleSet(set) {
217
218
  set.headers = flat;
218
219
  }
219
220
  if (set.cookie && require_utils.isNotEmpty(set.cookie)) {
220
- const cookie = require_cookie_utils.serializeCookie(set.cookie);
221
+ const cookie = require_cookie_serialize.serializeCookie(set.cookie);
221
222
  if (cookie) set.headers[setCookie] = cookie;
222
223
  }
223
224
  if (set.headers[setCookie] && Array.isArray(set.headers[setCookie])) set.headers = parseSetCookies(new Headers(set.headers), set.headers[setCookie]);
@@ -1,7 +1,8 @@
1
1
  import { hasHeaderShorthand, isBun } from "../universal/constants.mjs";
2
2
  import { StatusMap } from "../constants.mjs";
3
3
  import { isNotEmpty, nullObject } from "../utils.mjs";
4
- import { serializeCookie } from "../cookie/utils.mjs";
4
+ import { serializeCookie } from "../cookie/serialize.mjs";
5
+ import { mapCompactResponse, mapResponse } from "./web-standard/handler.mjs";
5
6
 
6
7
  //#region src/adapter/utils.ts
7
8
  const setCookie = "set-cookie";
@@ -100,7 +101,7 @@ function responseToSetHeaders(response, set) {
100
101
  } else if (set.headers["content-encoding"]) delete set.headers["content-encoding"];
101
102
  return set;
102
103
  }
103
- const enqueueBinaryChunk = (controller, chunk) => {
104
+ function enqueueBinaryChunk(controller, chunk) {
104
105
  if (chunk instanceof Blob) return chunk.arrayBuffer().then((buffer) => {
105
106
  controller.enqueue(new Uint8Array(buffer));
106
107
  return true;
@@ -118,8 +119,8 @@ const enqueueBinaryChunk = (controller, chunk) => {
118
119
  return true;
119
120
  }
120
121
  return false;
121
- };
122
- const createStreamHandler = ({ mapResponse, mapCompactResponse }) => async (generator, set, request, skipFormat) => {
122
+ }
123
+ const createStreamHandler = (_) => async (generator, set, request, skipFormat) => {
123
124
  let init = generator.next?.();
124
125
  if (set) handleSet(set);
125
126
  if (init instanceof Promise) init = await init;
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_universal_constants = require('../../universal/constants.js');
3
3
  const require_universal_file = require('../../universal/file.js');
4
4
  const require_utils = require('../../utils.js');
5
- const require_error = require('../../error.js');
6
5
  const require_adapter_utils = require('../utils.js');
6
+ const require_error = require('../../error.js');
7
7
 
8
8
  //#region src/adapter/web-standard/handler.ts
9
9
  function handleElysiaFile(file, set = { headers: require_utils.nullObject() }, request) {
@@ -1,8 +1,8 @@
1
1
  import { isBun } from "../../universal/constants.mjs";
2
2
  import { mime } from "../../universal/file.mjs";
3
3
  import { formToFormData, isNotEmpty, nullObject } from "../../utils.mjs";
4
- import { ElysiaStatus, isProduction } from "../../error.mjs";
5
4
  import { createResponseHandler, createStreamHandler, handleFile, handleSet } from "../utils.mjs";
5
+ import { ElysiaStatus, isProduction } from "../../error.mjs";
6
6
 
7
7
  //#region src/adapter/web-standard/handler.ts
8
8
  function handleElysiaFile(file, set = { headers: nullObject() }, request) {
package/dist/base.d.ts CHANGED
@@ -43,7 +43,7 @@ declare class Elysia<const in out BasePath extends string = '', const in out Sco
43
43
  '~map'?: {
44
44
  [method: string]: {
45
45
  [path: string]: CompiledHandler;
46
- };
46
+ } | undefined;
47
47
  };
48
48
  '~staticResponse'?: {
49
49
  [path: string]: {
package/dist/base.js CHANGED
@@ -378,7 +378,7 @@ var Elysia = class Elysia {
378
378
  return this;
379
379
  }
380
380
  macro(macro) {
381
- if (typeof macro === "function") throw new Error("Use `.macro({ name: fn })` instead of `.macro(fn)`");
381
+ if (typeof macro === "function") throw new Error("use `.macro({ name: fn })` instead of `.macro(fn)`");
382
382
  const ext = this.#ext;
383
383
  const m = ext.macro ??= require_utils.nullObject();
384
384
  for (const key in macro) if (typeof macro[key] === "object") macro[key] = require_utils.hookToGuard(macro[key]);
@@ -813,13 +813,13 @@ var Elysia = class Elysia {
813
813
  }
814
814
  #initMap() {
815
815
  this["~map"] ??= {
816
- GET: require_utils.nullObject(),
817
- POST: require_utils.nullObject(),
818
- PUT: require_utils.nullObject(),
819
- DELETE: require_utils.nullObject(),
820
- PATCH: require_utils.nullObject(),
821
- HEAD: require_utils.nullObject(),
822
- OPTIONS: require_utils.nullObject()
816
+ GET: void 0,
817
+ POST: void 0,
818
+ PUT: void 0,
819
+ DELETE: void 0,
820
+ PATCH: void 0,
821
+ HEAD: void 0,
822
+ OPTIONS: void 0
823
823
  };
824
824
  }
825
825
  compile() {
@@ -897,6 +897,8 @@ var Elysia = class Elysia {
897
897
  }
898
898
  const wrapHeadHandler = Elysia.#wrapHeadHandler;
899
899
  const strict = !!this["~config"]?.strictPath;
900
+ const routerOptions = strict ? void 0 : { loosePath: true };
901
+ const getRouter = () => this["~router"] ??= new memoirist.default(routerOptions);
900
902
  let explicitPaths;
901
903
  if (!strict && this["~config"]?.distinctPath) {
902
904
  explicitPaths = /* @__PURE__ */ new Map();
@@ -921,7 +923,7 @@ var Elysia = class Elysia {
921
923
  const ws = require_ws_route.buildWSRoute(route, this);
922
924
  const handler = ws[0];
923
925
  const options = ws[1];
924
- if (require_constants.isDynamicRegex.test(path)) (this["~router"] ??= new memoirist.default()).add("WS", path, handler, false);
926
+ if (require_constants.isDynamicRegex.test(path)) getRouter().add("WS", path, handler, false);
925
927
  else {
926
928
  this.#initMap();
927
929
  const wsMap = this["~map"]["WS"] ??= require_utils.nullObject();
@@ -961,8 +963,18 @@ var Elysia = class Elysia {
961
963
  const sharedStatic = maybeStatic && staticResponse instanceof Response ? staticResponse : void 0;
962
964
  const autoHead = enableAutoHead && method === "GET" && !explicitHead?.has(path);
963
965
  const isDynamic = require_constants.isDynamicRegex.test(path);
964
- const registerLoose = !isDynamic && !strict;
966
+ const registerLoose = !isDynamic && !strict && (path.length === 0 || path.charCodeAt(path.length - 1) === 47);
965
967
  const explicitMain = registerLoose ? explicitPaths?.get(method) : void 0;
968
+ if (!isDynamic && !require_constants.needEncodeRegex.test(path) && !registerLoose) {
969
+ const map = methods[method] ??= require_utils.nullObject();
970
+ const handler = this.handler(i, precompile, route, sharedStatic);
971
+ map[path] = handler;
972
+ if (autoHead) {
973
+ const head = methods["HEAD"] ??= require_utils.nullObject();
974
+ head[path] = wrapHeadHandler(handler);
975
+ }
976
+ continue;
977
+ }
966
978
  const variants = [path];
967
979
  if (require_constants.needEncodeRegex.test(path)) {
968
980
  const encoded = encodeURI(path);
@@ -978,7 +990,7 @@ var Elysia = class Elysia {
978
990
  }
979
991
  }
980
992
  if (isDynamic) {
981
- const router = this["~router"] ??= new memoirist.default();
993
+ const router = getRouter();
982
994
  const handler = this.handler(i, precompile, void 0, sharedStatic);
983
995
  const headHandler = autoHead ? wrapHeadHandler(handler) : void 0;
984
996
  for (let p = 0; p < paths.length; p++) {
@@ -1018,7 +1030,7 @@ var Elysia = class Elysia {
1018
1030
  return this;
1019
1031
  }
1020
1032
  wrap(callback) {
1021
- if (this.#fetchFn) console.warn("[Elysia] .wrap() was called after the fetch handler was built, so it will not take effect. Register .wrap() before .listen() or before accessing .fetch/.handle.");
1033
+ if (this.#fetchFn) console.warn("[Elysia] .wrap() was called after the fetch handler was built");
1022
1034
  const ext = this.#ext;
1023
1035
  (ext.hoc ??= []).push(callback);
1024
1036
  return this;
package/dist/base.mjs CHANGED
@@ -375,7 +375,7 @@ var Elysia = class Elysia {
375
375
  return this;
376
376
  }
377
377
  macro(macro) {
378
- if (typeof macro === "function") throw new Error("Use `.macro({ name: fn })` instead of `.macro(fn)`");
378
+ if (typeof macro === "function") throw new Error("use `.macro({ name: fn })` instead of `.macro(fn)`");
379
379
  const ext = this.#ext;
380
380
  const m = ext.macro ??= nullObject();
381
381
  for (const key in macro) if (typeof macro[key] === "object") macro[key] = hookToGuard(macro[key]);
@@ -810,13 +810,13 @@ var Elysia = class Elysia {
810
810
  }
811
811
  #initMap() {
812
812
  this["~map"] ??= {
813
- GET: nullObject(),
814
- POST: nullObject(),
815
- PUT: nullObject(),
816
- DELETE: nullObject(),
817
- PATCH: nullObject(),
818
- HEAD: nullObject(),
819
- OPTIONS: nullObject()
813
+ GET: void 0,
814
+ POST: void 0,
815
+ PUT: void 0,
816
+ DELETE: void 0,
817
+ PATCH: void 0,
818
+ HEAD: void 0,
819
+ OPTIONS: void 0
820
820
  };
821
821
  }
822
822
  compile() {
@@ -894,6 +894,8 @@ var Elysia = class Elysia {
894
894
  }
895
895
  const wrapHeadHandler = Elysia.#wrapHeadHandler;
896
896
  const strict = !!this["~config"]?.strictPath;
897
+ const routerOptions = strict ? void 0 : { loosePath: true };
898
+ const getRouter = () => this["~router"] ??= new Memoirist(routerOptions);
897
899
  let explicitPaths;
898
900
  if (!strict && this["~config"]?.distinctPath) {
899
901
  explicitPaths = /* @__PURE__ */ new Map();
@@ -918,7 +920,7 @@ var Elysia = class Elysia {
918
920
  const ws = buildWSRoute(route, this);
919
921
  const handler = ws[0];
920
922
  const options = ws[1];
921
- if (isDynamicRegex.test(path)) (this["~router"] ??= new Memoirist()).add("WS", path, handler, false);
923
+ if (isDynamicRegex.test(path)) getRouter().add("WS", path, handler, false);
922
924
  else {
923
925
  this.#initMap();
924
926
  const wsMap = this["~map"]["WS"] ??= nullObject();
@@ -958,8 +960,18 @@ var Elysia = class Elysia {
958
960
  const sharedStatic = maybeStatic && staticResponse instanceof Response ? staticResponse : void 0;
959
961
  const autoHead = enableAutoHead && method === "GET" && !explicitHead?.has(path);
960
962
  const isDynamic = isDynamicRegex.test(path);
961
- const registerLoose = !isDynamic && !strict;
963
+ const registerLoose = !isDynamic && !strict && (path.length === 0 || path.charCodeAt(path.length - 1) === 47);
962
964
  const explicitMain = registerLoose ? explicitPaths?.get(method) : void 0;
965
+ if (!isDynamic && !needEncodeRegex.test(path) && !registerLoose) {
966
+ const map = methods[method] ??= nullObject();
967
+ const handler = this.handler(i, precompile, route, sharedStatic);
968
+ map[path] = handler;
969
+ if (autoHead) {
970
+ const head = methods["HEAD"] ??= nullObject();
971
+ head[path] = wrapHeadHandler(handler);
972
+ }
973
+ continue;
974
+ }
963
975
  const variants = [path];
964
976
  if (needEncodeRegex.test(path)) {
965
977
  const encoded = encodeURI(path);
@@ -975,7 +987,7 @@ var Elysia = class Elysia {
975
987
  }
976
988
  }
977
989
  if (isDynamic) {
978
- const router = this["~router"] ??= new Memoirist();
990
+ const router = getRouter();
979
991
  const handler = this.handler(i, precompile, void 0, sharedStatic);
980
992
  const headHandler = autoHead ? wrapHeadHandler(handler) : void 0;
981
993
  for (let p = 0; p < paths.length; p++) {
@@ -1015,7 +1027,7 @@ var Elysia = class Elysia {
1015
1027
  return this;
1016
1028
  }
1017
1029
  wrap(callback) {
1018
- if (this.#fetchFn) console.warn("[Elysia] .wrap() was called after the fetch handler was built, so it will not take effect. Register .wrap() before .listen() or before accessing .fetch/.handle.");
1030
+ if (this.#fetchFn) console.warn("[Elysia] .wrap() was called after the fetch handler was built");
1019
1031
  const ext = this.#ext;
1020
1032
  (ext.hoc ??= []).push(callback);
1021
1033
  return this;
@@ -33,7 +33,10 @@ interface FrozenValidator {
33
33
  r?: 1;
34
34
  ps?: 1;
35
35
  pd?: unknown;
36
+ pn?: 1;
36
37
  pod?: Record<string, unknown>;
38
+ dc?: () => unknown;
39
+ pm?: (value: Record<string, unknown>) => Record<string, unknown>;
37
40
  ce?: Array<{
38
41
  p: string;
39
42
  c: FrozenCheckFactory;
@@ -63,6 +66,13 @@ interface HandlerManifest {
63
66
  [path: string]: FrozenHandler;
64
67
  };
65
68
  }
69
+ interface CompiledSnapshot {
70
+ validators: ValidatorManifest | undefined;
71
+ handlers: HandlerManifest | undefined;
72
+ lazyGroups: Array<() => ValidatorManifest> | undefined;
73
+ lazyGroupOf: Record<string, Record<string, number>> | undefined;
74
+ builtGroups: number[];
75
+ }
66
76
  declare abstract class Compiled {
67
77
  static get handlers(): HandlerManifest | undefined;
68
78
  static set handlers(manifest: HandlerManifest);
@@ -71,6 +81,10 @@ declare abstract class Compiled {
71
81
  static registerLazyValidators(groups: Array<() => ValidatorManifest>, groupOf: Record<string, Record<string, number>>): void;
72
82
  static getValidator(method: string, path: string, slot: ValidatorSlot): FrozenValidator | undefined;
73
83
  static hasValidator(method: string, path: string, slot: ValidatorSlot): boolean;
84
+ /** @internal preserve registry around in-process AOT analysis */
85
+ static snapshot(): CompiledSnapshot;
86
+ /** @internal restore registry after in-process AOT analysis */
87
+ static restore(snapshot: CompiledSnapshot): void;
74
88
  /** @internal test isolation */
75
89
  static clear(): void;
76
90
  }
@@ -145,7 +159,10 @@ interface CapturedValidator {
145
159
  encodeMirror?: CapturedMirror;
146
160
  precomputeSafe?: boolean;
147
161
  precomputedDefault?: unknown;
162
+ precomputeNull?: boolean;
148
163
  precomputedObjectDefault?: Record<string, unknown>;
164
+ defaultCloner?: string;
165
+ objectDefaultMerger?: string;
149
166
  customErrors?: Array<{
150
167
  path: string;
151
168
  identifier: string;
@@ -186,4 +203,4 @@ declare const Capture: {
186
203
  readonly isCapturing: () => boolean;
187
204
  };
188
205
  //#endregion
189
- export { Capture, CapturedHandler, CapturedMirror, CapturedValidator, CheckBuildResult, Compiled, EMPTY_EXTERNALS, FrozenBothFactory, FrozenCheckFactory, FrozenHandler, FrozenMirror, FrozenMirrorFactory, FrozenValidator, HandlerManifest, Source, ValidatorManifest, ValidatorSlot, beginValidatorCapture, collectExternals, endHandlerCapture, endValidatorCapture, externalsMatch, instantiateFrozenBoth, instantiateFrozenDecodeMirror, instantiateFrozenEncodeMirror, instantiateFrozenMirror, reconstructCheck };
206
+ export { Capture, CapturedHandler, CapturedMirror, CapturedValidator, CheckBuildResult, Compiled, CompiledSnapshot, EMPTY_EXTERNALS, FrozenBothFactory, FrozenCheckFactory, FrozenHandler, FrozenMirror, FrozenMirrorFactory, FrozenValidator, HandlerManifest, Source, ValidatorManifest, ValidatorSlot, beginValidatorCapture, collectExternals, endHandlerCapture, endValidatorCapture, externalsMatch, instantiateFrozenBoth, instantiateFrozenDecodeMirror, instantiateFrozenEncodeMirror, instantiateFrozenMirror, reconstructCheck };
@@ -48,6 +48,25 @@ var Compiled = class {
48
48
  static hasValidator(method, path, slot) {
49
49
  return validators?.[method]?.[path]?.[slot] !== void 0 || lazyGroupOf?.[method]?.[path] !== void 0;
50
50
  }
51
+ /** @internal preserve registry around in-process AOT analysis */
52
+ static snapshot() {
53
+ return {
54
+ validators,
55
+ handlers,
56
+ lazyGroups,
57
+ lazyGroupOf,
58
+ builtGroups: [...builtGroups]
59
+ };
60
+ }
61
+ /** @internal restore registry after in-process AOT analysis */
62
+ static restore(snapshot) {
63
+ validators = snapshot.validators;
64
+ handlers = snapshot.handlers;
65
+ lazyGroups = snapshot.lazyGroups;
66
+ lazyGroupOf = snapshot.lazyGroupOf;
67
+ builtGroups.clear();
68
+ for (const group of snapshot.builtGroups) builtGroups.add(group);
69
+ }
51
70
  /** @internal test isolation */
52
71
  static clear() {
53
72
  validators = void 0;
@@ -47,6 +47,25 @@ var Compiled = class {
47
47
  static hasValidator(method, path, slot) {
48
48
  return validators?.[method]?.[path]?.[slot] !== void 0 || lazyGroupOf?.[method]?.[path] !== void 0;
49
49
  }
50
+ /** @internal preserve registry around in-process AOT analysis */
51
+ static snapshot() {
52
+ return {
53
+ validators,
54
+ handlers,
55
+ lazyGroups,
56
+ lazyGroupOf,
57
+ builtGroups: [...builtGroups]
58
+ };
59
+ }
60
+ /** @internal restore registry after in-process AOT analysis */
61
+ static restore(snapshot) {
62
+ validators = snapshot.validators;
63
+ handlers = snapshot.handlers;
64
+ lazyGroups = snapshot.lazyGroups;
65
+ lazyGroupOf = snapshot.lazyGroupOf;
66
+ builtGroups.clear();
67
+ for (const group of snapshot.builtGroups) builtGroups.add(group);
68
+ }
50
69
  /** @internal test isolation */
51
70
  static clear() {
52
71
  validators = void 0;
@@ -1,9 +1,9 @@
1
1
  import { AnyLocalHook, CompiledHandler, InternalRoute } from "../../types.js";
2
2
  import { ChainNode } from "../../utils.js";
3
3
  import { AnyElysia } from "../../base.js";
4
+ import { setCaptureHeaderShorthand } from "./jit.js";
4
5
 
5
6
  //#region src/compile/handler/index.d.ts
6
- declare const setCaptureHeaderShorthand: (value: boolean | undefined) => void;
7
7
  declare function buildNativeStaticResponse([,, handler, instance, localHook, appHook, inheritedChain]: InternalRoute, root: AnyElysia): Response | Promise<Response> | undefined;
8
8
  declare function composeRouteHook(instance: AnyElysia, localHook: Partial<AnyLocalHook> | undefined, appHook: ChainNode | undefined, inheritedChain: ChainNode | undefined, root: AnyElysia): AnyLocalHook | undefined;
9
9
  declare function compileHandler([_method, path, handler, instance, localHook, appHook, inheritedChain]: InternalRoute, root: AnyElysia, precomputedStatic?: Response): CompiledHandler;