hono 4.6.7 → 4.6.9

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 (91) hide show
  1. package/dist/adapter/bun/websocket.js +4 -6
  2. package/dist/adapter/cloudflare-workers/websocket.js +34 -39
  3. package/dist/adapter/deno/serve-static.js +2 -1
  4. package/dist/adapter/lambda-edge/handler.js +1 -1
  5. package/dist/cjs/adapter/bun/websocket.js +4 -6
  6. package/dist/cjs/adapter/cloudflare-workers/websocket.js +34 -39
  7. package/dist/cjs/adapter/deno/serve-static.js +2 -1
  8. package/dist/cjs/adapter/lambda-edge/handler.js +1 -1
  9. package/dist/cjs/client/client.js +3 -3
  10. package/dist/cjs/compose.js +4 -3
  11. package/dist/cjs/context.js +12 -9
  12. package/dist/cjs/helper/cookie/index.js +1 -1
  13. package/dist/cjs/helper/html/index.js +1 -1
  14. package/dist/cjs/helper/ssg/ssg.js +2 -2
  15. package/dist/cjs/helper/ssg/utils.js +2 -2
  16. package/dist/cjs/helper/websocket/index.js +1 -4
  17. package/dist/cjs/hono-base.js +29 -32
  18. package/dist/cjs/jsx/base.js +8 -3
  19. package/dist/cjs/jsx/constants.js +3 -0
  20. package/dist/cjs/jsx/dom/index.js +8 -2
  21. package/dist/cjs/jsx/dom/render.js +15 -12
  22. package/dist/cjs/middleware/etag/digest.js +59 -0
  23. package/dist/cjs/middleware/etag/index.js +5 -2
  24. package/dist/cjs/middleware/ip-restriction/index.js +3 -3
  25. package/dist/cjs/middleware/jsx-renderer/index.js +2 -1
  26. package/dist/cjs/middleware/logger/index.js +13 -11
  27. package/dist/cjs/middleware/timing/timing.js +5 -7
  28. package/dist/cjs/request.js +15 -14
  29. package/dist/cjs/router/pattern-router/router.js +4 -4
  30. package/dist/cjs/router/reg-exp-router/router.js +5 -5
  31. package/dist/cjs/router/reg-exp-router/trie.js +2 -2
  32. package/dist/cjs/router/trie-router/node.js +9 -7
  33. package/dist/cjs/utils/color.js +1 -1
  34. package/dist/cjs/utils/cookie.js +13 -6
  35. package/dist/cjs/utils/crypto.js +0 -9
  36. package/dist/cjs/utils/headers.js +16 -0
  37. package/dist/cjs/utils/jwt/jwt.js +1 -1
  38. package/dist/cjs/utils/mime.js +2 -1
  39. package/dist/cjs/utils/url.js +9 -6
  40. package/dist/client/client.js +3 -3
  41. package/dist/compose.js +4 -3
  42. package/dist/context.js +12 -9
  43. package/dist/helper/cookie/index.js +1 -1
  44. package/dist/helper/html/index.js +1 -1
  45. package/dist/helper/ssg/ssg.js +2 -2
  46. package/dist/helper/ssg/utils.js +2 -2
  47. package/dist/helper/websocket/index.js +1 -4
  48. package/dist/hono-base.js +29 -32
  49. package/dist/jsx/base.js +7 -3
  50. package/dist/jsx/constants.js +2 -0
  51. package/dist/jsx/dom/index.js +7 -1
  52. package/dist/jsx/dom/render.js +22 -13
  53. package/dist/middleware/etag/digest.js +36 -0
  54. package/dist/middleware/etag/index.js +5 -2
  55. package/dist/middleware/ip-restriction/index.js +3 -3
  56. package/dist/middleware/jsx-renderer/index.js +2 -1
  57. package/dist/middleware/logger/index.js +13 -11
  58. package/dist/middleware/timing/timing.js +5 -7
  59. package/dist/request.js +16 -15
  60. package/dist/router/pattern-router/router.js +4 -4
  61. package/dist/router/reg-exp-router/router.js +5 -5
  62. package/dist/router/reg-exp-router/trie.js +2 -2
  63. package/dist/router/trie-router/node.js +9 -7
  64. package/dist/types/adapter/bun/websocket.d.ts +5 -3
  65. package/dist/types/adapter/cloudflare-workers/websocket.d.ts +2 -2
  66. package/dist/types/adapter/deno/websocket.d.ts +1 -20
  67. package/dist/types/context.d.ts +2 -2
  68. package/dist/types/helper/accepts/accepts.d.ts +1 -1
  69. package/dist/types/helper/websocket/index.d.ts +3 -3
  70. package/dist/types/hono-base.d.ts +1 -1
  71. package/dist/types/jsx/base.d.ts +5 -0
  72. package/dist/types/jsx/constants.d.ts +1 -0
  73. package/dist/types/jsx/dom/index.d.ts +6 -5
  74. package/dist/types/jsx/dom/render.d.ts +1 -0
  75. package/dist/types/middleware/etag/digest.d.ts +1 -0
  76. package/dist/types/request.d.ts +3 -1
  77. package/dist/types/types.d.ts +71 -70
  78. package/dist/types/utils/body.d.ts +2 -2
  79. package/dist/types/utils/cookie.d.ts +4 -4
  80. package/dist/types/utils/crypto.d.ts +2 -1
  81. package/dist/types/utils/headers.d.ts +8 -0
  82. package/dist/types/utils/mime.d.ts +58 -1
  83. package/dist/types/utils/url.d.ts +3 -0
  84. package/dist/utils/color.js +1 -1
  85. package/dist/utils/cookie.js +13 -6
  86. package/dist/utils/crypto.js +0 -9
  87. package/dist/utils/headers.js +0 -0
  88. package/dist/utils/jwt/jwt.js +1 -1
  89. package/dist/utils/mime.js +2 -1
  90. package/dist/utils/url.js +7 -5
  91. package/package.json +1 -1
@@ -9,13 +9,11 @@ var getTime = () => {
9
9
  };
10
10
  var timing = (config) => {
11
11
  const options = {
12
- ...{
13
- total: true,
14
- enabled: true,
15
- totalDescription: "Total Response Time",
16
- autoEnd: true,
17
- crossOrigin: false
18
- },
12
+ total: true,
13
+ enabled: true,
14
+ totalDescription: "Total Response Time",
15
+ autoEnd: true,
16
+ crossOrigin: false,
19
17
  ...config
20
18
  };
21
19
  return async function timing2(c, next) {
package/dist/request.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/request.ts
2
2
  import { parseBody } from "./utils/body.js";
3
- import { decodeURIComponent_, getQueryParam, getQueryParams } from "./utils/url.js";
3
+ import { decodeURIComponent_, getQueryParam, getQueryParams, tryDecode } from "./utils/url.js";
4
+ var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
4
5
  var HonoRequest = class {
5
6
  raw;
6
7
  #validatedData;
@@ -15,25 +16,25 @@ var HonoRequest = class {
15
16
  this.#validatedData = {};
16
17
  }
17
18
  param(key) {
18
- return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
19
+ return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams();
19
20
  }
20
- getDecodedParam(key) {
21
+ #getDecodedParam(key) {
21
22
  const paramKey = this.#matchResult[0][this.routeIndex][1][key];
22
- const param = this.getParamValue(paramKey);
23
- return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
23
+ const param = this.#getParamValue(paramKey);
24
+ return param ? /\%/.test(param) ? tryDecodeURIComponent(param) : param : void 0;
24
25
  }
25
- getAllDecodedParams() {
26
+ #getAllDecodedParams() {
26
27
  const decoded = {};
27
28
  const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
28
29
  for (const key of keys) {
29
- const value = this.getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
30
+ const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
30
31
  if (value && typeof value === "string") {
31
- decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value;
32
+ decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value;
32
33
  }
33
34
  }
34
35
  return decoded;
35
36
  }
36
- getParamValue(paramKey) {
37
+ #getParamValue(paramKey) {
37
38
  return this.#matchResult[1] ? this.#matchResult[1][paramKey] : paramKey;
38
39
  }
39
40
  query(key) {
@@ -55,7 +56,7 @@ var HonoRequest = class {
55
56
  async parseBody(options) {
56
57
  return this.bodyCache.parsedBody ??= await parseBody(this, options);
57
58
  }
58
- cachedBody = (key) => {
59
+ #cachedBody = (key) => {
59
60
  const { bodyCache, raw } = this;
60
61
  const cachedBody = bodyCache[key];
61
62
  if (cachedBody) {
@@ -73,19 +74,19 @@ var HonoRequest = class {
73
74
  return bodyCache[key] = raw[key]();
74
75
  };
75
76
  json() {
76
- return this.cachedBody("json");
77
+ return this.#cachedBody("json");
77
78
  }
78
79
  text() {
79
- return this.cachedBody("text");
80
+ return this.#cachedBody("text");
80
81
  }
81
82
  arrayBuffer() {
82
- return this.cachedBody("arrayBuffer");
83
+ return this.#cachedBody("arrayBuffer");
83
84
  }
84
85
  blob() {
85
- return this.cachedBody("blob");
86
+ return this.#cachedBody("blob");
86
87
  }
87
88
  formData() {
88
- return this.cachedBody("formData");
89
+ return this.#cachedBody("formData");
89
90
  }
90
91
  addValidatedData(target, data) {
91
92
  this.#validatedData[target] = data;
@@ -2,7 +2,7 @@
2
2
  import { METHOD_NAME_ALL, UnsupportedPathError } from "../../router.js";
3
3
  var PatternRouter = class {
4
4
  name = "PatternRouter";
5
- routes = [];
5
+ #routes = [];
6
6
  add(method, path, handler) {
7
7
  const endsWithWildcard = path[path.length - 1] === "*";
8
8
  if (endsWithWildcard) {
@@ -24,12 +24,12 @@ var PatternRouter = class {
24
24
  } catch {
25
25
  throw new UnsupportedPathError();
26
26
  }
27
- this.routes.push([re, method, handler]);
27
+ this.#routes.push([re, method, handler]);
28
28
  }
29
29
  match(method, path) {
30
30
  const handlers = [];
31
- for (let i = 0, len = this.routes.length; i < len; i++) {
32
- const [pattern, routeMethod, handler] = this.routes[i];
31
+ for (let i = 0, len = this.#routes.length; i < len; i++) {
32
+ const [pattern, routeMethod, handler] = this.#routes[i];
33
33
  if (routeMethod === method || routeMethod === METHOD_NAME_ALL) {
34
34
  const match = pattern.exec(path);
35
35
  if (match) {
@@ -155,7 +155,7 @@ var RegExpRouter = class {
155
155
  }
156
156
  match(method, path) {
157
157
  clearWildcardRegExpCache();
158
- const matchers = this.buildAllMatchers();
158
+ const matchers = this.#buildAllMatchers();
159
159
  this.match = (method2, path2) => {
160
160
  const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
161
161
  const staticMatch = matcher[2][path2];
@@ -171,15 +171,15 @@ var RegExpRouter = class {
171
171
  };
172
172
  return this.match(method, path);
173
173
  }
174
- buildAllMatchers() {
174
+ #buildAllMatchers() {
175
175
  const matchers = /* @__PURE__ */ Object.create(null);
176
- [...Object.keys(this.routes), ...Object.keys(this.middleware)].forEach((method) => {
177
- matchers[method] ||= this.buildMatcher(method);
176
+ Object.keys(this.routes).concat(Object.keys(this.middleware)).forEach((method) => {
177
+ matchers[method] ||= this.#buildMatcher(method);
178
178
  });
179
179
  this.middleware = this.routes = void 0;
180
180
  return matchers;
181
181
  }
182
- buildMatcher(method) {
182
+ #buildMatcher(method) {
183
183
  const routes = [];
184
184
  let hasOwnRoute = method === METHOD_NAME_ALL;
185
185
  [this.middleware, this.routes].forEach((r) => {
@@ -41,11 +41,11 @@ var Trie = class {
41
41
  const indexReplacementMap = [];
42
42
  const paramReplacementMap = [];
43
43
  regexp = regexp.replace(/#(\d+)|@(\d+)|\.\*\$/g, (_, handlerIndex, paramIndex) => {
44
- if (typeof handlerIndex !== "undefined") {
44
+ if (handlerIndex !== void 0) {
45
45
  indexReplacementMap[++captureIndex] = Number(handlerIndex);
46
46
  return "$()";
47
47
  }
48
- if (typeof paramIndex !== "undefined") {
48
+ if (paramIndex !== void 0) {
49
49
  paramReplacementMap[Number(paramIndex)] = ++captureIndex;
50
50
  return "";
51
51
  }
@@ -53,7 +53,7 @@ var Node = class {
53
53
  curNode.methods.push(m);
54
54
  return curNode;
55
55
  }
56
- gHSets(node, method, nodeParams, params) {
56
+ #gHSets(node, method, nodeParams, params) {
57
57
  const handlerSets = [];
58
58
  for (let i = 0, len = node.methods.length; i < len; i++) {
59
59
  const m = node.methods[i];
@@ -90,10 +90,10 @@ var Node = class {
90
90
  if (isLast) {
91
91
  if (nextNode.children["*"]) {
92
92
  handlerSets.push(
93
- ...this.gHSets(nextNode.children["*"], method, node.params, /* @__PURE__ */ Object.create(null))
93
+ ...this.#gHSets(nextNode.children["*"], method, node.params, /* @__PURE__ */ Object.create(null))
94
94
  );
95
95
  }
96
- handlerSets.push(...this.gHSets(nextNode, method, node.params, /* @__PURE__ */ Object.create(null)));
96
+ handlerSets.push(...this.#gHSets(nextNode, method, node.params, /* @__PURE__ */ Object.create(null)));
97
97
  } else {
98
98
  tempNodes.push(nextNode);
99
99
  }
@@ -104,7 +104,7 @@ var Node = class {
104
104
  if (pattern === "*") {
105
105
  const astNode = node.children["*"];
106
106
  if (astNode) {
107
- handlerSets.push(...this.gHSets(astNode, method, node.params, /* @__PURE__ */ Object.create(null)));
107
+ handlerSets.push(...this.#gHSets(astNode, method, node.params, /* @__PURE__ */ Object.create(null)));
108
108
  tempNodes.push(astNode);
109
109
  }
110
110
  continue;
@@ -117,16 +117,18 @@ var Node = class {
117
117
  const restPathString = parts.slice(i).join("/");
118
118
  if (matcher instanceof RegExp && matcher.test(restPathString)) {
119
119
  params[name] = restPathString;
120
- handlerSets.push(...this.gHSets(child, method, node.params, params));
120
+ handlerSets.push(...this.#gHSets(child, method, node.params, params));
121
121
  continue;
122
122
  }
123
123
  if (matcher === true || matcher.test(part)) {
124
124
  if (typeof key === "string") {
125
125
  params[name] = part;
126
126
  if (isLast) {
127
- handlerSets.push(...this.gHSets(child, method, params, node.params));
127
+ handlerSets.push(...this.#gHSets(child, method, params, node.params));
128
128
  if (child.children["*"]) {
129
- handlerSets.push(...this.gHSets(child.children["*"], method, params, node.params));
129
+ handlerSets.push(
130
+ ...this.#gHSets(child.children["*"], method, params, node.params)
131
+ );
130
132
  }
131
133
  } else {
132
134
  child.params = params;
@@ -1,4 +1,4 @@
1
- import type { UpgradeWebSocket } from '../../helper/websocket';
1
+ import type { UpgradeWebSocket, WSEvents } from '../../helper/websocket';
2
2
  import { WSContext } from '../../helper/websocket';
3
3
  /**
4
4
  * @internal
@@ -12,14 +12,16 @@ export interface BunServerWebSocket<T> {
12
12
  interface BunWebSocketHandler<T> {
13
13
  open(ws: BunServerWebSocket<T>): void;
14
14
  close(ws: BunServerWebSocket<T>, code?: number, reason?: string): void;
15
- message(ws: BunServerWebSocket<T>, message: string | Uint8Array): void;
15
+ message(ws: BunServerWebSocket<T>, message: string | {
16
+ buffer: ArrayBufferLike;
17
+ }): void;
16
18
  }
17
19
  interface CreateWebSocket<T> {
18
20
  upgradeWebSocket: UpgradeWebSocket<T>;
19
21
  websocket: BunWebSocketHandler<BunWebSocketData>;
20
22
  }
21
23
  export interface BunWebSocketData {
22
- connId: number;
24
+ events: WSEvents;
23
25
  url: URL;
24
26
  protocol: string;
25
27
  }
@@ -1,2 +1,2 @@
1
- import type { UpgradeWebSocket } from '../../helper/websocket';
2
- export declare const upgradeWebSocket: UpgradeWebSocket<WebSocket>;
1
+ import type { UpgradeWebSocket, WSEvents } from '../../helper/websocket';
2
+ export declare const upgradeWebSocket: UpgradeWebSocket<WebSocket, any, Omit<WSEvents<WebSocket>, "onOpen">>;
@@ -1,21 +1,2 @@
1
1
  import type { UpgradeWebSocket } from '../../helper/websocket';
2
- export interface UpgradeWebSocketOptions {
3
- /**
4
- * Sets the `.protocol` property on the client side web socket to the
5
- * value provided here, which should be one of the strings specified in the
6
- * `protocols` parameter when requesting the web socket. This is intended
7
- * for clients and servers to specify sub-protocols to use to communicate to
8
- * each other.
9
- */
10
- protocol?: string;
11
- /**
12
- * If the client does not respond to this frame with a
13
- * `pong` within the timeout specified, the connection is deemed
14
- * unhealthy and is closed. The `close` and `error` event will be emitted.
15
- *
16
- * The unit is seconds, with a default of 30.
17
- * Set to `0` to disable timeouts.
18
- */
19
- idleTimeout?: number;
20
- }
21
- export declare const upgradeWebSocket: UpgradeWebSocket<WebSocket, UpgradeWebSocketOptions>;
2
+ export declare const upgradeWebSocket: UpgradeWebSocket<WebSocket, Deno.UpgradeWebSocketOptions>;
@@ -1,6 +1,7 @@
1
1
  import { HonoRequest } from './request';
2
2
  import type { Result } from './router';
3
3
  import type { Env, FetchEventLike, H, Input, NotFoundHandler, RouterRoute, TypedResponse } from './types';
4
+ import type { ResponseHeader } from './utils/headers';
4
5
  import type { RedirectStatusCode, StatusCode } from './utils/http-status';
5
6
  import type { BaseMime } from './utils/mime';
6
7
  import type { InvalidJSONValue, IsAny, JSONParsed, JSONValue, SimplifyDeepArray } from './utils/types';
@@ -170,7 +171,6 @@ type ContextOptions<E extends Env> = {
170
171
  interface SetHeadersOptions {
171
172
  append?: boolean;
172
173
  }
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";
174
174
  interface SetHeaders {
175
175
  (name: "Content-Type", value?: BaseMime, options?: SetHeadersOptions): void;
176
176
  (name: ResponseHeader, value?: string, options?: SetHeadersOptions): void;
@@ -434,7 +434,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
434
434
  * })
435
435
  * ```
436
436
  */
437
- redirect: <T extends RedirectStatusCode = 302>(location: string, status?: T) => Response & TypedResponse<undefined, T, "redirect">;
437
+ redirect: <T extends RedirectStatusCode = 302>(location: string | URL, status?: T) => Response & TypedResponse<undefined, T, "redirect">;
438
438
  /**
439
439
  * `.notFound()` can return the Not Found Response.
440
440
  *
@@ -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
+ import type { AcceptHeader } from '../../utils/headers';
3
3
  export interface Accept {
4
4
  type: string;
5
5
  params: Record<string, string>;
@@ -16,7 +16,7 @@ export interface WSEvents<T = unknown> {
16
16
  /**
17
17
  * Upgrade WebSocket Type
18
18
  */
19
- export type UpgradeWebSocket<T = unknown, U = any> = (createEvents: (c: Context) => WSEvents<T> | Promise<WSEvents<T>>, options?: U) => MiddlewareHandler<any, string, {
19
+ export type UpgradeWebSocket<T = unknown, U = any, _WSEvents = WSEvents<T>> = (createEvents: (c: Context) => _WSEvents | Promise<_WSEvents>, options?: U) => MiddlewareHandler<any, string, {
20
20
  outputFormat: "ws";
21
21
  }>;
22
22
  /**
@@ -26,7 +26,7 @@ export type WSReadyState = 0 | 1 | 2 | 3;
26
26
  /**
27
27
  * An argument for WSContext class
28
28
  */
29
- export interface WSContestInit<T = unknown> {
29
+ export interface WSContextInit<T = unknown> {
30
30
  send(data: string | ArrayBuffer, options: SendOptions): void;
31
31
  close(code?: number, reason?: string): void;
32
32
  raw?: T;
@@ -44,7 +44,7 @@ export interface SendOptions {
44
44
  * A context for controlling WebSockets
45
45
  */
46
46
  export declare class WSContext<T = unknown> {
47
- constructor(init: WSContestInit<T>);
47
+ constructor(init: WSContextInit<T>);
48
48
  send(source: string | ArrayBuffer | Uint8Array, options?: SendOptions): void;
49
49
  raw?: T;
50
50
  binaryType: BinaryType;
@@ -23,7 +23,7 @@ export type HonoOptions<E extends Env> = {
23
23
  */
24
24
  strict?: boolean;
25
25
  /**
26
- * `router` option specifices which router to use.
26
+ * `router` option specifies which router to use.
27
27
  *
28
28
  * @see {@link https://hono.dev/docs/api/hono#router-option}
29
29
  *
@@ -1,4 +1,5 @@
1
1
  import type { HtmlEscaped, HtmlEscapedString, StringBufferWithCallbacks } from '../utils/html';
2
+ import { DOM_MEMO } from './constants';
2
3
  import type { Context } from './context';
3
4
  import type { JSX as HonoJSX, IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements';
4
5
  export type Props = Record<string, any>;
@@ -45,6 +46,10 @@ export declare class JSXFragmentNode extends JSXNode {
45
46
  }
46
47
  export declare const jsx: (tag: string | Function, props: Props | null, ...children: (string | number | HtmlEscapedString)[]) => JSXNode;
47
48
  export declare const jsxFn: (tag: string | Function, props: Props, children: (string | number | HtmlEscapedString)[]) => JSXNode;
49
+ export declare const shallowEqual: (a: Props, b: Props) => boolean;
50
+ export type MemorableFC<T> = FC<T> & {
51
+ [DOM_MEMO]: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean;
52
+ };
48
53
  export declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
49
54
  export declare const Fragment: ({ children, }: {
50
55
  key?: string;
@@ -2,4 +2,5 @@ export declare const DOM_RENDERER: unique symbol;
2
2
  export declare const DOM_ERROR_HANDLER: unique symbol;
3
3
  export declare const DOM_STASH: unique symbol;
4
4
  export declare const DOM_INTERNAL_TAG: unique symbol;
5
+ export declare const DOM_MEMO: unique symbol;
5
6
  export declare const PERMALINK: unique symbol;
@@ -2,8 +2,8 @@
2
2
  * @module
3
3
  * This module provides APIs for `hono/jsx/dom`.
4
4
  */
5
- import { isValidElement, memo, reactAPICompatVersion } from '../base';
6
- import type { Child, DOMAttributes, JSX, JSXNode, Props } from '../base';
5
+ import { isValidElement, reactAPICompatVersion } from '../base';
6
+ import type { Child, DOMAttributes, JSX, JSXNode, Props, FC } from '../base';
7
7
  import { Children } from '../children';
8
8
  import { useContext } from '../context';
9
9
  import { createRef, forwardRef, startTransition, startViewTransition, use, useCallback, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, useViewTransition } from '../hooks';
@@ -15,6 +15,7 @@ import { createPortal, flushSync } from './render';
15
15
  export { render } from './render';
16
16
  declare const createElement: (tag: string | ((props: Props) => JSXNode), props: Props | null, ...children: Child[]) => JSXNode;
17
17
  declare const cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Props, ...children: Child[]) => T;
18
+ declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
18
19
  export { reactAPICompatVersion as version, createElement as jsx, useState, useEffect, useRef, useCallback, use, startTransition, useTransition, useDeferredValue, startViewTransition, useViewTransition, useMemo, useLayoutEffect, useInsertionEffect, useReducer, useId, useDebugValue, createRef, forwardRef, useImperativeHandle, useSyncExternalStore, useFormStatus, useActionState, useOptimistic, Suspense, ErrorBoundary, createContext, useContext, memo, isValidElement, createElement, cloneElement, Children, Fragment, Fragment as StrictMode, DOMAttributes, flushSync, createPortal, };
19
20
  declare const _default: {
20
21
  version: string;
@@ -77,17 +78,17 @@ declare const _default: {
77
78
  T,
78
79
  (action: N) => void
79
80
  ];
80
- Suspense: import("..").FC<import("..").PropsWithChildren<{
81
+ Suspense: FC<import("..").PropsWithChildren<{
81
82
  fallback: any;
82
83
  }>>;
83
- ErrorBoundary: import("..").FC<import("..").PropsWithChildren<{
84
+ ErrorBoundary: FC<import("..").PropsWithChildren<{
84
85
  fallback?: Child;
85
86
  fallbackRender?: import("../components").FallbackRender;
86
87
  onError?: import("../components").ErrorHandler;
87
88
  }>>;
88
89
  createContext: <T>(defaultValue: T) => import("..").Context<T>;
89
90
  useContext: <T>(context: import("..").Context<T>) => T;
90
- memo: <T>(component: import("..").FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => import("..").FC<T>;
91
+ memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
91
92
  isValidElement: (element: unknown) => element is JSXNode;
92
93
  createElement: (tag: string | ((props: Props) => JSXNode), props: Props | null, ...children: Child[]) => JSXNode;
93
94
  cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Props, ...children: Child[]) => T;
@@ -25,6 +25,7 @@ export type NodeObject = {
25
25
  e: SupportedElement | Text | undefined;
26
26
  p?: PreserveNodeType;
27
27
  a?: boolean;
28
+ o?: NodeObject;
28
29
  [DOM_STASH]: [
29
30
  number,
30
31
  any[][],
@@ -0,0 +1 @@
1
+ export declare const generateDigest: (stream: ReadableStream<Uint8Array> | null) => Promise<string | null>;
@@ -1,6 +1,7 @@
1
1
  import type { Result } from './router';
2
2
  import type { Input, InputToDataByTarget, ParamKeyToRecord, ParamKeys, RemoveQuestion, RouterRoute, ValidationTargets } from './types';
3
3
  import type { BodyData, ParseBodyOptions } from './utils/body';
4
+ import type { CustomHeader, RequestHeader } from './utils/headers';
4
5
  import type { Simplify, UnionToIntersection } from './utils/types';
5
6
  type Body = {
6
7
  json: any;
@@ -110,8 +111,9 @@ export declare class HonoRequest<P extends string = "/", I extends Input["out"]
110
111
  * })
111
112
  * ```
112
113
  */
114
+ header(name: RequestHeader): string | undefined;
113
115
  header(name: string): string | undefined;
114
- header(): Record<string, string>;
116
+ header(): Record<RequestHeader | (string & CustomHeader), string>;
115
117
  /**
116
118
  * `.parseBody()` can parse Request body of type `multipart/form-data` or `application/x-www-form-urlencoded`
117
119
  *