mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Rename ReactInstanceDelegate -> ReactHostDelegate (#37323)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37323 ReactInstance is an internal concept and name, we should not leak ReactInstance name for client code. bypass-github-export-checks changelog: [internal] internal Reviewed By: RSNara Differential Revision: D45578268 fbshipit-source-id: c0306b89d854d7beb5fcd38ba3623099846ec932
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1200cdc810
commit
19927867bb
+12
-12
@@ -85,7 +85,7 @@ public class ReactHost {
|
||||
private static final int BRIDGELESS_MARKER_INSTANCE_KEY = 1;
|
||||
|
||||
private final Context mContext;
|
||||
private final ReactInstanceDelegate mReactInstanceDelegate;
|
||||
private final ReactHostDelegate mReactHostDelegate;
|
||||
private final ComponentFactory mComponentFactory;
|
||||
private final ReactJsExceptionHandler mReactJsExceptionHandler;
|
||||
private final DevSupportManager mDevSupportManager;
|
||||
@@ -121,7 +121,7 @@ public class ReactHost {
|
||||
|
||||
public ReactHost(
|
||||
Context context,
|
||||
ReactInstanceDelegate delegate,
|
||||
ReactHostDelegate delegate,
|
||||
ComponentFactory componentFactory,
|
||||
boolean allowPackagerServerAccess,
|
||||
ReactJsExceptionHandler reactJsExceptionHandler,
|
||||
@@ -139,7 +139,7 @@ public class ReactHost {
|
||||
|
||||
public ReactHost(
|
||||
Context context,
|
||||
ReactInstanceDelegate delegate,
|
||||
ReactHostDelegate delegate,
|
||||
ComponentFactory componentFactory,
|
||||
Executor bgExecutor,
|
||||
Executor uiExecutor,
|
||||
@@ -147,7 +147,7 @@ public class ReactHost {
|
||||
boolean allowPackagerServerAccess,
|
||||
boolean useDevSupport) {
|
||||
mContext = context;
|
||||
mReactInstanceDelegate = delegate;
|
||||
mReactHostDelegate = delegate;
|
||||
mComponentFactory = componentFactory;
|
||||
mBGExecutor = bgExecutor;
|
||||
mUIExecutor = uiExecutor;
|
||||
@@ -163,7 +163,7 @@ public class ReactHost {
|
||||
if (DEV) {
|
||||
mDevSupportManager =
|
||||
new BridgelessDevSupportManager(
|
||||
ReactHost.this, mContext, mReactInstanceDelegate.getJSMainModulePath());
|
||||
ReactHost.this, mContext, mReactHostDelegate.getJSMainModulePath());
|
||||
} else {
|
||||
mDevSupportManager = new DisabledDevSupportManager();
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public class ReactHost {
|
||||
destroy(
|
||||
"old_preload() failure: " + task.getError().getMessage(),
|
||||
task.getError());
|
||||
mReactInstanceDelegate.handleInstanceException(task.getError());
|
||||
mReactHostDelegate.handleInstanceException(task.getError());
|
||||
}
|
||||
|
||||
return task;
|
||||
@@ -246,7 +246,7 @@ public class ReactHost {
|
||||
.continueWithTask(
|
||||
(task) -> {
|
||||
if (task.isFaulted()) {
|
||||
mReactInstanceDelegate.handleInstanceException(task.getError());
|
||||
mReactHostDelegate.handleInstanceException(task.getError());
|
||||
// Wait for destroy to finish
|
||||
return new_getOrCreateDestroyTask(
|
||||
"new_preload() failure: " + task.getError().getMessage(),
|
||||
@@ -571,7 +571,7 @@ public class ReactHost {
|
||||
log(method);
|
||||
|
||||
destroy(method, e);
|
||||
mReactInstanceDelegate.handleInstanceException(e);
|
||||
mReactHostDelegate.handleInstanceException(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -779,7 +779,7 @@ public class ReactHost {
|
||||
final ReactInstance instance =
|
||||
new ReactInstance(
|
||||
reactContext,
|
||||
mReactInstanceDelegate,
|
||||
mReactHostDelegate,
|
||||
mComponentFactory,
|
||||
devSupportManager,
|
||||
mQueueThreadExceptionHandler,
|
||||
@@ -873,7 +873,7 @@ public class ReactHost {
|
||||
final ReactInstance instance =
|
||||
new ReactInstance(
|
||||
reactContext,
|
||||
mReactInstanceDelegate,
|
||||
mReactHostDelegate,
|
||||
mComponentFactory,
|
||||
devSupportManager,
|
||||
mQueueThreadExceptionHandler,
|
||||
@@ -945,7 +945,7 @@ public class ReactHost {
|
||||
// Since metro is running, fetch the JS bundle from the server
|
||||
return loadJSBundleFromMetro();
|
||||
}
|
||||
return Task.forResult(mReactInstanceDelegate.getJSBundleLoader(mContext));
|
||||
return Task.forResult(mReactHostDelegate.getJSBundleLoader(mContext));
|
||||
},
|
||||
mBGExecutor);
|
||||
} else {
|
||||
@@ -960,7 +960,7 @@ public class ReactHost {
|
||||
* throws an exception, the task will fault, and we'll go through the ReactHost error
|
||||
* reporting pipeline.
|
||||
*/
|
||||
return Task.call(() -> mReactInstanceDelegate.getJSBundleLoader(mContext));
|
||||
return Task.call(() -> mReactHostDelegate.getJSBundleLoader(mContext));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -20,7 +20,7 @@ import com.facebook.react.turbomodule.core.TurboModuleManagerDelegate
|
||||
/** TODO: add javadoc for class and methods */
|
||||
@ThreadSafe
|
||||
@UnstableReactNativeAPI
|
||||
interface ReactInstanceDelegate {
|
||||
interface ReactHostDelegate {
|
||||
val jSMainModulePath: String
|
||||
|
||||
val bindingsInstaller: BindingsInstaller
|
||||
@@ -38,7 +38,7 @@ interface ReactInstanceDelegate {
|
||||
fun getReactNativeConfig(turboModuleManager: TurboModuleManager): ReactNativeConfig
|
||||
|
||||
@UnstableReactNativeAPI
|
||||
class ReactInstanceDelegateBase(
|
||||
class ReactHostDelegateBase(
|
||||
override val jSMainModulePath: String,
|
||||
override val bindingsInstaller: BindingsInstaller,
|
||||
override val reactPackages: List<ReactPackage>,
|
||||
@@ -47,7 +47,7 @@ interface ReactInstanceDelegate {
|
||||
private val jsEngineInstance: JSEngineInstance,
|
||||
private val reactNativeConfig: ReactNativeConfig,
|
||||
private val exceptionHandler: (Exception) -> Unit = {}
|
||||
) : ReactInstanceDelegate {
|
||||
) : ReactHostDelegate {
|
||||
override fun getJSBundleLoader(context: Context) = jsBundleLoader
|
||||
|
||||
override fun getTurboModuleManagerDelegate(context: ReactApplicationContext) =
|
||||
+2
-2
@@ -75,7 +75,7 @@ final class ReactInstance {
|
||||
|
||||
@DoNotStrip private final HybridData mHybridData;
|
||||
|
||||
private final ReactInstanceDelegate mDelegate;
|
||||
private final ReactHostDelegate mDelegate;
|
||||
private final BridgelessReactContext mBridgelessReactContext;
|
||||
|
||||
private final ReactQueueConfiguration mQueueConfiguration;
|
||||
@@ -89,7 +89,7 @@ final class ReactInstance {
|
||||
|
||||
/* package */ ReactInstance(
|
||||
BridgelessReactContext bridgelessReactContext,
|
||||
ReactInstanceDelegate delegate,
|
||||
ReactHostDelegate delegate,
|
||||
ComponentFactory componentFactory,
|
||||
DevSupportManager devSupportManager,
|
||||
QueueThreadExceptionHandler exceptionHandler,
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.robolectric.annotation.Config
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@OptIn(UnstableReactNativeAPI::class)
|
||||
@Config(shadows = [ShadowSoLoader::class])
|
||||
class ReactInstanceDelegateTest {
|
||||
class ReactHostDelegateTest {
|
||||
|
||||
/** Mock test for ReactInstanceDelegate, used to setup the process to create a stable API */
|
||||
@Test
|
||||
@@ -38,7 +38,7 @@ class ReactInstanceDelegateTest {
|
||||
val reactPackages = listOf(reactPackage)
|
||||
val jsMainModulePathMocked = "mockedJSMainModulePath"
|
||||
val delegate =
|
||||
ReactInstanceDelegate.ReactInstanceDelegateBase(
|
||||
ReactHostDelegate.ReactHostDelegateBase(
|
||||
jsMainModulePathMocked,
|
||||
jsBundleLoader = jsBundleLoader,
|
||||
reactPackages = reactPackages,
|
||||
+4
-4
@@ -55,7 +55,7 @@ import org.robolectric.android.controller.ActivityController;
|
||||
@Ignore("Ignore for now as these tests fail in OSS only")
|
||||
public class ReactHostTest {
|
||||
|
||||
private ReactInstanceDelegate mReactInstanceDelegate;
|
||||
private ReactHostDelegate mReactHostDelegate;
|
||||
private ReactInstance mReactInstance;
|
||||
private MemoryPressureRouter mMemoryPressureRouter;
|
||||
private BridgelessDevSupportManager mDevSupportManager;
|
||||
@@ -72,7 +72,7 @@ public class ReactHostTest {
|
||||
|
||||
mActivityController = Robolectric.buildActivity(Activity.class).create().start().resume();
|
||||
|
||||
mReactInstanceDelegate = mock(ReactInstanceDelegate.class);
|
||||
mReactHostDelegate = mock(ReactHostDelegate.class);
|
||||
mReactInstance = mock(ReactInstance.class);
|
||||
mMemoryPressureRouter = mock(MemoryPressureRouter.class);
|
||||
mDevSupportManager = mock(BridgelessDevSupportManager.class);
|
||||
@@ -84,13 +84,13 @@ public class ReactHostTest {
|
||||
whenNew(BridgelessDevSupportManager.class).withAnyArguments().thenReturn(mDevSupportManager);
|
||||
|
||||
doReturn(mJSBundleLoader)
|
||||
.when(mReactInstanceDelegate)
|
||||
.when(mReactHostDelegate)
|
||||
.getJSBundleLoader(ArgumentMatchers.<ReactApplicationContext>any());
|
||||
|
||||
mReactHost =
|
||||
new ReactHost(
|
||||
mActivityController.get().getApplication(),
|
||||
mReactInstanceDelegate,
|
||||
mReactHostDelegate,
|
||||
mComponentFactory,
|
||||
false,
|
||||
null,
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ReactSurfaceTest {
|
||||
@Mock ReactInstanceDelegate mReactInstanceDelegate;
|
||||
@Mock ReactHostDelegate mReactHostDelegate;
|
||||
@Mock EventDispatcher mEventDispatcher;
|
||||
|
||||
private ReactHost mReactHost;
|
||||
@@ -49,7 +49,7 @@ public class ReactSurfaceTest {
|
||||
|
||||
mContext = Robolectric.buildActivity(Activity.class).create().get();
|
||||
|
||||
mReactHost = spy(new ReactHost(mContext, mReactInstanceDelegate, null, false, null, false));
|
||||
mReactHost = spy(new ReactHost(mContext, mReactHostDelegate, null, false, null, false));
|
||||
doAnswer(mockedStartSurface()).when(mReactHost).startSurface(any(ReactSurface.class));
|
||||
doAnswer(mockedStartSurface()).when(mReactHost).prerenderSurface(any(ReactSurface.class));
|
||||
doAnswer(mockedStopSurface()).when(mReactHost).stopSurface(any(ReactSurface.class));
|
||||
|
||||
Reference in New Issue
Block a user