fix[android]: fix bridgeless configuration to include DebuggingOverlay in react packages (#43661)

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

# Changelog: [Internal]

1. Remove `BridgelessDebugReactPackage.java`, this was added in D43407534. Technically, its the same as `DebugCorePackage.java`.
2. `ReactInstance` to add `DebugCorePackage`, so `DebuggingOverlay` view manager will be included in the bridgeless build.
3. Fix `RNTesterApplication.kt` to NOT create `MyLegacyViewManager` for every possible viewManagerName, apart from `"RNTMyNativeView"`, return null instead.

Reviewed By: cortinico

Differential Revision: D55375350

fbshipit-source-id: 1d3cb6b5ad3c0248df1def9f37c8c49b308f4473
This commit is contained in:
Ruslan Lesiutin
2024-03-28 11:06:17 -07:00
committed by Facebook GitHub Bot
parent 4841373719
commit ad9368068a
4 changed files with 18 additions and 3 deletions
@@ -29,6 +29,15 @@ public class com/facebook/react/CoreModulesPackage$$ReactModuleInfoProvider : co
public fun getReactModuleInfos ()Ljava/util/Map;
}
public class com/facebook/react/DebugCorePackage : com/facebook/react/TurboReactPackage, com/facebook/react/ViewManagerOnDemandReactPackage {
public fun <init> ()V
public fun createViewManager (Lcom/facebook/react/bridge/ReactApplicationContext;Ljava/lang/String;)Lcom/facebook/react/uimanager/ViewManager;
public fun getModule (Ljava/lang/String;Lcom/facebook/react/bridge/ReactApplicationContext;)Lcom/facebook/react/bridge/NativeModule;
public fun getReactModuleInfoProvider ()Lcom/facebook/react/module/model/ReactModuleInfoProvider;
public fun getViewManagerNames (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/Collection;
public fun getViewManagers (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List;
}
public class com/facebook/react/DebugCorePackage$$ReactModuleInfoProvider : com/facebook/react/module/model/ReactModuleInfoProvider {
public fun <init> ()V
public fun getReactModuleInfos ()Ljava/util/Map;
@@ -36,7 +36,7 @@ import javax.inject.Provider;
JSCHeapCapture.class,
})
/* package */
class DebugCorePackage extends TurboReactPackage implements ViewManagerOnDemandReactPackage {
public class DebugCorePackage extends TurboReactPackage implements ViewManagerOnDemandReactPackage {
private @Nullable Map<String, ModuleSpec> mViewManagers;
public DebugCorePackage() {}
@@ -15,6 +15,7 @@ import com.facebook.infer.annotation.ThreadConfined;
import com.facebook.infer.annotation.ThreadSafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.DebugCorePackage;
import com.facebook.react.ReactPackage;
import com.facebook.react.ViewManagerOnDemandReactPackage;
import com.facebook.react.bridge.Arguments;
@@ -176,6 +177,9 @@ final class ReactInstance {
new CoreReactPackage(
bridgelessReactContext.getDevSupportManager(),
bridgelessReactContext.getDefaultHardwareBackBtnHandler()));
if (useDevSupport) {
mReactPackages.add(new DebugCorePackage());
}
mReactPackages.addAll(mDelegate.getReactPackages());
TurboModuleManagerDelegate turboModuleManagerDelegate =
@@ -111,11 +111,13 @@ class RNTesterApplication : Application(), ReactApplication {
override fun createViewManager(
reactContext: ReactApplicationContext,
viewManagerName: String
): ViewManager<*, out ReactShadowNode<*>> =
): ViewManager<*, out ReactShadowNode<*>>? =
if (viewManagerName == "RNTMyNativeView") {
MyNativeViewManager()
} else {
} else if (viewManagerName == "RNTMyLegacyNativeView") {
MyLegacyViewManager(reactContext)
} else {
null
}
})
}