File tree 1 file changed +5
-17
lines changed
1 file changed +5
-17
lines changed Original file line number Diff line number Diff line change 1
1
const isStandardBrowserEnv = ( ) => {
2
2
// window is only defined when it is a browser
3
3
if ( typeof window !== 'undefined' ) {
4
- // Is the process an electron application
5
- // check if we are in electron `renderer`
6
- const electronRenderCheck =
7
- typeof navigator !== 'undefined' &&
8
- navigator . userAgent ?. toLowerCase ( ) . indexOf ( ' electron/' ) > - 1
9
- if ( electronRenderCheck && process ?. versions ) {
10
- const electronMainCheck = Object . prototype . hasOwnProperty . call (
11
- process . versions ,
12
- 'electron' ,
13
- )
14
- // Both electron checks are only true if the following webPreferences are set in the main electron BrowserWindow()
15
- // webPreferences: {
16
- // sandbox: false,
17
- // nodeIntegration: true
18
- // contextIsolation: false
19
- // }
20
- return ! electronMainCheck
4
+ if ( typeof process !== 'undefined' ) {
5
+ if ( process . type === 'renderer' ) return true
6
+ else if ( typeof process . electron !== 'undefined' ) return false
21
7
}
8
+
22
9
return typeof window . document !== 'undefined'
23
10
}
11
+
24
12
// return false if nothing is detected
25
13
return false
26
14
}
You can’t perform that action at this time.
0 commit comments