@orchestraai/agent-tools 0.10.16 → 0.10.18
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.
- package/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/.devin/adapter.json +1 -1
- package/.hermes/adapter.json +1 -1
- package/.opencode/adapter.json +1 -1
- package/dist/commands/claude-setup.d.ts +1 -1
- package/dist/runtime/conversation/command-guard.js +1347 -63
- package/dist/runtime/conversation/command-guard.js.map +1 -1
- package/dist/runtime/conversation/shell-parse.d.ts +44 -0
- package/dist/runtime/conversation/shell-parse.js +525 -0
- package/dist/runtime/conversation/shell-parse.js.map +1 -0
- package/docs/security.md +18 -2
- package/node_modules/@hono/node-server/dist/index.cjs +63 -17
- package/node_modules/@hono/node-server/dist/index.mjs +63 -17
- package/node_modules/@hono/node-server/dist/serve-static.cjs +1 -1
- package/node_modules/@hono/node-server/dist/serve-static.mjs +1 -1
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/cross-spawn/README.md +19 -3
- package/node_modules/cross-spawn/lib/parse.js +38 -10
- package/node_modules/cross-spawn/lib/util/escape.js +84 -25
- package/node_modules/cross-spawn/lib/util/readShebang.js +8 -2
- package/node_modules/cross-spawn/lib/util/resolveCommand.js +8 -1
- package/node_modules/cross-spawn/package.json +21 -24
- package/node_modules/hono/README.md +2 -3
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +2 -2
- package/node_modules/hono/dist/adapter/bun/websocket.js +19 -4
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +5 -1
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +2 -2
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +19 -4
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +5 -1
- package/node_modules/hono/dist/cjs/client/fetch-result-please.js +1 -1
- package/node_modules/hono/dist/cjs/client/utils.js +9 -5
- package/node_modules/hono/dist/cjs/context.js +1 -1
- package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +7 -1
- package/node_modules/hono/dist/cjs/helper/css/common.js +11 -8
- package/node_modules/hono/dist/cjs/helper/css/index.js +1 -1
- package/node_modules/hono/dist/cjs/helper/proxy/index.js +2 -0
- package/node_modules/hono/dist/cjs/helper/route/index.js +3 -1
- package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +5 -3
- package/node_modules/hono/dist/cjs/helper/streaming/sse.js +6 -2
- package/node_modules/hono/dist/cjs/hono-base.js +9 -10
- package/node_modules/hono/dist/cjs/hono.js +0 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +51 -32
- package/node_modules/hono/dist/cjs/jsx/components.js +2 -2
- package/node_modules/hono/dist/cjs/jsx/constants.js +2 -0
- package/node_modules/hono/dist/cjs/jsx/context.js +15 -2
- package/node_modules/hono/dist/cjs/jsx/dom/components.js +1 -1
- package/node_modules/hono/dist/cjs/jsx/dom/hooks/index.js +38 -8
- package/node_modules/hono/dist/cjs/jsx/dom/intrinsic-element/components.js +8 -5
- package/node_modules/hono/dist/cjs/jsx/dom/render.js +9 -3
- package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +13 -17
- package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +9 -1
- package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +9 -10
- package/node_modules/hono/dist/cjs/middleware/combine/index.js +4 -0
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -3
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/method-override/index.js +35 -12
- package/node_modules/hono/dist/cjs/middleware/mount/index.js +5 -4
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +1 -0
- package/node_modules/hono/dist/cjs/middleware/request-id/request-id.js +3 -3
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +4 -2
- package/node_modules/hono/dist/cjs/middleware/timing/timing.js +4 -3
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
- package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +6 -4
- package/node_modules/hono/dist/cjs/utils/body.js +2 -1
- package/node_modules/hono/dist/cjs/utils/cookie.js +3 -3
- package/node_modules/hono/dist/cjs/utils/html.js +5 -0
- package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +8 -5
- package/node_modules/hono/dist/cjs/utils/mime.js +3 -2
- package/node_modules/hono/dist/cjs/utils/mount.js +59 -0
- package/node_modules/hono/dist/cjs/utils/url.js +23 -11
- package/node_modules/hono/dist/cjs/validator/validator.js +5 -5
- package/node_modules/hono/dist/client/fetch-result-please.js +1 -1
- package/node_modules/hono/dist/client/utils.js +9 -5
- package/node_modules/hono/dist/context.js +1 -1
- package/node_modules/hono/dist/helper/accepts/accepts.js +7 -1
- package/node_modules/hono/dist/helper/css/common.js +11 -8
- package/node_modules/hono/dist/helper/css/index.js +1 -1
- package/node_modules/hono/dist/helper/proxy/index.js +2 -0
- package/node_modules/hono/dist/helper/route/index.js +3 -1
- package/node_modules/hono/dist/helper/ssg/ssg.js +5 -3
- package/node_modules/hono/dist/helper/streaming/sse.js +6 -2
- package/node_modules/hono/dist/hono-base.js +9 -10
- package/node_modules/hono/dist/hono.js +0 -1
- package/node_modules/hono/dist/jsx/base.js +51 -34
- package/node_modules/hono/dist/jsx/components.js +2 -2
- package/node_modules/hono/dist/jsx/constants.js +2 -1
- package/node_modules/hono/dist/jsx/context.js +15 -2
- package/node_modules/hono/dist/jsx/dom/components.js +2 -2
- package/node_modules/hono/dist/jsx/dom/hooks/index.js +39 -9
- package/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js +8 -5
- package/node_modules/hono/dist/jsx/dom/render.js +9 -3
- package/node_modules/hono/dist/jsx/jsx-runtime.js +15 -19
- package/node_modules/hono/dist/middleware/basic-auth/index.js +3 -1
- package/node_modules/hono/dist/middleware/bearer-auth/index.js +9 -1
- package/node_modules/hono/dist/middleware/body-limit/index.js +9 -10
- package/node_modules/hono/dist/middleware/combine/index.js +4 -0
- package/node_modules/hono/dist/middleware/compress/index.js +2 -3
- package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
- package/node_modules/hono/dist/middleware/etag/index.js +3 -1
- package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
- package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
- package/node_modules/hono/dist/middleware/method-not-allowed/index.js +1 -1
- package/node_modules/hono/dist/middleware/method-override/index.js +35 -12
- package/node_modules/hono/dist/middleware/mount/index.js +5 -4
- package/node_modules/hono/dist/middleware/pretty-json/index.js +1 -0
- package/node_modules/hono/dist/middleware/request-id/request-id.js +3 -3
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/middleware/serve-static/index.js +4 -2
- package/node_modules/hono/dist/middleware/timing/timing.js +4 -3
- package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
- package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
- package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
- package/node_modules/hono/dist/router/trie-router/node.js +6 -4
- package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/accepts/accepts.d.ts +5 -0
- package/node_modules/hono/dist/types/helper/factory/index.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/ssg/ssg.d.ts +6 -1
- package/node_modules/hono/dist/types/helper/streaming/sse.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/streaming/stream.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/streaming/text.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
- package/node_modules/hono/dist/types/helper/websocket/index.d.ts +13 -3
- package/node_modules/hono/dist/types/hono-base.d.ts +23 -9
- package/node_modules/hono/dist/types/index.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/base.d.ts +6 -3
- package/node_modules/hono/dist/types/jsx/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/constants.d.ts +1 -0
- package/node_modules/hono/dist/types/jsx/context.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +5 -3
- package/node_modules/hono/dist/types/jsx/dom/index.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/dom/server.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/index.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/jsx-runtime.d.ts +2 -1
- package/node_modules/hono/dist/types/jsx/streaming.d.ts +4 -3
- package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +1 -0
- package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
- package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +3 -3
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +3 -3
- package/node_modules/hono/dist/types/middleware/mount/index.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/request-id/request-id.d.ts +3 -3
- package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +2 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/cookie.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/ipaddr.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/jwt/jwt.d.ts +4 -2
- package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
- package/node_modules/hono/dist/types/utils/types.d.ts +12 -2
- package/node_modules/hono/dist/utils/body.js +2 -1
- package/node_modules/hono/dist/utils/cookie.js +3 -3
- package/node_modules/hono/dist/utils/html.js +5 -0
- package/node_modules/hono/dist/utils/jwt/jwt.js +8 -5
- package/node_modules/hono/dist/utils/mime.js +3 -2
- package/node_modules/hono/dist/utils/mount.js +58 -0
- package/node_modules/hono/dist/utils/url.js +23 -11
- package/node_modules/hono/dist/validator/validator.js +5 -5
- package/node_modules/hono/package.json +1 -1
- package/package.json +1 -1
|
@@ -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 === "
|
|
19
|
-
else if (b === "
|
|
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,
|
|
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
|
|
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 !== "
|
|
58
|
-
for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== "
|
|
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 !== "
|
|
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 =
|
|
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 {
|
|
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(),
|
|
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].
|
|
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].
|
|
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
|
|
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 {
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
8
|
+
function endsWithWildcard(keys) {
|
|
9
|
+
const tail = keys[keys.length - 1];
|
|
10
|
+
return tail === "[^]*" || tail === "(?:|/[^]*)";
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
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
|
-
#
|
|
18
|
-
#routes;
|
|
19
|
+
#handlers;
|
|
19
20
|
#tries;
|
|
20
21
|
constructor() {
|
|
21
|
-
this.#
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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(
|
|
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 (!
|
|
60
|
-
|
|
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.#
|
|
70
|
-
this.#
|
|
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
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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(""),
|
|
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(/(?::[^\/]+)|(?:\/\*$)|./
|
|
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,
|
|
42
|
-
this.paths[path] = [
|
|
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
|
-
|
|
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/
|
|
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/
|
|
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/
|
|
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,
|
|
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 {
|
|
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:
|
|
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:
|
|
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) =>
|
|
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/
|
|
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 };
|