elysia 2.0.0-exp.7 → 2.0.0-exp.8

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.
@@ -6,7 +6,7 @@ import { AnyElysia } from "../../base.js";
6
6
  declare function collectStaticRoutes(app: AnyElysia): readonly [Record<string, Record<string, Response>>, Promise<void>[]] | undefined;
7
7
  declare const BunAdapter: {
8
8
  parse: {
9
- default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
9
+ default: (context: Context, contentType: string) => string | unknown[] | ArrayBuffer | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
10
10
  json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
11
11
  text: (context: Context) => MaybePromise<string>;
12
12
  urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
@@ -5,7 +5,7 @@ import { AnyElysia } from "../base.js";
5
5
  //#region src/adapter/constants.d.ts
6
6
  declare const defaultAdapter: {
7
7
  parse: {
8
- default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
8
+ default: (context: Context, contentType: string) => string | unknown[] | ArrayBuffer | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
9
9
  json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
10
10
  text: (context: Context) => MaybePromise<string>;
11
11
  urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
@@ -7,7 +7,7 @@ import { AnyElysia } from "../base.js";
7
7
  //#region src/adapter/index.d.ts
8
8
  declare function createAdapter(adapter: ElysiaAdapterOptions): {
9
9
  parse: {
10
- default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
10
+ default: (context: Context, contentType: string) => string | unknown[] | ArrayBuffer | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
11
11
  json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
12
12
  text: (context: Context) => MaybePromise<string>;
13
13
  urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
@@ -12,7 +12,7 @@ declare function responseToSetHeaders(response: Response, set?: Context['set']):
12
12
  cookie?: Record<string, BaseCookie>;
13
13
  } | {
14
14
  headers: any;
15
- status: number | "Bad Request" | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required";
15
+ status: number | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required";
16
16
  };
17
17
  interface CreateHandlerParameter {
18
18
  mapResponse(response: unknown, set: Context['set'], request?: Request): Response;
@@ -5,7 +5,7 @@ import { AnyElysia } from "../../base.js";
5
5
  //#region src/adapter/web-standard/index.d.ts
6
6
  declare const WebStandardAdapter: {
7
7
  parse: {
8
- default: (context: Context, contentType: string) => string | ArrayBuffer | unknown[] | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
8
+ default: (context: Context, contentType: string) => string | unknown[] | ArrayBuffer | Record<string, unknown> | Promise<unknown[] | Record<string | number | symbol, undefined>> | Promise<ArrayBuffer> | Promise<Record<string, unknown>> | Promise<string> | undefined;
9
9
  json: (context: Context) => MaybePromise<Record<keyof any, undefined> | unknown[]>;
10
10
  text: (context: Context) => MaybePromise<string>;
11
11
  urlencoded: (context: Context) => MaybePromise<Record<string, string | string[]>>;
package/dist/error.d.ts CHANGED
@@ -85,7 +85,7 @@ declare class ElysiaStatus<const in out Code extends number | keyof StatusMap, T
85
85
  constructor(code: Code, res: T);
86
86
  get status(): number;
87
87
  }
88
- declare const status: <const Code extends number | keyof StatusMap, const T = (Code extends keyof StatusMapBack ? StatusMapBack[Code] : Code)>(code: Code, response?: T) => ElysiaStatus<Code, T, Code extends "Bad Request" | "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? {
88
+ declare const status: <const Code extends number | keyof StatusMap, const T = (Code extends keyof StatusMapBack ? StatusMapBack[Code] : Code)>(code: Code, response?: T) => ElysiaStatus<Code, T, Code extends "Continue" | "Switching Protocols" | "Processing" | "Early Hints" | "OK" | "Created" | "Accepted" | "Non-Authoritative Information" | "No Content" | "Reset Content" | "Partial Content" | "Multi-Status" | "Already Reported" | "Multiple Choices" | "Moved Permanently" | "Found" | "See Other" | "Not Modified" | "Temporary Redirect" | "Permanent Redirect" | "Bad Request" | "Unauthorized" | "Payment Required" | "Forbidden" | "Not Found" | "Method Not Allowed" | "Not Acceptable" | "Proxy Authentication Required" | "Request Timeout" | "Conflict" | "Gone" | "Length Required" | "Precondition Failed" | "Payload Too Large" | "URI Too Long" | "Unsupported Media Type" | "Range Not Satisfiable" | "Expectation Failed" | "I'm a teapot" | "Enhance Your Calm" | "Misdirected Request" | "Unprocessable Content" | "Locked" | "Failed Dependency" | "Too Early" | "Upgrade Required" | "Precondition Required" | "Too Many Requests" | "Request Header Fields Too Large" | "Unavailable For Legal Reasons" | "Internal Server Error" | "Not Implemented" | "Bad Gateway" | "Service Unavailable" | "Gateway Timeout" | "HTTP Version Not Supported" | "Variant Also Negotiates" | "Insufficient Storage" | "Loop Detected" | "Not Extended" | "Network Authentication Required" ? {
89
89
  readonly Continue: 100;
90
90
  readonly 'Switching Protocols': 101;
91
91
  readonly Processing: 102;
@@ -71,6 +71,21 @@ interface StubPlan {
71
71
  * cookie config (`cc`)
72
72
  */
73
73
  cookie: boolean;
74
+ /**
75
+ * Stub the trace runtime (`trace.ts` `createTracer` + recorder machinery)
76
+ * when no replayed handler aliases trace (`tr`). The live fetch handler keeps
77
+ * `createTracer` importable but only calls it when trace handlers exist, so a
78
+ * throwing stub is unreachable once detection proves trace is unused
79
+ */
80
+ trace: boolean;
81
+ /**
82
+ * Stub the `memory` module's `clearSucroseCache` edge when handler JIT is
83
+ * stubbed. Sucrose never runs in a precompiled app, so its caches are always
84
+ * empty and the flush is a no-op — dropping the import lets the Sucrose
85
+ * analyzer tree-shake. `flushMemory`'s other clears are preserved, and the
86
+ * public `elysia/sucrose` module is left untouched
87
+ */
88
+ sucrose: boolean;
74
89
  }
75
90
  declare const STUB_SOURCES: Record<keyof StubPlan, Array<{
76
91
  filter: RegExp;
@@ -24,7 +24,9 @@ const NO_STUB = {
24
24
  jit: false,
25
25
  ws: false,
26
26
  reconstruct: false,
27
- cookie: false
27
+ cookie: false,
28
+ trace: false,
29
+ sucrose: false
28
30
  };
29
31
  /**
30
32
  * Resolve whether handler JIT is safe to stub for `entry`, honouring the
@@ -38,7 +40,9 @@ function planFromReport(strip, report, hasWS, aliases) {
38
40
  jit,
39
41
  ws: !hasWS,
40
42
  reconstruct: jit && !aliases.has("va") && !aliases.has("cc") && !aliases.has("tr"),
41
- cookie: jit && !aliases.has("cc")
43
+ cookie: jit && !aliases.has("cc"),
44
+ trace: jit && !aliases.has("tr"),
45
+ sucrose: jit
42
46
  };
43
47
  }
44
48
  const STUB_SOURCES = {
@@ -60,6 +64,14 @@ const STUB_SOURCES = {
60
64
  }, {
61
65
  filter: /[\\/]cookie[\\/]config\.(m?js|ts)$/,
62
66
  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"
67
+ }],
68
+ trace: [{
69
+ filter: /[\\/]elysia[\\/](dist|src)[\\/]trace\.(m?js|ts)$/,
70
+ source: "const e=()=>{throw new Error(\"[elysia-aot] trace support was stripped (strip mode) but a route used trace. Rebuild with strip:false.\")}\nexport function createTracer(){return e()}\n"
71
+ }],
72
+ sucrose: [{
73
+ filter: /[\\/]elysia[\\/](dist|src)[\\/]memory\.(m?js|ts)$/,
74
+ source: "import { clearContextCache } from './context'\nimport { isBun } from './universal/constants'\nimport { Validator } from './validator'\nexport function flushMemory() {\n clearContextCache()\n Validator.clear()\n if (isBun) Bun.gc()\n else if (typeof global?.gc === 'function') global.gc()\n}\n"
63
75
  }]
64
76
  };
65
77
  async function generateCompiledModule(file, options) {
@@ -22,7 +22,9 @@ const NO_STUB = {
22
22
  jit: false,
23
23
  ws: false,
24
24
  reconstruct: false,
25
- cookie: false
25
+ cookie: false,
26
+ trace: false,
27
+ sucrose: false
26
28
  };
27
29
  /**
28
30
  * Resolve whether handler JIT is safe to stub for `entry`, honouring the
@@ -36,7 +38,9 @@ function planFromReport(strip, report, hasWS, aliases) {
36
38
  jit,
37
39
  ws: !hasWS,
38
40
  reconstruct: jit && !aliases.has("va") && !aliases.has("cc") && !aliases.has("tr"),
39
- cookie: jit && !aliases.has("cc")
41
+ cookie: jit && !aliases.has("cc"),
42
+ trace: jit && !aliases.has("tr"),
43
+ sucrose: jit
40
44
  };
41
45
  }
42
46
  const STUB_SOURCES = {
@@ -58,6 +62,14 @@ const STUB_SOURCES = {
58
62
  }, {
59
63
  filter: /[\\/]cookie[\\/]config\.(m?js|ts)$/,
60
64
  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"
65
+ }],
66
+ trace: [{
67
+ filter: /[\\/]elysia[\\/](dist|src)[\\/]trace\.(m?js|ts)$/,
68
+ source: "const e=()=>{throw new Error(\"[elysia-aot] trace support was stripped (strip mode) but a route used trace. Rebuild with strip:false.\")}\nexport function createTracer(){return e()}\n"
69
+ }],
70
+ sucrose: [{
71
+ filter: /[\\/]elysia[\\/](dist|src)[\\/]memory\.(m?js|ts)$/,
72
+ source: "import { clearContextCache } from './context'\nimport { isBun } from './universal/constants'\nimport { Validator } from './validator'\nexport function flushMemory() {\n clearContextCache()\n Validator.clear()\n if (isBun) Bun.gc()\n else if (typeof global?.gc === 'function') global.gc()\n}\n"
61
73
  }]
62
74
  };
63
75
  async function generateCompiledModule(file, options) {
@@ -27,7 +27,9 @@ const aot = (entry, options) => {
27
27
  jit: false,
28
28
  ws: false,
29
29
  reconstruct: false,
30
- cookie: false
30
+ cookie: false,
31
+ trace: false,
32
+ sucrose: false
31
33
  };
32
34
  return {
33
35
  name: "elysia-aot",
@@ -26,7 +26,9 @@ const aot = (entry, options) => {
26
26
  jit: false,
27
27
  ws: false,
28
28
  reconstruct: false,
29
- cookie: false
29
+ cookie: false,
30
+ trace: false,
31
+ sucrose: false
30
32
  };
31
33
  return {
32
34
  name: "elysia-aot",
@@ -1,16 +1,16 @@
1
- import { Intersect as Intersect$1 } from "./elysia/intersect.js";
1
+ import { Intersect as Intersect$2 } from "./elysia/intersect.js";
2
2
  import { applyCoercions as applyCoercions$1, coerceBody as coerceBody$1, coerceFormData as coerceFormData$1, coerceQuery as coerceQuery$1, coerceRoot as coerceRoot$1, coerceStringToStructure as coerceStringToStructure$1 } from "./coerce.js";
3
3
  import { TypeBoxValidatorCache as TypeBoxValidatorCache$1 } from "./validator/validator-cache.js";
4
4
  import { TypeBoxValidator as TypeBoxValidator$1 } from "./validator/index.js";
5
5
  import { hasTypes as hasTypes$1 } from "./utils.js";
6
- import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
7
6
  import { Compile as Compile$1 } from "typebox/compile";
8
- import { Decode as Decode$1, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
7
+ import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
8
+ import { Decode as Decode$2, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
9
9
 
10
10
  //#region src/type/bridge.d.ts
11
11
  interface TypeboxModule {
12
12
  Compile: typeof Compile$1;
13
- Decode: typeof Decode$1;
13
+ Decode: typeof Decode$2;
14
14
  applyCoercions: typeof applyCoercions$1;
15
15
  TypeBoxValidator: TypeBoxValidator$1;
16
16
  TypeBoxValidatorCache: TypeBoxValidatorCache$1;
@@ -21,12 +21,12 @@ interface TypeboxModule {
21
21
  coerceBody: typeof coerceBody$1;
22
22
  hasTypes: typeof hasTypes$1;
23
23
  HasCodec: typeof HasCodec$1;
24
- Intersect: typeof Intersect$1;
24
+ Intersect: typeof Intersect$2;
25
25
  Default: typeof Default$1;
26
26
  Ref: typeof Ref$1;
27
27
  }
28
28
  declare let Compile: typeof Compile$1;
29
- declare let Decode: typeof Decode$1;
29
+ declare let Decode: typeof Decode$2;
30
30
  declare let applyCoercions: typeof applyCoercions$1;
31
31
  declare let TypeBoxValidator: TypeBoxValidator$1;
32
32
  type TypeBoxValidator<T extends TSchema = TAny> = TypeBoxValidator$1<T>;
@@ -39,7 +39,7 @@ declare let coerceStringToStructure: typeof coerceStringToStructure$1;
39
39
  declare let coerceBody: typeof coerceBody$1;
40
40
  declare let hasTypes: typeof hasTypes$1;
41
41
  declare let HasCodec: typeof HasCodec$1;
42
- declare let Intersect: typeof Intersect$1;
42
+ declare let Intersect: typeof Intersect$2;
43
43
  declare let Default: typeof Default$1;
44
44
  declare let Ref: typeof Ref$1;
45
45
  declare function useTypebox(mod: TypeboxModule): void;
@@ -36,7 +36,7 @@ declare const coerceQuery: () => CoerceOption[];
36
36
  declare const coerceBody: () => CoerceOption[];
37
37
  declare const coerceFormData: () => CoerceOption[];
38
38
  declare const coerceStringToStructure: () => CoerceOption[];
39
- declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined): TSchema | BaseSchema;
39
+ declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined): BaseSchema | TSchema;
40
40
  interface CoerceLeaf {
41
41
  e: number;
42
42
  c?: Record<string, unknown>;
@@ -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 | 3 | 6 | 10 | 11 | 13 | 14>;
20
+ declare const primitiveElysiaTypes: Set<3 | 1 | 2 | 6 | 10 | 11 | 13 | 14>;
21
21
  declare const noEnumerable: {
22
22
  readonly enumerable: false;
23
23
  };
@@ -1,9 +1,9 @@
1
1
  import { ELYSIA_TYPES } from "./constants.js";
2
2
  import { CookieOptions } from "../cookie/types.js";
3
3
  import { MaybeArray } from "../types.js";
4
+ import { Validator } from "typebox/schema";
4
5
  import { TObjectOptions, TSchemaOptions } from "typebox";
5
6
  import { TLocalizedValidationError } from "typebox/error";
6
- import { Validator } from "typebox/schema";
7
7
 
8
8
  //#region src/type/types.d.ts
9
9
  type FileUnit = number | `${number}${'k' | 'm'}`;
@@ -2,8 +2,8 @@ import { MaybePromise } from "../../types.js";
2
2
  import { TypeBoxValidatorCache } from "./validator-cache.js";
3
3
  import { Validator as Validator$1, ValidatorOptions } from "../../validator/index.js";
4
4
  import { Static, StaticDecode, StaticEncode, TAny, TSchema } from "typebox/type";
5
- import { TLocalizedValidationError } from "typebox/error";
6
5
  import { Validator } from "typebox/schema";
6
+ import { TLocalizedValidationError } from "typebox/error";
7
7
 
8
8
  //#region src/type/validator/index.d.ts
9
9
  declare function shallowMergeObjects(members: any[]): TSchema | null;
package/dist/types.d.ts CHANGED
@@ -10,8 +10,8 @@ import { ChainNode } from "./utils.js";
10
10
  import { Context, ErrorContext, LifecycleContext, PreContext } from "./context.js";
11
11
  import { WebSocketHandler } from "./ws/types.js";
12
12
  import { AnyElysia, Elysia } from "./base.js";
13
- import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
14
13
  import { Instruction } from "exact-mirror";
14
+ import { Static, StaticDecode, StaticEncode, TIntersect, TObject, TSchema } from "typebox";
15
15
  import { OpenAPIV3 } from "openapi-types";
16
16
 
17
17
  //#region src/types.d.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elysia",
3
3
  "description": "Ergonomic Framework for Human",
4
- "version": "2.0.0-exp.7",
4
+ "version": "2.0.0-exp.8",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",