Skip to content

Commit

Permalink
fix[android]: fix bridgeless configuration to include DebuggingOverla…
Browse files Browse the repository at this point in the history
…y in react packages (#43661)

Summary:
Pull Request resolved: #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
  • Loading branch information
hoxyq authored and facebook-github-bot committed Mar 28, 2024
1 parent 4841373 commit ad93680
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
JSCHeapCapture.class,
})
/* package */
class DebugCorePackage extends TurboReactPackage implements ViewManagerOnDemandReactPackage {
public class DebugCorePackage extends TurboReactPackage implements ViewManagerOnDemandReactPackage {
private @Nullable Map<String, ModuleSpec> mViewManagers;

public DebugCorePackage() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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;
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
}
Expand Down

0 comments on commit ad93680

Please sign in to comment.