mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Convert com.facebook.react.runtime.ReactHostImpl to Kotlin (#51017)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51017 Changelog: [Internal] Reviewed By: rshest Differential Revision: D73846053 fbshipit-source-id: 98017000e8f10df4156b232bc8b5d6e132502ea5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7e5a2663f9
commit
5413304530
@@ -3222,9 +3222,9 @@ public abstract class com/facebook/react/runtime/JSRuntimeFactory {
|
||||
public fun <init> (Lcom/facebook/jni/HybridData;)V
|
||||
}
|
||||
|
||||
public class com/facebook/react/runtime/ReactHostImpl : com/facebook/react/ReactHost {
|
||||
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;ZZ)V
|
||||
public final class com/facebook/react/runtime/ReactHostImpl : com/facebook/react/ReactHost {
|
||||
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
|
||||
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
|
||||
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZZ)V
|
||||
public fun addBeforeDestroyListener (Lkotlin/jvm/functions/Function0;)V
|
||||
public fun addReactInstanceEventListener (Lcom/facebook/react/ReactInstanceEventListener;)V
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
package com.facebook.react.bridge
|
||||
|
||||
/** Listener interface for memory pressure events. */
|
||||
public interface MemoryPressureListener {
|
||||
public fun interface MemoryPressureListener {
|
||||
/** Called when the system generates a memory warning. */
|
||||
public fun handleMemoryPressure(level: Int)
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ internal class BridgelessAtomicRef<T>(
|
||||
@field:Volatile @get:Synchronized @get:JvmName("getNullable") var value: T? = null
|
||||
) {
|
||||
|
||||
internal interface Provider<T> {
|
||||
internal fun interface Provider<T> {
|
||||
fun get(): T
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -24,6 +24,7 @@ import com.facebook.react.bridge.RuntimeExecutor
|
||||
import com.facebook.react.bridge.RuntimeScheduler
|
||||
import com.facebook.react.bridge.UIManager
|
||||
import com.facebook.react.bridge.queue.ReactQueueConfiguration
|
||||
import com.facebook.react.common.annotations.FrameworkAPI
|
||||
import com.facebook.react.common.annotations.VisibleForTesting
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitecture
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
|
||||
@@ -35,6 +36,7 @@ import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHol
|
||||
message =
|
||||
"This class is deprecated, please to migrate to new architecture using [com.facebook.react.defaults.DefaultReactHost] instead.")
|
||||
@LegacyArchitecture
|
||||
@FrameworkAPI
|
||||
internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl) : CatalystInstance {
|
||||
|
||||
override fun handleMemoryPressure(level: Int) {
|
||||
@@ -94,13 +96,13 @@ internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl)
|
||||
|
||||
@get:Deprecated("Deprecated in Java")
|
||||
public override val javaScriptContextHolder: JavaScriptContextHolder
|
||||
get() = reactHost.getJavaScriptContextHolder()!!
|
||||
get() = reactHost.javaScriptContextHolder!!
|
||||
|
||||
@Suppress("INAPPLICABLE_JVM_NAME")
|
||||
@get:Deprecated("Deprecated in Java")
|
||||
@get:JvmName("getJSCallInvokerHolder") // This is needed to keep backward compatibility
|
||||
public override val jsCallInvokerHolder: CallInvokerHolder
|
||||
get() = reactHost.getJSCallInvokerHolder()!!
|
||||
get() = reactHost.jsCallInvokerHolder!!
|
||||
|
||||
public override val nativeMethodCallInvokerHolder: NativeMethodCallInvokerHolder
|
||||
get() =
|
||||
@@ -117,13 +119,13 @@ internal class BridgelessCatalystInstance(private val reactHost: ReactHostImpl)
|
||||
reactHost.getNativeModule(moduleName)
|
||||
|
||||
public override val nativeModules: Collection<NativeModule>
|
||||
get() = reactHost.getNativeModules()
|
||||
get() = reactHost.nativeModules
|
||||
|
||||
public override val reactQueueConfiguration: ReactQueueConfiguration
|
||||
get() = reactHost.reactQueueConfiguration!!
|
||||
|
||||
public override val runtimeExecutor: RuntimeExecutor?
|
||||
get() = reactHost.getRuntimeExecutor()
|
||||
get() = reactHost.runtimeExecutor
|
||||
|
||||
public override val runtimeScheduler: RuntimeScheduler
|
||||
get() = throw UnsupportedOperationException("Unimplemented method 'getRuntimeScheduler'")
|
||||
|
||||
+2
-1
@@ -63,6 +63,7 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
|
||||
@Deprecated("This method is deprecated, please use UIManagerHelper.getUIManager() instead.")
|
||||
override fun getFabricUIManager(): UIManager? = reactHost.uiManager
|
||||
|
||||
@OptIn(FrameworkAPI::class)
|
||||
override fun getCatalystInstance(): CatalystInstance {
|
||||
if (ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
|
||||
throw UnsupportedOperationException(
|
||||
@@ -136,7 +137,7 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
|
||||
override fun <T : NativeModule> hasNativeModule(nativeModuleInterface: Class<T>): Boolean =
|
||||
reactHost.hasNativeModule(nativeModuleInterface)
|
||||
|
||||
override fun getNativeModules(): MutableCollection<NativeModule> = reactHost.nativeModules
|
||||
override fun getNativeModules(): Collection<NativeModule> = reactHost.nativeModules
|
||||
|
||||
override fun <T : NativeModule> getNativeModule(nativeModuleInterface: Class<T>): T? =
|
||||
reactHost.getNativeModule(nativeModuleInterface)
|
||||
|
||||
-1825
File diff suppressed because it is too large
Load Diff
+1471
File diff suppressed because it is too large
Load Diff
+4
@@ -13,6 +13,8 @@ import android.view.View
|
||||
import com.facebook.react.bridge.JSBundleLoader
|
||||
import com.facebook.react.bridge.JavaScriptExecutorFactory
|
||||
import com.facebook.react.bridge.ReactContext
|
||||
import com.facebook.react.common.annotations.FrameworkAPI
|
||||
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
||||
import com.facebook.react.devsupport.ReactInstanceDevHelper
|
||||
import com.facebook.react.interfaces.TaskInterface
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule
|
||||
@@ -23,6 +25,8 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
|
||||
* This allows [BridgelessDevSupportHelper] and other classes inside the .devsupport package to
|
||||
* communicate with the Bridgeless infrastructure without exposing public APIs.
|
||||
*/
|
||||
@UnstableReactNativeAPI
|
||||
@OptIn(FrameworkAPI::class)
|
||||
internal class ReactHostImplDevHelper(private val delegate: ReactHostImpl) :
|
||||
ReactInstanceDevHelper {
|
||||
|
||||
|
||||
+4
@@ -10,11 +10,15 @@ package com.facebook.react.runtime
|
||||
import com.facebook.jni.HybridData
|
||||
import com.facebook.proguard.annotations.DoNotStripAny
|
||||
import com.facebook.react.bridge.UiThreadUtil
|
||||
import com.facebook.react.common.annotations.FrameworkAPI
|
||||
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
||||
import com.facebook.soloader.SoLoader
|
||||
import java.io.Closeable
|
||||
import java.util.concurrent.Executor
|
||||
|
||||
@DoNotStripAny
|
||||
@UnstableReactNativeAPI
|
||||
@OptIn(FrameworkAPI::class)
|
||||
internal class ReactHostInspectorTarget(reactHostImpl: ReactHostImpl) : Closeable {
|
||||
// fbjni looks for the exact name "mHybridData":
|
||||
// https://github.com/facebookincubator/fbjni/blob/5587a7fd2b191656be9391a3832ce04c034009a5/cxx/fbjni/detail/Hybrid.h#L310
|
||||
|
||||
+3
@@ -18,6 +18,8 @@ import com.facebook.react.ReactHost
|
||||
import com.facebook.react.bridge.Arguments
|
||||
import com.facebook.react.bridge.NativeMap
|
||||
import com.facebook.react.bridge.UiThreadUtil
|
||||
import com.facebook.react.common.annotations.FrameworkAPI
|
||||
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
||||
import com.facebook.react.common.annotations.VisibleForTesting
|
||||
import com.facebook.react.fabric.SurfaceHandlerBinding
|
||||
import com.facebook.react.interfaces.TaskInterface
|
||||
@@ -30,6 +32,7 @@ import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
/** A class responsible for creating and rendering a full-screen React surface. */
|
||||
@ThreadSafe
|
||||
@OptIn(FrameworkAPI::class, UnstableReactNativeAPI::class)
|
||||
public class ReactSurfaceImpl
|
||||
@VisibleForTesting
|
||||
internal constructor(
|
||||
|
||||
+3
@@ -17,6 +17,8 @@ import android.view.View
|
||||
import com.facebook.common.logging.FLog
|
||||
import com.facebook.react.ReactRootView
|
||||
import com.facebook.react.bridge.ReactContext
|
||||
import com.facebook.react.common.annotations.FrameworkAPI
|
||||
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
||||
import com.facebook.react.config.ReactFeatureFlags
|
||||
import com.facebook.react.uimanager.IllegalViewOperationException
|
||||
import com.facebook.react.uimanager.JSPointerDispatcher
|
||||
@@ -29,6 +31,7 @@ import java.util.Objects
|
||||
* A view created by [com.facebook.react.interfaces.fabric.ReactSurface] that's responsible for
|
||||
* rendering a React component.
|
||||
*/
|
||||
@OptIn(FrameworkAPI::class, UnstableReactNativeAPI::class)
|
||||
public class ReactSurfaceView(context: Context?, private val surface: ReactSurfaceImpl) :
|
||||
ReactRootView(context) {
|
||||
private val jsTouchDispatcher: JSTouchDispatcher = JSTouchDispatcher(this)
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ package com.facebook.react.runtime
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import com.facebook.react.bridge.WritableNativeArray
|
||||
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
||||
import com.facebook.react.common.annotations.FrameworkAPI
|
||||
import com.facebook.react.fabric.FabricUIManager
|
||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
|
||||
import com.facebook.react.uimanager.UIManagerModule
|
||||
@@ -46,7 +46,7 @@ import org.robolectric.annotation.Config
|
||||
ShadowNativeLoader::class,
|
||||
ShadowArguments::class,
|
||||
ShadowWritableNativeArray::class])
|
||||
@OptIn(UnstableReactNativeAPI::class)
|
||||
@OptIn(FrameworkAPI::class)
|
||||
class BridgelessReactContextTest {
|
||||
private lateinit var context: Context
|
||||
private lateinit var reactHost: ReactHostImpl
|
||||
|
||||
Reference in New Issue
Block a user