1import NativeModulesProxy from './NativeModulesProxy';
2/**
3 * Imports the native module registered with given name. In the first place it tries to load
4 * the module installed through the JSI host object and then falls back to the bridge proxy module.
5 * Notice that the modules loaded from the proxy may not support some features like synchronous functions.
6 *
7 * @param moduleName Name of the requested native module.
8 * @returns Object representing the native module.
9 * @throws Error when there is no native module with given name.
10 */
11export function requireNativeModule(moduleName) {
12    const nativeModule = requireOptionalNativeModule(moduleName);
13    if (!nativeModule) {
14        throw new Error(`Cannot find native module '${moduleName}'`);
15    }
16    return nativeModule;
17}
18/**
19 * Imports the native module registered with the given name. The same as `requireNativeModule`,
20 * but returns `null` when the module cannot be found instead of throwing an error.
21 *
22 * @param moduleName Name of the requested native module.
23 * @returns Object representing the native module or `null` when it cannot be found.
24 */
25export function requireOptionalNativeModule(moduleName) {
26    return (globalThis.expo?.modules?.[moduleName] ??
27        globalThis.ExpoModules?.[moduleName] ??
28        NativeModulesProxy[moduleName] ??
29        null);
30}
31//# sourceMappingURL=requireNativeModule.js.map