1 | 'use strict';
|
2 | import { Platform } from 'react-native';
|
3 |
|
4 |
|
5 |
|
6 | type localGlobal = typeof global & Record<string, unknown>;
|
7 |
|
8 | export function isJest(): boolean {
|
9 | return !!process.env.JEST_WORKER_ID;
|
10 | }
|
11 |
|
12 |
|
13 | export function isChromeDebugger(): boolean {
|
14 | return (
|
15 | (!(global as localGlobal).nativeCallSyncHook ||
|
16 | !!(global as localGlobal).__REMOTEDEV__) &&
|
17 | !(global as localGlobal).RN$Bridgeless
|
18 | );
|
19 | }
|
20 |
|
21 | export function isWeb(): boolean {
|
22 | return Platform.OS === 'web';
|
23 | }
|
24 |
|
25 | export function isAndroid(): boolean {
|
26 | return Platform.OS === 'android';
|
27 | }
|
28 |
|
29 | function isWindows(): boolean {
|
30 | return Platform.OS === 'windows';
|
31 | }
|
32 |
|
33 | export function shouldBeUseWeb() {
|
34 | return isJest() || isChromeDebugger() || isWeb() || isWindows();
|
35 | }
|
36 |
|
37 | export function isFabric() {
|
38 | return !!(global as localGlobal)._IS_FABRIC;
|
39 | }
|
40 |
|
41 | export function isWindowAvailable() {
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | return typeof window !== 'undefined';
|
47 | }
|
48 |
|
49 | export function isReducedMotion() {
|
50 | return isWeb()
|
51 | ? isWindowAvailable()
|
52 | ?
|
53 | !window.matchMedia('(prefers-reduced-motion: no-preference)').matches
|
54 | : false
|
55 | : !!(global as localGlobal)._REANIMATED_IS_REDUCED_MOTION;
|
56 | }
|