-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix[android]: fix bridgeless configuration to include DebuggingOverla…
…y in react packages (#43661) Summary: Pull Request resolved: #43661 # Changelog: [Internal] 1. Move `BridgelessDebugReactPackage.java` to core, this was added in D43407534. 2. `ReactInstanceJava` to add `BridgelessDebugReactPackage`, 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. Differential Revision: D55375350
- Loading branch information
1 parent
575507d
commit bcfc627
Showing
4 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...ve/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessDebugReactPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.runtime; | ||
|
||
import androidx.annotation.Nullable; | ||
import com.facebook.infer.annotation.Nullsafe; | ||
import com.facebook.react.TurboReactPackage; | ||
import com.facebook.react.ViewManagerOnDemandReactPackage; | ||
import com.facebook.react.bridge.ModuleSpec; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.module.annotations.ReactModuleList; | ||
import com.facebook.react.module.model.ReactModuleInfoProvider; | ||
import com.facebook.react.uimanager.UIManagerModule; | ||
import com.facebook.react.uimanager.ViewManager; | ||
import com.facebook.react.views.debuggingoverlay.DebuggingOverlayManager; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.inject.Provider; | ||
|
||
@Nullsafe(Nullsafe.Mode.LOCAL) | ||
@ReactModuleList(nativeModules = {}) | ||
public class BridgelessDebugReactPackage extends TurboReactPackage | ||
implements ViewManagerOnDemandReactPackage { | ||
private @Nullable Map<String, ModuleSpec> mViewManagers; | ||
|
||
public BridgelessDebugReactPackage() {} | ||
|
||
@Override | ||
public @Nullable NativeModule getModule(String name, ReactApplicationContext reactContext) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public ReactModuleInfoProvider getReactModuleInfoProvider() { | ||
return new BridgelessDebugReactPackage$$ReactModuleInfoProvider(); | ||
} | ||
|
||
private static void appendMap( | ||
Map<String, ModuleSpec> map, String name, Provider<? extends NativeModule> provider) { | ||
map.put(name, ModuleSpec.viewManagerSpec(provider)); | ||
} | ||
|
||
/** | ||
* @return a map of view managers that should be registered with {@link UIManagerModule} | ||
*/ | ||
private Map<String, ModuleSpec> getViewManagersMap() { | ||
if (mViewManagers == null) { | ||
Map<String, ModuleSpec> viewManagers = new HashMap<>(); | ||
appendMap(viewManagers, DebuggingOverlayManager.REACT_CLASS, DebuggingOverlayManager::new); | ||
|
||
mViewManagers = viewManagers; | ||
} | ||
return mViewManagers; | ||
} | ||
|
||
@Override | ||
public List<ModuleSpec> getViewManagers(ReactApplicationContext reactContext) { | ||
return new ArrayList<>(getViewManagersMap().values()); | ||
} | ||
|
||
@Override | ||
public Collection<String> getViewManagerNames(ReactApplicationContext reactContext) { | ||
return getViewManagersMap().keySet(); | ||
} | ||
|
||
@Override | ||
public @Nullable ViewManager createViewManager( | ||
ReactApplicationContext reactContext, String viewManagerName) { | ||
ModuleSpec spec = getViewManagersMap().get(viewManagerName); | ||
return spec != null ? (ViewManager) spec.getProvider().get() : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters