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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/adapter/bun/index.js +36 -21
  2. package/dist/adapter/bun/index.mjs +36 -21
  3. package/dist/adapter/utils.js +1 -0
  4. package/dist/adapter/utils.mjs +1 -0
  5. package/dist/adapter/web-standard/handler.js +8 -2
  6. package/dist/adapter/web-standard/handler.mjs +8 -2
  7. package/dist/base.d.ts +5 -0
  8. package/dist/base.js +109 -4
  9. package/dist/base.mjs +111 -6
  10. package/dist/compile/aot-capture.d.ts +2 -13
  11. package/dist/compile/aot-capture.js +5 -27
  12. package/dist/compile/aot-capture.mjs +6 -24
  13. package/dist/compile/aot-emit.js +1 -1
  14. package/dist/compile/aot-emit.mjs +1 -1
  15. package/dist/compile/aot.d.ts +1 -1
  16. package/dist/compile/aot.js +2 -2
  17. package/dist/compile/aot.mjs +2 -2
  18. package/dist/compile/handler/descriptor.d.ts +4 -8
  19. package/dist/compile/handler/descriptor.js +8 -21
  20. package/dist/compile/handler/descriptor.mjs +9 -21
  21. package/dist/compile/handler/index.d.ts +4 -3
  22. package/dist/compile/handler/index.js +16 -6
  23. package/dist/compile/handler/index.mjs +16 -7
  24. package/dist/compile/handler/jit.js +82 -76
  25. package/dist/compile/handler/jit.mjs +83 -77
  26. package/dist/compile/handler/params.d.ts +1 -4
  27. package/dist/compile/handler/params.js +3 -4
  28. package/dist/compile/handler/params.mjs +5 -5
  29. package/dist/compile/handler/reconstruct.d.ts +1 -1
  30. package/dist/compile/handler/static-clone-resolver.d.ts +6 -0
  31. package/dist/compile/handler/static-clone-resolver.js +8 -0
  32. package/dist/compile/handler/static-clone-resolver.mjs +7 -0
  33. package/dist/compile/handler/utils.d.ts +7 -7
  34. package/dist/compile/handler/utils.js +24 -20
  35. package/dist/compile/handler/utils.mjs +24 -20
  36. package/dist/compile/utils.js +7 -4
  37. package/dist/compile/utils.mjs +7 -4
  38. package/dist/context.js +3 -21
  39. package/dist/context.mjs +4 -22
  40. package/dist/cookie/index.d.ts +1 -2
  41. package/dist/cookie/index.js +0 -2
  42. package/dist/cookie/index.mjs +1 -2
  43. package/dist/cookie/lib.js +2 -1
  44. package/dist/cookie/lib.mjs +2 -1
  45. package/dist/cookie/utils.d.ts +3 -7
  46. package/dist/cookie/utils.js +9 -28
  47. package/dist/cookie/utils.mjs +11 -29
  48. package/dist/error.d.ts +40 -83
  49. package/dist/error.js +18 -19
  50. package/dist/error.mjs +18 -20
  51. package/dist/handler/error.js +4 -5
  52. package/dist/handler/error.mjs +4 -5
  53. package/dist/handler/fetch.js +31 -17
  54. package/dist/handler/fetch.mjs +32 -18
  55. package/dist/handler/utils.d.ts +3 -3
  56. package/dist/handler/utils.js +28 -17
  57. package/dist/handler/utils.mjs +28 -17
  58. package/dist/index.d.ts +3 -3
  59. package/dist/package.js +1 -1
  60. package/dist/package.mjs +1 -1
  61. package/dist/plugin/aot/core.d.ts +3 -7
  62. package/dist/plugin/aot/core.js +8 -18
  63. package/dist/plugin/aot/core.mjs +9 -17
  64. package/dist/plugin/aot/hooks.js +5 -1
  65. package/dist/plugin/aot/hooks.mjs +5 -1
  66. package/dist/trace.js +23 -10
  67. package/dist/trace.mjs +23 -10
  68. package/dist/type/bridge-live.d.ts +3 -2
  69. package/dist/type/bridge-live.js +4 -2
  70. package/dist/type/bridge-live.mjs +3 -2
  71. package/dist/type/bridge.d.ts +6 -4
  72. package/dist/type/bridge.js +9 -1
  73. package/dist/type/bridge.mjs +3 -1
  74. package/dist/type/coerce-plan.d.ts +2 -2
  75. package/dist/type/coerce-plan.js +0 -1
  76. package/dist/type/coerce-plan.mjs +2 -2
  77. package/dist/type/compat.js +2 -1
  78. package/dist/type/compat.mjs +3 -2
  79. package/dist/type/constants.d.ts +1 -1
  80. package/dist/type/shared.d.ts +1 -3
  81. package/dist/type/shared.js +0 -3
  82. package/dist/type/shared.mjs +1 -3
  83. package/dist/type/typebox-value-live.d.ts +4 -3
  84. package/dist/type/typebox-value-live.js +5 -3
  85. package/dist/type/typebox-value-live.mjs +4 -3
  86. package/dist/type/typebox-value.d.ts +11 -7
  87. package/dist/type/typebox-value.js +2 -1
  88. package/dist/type/typebox-value.mjs +1 -1
  89. package/dist/type/validator/index.d.ts +1 -1
  90. package/dist/type/validator/validator-cache.d.ts +1 -1
  91. package/dist/types.d.ts +10 -17
  92. package/dist/universal/file.d.ts +1 -3
  93. package/dist/universal/file.js +0 -2
  94. package/dist/universal/file.mjs +1 -2
  95. package/dist/universal/is-production.d.ts +1 -2
  96. package/dist/universal/is-production.js +1 -3
  97. package/dist/universal/is-production.mjs +2 -3
  98. package/dist/utils.d.ts +0 -1
  99. package/package.json +13 -6
@@ -2,7 +2,7 @@ import { authorityEnd, flattenChain, isNotEmpty, nullObject, requestId } from ".
2
2
  import { isProduction } from "../universal/is-production.mjs";
3
3
  import { NotFound, PROBLEM_JSON, internalServerErrorResponse } from "../error.mjs";
4
4
  import { handleSet, materializeSetHeaders } from "../adapter/utils.mjs";
5
- import { NOT_FOUND_BODY, emptyResponse, getAsyncIndexes, getNotFound } from "./utils.mjs";
5
+ import { emptyResponse, getAsyncIndexes, getNotFound, getNotFoundBody } from "./utils.mjs";
6
6
  import { createErrorHandler } from "./error.mjs";
7
7
  import { origin } from "../adapter/origin.mjs";
8
8
  import { defaultAdapter } from "../adapter/constants.mjs";
@@ -20,7 +20,7 @@ function notFound(context) {
20
20
  if (set.cookie || isNotEmpty(set.headers)) {
21
21
  handleSet(set);
22
22
  if (!set.headers["content-type"]) materializeSetHeaders(set)["content-type"] = PROBLEM_JSON;
23
- return new Response(NOT_FOUND_BODY, {
23
+ return new Response(getNotFoundBody(), {
24
24
  status: 404,
25
25
  headers: set.headers
26
26
  });
@@ -35,6 +35,12 @@ function decodeParams(params) {
35
35
  return params;
36
36
  }
37
37
  const notFoundBody = Object.freeze({ code: "NOT_FOUND" });
38
+ const warnedPathMutation = /* @__PURE__ */ new WeakSet();
39
+ function warnPathMutation(app) {
40
+ if (warnedPathMutation.has(app)) return;
41
+ warnedPathMutation.add(app);
42
+ console.warn("[elysia] context.path is readonly; request-hook rerouting will stop working in a future release.");
43
+ }
38
44
  function finalizeError(context, handleError, afterResponse, error) {
39
45
  if (error === notFoundBody) error = new NotFound();
40
46
  let resp;
@@ -111,6 +117,7 @@ function createFetchHandler(app) {
111
117
  const hook = flattenChain(app["~hookChain"]);
112
118
  const hasError = !!hook?.error;
113
119
  const abortSignal = app["~config"]?.abortSignal !== false;
120
+ const watchPath = !isProduction();
114
121
  /**
115
122
  * Arm `context['~sig']` unless this request is provably the untouched
116
123
  * `Request` the Bun adapter received, in which case materializing
@@ -126,11 +133,10 @@ function createFetchHandler(app) {
126
133
  return (context["~sig"] = request.signal).aborted;
127
134
  };
128
135
  /**
129
- * Post-suspension check: arm if nobody has yet, then read. Only emitted on
130
- * lanes that actually awaited, so a deferred request that never suspends
131
- * never reaches it.
136
+ * Peek after each callback. The actual await branch arms deferred requests;
137
+ * immediate callbacks must not materialize a signal just for this check.
132
138
  */
133
- const armedAbort = (request, context) => abortSignal && (context["~sig"] ??= request.signal).aborted === true;
139
+ const armedAbort = (context) => abortSignal && context["~sig"]?.aborted === true;
134
140
  const baseMapResponse = (app["~config"]?.adapter ?? defaultAdapter).response.map;
135
141
  const mapResponseHooks = hook?.mapResponse;
136
142
  const mapResponse = mapResponseHooks?.length ? (response, set, context) => {
@@ -140,7 +146,7 @@ function createFetchHandler(app) {
140
146
  const run = (i) => {
141
147
  for (; i < mapResponseHooks.length; i++) {
142
148
  const result = mapResponseHooks[i](context);
143
- if (result instanceof Promise) return result.then((resolved) => {
149
+ if (typeof result?.then === "function") return Promise.resolve(result).then((resolved) => {
144
150
  if (resolved !== void 0) return baseMapResponse(resolved, set, request, true);
145
151
  return run(i + 1);
146
152
  });
@@ -208,12 +214,11 @@ function createFetchHandler(app) {
208
214
  app["~finalizeError"] = (context, error) => finalizeError(context, handleError, afterResponse, error);
209
215
  if (traceRequestPhase) {
210
216
  const onRequests = hook?.request ?? [];
211
- const asyncIndexes = onRequests.length ? getAsyncIndexes(onRequests) : void 0;
212
217
  return async (request, server) => {
213
218
  const context = new Context(request);
214
219
  materializeSetHeaders(context.set);
215
220
  if (armEager(request, context)) return emptyResponse.clone();
216
- extractPath(request.url, context);
221
+ const path = extractPath(request.url, context);
217
222
  context.server = server ?? null;
218
223
  context.rid = requestId();
219
224
  const traceLength = tracerFactories.length;
@@ -237,9 +242,14 @@ function createFetchHandler(app) {
237
242
  name: onRequests[i].name || "anonymous",
238
243
  begin: performance.now()
239
244
  });
240
- const result = asyncIndexes?.[i] ? await onRequests[i](context) : onRequests[i](context);
245
+ let result = onRequests[i](context);
246
+ if (typeof result?.then === "function") {
247
+ if (abortSignal) context["~sig"] ??= request.signal;
248
+ result = await result;
249
+ }
250
+ if (watchPath && context.path !== path) warnPathMutation(app);
241
251
  for (let i = 0; i < traceLength; i++) endReports[i]?.();
242
- if (armedAbort(request, context)) {
252
+ if (armedAbort(context)) {
243
253
  for (let j = 0; j < traceLength; j++) trace[j].r(requestReports[j]);
244
254
  return emptyResponse.clone();
245
255
  }
@@ -260,18 +270,21 @@ function createFetchHandler(app) {
260
270
  }
261
271
  if (hook?.request) {
262
272
  const onRequests = hook.request;
263
- const asyncIndexes = getAsyncIndexes(onRequests);
264
- if (asyncIndexes) return async (request, server) => {
273
+ if (getAsyncIndexes(onRequests)) return async (request, server) => {
265
274
  const context = new Context(request);
266
275
  materializeSetHeaders(context.set);
267
276
  if (armEager(request, context)) return emptyResponse.clone();
268
- extractPath(request.url, context);
277
+ const path = extractPath(request.url, context);
269
278
  context.server = server ?? null;
270
279
  try {
271
280
  for (let i = 0; i < onRequests.length; i++) {
272
- let result = asyncIndexes?.[i] ? await onRequests[i](context) : onRequests[i](context);
273
- if (result instanceof Promise) result = await result;
274
- if (armedAbort(request, context)) return emptyResponse.clone();
281
+ let result = onRequests[i](context);
282
+ if (typeof result?.then === "function") {
283
+ if (abortSignal) context["~sig"] ??= request.signal;
284
+ result = await result;
285
+ }
286
+ if (watchPath && context.path !== path) warnPathMutation(app);
287
+ if (armedAbort(context)) return emptyResponse.clone();
275
288
  if (result !== void 0) {
276
289
  const response = await mapResponse(result, context.set, context);
277
290
  afterResponse?.(context);
@@ -287,11 +300,12 @@ function createFetchHandler(app) {
287
300
  const context = new Context(request);
288
301
  materializeSetHeaders(context.set);
289
302
  if (armEager(request, context)) return emptyResponse.clone();
290
- extractPath(request.url, context);
303
+ const path = extractPath(request.url, context);
291
304
  context.server = server ?? null;
292
305
  try {
293
306
  for (let i = 0; i < onRequests.length; i++) {
294
307
  const result = onRequests[i](context);
308
+ if (watchPath && context.path !== path) warnPathMutation(app);
295
309
  if (abortSignal && context["~sig"]?.aborted) return emptyResponse.clone();
296
310
  if (result !== void 0) {
297
311
  const response = mapResponse(result, context.set, context);
@@ -6,10 +6,10 @@ import { AnyElysia } from "../base.js";
6
6
  declare const emptyResponse: Response | {
7
7
  clone: () => Response;
8
8
  };
9
- declare const NOT_FOUND_BODY: string;
10
- declare const getNotFound: () => Response;
9
+ declare function getNotFoundBody(): string;
10
+ declare function getNotFound(): Response;
11
11
  declare function forwardError<T>(value: T): T;
12
12
  declare function finalizeRouteError(app: AnyElysia, context: Partial<Context>, error: unknown): MaybePromise<Response>;
13
13
  declare function getAsyncIndexes(onRequests: Function[]): (true | undefined)[] | undefined;
14
14
  //#endregion
15
- export { NOT_FOUND_BODY, emptyResponse, finalizeRouteError, forwardError, getAsyncIndexes, getNotFound };
15
+ export { emptyResponse, finalizeRouteError, forwardError, getAsyncIndexes, getNotFound, getNotFoundBody };
@@ -7,23 +7,34 @@ const require_compile_utils = require('../compile/utils.js');
7
7
  //#region src/handler/utils.ts
8
8
  const isPreallocateResponseUnsafe = require_universal_constants.isCloudflareWorker || require_universal_constants.isFastly || require_universal_env.env.ELYSIA_PREALLOCATE_RESPONSE === "false";
9
9
  const emptyResponse = isPreallocateResponseUnsafe ? { clone: () => new Response(null) } : new Response(null);
10
- function cachedResponse(body, status, headers) {
11
- let cached;
12
- return () => isPreallocateResponseUnsafe ? new Response(body, {
13
- status,
14
- headers
15
- }) : (cached ??= new Response(body, {
16
- status,
17
- headers
10
+ let notFoundBase;
11
+ let notFoundBody;
12
+ let notFoundResponse;
13
+ function getNotFoundBody() {
14
+ const base = require_error.HTTPError.typeBase;
15
+ if (notFoundBody === void 0 || base !== notFoundBase) {
16
+ notFoundBase = base;
17
+ notFoundResponse = void 0;
18
+ notFoundBody = JSON.stringify({
19
+ type: require_error.problemTypeOf("not-found"),
20
+ code: "not-found",
21
+ status: 404,
22
+ title: "Not Found"
23
+ });
24
+ }
25
+ return notFoundBody;
26
+ }
27
+ function getNotFound() {
28
+ const body = getNotFoundBody();
29
+ if (isPreallocateResponseUnsafe) return new Response(body, {
30
+ status: 404,
31
+ headers: { "content-type": require_error.PROBLEM_JSON }
32
+ });
33
+ return (notFoundResponse ??= new Response(body, {
34
+ status: 404,
35
+ headers: { "content-type": require_error.PROBLEM_JSON }
18
36
  })).clone();
19
37
  }
20
- const NOT_FOUND_BODY = JSON.stringify({
21
- type: "not-found",
22
- code: "not-found",
23
- status: 404,
24
- title: "Not Found"
25
- });
26
- const getNotFound = cachedResponse(NOT_FOUND_BODY, 404, { "content-type": require_error.PROBLEM_JSON });
27
38
  function forwardError(value) {
28
39
  if (value instanceof Error) throw value;
29
40
  return value;
@@ -43,9 +54,9 @@ function getAsyncIndexes(onRequests) {
43
54
  }
44
55
 
45
56
  //#endregion
46
- exports.NOT_FOUND_BODY = NOT_FOUND_BODY;
47
57
  exports.emptyResponse = emptyResponse;
48
58
  exports.finalizeRouteError = finalizeRouteError;
49
59
  exports.forwardError = forwardError;
50
60
  exports.getAsyncIndexes = getAsyncIndexes;
51
- exports.getNotFound = getNotFound;
61
+ exports.getNotFound = getNotFound;
62
+ exports.getNotFoundBody = getNotFoundBody;
@@ -1,28 +1,39 @@
1
1
  import { isCloudflareWorker, isFastly } from "../universal/constants.mjs";
2
2
  import { env } from "../universal/env.mjs";
3
- import { PROBLEM_JSON } from "../error.mjs";
3
+ import { HTTPError, PROBLEM_JSON, problemTypeOf } from "../error.mjs";
4
4
  import { isAsyncFunction, mayReturnPromise } from "../compile/utils.mjs";
5
5
 
6
6
  //#region src/handler/utils.ts
7
7
  const isPreallocateResponseUnsafe = isCloudflareWorker || isFastly || env.ELYSIA_PREALLOCATE_RESPONSE === "false";
8
8
  const emptyResponse = isPreallocateResponseUnsafe ? { clone: () => new Response(null) } : new Response(null);
9
- function cachedResponse(body, status, headers) {
10
- let cached;
11
- return () => isPreallocateResponseUnsafe ? new Response(body, {
12
- status,
13
- headers
14
- }) : (cached ??= new Response(body, {
15
- status,
16
- headers
9
+ let notFoundBase;
10
+ let notFoundBody;
11
+ let notFoundResponse;
12
+ function getNotFoundBody() {
13
+ const base = HTTPError.typeBase;
14
+ if (notFoundBody === void 0 || base !== notFoundBase) {
15
+ notFoundBase = base;
16
+ notFoundResponse = void 0;
17
+ notFoundBody = JSON.stringify({
18
+ type: problemTypeOf("not-found"),
19
+ code: "not-found",
20
+ status: 404,
21
+ title: "Not Found"
22
+ });
23
+ }
24
+ return notFoundBody;
25
+ }
26
+ function getNotFound() {
27
+ const body = getNotFoundBody();
28
+ if (isPreallocateResponseUnsafe) return new Response(body, {
29
+ status: 404,
30
+ headers: { "content-type": PROBLEM_JSON }
31
+ });
32
+ return (notFoundResponse ??= new Response(body, {
33
+ status: 404,
34
+ headers: { "content-type": PROBLEM_JSON }
17
35
  })).clone();
18
36
  }
19
- const NOT_FOUND_BODY = JSON.stringify({
20
- type: "not-found",
21
- code: "not-found",
22
- status: 404,
23
- title: "Not Found"
24
- });
25
- const getNotFound = cachedResponse(NOT_FOUND_BODY, 404, { "content-type": PROBLEM_JSON });
26
37
  function forwardError(value) {
27
38
  if (value instanceof Error) throw value;
28
39
  return value;
@@ -42,4 +53,4 @@ function getAsyncIndexes(onRequests) {
42
53
  }
43
54
 
44
55
  //#endregion
45
- export { NOT_FOUND_BODY, emptyResponse, finalizeRouteError, forwardError, getAsyncIndexes, getNotFound };
56
+ export { emptyResponse, finalizeRouteError, forwardError, getAsyncIndexes, getNotFound, getNotFoundBody };
package/dist/index.d.ts CHANGED
@@ -5,8 +5,8 @@ import { StatusMap, StatusMapBack } from "./constants.js";
5
5
  import { env } from "./universal/env.js";
6
6
  import { Server } from "./universal/server.js";
7
7
  import { bytes, form, prefix, redirect, sse } from "./utils.js";
8
- import { HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, MacroTypeLambda, RouteSchema, SSEPayload, UnwrapRoute, UnwrapSchema } from "./types.js";
9
- import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, ParseError, Problem, SelectiveStatus, TaggedHTTPError, ValidationError, problem, status, validationDetail } from "./error.js";
8
+ import { DefaultEphemeral, DefaultMetadata, DefaultSingleton, HTTPHeaders, InputSchema, Macro, MacroToContext, MacroToProperty, MacroTypeLambda, RouteSchema, SSEPayload, UnwrapRoute, UnwrapSchema } from "./types.js";
9
+ import { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, NotFound, NumericStatus, ParseError, Problem, SelectiveStatus, StatusResponse, TaggedHTTPError, ValidationError, ValidationErrorResponse, problem, status, validationDetail } from "./error.js";
10
10
  import { Context, ErrorContext, createBaseContext, createContext } from "./context.js";
11
11
  import { InvalidCookie } from "./cookie/error.js";
12
12
  import { AnySchema, BaseSchema, StandardJSONSchemaV1Like, StandardSchemaV1Like } from "./type/types.js";
@@ -20,4 +20,4 @@ import { TypeSystem, t } from "./type/index.js";
20
20
  import { AotFingerprint, Capture, Compiled, CompilerSession, ProgramId } from "./compile/aot.js";
21
21
  import { AnyElysia, Elysia } from "./base.js";
22
22
  import { borrow } from "./adapter/response-ownership.js";
23
- export { AnyElysia, type AnySchema, type AotFingerprint, type BaseCookie, type BaseSchema, Compiled, type CompilerSession, type Context, type Cookie, type CookieOptions, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, HTTPError, type HTTPHeaders, type InputSchema, InternalServerError, InvalidCookie, type Macro, type MacroToContext, type MacroToProperty, type MacroTypeLambda, Capture as Manifest, MultiValidator, NotFound, ParseError, type Problem, type ProgramId, type RouteSchema, type SSEPayload, type SelectiveStatus, type Server, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type TCookieField, type TCookieObject, type TFiles, type TaggedHTTPError, TypeBoxValidator, TypeSystem, type UnwrapRoute, type UnwrapSchema, ValidationError, Validator, borrow, bytes, createBaseContext, createContext, env, file, fileType, form, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
23
+ export { AnyElysia, type AnySchema, type AotFingerprint, type BaseCookie, type BaseSchema, Compiled, type CompilerSession, type Context, type Cookie, type CookieOptions, type DefaultEphemeral, type DefaultMetadata, type DefaultSingleton, Elysia, Elysia as default, ElysiaError, ElysiaFile, ElysiaStatus, type ErrorContext, type FileTypeDetector, HTTPError, type HTTPHeaders, type InputSchema, InternalServerError, InvalidCookie, type Macro, type MacroToContext, type MacroToProperty, type MacroTypeLambda, Capture as Manifest, MultiValidator, NotFound, type NumericStatus, ParseError, type Problem, type ProgramId, type RouteSchema, type SSEPayload, type SelectiveStatus, type Server, type StandardJSONSchemaV1Like, type StandardSchemaV1Like, StandardValidator, StatusMap, StatusMapBack, type StatusResponse, type TCookieField, type TCookieObject, type TFiles, type TaggedHTTPError, TypeBoxValidator, TypeSystem, type UnwrapRoute, type UnwrapSchema, ValidationError, type ValidationErrorResponse, Validator, borrow, bytes, createBaseContext, createContext, env, file, fileType, form, prefix, problem, redirect, setFileTypeDetector, setupTypebox, sse, status, t, validationDetail };
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.0.0-beta.11";
3
+ var version = "2.0.0-beta.13";
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-beta.11";
2
+ var version = "2.0.0-beta.13";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -100,6 +100,8 @@ declare const resolveEntryModuleKind: (entry: string) => "cjs" | "esm";
100
100
  interface StubPlan {
101
101
  /** Stub the internal handler codegen module. */
102
102
  jit: boolean;
103
+ /** Omit the static-clone resolver when no captured handler aliases scl. */
104
+ staticClone: boolean;
103
105
  /** Stub internal WS route builders when the app declares no WS routes. */
104
106
  ws: boolean;
105
107
  /**
@@ -249,7 +251,6 @@ declare const ELYSIA_MODULE_FILTER: RegExp;
249
251
  declare function resolveElysiaRoot(from?: string): string;
250
252
  declare function resolveExactMirror(from?: string): boolean;
251
253
  declare function makeIsElysiaModule(elysiaRoot: string): (path: string) => boolean;
252
- declare function makeElysiaModuleFilterRegex(elysiaRoot: string): RegExp;
253
254
  declare const rewriteIsProductionCalls: (code: string) => string;
254
255
  declare const bunAdapterStubSource: string;
255
256
  declare const STUB_SOURCES: Record<Exclude<keyof StubPlan, 'adapter' | 'isProduction'>, Array<{
@@ -275,11 +276,6 @@ interface CompiledArtifacts {
275
276
  */
276
277
  virtualType?: string;
277
278
  }
278
- /** @internal Test diagnostic for deterministic worker cleanup. */
279
- declare const getAotWorkerDiagnostics: () => {
280
- activeWorkers: number;
281
- lastExit: Promise<number> | undefined;
282
- };
283
279
  /**
284
280
  * Extension mirroring the running module's own build output, so a sibling
285
281
  * source file can be resolved from `import.meta.url` in `.mjs`/`.js`/`.ts`
@@ -295,4 +291,4 @@ declare function generateCompiledArtifacts(file: string, options?: ElysiaAotOpti
295
291
  declare const SOURCE_REGEX: RegExp;
296
292
  declare const realPath: (path: string) => string;
297
293
  //#endregion
298
- export { ADAPTER_BUN_FILTER, ADAPTER_CONSTANTS_FILTER, BridgeMode, CompiledArtifacts, ELYSIA_MODULE_FILTER, ElysiaAotOptions, IS_PRODUCTION_FILTER, NO_STUB, OVERRIDE_MAP, SOURCE_REGEX, STUB_SOURCES, StubPlan, adapterConstantsSource, alignStubExtensions, bunAdapterStubSource, generateCompiledArtifacts, generateCompiledArtifactsIsolated, generateVirtualType, getAotWorkerDiagnostics, makeElysiaModuleFilterRegex, makeIsElysiaModule, planFromReport, realPath, resolveElysiaRoot, resolveEntry, resolveEntryModuleKind, resolveExactMirror, rewriteIsProductionCalls, siblingModuleExt, validatorSlotSetsMatch };
294
+ export { ADAPTER_BUN_FILTER, ADAPTER_CONSTANTS_FILTER, BridgeMode, CompiledArtifacts, ELYSIA_MODULE_FILTER, ElysiaAotOptions, IS_PRODUCTION_FILTER, NO_STUB, OVERRIDE_MAP, SOURCE_REGEX, STUB_SOURCES, StubPlan, adapterConstantsSource, alignStubExtensions, bunAdapterStubSource, generateCompiledArtifacts, generateCompiledArtifactsIsolated, generateVirtualType, makeIsElysiaModule, planFromReport, realPath, resolveElysiaRoot, resolveEntry, resolveEntryModuleKind, resolveExactMirror, rewriteIsProductionCalls, siblingModuleExt, validatorSlotSetsMatch };
@@ -44,6 +44,7 @@ const resolveEntryModuleKind = (entry) => {
44
44
  };
45
45
  const NO_STUB = {
46
46
  jit: false,
47
+ staticClone: false,
47
48
  ws: false,
48
49
  reconstruct: false,
49
50
  cookie: false,
@@ -81,6 +82,7 @@ function planFromReport(strip, report, hasWS, mayTrace, aliases, allBridgeFree,
81
82
  return {
82
83
  plan: {
83
84
  jit,
85
+ staticClone: jit && !aliases.has("scl"),
84
86
  ws: !hasWS,
85
87
  reconstruct: jit && !aliases.has("va") && !aliases.has("cc") && !aliases.has("tr"),
86
88
  cookie: jit && !aliases.has("cc") && !wsCookie,
@@ -126,19 +128,19 @@ function makeIsElysiaModule(elysiaRoot) {
126
128
  return path.replace(/\\/g, "/").startsWith(root + "/") && ELYSIA_MODULE_FILTER.test(path);
127
129
  };
128
130
  }
129
- function makeElysiaModuleFilterRegex(elysiaRoot) {
130
- const escaped = elysiaRoot.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
131
- return new RegExp("^" + escaped + "[\\\\/](dist|src)[\\\\/].+\\.(m?js|ts)x?$");
132
- }
133
131
  const rewriteIsProductionCalls = (code) => code.replace(/(?<![.?])\bisProduction\(\)/g, "true");
134
132
  const bunAdapterStubSource = "const e=(t)=>{throw new Error(`[elysia-aot] Bun adapter was stripped for target 'web-standard' .listen() is unavailable; use the exported fetch handler or rebuild with a different target.`)}\nexport const BunAdapter={name:'bun',runtime:'bun',isWebStandard:true,parse:{},response:{},listen:e}\nexport function collectStaticRoutes(){}\n";
135
133
  const STUB_SOURCES = {
134
+ staticClone: [{
135
+ filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]static-clone-resolver\.(m?js|ts)$/,
136
+ source: `export const staticCloneResolver = undefined\n`
137
+ }],
136
138
  jit: [{
137
139
  filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]jit\.(m?js|ts)$/,
138
140
  source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function compileHandlerJit(){return e()}\nexport function createInlineHandler(){return e()}\nexport function setCaptureHeaderShorthand(){}\n"
139
141
  }, {
140
142
  filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]descriptor\.(m?js|ts)$/,
141
- source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function describeRoute(){return e()}\nexport const routeDescriptors=new WeakMap()\nexport function isEmptyPipelineHook(hook){\n if(!hook)return true\n for(const key in hook){\n if(key==='detail'||key==='tags')continue\n const value=hook[key]\n if(value!==undefined&&value!==false&&(!Array.isArray(value)||value.length))return false\n }\n return true\n}\n"
143
+ source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function describeRoute(){return e()}\nexport const routeDescriptors=new WeakMap()\nexport function isEmptyPipelineHook(hook){\n if(!hook)return true\n for(const key in hook){\n if(key==='detail'||key==='tags'||key==='error')continue\n const value=hook[key]\n if(value!==undefined&&value!==false&&(!Array.isArray(value)||value.length))return false\n }\n return true\n}\n"
142
144
  }],
143
145
  ws: [{
144
146
  filter: /[\\/]elysia[\\/](dist|src)[\\/]ws[\\/]route\.(m?js|ts)$/,
@@ -150,7 +152,7 @@ const STUB_SOURCES = {
150
152
  }],
151
153
  cookie: [{
152
154
  filter: /[\\/]elysia[\\/](dist|src)[\\/]cookie[\\/]utils\.(m?js|ts)$/,
153
- source: "const e=()=>{throw new Error(\"[elysia-aot] cookie support was stripped (strip mode) but a route used cookies. Rebuild with strip:false.\")}\nexport const hasSyncHmac=false\nexport function parseCookie(){return e()}\nexport function parseCookieRaw(){return e()}\nexport function parseCookieRawSync(){return e()}\nexport function parseCookieRawSigned(){return e()}\nexport function parseCookieRawLazy(){return e()}\nexport function parseCookieRawDeferred(){return e()}\nexport function buildCookieJar(){return e()}\nexport function signCookieValues(){return e()}\nexport function signCookie(){return e()}\nexport function signCookieSubtle(){return e()}\nexport function signCookieSync(){return e()}\nexport function unsignCookie(){return e()}\nexport function unsignCookieSync(){return e()}\n"
155
+ source: "const e=()=>{throw new Error(\"[elysia-aot] cookie support was stripped (strip mode) but a route used cookies. Rebuild with strip:false.\")}\nexport const hasSyncHmac=false\nexport function parseCookieRaw(){return e()}\nexport function parseCookieRawSync(){return e()}\nexport function parseCookieRawSigned(){return e()}\nexport function parseCookieRawLazy(){return e()}\nexport function parseCookieRawDeferred(){return e()}\nexport function buildCookieJar(){return e()}\nexport function signCookieValues(){return e()}\nexport function signCookie(){return e()}\nexport function signCookieSubtle(){return e()}\nexport function signCookieSync(){return e()}\nexport function unsignCookie(){return e()}\nexport function unsignCookieSync(){return e()}\n"
154
156
  }, {
155
157
  filter: /[\\/]elysia[\\/](dist|src)[\\/]cookie[\\/]config\.(m?js|ts)$/,
156
158
  source: "const e=()=>{throw new Error(\"[elysia-aot] cookie support was stripped (strip mode) but a route used cookies. Rebuild with strip:false.\")}\nexport function compileCookieConfig(){return e()}\nexport function isCookieSigned(){return e()}\n"
@@ -332,13 +334,6 @@ async function generateVirtualType(typeSpecifier = "elysia/type", moduleConditio
332
334
  return source;
333
335
  }
334
336
  const _importedEntries = /* @__PURE__ */ new Set();
335
- let activeGenerationWorkers = 0;
336
- let lastGenerationWorkerExit;
337
- /** @internal Test diagnostic for deterministic worker cleanup. */
338
- const getAotWorkerDiagnostics = () => ({
339
- activeWorkers: activeGenerationWorkers,
340
- lastExit: lastGenerationWorkerExit
341
- });
342
337
  /**
343
338
  * Extension mirroring the running module's own build output, so a sibling
344
339
  * source file can be resolved from `import.meta.url` in `.mjs`/`.js`/`.ts`
@@ -360,9 +355,7 @@ async function generateCompiledArtifactsIsolated(file, options, moduleCondition
360
355
  options,
361
356
  moduleCondition
362
357
  } });
363
- activeGenerationWorkers++;
364
358
  const exit = new Promise((resolve) => worker.once("exit", resolve));
365
- lastGenerationWorkerExit = exit;
366
359
  try {
367
360
  return await new Promise((resolve, reject) => {
368
361
  let received = false;
@@ -384,7 +377,6 @@ async function generateCompiledArtifactsIsolated(file, options, moduleCondition
384
377
  await worker.terminate();
385
378
  } finally {
386
379
  await exit;
387
- activeGenerationWorkers--;
388
380
  }
389
381
  }
390
382
  }
@@ -553,8 +545,6 @@ exports.bunAdapterStubSource = bunAdapterStubSource;
553
545
  exports.generateCompiledArtifacts = generateCompiledArtifacts;
554
546
  exports.generateCompiledArtifactsIsolated = generateCompiledArtifactsIsolated;
555
547
  exports.generateVirtualType = generateVirtualType;
556
- exports.getAotWorkerDiagnostics = getAotWorkerDiagnostics;
557
- exports.makeElysiaModuleFilterRegex = makeElysiaModuleFilterRegex;
558
548
  exports.makeIsElysiaModule = makeIsElysiaModule;
559
549
  exports.planFromReport = planFromReport;
560
550
  exports.realPath = realPath;
@@ -42,6 +42,7 @@ const resolveEntryModuleKind = (entry) => {
42
42
  };
43
43
  const NO_STUB = {
44
44
  jit: false,
45
+ staticClone: false,
45
46
  ws: false,
46
47
  reconstruct: false,
47
48
  cookie: false,
@@ -79,6 +80,7 @@ function planFromReport(strip, report, hasWS, mayTrace, aliases, allBridgeFree,
79
80
  return {
80
81
  plan: {
81
82
  jit,
83
+ staticClone: jit && !aliases.has("scl"),
82
84
  ws: !hasWS,
83
85
  reconstruct: jit && !aliases.has("va") && !aliases.has("cc") && !aliases.has("tr"),
84
86
  cookie: jit && !aliases.has("cc") && !wsCookie,
@@ -124,19 +126,19 @@ function makeIsElysiaModule(elysiaRoot) {
124
126
  return path.replace(/\\/g, "/").startsWith(root + "/") && ELYSIA_MODULE_FILTER.test(path);
125
127
  };
126
128
  }
127
- function makeElysiaModuleFilterRegex(elysiaRoot) {
128
- const escaped = elysiaRoot.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
129
- return new RegExp("^" + escaped + "[\\\\/](dist|src)[\\\\/].+\\.(m?js|ts)x?$");
130
- }
131
129
  const rewriteIsProductionCalls = (code) => code.replace(/(?<![.?])\bisProduction\(\)/g, "true");
132
130
  const bunAdapterStubSource = "const e=(t)=>{throw new Error(`[elysia-aot] Bun adapter was stripped for target 'web-standard' .listen() is unavailable; use the exported fetch handler or rebuild with a different target.`)}\nexport const BunAdapter={name:'bun',runtime:'bun',isWebStandard:true,parse:{},response:{},listen:e}\nexport function collectStaticRoutes(){}\n";
133
131
  const STUB_SOURCES = {
132
+ staticClone: [{
133
+ filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]static-clone-resolver\.(m?js|ts)$/,
134
+ source: `export const staticCloneResolver = undefined\n`
135
+ }],
134
136
  jit: [{
135
137
  filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]jit\.(m?js|ts)$/,
136
138
  source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function compileHandlerJit(){return e()}\nexport function createInlineHandler(){return e()}\nexport function setCaptureHeaderShorthand(){}\n"
137
139
  }, {
138
140
  filter: /[\\/]elysia[\\/](dist|src)[\\/]compile[\\/]handler[\\/]descriptor\.(m?js|ts)$/,
139
- source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function describeRoute(){return e()}\nexport const routeDescriptors=new WeakMap()\nexport function isEmptyPipelineHook(hook){\n if(!hook)return true\n for(const key in hook){\n if(key==='detail'||key==='tags')continue\n const value=hook[key]\n if(value!==undefined&&value!==false&&(!Array.isArray(value)||value.length))return false\n }\n return true\n}\n"
141
+ source: "const e=()=>{throw new Error(\"[elysia-aot] handler compiler JIT was stripped (strip mode) but a route needed runtime compilation. Rebuild with strip:false.\")}\nexport function describeRoute(){return e()}\nexport const routeDescriptors=new WeakMap()\nexport function isEmptyPipelineHook(hook){\n if(!hook)return true\n for(const key in hook){\n if(key==='detail'||key==='tags'||key==='error')continue\n const value=hook[key]\n if(value!==undefined&&value!==false&&(!Array.isArray(value)||value.length))return false\n }\n return true\n}\n"
140
142
  }],
141
143
  ws: [{
142
144
  filter: /[\\/]elysia[\\/](dist|src)[\\/]ws[\\/]route\.(m?js|ts)$/,
@@ -148,7 +150,7 @@ const STUB_SOURCES = {
148
150
  }],
149
151
  cookie: [{
150
152
  filter: /[\\/]elysia[\\/](dist|src)[\\/]cookie[\\/]utils\.(m?js|ts)$/,
151
- source: "const e=()=>{throw new Error(\"[elysia-aot] cookie support was stripped (strip mode) but a route used cookies. Rebuild with strip:false.\")}\nexport const hasSyncHmac=false\nexport function parseCookie(){return e()}\nexport function parseCookieRaw(){return e()}\nexport function parseCookieRawSync(){return e()}\nexport function parseCookieRawSigned(){return e()}\nexport function parseCookieRawLazy(){return e()}\nexport function parseCookieRawDeferred(){return e()}\nexport function buildCookieJar(){return e()}\nexport function signCookieValues(){return e()}\nexport function signCookie(){return e()}\nexport function signCookieSubtle(){return e()}\nexport function signCookieSync(){return e()}\nexport function unsignCookie(){return e()}\nexport function unsignCookieSync(){return e()}\n"
153
+ source: "const e=()=>{throw new Error(\"[elysia-aot] cookie support was stripped (strip mode) but a route used cookies. Rebuild with strip:false.\")}\nexport const hasSyncHmac=false\nexport function parseCookieRaw(){return e()}\nexport function parseCookieRawSync(){return e()}\nexport function parseCookieRawSigned(){return e()}\nexport function parseCookieRawLazy(){return e()}\nexport function parseCookieRawDeferred(){return e()}\nexport function buildCookieJar(){return e()}\nexport function signCookieValues(){return e()}\nexport function signCookie(){return e()}\nexport function signCookieSubtle(){return e()}\nexport function signCookieSync(){return e()}\nexport function unsignCookie(){return e()}\nexport function unsignCookieSync(){return e()}\n"
152
154
  }, {
153
155
  filter: /[\\/]elysia[\\/](dist|src)[\\/]cookie[\\/]config\.(m?js|ts)$/,
154
156
  source: "const e=()=>{throw new Error(\"[elysia-aot] cookie support was stripped (strip mode) but a route used cookies. Rebuild with strip:false.\")}\nexport function compileCookieConfig(){return e()}\nexport function isCookieSigned(){return e()}\n"
@@ -330,13 +332,6 @@ async function generateVirtualType(typeSpecifier = "elysia/type", moduleConditio
330
332
  return source;
331
333
  }
332
334
  const _importedEntries = /* @__PURE__ */ new Set();
333
- let activeGenerationWorkers = 0;
334
- let lastGenerationWorkerExit;
335
- /** @internal Test diagnostic for deterministic worker cleanup. */
336
- const getAotWorkerDiagnostics = () => ({
337
- activeWorkers: activeGenerationWorkers,
338
- lastExit: lastGenerationWorkerExit
339
- });
340
335
  /**
341
336
  * Extension mirroring the running module's own build output, so a sibling
342
337
  * source file can be resolved from `import.meta.url` in `.mjs`/`.js`/`.ts`
@@ -358,9 +353,7 @@ async function generateCompiledArtifactsIsolated(file, options, moduleCondition
358
353
  options,
359
354
  moduleCondition
360
355
  } });
361
- activeGenerationWorkers++;
362
356
  const exit = new Promise((resolve) => worker.once("exit", resolve));
363
- lastGenerationWorkerExit = exit;
364
357
  try {
365
358
  return await new Promise((resolve, reject) => {
366
359
  let received = false;
@@ -382,7 +375,6 @@ async function generateCompiledArtifactsIsolated(file, options, moduleCondition
382
375
  await worker.terminate();
383
376
  } finally {
384
377
  await exit;
385
- activeGenerationWorkers--;
386
378
  }
387
379
  }
388
380
  }
@@ -537,4 +529,4 @@ const realPath = (path) => {
537
529
  };
538
530
 
539
531
  //#endregion
540
- export { ADAPTER_BUN_FILTER, ADAPTER_CONSTANTS_FILTER, ELYSIA_MODULE_FILTER, IS_PRODUCTION_FILTER, NO_STUB, OVERRIDE_MAP, SOURCE_REGEX, STUB_SOURCES, adapterConstantsSource, alignStubExtensions, bunAdapterStubSource, generateCompiledArtifacts, generateCompiledArtifactsIsolated, generateVirtualType, getAotWorkerDiagnostics, makeElysiaModuleFilterRegex, makeIsElysiaModule, planFromReport, realPath, resolveElysiaRoot, resolveEntry, resolveEntryModuleKind, resolveExactMirror, rewriteIsProductionCalls, siblingModuleExt, validatorSlotSetsMatch };
532
+ export { ADAPTER_BUN_FILTER, ADAPTER_CONSTANTS_FILTER, ELYSIA_MODULE_FILTER, IS_PRODUCTION_FILTER, NO_STUB, OVERRIDE_MAP, SOURCE_REGEX, STUB_SOURCES, adapterConstantsSource, alignStubExtensions, bunAdapterStubSource, generateCompiledArtifacts, generateCompiledArtifactsIsolated, generateVirtualType, makeIsElysiaModule, planFromReport, realPath, resolveElysiaRoot, resolveEntry, resolveEntryModuleKind, resolveExactMirror, rewriteIsProductionCalls, siblingModuleExt, validatorSlotSetsMatch };
@@ -22,6 +22,7 @@ const createAotPluginHooks = (entry, options, moduleCondition = require_plugin_a
22
22
  let virtualType;
23
23
  let stub = { ...require_plugin_aot_core.NO_STUB };
24
24
  let isElysiaModule = (_path) => false;
25
+ let packageRoot = "";
25
26
  return {
26
27
  async buildStart() {
27
28
  const generated = initial ? await require_plugin_aot_core.generateCompiledArtifacts(entry, options, moduleCondition) : await require_plugin_aot_core.generateCompiledArtifactsIsolated(entry, options, moduleCondition);
@@ -29,7 +30,9 @@ const createAotPluginHooks = (entry, options, moduleCondition = require_plugin_a
29
30
  source = generated.source;
30
31
  stub = generated.stub;
31
32
  virtualType = generated.virtualType;
32
- isElysiaModule = require_plugin_aot_core.makeIsElysiaModule(require_plugin_aot_core.resolveElysiaRoot(entryPath));
33
+ const pkgRoot = require_plugin_aot_core.resolveElysiaRoot(entryPath);
34
+ isElysiaModule = require_plugin_aot_core.makeIsElysiaModule(pkgRoot);
35
+ packageRoot = toPosix(pkgRoot);
33
36
  },
34
37
  buildEnd() {
35
38
  if (!entryMatched) throw new Error(`[elysia-aot] entry "${entry}" never appeared in the Vite module graph. Compiled manifest was not injected. Check that the plugin entry matches a build input.`);
@@ -46,6 +49,7 @@ const createAotPluginHooks = (entry, options, moduleCondition = require_plugin_a
46
49
  const cleanId = id.split("?", 1)[0];
47
50
  for (const key of Object.keys(require_plugin_aot_core.STUB_SOURCES)) {
48
51
  if (!stub[key]) continue;
52
+ if (key === "staticClone" && (!isElysiaModule(cleanId) || !/^(dist|src)\/compile\/handler\/static-clone-resolver\.(m?js|ts)$/.test(toPosix(cleanId).slice(packageRoot.length + 1)))) continue;
49
53
  for (const { filter, source: stubSource } of require_plugin_aot_core.STUB_SOURCES[key]) if (filter.test(cleanId)) return require_plugin_aot_core.alignStubExtensions(stubSource, cleanId);
50
54
  }
51
55
  if (stub.adapter !== false && require_plugin_aot_core.ADAPTER_CONSTANTS_FILTER.test(cleanId)) return require_plugin_aot_core.alignStubExtensions(require_plugin_aot_core.adapterConstantsSource(stub.adapter), cleanId);
@@ -21,6 +21,7 @@ const createAotPluginHooks = (entry, options, moduleCondition = resolveEntryModu
21
21
  let virtualType;
22
22
  let stub = { ...NO_STUB };
23
23
  let isElysiaModule = (_path) => false;
24
+ let packageRoot = "";
24
25
  return {
25
26
  async buildStart() {
26
27
  const generated = initial ? await generateCompiledArtifacts(entry, options, moduleCondition) : await generateCompiledArtifactsIsolated(entry, options, moduleCondition);
@@ -28,7 +29,9 @@ const createAotPluginHooks = (entry, options, moduleCondition = resolveEntryModu
28
29
  source = generated.source;
29
30
  stub = generated.stub;
30
31
  virtualType = generated.virtualType;
31
- isElysiaModule = makeIsElysiaModule(resolveElysiaRoot(entryPath));
32
+ const pkgRoot = resolveElysiaRoot(entryPath);
33
+ isElysiaModule = makeIsElysiaModule(pkgRoot);
34
+ packageRoot = toPosix(pkgRoot);
32
35
  },
33
36
  buildEnd() {
34
37
  if (!entryMatched) throw new Error(`[elysia-aot] entry "${entry}" never appeared in the Vite module graph. Compiled manifest was not injected. Check that the plugin entry matches a build input.`);
@@ -45,6 +48,7 @@ const createAotPluginHooks = (entry, options, moduleCondition = resolveEntryModu
45
48
  const cleanId = id.split("?", 1)[0];
46
49
  for (const key of Object.keys(STUB_SOURCES)) {
47
50
  if (!stub[key]) continue;
51
+ if (key === "staticClone" && (!isElysiaModule(cleanId) || !/^(dist|src)\/compile\/handler\/static-clone-resolver\.(m?js|ts)$/.test(toPosix(cleanId).slice(packageRoot.length + 1)))) continue;
48
52
  for (const { filter, source: stubSource } of STUB_SOURCES[key]) if (filter.test(cleanId)) return alignStubExtensions(stubSource, cleanId);
49
53
  }
50
54
  if (stub.adapter !== false && ADAPTER_CONSTANTS_FILTER.test(cleanId)) return alignStubExtensions(adapterConstantsSource(stub.adapter), cleanId);