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 +1 -1
- package/dist/cjs/context.js +3 -7
- package/dist/context.js +3 -7
- package/dist/types/context.d.ts +3 -3
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils/types.d.ts +4 -1
- package/package.json +1 -1
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
|
|
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".
|
package/dist/cjs/context.js
CHANGED
|
@@ -115,14 +115,9 @@ class Context {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
if (arg && typeof arg !== "number") {
|
|
118
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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)) {
|
package/dist/types/context.d.ts
CHANGED
|
@@ -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>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -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
|
};
|