hono 4.10.3 → 4.10.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/dist/cjs/jsx/base.js +5 -4
- package/dist/cjs/middleware/cache/index.js +7 -0
- package/dist/cjs/utils/url.js +5 -2
- package/dist/jsx/base.js +5 -4
- package/dist/middleware/cache/index.js +7 -0
- package/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/dist/types/adapter/cloudflare-pages/handler.d.ts +1 -1
- package/dist/types/adapter/cloudflare-workers/websocket.d.ts +1 -1
- package/dist/types/adapter/lambda-edge/handler.d.ts +2 -2
- package/dist/types/client/types.d.ts +7 -7
- package/dist/types/client/utils.d.ts +1 -1
- package/dist/types/compose.d.ts +1 -11
- package/dist/types/context.d.ts +19 -29
- package/dist/types/helper/adapter/index.d.ts +1 -1
- package/dist/types/helper/conninfo/types.d.ts +2 -2
- package/dist/types/helper/css/common.d.ts +1 -6
- package/dist/types/helper/factory/index.d.ts +39 -312
- package/dist/types/helper/proxy/index.d.ts +2 -5
- package/dist/types/helper/ssg/ssg.d.ts +1 -1
- package/dist/types/helper/websocket/index.d.ts +3 -2
- package/dist/types/hono-base.d.ts +15 -18
- package/dist/types/hono.d.ts +1 -1
- package/dist/types/jsx/base.d.ts +1 -4
- package/dist/types/jsx/dom/hooks/index.d.ts +3 -9
- package/dist/types/jsx/dom/index.d.ts +7 -28
- package/dist/types/jsx/dom/intrinsic-element/components.d.ts +6 -6
- package/dist/types/jsx/dom/render.d.ts +4 -28
- package/dist/types/jsx/dom/server.d.ts +7 -28
- package/dist/types/jsx/hooks/index.d.ts +5 -20
- package/dist/types/jsx/index.d.ts +7 -28
- package/dist/types/jsx/intrinsic-element/components.d.ts +4 -4
- package/dist/types/jsx/intrinsic-elements.d.ts +46 -46
- package/dist/types/middleware/compress/index.d.ts +1 -4
- package/dist/types/middleware/csrf/index.d.ts +1 -6
- package/dist/types/middleware/language/language.d.ts +3 -3
- package/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
- package/dist/types/middleware/secure-headers/secure-headers.d.ts +1 -1
- package/dist/types/preset/quick.d.ts +1 -1
- package/dist/types/preset/tiny.d.ts +1 -1
- package/dist/types/request.d.ts +4 -9
- package/dist/types/router/linear-router/router.d.ts +1 -0
- package/dist/types/router/pattern-router/router.d.ts +1 -0
- package/dist/types/router/reg-exp-router/matcher.d.ts +2 -9
- package/dist/types/router/reg-exp-router/node.d.ts +2 -4
- package/dist/types/router/reg-exp-router/prepared-router.d.ts +2 -6
- package/dist/types/router/reg-exp-router/router.d.ts +1 -0
- package/dist/types/router/reg-exp-router/trie.d.ts +2 -5
- package/dist/types/router/smart-router/router.d.ts +1 -0
- package/dist/types/router/trie-router/node.d.ts +2 -6
- package/dist/types/router/trie-router/router.d.ts +1 -0
- package/dist/types/router.d.ts +2 -20
- package/dist/types/types.d.ts +113 -1994
- package/dist/types/utils/cookie.d.ts +4 -4
- package/dist/types/utils/headers.d.ts +3 -3
- package/dist/types/utils/html.d.ts +2 -6
- package/dist/types/utils/jwt/jwt.d.ts +1 -1
- package/dist/types/utils/mime.d.ts +2 -2
- package/dist/types/utils/stream.d.ts +4 -0
- package/dist/types/utils/url.d.ts +1 -5
- package/dist/types/validator/validator.d.ts +6 -18
- package/dist/utils/url.js +5 -2
- package/package.json +2 -1
package/dist/cjs/jsx/base.js
CHANGED
|
@@ -206,10 +206,11 @@ class JSXNode {
|
|
|
206
206
|
class JSXFunctionNode extends JSXNode {
|
|
207
207
|
toStringToBuffer(buffer) {
|
|
208
208
|
const { children } = this;
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
children
|
|
212
|
-
}
|
|
209
|
+
const props = { ...this.props };
|
|
210
|
+
if (children.length) {
|
|
211
|
+
props.children = children.length === 1 ? children[0] : children;
|
|
212
|
+
}
|
|
213
|
+
const res = this.tag.call(null, props);
|
|
213
214
|
if (typeof res === "boolean" || res == null) {
|
|
214
215
|
return;
|
|
215
216
|
} else if (res instanceof Promise) {
|
|
@@ -22,6 +22,10 @@ __export(cache_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(cache_exports);
|
|
24
24
|
const defaultCacheableStatusCodes = [200];
|
|
25
|
+
const shouldSkipCache = (res) => {
|
|
26
|
+
const vary = res.headers.get("Vary");
|
|
27
|
+
return vary && vary.includes("*");
|
|
28
|
+
};
|
|
25
29
|
const cache = (options) => {
|
|
26
30
|
if (!globalThis.caches) {
|
|
27
31
|
console.log("Cache Middleware is not enabled because caches is not defined.");
|
|
@@ -81,6 +85,9 @@ const cache = (options) => {
|
|
|
81
85
|
return;
|
|
82
86
|
}
|
|
83
87
|
addHeader(c);
|
|
88
|
+
if (shouldSkipCache(c.res)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
84
91
|
const res = c.res.clone();
|
|
85
92
|
if (options.wait) {
|
|
86
93
|
await cache3.put(key, res);
|
package/dist/cjs/utils/url.js
CHANGED
|
@@ -167,9 +167,12 @@ const _decodeURI = (value) => {
|
|
|
167
167
|
const _getQueryParam = (url, key, multiple) => {
|
|
168
168
|
let encoded;
|
|
169
169
|
if (!multiple && key && !/[%+]/.test(key)) {
|
|
170
|
-
let keyIndex2 = url.indexOf(
|
|
170
|
+
let keyIndex2 = url.indexOf("?", 8);
|
|
171
171
|
if (keyIndex2 === -1) {
|
|
172
|
-
|
|
172
|
+
return void 0;
|
|
173
|
+
}
|
|
174
|
+
if (!url.startsWith(key, keyIndex2 + 1)) {
|
|
175
|
+
keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
|
|
173
176
|
}
|
|
174
177
|
while (keyIndex2 !== -1) {
|
|
175
178
|
const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
|
package/dist/jsx/base.js
CHANGED
|
@@ -167,10 +167,11 @@ var JSXNode = class {
|
|
|
167
167
|
var JSXFunctionNode = class extends JSXNode {
|
|
168
168
|
toStringToBuffer(buffer) {
|
|
169
169
|
const { children } = this;
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
children
|
|
173
|
-
}
|
|
170
|
+
const props = { ...this.props };
|
|
171
|
+
if (children.length) {
|
|
172
|
+
props.children = children.length === 1 ? children[0] : children;
|
|
173
|
+
}
|
|
174
|
+
const res = this.tag.call(null, props);
|
|
174
175
|
if (typeof res === "boolean" || res == null) {
|
|
175
176
|
return;
|
|
176
177
|
} else if (res instanceof Promise) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// src/middleware/cache/index.ts
|
|
2
2
|
var defaultCacheableStatusCodes = [200];
|
|
3
|
+
var shouldSkipCache = (res) => {
|
|
4
|
+
const vary = res.headers.get("Vary");
|
|
5
|
+
return vary && vary.includes("*");
|
|
6
|
+
};
|
|
3
7
|
var cache = (options) => {
|
|
4
8
|
if (!globalThis.caches) {
|
|
5
9
|
console.log("Cache Middleware is not enabled because caches is not defined.");
|
|
@@ -59,6 +63,9 @@ var cache = (options) => {
|
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
addHeader(c);
|
|
66
|
+
if (shouldSkipCache(c.res)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
62
69
|
const res = c.res.clone();
|
|
63
70
|
if (options.wait) {
|
|
64
71
|
await cache3.put(key, res);
|
|
@@ -125,7 +125,7 @@ export declare abstract class EventProcessor<E extends LambdaEvent> {
|
|
|
125
125
|
protected abstract getCookies(event: E, headers: Headers): void;
|
|
126
126
|
protected abstract setCookiesToResult(result: APIGatewayProxyResult, cookies: string[]): void;
|
|
127
127
|
createRequest(event: E): Request;
|
|
128
|
-
createResult(event: E, res: Response, options: Pick<HandleOptions,
|
|
128
|
+
createResult(event: E, res: Response, options: Pick<HandleOptions, 'isContentTypeBinary'>): Promise<APIGatewayProxyResult>;
|
|
129
129
|
setCookies(event: E, res: Response, result: APIGatewayProxyResult): void;
|
|
130
130
|
}
|
|
131
131
|
export declare class EventV2Processor extends EventProcessor<APIGatewayProxyEventV2> {
|
|
@@ -22,7 +22,7 @@ export declare function handleMiddleware<E extends Env = {}, P extends string =
|
|
|
22
22
|
Bindings: {
|
|
23
23
|
eventContext: EventContext;
|
|
24
24
|
};
|
|
25
|
-
}, P, I>): PagesFunction<E[
|
|
25
|
+
}, P, I>): PagesFunction<E['Bindings']>;
|
|
26
26
|
/**
|
|
27
27
|
*
|
|
28
28
|
* @description `serveStatic()` is for advanced mode:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { UpgradeWebSocket, WSEvents } from '../../helper/websocket';
|
|
2
|
-
export declare const upgradeWebSocket: UpgradeWebSocket<WebSocket, any, Omit<WSEvents<WebSocket>,
|
|
2
|
+
export declare const upgradeWebSocket: UpgradeWebSocket<WebSocket, any, Omit<WSEvents<WebSocket>, 'onOpen'>>;
|
|
@@ -17,7 +17,7 @@ interface CloudFrontCustomOrigin {
|
|
|
17
17
|
sslProtocols: string[];
|
|
18
18
|
}
|
|
19
19
|
interface CloudFrontS3Origin {
|
|
20
|
-
authMethod:
|
|
20
|
+
authMethod: 'origin-access-identity' | 'none';
|
|
21
21
|
customHeaders: CloudFrontHeaders;
|
|
22
22
|
domainName: string;
|
|
23
23
|
path: string;
|
|
@@ -79,7 +79,7 @@ interface CloudFrontResult {
|
|
|
79
79
|
}[];
|
|
80
80
|
};
|
|
81
81
|
body?: string;
|
|
82
|
-
bodyEncoding?:
|
|
82
|
+
bodyEncoding?: 'text' | 'base64';
|
|
83
83
|
}
|
|
84
84
|
export declare const handle: (app: Hono<any>) => ((event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult>);
|
|
85
85
|
export declare const createBody: (method: string, requestBody: CloudFrontRequest["body"]) => string | Uint8Array<ArrayBuffer> | undefined;
|
|
@@ -3,7 +3,7 @@ import type { HonoBase } from '../hono-base';
|
|
|
3
3
|
import type { Endpoint, ResponseFormat, Schema } from '../types';
|
|
4
4
|
import type { StatusCode, SuccessStatusCode } from '../utils/http-status';
|
|
5
5
|
import type { HasRequiredKeys } from '../utils/types';
|
|
6
|
-
type HonoRequest = (typeof Hono.prototype)[
|
|
6
|
+
type HonoRequest = (typeof Hono.prototype)['request'];
|
|
7
7
|
export type ClientRequestOptions<T = unknown> = {
|
|
8
8
|
fetch?: typeof fetch | HonoRequest;
|
|
9
9
|
webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket;
|
|
@@ -40,9 +40,9 @@ export type ClientRequest<S extends Schema> = {
|
|
|
40
40
|
} ? {
|
|
41
41
|
query: Q;
|
|
42
42
|
} : {} : {}) => URL;
|
|
43
|
-
} & (S[
|
|
44
|
-
outputFormat:
|
|
45
|
-
} ? S[
|
|
43
|
+
} & (S['$get'] extends {
|
|
44
|
+
outputFormat: 'ws';
|
|
45
|
+
} ? S['$get'] extends {
|
|
46
46
|
input: infer I;
|
|
47
47
|
} ? {
|
|
48
48
|
$ws: (args?: I) => WebSocket;
|
|
@@ -62,8 +62,8 @@ export interface ClientResponse<T, U extends number = StatusCode, F extends Resp
|
|
|
62
62
|
url: string;
|
|
63
63
|
redirect(url: string, status: number): Response;
|
|
64
64
|
clone(): Response;
|
|
65
|
-
json(): F extends
|
|
66
|
-
text(): F extends
|
|
65
|
+
json(): F extends 'text' ? Promise<never> : F extends 'json' ? Promise<T> : Promise<unknown>;
|
|
66
|
+
text(): F extends 'text' ? (T extends string ? Promise<T> : Promise<never>) : Promise<string>;
|
|
67
67
|
blob(): Promise<Blob>;
|
|
68
68
|
formData(): Promise<FormData>;
|
|
69
69
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
@@ -96,7 +96,7 @@ export type FilterClientResponseByStatusCode<T extends ClientResponse<any, any,
|
|
|
96
96
|
type PathToChain<Path extends string, E extends Schema, Original extends string = Path> = Path extends `/${infer P}` ? PathToChain<P, E, Path> : Path extends `${infer P}/${infer R}` ? {
|
|
97
97
|
[K in P]: PathToChain<R, E, Original>;
|
|
98
98
|
} : {
|
|
99
|
-
[K in Path extends
|
|
99
|
+
[K in Path extends '' ? 'index' : Path]: ClientRequest<E extends Record<string, unknown> ? E[Original] : never>;
|
|
100
100
|
};
|
|
101
101
|
export type Client<T> = T extends HonoBase<any, infer S, any> ? S extends Record<infer K, Schema> ? K extends string ? PathToChain<K, S> : never : never : never;
|
|
102
102
|
export type Callback = (opts: CallbackOptions) => unknown;
|
|
@@ -15,4 +15,4 @@ export declare function deepMerge<T>(target: T, source: Record<string, unknown>)
|
|
|
15
15
|
*
|
|
16
16
|
* @example const result = await parseResponse(client.posts.$get())
|
|
17
17
|
*/
|
|
18
|
-
export declare function parseResponse<T extends ClientResponse<any>>(fetchRes: T | Promise<T>): Promise<FilterClientResponseByStatusCode<T, Exclude<ContentfulStatusCode, ClientErrorStatusCode | ServerErrorStatusCode>> extends never ? undefined : FilterClientResponseByStatusCode<T, Exclude<ContentfulStatusCode, ClientErrorStatusCode | ServerErrorStatusCode>> extends ClientResponse<infer RT, infer _, infer RF> ? RF extends
|
|
18
|
+
export declare function parseResponse<T extends ClientResponse<any>>(fetchRes: T | Promise<T>): Promise<FilterClientResponseByStatusCode<T, Exclude<ContentfulStatusCode, ClientErrorStatusCode | ServerErrorStatusCode>> extends never ? undefined : FilterClientResponseByStatusCode<T, Exclude<ContentfulStatusCode, ClientErrorStatusCode | ServerErrorStatusCode>> extends ClientResponse<infer RT, infer _, infer RF> ? RF extends 'json' ? RT : RT extends string ? RT : string : undefined>;
|
package/dist/types/compose.d.ts
CHANGED
|
@@ -11,14 +11,4 @@ import type { Env, ErrorHandler, Next, NotFoundHandler } from './types';
|
|
|
11
11
|
*
|
|
12
12
|
* @returns {(context: Context, next?: Next) => Promise<Context>} - A composed middleware function.
|
|
13
13
|
*/
|
|
14
|
-
export declare const compose: <E extends Env = Env>(middleware: [
|
|
15
|
-
[
|
|
16
|
-
Function,
|
|
17
|
-
unknown
|
|
18
|
-
],
|
|
19
|
-
unknown
|
|
20
|
-
][] | [
|
|
21
|
-
[
|
|
22
|
-
Function
|
|
23
|
-
]
|
|
24
|
-
][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>) => ((context: Context, next?: Next) => Promise<Context>);
|
|
14
|
+
export declare const compose: <E extends Env = Env>(middleware: [[Function, unknown], unknown][] | [[Function]][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>) => ((context: Context, next?: Next) => Promise<Context>);
|
package/dist/types/context.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ResponseHeader } from './utils/headers';
|
|
|
5
5
|
import type { ContentfulStatusCode, RedirectStatusCode, StatusCode } from './utils/http-status';
|
|
6
6
|
import type { BaseMime } from './utils/mime';
|
|
7
7
|
import type { InvalidJSONValue, IsAny, JSONParsed, JSONValue } from './utils/types';
|
|
8
|
-
type HeaderRecord = Record<
|
|
8
|
+
type HeaderRecord = Record<'Content-Type', BaseMime> | Record<ResponseHeader, string | string[]> | Record<string, string | string[]>;
|
|
9
9
|
/**
|
|
10
10
|
* Data type can be a string, ArrayBuffer, Uint8Array (buffer), or ReadableStream.
|
|
11
11
|
*/
|
|
@@ -56,12 +56,7 @@ export type Renderer = ContextRenderer extends Function ? ContextRenderer : Defa
|
|
|
56
56
|
/**
|
|
57
57
|
* Extracts the props for the renderer.
|
|
58
58
|
*/
|
|
59
|
-
export type PropsForRenderer = [
|
|
60
|
-
...Required<Parameters<Renderer>>
|
|
61
|
-
] extends [
|
|
62
|
-
unknown,
|
|
63
|
-
infer Props
|
|
64
|
-
] ? Props : unknown;
|
|
59
|
+
export type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props] ? Props : unknown;
|
|
65
60
|
export type Layout<T = Record<string, any>> = (props: T) => any;
|
|
66
61
|
/**
|
|
67
62
|
* Interface for getting context variables.
|
|
@@ -69,7 +64,7 @@ export type Layout<T = Record<string, any>> = (props: T) => any;
|
|
|
69
64
|
* @template E - Environment type.
|
|
70
65
|
*/
|
|
71
66
|
interface Get<E extends Env> {
|
|
72
|
-
<Key extends keyof E[
|
|
67
|
+
<Key extends keyof E['Variables']>(key: Key): E['Variables'][Key];
|
|
73
68
|
<Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key];
|
|
74
69
|
}
|
|
75
70
|
/**
|
|
@@ -78,7 +73,7 @@ interface Get<E extends Env> {
|
|
|
78
73
|
* @template E - Environment type.
|
|
79
74
|
*/
|
|
80
75
|
interface Set<E extends Env> {
|
|
81
|
-
<Key extends keyof E[
|
|
76
|
+
<Key extends keyof E['Variables']>(key: Key, value: E['Variables'][Key]): void;
|
|
82
77
|
<Key extends keyof ContextVariableMap>(key: Key, value: ContextVariableMap[Key]): void;
|
|
83
78
|
}
|
|
84
79
|
/**
|
|
@@ -92,10 +87,10 @@ interface NewResponse {
|
|
|
92
87
|
* Interface for responding with a body.
|
|
93
88
|
*/
|
|
94
89
|
interface BodyRespond {
|
|
95
|
-
<T extends Data, U extends ContentfulStatusCode>(data: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U,
|
|
96
|
-
<T extends Data, U extends ContentfulStatusCode>(data: T, init?: ResponseOrInit<U>): Response & TypedResponse<T, U,
|
|
97
|
-
<T extends null, U extends StatusCode>(data: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<null, U,
|
|
98
|
-
<T extends null, U extends StatusCode>(data: T, init?: ResponseOrInit<U>): Response & TypedResponse<null, U,
|
|
90
|
+
<T extends Data, U extends ContentfulStatusCode>(data: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, 'body'>;
|
|
91
|
+
<T extends Data, U extends ContentfulStatusCode>(data: T, init?: ResponseOrInit<U>): Response & TypedResponse<T, U, 'body'>;
|
|
92
|
+
<T extends null, U extends StatusCode>(data: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<null, U, 'body'>;
|
|
93
|
+
<T extends null, U extends StatusCode>(data: T, init?: ResponseOrInit<U>): Response & TypedResponse<null, U, 'body'>;
|
|
99
94
|
}
|
|
100
95
|
/**
|
|
101
96
|
* Interface for responding with text.
|
|
@@ -111,8 +106,8 @@ interface BodyRespond {
|
|
|
111
106
|
* @returns {Response & TypedResponse<T, U, 'text'>} - The response after rendering the text content, typed with the provided text and status code types.
|
|
112
107
|
*/
|
|
113
108
|
interface TextRespond {
|
|
114
|
-
<T extends string, U extends ContentfulStatusCode = ContentfulStatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U,
|
|
115
|
-
<T extends string, U extends ContentfulStatusCode = ContentfulStatusCode>(text: T, init?: ResponseOrInit<U>): Response & TypedResponse<T, U,
|
|
109
|
+
<T extends string, U extends ContentfulStatusCode = ContentfulStatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, 'text'>;
|
|
110
|
+
<T extends string, U extends ContentfulStatusCode = ContentfulStatusCode>(text: T, init?: ResponseOrInit<U>): Response & TypedResponse<T, U, 'text'>;
|
|
116
111
|
}
|
|
117
112
|
/**
|
|
118
113
|
* Interface for responding with JSON.
|
|
@@ -137,7 +132,7 @@ interface JSONRespond {
|
|
|
137
132
|
*
|
|
138
133
|
* @returns {Response & TypedResponse<JSONParsed<T>, U, 'json'>} - The response after rendering the JSON object, typed with the provided object and status code types.
|
|
139
134
|
*/
|
|
140
|
-
type JSONRespondReturn<T extends JSONValue | {} | InvalidJSONValue, U extends ContentfulStatusCode> = Response & TypedResponse<JSONParsed<T>, U,
|
|
135
|
+
type JSONRespondReturn<T extends JSONValue | {} | InvalidJSONValue, U extends ContentfulStatusCode> = Response & TypedResponse<JSONParsed<T>, U, 'json'>;
|
|
141
136
|
/**
|
|
142
137
|
* Interface representing a function that responds with HTML content.
|
|
143
138
|
*
|
|
@@ -161,7 +156,7 @@ type ContextOptions<E extends Env> = {
|
|
|
161
156
|
/**
|
|
162
157
|
* Bindings for the environment.
|
|
163
158
|
*/
|
|
164
|
-
env: E[
|
|
159
|
+
env: E['Bindings'];
|
|
165
160
|
/**
|
|
166
161
|
* Execution context for the request.
|
|
167
162
|
*/
|
|
@@ -170,24 +165,18 @@ type ContextOptions<E extends Env> = {
|
|
|
170
165
|
* Handler for not found responses.
|
|
171
166
|
*/
|
|
172
167
|
notFoundHandler?: NotFoundHandler<E>;
|
|
173
|
-
matchResult?: Result<[
|
|
174
|
-
H,
|
|
175
|
-
RouterRoute
|
|
176
|
-
]>;
|
|
168
|
+
matchResult?: Result<[H, RouterRoute]>;
|
|
177
169
|
path?: string;
|
|
178
170
|
};
|
|
179
171
|
interface SetHeadersOptions {
|
|
180
172
|
append?: boolean;
|
|
181
173
|
}
|
|
182
174
|
interface SetHeaders {
|
|
183
|
-
(name:
|
|
175
|
+
(name: 'Content-Type', value?: BaseMime, options?: SetHeadersOptions): void;
|
|
184
176
|
(name: ResponseHeader, value?: string, options?: SetHeadersOptions): void;
|
|
185
177
|
(name: string, value?: string, options?: SetHeadersOptions): void;
|
|
186
178
|
}
|
|
187
|
-
type ResponseHeadersInit = [
|
|
188
|
-
string,
|
|
189
|
-
string
|
|
190
|
-
][] | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string> | Record<string, string> | Headers;
|
|
179
|
+
type ResponseHeadersInit = [string, string][] | Record<'Content-Type', BaseMime> | Record<ResponseHeader, string> | Record<string, string> | Headers;
|
|
191
180
|
interface ResponseInit<T extends StatusCode = StatusCode> {
|
|
192
181
|
headers?: ResponseHeadersInit;
|
|
193
182
|
status?: T;
|
|
@@ -196,6 +185,7 @@ interface ResponseInit<T extends StatusCode = StatusCode> {
|
|
|
196
185
|
type ResponseOrInit<T extends StatusCode = StatusCode> = ResponseInit<T> | Response;
|
|
197
186
|
export declare const TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
198
187
|
export declare class Context<E extends Env = any, P extends string = any, I extends Input = {}> {
|
|
188
|
+
|
|
199
189
|
/**
|
|
200
190
|
* `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
|
|
201
191
|
*
|
|
@@ -209,7 +199,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
|
|
|
209
199
|
* })
|
|
210
200
|
* ```
|
|
211
201
|
*/
|
|
212
|
-
env: E[
|
|
202
|
+
env: E['Bindings'];
|
|
213
203
|
finalized: boolean;
|
|
214
204
|
/**
|
|
215
205
|
* `.error` can get the error object from the middleware if the Handler throws an error.
|
|
@@ -237,7 +227,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
|
|
|
237
227
|
/**
|
|
238
228
|
* `.req` is the instance of {@link HonoRequest}.
|
|
239
229
|
*/
|
|
240
|
-
get req(): HonoRequest<P, I[
|
|
230
|
+
get req(): HonoRequest<P, I['out']>;
|
|
241
231
|
/**
|
|
242
232
|
* @see {@link https://hono.dev/docs/api/context#event}
|
|
243
233
|
* The FetchEvent associated with the current request.
|
|
@@ -377,7 +367,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
|
|
|
377
367
|
* const result = c.var.client.oneMethod()
|
|
378
368
|
* ```
|
|
379
369
|
*/
|
|
380
|
-
get var(): Readonly<ContextVariableMap & (IsAny<E[
|
|
370
|
+
get var(): Readonly<ContextVariableMap & (IsAny<E['Variables']> extends true ? Record<string, any> : E['Variables'])>;
|
|
381
371
|
newResponse: NewResponse;
|
|
382
372
|
/**
|
|
383
373
|
* `.body()` can return the HTTP response.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Adapter Helper for Hono.
|
|
4
4
|
*/
|
|
5
5
|
import type { Context } from '../../context';
|
|
6
|
-
export type Runtime =
|
|
6
|
+
export type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'other';
|
|
7
7
|
export declare const env: <T extends Record<string, unknown>, C extends Context = Context<{
|
|
8
8
|
Bindings: T;
|
|
9
9
|
}>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Context } from '../../context';
|
|
2
|
-
export type AddressType =
|
|
2
|
+
export type AddressType = 'IPv6' | 'IPv4' | undefined;
|
|
3
3
|
export type NetAddrInfo = {
|
|
4
4
|
/**
|
|
5
5
|
* Transport protocol type
|
|
6
6
|
*/
|
|
7
|
-
transport?:
|
|
7
|
+
transport?: 'tcp' | 'udp';
|
|
8
8
|
/**
|
|
9
9
|
* Transport port number
|
|
10
10
|
*/
|
|
@@ -29,12 +29,7 @@ type CssVariableBasicType = CssClassName | CssEscapedString | string | number |
|
|
|
29
29
|
type CssVariableAsyncType = Promise<CssVariableBasicType>;
|
|
30
30
|
type CssVariableArrayType = (CssVariableBasicType | CssVariableAsyncType)[];
|
|
31
31
|
export type CssVariableType = CssVariableBasicType | CssVariableAsyncType | CssVariableArrayType;
|
|
32
|
-
export declare const buildStyleString: (strings: TemplateStringsArray, values: CssVariableType[]) => [
|
|
33
|
-
string,
|
|
34
|
-
string,
|
|
35
|
-
CssClassName[],
|
|
36
|
-
string[]
|
|
37
|
-
];
|
|
32
|
+
export declare const buildStyleString: (strings: TemplateStringsArray, values: CssVariableType[]) => [string, string, CssClassName[], string[]];
|
|
38
33
|
export declare const cssCommon: (strings: TemplateStringsArray, values: CssVariableType[]) => CssClassName;
|
|
39
34
|
export declare const cxCommon: (args: (string | boolean | null | undefined | CssClassName)[]) => (string | boolean | null | undefined | CssClassName)[];
|
|
40
35
|
export declare const keyframesCommon: (strings: TemplateStringsArray, ...values: CssVariableType[]) => CssClassName;
|