react-native-windows 0.82.1 → 0.83.0-preview.0

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 (232) hide show
  1. package/.flowconfig +2 -7
  2. package/Libraries/Animated/components/AnimatedFlatList.js +5 -3
  3. package/Libraries/Animated/components/AnimatedImage.js +4 -3
  4. package/Libraries/Animated/components/AnimatedSectionList.js +2 -2
  5. package/Libraries/Animated/components/AnimatedText.js +7 -3
  6. package/Libraries/Animated/components/AnimatedView.js +3 -2
  7. package/Libraries/Animated/createAnimatedComponent.js +24 -12
  8. package/Libraries/Animated/nodes/AnimatedColor.js +26 -10
  9. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +43 -15
  10. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +43 -15
  11. package/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +2 -2
  12. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +2 -2
  13. package/Libraries/Components/Glyph/Glyph.js +4 -1
  14. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +2 -2
  15. package/Libraries/Components/RefreshControl/RefreshControl.d.ts +3 -3
  16. package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +2 -2
  17. package/Libraries/Components/ScrollView/ScrollView.js +1 -0
  18. package/Libraries/Components/ScrollView/ScrollView.windows.js +1 -0
  19. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -6
  20. package/Libraries/Components/Switch/Switch.d.ts +2 -2
  21. package/Libraries/Components/Switch/Switch.windows.js +1 -1
  22. package/Libraries/Components/TextInput/TextInput.d.ts +2 -5
  23. package/Libraries/Components/TextInput/TextInput.js +6 -0
  24. package/Libraries/Components/TextInput/TextInput.windows.js +6 -0
  25. package/Libraries/Components/Touchable/TouchableBounce.js +7 -7
  26. package/Libraries/Components/Touchable/TouchableBounce.windows.js +7 -7
  27. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
  28. package/Libraries/Components/View/ReactNativeStyleAttributes.js +19 -1
  29. package/Libraries/Components/View/View.d.ts +2 -2
  30. package/Libraries/Components/View/View.windows.js +0 -1
  31. package/Libraries/Components/View/ViewNativeComponent.js +13 -1
  32. package/Libraries/Core/ReactNativeVersion.js +3 -3
  33. package/Libraries/Core/setUpPerformance.js +2 -0
  34. package/Libraries/Debugging/DebuggingOverlay.js +14 -14
  35. package/Libraries/Debugging/DebuggingOverlayRegistry.js +8 -2
  36. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +5 -2
  37. package/Libraries/Image/Image.d.ts +3 -3
  38. package/Libraries/Image/ImageInjection.js +3 -6
  39. package/Libraries/Image/ImageTypes.flow.js +3 -7
  40. package/Libraries/Lists/FlatList.js +8 -8
  41. package/Libraries/Lists/SectionList.d.ts +5 -1
  42. package/Libraries/Lists/ViewabilityHelper.js +1 -1
  43. package/Libraries/Lists/VirtualizedList.js +1 -0
  44. package/Libraries/LogBox/UI/AnsiHighlight.js +4 -1
  45. package/Libraries/NativeComponent/BaseViewConfig.android.js +11 -2
  46. package/Libraries/NativeComponent/NativeComponentRegistry.d.ts +98 -0
  47. package/Libraries/NativeComponent/NativeComponentRegistry.js +2 -0
  48. package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +3 -1
  49. package/Libraries/NativeComponent/ViewConfigIgnore.windows.js +45 -0
  50. package/Libraries/Network/RCTNetworking.android.js +3 -1
  51. package/Libraries/Network/RCTNetworking.ios.js +3 -0
  52. package/Libraries/Network/RCTNetworking.windows.js +3 -0
  53. package/Libraries/Network/XMLHttpRequest.js +1 -41
  54. package/Libraries/Pressability/usePressability.js +14 -3
  55. package/Libraries/ReactNative/PaperUIManager.windows.js +3 -3
  56. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +20 -82
  57. package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
  58. package/Libraries/Renderer/implementations/ReactFabric-dev.js +6759 -4478
  59. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3169 -3119
  60. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4732 -3535
  61. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +6646 -4070
  62. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3136 -2825
  63. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4761 -3312
  64. package/Libraries/Renderer/shims/ReactNative.js +3 -1
  65. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
  66. package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +2 -1
  67. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
  68. package/Libraries/StyleSheet/StyleSheetTypes.js +44 -0
  69. package/Libraries/StyleSheet/processBackgroundPosition.js +284 -0
  70. package/Libraries/StyleSheet/processBackgroundRepeat.js +105 -0
  71. package/Libraries/StyleSheet/processBackgroundSize.js +104 -0
  72. package/Libraries/Text/Text.d.ts +2 -2
  73. package/Libraries/Text/TextNativeComponent.js +10 -0
  74. package/Libraries/TurboModule/TurboModuleRegistry.js +3 -9
  75. package/Libraries/Utilities/DevLoadingView.js +14 -6
  76. package/Libraries/Utilities/HMRClient.js +13 -5
  77. package/Microsoft.ReactNative/Base/CxxReactIncludes.h +11 -0
  78. package/Microsoft.ReactNative/CompositionComponentView.idl +2 -0
  79. package/Microsoft.ReactNative/CompositionHwndHost.idl +1 -0
  80. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -1
  81. package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
  82. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +10 -40
  83. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +3 -80
  84. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +45 -12
  85. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +8 -0
  86. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +61 -74
  87. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -0
  88. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +1 -0
  89. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +4 -3
  90. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +2 -1
  91. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.cpp +245 -0
  92. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.h +80 -0
  93. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +20 -36
  94. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +70 -49
  95. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -1
  96. package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -0
  97. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +7 -2
  98. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
  99. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
  100. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
  101. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +20 -94
  102. package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -3
  103. package/Microsoft.ReactNative/Pch/pch.h +2 -0
  104. package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +5 -0
  105. package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -0
  106. package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +0 -41
  107. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +0 -11
  108. package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -3
  109. package/Microsoft.ReactNative/ReactNativeWin32App.cpp +31 -101
  110. package/Microsoft.ReactNative/ReactNativeWin32App.h +2 -13
  111. package/Microsoft.ReactNative/ReactNativeWindow.idl +44 -0
  112. package/Microsoft.ReactNative.Cxx/AutoDraw.h +9 -1
  113. package/Microsoft.ReactNative.Cxx/ReactCommon/CallInvoker.h +13 -16
  114. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +24 -36
  115. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.h +5 -8
  116. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/AString.h +8 -6
  117. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Array.h +32 -49
  118. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Base.h +27 -76
  119. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +4 -2
  120. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/CallbackWrapper.h +19 -18
  121. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +25 -48
  122. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Convert.h +38 -31
  123. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Error.h +11 -6
  124. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/EventEmitter.h +47 -45
  125. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Function.h +69 -89
  126. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/HighResTimeStamp.h +8 -8
  127. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.h +6 -6
  128. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Number.h +16 -8
  129. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Object.h +17 -24
  130. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Promise.h +17 -17
  131. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Value.h +20 -29
  132. package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/react_native_assert.h +2 -7
  133. package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +127 -115
  134. package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.props +10 -0
  135. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +10 -0
  136. package/PropertySheets/Generated/PackageVersion.g.props +5 -5
  137. package/PropertySheets/Warnings.props +2 -1
  138. package/ReactCommon/ReactCommon.vcxproj +21 -12
  139. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
  140. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +381 -0
  141. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +49 -0
  142. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +145 -0
  143. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +100 -0
  144. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +256 -0
  145. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +13 -4
  146. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +93 -0
  147. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +149 -0
  148. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +25 -35
  149. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +86 -67
  150. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +629 -0
  151. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +123 -0
  152. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +84 -68
  153. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +31 -35
  154. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +4 -5
  155. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/network/HttpUtils.cpp +2 -1
  156. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +24 -36
  157. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +28 -66
  158. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +414 -0
  159. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +3 -3
  160. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +8 -4
  161. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +19 -16
  162. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +8 -9
  163. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +25 -95
  164. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +85 -42
  165. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +81 -0
  166. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +140 -0
  167. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
  168. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +746 -0
  169. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +702 -0
  170. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +1 -15
  171. package/Scripts/creaternwapp.cmd +1 -1
  172. package/Scripts/perf/compare-results.js +357 -0
  173. package/Scripts/perf/create-perf-test.js +343 -0
  174. package/Scripts/perf/post-pr-comment.js +210 -0
  175. package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +8 -0
  176. package/Shared/Hermes/HermesRuntimeTargetDelegate.h +3 -0
  177. package/Shared/Shared.vcxitems +24 -12
  178. package/Shared/Shared.vcxitems.filters +11 -3
  179. package/codegen/NativeIntersectionObserverSpec.g.h +2 -0
  180. package/codegen/NativeNetworkingIOSSpec.g.h +2 -0
  181. package/codegen/NativePerformanceSpec.g.h +6 -0
  182. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +229 -139
  183. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +2 -1
  184. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +42 -25
  185. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +2 -1
  186. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +2 -1
  187. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +11 -6
  188. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +11 -6
  189. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +1 -0
  190. package/codegen/react/components/rnwcore/InputAccessory.g.h +2 -1
  191. package/codegen/react/components/rnwcore/ModalHostView.g.h +40 -23
  192. package/codegen/react/components/rnwcore/Props.cpp +6 -1
  193. package/codegen/react/components/rnwcore/Props.h +1 -0
  194. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +11 -6
  195. package/codegen/react/components/rnwcore/SafeAreaView.g.h +1 -0
  196. package/codegen/react/components/rnwcore/Switch.g.h +11 -6
  197. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +2 -1
  198. package/codegen/react/components/rnwcore/VirtualView.g.h +41 -8
  199. package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +45 -8
  200. package/codegen/rnwcoreJSI.h +3973 -6059
  201. package/index.js +6 -0
  202. package/index.windows.js +6 -0
  203. package/jest/mockComponent.js +6 -6
  204. package/jest/setup.js +15 -10
  205. package/package.json +27 -27
  206. package/src/private/components/virtualview/VirtualView.js +22 -27
  207. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +6 -0
  208. package/src/private/featureflags/ReactNativeFeatureFlags.js +100 -19
  209. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +18 -3
  210. package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
  211. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
  212. package/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +1 -0
  213. package/src/private/webapis/dom/nodes/ReactNativeElement.js +12 -2
  214. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +76 -15
  215. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +1 -0
  216. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
  217. package/src/private/webapis/performance/ResourceTiming.js +31 -4
  218. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +4 -1
  219. package/src/private/webapis/performance/specs/NativePerformance.js +3 -0
  220. package/stubs/double-conversion/double-conversion.h +5 -0
  221. package/templates/cpp-app/template.config.js +1 -1
  222. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +3 -1
  223. package/templates/cpp-lib/template.config.js +1 -1
  224. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
  225. package/types/index.d.ts +1 -0
  226. package/types/public/ReactNativeTypes.d.ts +115 -2
  227. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +0 -152
  228. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +0 -1574
  229. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ShadowNode.cpp +0 -528
  230. package/Scripts/OpenSSL.nuspec +0 -39
  231. package/Scripts/OpenSSL.targets +0 -36
  232. package/codegen/rnwcoreJSI-generated.cpp +0 -3470
@@ -0,0 +1,256 @@
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
+
9
+ #if _MSC_VER
10
+ #pragma warning(push)
11
+ #pragma warning(disable : 4996) // deprecated APIs
12
+ #endif
13
+ #include "ModuleRegistry.h"
14
+
15
+ #ifndef RCT_REMOVE_LEGACY_ARCH
16
+
17
+ #include <glog/logging.h>
18
+ #include <reactperflogger/BridgeNativeModulePerfLogger.h>
19
+ #include <utility>
20
+
21
+ #include "NativeModule.h"
22
+ #include "TraceSection.h"
23
+
24
+ namespace facebook::react {
25
+
26
+ namespace {
27
+
28
+ std::string normalizeName(std::string name) {
29
+ // TODO mhorowitz #10487027: This is super ugly. We should just
30
+ // change iOS to emit normalized names, drop the "RK..." from
31
+ // names hardcoded in Android, and then delete this and the
32
+ // similar hacks in js.
33
+ if (name.compare(0, 3, "RCT") == 0) {
34
+ return name.substr(3);
35
+ } else if (name.compare(0, 2, "RK") == 0) {
36
+ return name.substr(2);
37
+ }
38
+ return name;
39
+ }
40
+
41
+ } // namespace
42
+
43
+ ModuleRegistry::ModuleRegistry(
44
+ std::vector<std::unique_ptr<NativeModule>> modules,
45
+ ModuleNotFoundCallback callback)
46
+ : modules_{std::move(modules)},
47
+ moduleNotFoundCallback_{std::move(callback)} {}
48
+
49
+ void ModuleRegistry::updateModuleNamesFromIndex(size_t index) {
50
+ for (; index < modules_.size(); index++) {
51
+ std::string name = normalizeName(modules_[index]->getName());
52
+ modulesByName_[name] = index;
53
+ }
54
+ }
55
+
56
+ void ModuleRegistry::registerModules(
57
+ std::vector<std::unique_ptr<NativeModule>> modules) {
58
+ TraceSection s_("ModuleRegistry::registerModules");
59
+ // Noop if there are no NativeModules to add
60
+ if (modules.empty()) {
61
+ return;
62
+ }
63
+
64
+ if (modules_.empty() && unknownModules_.empty()) {
65
+ modules_ = std::move(modules);
66
+ } else {
67
+ size_t modulesSize = modules_.size();
68
+ size_t addModulesSize = modules.size();
69
+ bool addToNames = !modulesByName_.empty();
70
+ modules_.reserve(modulesSize + addModulesSize);
71
+ std::move(modules.begin(), modules.end(), std::back_inserter(modules_));
72
+ if (!unknownModules_.empty()) {
73
+ for (size_t index = modulesSize; index < modulesSize + addModulesSize;
74
+ index++) {
75
+ std::string name = normalizeName(modules_[index]->getName());
76
+ auto it = unknownModules_.find(name);
77
+ if (it != unknownModules_.end()) {
78
+ throw std::runtime_error(
79
+ "module " + name +
80
+ " was required without being registered and is now being registered.");
81
+ } else if (addToNames) {
82
+ modulesByName_[name] = index;
83
+ }
84
+ }
85
+ } else if (addToNames) {
86
+ updateModuleNamesFromIndex(modulesSize);
87
+ }
88
+ }
89
+ }
90
+
91
+ std::vector<std::string> ModuleRegistry::moduleNames() {
92
+ TraceSection s_("ModuleRegistry::moduleNames");
93
+ std::vector<std::string> names;
94
+ for (size_t i = 0; i < modules_.size(); i++) {
95
+ std::string name = normalizeName(modules_[i]->getName());
96
+ modulesByName_[name] = i;
97
+ names.push_back(std::move(name));
98
+ }
99
+ return names;
100
+ }
101
+
102
+ std::optional<ModuleConfig> ModuleRegistry::getConfig(const std::string& name) {
103
+ TraceSection s("ModuleRegistry::getConfig", "module", name);
104
+
105
+ // Initialize modulesByName_
106
+ if (modulesByName_.empty() && !modules_.empty()) {
107
+ moduleNames();
108
+ }
109
+
110
+ auto it = modulesByName_.find(name);
111
+
112
+ if (it == modulesByName_.end()) {
113
+ if (unknownModules_.find(name) != unknownModules_.end()) {
114
+ BridgeNativeModulePerfLogger::moduleJSRequireBeginningFail(name.c_str());
115
+ BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
116
+ return std::nullopt;
117
+ }
118
+
119
+ if (!moduleNotFoundCallback_) {
120
+ unknownModules_.insert(name);
121
+ BridgeNativeModulePerfLogger::moduleJSRequireBeginningFail(name.c_str());
122
+ BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
123
+ return std::nullopt;
124
+ }
125
+
126
+ BridgeNativeModulePerfLogger::moduleJSRequireBeginningEnd(name.c_str());
127
+
128
+ bool wasModuleLazilyLoaded = moduleNotFoundCallback_(name);
129
+ it = modulesByName_.find(name);
130
+
131
+ bool wasModuleRegisteredWithRegistry =
132
+ wasModuleLazilyLoaded && it != modulesByName_.end();
133
+
134
+ if (!wasModuleRegisteredWithRegistry) {
135
+ BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
136
+ unknownModules_.insert(name);
137
+ return std::nullopt;
138
+ }
139
+ } else {
140
+ BridgeNativeModulePerfLogger::moduleJSRequireBeginningEnd(name.c_str());
141
+ }
142
+
143
+ // If we've gotten this far, then we've signaled moduleJSRequireBeginningEnd
144
+
145
+ size_t index = it->second;
146
+
147
+ CHECK(index < modules_.size());
148
+ NativeModule* module = modules_[index].get();
149
+
150
+ // string name, object constants, array methodNames (methodId is index),
151
+ // [array promiseMethodIds], [array syncMethodIds]
152
+ folly::dynamic config = folly::dynamic::array(name);
153
+
154
+ {
155
+ TraceSection s_("ModuleRegistry::getConstants", "module", name);
156
+ /**
157
+ * In the case that there are constants, we'll initialize the NativeModule,
158
+ * and signal moduleJSRequireEndingStart. Otherwise, we'll simply signal the
159
+ * event. The Module will be initialized when we invoke one of its
160
+ * NativeModule methods.
161
+ */
162
+ config.push_back(module->getConstants());
163
+ }
164
+
165
+ {
166
+ TraceSection s_("ModuleRegistry::getMethods", "module", name);
167
+ std::vector<MethodDescriptor> methods = module->getMethods();
168
+
169
+ folly::dynamic methodNames = folly::dynamic::array;
170
+ folly::dynamic promiseMethodIds = folly::dynamic::array;
171
+ folly::dynamic syncMethodIds = folly::dynamic::array;
172
+
173
+ for (auto& descriptor : methods) {
174
+ // TODO: #10487027 compare tags instead of doing string comparison?
175
+ methodNames.push_back(std::move(descriptor.name));
176
+ if (descriptor.type == "promise") {
177
+ promiseMethodIds.push_back(methodNames.size() - 1);
178
+ } else if (descriptor.type == "sync") {
179
+ syncMethodIds.push_back(methodNames.size() - 1);
180
+ }
181
+ }
182
+
183
+ if (!methodNames.empty()) {
184
+ config.push_back(std::move(methodNames));
185
+ if (!promiseMethodIds.empty() || !syncMethodIds.empty()) {
186
+ config.push_back(std::move(promiseMethodIds));
187
+ if (!syncMethodIds.empty()) {
188
+ config.push_back(std::move(syncMethodIds));
189
+ }
190
+ }
191
+ }
192
+ }
193
+
194
+ if (config.size() == 2 && config[1].empty()) {
195
+ // no constants or methods
196
+ return std::nullopt;
197
+ } else {
198
+ return ModuleConfig{.index = index, .config = std::move(config)};
199
+ }
200
+ }
201
+
202
+ std::string ModuleRegistry::getModuleName(unsigned int moduleId) {
203
+ if (moduleId >= modules_.size()) {
204
+ throw std::runtime_error(
205
+ "moduleId " + std::to_string(moduleId) + " out of range [0.." +
206
+ std::to_string(modules_.size()) + ")");
207
+ }
208
+
209
+ return modules_[moduleId]->getName();
210
+ }
211
+
212
+ std::string ModuleRegistry::getModuleSyncMethodName(
213
+ unsigned int moduleId,
214
+ unsigned int methodId) {
215
+ if (moduleId >= modules_.size()) {
216
+ throw std::runtime_error(
217
+ "moduleId " + std::to_string(moduleId) + " out of range [0.." +
218
+ std::to_string(modules_.size()) + ")");
219
+ }
220
+
221
+ return modules_[moduleId]->getSyncMethodName(methodId);
222
+ }
223
+
224
+ void ModuleRegistry::callNativeMethod(
225
+ unsigned int moduleId,
226
+ unsigned int methodId,
227
+ folly::dynamic&& params,
228
+ int callId) {
229
+ if (moduleId >= modules_.size()) {
230
+ throw std::runtime_error(
231
+ "moduleId " + std::to_string(moduleId) + " out of range [0.." +
232
+ std::to_string(modules_.size()) + ")");
233
+ }
234
+ modules_[moduleId]->invoke(methodId, std::move(params), callId);
235
+ }
236
+
237
+ MethodCallResult ModuleRegistry::callSerializableNativeHook(
238
+ unsigned int moduleId,
239
+ unsigned int methodId,
240
+ folly::dynamic&& params) {
241
+ if (moduleId >= modules_.size()) {
242
+ throw std::runtime_error(
243
+ "moduleId " + std::to_string(moduleId) + " out of range [0.." +
244
+ std::to_string(modules_.size()) + ")");
245
+ }
246
+ return modules_[moduleId]->callSerializableNativeHook(
247
+ methodId, std::move(params));
248
+ }
249
+
250
+ } // namespace facebook::react
251
+
252
+ #endif // RCT_REMOVE_LEGACY_ARCH
253
+
254
+ #if _MSC_VER
255
+ #pragma warning(pop)
256
+ #endif
@@ -5,9 +5,14 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ #if _MSC_VER
9
+ #pragma warning(push)
10
+ #pragma warning(disable : 4996) // deprecated APIs
11
+ #endif
12
+
8
13
  #include "NativeToJsBridge.h"
9
14
 
10
- #ifndef RCT_FIT_RM_OLD_RUNTIME
15
+ #ifndef RCT_REMOVE_LEGACY_ARCH
11
16
 
12
17
  #include <ReactCommon/CallInvoker.h>
13
18
  #include <folly/json.h>
@@ -38,8 +43,8 @@ namespace facebook::react {
38
43
 
39
44
  // This class manages calls from JS to native code.
40
45
  class [[deprecated(
41
- "This API will be removed along with the legacy architecture.")]] JsToNativeBridge
42
- : public react::ExecutorDelegate {
46
+ "This API will be removed along with the legacy architecture.")]]
47
+ JsToNativeBridge : public react::ExecutorDelegate {
43
48
  public:
44
49
  JsToNativeBridge(
45
50
  std::shared_ptr<ModuleRegistry> registry,
@@ -351,4 +356,8 @@ NativeToJsBridge::getInspectorTargetDelegate() {
351
356
 
352
357
  } // namespace facebook::react
353
358
 
354
- #endif // RCT_FIT_RM_OLD_RUNTIME
359
+ #endif // RCT_REMOVE_LEGACY_ARCH
360
+
361
+ #if _MSC_VER
362
+ #pragma warning(pop)
363
+ #endif
@@ -0,0 +1,93 @@
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
+
9
+ #if _MSC_VER
10
+ #pragma warning(push)
11
+ #pragma warning(disable : 4996) // deprecated APIs
12
+ #endif
13
+ #include "RAMBundleRegistry.h"
14
+
15
+ #ifndef RCT_REMOVE_LEGACY_ARCH
16
+
17
+ #include <folly/String.h>
18
+
19
+ #include <memory>
20
+
21
+ namespace facebook::react {
22
+
23
+ #pragma clang diagnostic push
24
+ #pragma clang diagnostic ignored "-Wdeprecated"
25
+ constexpr uint32_t RAMBundleRegistry::MAIN_BUNDLE_ID;
26
+ #pragma clang diagnostic pop
27
+
28
+ std::unique_ptr<RAMBundleRegistry> RAMBundleRegistry::singleBundleRegistry(
29
+ std::unique_ptr<JSModulesUnbundle> mainBundle) {
30
+ return std::make_unique<RAMBundleRegistry>(std::move(mainBundle));
31
+ }
32
+
33
+ std::unique_ptr<RAMBundleRegistry> RAMBundleRegistry::multipleBundlesRegistry(
34
+ std::unique_ptr<JSModulesUnbundle> mainBundle,
35
+ std::function<std::unique_ptr<JSModulesUnbundle>(std::string)> factory) {
36
+ return std::make_unique<RAMBundleRegistry>(
37
+ std::move(mainBundle), std::move(factory));
38
+ }
39
+
40
+ RAMBundleRegistry::RAMBundleRegistry(
41
+ std::unique_ptr<JSModulesUnbundle> mainBundle,
42
+ std::function<std::unique_ptr<JSModulesUnbundle>(std::string)> factory)
43
+ : m_factory(std::move(factory)) {
44
+ m_bundles.emplace(MAIN_BUNDLE_ID, std::move(mainBundle));
45
+ }
46
+
47
+ void RAMBundleRegistry::registerBundle(
48
+ uint32_t bundleId,
49
+ std::string bundlePath) {
50
+ m_bundlePaths.emplace(bundleId, std::move(bundlePath));
51
+ }
52
+
53
+ JSModulesUnbundle::Module RAMBundleRegistry::getModule(
54
+ uint32_t bundleId,
55
+ uint32_t moduleId) {
56
+ if (m_bundles.find(bundleId) == m_bundles.end()) {
57
+ if (!m_factory) {
58
+ throw std::runtime_error(
59
+ "You need to register factory function in order to "
60
+ "support multiple RAM bundles.");
61
+ }
62
+
63
+ auto bundlePath = m_bundlePaths.find(bundleId);
64
+ if (bundlePath == m_bundlePaths.end()) {
65
+ throw std::runtime_error(
66
+ "In order to fetch RAM bundle from the registry, its file "
67
+ "path needs to be registered first.");
68
+ }
69
+ m_bundles.emplace(bundleId, m_factory(bundlePath->second));
70
+ }
71
+
72
+ auto module = getBundle(bundleId)->getModule(moduleId);
73
+ if (bundleId == MAIN_BUNDLE_ID) {
74
+ return module;
75
+ }
76
+
77
+ return {
78
+ .name = "seg-" + std::to_string(bundleId) + '_' + module.name,
79
+ .code = std::move(module.code),
80
+ };
81
+ }
82
+
83
+ JSModulesUnbundle* RAMBundleRegistry::getBundle(uint32_t bundleId) const {
84
+ return m_bundles.at(bundleId).get();
85
+ }
86
+
87
+ } // namespace facebook::react
88
+
89
+ #endif // RCT_REMOVE_LEGACY_ARCH
90
+
91
+ #if _MSC_VER
92
+ #pragma warning(pop)
93
+ #endif
@@ -0,0 +1,149 @@
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
+
9
+ #if _MSC_VER
10
+ #pragma warning(push)
11
+ #pragma warning(disable : 4996) // deprecated APIs
12
+ #endif
13
+ #include "ReactMarker.h"
14
+ #include <cxxreact/JSExecutor.h>
15
+
16
+ namespace facebook::react::ReactMarker {
17
+
18
+ #if __clang__
19
+ #pragma clang diagnostic push
20
+ #pragma clang diagnostic ignored "-Wglobal-constructors"
21
+ #endif
22
+
23
+ LogTaggedMarker logTaggedMarkerBridgelessImpl = nullptr;
24
+ LogTaggedMarker logTaggedMarkerImpl = nullptr;
25
+ std::shared_mutex logTaggedMarkerImplMutex;
26
+
27
+ #if __clang__
28
+ #pragma clang diagnostic pop
29
+ #endif
30
+
31
+ void logMarker(const ReactMarkerId markerId) {
32
+ logTaggedMarker(markerId, nullptr);
33
+ }
34
+
35
+ void logTaggedMarker(const ReactMarkerId markerId, const char* tag) {
36
+ LogTaggedMarker marker = nullptr;
37
+ {
38
+ std::shared_lock lock(logTaggedMarkerImplMutex);
39
+ marker = logTaggedMarkerImpl;
40
+ }
41
+ if (marker != nullptr) {
42
+ marker(markerId, tag);
43
+ }
44
+ }
45
+
46
+ void logMarkerBridgeless(const ReactMarkerId markerId) {
47
+ logTaggedMarkerBridgeless(markerId, nullptr);
48
+ }
49
+
50
+ void logTaggedMarkerBridgeless(const ReactMarkerId markerId, const char* tag) {
51
+ logTaggedMarkerBridgelessImpl(markerId, tag);
52
+ }
53
+
54
+ void logMarkerDone(const ReactMarkerId markerId, double markerTime) {
55
+ StartupLogger::getInstance().logStartupEvent(markerId, markerTime);
56
+ }
57
+
58
+ StartupLogger& StartupLogger::getInstance() {
59
+ static StartupLogger instance;
60
+ return instance;
61
+ }
62
+
63
+ void StartupLogger::logStartupEvent(
64
+ const ReactMarkerId markerId,
65
+ double markerTime) {
66
+ switch (markerId) {
67
+ case ReactMarkerId::APP_STARTUP_START:
68
+ if (!std::isnan(appStartupStartTime)) {
69
+ // We had a startup start time, which indicates a warm start (user
70
+ // closed the app and start again). In this case we need to invalidate
71
+ // all other startup timings.
72
+ reset();
73
+ }
74
+ appStartupStartTime = markerTime;
75
+ return;
76
+
77
+ case ReactMarkerId::APP_STARTUP_STOP:
78
+ if (std::isnan(appStartupEndTime)) {
79
+ appStartupEndTime = markerTime;
80
+ }
81
+ return;
82
+
83
+ case ReactMarkerId::INIT_REACT_RUNTIME_START:
84
+ if (std::isnan(initReactRuntimeStartTime)) {
85
+ initReactRuntimeStartTime = markerTime;
86
+ }
87
+ return;
88
+
89
+ case ReactMarkerId::INIT_REACT_RUNTIME_STOP:
90
+ if (std::isnan(initReactRuntimeEndTime)) {
91
+ initReactRuntimeEndTime = markerTime;
92
+ }
93
+ return;
94
+
95
+ case ReactMarkerId::RUN_JS_BUNDLE_START:
96
+ if (std::isnan(runJSBundleStartTime)) {
97
+ runJSBundleStartTime = markerTime;
98
+ }
99
+ return;
100
+
101
+ case ReactMarkerId::RUN_JS_BUNDLE_STOP:
102
+ if (std::isnan(runJSBundleEndTime)) {
103
+ runJSBundleEndTime = markerTime;
104
+ }
105
+ return;
106
+
107
+ default:
108
+ return;
109
+ }
110
+ }
111
+
112
+ void StartupLogger::reset() {
113
+ appStartupStartTime = std::nan("");
114
+ appStartupEndTime = std::nan("");
115
+ initReactRuntimeStartTime = std::nan("");
116
+ initReactRuntimeEndTime = std::nan("");
117
+ runJSBundleStartTime = std::nan("");
118
+ runJSBundleEndTime = std::nan("");
119
+ }
120
+
121
+ double StartupLogger::getAppStartupStartTime() {
122
+ return appStartupStartTime;
123
+ }
124
+
125
+ double StartupLogger::getInitReactRuntimeStartTime() {
126
+ return initReactRuntimeStartTime;
127
+ }
128
+
129
+ double StartupLogger::getInitReactRuntimeEndTime() {
130
+ return initReactRuntimeEndTime;
131
+ }
132
+
133
+ double StartupLogger::getRunJSBundleStartTime() {
134
+ return runJSBundleStartTime;
135
+ }
136
+
137
+ double StartupLogger::getRunJSBundleEndTime() {
138
+ return runJSBundleEndTime;
139
+ }
140
+
141
+ double StartupLogger::getAppStartupEndTime() {
142
+ return appStartupEndTime;
143
+ }
144
+
145
+ } // namespace facebook::react::ReactMarker
146
+
147
+ #if _MSC_VER
148
+ #pragma warning(pop)
149
+ #endif
@@ -69,13 +69,13 @@ namespace facebook::react {
69
69
  struct TraceSection {
70
70
  public:
71
71
  template <typename... ConvertsToStringPiece>
72
- explicit TraceSection(
73
- [[maybe_unused]] const char* name,
74
- [[maybe_unused]] ConvertsToStringPiece&&... args) {
72
+ explicit TraceSection([[maybe_unused]] const char *name, [[maybe_unused]] ConvertsToStringPiece &&...args)
73
+ {
75
74
  TRACE_EVENT_BEGIN("react-native", perfetto::DynamicString{name}, args...);
76
75
  }
77
76
 
78
- ~TraceSection() {
77
+ ~TraceSection()
78
+ {
79
79
  TRACE_EVENT_END("react-native");
80
80
  }
81
81
  };
@@ -84,10 +84,10 @@ using TraceSectionUnwrapped = TraceSection;
84
84
  struct ConcreteTraceSection {
85
85
  public:
86
86
  template <typename... ConvertsToStringPiece>
87
- explicit ConcreteTraceSection(
88
- const char* name,
89
- ConvertsToStringPiece&&... args)
90
- : m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...) {} // [Windows][issue #14819]
87
+ explicit ConcreteTraceSection(const char *name, ConvertsToStringPiece &&...args)
88
+ : m_section(TRACE_TAG_REACT_CXX_BRIDGE, name, args...) // [Windows][issue #14819]
89
+ {
90
+ }
91
91
 
92
92
  private:
93
93
  fbsystrace::FbSystraceSection m_section;
@@ -97,9 +97,9 @@ using TraceSectionUnwrapped = ConcreteTraceSection;
97
97
  struct DummyTraceSection {
98
98
  public:
99
99
  template <typename... ConvertsToStringPiece>
100
- explicit DummyTraceSection(
101
- [[maybe_unused]] const char* name,
102
- [[maybe_unused]] ConvertsToStringPiece&&... args) {}
100
+ explicit DummyTraceSection([[maybe_unused]] const char *name, [[maybe_unused]] ConvertsToStringPiece &&...args)
101
+ {
102
+ }
103
103
  };
104
104
  using TraceSectionUnwrapped = DummyTraceSection;
105
105
  #endif
@@ -110,14 +110,14 @@ using TraceSectionUnwrapped = DummyTraceSection;
110
110
  * In the case of WITH_LOOM_TRACE we don't use the signposts APIs because of the
111
111
  * templated type for TraceSection.
112
112
  */
113
- #if defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES && \
114
- !defined(WITH_LOOM_TRACE)
113
+ #if defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES && !defined(WITH_LOOM_TRACE)
115
114
 
116
115
  namespace systrace {
117
116
 
118
117
  template <typename T, typename = void>
119
118
  struct renderer {
120
- static std::string render(const T& t) {
119
+ static std::string render(const T &t)
120
+ {
121
121
  std::ostringstream oss;
122
122
  oss << t;
123
123
  return oss.str();
@@ -125,19 +125,19 @@ struct renderer {
125
125
  };
126
126
 
127
127
  template <typename T>
128
- static auto render(const T& t)
129
- -> decltype(renderer<T>::render(std::declval<const T&>())) {
128
+ static auto render(const T &t) -> decltype(renderer<T>::render(std::declval<const T &>()))
129
+ {
130
130
  return renderer<T>::render(t);
131
131
  }
132
132
 
133
133
  inline os_log_t instrumentsLogHandle = nullptr;
134
134
 
135
- static inline os_log_t getOrCreateInstrumentsLogHandle() {
135
+ static inline os_log_t getOrCreateInstrumentsLogHandle()
136
+ {
136
137
  static std::once_flag flag{};
137
138
  std::call_once(flag, []() {
138
139
  if (!instrumentsLogHandle) {
139
- instrumentsLogHandle = os_log_create(
140
- "dev.reactnative.instruments", OS_LOG_CATEGORY_DYNAMIC_TRACING);
140
+ instrumentsLogHandle = os_log_create("dev.reactnative.instruments", OS_LOG_CATEGORY_DYNAMIC_TRACING);
141
141
  }
142
142
  });
143
143
  return instrumentsLogHandle;
@@ -148,8 +148,8 @@ static inline os_log_t getOrCreateInstrumentsLogHandle() {
148
148
  struct TraceSection {
149
149
  public:
150
150
  template <typename... ConvertsToStringPiece>
151
- explicit TraceSection(const char* name, ConvertsToStringPiece&&... args)
152
- : systraceSectionUnwrapped_(name, args...) {
151
+ explicit TraceSection(const char *name, ConvertsToStringPiece &&...args) : systraceSectionUnwrapped_(name, args...)
152
+ {
153
153
  os_log_t instrumentsLogHandle = systrace::getOrCreateInstrumentsLogHandle();
154
154
 
155
155
  // If the log isn't enabled, we don't want the performance overhead of the
@@ -168,24 +168,14 @@ struct TraceSection {
168
168
 
169
169
  signpostID_ = os_signpost_id_make_with_pointer(instrumentsLogHandle, this);
170
170
 
171
- os_signpost_interval_begin(
172
- instrumentsLogHandle,
173
- signpostID_,
174
- "Systrace",
175
- "%s begin: %s",
176
- name,
177
- argsString.c_str());
171
+ os_signpost_interval_begin(instrumentsLogHandle, signpostID_, "Systrace", "%s begin: %s", name, argsString.c_str());
178
172
  }
179
173
 
180
- ~TraceSection() {
174
+ ~TraceSection()
175
+ {
181
176
  // We don't need to gate on os_signpost_enabled here because it's already
182
177
  // checked in os_signpost_interval_end.
183
- os_signpost_interval_end(
184
- systrace::instrumentsLogHandle,
185
- signpostID_,
186
- "Systrace",
187
- "%s end",
188
- name_.data());
178
+ os_signpost_interval_end(systrace::instrumentsLogHandle, signpostID_, "Systrace", "%s end", name_.data());
189
179
  }
190
180
 
191
181
  private: