hono 4.6.4 → 4.6.6

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 (63) hide show
  1. package/dist/adapter/deno/serve-static.js +4 -2
  2. package/dist/cjs/adapter/deno/serve-static.js +4 -2
  3. package/dist/cjs/client/client.js +10 -16
  4. package/dist/cjs/client/utils.js +18 -0
  5. package/dist/cjs/middleware/cors/index.js +6 -2
  6. package/dist/cjs/middleware/csrf/index.js +1 -1
  7. package/dist/cjs/middleware/powered-by/index.js +2 -2
  8. package/dist/cjs/middleware/secure-headers/secure-headers.js +6 -5
  9. package/dist/client/client.js +11 -16
  10. package/dist/client/utils.js +17 -0
  11. package/dist/middleware/cors/index.js +6 -2
  12. package/dist/middleware/csrf/index.js +1 -1
  13. package/dist/middleware/powered-by/index.js +2 -2
  14. package/dist/middleware/secure-headers/secure-headers.js +6 -5
  15. package/dist/types/adapter/cloudflare-pages/handler.d.ts +1 -1
  16. package/dist/types/adapter/lambda-edge/handler.d.ts +2 -2
  17. package/dist/types/client/types.d.ts +18 -8
  18. package/dist/types/client/utils.d.ts +1 -0
  19. package/dist/types/compose.d.ts +7 -1
  20. package/dist/types/context.d.ts +26 -16
  21. package/dist/types/helper/accepts/accepts.d.ts +1 -1
  22. package/dist/types/helper/adapter/index.d.ts +1 -1
  23. package/dist/types/helper/conninfo/types.d.ts +2 -2
  24. package/dist/types/helper/css/common.d.ts +6 -1
  25. package/dist/types/helper/factory/index.d.ts +31 -10
  26. package/dist/types/helper/ssg/ssg.d.ts +1 -1
  27. package/dist/types/helper/websocket/index.d.ts +1 -1
  28. package/dist/types/hono-base.d.ts +19 -22
  29. package/dist/types/hono.d.ts +1 -1
  30. package/dist/types/jsx/base.d.ts +4 -1
  31. package/dist/types/jsx/dom/hooks/index.d.ts +9 -3
  32. package/dist/types/jsx/dom/index.d.ts +28 -7
  33. package/dist/types/jsx/dom/intrinsic-element/components.d.ts +6 -6
  34. package/dist/types/jsx/dom/render.d.ts +28 -4
  35. package/dist/types/jsx/dom/server.d.ts +28 -7
  36. package/dist/types/jsx/hooks/index.d.ts +20 -5
  37. package/dist/types/jsx/index.d.ts +28 -7
  38. package/dist/types/jsx/intrinsic-element/components.d.ts +4 -4
  39. package/dist/types/jsx/intrinsic-elements.d.ts +46 -46
  40. package/dist/types/middleware/compress/index.d.ts +4 -1
  41. package/dist/types/middleware/powered-by/index.d.ts +24 -1
  42. package/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
  43. package/dist/types/middleware/secure-headers/secure-headers.d.ts +1 -1
  44. package/dist/types/preset/quick.d.ts +1 -1
  45. package/dist/types/preset/tiny.d.ts +1 -1
  46. package/dist/types/request.d.ts +5 -7
  47. package/dist/types/router/linear-router/router.d.ts +5 -1
  48. package/dist/types/router/pattern-router/router.d.ts +0 -1
  49. package/dist/types/router/reg-exp-router/node.d.ts +4 -1
  50. package/dist/types/router/reg-exp-router/router.d.ts +4 -3
  51. package/dist/types/router/reg-exp-router/trie.d.ts +5 -1
  52. package/dist/types/router/smart-router/router.d.ts +6 -2
  53. package/dist/types/router/trie-router/node.d.ts +6 -2
  54. package/dist/types/router.d.ts +20 -2
  55. package/dist/types/types.d.ts +908 -120
  56. package/dist/types/utils/cookie.d.ts +3 -3
  57. package/dist/types/utils/html.d.ts +6 -2
  58. package/dist/types/utils/jwt/jwt.d.ts +1 -1
  59. package/dist/types/utils/mime.d.ts +1 -1
  60. package/dist/types/utils/stream.d.ts +0 -4
  61. package/dist/types/utils/url.d.ts +5 -1
  62. package/dist/types/validator/validator.d.ts +18 -6
  63. package/package.json +8 -7
@@ -1,6 +1,6 @@
1
1
  // src/adapter/deno/serve-static.ts
2
2
  import { serveStatic as baseServeStatic } from "../../middleware/serve-static/index.js";
3
- var { open, lstatSync } = Deno;
3
+ var { open, lstatSync, errors } = Deno;
4
4
  var serveStatic = (options) => {
5
5
  return async function serveStatic2(c, next) {
6
6
  const getContent = async (path) => {
@@ -8,7 +8,9 @@ var serveStatic = (options) => {
8
8
  const file = await open(path);
9
9
  return file ? file.readable : null;
10
10
  } catch (e) {
11
- console.warn(`${e}`);
11
+ if (!(e instanceof errors.NotFound)) {
12
+ console.warn(`${e}`);
13
+ }
12
14
  }
13
15
  };
14
16
  const pathResolve = (path) => {
@@ -22,7 +22,7 @@ __export(serve_static_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(serve_static_exports);
24
24
  var import_serve_static = require("../../middleware/serve-static");
25
- const { open, lstatSync } = Deno;
25
+ const { open, lstatSync, errors } = Deno;
26
26
  const serveStatic = (options) => {
27
27
  return async function serveStatic2(c, next) {
28
28
  const getContent = async (path) => {
@@ -30,7 +30,9 @@ const serveStatic = (options) => {
30
30
  const file = await open(path);
31
31
  return file ? file.readable : null;
32
32
  } catch (e) {
33
- console.warn(`${e}`);
33
+ if (!(e instanceof errors.NotFound)) {
34
+ console.warn(`${e}`);
35
+ }
34
36
  }
35
37
  };
36
38
  const pathResolve = (path) => {
@@ -55,19 +55,7 @@ class ClientRequestImpl {
55
55
  fetch = async (args, opt) => {
56
56
  if (args) {
57
57
  if (args.query) {
58
- for (const [k, v] of Object.entries(args.query)) {
59
- if (v === void 0) {
60
- continue;
61
- }
62
- this.queryParams ||= new URLSearchParams();
63
- if (Array.isArray(v)) {
64
- for (const v2 of v) {
65
- this.queryParams.append(k, v2);
66
- }
67
- } else {
68
- this.queryParams.set(k, v);
69
- }
70
- }
58
+ this.queryParams = (0, import_utils.buildSearchParams)(args.query);
71
59
  }
72
60
  if (args.form) {
73
61
  const form = new FormData();
@@ -146,10 +134,16 @@ const hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
146
134
  const path = parts.join("/");
147
135
  const url = (0, import_utils.mergePath)(baseUrl, path);
148
136
  if (method === "url") {
149
- if (opts.args[0] && opts.args[0].param) {
150
- return new URL((0, import_utils.replaceUrlParam)(url, opts.args[0].param));
137
+ let result = url;
138
+ if (opts.args[0]) {
139
+ if (opts.args[0].param) {
140
+ result = (0, import_utils.replaceUrlParam)(url, opts.args[0].param);
141
+ }
142
+ if (opts.args[0].query) {
143
+ result = result + "?" + (0, import_utils.buildSearchParams)(opts.args[0].query).toString();
144
+ }
151
145
  }
152
- return new URL(url);
146
+ return new URL(result);
153
147
  }
154
148
  if (method === "ws") {
155
149
  const webSocketUrl = (0, import_utils.replaceUrlProtocol)(
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var utils_exports = {};
20
20
  __export(utils_exports, {
21
+ buildSearchParams: () => buildSearchParams,
21
22
  deepMerge: () => deepMerge,
22
23
  mergePath: () => mergePath,
23
24
  removeIndexString: () => removeIndexString,
@@ -38,6 +39,22 @@ const replaceUrlParam = (urlString, params) => {
38
39
  }
39
40
  return urlString;
40
41
  };
42
+ const buildSearchParams = (query) => {
43
+ const searchParams = new URLSearchParams();
44
+ for (const [k, v] of Object.entries(query)) {
45
+ if (v === void 0) {
46
+ continue;
47
+ }
48
+ if (Array.isArray(v)) {
49
+ for (const v2 of v) {
50
+ searchParams.append(k, v2);
51
+ }
52
+ } else {
53
+ searchParams.set(k, v);
54
+ }
55
+ }
56
+ return searchParams;
57
+ };
41
58
  const replaceUrlProtocol = (urlString, protocol) => {
42
59
  switch (protocol) {
43
60
  case "ws":
@@ -72,6 +89,7 @@ function deepMerge(target, source) {
72
89
  }
73
90
  // Annotate the CommonJS export names for ESM import in node:
74
91
  0 && (module.exports = {
92
+ buildSearchParams,
75
93
  deepMerge,
76
94
  mergePath,
77
95
  removeIndexString,
@@ -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:
@@ -59,11 +59,12 @@ const generateNonce = () => {
59
59
  return (0, import_encode.encodeBase64)(buffer);
60
60
  };
61
61
  const NONCE = (ctx) => {
62
- const nonce = ctx.get("secureHeadersNonce") || (() => {
63
- const newNonce = generateNonce();
64
- ctx.set("secureHeadersNonce", newNonce);
65
- return newNonce;
66
- })();
62
+ const key = "secureHeadersNonce";
63
+ const init = ctx.get(key);
64
+ const nonce = init || generateNonce();
65
+ if (init == null) {
66
+ ctx.set(key, nonce);
67
+ }
67
68
  return `'nonce-${nonce}'`;
68
69
  };
69
70
  const secureHeaders = (customOptions) => {
@@ -1,6 +1,7 @@
1
1
  // src/client/client.ts
2
2
  import { serialize } from "../utils/cookie.js";
3
3
  import {
4
+ buildSearchParams,
4
5
  deepMerge,
5
6
  mergePath,
6
7
  removeIndexString,
@@ -39,19 +40,7 @@ var ClientRequestImpl = class {
39
40
  fetch = async (args, opt) => {
40
41
  if (args) {
41
42
  if (args.query) {
42
- for (const [k, v] of Object.entries(args.query)) {
43
- if (v === void 0) {
44
- continue;
45
- }
46
- this.queryParams ||= new URLSearchParams();
47
- if (Array.isArray(v)) {
48
- for (const v2 of v) {
49
- this.queryParams.append(k, v2);
50
- }
51
- } else {
52
- this.queryParams.set(k, v);
53
- }
54
- }
43
+ this.queryParams = buildSearchParams(args.query);
55
44
  }
56
45
  if (args.form) {
57
46
  const form = new FormData();
@@ -130,10 +119,16 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
130
119
  const path = parts.join("/");
131
120
  const url = mergePath(baseUrl, path);
132
121
  if (method === "url") {
133
- if (opts.args[0] && opts.args[0].param) {
134
- return new URL(replaceUrlParam(url, opts.args[0].param));
122
+ let result = url;
123
+ if (opts.args[0]) {
124
+ if (opts.args[0].param) {
125
+ result = replaceUrlParam(url, opts.args[0].param);
126
+ }
127
+ if (opts.args[0].query) {
128
+ result = result + "?" + buildSearchParams(opts.args[0].query).toString();
129
+ }
135
130
  }
136
- return new URL(url);
131
+ return new URL(result);
137
132
  }
138
133
  if (method === "ws") {
139
134
  const webSocketUrl = replaceUrlProtocol(
@@ -12,6 +12,22 @@ var replaceUrlParam = (urlString, params) => {
12
12
  }
13
13
  return urlString;
14
14
  };
15
+ var buildSearchParams = (query) => {
16
+ const searchParams = new URLSearchParams();
17
+ for (const [k, v] of Object.entries(query)) {
18
+ if (v === void 0) {
19
+ continue;
20
+ }
21
+ if (Array.isArray(v)) {
22
+ for (const v2 of v) {
23
+ searchParams.append(k, v2);
24
+ }
25
+ } else {
26
+ searchParams.set(k, v);
27
+ }
28
+ }
29
+ return searchParams;
30
+ };
15
31
  var replaceUrlProtocol = (urlString, protocol) => {
16
32
  switch (protocol) {
17
33
  case "ws":
@@ -45,6 +61,7 @@ function deepMerge(target, source) {
45
61
  return merged;
46
62
  }
47
63
  export {
64
+ buildSearchParams,
48
65
  deepMerge,
49
66
  mergePath,
50
67
  removeIndexString,
@@ -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 {
@@ -36,11 +36,12 @@ var generateNonce = () => {
36
36
  return encodeBase64(buffer);
37
37
  };
38
38
  var NONCE = (ctx) => {
39
- const nonce = ctx.get("secureHeadersNonce") || (() => {
40
- const newNonce = generateNonce();
41
- ctx.set("secureHeadersNonce", newNonce);
42
- return newNonce;
43
- })();
39
+ const key = "secureHeadersNonce";
40
+ const init = ctx.get(key);
41
+ const nonce = init || generateNonce();
42
+ if (init == null) {
43
+ ctx.set(key, nonce);
44
+ }
44
45
  return `'nonce-${nonce}'`;
45
46
  };
46
47
  var secureHeaders = (customOptions) => {
@@ -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;
@@ -27,12 +28,21 @@ export type ClientRequest<S extends Schema> = {
27
28
  input: infer R;
28
29
  } ? R extends {
29
30
  param: infer P;
31
+ } ? R extends {
32
+ query: infer Q;
30
33
  } ? {
31
34
  param: P;
35
+ query: Q;
36
+ } : {
37
+ param: P;
38
+ } : R extends {
39
+ query: infer Q;
40
+ } ? {
41
+ query: Q;
32
42
  } : {} : {}) => URL;
33
- } & (S['$get'] extends {
34
- outputFormat: 'ws';
35
- } ? S['$get'] extends {
43
+ } & (S["$get"] extends {
44
+ outputFormat: "ws";
45
+ } ? S["$get"] extends {
36
46
  input: infer I;
37
47
  } ? {
38
48
  $ws: (args?: I) => WebSocket;
@@ -53,8 +63,8 @@ export interface ClientResponse<T, U extends number = StatusCode, F extends Resp
53
63
  url: string;
54
64
  redirect(url: string, status: number): Response;
55
65
  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>;
66
+ json(): F extends "text" ? Promise<never> : F extends "json" ? Promise<BlankRecordToNever<T>> : Promise<unknown>;
67
+ text(): F extends "text" ? (T extends string ? Promise<T> : Promise<never>) : Promise<string>;
58
68
  blob(): Promise<Blob>;
59
69
  formData(): Promise<FormData>;
60
70
  arrayBuffer(): Promise<ArrayBuffer>;
@@ -83,9 +93,9 @@ export type InferRequestOptionsType<T> = T extends (args: any, options: infer R)
83
93
  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
94
  [K in P]: PathToChain<R, E, Original>;
85
95
  } : {
86
- [K in Path extends '' ? 'index' : Path]: ClientRequest<E extends Record<string, unknown> ? E[Original] : never>;
96
+ [K in Path extends "" ? "index" : Path]: ClientRequest<E extends Record<string, unknown> ? E[Original] : never>;
87
97
  };
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;
98
+ 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
99
  export type Callback = (opts: CallbackOptions) => unknown;
90
100
  interface CallbackOptions {
91
101
  path: string[];
@@ -1,5 +1,6 @@
1
1
  export declare const mergePath: (base: string, path: string) => string;
2
2
  export declare const replaceUrlParam: (urlString: string, params: Record<string, string | undefined>) => string;
3
+ export declare const buildSearchParams: (query: Record<string, string | string[]>) => URLSearchParams;
3
4
  export declare const replaceUrlProtocol: (urlString: string, protocol: "ws" | "http") => string;
4
5
  export declare const removeIndexString: (urlSting: string) => string;
5
6
  export declare function deepMerge<T>(target: T, source: Record<string, unknown>): T;
@@ -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;