react-native 0.84.0-nightly-20251106-de5141a3d → 0.84.0-nightly-20251107-f8198f662

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/Libraries/Animated/createAnimatedComponent.js +1 -0
  2. package/Libraries/Blob/RCTBlobManager.mm +1 -4
  3. package/Libraries/Blob/RCTFileReaderModule.mm +1 -4
  4. package/Libraries/Components/Button.js +0 -3
  5. package/Libraries/Core/ReactNativeVersion.js +1 -1
  6. package/Libraries/Image/RCTBundleAssetImageLoader.mm +1 -4
  7. package/Libraries/Image/RCTGIFImageDecoder.mm +1 -4
  8. package/Libraries/Image/RCTImageEditingManager.mm +1 -4
  9. package/Libraries/Image/RCTImageLoader.mm +1 -4
  10. package/Libraries/Image/RCTImageStoreManager.mm +1 -4
  11. package/Libraries/Image/RCTImageViewManager.mm +1 -4
  12. package/Libraries/Image/RCTLocalAssetImageLoader.mm +1 -4
  13. package/Libraries/LinkingIOS/RCTLinkingManager.mm +1 -4
  14. package/Libraries/NativeAnimation/RCTNativeAnimatedModule.mm +1 -4
  15. package/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm +1 -4
  16. package/Libraries/Network/RCTDataRequestHandler.mm +1 -4
  17. package/Libraries/Network/RCTFileRequestHandler.mm +1 -4
  18. package/Libraries/Network/RCTHTTPRequestHandler.mm +1 -4
  19. package/Libraries/Network/RCTNetworking.mm +1 -4
  20. package/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm +1 -4
  21. package/Libraries/Settings/RCTSettingsManager.mm +1 -4
  22. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
  23. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
  24. package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +4 -2
  25. package/Libraries/Text/BaseText/RCTBaseTextViewManager.mm +1 -4
  26. package/Libraries/Text/RawText/RCTRawTextViewManager.mm +1 -4
  27. package/Libraries/Text/Text/RCTTextViewManager.mm +1 -4
  28. package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.mm +1 -4
  29. package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm +1 -4
  30. package/Libraries/Text/TextInput/RCTInputAccessoryViewManager.mm +1 -4
  31. package/Libraries/Text/TextInput/Singleline/RCTSinglelineTextInputViewManager.mm +1 -4
  32. package/Libraries/Text/VirtualText/RCTVirtualTextViewManager.mm +1 -4
  33. package/Libraries/Vibration/RCTVibration.mm +1 -4
  34. package/React/Base/RCTVersion.m +1 -1
  35. package/React/CoreModules/RCTAccessibilityManager.mm +1 -4
  36. package/React/CoreModules/RCTActionSheetManager.mm +1 -4
  37. package/React/CoreModules/RCTAlertManager.mm +1 -4
  38. package/React/CoreModules/RCTAppState.mm +1 -4
  39. package/React/CoreModules/RCTAppearance.mm +1 -4
  40. package/React/CoreModules/RCTClipboard.mm +1 -4
  41. package/React/CoreModules/RCTDevLoadingView.mm +1 -4
  42. package/React/CoreModules/RCTDevMenu.mm +1 -4
  43. package/React/CoreModules/RCTDevSettings.mm +1 -4
  44. package/React/CoreModules/RCTDevToolsRuntimeSettingsModule.mm +1 -5
  45. package/React/CoreModules/RCTDeviceInfo.mm +1 -4
  46. package/React/CoreModules/RCTEventDispatcher.mm +1 -4
  47. package/React/CoreModules/RCTExceptionsManager.mm +1 -4
  48. package/React/CoreModules/RCTI18nManager.mm +1 -4
  49. package/React/CoreModules/RCTKeyboardObserver.mm +1 -4
  50. package/React/CoreModules/RCTLogBox.mm +1 -4
  51. package/React/CoreModules/RCTPerfMonitor.mm +1 -4
  52. package/React/CoreModules/RCTPlatform.mm +1 -4
  53. package/React/CoreModules/RCTRedBox.mm +1 -4
  54. package/React/CoreModules/RCTSourceCode.mm +1 -4
  55. package/React/CoreModules/RCTStatusBarManager.mm +1 -4
  56. package/React/CoreModules/RCTTiming.mm +1 -4
  57. package/React/CoreModules/RCTWebSocketModule.mm +1 -4
  58. package/React/Modules/RCTUIManager.mm +1 -4
  59. package/React/Views/RCTActivityIndicatorViewManager.m +1 -4
  60. package/React/Views/RCTDebuggingOverlayManager.m +1 -4
  61. package/React/Views/RCTModalHostViewManager.m +1 -4
  62. package/React/Views/RCTModalManager.m +1 -4
  63. package/React/Views/RCTSwitchManager.m +1 -4
  64. package/React/Views/RCTViewManager.m +1 -4
  65. package/React/Views/RefreshControl/RCTRefreshControlManager.m +1 -4
  66. package/React/Views/SafeAreaView/RCTSafeAreaViewManager.m +1 -4
  67. package/React/Views/ScrollView/RCTScrollContentViewManager.m +1 -4
  68. package/React/Views/ScrollView/RCTScrollViewManager.m +1 -4
  69. package/ReactAndroid/api/ReactAndroid.api +0 -13
  70. package/ReactAndroid/gradle.properties +1 -1
  71. package/ReactAndroid/src/main/java/com/facebook/react/ReactPackageTurboModuleManagerDelegate.kt +2 -3
  72. package/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +2 -6
  73. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.kt +2 -2
  74. package/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.kt +1 -16
  75. package/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt +2 -35
  76. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
  77. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/VirtualViewContainerStateExperimental.kt +7 -0
  78. package/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +3 -13
  79. package/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h +1 -4
  80. package/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapperBase.h +0 -24
  81. package/ReactAndroid/src/main/jni/react/jni/JavaModuleWrapper.cpp +0 -1
  82. package/ReactAndroid/src/main/jni/react/jni/ModuleRegistryBuilder.cpp +1 -29
  83. package/ReactAndroid/src/main/jni/react/jni/ModuleRegistryBuilder.h +1 -2
  84. package/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +0 -2
  85. package/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp +2 -1
  86. package/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/TurboModuleManager.cpp +1 -35
  87. package/ReactCommon/cxxreact/ReactMarker.cpp +0 -1
  88. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  89. package/ReactCommon/jsiexecutor/CMakeLists.txt +3 -1
  90. package/ReactCommon/jsiexecutor/React-jsiexecutor.podspec +2 -0
  91. package/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +0 -40
  92. package/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h +1 -6
  93. package/ReactCommon/jsinspector-modern/ConsoleTask.cpp +27 -0
  94. package/ReactCommon/jsinspector-modern/ConsoleTask.h +38 -0
  95. package/ReactCommon/jsinspector-modern/ConsoleTaskContext.cpp +46 -0
  96. package/ReactCommon/jsinspector-modern/ConsoleTaskContext.h +102 -0
  97. package/ReactCommon/jsinspector-modern/ConsoleTaskOrchestrator.cpp +55 -0
  98. package/ReactCommon/jsinspector-modern/ConsoleTaskOrchestrator.h +48 -0
  99. package/ReactCommon/jsinspector-modern/RuntimeAgent.h +1 -1
  100. package/ReactCommon/jsinspector-modern/RuntimeTarget.cpp +12 -0
  101. package/ReactCommon/jsinspector-modern/RuntimeTarget.h +16 -13
  102. package/ReactCommon/jsinspector-modern/RuntimeTargetConsole.cpp +106 -1
  103. package/ReactCommon/jsinspector-modern/tests/ConsoleCreateTaskTest.cpp +131 -0
  104. package/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp +1 -0
  105. package/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +13 -2
  106. package/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h +6 -2
  107. package/ReactCommon/jsinspector-modern/tracing/TargetTracingAgent.h +5 -0
  108. package/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.cpp +54 -0
  109. package/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.h +20 -0
  110. package/ReactCommon/react/nativemodule/samples/platform/ios/ReactCommon/RCTSampleTurboModule.mm +1 -4
  111. package/ReactCommon/react/performance/timeline/CMakeLists.txt +1 -0
  112. package/ReactCommon/react/performance/timeline/PerformanceEntryReporter.cpp +9 -1
  113. package/ReactCommon/react/performance/timeline/React-performancetimeline.podspec +1 -0
  114. package/ReactCommon/react/renderer/animated/NativeAnimatedNodesManager.cpp +21 -16
  115. package/ReactCommon/react/renderer/animated/NativeAnimatedNodesManagerProvider.cpp +9 -5
  116. package/ReactCommon/react/renderer/animationbackend/AnimationBackend.cpp +67 -32
  117. package/ReactCommon/react/renderer/animationbackend/AnimationBackend.h +14 -2
  118. package/ReactCommon/react/renderer/core/EventDispatcher.cpp +1 -1
  119. package/ReactCommon/react/renderer/core/EventQueueProcessor.cpp +3 -3
  120. package/ReactCommon/react/runtime/ReactInstance.cpp +8 -6
  121. package/ReactCommon/react/runtime/ReactInstance.h +0 -1
  122. package/flow/bom.js.flow +7 -0
  123. package/package.json +8 -8
  124. package/scripts/ios-configure-glog.sh +6 -1
  125. package/types_generated/Libraries/Components/Button.d.ts +1 -4
  126. package/types_generated/Libraries/StyleSheet/PlatformColorValueTypes.d.ts +3 -3
  127. package/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.kt +0 -25
  128. package/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapperBase.kt +0 -61
  129. package/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.h +0 -37
@@ -17,10 +17,9 @@
17
17
  #include <ReactCommon/BindingsInstallerHolder.h>
18
18
  #include <ReactCommon/CxxTurboModuleUtils.h>
19
19
  #include <ReactCommon/JavaInteropTurboModule.h>
20
- #include <ReactCommon/TurboCxxModule.h>
21
20
  #include <ReactCommon/TurboModuleBinding.h>
22
21
  #include <ReactCommon/TurboModulePerfLogger.h>
23
- #include <react/jni/CxxModuleWrapper.h>
22
+ #include <react/jni/CxxModuleWrapperBase.h>
24
23
 
25
24
  namespace facebook::react {
26
25
 
@@ -208,22 +207,6 @@ std::shared_ptr<TurboModule> TurboModuleManager::getTurboModule(
208
207
  return turboModule;
209
208
  }
210
209
 
211
- static auto getTurboLegacyCxxModule =
212
- javaPart->getClass()
213
- ->getMethod<jni::alias_ref<CxxModuleWrapper::javaobject>(
214
- const std::string&)>("getTurboLegacyCxxModule");
215
- auto legacyCxxModule = getTurboLegacyCxxModule(javaPart.get(), name);
216
- if (legacyCxxModule) {
217
- TurboModulePerfLogger::moduleJSRequireEndingStart(moduleName);
218
-
219
- auto turboModule = std::make_shared<react::TurboCxxModule>(
220
- legacyCxxModule->cthis()->getModule(), jsCallInvoker_);
221
- turboModuleCache_.insert({name, turboModule});
222
-
223
- TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName);
224
- return turboModule;
225
- }
226
-
227
210
  return nullptr;
228
211
  }
229
212
 
@@ -260,23 +243,6 @@ std::shared_ptr<TurboModule> TurboModuleManager::getLegacyModule(
260
243
 
261
244
  TurboModulePerfLogger::moduleJSRequireBeginningEnd(moduleName);
262
245
 
263
- static auto getLegacyCxxModule =
264
- javaPart->getClass()
265
- ->getMethod<jni::alias_ref<CxxModuleWrapper::javaobject>(
266
- const std::string&)>("getLegacyCxxModule");
267
- auto legacyCxxModule = getLegacyCxxModule(javaPart.get(), name);
268
-
269
- if (legacyCxxModule) {
270
- TurboModulePerfLogger::moduleJSRequireEndingStart(moduleName);
271
-
272
- auto turboModule = std::make_shared<react::TurboCxxModule>(
273
- legacyCxxModule->cthis()->getModule(), jsCallInvoker_);
274
- legacyModuleCache_.insert({name, turboModule});
275
-
276
- TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName);
277
- return turboModule;
278
- }
279
-
280
246
  static auto getLegacyJavaModule =
281
247
  javaPart->getClass()
282
248
  ->getMethod<jni::alias_ref<JNativeModule>(const std::string&)>(
@@ -6,7 +6,6 @@
6
6
  */
7
7
 
8
8
  #include "ReactMarker.h"
9
- #include <cxxreact/JSExecutor.h>
10
9
 
11
10
  namespace facebook::react::ReactMarker {
12
11
 
@@ -22,7 +22,7 @@ constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 84;
24
24
  int32_t Patch = 0;
25
- std::string_view Prerelease = "nightly-20251106-de5141a3d";
25
+ std::string_view Prerelease = "nightly-20251107-f8198f662";
26
26
  } ReactNativeVersion;
27
27
 
28
28
  } // namespace facebook::react
@@ -20,7 +20,9 @@ target_link_libraries(jsireact
20
20
  reactperflogger
21
21
  folly_runtime
22
22
  glog
23
- jsi)
23
+ jserrorhandler
24
+ jsi
25
+ jsitooling)
24
26
 
25
27
  target_compile_reactnative_options(jsireact PRIVATE)
26
28
  target_compile_options(jsireact PRIVATE -O3)
@@ -30,7 +30,9 @@ Pod::Spec.new do |s|
30
30
  s.header_dir = "jsireact"
31
31
 
32
32
  s.dependency "React-cxxreact"
33
+ s.dependency "React-jserrorhandler"
33
34
  s.dependency "React-jsi"
35
+ s.dependency "React-jsitooling"
34
36
  s.dependency "React-perflogger"
35
37
  add_dependency(s, "React-debug")
36
38
  add_dependency(s, "React-runtimeexecutor", :additional_framework_paths => ["platform/ios"])
@@ -576,44 +576,4 @@ void JSIExecutor::flush() {}
576
576
 
577
577
  #endif // RCT_REMOVE_LEGACY_ARCH
578
578
 
579
- void bindNativeLogger(Runtime& runtime, Logger logger) {
580
- runtime.global().setProperty(
581
- runtime,
582
- "nativeLoggingHook",
583
- Function::createFromHostFunction(
584
- runtime,
585
- PropNameID::forAscii(runtime, "nativeLoggingHook"),
586
- 2,
587
- [logger = std::move(logger)](
588
- jsi::Runtime& runtime,
589
- const jsi::Value&,
590
- const jsi::Value* args,
591
- size_t count) {
592
- if (count != 2) {
593
- throw std::invalid_argument(
594
- "nativeLoggingHook takes 2 arguments");
595
- }
596
- logger(
597
- args[0].asString(runtime).utf8(runtime),
598
- static_cast<unsigned int>(args[1].asNumber()));
599
- return Value::undefined();
600
- }));
601
- }
602
-
603
- void bindNativePerformanceNow(Runtime& runtime) {
604
- runtime.global().setProperty(
605
- runtime,
606
- "nativePerformanceNow",
607
- Function::createFromHostFunction(
608
- runtime,
609
- PropNameID::forAscii(runtime, "nativePerformanceNow"),
610
- 0,
611
- [](jsi::Runtime& runtime,
612
- const jsi::Value&,
613
- const jsi::Value* args,
614
- size_t /*count*/) {
615
- return HighResTimeStamp::now().toDOMHighResTimeStamp();
616
- }));
617
- }
618
-
619
579
  } // namespace facebook::react
@@ -12,6 +12,7 @@
12
12
  #include <cxxreact/RAMBundleRegistry.h>
13
13
  #include <jsi/jsi.h>
14
14
  #include <jsireact/JSINativeModules.h>
15
+ #include <react/runtime/JSRuntimeBindings.h>
15
16
  #include <functional>
16
17
  #include <mutex>
17
18
  #include <optional>
@@ -127,10 +128,4 @@ class [[deprecated("This API will be removed along with the legacy architecture.
127
128
  #endif // RCT_REMOVE_LEGACY_ARCH
128
129
  };
129
130
 
130
- using Logger = std::function<void(const std::string &message, unsigned int logLevel)>;
131
- void bindNativeLogger(jsi::Runtime &runtime, Logger logger);
132
-
133
- void bindNativePerformanceNow(jsi::Runtime &runtime);
134
-
135
- double performanceNow();
136
131
  } // namespace facebook::react
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #include "ConsoleTask.h"
9
+ #include "ConsoleTaskOrchestrator.h"
10
+
11
+ namespace facebook::react::jsinspector_modern {
12
+
13
+ ConsoleTask::ConsoleTask(std::shared_ptr<ConsoleTaskContext> taskContext)
14
+ : taskContext_(std::move(taskContext)),
15
+ orchestrator_(ConsoleTaskOrchestrator::getInstance()) {
16
+ if (taskContext_) {
17
+ orchestrator_.startTask(taskContext_->id());
18
+ }
19
+ }
20
+
21
+ ConsoleTask::~ConsoleTask() {
22
+ if (taskContext_) {
23
+ orchestrator_.finishTask(taskContext_->id());
24
+ }
25
+ }
26
+
27
+ } // namespace facebook::react::jsinspector_modern
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <memory>
11
+
12
+ namespace facebook::react::jsinspector_modern {
13
+
14
+ class ConsoleTaskContext;
15
+ class RuntimeTargetDelegate;
16
+ class ConsoleTaskOrchestrator;
17
+
18
+ class ConsoleTask {
19
+ public:
20
+ /**
21
+ * \param runtimeTargetDelegate The delegate to the corresponding runtime.
22
+ * \param taskContext The context that tracks the task.
23
+ */
24
+ explicit ConsoleTask(std::shared_ptr<ConsoleTaskContext> taskContext);
25
+ ~ConsoleTask();
26
+
27
+ ConsoleTask(const ConsoleTask &) = default;
28
+ ConsoleTask &operator=(const ConsoleTask &) = delete;
29
+
30
+ ConsoleTask(ConsoleTask &&) = default;
31
+ ConsoleTask &operator=(ConsoleTask &&) = delete;
32
+
33
+ private:
34
+ std::shared_ptr<ConsoleTaskContext> taskContext_;
35
+ ConsoleTaskOrchestrator &orchestrator_;
36
+ };
37
+
38
+ } // namespace facebook::react::jsinspector_modern
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #include "ConsoleTaskContext.h"
9
+ #include "ConsoleTaskOrchestrator.h"
10
+ #include "RuntimeTarget.h"
11
+
12
+ namespace facebook::react::jsinspector_modern {
13
+
14
+ ConsoleTaskContext::ConsoleTaskContext(
15
+ jsi::Runtime& runtime,
16
+ RuntimeTargetDelegate& runtimeTargetDelegate,
17
+ std::string name)
18
+ : runtimeTargetDelegate_(runtimeTargetDelegate),
19
+ name_(std::move(name)),
20
+ orchestrator_(ConsoleTaskOrchestrator::getInstance()) {
21
+ stackTrace_ = runtimeTargetDelegate_.captureStackTrace(runtime);
22
+ }
23
+
24
+ ConsoleTaskContext::~ConsoleTaskContext() {
25
+ orchestrator_.cancelTask(id());
26
+ }
27
+
28
+ ConsoleTaskId ConsoleTaskContext::id() const {
29
+ return ConsoleTaskId{(void*)this};
30
+ }
31
+
32
+ std::optional<folly::dynamic> ConsoleTaskContext::getSerializedStackTrace()
33
+ const {
34
+ auto maybeValue = runtimeTargetDelegate_.serializeStackTrace(*stackTrace_);
35
+ if (maybeValue) {
36
+ maybeValue.value()["description"] = name_;
37
+ }
38
+
39
+ return maybeValue;
40
+ }
41
+
42
+ void ConsoleTaskContext::schedule() {
43
+ orchestrator_.scheduleTask(id(), weak_from_this());
44
+ }
45
+
46
+ } // namespace facebook::react::jsinspector_modern
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include "StackTrace.h"
11
+
12
+ #include <folly/dynamic.h>
13
+ #include <jsi/jsi.h>
14
+
15
+ #include <cassert>
16
+ #include <functional>
17
+ #include <memory>
18
+ #include <string>
19
+
20
+ namespace facebook::react::jsinspector_modern {
21
+
22
+ class ConsoleTaskOrchestrator;
23
+ class RuntimeTargetDelegate;
24
+
25
+ class ConsoleTaskId {
26
+ public:
27
+ ConsoleTaskId() = default;
28
+ ~ConsoleTaskId() = default;
29
+
30
+ ConsoleTaskId(const ConsoleTaskId &) = default;
31
+ ConsoleTaskId &operator=(const ConsoleTaskId &) = default;
32
+
33
+ ConsoleTaskId(ConsoleTaskId &&) = default;
34
+ ConsoleTaskId &operator=(ConsoleTaskId &&) = default;
35
+
36
+ bool operator==(const ConsoleTaskId &) const = default;
37
+ inline operator bool() const
38
+ {
39
+ return (bool)id_;
40
+ }
41
+
42
+ explicit inline operator void *() const
43
+ {
44
+ return id_;
45
+ }
46
+
47
+ private:
48
+ explicit inline ConsoleTaskId(void *id) : id_(id)
49
+ {
50
+ assert(id_ != nullptr);
51
+ }
52
+
53
+ void *id_{nullptr};
54
+
55
+ friend class ConsoleTaskContext;
56
+ };
57
+
58
+ class ConsoleTaskContext : public std::enable_shared_from_this<ConsoleTaskContext> {
59
+ public:
60
+ ConsoleTaskContext(jsi::Runtime &runtime, RuntimeTargetDelegate &runtimeTargetDelegate, std::string name);
61
+ ~ConsoleTaskContext();
62
+
63
+ // Can't be moved or copied: the address of `ConsoleTaskContext` is used to
64
+ // identify this task and all corresponding invocations.
65
+ ConsoleTaskContext(const ConsoleTaskContext &) = delete;
66
+ ConsoleTaskContext &operator=(const ConsoleTaskContext &) = delete;
67
+
68
+ ConsoleTaskContext(ConsoleTaskContext &&) = delete;
69
+ ConsoleTaskContext &operator=(ConsoleTaskContext &&) = delete;
70
+
71
+ /**
72
+ * Unique identifier that is calculated based on the address of
73
+ * ConsoleTaskContext.
74
+ */
75
+ ConsoleTaskId id() const;
76
+
77
+ /**
78
+ * Returns the serialized stack trace that was captured during the allocation
79
+ * of ConsoleTaskContext.
80
+ */
81
+ std::optional<folly::dynamic> getSerializedStackTrace() const;
82
+
83
+ void schedule();
84
+
85
+ private:
86
+ RuntimeTargetDelegate &runtimeTargetDelegate_;
87
+ std::string name_;
88
+ ConsoleTaskOrchestrator &orchestrator_;
89
+ std::unique_ptr<StackTrace> stackTrace_;
90
+ };
91
+
92
+ } // namespace facebook::react::jsinspector_modern
93
+
94
+ namespace std {
95
+ template <>
96
+ struct hash<facebook::react::jsinspector_modern::ConsoleTaskId> {
97
+ size_t operator()(const facebook::react::jsinspector_modern::ConsoleTaskId &id) const
98
+ {
99
+ return std::hash<void *>{}(static_cast<void *>(id));
100
+ }
101
+ };
102
+ } // namespace std
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #include "ConsoleTaskOrchestrator.h"
9
+
10
+ namespace facebook::react::jsinspector_modern {
11
+
12
+ /* static */ ConsoleTaskOrchestrator& ConsoleTaskOrchestrator::getInstance() {
13
+ static ConsoleTaskOrchestrator instance;
14
+ return instance;
15
+ }
16
+
17
+ void ConsoleTaskOrchestrator::scheduleTask(
18
+ ConsoleTaskId taskId,
19
+ std::weak_ptr<ConsoleTaskContext> taskContext) {
20
+ std::lock_guard<std::mutex> lock(mutex_);
21
+ tasks_.emplace(taskId, taskContext);
22
+ }
23
+
24
+ void ConsoleTaskOrchestrator::cancelTask(ConsoleTaskId id) {
25
+ std::lock_guard<std::mutex> lock(mutex_);
26
+ tasks_.erase(id);
27
+ }
28
+
29
+ void ConsoleTaskOrchestrator::startTask(ConsoleTaskId id) {
30
+ std::lock_guard<std::mutex> lock(mutex_);
31
+ stack_.push(id);
32
+ }
33
+
34
+ void ConsoleTaskOrchestrator::finishTask(ConsoleTaskId id) {
35
+ std::lock_guard<std::mutex> lock(mutex_);
36
+ assert(stack_.top() == id);
37
+
38
+ stack_.pop();
39
+ }
40
+
41
+ std::shared_ptr<ConsoleTaskContext> ConsoleTaskOrchestrator::top() const {
42
+ std::lock_guard<std::mutex> lock(mutex_);
43
+ if (stack_.empty()) {
44
+ return nullptr;
45
+ }
46
+
47
+ auto it = tasks_.find(stack_.top());
48
+ if (it == tasks_.end()) {
49
+ return nullptr;
50
+ }
51
+
52
+ return it->second.lock();
53
+ }
54
+
55
+ } // namespace facebook::react::jsinspector_modern
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ #include <memory>
11
+ #include <mutex>
12
+ #include <stack>
13
+
14
+ #include "ConsoleTaskContext.h"
15
+
16
+ namespace facebook::react::jsinspector_modern {
17
+
18
+ class ConsoleTaskOrchestrator {
19
+ public:
20
+ static ConsoleTaskOrchestrator &getInstance();
21
+
22
+ ~ConsoleTaskOrchestrator() = default;
23
+
24
+ ConsoleTaskOrchestrator(const ConsoleTaskOrchestrator &) = delete;
25
+ ConsoleTaskOrchestrator &operator=(const ConsoleTaskOrchestrator &) = delete;
26
+
27
+ ConsoleTaskOrchestrator(ConsoleTaskOrchestrator &&) = delete;
28
+ ConsoleTaskOrchestrator &operator=(ConsoleTaskOrchestrator &&) = delete;
29
+
30
+ void scheduleTask(ConsoleTaskId taskId, std::weak_ptr<ConsoleTaskContext> taskContext);
31
+ void cancelTask(ConsoleTaskId taskId);
32
+
33
+ void startTask(ConsoleTaskId taskId);
34
+ void finishTask(ConsoleTaskId taskId);
35
+ std::shared_ptr<ConsoleTaskContext> top() const;
36
+
37
+ private:
38
+ ConsoleTaskOrchestrator() = default;
39
+
40
+ std::stack<ConsoleTaskId> stack_;
41
+ std::unordered_map<ConsoleTaskId, std::weak_ptr<ConsoleTaskContext>> tasks_;
42
+ /**
43
+ * Protects the stack_ and tasks_ members.
44
+ */
45
+ mutable std::mutex mutex_;
46
+ };
47
+
48
+ } // namespace facebook::react::jsinspector_modern
@@ -99,7 +99,7 @@ class RuntimeAgent final {
99
99
  * Lifetime of this agent is bound to the lifetime of the Tracing session -
100
100
  * HostTargetTraceRecording and to the lifetime of the RuntimeTarget.
101
101
  */
102
- class RuntimeTracingAgent : tracing::TargetTracingAgent {
102
+ class RuntimeTracingAgent : public tracing::TargetTracingAgent {
103
103
  public:
104
104
  explicit RuntimeTracingAgent(tracing::TraceRecordingState &state, RuntimeTargetController &targetController);
105
105
 
@@ -248,6 +248,18 @@ bool RuntimeTarget::isDomainEnabled(Domain domain) const {
248
248
  return threadSafeDomainStatus_[domain];
249
249
  }
250
250
 
251
+ bool RuntimeTarget::isConsoleCreateTaskEnabled() const {
252
+ if (isDomainEnabled(Domain::Runtime)) {
253
+ return true;
254
+ }
255
+
256
+ if (auto tracingAgent = tracingAgent_.lock()) {
257
+ return tracingAgent->isRunningInBackgroundMode();
258
+ }
259
+
260
+ return false;
261
+ }
262
+
251
263
  RuntimeTargetController::RuntimeTargetController(RuntimeTarget& target)
252
264
  : target_(target) {}
253
265
 
@@ -207,19 +207,6 @@ class JSINSPECTOR_EXPORT RuntimeTarget : public EnableExecutorFromThis<RuntimeTa
207
207
  */
208
208
  std::shared_ptr<RuntimeTracingAgent> createTracingAgent(tracing::TraceRecordingState &state);
209
209
 
210
- /**
211
- * Start sampling profiler for a particular JavaScript runtime.
212
- */
213
- void enableSamplingProfiler();
214
- /**
215
- * Stop sampling profiler for a particular JavaScript runtime.
216
- */
217
- void disableSamplingProfiler();
218
- /**
219
- * Return recorded sampling profile for the previous sampling session.
220
- */
221
- tracing::RuntimeSamplingProfile collectSamplingProfile();
222
-
223
210
  private:
224
211
  using Domain = RuntimeTargetController::Domain;
225
212
 
@@ -275,6 +262,18 @@ class JSINSPECTOR_EXPORT RuntimeTarget : public EnableExecutorFromThis<RuntimeTa
275
262
  * session - HostTargetTraceRecording.
276
263
  */
277
264
  std::weak_ptr<RuntimeTracingAgent> tracingAgent_;
265
+ /**
266
+ * Start sampling profiler for a particular JavaScript runtime.
267
+ */
268
+ void enableSamplingProfiler();
269
+ /**
270
+ * Stop sampling profiler for a particular JavaScript runtime.
271
+ */
272
+ void disableSamplingProfiler();
273
+ /**
274
+ * Return recorded sampling profile for the previous sampling session.
275
+ */
276
+ tracing::RuntimeSamplingProfile collectSamplingProfile();
278
277
 
279
278
  /**
280
279
  * Adds a function with the given name on the runtime's global object, that
@@ -293,6 +292,10 @@ class JSINSPECTOR_EXPORT RuntimeTarget : public EnableExecutorFromThis<RuntimeTa
293
292
  * Install the console API handler.
294
293
  */
295
294
  void installConsoleHandler();
295
+ /**
296
+ * Returns whether console.createTask should actually capture stack traces.
297
+ */
298
+ bool isConsoleCreateTaskEnabled() const;
296
299
 
297
300
  /**
298
301
  * Installs __DEBUGGER_SESSION_OBSERVER__ object on the JavaScript's global