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