h3-nightly 2.0.1-rc.2 → 3.0.0-20251021-151501-4247682
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/h3.d.mts +1 -1
- package/dist/h3.mjs +174 -3
- package/package.json +15 -14
package/dist/h3.d.mts
CHANGED
|
@@ -282,7 +282,7 @@ declare class HTTPError<DataT = unknown> extends Error implements ErrorBody<Data
|
|
|
282
282
|
* @deprecated Use `statusText`
|
|
283
283
|
*/
|
|
284
284
|
get statusMessage(): string | undefined;
|
|
285
|
-
toJSON(): ErrorBody;
|
|
285
|
+
toJSON(): Omit<ErrorBody, "body"> & ErrorBody["body"];
|
|
286
286
|
}
|
|
287
287
|
//#endregion
|
|
288
288
|
//#region src/types/h3.d.ts
|
package/dist/h3.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NullProtoObj as EmptyObject, addRoute, createRouter, findRoute, routeToRegExp } from "rou3";
|
|
2
2
|
import { FastResponse, FastURL } from "srvx";
|
|
3
|
-
import { parse, parseSetCookie, serialize, splitSetCookieString } from "cookie-es";
|
|
4
3
|
|
|
5
4
|
//#region src/_entries/_common.ts
|
|
6
5
|
function freezeApp(app) {
|
|
@@ -1567,10 +1566,10 @@ async function proxy(event, target, opts = {}) {
|
|
|
1567
1566
|
if (key === "content-encoding") continue;
|
|
1568
1567
|
if (key === "content-length") continue;
|
|
1569
1568
|
if (key === "set-cookie") {
|
|
1570
|
-
cookies.push(
|
|
1569
|
+
cookies.push(value);
|
|
1571
1570
|
continue;
|
|
1572
1571
|
}
|
|
1573
|
-
headers.
|
|
1572
|
+
headers.append(key, value);
|
|
1574
1573
|
}
|
|
1575
1574
|
if (cookies.length > 0) {
|
|
1576
1575
|
const _cookies = cookies.map((cookie) => {
|
|
@@ -1699,6 +1698,178 @@ async function readValidatedBody(event, validate) {
|
|
|
1699
1698
|
return validateData(_body, validate);
|
|
1700
1699
|
}
|
|
1701
1700
|
|
|
1701
|
+
//#endregion
|
|
1702
|
+
//#region node_modules/.pnpm/cookie-es@2.0.0/node_modules/cookie-es/dist/index.mjs
|
|
1703
|
+
function parse(str, options) {
|
|
1704
|
+
if (typeof str !== "string") throw new TypeError("argument str must be a string");
|
|
1705
|
+
const obj = {};
|
|
1706
|
+
const opt = options || {};
|
|
1707
|
+
const dec = opt.decode || decode;
|
|
1708
|
+
let index = 0;
|
|
1709
|
+
while (index < str.length) {
|
|
1710
|
+
const eqIdx = str.indexOf("=", index);
|
|
1711
|
+
if (eqIdx === -1) break;
|
|
1712
|
+
let endIdx = str.indexOf(";", index);
|
|
1713
|
+
if (endIdx === -1) endIdx = str.length;
|
|
1714
|
+
else if (endIdx < eqIdx) {
|
|
1715
|
+
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
|
1716
|
+
continue;
|
|
1717
|
+
}
|
|
1718
|
+
const key = str.slice(index, eqIdx).trim();
|
|
1719
|
+
if (opt?.filter && !opt?.filter(key)) {
|
|
1720
|
+
index = endIdx + 1;
|
|
1721
|
+
continue;
|
|
1722
|
+
}
|
|
1723
|
+
if (void 0 === obj[key]) {
|
|
1724
|
+
let val = str.slice(eqIdx + 1, endIdx).trim();
|
|
1725
|
+
if (val.codePointAt(0) === 34) val = val.slice(1, -1);
|
|
1726
|
+
obj[key] = tryDecode(val, dec);
|
|
1727
|
+
}
|
|
1728
|
+
index = endIdx + 1;
|
|
1729
|
+
}
|
|
1730
|
+
return obj;
|
|
1731
|
+
}
|
|
1732
|
+
function decode(str) {
|
|
1733
|
+
return str.includes("%") ? decodeURIComponent(str) : str;
|
|
1734
|
+
}
|
|
1735
|
+
function tryDecode(str, decode2) {
|
|
1736
|
+
try {
|
|
1737
|
+
return decode2(str);
|
|
1738
|
+
} catch {
|
|
1739
|
+
return str;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
const fieldContentRegExp = /^[\u0009\u0020-\u007E\u0080-\u00FF]+$/;
|
|
1743
|
+
function serialize(name, value, options) {
|
|
1744
|
+
const opt = options || {};
|
|
1745
|
+
const enc = opt.encode || encodeURIComponent;
|
|
1746
|
+
if (typeof enc !== "function") throw new TypeError("option encode is invalid");
|
|
1747
|
+
if (!fieldContentRegExp.test(name)) throw new TypeError("argument name is invalid");
|
|
1748
|
+
const encodedValue = enc(value);
|
|
1749
|
+
if (encodedValue && !fieldContentRegExp.test(encodedValue)) throw new TypeError("argument val is invalid");
|
|
1750
|
+
let str = name + "=" + encodedValue;
|
|
1751
|
+
if (void 0 !== opt.maxAge && opt.maxAge !== null) {
|
|
1752
|
+
const maxAge = opt.maxAge - 0;
|
|
1753
|
+
if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError("option maxAge is invalid");
|
|
1754
|
+
str += "; Max-Age=" + Math.floor(maxAge);
|
|
1755
|
+
}
|
|
1756
|
+
if (opt.domain) {
|
|
1757
|
+
if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid");
|
|
1758
|
+
str += "; Domain=" + opt.domain;
|
|
1759
|
+
}
|
|
1760
|
+
if (opt.path) {
|
|
1761
|
+
if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid");
|
|
1762
|
+
str += "; Path=" + opt.path;
|
|
1763
|
+
}
|
|
1764
|
+
if (opt.expires) {
|
|
1765
|
+
if (!isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) throw new TypeError("option expires is invalid");
|
|
1766
|
+
str += "; Expires=" + opt.expires.toUTCString();
|
|
1767
|
+
}
|
|
1768
|
+
if (opt.httpOnly) str += "; HttpOnly";
|
|
1769
|
+
if (opt.secure) str += "; Secure";
|
|
1770
|
+
if (opt.priority) {
|
|
1771
|
+
const priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
|
|
1772
|
+
switch (priority) {
|
|
1773
|
+
case "low": {
|
|
1774
|
+
str += "; Priority=Low";
|
|
1775
|
+
break;
|
|
1776
|
+
}
|
|
1777
|
+
case "medium": {
|
|
1778
|
+
str += "; Priority=Medium";
|
|
1779
|
+
break;
|
|
1780
|
+
}
|
|
1781
|
+
case "high": {
|
|
1782
|
+
str += "; Priority=High";
|
|
1783
|
+
break;
|
|
1784
|
+
}
|
|
1785
|
+
default: throw new TypeError("option priority is invalid");
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
if (opt.sameSite) {
|
|
1789
|
+
const sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
|
|
1790
|
+
switch (sameSite) {
|
|
1791
|
+
case true: {
|
|
1792
|
+
str += "; SameSite=Strict";
|
|
1793
|
+
break;
|
|
1794
|
+
}
|
|
1795
|
+
case "lax": {
|
|
1796
|
+
str += "; SameSite=Lax";
|
|
1797
|
+
break;
|
|
1798
|
+
}
|
|
1799
|
+
case "strict": {
|
|
1800
|
+
str += "; SameSite=Strict";
|
|
1801
|
+
break;
|
|
1802
|
+
}
|
|
1803
|
+
case "none": {
|
|
1804
|
+
str += "; SameSite=None";
|
|
1805
|
+
break;
|
|
1806
|
+
}
|
|
1807
|
+
default: throw new TypeError("option sameSite is invalid");
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
if (opt.partitioned) str += "; Partitioned";
|
|
1811
|
+
return str;
|
|
1812
|
+
}
|
|
1813
|
+
function isDate(val) {
|
|
1814
|
+
return Object.prototype.toString.call(val) === "[object Date]" || val instanceof Date;
|
|
1815
|
+
}
|
|
1816
|
+
function parseSetCookie(setCookieValue, options) {
|
|
1817
|
+
const parts = (setCookieValue || "").split(";").filter((str) => typeof str === "string" && !!str.trim());
|
|
1818
|
+
const nameValuePairStr = parts.shift() || "";
|
|
1819
|
+
const parsed = _parseNameValuePair(nameValuePairStr);
|
|
1820
|
+
const name = parsed.name;
|
|
1821
|
+
let value = parsed.value;
|
|
1822
|
+
try {
|
|
1823
|
+
value = options?.decode === false ? value : (options?.decode || decodeURIComponent)(value);
|
|
1824
|
+
} catch {}
|
|
1825
|
+
const cookie = {
|
|
1826
|
+
name,
|
|
1827
|
+
value
|
|
1828
|
+
};
|
|
1829
|
+
for (const part of parts) {
|
|
1830
|
+
const sides = part.split("=");
|
|
1831
|
+
const partKey = (sides.shift() || "").trimStart().toLowerCase();
|
|
1832
|
+
const partValue = sides.join("=");
|
|
1833
|
+
switch (partKey) {
|
|
1834
|
+
case "expires": {
|
|
1835
|
+
cookie.expires = new Date(partValue);
|
|
1836
|
+
break;
|
|
1837
|
+
}
|
|
1838
|
+
case "max-age": {
|
|
1839
|
+
cookie.maxAge = Number.parseInt(partValue, 10);
|
|
1840
|
+
break;
|
|
1841
|
+
}
|
|
1842
|
+
case "secure": {
|
|
1843
|
+
cookie.secure = true;
|
|
1844
|
+
break;
|
|
1845
|
+
}
|
|
1846
|
+
case "httponly": {
|
|
1847
|
+
cookie.httpOnly = true;
|
|
1848
|
+
break;
|
|
1849
|
+
}
|
|
1850
|
+
case "samesite": {
|
|
1851
|
+
cookie.sameSite = partValue;
|
|
1852
|
+
break;
|
|
1853
|
+
}
|
|
1854
|
+
default: cookie[partKey] = partValue;
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
return cookie;
|
|
1858
|
+
}
|
|
1859
|
+
function _parseNameValuePair(nameValuePairStr) {
|
|
1860
|
+
let name = "";
|
|
1861
|
+
let value = "";
|
|
1862
|
+
const nameValueArr = nameValuePairStr.split("=");
|
|
1863
|
+
if (nameValueArr.length > 1) {
|
|
1864
|
+
name = nameValueArr.shift();
|
|
1865
|
+
value = nameValueArr.join("=");
|
|
1866
|
+
} else value = nameValuePairStr;
|
|
1867
|
+
return {
|
|
1868
|
+
name,
|
|
1869
|
+
value
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1702
1873
|
//#endregion
|
|
1703
1874
|
//#region src/utils/cookie.ts
|
|
1704
1875
|
const CHUNKED_COOKIE = "__chunked__";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "h3-nightly",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-20251021-151501-4247682",
|
|
4
4
|
"description": "Minimal H(TTP) framework built for high performance and portability.",
|
|
5
5
|
"homepage": "https://h3.dev",
|
|
6
6
|
"repository": "h3js/h3",
|
|
@@ -48,39 +48,40 @@
|
|
|
48
48
|
"h3": "link:."
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"rou3": "^0.7.7",
|
|
54
|
-
"srvx": "^0.8.15"
|
|
51
|
+
"rou3": "^0.7.8",
|
|
52
|
+
"srvx": "^0.9.1"
|
|
55
53
|
},
|
|
56
54
|
"devDependencies": {
|
|
57
55
|
"@mitata/counters": "^0.0.8",
|
|
58
56
|
"@types/connect": "^3.4.38",
|
|
59
57
|
"@types/express": "^5.0.3",
|
|
60
|
-
"@types/node": "^24.
|
|
58
|
+
"@types/node": "^24.9.1",
|
|
61
59
|
"@types/react": "^19.2.2",
|
|
62
|
-
"@types/react-dom": "^19.2.
|
|
60
|
+
"@types/react-dom": "^19.2.2",
|
|
63
61
|
"@vitest/coverage-v8": "^3.2.4",
|
|
64
62
|
"automd": "^0.4.2",
|
|
65
63
|
"changelogen": "^0.6.2",
|
|
66
64
|
"connect": "^3.7.0",
|
|
65
|
+
"cookie-es": "^2.0.0",
|
|
67
66
|
"crossws": "^0.4.1",
|
|
68
|
-
"elysia": "^1.4.
|
|
69
|
-
"esbuild": "^0.25.
|
|
70
|
-
"eslint": "^9.
|
|
67
|
+
"elysia": "^1.4.12",
|
|
68
|
+
"esbuild": "^0.25.11",
|
|
69
|
+
"eslint": "^9.38.0",
|
|
71
70
|
"eslint-config-unjs": "^0.5.0",
|
|
72
71
|
"express": "^5.1.0",
|
|
72
|
+
"fetchdts": "^0.1.7",
|
|
73
73
|
"get-port-please": "^3.2.0",
|
|
74
|
-
"h3-nightly": "
|
|
74
|
+
"h3-nightly": "^2.0.1-20251021-150207-c090e78",
|
|
75
75
|
"h3-v1": "npm:h3@^1.15.4",
|
|
76
|
-
"hono": "^4.
|
|
76
|
+
"hono": "^4.10.1",
|
|
77
|
+
"memoirist": "^0.4.0",
|
|
77
78
|
"mitata": "^1.0.34",
|
|
78
79
|
"obuild": "^0.2.1",
|
|
79
80
|
"prettier": "^3.6.2",
|
|
80
81
|
"react": "^19.2.0",
|
|
81
82
|
"react-dom": "^19.2.0",
|
|
82
83
|
"typescript": "^5.9.3",
|
|
83
|
-
"vite": "^7.1.
|
|
84
|
+
"vite": "^7.1.11",
|
|
84
85
|
"vitest": "^3.2.4",
|
|
85
86
|
"zod": "^4.1.12"
|
|
86
87
|
},
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"optional": true
|
|
93
94
|
}
|
|
94
95
|
},
|
|
95
|
-
"packageManager": "pnpm@10.
|
|
96
|
+
"packageManager": "pnpm@10.19.0",
|
|
96
97
|
"engines": {
|
|
97
98
|
"node": ">=20.11.1"
|
|
98
99
|
}
|