Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,21 @@ export function keywordFilter(str: string, keywords: string[]): boolean {
return true;
}

// Precompute environment flags to avoid recursion when both globals exist (e.g. Electron renderer).
const hasWindow = typeof window !== "undefined";
const hasProcess = typeof process !== "undefined";
const hasElectron = hasProcess && !!(process as any).versions?.electron;

export function isBrowser(): boolean {
return typeof window !== 'undefined' && !isNode();
return hasWindow && !hasElectron;
}

export function isNode(): boolean {
return typeof process !== 'undefined' && !isBrowser();
return hasProcess && !hasElectron;
}

export function isElectron(): boolean {
return hasElectron;
}

export function apiKeys() {
Expand Down Expand Up @@ -180,4 +189,4 @@ export function join(...pathSegments: string[]): string {

if (parts[0] === "") newParts.unshift("");
return newParts.join("/") || (newParts.length ? "/" : ".");
}
}