Skip to content

Commit f79e280

Browse files
Merge pull request #298 from shannonhochkins/pre-for-release
Prep for 6.0.1
2 parents 3c9fddc + bc700b1 commit f79e280

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+38314
-12202
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# 6.0.1
2+
3+
### General
4+
CHORE - Locales refreshed to the latest Home Assistant strings/hashes; locale key types updated for new tokens (e.g., any/first/last, additional device status terms).
5+
6+
### @hakit/core
7+
BUGFIX - HassConnect now guards all window access in suspend/resume and connection flows to avoid SSR/test crashes and ensure inherited connections/auth-callback cleanup stay safe (nextjs fix)
8+
IMPROVEMENT - Entity registry list derives domain titles via computeDomainTitle, improving labels/search without relying on locale strings.
9+
IMPROVEMENT - Service schema/types regenerated from the latest HA: frontend.setTheme supports optional light/dark names, scene services add apply/create/delete with transitions, media/recorder constraints refreshed.
10+
IMPROVEMENT - Humidifier entities expose target_humidity_step for finer control.
11+
12+
### @hakit/components
13+
No component code changes; version bumped to align with core 6.0.1.
14+
15+
### create-hakit
16+
Bump to 1.2.3 to consume the latest packages.
17+
118
# 6.0.0
219

320
## Migration Checklist

packages/components/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@hakit/components",
33
"type": "module",
4-
"version": "6.0.0",
4+
"version": "6.0.1",
55
"private": false,
66
"keywords": [
77
"react",
@@ -70,7 +70,7 @@
7070
"@emotion/react": ">=11.x.x",
7171
"@emotion/styled": ">=11.x",
7272
"@fullcalendar/react": ">=6.x.x",
73-
"@hakit/core": "^6.0.0",
73+
"@hakit/core": "^6.0.1",
7474
"@use-gesture/react": ">=10.x",
7575
"autolinker": ">=4.x",
7676
"fullcalendar": ">=6.x.x",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hakit/core",
3-
"version": "6.0.0",
3+
"version": "6.0.1",
44
"private": false,
55
"type": "module",
66
"keywords": [

packages/core/src/HassConnect/Provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ export function HassProvider({
255255
}, [_hash]);
256256

257257
useEffect(() => {
258-
window.addEventListener("hashchange", onHashChange);
258+
if (typeof window !== "undefined") window.addEventListener("hashchange", onHashChange);
259259
return () => {
260-
window.removeEventListener("hashchange", onHashChange);
260+
if (typeof window !== "undefined") window.removeEventListener("hashchange", onHashChange);
261261
};
262262
}, []);
263263

packages/core/src/HassConnect/handleSuspendResume.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,27 @@ export function handleSuspendResume(connection: Connection, options: HandleSuspe
9999

100100
// Wait DELAY_MS before actually closing the socket.
101101
if (debug) console.log(`[SR] Starting hidden delay of ${DELAY_MS}ms before actual suspend()`);
102-
hiddenTimeoutId = window.setTimeout(() => {
103-
hiddenTimeoutId = null;
104-
// If still hidden, suspend the connection:
105-
if (document.hidden) {
106-
if (debug) console.log("[SR] Hidden timeout elapsed → calling suspend()");
107-
suspend();
108-
} else {
109-
// User returned before timeout. Resolve immediately.
110-
if (pendingResolve) {
111-
if (debug) console.log("[SR] Hidden timeout elapsed but page is visible → resolving pendingResolve()");
112-
// potentially unreachable, but just in case!
113-
pendingResolve();
114-
}
115-
}
116-
}, DELAY_MS);
102+
hiddenTimeoutId =
103+
typeof window !== "undefined"
104+
? window.setTimeout(() => {
105+
hiddenTimeoutId = null;
106+
// If still hidden, suspend the connection:
107+
if (document.hidden) {
108+
if (debug) console.log("[SR] Hidden timeout elapsed → calling suspend()");
109+
suspend();
110+
} else {
111+
// User returned before timeout. Resolve immediately.
112+
if (pendingResolve) {
113+
if (debug) console.log("[SR] Hidden timeout elapsed but page is visible → resolving pendingResolve()");
114+
// potentially unreachable, but just in case!
115+
pendingResolve();
116+
}
117+
}
118+
}, DELAY_MS)
119+
: null;
117120

118121
// If the user focuses before DELAY_MS is up, resume immediately:
119-
window.addEventListener("focus", onVisibleOrResume, { once: true });
122+
if (typeof window !== "undefined") window.addEventListener("focus", onVisibleOrResume, { once: true });
120123
}
121124

122125
// helper when page/tab becomes visible or “resume” fires after freeze
@@ -161,7 +164,7 @@ export function handleSuspendResume(connection: Connection, options: HandleSuspe
161164
}
162165
onStatusChange?.("suspended");
163166
if (debug) console.log("[SR] suspend() called → suspending connection");
164-
window.stop();
167+
if (typeof window !== "undefined") window.stop();
165168
connection.suspend();
166169
}
167170

@@ -179,7 +182,7 @@ export function handleSuspendResume(connection: Connection, options: HandleSuspe
179182
document.removeEventListener("visibilitychange", visibilityChangeHandler, false);
180183
document.removeEventListener("freeze", suspend);
181184
document.removeEventListener("resume", resumeHandler);
182-
window.removeEventListener("focus", onVisibleOrResume);
185+
if (typeof window !== "undefined") window.removeEventListener("focus", onVisibleOrResume);
183186

184187
if (hiddenTimeoutId !== null) {
185188
if (debug) console.log("[SR] cleanup: Clearing hiddenTimeoutId");

packages/core/src/HassConnect/tryConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type ConnectionType = "auth-callback" | "user-request" | "saved-tokens" | "inher
6161

6262
function getInheritedConnection(): typeof window.hassConnection | undefined {
6363
try {
64-
return window.top?.hassConnection;
64+
return typeof window !== "undefined" ? window.top?.hassConnection : undefined;
6565
} catch (e) {
6666
console.error("Error getting inherited connection", e);
6767
return undefined;
@@ -185,7 +185,7 @@ export const tryConnection = async (hassUrl: string, hassToken?: string): Promis
185185
};
186186
} finally {
187187
// Clear url if we have a auth callback in url.
188-
if (location && location.search.includes("auth_callback=1")) {
188+
if (typeof window !== "undefined" && location && location.search.includes("auth_callback=1")) {
189189
history.replaceState(null, "", location.pathname);
190190
}
191191
}

packages/core/src/hooks/useEntity/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function useEntity<E extends EntityName, O extends UseEntityOptions = Use
7777
// if returnNullIfNotFound is true, we return null, if not we throw an error
7878
return null as unknown as UseEntityReturnType<E, O>;
7979
}
80-
return { ...formatted, service, history } as UseEntityReturnType<E, O>;
80+
return { ...formatted, service, history } as unknown as UseEntityReturnType<E, O>;
8181
}, [formatted, service, history]);
8282

8383
return entityWithHelpers;

0 commit comments

Comments
 (0)