@@ -333,15 +333,18 @@ var __defProp = Object.defineProperty; | ||
| } | ||
| const [serverSnapshotIsUsed] = useState(!!(buildData[0][4] && getServerSnapshot)); | ||
| const [state, setState] = useState( | ||
| () => serverSnapshotIsUsed ? getServerSnapshot() : getSnapshot() | ||
| ); | ||
| const snapshot = buildData[0][4] && getServerSnapshot ? getServerSnapshot() : getSnapshot(); | ||
| const [, setVersion] = useState(0); | ||
| const latestSnapshot = useRef([snapshot, getSnapshot]); | ||
| latestSnapshot.current = [snapshot, getSnapshot]; | ||
| const unsubscribeRef = useRef(null); | ||
| useEffect(() => { | ||
| if (serverSnapshotIsUsed) { | ||
| setState(getSnapshot()); | ||
| const update2 = () => setVersion((version) => version + 1); | ||
| unsubscribeRef.current?.(); | ||
| unsubscribeRef.current = subscribe(update2); | ||
| const [snapshot2, getSnapshot2] = latestSnapshot.current; | ||
| if (!Object.is(snapshot2, getSnapshot2())) { | ||
| update2(); | ||
| } | ||
| return subscribe(() => { | ||
| setState(getSnapshot()); | ||
| }); | ||
| }, []); | ||
| return state; | ||
| }, [subscribe]); | ||
| useEffect(() => () => unsubscribeRef.current?.(), []); | ||
| return snapshot; | ||
| }; | ||
@@ -348,0 +351,0 @@ // Annotate the CommonJS export names for ESM import in node: |
@@ -50,2 +50,3 @@ var __defProp = Object.defineProperty; | ||
| const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/; | ||
| const relaxedCookieNameRegEx = /^[!#-:<>-[\]-~]+$/; | ||
| const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/; | ||
@@ -83,3 +84,3 @@ const trimCookieWhitespace = (value) => { | ||
| const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos)); | ||
| if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) { | ||
| if (name && name !== cookieName || !relaxedCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) { | ||
| continue; | ||
@@ -86,0 +87,0 @@ } |
+14
-11
@@ -292,15 +292,18 @@ // src/jsx/hooks/index.ts | ||
| } | ||
| const [serverSnapshotIsUsed] = useState(!!(buildData[0][4] && getServerSnapshot)); | ||
| const [state, setState] = useState( | ||
| () => serverSnapshotIsUsed ? getServerSnapshot() : getSnapshot() | ||
| ); | ||
| const snapshot = buildData[0][4] && getServerSnapshot ? getServerSnapshot() : getSnapshot(); | ||
| const [, setVersion] = useState(0); | ||
| const latestSnapshot = useRef([snapshot, getSnapshot]); | ||
| latestSnapshot.current = [snapshot, getSnapshot]; | ||
| const unsubscribeRef = useRef(null); | ||
| useEffect(() => { | ||
| if (serverSnapshotIsUsed) { | ||
| setState(getSnapshot()); | ||
| const update2 = () => setVersion((version) => version + 1); | ||
| unsubscribeRef.current?.(); | ||
| unsubscribeRef.current = subscribe(update2); | ||
| const [snapshot2, getSnapshot2] = latestSnapshot.current; | ||
| if (!Object.is(snapshot2, getSnapshot2())) { | ||
| update2(); | ||
| } | ||
| return subscribe(() => { | ||
| setState(getSnapshot()); | ||
| }); | ||
| }, []); | ||
| return state; | ||
| }, [subscribe]); | ||
| useEffect(() => () => unsubscribeRef.current?.(), []); | ||
| return snapshot; | ||
| }; | ||
@@ -307,0 +310,0 @@ export { |
@@ -26,2 +26,3 @@ // src/utils/cookie.ts | ||
| var validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/; | ||
| var relaxedCookieNameRegEx = /^[!#-:<>-[\]-~]+$/; | ||
| var validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/; | ||
@@ -59,3 +60,3 @@ var trimCookieWhitespace = (value) => { | ||
| const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos)); | ||
| if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) { | ||
| if (name && name !== cookieName || !relaxedCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) { | ||
| continue; | ||
@@ -62,0 +63,0 @@ } |
+2
-3
| { | ||
| "name": "hono", | ||
| "version": "4.12.32", | ||
| "version": "4.12.33", | ||
| "description": "Web framework built on Web Standards", | ||
@@ -670,3 +670,3 @@ "main": "dist/cjs/index.js", | ||
| "@hono/eslint-config": "^2.1.1", | ||
| "@hono/node-server": "^2.0.2", | ||
| "@hono/node-server": "^2.0.12", | ||
| "@types/jsdom": "^21.1.7", | ||
@@ -689,3 +689,2 @@ "@types/node": "^24.3.0", | ||
| "typescript": "^6.0.3", | ||
| "undici": "^6.27.0", | ||
| "vite-plugin-fastly-js-compute": "^0.4.2", | ||
@@ -692,0 +691,0 @@ "vitest": "^4.1.9", |
1357018
0.05%24
-4%37703
0.02%