hono 4.6.2 → 4.6.4

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 (59) hide show
  1. package/dist/adapter/bun/serve-static.js +2 -2
  2. package/dist/adapter/deno/serve-static.js +1 -1
  3. package/dist/adapter/service-worker/handler.js +1 -1
  4. package/dist/cjs/adapter/bun/serve-static.js +2 -2
  5. package/dist/cjs/adapter/deno/serve-static.js +1 -1
  6. package/dist/cjs/adapter/service-worker/handler.js +1 -1
  7. package/dist/cjs/jsx/base.js +2 -0
  8. package/dist/cjs/jsx/jsx-runtime.js +28 -1
  9. package/dist/cjs/jsx/streaming.js +7 -4
  10. package/dist/cjs/middleware/combine/index.js +1 -0
  11. package/dist/cjs/middleware/secure-headers/secure-headers.js +8 -1
  12. package/dist/cjs/middleware/serve-static/index.js +13 -1
  13. package/dist/cjs/utils/filepath.js +3 -0
  14. package/dist/jsx/base.js +1 -0
  15. package/dist/jsx/jsx-runtime.js +28 -1
  16. package/dist/jsx/streaming.js +7 -4
  17. package/dist/middleware/combine/index.js +1 -0
  18. package/dist/middleware/secure-headers/secure-headers.js +8 -1
  19. package/dist/middleware/serve-static/index.js +13 -1
  20. package/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
  21. package/dist/types/adapter/cloudflare-pages/handler.d.ts +1 -1
  22. package/dist/types/adapter/lambda-edge/handler.d.ts +2 -2
  23. package/dist/types/adapter/netlify/handler.d.ts +1 -1
  24. package/dist/types/client/utils.d.ts +1 -1
  25. package/dist/types/compose.d.ts +1 -1
  26. package/dist/types/context.d.ts +1 -1
  27. package/dist/types/helper/adapter/index.d.ts +1 -1
  28. package/dist/types/helper/dev/index.d.ts +3 -3
  29. package/dist/types/helper/factory/index.d.ts +6 -3
  30. package/dist/types/helper/ssg/utils.d.ts +1 -1
  31. package/dist/types/helper/streaming/sse.d.ts +1 -1
  32. package/dist/types/helper/streaming/stream.d.ts +1 -1
  33. package/dist/types/helper/streaming/text.d.ts +1 -1
  34. package/dist/types/helper/testing/index.d.ts +1 -1
  35. package/dist/types/hono-base.d.ts +1 -1
  36. package/dist/types/jsx/base.d.ts +5 -1
  37. package/dist/types/jsx/dom/index.d.ts +28 -28
  38. package/dist/types/jsx/dom/intrinsic-element/components.d.ts +1 -1
  39. package/dist/types/jsx/dom/server.d.ts +32 -32
  40. package/dist/types/jsx/hooks/index.d.ts +6 -6
  41. package/dist/types/jsx/index.d.ts +29 -29
  42. package/dist/types/jsx/jsx-runtime.d.ts +1 -1
  43. package/dist/types/jsx/streaming.d.ts +2 -1
  44. package/dist/types/middleware/cache/index.d.ts +4 -4
  45. package/dist/types/middleware/context-storage/index.d.ts +1 -1
  46. package/dist/types/middleware/ip-restriction/index.d.ts +2 -2
  47. package/dist/types/middleware/jwt/jwt.d.ts +4 -4
  48. package/dist/types/middleware/secure-headers/secure-headers.d.ts +2 -0
  49. package/dist/types/middleware/serve-static/index.d.ts +3 -3
  50. package/dist/types/types.d.ts +23 -23
  51. package/dist/types/utils/concurrent.d.ts +2 -2
  52. package/dist/types/utils/cookie.d.ts +1 -1
  53. package/dist/types/utils/filepath.d.ts +1 -1
  54. package/dist/types/utils/jwt/index.d.ts +2 -2
  55. package/dist/types/utils/types.d.ts +3 -1
  56. package/dist/types/validator/validator.d.ts +3 -3
  57. package/dist/utils/filepath.js +3 -0
  58. package/package.json +14 -16
  59. package/perf-measures/type-check/generated/.gitkeep +0 -0
@@ -4,12 +4,12 @@ import { serveStatic as baseServeStatic } from "../../middleware/serve-static/in
4
4
  var serveStatic = (options) => {
5
5
  return async function serveStatic2(c, next) {
6
6
  const getContent = async (path) => {
7
- path = `./${path}`;
7
+ path = path.startsWith("/") ? path : `./${path}`;
8
8
  const file = Bun.file(path);
9
9
  return await file.exists() ? file : null;
10
10
  };
11
11
  const pathResolve = (path) => {
12
- return `./${path}`;
12
+ return path.startsWith("/") ? path : `./${path}`;
13
13
  };
14
14
  const isDir = async (path) => {
15
15
  let isDir2;
@@ -12,7 +12,7 @@ var serveStatic = (options) => {
12
12
  }
13
13
  };
14
14
  const pathResolve = (path) => {
15
- return `./${path}`;
15
+ return path.startsWith("/") ? path : `./${path}`;
16
16
  };
17
17
  const isDir = (path) => {
18
18
  let isDir2;
@@ -1,6 +1,6 @@
1
1
  // src/adapter/service-worker/handler.ts
2
2
  var handle = (app, opts = {
3
- fetch: globalThis.self !== void 0 ? globalThis.self.fetch : fetch
3
+ fetch: globalThis.fetch.bind(globalThis)
4
4
  }) => {
5
5
  return (evt) => {
6
6
  evt.respondWith(
@@ -26,12 +26,12 @@ var import_serve_static = require("../../middleware/serve-static");
26
26
  const serveStatic = (options) => {
27
27
  return async function serveStatic2(c, next) {
28
28
  const getContent = async (path) => {
29
- path = `./${path}`;
29
+ path = path.startsWith("/") ? path : `./${path}`;
30
30
  const file = Bun.file(path);
31
31
  return await file.exists() ? file : null;
32
32
  };
33
33
  const pathResolve = (path) => {
34
- return `./${path}`;
34
+ return path.startsWith("/") ? path : `./${path}`;
35
35
  };
36
36
  const isDir = async (path) => {
37
37
  let isDir2;
@@ -34,7 +34,7 @@ const serveStatic = (options) => {
34
34
  }
35
35
  };
36
36
  const pathResolve = (path) => {
37
- return `./${path}`;
37
+ return path.startsWith("/") ? path : `./${path}`;
38
38
  };
39
39
  const isDir = (path) => {
40
40
  let isDir2;
@@ -22,7 +22,7 @@ __export(handler_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(handler_exports);
24
24
  const handle = (app, opts = {
25
- fetch: globalThis.self !== void 0 ? globalThis.self.fetch : fetch
25
+ fetch: globalThis.fetch.bind(globalThis)
26
26
  }) => {
27
27
  return (evt) => {
28
28
  evt.respondWith(
@@ -27,6 +27,7 @@ __export(base_exports, {
27
27
  Fragment: () => Fragment,
28
28
  JSXFragmentNode: () => JSXFragmentNode,
29
29
  JSXNode: () => JSXNode,
30
+ booleanAttributes: () => booleanAttributes,
30
31
  cloneElement: () => cloneElement,
31
32
  getNameSpaceContext: () => getNameSpaceContext,
32
33
  isValidElement: () => isValidElement,
@@ -342,6 +343,7 @@ const reactAPICompatVersion = "19.0.0-hono-jsx";
342
343
  Fragment,
343
344
  JSXFragmentNode,
344
345
  JSXNode,
346
+ booleanAttributes,
345
347
  cloneElement,
346
348
  getNameSpaceContext,
347
349
  isValidElement,
@@ -29,7 +29,34 @@ module.exports = __toCommonJS(jsx_runtime_exports);
29
29
  var import_jsx_dev_runtime = require("./jsx-dev-runtime");
30
30
  var import_jsx_dev_runtime2 = require("./jsx-dev-runtime");
31
31
  var import_html = require("../helper/html");
32
- const jsxAttr = (name, value) => typeof value === "string" ? (0, import_html.raw)(name + '="' + import_html.html`${value}` + '"') : import_html.html`${name}="${value}"`;
32
+ var import_html2 = require("../utils/html");
33
+ var import_utils = require("./utils");
34
+ const jsxAttr = (key, v) => {
35
+ const buffer = [`${key}="`];
36
+ if (key === "style" && typeof v === "object") {
37
+ let styleStr = "";
38
+ (0, import_utils.styleObjectForEach)(v, (property, value) => {
39
+ if (value != null) {
40
+ styleStr += `${styleStr ? ";" : ""}${property}:${value}`;
41
+ }
42
+ });
43
+ (0, import_html2.escapeToBuffer)(styleStr, buffer);
44
+ buffer[0] += '"';
45
+ } else if (typeof v === "string") {
46
+ (0, import_html2.escapeToBuffer)(v, buffer);
47
+ buffer[0] += '"';
48
+ } else if (v === null || v === void 0) {
49
+ return (0, import_html.raw)("");
50
+ } else if (typeof v === "number" || v.isEscaped) {
51
+ buffer[0] += `${v}"`;
52
+ } else if (v instanceof Promise) {
53
+ buffer.unshift('"', v);
54
+ } else {
55
+ (0, import_html2.escapeToBuffer)(v.toString(), buffer);
56
+ buffer[0] += '"';
57
+ }
58
+ return buffer.length === 1 ? (0, import_html.raw)(buffer[0]) : (0, import_html2.stringBufferToString)(buffer, void 0);
59
+ };
33
60
  const jsxEscape = (value) => value;
34
61
  // Annotate the CommonJS export names for ESM import in node:
35
62
  0 && (module.exports = {
@@ -24,6 +24,7 @@ __export(streaming_exports, {
24
24
  module.exports = __toCommonJS(streaming_exports);
25
25
  var import_html = require("../helper/html");
26
26
  var import_html2 = require("../utils/html");
27
+ var import_base = require("./base");
27
28
  var import_components = require("./components");
28
29
  var import_constants = require("./constants");
29
30
  var import_components2 = require("./dom/components");
@@ -110,14 +111,16 @@ d.replaceWith(c.content)
110
111
  };
111
112
  Suspense[import_constants.DOM_RENDERER] = import_components2.Suspense;
112
113
  const textEncoder = new TextEncoder();
113
- const renderToReadableStream = (str, onError = console.trace) => {
114
+ const renderToReadableStream = (content, onError = console.trace) => {
114
115
  const reader = new ReadableStream({
115
116
  async start(controller) {
116
117
  try {
117
- const tmp = str instanceof Promise ? await str : await str.toString();
118
- const context = typeof tmp === "object" ? tmp : {};
118
+ if (content instanceof import_base.JSXNode) {
119
+ content = content.toString();
120
+ }
121
+ const context = typeof content === "object" ? content : {};
119
122
  const resolved = await (0, import_html2.resolveCallback)(
120
- tmp,
123
+ content,
121
124
  import_html2.HtmlEscapedCallbackPhase.BeforeStream,
122
125
  true,
123
126
  context
@@ -56,6 +56,7 @@ const every = (...middleware) => {
56
56
  if (res === false) {
57
57
  throw new Error("Unmet condition");
58
58
  }
59
+ return res;
59
60
  });
60
61
  const handler = async (c, next) => (0, import_compose.compose)(wrappedMiddleware.map((m) => [[m, void 0], c.req.param()]))(c, next);
61
62
  return async function every2(c, next) {
@@ -77,6 +77,13 @@ const secureHeaders = (customOptions) => {
77
77
  }
78
78
  headersToSet.push(["Content-Security-Policy", value]);
79
79
  }
80
+ if (options.contentSecurityPolicyReportOnly) {
81
+ const [callback, value] = getCSPDirectives(options.contentSecurityPolicyReportOnly);
82
+ if (callback) {
83
+ callbacks.push(callback);
84
+ }
85
+ headersToSet.push(["Content-Security-Policy-Report-Only", value]);
86
+ }
80
87
  if (options.permissionsPolicy && Object.keys(options.permissionsPolicy).length > 0) {
81
88
  headersToSet.push([
82
89
  "Permissions-Policy",
@@ -129,7 +136,7 @@ function getCSPDirectives(contentSecurityPolicy) {
129
136
  resultValues.pop();
130
137
  return callbacks.length === 0 ? [void 0, resultValues.join("")] : [
131
138
  (ctx, headersToSet) => headersToSet.map((values) => {
132
- if (values[0] === "Content-Security-Policy") {
139
+ if (values[0] === "Content-Security-Policy" || values[0] === "Content-Security-Policy-Report-Only") {
133
140
  const clone = values[1].slice();
134
141
  callbacks.forEach((cb) => {
135
142
  cb(ctx, clone);
@@ -33,6 +33,16 @@ const ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
33
33
  const DEFAULT_DOCUMENT = "index.html";
34
34
  const defaultPathResolve = (path) => path;
35
35
  const serveStatic = (options) => {
36
+ let isAbsoluteRoot = false;
37
+ let root;
38
+ if (options.root) {
39
+ if (options.root.startsWith("/")) {
40
+ isAbsoluteRoot = true;
41
+ root = new URL(`file://${options.root}`).pathname;
42
+ } else {
43
+ root = options.root;
44
+ }
45
+ }
36
46
  return async (c, next) => {
37
47
  if (c.finalized) {
38
48
  await next();
@@ -40,7 +50,6 @@ const serveStatic = (options) => {
40
50
  }
41
51
  let filename = options.path ?? decodeURI(c.req.path);
42
52
  filename = options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename;
43
- const root = options.root;
44
53
  if (!filename.endsWith("/") && options.isDir) {
45
54
  const path2 = (0, import_filepath.getFilePathWithoutDefaultDocument)({
46
55
  filename,
@@ -58,6 +67,9 @@ const serveStatic = (options) => {
58
67
  if (!path) {
59
68
  return await next();
60
69
  }
70
+ if (isAbsoluteRoot) {
71
+ path = "/" + path;
72
+ }
61
73
  const getContent = options.getContent;
62
74
  const pathResolve = options.pathResolve ?? defaultPathResolve;
63
75
  path = pathResolve(path);
@@ -47,6 +47,9 @@ const getFilePathWithoutDefaultDocument = (options) => {
47
47
  root = root.replace(/\/$/, "");
48
48
  let path = root ? root + "/" + filename : filename;
49
49
  path = path.replace(/^\.?\//, "");
50
+ if (root[0] !== "/" && path[0] === "/") {
51
+ return;
52
+ }
50
53
  return path;
51
54
  };
52
55
  // Annotate the CommonJS export names for ESM import in node:
package/dist/jsx/base.js CHANGED
@@ -304,6 +304,7 @@ export {
304
304
  Fragment,
305
305
  JSXFragmentNode,
306
306
  JSXNode,
307
+ booleanAttributes,
307
308
  cloneElement,
308
309
  getNameSpaceContext,
309
310
  isValidElement,
@@ -2,7 +2,34 @@
2
2
  import { jsxDEV, Fragment } from "./jsx-dev-runtime.js";
3
3
  import { jsxDEV as jsxDEV2 } from "./jsx-dev-runtime.js";
4
4
  import { html, raw } from "../helper/html/index.js";
5
- var jsxAttr = (name, value) => typeof value === "string" ? raw(name + '="' + html`${value}` + '"') : html`${name}="${value}"`;
5
+ import { escapeToBuffer, stringBufferToString } from "../utils/html.js";
6
+ import { styleObjectForEach } from "./utils.js";
7
+ var jsxAttr = (key, v) => {
8
+ const buffer = [`${key}="`];
9
+ if (key === "style" && typeof v === "object") {
10
+ let styleStr = "";
11
+ styleObjectForEach(v, (property, value) => {
12
+ if (value != null) {
13
+ styleStr += `${styleStr ? ";" : ""}${property}:${value}`;
14
+ }
15
+ });
16
+ escapeToBuffer(styleStr, buffer);
17
+ buffer[0] += '"';
18
+ } else if (typeof v === "string") {
19
+ escapeToBuffer(v, buffer);
20
+ buffer[0] += '"';
21
+ } else if (v === null || v === void 0) {
22
+ return raw("");
23
+ } else if (typeof v === "number" || v.isEscaped) {
24
+ buffer[0] += `${v}"`;
25
+ } else if (v instanceof Promise) {
26
+ buffer.unshift('"', v);
27
+ } else {
28
+ escapeToBuffer(v.toString(), buffer);
29
+ buffer[0] += '"';
30
+ }
31
+ return buffer.length === 1 ? raw(buffer[0]) : stringBufferToString(buffer, void 0);
32
+ };
6
33
  var jsxEscape = (value) => value;
7
34
  export {
8
35
  Fragment,
@@ -1,6 +1,7 @@
1
1
  // src/jsx/streaming.ts
2
2
  import { raw } from "../helper/html/index.js";
3
3
  import { HtmlEscapedCallbackPhase, resolveCallback } from "../utils/html.js";
4
+ import { JSXNode } from "./base.js";
4
5
  import { childrenToString } from "./components.js";
5
6
  import { DOM_RENDERER, DOM_STASH } from "./constants.js";
6
7
  import { Suspense as SuspenseDomRenderer } from "./dom/components.js";
@@ -87,14 +88,16 @@ d.replaceWith(c.content)
87
88
  };
88
89
  Suspense[DOM_RENDERER] = SuspenseDomRenderer;
89
90
  var textEncoder = new TextEncoder();
90
- var renderToReadableStream = (str, onError = console.trace) => {
91
+ var renderToReadableStream = (content, onError = console.trace) => {
91
92
  const reader = new ReadableStream({
92
93
  async start(controller) {
93
94
  try {
94
- const tmp = str instanceof Promise ? await str : await str.toString();
95
- const context = typeof tmp === "object" ? tmp : {};
95
+ if (content instanceof JSXNode) {
96
+ content = content.toString();
97
+ }
98
+ const context = typeof content === "object" ? content : {};
96
99
  const resolved = await resolveCallback(
97
- tmp,
100
+ content,
98
101
  HtmlEscapedCallbackPhase.BeforeStream,
99
102
  true,
100
103
  context
@@ -32,6 +32,7 @@ var every = (...middleware) => {
32
32
  if (res === false) {
33
33
  throw new Error("Unmet condition");
34
34
  }
35
+ return res;
35
36
  });
36
37
  const handler = async (c, next) => compose(wrappedMiddleware.map((m) => [[m, void 0], c.req.param()]))(c, next);
37
38
  return async function every2(c, next) {
@@ -54,6 +54,13 @@ var secureHeaders = (customOptions) => {
54
54
  }
55
55
  headersToSet.push(["Content-Security-Policy", value]);
56
56
  }
57
+ if (options.contentSecurityPolicyReportOnly) {
58
+ const [callback, value] = getCSPDirectives(options.contentSecurityPolicyReportOnly);
59
+ if (callback) {
60
+ callbacks.push(callback);
61
+ }
62
+ headersToSet.push(["Content-Security-Policy-Report-Only", value]);
63
+ }
57
64
  if (options.permissionsPolicy && Object.keys(options.permissionsPolicy).length > 0) {
58
65
  headersToSet.push([
59
66
  "Permissions-Policy",
@@ -106,7 +113,7 @@ function getCSPDirectives(contentSecurityPolicy) {
106
113
  resultValues.pop();
107
114
  return callbacks.length === 0 ? [void 0, resultValues.join("")] : [
108
115
  (ctx, headersToSet) => headersToSet.map((values) => {
109
- if (values[0] === "Content-Security-Policy") {
116
+ if (values[0] === "Content-Security-Policy" || values[0] === "Content-Security-Policy-Report-Only") {
110
117
  const clone = values[1].slice();
111
118
  callbacks.forEach((cb) => {
112
119
  cb(ctx, clone);
@@ -11,6 +11,16 @@ var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
11
11
  var DEFAULT_DOCUMENT = "index.html";
12
12
  var defaultPathResolve = (path) => path;
13
13
  var serveStatic = (options) => {
14
+ let isAbsoluteRoot = false;
15
+ let root;
16
+ if (options.root) {
17
+ if (options.root.startsWith("/")) {
18
+ isAbsoluteRoot = true;
19
+ root = new URL(`file://${options.root}`).pathname;
20
+ } else {
21
+ root = options.root;
22
+ }
23
+ }
14
24
  return async (c, next) => {
15
25
  if (c.finalized) {
16
26
  await next();
@@ -18,7 +28,6 @@ var serveStatic = (options) => {
18
28
  }
19
29
  let filename = options.path ?? decodeURI(c.req.path);
20
30
  filename = options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename;
21
- const root = options.root;
22
31
  if (!filename.endsWith("/") && options.isDir) {
23
32
  const path2 = getFilePathWithoutDefaultDocument({
24
33
  filename,
@@ -36,6 +45,9 @@ var serveStatic = (options) => {
36
45
  if (!path) {
37
46
  return await next();
38
47
  }
48
+ if (isAbsoluteRoot) {
49
+ path = "/" + path;
50
+ }
39
51
  const getContent = options.getContent;
40
52
  const pathResolve = options.pathResolve ?? defaultPathResolve;
41
53
  path = pathResolve(path);
@@ -70,7 +70,7 @@ export declare const streamHandle: <E extends Env = Env, S extends Schema = {},
70
70
  /**
71
71
  * Accepts events from API Gateway/ELB(`APIGatewayProxyEvent`) and directly through Function Url(`APIGatewayProxyEventV2`)
72
72
  */
73
- export declare const handle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => (event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>;
73
+ export declare const handle: <E extends Env = Env, S extends Schema = {}, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => ((event: LambdaEvent, lambdaContext?: LambdaContext) => Promise<APIGatewayProxyResult>);
74
74
  declare abstract class EventProcessor<E extends LambdaEvent> {
75
75
  protected abstract getPath(event: E): string;
76
76
  protected abstract getMethod(event: E): string;
@@ -16,7 +16,7 @@ export type EventContext<Env = {}, P extends string = any, Data = Record<string,
16
16
  data: Data;
17
17
  };
18
18
  declare type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
19
- export declare const handle: <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => PagesFunction<E["Bindings"], any, Record<string, unknown>>;
19
+ export declare const handle: <E extends Env = Env, S extends Schema = BlankSchema, BasePath extends string = "/">(app: Hono<E, S, BasePath>) => PagesFunction<E["Bindings"]>;
20
20
  export declare function handleMiddleware<E extends Env = {}, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E & {
21
21
  Bindings: {
22
22
  eventContext: EventContext;
@@ -81,7 +81,7 @@ interface CloudFrontResult {
81
81
  body?: string;
82
82
  bodyEncoding?: 'text' | 'base64';
83
83
  }
84
- export declare const handle: (app: Hono<any>) => (event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult>;
85
- export declare const createBody: (method: string, requestBody: CloudFrontRequest['body']) => string | Uint8Array | undefined;
84
+ export declare const handle: (app: Hono<any>) => ((event: CloudFrontEdgeEvent, context?: CloudFrontContext, callback?: Callback) => Promise<CloudFrontResult>);
85
+ export declare const createBody: (method: string, requestBody: CloudFrontRequest["body"]) => string | Uint8Array | undefined;
86
86
  export declare const isContentTypeBinary: (contentType: string) => boolean;
87
87
  export {};
@@ -1,2 +1,2 @@
1
1
  import type { Hono } from '../../hono';
2
- export declare const handle: (app: Hono<any, any>) => (req: Request, context: any) => Response | Promise<Response>;
2
+ export declare const handle: (app: Hono<any, any>) => ((req: Request, context: any) => Response | Promise<Response>);
@@ -1,5 +1,5 @@
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 replaceUrlProtocol: (urlString: string, protocol: 'ws' | 'http') => string;
3
+ export declare const replaceUrlProtocol: (urlString: string, protocol: "ws" | "http") => string;
4
4
  export declare const removeIndexString: (urlSting: string) => string;
5
5
  export declare function deepMerge<T>(target: T, source: Record<string, unknown>): T;
@@ -26,5 +26,5 @@ 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> | undefined, onNotFound?: NotFoundHandler<E> | undefined) => (context: C, next?: Function) => Promise<C>;
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>);
30
30
  export {};
@@ -424,7 +424,7 @@ export declare class Context<E extends Env = any, P extends string = any, I exte
424
424
  * })
425
425
  * ```
426
426
  */
427
- redirect: <T extends RedirectStatusCode = 302>(location: string, status?: T | undefined) => Response & TypedResponse<undefined, T, "redirect">;
427
+ redirect: <T extends RedirectStatusCode = 302>(location: string, status?: T) => Response & TypedResponse<undefined, T, "redirect">;
428
428
  /**
429
429
  * `.notFound()` can return the Not Found Response.
430
430
  *
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { Context } from '../../context';
6
6
  export type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'other';
7
- export declare const env: <T extends Record<string, unknown>, C extends Context<any, any, {}> = Context<{}, any, {}>>(c: C, runtime?: Runtime) => T & C["env"];
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;
10
10
  export declare const checkUserAgentEquals: (platform: string) => boolean;
@@ -14,7 +14,7 @@ interface RouteData {
14
14
  name: string;
15
15
  isMiddleware: boolean;
16
16
  }
17
- export declare const inspectRoutes: <E extends Env>(hono: Hono<E, import("../../types").BlankSchema, "/">) => RouteData[];
18
- export declare const showRoutes: <E extends Env>(hono: Hono<E, import("../../types").BlankSchema, "/">, opts?: ShowRoutesOptions) => void;
19
- export declare const getRouterName: <E extends Env>(app: Hono<E, import("../../types").BlankSchema, "/">) => string;
17
+ export declare const inspectRoutes: <E extends Env>(hono: Hono<E>) => RouteData[];
18
+ export declare const showRoutes: <E extends Env>(hono: Hono<E>, opts?: ShowRoutesOptions) => void;
19
+ export declare const getRouterName: <E extends Env>(app: Hono<E>) => string;
20
20
  export {};
@@ -67,7 +67,10 @@ export declare class Factory<E extends Env = any, P extends string = any> {
67
67
  createHandlers: CreateHandlersInterface<E, P>;
68
68
  }
69
69
  export declare const createFactory: <E extends Env = any, P extends string = any>(init?: {
70
- initApp?: InitApp<E> | undefined;
71
- } | undefined) => Factory<E, P>;
72
- export declare const createMiddleware: <E extends Env = any, P extends string = string, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>;
70
+ initApp?: InitApp<E>;
71
+ }) => 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>;
73
76
  export {};
@@ -10,5 +10,5 @@ export declare const joinPaths: (...paths: string[]) => string;
10
10
  interface FilterStaticGenerateRouteData {
11
11
  path: string;
12
12
  }
13
- export declare const filterStaticGenerateRoutes: <E extends Env>(hono: Hono<E, import("../../types").BlankSchema, "/">) => FilterStaticGenerateRouteData[];
13
+ export declare const filterStaticGenerateRoutes: <E extends Env>(hono: Hono<E>) => FilterStaticGenerateRouteData[];
14
14
  export {};
@@ -10,4 +10,4 @@ export declare class SSEStreamingApi extends StreamingApi {
10
10
  constructor(writable: WritableStream, readable: ReadableStream);
11
11
  writeSSE(message: SSEMessage): Promise<void>;
12
12
  }
13
- export declare const streamSSE: (c: Context, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: ((e: Error, stream: SSEStreamingApi) => Promise<void>) | undefined) => Response;
13
+ export declare const streamSSE: (c: Context, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>) => Response;
@@ -1,3 +1,3 @@
1
1
  import type { Context } from '../../context';
2
2
  import { StreamingApi } from '../../utils/stream';
3
- export declare const stream: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: ((e: Error, stream: StreamingApi) => Promise<void>) | undefined) => Response;
3
+ export declare const stream: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response;
@@ -1,3 +1,3 @@
1
1
  import type { Context } from '../../context';
2
2
  import type { StreamingApi } from '../../utils/stream';
3
- export declare const streamText: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: ((e: Error, stream: StreamingApi) => Promise<void>) | undefined) => Response;
3
+ export declare const streamText: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response;
@@ -8,5 +8,5 @@ import type { Hono } from '../../hono';
8
8
  import type { Schema } from '../../types';
9
9
  import type { UnionToIntersection } from '../../utils/types';
10
10
  type ExtractEnv<T> = T extends Hono<infer E, Schema, string> ? E : never;
11
- export declare const testClient: <T extends Hono<any, Schema, string>>(app: T, Env?: {} | ExtractEnv<T>["Bindings"] | undefined, executionCtx?: ExecutionContext) => UnionToIntersection<Client<T>>;
11
+ export declare const testClient: <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext) => UnionToIntersection<Client<T>>;
12
12
  export {};
@@ -207,7 +207,7 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
207
207
  * ```
208
208
  * @see https://hono.dev/docs/api/hono#request
209
209
  */
210
- request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: E['Bindings'] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
210
+ request: (input: RequestInfo | URL, requestInit?: RequestInit, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
211
211
  /**
212
212
  * `.fire()` automatically adds a global fetch event listener.
213
213
  * This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
@@ -16,8 +16,12 @@ export declare namespace JSX {
16
16
  interface IntrinsicElements extends IntrinsicElementsDefined {
17
17
  [tagName: string]: Props;
18
18
  }
19
+ interface IntrinsicAttributes {
20
+ key?: string | number | bigint | null | undefined;
21
+ }
19
22
  }
20
23
  export declare const getNameSpaceContext: () => Context<string> | undefined;
24
+ export declare const booleanAttributes: string[];
21
25
  type LocalContexts = [Context<unknown>, unknown][];
22
26
  export type Child = string | Promise<string> | number | JSXNode | null | undefined | boolean | Child[];
23
27
  export declare class JSXNode implements HtmlEscaped {
@@ -40,7 +44,7 @@ export declare const jsx: (tag: string | Function, props: Props | null, ...child
40
44
  export declare const jsxFn: (tag: string | Function, props: Props, children: (string | number | HtmlEscapedString)[]) => JSXNode;
41
45
  export declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>;
42
46
  export declare const Fragment: ({ children, }: {
43
- key?: string | undefined;
47
+ key?: string;
44
48
  children?: Child | HtmlEscapedString;
45
49
  }) => HtmlEscapedString;
46
50
  export declare const isValidElement: (element: unknown) => element is JSXNode;