From fbe4c0ed347156a7ea24da29e09083a499c80cf5 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 18 Nov 2024 17:34:59 -0800 Subject: [PATCH] Remove jsBundleLoader from DefaultReactHost.getDefaultReactHost (#47684) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47684 jsBundleLoader parameter was added into DefaultReactHost.getDefaultReactHost but we decided to revert this change. We want to keep DefaultReactHost.getDefaultReactHost as simple as possible and we don't want to include this change in 0.77 changelog: [Android][Breaking] Remove jsBundleLoader from DefaultReactHost.getDefaultReactHost() Reviewed By: shwanton Differential Revision: D66131197 fbshipit-source-id: 7451bb55d7953d3282b23d23ad15e91bae71ff24 --- .../ReactAndroid/api/ReactAndroid.api | 8 +++---- .../react/defaults/DefaultReactHost.kt | 24 ++++++++----------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 16be4f9f3989f9..a55f39188d03a8 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -2037,10 +2037,10 @@ public class com/facebook/react/defaults/DefaultReactActivityDelegate : com/face public final class com/facebook/react/defaults/DefaultReactHost { public static final field INSTANCE Lcom/facebook/react/defaults/DefaultReactHost; public static final fun getDefaultReactHost (Landroid/content/Context;Lcom/facebook/react/ReactNativeHost;)Lcom/facebook/react/ReactHost; - public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lcom/facebook/react/bridge/JSBundleLoader;)Lcom/facebook/react/ReactHost; - public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lcom/facebook/react/bridge/JSBundleLoader;Lkotlin/jvm/functions/Function1;)Lcom/facebook/react/ReactHost; - public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lcom/facebook/react/bridge/JSBundleLoader;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; - public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lcom/facebook/react/bridge/JSBundleLoader;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; + public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;)Lcom/facebook/react/ReactHost; + public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lkotlin/jvm/functions/Function1;)Lcom/facebook/react/ReactHost; + public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; + public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lcom/facebook/react/ReactHost; } public abstract class com/facebook/react/defaults/DefaultReactNativeHost : com/facebook/react/ReactNativeHost { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt index 1c17bc6e79c6ee..f0d0cdcaccb0d2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt @@ -61,7 +61,6 @@ public object DefaultReactHost { isHermesEnabled: Boolean = true, useDevSupport: Boolean = ReactBuildConfig.DEBUG, cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(), - jsBundleLoader: JSBundleLoader? = null, ): ReactHost = getDefaultReactHost( context, @@ -71,8 +70,7 @@ public object DefaultReactHost { jsBundleFilePath, isHermesEnabled, useDevSupport, - cxxReactPackageProviders, - jsBundleLoader) { + cxxReactPackageProviders) { throw it } @@ -107,22 +105,20 @@ public object DefaultReactHost { isHermesEnabled: Boolean = true, useDevSupport: Boolean = ReactBuildConfig.DEBUG, cxxReactPackageProviders: List<(ReactContext) -> CxxReactPackage> = emptyList(), - jsBundleLoader: JSBundleLoader? = null, exceptionHandler: (Exception) -> Unit = { throw it }, ): ReactHost { if (reactHost == null) { val bundleLoader = - jsBundleLoader - ?: if (jsBundleFilePath != null) { - if (jsBundleFilePath.startsWith("assets://")) { - JSBundleLoader.createAssetLoader(context, jsBundleFilePath, true) - } else { - JSBundleLoader.createFileLoader(jsBundleFilePath) - } - } else { - JSBundleLoader.createAssetLoader(context, "assets://$jsBundleAssetPath", true) - } + if (jsBundleFilePath != null) { + if (jsBundleFilePath.startsWith("assets://")) { + JSBundleLoader.createAssetLoader(context, jsBundleFilePath, true) + } else { + JSBundleLoader.createFileLoader(jsBundleFilePath) + } + } else { + JSBundleLoader.createAssetLoader(context, "assets://$jsBundleAssetPath", true) + } val jsRuntimeFactory = if (isHermesEnabled) HermesInstance() else JSCInstance() val defaultTmmDelegateBuilder = DefaultTurboModuleManagerDelegate.Builder() cxxReactPackageProviders.forEach { defaultTmmDelegateBuilder.addCxxReactPackage(it) }