@orchestraai/agent-tools 0.10.15 → 0.10.17

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 (188) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/.cursor-plugin/plugin.json +1 -1
  6. package/.devin/adapter.json +1 -1
  7. package/.hermes/adapter.json +1 -1
  8. package/.opencode/adapter.json +1 -1
  9. package/README.md +9 -0
  10. package/dist/commands/claude-setup.d.ts +1 -1
  11. package/dist/onboarding/init.js +6 -2
  12. package/dist/onboarding/init.js.map +1 -1
  13. package/dist/runtime/conversation/command-guard.js +1023 -63
  14. package/dist/runtime/conversation/command-guard.js.map +1 -1
  15. package/dist/runtime/conversation/shell-parse.d.ts +42 -0
  16. package/dist/runtime/conversation/shell-parse.js +517 -0
  17. package/dist/runtime/conversation/shell-parse.js.map +1 -0
  18. package/docs/security.md +11 -2
  19. package/install.sh +41 -7
  20. package/node_modules/@hono/node-server/dist/index.cjs +63 -17
  21. package/node_modules/@hono/node-server/dist/index.mjs +63 -17
  22. package/node_modules/@hono/node-server/dist/serve-static.cjs +1 -1
  23. package/node_modules/@hono/node-server/dist/serve-static.mjs +1 -1
  24. package/node_modules/@hono/node-server/package.json +1 -1
  25. package/node_modules/cross-spawn/README.md +19 -3
  26. package/node_modules/cross-spawn/lib/parse.js +38 -10
  27. package/node_modules/cross-spawn/lib/util/escape.js +84 -25
  28. package/node_modules/cross-spawn/lib/util/readShebang.js +8 -2
  29. package/node_modules/cross-spawn/lib/util/resolveCommand.js +8 -1
  30. package/node_modules/cross-spawn/package.json +21 -24
  31. package/node_modules/hono/README.md +2 -3
  32. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +2 -2
  33. package/node_modules/hono/dist/adapter/bun/websocket.js +19 -4
  34. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +5 -1
  35. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +2 -2
  36. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +19 -4
  37. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +5 -1
  38. package/node_modules/hono/dist/cjs/client/fetch-result-please.js +1 -1
  39. package/node_modules/hono/dist/cjs/client/utils.js +9 -5
  40. package/node_modules/hono/dist/cjs/context.js +1 -1
  41. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +7 -1
  42. package/node_modules/hono/dist/cjs/helper/css/common.js +11 -8
  43. package/node_modules/hono/dist/cjs/helper/css/index.js +1 -1
  44. package/node_modules/hono/dist/cjs/helper/proxy/index.js +2 -0
  45. package/node_modules/hono/dist/cjs/helper/route/index.js +3 -1
  46. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +5 -3
  47. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +6 -2
  48. package/node_modules/hono/dist/cjs/hono-base.js +9 -10
  49. package/node_modules/hono/dist/cjs/hono.js +0 -1
  50. package/node_modules/hono/dist/cjs/jsx/base.js +51 -32
  51. package/node_modules/hono/dist/cjs/jsx/components.js +2 -2
  52. package/node_modules/hono/dist/cjs/jsx/constants.js +2 -0
  53. package/node_modules/hono/dist/cjs/jsx/context.js +15 -2
  54. package/node_modules/hono/dist/cjs/jsx/dom/components.js +1 -1
  55. package/node_modules/hono/dist/cjs/jsx/dom/hooks/index.js +38 -8
  56. package/node_modules/hono/dist/cjs/jsx/dom/intrinsic-element/components.js +8 -5
  57. package/node_modules/hono/dist/cjs/jsx/dom/render.js +9 -3
  58. package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +13 -17
  59. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +3 -1
  60. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +9 -1
  61. package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +9 -10
  62. package/node_modules/hono/dist/cjs/middleware/combine/index.js +4 -0
  63. package/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -3
  64. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
  65. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -1
  66. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
  67. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
  68. package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +1 -1
  69. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +35 -12
  70. package/node_modules/hono/dist/cjs/middleware/mount/index.js +5 -4
  71. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +1 -0
  72. package/node_modules/hono/dist/cjs/middleware/request-id/request-id.js +3 -3
  73. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
  74. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +4 -2
  75. package/node_modules/hono/dist/cjs/middleware/timing/timing.js +4 -3
  76. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
  77. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
  78. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
  79. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
  80. package/node_modules/hono/dist/cjs/router/trie-router/node.js +6 -4
  81. package/node_modules/hono/dist/cjs/utils/body.js +2 -1
  82. package/node_modules/hono/dist/cjs/utils/cookie.js +3 -3
  83. package/node_modules/hono/dist/cjs/utils/html.js +5 -0
  84. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +8 -5
  85. package/node_modules/hono/dist/cjs/utils/mime.js +3 -2
  86. package/node_modules/hono/dist/cjs/utils/mount.js +59 -0
  87. package/node_modules/hono/dist/cjs/utils/url.js +23 -11
  88. package/node_modules/hono/dist/cjs/validator/validator.js +5 -5
  89. package/node_modules/hono/dist/client/fetch-result-please.js +1 -1
  90. package/node_modules/hono/dist/client/utils.js +9 -5
  91. package/node_modules/hono/dist/context.js +1 -1
  92. package/node_modules/hono/dist/helper/accepts/accepts.js +7 -1
  93. package/node_modules/hono/dist/helper/css/common.js +11 -8
  94. package/node_modules/hono/dist/helper/css/index.js +1 -1
  95. package/node_modules/hono/dist/helper/proxy/index.js +2 -0
  96. package/node_modules/hono/dist/helper/route/index.js +3 -1
  97. package/node_modules/hono/dist/helper/ssg/ssg.js +5 -3
  98. package/node_modules/hono/dist/helper/streaming/sse.js +6 -2
  99. package/node_modules/hono/dist/hono-base.js +9 -10
  100. package/node_modules/hono/dist/hono.js +0 -1
  101. package/node_modules/hono/dist/jsx/base.js +51 -34
  102. package/node_modules/hono/dist/jsx/components.js +2 -2
  103. package/node_modules/hono/dist/jsx/constants.js +2 -1
  104. package/node_modules/hono/dist/jsx/context.js +15 -2
  105. package/node_modules/hono/dist/jsx/dom/components.js +2 -2
  106. package/node_modules/hono/dist/jsx/dom/hooks/index.js +39 -9
  107. package/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js +8 -5
  108. package/node_modules/hono/dist/jsx/dom/render.js +9 -3
  109. package/node_modules/hono/dist/jsx/jsx-runtime.js +15 -19
  110. package/node_modules/hono/dist/middleware/basic-auth/index.js +3 -1
  111. package/node_modules/hono/dist/middleware/bearer-auth/index.js +9 -1
  112. package/node_modules/hono/dist/middleware/body-limit/index.js +9 -10
  113. package/node_modules/hono/dist/middleware/combine/index.js +4 -0
  114. package/node_modules/hono/dist/middleware/compress/index.js +2 -3
  115. package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
  116. package/node_modules/hono/dist/middleware/etag/index.js +3 -1
  117. package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
  118. package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
  119. package/node_modules/hono/dist/middleware/method-not-allowed/index.js +1 -1
  120. package/node_modules/hono/dist/middleware/method-override/index.js +35 -12
  121. package/node_modules/hono/dist/middleware/mount/index.js +5 -4
  122. package/node_modules/hono/dist/middleware/pretty-json/index.js +1 -0
  123. package/node_modules/hono/dist/middleware/request-id/request-id.js +3 -3
  124. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
  125. package/node_modules/hono/dist/middleware/serve-static/index.js +4 -2
  126. package/node_modules/hono/dist/middleware/timing/timing.js +4 -3
  127. package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
  128. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
  129. package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
  130. package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
  131. package/node_modules/hono/dist/router/trie-router/node.js +6 -4
  132. package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +1 -1
  133. package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +1 -1
  134. package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +1 -1
  135. package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +1 -1
  136. package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +1 -1
  137. package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +1 -1
  138. package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +1 -1
  139. package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +1 -1
  140. package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +1 -1
  141. package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +1 -1
  142. package/node_modules/hono/dist/types/helper/accepts/accepts.d.ts +5 -0
  143. package/node_modules/hono/dist/types/helper/factory/index.d.ts +1 -1
  144. package/node_modules/hono/dist/types/helper/ssg/ssg.d.ts +6 -1
  145. package/node_modules/hono/dist/types/helper/streaming/sse.d.ts +1 -1
  146. package/node_modules/hono/dist/types/helper/streaming/stream.d.ts +1 -1
  147. package/node_modules/hono/dist/types/helper/streaming/text.d.ts +1 -1
  148. package/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
  149. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +13 -3
  150. package/node_modules/hono/dist/types/hono-base.d.ts +23 -9
  151. package/node_modules/hono/dist/types/index.d.ts +1 -1
  152. package/node_modules/hono/dist/types/jsx/base.d.ts +6 -3
  153. package/node_modules/hono/dist/types/jsx/components.d.ts +2 -2
  154. package/node_modules/hono/dist/types/jsx/constants.d.ts +1 -0
  155. package/node_modules/hono/dist/types/jsx/context.d.ts +2 -2
  156. package/node_modules/hono/dist/types/jsx/dom/components.d.ts +2 -2
  157. package/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -2
  158. package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +5 -3
  159. package/node_modules/hono/dist/types/jsx/dom/index.d.ts +1 -1
  160. package/node_modules/hono/dist/types/jsx/dom/server.d.ts +1 -1
  161. package/node_modules/hono/dist/types/jsx/index.d.ts +1 -1
  162. package/node_modules/hono/dist/types/jsx/jsx-runtime.d.ts +2 -1
  163. package/node_modules/hono/dist/types/jsx/streaming.d.ts +4 -3
  164. package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +1 -0
  165. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
  166. package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +3 -3
  167. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +3 -3
  168. package/node_modules/hono/dist/types/middleware/mount/index.d.ts +2 -0
  169. package/node_modules/hono/dist/types/middleware/request-id/request-id.d.ts +3 -3
  170. package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +2 -0
  171. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
  172. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
  173. package/node_modules/hono/dist/types/utils/cookie.d.ts +1 -1
  174. package/node_modules/hono/dist/types/utils/ipaddr.d.ts +1 -1
  175. package/node_modules/hono/dist/types/utils/jwt/jwt.d.ts +4 -2
  176. package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
  177. package/node_modules/hono/dist/types/utils/types.d.ts +12 -2
  178. package/node_modules/hono/dist/utils/body.js +2 -1
  179. package/node_modules/hono/dist/utils/cookie.js +3 -3
  180. package/node_modules/hono/dist/utils/html.js +5 -0
  181. package/node_modules/hono/dist/utils/jwt/jwt.js +8 -5
  182. package/node_modules/hono/dist/utils/mime.js +3 -2
  183. package/node_modules/hono/dist/utils/mount.js +58 -0
  184. package/node_modules/hono/dist/utils/url.js +23 -11
  185. package/node_modules/hono/dist/validator/validator.js +5 -5
  186. package/node_modules/hono/package.json +1 -1
  187. package/package.json +1 -1
  188. package/skills/install-agent-adapter/reference.md +8 -0
@@ -1,8 +1,8 @@
1
1
  import { createNullObject } from "../utils.js";
2
2
  //#region src/router/reg-exp-router/node.ts
3
3
  const LABEL_REG_EXP_STR = "[^/]+";
4
- const ONLY_WILDCARD_REG_EXP_STR = ".*";
5
- const TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
4
+ const ONLY_WILDCARD_REG_EXP_STR = "[^]*";
5
+ const TAIL_WILDCARD_REG_EXP_STR = "(?:|/[^]*)";
6
6
  const PATH_ERROR = Symbol();
7
7
  const regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
8
8
  /**
@@ -15,8 +15,8 @@ const regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
15
15
  function compareKey(a, b) {
16
16
  if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
17
17
  if (b.length === 1) return 1;
18
- if (a === ".*" || a === "(?:|/.*)") return b === "(?:|/.*)" ? -1 : 1;
19
- else if (b === ".*" || b === "(?:|/.*)") return -1;
18
+ if (a === "[^]*" || a === "(?:|/[^]*)") return b === "[^]*" ? -1 : 1;
19
+ else if (b === "[^]*" || b === "(?:|/[^]*)") return -1;
20
20
  if (a === "[^/]+") return 1;
21
21
  else if (b === "[^/]+") return -1;
22
22
  return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
@@ -25,14 +25,14 @@ var Node = class Node {
25
25
  #index;
26
26
  #varIndex;
27
27
  #children = createNullObject();
28
- insert(tokens, index, paramMap, context, isStatic) {
28
+ insert(tokens, index, paramMap, context, keys) {
29
29
  let node = this;
30
30
  for (let i = 0, len = tokens.length; i < len; i++) {
31
31
  const token = tokens[i];
32
32
  const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? [
33
33
  "",
34
34
  "",
35
- ".*"
35
+ ONLY_WILDCARD_REG_EXP_STR
36
36
  ] : [
37
37
  "",
38
38
  "",
@@ -47,15 +47,16 @@ var Node = class Node {
47
47
  const name = pattern[1];
48
48
  let regexpStr = pattern[2] || "[^/]+";
49
49
  if (name && pattern[2]) {
50
- if (regexpStr === ".*") throw PATH_ERROR;
50
+ if (new RegExp(regexpStr).test("")) throw PATH_ERROR;
51
51
  regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
52
52
  if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
53
53
  if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
54
54
  }
55
+ keys.push(regexpStr);
55
56
  nextNode = node.#children[regexpStr];
56
57
  if (!nextNode) {
57
- if (regexpStr !== ".*" && regexpStr !== "(?:|/.*)") {
58
- for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
58
+ if (regexpStr !== "[^]*" && regexpStr !== "(?:|/[^]*)") {
59
+ for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
59
60
  }
60
61
  nextNode = node.#children[regexpStr] = new Node();
61
62
  }
@@ -64,16 +65,17 @@ var Node = class Node {
64
65
  paramMap.push([name, nextNode.#varIndex]);
65
66
  }
66
67
  } else {
68
+ keys.push(token);
67
69
  nextNode = node.#children[token];
68
70
  if (!nextNode) {
69
- for (const k in node.#children) if (k.length > 1 && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
71
+ for (const k in node.#children) if (k.length > 1 && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
70
72
  nextNode = node.#children[token] = new Node();
71
73
  }
72
74
  }
73
75
  node = nextNode;
74
76
  }
75
77
  if (node.#index !== void 0) throw PATH_ERROR;
76
- node.#index = isStatic ? -1 : index;
78
+ node.#index = index;
77
79
  }
78
80
  buildRegExpStr() {
79
81
  const strList = Object.keys(this.#children).sort(compareKey).map((k) => {
@@ -1,5 +1,5 @@
1
1
  import "../../router.js";
2
- import { emptyParam, match } from "./matcher.js";
2
+ import { match } from "./matcher.js";
3
3
  import { RegExpRouter } from "./router.js";
4
4
  //#region src/router/reg-exp-router/prepared-router.ts
5
5
  var PreparedRegExpRouter = class {
@@ -27,7 +27,7 @@ var PreparedRegExpRouter = class {
27
27
  if (!this.#matchers[method]) {
28
28
  const all = this.#matchers["ALL"];
29
29
  const staticMap = {};
30
- for (const key in all[2]) staticMap[key] = [all[2][key][0].slice(), emptyParam];
30
+ for (const key in all[2]) staticMap[key] = [all[2][key][0].slice(), all[2][key][1]];
31
31
  this.#matchers[method] = [
32
32
  all[0],
33
33
  all[1].map((list) => Array.isArray(list) ? list.slice() : 0),
@@ -71,7 +71,7 @@ const buildInitParams = ({ paths }) => {
71
71
  ...map
72
72
  };
73
73
  else relocateMap[path] = [[[], map]];
74
- if (relocateMap[path][0][0].findIndex((j) => j === i) === -1) relocateMap[path][0][0].push(i);
74
+ if (!relocateMap[path][0][0].includes(i)) relocateMap[path][0][0].push(i);
75
75
  }
76
76
  });
77
77
  });
@@ -79,7 +79,7 @@ const buildInitParams = ({ paths }) => {
79
79
  if (p === path) {
80
80
  relocateMap[path] ||= [[[]]];
81
81
  const value = path2 === path ? "" : path2;
82
- if (relocateMap[path][0][0].findIndex((v) => v === value) === -1) relocateMap[path][0][0].push(value);
82
+ if (!relocateMap[path][0][0].includes(value)) relocateMap[path][0][0].push(value);
83
83
  }
84
84
  });
85
85
  }
@@ -88,7 +88,7 @@ const buildInitParams = ({ paths }) => {
88
88
  return [matchers, relocateMap];
89
89
  };
90
90
  const serializeInitParams = ([matchers, relocateMap]) => {
91
- return `[${JSON.stringify(matchers, (_, value) => value instanceof RegExp ? `##${value.toString()}##` : value).replace(/"##(.+?)##"/g, (_, str) => str.replace(/\\\\/g, "\\"))},${JSON.stringify(relocateMap)}]`;
91
+ return `[${JSON.stringify(matchers, (_, value) => value instanceof RegExp || value === void 0 ? `##${value}##` : value).replace(/"##(.+?)##"/g, (_, str) => str.replace(/\\\\/g, "\\"))},${JSON.stringify(relocateMap)}]`;
92
92
  };
93
93
  //#endregion
94
94
  export { PreparedRegExpRouter, buildInitParams, serializeInitParams };
@@ -2,24 +2,24 @@ import { checkOptionalParameter } from "../../utils/url.js";
2
2
  import { MESSAGE_MATCHER_IS_ALREADY_BUILT, UnsupportedPathError } from "../../router.js";
3
3
  import { createNullObject } from "../utils.js";
4
4
  import { emptyParam, match } from "./matcher.js";
5
- import { LABEL_REG_EXP_STR, PATH_ERROR, TAIL_WILDCARD_REG_EXP_STR } from "./node.js";
5
+ import { PATH_ERROR } from "./node.js";
6
6
  import { Trie } from "./trie.js";
7
7
  //#region src/router/reg-exp-router/router.ts
8
- let wildcardRegExpCache = createNullObject();
9
- function buildWildcardRegExp(path) {
10
- return wildcardRegExpCache[path] ??= new RegExp(`^${path.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (match, metaChar) => metaChar ? `\\${metaChar}` : match === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match === "*" ? ".*" : `/:${LABEL_REG_EXP_STR}`)}$`);
8
+ function endsWithWildcard(keys) {
9
+ const tail = keys[keys.length - 1];
10
+ return tail === "[^]*" || tail === "(?:|/[^]*)";
11
11
  }
12
- function findMiddleware(middleware, path) {
13
- for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path)) return [...middleware[k]];
12
+ function covers(wildcard, target) {
13
+ const last = wildcard.length - 1;
14
+ for (let i = 0; i < last; i++) if (wildcard[i] !== target[i]) return false;
15
+ return wildcard[last] === "[^]*" || target.length === last || target[last] === "/";
14
16
  }
15
17
  var RegExpRouter = class {
16
18
  name = "RegExpRouter";
17
- #middleware;
18
- #routes;
19
+ #handlers;
19
20
  #tries;
20
21
  constructor() {
21
- this.#middleware = { ["ALL"]: createNullObject() };
22
- this.#routes = { ["ALL"]: createNullObject() };
22
+ this.#handlers = { ["ALL"]: [] };
23
23
  this.#tries = { ["ALL"]: new Trie() };
24
24
  }
25
25
  #insertPath(method, path) {
@@ -30,65 +30,53 @@ var RegExpRouter = class {
30
30
  }
31
31
  }
32
32
  add(method, path, handler) {
33
- const middleware = this.#middleware;
34
- const routes = this.#routes;
35
- if (!middleware) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
36
- if (!middleware[method]) {
37
- this.#tries[method] = new Trie();
38
- for (const handlerMap of [middleware, routes]) {
39
- handlerMap[method] = createNullObject();
40
- for (const p in handlerMap["ALL"]) {
41
- handlerMap[method][p] = [...handlerMap["ALL"][p]];
42
- this.#insertPath(method, p);
43
- }
44
- }
33
+ const handlers = this.#handlers;
34
+ if (!handlers) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
35
+ const tries = this.#tries;
36
+ if (!handlers[method]) {
37
+ tries[method] = new Trie();
38
+ handlers[method] = [...handlers["ALL"]];
39
+ for (const p in tries["ALL"].paths) this.#insertPath(method, p);
45
40
  }
46
41
  if (path === "/*") path = "*";
47
- const methods = method === "ALL" ? Object.keys(middleware) : [method];
48
- if (/\*$/.test(path)) {
49
- const re = buildWildcardRegExp(path);
50
- for (const m of methods) if (!middleware[m][path]) {
51
- this.#insertPath(m, path);
52
- middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
53
- }
54
- for (const handlerMap of [middleware, routes]) for (const m of methods) for (const p in handlerMap[m]) re.test(p) && handlerMap[m][p].push([handler, path]);
55
- return;
56
- }
42
+ const methods = method === "ALL" ? Object.keys(handlers) : [method];
57
43
  const paths = checkOptionalParameter(path) || [path];
58
44
  for (const path of paths) for (const m of methods) {
59
- if (!routes[m][path]) {
60
- this.#insertPath(m, path);
61
- routes[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
62
- }
63
- routes[m][path].push([handler, path]);
45
+ if (!tries[m].paths[path]) this.#insertPath(m, path);
46
+ handlers[m].push([handler, path]);
64
47
  }
65
48
  }
66
49
  match = match;
67
50
  buildAllMatchers() {
68
51
  const matchers = createNullObject();
69
- for (const method of Object.keys(this.#routes)) matchers[method] = this.#buildMatcher(method);
70
- this.#middleware = this.#routes = this.#tries = void 0;
71
- wildcardRegExpCache = createNullObject();
52
+ for (const method of Object.keys(this.#handlers)) matchers[method] = this.#buildMatcher(method);
53
+ this.#handlers = this.#tries = void 0;
72
54
  return matchers;
73
55
  }
74
56
  #buildMatcher(method) {
75
- const middleware = this.#middleware[method];
76
- const routes = this.#routes[method];
57
+ const handlers = this.#handlers[method];
77
58
  const trie = this.#tries[method];
78
59
  const staticMap = createNullObject();
79
60
  const handlerData = [];
80
61
  const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
81
- for (const r of [middleware, routes]) for (const path in r) {
82
- const handlers = r[path];
83
- const pathData = trie.paths[path];
84
- if (!pathData) {
85
- staticMap[path] = [handlers.map(([h]) => [h, createNullObject()]), emptyParam];
86
- continue;
87
- }
88
- handlerData[pathData[0]] = handlers.map(([h, handlerPath]) => [h, trie.paths[handlerPath][1].reduceRight((map, [key], i) => {
89
- map[key] = paramReplacementMap[pathData[1][i][1]];
62
+ const own = createNullObject();
63
+ const entries = handlers.map(([h, p], i) => {
64
+ (own[p] ??= []).push(i);
65
+ return [h, trie.paths[p][1].reduceRight((map, [key, varIndex]) => {
66
+ map[key] = paramReplacementMap[varIndex];
90
67
  return map;
91
- }, createNullObject())]);
68
+ }, createNullObject())];
69
+ });
70
+ const wildcards = Object.keys(own).filter((p) => endsWithWildcard(trie.paths[p][2]));
71
+ for (const path in trie.paths) {
72
+ const [index, , keys] = trie.paths[path];
73
+ const indexes = [...own[path]];
74
+ for (const p of wildcards) if (p !== path && covers(trie.paths[p][2], keys)) indexes.push(...own[p]);
75
+ const data = indexes.sort((a, b) => a - b).map((i) => entries[i]);
76
+ if (index === -1) {
77
+ const last = Math.max(-1, ...data.flatMap(([, map]) => Object.values(map)));
78
+ staticMap[path] = [data, last === -1 ? emptyParam : path.match(regexp).slice(0, last + 1)];
79
+ } else handlerData[index] = data;
92
80
  }
93
81
  return [
94
82
  regexp,
@@ -7,8 +7,14 @@ var Trie = class {
7
7
  #index = 0;
8
8
  paths = createNullObject();
9
9
  insert(path, isStatic) {
10
+ const keys = [];
10
11
  if (isStatic) {
11
- this.#root.insert(path.split(""), 0, [], this.#context, true);
12
+ this.#root.insert(path.split(""), -1, [], this.#context, keys);
13
+ this.paths[path] = [
14
+ -1,
15
+ [],
16
+ keys
17
+ ];
12
18
  return;
13
19
  }
14
20
  const paramAssoc = [];
@@ -16,7 +22,7 @@ var Trie = class {
16
22
  let markedPath = path;
17
23
  for (let i = 0;;) {
18
24
  let replaced = false;
19
- markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
25
+ markedPath = markedPath.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g, (m) => {
20
26
  const mark = `@\\${i}`;
21
27
  groups[i] = [mark, m];
22
28
  i++;
@@ -30,7 +36,7 @@ var Trie = class {
30
36
  * - /* wildcard
31
37
  * - character
32
38
  */
33
- const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
39
+ const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./gs) || [];
34
40
  for (let i = groups.length - 1; i >= 0; i--) {
35
41
  const [mark] = groups[i];
36
42
  for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
@@ -38,8 +44,12 @@ var Trie = class {
38
44
  break;
39
45
  }
40
46
  }
41
- this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
42
- this.paths[path] = [this.#index++, paramAssoc];
47
+ this.#root.insert(tokens, this.#index, paramAssoc, this.#context, keys);
48
+ this.paths[path] = [
49
+ this.#index++,
50
+ paramAssoc,
51
+ keys
52
+ ];
43
53
  }
44
54
  buildRegExp() {
45
55
  let regexp = this.#root.buildRegExpStr();
@@ -28,11 +28,13 @@ var Node = class Node {
28
28
  curNode = child;
29
29
  if (isParam) possibleKeys.add(pattern[1]);
30
30
  }
31
- curNode.#methods.push({ [method]: {
31
+ const methodMap = createNullObject();
32
+ methodMap[method] = {
32
33
  handler,
33
34
  possibleKeys: [...possibleKeys],
34
35
  score: ++order
35
- } });
36
+ };
37
+ curNode.#methods.push(methodMap);
36
38
  }
37
39
  #pushHandlerSets(handlerSets, node, method, nodeParams, params) {
38
40
  for (let i = 0, len = node.#methods.length; i < len; i++) {
@@ -97,7 +99,7 @@ var Node = class Node {
97
99
  const restPathString = path.slice(partOffsets[i]);
98
100
  const m = matcher.exec(restPathString);
99
101
  if (m) {
100
- params[name] = m[0];
102
+ if (!Object.hasOwn(params, name)) params[name] = m[0];
101
103
  this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
102
104
  if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
103
105
  for (const _ in child.#children) {
@@ -110,7 +112,7 @@ var Node = class Node {
110
112
  }
111
113
  }
112
114
  if (matcher === true || matcher.test(part)) {
113
- params[name] = part;
115
+ if (!Object.hasOwn(params, name)) params[name] = part;
114
116
  if (isLast) {
115
117
  this.#pushHandlerSets(handlerSets, child, method, params, node.#params);
116
118
  if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node.#params);
@@ -1,4 +1,4 @@
1
- import { GetConnInfo } from "../../helper/conninfo/types.js";
1
+ import { GetConnInfo } from "../../helper/conninfo/index.js";
2
2
  //#region src/adapter/aws-lambda/conninfo.d.ts
3
3
  /**
4
4
  * Get connection information from AWS Lambda
@@ -1,4 +1,4 @@
1
- import { GetConnInfo } from "../../helper/conninfo/types.js";
1
+ import { GetConnInfo } from "../../helper/conninfo/index.js";
2
2
  //#region src/adapter/bun/conninfo.d.ts
3
3
  /**
4
4
  * Get ConnInfo with Bun
@@ -1,4 +1,4 @@
1
- import { FileSystemModule, ToSSGAdaptorInterface } from "../../helper/ssg/ssg.js";
1
+ import { FileSystemModule, ToSSGAdaptorInterface } from "../../helper/ssg/index.js";
2
2
  //#region src/adapter/bun/ssg.d.ts
3
3
  /**
4
4
  * @experimental
@@ -1,4 +1,4 @@
1
- import { GetConnInfo } from "../../helper/conninfo/types.js";
1
+ import { GetConnInfo } from "../../helper/conninfo/index.js";
2
2
  //#region src/adapter/cloudflare-pages/conninfo.d.ts
3
3
  /**
4
4
  * Get connection information from Cloudflare Pages
@@ -1,4 +1,4 @@
1
- import { GetConnInfo } from "../../helper/conninfo/types.js";
1
+ import { GetConnInfo } from "../../helper/conninfo/index.js";
2
2
  //#region src/adapter/cloudflare-workers/conninfo.d.ts
3
3
  /**
4
4
  * @deprecated `hono/cloudflare-workers` will be removed in v5. Install `@hono/cloudflare-workers` and import from there instead.
@@ -1,4 +1,4 @@
1
- import { GetConnInfo } from "../../helper/conninfo/types.js";
1
+ import { GetConnInfo } from "../../helper/conninfo/index.js";
2
2
  //#region src/adapter/deno/conninfo.d.ts
3
3
  /**
4
4
  * Get conninfo with Deno
@@ -1,4 +1,4 @@
1
- import { FileSystemModule, ToSSGAdaptorInterface } from "../../helper/ssg/ssg.js";
1
+ import { FileSystemModule, ToSSGAdaptorInterface } from "../../helper/ssg/index.js";
2
2
  //#region src/adapter/deno/ssg.d.ts
3
3
  /**
4
4
  * @experimental
@@ -1,4 +1,4 @@
1
- import { GetConnInfo } from "../../helper/conninfo/types.js";
1
+ import { GetConnInfo } from "../../helper/conninfo/index.js";
2
2
  //#region src/adapter/lambda-edge/conninfo.d.ts
3
3
  /**
4
4
  * @deprecated `hono/lambda-edge` will be removed in v5. Install `@hono/lambda-edge` and import from there instead.
@@ -1,4 +1,4 @@
1
- import { GetConnInfo } from "../../helper/conninfo/types.js";
1
+ import { GetConnInfo } from "../../helper/conninfo/index.js";
2
2
  //#region src/adapter/netlify/conninfo.d.ts
3
3
  /**
4
4
  * Get connection information from Netlify
@@ -1,4 +1,4 @@
1
- import { GetConnInfo } from "../../helper/conninfo/types.js";
1
+ import { GetConnInfo } from "../../helper/conninfo/index.js";
2
2
  //#region src/adapter/vercel/conninfo.d.ts
3
3
  /**
4
4
  * @deprecated `hono/vercel` will be removed in v5. Install `@hono/vercel` and import from there instead.
@@ -17,6 +17,11 @@ export interface acceptsOptions extends acceptsConfig {
17
17
  export declare const defaultMatch: (accepts: Accept[], config: acceptsConfig) => string;
18
18
  /**
19
19
  * Match the accept header with the given options.
20
+ *
21
+ * @param {Context} c - The context of the request.
22
+ * @param {acceptsOptions} options - The options for matching the accept header.
23
+ * @returns {string} The matched supported value or the default value.
24
+ *
20
25
  * @example
21
26
  * ```ts
22
27
  * app.get('/users', (c) => {
@@ -12,7 +12,7 @@ export interface CreateHandlersInterface<E extends Env, P extends string> {
12
12
  <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, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any, R5 extends HandlerResponse<any> = any, R6 extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R2>, handler3: H<E4, P, I3, R3>, handler4: H<E5, P, I4, R4>, handler5: H<E6, P, I5, R5>, handler6: H<E7, P, I6, R6>): [H<E2, P, I, R>, H<E3, P, I2, R2>, H<E4, P, I3, R3>, H<E5, P, I4, R4>, H<E6, P, I5, R5>, H<E7, P, I6, R6>];
13
13
  <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, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any, R5 extends HandlerResponse<any> = any, R6 extends HandlerResponse<any> = any, R7 extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R2>, handler3: H<E4, P, I3, R3>, handler4: H<E5, P, I4, R4>, handler5: H<E6, P, I5, R5>, handler6: H<E7, P, I6, R6>, handler7: H<E8, P, I7, R7>): [H<E2, P, I, R>, H<E3, P, I2, R2>, H<E4, P, I3, R3>, H<E5, P, I4, R4>, H<E6, P, I5, R5>, H<E7, P, I6, R6>, H<E8, P, I7, R7>];
14
14
  <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, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any, R5 extends HandlerResponse<any> = any, R6 extends HandlerResponse<any> = any, R7 extends HandlerResponse<any> = any, R8 extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, E9 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R2>, handler3: H<E4, P, I3, R3>, handler4: H<E5, P, I4, R4>, handler5: H<E6, P, I5, R5>, handler6: H<E7, P, I6, R6>, handler7: H<E8, P, I7, R7>, handler8: H<E9, P, I8, R8>): [H<E2, P, I, R>, H<E3, P, I2, R2>, H<E4, P, I3, R3>, H<E5, P, I4, R4>, H<E6, P, I5, R5>, H<E7, P, I6, R6>, H<E8, P, I7, R7>, H<E9, P, I8, R8>];
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, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any, R5 extends HandlerResponse<any> = any, R6 extends HandlerResponse<any> = any, R7 extends HandlerResponse<any> = any, R8 extends HandlerResponse<any> = any, R9 extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, E9 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, E10 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R2>, handler3: H<E4, P, I3, R3>, handler4: H<E5, P, I4, R4>, handler5: H<E6, P, I5, R5>, handler6: H<E7, P, I6, R6>, handler7: H<E8, P, I7, R7>, handler8: H<E9, P, I8, R8>, handler9: H<E10, P, I9, R9>): [H<E2, P, I, R>, H<E3, P, I2, R>, H<E4, P, I3, R>, H<E5, P, I4, R>, H<E6, P, I5, R>, H<E7, P, I6, R>, H<E8, P, I7, R>, H<E9, P, I8, R>, H<E10, P, I9, 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, I6 extends Input = I & I2 & I3 & I4 & I5, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any, R5 extends HandlerResponse<any> = any, R6 extends HandlerResponse<any> = any, R7 extends HandlerResponse<any> = any, R8 extends HandlerResponse<any> = any, R9 extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, E9 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, E10 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R2>, handler3: H<E4, P, I3, R3>, handler4: H<E5, P, I4, R4>, handler5: H<E6, P, I5, R5>, handler6: H<E7, P, I6, R6>, handler7: H<E8, P, I7, R7>, handler8: H<E9, P, I8, R8>, handler9: H<E10, P, I9, R9>): [H<E2, P, I, R>, H<E3, P, I2, R2>, H<E4, P, I3, R3>, H<E5, P, I4, R4>, H<E6, P, I5, R5>, H<E7, P, I6, R6>, H<E8, P, I7, R7>, H<E9, P, I8, R8>, H<E10, P, I9, R9>];
16
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, I7 extends Input = I & I2 & I3 & I4 & I5 & I6, I8 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7, I9 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8, I10 extends Input = I & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9, R extends HandlerResponse<any> = any, R2 extends HandlerResponse<any> = any, R3 extends HandlerResponse<any> = any, R4 extends HandlerResponse<any> = any, R5 extends HandlerResponse<any> = any, R6 extends HandlerResponse<any> = any, R7 extends HandlerResponse<any> = any, R8 extends HandlerResponse<any> = any, R9 extends HandlerResponse<any> = any, R10 extends HandlerResponse<any> = any, E2 extends Env = E, E3 extends Env = IntersectNonAnyTypes<[E, E2]>, E4 extends Env = IntersectNonAnyTypes<[E, E2, E3]>, E5 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4]>, E6 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5]>, E7 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6]>, E8 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7]>, E9 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8]>, E10 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9]>, E11 extends Env = IntersectNonAnyTypes<[E, E2, E3, E4, E5, E6, E7, E8, E9, E10]>>(handler1: H<E2, P, I, R>, handler2: H<E3, P, I2, R2>, handler3: H<E4, P, I3, R3>, handler4: H<E5, P, I4, R4>, handler5: H<E6, P, I5, R5>, handler6: H<E7, P, I6, R6>, handler7: H<E8, P, I7, R7>, handler8: H<E9, P, I8, R8>, handler9: H<E10, P, I9, R9>, handler10: H<E11, P, I10, R10>): [H<E2, P, I, R>, H<E3, P, I2, R2>, H<E4, P, I3, R3>, H<E5, P, I4, R4>, H<E6, P, I5, R5>, H<E7, P, I6, R6>, H<E8, P, I7, R7>, H<E9, P, I8, R8>, H<E10, P, I9, R9>, H<E11, P, I10, R10>];
17
17
  }
18
18
  export declare class Factory<E extends Env = Env, P extends string = string> {
@@ -63,11 +63,16 @@ export declare const fetchRoutesContent: <E extends Env = Env, S extends Schema
63
63
  mimeType: string;
64
64
  content: string | ArrayBuffer;
65
65
  } | undefined>> | undefined>>;
66
+ /**
67
+ * @experimental
68
+ * `saveContentToFile` is an experimental feature.
69
+ * The API might be changed.
70
+ */
66
71
  export declare const saveContentToFile: (data: Promise<{
67
72
  routePath: string;
68
73
  content: string | ArrayBuffer;
69
74
  mimeType: string;
70
- } | undefined>, fsModule: FileSystemModule, outDir: string, extensionMap?: Record<string, string>) => Promise<string | undefined>;
75
+ } | undefined>, fsModule: FileSystemModule, outDir: string, extensionMap?: Record<string, string>, createdDirs?: Set<string>) => Promise<string | undefined>;
71
76
  /**
72
77
  * @experimental
73
78
  * `ToSSGInterface` is an experimental feature.
@@ -11,5 +11,5 @@ export declare class SSEStreamingApi extends StreamingApi {
11
11
  constructor(writable: WritableStream, readable: ReadableStream);
12
12
  writeSSE(message: SSEMessage): Promise<void>;
13
13
  }
14
- export declare const streamSSE: (c: Context, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: (e: Error, stream: SSEStreamingApi) => Promise<void>) => Response;
14
+ export declare const streamSSE: (c: Context, cb: (stream: SSEStreamingApi) => Promise<void>, onError?: (e: Error, stream: SSEStreamingApi) => void | Promise<void>) => Response;
15
15
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { Context } from "../../context.js";
2
2
  import { StreamingApi } from "../../utils/stream.js";
3
3
  //#region src/helper/streaming/stream.d.ts
4
- export declare const stream: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response;
4
+ export declare const stream: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => void | Promise<void>) => Response;
5
5
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { Context } from "../../context.js";
2
2
  import { StreamingApi } from "../../utils/stream.js";
3
3
  //#region src/helper/streaming/text.d.ts
4
- export declare const streamText: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => Promise<void>) => Response;
4
+ export declare const streamText: (c: Context, cb: (stream: StreamingApi) => Promise<void>, onError?: (e: Error, stream: StreamingApi) => void | Promise<void>) => Response;
5
5
  //#endregion
@@ -2,7 +2,8 @@ import { UnionToIntersection } from "../../utils/types.js";
2
2
  import { Schema } from "../../types.js";
3
3
  import { ExecutionContext } from "../../context.js";
4
4
  import { Hono } from "../../hono.js";
5
- import { Client, ClientRequestOptions } from "../../client/types.js";
5
+ import { ClientRequestOptions } from "../../client/index.js";
6
+ import { Client } from "../../client/types.js";
6
7
  //#region src/helper/testing/index.d.ts
7
8
  type ExtractEnv<T> = T extends Hono<infer E, Schema, string> ? E : never;
8
9
  export declare const testClient: <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext, options?: Omit<ClientRequestOptions, "fetch">) => UnionToIntersection<Client<T, "http://localhost">>;
@@ -2,12 +2,22 @@ import { StatusCode } from "../../utils/http-status.js";
2
2
  import { MiddlewareHandler, TypedResponse } from "../../types.js";
3
3
  import { Context } from "../../context.js";
4
4
  //#region src/helper/websocket/index.d.ts
5
+ /**
6
+ * The message event of a WebSocket. `MessageEvent` is not generic without the DOM lib.
7
+ */
8
+ export type WSMessageEvent = Omit<MessageEvent, 'data'> & {
9
+ readonly data: WSMessageReceive;
10
+ };
11
+ /**
12
+ * The binary type of a WebSocket. `BinaryType` is not declared without the DOM lib.
13
+ */
14
+ export type WSBinaryType = 'blob' | 'arraybuffer';
5
15
  /**
6
16
  * WebSocket Event Listeners type
7
17
  */
8
18
  export interface WSEvents<T = unknown> {
9
19
  onOpen?: (evt: Event, ws: WSContext<T>) => void;
10
- onMessage?: (evt: MessageEvent<WSMessageReceive>, ws: WSContext<T>) => void;
20
+ onMessage?: (evt: WSMessageEvent, ws: WSContext<T>) => void;
11
21
  onClose?: (evt: CloseEvent, ws: WSContext<T>) => void;
12
22
  onError?: (evt: Event, ws: WSContext<T>) => void;
13
23
  }
@@ -49,14 +59,14 @@ export declare class WSContext<T = unknown> {
49
59
  constructor(init: WSContextInit<T>);
50
60
  send(source: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options?: SendOptions): void;
51
61
  raw?: T;
52
- binaryType: BinaryType;
62
+ binaryType: WSBinaryType;
53
63
  get readyState(): WSReadyState;
54
64
  url: URL | null;
55
65
  protocol: string | null;
56
66
  close(code?: number, reason?: string): void;
57
67
  }
58
68
  export type WSMessageReceive = string | Blob | ArrayBufferLike;
59
- export declare const createWSMessageEvent: (source: WSMessageReceive) => MessageEvent<WSMessageReceive>;
69
+ export declare const createWSMessageEvent: (source: WSMessageReceive) => WSMessageEvent;
60
70
  export interface WebSocketHelperDefineContext {}
61
71
  export type WebSocketHelperDefineHandler<T, U> = (c: Context, events: WSEvents<T>, options?: U) => Promise<Response | void> | Response | void;
62
72
  /**
@@ -6,14 +6,6 @@ type GetPath<E extends Env> = (request: Request, options?: {
6
6
  env?: E['Bindings'];
7
7
  }) => string;
8
8
  export type HonoOptions<E extends Env> = {
9
- /**
10
- * `strict` option specifies whether to distinguish whether the last path is a directory or not.
11
- *
12
- * @see {@link https://hono.dev/docs/api/hono#strict-mode}
13
- *
14
- * @default true
15
- */
16
- strict?: boolean;
17
9
  /**
18
10
  * `router` option specifies which router to use.
19
11
  *
@@ -25,6 +17,15 @@ export type HonoOptions<E extends Env> = {
25
17
  * ```
26
18
  */
27
19
  router?: Router<[H, RouterRoute]>;
20
+ } & ({
21
+ /**
22
+ * `strict` option specifies whether to distinguish whether the last path is a directory or not.
23
+ *
24
+ * @see {@link https://hono.dev/docs/api/hono#strict-mode}
25
+ *
26
+ * @default true
27
+ */
28
+ strict?: true;
28
29
  /**
29
30
  * `getPath` can handle the host header value.
30
31
  *
@@ -46,7 +47,18 @@ export type HonoOptions<E extends Env> = {
46
47
  * ```
47
48
  */
48
49
  getPath?: GetPath<E>;
49
- };
50
+ } | {
51
+ /**
52
+ * `strict` option specifies whether to distinguish whether the last path is a directory or not.
53
+ * When `strict` is `false`, `getPath` is not used.
54
+ *
55
+ * @see {@link https://hono.dev/docs/api/hono#strict-mode}
56
+ *
57
+ * @default true
58
+ */
59
+ strict: false;
60
+ getPath?: never;
61
+ });
50
62
  type MountOptionHandler = (c: Context) => unknown;
51
63
  type MountReplaceRequest = (originalRequest: Request) => Request;
52
64
  type MountOptions = MountOptionHandler | {
@@ -148,6 +160,8 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
148
160
  * @param {Function} applicationHandler - other Request Handler
149
161
  * @param {MountOptions} [options] - options of `.mount()`
150
162
  * @returns {Hono} mounted Hono instance
163
+ * @throws {Error} If automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
164
+ * @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
151
165
  *
152
166
  * @example
153
167
  * ```ts
@@ -2,5 +2,5 @@ import { Env, ErrorHandler, Handler, Input, MiddlewareHandler, Next, NotFoundHan
2
2
  import { HonoRequest } from "./request.js";
3
3
  import { Context, ContextRenderer, ContextVariableMap, ExecutionContext } from "./context.js";
4
4
  import { Hono } from "./hono.js";
5
- import { ClientRequestOptions, InferRequestType, InferResponseType } from "./client/types.js";
5
+ import { ClientRequestOptions, InferRequestType, InferResponseType } from "./client/index.js";
6
6
  export { type ClientRequestOptions, Context, type ContextRenderer, type ContextVariableMap, type Env, type ErrorHandler, type ExecutionContext, type Handler, Hono, type HonoRequest, type InferRequestType, type InferResponseType, type Input, type MiddlewareHandler, type Next, type NotFoundHandler, type NotFoundResponse, type Schema, type ToSchema, type TypedResponse, type ValidationTargets };