react-native-windows 0.75.4 → 0.76.0-preview.1

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 (310) hide show
  1. package/.flowconfig +6 -4
  2. package/Directory.Build.props +4 -0
  3. package/Directory.Build.targets +5 -0
  4. package/Libraries/Alert/Alert.js +3 -0
  5. package/Libraries/Alert/Alert.windows.js +3 -0
  6. package/Libraries/Animated/AnimatedEvent.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +7 -7
  8. package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
  9. package/Libraries/Animated/animations/Animation.js +11 -1
  10. package/Libraries/Animated/animations/DecayAnimation.js +1 -1
  11. package/Libraries/Animated/animations/SpringAnimation.js +1 -1
  12. package/Libraries/Animated/animations/TimingAnimation.js +2 -1
  13. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  14. package/Libraries/Animated/createAnimatedComponent.js +10 -9
  15. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  16. package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
  17. package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
  18. package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
  19. package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
  20. package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
  21. package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
  22. package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
  23. package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
  24. package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
  25. package/Libraries/Animated/useAnimatedProps.js +142 -7
  26. package/Libraries/BatchedBridge/NativeModules.js +2 -0
  27. package/Libraries/Blob/FileReader.js +1 -1
  28. package/Libraries/Blob/URL.js +2 -62
  29. package/Libraries/Blob/URLSearchParams.js +71 -0
  30. package/Libraries/Components/Button.windows.js +0 -1
  31. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
  32. package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
  33. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
  34. package/Libraries/Components/ScrollView/ScrollView.js +131 -169
  35. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  36. package/Libraries/Components/StatusBar/StatusBar.js +3 -1
  37. package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
  38. package/Libraries/Components/TextInput/TextInput.js +230 -94
  39. package/Libraries/Components/TextInput/TextInput.windows.js +230 -105
  40. package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
  41. package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
  42. package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +2 -0
  43. package/Libraries/Components/View/View.windows.js +32 -30
  44. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  45. package/Libraries/Components/View/ViewNativeComponent.js +0 -1
  46. package/Libraries/Components/View/ViewPropTypes.js +14 -0
  47. package/Libraries/Components/View/ViewPropTypes.windows.js +14 -0
  48. package/Libraries/Core/ExceptionsManager.js +2 -0
  49. package/Libraries/Core/InitializeCore.js +3 -1
  50. package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
  51. package/Libraries/Core/ReactNativeVersion.js +4 -4
  52. package/Libraries/Core/setUpErrorHandling.js +7 -1
  53. package/Libraries/Core/setUpGlobals.js +1 -0
  54. package/Libraries/Core/setUpReactRefresh.js +0 -4
  55. package/Libraries/Image/AssetSourceResolver.js +28 -1
  56. package/Libraries/Image/AssetSourceResolver.windows.js +28 -1
  57. package/Libraries/Image/Image.android.js +9 -14
  58. package/Libraries/Image/Image.ios.js +11 -22
  59. package/Libraries/Image/Image.windows.js +11 -22
  60. package/Libraries/Image/ImageBackground.js +1 -8
  61. package/Libraries/Image/ImageUtils.js +9 -9
  62. package/Libraries/Image/ImageViewNativeComponent.js +1 -0
  63. package/Libraries/Inspector/Inspector.js +3 -2
  64. package/Libraries/Inspector/InspectorPanel.js +16 -10
  65. package/Libraries/Inspector/NetworkOverlay.js +1 -1
  66. package/Libraries/Interaction/TaskQueue.js +1 -0
  67. package/Libraries/Lists/FlatList.js +1 -1
  68. package/Libraries/Lists/SectionList.js +2 -2
  69. package/Libraries/Lists/SectionListModern.js +3 -3
  70. package/Libraries/LogBox/Data/LogBoxData.js +24 -3
  71. package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
  72. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
  73. package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +9 -8
  74. package/Libraries/Modal/Modal.js +0 -1
  75. package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
  76. package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
  77. package/Libraries/NativeComponent/BaseViewConfig.windows.js +7 -0
  78. package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
  79. package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
  80. package/Libraries/Network/XMLHttpRequest.js +4 -2
  81. package/Libraries/ReactNative/AppContainer-dev.js +1 -5
  82. package/Libraries/ReactNative/AppContainer-prod.js +1 -5
  83. package/Libraries/ReactNative/AppContainer.js +1 -2
  84. package/Libraries/ReactNative/AppRegistry.d.ts +0 -4
  85. package/Libraries/ReactNative/AppRegistry.js +1 -7
  86. package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
  87. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
  88. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
  89. package/Libraries/ReactNative/RendererImplementation.js +26 -4
  90. package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
  91. package/Libraries/ReactNative/renderApplication.js +1 -3
  92. package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
  93. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  94. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +57 -0
  95. package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
  96. package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
  97. package/Libraries/StyleSheet/processBoxShadow.js +211 -0
  98. package/Libraries/StyleSheet/processFilter.js +231 -42
  99. package/Libraries/Text/Text.js +394 -196
  100. package/Libraries/Text/Text.windows.js +476 -300
  101. package/Libraries/Text/TextNativeComponent.js +2 -1
  102. package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
  103. package/Libraries/Types/CodegenTypes.js +3 -1
  104. package/Libraries/Utilities/Appearance.js +108 -84
  105. package/Libraries/Utilities/DevLoadingView.js +2 -4
  106. package/Libraries/Utilities/HMRClient.js +2 -1
  107. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  108. package/Libraries/Utilities/createPerformanceLogger.js +0 -9
  109. package/Libraries/Utilities/stringifyViewConfig.js +22 -0
  110. package/Libraries/Utilities/useColorScheme.js +3 -3
  111. package/Libraries/WebSocket/WebSocket.js +1 -1
  112. package/Libraries/promiseRejectionTrackingOptions.js +1 -1
  113. package/Libraries/vendor/emitter/EventEmitter.js +6 -5
  114. package/Microsoft.ReactNative/ComponentView.idl +11 -0
  115. package/Microsoft.ReactNative/Composition.Input.idl +1 -0
  116. package/Microsoft.ReactNative/CompositionSwitcher.idl +3 -0
  117. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +9 -9
  118. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +9 -9
  119. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +7 -9
  120. package/Microsoft.ReactNative/Fabric/ComponentView.h +5 -6
  121. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +4 -0
  122. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +1 -0
  123. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +44 -13
  124. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +42 -5
  125. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +1 -0
  126. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +81 -63
  127. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -3
  128. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +8 -6
  129. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.h +1 -2
  130. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +20 -6
  131. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +13 -6
  132. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +2 -3
  133. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +1 -2
  134. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +72 -54
  135. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +14 -4
  136. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +26 -8
  137. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +5 -2
  138. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +18 -7
  139. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +1 -2
  140. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +6 -6
  141. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +1 -2
  142. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +97 -140
  143. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +8 -4
  144. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +18 -11
  145. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +5 -4
  146. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +0 -13
  147. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +0 -3
  148. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +29 -4
  149. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +2 -0
  150. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -2
  151. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +1 -2
  152. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +28 -12
  153. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +33 -0
  154. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +26 -9
  155. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +10 -4
  156. package/Microsoft.ReactNative/IReactModuleBuilder.cpp +5 -0
  157. package/Microsoft.ReactNative/IReactModuleBuilder.h +1 -0
  158. package/Microsoft.ReactNative/IReactModuleBuilder.idl +9 -0
  159. package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +8 -1
  160. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -0
  161. package/Microsoft.ReactNative/Modules/AlertModule.cpp +3 -1
  162. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +1 -1
  163. package/Microsoft.ReactNative/Modules/AppearanceModule.h +7 -1
  164. package/Microsoft.ReactNative/Modules/DevSettingsModule.cpp +3 -3
  165. package/Microsoft.ReactNative/Modules/DevSettingsModule.h +1 -1
  166. package/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp +2 -2
  167. package/Microsoft.ReactNative/Modules/LinkingManagerModule.h +1 -1
  168. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +9 -0
  169. package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -0
  170. package/Microsoft.ReactNative/Modules/SampleTurboModule.cpp +121 -0
  171. package/Microsoft.ReactNative/Modules/SampleTurboModule.h +90 -0
  172. package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -7
  173. package/Microsoft.ReactNative/ReactHost/MsoReactContext.h +0 -5
  174. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +5 -1
  175. package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +59 -0
  176. package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +23 -0
  177. package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +179 -0
  178. package/Microsoft.ReactNative/ReactNativeAppBuilder.h +35 -0
  179. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +69 -0
  180. package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -0
  181. package/Microsoft.ReactNative/ReactNativeWin32App.cpp +82 -0
  182. package/Microsoft.ReactNative/ReactNativeWin32App.h +38 -0
  183. package/Microsoft.ReactNative/TurboModulesProvider.cpp +45 -0
  184. package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +2 -1
  185. package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +25 -16
  186. package/Microsoft.ReactNative/packages.fabric.lock.json +159 -0
  187. package/Microsoft.ReactNative/packages.lock.json +11 -12
  188. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +3 -4
  189. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +3 -0
  190. package/Microsoft.ReactNative.Cxx/ModuleRegistration.cpp +2 -2
  191. package/Microsoft.ReactNative.Cxx/ModuleRegistration.h +62 -4
  192. package/Microsoft.ReactNative.Cxx/NativeModules.h +131 -14
  193. package/Microsoft.ReactNative.Managed/packages.lock.json +9 -9
  194. package/Microsoft.ReactNative.Managed.CodeGen/ReactNativeNames.cs +10 -2
  195. package/PropertySheets/Autolink.props +1 -1
  196. package/PropertySheets/Bundle.props +1 -1
  197. package/PropertySheets/Codegen.props +1 -1
  198. package/PropertySheets/Generated/PackageVersion.g.props +4 -4
  199. package/PropertySheets/NuGet.LockFile.props +18 -0
  200. package/README.md +29 -29
  201. package/ReactCommon/ReactCommon.vcxproj +5 -1
  202. package/ReactCommon/ReactCommon.vcxproj.filters +11 -2
  203. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +2 -7
  204. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +441 -0
  205. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +266 -0
  206. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +56 -0
  207. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Base.h +3 -1
  208. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +2 -2
  209. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +1 -1
  210. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Convert.h +172 -0
  211. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/EventEmitter.h +4 -5
  212. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Function.h +2 -2
  213. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +1 -1
  214. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +3 -2
  215. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +9 -0
  216. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/LayoutableShadowNode.cpp +363 -0
  217. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/JSRuntimeFactory.h +22 -2
  218. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +118 -51
  219. package/ReactCommon/packages.lock.json +2 -2
  220. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +8 -1
  221. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -2
  222. package/Shared/Modules/WebSocketModule.cpp +1 -2
  223. package/Shared/Networking/WinRTWebSocketResource.cpp +4 -1
  224. package/Shared/Shared.vcxitems +38 -2
  225. package/Shared/Shared.vcxitems.filters +6 -1
  226. package/Shared/TurboModuleManager.cpp +0 -3
  227. package/codegen/NativeLinkingManagerSpec.g.h +3 -3
  228. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +198 -54
  229. package/codegen/NativeSampleTurboModuleSpec.g.h +35 -0
  230. package/codegen/rnwcoreJSI-generated.cpp +245 -101
  231. package/codegen/rnwcoreJSI.h +847 -548
  232. package/index.js +3 -1
  233. package/index.windows.js +3 -1
  234. package/jest/mockComponent.js +4 -1
  235. package/jest/mockModal.js +1 -3
  236. package/jest/mockScrollView.js +1 -1
  237. package/jest/renderer.js +2 -2
  238. package/jest/setup.js +16 -13
  239. package/package.json +29 -29
  240. package/src/private/animated/NativeAnimatedHelper.js +438 -0
  241. package/src/private/animated/NativeAnimatedValidation.js +64 -0
  242. package/src/private/components/HScrollViewNativeComponents.js +56 -0
  243. package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
  244. package/src/private/components/VScrollViewNativeComponents.js +48 -0
  245. package/src/private/components/useSyncOnScroll.js +48 -0
  246. package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
  247. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
  248. package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
  249. package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
  250. package/src/private/setup/setUpDOM.js +28 -0
  251. package/src/private/setup/setUpIntersectionObserver.js +27 -0
  252. package/src/private/setup/setUpMutationObserver.js +26 -0
  253. package/src/private/setup/setUpPerformanceObserver.js +64 -0
  254. package/src/private/specs/modules/NativeAppearance.js +3 -3
  255. package/src/private/specs/modules/NativeLinkingManager.js +1 -1
  256. package/src/private/specs/modules/NativePlatformConstantsWindows.js +7 -0
  257. package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
  258. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
  259. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
  260. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
  261. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
  262. package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
  263. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
  264. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
  265. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
  266. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
  267. package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
  268. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
  269. package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
  270. package/src/private/webapis/performance/LongTasks.js +39 -0
  271. package/src/private/webapis/performance/Performance.js +22 -9
  272. package/src/private/webapis/performance/PerformanceEntry.js +36 -18
  273. package/src/private/webapis/performance/PerformanceObserver.js +29 -43
  274. package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
  275. package/src/private/webapis/performance/UserTiming.js +17 -12
  276. package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
  277. package/template/cpp-app/src/AutolinkedNativeModules.g.cpp +1 -1
  278. package/template/cpp-app/src/AutolinkedNativeModules.g.h +1 -1
  279. package/template/cs-app/src/AutolinkedNativeModules.g.cs +1 -1
  280. package/template/index.windows.bundle +1 -1
  281. package/template/metro.config.js +2 -2
  282. package/template/shared-app/src/AutolinkedNativeModules.g.props +1 -1
  283. package/template/shared-app/src/AutolinkedNativeModules.g.targets +1 -1
  284. package/templates/cpp-app/metro.config.js +2 -2
  285. package/templates/cpp-app/template.config.js +5 -5
  286. package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.cpp +1 -1
  287. package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.h +1 -1
  288. package/templates/cpp-app/windows/MyApp/MyApp.cpp +2 -0
  289. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
  290. package/templates/cpp-lib/example/metro.config.js +2 -2
  291. package/templates/cpp-lib/template.config.js +3 -3
  292. package/templates/cpp-lib/windows/MyLib/MyLib.h +3 -3
  293. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
  294. package/types/experimental.d.ts +20 -1
  295. package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
  296. package/Libraries/Core/setUpIntersectionObserver.js +0 -16
  297. package/Libraries/Core/setUpMutationObserver.js +0 -16
  298. package/Libraries/Core/setUpPerformanceObserver.js +0 -18
  299. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
  300. package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
  301. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
  302. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +0 -2396
  303. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.cpp +0 -136
  304. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +0 -92
  305. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.cpp +0 -48
  306. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +0 -122
  307. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +0 -388
  308. package/src/private/core/setUpDOM.js +0 -18
  309. package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
  310. /package/src/private/{core → styles}/composeStyles.js +0 -0
@@ -0,0 +1,363 @@
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 "LayoutableShadowNode.h"
9
+
10
+ #include <react/renderer/core/LayoutConstraints.h>
11
+ #include <react/renderer/core/LayoutContext.h>
12
+ #include <react/renderer/core/LayoutMetrics.h>
13
+ #include <react/renderer/core/ShadowNode.h>
14
+ #include <react/renderer/core/graphicsConversions.h>
15
+ #include <react/renderer/debug/DebugStringConvertibleItem.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ template <class T>
20
+ using LayoutableSmallVector = std::vector<T>;
21
+
22
+ LayoutableShadowNode::LayoutableShadowNode(
23
+ const ShadowNodeFragment& fragment,
24
+ const ShadowNodeFamily::Shared& family,
25
+ ShadowNodeTraits traits)
26
+ : ShadowNode(fragment, family, traits), layoutMetrics_({}) {}
27
+
28
+ LayoutableShadowNode::LayoutableShadowNode(
29
+ const ShadowNode& sourceShadowNode,
30
+ const ShadowNodeFragment& fragment)
31
+ : ShadowNode(sourceShadowNode, fragment),
32
+ layoutMetrics_(static_cast<const LayoutableShadowNode&>(sourceShadowNode)
33
+ .layoutMetrics_) {}
34
+
35
+ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
36
+ const ShadowNodeFamily& descendantNodeFamily,
37
+ const LayoutableShadowNode& ancestorNode,
38
+ LayoutInspectingPolicy policy) {
39
+ // Prelude.
40
+
41
+ if (&descendantNodeFamily == &ancestorNode.getFamily()) {
42
+ // Layout metrics of a node computed relatively to the same node are equal
43
+ // to `transform`-ed layout metrics of the node with zero `origin`.
44
+ auto layoutMetrics = ancestorNode.getLayoutMetrics();
45
+ if (layoutMetrics.displayType == DisplayType::None) {
46
+ return EmptyLayoutMetrics;
47
+ }
48
+ if (policy.includeTransform) {
49
+ layoutMetrics.frame = layoutMetrics.frame * ancestorNode.getTransform();
50
+ }
51
+ layoutMetrics.frame.origin = {0, 0};
52
+ return layoutMetrics;
53
+ }
54
+
55
+ auto ancestors = descendantNodeFamily.getAncestors(ancestorNode);
56
+ return computeRelativeLayoutMetrics(ancestors, policy);
57
+ }
58
+
59
+ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
60
+ const AncestorList& ancestors,
61
+ LayoutInspectingPolicy policy) {
62
+ if (ancestors.empty()) {
63
+ // Specified nodes do not form an ancestor-descender relationship
64
+ // in the same tree. Aborting.
65
+ return EmptyLayoutMetrics;
66
+ }
67
+
68
+ // ------------------------------
69
+
70
+ // Step 1.
71
+ // Creating a list of nodes that form a chain from the descender node to
72
+ // ancestor node inclusively.
73
+ auto shadowNodeList = LayoutableSmallVector<const ShadowNode*>{};
74
+
75
+ // Finding the measured node.
76
+ // The last element in the `AncestorList` is a pair of a parent of the node
77
+ // and an index of this node in the parent's children list.
78
+ auto& pair = ancestors.at(ancestors.size() - 1);
79
+ auto descendantNode = pair.first.get().getChildren().at(pair.second).get();
80
+
81
+ // Putting the node inside the list.
82
+ // Even if this is a node with a `RootNodeKind` trait, we don't treat it as
83
+ // root because we measure it from an outside tree perspective.
84
+ shadowNodeList.push_back(descendantNode);
85
+
86
+ for (auto it = ancestors.rbegin(); it != ancestors.rend(); it++) {
87
+ auto& shadowNode = it->first.get();
88
+
89
+ shadowNodeList.push_back(&shadowNode);
90
+
91
+ if (shadowNode.getTraits().check(ShadowNodeTraits::Trait::RootNodeKind)) {
92
+ // If this is a node with a `RootNodeKind` trait, we need to stop right
93
+ // there.
94
+ break;
95
+ }
96
+ }
97
+
98
+ // ------------------------------
99
+
100
+ // Step 2.
101
+ // Computing the initial size of the measured node.
102
+ auto descendantLayoutableNode =
103
+ dynamic_cast<const LayoutableShadowNode*>(descendantNode);
104
+
105
+ if (descendantLayoutableNode == nullptr) {
106
+ return EmptyLayoutMetrics;
107
+ }
108
+
109
+ auto layoutMetrics = descendantLayoutableNode->getLayoutMetrics();
110
+ auto& resultFrame = layoutMetrics.frame;
111
+ resultFrame.origin = {0, 0};
112
+
113
+ // Step 3.
114
+ // Iterating on a list of nodes computing compound offset and size.
115
+ auto size = shadowNodeList.size();
116
+ for (size_t i = 0; i < size; i++) {
117
+ auto currentShadowNode =
118
+ dynamic_cast<const LayoutableShadowNode*>(shadowNodeList.at(i));
119
+
120
+ if (currentShadowNode == nullptr) {
121
+ return EmptyLayoutMetrics;
122
+ }
123
+
124
+ // Descendants of display: none don't have relative layout metrics.
125
+ if (currentShadowNode->getLayoutMetrics().displayType ==
126
+ DisplayType::None) {
127
+ return EmptyLayoutMetrics;
128
+ }
129
+
130
+ auto currentFrame = currentShadowNode->getLayoutMetrics().frame;
131
+ if (i == size - 1) {
132
+ // If it's the last element, its origin is irrelevant.
133
+ currentFrame.origin = {0, 0};
134
+ }
135
+
136
+ auto isRootNode = currentShadowNode->getTraits().check(
137
+ ShadowNodeTraits::Trait::RootNodeKind);
138
+
139
+ auto shouldApplyTransformation = (policy.includeTransform && !isRootNode) ||
140
+ (policy.includeViewportOffset && isRootNode);
141
+
142
+ // Move frame to the coordinate space of the current node.
143
+ resultFrame.origin += currentFrame.origin;
144
+
145
+ if (shouldApplyTransformation) {
146
+ // If a node has a transform, we need to use the center of that node as
147
+ // the origin of the transform when transforming its children (which
148
+ // affects the result of transforms like `scale` and `rotate`).
149
+ resultFrame = currentShadowNode->getTransform().applyWithCenter(
150
+ resultFrame, currentFrame.getCenter());
151
+ }
152
+
153
+ if (i != 0 && policy.includeTransform) {
154
+ // Transformation is not applied here and instead we delegated out in
155
+ // getContentOriginOffset. The reason is that for `ScrollViewShadowNode`,
156
+ // we need to consider `scrollAwayPaddingTop` which should NOT be included
157
+ // in the transform.
158
+ resultFrame.origin += currentShadowNode->getContentOriginOffset(true);
159
+ }
160
+
161
+ if (policy.enableOverflowClipping) {
162
+ auto overflowInset = currentShadowNode->getLayoutMetrics().overflowInset;
163
+ auto overflowRect = insetBy(
164
+ currentFrame * currentShadowNode->getTransform(), overflowInset);
165
+ resultFrame = Rect::intersect(resultFrame, overflowRect);
166
+ if (resultFrame.size.width == 0 && resultFrame.size.height == 0) {
167
+ return EmptyLayoutMetrics;
168
+ }
169
+ }
170
+ }
171
+
172
+ // ------------------------------
173
+
174
+ return layoutMetrics;
175
+ }
176
+
177
+ LayoutMetrics LayoutableShadowNode::getLayoutMetrics() const {
178
+ return layoutMetrics_;
179
+ }
180
+
181
+ void LayoutableShadowNode::setLayoutMetrics(LayoutMetrics layoutMetrics) {
182
+ ensureUnsealed();
183
+
184
+ if (layoutMetrics_ == layoutMetrics) {
185
+ return;
186
+ }
187
+
188
+ layoutMetrics_ = layoutMetrics;
189
+ }
190
+
191
+ Transform LayoutableShadowNode::getTransform() const {
192
+ return Transform::Identity();
193
+ }
194
+
195
+ Point LayoutableShadowNode::getContentOriginOffset(
196
+ bool /*includeTransform*/) const {
197
+ return {0, 0};
198
+ }
199
+
200
+ bool LayoutableShadowNode::canBeTouchTarget() const {
201
+ return false;
202
+ }
203
+
204
+ bool LayoutableShadowNode::canChildrenBeTouchTarget() const {
205
+ return true;
206
+ }
207
+
208
+ LayoutableShadowNode::UnsharedList
209
+ LayoutableShadowNode::getLayoutableChildNodes() const {
210
+ LayoutableShadowNode::UnsharedList layoutableChildren;
211
+ for (const auto& childShadowNode : getChildren()) {
212
+ auto layoutableChildShadowNode =
213
+ dynamic_cast<const LayoutableShadowNode*>(childShadowNode.get());
214
+ if (layoutableChildShadowNode != nullptr) {
215
+ layoutableChildren.push_back(
216
+ const_cast<LayoutableShadowNode*>(layoutableChildShadowNode));
217
+ }
218
+ }
219
+ return layoutableChildren;
220
+ }
221
+
222
+ Size LayoutableShadowNode::measureContent(
223
+ const LayoutContext& /*layoutContext*/,
224
+ const LayoutConstraints& /*layoutConstraints*/) const {
225
+ return {};
226
+ }
227
+
228
+ Size LayoutableShadowNode::measure(
229
+ const LayoutContext& layoutContext,
230
+ const LayoutConstraints& layoutConstraints) const {
231
+ auto clonedShadowNode = clone({});
232
+ auto& layoutableShadowNode =
233
+ static_cast<LayoutableShadowNode&>(*clonedShadowNode);
234
+
235
+ auto localLayoutContext = layoutContext;
236
+ localLayoutContext.affectedNodes = nullptr;
237
+
238
+ layoutableShadowNode.layoutTree(localLayoutContext, layoutConstraints);
239
+
240
+ return layoutableShadowNode.getLayoutMetrics().frame.size;
241
+ }
242
+
243
+ Float LayoutableShadowNode::baseline(
244
+ const LayoutContext& /*layoutContext*/,
245
+ Size /*size*/) const {
246
+ return 0;
247
+ }
248
+
249
+ ShadowNode::Shared LayoutableShadowNode::findNodeAtPoint(
250
+ const ShadowNode::Shared& node,
251
+ Point point) {
252
+ auto layoutableShadowNode =
253
+ dynamic_cast<const LayoutableShadowNode*>(node.get());
254
+
255
+ if (layoutableShadowNode == nullptr) {
256
+ return nullptr;
257
+ }
258
+
259
+ if (!layoutableShadowNode->canBeTouchTarget() &&
260
+ !layoutableShadowNode->canChildrenBeTouchTarget()) {
261
+ return nullptr;
262
+ }
263
+
264
+ auto transform = layoutableShadowNode->getTransform();
265
+ auto frame = layoutableShadowNode->getLayoutMetrics().frame;
266
+ auto transformedFrame = frame * transform;
267
+ auto isPointInside = transformedFrame.containsPoint(point);
268
+
269
+ if (!isPointInside) {
270
+ return nullptr;
271
+ } else if (!layoutableShadowNode->canChildrenBeTouchTarget()) {
272
+ return node;
273
+ }
274
+
275
+ if (Transform::isVerticalInversion(transform) ||
276
+ Transform::isHorizontalInversion(transform)) {
277
+ auto centerX =
278
+ transformedFrame.origin.x + transformedFrame.size.width / 2.0;
279
+ auto centerY =
280
+ transformedFrame.origin.y + transformedFrame.size.height / 2.0;
281
+
282
+ // [Windows - #13644
283
+ auto relativeX = point.x - centerX;
284
+ auto relativeY = point.y - centerY;
285
+ // Windows]
286
+
287
+ if (Transform::isVerticalInversion(transform)) {
288
+ relativeY = -relativeY;
289
+ }
290
+ if (Transform::isHorizontalInversion(transform)) {
291
+ relativeX = -relativeX;
292
+ }
293
+
294
+ // [Windows - #13644
295
+ point.x = float(centerX + relativeX);
296
+ point.y = float(centerY + relativeY);
297
+ // Windows]
298
+ }
299
+
300
+ auto newPoint = point - transformedFrame.origin -
301
+ layoutableShadowNode->getContentOriginOffset(false);
302
+
303
+ auto sortedChildren = node->getChildren();
304
+ std::stable_sort(
305
+ sortedChildren.begin(),
306
+ sortedChildren.end(),
307
+ [](const auto& lhs, const auto& rhs) -> bool {
308
+ return lhs->getOrderIndex() < rhs->getOrderIndex();
309
+ });
310
+
311
+ for (auto it = sortedChildren.rbegin(); it != sortedChildren.rend(); it++) {
312
+ const auto& childShadowNode = *it;
313
+ auto hitView = findNodeAtPoint(childShadowNode, newPoint);
314
+ if (hitView) {
315
+ return hitView;
316
+ }
317
+ }
318
+ return layoutableShadowNode->canBeTouchTarget() ? node : nullptr;
319
+ }
320
+
321
+ #if RN_DEBUG_STRING_CONVERTIBLE
322
+ SharedDebugStringConvertibleList LayoutableShadowNode::getDebugProps() const {
323
+ auto list = ShadowNode::getDebugProps();
324
+
325
+ auto layoutInfo = SharedDebugStringConvertibleList{};
326
+
327
+ if (!getIsLayoutClean()) {
328
+ layoutInfo.push_back(std::make_shared<DebugStringConvertibleItem>("dirty"));
329
+ }
330
+
331
+ auto layoutMetrics = getLayoutMetrics();
332
+ auto defaultLayoutMetrics = LayoutMetrics();
333
+
334
+ layoutInfo.push_back(std::make_shared<DebugStringConvertibleItem>(
335
+ "frame", toString(layoutMetrics.frame)));
336
+
337
+ if (layoutMetrics.borderWidth != defaultLayoutMetrics.borderWidth) {
338
+ layoutInfo.push_back(std::make_shared<DebugStringConvertibleItem>(
339
+ "borderWidth", toString(layoutMetrics.borderWidth)));
340
+ }
341
+
342
+ if (layoutMetrics.contentInsets != defaultLayoutMetrics.contentInsets) {
343
+ layoutInfo.push_back(std::make_shared<DebugStringConvertibleItem>(
344
+ "contentInsets", toString(layoutMetrics.contentInsets)));
345
+ }
346
+
347
+ if (layoutMetrics.displayType == DisplayType::None) {
348
+ layoutInfo.push_back(
349
+ std::make_shared<DebugStringConvertibleItem>("hidden"));
350
+ }
351
+
352
+ if (layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
353
+ layoutInfo.push_back(std::make_shared<DebugStringConvertibleItem>("rtl"));
354
+ }
355
+
356
+ list.push_back(
357
+ std::make_shared<DebugStringConvertibleItem>("layout", "", layoutInfo));
358
+
359
+ return list;
360
+ }
361
+ #endif
362
+
363
+ } // namespace facebook::react
@@ -25,8 +25,28 @@ class JSRuntime : public jsinspector_modern::RuntimeTargetDelegate {
25
25
 
26
26
  virtual ~JSRuntime() = default;
27
27
 
28
- virtual void addConsoleMessage(jsi::Runtime& runtime, jsinspector_modern::ConsoleMessage message) = 0;
29
- virtual bool supportsConsole() const = 0;
28
+ /**
29
+ * Get a reference to the \c RuntimeTargetDelegate owned (or implemented) by
30
+ * this JSRuntime. This reference must remain valid for the duration of the
31
+ * JSRuntime's lifetime.
32
+ */
33
+ // virtual jsinspector_modern::RuntimeTargetDelegate& getRuntimeTargetDelegate();
34
+
35
+ /**
36
+ * Run initialize work that must happen on the runtime's JS thread. Used for
37
+ * initializing TLS and registering profiling.
38
+ *
39
+ * TODO T194671568 Move the runtime constructor to the JsThread
40
+ */
41
+ virtual void unstable_initializeOnJsThread() {}
42
+
43
+ private:
44
+ /**
45
+ * Initialized by \c getRuntimeTargetDelegate if not overridden, and then
46
+ * never changes.
47
+ */
48
+ std::optional<jsinspector_modern::FallbackRuntimeTargetDelegate>
49
+ runtimeTargetDelegate_;
30
50
  };
31
51
 
32
52
  /**
@@ -43,44 +43,50 @@ ReactInstance::ReactInstance(
43
43
  std::weak_ptr(timerManager_),
44
44
  weakJsThread =
45
45
  std::weak_ptr(jsMessageQueueThread_),
46
- weakJsErrorHander = std::weak_ptr(
47
- jsErrorHandler_)](auto callback) {
48
- auto jsErrorHandler = weakJsErrorHander.lock();
49
- if (weakRuntime.expired() || !jsErrorHandler) {
46
+ jsErrorHandler =
47
+ jsErrorHandler_](auto callback) {
48
+ if (weakRuntime.expired()) {
50
49
  return;
51
50
  }
52
51
 
53
- if (jsErrorHandler->hasHandledFatalError()) {
52
+ /**
53
+ * If a fatal error was caught while executing the main bundle, assume the
54
+ * js runtime is invalid. And stop executing any more js.
55
+ */
56
+ if (!jsErrorHandler->isRuntimeReady() &&
57
+ jsErrorHandler->hasHandledFatalError()) {
54
58
  LOG(INFO)
55
- << "RuntimeExecutor: Detected fatal js error. Dropping work on non-js thread."
59
+ << "RuntimeExecutor: Detected fatal error. Dropping work on non-js thread."
56
60
  << std::endl;
57
61
  return;
58
62
  }
59
63
 
60
64
  if (auto jsThread = weakJsThread.lock()) {
61
- jsThread->runOnQueue(
62
- [weakRuntime, weakTimerManager, callback = std::move(callback)]() {
63
- auto runtime = weakRuntime.lock();
64
- if (!runtime) {
65
- return;
66
- }
65
+ jsThread->runOnQueue([jsErrorHandler,
66
+ weakRuntime,
67
+ weakTimerManager,
68
+ callback = std::move(callback)]() {
69
+ auto runtime = weakRuntime.lock();
70
+ if (!runtime) {
71
+ return;
72
+ }
67
73
 
68
- jsi::Runtime& jsiRuntime = runtime->getRuntime();
69
- SystraceSection s("ReactInstance::_runtimeExecutor[Callback]");
70
- try {
71
- callback(jsiRuntime);
74
+ jsi::Runtime& jsiRuntime = runtime->getRuntime();
75
+ SystraceSection s("ReactInstance::_runtimeExecutor[Callback]");
76
+ try {
77
+ callback(jsiRuntime);
72
78
 
73
- // If we have first-class support for microtasks,
74
- // they would've been called as part of the previous callback.
75
- if (!ReactNativeFeatureFlags::enableMicrotasks()) {
76
- if (auto timerManager = weakTimerManager.lock()) {
77
- timerManager->callReactNativeMicrotasks(jsiRuntime);
78
- }
79
- }
80
- } catch (jsi::JSError& originalError) {
81
- handleJSError(jsiRuntime, originalError, true);
79
+ // If we have first-class support for microtasks,
80
+ // they would've been called as part of the previous callback.
81
+ if (!ReactNativeFeatureFlags::enableMicrotasks()) {
82
+ if (auto timerManager = weakTimerManager.lock()) {
83
+ timerManager->callReactNativeMicrotasks(jsiRuntime);
82
84
  }
83
- });
85
+ }
86
+ } catch (jsi::JSError& originalError) {
87
+ jsErrorHandler->handleFatalError(jsiRuntime, originalError);
88
+ }
89
+ });
84
90
  }
85
91
  };
86
92
 
@@ -104,7 +110,7 @@ ReactInstance::ReactInstance(
104
110
  // creation task to finish before starting the destruction.
105
111
  inspectorTarget_ = &hostTarget.registerInstance(*this);
106
112
  runtimeInspectorTarget_ =
107
- &inspectorTarget_->registerRuntime(*runtime_, runtimeExecutor);
113
+ &inspectorTarget_->registerRuntime(*runtime_, runtimeExecutor); // [Windows #13172]
108
114
  runtimeExecutorThatWaitsForInspectorSetup->flush();
109
115
  });
110
116
 
@@ -118,7 +124,17 @@ ReactInstance::ReactInstance(
118
124
  };
119
125
  }
120
126
 
121
- runtimeScheduler_ = std::make_shared<RuntimeScheduler>(runtimeExecutor);
127
+ runtimeScheduler_ = std::make_shared<RuntimeScheduler>(
128
+ runtimeExecutor,
129
+ RuntimeSchedulerClock::now,
130
+ [jsErrorHandler = jsErrorHandler_](
131
+ jsi::Runtime& runtime, jsi::JSError& error) {
132
+ jsErrorHandler->handleFatalError(runtime, error);
133
+ });
134
+ runtimeScheduler_->setPerformanceEntryReporter(
135
+ // FIXME: Move creation of PerformanceEntryReporter to here and guarantee
136
+ // that its lifetime is the same as the runtime.
137
+ PerformanceEntryReporter::getInstance().get());
122
138
 
123
139
  bufferedRuntimeExecutor_ = std::make_shared<BufferedRuntimeExecutor>(
124
140
  [runtimeScheduler = runtimeScheduler_.get()](
@@ -148,8 +164,8 @@ RuntimeExecutor ReactInstance::getUnbufferedRuntimeExecutor() noexcept {
148
164
 
149
165
  // This BufferedRuntimeExecutor ensures that the main JS bundle finished
150
166
  // execution before any JS queued into it from C++ are executed. Use
151
- // getBufferedRuntimeExecutor() instead if you do not need the main JS bundle to
152
- // have finished. e.g. setting global variables into JS runtime.
167
+ // getUnbufferedRuntimeExecutor() instead if you do not need the main JS bundle
168
+ // to have finished. e.g. setting global variables into JS runtime.
153
169
  RuntimeExecutor ReactInstance::getBufferedRuntimeExecutor() noexcept {
154
170
  return [weakBufferedRuntimeExecutor_ =
155
171
  std::weak_ptr<BufferedRuntimeExecutor>(bufferedRuntimeExecutor_)](
@@ -199,28 +215,34 @@ void ReactInstance::loadScript(
199
215
  buffer = std::move(buffer),
200
216
  weakBufferedRuntimeExecuter = std::weak_ptr<BufferedRuntimeExecutor>(
201
217
  bufferedRuntimeExecutor_)](jsi::Runtime& runtime) {
202
- try {
203
- SystraceSection s("ReactInstance::loadScript");
204
- bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl);
205
- if (hasLogger) {
206
- ReactMarker::logTaggedMarkerBridgeless(
207
- ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str());
208
- }
218
+ SystraceSection s("ReactInstance::loadScript");
219
+ bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl);
220
+ if (hasLogger) {
221
+ ReactMarker::logTaggedMarkerBridgeless(
222
+ ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str());
223
+ }
209
224
 
210
- runtime.evaluateJavaScript(buffer, sourceURL);
211
- if (hasLogger) {
212
- ReactMarker::logTaggedMarkerBridgeless(
213
- ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str());
214
- ReactMarker::logMarkerBridgeless(
215
- ReactMarker::INIT_REACT_RUNTIME_STOP);
216
- ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP);
217
- }
218
- if (auto strongBufferedRuntimeExecuter =
219
- weakBufferedRuntimeExecuter.lock()) {
220
- strongBufferedRuntimeExecuter->flush();
221
- }
222
- } catch (jsi::JSError& error) {
223
- jsErrorHandler_->handleFatalError(error);
225
+ runtime.evaluateJavaScript(buffer, sourceURL);
226
+
227
+ /**
228
+ * TODO(T183610671): We need a safe/reliable way to enable the js
229
+ * pipeline from javascript. Remove this after we figure that out, or
230
+ * after we just remove the js pipeline.
231
+ */
232
+ if (!jsErrorHandler_->hasHandledFatalError()) {
233
+ jsErrorHandler_->setRuntimeReady();
234
+ }
235
+
236
+ if (hasLogger) {
237
+ ReactMarker::logTaggedMarkerBridgeless(
238
+ ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str());
239
+ ReactMarker::logMarkerBridgeless(
240
+ ReactMarker::INIT_REACT_RUNTIME_STOP);
241
+ ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP);
242
+ }
243
+ if (auto strongBufferedRuntimeExecuter =
244
+ weakBufferedRuntimeExecuter.lock()) {
245
+ strongBufferedRuntimeExecuter->flush();
224
246
  }
225
247
  });
226
248
  }
@@ -332,6 +354,11 @@ void defineReactInstanceFlags(
332
354
  }
333
355
  }
334
356
 
357
+ bool isTruthy(jsi::Runtime& runtime, const jsi::Value& value) {
358
+ auto Boolean = runtime.global().getPropertyAsFunction(runtime, "Boolean");
359
+ return Boolean.call(runtime, value).getBool();
360
+ }
361
+
335
362
  } // namespace
336
363
 
337
364
  void ReactInstance::initializeRuntime(
@@ -346,8 +373,48 @@ void ReactInstance::initializeRuntime(
346
373
  RuntimeSchedulerBinding::createAndInstallIfNeeded(
347
374
  runtime, runtimeScheduler_);
348
375
 
376
+ runtime_->unstable_initializeOnJsThread();
377
+
349
378
  defineReactInstanceFlags(runtime, options);
350
379
 
380
+ // TODO(T196834299): We should really use a C++ turbomodule for this
381
+ defineReadOnlyGlobal(
382
+ runtime,
383
+ "RN$handleException",
384
+ jsi::Function::createFromHostFunction(
385
+ runtime,
386
+ jsi::PropNameID::forAscii(runtime, "handleException"),
387
+ 2,
388
+ [jsErrorHandler = jsErrorHandler_](
389
+ jsi::Runtime& runtime,
390
+ const jsi::Value& /*unused*/,
391
+ const jsi::Value* args,
392
+ size_t count) {
393
+ if (count < 2) {
394
+ throw jsi::JSError(
395
+ runtime,
396
+ "handleException requires 2 arguments: error, isFatal");
397
+ }
398
+
399
+ auto isFatal = isTruthy(runtime, args[1]);
400
+ if (jsErrorHandler->isRuntimeReady()) {
401
+ if (isFatal) {
402
+ jsErrorHandler->notifyOfFatalError();
403
+ }
404
+
405
+ return jsi::Value(false);
406
+ }
407
+
408
+ if (isFatal) {
409
+ auto jsError =
410
+ jsi::JSError(runtime, jsi::Value(runtime, args[0]));
411
+ jsErrorHandler->handleFatalError(runtime, jsError);
412
+ return jsi::Value(true);
413
+ }
414
+
415
+ return jsi::Value(false);
416
+ }));
417
+
351
418
  defineReadOnlyGlobal(
352
419
  runtime,
353
420
  "RN$registerCallableModule",
@@ -14,8 +14,8 @@
14
14
  "folly": {
15
15
  "type": "Project",
16
16
  "dependencies": {
17
- "Fmt": "[1.0.0, )",
18
- "boost": "[1.83.0, )"
17
+ "boost": "[1.83.0, )",
18
+ "fmt": "[1.0.0, )"
19
19
  }
20
20
  }
21
21
  },
@@ -11,10 +11,17 @@ try
11
11
  $packagesSolutions = Get-ChildItem -File -Recurse -Path packages *.sln | Where-Object { !$_.FullName.Contains('node_modules') -and !$_.FullName.Contains('e2etest') }
12
12
  $vnextSolutions = Get-ChildItem -File -Path vnext *.sln
13
13
 
14
+ # Run all solutions with their defaults
14
15
  $($packagesSolutions; $vnextSolutions) | Foreach {
15
- Write-Host Restoring $_.FullName
16
+ Write-Host Restoring $_.FullName with defaults
16
17
  & msbuild /t:Restore /p:RestoreForceEvaluate=true $_.FullName
17
18
  }
19
+
20
+ # Re-run solutions that we also build a Fabric variant
21
+ @("$RepoRoot\vnext\ReactWindows-Desktop.sln", "$RepoRoot\vnext\Microsoft.ReactNative.CppOnly.slnf") | Foreach {
22
+ Write-Host Restoring $_ with Fabric
23
+ & msbuild /t:Restore /p:RestoreForceEvaluate=true /p:UseFabric=true /p:UseWinUI3=true $_
24
+ }
18
25
  }
19
26
  finally
20
27
  {
@@ -80,12 +80,12 @@ New-Item -ItemType Directory -Path $TargetRoot\Microsoft.ReactNative.Cxx\ReactCo
80
80
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\callinvoker\ReactCommon\CallInvoker.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
81
81
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\callinvoker\ReactCommon\SchedulerPriority.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
82
82
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\CallbackWrapper.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
83
+ Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\LongLivedObject.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
84
+ Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\LongLivedObject.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
83
85
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\EventEmitter.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
84
86
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\Function.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
85
87
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\Base.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
86
88
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\Convert.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
87
- Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\LongLivedObject.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
88
- Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\bridging\LongLivedObject.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
89
89
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\nativemodule\core\ReactCommon\TurboModule.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
90
90
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\nativemodule\core\ReactCommon\TurboModule.h -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
91
91
  Copy-Item -Force -Path $ReactNativeRoot\ReactCommon\react\nativemodule\core\ReactCommon\TurboModuleUtils.cpp -Destination $TargetRoot\Microsoft.ReactNative.Cxx\ReactCommon\
@@ -416,9 +416,8 @@ void WebSocketTurboModule::Connect(
416
416
  auto &optHeaders = options.headers;
417
417
  if (optHeaders.has_value()) {
418
418
  auto &headersVal = optHeaders.value();
419
- for (const auto &headerVal : headersVal.AsArray()) {
419
+ for (const auto &entry : headersVal.AsObject()) {
420
420
  // Each header JSValueObject should only contain one key-value pair
421
- const auto &entry = *headerVal.AsObject().cbegin();
422
421
  rcOptions.emplace(winrt::to_hstring(entry.first), entry.second.AsString());
423
422
  }
424
423
  }