From b4c174664d24b6d86c14ca42aaaad5eaf8dcee61 Mon Sep 17 00:00:00 2001 From: Rob Herhold Date: Fri, 4 Dec 2026 13:57:34 -0800 Subject: [PATCH] Let development tooling observe each JavaScript buffer ReactInstance evaluates (#60561) Summary: Development tooling sometimes needs to know exactly which JavaScript a process ran, for example to tie a recording to the source it came from. `ReactInstance` evaluates JavaScript in four places: the main bundle (`loadScript`), segments registered from files (`registerSegment`), source evaluated through `globalEvalWithSourceUrl` (lazy segments fetched from a dev server and Fast Refresh updates), and Static Hermes units compiled into the binary. This adds `setJSEvaluationObserver`, a process-wide hook in `react/runtime/JSEvaluationObserver.h`. `ReactInstance` calls the installed observer on the JS thread immediately before each evaluation, with the exact bytes it is about to evaluate, the source URL and the kind of evaluation. With no observer installed, each path only counts the evaluation; `setJSEvaluationObserver` returns that count, so an observer installed late can tell that it missed some. The header is in the for-frameworks tier, like `ReactMarker`. Changelog: [General][Added] - Add `setJSEvaluationObserver` to observe the JavaScript `ReactInstance` evaluates Differential Revision: D136024543 --- .../react/runtime/JSEvaluationObserver.cpp | 40 +++++ .../react/runtime/JSEvaluationObserver.h | 55 +++++++ .../react/runtime/ReactInstance.cpp | 148 ++++++++++-------- .../runtime/tests/cxx/ReactInstanceTest.cpp | 117 ++++++++++++++ .../ReactAndroidFrameworksCxx.api | 10 ++ .../api-snapshots/ReactAppleFrameworksCxx.api | 10 ++ .../ReactCommonFrameworksCxx.api | 10 ++ 7 files changed, 322 insertions(+), 68 deletions(-) create mode 100644 packages/react-native/ReactCommon/react/runtime/JSEvaluationObserver.cpp create mode 100644 packages/react-native/ReactCommon/react/runtime/JSEvaluationObserver.h diff --git a/packages/react-native/ReactCommon/react/runtime/JSEvaluationObserver.cpp b/packages/react-native/ReactCommon/react/runtime/JSEvaluationObserver.cpp new file mode 100644 index 000000000000..f9efe97410b7 --- /dev/null +++ b/packages/react-native/ReactCommon/react/runtime/JSEvaluationObserver.cpp @@ -0,0 +1,40 @@ +/* + * 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 "JSEvaluationObserver.h" + +#include + +namespace facebook::react { + +namespace { + +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::atomic observer{nullptr}; +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +std::atomic unobservedEvaluations{0}; + +} // namespace + +uint64_t setJSEvaluationObserver(JSEvaluationObserver newObserver) { + observer.store(newObserver); + return unobservedEvaluations.load(); +} + +void notifyJSEvaluation( + JSEvaluationKind kind, + const uint8_t* data, + size_t size, + const std::string& sourceURL) { + if (auto current = observer.load()) { + current(kind, data, size, sourceURL); + } else { + unobservedEvaluations.fetch_add(1); + } +} + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/runtime/JSEvaluationObserver.h b/packages/react-native/ReactCommon/react/runtime/JSEvaluationObserver.h new file mode 100644 index 000000000000..05ebaf66d2de --- /dev/null +++ b/packages/react-native/ReactCommon/react/runtime/JSEvaluationObserver.h @@ -0,0 +1,55 @@ +/* + * 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 RN_EXPORT +#define RN_EXPORT __attribute__((visibility("default"))) +#endif + +namespace facebook::react { + +/// How React Native came to evaluate a piece of JavaScript. +enum class JSEvaluationKind { + /// The main bundle a host loads. + Bundle, + /// A segment registered from a file. + Segment, + /// Source evaluated through `globalEvalWithSourceUrl`: lazy segments + /// fetched from a dev server, and Fast Refresh updates. + DevServerEval, + /// A Static Hermes unit compiled into the app binary. It has no source + /// buffer. + SHUnit, +}; + +/// Called on the JS thread immediately before React Native evaluates a piece +/// of JavaScript, with the exact bytes it is about to evaluate (`data` is null +/// and `size` is 0 for `SHUnit`) and where they came from: the URL a host +/// loaded, a segment's file path, or the URL passed to +/// `globalEvalWithSourceUrl`. Development tooling uses it to tell which +/// JavaScript a process ran. It must not call into the runtime. +using JSEvaluationObserver = + void (*)(JSEvaluationKind kind, const uint8_t *data, size_t size, const std::string &sourceURL); + +/// Installs the process-wide observer, replacing any earlier one; nullptr +/// removes it. Returns how many evaluations happened while no observer was +/// installed, so an observer installed late can tell that it missed some. +RN_EXPORT uint64_t setJSEvaluationObserver(JSEvaluationObserver observer); + +/// Reports an evaluation to the installed observer. Called by React Native's +/// script loading paths. +RN_EXPORT void +notifyJSEvaluation(JSEvaluationKind kind, const uint8_t *data, size_t size, const std::string &sourceURL); + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp index 7dde590b0664..0b35f76e0699 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -250,63 +251,65 @@ void ReactInstance::loadScript( std::shared_ptr buffer(std::move(script)); std::string scriptName = simpleBasename(sourceURL); - runtimeScheduler_->scheduleWork( - [jsErrorHandler = jsErrorHandler_, - scriptName, - sourceURL = sourceURL, - buffer = std::move(buffer), - weakBufferedRuntimeExecuter = - std::weak_ptr(bufferedRuntimeExecutor_), - beforeLoad, - afterLoad](jsi::Runtime& runtime) mutable { - if (beforeLoad) { - beforeLoad(runtime); - } - TraceSection s("ReactInstance::loadScript"); - bool hasLogger(ReactMarker::logTaggedMarkerImpl); - if (hasLogger) { - ReactMarker::logTaggedMarker( - ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); - ReactMarker::logMarker(ReactMarker::INIT_REACT_RUNTIME_START); - ReactMarker::logMarker(ReactMarker::APP_STARTUP_START); - } + runtimeScheduler_->scheduleWork([jsErrorHandler = jsErrorHandler_, + scriptName, + sourceURL = sourceURL, + buffer = std::move(buffer), + weakBufferedRuntimeExecuter = + std::weak_ptr( + bufferedRuntimeExecutor_), + beforeLoad, + afterLoad](jsi::Runtime& runtime) mutable { + if (beforeLoad) { + beforeLoad(runtime); + } + TraceSection s("ReactInstance::loadScript"); + bool hasLogger(ReactMarker::logTaggedMarkerImpl); + if (hasLogger) { + ReactMarker::logTaggedMarker( + ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); + ReactMarker::logMarker(ReactMarker::INIT_REACT_RUNTIME_START); + ReactMarker::logMarker(ReactMarker::APP_STARTUP_START); + } - // Check if the shermes unit is avaliable. - auto* shUnitAPI = jsi::castInterface(&runtime); - auto* shUnitCreator = - shUnitAPI ? shUnitAPI->getSHUnitCreator() : nullptr; - if (shUnitCreator) { - LOG(WARNING) << "ReactInstance: evaluateSHUnit"; - auto* hermesAPI = jsi::castInterface(&runtime); - hermesAPI->evaluateSHUnit(shUnitCreator); - } else { - LOG(WARNING) << "ReactInstance: evaluateJavaScript() with JS bundle"; - runtime.evaluateJavaScript(buffer, sourceURL); - } + // Check if the shermes unit is avaliable. + auto* shUnitAPI = jsi::castInterface(&runtime); + auto* shUnitCreator = shUnitAPI ? shUnitAPI->getSHUnitCreator() : nullptr; + if (shUnitCreator) { + LOG(WARNING) << "ReactInstance: evaluateSHUnit"; + notifyJSEvaluation(JSEvaluationKind::SHUnit, nullptr, 0, sourceURL); + auto* hermesAPI = jsi::castInterface(&runtime); + hermesAPI->evaluateSHUnit(shUnitCreator); + } else { + LOG(WARNING) << "ReactInstance: evaluateJavaScript() with JS bundle"; + notifyJSEvaluation( + JSEvaluationKind::Bundle, buffer->data(), buffer->size(), sourceURL); + runtime.evaluateJavaScript(buffer, sourceURL); + } - /** - * TODO(T183610671): We need a safe/reliable way to enable the js - * pipeline from javascript. Remove this after we figure that out, or - * after we just remove the js pipeline. - */ - if (!jsErrorHandler->hasHandledFatalError()) { - jsErrorHandler->setRuntimeReady(); - } + /** + * TODO(T183610671): We need a safe/reliable way to enable the js + * pipeline from javascript. Remove this after we figure that out, or + * after we just remove the js pipeline. + */ + if (!jsErrorHandler->hasHandledFatalError()) { + jsErrorHandler->setRuntimeReady(); + } - if (hasLogger) { - ReactMarker::logTaggedMarker( - ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str()); - ReactMarker::logMarker(ReactMarker::INIT_REACT_RUNTIME_STOP); - ReactMarker::logMarker(ReactMarker::APP_STARTUP_STOP); - } - if (auto strongBufferedRuntimeExecuter = - weakBufferedRuntimeExecuter.lock()) { - strongBufferedRuntimeExecuter->flush(); - } - if (afterLoad) { - afterLoad(runtime); - } - }); + if (hasLogger) { + ReactMarker::logTaggedMarker( + ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str()); + ReactMarker::logMarker(ReactMarker::INIT_REACT_RUNTIME_STOP); + ReactMarker::logMarker(ReactMarker::APP_STARTUP_STOP); + } + if (auto strongBufferedRuntimeExecuter = + weakBufferedRuntimeExecuter.lock()) { + strongBufferedRuntimeExecuter->flush(); + } + if (afterLoad) { + afterLoad(runtime); + } + }); } namespace { @@ -442,20 +445,23 @@ void ReactInstance::registerSegment( "Empty segment registered with ID " + std::to_string(segmentId) + " from " + segmentPath); } - runtimeScheduler_->scheduleWork( - [script = std::move(script), segmentId](jsi::Runtime& runtime) { - TraceSection s("ReactInstance::registerSegment"); - auto tag = std::to_string(segmentId); - ReactMarker::logTaggedMarker( - ReactMarker::REGISTER_JS_SEGMENT_START, tag.c_str()); - LOG(WARNING) << "Starting to evaluate segment " << segmentId - << " in ReactInstance::registerSegment"; - runtime.evaluateJavaScript(script, getSyntheticBundlePath(segmentId)); - LOG(WARNING) << "Finished evaluating segment " << segmentId - << " in ReactInstance::registerSegment"; - ReactMarker::logTaggedMarker( - ReactMarker::REGISTER_JS_SEGMENT_STOP, tag.c_str()); - }); + runtimeScheduler_->scheduleWork([script = std::move(script), + segmentId, + segmentPath](jsi::Runtime& runtime) { + TraceSection s("ReactInstance::registerSegment"); + auto tag = std::to_string(segmentId); + ReactMarker::logTaggedMarker( + ReactMarker::REGISTER_JS_SEGMENT_START, tag.c_str()); + LOG(WARNING) << "Starting to evaluate segment " << segmentId + << " in ReactInstance::registerSegment"; + notifyJSEvaluation( + JSEvaluationKind::Segment, script->data(), script->size(), segmentPath); + runtime.evaluateJavaScript(script, getSyntheticBundlePath(segmentId)); + LOG(WARNING) << "Finished evaluating segment " << segmentId + << " in ReactInstance::registerSegment"; + ReactMarker::logTaggedMarker( + ReactMarker::REGISTER_JS_SEGMENT_STOP, tag.c_str()); + }); } namespace { @@ -531,6 +537,12 @@ void ReactInstance::initializeRuntime( } // NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic) + notifyJSEvaluation( + JSEvaluationKind::DevServerEval, + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + reinterpret_cast(code.data()), + code.size(), + url); return rt.evaluateJavaScript( std::make_unique(std::move(code)), url); })); diff --git a/packages/react-native/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp b/packages/react-native/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp index e8c12e2d8106..4673376d4d5c 100644 --- a/packages/react-native/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp +++ b/packages/react-native/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#include +#include #include #include #include @@ -17,6 +19,7 @@ #include #include #include +#include #include using ::testing::_; @@ -903,4 +906,118 @@ function getCalls() { EXPECT_EQ(calls.getNumber(), 0); } +namespace { + +struct ObservedEvaluation { + JSEvaluationKind kind; + std::string source; + std::string sourceURL; + bool sawSegmentRun; + + bool operator==(const ObservedEvaluation& other) const = default; +}; + +// Observers are plain functions, so what they record lives in globals. +// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables) +std::vector observedEvaluations; +jsi::Runtime* observedRuntime = nullptr; +// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables) + +void recordEvaluation( + JSEvaluationKind kind, + const uint8_t* data, + size_t size, + const std::string& sourceURL) { + observedEvaluations.push_back({ + .kind = kind, + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + .source = std::string(reinterpret_cast(data), size), + .sourceURL = sourceURL, + .sawSegmentRun = + observedRuntime->global().hasProperty(*observedRuntime, "segmentRan"), + }); +} + +} // namespace + +TEST_F(ReactInstanceTest, testEvaluationObserverSeesEachScriptBeforeItRuns) { + observedEvaluations.clear(); + observedRuntime = runtime_; + const auto segmentPath = + std::filesystem::temp_directory_path() / "ReactInstanceTestSegment.js"; + std::ofstream(segmentPath) << "var segmentRan = true;"; + setJSEvaluationObserver(recordEvaluation); + + initializeRuntimeWithScript("var mainRan = true;"); + instance_->registerSegment(7, segmentPath.string()); + step(); + eval( + "globalEvalWithSourceUrl('var lazyRan = true;', 'http://localhost:8081/Lazy.bundle')"); + + setJSEvaluationObserver(nullptr); + std::filesystem::remove(segmentPath); + const std::vector expected{ + {JSEvaluationKind::Bundle, "var mainRan = true;", "", false}, + {JSEvaluationKind::Segment, + "var segmentRan = true;", + segmentPath.string(), + false}, + {JSEvaluationKind::DevServerEval, + "var lazyRan = true;", + "http://localhost:8081/Lazy.bundle", + true}, + }; + EXPECT_EQ(observedEvaluations, expected); +} + +namespace { + +// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables) +int firstObserverCalls = 0; +int secondObserverCalls = 0; +// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables) + +void countFirstObserverCall( + JSEvaluationKind /*kind*/, + const uint8_t* /*data*/, + size_t /*size*/, + const std::string& /*sourceURL*/) { + ++firstObserverCalls; +} + +void countSecondObserverCall( + JSEvaluationKind /*kind*/, + const uint8_t* /*data*/, + size_t /*size*/, + const std::string& /*sourceURL*/) { + ++secondObserverCalls; +} + +} // namespace + +TEST_F(ReactInstanceTest, testOnlyTheCurrentEvaluationObserverIsCalled) { + firstObserverCalls = 0; + secondObserverCalls = 0; + initializeRuntimeWithScript("var mainRan = true;"); + + setJSEvaluationObserver(countFirstObserverCall); + eval("globalEvalWithSourceUrl('var first = true;')"); + setJSEvaluationObserver(countSecondObserverCall); + eval("globalEvalWithSourceUrl('var second = true;')"); + setJSEvaluationObserver(nullptr); + eval("globalEvalWithSourceUrl('var third = true;')"); + + EXPECT_EQ( + std::make_pair(firstObserverCalls, secondObserverCalls), + std::make_pair(1, 1)); +} + +TEST_F(ReactInstanceTest, testEvaluationsWithoutObserverAreCounted) { + const auto missedBefore = setJSEvaluationObserver(nullptr); + + initializeRuntimeWithScript("var mainRan = true;"); + + EXPECT_EQ(setJSEvaluationObserver(nullptr), missedBefore + 1); +} + } // namespace facebook::react diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api index fa5fd1266516..b63f0eabea21 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api @@ -534,6 +534,7 @@ using facebook::react::GradientDirection = std::variant; +using facebook::react::JSEvaluationObserver = void(*)(facebook::react::JSEvaluationKind kind, const uint8_t* data, size_t size, const std::string& sourceURL); using facebook::react::LayoutConformanceComponentDescriptor = facebook::react::ConcreteComponentDescriptor; using facebook::react::LineMeasureCache = facebook::react::SimpleThreadSafeCache; using facebook::react::LinesMeasurements = std::vector; @@ -877,6 +878,7 @@ uint8_t facebook::react::alphaFromColor(facebook::react::SharedColor color) noex uint8_t facebook::react::blueFromColor(facebook::react::SharedColor color) noexcept; uint8_t facebook::react::greenFromColor(facebook::react::SharedColor color) noexcept; uint8_t facebook::react::redFromColor(facebook::react::SharedColor color) noexcept; +uint64_t facebook::react::setJSEvaluationObserver(facebook::react::JSEvaluationObserver observer); void facebook::react::FBReactNativeSpec_registerComponentDescriptorsFromCodegen(std::shared_ptr registry); void facebook::react::addDynamicToJArray(jni::alias_ref> jarray, jint index, const folly::dynamic& dyn); void facebook::react::bindNativeLogger(facebook::jsi::Runtime& runtime, facebook::react::Logger logger); @@ -957,6 +959,7 @@ void facebook::react::fromRawValueShared(const facebook::react::ContextContainer void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result); void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction); void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal); +void facebook::react::notifyJSEvaluation(facebook::react::JSEvaluationKind kind, const uint8_t* data, size_t size, const std::string& sourceURL); void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector& result); void facebook::react::parseProcessedFontVariant(const facebook::react::PropsParserContext&, const facebook::react::RawValue& value, facebook::react::FontVariant& result); void facebook::react::parseUnprocessedBackgroundImageList(const facebook::react::PropsParserContext& context, const std::vector& value, std::vector& result); @@ -5166,6 +5169,13 @@ enum facebook::react::Isolation { Isolate, } +enum facebook::react::JSEvaluationKind { + Bundle, + DevServerEval, + SHUnit, + Segment, +} + enum facebook::react::LayoutConformance : uint8_t { Compatibility, Strict, diff --git a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api index c77753f04eb3..4bcb416e9b70 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleFrameworksCxx.api @@ -3317,6 +3317,7 @@ using facebook::react::GradientDirection = std::variant; +using facebook::react::JSEvaluationObserver = void(*)(facebook::react::JSEvaluationKind kind, const uint8_t* data, size_t size, const std::string& sourceURL); using facebook::react::LayoutConformanceComponentDescriptor = facebook::react::ConcreteComponentDescriptor; using facebook::react::LineMeasureCache = facebook::react::SimpleThreadSafeCache; using facebook::react::LinesMeasurements = std::vector; @@ -3629,6 +3630,7 @@ uint8_t facebook::react::alphaFromColor(facebook::react::SharedColor color) noex uint8_t facebook::react::blueFromColor(facebook::react::SharedColor color) noexcept; uint8_t facebook::react::greenFromColor(facebook::react::SharedColor color) noexcept; uint8_t facebook::react::redFromColor(facebook::react::SharedColor color) noexcept; +uint64_t facebook::react::setJSEvaluationObserver(facebook::react::JSEvaluationObserver observer); void facebook::react::FBReactNativeSpec_registerComponentDescriptorsFromCodegen(std::shared_ptr registry); void facebook::react::bindNativeLogger(facebook::jsi::Runtime& runtime, facebook::react::Logger logger); void facebook::react::bindNativePerformanceNow(facebook::jsi::Runtime& runtime); @@ -3713,6 +3715,7 @@ void facebook::react::fromString(const std::string& string, facebook::react::Acc void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction); void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal); void facebook::react::installLegacyUIManagerConstantsProviderBinding(facebook::jsi::Runtime& runtime); +void facebook::react::notifyJSEvaluation(facebook::react::JSEvaluationKind kind, const uint8_t* data, size_t size, const std::string& sourceURL); void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector& result); void facebook::react::parseProcessedFontVariant(const facebook::react::PropsParserContext&, const facebook::react::RawValue& value, facebook::react::FontVariant& result); void facebook::react::parseUnprocessedBackgroundImageList(const facebook::react::PropsParserContext& context, const std::vector& value, std::vector& result); @@ -7262,6 +7265,13 @@ enum facebook::react::Isolation { Isolate, } +enum facebook::react::JSEvaluationKind { + Bundle, + DevServerEval, + SHUnit, + Segment, +} + enum facebook::react::KeyboardAppearance { Dark, Default, diff --git a/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api index 9b9f604d2fef..c9edaf00dbbe 100644 --- a/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactCommonFrameworksCxx.api @@ -156,6 +156,7 @@ using facebook::react::EventPipeConclusion = std::function; using facebook::react::ImageSources = std::vector; +using facebook::react::JSEvaluationObserver = void(*)(facebook::react::JSEvaluationKind kind, const uint8_t* data, size_t size, const std::string& sourceURL); using facebook::react::LayoutConformanceComponentDescriptor = facebook::react::ConcreteComponentDescriptor; using facebook::react::LineMeasureCache = facebook::react::SimpleThreadSafeCache; using facebook::react::LinesMeasurements = std::vector; @@ -443,6 +444,7 @@ uint8_t facebook::react::alphaFromColor(facebook::react::SharedColor color) noex uint8_t facebook::react::blueFromColor(facebook::react::SharedColor color) noexcept; uint8_t facebook::react::greenFromColor(facebook::react::SharedColor color) noexcept; uint8_t facebook::react::redFromColor(facebook::react::SharedColor color) noexcept; +uint64_t facebook::react::setJSEvaluationObserver(facebook::react::JSEvaluationObserver observer); void facebook::react::bindNativeLogger(facebook::jsi::Runtime& runtime, facebook::react::Logger logger); void facebook::react::bindNativePerformanceNow(facebook::jsi::Runtime& runtime); void facebook::react::cloneProp(facebook::react::BaseViewProps& viewProps, const facebook::react::AnimatedPropBase& animatedProp); @@ -519,6 +521,7 @@ void facebook::react::fromRawValueShared(const facebook::react::ContextContainer void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result); void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction); void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal); +void facebook::react::notifyJSEvaluation(facebook::react::JSEvaluationKind kind, const uint8_t* data, size_t size, const std::string& sourceURL); void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector& result); void facebook::react::parseProcessedFontVariant(const facebook::react::PropsParserContext&, const facebook::react::RawValue& value, facebook::react::FontVariant& result); void facebook::react::parseUnprocessedBackgroundImageList(const facebook::react::PropsParserContext& context, const std::vector& value, std::vector& result); @@ -3534,6 +3537,13 @@ enum facebook::react::Isolation { Isolate, } +enum facebook::react::JSEvaluationKind { + Bundle, + DevServerEval, + SHUnit, + Segment, +} + enum facebook::react::LayoutConformance : uint8_t { Compatibility, Strict,