// Helper file to import native PortalMobileMpc Module // Handles both TurboModule (New Architecture) and legacy NativeModules (Old Architecture) // Also provides helpful error messages for linking issues import { NativeModules, Platform, TurboModuleRegistry } from 'react-native' const LINKING_ERROR = "The package '@portal-hq/core' doesn't seem to be linked. Make sure: \n\n" + Platform.select({ ios: "- You have run 'pod install'\n", default: '', }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n' const getNewProxy = () => new Proxy( {}, { get() { throw new Error(LINKING_ERROR) }, }, ) const createNativeModule = () => { try { // Try to get the TurboModule first (New Architecture) return require('../NativePortalMobileMpc').default // eslint-disable-line @typescript-eslint/no-var-requires } catch { // Fall back to legacy module (Old Architecture) const nativeModule = NativeModules.PortalMobileMpc if (!nativeModule) { return getNewProxy() } return nativeModule } } const PortalMobileMpcModule = createNativeModule() // Legacy export for backward compatibility export const isTurboModuleEnabled = TurboModuleRegistry.get('PortalMobileMpc') != null export default PortalMobileMpcModule