Kotlinify ReactInstanceManagerInspectorTarget + make internal (#51196)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51196

As per title.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D74325454

fbshipit-source-id: a490614c83bd69660ecdd4cc8439a1a168de3010
This commit is contained in:
Fabrizio Cucci authored and Facebook GitHub Bot committed 2025-05-08 07:47:57 -07:00
1 parent 69fe957dcf
commit 090a8da0d1
3 files changed
+69 -88

No files matched your search

@@ -1136,19 +1136,6 @@ public final class com/facebook/react/bridge/ReactCxxErrorHandler {
public static final fun setHandleErrorFunc (Ljava/lang/Object;Ljava/lang/reflect/Method;)V
}
public class com/facebook/react/bridge/ReactInstanceManagerInspectorTarget : java/lang/AutoCloseable {
public fun <init> (Lcom/facebook/react/bridge/ReactInstanceManagerInspectorTarget$TargetDelegate;)V
public fun close ()V
public fun sendDebuggerResumeCommand ()V
}
public abstract interface class com/facebook/react/bridge/ReactInstanceManagerInspectorTarget$TargetDelegate {
public abstract fun getMetadata ()Ljava/util/Map;
public abstract fun loadNetworkResource (Ljava/lang/String;Lcom/facebook/react/devsupport/inspector/InspectorNetworkRequestListener;)V
public abstract fun onReload ()V
public abstract fun onSetPausedInDebuggerMessage (Ljava/lang/String;)V
}
public class com/facebook/react/bridge/ReactMarker {
public fun <init> ()V
public static fun addFabricListener (Lcom/facebook/react/bridge/ReactMarker$FabricMarkerListener;)V
@@ -1,75 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.bridge;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStripAny;
import com.facebook.react.common.annotations.internal.LegacyArchitecture;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import com.facebook.react.devsupport.inspector.InspectorNetworkRequestListener;
import java.util.Map;
import java.util.concurrent.Executor;
import javax.annotation.Nullable;
@DoNotStripAny
@Nullsafe(Nullsafe.Mode.LOCAL)
@LegacyArchitecture
public class ReactInstanceManagerInspectorTarget implements AutoCloseable {
@DoNotStripAny
public interface TargetDelegate {
/** Android implementation for {@code HostTargetDelegate::getMetadata} */
public Map<String, String> getMetadata();
/** Android implementation for {@code HostTargetDelegate::onReload} */
public void onReload();
/** Android implementation for {@code HostTargetDelegate::onSetPausedInDebuggerMessage} */
public void onSetPausedInDebuggerMessage(@Nullable String message);
/** Android implementation for {@code HostTargetDelegate::loadNetworkResource} */
public void loadNetworkResource(String url, InspectorNetworkRequestListener listener);
}
private final HybridData mHybridData;
public ReactInstanceManagerInspectorTarget(TargetDelegate delegate) {
mHybridData =
initHybrid(
new Executor() {
@Override
public void execute(Runnable command) {
if (UiThreadUtil.isOnUiThread()) {
command.run();
} else {
UiThreadUtil.runOnUiThread(command);
}
}
},
delegate);
}
private native HybridData initHybrid(Executor executor, TargetDelegate delegate);
public native void sendDebuggerResumeCommand();
public void close() {
mHybridData.resetNative();
}
/*internal*/ boolean isValid() {
return mHybridData.isValid();
}
static {
LegacyArchitectureLogger.assertLegacyArchitecture(
"ReactInstanceManagerInspectorTarget", LegacyArchitectureLogLevel.WARNING);
BridgeSoLoader.staticInit();
}
}
@@ -0,0 +1,69 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.bridge
import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStripAny
import com.facebook.react.common.annotations.internal.LegacyArchitecture
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
import com.facebook.react.devsupport.inspector.InspectorNetworkRequestListener
import java.util.concurrent.Executor
@DoNotStripAny
@LegacyArchitecture
internal class ReactInstanceManagerInspectorTarget(delegate: TargetDelegate) : AutoCloseable {
@DoNotStripAny
public interface TargetDelegate {
/** Android implementation for [HostTargetDelegate::getMetadata] */
public fun getMetadata(): Map<String, String>
/** Android implementation for [HostTargetDelegate::onReload] */
public fun onReload()
/** Android implementation for [HostTargetDelegate::onSetPausedInDebuggerMessage] */
public fun onSetPausedInDebuggerMessage(message: String?)
/** Android implementation for [HostTargetDelegate::loadNetworkResource] */
public fun loadNetworkResource(url: String, listener: InspectorNetworkRequestListener)
}
@Suppress("NoHungarianNotation")
private val mHybridData: HybridData =
initHybrid(
Executor { command ->
if (UiThreadUtil.isOnUiThread()) {
command.run()
} else {
UiThreadUtil.runOnUiThread(command)
}
},
delegate)
private external fun initHybrid(executor: Executor, delegate: TargetDelegate): HybridData
public external fun sendDebuggerResumeCommand()
public override fun close() {
mHybridData.resetNative()
}
@JvmName("isValid")
internal fun isValid(): Boolean {
return mHybridData.isValid
}
private companion object {
init {
LegacyArchitectureLogger.assertLegacyArchitecture(
"ReactInstanceManagerInspectorTarget", LegacyArchitectureLogLevel.WARNING)
BridgeSoLoader.staticInit()
}
}
}