hono 3.11.3 → 3.11.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.
package/README.md CHANGED
@@ -48,7 +48,7 @@ npm create hono@latest my-app
48
48
  ## Features
49
49
 
50
50
  - **Ultrafast** 🚀 - The router `RegExpRouter` is really fast. Not using linear loops. Fast.
51
- - **Lightweight** ðŸŠķ - The `hono/tiny` preset is under 12kB. Hono has zero dependencies and uses only the Web Standard API.
51
+ - **Lightweight** ðŸŠķ - The `hono/tiny` preset is under 14kB. Hono has zero dependencies and uses only the Web Standard API.
52
52
  - **Multi-runtime** 🌍 - Works on Cloudflare Workers, Fastly Compute, Deno, Bun, Lagon, AWS Lambda, Lambda@Edge, or Node.js. The same code runs on all platforms.
53
53
  - **Batteries Included** 🔋 - Hono has built-in middleware, custom middleware, and third-party middleware. Batteries included.
54
54
  - **Delightful DX** 😃 - Super clean APIs. First-class TypeScript support. Now, we've got "Types".
@@ -115,14 +115,9 @@ class Context {
115
115
  });
116
116
  }
117
117
  if (arg && typeof arg !== "number") {
118
- const res = new Response(data, arg);
119
- const contentType = __privateGet(this, _preparedHeaders)?.["content-type"];
120
- if (contentType) {
121
- res.headers.set("content-type", contentType);
122
- }
123
- return res;
118
+ this.res = new Response(data, arg);
124
119
  }
125
- const status = arg ?? __privateGet(this, _status);
120
+ let status = typeof arg === "number" ? arg : __privateGet(this, _status);
126
121
  __privateGet(this, _preparedHeaders) ?? __privateSet(this, _preparedHeaders, {});
127
122
  __privateGet(this, _headers) ?? __privateSet(this, _headers, new Headers());
128
123
  for (const [k, v] of Object.entries(__privateGet(this, _preparedHeaders))) {
@@ -135,6 +130,7 @@ class Context {
135
130
  for (const [k, v] of Object.entries(__privateGet(this, _preparedHeaders))) {
136
131
  __privateGet(this, _headers).set(k, v);
137
132
  }
133
+ status = __privateGet(this, _res).status;
138
134
  }
139
135
  headers ?? (headers = {});
140
136
  for (const [k, v] of Object.entries(headers)) {
package/dist/context.js CHANGED
@@ -94,14 +94,9 @@ var Context = class {
94
94
  });
95
95
  }
96
96
  if (arg && typeof arg !== "number") {
97
- const res = new Response(data, arg);
98
- const contentType = __privateGet(this, _preparedHeaders)?.["content-type"];
99
- if (contentType) {
100
- res.headers.set("content-type", contentType);
101
- }
102
- return res;
97
+ this.res = new Response(data, arg);
103
98
  }
104
- const status = arg ?? __privateGet(this, _status);
99
+ let status = typeof arg === "number" ? arg : __privateGet(this, _status);
105
100
  __privateGet(this, _preparedHeaders) ?? __privateSet(this, _preparedHeaders, {});
106
101
  __privateGet(this, _headers) ?? __privateSet(this, _headers, new Headers());
107
102
  for (const [k, v] of Object.entries(__privateGet(this, _preparedHeaders))) {
@@ -114,6 +109,7 @@ var Context = class {
114
109
  for (const [k, v] of Object.entries(__privateGet(this, _preparedHeaders))) {
115
110
  __privateGet(this, _headers).set(k, v);
116
111
  }
112
+ status = __privateGet(this, _res).status;
117
113
  }
118
114
  headers ?? (headers = {});
119
115
  for (const [k, v] of Object.entries(headers)) {
@@ -4,7 +4,7 @@ import type { Env, FetchEventLike, NotFoundHandler, Input, TypedResponse } from
4
4
  import type { CookieOptions } from './utils/cookie';
5
5
  import type { StatusCode } from './utils/http-status';
6
6
  import { StreamingApi } from './utils/stream';
7
- import type { JSONValue, InterfaceToType } from './utils/types';
7
+ import type { JSONValue, InterfaceToType, JSONParsed } from './utils/types';
8
8
  declare type HeaderRecord = Record<string, string | string[]>;
9
9
  declare type Data = string | ArrayBuffer | ReadableStream;
10
10
  export interface ExecutionContext {
@@ -38,8 +38,8 @@ interface TextRespond {
38
38
  (text: string, init?: ResponseInit): Response;
39
39
  }
40
40
  interface JSONRespond {
41
- <T>(object: InterfaceToType<T> extends JSONValue ? T : JSONValue, status?: StatusCode, headers?: HeaderRecord): Response & TypedResponse<InterfaceToType<T> extends JSONValue ? JSONValue extends InterfaceToType<T> ? never : T : never>;
42
- <T>(object: InterfaceToType<T> extends JSONValue ? T : JSONValue, init?: ResponseInit): Response & TypedResponse<InterfaceToType<T> extends JSONValue ? JSONValue extends InterfaceToType<T> ? never : T : never>;
41
+ <T>(object: InterfaceToType<T> extends JSONValue ? T : JSONValue, status?: StatusCode, headers?: HeaderRecord): Response & TypedResponse<InterfaceToType<T> extends JSONValue ? JSONValue extends InterfaceToType<T> ? never : JSONParsed<T> : never>;
42
+ <T>(object: InterfaceToType<T> extends JSONValue ? T : JSONValue, init?: ResponseInit): Response & TypedResponse<InterfaceToType<T> extends JSONValue ? JSONValue extends InterfaceToType<T> ? never : JSONParsed<T> : never>;
43
43
  }
44
44
  interface HTMLRespond {
45
45
  (html: string | Promise<string>, status?: StatusCode, headers?: HeaderRecord): Response | Promise<Response>;
@@ -306,7 +306,7 @@ export declare type Schema = {
306
306
  input: Partial<ValidationTargets> & {
307
307
  param?: Record<string, string>;
308
308
  };
309
- output: {};
309
+ output: any;
310
310
  };
311
311
  };
312
312
  };
@@ -8,9 +8,12 @@ export declare type IntersectNonAnyTypes<T extends any[]> = T extends [infer Hea
8
8
  export declare type JSONPrimitive = string | boolean | number | null | undefined;
9
9
  export declare type JSONArray = (JSONPrimitive | JSONObject | JSONArray)[];
10
10
  export declare type JSONObject = {
11
- [key: string]: JSONPrimitive | JSONArray | JSONObject;
11
+ [key: string]: JSONPrimitive | JSONArray | JSONObject | object;
12
12
  };
13
13
  export declare type JSONValue = JSONObject | JSONArray | JSONPrimitive;
14
+ export declare type JSONParsed<T> = {
15
+ [k in keyof T]: T[k] extends JSONValue ? T[k] : string;
16
+ };
14
17
  export declare type InterfaceToType<T> = T extends Function ? T : {
15
18
  [K in keyof T]: InterfaceToType<T[K]>;
16
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.11.3",
3
+ "version": "3.11.5",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",