diff --git a/src/lib/is-browser.ts b/src/lib/is-browser.ts index cdf926a3e..c472b85af 100644 --- a/src/lib/is-browser.ts +++ b/src/lib/is-browser.ts @@ -1,26 +1,14 @@ const isStandardBrowserEnv = () => { // window is only defined when it is a browser if (typeof window !== 'undefined') { - // Is the process an electron application - // check if we are in electron `renderer` - const electronRenderCheck = - typeof navigator !== 'undefined' && - navigator.userAgent?.toLowerCase().indexOf(' electron/') > -1 - if (electronRenderCheck && process?.versions) { - const electronMainCheck = Object.prototype.hasOwnProperty.call( - process.versions, - 'electron', - ) - // Both electron checks are only true if the following webPreferences are set in the main electron BrowserWindow() - // webPreferences: { - // sandbox: false, - // nodeIntegration: true - // contextIsolation: false - // } - return !electronMainCheck + if (typeof process !== 'undefined') { + if (process.type === 'renderer') return true + else if (typeof process.electron !== 'undefined') return false } + return typeof window.document !== 'undefined' } + // return false if nothing is detected return false }