Skip to content

Commit ee9c340

Browse files
committed
fix: use globalThis.window instead of window
1 parent 4a71385 commit ee9c340

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

packages/core/src/shared/userAgent.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ export type UserAgentProvider = () => Promise<string>;
66

77
const UA_LANG = 'lang/js';
88

9-
// Declare window for browser environment detection
10-
declare const window: { navigator?: { userAgent?: string } } | undefined;
11-
129
function isBrowser(): boolean {
13-
return window !== undefined;
10+
return globalThis.window !== undefined;
1411
}
1512

1613
function uaProduct(): string {
@@ -29,7 +26,7 @@ function uaNode(version: string | undefined) {
2926

3027
function browserUserAgent(): string {
3128
// window is guaranteed to exist when this function is called (checked by isBrowser())
32-
const userAgent = window?.navigator?.userAgent;
29+
const userAgent = globalThis.window?.navigator?.userAgent;
3330
const ua = userAgent ? Bowser.parse(userAgent) : undefined;
3431
return `${uaProduct()} ${uaOS(ua?.os.name, ua?.os.version)} ${UA_LANG}`;
3532
}

0 commit comments

Comments
 (0)