hono 4.6.4 → 4.6.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.
Files changed (54) hide show
  1. package/dist/cjs/middleware/cors/index.js +6 -2
  2. package/dist/cjs/middleware/csrf/index.js +1 -1
  3. package/dist/cjs/middleware/powered-by/index.js +2 -2
  4. package/dist/middleware/cors/index.js +6 -2
  5. package/dist/middleware/csrf/index.js +1 -1
  6. package/dist/middleware/powered-by/index.js +2 -2
  7. package/dist/types/adapter/cloudflare-pages/handler.d.ts +1 -1
  8. package/dist/types/adapter/lambda-edge/handler.d.ts +2 -2
  9. package/dist/types/client/types.d.ts +9 -8
  10. package/dist/types/compose.d.ts +7 -1
  11. package/dist/types/context.d.ts +26 -16
  12. package/dist/types/helper/accepts/accepts.d.ts +1 -1
  13. package/dist/types/helper/adapter/index.d.ts +1 -1
  14. package/dist/types/helper/conninfo/types.d.ts +2 -2
  15. package/dist/types/helper/css/common.d.ts +6 -1
  16. package/dist/types/helper/factory/index.d.ts +31 -10
  17. package/dist/types/helper/ssg/ssg.d.ts +1 -1
  18. package/dist/types/helper/websocket/index.d.ts +1 -1
  19. package/dist/types/hono-base.d.ts +19 -22
  20. package/dist/types/hono.d.ts +1 -1
  21. package/dist/types/jsx/base.d.ts +4 -1
  22. package/dist/types/jsx/dom/hooks/index.d.ts +9 -3
  23. package/dist/types/jsx/dom/index.d.ts +28 -7
  24. package/dist/types/jsx/dom/intrinsic-element/components.d.ts +6 -6
  25. package/dist/types/jsx/dom/render.d.ts +28 -4
  26. package/dist/types/jsx/dom/server.d.ts +28 -7
  27. package/dist/types/jsx/hooks/index.d.ts +20 -5
  28. package/dist/types/jsx/index.d.ts +28 -7
  29. package/dist/types/jsx/intrinsic-element/components.d.ts +4 -4
  30. package/dist/types/jsx/intrinsic-elements.d.ts +46 -46
  31. package/dist/types/middleware/compress/index.d.ts +4 -1
  32. package/dist/types/middleware/powered-by/index.d.ts +5 -1
  33. package/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
  34. package/dist/types/middleware/secure-headers/secure-headers.d.ts +1 -1
  35. package/dist/types/preset/quick.d.ts +1 -1
  36. package/dist/types/preset/tiny.d.ts +1 -1
  37. package/dist/types/request.d.ts +5 -7
  38. package/dist/types/router/linear-router/router.d.ts +5 -1
  39. package/dist/types/router/pattern-router/router.d.ts +0 -1
  40. package/dist/types/router/reg-exp-router/node.d.ts +4 -1
  41. package/dist/types/router/reg-exp-router/router.d.ts +4 -3
  42. package/dist/types/router/reg-exp-router/trie.d.ts +5 -1
  43. package/dist/types/router/smart-router/router.d.ts +6 -2
  44. package/dist/types/router/trie-router/node.d.ts +6 -2
  45. package/dist/types/router.d.ts +20 -2
  46. package/dist/types/types.d.ts +908 -120
  47. package/dist/types/utils/cookie.d.ts +3 -3
  48. package/dist/types/utils/html.d.ts +6 -2
  49. package/dist/types/utils/jwt/jwt.d.ts +1 -1
  50. package/dist/types/utils/mime.d.ts +1 -1
  51. package/dist/types/utils/stream.d.ts +0 -4
  52. package/dist/types/utils/url.d.ts +5 -1
  53. package/dist/types/validator/validator.d.ts +18 -6
  54. package/package.json +8 -7
@@ -34,11 +34,15 @@ const cors = (options) => {
34
34
  };
35
35
  const findAllowOrigin = ((optsOrigin) => {
36
36
  if (typeof optsOrigin === "string") {
37
- return () => optsOrigin;
37
+ if (optsOrigin === "*") {
38
+ return () => optsOrigin;
39
+ } else {
40
+ return (origin) => optsOrigin === origin ? origin : null;
41
+ }
38
42
  } else if (typeof optsOrigin === "function") {
39
43
  return optsOrigin;
40
44
  } else {
41
- return (origin) => optsOrigin.includes(origin) ? origin : optsOrigin[0];
45
+ return (origin) => optsOrigin.includes(origin) ? origin : null;
42
46
  }
43
47
  })(opts.origin);
44
48
  return async function cors2(c, next) {
@@ -43,7 +43,7 @@ const csrf = (options) => {
43
43
  return handler(origin, c);
44
44
  };
45
45
  return async function csrf2(c, next) {
46
- if (!isSafeMethodRe.test(c.req.method) && isRequestedByFormElementRe.test(c.req.header("content-type") || "") && !isAllowedOrigin(c.req.header("origin"), c)) {
46
+ if (!isSafeMethodRe.test(c.req.method) && isRequestedByFormElementRe.test(c.req.header("content-type") || "text/plain") && !isAllowedOrigin(c.req.header("origin"), c)) {
47
47
  const res = new Response("Forbidden", {
48
48
  status: 403
49
49
  });
@@ -21,10 +21,10 @@ __export(powered_by_exports, {
21
21
  poweredBy: () => poweredBy
22
22
  });
23
23
  module.exports = __toCommonJS(powered_by_exports);
24
- const poweredBy = () => {
24
+ const poweredBy = (options) => {
25
25
  return async function poweredBy2(c, next) {
26
26
  await next();
27
- c.res.headers.set("X-Powered-By", "Hono");
27
+ c.res.headers.set("X-Powered-By", options?.serverName ?? "Hono");
28
28
  };
29
29
  };
30
30
  // Annotate the CommonJS export names for ESM import in node:
@@ -12,11 +12,15 @@ var cors = (options) => {
12
12
  };
13
13
  const findAllowOrigin = ((optsOrigin) => {
14
14
  if (typeof optsOrigin === "string") {
15
- return () => optsOrigin;
15
+ if (optsOrigin === "*") {
16
+ return () => optsOrigin;
17
+ } else {
18
+ return (origin) => optsOrigin === origin ? origin : null;
19
+ }
16
20
  } else if (typeof optsOrigin === "function") {
17
21
  return optsOrigin;
18
22
  } else {
19
- return (origin) => optsOrigin.includes(origin) ? origin : optsOrigin[0];
23
+ return (origin) => optsOrigin.includes(origin) ? origin : null;
20
24
  }
21
25
  })(opts.origin);
22
26
  return async function cors2(c, next) {
@@ -21,7 +21,7 @@ var csrf = (options) => {
21
21
  return handler(origin, c);
22
22
  };
23
23
  return async function csrf2(c, next) {
24
- if (!isSafeMethodRe.test(c.req.method) && isRequestedByFormElementRe.test(c.req.header("content-type") || "") && !isAllowedOrigin(c.req.header("origin"), c)) {
24
+ if (!isSafeMethodRe.test(c.req.method) && isRequestedByFormElementRe.test(c.req.header("content-type") || "text/plain") && !isAllowedOrigin(c.req.header("origin"), c)) {
25
25
  const res = new Response("Forbidden", {
26
26
  status: 403
27
27
  });
@@ -1,8 +1,8 @@
1
1
  // src/middleware/powered-by/index.ts
2
- var poweredBy = () => {
2
+ var poweredBy = (options) => {
3
3
  return async function poweredBy2(c, next) {
4
4
  await next();
5
- c.res.headers.set("X-Powered-By", "Hono");
5
+ c.res.headers.set("X-Powered-By", options?.serverName ?? "Hono");
6
6
  };
7
7
  };
8
8
  export {
@@ -21,7 +21,7 @@ export declare function handleMiddleware<E extends Env = {}, P extends string =
21
21
  Bindings: {
22
22
  eventContext: EventContext;
23
23
  };
24
- }, P, I>): PagesFunction<E['Bindings']>;
24
+ }, P, I>): PagesFunction<E["Bindings"]>;
25
25
  /**
26
26
  *
27
27
  * @description `serveStatic()` is for advanced mode:
@@ -17,7 +17,7 @@ interface CloudFrontCustomOrigin {
17
17
  sslProtocols: string[];
18
18
  }
19
19
  interface CloudFrontS3Origin {
20
- authMethod: 'origin-access-identity' | 'none';
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?: 'text' | 'base64';
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 | undefined;
@@ -1,8 +1,9 @@
1
1
  import type { Hono } from '../hono';
2
+ import type { HonoBase } from '../hono-base';
2
3
  import type { Endpoint, ResponseFormat, Schema } from '../types';
3
4
  import type { StatusCode, SuccessStatusCode } from '../utils/http-status';
4
5
  import type { HasRequiredKeys } from '../utils/types';
5
- type HonoRequest = (typeof Hono.prototype)['request'];
6
+ type HonoRequest = (typeof Hono.prototype)["request"];
6
7
  export type ClientRequestOptions<T = unknown> = {
7
8
  fetch?: typeof fetch | HonoRequest;
8
9
  webSocket?: (...args: ConstructorParameters<typeof WebSocket>) => WebSocket;
@@ -30,9 +31,9 @@ export type ClientRequest<S extends Schema> = {
30
31
  } ? {
31
32
  param: P;
32
33
  } : {} : {}) => URL;
33
- } & (S['$get'] extends {
34
- outputFormat: 'ws';
35
- } ? S['$get'] extends {
34
+ } & (S["$get"] extends {
35
+ outputFormat: "ws";
36
+ } ? S["$get"] extends {
36
37
  input: infer I;
37
38
  } ? {
38
39
  $ws: (args?: I) => WebSocket;
@@ -53,8 +54,8 @@ export interface ClientResponse<T, U extends number = StatusCode, F extends Resp
53
54
  url: string;
54
55
  redirect(url: string, status: number): Response;
55
56
  clone(): Response;
56
- json(): F extends 'text' ? Promise<never> : F extends 'json' ? Promise<BlankRecordToNever<T>> : Promise<unknown>;
57
- text(): F extends 'text' ? (T extends string ? Promise<T> : Promise<never>) : Promise<string>;
57
+ json(): F extends "text" ? Promise<never> : F extends "json" ? Promise<BlankRecordToNever<T>> : Promise<unknown>;
58
+ text(): F extends "text" ? (T extends string ? Promise<T> : Promise<never>) : Promise<string>;
58
59
  blob(): Promise<Blob>;
59
60
  formData(): Promise<FormData>;
60
61
  arrayBuffer(): Promise<ArrayBuffer>;
@@ -83,9 +84,9 @@ export type InferRequestOptionsType<T> = T extends (args: any, options: infer R)
83
84
  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}` ? {
84
85
  [K in P]: PathToChain<R, E, Original>;
85
86
  } : {
86
- [K in Path extends '' ? 'index' : Path]: ClientRequest<E extends Record<string, unknown> ? E[Original] : never>;
87
+ [K in Path extends "" ? "index" : Path]: ClientRequest<E extends Record<string, unknown> ? E[Original] : never>;
87
88
  };
88
- export type Client<T> = T extends Hono<any, infer S, any> ? S extends Record<infer K, Schema> ? K extends string ? PathToChain<K, S> : never : never : never;
89
+ 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;
89
90
  export type Callback = (opts: CallbackOptions) => unknown;
90
91
  interface CallbackOptions {
91
92
  path: string[];
@@ -26,5 +26,11 @@ interface ComposeContext {
26
26
  *
27
27
  * @returns {(context: C, next?: Function) => Promise<C>} - A composed middleware function.
28
28
  */
29
- export declare const compose: <C extends ComposeContext, E extends Env = Env>(middleware: [[Function, unknown], ParamIndexMap | Params][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>) => ((context: C, next?: Function) => Promise<C>);
29
+ export declare const compose: <C extends ComposeContext, E extends Env = Env>(middleware: [
30
+ [
31
+ Function,
32
+ unknown
33
+ ],
34
+ ParamIndexMap | Params
35
+ ][], onError?: ErrorHandler<E>, onNotFound?: NotFoundHandler<E>) => ((context: C, next?: Function) => Promise<C>);
30
36
  export {};
@@ -4,7 +4,7 @@ import type { Env, FetchEventLike, H, Input, NotFoundHandler, RouterRoute, Typed
4
4
  import type { RedirectStatusCode, StatusCode } from './utils/http-status';
5
5
  import type { BaseMime } from './utils/mime';
6
6
  import type { InvalidJSONValue, IsAny, JSONParsed, JSONValue, SimplifyDeepArray } from './utils/types';
7
- type HeaderRecord = Record<'Content-Type', BaseMime> | Record<ResponseHeader, string | string[]> | Record<string, string | string[]>;
7
+ type HeaderRecord = Record<"Content-Type", BaseMime> | Record<ResponseHeader, string | string[]> | Record<string, string | string[]>;
8
8
  /**
9
9
  * Data type can be a string, ArrayBuffer, or ReadableStream.
10
10
  */
@@ -51,7 +51,12 @@ export type Renderer = ContextRenderer extends Function ? ContextRenderer : Defa
51
51
  /**
52
52
  * Extracts the props for the renderer.
53
53
  */
54
- export type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props] ? Props : unknown;
54
+ export type PropsForRenderer = [
55
+ ...Required<Parameters<Renderer>>
56
+ ] extends [
57
+ unknown,
58
+ infer Props
59
+ ] ? Props : unknown;
55
60
  export type Layout<T = Record<string, any>> = (props: T) => any;
56
61
  /**
57
62
  * Interface for getting context variables.
@@ -59,7 +64,7 @@ export type Layout<T = Record<string, any>> = (props: T) => any;
59
64
  * @template E - Environment type.
60
65
  */
61
66
  interface Get<E extends Env> {
62
- <Key extends keyof E['Variables']>(key: Key): E['Variables'][Key];
67
+ <Key extends keyof E["Variables"]>(key: Key): E["Variables"][Key];
63
68
  <Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key];
64
69
  }
65
70
  /**
@@ -68,7 +73,7 @@ interface Get<E extends Env> {
68
73
  * @template E - Environment type.
69
74
  */
70
75
  interface Set<E extends Env> {
71
- <Key extends keyof E['Variables']>(key: Key, value: E['Variables'][Key]): void;
76
+ <Key extends keyof E["Variables"]>(key: Key, value: E["Variables"][Key]): void;
72
77
  <Key extends keyof ContextVariableMap>(key: Key, value: ContextVariableMap[Key]): void;
73
78
  }
74
79
  /**
@@ -97,8 +102,8 @@ interface BodyRespond extends NewResponse {
97
102
  * @returns {Response & TypedResponse<T, U, 'text'>} - The response after rendering the text content, typed with the provided text and status code types.
98
103
  */
99
104
  interface TextRespond {
100
- <T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, 'text'>;
101
- <T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, 'text'>;
105
+ <T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, "text">;
106
+ <T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, "text">;
102
107
  }
103
108
  /**
104
109
  * Interface for responding with JSON.
@@ -123,7 +128,7 @@ interface JSONRespond {
123
128
  *
124
129
  * @returns {Response & TypedResponse<SimplifyDeepArray<T> extends JSONValue ? (JSONValue extends SimplifyDeepArray<T> ? never : JSONParsed<T>) : never, U, 'json'>} - The response after rendering the JSON object, typed with the provided object and status code types.
125
130
  */
126
- type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode> = Response & TypedResponse<SimplifyDeepArray<T> extends JSONValue ? JSONValue extends SimplifyDeepArray<T> ? never : JSONParsed<T> : never, U, 'json'>;
131
+ type JSONRespondReturn<T extends JSONValue | SimplifyDeepArray<unknown> | InvalidJSONValue, U extends StatusCode> = Response & TypedResponse<SimplifyDeepArray<T> extends JSONValue ? JSONValue extends SimplifyDeepArray<T> ? never : JSONParsed<T> : never, U, "json">;
127
132
  /**
128
133
  * Interface representing a function that responds with HTML content.
129
134
  *
@@ -147,7 +152,7 @@ type ContextOptions<E extends Env> = {
147
152
  /**
148
153
  * Bindings for the environment.
149
154
  */
150
- env: E['Bindings'];
155
+ env: E["Bindings"];
151
156
  /**
152
157
  * Execution context for the request.
153
158
  */
@@ -156,19 +161,25 @@ type ContextOptions<E extends Env> = {
156
161
  * Handler for not found responses.
157
162
  */
158
163
  notFoundHandler?: NotFoundHandler<E>;
159
- matchResult?: Result<[H, RouterRoute]>;
164
+ matchResult?: Result<[
165
+ H,
166
+ RouterRoute
167
+ ]>;
160
168
  path?: string;
161
169
  };
162
170
  interface SetHeadersOptions {
163
171
  append?: boolean;
164
172
  }
165
- type ResponseHeader = 'Access-Control-Allow-Credentials' | 'Access-Control-Allow-Headers' | 'Access-Control-Allow-Methods' | 'Access-Control-Allow-Origin' | 'Access-Control-Expose-Headers' | 'Access-Control-Max-Age' | 'Age' | 'Allow' | 'Cache-Control' | 'Clear-Site-Data' | 'Content-Disposition' | 'Content-Encoding' | 'Content-Language' | 'Content-Length' | 'Content-Location' | 'Content-Range' | 'Content-Security-Policy' | 'Content-Security-Policy-Report-Only' | 'Content-Type' | 'Cookie' | 'Cross-Origin-Embedder-Policy' | 'Cross-Origin-Opener-Policy' | 'Cross-Origin-Resource-Policy' | 'Date' | 'ETag' | 'Expires' | 'Last-Modified' | 'Location' | 'Permissions-Policy' | 'Pragma' | 'Retry-After' | 'Save-Data' | 'Sec-CH-Prefers-Color-Scheme' | 'Sec-CH-Prefers-Reduced-Motion' | 'Sec-CH-UA' | 'Sec-CH-UA-Arch' | 'Sec-CH-UA-Bitness' | 'Sec-CH-UA-Form-Factor' | 'Sec-CH-UA-Full-Version' | 'Sec-CH-UA-Full-Version-List' | 'Sec-CH-UA-Mobile' | 'Sec-CH-UA-Model' | 'Sec-CH-UA-Platform' | 'Sec-CH-UA-Platform-Version' | 'Sec-CH-UA-WoW64' | 'Sec-Fetch-Dest' | 'Sec-Fetch-Mode' | 'Sec-Fetch-Site' | 'Sec-Fetch-User' | 'Sec-GPC' | 'Server' | 'Server-Timing' | 'Service-Worker-Navigation-Preload' | 'Set-Cookie' | 'Strict-Transport-Security' | 'Timing-Allow-Origin' | 'Trailer' | 'Transfer-Encoding' | 'Upgrade' | 'Vary' | 'WWW-Authenticate' | 'Warning' | 'X-Content-Type-Options' | 'X-DNS-Prefetch-Control' | 'X-Frame-Options' | 'X-Permitted-Cross-Domain-Policies' | 'X-Powered-By' | 'X-Robots-Tag' | 'X-XSS-Protection';
173
+ type ResponseHeader = "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | "Access-Control-Max-Age" | "Age" | "Allow" | "Cache-Control" | "Clear-Site-Data" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-Range" | "Content-Security-Policy" | "Content-Security-Policy-Report-Only" | "Content-Type" | "Cookie" | "Cross-Origin-Embedder-Policy" | "Cross-Origin-Opener-Policy" | "Cross-Origin-Resource-Policy" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Location" | "Permissions-Policy" | "Pragma" | "Retry-After" | "Save-Data" | "Sec-CH-Prefers-Color-Scheme" | "Sec-CH-Prefers-Reduced-Motion" | "Sec-CH-UA" | "Sec-CH-UA-Arch" | "Sec-CH-UA-Bitness" | "Sec-CH-UA-Form-Factor" | "Sec-CH-UA-Full-Version" | "Sec-CH-UA-Full-Version-List" | "Sec-CH-UA-Mobile" | "Sec-CH-UA-Model" | "Sec-CH-UA-Platform" | "Sec-CH-UA-Platform-Version" | "Sec-CH-UA-WoW64" | "Sec-Fetch-Dest" | "Sec-Fetch-Mode" | "Sec-Fetch-Site" | "Sec-Fetch-User" | "Sec-GPC" | "Server" | "Server-Timing" | "Service-Worker-Navigation-Preload" | "Set-Cookie" | "Strict-Transport-Security" | "Timing-Allow-Origin" | "Trailer" | "Transfer-Encoding" | "Upgrade" | "Vary" | "WWW-Authenticate" | "Warning" | "X-Content-Type-Options" | "X-DNS-Prefetch-Control" | "X-Frame-Options" | "X-Permitted-Cross-Domain-Policies" | "X-Powered-By" | "X-Robots-Tag" | "X-XSS-Protection";
166
174
  interface SetHeaders {
167
- (name: 'Content-Type', value?: BaseMime, options?: SetHeadersOptions): void;
175
+ (name: "Content-Type", value?: BaseMime, options?: SetHeadersOptions): void;
168
176
  (name: ResponseHeader, value?: string, options?: SetHeadersOptions): void;
169
177
  (name: string, value?: string, options?: SetHeadersOptions): void;
170
178
  }
171
- type ResponseHeadersInit = [string, string][] | Record<'Content-Type', BaseMime> | Record<ResponseHeader, string> | Record<string, string> | Headers;
179
+ type ResponseHeadersInit = [
180
+ string,
181
+ string
182
+ ][] | Record<"Content-Type", BaseMime> | Record<ResponseHeader, string> | Record<string, string> | Headers;
172
183
  interface ResponseInit {
173
184
  headers?: ResponseHeadersInit;
174
185
  status?: number;
@@ -176,7 +187,6 @@ interface ResponseInit {
176
187
  }
177
188
  export declare const TEXT_PLAIN = "text/plain; charset=UTF-8";
178
189
  export declare class Context<E extends Env = any, P extends string = any, I extends Input = {}> {
179
- #private;
180
190
  /**
181
191
  * `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
182
192
  *
@@ -190,7 +200,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
190
200
  * })
191
201
  * ```
192
202
  */
193
- env: E['Bindings'];
203
+ env: E["Bindings"];
194
204
  finalized: boolean;
195
205
  /**
196
206
  * `.error` can get the error object from the middleware if the Handler throws an error.
@@ -218,7 +228,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
218
228
  /**
219
229
  * `.req` is the instance of {@link HonoRequest}.
220
230
  */
221
- get req(): HonoRequest<P, I['out']>;
231
+ get req(): HonoRequest<P, I["out"]>;
222
232
  /**
223
233
  * @see {@link https://hono.dev/docs/api/context#event}
224
234
  * The FetchEvent associated with the current request.
@@ -358,7 +368,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
358
368
  * const result = c.var.client.oneMethod()
359
369
  * ```
360
370
  */
361
- get var(): Readonly<ContextVariableMap & (IsAny<E['Variables']> extends true ? Record<string, any> : E['Variables'])>;
371
+ get var(): Readonly<ContextVariableMap & (IsAny<E["Variables"]> extends true ? Record<string, any> : E["Variables"])>;
362
372
  newResponse: NewResponse;
363
373
  /**
364
374
  * `.body()` can return the HTTP response.
@@ -1,5 +1,5 @@
1
1
  import type { Context } from '../../context';
2
- export type AcceptHeader = 'Accept' | 'Accept-Charset' | 'Accept-Encoding' | 'Accept-Language' | 'Accept-Patch' | 'Accept-Post' | 'Accept-Ranges';
2
+ export type AcceptHeader = "Accept" | "Accept-Charset" | "Accept-Encoding" | "Accept-Language" | "Accept-Patch" | "Accept-Post" | "Accept-Ranges";
3
3
  export interface Accept {
4
4
  type: string;
5
5
  params: Record<string, string>;
@@ -3,7 +3,7 @@
3
3
  * Adapter Helper for Hono.
4
4
  */
5
5
  import type { Context } from '../../context';
6
- export type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'other';
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<{}, any, {}>>(c: C, runtime?: Runtime) => T & C["env"];
8
8
  export declare const knownUserAgents: Partial<Record<Runtime, string>>;
9
9
  export declare const getRuntimeKey: () => Runtime;
@@ -1,10 +1,10 @@
1
1
  import type { Context } from '../../context';
2
- export type AddressType = 'IPv6' | 'IPv4' | undefined;
2
+ export type AddressType = "IPv6" | "IPv4" | undefined;
3
3
  export type NetAddrInfo = {
4
4
  /**
5
5
  * Transport protocol type
6
6
  */
7
- transport?: 'tcp' | 'udp';
7
+ transport?: "tcp" | "udp";
8
8
  /**
9
9
  * Transport port number
10
10
  */
@@ -29,7 +29,12 @@ 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[]) => [string, string, CssClassName[], string[]];
32
+ export declare const buildStyleString: (strings: TemplateStringsArray, values: CssVariableType[]) => [
33
+ string,
34
+ string,
35
+ CssClassName[],
36
+ string[]
37
+ ];
33
38
  export declare const cssCommon: (strings: TemplateStringsArray, values: CssVariableType[]) => CssClassName;
34
39
  export declare const cxCommon: (args: (string | boolean | null | undefined | CssClassName)[]) => (string | boolean | null | undefined | CssClassName)[];
35
40
  export declare const keyframesCommon: (strings: TemplateStringsArray, ...values: CssVariableType[]) => CssClassName;
@@ -9,11 +9,36 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
9
9
  <I extends Input = {}, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>): [
10
10
  H<E, P, I, R>
11
11
  ];
12
- <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [H<E, P, I, R>, H<E, P, I2, R>];
13
- <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>];
14
- <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>];
15
- <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>];
16
- <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [H<E, P, I, R>, H<E, P, I2, R>, H<E, P, I3, R>, H<E, P, I4, R>, H<E, P, I5, R>, H<E, P, I6, R>];
12
+ <I extends Input = {}, I2 extends Input = I, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>): [
13
+ H<E, P, I, R>,
14
+ H<E, P, I2, R>
15
+ ];
16
+ <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>): [
17
+ H<E, P, I, R>,
18
+ H<E, P, I2, R>,
19
+ H<E, P, I3, R>
20
+ ];
21
+ <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>): [
22
+ H<E, P, I, R>,
23
+ H<E, P, I2, R>,
24
+ H<E, P, I3, R>,
25
+ H<E, P, I4, R>
26
+ ];
27
+ <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>): [
28
+ H<E, P, I, R>,
29
+ H<E, P, I2, R>,
30
+ H<E, P, I3, R>,
31
+ H<E, P, I4, R>,
32
+ H<E, P, I5, R>
33
+ ];
34
+ <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>): [
35
+ H<E, P, I, R>,
36
+ H<E, P, I2, R>,
37
+ H<E, P, I3, R>,
38
+ H<E, P, I4, R>,
39
+ H<E, P, I5, R>,
40
+ H<E, P, I6, R>
41
+ ];
17
42
  <I extends Input = {}, I2 extends Input = I, I3 extends Input = I & I2, I4 extends Input = I & I2 & I3, I5 extends Input = I & I2 & I3 & I4, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, R extends HandlerResponse<any> = any>(handler1: H<E, P, I, R>, handler2: H<E, P, I2, R>, handler3: H<E, P, I3, R>, handler4: H<E, P, I4, R>, handler5: H<E, P, I5, R>, handler6: H<E, P, I6, R>, handler7: H<E, P, I7, R>): [
18
43
  H<E, P, I, R>,
19
44
  H<E, P, I2, R>,
@@ -58,7 +83,6 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
58
83
  ];
59
84
  }
60
85
  export declare class Factory<E extends Env = any, P extends string = any> {
61
- private initApp?;
62
86
  constructor(init?: {
63
87
  initApp?: InitApp<E>;
64
88
  });
@@ -69,8 +93,5 @@ export declare class Factory<E extends Env = any, P extends string = any> {
69
93
  export declare const createFactory: <E extends Env = any, P extends string = any>(init?: {
70
94
  initApp?: InitApp<E>;
71
95
  }) => Factory<E, P>;
72
- export declare const createMiddleware: <E extends Env = any, P extends string = string, I extends Input = {}, E2 extends Env = {
73
- Bindings: undefined extends E["Bindings"] ? any : E["Bindings"];
74
- Variables: undefined extends E["Variables"] ? any : E["Variables"];
75
- }>(middleware: MiddlewareHandler<E2, P, I>) => MiddlewareHandler<E2, P, I>;
96
+ export declare const createMiddleware: <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>;
76
97
  export {};
@@ -64,7 +64,7 @@ export interface ToSSGInterface {
64
64
  * `ToSSGAdaptorInterface` is an experimental feature.
65
65
  * The API might be changed.
66
66
  */
67
- export interface ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
67
+ export interface ToSSGAdaptorInterface<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/"> {
68
68
  (app: Hono<E, S, BasePath>, options?: ToSSGOptions): Promise<ToSSGResult>;
69
69
  }
70
70
  /**
@@ -17,7 +17,7 @@ export interface WSEvents<T = unknown> {
17
17
  * Upgrade WebSocket Type
18
18
  */
19
19
  export type UpgradeWebSocket<T = unknown, U = any> = (createEvents: (c: Context) => WSEvents<T> | Promise<WSEvents<T>>, options?: U) => MiddlewareHandler<any, string, {
20
- outputFormat: 'ws';
20
+ outputFormat: "ws";
21
21
  }>;
22
22
  export type WSReadyState = 0 | 1 | 2 | 3;
23
23
  export type WSContext<T = unknown> = {
@@ -11,7 +11,7 @@ import type { Env, ErrorHandler, H, HandlerInterface, MergePath, MergeSchemaPath
11
11
  */
12
12
  export declare const COMPOSED_HANDLER: unique symbol;
13
13
  type GetPath<E extends Env> = (request: Request, options?: {
14
- env?: E['Bindings'];
14
+ env?: E["Bindings"];
15
15
  }) => string;
16
16
  export type HonoOptions<E extends Env> = {
17
17
  /**
@@ -32,7 +32,10 @@ export type HonoOptions<E extends Env> = {
32
32
  * const app = new Hono({ router: new RegExpRouter() })
33
33
  * ```
34
34
  */
35
- router?: Router<[H, RouterRoute]>;
35
+ router?: Router<[
36
+ H,
37
+ RouterRoute
38
+ ]>;
36
39
  /**
37
40
  * `getPath` can handle the host header value.
38
41
  *
@@ -61,25 +64,23 @@ type MountOptions = MountOptionHandler | {
61
64
  optionHandler?: MountOptionHandler;
62
65
  replaceRequest?: MountReplaceRequest;
63
66
  };
64
- declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'> {
65
- #private;
66
- get: HandlerInterface<E, 'get', S, BasePath>;
67
- post: HandlerInterface<E, 'post', S, BasePath>;
68
- put: HandlerInterface<E, 'put', S, BasePath>;
69
- delete: HandlerInterface<E, 'delete', S, BasePath>;
70
- options: HandlerInterface<E, 'options', S, BasePath>;
71
- patch: HandlerInterface<E, 'patch', S, BasePath>;
72
- all: HandlerInterface<E, 'all', S, BasePath>;
67
+ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/"> {
68
+ get: HandlerInterface<E, "get", S, BasePath>;
69
+ post: HandlerInterface<E, "post", S, BasePath>;
70
+ put: HandlerInterface<E, "put", S, BasePath>;
71
+ delete: HandlerInterface<E, "delete", S, BasePath>;
72
+ options: HandlerInterface<E, "options", S, BasePath>;
73
+ patch: HandlerInterface<E, "patch", S, BasePath>;
74
+ all: HandlerInterface<E, "all", S, BasePath>;
73
75
  on: OnHandlerInterface<E, S, BasePath>;
74
76
  use: MiddlewareHandlerInterface<E, S, BasePath>;
75
- router: Router<[H, RouterRoute]>;
77
+ router: Router<[
78
+ H,
79
+ RouterRoute
80
+ ]>;
76
81
  readonly getPath: GetPath<E>;
77
- private _basePath;
78
82
  routes: RouterRoute[];
79
83
  constructor(options?: HonoOptions<E>);
80
- private clone;
81
- private notFoundHandler;
82
- private errorHandler;
83
84
  /**
84
85
  * `.route()` allows grouping other Hono instance in routes.
85
86
  *
@@ -98,7 +99,7 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
98
99
  * app.route("/api", app2) // GET /api/user
99
100
  * ```
100
101
  */
101
- route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app: Hono<SubEnv, SubSchema, SubBasePath>): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>;
102
+ route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app: Hono<SubEnv, SubSchema, SubBasePath>): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> | S, BasePath>;
102
103
  /**
103
104
  * `.basePath()` allows base paths to be specified.
104
105
  *
@@ -179,10 +180,6 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
179
180
  * ```
180
181
  */
181
182
  mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Hono<E, S, BasePath>;
182
- private addRoute;
183
- private matchRoute;
184
- private handleError;
185
- private dispatch;
186
183
  /**
187
184
  * `.fetch()` will be entry point of your app.
188
185
  *
@@ -194,7 +191,7 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
194
191
  * @returns {Response | Promise<Response>} response of request
195
192
  *
196
193
  */
197
- fetch: (request: Request, Env?: E['Bindings'] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
194
+ fetch: (request: Request, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
198
195
  /**
199
196
  * `.request()` is a useful method for testing.
200
197
  * You can pass a URL or pathname to send a GET request.
@@ -9,7 +9,7 @@ import type { BlankEnv, BlankSchema, Env, Schema } from './types';
9
9
  * @template S - The schema type.
10
10
  * @template BasePath - The base path type.
11
11
  */
12
- export declare class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = '/'> extends HonoBase<E, S, BasePath> {
12
+ export declare class Hono<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = "/"> extends HonoBase<E, S, BasePath> {
13
13
  /**
14
14
  * Creates an instance of the Hono class.
15
15
  *
@@ -22,7 +22,10 @@ export declare namespace JSX {
22
22
  }
23
23
  export declare const getNameSpaceContext: () => Context<string> | undefined;
24
24
  export declare const booleanAttributes: string[];
25
- type LocalContexts = [Context<unknown>, unknown][];
25
+ type LocalContexts = [
26
+ Context<unknown>,
27
+ unknown
28
+ ][];
26
29
  export type Child = string | Promise<string> | number | JSXNode | null | undefined | boolean | Child[];
27
30
  export declare class JSXNode implements HtmlEscaped {
28
31
  tag: string | Function;
@@ -10,7 +10,7 @@ type FormStatus = {
10
10
  } | {
11
11
  pending: true;
12
12
  data: FormData;
13
- method: 'get' | 'post';
13
+ method: "get" | "post";
14
14
  action: string | ((formData: FormData) => void | Promise<void>);
15
15
  };
16
16
  export declare const FormContext: Context<FormStatus>;
@@ -27,7 +27,10 @@ export declare const useFormStatus: () => FormStatus;
27
27
  * @param updateState
28
28
  * @returns [T, (action: N) => void]
29
29
  */
30
- export declare const useOptimistic: <T, N>(state: T, updateState: (currentState: T, action: N) => T) => [T, (action: N) => void];
30
+ export declare const useOptimistic: <T, N>(state: T, updateState: (currentState: T, action: N) => T) => [
31
+ T,
32
+ (action: N) => void
33
+ ];
31
34
  /**
32
35
  * This hook returns the current state and a function to update the state by form action
33
36
  * @param fn
@@ -35,5 +38,8 @@ export declare const useOptimistic: <T, N>(state: T, updateState: (currentState:
35
38
  * @param permalink
36
39
  * @returns [T, (data: FormData) => void]
37
40
  */
38
- export declare const useActionState: <T>(fn: Function, initialState: T, permalink?: string) => [T, Function];
41
+ export declare const useActionState: <T>(fn: Function, initialState: T, permalink?: string) => [
42
+ T,
43
+ Function
44
+ ];
39
45
  export {};