// Runtime wrapper for react-native-ble-plx to avoid Metro resolving the native // module at bundle-time in workspaces where the example app doesn't list it. // It attempts to require the real module at runtime; if not found, it provides // a minimal stub that throws informative errors when used. type AnyClass = any let BleManager: AnyClass let isAvailable = true try { // Use require to delay resolution until runtime // eslint-disable-next-line @typescript-eslint/no-var-requires const rnBle = require("react-native-ble-plx") BleManager = rnBle.BleManager ?? rnBle.default?.BleManager ?? rnBle isAvailable = true } catch (e) { // Do not warn at import time. Provide a minimal stub and mark as unavailable. isAvailable = false BleManager = class { constructor() {} startDeviceScan() { // no-op } stopDeviceScan() {} async connectToDevice(_id: string) { throw new Error("react-native-ble-plx is not installed") } async cancelDeviceConnection(_id: string) { return } async devices(_ids: string[]) { return [] } } } export { BleManager, isAvailable }