elysia 2.0.0-beta.15 → 2.0.0-beta.16

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.
@@ -3,7 +3,8 @@ import { AnyElysia } from "../../base.js";
3
3
  import { ElysiaAdapterOptions } from "../types.js";
4
4
  //#region src/adapter/bun/index.d.ts
5
5
  declare const isHTMLBundle: (value: unknown) => value is BunHTMLBundlelike;
6
+ declare function collectHTMLBundleRoutes(app: AnyElysia): Record<string, Record<string, BunHTMLBundlelike>> | undefined;
6
7
  declare function collectStaticRoutes(app: AnyElysia): Record<string, Record<string, Response | BunHTMLBundlelike>> | undefined;
7
8
  declare const BunAdapter: ElysiaAdapterOptions<void>;
8
9
  //#endregion
9
- export { BunAdapter, collectStaticRoutes, isHTMLBundle };
10
+ export { BunAdapter, collectHTMLBundleRoutes, collectStaticRoutes, isHTMLBundle };
@@ -69,6 +69,14 @@ const withOrigin = (fetch) => (request, server) => {
69
69
  };
70
70
  const isNativeStaticMethod = (method) => method === "GET" || method === "POST" || method === "PUT" || method === "DELETE" || method === "PATCH" || method === "HEAD" || method === "OPTIONS";
71
71
  const isHTMLBundle = (value) => typeof value === "object" && value !== null && typeof value.index === "string";
72
+ function collectHTMLBundleRoutes(app) {
73
+ let routes;
74
+ for (const [method, path, handler] of app["~routes"]) {
75
+ if (!isNativeStaticMethod(method) || !isHTMLBundle(handler) || path.indexOf(":") !== -1 || path.indexOf("*") !== -1) continue;
76
+ ((routes ??= require_utils.nullObject())[path] ??= require_utils.nullObject())[method] = handler;
77
+ }
78
+ return routes;
79
+ }
72
80
  function collectStaticRoutes(app) {
73
81
  app.fetch;
74
82
  const frozenRoot = require_generation.frozenRootOf(app);
@@ -158,10 +166,11 @@ const BunAdapter = require_adapter_index.createAdapter({
158
166
  ..._config,
159
167
  ..._options
160
168
  } : _options;
161
- const server = app.server = Bun.serve(serve.routes || serve.error ? {
169
+ const htmlRoutes = collectHTMLBundleRoutes(app);
170
+ const server = app.server = Bun.serve(serve.routes || serve.error || htmlRoutes ? {
162
171
  ...serve,
163
172
  error: unavailableFetch,
164
- routes: {}
173
+ routes: htmlRoutes ?? {}
165
174
  } : serve);
166
175
  let live;
167
176
  let cancelled = false;
@@ -486,5 +495,6 @@ const BunAdapter = require_adapter_index.createAdapter({
486
495
 
487
496
  //#endregion
488
497
  exports.BunAdapter = BunAdapter;
498
+ exports.collectHTMLBundleRoutes = collectHTMLBundleRoutes;
489
499
  exports.collectStaticRoutes = collectStaticRoutes;
490
500
  exports.isHTMLBundle = isHTMLBundle;
@@ -68,6 +68,14 @@ const withOrigin = (fetch) => (request, server) => {
68
68
  };
69
69
  const isNativeStaticMethod = (method) => method === "GET" || method === "POST" || method === "PUT" || method === "DELETE" || method === "PATCH" || method === "HEAD" || method === "OPTIONS";
70
70
  const isHTMLBundle = (value) => typeof value === "object" && value !== null && typeof value.index === "string";
71
+ function collectHTMLBundleRoutes(app) {
72
+ let routes;
73
+ for (const [method, path, handler] of app["~routes"]) {
74
+ if (!isNativeStaticMethod(method) || !isHTMLBundle(handler) || path.indexOf(":") !== -1 || path.indexOf("*") !== -1) continue;
75
+ ((routes ??= nullObject())[path] ??= nullObject())[method] = handler;
76
+ }
77
+ return routes;
78
+ }
71
79
  function collectStaticRoutes(app) {
72
80
  app.fetch;
73
81
  const frozenRoot = frozenRootOf(app);
@@ -157,10 +165,11 @@ const BunAdapter = createAdapter({
157
165
  ..._config,
158
166
  ..._options
159
167
  } : _options;
160
- const server = app.server = Bun.serve(serve.routes || serve.error ? {
168
+ const htmlRoutes = collectHTMLBundleRoutes(app);
169
+ const server = app.server = Bun.serve(serve.routes || serve.error || htmlRoutes ? {
161
170
  ...serve,
162
171
  error: unavailableFetch,
163
- routes: {}
172
+ routes: htmlRoutes ?? {}
164
173
  } : serve);
165
174
  let live;
166
175
  let cancelled = false;
@@ -484,4 +493,4 @@ const BunAdapter = createAdapter({
484
493
  });
485
494
 
486
495
  //#endregion
487
- export { BunAdapter, collectStaticRoutes, isHTMLBundle };
496
+ export { BunAdapter, collectHTMLBundleRoutes, collectStaticRoutes, isHTMLBundle };
@@ -13,8 +13,8 @@ const require_type_validator_frozen_check = require('../type/validator/frozen-ch
13
13
  const require_type_validator_custom_error = require('../type/validator/custom-error.js');
14
14
  const require_type_validator_exact_mirror = require('../type/validator/exact-mirror.js');
15
15
  const require_type_validator_string_codec_aot = require('../type/validator/string-codec-aot.js');
16
- let typebox_value = require("typebox/value");
17
16
  let typebox_schema = require("typebox/schema");
17
+ let typebox_value = require("typebox/value");
18
18
 
19
19
  //#region src/compile/aot-capture.ts
20
20
  function emptyContainers(node, depth) {
@@ -11,8 +11,8 @@ import { buildFrozenCheck } from "../type/validator/frozen-check.mjs";
11
11
  import { captureCustomErrors } from "../type/validator/custom-error.mjs";
12
12
  import { getExactMirror } from "../type/validator/exact-mirror.mjs";
13
13
  import { captureStringCodecEntries } from "../type/validator/string-codec-aot.mjs";
14
- import { Default } from "typebox/value";
15
14
  import { Build, Compile } from "typebox/schema";
15
+ import { Default } from "typebox/value";
16
16
 
17
17
  //#region src/compile/aot-capture.ts
18
18
  function emptyContainers(node, depth) {
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.0.0-beta.15";
3
+ var version = "2.0.0-beta.16";
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.15";
2
+ var version = "2.0.0-beta.16";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -95,7 +95,7 @@ interface ElysiaAotOptions {
95
95
  }
96
96
  declare const resolveEntry: (entry: string) => string;
97
97
  /** @internal Resolve the package condition used to evaluate an AOT entry. */
98
- declare const resolveEntryModuleKind: (entry: string) => "cjs" | "esm";
98
+ declare const resolveEntryModuleKind: (entry: string) => "esm" | "cjs";
99
99
  /** Runtime handler-JIT module a strip build can replace with a throwing stub. */
100
100
  interface StubPlan {
101
101
  /** Stub the internal handler codegen module. */
@@ -4,9 +4,9 @@ import { useTypebox as useTypebox$1 } from "./bridge.js";
4
4
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-cache.js";
5
5
  import { TypeBoxValidator } from "./validator/index.js";
6
6
  import { applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, coerceStringToStructure } from "./coerce.js";
7
+ import { Check, Clone, Create, Decode, Default, HasCodec } from "typebox/value";
7
8
  import { Compile } from "typebox/compile";
8
9
  import { Ref } from "typebox/type";
9
- import { Check, Clone, Create, Decode, Default, HasCodec } from "typebox/value";
10
10
 
11
11
  //#region src/type/bridge-live.d.ts
12
12
  declare function useTypebox(_mod?: Parameters<typeof useTypebox$1>[0]): void;
@@ -5,9 +5,9 @@ const require_type_coerce = require('./coerce.js');
5
5
  const require_type_validator_validator_cache = require('./validator/validator-cache.js');
6
6
  const require_type_validator_index = require('./validator/index.js');
7
7
  const require_type_elysia_intersect = require('./elysia/intersect.js');
8
+ let typebox_value = require("typebox/value");
8
9
  let typebox_compile = require("typebox/compile");
9
10
  let typebox_type = require("typebox/type");
10
- let typebox_value = require("typebox/value");
11
11
  let typebox_system = require("typebox/system");
12
12
 
13
13
  //#region src/type/bridge-live.ts
@@ -3,9 +3,9 @@ import { applyCoercions, coerceBody, coerceFormData, coerceQuery, coerceRoot, co
3
3
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator/validator-cache.mjs";
4
4
  import { TypeBoxValidator } from "./validator/index.mjs";
5
5
  import { Intersect } from "./elysia/intersect.mjs";
6
+ import { Check, Clone, Create, Decode, Default, HasCodec } from "typebox/value";
6
7
  import { Compile } from "typebox/compile";
7
8
  import { Ref } from "typebox/type";
8
- import { Check, Clone, Create, Decode, Default, HasCodec } from "typebox/value";
9
9
  import { Settings } from "typebox/system";
10
10
 
11
11
  //#region src/type/bridge-live.ts
@@ -3,15 +3,15 @@ import { hasTypes as hasTypes$1 } from "./utils.js";
3
3
  import { TypeBoxValidatorCache as TypeBoxValidatorCache$1, mayHaveFileType as mayHaveFileType$1 } from "./validator/validator-cache.js";
4
4
  import { TypeBoxValidator as TypeBoxValidator$1 } from "./validator/index.js";
5
5
  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";
6
+ import { Check as Check$1, Clone as Clone$1, Create as Create$1, Decode as Decode$1, Default as Default$1, HasCodec as HasCodec$1 } from "typebox/value";
6
7
  import { Compile as Compile$1 } from "typebox/compile";
7
8
  import { Ref as Ref$1, TAny, TSchema } from "typebox/type";
8
- import { Check as Check$1, Clone as Clone$1, Create as Create$1, 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
13
  Create: typeof Create$1;
14
- Decode: typeof Decode$2;
14
+ Decode: typeof Decode$1;
15
15
  applyCoercions: typeof applyCoercions$1;
16
16
  TypeBoxValidator: TypeBoxValidator$1;
17
17
  TypeBoxValidatorCache: TypeBoxValidatorCache$1;
@@ -32,7 +32,7 @@ interface TypeboxModule {
32
32
  }
33
33
  declare let Compile: typeof Compile$1;
34
34
  declare let Create: typeof Create$1;
35
- declare let Decode: typeof Decode$2;
35
+ declare let Decode: typeof Decode$1;
36
36
  declare let applyCoercions: typeof applyCoercions$1;
37
37
  declare let TypeBoxValidator: TypeBoxValidator$1;
38
38
  type TypeBoxValidator<T extends TSchema = TAny> = TypeBoxValidator$1<T>;
@@ -34,7 +34,7 @@ declare const coerceQuery: () => CoerceOption[];
34
34
  declare const coerceBody: () => CoerceOption[];
35
35
  declare const coerceFormData: () => CoerceOption[];
36
36
  declare const coerceStringToStructure: () => CoerceOption[];
37
- declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined): TSchema | BaseSchema;
37
+ declare function applyCoercions(schema: BaseSchema | TSchema, coerces: CoerceOption[] | undefined): BaseSchema | TSchema;
38
38
  declare function captureCoercePlan(original: any, coerced: any): CoerceNode | null;
39
39
  /** Full rebuild: scalar leaves + ObjectString/ArrayString sites (wired path). */
40
40
  declare const buildCoercedFromPlan: (original: any, plan: CoerceNode, seen?: Set<string>) => any;
@@ -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 | 14 | 13 | 11 | 10 | 6>;
20
+ declare const primitiveElysiaTypes: Set<1 | 2 | 6 | 3 | 10 | 11 | 13 | 14>;
21
21
  declare const noEnumerable: {
22
22
  readonly enumerable: false;
23
23
  };
@@ -1,7 +1,7 @@
1
1
  import { TypeboxNamespaces } from "./typebox-value.js";
2
- import { Compile } from "typebox/compile";
3
- import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
4
2
  import { Build, Compile as SchemaCompile } from "typebox/schema";
3
+ import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
4
+ import { Compile } from "typebox/compile";
5
5
 
6
6
  //#region src/type/typebox-value-live.d.ts
7
7
  declare function injectTypebox(_typebox?: TypeboxNamespaces): void;
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.js');
3
- let typebox_compile = require("typebox/compile");
3
+ let typebox_schema = require("typebox/schema");
4
4
  let typebox_value = require("typebox/value");
5
+ let typebox_compile = require("typebox/compile");
5
6
  let typebox_system = require("typebox/system");
6
- let typebox_schema = require("typebox/schema");
7
7
 
8
8
  //#region src/type/typebox-value-live.ts
9
9
  typebox_system.Settings.Set({ unionPrioritySort: false });
@@ -1,7 +1,7 @@
1
- import { Compile } from "typebox/compile";
1
+ import { Build, Compile as SchemaCompile } from "typebox/schema";
2
2
  import { Check, Clean, Clone, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec } from "typebox/value";
3
+ import { Compile } from "typebox/compile";
3
4
  import { Settings } from "typebox/system";
4
- import { Build, Compile as SchemaCompile } from "typebox/schema";
5
5
 
6
6
  //#region src/type/typebox-value-live.ts
7
7
  Settings.Set({ unionPrioritySort: false });
@@ -1,9 +1,9 @@
1
- import * as _$typebox_compile0 from "typebox/compile";
2
- import { Compile as Compile$1 } from "typebox/compile";
1
+ import * as _$typebox_schema0 from "typebox/schema";
2
+ import { Build as Build$1, Compile as Compile$1 } from "typebox/schema";
3
3
  import * as _$typebox_value0 from "typebox/value";
4
4
  import { Check as Check$1, Clean as Clean$1, Clone as Clone$1, Create as Create$1, Decode as Decode$1, DecodeUnsafe as DecodeUnsafe$1, Default as Default$1, Encode as Encode$1, EncodeUnsafe as EncodeUnsafe$1, Errors as Errors$1, HasCodec as HasCodec$1 } from "typebox/value";
5
- import * as _$typebox_schema0 from "typebox/schema";
6
- import { Build as Build$1, Compile as Compile$2 } from "typebox/schema";
5
+ import * as _$typebox_compile0 from "typebox/compile";
6
+ import { Compile as Compile$2 } from "typebox/compile";
7
7
 
8
8
  //#region src/type/typebox-value.d.ts
9
9
  interface TypeboxNamespaces {
@@ -26,9 +26,9 @@ declare let Encode: typeof Encode$1;
26
26
  declare let EncodeUnsafe: typeof EncodeUnsafe$1;
27
27
  declare let Errors: typeof Errors$1;
28
28
  declare let HasCodec: typeof HasCodec$1;
29
- declare let SchemaCompile: typeof Compile$2;
29
+ declare let SchemaCompile: typeof Compile$1;
30
30
  declare let Build: typeof Build$1;
31
- declare let Compile: typeof Compile$1;
31
+ declare let Compile: typeof Compile$2;
32
32
  declare function injectTypebox(typebox: TypeboxNamespaces): void;
33
33
  //#endregion
34
34
  export { Build, Check, Clean, Clone, Compile, Create, Decode, DecodeUnsafe, Default, Encode, EncodeUnsafe, Errors, HasCodec, SchemaCompile, TypeboxNamespaces, injectTypebox, load as warmTypebox };
@@ -1,8 +1,8 @@
1
1
  import { MaybePromise } from "../../types.js";
2
2
  import { Validator as Validator$1, ValidatorOptions } from "../../validator/index.js";
3
3
  import { TypeBoxValidatorCache, mayHaveFileType } from "./validator-cache.js";
4
- import { Static, StaticDecode, StaticEncode, TAny, TSchema } from "typebox/type";
5
4
  import { Validator } from "typebox/schema";
5
+ import { Static, StaticDecode, StaticEncode, TAny, TSchema } from "typebox/type";
6
6
  import { TLocalizedValidationError } from "typebox/error";
7
7
 
8
8
  //#region src/type/validator/index.d.ts
@@ -1,7 +1,7 @@
1
1
  import { CoerceOption } from "../coerce.js";
2
- import { TSchema } from "typebox/type";
3
2
  import * as _$typebox_schema0 from "typebox/schema";
4
3
  import { Validator } from "typebox/schema";
4
+ import { TSchema } from "typebox/type";
5
5
 
6
6
  //#region src/type/validator/validator-cache.d.ts
7
7
  interface SchemaMeta {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "elysia",
3
3
  "description": "Ergonomic Framework for Human",
4
- "version": "2.0.0-beta.15",
4
+ "version": "2.0.0-beta.16",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",