mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Turn FBMainReactPackage into a TurboReactPackage
Summary: `ReactTurboModuleManagerDelegate` only understands `TurboReactPackage`s. So, we need to convert `FBMainReactPackage` and all its dependent packages into `TurboReactPackage`. Reviewed By: fkgozali Differential Revision: D15711546 fbshipit-source-id: df626d542a6477b116c867299219156423c6364a
This commit is contained in:
committed by
Facebook Github Bot
parent
e5c96a85fc
commit
9c76e14b07
+3
-1
@@ -19,11 +19,13 @@ import com.facebook.react.bridge.ReactMethod;
|
||||
*/
|
||||
public class StringRecordingModule extends BaseJavaModule {
|
||||
|
||||
public static final String NAME = "Recording";
|
||||
|
||||
private final List<String> mCalls = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Recording";
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
|
||||
@@ -22,6 +22,8 @@ rn_android_library(
|
||||
react_native_target("java/com/facebook/react:react"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
react_native_target("java/com/facebook/react/module/annotations:annotations"),
|
||||
react_native_target("java/com/facebook/react/module/model:model"),
|
||||
react_native_target("java/com/facebook/react/shell:shell"),
|
||||
react_native_target("java/com/facebook/react/uimanager:uimanager"),
|
||||
]) + ([
|
||||
|
||||
+46
-12
@@ -26,11 +26,16 @@ import com.facebook.react.testing.rule.ReactNativeTestRule;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.inject.Provider;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import com.facebook.react.module.model.ReactModuleInfo;
|
||||
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ReactRootViewTest {
|
||||
@@ -42,18 +47,47 @@ public class ReactRootViewTest {
|
||||
final StringRecordingModule mRecordingModule = new StringRecordingModule();
|
||||
final ReactPackage mReactPackage = new MainReactPackage() {
|
||||
@Override
|
||||
public List<ModuleSpec> getNativeModules(ReactApplicationContext context) {
|
||||
List<ModuleSpec> modules = new ArrayList<>(super.getNativeModules(context));
|
||||
modules.add(
|
||||
ModuleSpec.nativeModuleSpec(
|
||||
StringRecordingModule.class,
|
||||
new Provider<NativeModule>() {
|
||||
@Override
|
||||
public NativeModule get() {
|
||||
return mRecordingModule;
|
||||
}
|
||||
}));
|
||||
return modules;
|
||||
public NativeModule getModule(String name, ReactApplicationContext context) {
|
||||
if (name.equals(StringRecordingModule.NAME)) {
|
||||
return mRecordingModule;
|
||||
}
|
||||
|
||||
return super.getModule(name, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
||||
final ReactModuleInfoProvider provider = super.getReactModuleInfoProvider();
|
||||
|
||||
return new ReactModuleInfoProvider() {
|
||||
private Map<String, ReactModuleInfo> mModuleInfos = null;
|
||||
|
||||
@Override
|
||||
public Map<String, ReactModuleInfo> getReactModuleInfos() {
|
||||
if (mModuleInfos != null) {
|
||||
return mModuleInfos;
|
||||
}
|
||||
|
||||
mModuleInfos = new HashMap<>();
|
||||
mModuleInfos.putAll(provider.getReactModuleInfos());
|
||||
|
||||
Class<? extends NativeModule> moduleClass = StringRecordingModule.class;
|
||||
ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class);
|
||||
|
||||
mModuleInfos.put(
|
||||
reactModule.name(),
|
||||
new ReactModuleInfo(
|
||||
reactModule.name(),
|
||||
moduleClass.getName(),
|
||||
reactModule.canOverrideExistingModule(),
|
||||
reactModule.needsEagerInit(),
|
||||
reactModule.hasConstants(),
|
||||
reactModule.isCxxModule(),
|
||||
false));
|
||||
|
||||
return mModuleInfos;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user