diff --git a/ReactAndroid/src/main/java/com/facebook/react/BridgeCorePackage.java b/ReactAndroid/src/main/java/com/facebook/react/BridgeCorePackage.java deleted file mode 100644 index 7554c223f1c49e..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/BridgeCorePackage.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package com.facebook.react; - -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.modules.core.DefaultHardwareBackBtnHandler; -import com.facebook.react.modules.core.DeviceEventManagerModule; -import com.facebook.react.modules.core.ExceptionsManagerModule; -import com.facebook.react.modules.core.HeadlessJsTaskSupportModule; -import com.facebook.react.modules.core.Timing; -import com.facebook.react.modules.debug.SourceCodeModule; -import com.facebook.react.modules.deviceinfo.DeviceInfoModule; -import com.facebook.react.modules.systeminfo.AndroidInfoModule; -import java.util.ArrayList; -import java.util.List; -import javax.inject.Provider; - -/** - * Package defining core framework modules for basic JS interop. - * It should be used for modules that are always necessary for interacting with - * JS, not for modules that provide RN specific functionality - */ -@ReactModuleList( - nativeModules = { - AndroidInfoModule.class, - DeviceEventManagerModule.class, - ExceptionsManagerModule.class, - HeadlessJsTaskSupportModule.class, - SourceCodeModule.class, - Timing.class, - DeviceInfoModule.class, - } -) -/* package */ class BridgeCorePackage extends LazyReactPackage { - - private final ReactInstanceManager mReactInstanceManager; - private final DefaultHardwareBackBtnHandler mHardwareBackBtnHandler; - - BridgeCorePackage( - ReactInstanceManager reactInstanceManager, - DefaultHardwareBackBtnHandler hardwareBackBtnHandler) { - mReactInstanceManager = reactInstanceManager; - mHardwareBackBtnHandler = hardwareBackBtnHandler; - } - - @Override - public List getNativeModules(final ReactApplicationContext reactContext) { - List moduleSpecList = new ArrayList<>(); - - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - AndroidInfoModule.class, - new Provider() { - @Override - public NativeModule get() { - return new AndroidInfoModule(); - } - })); - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - DeviceEventManagerModule.class, - new Provider() { - @Override - public NativeModule get() { - return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler); - } - })); - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - ExceptionsManagerModule.class, - new Provider() { - @Override - public NativeModule get() { - return new ExceptionsManagerModule(mReactInstanceManager.getDevSupportManager()); - } - })); - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - HeadlessJsTaskSupportModule.class, - new Provider() { - @Override - public NativeModule get() { - return new HeadlessJsTaskSupportModule(reactContext); - } - })); - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - SourceCodeModule.class, - new Provider() { - @Override - public NativeModule get() { - return new SourceCodeModule(reactContext); - } - })); - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - Timing.class, - new Provider() { - @Override - public NativeModule get() { - return new Timing(reactContext, mReactInstanceManager.getDevSupportManager()); - } - })); - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - DeviceInfoModule.class, - new Provider() { - @Override - public NativeModule get() { - return new DeviceInfoModule(reactContext); - } - })); - - return moduleSpecList; - } - - @Override - public ReactModuleInfoProvider getReactModuleInfoProvider() { - return LazyReactPackage.getReactModuleInfoProviderViaReflection(this); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java index 293ca70b58a4e0..7b0ac3253bf402 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java @@ -18,9 +18,6 @@ import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactMarker; -import com.facebook.react.common.build.ReactBuildConfig; -import com.facebook.react.devsupport.JSCHeapCapture; -import com.facebook.react.devsupport.JSCSamplingProfiler; import com.facebook.react.module.annotations.ReactModuleList; import com.facebook.react.module.model.ReactModuleInfoProvider; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; @@ -28,7 +25,6 @@ import com.facebook.react.modules.core.ExceptionsManagerModule; import com.facebook.react.modules.core.HeadlessJsTaskSupportModule; import com.facebook.react.modules.core.Timing; -import com.facebook.react.modules.debug.AnimationsDebugModule; import com.facebook.react.modules.debug.SourceCodeModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule; import com.facebook.react.modules.systeminfo.AndroidInfoModule; @@ -36,35 +32,24 @@ import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.systrace.Systrace; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import javax.annotation.Nullable; import javax.inject.Provider; + /** - * This module should be removed following the completion of an experiment into splitting this into - * three modules to allow for more light-weight instantiations of the bridge without UIManager - * The core modules are now in BridgeCorePackage - * The debug modules are now in DebugCorePackage - * The UI manager is in ReactNativeCorePackage - * - * Package defining core framework modules (e.g. UIManager). It should be used for modules that - * require special integration with other framework parts (e.g. with the list of packages to load - * view managers from). + * This is the basic module to support React Native. The debug modules are now in DebugCorePackage. */ @ReactModuleList( nativeModules = { AndroidInfoModule.class, - AnimationsDebugModule.class, DeviceEventManagerModule.class, + DeviceInfoModule.class, ExceptionsManagerModule.class, HeadlessJsTaskSupportModule.class, SourceCodeModule.class, Timing.class, UIManagerModule.class, - DeviceInfoModule.class, - // Debug only - JSCHeapCapture.class, - JSCSamplingProfiler.class, } ) /* package */ class CoreModulesPackage extends LazyReactPackage implements ReactPackageLogger { @@ -90,9 +75,7 @@ @Override public List getNativeModules(final ReactApplicationContext reactContext) { - List moduleSpecList = new ArrayList<>(); - - moduleSpecList.add( + return Arrays.asList( ModuleSpec.nativeModuleSpec( AndroidInfoModule.class, new Provider() { @@ -100,18 +83,7 @@ public List getNativeModules(final ReactApplicationContext reactCont public NativeModule get() { return new AndroidInfoModule(); } - })); - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - AnimationsDebugModule.class, - new Provider() { - @Override - public NativeModule get() { - return new AnimationsDebugModule( - reactContext, mReactInstanceManager.getDevSupportManager().getDevSettings()); - } - })); - moduleSpecList.add( + }), ModuleSpec.nativeModuleSpec( DeviceEventManagerModule.class, new Provider() { @@ -119,8 +91,7 @@ public NativeModule get() { public NativeModule get() { return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler); } - })); - moduleSpecList.add( + }), ModuleSpec.nativeModuleSpec( ExceptionsManagerModule.class, new Provider() { @@ -128,8 +99,7 @@ public NativeModule get() { public NativeModule get() { return new ExceptionsManagerModule(mReactInstanceManager.getDevSupportManager()); } - })); - moduleSpecList.add( + }), ModuleSpec.nativeModuleSpec( HeadlessJsTaskSupportModule.class, new Provider() { @@ -137,8 +107,7 @@ public NativeModule get() { public NativeModule get() { return new HeadlessJsTaskSupportModule(reactContext); } - })); - moduleSpecList.add( + }), ModuleSpec.nativeModuleSpec( SourceCodeModule.class, new Provider() { @@ -146,8 +115,7 @@ public NativeModule get() { public NativeModule get() { return new SourceCodeModule(reactContext); } - })); - moduleSpecList.add( + }), ModuleSpec.nativeModuleSpec( Timing.class, new Provider() { @@ -155,8 +123,7 @@ public NativeModule get() { public NativeModule get() { return new Timing(reactContext, mReactInstanceManager.getDevSupportManager()); } - })); - moduleSpecList.add( + }), ModuleSpec.nativeModuleSpec( UIManagerModule.class, new Provider() { @@ -164,8 +131,7 @@ public NativeModule get() { public NativeModule get() { return createUIManager(reactContext); } - })); - moduleSpecList.add( + }), ModuleSpec.nativeModuleSpec( DeviceInfoModule.class, new Provider() { @@ -174,29 +140,6 @@ public NativeModule get() { return new DeviceInfoModule(reactContext); } })); - - if (ReactBuildConfig.DEBUG) { - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - JSCHeapCapture.class, - new Provider() { - @Override - public NativeModule get() { - return new JSCHeapCapture(reactContext); - } - })); - moduleSpecList.add( - ModuleSpec.nativeModuleSpec( - JSCSamplingProfiler.class, - new Provider() { - @Override - public NativeModule get() { - return new JSCSamplingProfiler(reactContext); - } - })); - } - - return moduleSpecList; } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index aa317e7503bb4a..0e06dd854916b9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -272,16 +272,16 @@ public static ReactInstanceManagerBuilder builder() { mMinNumShakes = minNumShakes; synchronized (mPackages) { PrinterHolder.getPrinter().logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: Use Split Packages"); - mPackages.add(new BridgeCorePackage(this, mBackBtnHandler)); - if (mUseDeveloperSupport) { - mPackages.add(new DebugCorePackage()); - } mPackages.add( - new ReactNativeCorePackage( + new CoreModulesPackage( this, + mBackBtnHandler, mUIImplementationProvider, mLazyViewManagersEnabled, mMinTimeLeftInFrameForNonBatchedOperationMs)); + if (mUseDeveloperSupport) { + mPackages.add(new DebugCorePackage()); + } mPackages.addAll(packages); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactNativeCorePackage.java b/ReactAndroid/src/main/java/com/facebook/react/ReactNativeCorePackage.java deleted file mode 100644 index 0e7b36edbf7b11..00000000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactNativeCorePackage.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -package com.facebook.react; - -import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END; -import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START; - -import com.facebook.react.bridge.ModuleSpec; -import com.facebook.react.bridge.NativeModule; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactMarker; -import com.facebook.react.module.annotations.ReactModuleList; -import com.facebook.react.module.model.ReactModuleInfoProvider; -import com.facebook.react.uimanager.UIImplementationProvider; -import com.facebook.react.uimanager.UIManagerModule; -import com.facebook.react.uimanager.ViewManager; -import com.facebook.systrace.Systrace; -import java.util.Collections; -import java.util.List; -import javax.annotation.Nullable; -import javax.inject.Provider; - -/** - * Package defining core framework modules for initializing ReactNative (e.g. UIManager). It should be used for modules that - * require special integration with other framework parts (e.g. with the list of packages to load - * view managers from). - */ -@ReactModuleList( - nativeModules = { - UIManagerModule.class, - } -) -public class ReactNativeCorePackage extends LazyReactPackage { - - private final ReactInstanceManager mReactInstanceManager; - private final UIImplementationProvider mUIImplementationProvider; - private final boolean mLazyViewManagersEnabled; - private final int mMinTimeLeftInFrameForNonBatchedOperationMs; - - public ReactNativeCorePackage( - ReactInstanceManager reactInstanceManager, - UIImplementationProvider uiImplementationProvider, - boolean lazyViewManagersEnabled, - int minTimeLeftInFrameForNonBatchedOperationMs) { - mReactInstanceManager = reactInstanceManager; - mUIImplementationProvider = uiImplementationProvider; - mLazyViewManagersEnabled = lazyViewManagersEnabled; - mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs; - } - - @Override - public List getNativeModules(final ReactApplicationContext reactContext) { - return Collections.singletonList( - ModuleSpec.nativeModuleSpec( - UIManagerModule.class, - new Provider() { - @Override - public NativeModule get() { - return createUIManager(reactContext); - } - })); - } - - @Override - public ReactModuleInfoProvider getReactModuleInfoProvider() { - // This has to be done via reflection or we break open source. - ReactModuleInfoProvider reactModuleInfoProvider = - LazyReactPackage.getReactModuleInfoProviderViaReflection(this); - return reactModuleInfoProvider; - } - - private UIManagerModule createUIManager(final ReactApplicationContext reactContext) { - ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START); - Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule"); - try { - if (mLazyViewManagersEnabled) { - UIManagerModule.ViewManagerResolver viewManagerResolver = - new UIManagerModule.ViewManagerResolver() { - @Override - public @Nullable ViewManager getViewManager(String viewManagerName) { - return mReactInstanceManager.createViewManager(viewManagerName); - } - - @Override - public List getViewManagerNames() { - return mReactInstanceManager.getViewManagerNames(); - } - }; - - return new UIManagerModule( - reactContext, - viewManagerResolver, - mUIImplementationProvider, - mMinTimeLeftInFrameForNonBatchedOperationMs); - } else { - return new UIManagerModule( - reactContext, - mReactInstanceManager.createAllViewManagers(reactContext), - mUIImplementationProvider, - mMinTimeLeftInFrameForNonBatchedOperationMs); - } - } finally { - Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); - ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END); - } - } -}