UNPKG

@react-native-module/utility

Version:
36 lines (32 loc) 1.21 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const PlatformType = (function () { const isReactNative = globalThis?.navigator?.product === 'ReactNative'; if (isReactNative) { try { // check if exists (or throw error) // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unused-vars const reactNative = require('react-native'); const usingHermes = typeof HermesInternal === 'object' && HermesInternal !== null; if (usingHermes) return 'Hermes'; return 'JavaScriptCore'; } catch (error) { // do nothing } } if (typeof globalThis.document !== 'undefined') { return 'Browser'; } return 'NodeJs'; })(); const isRunningOnNativeMobile = PlatformType === 'JavaScriptCore' || PlatformType === 'Hermes'; const isRunningOnBrowser = PlatformType === 'Browser'; const Environment = isRunningOnNativeMobile ? 'NativeMobile' : isRunningOnBrowser ? 'Browser' : 'NodeJs'; exports.Environment = Environment; exports.PlatformType = PlatformType;