You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
18 KiB

{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nvar _constants$platform;\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nimport { CodedError, NativeModulesProxy } from 'expo-modules-core';\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport NativeModules from \"react-native-web/dist/exports/NativeModules\";\nimport { AppOwnership, ExecutionEnvironment, UserInterfaceIdiom } from \"./Constants.types\";\nimport ExponentConstants from \"./ExponentConstants\";\nexport { AppOwnership, ExecutionEnvironment, UserInterfaceIdiom };\nif (!ExponentConstants) {\n console.warn(\"No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?\");\n}\nvar rawManifest = null;\nif (NativeModulesProxy.ExpoUpdates) {\n var updatesManifest;\n if (NativeModulesProxy.ExpoUpdates.manifest) {\n updatesManifest = NativeModulesProxy.ExpoUpdates.manifest;\n } else if (NativeModulesProxy.ExpoUpdates.manifestString) {\n updatesManifest = JSON.parse(NativeModulesProxy.ExpoUpdates.manifestString);\n }\n if (updatesManifest && Object.keys(updatesManifest).length > 0) {\n rawManifest = updatesManifest;\n }\n}\nif (NativeModules.EXDevLauncher) {\n var devLauncherManifest;\n if (NativeModules.EXDevLauncher.manifestString) {\n devLauncherManifest = JSON.parse(NativeModules.EXDevLauncher.manifestString);\n }\n if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {\n rawManifest = devLauncherManifest;\n }\n}\nif (!rawManifest && ExponentConstants && ExponentConstants.manifest) {\n rawManifest = ExponentConstants.manifest;\n if (typeof rawManifest === 'string') {\n rawManifest = JSON.parse(rawManifest);\n }\n}\nvar _ref = ExponentConstants || {},\n name = _ref.name,\n appOwnership = _ref.appOwnership,\n nativeConstants = _objectWithoutProperties(_ref, [\"name\", \"appOwnership\"]);\nvar warnedAboutDeviceYearClass = false;\nvar warnedAboutIosModel = false;\nvar constants = _objectSpread(_objectSpread({}, nativeConstants), {}, {\n appOwnership: appOwnership != null ? appOwnership : null\n});\nObject.defineProperties(constants, {\n deviceYearClass: {\n get: function get() {\n if (!warnedAboutDeviceYearClass) {\n console.warn(\"Constants.deviceYearClass has been deprecated in favor of expo-device's Device.deviceYearClass property. This API will be removed in SDK 45.\");\n warnedAboutDeviceYearClass = true;\n }\n return nativeConstants.deviceYearClass;\n },\n enumerable: false\n },\n installationId: {\n get: function get() {\n return nativeConstants.installationId;\n },\n enumerable: false\n },\n __unsafeNoWarnManifest: {\n get: function get() {\n var maybeManifest = getManifest(true);\n if (!maybeManifest || !isAppManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: false\n },\n __unsafeNoWarnManifest2: {\n get: function get() {\n var maybeManifest = getManifest(true);\n if (!maybeManifest || !isManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: false\n },\n manifest: {\n get: function get() {\n var maybeManifest = getManifest();\n if (!maybeManifest || !isAppManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: true\n },\n manifest2: {\n get: function get() {\n var maybeManifest = getManifest();\n if (!maybeManifest || !isManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: true\n },\n expoConfig: {\n get: function get() {\n var maybeManifest = getManifest(true);\n if (!maybeManifest) {\n return null;\n }\n if (isManifest(maybeManifest)) {\n var _maybeManifest$extra$, _maybeManifest$extra;\n return (_maybeManifest$extra$ = (_maybeManifest$extra = maybeManifest.extra) == null ? void 0 : _maybeManifest$extra.expoClient) != null ? _maybeManifest$extra$ : null;\n } else if (isAppManifest(maybeManifest)) {\n return maybeManifest;\n }\n return null;\n },\n enumerable: true\n },\n __rawManifest_TEST: {\n get: function get() {\n return rawManifest;\n },\n set: function set(value) {\n rawManifest = value;\n },\n enumerable: false\n }\n});\nif (constants != null && (_constants$platform = constants.platform) != null && _constants$platform.ios) {\n var originalModel = nativeConstants.platform.ios.model;\n Object.defineProperty(constants.platform.ios, 'model', {\n get: function get() {\n if (!warnedAboutIosModel) {\n console.warn(\"Constants.platform.ios.model has been deprecated in favor of expo-device's Device.modelName property. This API will be removed in SDK 45.\");\n warnedAboutIosModel = true;\n }\n return originalModel;\n },\n enumerable: false\n });\n}\nfunction isAppManifest(manifest) {\n return !isManifest(manifest);\n}\nfunction isManifest(manifest) {\n return 'metadata' in manifest;\n}\nfunction getManifest() {\n var suppressWarning = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n if (!rawManifest) {\n var invalidManifestType = rawManifest === null ? 'null' : 'undefined';\n if (nativeConstants.executionEnvironment === ExecutionEnvironment.Bare && Platform.OS !== 'web') {\n if (!suppressWarning) {\n console.warn(\"Constants.manifest is \" + invalidManifestType + \" because the embedded app.config could not be read. Ensure that you have installed the expo-constants build scripts if you need to read from Constants.manifest.\");\n }\n } else if (nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient || nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone) {\n throw new CodedError('ERR_CONSTANTS_MANIFEST_UNAVAILABLE', \"Constants.manifest is \" + invalidManifestType + \", must be an object.\");\n }\n }\n return rawManifest;\n}\nexport default constants;","map":{"version":3,"sources":["../src/Constants.ts"],"names":[],"mappings":";;;;;AACA,SAAS,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AA;EACrD,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;AAC9B;AAEA,SAAS,UAAU,CAAC,QAAgC,EAAA;EAClD,OAAO,UAAU,IAAI,QAAQ;AAC/B;AAEA,SAAS,WAAW,GAAwB;EAAA,IAAvB,eAAe,uEAAG,KAAK;EAC1C,IAAI,CAAC,WAAW,EAAE;IAChB,IAAM,mBAAmB,GAAG,WAAW,KAAK,IAAI,GAAG,MAAM,GAAG,WAAW;IACvE,IACE,eAAe,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,IAAI,IAClE,QAAQ,CAAC,EAAE,KAAK,KAAK,EACrB;MACA,IAAI,CAAC,eAAe,EAAE;QACpB,OAAO,CAAC,IAAI,4BACe,mBAAmB,sKAC7C;MACF;KACF,MAAM,IACL,eAAe,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,WAAW,IACzE,eAAe,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,UAAU,EACxE;MAGA,MAAM,IAAI,UAAU,CAClB,oCAAoC,6BACX,mBAAmB,0BAC7C;IACF;EACF;EACD,OAAO,WAAW;AACpB;AAEA,eAAe,SAAsB","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { CodedError, NativeModulesProxy } from 'expo-modules-core';\nimport { Platform, NativeModules } from 'react-native';\n\nimport {\n AndroidManifest,\n AppManifest,\n AppOwnership,\n Constants,\n ExecutionEnvironment,\n IOSManifest,\n Manifest,\n NativeConstants,\n PlatformManifest,\n UserInterfaceIdiom,\n WebManifest,\n} from './Constants.types';\nimport ExponentConstants from './ExponentConstants';\n\nexport {\n AndroidManifest,\n AppOwnership,\n Constants,\n ExecutionEnvironment,\n IOSManifest,\n NativeConstants,\n PlatformManifest,\n UserInterfaceIdiom,\n WebManifest,\n};\n\nif (!ExponentConstants) {\n console.warn(\n \"No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?\"\n );\n}\n\nlet rawManifest: AppManifest | Manifest | null = null;\n// If expo-updates defines a non-empty manifest, prefer that one\nif (NativeModulesProxy.ExpoUpdates) {\n let updatesManifest;\n if (NativeModulesProxy.ExpoUpdates.manifest) {\n updatesManifest = NativeModulesProxy.ExpoUpdates.manifest;\n } else if (NativeModulesProxy.ExpoUpdates.manifestString) {\n updatesManifest = JSON.parse(NativeModulesProxy.ExpoUpdates.manifestString);\n }\n if (updatesManifest && Object.keys(updatesManifest).length > 0) {\n rawManifest = updatesManifest;\n }\n}\n\n// If dev-launcher defines a non-empty manifest, prefer that one\nif (NativeModules.EXDevLauncher) {\n let devLauncherManifest;\n if (NativeModules.EXDevLauncher.manifestString) {\n devLauncherManifest = JSON.parse(NativeModules.EXDevLauncher.manifestString);\n }\n\n if (devLauncherManifest && Object.keys(devLauncherManifest).length > 0) {\n rawManifest = devLauncherManifest;\n }\n}\n\n// Fall back to ExponentConstants.manifest if we don't have one from Updates\nif (!rawManifest && ExponentConstants && ExponentConstants.manifest) {\n rawManifest = ExponentConstants.manifest;\n // On Android we pass the manifest in JSON form so this step is necessary\n if (typeof rawManifest === 'string') {\n rawManifest = JSON.parse(rawManifest);\n }\n}\n\nconst { name, appOwnership, ...nativeConstants } = (ExponentConstants || {}) as any;\n\nlet warnedAboutDeviceYearClass = false;\nlet warnedAboutIosModel = false;\n\nconst constants: Constants = {\n ...nativeConstants,\n // Ensure this is null in bare workflow\n appOwnership: appOwnership ?? null,\n};\n\nObject.defineProperties(constants, {\n // Deprecated field\n deviceYearClass: {\n get() {\n if (!warnedAboutDeviceYearClass) {\n console.warn(\n `Constants.deviceYearClass has been deprecated in favor of expo-device's Device.deviceYearClass property. This API will be removed in SDK 45.`\n );\n warnedAboutDeviceYearClass = true;\n }\n return nativeConstants.deviceYearClass;\n },\n enumerable: false,\n },\n installationId: {\n get() {\n return nativeConstants.installationId;\n },\n enumerable: false,\n },\n /**\n * Use `manifest` property by default.\n * This property is only used for internal purposes.\n * It behaves similarly to the original one, but suppresses warning upon no manifest available.\n * `expo-asset` uses it to prevent users from seeing mentioned warning.\n */\n __unsafeNoWarnManifest: {\n get(): AppManifest | Manifest | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest || !isAppManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: false,\n },\n __unsafeNoWarnManifest2: {\n get(): Manifest | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest || !isManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: false,\n },\n manifest: {\n get(): AppManifest | null {\n const maybeManifest = getManifest();\n if (!maybeManifest || !isAppManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: true,\n },\n manifest2: {\n get(): Manifest | null {\n const maybeManifest = getManifest();\n if (!maybeManifest || !isManifest(maybeManifest)) {\n return null;\n }\n return maybeManifest;\n },\n enumerable: true,\n },\n expoConfig: {\n get(): ExpoConfig | null {\n const maybeManifest = getManifest(true);\n if (!maybeManifest) {\n return null;\n }\n\n if (isManifest(maybeManifest)) {\n return maybeManifest.extra?.expoClient ?? null;\n } else if (isAppManifest(maybeManifest)) {\n return maybeManifest;\n }\n\n return null;\n },\n enumerable: true,\n },\n __rawManifest_TEST: {\n get(): AppManifest | Manifest | null {\n return rawManifest;\n },\n set(value: AppManifest | Manifest | null) {\n rawManifest = value;\n },\n enumerable: false,\n },\n});\n\n// Add deprecation warning for `platform.ios.model`\nif (constants?.platform?.ios) {\n const originalModel = nativeConstants.platform.ios.model;\n Object.defineProperty(constants.platform.ios, 'model', {\n get() {\n if (!warnedAboutIosModel) {\n console.warn(\n `Constants.platform.ios.model has been deprecated in favor of expo-device's Device.modelName property. This API will be removed in SDK 45.`\n );\n warnedAboutIosModel = true;\n }\n return originalModel;\n },\n enumerable: false,\n });\n}\n\nfunction isAppManifest(manifest: AppManifest | Manifest): manifest is AppManifest {\n return !isManifest(manifest);\n}\n\nfunction isManifest(manifest: AppManifest | Manifest): manifest is Manifest {\n return 'metadata' in manifest;\n}\n\nfunction getManifest(suppressWarning = false): AppManifest | Manifest | null {\n if (!rawManifest) {\n const invalidManifestType = rawManifest === null ? 'null' : 'undefined';\n if (\n nativeConstants.executionEnvironment === ExecutionEnvironment.Bare &&\n Platform.OS !== 'web'\n ) {\n if (!suppressWarning) {\n console.warn(\n `Constants.manifest is ${invalidManifestType} because the embedded app.config could not be read. Ensure that you have installed the expo-constants build scripts if you need to read from Constants.manifest.`\n );\n }\n } else if (\n nativeConstants.executionEnvironment === ExecutionEnvironment.StoreClient ||\n nativeConstants.executionEnvironment === ExecutionEnvironment.Standalone\n ) {\n // If we somehow get here, this is a truly exceptional state to be in.\n // Constants.manifest should *always* be defined in those contexts.\n throw new CodedError(\n 'ERR_CONSTANTS_MANIFEST_UNAVAILABLE',\n `Constants.manifest is ${invalidManifestType}, must be an object.`\n );\n }\n }\n return rawManifest;\n}\n\nexport default constants as Constants;\n"],"sourceRoot":""},"metadata":{},"sourceType":"module"}