convert CoreModulesPackage to use @ReactModuleList

Reviewed By: astreet

Differential Revision: D3809512

fbshipit-source-id: 658284c642d55cf5f90e16901fdf6d4229d6b762
This commit is contained in:
Aaron Chiu
2016-09-02 19:02:38 -07:00
committed by Facebook Github Bot 6
parent 31c8e20c8e
commit 367c71241a
9 changed files with 36 additions and 10 deletions

View File

@@ -5,6 +5,8 @@ DEPS = [
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/devsupport:devsupport'),
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/modules/core:core'),
react_native_target('java/com/facebook/react/modules/debug:debug'),
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),

View File

@@ -13,6 +13,7 @@ import javax.inject.Provider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.facebook.react.bridge.JavaScriptModule;
@@ -23,6 +24,7 @@ import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.devsupport.HMRClient;
import com.facebook.react.devsupport.JSCHeapCapture;
import com.facebook.react.devsupport.JSCSamplingProfiler;
import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.core.ExceptionsManagerModule;
@@ -45,6 +47,18 @@ import com.facebook.systrace.Systrace;
* require special integration with other framework parts (e.g. with the list of packages to load
* view managers from).
*/
@ReactModuleList({
AnimationsDebugModule.class,
AndroidInfoModule.class,
DeviceEventManagerModule.class,
ExceptionsManagerModule.class,
Timing.class,
SourceCodeModule.class,
UIManagerModule.class,
DebugComponentOwnershipModule.class,
JSCHeapCapture.class,
JSCSamplingProfiler.class,
})
/* package */ class CoreModulesPackage extends LazyReactPackage {
private final ReactInstanceManager mReactInstanceManager;
@@ -62,7 +76,7 @@ import com.facebook.systrace.Systrace;
@Override
public List<ModuleSpec> getNativeModules(final ReactApplicationContext reactContext) {
List<ModuleSpec> moduleSpecList = new ArrayList();
List<ModuleSpec> moduleSpecList = new ArrayList<>();
moduleSpecList.add(
new ModuleSpec(AnimationsDebugModule.class, new Provider<NativeModule>() {
@Override
@@ -164,7 +178,7 @@ import com.facebook.systrace.Systrace;
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return new ArrayList<>(0);
return Collections.emptyList();
}
private UIManagerModule createUIManager(ReactApplicationContext reactContext) {

View File

@@ -15,6 +15,7 @@ android_library(
react_native_target('java/com/facebook/react/bridge:bridge'),
react_native_target('java/com/facebook/react/common/network:network'),
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/modules/debug:debug'),
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),
react_native_target('res:devsupport'),

View File

@@ -20,7 +20,9 @@ import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = "JSCHeapCapture")
public class JSCHeapCapture extends ReactContextBaseJavaModule {
public interface HeapCapture extends JavaScriptModule {
void captureHeap(String path);

View File

@@ -11,7 +11,6 @@ package com.facebook.react.devsupport;
import javax.annotation.Nullable;
import java.io.File;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -20,7 +19,9 @@ import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = "JSCSamplingProfiler")
public class JSCSamplingProfiler extends ReactContextBaseJavaModule {
public interface SamplingProfiler extends JavaScriptModule {
void poke(int token);

View File

@@ -139,7 +139,8 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
TypeElement typeElement = mElements.getTypeElement(nativeModule);
ReactModule reactModule = typeElement.getAnnotation(ReactModule.class);
if (reactModule == null) {
throw new ReactModuleSpecException(keyString + " not found.");
throw new ReactModuleSpecException(keyString + " not found by ReactModuleSpecProcessor. " +
"Did you forget to add the @ReactModule annotation the the native module?");
}
String valueString = new StringBuilder()
.append("new ReactModuleInfo(")

View File

@@ -18,6 +18,7 @@ android_library(
react_native_target('java/com/facebook/react/animation:animation'),
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/modules/i18nmanager:i18nmanager'),
react_native_target('java/com/facebook/react/touch:touch'),
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),

View File

@@ -27,6 +27,7 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace;
@@ -37,12 +38,12 @@ import com.facebook.systrace.SystraceMessage;
*
* <p>
* <h2>== Transactional Requirement ==</h2>
* A requirement of this class is to make sure that transactional UI updates occur all at once, meaning
* that no intermediate state is ever rendered to the screen. For example, if a JS application
* update changes the background of View A to blue and the width of View B to 100, both need to
* appear at once. Practically, this means that all UI update code related to a single transaction
* must be executed as a single code block on the UI thread. Executing as multiple code blocks
* could allow the platform UI system to interrupt and render a partial UI state.
* A requirement of this class is to make sure that transactional UI updates occur all at once,
* meaning that no intermediate state is ever rendered to the screen. For example, if a JS
* application update changes the background of View A to blue and the width of View B to 100, both
* need to appear at once. Practically, this means that all UI update code related to a single
* transaction must be executed as a single code block on the UI thread. Executing as multiple code
* blocks could allow the platform UI system to interrupt and render a partial UI state.
* </p>
*
* <p>To facilitate this, this module enqueues operations that are then applied to native view
@@ -61,6 +62,7 @@ import com.facebook.systrace.SystraceMessage;
* consider implementing a pool
* TODO(5483063): Don't dispatch the view hierarchy at the end of a batch if no UI changes occurred
*/
@ReactModule(name = "RKUIManager")
public class UIManagerModule extends ReactContextBaseJavaModule implements
OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter {

View File

@@ -20,12 +20,14 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.module.annotations.ReactModule;
/**
* Native module that can asynchronously request the owners hierarchy of a react tag.
*
* Example returned owner hierarchy: ['RootView', 'Dialog', 'TitleView', 'Text']
*/
@ReactModule(name = "DebugComponentOwnershipModule")
public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule {
public interface RCTDebugComponentOwnership extends JavaScriptModule {