UNPKG

1.41 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.isReactNativeBrowser = exports.isWebWorker = void 0;
4const isStandardBrowserEnv = () => {
5 var _a;
6 if (typeof window !== 'undefined') {
7 const electronRenderCheck = typeof navigator !== 'undefined' &&
8 ((_a = navigator.userAgent) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf(' electron/')) > -1;
9 if (electronRenderCheck && (process === null || process === void 0 ? void 0 : process.versions)) {
10 const electronMainCheck = Object.prototype.hasOwnProperty.call(process.versions, 'electron');
11 return !electronMainCheck;
12 }
13 return typeof window.document !== 'undefined';
14 }
15 return false;
16};
17const isWebWorkerEnv = () => {
18 var _a, _b;
19 return Boolean(typeof self === 'object' &&
20 ((_b = (_a = self === null || self === void 0 ? void 0 : self.constructor) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.includes('WorkerGlobalScope')));
21};
22const isReactNativeEnv = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
23const isBrowser = isStandardBrowserEnv() || isWebWorkerEnv() || isReactNativeEnv();
24exports.isWebWorker = isWebWorkerEnv();
25exports.isReactNativeBrowser = isReactNativeEnv();
26exports.default = isBrowser;
27//# sourceMappingURL=is-browser.js.map
\No newline at end of file