Breaking - remove unused registration of JS modules
Summary: It's now unnecessary to declare which JS modules you want to expose on your package. To upgrade, remove all overrides of `createJSModules` and keeping calling your JS modules as before. Reviewed By: AaaChiuuu Differential Revision: D5229259 fbshipit-source-id: 1160826c951433722f1fe0421c1200883ba1a348
This commit is contained in:
parent
71ea94b51e
commit
ce6fb337a1
|
@ -40,8 +40,7 @@ public abstract class AbstractScrollViewTestCase extends ReactAppInstrumentation
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
mScrollListenerModule = new ScrollListenerModule();
|
mScrollListenerModule = new ScrollListenerModule();
|
||||||
return super.createReactInstanceSpecForTest()
|
return super.createReactInstanceSpecForTest()
|
||||||
.addNativeModule(mScrollListenerModule)
|
.addNativeModule(mScrollListenerModule);
|
||||||
.addJSModule(ScrollViewTestModule.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See ScrollViewListenerModule.js
|
// See ScrollViewListenerModule.js
|
||||||
|
|
|
@ -36,11 +36,6 @@ public class InstanceSpecForTestPackage implements ReactPackage {
|
||||||
return mSpecForTest.getExtraNativeModulesForTest();
|
return mSpecForTest.getExtraNativeModulesForTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
||||||
return mSpecForTest.getExtraJSModulesForTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||||
return mSpecForTest.getExtraViewManagers();
|
return mSpecForTest.getExtraViewManagers();
|
||||||
|
|
|
@ -38,11 +38,6 @@ public class ReactInstanceSpecForTest {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReactInstanceSpecForTest addJSModule(Class jsClass) {
|
|
||||||
mJSModuleSpecs.add(jsClass);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReactInstanceSpecForTest setPackage(ReactPackage reactPackage) {
|
public ReactInstanceSpecForTest setPackage(ReactPackage reactPackage) {
|
||||||
mReactPackage = reactPackage;
|
mReactPackage = reactPackage;
|
||||||
return this;
|
return this;
|
||||||
|
@ -57,10 +52,6 @@ public class ReactInstanceSpecForTest {
|
||||||
return mNativeModules;
|
return mNativeModules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Class<? extends JavaScriptModule>> getExtraJSModulesForTest() {
|
|
||||||
return mJSModuleSpecs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReactPackage getAlternativeReactPackageForTest() {
|
public ReactPackage getAlternativeReactPackageForTest() {
|
||||||
return mReactPackage;
|
return mReactPackage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ public interface ReactTestFactory {
|
||||||
public static interface ReactInstanceEasyBuilder {
|
public static interface ReactInstanceEasyBuilder {
|
||||||
ReactInstanceEasyBuilder setContext(Context context);
|
ReactInstanceEasyBuilder setContext(Context context);
|
||||||
ReactInstanceEasyBuilder addNativeModule(NativeModule module);
|
ReactInstanceEasyBuilder addNativeModule(NativeModule module);
|
||||||
ReactInstanceEasyBuilder addJSModule(Class moduleInterfaceClass);
|
|
||||||
CatalystInstance build();
|
CatalystInstance build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import android.support.test.InstrumentationRegistry;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import com.facebook.infer.annotation.Assertions;
|
||||||
import com.facebook.react.NativeModuleRegistryBuilder;
|
import com.facebook.react.NativeModuleRegistryBuilder;
|
||||||
import com.facebook.react.R;
|
import com.facebook.react.R;
|
||||||
import com.facebook.react.ReactInstanceManager;
|
import com.facebook.react.ReactInstanceManager;
|
||||||
|
@ -39,8 +40,6 @@ public class ReactTestHelper {
|
||||||
private static class DefaultReactTestFactory implements ReactTestFactory {
|
private static class DefaultReactTestFactory implements ReactTestFactory {
|
||||||
private static class ReactInstanceEasyBuilderImpl implements ReactInstanceEasyBuilder {
|
private static class ReactInstanceEasyBuilderImpl implements ReactInstanceEasyBuilder {
|
||||||
|
|
||||||
private final JavaScriptModuleRegistry.Builder mJSModuleRegistryBuilder =
|
|
||||||
new JavaScriptModuleRegistry.Builder();
|
|
||||||
private NativeModuleRegistryBuilder mNativeModuleRegistryBuilder;
|
private NativeModuleRegistryBuilder mNativeModuleRegistryBuilder;
|
||||||
|
|
||||||
private @Nullable Context mContext;
|
private @Nullable Context mContext;
|
||||||
|
@ -59,16 +58,11 @@ public class ReactTestHelper {
|
||||||
null,
|
null,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
Assertions.assertNotNull(nativeModule);
|
||||||
mNativeModuleRegistryBuilder.addNativeModule(nativeModule);
|
mNativeModuleRegistryBuilder.addNativeModule(nativeModule);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ReactInstanceEasyBuilder addJSModule(Class moduleInterfaceClass) {
|
|
||||||
mJSModuleRegistryBuilder.add(moduleInterfaceClass);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CatalystInstance build() {
|
public CatalystInstance build() {
|
||||||
if (mNativeModuleRegistryBuilder == null) {
|
if (mNativeModuleRegistryBuilder == null) {
|
||||||
|
@ -87,7 +81,6 @@ public class ReactTestHelper {
|
||||||
.setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault())
|
.setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault())
|
||||||
.setJSExecutor(executor)
|
.setJSExecutor(executor)
|
||||||
.setRegistry(mNativeModuleRegistryBuilder.build())
|
.setRegistry(mNativeModuleRegistryBuilder.build())
|
||||||
.setJSModuleRegistry(mJSModuleRegistryBuilder.build())
|
|
||||||
.setJSBundleLoader(JSBundleLoader.createAssetLoader(
|
.setJSBundleLoader(JSBundleLoader.createAssetLoader(
|
||||||
mContext,
|
mContext,
|
||||||
"assets://AndroidTestBundle.js",
|
"assets://AndroidTestBundle.js",
|
||||||
|
@ -141,12 +134,6 @@ public class ReactTestHelper {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ReactTestFactory.ReactInstanceEasyBuilder addJSModule(Class moduleInterfaceClass) {
|
|
||||||
builder.addJSModule(moduleInterfaceClass);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CatalystInstance build() {
|
public CatalystInstance build() {
|
||||||
final CatalystInstance instance = builder.build();
|
final CatalystInstance instance = builder.build();
|
||||||
|
|
|
@ -74,9 +74,8 @@ public class CatalystMeasureLayoutTest extends ReactAppInstrumentationTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
mAssertModule = new AssertModule();
|
mAssertModule = new AssertModule();
|
||||||
return new ReactInstanceSpecForTest()
|
return super.createReactInstanceSpecForTest()
|
||||||
.addNativeModule(mAssertModule)
|
.addNativeModule(mAssertModule);
|
||||||
.addJSModule(MeasureLayoutTestModule.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForBridgeIdleAndVerifyAsserts() {
|
private void waitForBridgeIdleAndVerifyAsserts() {
|
||||||
|
|
|
@ -109,7 +109,6 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe
|
||||||
.addNativeModule(new AppStateModule(getContext()))
|
.addNativeModule(new AppStateModule(getContext()))
|
||||||
.addNativeModule(new FakeWebSocketModule())
|
.addNativeModule(new FakeWebSocketModule())
|
||||||
.addNativeModule(mUIManager)
|
.addNativeModule(mUIManager)
|
||||||
.addJSModule(TestJSToJavaParametersModule.class)
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,6 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes
|
||||||
.addNativeModule(new DeviceInfoModule(getContext()))
|
.addNativeModule(new DeviceInfoModule(getContext()))
|
||||||
.addNativeModule(new AppStateModule(getContext()))
|
.addNativeModule(new AppStateModule(getContext()))
|
||||||
.addNativeModule(new FakeWebSocketModule())
|
.addNativeModule(new FakeWebSocketModule())
|
||||||
.addJSModule(TestJavaToJSArgumentsModule.class)
|
|
||||||
.addNativeModule(mUIManager)
|
.addNativeModule(mUIManager)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,6 @@ public class CatalystNativeJavaToJSReturnValuesTestCase extends ReactIntegration
|
||||||
.addNativeModule(new DeviceInfoModule(getContext()))
|
.addNativeModule(new DeviceInfoModule(getContext()))
|
||||||
.addNativeModule(new AppStateModule(getContext()))
|
.addNativeModule(new AppStateModule(getContext()))
|
||||||
.addNativeModule(new FakeWebSocketModule())
|
.addNativeModule(new FakeWebSocketModule())
|
||||||
.addJSModule(TestJavaToJSReturnValuesModule.class)
|
|
||||||
.addNativeModule(mUIManager)
|
.addNativeModule(mUIManager)
|
||||||
.addNativeModule(new TestModule())
|
.addNativeModule(new TestModule())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -51,10 +51,8 @@ public class CatalystSubviewsClippingTestCase extends ReactAppInstrumentationTes
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
ReactInstanceSpecForTest instanceSpec = new ReactInstanceSpecForTest();
|
return super.createReactInstanceSpecForTest()
|
||||||
instanceSpec.addJSModule(SubviewsClippingTestModule.class);
|
.addViewManager(new ClippableViewManager(mEvents));
|
||||||
instanceSpec.addViewManager(new ClippableViewManager(mEvents));
|
|
||||||
return instanceSpec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -99,7 +99,6 @@ public class CatalystUIManagerTestCase extends ReactIntegrationTestCase {
|
||||||
.addNativeModule(new DeviceInfoModule(getContext()))
|
.addNativeModule(new DeviceInfoModule(getContext()))
|
||||||
.addNativeModule(new AppStateModule(getContext()))
|
.addNativeModule(new AppStateModule(getContext()))
|
||||||
.addNativeModule(new FakeWebSocketModule())
|
.addNativeModule(new FakeWebSocketModule())
|
||||||
.addJSModule(UIManagerTestModule.class)
|
|
||||||
.build()
|
.build()
|
||||||
.getJSModule(UIManagerTestModule.class);
|
.getJSModule(UIManagerTestModule.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,7 @@ public class DatePickerDialogTestCase extends ReactAppInstrumentationTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
return super.createReactInstanceSpecForTest()
|
return super.createReactInstanceSpecForTest()
|
||||||
.addNativeModule(mRecordingModule)
|
.addNativeModule(mRecordingModule);
|
||||||
.addJSModule(DatePickerDialogTestModule.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -66,7 +66,6 @@ public class JSLocaleTest extends ReactIntegrationTestCase {
|
||||||
.addNativeModule(new DeviceInfoModule(getContext()))
|
.addNativeModule(new DeviceInfoModule(getContext()))
|
||||||
.addNativeModule(new AppStateModule(getContext()))
|
.addNativeModule(new AppStateModule(getContext()))
|
||||||
.addNativeModule(new FakeWebSocketModule())
|
.addNativeModule(new FakeWebSocketModule())
|
||||||
.addJSModule(TestJSLocaleModule.class)
|
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,6 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase {
|
||||||
.addNativeModule(new DeviceInfoModule(getContext()))
|
.addNativeModule(new DeviceInfoModule(getContext()))
|
||||||
.addNativeModule(new AppStateModule(getContext()))
|
.addNativeModule(new AppStateModule(getContext()))
|
||||||
.addNativeModule(new FakeWebSocketModule())
|
.addNativeModule(new FakeWebSocketModule())
|
||||||
.addJSModule(ProgressBarTestModule.class)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
mRootView = new ReactRootView(getContext());
|
mRootView = new ReactRootView(getContext());
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* 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.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.facebook.react.tests;
|
package com.facebook.react.tests;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -68,7 +68,6 @@ public class ReactPickerTestCase extends ReactAppInstrumentationTestCase {
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
mRecordingModule = new PickerAndroidRecordingModule();
|
mRecordingModule = new PickerAndroidRecordingModule();
|
||||||
return super.createReactInstanceSpecForTest()
|
return super.createReactInstanceSpecForTest()
|
||||||
.addJSModule(PickerAndroidTestModule.class)
|
|
||||||
.addNativeModule(mRecordingModule);
|
.addNativeModule(mRecordingModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,7 @@ public class ReactSwipeRefreshLayoutTestCase extends ReactAppInstrumentationTest
|
||||||
@Override
|
@Override
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
return super.createReactInstanceSpecForTest()
|
return super.createReactInstanceSpecForTest()
|
||||||
.addNativeModule(mRecordingModule)
|
.addNativeModule(mRecordingModule);
|
||||||
.addJSModule(SwipeRefreshLayoutTestModule.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRefreshNoScroll() {
|
public void testRefreshNoScroll() {
|
||||||
|
|
|
@ -73,8 +73,7 @@ public class ShareTestCase extends ReactAppInstrumentationTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
return super.createReactInstanceSpecForTest()
|
return super.createReactInstanceSpecForTest()
|
||||||
.addNativeModule(mRecordingModule)
|
.addNativeModule(mRecordingModule);
|
||||||
.addJSModule(ShareTestModule.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -248,7 +248,6 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
return super.createReactInstanceSpecForTest()
|
return super.createReactInstanceSpecForTest()
|
||||||
.addJSModule(TextInputTestModule.class)
|
|
||||||
.addNativeModule(mRecordingModule);
|
.addNativeModule(mRecordingModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,7 @@ public class TimePickerDialogTestCase extends ReactAppInstrumentationTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
|
||||||
return super.createReactInstanceSpecForTest()
|
return super.createReactInstanceSpecForTest()
|
||||||
.addNativeModule(mRecordingModule)
|
.addNativeModule(mRecordingModule);
|
||||||
.addJSModule(TimePickerDialogTestModule.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -71,7 +71,6 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase {
|
||||||
.addNativeModule(new DeviceInfoModule(getContext()))
|
.addNativeModule(new DeviceInfoModule(getContext()))
|
||||||
.addNativeModule(new AppStateModule(getContext()))
|
.addNativeModule(new AppStateModule(getContext()))
|
||||||
.addNativeModule(new FakeWebSocketModule())
|
.addNativeModule(new FakeWebSocketModule())
|
||||||
.addJSModule(ViewRenderingTestModule.class)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
mRootView = new ReactRootView(getContext());
|
mRootView = new ReactRootView(getContext());
|
||||||
|
|
|
@ -84,20 +84,6 @@ public class CompositeReactPackage extends ReactInstancePackage {
|
||||||
return new ArrayList(moduleMap.values());
|
return new ArrayList(moduleMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
||||||
final Set<Class<? extends JavaScriptModule>> moduleSet = new HashSet<>();
|
|
||||||
for (ReactPackage reactPackage: mChildReactPackages) {
|
|
||||||
for (Class<? extends JavaScriptModule> jsModule: reactPackage.createJSModules()) {
|
|
||||||
moduleSet.add(jsModule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ArrayList(moduleSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,27 +12,21 @@ package com.facebook.react;
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.facebook.react.bridge.JavaScriptModule;
|
|
||||||
import com.facebook.react.bridge.ModuleSpec;
|
import com.facebook.react.bridge.ModuleSpec;
|
||||||
import com.facebook.react.bridge.NativeModule;
|
import com.facebook.react.bridge.NativeModule;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.bridge.ReactMarker;
|
import com.facebook.react.bridge.ReactMarker;
|
||||||
import com.facebook.react.common.build.ReactBuildConfig;
|
import com.facebook.react.common.build.ReactBuildConfig;
|
||||||
import com.facebook.react.devsupport.HMRClient;
|
|
||||||
import com.facebook.react.devsupport.JSCHeapCapture;
|
import com.facebook.react.devsupport.JSCHeapCapture;
|
||||||
import com.facebook.react.devsupport.JSCSamplingProfiler;
|
import com.facebook.react.devsupport.JSCSamplingProfiler;
|
||||||
import com.facebook.react.module.annotations.ReactModuleList;
|
import com.facebook.react.module.annotations.ReactModuleList;
|
||||||
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
||||||
import com.facebook.react.modules.appregistry.AppRegistry;
|
|
||||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||||
import com.facebook.react.modules.core.ExceptionsManagerModule;
|
import com.facebook.react.modules.core.ExceptionsManagerModule;
|
||||||
import com.facebook.react.modules.core.HeadlessJsTaskSupportModule;
|
import com.facebook.react.modules.core.HeadlessJsTaskSupportModule;
|
||||||
import com.facebook.react.modules.core.JSTimersExecution;
|
|
||||||
import com.facebook.react.modules.core.RCTNativeAppEventEmitter;
|
|
||||||
import com.facebook.react.modules.core.Timing;
|
import com.facebook.react.modules.core.Timing;
|
||||||
import com.facebook.react.modules.debug.AnimationsDebugModule;
|
import com.facebook.react.modules.debug.AnimationsDebugModule;
|
||||||
import com.facebook.react.modules.debug.SourceCodeModule;
|
import com.facebook.react.modules.debug.SourceCodeModule;
|
||||||
|
@ -42,7 +36,6 @@ import com.facebook.react.uimanager.UIImplementationProvider;
|
||||||
import com.facebook.react.uimanager.UIManagerModule;
|
import com.facebook.react.uimanager.UIManagerModule;
|
||||||
import com.facebook.react.uimanager.ViewManager;
|
import com.facebook.react.uimanager.ViewManager;
|
||||||
import com.facebook.react.uimanager.debug.DebugComponentOwnershipModule;
|
import com.facebook.react.uimanager.debug.DebugComponentOwnershipModule;
|
||||||
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
||||||
import com.facebook.systrace.Systrace;
|
import com.facebook.systrace.Systrace;
|
||||||
|
|
||||||
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END;
|
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END;
|
||||||
|
@ -187,26 +180,6 @@ import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_
|
||||||
return moduleSpecList;
|
return moduleSpecList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
||||||
List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList(
|
|
||||||
DeviceEventManagerModule.RCTDeviceEventEmitter.class,
|
|
||||||
JSTimersExecution.class,
|
|
||||||
RCTEventEmitter.class,
|
|
||||||
RCTNativeAppEventEmitter.class,
|
|
||||||
AppRegistry.class,
|
|
||||||
com.facebook.react.bridge.Systrace.class,
|
|
||||||
HMRClient.class));
|
|
||||||
|
|
||||||
if (ReactBuildConfig.DEBUG) {
|
|
||||||
jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
|
|
||||||
jsModules.add(JSCHeapCapture.HeapCapture.class);
|
|
||||||
jsModules.add(JSCSamplingProfiler.SamplingProfiler.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsModules;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
||||||
// This has to be done via reflection or we break open source.
|
// This has to be done via reflection or we break open source.
|
||||||
|
|
|
@ -926,7 +926,6 @@ public class ReactInstanceManager {
|
||||||
reactContext,
|
reactContext,
|
||||||
this,
|
this,
|
||||||
mLazyNativeModulesEnabled);
|
mLazyNativeModulesEnabled);
|
||||||
JavaScriptModuleRegistry.Builder jsModulesBuilder = new JavaScriptModuleRegistry.Builder();
|
|
||||||
if (mUseDeveloperSupport) {
|
if (mUseDeveloperSupport) {
|
||||||
reactContext.setNativeModuleCallExceptionHandler(mDevSupportManager);
|
reactContext.setNativeModuleCallExceptionHandler(mDevSupportManager);
|
||||||
}
|
}
|
||||||
|
@ -942,7 +941,7 @@ public class ReactInstanceManager {
|
||||||
mBackBtnHandler,
|
mBackBtnHandler,
|
||||||
mUIImplementationProvider,
|
mUIImplementationProvider,
|
||||||
mLazyViewManagersEnabled);
|
mLazyViewManagersEnabled);
|
||||||
processPackage(coreModulesPackage, nativeModuleRegistryBuilder, jsModulesBuilder);
|
processPackage(coreModulesPackage, nativeModuleRegistryBuilder);
|
||||||
} finally {
|
} finally {
|
||||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||||
}
|
}
|
||||||
|
@ -953,7 +952,7 @@ public class ReactInstanceManager {
|
||||||
TRACE_TAG_REACT_JAVA_BRIDGE,
|
TRACE_TAG_REACT_JAVA_BRIDGE,
|
||||||
"createAndProcessCustomReactPackage");
|
"createAndProcessCustomReactPackage");
|
||||||
try {
|
try {
|
||||||
processPackage(reactPackage, nativeModuleRegistryBuilder, jsModulesBuilder);
|
processPackage(reactPackage, nativeModuleRegistryBuilder);
|
||||||
} finally {
|
} finally {
|
||||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||||
}
|
}
|
||||||
|
@ -979,7 +978,6 @@ public class ReactInstanceManager {
|
||||||
ReactQueueConfigurationSpec.createDefault())
|
ReactQueueConfigurationSpec.createDefault())
|
||||||
.setJSExecutor(jsExecutor)
|
.setJSExecutor(jsExecutor)
|
||||||
.setRegistry(nativeModuleRegistry)
|
.setRegistry(nativeModuleRegistry)
|
||||||
.setJSModuleRegistry(jsModulesBuilder.build())
|
|
||||||
.setJSBundleLoader(jsBundleLoader)
|
.setJSBundleLoader(jsBundleLoader)
|
||||||
.setNativeModuleCallExceptionHandler(exceptionHandler);
|
.setNativeModuleCallExceptionHandler(exceptionHandler);
|
||||||
|
|
||||||
|
@ -1010,8 +1008,7 @@ public class ReactInstanceManager {
|
||||||
|
|
||||||
private void processPackage(
|
private void processPackage(
|
||||||
ReactPackage reactPackage,
|
ReactPackage reactPackage,
|
||||||
NativeModuleRegistryBuilder nativeModuleRegistryBuilder,
|
NativeModuleRegistryBuilder nativeModuleRegistryBuilder) {
|
||||||
JavaScriptModuleRegistry.Builder jsModulesBuilder) {
|
|
||||||
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage")
|
SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage")
|
||||||
.arg("className", reactPackage.getClass().getSimpleName())
|
.arg("className", reactPackage.getClass().getSimpleName())
|
||||||
.flush();
|
.flush();
|
||||||
|
@ -1020,9 +1017,6 @@ public class ReactInstanceManager {
|
||||||
}
|
}
|
||||||
nativeModuleRegistryBuilder.processPackage(reactPackage);
|
nativeModuleRegistryBuilder.processPackage(reactPackage);
|
||||||
|
|
||||||
for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
|
|
||||||
jsModulesBuilder.add(jsModuleClass);
|
|
||||||
}
|
|
||||||
if (reactPackage instanceof ReactPackageLogger) {
|
if (reactPackage instanceof ReactPackageLogger) {
|
||||||
((ReactPackageLogger) reactPackage).endProcessPackage();
|
((ReactPackageLogger) reactPackage).endProcessPackage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,15 +38,6 @@ public interface ReactPackage {
|
||||||
*/
|
*/
|
||||||
List<NativeModule> createNativeModules(ReactApplicationContext reactContext);
|
List<NativeModule> createNativeModules(ReactApplicationContext reactContext);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list of JS modules to register with the newly created catalyst instance.
|
|
||||||
*
|
|
||||||
* IMPORTANT: Note that only modules that needs to be accessible from the native code should be
|
|
||||||
* listed here. Also listing a native module here doesn't imply that the JS implementation of it
|
|
||||||
* will be automatically included in the JS bundle.
|
|
||||||
*/
|
|
||||||
List<Class<? extends JavaScriptModule>> createJSModules();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of view managers that should be registered with {@link UIManagerModule}
|
* @return a list of view managers that should be registered with {@link UIManagerModule}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -541,10 +541,6 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setJSModuleRegistry(JavaScriptModuleRegistry jsModuleRegistry) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setJSBundleLoader(JSBundleLoader jsBundleLoader) {
|
public Builder setJSBundleLoader(JSBundleLoader jsBundleLoader) {
|
||||||
mJSBundleLoader = jsBundleLoader;
|
mJSBundleLoader = jsBundleLoader;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -48,16 +48,6 @@ public final class JavaScriptModuleRegistry {
|
||||||
return (T) interfaceProxy;
|
return (T) interfaceProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
public Builder add(Class<? extends JavaScriptModule> moduleInterfaceClass) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JavaScriptModuleRegistry build() {
|
|
||||||
return new JavaScriptModuleRegistry();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class JavaScriptModuleInvocationHandler implements InvocationHandler {
|
private static class JavaScriptModuleInvocationHandler implements InvocationHandler {
|
||||||
private final CatalystInstance mCatalystInstance;
|
private final CatalystInstance mCatalystInstance;
|
||||||
private final Class<? extends JavaScriptModule> mModuleInterface;
|
private final Class<? extends JavaScriptModule> mModuleInterface;
|
||||||
|
|
|
@ -247,11 +247,6 @@ public class MainReactPackage extends LazyReactPackage {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||||
List<ViewManager> viewManagers = new ArrayList<>();
|
List<ViewManager> viewManagers = new ArrayList<>();
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.facebook.react.bridge.JavaScriptModule;
|
|
||||||
import com.facebook.react.bridge.NativeModule;
|
import com.facebook.react.bridge.NativeModule;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.uimanager.ViewManager;
|
import com.facebook.react.uimanager.ViewManager;
|
||||||
|
@ -68,20 +67,6 @@ public class CompositeReactPackageTest {
|
||||||
verify(packageNo3).createNativeModules(reactContext);
|
verify(packageNo3).createNativeModules(reactContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testThatCreateJSModulesIsCalledOnAllPackages() {
|
|
||||||
// Given
|
|
||||||
CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2, packageNo3);
|
|
||||||
|
|
||||||
// When
|
|
||||||
composite.createJSModules();
|
|
||||||
|
|
||||||
// Then
|
|
||||||
verify(packageNo1).createJSModules();
|
|
||||||
verify(packageNo2).createJSModules();
|
|
||||||
verify(packageNo3).createJSModules();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThatCreateViewManagersIsCalledOnAllPackages() {
|
public void testThatCreateViewManagersIsCalledOnAllPackages() {
|
||||||
// Given
|
// Given
|
||||||
|
@ -176,43 +161,4 @@ public class CompositeReactPackageTest {
|
||||||
|
|
||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public access level is required by Mockito
|
|
||||||
public static class JavaScriptModuleNo1 implements JavaScriptModule {};
|
|
||||||
public static class JavaScriptModuleNo2 implements JavaScriptModule {};
|
|
||||||
public static class JavaScriptModuleNo3 implements JavaScriptModule {};
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testThatCompositeReturnsASumOfJSModules() {
|
|
||||||
// Given
|
|
||||||
CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2);
|
|
||||||
|
|
||||||
Class<? extends JavaScriptModule> moduleNo1 = mock(JavaScriptModuleNo1.class).getClass();
|
|
||||||
Class<? extends JavaScriptModule> moduleNo2 = mock(JavaScriptModuleNo2.class).getClass();
|
|
||||||
Class<? extends JavaScriptModule> moduleNo3 = mock(JavaScriptModuleNo3.class).getClass();
|
|
||||||
|
|
||||||
List<Class<? extends JavaScriptModule>> l1 = new ArrayList<>();
|
|
||||||
l1.add(moduleNo1);
|
|
||||||
when(packageNo1.createJSModules()).thenReturn(l1);
|
|
||||||
|
|
||||||
List<Class<? extends JavaScriptModule>> l2 = new ArrayList<>();
|
|
||||||
l2.add(moduleNo2);
|
|
||||||
l2.add(moduleNo3);
|
|
||||||
when(packageNo2.createJSModules()).thenReturn(l2);
|
|
||||||
|
|
||||||
// When
|
|
||||||
List<Class<? extends JavaScriptModule>> compositeModules = composite.createJSModules();
|
|
||||||
|
|
||||||
// Then
|
|
||||||
|
|
||||||
// wrapping lists into sets to be order-independent
|
|
||||||
List<Class<? extends JavaScriptModule>> l3 = new ArrayList<>();
|
|
||||||
l3.add(moduleNo1);
|
|
||||||
l3.add(moduleNo2);
|
|
||||||
l3.add(moduleNo3);
|
|
||||||
Set<Class<? extends JavaScriptModule>> expected = new HashSet<>(l3);
|
|
||||||
Set<Class<? extends JavaScriptModule>> actual = new HashSet<>(compositeModules);
|
|
||||||
|
|
||||||
assertEquals(expected, actual);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,6 @@ The last step within Java is to register the Module; this happens in the `create
|
||||||
package com.facebook.react.modules.toast;
|
package com.facebook.react.modules.toast;
|
||||||
|
|
||||||
import com.facebook.react.ReactPackage;
|
import com.facebook.react.ReactPackage;
|
||||||
import com.facebook.react.bridge.JavaScriptModule;
|
|
||||||
import com.facebook.react.bridge.NativeModule;
|
import com.facebook.react.bridge.NativeModule;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.uimanager.ViewManager;
|
import com.facebook.react.uimanager.ViewManager;
|
||||||
|
@ -113,11 +112,6 @@ import java.util.List;
|
||||||
|
|
||||||
public class AnExampleReactPackage implements ReactPackage {
|
public class AnExampleReactPackage implements ReactPackage {
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.some.example;
|
package com.some.example;
|
||||||
|
|
||||||
import com.facebook.react.ReactPackage;
|
import com.facebook.react.ReactPackage;
|
||||||
import com.facebook.react.bridge.JavaScriptModule;
|
|
||||||
import com.facebook.react.bridge.NativeModule;
|
import com.facebook.react.bridge.NativeModule;
|
||||||
import com.facebook.react.bridge.ReactApplicationContext;
|
import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.uimanager.ViewManager;
|
import com.facebook.react.uimanager.ViewManager;
|
||||||
|
@ -13,8 +12,6 @@ import java.util.List;
|
||||||
|
|
||||||
public class SomeExamplePackage implements ReactPackage {
|
public class SomeExamplePackage implements ReactPackage {
|
||||||
|
|
||||||
public SomeExamplePackage() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NativeModule> createNativeModules(
|
public List<NativeModule> createNativeModules(
|
||||||
ReactApplicationContext reactContext) {
|
ReactApplicationContext reactContext) {
|
||||||
|
@ -23,11 +20,6 @@ public class SomeExamplePackage implements ReactPackage {
|
||||||
return modules;
|
return modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
Loading…
Reference in New Issue