mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove dead Inspector.kt/JInspector.h/.cpp code (#53403)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53403 This code is Legacy and totally unused. It should be safe to remove it altogether. This class is public but no one is using it in OSS + no one should be using it, so I don't think we'll need the full deprecation cycle for it. Changelog: [Android] [Removed] - Removed unused `Inspector` public class from React Android Reviewed By: cipolleschi Differential Revision: D80711515 fbshipit-source-id: 83134851877fcbccd50f7a5b75b2ab8906b3416a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
0530ea3349
commit
cf528526cc
@@ -744,34 +744,6 @@ public abstract class com/facebook/react/bridge/GuardedRunnable : java/lang/Runn
|
||||
public abstract fun runGuarded ()V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/bridge/Inspector {
|
||||
public static final field Companion Lcom/facebook/react/bridge/Inspector$Companion;
|
||||
public static final fun connect (ILcom/facebook/react/bridge/Inspector$RemoteConnection;)Lcom/facebook/react/bridge/Inspector$LocalConnection;
|
||||
public static final fun getPages ()Ljava/util/List;
|
||||
}
|
||||
|
||||
public final class com/facebook/react/bridge/Inspector$Companion {
|
||||
public final fun connect (ILcom/facebook/react/bridge/Inspector$RemoteConnection;)Lcom/facebook/react/bridge/Inspector$LocalConnection;
|
||||
public final fun getPages ()Ljava/util/List;
|
||||
}
|
||||
|
||||
public final class com/facebook/react/bridge/Inspector$LocalConnection {
|
||||
public final fun disconnect ()V
|
||||
public final fun sendMessage (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/bridge/Inspector$Page {
|
||||
public final fun getId ()I
|
||||
public final fun getTitle ()Ljava/lang/String;
|
||||
public final fun getVM ()Ljava/lang/String;
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/bridge/Inspector$RemoteConnection {
|
||||
public abstract fun onDisconnect ()V
|
||||
public abstract fun onMessage (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public class com/facebook/react/bridge/JSApplicationCausedNativeException : java/lang/RuntimeException {
|
||||
public fun <init> (Ljava/lang/String;)V
|
||||
public fun <init> (Ljava/lang/String;Ljava/lang/Throwable;)V
|
||||
|
||||
-78
@@ -1,78 +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.common.logging.FLog
|
||||
import com.facebook.jni.HybridData
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.common.ReactConstants
|
||||
|
||||
@DoNotStrip
|
||||
public class Inspector
|
||||
private constructor(@Suppress("NoHungarianNotation") private val mHybridData: HybridData) {
|
||||
|
||||
private external fun getPagesNative(): Array<Page>
|
||||
|
||||
private external fun connectNative(pageId: Int, remote: RemoteConnection): LocalConnection?
|
||||
|
||||
@DoNotStrip
|
||||
public class Page
|
||||
private constructor(private val id: Int, private val title: String, private val vm: String) {
|
||||
public fun getId(): Int = id
|
||||
|
||||
public fun getTitle(): String = title
|
||||
|
||||
public fun getVM(): String = vm
|
||||
|
||||
override fun toString(): String = "Page{id=$id, title='$title'}"
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public interface RemoteConnection {
|
||||
@DoNotStrip public fun onMessage(message: String)
|
||||
|
||||
@DoNotStrip public fun onDisconnect()
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public class LocalConnection
|
||||
private constructor(@Suppress("NoHungarianNotation") private val mHybridData: HybridData) {
|
||||
public external fun sendMessage(message: String)
|
||||
|
||||
public external fun disconnect()
|
||||
}
|
||||
|
||||
public companion object {
|
||||
init {
|
||||
ReactNativeJNISoLoader.staticInit()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun getPages(): List<Page> {
|
||||
return try {
|
||||
instance().getPagesNative().toList()
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
FLog.e(ReactConstants.TAG, "Inspector doesn't work in open source yet", e)
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun connect(pageId: Int, remote: RemoteConnection): LocalConnection {
|
||||
return try {
|
||||
instance().connectNative(pageId, remote)
|
||||
?: throw IllegalStateException("Can't open failed connection")
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
FLog.e(ReactConstants.TAG, "Inspector doesn't work in open source yet", e)
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic private external fun instance(): Inspector
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,6 @@ add_library(
|
||||
CatalystInstanceImpl.cpp
|
||||
InspectorNetworkRequestListener.cpp
|
||||
JExecutor.cpp
|
||||
JInspector.cpp
|
||||
JMessageQueueThread.cpp
|
||||
JReactCxxErrorHandler.cpp
|
||||
JReactSoftExceptionLogger.cpp
|
||||
|
||||
@@ -1,112 +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.
|
||||
*/
|
||||
|
||||
#include "JInspector.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
namespace {
|
||||
|
||||
class RemoteConnection : public jsinspector_modern::IRemoteConnection {
|
||||
public:
|
||||
RemoteConnection(jni::alias_ref<JRemoteConnection::javaobject> connection)
|
||||
: connection_(jni::make_global(connection)) {}
|
||||
|
||||
void onMessage(std::string message) override {
|
||||
connection_->onMessage(message);
|
||||
}
|
||||
|
||||
void onDisconnect() override {
|
||||
connection_->onDisconnect();
|
||||
}
|
||||
|
||||
private:
|
||||
jni::global_ref<JRemoteConnection::javaobject> connection_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
jni::local_ref<JPage::javaobject>
|
||||
JPage::create(int id, const std::string& title, const std::string& vm) {
|
||||
static auto constructor = javaClassStatic()
|
||||
->getConstructor<JPage::javaobject(
|
||||
jint,
|
||||
jni::local_ref<jni::JString>,
|
||||
jni::local_ref<jni::JString>)>();
|
||||
return javaClassStatic()->newObject(
|
||||
constructor, id, jni::make_jstring(title), jni::make_jstring(vm));
|
||||
}
|
||||
|
||||
void JRemoteConnection::onMessage(const std::string& message) const {
|
||||
static auto method =
|
||||
javaClassStatic()->getMethod<void(jni::local_ref<jstring>)>("onMessage");
|
||||
method(self(), jni::make_jstring(message));
|
||||
}
|
||||
|
||||
void JRemoteConnection::onDisconnect() const {
|
||||
static auto method = javaClassStatic()->getMethod<void()>("onDisconnect");
|
||||
method(self());
|
||||
}
|
||||
|
||||
JLocalConnection::JLocalConnection(
|
||||
std::unique_ptr<jsinspector_modern::ILocalConnection> connection)
|
||||
: connection_(std::move(connection)) {}
|
||||
|
||||
void JLocalConnection::sendMessage(std::string message) {
|
||||
connection_->sendMessage(std::move(message));
|
||||
}
|
||||
|
||||
void JLocalConnection::disconnect() {
|
||||
connection_->disconnect();
|
||||
}
|
||||
|
||||
void JLocalConnection::registerNatives() {
|
||||
javaClassStatic()->registerNatives({
|
||||
makeNativeMethod("sendMessage", JLocalConnection::sendMessage),
|
||||
makeNativeMethod("disconnect", JLocalConnection::disconnect),
|
||||
});
|
||||
}
|
||||
|
||||
jni::global_ref<JInspector::javaobject> JInspector::instance(
|
||||
jni::alias_ref<jclass> /*unused*/) {
|
||||
static auto instance = jni::make_global(
|
||||
newObjectCxxArgs(&jsinspector_modern::getInspectorInstance()));
|
||||
return instance;
|
||||
}
|
||||
|
||||
jni::local_ref<jni::JArrayClass<JPage::javaobject>> JInspector::getPages() {
|
||||
std::vector<jsinspector_modern::InspectorPageDescription> pages =
|
||||
inspector_->getPages();
|
||||
auto array = jni::JArrayClass<JPage::javaobject>::newArray(pages.size());
|
||||
for (size_t i = 0; i < pages.size(); i++) {
|
||||
(*array)[i] = JPage::create(pages[i].id, pages[i].description, pages[i].vm);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
jni::local_ref<JLocalConnection::javaobject> JInspector::connect(
|
||||
int pageId,
|
||||
jni::alias_ref<JRemoteConnection::javaobject> remote) {
|
||||
auto localConnection = inspector_->connect(
|
||||
pageId, std::make_unique<RemoteConnection>(std::move(remote)));
|
||||
return localConnection
|
||||
? JLocalConnection::newObjectCxxArgs(std::move(localConnection))
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
void JInspector::registerNatives() {
|
||||
JLocalConnection::registerNatives();
|
||||
javaClassStatic()->registerNatives({
|
||||
makeNativeMethod("instance", JInspector::instance),
|
||||
makeNativeMethod("getPagesNative", JInspector::getPages),
|
||||
makeNativeMethod("connectNative", JInspector::connect),
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -1,77 +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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jsinspector-modern/InspectorInterfaces.h>
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
class JPage : public jni::JavaClass<JPage> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor =
|
||||
"Lcom/facebook/react/bridge/Inspector$Page;";
|
||||
|
||||
static jni::local_ref<JPage::javaobject>
|
||||
create(int id, const std::string& title, const std::string& vm);
|
||||
};
|
||||
|
||||
class JRemoteConnection : public jni::JavaClass<JRemoteConnection> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor =
|
||||
"Lcom/facebook/react/bridge/Inspector$RemoteConnection;";
|
||||
|
||||
void onMessage(const std::string& message) const;
|
||||
void onDisconnect() const;
|
||||
};
|
||||
|
||||
class JLocalConnection : public jni::HybridClass<JLocalConnection> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor =
|
||||
"Lcom/facebook/react/bridge/Inspector$LocalConnection;";
|
||||
|
||||
JLocalConnection(
|
||||
std::unique_ptr<jsinspector_modern::ILocalConnection> connection);
|
||||
|
||||
void sendMessage(std::string message);
|
||||
void disconnect();
|
||||
|
||||
static void registerNatives();
|
||||
|
||||
private:
|
||||
std::unique_ptr<jsinspector_modern::ILocalConnection> connection_;
|
||||
};
|
||||
|
||||
class JInspector : public jni::HybridClass<JInspector> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor =
|
||||
"Lcom/facebook/react/bridge/Inspector;";
|
||||
|
||||
static jni::global_ref<JInspector::javaobject> instance(
|
||||
jni::alias_ref<jclass>);
|
||||
|
||||
jni::local_ref<jni::JArrayClass<JPage::javaobject>> getPages();
|
||||
jni::local_ref<JLocalConnection::javaobject> connect(
|
||||
int pageId,
|
||||
jni::alias_ref<JRemoteConnection::javaobject> remote);
|
||||
|
||||
static void registerNatives();
|
||||
|
||||
private:
|
||||
friend HybridBase;
|
||||
|
||||
JInspector(jsinspector_modern::IInspector* inspector)
|
||||
: inspector_(inspector) {}
|
||||
|
||||
jsinspector_modern::IInspector* inspector_;
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "CatalystInstanceImpl.h"
|
||||
#include "CxxModuleWrapperBase.h"
|
||||
#include "InspectorNetworkRequestListener.h"
|
||||
#include "JInspector.h"
|
||||
#include "JavaScriptExecutorHolder.h"
|
||||
#include "ReactInstanceManagerInspectorTarget.h"
|
||||
|
||||
@@ -41,7 +40,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
CatalystInstanceImpl::registerNatives();
|
||||
#endif
|
||||
CxxModuleWrapperBase::registerNatives();
|
||||
JInspector::registerNatives();
|
||||
ReactInstanceManagerInspectorTarget::registerNatives();
|
||||
InspectorNetworkRequestListener::registerNatives();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user