Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ public abstract class com/facebook/react/bridge/JSBundleLoader {
public fun <init> ()V
public static final fun createAssetLoader (Landroid/content/Context;Ljava/lang/String;Z)Lcom/facebook/react/bridge/JSBundleLoader;
public static final fun createCachedBundleFromNetworkLoader (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
public static final fun createCachedSplitBundleFromNetworkLoader (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
public static final fun createFileLoader (Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
public static final fun createFileLoader (Ljava/lang/String;Ljava/lang/String;Z)Lcom/facebook/react/bridge/JSBundleLoader;
public abstract fun loadScript (Lcom/facebook/react/bridge/JSBundleLoaderDelegate;)Ljava/lang/String;
Expand All @@ -708,15 +707,13 @@ public abstract class com/facebook/react/bridge/JSBundleLoader {
public final class com/facebook/react/bridge/JSBundleLoader$Companion {
public final fun createAssetLoader (Landroid/content/Context;Ljava/lang/String;Z)Lcom/facebook/react/bridge/JSBundleLoader;
public final fun createCachedBundleFromNetworkLoader (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
public final fun createCachedSplitBundleFromNetworkLoader (Ljava/lang/String;Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
public final fun createFileLoader (Ljava/lang/String;)Lcom/facebook/react/bridge/JSBundleLoader;
public final fun createFileLoader (Ljava/lang/String;Ljava/lang/String;Z)Lcom/facebook/react/bridge/JSBundleLoader;
}

public abstract interface class com/facebook/react/bridge/JSBundleLoaderDelegate {
public abstract fun loadScriptFromAssets (Landroid/content/res/AssetManager;Ljava/lang/String;Z)V
public abstract fun loadScriptFromFile (Ljava/lang/String;Ljava/lang/String;Z)V
public abstract fun loadSplitBundleFromFile (Ljava/lang/String;Ljava/lang/String;)V
public abstract fun setSourceURLs (Ljava/lang/String;Ljava/lang/String;)V
}

Expand Down Expand Up @@ -1865,7 +1862,6 @@ public class com/facebook/react/devsupport/DevServerHelper {
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 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 fun isPackagerRunning (Lcom/facebook/react/devsupport/interfaces/PackagerStatusCallback;)V
Expand All @@ -1890,7 +1886,6 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
public fun createSurfaceDelegate (Ljava/lang/String;)Lcom/facebook/react/common/SurfaceDelegate;
public fun destroyRootView (Landroid/view/View;)V
public fun downloadBundleResourceFromUrlSync (Ljava/lang/String;Ljava/io/File;)Ljava/io/File;
public final fun fetchSplitBundleAndCreateBundleLoader (Ljava/lang/String;Lcom/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader;)V
protected final fun getApplicationContext ()Landroid/content/Context;
public fun getBundleFilePath ()Ljava/lang/String;
public fun getCurrentActivity ()Landroid/app/Activity;
Expand Down Expand Up @@ -1951,11 +1946,6 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
public fun toggleElementInspector ()V
}

public abstract interface class com/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader {
public abstract fun onError (Ljava/lang/String;Ljava/lang/Throwable;)V
public abstract fun onSuccess (Lcom/facebook/react/bridge/JSBundleLoader;)V
}

public final class com/facebook/react/devsupport/DevSupportManagerBase$Companion {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,5 @@ public abstract class JSBundleLoader {
}
}
}

/** Same as [createCachedBundleFromNetworkLoader], but for split bundles in development. */
@JvmStatic
public fun createCachedSplitBundleFromNetworkLoader(
sourceURL: String,
cachedFileLocation: String,
): JSBundleLoader =
object : JSBundleLoader() {
override fun loadScript(delegate: JSBundleLoaderDelegate): String {
return try {
delegate.loadSplitBundleFromFile(cachedFileLocation, sourceURL)
sourceURL
} catch (e: Exception) {
throw DebugServerException.makeGeneric(sourceURL, e.message.orEmpty(), e)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ public interface JSBundleLoaderDelegate {
*/
public fun loadScriptFromFile(fileName: String, sourceURL: String, loadSynchronously: Boolean)

/**
* Load a split JS bundle from the filesystem. See
* [JSBundleLoader.createCachedSplitBundleFromNetworkLoader].
*/
public fun loadSplitBundleFromFile(fileName: String, sourceURL: String)

/**
* This API is used in situations where the JS bundle is being executed not on the device, but on
* a host machine. In that case, we must provide two source URLs for the JS bundle: One to be used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ public open class DevServerHelper(
)
}

private fun createSplitBundleURL(mainModuleID: String, host: String): String =
createBundleURL(mainModuleID, BundleType.BUNDLE, host, true, false)

private fun createBundleURL(
mainModuleID: String,
type: BundleType,
Expand Down Expand Up @@ -302,9 +299,6 @@ public open class DevServerHelper(
public open fun getDevServerBundleURL(jsModulePath: String): String =
createBundleURL(jsModulePath, BundleType.BUNDLE, packagerConnectionSettings.debugServerHost)

public open fun getDevServerSplitBundleURL(jsModulePath: String): String =
createSplitBundleURL(jsModulePath, packagerConnectionSettings.debugServerHost)

public open fun isPackagerRunning(callback: PackagerStatusCallback) {
packagerStatusCheck.run(packagerConnectionSettings.debugServerHost, callback)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import androidx.core.util.Supplier
import com.facebook.common.logging.FLog
import com.facebook.react.R
import com.facebook.react.bridge.DefaultJSExceptionHandler
import com.facebook.react.bridge.JSBundleLoader
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.ReactMarker
import com.facebook.react.bridge.ReactMarkerConstants
Expand Down Expand Up @@ -96,12 +95,6 @@ public abstract class DevSupportManagerBase(
private var pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?,
) : DevSupportManager {

public interface CallbackWithBundleLoader {
public fun onSuccess(bundleLoader: JSBundleLoader)

public fun onError(url: String, cause: Throwable)
}

protected abstract val uniqueTag: String

public final override var currentReactContext: ReactContext? = null
Expand Down Expand Up @@ -187,13 +180,11 @@ public abstract class DevSupportManagerBase(
}
private val customDevOptions = LinkedHashMap<String, DevOptionHandler>()
private val jsBundleDownloadedFile: File
private val jsSplitBundlesDir: File
private val defaultJSExceptionHandler: DefaultJSExceptionHandler = DefaultJSExceptionHandler()
private var redBoxSurfaceDelegate: SurfaceDelegate? = null
private var devOptionsDialog: AlertDialog? = null
private var debugOverlayController: DebugOverlayController? = null
private var devLoadingViewVisible = false
private var pendingJSSplitBundleRequests = 0
private var isReceiverRegistered = false
private var isShakeDetectorStarted = false
private var isDevSupportEnabled = false
Expand Down Expand Up @@ -224,8 +215,6 @@ public abstract class DevSupportManagerBase(
val subclassTag = uniqueTag
val bundleFile = subclassTag + "ReactNativeDevBundle.js"
jsBundleDownloadedFile = File(applicationContext.filesDir, bundleFile)
val splitBundlesDir = subclassTag.lowercase() + "_dev_js_split_bundles"
jsSplitBundlesDir = applicationContext.getDir(splitBundlesDir, Context.MODE_PRIVATE)
devSupportEnabled = enableOnCreate
if (devLoadingViewManager == null) {
devLoadingViewManager = DefaultDevLoadingViewImplementation(reactInstanceDevHelper)
Expand Down Expand Up @@ -762,64 +751,6 @@ public abstract class DevSupportManagerBase(
devLoadingViewVisible = false
}

public fun fetchSplitBundleAndCreateBundleLoader(
bundlePath: String,
callback: CallbackWithBundleLoader,
) {
val bundleUrl = devServerHelper.getDevServerSplitBundleURL(bundlePath)
// The bundle path may contain the '/' character, which is not allowed in file names.
val bundleFile = File(jsSplitBundlesDir, bundlePath.replace("/".toRegex(), "_") + ".jsbundle")
UiThreadUtil.runOnUiThread {
showSplitBundleDevLoadingView(bundleUrl)
devServerHelper.downloadBundleFromURL(
object : DevBundleDownloadListener {
override fun onSuccess() {
UiThreadUtil.runOnUiThread { hideSplitBundleDevLoadingView() }

val context: ReactContext? = this@DevSupportManagerBase.currentReactContext
if (context == null || !context.hasActiveReactInstance()) {
return
}

val bundleLoader =
JSBundleLoader.createCachedSplitBundleFromNetworkLoader(
bundleUrl,
bundleFile.absolutePath,
)
callback.onSuccess(bundleLoader)
}

override fun onProgress(status: String?, done: Int?, total: Int?, percent: Int?) {
devLoadingViewManager?.updateProgress(status, done, total, percent)
}

override fun onFailure(cause: Exception) {
UiThreadUtil.runOnUiThread {
this@DevSupportManagerBase.hideSplitBundleDevLoadingView()
}
callback.onError(bundleUrl, cause)
}
},
bundleFile,
bundleUrl,
null,
)
}
}

@UiThread
private fun showSplitBundleDevLoadingView(bundleUrl: String) {
showDevLoadingViewForUrl(bundleUrl)
pendingJSSplitBundleRequests++
}

@UiThread
private fun hideSplitBundleDevLoadingView() {
if (--pendingJSSplitBundleRequests == 0) {
hideDevLoadingView()
}
}

override fun isPackagerRunning(callback: PackagerStatusCallback) {
val checkPackagerRunning = Runnable { devServerHelper.isPackagerRunning(callback) }
packagerLocationCustomizer?.run(checkPackagerRunning) ?: checkPackagerRunning.run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl)
throw UnsupportedOperationException("Unimplemented method 'loadScriptFromFile'")
}

override fun loadSplitBundleFromFile(fileName: String, sourceURL: String) {
throw UnsupportedOperationException("Unimplemented method 'loadSplitBundleFromFile'")
}

override fun setSourceURLs(deviceURL: String, remoteURL: String) {
throw UnsupportedOperationException("Unimplemented method 'setSourceURLs'")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@ internal class ReactInstance(
loadJSBundleFromFile(fileName, sourceURL)
}

override fun loadSplitBundleFromFile(fileName: String, sourceURL: String) {
loadJSBundleFromFile(fileName, sourceURL)
}

override fun loadScriptFromAssets(
assetManager: AssetManager,
assetURL: String,
Expand Down
Loading