diff --git a/packages/react-native/ReactCommon/jsinspector/.clang-tidy b/packages/react-native/ReactCommon/jsinspector/.clang-tidy deleted file mode 100644 index 9f33ef5a06d828..00000000000000 --- a/packages/react-native/ReactCommon/jsinspector/.clang-tidy +++ /dev/null @@ -1,6 +0,0 @@ ---- -Checks: '> -clang-diagnostic-*, -' -InheritParentConfig: true -... diff --git a/packages/react-native/ReactCommon/jsinspector/InspectorInterfaces.cpp b/packages/react-native/ReactCommon/jsinspector/InspectorInterfaces.cpp deleted file mode 100644 index 93ab7fad40db91..00000000000000 --- a/packages/react-native/ReactCommon/jsinspector/InspectorInterfaces.cpp +++ /dev/null @@ -1,106 +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 "InspectorInterfaces.h" - -#include -#include -#include - -namespace facebook::react { - -// pure destructors in C++ are odd. You would think they don't want an -// implementation, but in fact the linker requires one. Define them to be -// empty so that people don't count on them for any particular behaviour. -IDestructible::~IDestructible() {} -ILocalConnection::~ILocalConnection() {} -IRemoteConnection::~IRemoteConnection() {} -IInspector::~IInspector() {} - -namespace { - -class InspectorImpl : public IInspector { - public: - int addPage( - const std::string& title, - const std::string& vm, - ConnectFunc connectFunc) override; - void removePage(int pageId) override; - - std::vector getPages() const override; - std::unique_ptr connect( - int pageId, - std::unique_ptr remote) override; - - private: - mutable std::mutex mutex_; - int nextPageId_{1}; - std::unordered_map> titles_; - std::unordered_map connectFuncs_; -}; - -int InspectorImpl::addPage( - const std::string& title, - const std::string& vm, - ConnectFunc connectFunc) { - std::scoped_lock lock(mutex_); - - int pageId = nextPageId_++; - titles_[pageId] = std::make_tuple(title, vm); - connectFuncs_[pageId] = std::move(connectFunc); - - return pageId; -} - -void InspectorImpl::removePage(int pageId) { - std::scoped_lock lock(mutex_); - - titles_.erase(pageId); - connectFuncs_.erase(pageId); -} - -std::vector InspectorImpl::getPages() const { - std::scoped_lock lock(mutex_); - - std::vector inspectorPages; - for (auto& it : titles_) { - inspectorPages.push_back(InspectorPage{ - it.first, std::get<0>(it.second), std::get<1>(it.second)}); - } - - return inspectorPages; -} - -std::unique_ptr InspectorImpl::connect( - int pageId, - std::unique_ptr remote) { - IInspector::ConnectFunc connectFunc; - - { - std::scoped_lock lock(mutex_); - - auto it = connectFuncs_.find(pageId); - if (it != connectFuncs_.end()) { - connectFunc = it->second; - } - } - - return connectFunc ? connectFunc(std::move(remote)) : nullptr; -} - -} // namespace - -IInspector& getInspectorInstance() { - static InspectorImpl instance; - return instance; -} - -std::unique_ptr makeTestInspectorInstance() { - return std::make_unique(); -} - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/jsinspector/InspectorInterfaces.h b/packages/react-native/ReactCommon/jsinspector/InspectorInterfaces.h deleted file mode 100644 index c92e41db907dea..00000000000000 --- a/packages/react-native/ReactCommon/jsinspector/InspectorInterfaces.h +++ /dev/null @@ -1,92 +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 -#include -#include -#include - -#ifndef JSINSPECTOR_EXPORT -#ifdef _MSC_VER -#ifdef CREATE_SHARED_LIBRARY -#define JSINSPECTOR_EXPORT __declspec(dllexport) -#else -#define JSINSPECTOR_EXPORT -#endif // CREATE_SHARED_LIBRARY -#else // _MSC_VER -#define JSINSPECTOR_EXPORT __attribute__((visibility("default"))) -#endif // _MSC_VER -#endif // !defined(JSINSPECTOR_EXPORT) - -namespace facebook::react { - -class IDestructible { - public: - virtual ~IDestructible() = 0; -}; - -struct InspectorPage { - const int id; - const std::string title; - const std::string vm; -}; - -/// IRemoteConnection allows the VM to send debugger messages to the client. -class JSINSPECTOR_EXPORT IRemoteConnection : public IDestructible { - public: - virtual ~IRemoteConnection() = 0; - virtual void onMessage(std::string message) = 0; - virtual void onDisconnect() = 0; -}; - -/// ILocalConnection allows the client to send debugger messages to the VM. -class JSINSPECTOR_EXPORT ILocalConnection : public IDestructible { - public: - virtual ~ILocalConnection() = 0; - virtual void sendMessage(std::string message) = 0; - virtual void disconnect() = 0; -}; - -/// IInspector tracks debuggable JavaScript targets (pages). -class JSINSPECTOR_EXPORT IInspector : public IDestructible { - public: - using ConnectFunc = std::function( - std::unique_ptr)>; - - virtual ~IInspector() = 0; - - /// addPage is called by the VM to add a page to the list of debuggable pages. - virtual int addPage( - const std::string& title, - const std::string& vm, - ConnectFunc connectFunc) = 0; - - /// removePage is called by the VM to remove a page from the list of - /// debuggable pages. - virtual void removePage(int pageId) = 0; - - /// getPages is called by the client to list all debuggable pages. - virtual std::vector getPages() const = 0; - - /// connect is called by the client to initiate a debugging session on the - /// given page. - virtual std::unique_ptr connect( - int pageId, - std::unique_ptr remote) = 0; -}; - -/// getInspectorInstance retrieves the singleton inspector that tracks all -/// debuggable pages in this process. -extern IInspector& getInspectorInstance(); - -/// makeTestInspectorInstance creates an independent inspector instance that -/// should only be used in tests. -extern std::unique_ptr makeTestInspectorInstance(); - -} // namespace facebook::react