1{"version":3,"file":"requireNativeModule.js","sourceRoot":"","sources":["../src/requireNativeModule.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAyBtD;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAmB,UAAkB;IACtE,MAAM,YAAY,GAChB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC;QAClC,MAAM,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC;QAChC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAEjC,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,UAAU,GAAG,CAAC,CAAC;KAC9D;IACD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import NativeModulesProxy from './NativeModulesProxy';\n\ntype ExpoObject = {\n modules:\n | undefined\n | {\n [key: string]: any;\n };\n};\n\ndeclare global {\n // eslint-disable-next-line no-var\n var expo: ExpoObject | undefined;\n\n /**\n * @deprecated `global.ExpoModules` is deprecated, use `global.expo.modules` instead.\n */\n // eslint-disable-next-line no-var\n var ExpoModules:\n | undefined\n | {\n [key: string]: any;\n };\n}\n\n/**\n * Imports the native module registered with given name. In the first place it tries to load\n * the module installed through the JSI host object and then falls back to the bridge proxy module.\n * Notice that the modules loaded from the proxy may not support some features like synchronous functions.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module.\n * @throws Error when there is no native module with given name.\n */\nexport function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {\n const nativeModule: ModuleType =\n global.expo?.modules?.[moduleName] ??\n global.ExpoModules?.[moduleName] ??\n NativeModulesProxy[moduleName];\n\n if (!nativeModule) {\n throw new Error(`Cannot find native module '${moduleName}'`);\n }\n return nativeModule;\n}\n"]}