diff --git a/packages/react-native/Package.swift b/packages/react-native/Package.swift index db484e886d4e..9e23bf7a25f9 100644 --- a/packages/react-native/Package.swift +++ b/packages/react-native/Package.swift @@ -199,21 +199,20 @@ let reactCxxReact = RNTarget( searchPaths: [CallInvokerPath], excludedPaths: ["tests"], dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .logger, .reactDebug, .reactJsInspector] +) +/// React-jsitooling.podspec +let reactJsiTooling = RNTarget( + name: .reactJsiTooling, + path: "ReactCommon/jsitooling", + dependencies: [.reactNativeDependencies, .jsi, .reactJsInspector, .reactJsInspectorTracing, .reactCxxReact] ) /// React-jsiexecutor.podspec let reactJsiExecutor = RNTarget( name: .reactJsiExecutor, path: "ReactCommon/jsiexecutor", - dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .reactCxxReact, .reactJsInspector] -) - -/// React-jsitooling.podspec -let reactJsiTooling = RNTarget( - name: .reactJsiTooling, - path: "ReactCommon/jsitooling", - dependencies: [.reactNativeDependencies, .reactJsInspector, .reactJsInspectorTracing, .reactCxxReact, .jsi, .reactRuntimeExecutor] + dependencies: [.reactNativeDependencies, .jsi, .reactCxxReact, .reactJsiTooling] ) /// React-hermes.podspec diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp index 5d123a5d1b80..b2911f092b5f 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp @@ -13,11 +13,12 @@ #include #include #include -#include #include #include #include #include +#include + #include "JavaTimerRegistry.h" namespace facebook::react { diff --git a/packages/react-native/ReactCommon/cxxreact/ReactMarker.cpp b/packages/react-native/ReactCommon/cxxreact/ReactMarker.cpp index df845915f882..e605de535554 100644 --- a/packages/react-native/ReactCommon/cxxreact/ReactMarker.cpp +++ b/packages/react-native/ReactCommon/cxxreact/ReactMarker.cpp @@ -6,7 +6,6 @@ */ #include "ReactMarker.h" -#include namespace facebook::react::ReactMarker { diff --git a/packages/react-native/ReactCommon/jsiexecutor/CMakeLists.txt b/packages/react-native/ReactCommon/jsiexecutor/CMakeLists.txt index 85f67b32d155..4ba0d44f3f26 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/CMakeLists.txt +++ b/packages/react-native/ReactCommon/jsiexecutor/CMakeLists.txt @@ -20,7 +20,9 @@ target_link_libraries(jsireact reactperflogger folly_runtime glog - jsi) + jserrorhandler + jsi + jsitooling) target_compile_reactnative_options(jsireact PRIVATE) target_compile_options(jsireact PRIVATE -O3) diff --git a/packages/react-native/ReactCommon/jsiexecutor/React-jsiexecutor.podspec b/packages/react-native/ReactCommon/jsiexecutor/React-jsiexecutor.podspec index 03497f2e1463..a0cc74783b04 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/React-jsiexecutor.podspec +++ b/packages/react-native/ReactCommon/jsiexecutor/React-jsiexecutor.podspec @@ -30,7 +30,9 @@ Pod::Spec.new do |s| s.header_dir = "jsireact" s.dependency "React-cxxreact" + s.dependency "React-jserrorhandler" s.dependency "React-jsi" + s.dependency "React-jsitooling" s.dependency "React-perflogger" add_dependency(s, "React-debug") add_dependency(s, "React-runtimeexecutor", :additional_framework_paths => ["platform/ios"]) diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp index 183b148c635a..5c16909b002c 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp @@ -576,44 +576,4 @@ void JSIExecutor::flush() {} #endif // RCT_REMOVE_LEGACY_ARCH -void bindNativeLogger(Runtime& runtime, Logger logger) { - runtime.global().setProperty( - runtime, - "nativeLoggingHook", - Function::createFromHostFunction( - runtime, - PropNameID::forAscii(runtime, "nativeLoggingHook"), - 2, - [logger = std::move(logger)]( - jsi::Runtime& runtime, - const jsi::Value&, - const jsi::Value* args, - size_t count) { - if (count != 2) { - throw std::invalid_argument( - "nativeLoggingHook takes 2 arguments"); - } - logger( - args[0].asString(runtime).utf8(runtime), - static_cast(args[1].asNumber())); - return Value::undefined(); - })); -} - -void bindNativePerformanceNow(Runtime& runtime) { - runtime.global().setProperty( - runtime, - "nativePerformanceNow", - Function::createFromHostFunction( - runtime, - PropNameID::forAscii(runtime, "nativePerformanceNow"), - 0, - [](jsi::Runtime& runtime, - const jsi::Value&, - const jsi::Value* args, - size_t /*count*/) { - return HighResTimeStamp::now().toDOMHighResTimeStamp(); - })); -} - } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h index ad088e873bce..b1a09bd61414 100644 --- a/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h +++ b/packages/react-native/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -127,10 +128,4 @@ class [[deprecated("This API will be removed along with the legacy architecture. #endif // RCT_REMOVE_LEGACY_ARCH }; -using Logger = std::function; -void bindNativeLogger(jsi::Runtime &runtime, Logger logger); - -void bindNativePerformanceNow(jsi::Runtime &runtime); - -double performanceNow(); } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp index 8cc8dc3c5089..de1770495282 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include using namespace ::testing; diff --git a/packages/react-native/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.cpp b/packages/react-native/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.cpp new file mode 100644 index 000000000000..f44f9633deab --- /dev/null +++ b/packages/react-native/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.cpp @@ -0,0 +1,54 @@ +/* + * 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 "JSRuntimeBindings.h" + +#include + +namespace facebook::react { + +void bindNativeLogger(jsi::Runtime& runtime, Logger logger) { + runtime.global().setProperty( + runtime, + "nativeLoggingHook", + jsi::Function::createFromHostFunction( + runtime, + jsi::PropNameID::forAscii(runtime, "nativeLoggingHook"), + 2, + [logger = std::move(logger)]( + jsi::Runtime& runtime, + const jsi::Value& /* this */, + const jsi::Value* args, + size_t count) { + if (count != 2) { + throw std::invalid_argument( + "nativeLoggingHook takes 2 arguments"); + } + logger( + args[0].asString(runtime).utf8(runtime), + static_cast(args[1].asNumber())); + return jsi::Value::undefined(); + })); +} + +void bindNativePerformanceNow(jsi::Runtime& runtime) { + runtime.global().setProperty( + runtime, + "nativePerformanceNow", + jsi::Function::createFromHostFunction( + runtime, + jsi::PropNameID::forAscii(runtime, "nativePerformanceNow"), + 0, + [](jsi::Runtime& /* runtime */, + const jsi::Value& /* this */, + const jsi::Value* /* args */, + size_t /*count*/) { + return HighResTimeStamp::now().toDOMHighResTimeStamp(); + })); +} + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.h b/packages/react-native/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.h new file mode 100644 index 000000000000..720ef82ed853 --- /dev/null +++ b/packages/react-native/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.h @@ -0,0 +1,20 @@ +/* + * 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 + +namespace facebook::react { + +using Logger = std::function; +void bindNativeLogger(jsi::Runtime &runtime, Logger logger); + +void bindNativePerformanceNow(jsi::Runtime &runtime); + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp index 6bc38b94d835..5fa5e6821a51 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/EventDispatcher.cpp @@ -6,7 +6,7 @@ */ #include "EventDispatcher.h" -#include + #include #include "EventQueue.h" diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp b/packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp index 7d268e2c2048..90cdc8f9888a 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/EventQueueProcessor.cpp @@ -5,13 +5,13 @@ * LICENSE file in the root directory of this source tree. */ -#include +#include "EventQueueProcessor.h" + #include #include + #include "EventEmitter.h" #include "EventLogger.h" -#include "EventQueue.h" -#include "ShadowNodeFamily.h" namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp index 7b3e6786b463..8e1dfd2fa0ee 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp @@ -18,10 +18,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -48,6 +48,12 @@ std::shared_ptr createRuntimeScheduler( return scheduler; } +std::string getSyntheticBundlePath(uint32_t bundleId) { + std::array buffer{}; + std::snprintf(buffer.data(), buffer.size(), "seg-%u.js", bundleId); + return buffer.data(); +} + } // namespace ReactInstance::ReactInstance( @@ -365,12 +371,8 @@ void ReactInstance::registerSegment( } LOG(WARNING) << "Starting to evaluate segment " << segmentId << " in ReactInstance::registerSegment"; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" runtime.evaluateJavaScript( - std::move(script), - JSExecutor::getSyntheticBundlePath(segmentId, segmentPath)); -#pragma clang diagnostic pop + std::move(script), getSyntheticBundlePath(segmentId)); LOG(WARNING) << "Finished evaluating segment " << segmentId << " in ReactInstance::registerSegment"; if (hasLogger) { diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.h b/packages/react-native/ReactCommon/react/runtime/ReactInstance.h index a138c2e1fc5c..84a8b4cc2cb2 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.h +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.h @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp b/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp index d58d0a18692f..896ec4f76790 100644 --- a/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp +++ b/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include