This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
Checks: '>
clang-diagnostic-*,
'
...

View File

@ -0,0 +1,19 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := jsinspector
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_CFLAGS += -fexceptions
include $(BUILD_SHARED_LIBRARY)

38
node_modules/react-native/ReactCommon/jsinspector/BUCK generated vendored Normal file
View File

@ -0,0 +1,38 @@
load("@fbsource//tools/build_defs:glob_defs.bzl", "subdir_glob")
load("//tools/build_defs/oss:rn_defs.bzl", "rn_xplat_cxx_library")
EXPORTED_HEADERS = [
"InspectorInterfaces.h",
]
rn_xplat_cxx_library(
name = "jsinspector",
srcs = glob(
["*.cpp"],
),
headers = subdir_glob(
[
("", "*.h"),
],
exclude = EXPORTED_HEADERS,
prefix = "jsinspector",
),
header_namespace = "",
exported_headers = subdir_glob(
[
("", header)
for header in EXPORTED_HEADERS
],
prefix = "jsinspector",
),
compiler_flags = [
"-Wall",
"-fexceptions",
"-std=c++1y",
],
fbandroid_preferred_linkage = "shared",
fbobjc_labels = ["supermodule:ios/default/public.react_native.infra"],
visibility = [
"PUBLIC",
],
)

View File

@ -0,0 +1,108 @@
/*
* Copyright (c) Facebook, Inc. and its 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 <mutex>
#include <tuple>
#include <unordered_map>
namespace facebook {
namespace 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<InspectorPage> getPages() const override;
std::unique_ptr<ILocalConnection> connect(
int pageId,
std::unique_ptr<IRemoteConnection> remote) override;
private:
mutable std::mutex mutex_;
int nextPageId_{1};
std::unordered_map<int, std::tuple<std::string, std::string>> titles_;
std::unordered_map<int, ConnectFunc> connectFuncs_;
};
int InspectorImpl::addPage(
const std::string &title,
const std::string &vm,
ConnectFunc connectFunc) {
std::lock_guard<std::mutex> 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::lock_guard<std::mutex> lock(mutex_);
titles_.erase(pageId);
connectFuncs_.erase(pageId);
}
std::vector<InspectorPage> InspectorImpl::getPages() const {
std::lock_guard<std::mutex> lock(mutex_);
std::vector<InspectorPage> 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<ILocalConnection> InspectorImpl::connect(
int pageId,
std::unique_ptr<IRemoteConnection> remote) {
IInspector::ConnectFunc connectFunc;
{
std::lock_guard<std::mutex> 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<IInspector> makeTestInspectorInstance() {
return std::make_unique<InspectorImpl>();
}
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) Facebook, Inc. and its 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 <functional>
#include <memory>
#include <string>
#include <vector>
namespace facebook {
namespace 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 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 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 IInspector : public IDestructible {
public:
using ConnectFunc = std::function<std::unique_ptr<ILocalConnection>(
std::unique_ptr<IRemoteConnection>)>;
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<InspectorPage> getPages() const = 0;
/// connect is called by the client to initiate a debugging session on the
/// given page.
virtual std::unique_ptr<ILocalConnection> connect(
int pageId,
std::unique_ptr<IRemoteConnection> 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<IInspector> makeTestInspectorInstance();
} // namespace react
} // namespace facebook

View File

@ -0,0 +1,30 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
require "json"
package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which were presumably in.
source[:commit] = `git rev-parse HEAD`.strip
else
source[:tag] = "v#{version}"
end
Pod::Spec.new do |s|
s.name = "React-jsinspector"
s.version = version
s.summary = "-" # TODO
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Facebook, Inc. and its affiliates"
s.platforms = { :ios => "10.0", :tvos => "10.0" }
s.source = source
s.source_files = "*.{cpp,h}"
s.header_dir = 'jsinspector'
end