UNPKG

1.26 kBJavaScriptView Raw
1'use strict';
2
3import { Platform } from 'react-native';
4
5// This type is necessary since some libraries tend to do a lib check
6// and this file causes type errors on `global` access.
7
8export function isJest() {
9 return !!process.env.JEST_WORKER_ID;
10}
11
12// `isChromeDebugger` also returns true in Jest environment, so `isJest()` check should always be performed first
13export function isChromeDebugger() {
14 return (!global.nativeCallSyncHook || !!global.__REMOTEDEV__) && !global.RN$Bridgeless;
15}
16export function isWeb() {
17 return Platform.OS === 'web';
18}
19export function isAndroid() {
20 return Platform.OS === 'android';
21}
22function isWindows() {
23 return Platform.OS === 'windows';
24}
25export function shouldBeUseWeb() {
26 return isJest() || isChromeDebugger() || isWeb() || isWindows();
27}
28export function isFabric() {
29 return !!global._IS_FABRIC;
30}
31export function isWindowAvailable() {
32 // the window object is unavailable when building the server portion of a site that uses SSG
33 // this function shouldn't be used to conditionally render components
34 // https://www.joshwcomeau.com/react/the-perils-of-rehydration/
35 // @ts-ignore Fallback if `window` is undefined.
36 return typeof window !== 'undefined';
37}
38//# sourceMappingURL=PlatformChecker.js.map
\No newline at end of file