elysia 2.0.0-beta.7 → 2.0.0-beta.9

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.
@@ -211,6 +211,10 @@ function composeRootHook(root, inheritedChain) {
211
211
  if (!locals) return inherited;
212
212
  return require_utils.mergeHook(inherited, locals);
213
213
  }
214
+ function staticPrimitiveType(response, value) {
215
+ if ((typeof value === "string" || typeof value === "number" || typeof value === "boolean") && !response.headers.has("content-type")) response.headers.set("content-type", "text/plain;charset=utf-8");
216
+ return response;
217
+ }
214
218
  function buildNativeStaticResponse(route, root) {
215
219
  const [, , handler, instance, localHook, appHook, inheritedChain, macroScope] = route;
216
220
  if (typeof handler === "function" || handler instanceof Error || handler instanceof Promise) return;
@@ -221,10 +225,7 @@ function buildNativeStaticResponse(route, root) {
221
225
  const rootHeaders = frozenRoot["~ext"]?.headers;
222
226
  if (handler instanceof Response && !rootHeaders) return handler;
223
227
  const mapped = adapter.response.map(handler, { headers: rootHeaders ? Object.assign(require_utils.nullObject(), rootHeaders) : require_utils.nullObject() });
224
- if (mapped instanceof Response) {
225
- if (!mapped.headers.has("content-type") && (typeof handler === "string" || typeof handler === "number" || typeof handler === "boolean")) mapped.headers.set("content-type", "text/plain;charset=utf-8");
226
- return mapped;
227
- }
228
+ if (mapped instanceof Response) return staticPrimitiveType(mapped, handler);
228
229
  }
229
230
  function toArray(name, hook) {
230
231
  if (typeof hook[name] === "function") hook[name] = [hook[name]];
@@ -320,7 +321,7 @@ function compileHandler(route, root, precomputedStatic, liveOnly = false) {
320
321
  const rootHeaders = frozenRoot["~ext"]?.headers;
321
322
  const set = { headers: rootHeaders ? Object.assign(require_utils.nullObject(), rootHeaders) : require_utils.nullObject() };
322
323
  const mapped = adapter.response.map(handler, set);
323
- if (mapped instanceof Response) handler = mapped;
324
+ if (mapped instanceof Response) handler = staticPrimitiveType(mapped, handler);
324
325
  }
325
326
  const isStaticResponse = !isHandleFunction && handler instanceof Response;
326
327
  const isPromiseHandler = !isHandleFunction && handler instanceof Promise;
@@ -210,6 +210,10 @@ function composeRootHook(root, inheritedChain) {
210
210
  if (!locals) return inherited;
211
211
  return mergeHook(inherited, locals);
212
212
  }
213
+ function staticPrimitiveType(response, value) {
214
+ if ((typeof value === "string" || typeof value === "number" || typeof value === "boolean") && !response.headers.has("content-type")) response.headers.set("content-type", "text/plain;charset=utf-8");
215
+ return response;
216
+ }
213
217
  function buildNativeStaticResponse(route, root) {
214
218
  const [, , handler, instance, localHook, appHook, inheritedChain, macroScope] = route;
215
219
  if (typeof handler === "function" || handler instanceof Error || handler instanceof Promise) return;
@@ -220,10 +224,7 @@ function buildNativeStaticResponse(route, root) {
220
224
  const rootHeaders = frozenRoot["~ext"]?.headers;
221
225
  if (handler instanceof Response && !rootHeaders) return handler;
222
226
  const mapped = adapter.response.map(handler, { headers: rootHeaders ? Object.assign(nullObject(), rootHeaders) : nullObject() });
223
- if (mapped instanceof Response) {
224
- if (!mapped.headers.has("content-type") && (typeof handler === "string" || typeof handler === "number" || typeof handler === "boolean")) mapped.headers.set("content-type", "text/plain;charset=utf-8");
225
- return mapped;
226
- }
227
+ if (mapped instanceof Response) return staticPrimitiveType(mapped, handler);
227
228
  }
228
229
  function toArray(name, hook) {
229
230
  if (typeof hook[name] === "function") hook[name] = [hook[name]];
@@ -319,7 +320,7 @@ function compileHandler(route, root, precomputedStatic, liveOnly = false) {
319
320
  const rootHeaders = frozenRoot["~ext"]?.headers;
320
321
  const set = { headers: rootHeaders ? Object.assign(nullObject(), rootHeaders) : nullObject() };
321
322
  const mapped = adapter.response.map(handler, set);
322
- if (mapped instanceof Response) handler = mapped;
323
+ if (mapped instanceof Response) handler = staticPrimitiveType(mapped, handler);
323
324
  }
324
325
  const isStaticResponse = !isHandleFunction && handler instanceof Response;
325
326
  const isPromiseHandler = !isHandleFunction && handler instanceof Promise;
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.0.0-beta.7";
3
+ var version = "2.0.0-beta.9";
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.7";
2
+ var version = "2.0.0-beta.9";
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) => "esm" | "cjs";
98
+ declare const resolveEntryModuleKind: (entry: string) => "cjs" | "esm";
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. */
@@ -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<1 | 2 | 6 | 3 | 10 | 14 | 13 | 11>;
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
  };
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.7",
4
+ "version": "2.0.0-beta.9",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",
@@ -45,6 +45,11 @@
45
45
  "import": "./dist/adapter/web-standard/handler.mjs",
46
46
  "require": "./dist/adapter/web-standard/handler.js"
47
47
  },
48
+ "./adapter/response-ownership": {
49
+ "types": "./dist/adapter/response-ownership.d.ts",
50
+ "import": "./dist/adapter/response-ownership.mjs",
51
+ "require": "./dist/adapter/response-ownership.js"
52
+ },
48
53
  "./base": {
49
54
  "types": "./dist/base.d.ts",
50
55
  "import": "./dist/base.mjs",