Skip to content

Commit 36e6971

Browse files
javachefacebook-github-bot
authored andcommitted
Move defaults for DevSupportManagerFactory.create() into the interface signature (#57429)
Summary: 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
1 parent 97aa7ad commit 36e6971

3 files changed

Lines changed: 20 additions & 18 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,11 @@ public final class com/facebook/react/devsupport/DevSupportManagerBase$Companion
19501950
public abstract interface class com/facebook/react/devsupport/DevSupportManagerFactory {
19511951
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;
19521952
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;
1953+
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;
1954+
}
1955+
1956+
public final class com/facebook/react/devsupport/DevSupportManagerFactory$DefaultImpls {
1957+
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;
19531958
}
19541959

19551960
public final class com/facebook/react/devsupport/DoubleTapReloadRecognizer {
@@ -3017,6 +3022,8 @@ public final class com/facebook/react/runtime/ReactHostImpl : com/facebook/react
30173022
public fun <init> (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
30183023
public synthetic fun <init> (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
30193024
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZZ)V
3025+
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZZLcom/facebook/react/devsupport/DevSupportManagerFactory;)V
3026+
public synthetic fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZZLcom/facebook/react/devsupport/DevSupportManagerFactory;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
30203027
public fun addBeforeDestroyListener (Lkotlin/jvm/functions/Function0;)V
30213028
public fun addReactInstanceEventListener (Lcom/facebook/react/ReactInstanceEventListener;)V
30223029
public fun createSurface (Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Lcom/facebook/react/interfaces/fabric/ReactSurface;

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public interface DevSupportManagerFactory {
4848
public fun create(
4949
applicationContext: Context,
5050
reactInstanceManagerHelper: ReactInstanceDevHelper,
51-
packagerPathForJSBundleName: String?,
52-
enableOnCreate: Boolean,
53-
redBoxHandler: RedBoxHandler?,
54-
devBundleDownloadListener: DevBundleDownloadListener?,
55-
minNumShakes: Int,
56-
customPackagerCommandHandlers: Map<String, RequestHandler>?,
57-
surfaceDelegateFactory: SurfaceDelegateFactory?,
58-
devLoadingViewManager: DevLoadingViewManager?,
59-
pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?,
60-
useDevSupport: Boolean,
51+
packagerPathForJSBundleName: String? = null,
52+
enableOnCreate: Boolean = true,
53+
redBoxHandler: RedBoxHandler? = null,
54+
devBundleDownloadListener: DevBundleDownloadListener? = null,
55+
minNumShakes: Int = 2,
56+
customPackagerCommandHandlers: Map<String, RequestHandler>? = null,
57+
surfaceDelegateFactory: SurfaceDelegateFactory? = null,
58+
devLoadingViewManager: DevLoadingViewManager? = null,
59+
pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager? = null,
60+
useDevSupport: Boolean = true,
6161
): DevSupportManager
6262
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ public class ReactHostImpl(
113113
applicationContext = context.applicationContext,
114114
reactInstanceManagerHelper = reactHostImplDevHelper,
115115
packagerPathForJSBundleName = reactHostDelegate.jsMainModulePath,
116-
enableOnCreate = true,
117-
redBoxHandler = null,
118-
devBundleDownloadListener = null,
119-
minNumShakes = 2,
120-
customPackagerCommandHandlers = null,
121-
surfaceDelegateFactory = null,
122-
devLoadingViewManager = null,
123-
pausedInDebuggerOverlayManager = null,
124116
useDevSupport = useDevSupport,
125117
)
126118
.also { devSupportManager ->
@@ -156,12 +148,14 @@ public class ReactHostImpl(
156148

157149
@Volatile private var hostInvalidated = false
158150

151+
@JvmOverloads
159152
public constructor(
160153
context: Context,
161154
delegate: ReactHostDelegate,
162155
componentFactory: ComponentFactory,
163156
allowPackagerServerAccess: Boolean,
164157
useDevSupport: Boolean,
158+
devSupportManagerFactory: DevSupportManagerFactory? = null,
165159
) : this(
166160
context,
167161
delegate,
@@ -170,6 +164,7 @@ public class ReactHostImpl(
170164
Task.UI_THREAD_EXECUTOR,
171165
allowPackagerServerAccess,
172166
useDevSupport,
167+
devSupportManagerFactory,
173168
)
174169

175170
public override val lifecycleState: LifecycleState

0 commit comments

Comments
 (0)