hono 4.8.2 → 4.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/client.js +1 -0
- package/dist/cjs/helper/ssg/middleware.js +6 -2
- package/dist/cjs/helper/ssg/ssg.js +1 -4
- package/dist/cjs/helper/ssg/utils.js +5 -0
- package/dist/cjs/jsx/base.js +11 -4
- package/dist/cjs/request.js +1 -1
- package/dist/cjs/utils/cookie.js +1 -1
- package/dist/cjs/utils/jwt/types.js +3 -1
- package/dist/client/client.js +1 -0
- package/dist/helper/ssg/middleware.js +6 -2
- package/dist/helper/ssg/ssg.js +1 -4
- package/dist/helper/ssg/utils.js +4 -0
- package/dist/jsx/base.js +11 -4
- package/dist/request.js +1 -1
- package/dist/types/helper/adapter/index.d.ts +1 -1
- package/dist/types/helper/ssg/utils.d.ts +1 -0
- package/dist/types/request.d.ts +0 -5
- package/dist/types/utils/cookie.d.ts +0 -1
- package/dist/utils/cookie.js +2 -2
- package/dist/utils/jwt/types.js +3 -1
- package/package.json +2 -1
|
@@ -144,6 +144,7 @@ const hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
|
144
144
|
result = result + "?" + (0, import_utils.buildSearchParams)(opts.args[0].query).toString();
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
+
result = (0, import_utils.removeIndexString)(result);
|
|
147
148
|
return new URL(result);
|
|
148
149
|
}
|
|
149
150
|
if (method === "ws") {
|
|
@@ -27,6 +27,7 @@ __export(middleware_exports, {
|
|
|
27
27
|
ssgParams: () => ssgParams
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(middleware_exports);
|
|
30
|
+
var import_utils = require("./utils");
|
|
30
31
|
const SSG_CONTEXT = "HONO_SSG_CONTEXT";
|
|
31
32
|
const X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
|
|
32
33
|
const SSG_DISABLED_RESPONSE = (() => {
|
|
@@ -40,8 +41,11 @@ const SSG_DISABLED_RESPONSE = (() => {
|
|
|
40
41
|
}
|
|
41
42
|
})();
|
|
42
43
|
const ssgParams = (params) => async (c, next) => {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if ((0, import_utils.isDynamicRoute)(c.req.path)) {
|
|
45
|
+
;
|
|
46
|
+
c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
|
|
47
|
+
return c.notFound();
|
|
48
|
+
}
|
|
45
49
|
await next();
|
|
46
50
|
};
|
|
47
51
|
const isSSGContext = (c) => !!c.env?.[SSG_CONTEXT];
|
|
@@ -140,7 +140,7 @@ const fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook,
|
|
|
140
140
|
}
|
|
141
141
|
await pool.run(() => app.fetch(forGetInfoURLRequest));
|
|
142
142
|
if (!forGetInfoURLRequest.ssgParams) {
|
|
143
|
-
if (isDynamicRoute(route.path)) {
|
|
143
|
+
if ((0, import_utils2.isDynamicRoute)(route.path)) {
|
|
144
144
|
resolveGetInfo(void 0);
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
@@ -193,9 +193,6 @@ const fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook,
|
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
|
-
const isDynamicRoute = (path) => {
|
|
197
|
-
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
198
|
-
};
|
|
199
196
|
const createdDirs = /* @__PURE__ */ new Set();
|
|
200
197
|
const saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
201
198
|
const awaitedData = await data;
|
|
@@ -20,6 +20,7 @@ var utils_exports = {};
|
|
|
20
20
|
__export(utils_exports, {
|
|
21
21
|
dirname: () => dirname,
|
|
22
22
|
filterStaticGenerateRoutes: () => filterStaticGenerateRoutes,
|
|
23
|
+
isDynamicRoute: () => isDynamicRoute,
|
|
23
24
|
joinPaths: () => joinPaths
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -72,9 +73,13 @@ const filterStaticGenerateRoutes = (hono) => {
|
|
|
72
73
|
return acc;
|
|
73
74
|
}, []);
|
|
74
75
|
};
|
|
76
|
+
const isDynamicRoute = (path) => {
|
|
77
|
+
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
78
|
+
};
|
|
75
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
80
|
0 && (module.exports = {
|
|
77
81
|
dirname,
|
|
78
82
|
filterStaticGenerateRoutes,
|
|
83
|
+
isDynamicRoute,
|
|
79
84
|
joinPaths
|
|
80
85
|
});
|
package/dist/cjs/jsx/base.js
CHANGED
|
@@ -178,15 +178,15 @@ class JSXNode {
|
|
|
178
178
|
}
|
|
179
179
|
} else if (key === "dangerouslySetInnerHTML") {
|
|
180
180
|
if (children.length > 0) {
|
|
181
|
-
throw "Can only set one of `children` or `props.dangerouslySetInnerHTML`.";
|
|
181
|
+
throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
|
|
182
182
|
}
|
|
183
183
|
children = [(0, import_html.raw)(v.__html)];
|
|
184
184
|
} else if (v instanceof Promise) {
|
|
185
185
|
buffer[0] += ` ${key}="`;
|
|
186
186
|
buffer.unshift('"', v);
|
|
187
187
|
} else if (typeof v === "function") {
|
|
188
|
-
if (!key.startsWith("on")) {
|
|
189
|
-
throw `Invalid prop '${key}' of type 'function' supplied to '${tag}'
|
|
188
|
+
if (!key.startsWith("on") && key !== "ref") {
|
|
189
|
+
throw new Error(`Invalid prop '${key}' of type 'function' supplied to '${tag}'.`);
|
|
190
190
|
}
|
|
191
191
|
} else {
|
|
192
192
|
buffer[0] += ` ${key}="`;
|
|
@@ -335,10 +335,17 @@ const isValidElement = (element) => {
|
|
|
335
335
|
return !!(element && typeof element === "object" && "tag" in element && "props" in element);
|
|
336
336
|
};
|
|
337
337
|
const cloneElement = (element, props, ...children) => {
|
|
338
|
+
let childrenToClone;
|
|
339
|
+
if (children.length > 0) {
|
|
340
|
+
childrenToClone = children;
|
|
341
|
+
} else {
|
|
342
|
+
const c = element.props.children;
|
|
343
|
+
childrenToClone = Array.isArray(c) ? c : [c];
|
|
344
|
+
}
|
|
338
345
|
return jsx(
|
|
339
346
|
element.tag,
|
|
340
347
|
{ ...element.props, ...props },
|
|
341
|
-
...
|
|
348
|
+
...childrenToClone
|
|
342
349
|
);
|
|
343
350
|
};
|
|
344
351
|
const reactAPICompatVersion = "19.0.0-hono-jsx";
|
package/dist/cjs/request.js
CHANGED
package/dist/cjs/utils/cookie.js
CHANGED
|
@@ -70,7 +70,7 @@ const parse = (cookie, name) => {
|
|
|
70
70
|
cookieValue = cookieValue.slice(1, -1);
|
|
71
71
|
}
|
|
72
72
|
if (validCookieValueRegEx.test(cookieValue)) {
|
|
73
|
-
parsedCookie[cookieName] = (0, import_url.
|
|
73
|
+
parsedCookie[cookieName] = cookieValue.indexOf("%") !== -1 ? (0, import_url.tryDecode)(cookieValue, import_url.decodeURIComponent_) : cookieValue;
|
|
74
74
|
if (name) {
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
@@ -55,7 +55,9 @@ class JwtTokenExpired extends Error {
|
|
|
55
55
|
}
|
|
56
56
|
class JwtTokenIssuedAt extends Error {
|
|
57
57
|
constructor(currentTimestamp, iat) {
|
|
58
|
-
super(
|
|
58
|
+
super(
|
|
59
|
+
`Invalid "iat" claim, must be a valid number lower than "${currentTimestamp}" (iat: "${iat}")`
|
|
60
|
+
);
|
|
59
61
|
this.name = "JwtTokenIssuedAt";
|
|
60
62
|
}
|
|
61
63
|
}
|
package/dist/client/client.js
CHANGED
|
@@ -129,6 +129,7 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
|
129
129
|
result = result + "?" + buildSearchParams(opts.args[0].query).toString();
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
+
result = removeIndexString(result);
|
|
132
133
|
return new URL(result);
|
|
133
134
|
}
|
|
134
135
|
if (method === "ws") {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/helper/ssg/middleware.ts
|
|
2
|
+
import { isDynamicRoute } from "./utils.js";
|
|
2
3
|
var SSG_CONTEXT = "HONO_SSG_CONTEXT";
|
|
3
4
|
var X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
|
|
4
5
|
var SSG_DISABLED_RESPONSE = (() => {
|
|
@@ -12,8 +13,11 @@ var SSG_DISABLED_RESPONSE = (() => {
|
|
|
12
13
|
}
|
|
13
14
|
})();
|
|
14
15
|
var ssgParams = (params) => async (c, next) => {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
if (isDynamicRoute(c.req.path)) {
|
|
17
|
+
;
|
|
18
|
+
c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
|
|
19
|
+
return c.notFound();
|
|
20
|
+
}
|
|
17
21
|
await next();
|
|
18
22
|
};
|
|
19
23
|
var isSSGContext = (c) => !!c.env?.[SSG_CONTEXT];
|
package/dist/helper/ssg/ssg.js
CHANGED
|
@@ -3,7 +3,7 @@ import { replaceUrlParam } from "../../client/utils.js";
|
|
|
3
3
|
import { createPool } from "../../utils/concurrent.js";
|
|
4
4
|
import { getExtension } from "../../utils/mime.js";
|
|
5
5
|
import { SSG_CONTEXT, X_HONO_DISABLE_SSG_HEADER_KEY } from "./middleware.js";
|
|
6
|
-
import { dirname, filterStaticGenerateRoutes, joinPaths } from "./utils.js";
|
|
6
|
+
import { dirname, filterStaticGenerateRoutes, isDynamicRoute, joinPaths } from "./utils.js";
|
|
7
7
|
var DEFAULT_CONCURRENCY = 2;
|
|
8
8
|
var DEFAULT_CONTENT_TYPE = "text/plain";
|
|
9
9
|
var DEFAULT_OUTPUT_DIR = "./static";
|
|
@@ -164,9 +164,6 @@ var fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, c
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
|
-
var isDynamicRoute = (path) => {
|
|
168
|
-
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
169
|
-
};
|
|
170
167
|
var createdDirs = /* @__PURE__ */ new Set();
|
|
171
168
|
var saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
172
169
|
const awaitedData = await data;
|
package/dist/helper/ssg/utils.js
CHANGED
|
@@ -48,8 +48,12 @@ var filterStaticGenerateRoutes = (hono) => {
|
|
|
48
48
|
return acc;
|
|
49
49
|
}, []);
|
|
50
50
|
};
|
|
51
|
+
var isDynamicRoute = (path) => {
|
|
52
|
+
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
53
|
+
};
|
|
51
54
|
export {
|
|
52
55
|
dirname,
|
|
53
56
|
filterStaticGenerateRoutes,
|
|
57
|
+
isDynamicRoute,
|
|
54
58
|
joinPaths
|
|
55
59
|
};
|
package/dist/jsx/base.js
CHANGED
|
@@ -139,15 +139,15 @@ var JSXNode = class {
|
|
|
139
139
|
}
|
|
140
140
|
} else if (key === "dangerouslySetInnerHTML") {
|
|
141
141
|
if (children.length > 0) {
|
|
142
|
-
throw "Can only set one of `children` or `props.dangerouslySetInnerHTML`.";
|
|
142
|
+
throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
|
|
143
143
|
}
|
|
144
144
|
children = [raw(v.__html)];
|
|
145
145
|
} else if (v instanceof Promise) {
|
|
146
146
|
buffer[0] += ` ${key}="`;
|
|
147
147
|
buffer.unshift('"', v);
|
|
148
148
|
} else if (typeof v === "function") {
|
|
149
|
-
if (!key.startsWith("on")) {
|
|
150
|
-
throw `Invalid prop '${key}' of type 'function' supplied to '${tag}'
|
|
149
|
+
if (!key.startsWith("on") && key !== "ref") {
|
|
150
|
+
throw new Error(`Invalid prop '${key}' of type 'function' supplied to '${tag}'.`);
|
|
151
151
|
}
|
|
152
152
|
} else {
|
|
153
153
|
buffer[0] += ` ${key}="`;
|
|
@@ -296,10 +296,17 @@ var isValidElement = (element) => {
|
|
|
296
296
|
return !!(element && typeof element === "object" && "tag" in element && "props" in element);
|
|
297
297
|
};
|
|
298
298
|
var cloneElement = (element, props, ...children) => {
|
|
299
|
+
let childrenToClone;
|
|
300
|
+
if (children.length > 0) {
|
|
301
|
+
childrenToClone = children;
|
|
302
|
+
} else {
|
|
303
|
+
const c = element.props.children;
|
|
304
|
+
childrenToClone = Array.isArray(c) ? c : [c];
|
|
305
|
+
}
|
|
299
306
|
return jsx(
|
|
300
307
|
element.tag,
|
|
301
308
|
{ ...element.props, ...props },
|
|
302
|
-
...
|
|
309
|
+
...childrenToClone
|
|
303
310
|
);
|
|
304
311
|
};
|
|
305
312
|
var reactAPICompatVersion = "19.0.0-hono-jsx";
|
package/dist/request.js
CHANGED
|
@@ -6,7 +6,7 @@ import type { Context } from '../../context';
|
|
|
6
6
|
export type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other";
|
|
7
7
|
export declare const env: <T extends Record<string, unknown>, C extends Context = Context<{
|
|
8
8
|
Bindings: T;
|
|
9
|
-
}>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
|
|
9
|
+
}, any, {}>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
|
|
10
10
|
export declare const knownUserAgents: Partial<Record<Runtime, string>>;
|
|
11
11
|
export declare const getRuntimeKey: () => Runtime;
|
|
12
12
|
export declare const checkUserAgentEquals: (platform: string) => boolean;
|
package/dist/types/request.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GET_MATCH_RESULT } from './request/constants';
|
|
2
1
|
import type { Result } from './router';
|
|
3
2
|
import type { Input, InputToDataByTarget, ParamKeyToRecord, ParamKeys, RemoveQuestion, RouterRoute, ValidationTargets } from './types';
|
|
4
3
|
import type { BodyData, ParseBodyOptions } from './utils/body';
|
|
@@ -15,10 +14,6 @@ type BodyCache = Partial<Body & {
|
|
|
15
14
|
parsedBody: BodyData;
|
|
16
15
|
}>;
|
|
17
16
|
export declare class HonoRequest<P extends string = "/", I extends Input["out"] = {}> {
|
|
18
|
-
[GET_MATCH_RESULT]: Result<[
|
|
19
|
-
unknown,
|
|
20
|
-
RouterRoute
|
|
21
|
-
]>;
|
|
22
17
|
/**
|
|
23
18
|
* `.raw` can get the raw Request object.
|
|
24
19
|
*
|
package/dist/utils/cookie.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/utils/cookie.ts
|
|
2
|
-
import { decodeURIComponent_ } from "./url.js";
|
|
2
|
+
import { decodeURIComponent_, tryDecode } from "./url.js";
|
|
3
3
|
var algorithm = { name: "HMAC", hash: "SHA-256" };
|
|
4
4
|
var getCryptoKey = async (secret) => {
|
|
5
5
|
const secretBuf = typeof secret === "string" ? new TextEncoder().encode(secret) : secret;
|
|
@@ -45,7 +45,7 @@ var parse = (cookie, name) => {
|
|
|
45
45
|
cookieValue = cookieValue.slice(1, -1);
|
|
46
46
|
}
|
|
47
47
|
if (validCookieValueRegEx.test(cookieValue)) {
|
|
48
|
-
parsedCookie[cookieName] =
|
|
48
|
+
parsedCookie[cookieName] = cookieValue.indexOf("%") !== -1 ? tryDecode(cookieValue, decodeURIComponent_) : cookieValue;
|
|
49
49
|
if (name) {
|
|
50
50
|
break;
|
|
51
51
|
}
|
package/dist/utils/jwt/types.js
CHANGED
|
@@ -25,7 +25,9 @@ var JwtTokenExpired = class extends Error {
|
|
|
25
25
|
};
|
|
26
26
|
var JwtTokenIssuedAt = class extends Error {
|
|
27
27
|
constructor(currentTimestamp, iat) {
|
|
28
|
-
super(
|
|
28
|
+
super(
|
|
29
|
+
`Invalid "iat" claim, must be a valid number lower than "${currentTimestamp}" (iat: "${iat}")`
|
|
30
|
+
);
|
|
29
31
|
this.name = "JwtTokenIssuedAt";
|
|
30
32
|
}
|
|
31
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.4",
|
|
4
4
|
"description": "Web framework built on Web Standards",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -671,6 +671,7 @@
|
|
|
671
671
|
"jsdom": "^22.1.0",
|
|
672
672
|
"msw": "^2.6.0",
|
|
673
673
|
"np": "10.2.0",
|
|
674
|
+
"pkg-pr-new": "^0.0.53",
|
|
674
675
|
"prettier": "^2.6.2",
|
|
675
676
|
"publint": "^0.1.16",
|
|
676
677
|
"supertest": "^6.3.4",
|