first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
# 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.
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
file(GLOB jsitooling_SRC CONFIGURE_DEPENDS react/runtime/*.cpp)
add_library(jsitooling OBJECT ${jsitooling_SRC})
target_include_directories(jsitooling
PUBLIC
${REACT_COMMON_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(jsitooling
react_cxxreact
folly_runtime
glog
jsi)
target_compile_reactnative_options(jsitooling PRIVATE)
target_compile_options(jsitooling PRIVATE -Wpedantic)

View File

@@ -0,0 +1,49 @@
# 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.
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 if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end
Pod::Spec.new do |s|
s.name = "React-jsitooling"
s.version = version
s.summary = "-" # TODO
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = podspec_sources("react/runtime/*.{cpp,h}", "react/runtime/*.h")
s.header_dir = "react/runtime"
resolve_use_frameworks(s, header_mappings_dir: "./", module_name: "JSITooling")
s.pod_target_xcconfig = {
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"DEFINES_MODULE" => "YES",
}
s.dependency "React-cxxreact", version
s.dependency "React-jsi", version
add_dependency(s, "React-debug")
add_dependency(s, "React-runtimeexecutor", :additional_framework_paths => ["platform/ios"])
add_dependency(s, "React-jsinspector", :framework_name => 'jsinspector_modern')
add_dependency(s, "React-jsinspectorcdp", :framework_name => 'jsinspector_moderncdp')
add_dependency(s, "React-jsinspectortracing", :framework_name => 'jsinspector_moderntracing')
add_dependency(s, "React-utils", :additional_framework_paths => ["react/utils/platform/ios"])
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end

View File

@@ -0,0 +1,29 @@
/*
* 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 "JSRuntimeFactory.h"
namespace facebook::react {
jsi::Runtime& JSIRuntimeHolder::getRuntime() noexcept {
return *runtime_;
}
JSIRuntimeHolder::JSIRuntimeHolder(std::unique_ptr<jsi::Runtime> runtime)
: runtime_(std::move(runtime)) {
assert(runtime_ != nullptr);
}
jsinspector_modern::RuntimeTargetDelegate&
JSRuntime::getRuntimeTargetDelegate() {
if (!runtimeTargetDelegate_) {
runtimeTargetDelegate_.emplace(getRuntime().description());
}
return *runtimeTargetDelegate_;
}
} // namespace facebook::react

View File

@@ -0,0 +1,76 @@
/*
* 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
#ifdef __cplusplus
#include <jsi/jsi.h>
#include <jsinspector-modern/ReactCdp.h>
namespace facebook::react {
class MessageQueueThread;
/**
* An interface that represents an instance of a JS VM
*/
class JSRuntime {
public:
virtual jsi::Runtime &getRuntime() noexcept = 0;
virtual ~JSRuntime() = default;
/**
* Get a reference to the \c RuntimeTargetDelegate owned (or implemented) by
* this JSRuntime. This reference must remain valid for the duration of the
* JSRuntime's lifetime.
*/
virtual jsinspector_modern::RuntimeTargetDelegate &getRuntimeTargetDelegate();
/**
* Run initialize work that must happen on the runtime's JS thread. Used for
* initializing TLS and registering profiling.
*
* TODO T194671568 Move the runtime constructor to the JsThread
*/
virtual void unstable_initializeOnJsThread() {}
private:
/**
* Initialized by \c getRuntimeTargetDelegate if not overridden, and then
* never changes.
*/
std::optional<jsinspector_modern::FallbackRuntimeTargetDelegate> runtimeTargetDelegate_;
};
/**
* Interface for a class that creates instances of a JS VM
*/
class JSRuntimeFactory {
public:
virtual std::unique_ptr<JSRuntime> createJSRuntime(std::shared_ptr<MessageQueueThread> msgQueueThread) noexcept = 0;
virtual ~JSRuntimeFactory() = default;
};
/**
* Utility class for creating a JSRuntime from a uniquely owned jsi::Runtime.
*/
class JSIRuntimeHolder : public JSRuntime {
public:
jsi::Runtime &getRuntime() noexcept override;
explicit JSIRuntimeHolder(std::unique_ptr<jsi::Runtime> runtime);
private:
std::unique_ptr<jsi::Runtime> runtime_;
};
} // namespace facebook::react
#endif // __cplusplus

View File

@@ -0,0 +1,15 @@
/*
* 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 "JSRuntimeFactoryCAPI.h"
#include "JSRuntimeFactory.h"
void js_runtime_factory_destroy(JSRuntimeFactoryRef factory) {
if (factory != nullptr) {
delete static_cast<facebook::react::JSRuntimeFactory*>(factory);
}
}

View File

@@ -0,0 +1,26 @@
/*
* 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
#ifdef __cplusplus
extern "C" {
#endif
/**
JSRuntimeFactory pointer representation in C.
*/
typedef void *JSRuntimeFactoryRef;
/**
Function used to destroy instance of JSRuntimeFactory.
*/
void js_runtime_factory_destroy(JSRuntimeFactoryRef factory);
#ifdef __cplusplus
}
#endif