isBrowser.js 815 B

1234567891011121314151617181920212223
  1. Object.defineProperty(exports, '__esModule', { value: true });
  2. const node = require('./node.js');
  3. const worldwide = require('./worldwide.js');
  4. /**
  5. * Returns true if we are in the browser.
  6. */
  7. function isBrowser() {
  8. // eslint-disable-next-line no-restricted-globals
  9. return typeof window !== 'undefined' && (!node.isNodeEnv() || isElectronNodeRenderer());
  10. }
  11. // Electron renderers with nodeIntegration enabled are detected as Node.js so we specifically test for them
  12. function isElectronNodeRenderer() {
  13. return (
  14. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
  15. (worldwide.GLOBAL_OBJ ).process !== undefined && ((worldwide.GLOBAL_OBJ ).process ).type === 'renderer'
  16. );
  17. }
  18. exports.isBrowser = isBrowser;
  19. //# sourceMappingURL=isBrowser.js.map