hono 4.11.7 → 4.12.7
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/adapter/aws-lambda/conninfo.js +24 -0
- package/dist/adapter/aws-lambda/handler.js +2 -2
- package/dist/adapter/aws-lambda/index.js +2 -0
- package/dist/adapter/cloudflare-pages/conninfo.js +9 -0
- package/dist/adapter/cloudflare-pages/index.js +2 -0
- package/dist/adapter/lambda-edge/handler.js +2 -1
- package/dist/adapter/netlify/conninfo.js +9 -0
- package/dist/adapter/netlify/mod.js +2 -0
- package/dist/cjs/adapter/aws-lambda/conninfo.js +46 -0
- package/dist/cjs/adapter/aws-lambda/handler.js +2 -3
- package/dist/cjs/adapter/aws-lambda/index.js +3 -1
- package/dist/cjs/adapter/aws-lambda/types.js +0 -1
- package/dist/cjs/adapter/bun/conninfo.js +0 -1
- package/dist/cjs/adapter/bun/index.js +0 -1
- package/dist/cjs/adapter/bun/serve-static.js +0 -1
- package/dist/cjs/adapter/bun/server.js +0 -1
- package/dist/cjs/adapter/bun/ssg.js +0 -1
- package/dist/cjs/adapter/bun/websocket.js +0 -1
- package/dist/cjs/adapter/cloudflare-pages/conninfo.js +31 -0
- package/dist/cjs/adapter/cloudflare-pages/handler.js +0 -1
- package/dist/cjs/adapter/cloudflare-pages/index.js +3 -1
- package/dist/cjs/adapter/cloudflare-workers/conninfo.js +0 -1
- package/dist/cjs/adapter/cloudflare-workers/index.js +0 -1
- package/dist/cjs/adapter/cloudflare-workers/serve-static-module.js +0 -1
- package/dist/cjs/adapter/cloudflare-workers/serve-static.js +0 -1
- package/dist/cjs/adapter/cloudflare-workers/utils.js +0 -1
- package/dist/cjs/adapter/cloudflare-workers/websocket.js +0 -1
- package/dist/cjs/adapter/deno/conninfo.js +0 -1
- package/dist/cjs/adapter/deno/deno.d.js +0 -1
- package/dist/cjs/adapter/deno/index.js +0 -1
- package/dist/cjs/adapter/deno/serve-static.js +0 -1
- package/dist/cjs/adapter/deno/ssg.js +0 -1
- package/dist/cjs/adapter/deno/websocket.js +0 -1
- package/dist/cjs/adapter/lambda-edge/conninfo.js +0 -1
- package/dist/cjs/adapter/lambda-edge/handler.js +2 -2
- package/dist/cjs/adapter/lambda-edge/index.js +0 -1
- package/dist/cjs/adapter/netlify/conninfo.js +31 -0
- package/dist/cjs/adapter/netlify/handler.js +0 -1
- package/dist/cjs/adapter/netlify/index.js +0 -1
- package/dist/cjs/adapter/netlify/mod.js +3 -1
- package/dist/cjs/adapter/service-worker/handler.js +0 -1
- package/dist/cjs/adapter/service-worker/index.js +0 -1
- package/dist/cjs/adapter/service-worker/types.js +0 -1
- package/dist/cjs/adapter/vercel/conninfo.js +0 -1
- package/dist/cjs/adapter/vercel/handler.js +0 -1
- package/dist/cjs/adapter/vercel/index.js +0 -1
- package/dist/cjs/client/client.js +8 -3
- package/dist/cjs/client/fetch-result-please.js +0 -1
- package/dist/cjs/client/index.js +0 -1
- package/dist/cjs/client/types.js +0 -1
- package/dist/cjs/client/utils.js +0 -1
- package/dist/cjs/compose.js +0 -1
- package/dist/cjs/context.js +6 -6
- package/dist/cjs/helper/accepts/accepts.js +0 -1
- package/dist/cjs/helper/accepts/index.js +0 -1
- package/dist/cjs/helper/adapter/index.js +0 -1
- package/dist/cjs/helper/conninfo/index.js +0 -1
- package/dist/cjs/helper/conninfo/types.js +0 -1
- package/dist/cjs/helper/cookie/index.js +0 -1
- package/dist/cjs/helper/css/common.js +0 -1
- package/dist/cjs/helper/css/index.js +0 -1
- package/dist/cjs/helper/dev/index.js +0 -1
- package/dist/cjs/helper/factory/index.js +0 -1
- package/dist/cjs/helper/html/index.js +0 -1
- package/dist/cjs/helper/proxy/index.js +0 -1
- package/dist/cjs/helper/route/index.js +0 -1
- package/dist/cjs/helper/ssg/index.js +5 -1
- package/dist/cjs/helper/ssg/middleware.js +0 -1
- package/dist/cjs/helper/ssg/plugins.js +70 -0
- package/dist/cjs/helper/ssg/ssg.js +2 -12
- package/dist/cjs/helper/ssg/utils.js +0 -1
- package/dist/cjs/helper/streaming/index.js +0 -1
- package/dist/cjs/helper/streaming/sse.js +5 -1
- package/dist/cjs/helper/streaming/stream.js +0 -1
- package/dist/cjs/helper/streaming/text.js +0 -1
- package/dist/cjs/helper/streaming/utils.js +0 -1
- package/dist/cjs/helper/testing/index.js +0 -1
- package/dist/cjs/helper/websocket/index.js +0 -1
- package/dist/cjs/hono-base.js +0 -1
- package/dist/cjs/hono.js +0 -1
- package/dist/cjs/http-exception.js +0 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/jsx/base.js +0 -1
- package/dist/cjs/jsx/children.js +0 -1
- package/dist/cjs/jsx/components.js +0 -1
- package/dist/cjs/jsx/constants.js +0 -1
- package/dist/cjs/jsx/context.js +4 -3
- package/dist/cjs/jsx/dom/client.js +0 -1
- package/dist/cjs/jsx/dom/components.js +0 -1
- package/dist/cjs/jsx/dom/context.js +0 -1
- package/dist/cjs/jsx/dom/css.js +0 -1
- package/dist/cjs/jsx/dom/hooks/index.js +0 -1
- package/dist/cjs/jsx/dom/index.js +0 -1
- package/dist/cjs/jsx/dom/intrinsic-element/components.js +40 -10
- package/dist/cjs/jsx/dom/jsx-dev-runtime.js +0 -1
- package/dist/cjs/jsx/dom/jsx-runtime.js +0 -1
- package/dist/cjs/jsx/dom/render.js +7 -10
- package/dist/cjs/jsx/dom/server.js +0 -1
- package/dist/cjs/jsx/dom/utils.js +0 -1
- package/dist/cjs/jsx/hooks/index.js +0 -1
- package/dist/cjs/jsx/index.js +0 -1
- package/dist/cjs/jsx/intrinsic-element/common.js +13 -3
- package/dist/cjs/jsx/intrinsic-element/components.js +18 -12
- package/dist/cjs/jsx/intrinsic-elements.js +0 -1
- package/dist/cjs/jsx/jsx-dev-runtime.js +0 -1
- package/dist/cjs/jsx/jsx-runtime.js +0 -1
- package/dist/cjs/jsx/streaming.js +13 -4
- package/dist/cjs/jsx/types.js +0 -1
- package/dist/cjs/jsx/utils.js +0 -1
- package/dist/cjs/middleware/basic-auth/index.js +6 -1
- package/dist/cjs/middleware/bearer-auth/index.js +1 -2
- package/dist/cjs/middleware/body-limit/index.js +0 -1
- package/dist/cjs/middleware/cache/index.js +0 -1
- package/dist/cjs/middleware/combine/index.js +0 -1
- package/dist/cjs/middleware/compress/index.js +0 -1
- package/dist/cjs/middleware/context-storage/index.js +0 -1
- package/dist/cjs/middleware/cors/index.js +0 -1
- package/dist/cjs/middleware/csrf/index.js +0 -1
- package/dist/cjs/middleware/etag/digest.js +0 -1
- package/dist/cjs/middleware/etag/index.js +0 -1
- package/dist/cjs/middleware/ip-restriction/index.js +0 -1
- package/dist/cjs/middleware/jsx-renderer/index.js +1 -1
- package/dist/cjs/middleware/jwk/index.js +0 -1
- package/dist/cjs/middleware/jwk/jwk.js +0 -1
- package/dist/cjs/middleware/jwt/index.js +0 -1
- package/dist/cjs/middleware/jwt/jwt.js +0 -1
- package/dist/cjs/middleware/language/index.js +0 -1
- package/dist/cjs/middleware/language/language.js +13 -3
- package/dist/cjs/middleware/logger/index.js +0 -1
- package/dist/cjs/middleware/method-override/index.js +0 -1
- package/dist/cjs/middleware/powered-by/index.js +0 -1
- package/dist/cjs/middleware/pretty-json/index.js +0 -1
- package/dist/cjs/middleware/request-id/index.js +0 -1
- package/dist/cjs/middleware/request-id/request-id.js +0 -1
- package/dist/cjs/middleware/secure-headers/index.js +0 -1
- package/dist/cjs/middleware/secure-headers/permissions-policy.js +0 -1
- package/dist/cjs/middleware/secure-headers/secure-headers.js +0 -1
- package/dist/cjs/middleware/serve-static/index.js +2 -2
- package/dist/cjs/middleware/serve-static/path.js +0 -1
- package/dist/cjs/middleware/timeout/index.js +0 -1
- package/dist/cjs/middleware/timing/index.js +0 -1
- package/dist/cjs/middleware/timing/timing.js +0 -1
- package/dist/cjs/middleware/trailing-slash/index.js +18 -5
- package/dist/cjs/preset/quick.js +0 -1
- package/dist/cjs/preset/tiny.js +0 -1
- package/dist/cjs/request/constants.js +0 -1
- package/dist/cjs/request.js +0 -1
- package/dist/cjs/router/linear-router/index.js +0 -1
- package/dist/cjs/router/linear-router/router.js +0 -1
- package/dist/cjs/router/pattern-router/index.js +0 -1
- package/dist/cjs/router/pattern-router/router.js +0 -1
- package/dist/cjs/router/reg-exp-router/index.js +0 -1
- package/dist/cjs/router/reg-exp-router/matcher.js +0 -1
- package/dist/cjs/router/reg-exp-router/node.js +0 -1
- package/dist/cjs/router/reg-exp-router/prepared-router.js +0 -1
- package/dist/cjs/router/reg-exp-router/router.js +0 -1
- package/dist/cjs/router/reg-exp-router/trie.js +0 -1
- package/dist/cjs/router/smart-router/index.js +0 -1
- package/dist/cjs/router/smart-router/router.js +0 -1
- package/dist/cjs/router/trie-router/index.js +0 -1
- package/dist/cjs/router/trie-router/node.js +33 -17
- package/dist/cjs/router/trie-router/router.js +0 -1
- package/dist/cjs/router.js +0 -1
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/utils/accept.js +188 -29
- package/dist/cjs/utils/basic-auth.js +0 -1
- package/dist/cjs/utils/body.js +3 -1
- package/dist/cjs/utils/buffer.js +29 -3
- package/dist/cjs/utils/color.js +0 -1
- package/dist/cjs/utils/compress.js +0 -1
- package/dist/cjs/utils/concurrent.js +0 -1
- package/dist/cjs/utils/constants.js +0 -1
- package/dist/cjs/utils/cookie.js +5 -1
- package/dist/cjs/utils/crypto.js +0 -1
- package/dist/cjs/utils/encode.js +0 -1
- package/dist/cjs/utils/filepath.js +0 -1
- package/dist/cjs/utils/handler.js +0 -1
- package/dist/cjs/utils/headers.js +0 -1
- package/dist/cjs/utils/html.js +0 -1
- package/dist/cjs/utils/http-status.js +0 -1
- package/dist/cjs/utils/ipaddr.js +0 -1
- package/dist/cjs/utils/jwt/index.js +0 -1
- package/dist/cjs/utils/jwt/jwa.js +0 -1
- package/dist/cjs/utils/jwt/jws.js +0 -1
- package/dist/cjs/utils/jwt/jwt.js +17 -14
- package/dist/cjs/utils/jwt/types.js +0 -1
- package/dist/cjs/utils/jwt/utf8.js +0 -1
- package/dist/cjs/utils/mime.js +0 -1
- package/dist/cjs/utils/stream.js +0 -1
- package/dist/cjs/utils/types.js +0 -1
- package/dist/cjs/utils/url.js +8 -5
- package/dist/cjs/validator/index.js +0 -1
- package/dist/cjs/validator/utils.js +0 -1
- package/dist/cjs/validator/validator.js +2 -3
- package/dist/client/client.js +8 -2
- package/dist/context.js +6 -5
- package/dist/helper/ssg/index.js +3 -0
- package/dist/helper/ssg/plugins.js +47 -0
- package/dist/helper/ssg/ssg.js +2 -10
- package/dist/helper/streaming/sse.js +5 -0
- package/dist/jsx/context.js +4 -2
- package/dist/jsx/dom/intrinsic-element/components.js +47 -10
- package/dist/jsx/dom/render.js +7 -9
- package/dist/jsx/intrinsic-element/common.js +10 -1
- package/dist/jsx/intrinsic-element/components.js +24 -12
- package/dist/jsx/streaming.js +13 -3
- package/dist/middleware/basic-auth/index.js +6 -0
- package/dist/middleware/bearer-auth/index.js +1 -1
- package/dist/middleware/jsx-renderer/index.js +1 -0
- package/dist/middleware/language/language.js +13 -2
- package/dist/middleware/serve-static/index.js +2 -1
- package/dist/middleware/trailing-slash/index.js +18 -4
- package/dist/router/trie-router/node.js +33 -16
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/adapter/aws-lambda/conninfo.d.ts +27 -0
- package/dist/types/adapter/aws-lambda/handler.d.ts +2 -2
- package/dist/types/adapter/aws-lambda/index.d.ts +1 -0
- package/dist/types/adapter/cloudflare-pages/conninfo.d.ts +21 -0
- package/dist/types/adapter/cloudflare-pages/index.d.ts +1 -0
- package/dist/types/adapter/netlify/conninfo.d.ts +21 -0
- package/dist/types/adapter/netlify/mod.d.ts +1 -0
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/types.d.ts +43 -2
- package/dist/types/context.d.ts +4 -0
- package/dist/types/helper/ssg/index.d.ts +1 -0
- package/dist/types/helper/ssg/plugins.d.ts +27 -0
- package/dist/types/helper/ssg/ssg.d.ts +0 -8
- package/dist/types/hono-base.d.ts +1 -1
- package/dist/types/jsx/intrinsic-element/common.d.ts +3 -0
- package/dist/types/jsx/types.d.ts +1 -1
- package/dist/types/middleware/basic-auth/index.d.ts +19 -0
- package/dist/types/middleware/jsx-renderer/index.d.ts +1 -1
- package/dist/types/middleware/jwt/index.d.ts +1 -1
- package/dist/types/middleware/jwt/jwt.d.ts +1 -1
- package/dist/types/middleware/trailing-slash/index.d.ts +43 -2
- package/dist/types/request.d.ts +1 -1
- package/dist/types/types.d.ts +18 -18
- package/dist/types/utils/accept.d.ts +0 -5
- package/dist/types/utils/buffer.d.ts +10 -1
- package/dist/types/utils/url.d.ts +10 -0
- package/dist/utils/accept.js +188 -28
- package/dist/utils/body.js +3 -0
- package/dist/utils/buffer.js +29 -2
- package/dist/utils/cookie.js +5 -0
- package/dist/utils/jwt/jwt.js +17 -13
- package/dist/utils/url.js +6 -3
- package/dist/validator/validator.js +2 -2
- package/package.json +5 -4
package/dist/cjs/utils/url.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -29,7 +28,8 @@ __export(url_exports, {
|
|
|
29
28
|
mergePath: () => mergePath,
|
|
30
29
|
splitPath: () => splitPath,
|
|
31
30
|
splitRoutingPath: () => splitRoutingPath,
|
|
32
|
-
tryDecode: () => tryDecode
|
|
31
|
+
tryDecode: () => tryDecode,
|
|
32
|
+
tryDecodeURI: () => tryDecodeURI
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(url_exports);
|
|
35
35
|
const splitPath = (path) => {
|
|
@@ -106,9 +106,11 @@ const getPath = (request) => {
|
|
|
106
106
|
const charCode = url.charCodeAt(i);
|
|
107
107
|
if (charCode === 37) {
|
|
108
108
|
const queryIndex = url.indexOf("?", i);
|
|
109
|
-
const
|
|
109
|
+
const hashIndex = url.indexOf("#", i);
|
|
110
|
+
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
111
|
+
const path = url.slice(start, end);
|
|
110
112
|
return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
|
|
111
|
-
} else if (charCode === 63) {
|
|
113
|
+
} else if (charCode === 63 || charCode === 35) {
|
|
112
114
|
break;
|
|
113
115
|
}
|
|
114
116
|
}
|
|
@@ -249,5 +251,6 @@ const decodeURIComponent_ = decodeURIComponent;
|
|
|
249
251
|
mergePath,
|
|
250
252
|
splitPath,
|
|
251
253
|
splitRoutingPath,
|
|
252
|
-
tryDecode
|
|
254
|
+
tryDecode,
|
|
255
|
+
tryDecodeURI
|
|
253
256
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -61,7 +60,7 @@ const validator = (target, validationFunc) => {
|
|
|
61
60
|
throw new import_http_exception.HTTPException(400, { message });
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
const form =
|
|
63
|
+
const form = /* @__PURE__ */ Object.create(null);
|
|
65
64
|
formData.forEach((value2, key) => {
|
|
66
65
|
if (key.endsWith("[]")) {
|
|
67
66
|
;
|
|
@@ -69,7 +68,7 @@ const validator = (target, validationFunc) => {
|
|
|
69
68
|
} else if (Array.isArray(form[key])) {
|
|
70
69
|
;
|
|
71
70
|
form[key].push(value2);
|
|
72
|
-
} else if (key
|
|
71
|
+
} else if (Object.hasOwn(form, key)) {
|
|
73
72
|
form[key] = [form[key], value2];
|
|
74
73
|
} else {
|
|
75
74
|
form[key] = value2;
|
package/dist/client/client.js
CHANGED
|
@@ -47,6 +47,9 @@ var ClientRequestImpl = class {
|
|
|
47
47
|
if (args.form) {
|
|
48
48
|
const form = new FormData();
|
|
49
49
|
for (const [k, v] of Object.entries(args.form)) {
|
|
50
|
+
if (v === void 0) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
50
53
|
if (Array.isArray(v)) {
|
|
51
54
|
for (const v2 of v) {
|
|
52
55
|
form.append(k, v2);
|
|
@@ -122,7 +125,7 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
|
122
125
|
}
|
|
123
126
|
const path = parts.join("/");
|
|
124
127
|
const url = mergePath(baseUrl, path);
|
|
125
|
-
if (method === "url") {
|
|
128
|
+
if (method === "url" || method === "path") {
|
|
126
129
|
let result = url;
|
|
127
130
|
if (opts.args[0]) {
|
|
128
131
|
if (opts.args[0].param) {
|
|
@@ -133,7 +136,10 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
138
|
result = removeIndexString(result);
|
|
136
|
-
|
|
139
|
+
if (method === "url") {
|
|
140
|
+
return new URL(result);
|
|
141
|
+
}
|
|
142
|
+
return result.slice(baseUrl.replace(/\/+$/, "").length).replace(/^\/?/, "/");
|
|
137
143
|
}
|
|
138
144
|
if (method === "ws") {
|
|
139
145
|
const webSocketUrl = replaceUrlProtocol(
|
package/dist/context.js
CHANGED
|
@@ -8,6 +8,7 @@ var setDefaultContentType = (contentType, headers) => {
|
|
|
8
8
|
...headers
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
+
var createResponseInstance = (body, init) => new Response(body, init);
|
|
11
12
|
var Context = class {
|
|
12
13
|
#rawRequest;
|
|
13
14
|
#req;
|
|
@@ -106,7 +107,7 @@ var Context = class {
|
|
|
106
107
|
* The Response object for the current request.
|
|
107
108
|
*/
|
|
108
109
|
get res() {
|
|
109
|
-
return this.#res ||=
|
|
110
|
+
return this.#res ||= createResponseInstance(null, {
|
|
110
111
|
headers: this.#preparedHeaders ??= new Headers()
|
|
111
112
|
});
|
|
112
113
|
}
|
|
@@ -117,7 +118,7 @@ var Context = class {
|
|
|
117
118
|
*/
|
|
118
119
|
set res(_res) {
|
|
119
120
|
if (this.#res && _res) {
|
|
120
|
-
_res =
|
|
121
|
+
_res = createResponseInstance(_res.body, _res);
|
|
121
122
|
for (const [k, v] of this.#res.headers.entries()) {
|
|
122
123
|
if (k === "content-type") {
|
|
123
124
|
continue;
|
|
@@ -207,7 +208,7 @@ var Context = class {
|
|
|
207
208
|
*/
|
|
208
209
|
header = (name, value, options) => {
|
|
209
210
|
if (this.finalized) {
|
|
210
|
-
this.#res =
|
|
211
|
+
this.#res = createResponseInstance(this.#res.body, this.#res);
|
|
211
212
|
}
|
|
212
213
|
const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
|
|
213
214
|
if (value === void 0) {
|
|
@@ -296,7 +297,7 @@ var Context = class {
|
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
const status = typeof arg === "number" ? arg : arg?.status ?? this.#status;
|
|
299
|
-
return
|
|
300
|
+
return createResponseInstance(data, { status, headers: responseHeaders });
|
|
300
301
|
}
|
|
301
302
|
newResponse = (...args) => this.#newResponse(...args);
|
|
302
303
|
/**
|
|
@@ -401,7 +402,7 @@ var Context = class {
|
|
|
401
402
|
* ```
|
|
402
403
|
*/
|
|
403
404
|
notFound = () => {
|
|
404
|
-
this.#notFoundHandler ??= () =>
|
|
405
|
+
this.#notFoundHandler ??= () => createResponseInstance();
|
|
405
406
|
return this.#notFoundHandler(this);
|
|
406
407
|
};
|
|
407
408
|
};
|
package/dist/helper/ssg/index.js
CHANGED
|
@@ -7,10 +7,13 @@ import {
|
|
|
7
7
|
disableSSG,
|
|
8
8
|
onlySSG
|
|
9
9
|
} from "./middleware.js";
|
|
10
|
+
import { defaultPlugin, redirectPlugin } from "./plugins.js";
|
|
10
11
|
export {
|
|
11
12
|
X_HONO_DISABLE_SSG_HEADER_KEY,
|
|
13
|
+
defaultPlugin,
|
|
12
14
|
disableSSG,
|
|
13
15
|
isSSGContext,
|
|
14
16
|
onlySSG,
|
|
17
|
+
redirectPlugin,
|
|
15
18
|
ssgParams
|
|
16
19
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/helper/ssg/plugins.ts
|
|
2
|
+
import { html } from "../html/index.js";
|
|
3
|
+
var defaultPlugin = () => {
|
|
4
|
+
return {
|
|
5
|
+
afterResponseHook: (res) => {
|
|
6
|
+
if (res.status !== 200) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return res;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
var REDIRECT_STATUS_CODES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
14
|
+
var generateRedirectHtml = (location) => {
|
|
15
|
+
const content = html`<!DOCTYPE html>
|
|
16
|
+
<title>Redirecting to: ${location}</title>
|
|
17
|
+
<meta http-equiv="refresh" content="0;url=${location}" />
|
|
18
|
+
<meta name="robots" content="noindex" />
|
|
19
|
+
<link rel="canonical" href="${location}" />
|
|
20
|
+
<body>
|
|
21
|
+
<a href="${location}">Redirecting to <code>${location}</code></a>
|
|
22
|
+
</body>
|
|
23
|
+
`;
|
|
24
|
+
return content.toString().replace(/\n/g, "");
|
|
25
|
+
};
|
|
26
|
+
var redirectPlugin = () => {
|
|
27
|
+
return {
|
|
28
|
+
afterResponseHook: (res) => {
|
|
29
|
+
if (REDIRECT_STATUS_CODES.has(res.status)) {
|
|
30
|
+
const location = res.headers.get("Location");
|
|
31
|
+
if (!location) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const htmlBody = generateRedirectHtml(location);
|
|
35
|
+
return new Response(htmlBody, {
|
|
36
|
+
status: 200,
|
|
37
|
+
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return res;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
defaultPlugin,
|
|
46
|
+
redirectPlugin
|
|
47
|
+
};
|
package/dist/helper/ssg/ssg.js
CHANGED
|
@@ -3,6 +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 { defaultPlugin } from "./plugins.js";
|
|
6
7
|
import { dirname, filterStaticGenerateRoutes, isDynamicRoute, joinPaths } from "./utils.js";
|
|
7
8
|
var DEFAULT_CONCURRENCY = 2;
|
|
8
9
|
var DEFAULT_CONTENT_TYPE = "text/plain";
|
|
@@ -184,19 +185,11 @@ var saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
|
184
185
|
}
|
|
185
186
|
return filePath;
|
|
186
187
|
};
|
|
187
|
-
var defaultPlugin = {
|
|
188
|
-
afterResponseHook: (res) => {
|
|
189
|
-
if (res.status !== 200) {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
return res;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
188
|
var toSSG = async (app, fs, options) => {
|
|
196
189
|
let result;
|
|
197
190
|
const getInfoPromises = [];
|
|
198
191
|
const savePromises = [];
|
|
199
|
-
const plugins = options?.plugins || [defaultPlugin];
|
|
192
|
+
const plugins = options?.plugins || [defaultPlugin()];
|
|
200
193
|
const beforeRequestHooks = [];
|
|
201
194
|
const afterResponseHooks = [];
|
|
202
195
|
const afterGenerateHooks = [];
|
|
@@ -288,7 +281,6 @@ export {
|
|
|
288
281
|
combineAfterResponseHooks,
|
|
289
282
|
combineBeforeRequestHooks,
|
|
290
283
|
defaultExtensionMap,
|
|
291
|
-
defaultPlugin,
|
|
292
284
|
fetchRoutesContent,
|
|
293
285
|
saveContentToFile,
|
|
294
286
|
toSSG
|
|
@@ -11,6 +11,11 @@ var SSEStreamingApi = class extends StreamingApi {
|
|
|
11
11
|
const dataLines = data.split(/\r\n|\r|\n/).map((line) => {
|
|
12
12
|
return `data: ${line}`;
|
|
13
13
|
}).join("\n");
|
|
14
|
+
for (const key of ["event", "id", "retry"]) {
|
|
15
|
+
if (message[key] && /[\r\n]/.test(message[key])) {
|
|
16
|
+
throw new Error(`${key} must not contain "\\r" or "\\n"`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
14
19
|
const sseData = [
|
|
15
20
|
message.event && `event: ${message.event}`,
|
|
16
21
|
dataLines,
|
package/dist/jsx/context.js
CHANGED
|
@@ -11,12 +11,14 @@ var createContext = (defaultValue) => {
|
|
|
11
11
|
let string;
|
|
12
12
|
try {
|
|
13
13
|
string = props.children ? (Array.isArray(props.children) ? new JSXFragmentNode("", {}, props.children) : props.children).toString() : "";
|
|
14
|
-
}
|
|
14
|
+
} catch (e) {
|
|
15
15
|
values.pop();
|
|
16
|
+
throw e;
|
|
16
17
|
}
|
|
17
18
|
if (string instanceof Promise) {
|
|
18
|
-
return string.then((resString) => raw(resString, resString.callbacks));
|
|
19
|
+
return string.finally(() => values.pop()).then((resString) => raw(resString, resString.callbacks));
|
|
19
20
|
} else {
|
|
21
|
+
values.pop();
|
|
20
22
|
return raw(string);
|
|
21
23
|
}
|
|
22
24
|
});
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// src/jsx/dom/intrinsic-element/components.ts
|
|
2
2
|
import { useContext } from "../../context.js";
|
|
3
3
|
import { use, useCallback, useMemo, useState } from "../../hooks/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
dataPrecedenceAttr,
|
|
6
|
+
deDupeKeyMap,
|
|
7
|
+
domRenderers,
|
|
8
|
+
isStylesheetLinkWithPrecedence,
|
|
9
|
+
shouldDeDupeByKey
|
|
10
|
+
} from "../../intrinsic-element/common.js";
|
|
5
11
|
import { FormContext, registerAction } from "../hooks/index.js";
|
|
6
12
|
import { createPortal, getNameSpaceContext } from "../render.js";
|
|
7
13
|
var clearCache = () => {
|
|
@@ -49,11 +55,16 @@ var documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlo
|
|
|
49
55
|
let element = null;
|
|
50
56
|
let created = false;
|
|
51
57
|
const deDupeKeys = deDupeKeyMap[tag];
|
|
58
|
+
const deDupeByKey = shouldDeDupeByKey(tag, supportSort);
|
|
59
|
+
const isDeDupeCandidateLink = (e) => e.getAttribute("rel") === "stylesheet" && e.getAttribute(dataPrecedenceAttr) !== null;
|
|
52
60
|
let existingElements = void 0;
|
|
53
|
-
if (
|
|
61
|
+
if (deDupeByKey) {
|
|
54
62
|
const tags = head.querySelectorAll(tag);
|
|
55
63
|
LOOP: for (const e of tags) {
|
|
56
|
-
|
|
64
|
+
if (tag === "link" && !isDeDupeCandidateLink(e)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
for (const key of deDupeKeys) {
|
|
57
68
|
if (e.getAttribute(key) === props[key]) {
|
|
58
69
|
element = e;
|
|
59
70
|
break LOOP;
|
|
@@ -72,9 +83,9 @@ var documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlo
|
|
|
72
83
|
if (props[key] !== void 0) {
|
|
73
84
|
e.setAttribute(key, props[key]);
|
|
74
85
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
}
|
|
87
|
+
if (props.rel) {
|
|
88
|
+
e.setAttribute("rel", props.rel);
|
|
78
89
|
}
|
|
79
90
|
return e;
|
|
80
91
|
})();
|
|
@@ -88,7 +99,26 @@ var documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlo
|
|
|
88
99
|
}
|
|
89
100
|
const insert = useCallback(
|
|
90
101
|
(e) => {
|
|
91
|
-
if (
|
|
102
|
+
if (deDupeByKey) {
|
|
103
|
+
if (tag === "link" && precedence !== void 0) {
|
|
104
|
+
let found2 = false;
|
|
105
|
+
for (const existingElement of head.querySelectorAll(tag)) {
|
|
106
|
+
const existingPrecedence = existingElement.getAttribute(dataPrecedenceAttr);
|
|
107
|
+
if (existingPrecedence === null) {
|
|
108
|
+
head.insertBefore(e, existingElement);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (found2 && existingPrecedence !== precedence) {
|
|
112
|
+
head.insertBefore(e, existingElement);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (existingPrecedence === precedence) {
|
|
116
|
+
found2 = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
head.appendChild(e);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
92
122
|
let found = false;
|
|
93
123
|
for (const existingElement of head.querySelectorAll(tag)) {
|
|
94
124
|
if (found && existingElement.getAttribute(dataPrecedenceAttr) !== precedence) {
|
|
@@ -100,6 +130,10 @@ var documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlo
|
|
|
100
130
|
}
|
|
101
131
|
}
|
|
102
132
|
head.appendChild(e);
|
|
133
|
+
} else if (tag === "link") {
|
|
134
|
+
if (!head.contains(e)) {
|
|
135
|
+
head.appendChild(e);
|
|
136
|
+
}
|
|
103
137
|
} else if (existingElements) {
|
|
104
138
|
let found = false;
|
|
105
139
|
for (const existingElement of existingElements) {
|
|
@@ -117,7 +151,7 @@ var documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlo
|
|
|
117
151
|
existingElements = void 0;
|
|
118
152
|
}
|
|
119
153
|
},
|
|
120
|
-
[precedence]
|
|
154
|
+
[deDupeByKey, precedence, tag]
|
|
121
155
|
);
|
|
122
156
|
const ref = composeRef(props.ref, (e) => {
|
|
123
157
|
const key = deDupeKeys[0];
|
|
@@ -130,6 +164,9 @@ var documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlo
|
|
|
130
164
|
if (!onError && !onLoad) {
|
|
131
165
|
return;
|
|
132
166
|
}
|
|
167
|
+
if (!key) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
133
170
|
let promise = blockingPromiseMap[e.getAttribute(key)] ||= new Promise(
|
|
134
171
|
(resolve, reject) => {
|
|
135
172
|
e.addEventListener("load", resolve);
|
|
@@ -147,7 +184,7 @@ var documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlo
|
|
|
147
184
|
});
|
|
148
185
|
if (supportBlocking && blocking === "render") {
|
|
149
186
|
const key = deDupeKeyMap[tag][0];
|
|
150
|
-
if (props[key]) {
|
|
187
|
+
if (key && props[key]) {
|
|
151
188
|
const value = props[key];
|
|
152
189
|
const promise = blockingPromiseMap[value] ||= new Promise((resolve, reject) => {
|
|
153
190
|
insert(element);
|
|
@@ -223,7 +260,7 @@ var link = (props) => {
|
|
|
223
260
|
ref: props.ref
|
|
224
261
|
};
|
|
225
262
|
}
|
|
226
|
-
return documentMetadataTag("link", props, 1,
|
|
263
|
+
return documentMetadataTag("link", props, 1, isStylesheetLinkWithPrecedence(props), true);
|
|
227
264
|
};
|
|
228
265
|
var meta = (props) => {
|
|
229
266
|
return documentMetadataTag("meta", props, void 0, false, false);
|
package/dist/jsx/dom/render.js
CHANGED
|
@@ -184,14 +184,10 @@ var getNextChildren = (node, container, nextChildren, childrenToRemove, callback
|
|
|
184
184
|
});
|
|
185
185
|
};
|
|
186
186
|
var findInsertBefore = (node) => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
if (node.tag !== HONO_PORTAL_ELEMENT && node.e) {
|
|
192
|
-
return node.e;
|
|
193
|
-
}
|
|
187
|
+
while (node && (node.tag === HONO_PORTAL_ELEMENT || !node.e)) {
|
|
188
|
+
node = node.tag === HONO_PORTAL_ELEMENT || !node.vC?.[0] ? node.nN : node.vC[0];
|
|
194
189
|
}
|
|
190
|
+
return node?.e;
|
|
195
191
|
};
|
|
196
192
|
var removeNode = (node) => {
|
|
197
193
|
if (!isNodeString(node)) {
|
|
@@ -289,7 +285,7 @@ var applyNodeObject = (node, container, isNew) => {
|
|
|
289
285
|
}
|
|
290
286
|
}
|
|
291
287
|
if (node.pP) {
|
|
292
|
-
|
|
288
|
+
node.pP = void 0;
|
|
293
289
|
}
|
|
294
290
|
if (callbacks.length) {
|
|
295
291
|
const useLayoutEffectCbs = [];
|
|
@@ -330,7 +326,9 @@ var build = (context, node, children) => {
|
|
|
330
326
|
let prevNode;
|
|
331
327
|
for (let i = 0; i < children.length; i++) {
|
|
332
328
|
if (Array.isArray(children[i])) {
|
|
333
|
-
children.splice(i, 1, ...children[i].flat());
|
|
329
|
+
children.splice(i, 1, ...children[i].flat(Infinity));
|
|
330
|
+
i--;
|
|
331
|
+
continue;
|
|
334
332
|
}
|
|
335
333
|
let child = buildNode(children[i]);
|
|
336
334
|
if (child) {
|
|
@@ -8,8 +8,17 @@ var deDupeKeyMap = {
|
|
|
8
8
|
};
|
|
9
9
|
var domRenderers = {};
|
|
10
10
|
var dataPrecedenceAttr = "data-precedence";
|
|
11
|
+
var isStylesheetLinkWithPrecedence = (props) => props.rel === "stylesheet" && "precedence" in props;
|
|
12
|
+
var shouldDeDupeByKey = (tagName, supportSort) => {
|
|
13
|
+
if (tagName === "link") {
|
|
14
|
+
return supportSort;
|
|
15
|
+
}
|
|
16
|
+
return deDupeKeyMap[tagName].length > 0;
|
|
17
|
+
};
|
|
11
18
|
export {
|
|
12
19
|
dataPrecedenceAttr,
|
|
13
20
|
deDupeKeyMap,
|
|
14
|
-
domRenderers
|
|
21
|
+
domRenderers,
|
|
22
|
+
isStylesheetLinkWithPrecedence,
|
|
23
|
+
shouldDeDupeByKey
|
|
15
24
|
};
|
|
@@ -4,7 +4,12 @@ import { JSXNode, getNameSpaceContext } from "../base.js";
|
|
|
4
4
|
import { toArray } from "../children.js";
|
|
5
5
|
import { PERMALINK } from "../constants.js";
|
|
6
6
|
import { useContext } from "../context.js";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
dataPrecedenceAttr,
|
|
9
|
+
deDupeKeyMap,
|
|
10
|
+
isStylesheetLinkWithPrecedence,
|
|
11
|
+
shouldDeDupeByKey
|
|
12
|
+
} from "./common.js";
|
|
8
13
|
var metaTagMap = /* @__PURE__ */ new WeakMap();
|
|
9
14
|
var insertIntoHead = (tagName, tag, props, precedence) => ({ buffer, context }) => {
|
|
10
15
|
if (!buffer) {
|
|
@@ -15,8 +20,12 @@ var insertIntoHead = (tagName, tag, props, precedence) => ({ buffer, context })
|
|
|
15
20
|
const tags = map[tagName] ||= [];
|
|
16
21
|
let duped = false;
|
|
17
22
|
const deDupeKeys = deDupeKeyMap[tagName];
|
|
18
|
-
|
|
23
|
+
const deDupeByKey = shouldDeDupeByKey(tagName, precedence !== void 0);
|
|
24
|
+
if (deDupeByKey) {
|
|
19
25
|
LOOP: for (const [, tagProps] of tags) {
|
|
26
|
+
if (tagName === "link" && !(tagProps.rel === "stylesheet" && tagProps[dataPrecedenceAttr] !== void 0)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
20
29
|
for (const key of deDupeKeys) {
|
|
21
30
|
if ((tagProps?.[key] ?? null) === props?.[key]) {
|
|
22
31
|
duped = true;
|
|
@@ -27,25 +36,28 @@ var insertIntoHead = (tagName, tag, props, precedence) => ({ buffer, context })
|
|
|
27
36
|
}
|
|
28
37
|
if (duped) {
|
|
29
38
|
buffer[0] = buffer[0].replaceAll(tag, "");
|
|
30
|
-
} else if (
|
|
39
|
+
} else if (deDupeByKey || tagName === "link") {
|
|
31
40
|
tags.push([tag, props, precedence]);
|
|
32
41
|
} else {
|
|
33
42
|
tags.unshift([tag, props, precedence]);
|
|
34
43
|
}
|
|
35
44
|
if (buffer[0].indexOf("</head>") !== -1) {
|
|
36
45
|
let insertTags;
|
|
37
|
-
if (
|
|
38
|
-
insertTags = tags.map(([tag2]) => tag2);
|
|
39
|
-
} else {
|
|
46
|
+
if (tagName === "link" || precedence !== void 0) {
|
|
40
47
|
const precedences = [];
|
|
41
|
-
insertTags = tags.map(([tag2, ,
|
|
42
|
-
|
|
48
|
+
insertTags = tags.map(([tag2, , tagPrecedence], index) => {
|
|
49
|
+
if (tagPrecedence === void 0) {
|
|
50
|
+
return [tag2, Number.MAX_SAFE_INTEGER, index];
|
|
51
|
+
}
|
|
52
|
+
let order = precedences.indexOf(tagPrecedence);
|
|
43
53
|
if (order === -1) {
|
|
44
|
-
precedences.push(
|
|
54
|
+
precedences.push(tagPrecedence);
|
|
45
55
|
order = precedences.length - 1;
|
|
46
56
|
}
|
|
47
|
-
return [tag2, order];
|
|
48
|
-
}).sort((a, b) => a[1] - b[1]).map(([tag2]) => tag2);
|
|
57
|
+
return [tag2, order, index];
|
|
58
|
+
}).sort((a, b) => a[1] - b[1] || a[2] - b[2]).map(([tag2]) => tag2);
|
|
59
|
+
} else {
|
|
60
|
+
insertTags = tags.map(([tag2]) => tag2);
|
|
49
61
|
}
|
|
50
62
|
insertTags.forEach((tag2) => {
|
|
51
63
|
buffer[0] = buffer[0].replaceAll(tag2, "");
|
|
@@ -114,7 +126,7 @@ var link = ({ children, ...props }) => {
|
|
|
114
126
|
if (["onLoad", "onError"].some((k) => k in props) || props.rel === "stylesheet" && (!("precedence" in props) || "disabled" in props)) {
|
|
115
127
|
return returnWithoutSpecialBehavior("link", children, props);
|
|
116
128
|
}
|
|
117
|
-
return documentMetadataTag("link", children, props,
|
|
129
|
+
return documentMetadataTag("link", children, props, isStylesheetLinkWithPrecedence(props));
|
|
118
130
|
};
|
|
119
131
|
var meta = ({ children, ...props }) => {
|
|
120
132
|
const nameSpaceContext = getNameSpaceContext();
|
package/dist/jsx/streaming.js
CHANGED
|
@@ -89,6 +89,7 @@ d.replaceWith(c.content)
|
|
|
89
89
|
Suspense[DOM_RENDERER] = SuspenseDomRenderer;
|
|
90
90
|
var textEncoder = new TextEncoder();
|
|
91
91
|
var renderToReadableStream = (content, onError = console.trace) => {
|
|
92
|
+
let cancelled = false;
|
|
92
93
|
const reader = new ReadableStream({
|
|
93
94
|
async start(controller) {
|
|
94
95
|
try {
|
|
@@ -102,7 +103,9 @@ var renderToReadableStream = (content, onError = console.trace) => {
|
|
|
102
103
|
true,
|
|
103
104
|
context
|
|
104
105
|
);
|
|
105
|
-
|
|
106
|
+
if (!cancelled) {
|
|
107
|
+
controller.enqueue(textEncoder.encode(resolved));
|
|
108
|
+
}
|
|
106
109
|
let resolvedCount = 0;
|
|
107
110
|
const callbacks = [];
|
|
108
111
|
const then = (promise) => {
|
|
@@ -120,7 +123,9 @@ var renderToReadableStream = (content, onError = console.trace) => {
|
|
|
120
123
|
);
|
|
121
124
|
res.callbacks?.map((c) => c({ phase: HtmlEscapedCallbackPhase.Stream, context })).filter(Boolean).forEach(then);
|
|
122
125
|
resolvedCount++;
|
|
123
|
-
|
|
126
|
+
if (!cancelled) {
|
|
127
|
+
controller.enqueue(textEncoder.encode(res));
|
|
128
|
+
}
|
|
124
129
|
})
|
|
125
130
|
);
|
|
126
131
|
};
|
|
@@ -131,7 +136,12 @@ var renderToReadableStream = (content, onError = console.trace) => {
|
|
|
131
136
|
} catch (e) {
|
|
132
137
|
onError(e);
|
|
133
138
|
}
|
|
134
|
-
|
|
139
|
+
if (!cancelled) {
|
|
140
|
+
controller.close();
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
cancel() {
|
|
144
|
+
cancelled = true;
|
|
135
145
|
}
|
|
136
146
|
});
|
|
137
147
|
return reader;
|
|
@@ -24,6 +24,9 @@ var basicAuth = (options, ...users) => {
|
|
|
24
24
|
if (requestUser) {
|
|
25
25
|
if (verifyUserInOptions) {
|
|
26
26
|
if (await options.verifyUser(requestUser.username, requestUser.password, ctx)) {
|
|
27
|
+
if (options.onAuthSuccess) {
|
|
28
|
+
await options.onAuthSuccess(ctx, requestUser.username);
|
|
29
|
+
}
|
|
27
30
|
await next();
|
|
28
31
|
return;
|
|
29
32
|
}
|
|
@@ -34,6 +37,9 @@ var basicAuth = (options, ...users) => {
|
|
|
34
37
|
timingSafeEqual(user.password, requestUser.password, options.hashFunction)
|
|
35
38
|
]);
|
|
36
39
|
if (usernameEqual && passwordEqual) {
|
|
40
|
+
if (options.onAuthSuccess) {
|
|
41
|
+
await options.onAuthSuccess(ctx, requestUser.username);
|
|
42
|
+
}
|
|
37
43
|
await next();
|
|
38
44
|
return;
|
|
39
45
|
}
|
|
@@ -16,7 +16,7 @@ var bearerAuth = (options) => {
|
|
|
16
16
|
}
|
|
17
17
|
const realm = options.realm?.replace(/"/g, '\\"');
|
|
18
18
|
const prefixRegexStr = options.prefix === "" ? "" : `${options.prefix} +`;
|
|
19
|
-
const regexp = new RegExp(`^${prefixRegexStr}(${TOKEN_STRINGS})
|
|
19
|
+
const regexp = new RegExp(`^${prefixRegexStr}(${TOKEN_STRINGS}) *$`, "i");
|
|
20
20
|
const wwwAuthenticatePrefix = options.prefix === "" ? "" : `${options.prefix} `;
|
|
21
21
|
const throwHTTPException = async (c, status, wwwAuthenticateHeader, messageOption) => {
|
|
22
22
|
const wwwAuthenticateHeaderValue = typeof wwwAuthenticateHeader === "function" ? await wwwAuthenticateHeader(c) : wwwAuthenticateHeader;
|
|
@@ -4,6 +4,7 @@ import { Fragment, createContext, jsx, useContext } from "../../jsx/index.js";
|
|
|
4
4
|
import { renderToReadableStream } from "../../jsx/streaming.js";
|
|
5
5
|
var RequestContext = createContext(null);
|
|
6
6
|
var createRenderer = (c, Layout, component, options) => (children, props) => {
|
|
7
|
+
options = typeof options === "function" ? options(c) : options;
|
|
7
8
|
const docType = typeof options?.docType === "string" ? options.docType : options?.docType === false ? "" : "<!DOCTYPE html>";
|
|
8
9
|
const currentLayout = component ? jsx(
|
|
9
10
|
(props2) => component(props2, c),
|
|
@@ -35,8 +35,19 @@ var normalizeLanguage = (lang, options) => {
|
|
|
35
35
|
const compSupported = options.supportedLanguages.map(
|
|
36
36
|
(l) => options.ignoreCase ? l.toLowerCase() : l
|
|
37
37
|
);
|
|
38
|
-
const
|
|
39
|
-
|
|
38
|
+
const exactIndex = compSupported.indexOf(compLang);
|
|
39
|
+
if (exactIndex !== -1) {
|
|
40
|
+
return options.supportedLanguages[exactIndex];
|
|
41
|
+
}
|
|
42
|
+
const parts = compLang.split("-");
|
|
43
|
+
for (let i = parts.length - 1; i > 0; i--) {
|
|
44
|
+
const candidate = parts.slice(0, i).join("-");
|
|
45
|
+
const prefixIndex = compSupported.indexOf(candidate);
|
|
46
|
+
if (prefixIndex !== -1) {
|
|
47
|
+
return options.supportedLanguages[prefixIndex];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return void 0;
|
|
40
51
|
} catch {
|
|
41
52
|
return void 0;
|
|
42
53
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/middleware/serve-static/index.ts
|
|
2
2
|
import { COMPRESSIBLE_CONTENT_TYPE_REGEX } from "../../utils/compress.js";
|
|
3
3
|
import { getMimeType } from "../../utils/mime.js";
|
|
4
|
+
import { tryDecodeURI } from "../../utils/url.js";
|
|
4
5
|
import { defaultJoin } from "./path.js";
|
|
5
6
|
var ENCODINGS = {
|
|
6
7
|
br: ".br",
|
|
@@ -22,7 +23,7 @@ var serveStatic = (options) => {
|
|
|
22
23
|
filename = options.path;
|
|
23
24
|
} else {
|
|
24
25
|
try {
|
|
25
|
-
filename =
|
|
26
|
+
filename = tryDecodeURI(c.req.path);
|
|
26
27
|
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
|
|
27
28
|
throw new Error();
|
|
28
29
|
}
|