Support more stubbed methods in BridgelessCatalystInstance (#44091)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44091

These can be stubbed easily using existing ReactHostImpl/ReactInstance API's

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D56139806

fbshipit-source-id: cefabe3aa0fb6556f8e296243ff233df07ddffee
This commit is contained in:
Pieter De Baets
2024-05-02 10:14:21 +01:00
committed by Riccardo Cipolleschi
parent 58b1f9b2d4
commit cc1c69799e
2 changed files with 21 additions and 18 deletions
@@ -92,25 +92,20 @@ public class BridgelessCatalystInstance(private val reactHost: ReactHostImpl) :
throw UnsupportedOperationException("Unimplemented method 'initialize'")
}
override fun getReactQueueConfiguration(): ReactQueueConfiguration {
throw UnsupportedOperationException("Unimplemented method 'getReactQueueConfiguration'")
}
override fun getReactQueueConfiguration(): ReactQueueConfiguration =
reactHost.reactQueueConfiguration!!
override fun <T : JavaScriptModule> getJSModule(jsInterface: Class<T>): T {
throw UnsupportedOperationException("Unimplemented method 'getJSModule'")
}
override fun <T : JavaScriptModule> getJSModule(jsInterface: Class<T>): T =
reactHost.currentReactContext?.getJSModule(jsInterface)!!
override fun <T : NativeModule> hasNativeModule(nativeModuleInterface: Class<T>): Boolean {
throw UnsupportedOperationException("Unimplemented method 'hasNativeModule'")
}
override fun <T : NativeModule> hasNativeModule(nativeModuleInterface: Class<T>): Boolean =
reactHost.hasNativeModule(nativeModuleInterface)
override fun <T : NativeModule> getNativeModule(nativeModuleInterface: Class<T>): T? {
throw UnsupportedOperationException("Unimplemented method 'getNativeModule'")
}
override fun <T : NativeModule> getNativeModule(nativeModuleInterface: Class<T>): T? =
reactHost.getNativeModule(nativeModuleInterface)
override fun getNativeModule(moduleName: String): NativeModule? {
throw UnsupportedOperationException("Unimplemented method 'getNativeModule'")
}
override fun getNativeModule(moduleName: String): NativeModule? =
reactHost.getNativeModule(moduleName)
@Deprecated(
message =
@@ -119,9 +114,7 @@ public class BridgelessCatalystInstance(private val reactHost: ReactHostImpl) :
throw UnsupportedOperationException("Unimplemented method 'getJSIModule'")
}
override fun getNativeModules(): Collection<NativeModule> {
throw UnsupportedOperationException("Unimplemented method 'getNativeModules'")
}
override fun getNativeModules(): Collection<NativeModule> = reactHost.getNativeModules()
override fun extendNativeModules(modules: NativeModuleRegistry) {
throw UnsupportedOperationException("Unimplemented method 'extendNativeModules'")
@@ -592,6 +592,16 @@ public class ReactHostImpl implements ReactHost {
return null;
}
/* package */
@Nullable
NativeModule getNativeModule(String nativeModuleName) {
final ReactInstance reactInstance = mReactInstanceTaskRef.get().getResult();
if (reactInstance != null) {
return reactInstance.getNativeModule(nativeModuleName);
}
return null;
}
/* package */
@Nullable
RuntimeExecutor getRuntimeExecutor() {