h3-nightly 2.0.1-rc.2 → 3.0.0-20251021-175148-5911ecb

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.
Files changed (3) hide show
  1. package/dist/h3.d.mts +1 -1
  2. package/dist/h3.mjs +191 -6
  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) {
@@ -361,8 +360,22 @@ function mergeHeaders$1(base, overrides, target = new Headers(base)) {
361
360
  else target.set(name, value);
362
361
  return target;
363
362
  }
364
- const emptyHeaders = /* @__PURE__ */ new Headers({ "content-length": "0" });
365
- const jsonHeaders = /* @__PURE__ */ new Headers({ "content-type": "application/json;charset=UTF-8" });
363
+ const ERROR_FROZEN = () => {
364
+ throw new Error("Headers are frozen");
365
+ };
366
+ var FrozenHeaders = class extends Headers {
367
+ set() {
368
+ ERROR_FROZEN();
369
+ }
370
+ append() {
371
+ ERROR_FROZEN();
372
+ }
373
+ delete() {
374
+ ERROR_FROZEN();
375
+ }
376
+ };
377
+ const emptyHeaders = /* @__PURE__ */ new FrozenHeaders({ "content-length": "0" });
378
+ const jsonHeaders = /* @__PURE__ */ new FrozenHeaders({ "content-type": "application/json;charset=UTF-8" });
366
379
  function prepareResponseBody(val, event, config) {
367
380
  if (val === null || val === void 0) return {
368
381
  body: "",
@@ -412,7 +425,7 @@ function errorResponse(error, debug) {
412
425
  }, void 0, debug ? 2 : void 0), {
413
426
  status: error.status,
414
427
  statusText: error.statusText,
415
- headers: error.headers ? mergeHeaders$1(jsonHeaders, error.headers) : jsonHeaders
428
+ headers: error.headers ? mergeHeaders$1(jsonHeaders, error.headers) : new Headers(jsonHeaders)
416
429
  });
417
430
  }
418
431
 
@@ -1567,10 +1580,10 @@ async function proxy(event, target, opts = {}) {
1567
1580
  if (key === "content-encoding") continue;
1568
1581
  if (key === "content-length") continue;
1569
1582
  if (key === "set-cookie") {
1570
- cookies.push(...splitSetCookieString(value));
1583
+ cookies.push(value);
1571
1584
  continue;
1572
1585
  }
1573
- headers.set(key, value);
1586
+ headers.append(key, value);
1574
1587
  }
1575
1588
  if (cookies.length > 0) {
1576
1589
  const _cookies = cookies.map((cookie) => {
@@ -1699,6 +1712,178 @@ async function readValidatedBody(event, validate) {
1699
1712
  return validateData(_body, validate);
1700
1713
  }
1701
1714
 
1715
+ //#endregion
1716
+ //#region node_modules/.pnpm/cookie-es@2.0.0/node_modules/cookie-es/dist/index.mjs
1717
+ function parse(str, options) {
1718
+ if (typeof str !== "string") throw new TypeError("argument str must be a string");
1719
+ const obj = {};
1720
+ const opt = options || {};
1721
+ const dec = opt.decode || decode;
1722
+ let index = 0;
1723
+ while (index < str.length) {
1724
+ const eqIdx = str.indexOf("=", index);
1725
+ if (eqIdx === -1) break;
1726
+ let endIdx = str.indexOf(";", index);
1727
+ if (endIdx === -1) endIdx = str.length;
1728
+ else if (endIdx < eqIdx) {
1729
+ index = str.lastIndexOf(";", eqIdx - 1) + 1;
1730
+ continue;
1731
+ }
1732
+ const key = str.slice(index, eqIdx).trim();
1733
+ if (opt?.filter && !opt?.filter(key)) {
1734
+ index = endIdx + 1;
1735
+ continue;
1736
+ }
1737
+ if (void 0 === obj[key]) {
1738
+ let val = str.slice(eqIdx + 1, endIdx).trim();
1739
+ if (val.codePointAt(0) === 34) val = val.slice(1, -1);
1740
+ obj[key] = tryDecode(val, dec);
1741
+ }
1742
+ index = endIdx + 1;
1743
+ }
1744
+ return obj;
1745
+ }
1746
+ function decode(str) {
1747
+ return str.includes("%") ? decodeURIComponent(str) : str;
1748
+ }
1749
+ function tryDecode(str, decode2) {
1750
+ try {
1751
+ return decode2(str);
1752
+ } catch {
1753
+ return str;
1754
+ }
1755
+ }
1756
+ const fieldContentRegExp = /^[\u0009\u0020-\u007E\u0080-\u00FF]+$/;
1757
+ function serialize(name, value, options) {
1758
+ const opt = options || {};
1759
+ const enc = opt.encode || encodeURIComponent;
1760
+ if (typeof enc !== "function") throw new TypeError("option encode is invalid");
1761
+ if (!fieldContentRegExp.test(name)) throw new TypeError("argument name is invalid");
1762
+ const encodedValue = enc(value);
1763
+ if (encodedValue && !fieldContentRegExp.test(encodedValue)) throw new TypeError("argument val is invalid");
1764
+ let str = name + "=" + encodedValue;
1765
+ if (void 0 !== opt.maxAge && opt.maxAge !== null) {
1766
+ const maxAge = opt.maxAge - 0;
1767
+ if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) throw new TypeError("option maxAge is invalid");
1768
+ str += "; Max-Age=" + Math.floor(maxAge);
1769
+ }
1770
+ if (opt.domain) {
1771
+ if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid");
1772
+ str += "; Domain=" + opt.domain;
1773
+ }
1774
+ if (opt.path) {
1775
+ if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid");
1776
+ str += "; Path=" + opt.path;
1777
+ }
1778
+ if (opt.expires) {
1779
+ if (!isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) throw new TypeError("option expires is invalid");
1780
+ str += "; Expires=" + opt.expires.toUTCString();
1781
+ }
1782
+ if (opt.httpOnly) str += "; HttpOnly";
1783
+ if (opt.secure) str += "; Secure";
1784
+ if (opt.priority) {
1785
+ const priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
1786
+ switch (priority) {
1787
+ case "low": {
1788
+ str += "; Priority=Low";
1789
+ break;
1790
+ }
1791
+ case "medium": {
1792
+ str += "; Priority=Medium";
1793
+ break;
1794
+ }
1795
+ case "high": {
1796
+ str += "; Priority=High";
1797
+ break;
1798
+ }
1799
+ default: throw new TypeError("option priority is invalid");
1800
+ }
1801
+ }
1802
+ if (opt.sameSite) {
1803
+ const sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
1804
+ switch (sameSite) {
1805
+ case true: {
1806
+ str += "; SameSite=Strict";
1807
+ break;
1808
+ }
1809
+ case "lax": {
1810
+ str += "; SameSite=Lax";
1811
+ break;
1812
+ }
1813
+ case "strict": {
1814
+ str += "; SameSite=Strict";
1815
+ break;
1816
+ }
1817
+ case "none": {
1818
+ str += "; SameSite=None";
1819
+ break;
1820
+ }
1821
+ default: throw new TypeError("option sameSite is invalid");
1822
+ }
1823
+ }
1824
+ if (opt.partitioned) str += "; Partitioned";
1825
+ return str;
1826
+ }
1827
+ function isDate(val) {
1828
+ return Object.prototype.toString.call(val) === "[object Date]" || val instanceof Date;
1829
+ }
1830
+ function parseSetCookie(setCookieValue, options) {
1831
+ const parts = (setCookieValue || "").split(";").filter((str) => typeof str === "string" && !!str.trim());
1832
+ const nameValuePairStr = parts.shift() || "";
1833
+ const parsed = _parseNameValuePair(nameValuePairStr);
1834
+ const name = parsed.name;
1835
+ let value = parsed.value;
1836
+ try {
1837
+ value = options?.decode === false ? value : (options?.decode || decodeURIComponent)(value);
1838
+ } catch {}
1839
+ const cookie = {
1840
+ name,
1841
+ value
1842
+ };
1843
+ for (const part of parts) {
1844
+ const sides = part.split("=");
1845
+ const partKey = (sides.shift() || "").trimStart().toLowerCase();
1846
+ const partValue = sides.join("=");
1847
+ switch (partKey) {
1848
+ case "expires": {
1849
+ cookie.expires = new Date(partValue);
1850
+ break;
1851
+ }
1852
+ case "max-age": {
1853
+ cookie.maxAge = Number.parseInt(partValue, 10);
1854
+ break;
1855
+ }
1856
+ case "secure": {
1857
+ cookie.secure = true;
1858
+ break;
1859
+ }
1860
+ case "httponly": {
1861
+ cookie.httpOnly = true;
1862
+ break;
1863
+ }
1864
+ case "samesite": {
1865
+ cookie.sameSite = partValue;
1866
+ break;
1867
+ }
1868
+ default: cookie[partKey] = partValue;
1869
+ }
1870
+ }
1871
+ return cookie;
1872
+ }
1873
+ function _parseNameValuePair(nameValuePairStr) {
1874
+ let name = "";
1875
+ let value = "";
1876
+ const nameValueArr = nameValuePairStr.split("=");
1877
+ if (nameValueArr.length > 1) {
1878
+ name = nameValueArr.shift();
1879
+ value = nameValueArr.join("=");
1880
+ } else value = nameValuePairStr;
1881
+ return {
1882
+ name,
1883
+ value
1884
+ };
1885
+ }
1886
+
1702
1887
  //#endregion
1703
1888
  //#region src/utils/cookie.ts
1704
1889
  const CHUNKED_COOKIE = "__chunked__";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h3-nightly",
3
- "version": "2.0.1-rc.2",
3
+ "version": "3.0.0-20251021-175148-5911ecb",
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
- "cookie-es": "^2.0.0",
52
- "fetchdts": "^0.1.7",
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.7.0",
58
+ "@types/node": "^24.9.1",
61
59
  "@types/react": "^19.2.2",
62
- "@types/react-dom": "^19.2.1",
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.9",
69
- "esbuild": "^0.25.10",
70
- "eslint": "^9.37.0",
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": "latest",
74
+ "h3-nightly": "^2.0.1-20251021-150207-c090e78",
75
75
  "h3-v1": "npm:h3@^1.15.4",
76
- "hono": "^4.9.10",
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.9",
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.17.1",
96
+ "packageManager": "pnpm@10.19.0",
96
97
  "engines": {
97
98
  "node": ">=20.11.1"
98
99
  }