UNPKG

react-native-test-app

Version:

react-native-test-app provides a test app for all supported platforms as a package

75 lines (64 loc) 1.83 kB
// @ts-check /** @import { JSONObject } from "../scripts/types.ts"; */ import { v } from "../scripts/helpers.js"; /** * @param {number} reactNativeVersion */ function isNewArchExclusive(reactNativeVersion) { return reactNativeVersion >= v(0, 82, 0); } /** * @param {number} reactNativeVersion * @param {JSONObject} options * @returns {boolean} */ export function isNewArchEnabled(reactNativeVersion, options) { if (isNewArchExclusive(reactNativeVersion)) { return true; } const newArchEnabled = process.env["RCT_NEW_ARCH_ENABLED"]; if (typeof newArchEnabled === "string") { return newArchEnabled !== "0"; } if ("newArchEnabled" in options) { return Boolean(options["newArchEnabled"]); } if ("fabricEnabled" in options) { return Boolean(options["fabricEnabled"]); } // TODO: https://github.com/microsoft/react-native-test-app/issues/2321 return false; } /** * @param {number} reactNativeVersion * @param {JSONObject} options * @returns {boolean} */ export function isBridgelessEnabled(reactNativeVersion, options) { if (isNewArchExclusive(reactNativeVersion)) { return true; } if (isNewArchEnabled(reactNativeVersion, options)) { if (reactNativeVersion >= v(0, 74, 0)) { return options["bridgelessEnabled"] !== false; } if (reactNativeVersion >= v(0, 73, 0)) { return Boolean(options["bridgelessEnabled"]); } } return false; } /** * @param {number} reactNativeVersion * @param {JSONObject} options * @returns {boolean | "from-source"} */ export function isHermesEnabled(reactNativeVersion, options) { if (reactNativeVersion < v(0, 80, 0)) { const useHermes = process.env["USE_HERMES"]; return typeof useHermes === "string" ? useHermes === "1" : options["hermesEnabled"] === true; } return true; }