hono 4.12.9 → 4.12.12
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/helper/css/common.js +56 -7
- package/dist/cjs/helper/css/index.js +11 -4
- package/dist/cjs/helper/ssg/ssg.js +10 -8
- package/dist/cjs/helper/ssg/utils.js +9 -0
- package/dist/cjs/jsx/dom/css.js +11 -4
- package/dist/cjs/jsx/dom/render.js +17 -8
- package/dist/cjs/middleware/compress/index.js +4 -0
- package/dist/cjs/middleware/ip-restriction/index.js +31 -9
- package/dist/cjs/middleware/serve-static/index.js +1 -1
- package/dist/cjs/utils/cookie.js +26 -5
- package/dist/cjs/utils/ipaddr.js +10 -4
- package/dist/helper/css/common.js +56 -7
- package/dist/helper/css/index.js +11 -4
- package/dist/helper/ssg/ssg.js +17 -9
- package/dist/helper/ssg/utils.js +8 -0
- package/dist/jsx/dom/css.js +11 -4
- package/dist/jsx/dom/render.js +17 -8
- package/dist/middleware/compress/index.js +4 -0
- package/dist/middleware/ip-restriction/index.js +34 -10
- package/dist/middleware/serve-static/index.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/helper/css/common.d.ts +20 -3
- package/dist/types/helper/css/index.d.ts +9 -2
- package/dist/types/helper/ssg/utils.d.ts +1 -0
- package/dist/types/jsx/dom/css.d.ts +8 -2
- package/dist/types/middleware/ip-restriction/index.d.ts +38 -2
- package/dist/types/utils/ipaddr.d.ts +12 -0
- package/dist/utils/cookie.js +26 -5
- package/dist/utils/ipaddr.js +7 -3
- package/package.json +1 -1
package/dist/jsx/dom/css.js
CHANGED
|
@@ -100,22 +100,29 @@ var createCssJsxDomObjects = ({ id }) => {
|
|
|
100
100
|
});
|
|
101
101
|
return [cssObject, Style2];
|
|
102
102
|
};
|
|
103
|
-
var createCssContext = ({
|
|
103
|
+
var createCssContext = ({
|
|
104
|
+
id,
|
|
105
|
+
classNameSlug,
|
|
106
|
+
onInvalidSlug
|
|
107
|
+
}) => {
|
|
104
108
|
const [cssObject, Style2] = createCssJsxDomObjects({ id });
|
|
105
109
|
const newCssClassNameObject = (cssClassName) => {
|
|
106
110
|
cssClassName.toString = cssObject.toString;
|
|
107
111
|
return cssClassName;
|
|
108
112
|
};
|
|
109
113
|
const css2 = (strings, ...values) => {
|
|
110
|
-
return newCssClassNameObject(cssCommon(strings, values));
|
|
114
|
+
return newCssClassNameObject(cssCommon(strings, values, classNameSlug, onInvalidSlug));
|
|
111
115
|
};
|
|
112
116
|
const cx2 = (...args) => {
|
|
113
117
|
args = cxCommon(args);
|
|
114
118
|
return css2(Array(args.length).fill(""), ...args);
|
|
115
119
|
};
|
|
116
|
-
const keyframes2 = keyframesCommon;
|
|
120
|
+
const keyframes2 = (strings, ...values) => keyframesCommon(strings, values, classNameSlug, onInvalidSlug);
|
|
117
121
|
const viewTransition2 = ((strings, ...values) => {
|
|
118
|
-
return newCssClassNameObject(
|
|
122
|
+
return newCssClassNameObject(
|
|
123
|
+
viewTransitionCommon(strings, values, classNameSlug, onInvalidSlug)
|
|
124
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
125
|
+
);
|
|
119
126
|
});
|
|
120
127
|
return {
|
|
121
128
|
css: css2,
|
package/dist/jsx/dom/render.js
CHANGED
|
@@ -45,6 +45,16 @@ var getEventSpec = (key) => {
|
|
|
45
45
|
};
|
|
46
46
|
var toAttributeName = (element, key) => nameSpaceContext && element instanceof SVGElement && /[A-Z]/.test(key) && (key in element.style || // Presentation attributes are findable in style object. "clip-path", "font-size", "stroke-width", etc.
|
|
47
47
|
key.match(/^(?:o|pai|str|u|ve)/)) ? key.replace(/([A-Z])/g, "-$1").toLowerCase() : key;
|
|
48
|
+
var normalizeFormValue = (value) => value === null || value === void 0 || value === false ? null : value;
|
|
49
|
+
var applySelectValue = (select, props) => {
|
|
50
|
+
if (!("value" in props)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
select.value = normalizeFormValue(props["value"]);
|
|
54
|
+
if (!select.multiple && select.selectedIndex === -1) {
|
|
55
|
+
select.selectedIndex = 0;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
48
58
|
var applyProps = (container, attributes, oldAttributes) => {
|
|
49
59
|
attributes ||= {};
|
|
50
60
|
for (let key in attributes) {
|
|
@@ -88,18 +98,14 @@ var applyProps = (container, attributes, oldAttributes) => {
|
|
|
88
98
|
} else {
|
|
89
99
|
if (key === "value") {
|
|
90
100
|
const nodeName = container.nodeName;
|
|
91
|
-
if (nodeName === "
|
|
101
|
+
if (nodeName === "SELECT") {
|
|
102
|
+
continue;
|
|
103
|
+
} else if (nodeName === "INPUT" || nodeName === "TEXTAREA") {
|
|
92
104
|
;
|
|
93
|
-
container.value = value
|
|
105
|
+
container.value = normalizeFormValue(value);
|
|
94
106
|
if (nodeName === "TEXTAREA") {
|
|
95
107
|
container.textContent = value;
|
|
96
108
|
continue;
|
|
97
|
-
} else if (nodeName === "SELECT") {
|
|
98
|
-
if (container.selectedIndex === -1) {
|
|
99
|
-
;
|
|
100
|
-
container.selectedIndex = 0;
|
|
101
|
-
}
|
|
102
|
-
continue;
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
} else if (key === "checked" && container.nodeName === "INPUT" || key === "selected" && container.nodeName === "OPTION") {
|
|
@@ -268,6 +274,9 @@ var applyNodeObject = (node, container, isNew) => {
|
|
|
268
274
|
el = child.e ||= child.n ? document.createElementNS(child.n, child.tag) : document.createElement(child.tag);
|
|
269
275
|
applyProps(el, child.props, child.pP);
|
|
270
276
|
applyNodeObject(child, el, isNewLocal);
|
|
277
|
+
if (child.tag === "select") {
|
|
278
|
+
applySelectValue(el, child.props);
|
|
279
|
+
}
|
|
271
280
|
}
|
|
272
281
|
}
|
|
273
282
|
if (child.tag === HONO_PORTAL_ELEMENT) {
|
|
@@ -24,6 +24,10 @@ var compress = (options) => {
|
|
|
24
24
|
ctx.res = new Response(ctx.res.body.pipeThrough(stream), ctx.res);
|
|
25
25
|
ctx.res.headers.delete("Content-Length");
|
|
26
26
|
ctx.res.headers.set("Content-Encoding", encoding);
|
|
27
|
+
const etag = ctx.res.headers.get("ETag");
|
|
28
|
+
if (etag && !etag.startsWith("W/")) {
|
|
29
|
+
ctx.res.headers.set("ETag", `W/${etag}`);
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
};
|
|
29
33
|
var shouldCompress = (res) => {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// src/middleware/ip-restriction/index.ts
|
|
2
2
|
import { HTTPException } from "../../http-exception.js";
|
|
3
3
|
import {
|
|
4
|
+
convertIPv4MappedIPv6ToIPv4,
|
|
4
5
|
convertIPv4ToBinary,
|
|
5
6
|
convertIPv6BinaryToString,
|
|
6
7
|
convertIPv6ToBinary,
|
|
7
|
-
distinctRemoteAddr
|
|
8
|
+
distinctRemoteAddr,
|
|
9
|
+
isIPv4MappedIPv6
|
|
8
10
|
} from "../../utils/ipaddr.js";
|
|
9
11
|
var IS_CIDR_NOTATION_REGEX = /\/[0-9]{0,3}$/;
|
|
10
12
|
var buildMatcher = (rules) => {
|
|
@@ -24,12 +26,17 @@ var buildMatcher = (rules) => {
|
|
|
24
26
|
if (type2 === void 0) {
|
|
25
27
|
throw new TypeError(`Invalid rule: ${rule}`);
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
let isIPv4 = type2 === "IPv4";
|
|
30
|
+
let prefix = parseInt(separatedRule[1]);
|
|
29
31
|
if (isIPv4 ? prefix === 32 : prefix === 128) {
|
|
30
32
|
rule = addrStr;
|
|
31
33
|
} else {
|
|
32
|
-
|
|
34
|
+
let addr = (isIPv4 ? convertIPv4ToBinary : convertIPv6ToBinary)(addrStr);
|
|
35
|
+
if (type2 === "IPv6" && isIPv4MappedIPv6(addr) && prefix >= 96) {
|
|
36
|
+
isIPv4 = true;
|
|
37
|
+
addr = convertIPv4MappedIPv6ToIPv4(addr);
|
|
38
|
+
prefix -= 96;
|
|
39
|
+
}
|
|
33
40
|
const mask = (1n << BigInt(prefix)) - 1n << BigInt((isIPv4 ? 32 : 128) - prefix);
|
|
34
41
|
cidrRules.push([isIPv4, addr & mask, mask]);
|
|
35
42
|
continue;
|
|
@@ -39,21 +46,38 @@ var buildMatcher = (rules) => {
|
|
|
39
46
|
if (type === void 0) {
|
|
40
47
|
throw new TypeError(`Invalid rule: ${rule}`);
|
|
41
48
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
if (type === "IPv4") {
|
|
50
|
+
staticRules.add(rule);
|
|
51
|
+
staticRules.add(`::ffff:${rule}`);
|
|
52
|
+
} else {
|
|
53
|
+
const ipv6binary = convertIPv6ToBinary(rule);
|
|
54
|
+
const ipv6Addr = convertIPv6BinaryToString(ipv6binary);
|
|
55
|
+
staticRules.add(ipv6Addr);
|
|
56
|
+
if (isIPv4MappedIPv6(ipv6binary)) {
|
|
57
|
+
staticRules.add(ipv6Addr.substring(7));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
return (remote) => {
|
|
49
63
|
if (staticRules.has(remote.addr)) {
|
|
50
64
|
return true;
|
|
51
65
|
}
|
|
66
|
+
const remoteAddr = remote.binaryAddr ||= (remote.isIPv4 ? convertIPv4ToBinary : convertIPv6ToBinary)(remote.addr);
|
|
67
|
+
const remoteIPv4Addr = remote.isIPv4 || isIPv4MappedIPv6(remoteAddr) ? remote.isIPv4 ? remoteAddr : convertIPv4MappedIPv6ToIPv4(remoteAddr) : void 0;
|
|
52
68
|
for (const [isIPv4, addr, mask] of cidrRules) {
|
|
53
|
-
if (isIPv4
|
|
69
|
+
if (isIPv4) {
|
|
70
|
+
if (remoteIPv4Addr === void 0) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if ((remoteIPv4Addr & mask) === addr) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (remote.isIPv4) {
|
|
54
79
|
continue;
|
|
55
80
|
}
|
|
56
|
-
const remoteAddr = remote.binaryAddr ||= (isIPv4 ? convertIPv4ToBinary : convertIPv6ToBinary)(remote.addr);
|
|
57
81
|
if ((remoteAddr & mask) === addr) {
|
|
58
82
|
return true;
|
|
59
83
|
}
|