From f5dc3991a275eb809dd89873c084bdbb19352b0f Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 3 Jul 2026 11:03:44 -0700 Subject: [PATCH] Move defaults for `DevSupportManagerFactory.create()` into the interface signature (#57429) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/react/react-native/pull/57429 The optional parameters on `DevSupportManagerFactory.create()` (the New Architecture overload) all have canonical defaults, but callers were forced to pass every one explicitly. Move the defaults into the interface signature so callers only specify the parameters that vary — `applicationContext`, `reactInstanceManagerHelper`, `packagerPathForJSBundleName`, and `useDevSupport`. This also lets external factories inject a `customPackagerCommandHandlers` map without having to repeat the eleven other arguments. `ReactHostImpl` is updated to use the shorter form. JVM signatures are unchanged (Kotlin default values on abstract interface methods don't emit bridge methods), so no ABI change for Java callers. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D110599799 fbshipit-source-id: 02d4b886f3131b47ed830a7e603cb60cbdd96b02 --- .../ReactAndroid/api/ReactAndroid.api | 7 +++++++ .../devsupport/DevSupportManagerFactory.kt | 20 +++++++++---------- .../facebook/react/runtime/ReactHostImpl.kt | 11 +++------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 53e1ca1c263..57ed2ec2aa7 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1950,6 +1950,11 @@ public final class com/facebook/react/devsupport/DevSupportManagerBase$Companion public abstract interface class com/facebook/react/devsupport/DevSupportManagerFactory { public abstract fun create (Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;)Lcom/facebook/react/devsupport/interfaces/DevSupportManager; public abstract fun create (Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;Z)Lcom/facebook/react/devsupport/interfaces/DevSupportManager; + public static synthetic fun create$default (Lcom/facebook/react/devsupport/DevSupportManagerFactory;Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;ZILjava/lang/Object;)Lcom/facebook/react/devsupport/interfaces/DevSupportManager; +} + +public final class com/facebook/react/devsupport/DevSupportManagerFactory$DefaultImpls { + public static synthetic fun create$default (Lcom/facebook/react/devsupport/DevSupportManagerFactory;Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;ZILjava/lang/Object;)Lcom/facebook/react/devsupport/interfaces/DevSupportManager; } public final class com/facebook/react/devsupport/DoubleTapReloadRecognizer { @@ -3017,6 +3022,8 @@ public final class com/facebook/react/runtime/ReactHostImpl : com/facebook/react public fun (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;ZZLcom/facebook/react/devsupport/DevSupportManagerFactory;)V public synthetic fun (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;ZZLcom/facebook/react/devsupport/DevSupportManagerFactory;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZZ)V + public fun (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZZLcom/facebook/react/devsupport/DevSupportManagerFactory;)V + public synthetic fun (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZZLcom/facebook/react/devsupport/DevSupportManagerFactory;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun addBeforeDestroyListener (Lkotlin/jvm/functions/Function0;)V public fun addReactInstanceEventListener (Lcom/facebook/react/ReactInstanceEventListener;)V public fun createSurface (Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Lcom/facebook/react/interfaces/fabric/ReactSurface; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt index 7210d90a4c8..405ae476ded 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt @@ -48,15 +48,15 @@ public interface DevSupportManagerFactory { public fun create( applicationContext: Context, reactInstanceManagerHelper: ReactInstanceDevHelper, - packagerPathForJSBundleName: String?, - enableOnCreate: Boolean, - redBoxHandler: RedBoxHandler?, - devBundleDownloadListener: DevBundleDownloadListener?, - minNumShakes: Int, - customPackagerCommandHandlers: Map?, - surfaceDelegateFactory: SurfaceDelegateFactory?, - devLoadingViewManager: DevLoadingViewManager?, - pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?, - useDevSupport: Boolean, + packagerPathForJSBundleName: String? = null, + enableOnCreate: Boolean = true, + redBoxHandler: RedBoxHandler? = null, + devBundleDownloadListener: DevBundleDownloadListener? = null, + minNumShakes: Int = 2, + customPackagerCommandHandlers: Map? = null, + surfaceDelegateFactory: SurfaceDelegateFactory? = null, + devLoadingViewManager: DevLoadingViewManager? = null, + pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager? = null, + useDevSupport: Boolean = true, ): DevSupportManager } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt index 66fa21ae9df..56ffb409268 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt @@ -113,14 +113,6 @@ public class ReactHostImpl( applicationContext = context.applicationContext, reactInstanceManagerHelper = reactHostImplDevHelper, packagerPathForJSBundleName = reactHostDelegate.jsMainModulePath, - enableOnCreate = true, - redBoxHandler = null, - devBundleDownloadListener = null, - minNumShakes = 2, - customPackagerCommandHandlers = null, - surfaceDelegateFactory = null, - devLoadingViewManager = null, - pausedInDebuggerOverlayManager = null, useDevSupport = useDevSupport, ) .also { devSupportManager -> @@ -156,12 +148,14 @@ public class ReactHostImpl( @Volatile private var hostInvalidated = false + @JvmOverloads public constructor( context: Context, delegate: ReactHostDelegate, componentFactory: ComponentFactory, allowPackagerServerAccess: Boolean, useDevSupport: Boolean, + devSupportManagerFactory: DevSupportManagerFactory? = null, ) : this( context, delegate, @@ -170,6 +164,7 @@ public class ReactHostImpl( Task.UI_THREAD_EXECUTOR, allowPackagerServerAccess, useDevSupport, + devSupportManagerFactory, ) public override val lifecycleState: LifecycleState