mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-14 05:37:40 +02:00
9 lines
616 B
TypeScript
9 lines
616 B
TypeScript
// Are we running inside the Electron shell? Detect it by the preload bridge, NOT by sniffing
|
|
// navigator.userAgent for "Electron": the UA token is deliberately stripped in the browser
|
|
// partition (and can be stripped app-wide) so sign-in walls stop seeing an embedded browser, which
|
|
// would make a UA-string check silently wrong. window.openswarm is exposed synchronously in preload
|
|
// before the first frontend frame, so it is a reliable structural signal (ENG-238).
|
|
export function isElectron(): boolean {
|
|
return typeof window !== 'undefined' && !!(window as unknown as { openswarm?: unknown }).openswarm;
|
|
}
|