From 2a0c1e6a9e98c19101dc89b9adba4a990cd6902c Mon Sep 17 00:00:00 2001 From: Christian Falch Date: Fri, 16 May 2025 07:52:01 -0700 Subject: [PATCH] make DevServerHelper open (#51323) Summary: Expo inherits from the DevServerHelper class, and needs it to be declared as open, the same goes for its public interface. Expo is using this in `DevLauncherDevServerHelper` and overrides the methods: - getDevServerBundleURL - getDevServerSplitBundleURL - getSourceUrl - getSourceMapUrl - isPackagerRunning This PR fixes this by adding the open to the class and to the methods that should be open ## Changelog: [ANDROID] [FIXED] - Made DevServerHelper and its method open so that they can be overridden. Pull Request resolved: https://github.com/facebook/react-native/pull/51323 Test Plan: Verify that we can build against Expo. Reviewed By: cipolleschi Differential Revision: D74876479 Pulled By: cortinico fbshipit-source-id: 0037d6f7cee190a690ec3ec59896df04f46797b2 --- .../react-native/ReactAndroid/api/ReactAndroid.api | 12 ++++++------ .../com/facebook/react/devsupport/DevServerHelper.kt | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 3a50bd2e0a3..1fe98eb7201 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1947,7 +1947,7 @@ public final class com/facebook/react/devsupport/DefaultDevLoadingViewImplementa public final fun setDevLoadingEnabled (Z)V } -public final class com/facebook/react/devsupport/DevServerHelper { +public class com/facebook/react/devsupport/DevServerHelper { public fun (Lcom/facebook/react/modules/debug/interfaces/DeveloperSettings;Landroid/content/Context;Lcom/facebook/react/packagerconnection/PackagerConnectionSettings;)V public final fun closeInspectorConnection ()V public final fun closePackagerConnection ()V @@ -1956,12 +1956,12 @@ public final class com/facebook/react/devsupport/DevServerHelper { public final fun downloadBundleFromURL (Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;Ljava/io/File;Ljava/lang/String;Lcom/facebook/react/devsupport/BundleDownloader$BundleInfo;Lokhttp3/Request$Builder;)V public static synthetic fun downloadBundleFromURL$default (Lcom/facebook/react/devsupport/DevServerHelper;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;Ljava/io/File;Ljava/lang/String;Lcom/facebook/react/devsupport/BundleDownloader$BundleInfo;Lokhttp3/Request$Builder;ILjava/lang/Object;)V public final fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File; - public final fun getDevServerBundleURL (Ljava/lang/String;)Ljava/lang/String; - public final fun getDevServerSplitBundleURL (Ljava/lang/String;)Ljava/lang/String; - public final fun getSourceMapUrl (Ljava/lang/String;)Ljava/lang/String; - public final fun getSourceUrl (Ljava/lang/String;)Ljava/lang/String; + public fun getDevServerBundleURL (Ljava/lang/String;)Ljava/lang/String; + public fun getDevServerSplitBundleURL (Ljava/lang/String;)Ljava/lang/String; + public fun getSourceMapUrl (Ljava/lang/String;)Ljava/lang/String; + public fun getSourceUrl (Ljava/lang/String;)Ljava/lang/String; public final fun getWebsocketProxyURL ()Ljava/lang/String; - public final fun isPackagerRunning (Lcom/facebook/react/devsupport/interfaces/PackagerStatusCallback;)V + public fun isPackagerRunning (Lcom/facebook/react/devsupport/interfaces/PackagerStatusCallback;)V public final fun openDebugger (Lcom/facebook/react/bridge/ReactContext;Ljava/lang/String;)V public final fun openInspectorConnection ()V public final fun openPackagerConnection (Ljava/lang/String;Lcom/facebook/react/devsupport/DevServerHelper$PackagerCommandListener;)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt index 9d4d79b7d94..1e5084ef2a8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.kt @@ -59,7 +59,7 @@ import okio.Okio */ @SuppressLint( "StaticFieldLeak") // TODO: This entire class should be rewritten to don't use AsyncTask -public class DevServerHelper( +public open class DevServerHelper( private val settings: DeveloperSettings, private val applicationContext: Context, private val packagerConnectionSettings: PackagerConnectionSettings @@ -287,20 +287,20 @@ public class DevServerHelper( additionalOptionsBuilder.toString()) } - public fun getDevServerBundleURL(jsModulePath: String): String = + public open fun getDevServerBundleURL(jsModulePath: String): String = createBundleURL(jsModulePath, BundleType.BUNDLE, packagerConnectionSettings.debugServerHost) - public fun getDevServerSplitBundleURL(jsModulePath: String): String = + public open fun getDevServerSplitBundleURL(jsModulePath: String): String = createSplitBundleURL(jsModulePath, packagerConnectionSettings.debugServerHost) - public fun isPackagerRunning(callback: PackagerStatusCallback) { + public open fun isPackagerRunning(callback: PackagerStatusCallback) { packagerStatusCheck.run(packagerConnectionSettings.debugServerHost, callback) } - public fun getSourceMapUrl(mainModuleName: String): String = + public open fun getSourceMapUrl(mainModuleName: String): String = createBundleURL(mainModuleName, BundleType.MAP) - public fun getSourceUrl(mainModuleName: String): String = + public open fun getSourceUrl(mainModuleName: String): String = createBundleURL(mainModuleName, BundleType.BUNDLE) /**