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
2.5 KiB

{"ast":null,"code":"import NativeModulesProxy from \"./NativeModulesProxy\";\nexport function requireNativeModule(moduleName) {\n var _ref, _global$expo$modules$, _global$expo, _global$expo$modules, _global$ExpoModules;\n var nativeModule = (_ref = (_global$expo$modules$ = (_global$expo = global.expo) == null ? void 0 : (_global$expo$modules = _global$expo.modules) == null ? void 0 : _global$expo$modules[moduleName]) != null ? _global$expo$modules$ : (_global$ExpoModules = global.ExpoModules) == null ? void 0 : _global$ExpoModules[moduleName]) != null ? _ref : NativeModulesProxy[moduleName];\n if (!nativeModule) {\n throw new Error(\"Cannot find native module '\" + moduleName + \"'\");\n }\n return nativeModule;\n}","map":{"version":3,"sources":["../src/requireNativeModule.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB;AAkCzB,OAAM,SAAU,mBAAmB,CAAmB,UAAkB,EAAA;EAAA;EACtE,IAAM,YAAY,oDAChB,MAAM,CAAC,IAAI,6CAAX,aAAa,OAAO,qBAApB,qBAAuB,UAAU,CAAC,2DAClC,MAAM,CAAC,WAAW,qBAAlB,oBAAqB,UAAU,CAAC,mBAChC,kBAAkB,CAAC,UAAU,CAAC;EAEhC,IAAI,CAAC,YAAY,EAAE;IACjB,MAAM,IAAI,KAAK,iCAA+B,UAAU,OAAI;EAC7D;EACD,OAAO,YAAY;AACrB","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"],"sourceRoot":""},"metadata":{},"sourceType":"module"}