react-native-windows 0.74.12 → 0.75.0-preview.2

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 (335) hide show
  1. package/.flowconfig +8 -2
  2. package/Common/Utilities.cpp +2 -2
  3. package/Folly/TEMP_UntilFollyUpdate/ConstexprMath.h +970 -0
  4. package/Folly/TEMP_UntilFollyUpdate/json.cpp +1110 -0
  5. package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.cpp +4 -2
  6. package/Libraries/Animated/AnimatedImplementation.js +2 -0
  7. package/Libraries/Animated/NativeAnimatedHelper.js +4 -0
  8. package/Libraries/Animated/createAnimatedComponent.js +10 -4
  9. package/Libraries/Animated/useAnimatedProps.js +56 -28
  10. package/Libraries/BatchedBridge/MessageQueue.js +1 -0
  11. package/Libraries/Components/Button.js +10 -5
  12. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +11 -2
  13. package/Libraries/Components/Flyout/Flyout.js +10 -10
  14. package/Libraries/Components/Flyout/FlyoutNativeComponent.js +8 -7
  15. package/Libraries/Components/Pressable/Pressable.js +13 -6
  16. package/Libraries/Components/Pressable/Pressable.windows.js +13 -6
  17. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +4 -0
  18. package/Libraries/Components/ScrollView/ScrollView.js +109 -29
  19. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +6 -0
  20. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.windows.js +6 -0
  21. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +13 -1
  22. package/Libraries/Components/StatusBar/StatusBar.js +1 -21
  23. package/Libraries/Components/Switch/Switch.windows.js +2 -0
  24. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +0 -15
  25. package/Libraries/Components/TextInput/InputAccessoryView.js +10 -1
  26. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +0 -12
  27. package/Libraries/Components/TextInput/TextInput.d.ts +0 -19
  28. package/Libraries/Components/TextInput/TextInput.js +14 -70
  29. package/Libraries/Components/TextInput/TextInput.windows.js +15 -72
  30. package/Libraries/Components/TextInput/WindowsTextInputNativeComponent.js +27 -12
  31. package/Libraries/Components/Touchable/Touchable.js +2 -2
  32. package/Libraries/Components/Touchable/TouchableHighlight.d.ts +4 -10
  33. package/Libraries/Components/Touchable/TouchableHighlight.js +3 -1
  34. package/Libraries/Components/Touchable/TouchableHighlight.windows.js +3 -1
  35. package/Libraries/Components/Touchable/TouchableOpacity.d.ts +4 -32
  36. package/Libraries/Components/Touchable/TouchableOpacity.js +3 -1
  37. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +3 -1
  38. package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +8 -0
  39. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +117 -111
  40. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +129 -110
  41. package/Libraries/Components/View/ReactNativeStyleAttributes.js +6 -0
  42. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  43. package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +1 -0
  44. package/Libraries/Components/View/View.js +0 -11
  45. package/Libraries/Components/View/View.windows.js +0 -11
  46. package/Libraries/Components/View/ViewAccessibility.js +4 -4
  47. package/Libraries/Components/View/ViewAccessibility.windows.js +4 -4
  48. package/Libraries/Components/View/ViewPropTypes.d.ts +21 -59
  49. package/Libraries/Components/View/ViewPropTypes.js +7 -0
  50. package/Libraries/Components/View/ViewPropTypes.windows.js +7 -0
  51. package/Libraries/Core/Devtools/loadBundleFromServer.js +3 -3
  52. package/Libraries/Core/Devtools/loadBundleFromServer.windows.js +153 -0
  53. package/Libraries/Core/Devtools/parseErrorStack.js +5 -5
  54. package/Libraries/Core/Devtools/parseHermesStack.js +22 -16
  55. package/Libraries/Core/ErrorHandlers.js +116 -0
  56. package/Libraries/Core/ExceptionsManager.js +2 -2
  57. package/Libraries/Core/ReactNativeVersion.js +3 -3
  58. package/Libraries/Core/setUpDeveloperTools.js +3 -1
  59. package/Libraries/Core/setUpPerformance.js +6 -4
  60. package/Libraries/Core/setUpReactDevTools.js +70 -10
  61. package/Libraries/Core/setUpTimers.js +50 -31
  62. package/Libraries/Debugging/DebuggingOverlayRegistry.js +1 -1
  63. package/Libraries/Image/Image.android.js +23 -13
  64. package/Libraries/Image/Image.d.ts +14 -15
  65. package/Libraries/Image/Image.ios.js +21 -11
  66. package/Libraries/Image/Image.windows.js +21 -11
  67. package/Libraries/Image/ImageProps.js +16 -5
  68. package/Libraries/Image/ImageTypes.flow.js +7 -2
  69. package/Libraries/Image/ImageUtils.js +1 -0
  70. package/Libraries/Image/ImageViewNativeComponent.js +2 -1
  71. package/Libraries/Inspector/ElementBox.js +6 -3
  72. package/Libraries/Inspector/ElementProperties.js +1 -1
  73. package/Libraries/Interaction/TouchHistoryMath.js +4 -4
  74. package/Libraries/IntersectionObserver/IntersectionObserverManager.js +6 -26
  75. package/Libraries/JSInspector/NetworkAgent.js +1 -1
  76. package/Libraries/LogBox/Data/LogBoxData.js +39 -29
  77. package/Libraries/LogBox/Data/LogBoxLog.js +114 -2
  78. package/Libraries/LogBox/Data/parseLogBoxLog.js +168 -53
  79. package/Libraries/LogBox/LogBox.js +29 -12
  80. package/Libraries/LogBox/LogBoxNotificationContainer.js +4 -0
  81. package/Libraries/LogBox/UI/LogBoxInspector.js +8 -70
  82. package/Libraries/LogBox/UI/LogBoxInspectorBody.js +87 -0
  83. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +6 -42
  84. package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +58 -0
  85. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +5 -66
  86. package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +5 -66
  87. package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +76 -0
  88. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +8 -5
  89. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.windows.js +8 -5
  90. package/Libraries/LogBox/UI/LogBoxNotification.js +13 -152
  91. package/Libraries/LogBox/UI/LogBoxNotificationCountBadge.js +63 -0
  92. package/Libraries/LogBox/UI/LogBoxNotificationDismissButton.js +67 -0
  93. package/Libraries/LogBox/UI/LogBoxNotificationMessage.js +57 -0
  94. package/Libraries/NativeComponent/BaseViewConfig.android.js +5 -0
  95. package/Libraries/NativeComponent/BaseViewConfig.ios.js +5 -0
  96. package/Libraries/NativeComponent/BaseViewConfig.windows.js +5 -0
  97. package/Libraries/NativeComponent/NativeComponentRegistry.js +12 -5
  98. package/Libraries/NativeComponent/StaticViewConfigValidator.js +3 -0
  99. package/Libraries/Network/XMLHttpRequest.js +5 -1
  100. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +3 -3
  101. package/Libraries/Pressability/Pressability.js +3 -51
  102. package/Libraries/Pressability/Pressability.windows.js +3 -51
  103. package/Libraries/ReactNative/AppRegistry.d.ts +4 -0
  104. package/Libraries/ReactNative/AppRegistry.js +2 -4
  105. package/Libraries/ReactNative/BridgelessUIManager.js +1 -21
  106. package/Libraries/ReactNative/FabricUIManager.js +0 -51
  107. package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +1 -0
  108. package/Libraries/ReactNative/RendererImplementation.js +20 -2
  109. package/Libraries/ReactNative/UIManager.d.ts +0 -21
  110. package/Libraries/ReactNative/UIManagerProperties.js +0 -3
  111. package/Libraries/ReactNative/__mocks__/FabricUIManager.js +5 -341
  112. package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -8
  113. package/Libraries/Renderer/implementations/ReactFabric-dev.js +15682 -27088
  114. package/Libraries/Renderer/implementations/ReactFabric-prod.js +5082 -4381
  115. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3480 -2571
  116. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +15943 -27543
  117. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5303 -4606
  118. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3450 -2572
  119. package/Libraries/Renderer/shims/ReactFabric.js +2 -2
  120. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
  121. package/Libraries/Renderer/shims/ReactNative.js +2 -3
  122. package/Libraries/Renderer/shims/ReactNativeTypes.js +24 -3
  123. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -2
  124. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
  125. package/Libraries/Share/Share.d.ts +16 -10
  126. package/Libraries/Share/Share.js +14 -15
  127. package/Libraries/StyleSheet/StyleSheet.d.ts +1 -1
  128. package/Libraries/StyleSheet/StyleSheet.js +3 -10
  129. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +21 -21
  130. package/Libraries/StyleSheet/StyleSheetTypes.js +24 -18
  131. package/Libraries/StyleSheet/flattenStyle.js +1 -0
  132. package/Libraries/StyleSheet/processFilter.js +132 -0
  133. package/Libraries/StyleSheet/processTransform.js +18 -3
  134. package/Libraries/Text/Text.js +151 -128
  135. package/Libraries/Text/Text.windows.js +144 -128
  136. package/Libraries/Text/TextNativeComponent.js +5 -4
  137. package/Libraries/Text/TextProps.js +6 -6
  138. package/Libraries/Text/TextProps.windows.js +6 -6
  139. package/Libraries/TurboModule/TurboModuleRegistry.js +2 -1
  140. package/Libraries/Types/CodegenTypes.js +3 -0
  141. package/Libraries/Utilities/{LoadingView.android.js → DevLoadingView.js} +33 -11
  142. package/Libraries/Utilities/Dimensions.js +1 -0
  143. package/Libraries/Utilities/HMRClient.js +36 -8
  144. package/Libraries/Utilities/HMRClientProdShim.js +1 -0
  145. package/Libraries/Utilities/NativePlatformConstantsWin.js +2 -2
  146. package/Libraries/Utilities/Platform.android.js +4 -4
  147. package/Libraries/Utilities/RCTLog.js +1 -0
  148. package/Libraries/Utilities/ReactNativeTestTools.js +12 -24
  149. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +11 -6
  150. package/Libraries/__tests__/ViewWindows-test.js +6 -6
  151. package/Libraries/promiseRejectionTrackingOptions.js +1 -0
  152. package/Microsoft.ReactNative/Base/FollyIncludes.h +1 -1
  153. package/Microsoft.ReactNative/ComponentView.idl +0 -17
  154. package/Microsoft.ReactNative/Composition.Input.idl +3 -3
  155. package/Microsoft.ReactNative/CompositionSwitcher.idl +0 -1
  156. package/Microsoft.ReactNative/Fabric/AbiState.cpp +3 -45
  157. package/Microsoft.ReactNative/Fabric/AbiState.h +0 -6
  158. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -3
  159. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +2 -2
  160. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +4 -4
  161. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +0 -10
  162. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +27 -16
  163. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -1
  164. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +48 -85
  165. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +0 -4
  166. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +24 -24
  167. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +6 -8
  168. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +0 -10
  169. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +0 -3
  170. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +29 -45
  171. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +1 -3
  172. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +6 -43
  173. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +23 -34
  174. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +1 -2
  175. package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +9 -3
  176. package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.h +1 -1
  177. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +17 -48
  178. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +3 -7
  179. package/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp +23 -16
  180. package/Microsoft.ReactNative/Fabric/WindowsImageManager.h +5 -2
  181. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +2 -10
  182. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +107 -36
  183. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +18 -12
  184. package/Microsoft.ReactNative/Modules/DevSettingsModule.cpp +4 -0
  185. package/Microsoft.ReactNative/Modules/DevSettingsModule.h +1 -0
  186. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -2
  187. package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +7 -4
  188. package/Microsoft.ReactNative/Modules/NativeUIManager.h +1 -1
  189. package/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.cpp +2 -2
  190. package/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.h +3 -3
  191. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +13 -20
  192. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  193. package/Microsoft.ReactNative/Timer.idl +1 -3
  194. package/Microsoft.ReactNative/Utils/BatchingEventEmitter.cpp +1 -1
  195. package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +2 -3
  196. package/Microsoft.ReactNative/Utils/ValueUtils.cpp +1 -1
  197. package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +2 -2
  198. package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +1 -1
  199. package/Microsoft.ReactNative/packages.lock.json +41 -78
  200. package/Microsoft.ReactNative.Cxx/JSI/LongLivedJsiValue.h +1 -1
  201. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +5 -0
  202. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +1 -0
  203. package/Microsoft.ReactNative.Cxx/TurboModuleProvider.cpp +14 -6
  204. package/Microsoft.ReactNative.Cxx/TurboModuleProvider.h +2 -2
  205. package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +1 -1
  206. package/Microsoft.ReactNative.Managed/packages.lock.json +3 -3
  207. package/PropertySheets/External/Microsoft.ReactNative.WindowsSdk.Default.props +4 -4
  208. package/PropertySheets/Generated/PackageVersion.g.props +4 -4
  209. package/README.md +21 -21
  210. package/ReactCommon/ReactCommon.vcxproj +2 -0
  211. package/ReactCommon/ReactCommon.vcxproj.filters +3 -0
  212. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +67 -0
  213. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.h +180 -0
  214. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +351 -0
  215. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +6 -3
  216. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Base.h +152 -0
  217. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +2 -1
  218. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +13 -15
  219. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/EventEmitter.h +137 -0
  220. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Function.h +283 -0
  221. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.cpp +7 -10
  222. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +162 -0
  223. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +2 -4
  224. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +33 -8
  225. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/JSRuntimeFactory.cpp +45 -0
  226. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/JSRuntimeFactory.h +67 -0
  227. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +104 -74
  228. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +4 -0
  229. package/Scripts/rnw-dependencies.ps1 +36 -23
  230. package/Shared/HermesRuntimeHolder.cpp +19 -1
  231. package/Shared/HermesRuntimeHolder.h +8 -1
  232. package/Shared/HermesSamplingProfiler.cpp +1 -2
  233. package/Shared/Networking/WinRTWebSocketResource.cpp +3 -3
  234. package/Shared/OInstance.cpp +1 -2
  235. package/Shared/Shared.vcxitems +21 -15
  236. package/Shared/Shared.vcxitems.filters +8 -3
  237. package/Shared/Threading/BatchingQueueThread.cpp +6 -2
  238. package/Shared/Threading/BatchingQueueThread.h +2 -2
  239. package/Shared/Utils/CppWinrtLessExceptions.h +2 -2
  240. package/codegen/NativeAppStateSpec.g.h +8 -8
  241. package/codegen/NativeBlobModuleSpec.g.h +0 -10
  242. package/codegen/NativeDOMSpec.g.h +136 -0
  243. package/codegen/NativeDevSettingsSpec.g.h +11 -5
  244. package/codegen/NativeIdleCallbacksSpec.g.h +64 -0
  245. package/codegen/NativeIntersectionObserverSpec.g.h +14 -14
  246. package/codegen/NativeMicrotasksSpec.g.h +34 -0
  247. package/codegen/NativePerformanceSpec.g.h +35 -7
  248. package/codegen/NativePlatformConstantsWindowsSpec.g.h +81 -0
  249. package/codegen/NativePushNotificationManagerIOSSpec.g.h +15 -19
  250. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +111 -39
  251. package/codegen/NativeUIManagerSpec.g.h +5 -17
  252. package/codegen/react/components/rnwcore/Props.cpp +1 -1
  253. package/codegen/react/components/rnwcore/Props.h +16 -12
  254. package/codegen/react/components/rnwcore/States.h +0 -26
  255. package/codegen/rnwcoreJSI-generated.cpp +688 -463
  256. package/codegen/rnwcoreJSI.h +1374 -2867
  257. package/fmt/TEMP_UntilFmtUpdate/core.h +2925 -0
  258. package/fmt/fmt.vcxproj +1 -1
  259. package/jest/mockComponent.js +7 -0
  260. package/jest/renderer.js +25 -14
  261. package/jest/setup.js +19 -13
  262. package/package.json +29 -27
  263. package/rn-get-polyfills.js +1 -0
  264. package/src/private/core/composeStyles.js +27 -0
  265. package/src/private/featureflags/ReactNativeFeatureFlags.js +93 -33
  266. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
  267. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +56 -0
  268. package/src/private/fusebox/setUpFuseboxReactDevToolsDispatcher.js +108 -0
  269. package/src/private/specs/modules/NativeBlobModule.js +4 -2
  270. package/src/private/specs/modules/NativeDevSettings.js +1 -0
  271. package/src/private/specs/modules/NativePushNotificationManagerIOS.js +0 -4
  272. package/src/private/specs/modules/NativeUIManager.js +0 -7
  273. package/src/private/webapis/dom/geometry/DOMRectReadOnly.js +24 -24
  274. package/src/private/webapis/dom/nodes/ReactNativeElement.js +11 -14
  275. package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +2 -3
  276. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +24 -54
  277. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +5 -13
  278. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +468 -0
  279. package/src/private/webapis/dom/nodes/specs/__mocks__/NativeDOMMock.js +413 -0
  280. package/src/private/webapis/dom/oldstylecollections/DOMRectList.js +4 -4
  281. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +4 -4
  282. package/src/private/webapis/dom/oldstylecollections/NodeList.js +5 -5
  283. package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +34 -0
  284. package/src/private/webapis/microtasks/specs/NativeMicrotasks.js +21 -0
  285. package/src/private/webapis/performance/EventCounts.js +1 -1
  286. package/src/private/webapis/performance/MemoryInfo.js +9 -9
  287. package/src/private/webapis/performance/Performance.js +10 -56
  288. package/src/private/webapis/performance/PerformanceObserver.js +30 -22
  289. package/src/private/webapis/performance/RawPerformanceEntry.js +2 -7
  290. package/src/private/webapis/performance/ReactNativeStartupTiming.js +18 -18
  291. package/src/private/webapis/performance/UserTiming.js +63 -0
  292. package/src/private/webapis/performance/{NativePerformance.js → specs/NativePerformance.js} +3 -2
  293. package/src/private/webapis/performance/{NativePerformanceObserver.js → specs/NativePerformanceObserver.js} +2 -2
  294. package/src/private/webapis/performance/{__mocks__ → specs/__mocks__}/NativePerformance.js +1 -1
  295. package/src/private/webapis/performance/{__mocks__ → specs/__mocks__}/NativePerformanceObserver.js +3 -4
  296. package/stubs/glog/logging.h +1 -0
  297. package/template/cpp-lib/proj/MyLib.vcxproj +1 -1
  298. package/template/cs-lib/proj/MyLib.csproj +1 -1
  299. package/template/metro.config.js +13 -2
  300. package/templates/cpp-app/template.config.js +1 -1
  301. package/templates/cpp-lib/example/metro.config.js +2 -2
  302. package/templates/cpp-lib/template.config.js +1 -1
  303. package/templates/old/generateWrapper.js +4 -1
  304. package/types/modules/globals.d.ts +4 -0
  305. package/Libraries/Lists/FlatList.windows.js +0 -717
  306. package/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js +0 -13
  307. package/Libraries/Utilities/LoadingView.ios.js +0 -50
  308. package/Libraries/Utilities/LoadingView.js +0 -16
  309. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp +0 -178
  310. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/utils/jsi-utils.cpp +0 -39
  311. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/utils/jsi-utils.h +0 -31
  312. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/YGEnums.h +0 -137
  313. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +0 -2377
  314. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.cpp +0 -140
  315. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +0 -92
  316. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/enums/ExperimentalFeature.h +0 -40
  317. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.cpp +0 -48
  318. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +0 -122
  319. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +0 -366
  320. package/codegen/NativeAnimationsDebugModuleSpec.g.h +0 -40
  321. package/codegen/NativePlatformConstantsWinSpec.g.h +0 -81
  322. package/jest/ReactNativeInternalFeatureFlagsMock.js +0 -13
  323. package/src/private/featureflags/NativeReactNativeFeatureFlags.js +0 -44
  324. package/src/private/featureflags/__tests__/ReactNativeFeatureFlags-test.js +0 -92
  325. package/src/private/specs/modules/NativeAnimationsDebugModule.js +0 -20
  326. package/src/private/webapis/dom/oldstylecollections/__tests__/DOMRectList-test.js +0 -85
  327. package/src/private/webapis/dom/oldstylecollections/__tests__/HTMLCollection-test.js +0 -80
  328. package/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js +0 -161
  329. package/src/private/webapis/performance/__tests__/EventCounts-test.js +0 -116
  330. package/src/private/webapis/performance/__tests__/NativePerformanceMock-test.js +0 -82
  331. package/src/private/webapis/performance/__tests__/NativePerformanceObserverMock-test.js +0 -108
  332. package/src/private/webapis/performance/__tests__/Performance-test.js +0 -117
  333. package/src/private/webapis/performance/__tests__/PerformanceObserver-test.js +0 -208
  334. package/template/metro.devMode.config.js +0 -56
  335. /package/src/private/specs/modules/{NativePlatformConstantsWin.js → NativePlatformConstantsWindows.js} +0 -0
@@ -0,0 +1,153 @@
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
+ * @flow strict-local
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import Networking from '../../Network/RCTNetworking';
13
+ import DevLoadingView from '../../Utilities/DevLoadingView';
14
+ import HMRClient from '../../Utilities/HMRClient';
15
+ import getDevServer from './getDevServer';
16
+
17
+ declare var global: {globalEvalWithSourceUrl?: (string, string) => mixed, ...};
18
+
19
+ let pendingRequests = 0;
20
+
21
+ const cachedPromisesByUrl = new Map<string, Promise<void>>();
22
+
23
+ function asyncRequest(
24
+ url: string,
25
+ ): Promise<{body: string, headers: {[string]: string}}> {
26
+ let id = null;
27
+ let responseText = null;
28
+ let headers = null;
29
+ let dataListener;
30
+ let completeListener;
31
+ let responseListener;
32
+ let incrementalDataListener;
33
+ return new Promise<{body: string, headers: {[string]: string}}>(
34
+ (resolve, reject) => {
35
+ dataListener = Networking.addListener(
36
+ 'didReceiveNetworkData',
37
+ ([requestId, response]) => {
38
+ if (requestId === id) {
39
+ responseText = response;
40
+ }
41
+ },
42
+ );
43
+ incrementalDataListener = Networking.addListener(
44
+ 'didReceiveNetworkIncrementalData',
45
+ ([requestId, data]) => {
46
+ if (requestId === id) {
47
+ if (responseText != null) {
48
+ responseText += data;
49
+ } else {
50
+ responseText = data;
51
+ }
52
+ }
53
+ },
54
+ );
55
+ responseListener = Networking.addListener(
56
+ 'didReceiveNetworkResponse',
57
+ ([requestId, status, responseHeaders]) => {
58
+ if (requestId === id) {
59
+ headers = responseHeaders;
60
+ }
61
+ },
62
+ );
63
+ completeListener = Networking.addListener(
64
+ 'didCompleteNetworkResponse',
65
+ ([requestId, error]) => {
66
+ if (requestId === id) {
67
+ if (error) {
68
+ reject(error);
69
+ } else {
70
+ //$FlowFixMe[incompatible-call]
71
+ resolve({body: responseText, headers});
72
+ }
73
+ }
74
+ },
75
+ );
76
+ Networking.sendRequest(
77
+ 'GET',
78
+ 'asyncRequest',
79
+ url,
80
+ {},
81
+ '',
82
+ 'text',
83
+ true,
84
+ 0,
85
+ requestId => {
86
+ id = requestId;
87
+ },
88
+ true,
89
+ );
90
+ },
91
+ ).finally(() => {
92
+ dataListener?.remove();
93
+ completeListener?.remove();
94
+ responseListener?.remove();
95
+ incrementalDataListener?.remove();
96
+ });
97
+ }
98
+
99
+ function buildUrlForBundle(bundlePathAndQuery: string) {
100
+ const {url: serverUrl} = getDevServer();
101
+ return (
102
+ serverUrl.replace(/\/+$/, '') + '/' + bundlePathAndQuery.replace(/^\/+/, '')
103
+ );
104
+ }
105
+
106
+ module.exports = function (bundlePathAndQuery: string): Promise<void> {
107
+ const requestUrl = buildUrlForBundle(bundlePathAndQuery);
108
+ let loadPromise = cachedPromisesByUrl.get(requestUrl);
109
+
110
+ if (loadPromise) {
111
+ return loadPromise;
112
+ }
113
+ DevLoadingView.showMessage('Downloading...', 'load');
114
+ ++pendingRequests;
115
+
116
+ loadPromise = asyncRequest(requestUrl)
117
+ .then<void>(({body, headers}) => {
118
+ if (
119
+ headers['Content-Type'] != null &&
120
+ headers['Content-Type'].indexOf('application/json') >= 0
121
+ ) {
122
+ // Errors are returned as JSON.
123
+ throw new Error(
124
+ JSON.parse(body).message ||
125
+ `Unknown error fetching '${bundlePathAndQuery}'`,
126
+ );
127
+ }
128
+
129
+ HMRClient.registerBundle(requestUrl);
130
+
131
+ // Some engines do not support `sourceURL` as a comment. We expose a
132
+ // `globalEvalWithSourceUrl` function to handle updates in that case.
133
+ if (global.globalEvalWithSourceUrl) {
134
+ global.globalEvalWithSourceUrl(body, requestUrl);
135
+ } else {
136
+ // [Windows #12704 - CodeQL patch]
137
+ // eslint-disable-next-line no-eval
138
+ eval(body); // CodeQL [js/eval-usage] Debug only. Developer inner loop.
139
+ }
140
+ })
141
+ .catch<void>(e => {
142
+ cachedPromisesByUrl.delete(requestUrl);
143
+ throw e;
144
+ })
145
+ .finally(() => {
146
+ if (!--pendingRequests) {
147
+ DevLoadingView.hide();
148
+ }
149
+ });
150
+
151
+ cachedPromisesByUrl.set(requestUrl, loadPromise);
152
+ return loadPromise;
153
+ };
@@ -47,11 +47,11 @@ function parseErrorStack(errorStack?: string): Array<StackFrame> {
47
47
  const parsedStack = Array.isArray(errorStack)
48
48
  ? errorStack
49
49
  : global.HermesInternal
50
- ? convertHermesStack(parseHermesStack(errorStack))
51
- : stacktraceParser.parse(errorStack).map((frame): StackFrame => ({
52
- ...frame,
53
- column: frame.column != null ? frame.column - 1 : null,
54
- }));
50
+ ? convertHermesStack(parseHermesStack(errorStack))
51
+ : stacktraceParser.parse(errorStack).map((frame): StackFrame => ({
52
+ ...frame,
53
+ column: frame.column != null ? frame.column - 1 : null,
54
+ }));
55
55
 
56
56
  return parsedStack;
57
57
  }
@@ -72,6 +72,7 @@ const RE_FRAME =
72
72
  // Capturing groups:
73
73
  // 1. count of skipped frames
74
74
  const RE_SKIPPED = /^ {4}... skipping (\d+) frames$/;
75
+ const RE_COMPONENT_NO_STACK = /^ {4}at .*$/;
75
76
 
76
77
  function isInternalBytecodeSourceUrl(sourceUrl: string): boolean {
77
78
  // See https://github.com/facebook/hermes/blob/3332fa020cae0bab751f648db7c94e1d687eeec7/lib/VM/Runtime.cpp#L1100
@@ -88,25 +89,25 @@ function parseLine(line: string): ?HermesStackEntry {
88
89
  asFrame[2] === 'native'
89
90
  ? {type: 'NATIVE'}
90
91
  : asFrame[3] === 'address at '
91
- ? isInternalBytecodeSourceUrl(asFrame[4])
92
- ? {
93
- type: 'INTERNAL_BYTECODE',
94
- sourceUrl: asFrame[4],
95
- line1Based: Number.parseInt(asFrame[5], 10),
96
- virtualOffset0Based: Number.parseInt(asFrame[6], 10),
97
- }
92
+ ? isInternalBytecodeSourceUrl(asFrame[4])
93
+ ? {
94
+ type: 'INTERNAL_BYTECODE',
95
+ sourceUrl: asFrame[4],
96
+ line1Based: Number.parseInt(asFrame[5], 10),
97
+ virtualOffset0Based: Number.parseInt(asFrame[6], 10),
98
+ }
99
+ : {
100
+ type: 'BYTECODE',
101
+ sourceUrl: asFrame[4],
102
+ line1Based: Number.parseInt(asFrame[5], 10),
103
+ virtualOffset0Based: Number.parseInt(asFrame[6], 10),
104
+ }
98
105
  : {
99
- type: 'BYTECODE',
106
+ type: 'SOURCE',
100
107
  sourceUrl: asFrame[4],
101
108
  line1Based: Number.parseInt(asFrame[5], 10),
102
- virtualOffset0Based: Number.parseInt(asFrame[6], 10),
103
- }
104
- : {
105
- type: 'SOURCE',
106
- sourceUrl: asFrame[4],
107
- line1Based: Number.parseInt(asFrame[5], 10),
108
- column1Based: Number.parseInt(asFrame[6], 10),
109
- },
109
+ column1Based: Number.parseInt(asFrame[6], 10),
110
+ },
110
111
  };
111
112
  }
112
113
  const asSkipped = line.match(RE_SKIPPED);
@@ -132,6 +133,11 @@ module.exports = function parseHermesStack(stack: string): HermesParsedStack {
132
133
  entries.push(entry);
133
134
  continue;
134
135
  }
136
+ if (RE_COMPONENT_NO_STACK.test(line)) {
137
+ // Skip component stacks without source location.
138
+ // TODO: This will not be displayed, not sure how to handle it.
139
+ continue;
140
+ }
135
141
  // No match - we're still in the message
136
142
  lastMessageLine = i;
137
143
  entries = [];
@@ -0,0 +1,116 @@
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
+ * @format
8
+ * @flow strict
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ import type {ExtendedError} from './ExtendedError';
14
+
15
+ import {SyntheticError, handleException} from './ExceptionsManager';
16
+
17
+ type ErrorInfo = {
18
+ +componentStack?: ?string,
19
+ // $FlowFixMe[unclear-type] unknown props and state.
20
+ +errorBoundary?: ?React$Component<any, any>,
21
+ };
22
+
23
+ export function onUncaughtError(errorValue: mixed, errorInfo: ErrorInfo): void {
24
+ let error;
25
+
26
+ // Typically, `errorValue` should be an error. However, other values such as
27
+ // strings (or even null) are sometimes thrown.
28
+ if (errorValue instanceof Error) {
29
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
30
+ * this parameters */
31
+ error = (errorValue: ExtendedError);
32
+ } else if (typeof errorValue === 'string') {
33
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
34
+ * this parameters */
35
+ error = (new SyntheticError(errorValue): ExtendedError);
36
+ } else {
37
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
38
+ * this parameters */
39
+ error = (new SyntheticError('Unspecified error'): ExtendedError);
40
+ }
41
+ try {
42
+ // $FlowFixMe[incompatible-use] this is in try/catch.
43
+ error.componentStack = errorInfo.componentStack;
44
+ error.isComponentError = true;
45
+ } catch {
46
+ // Ignored.
47
+ }
48
+
49
+ // Uncaught errors are fatal.
50
+ handleException(error, true);
51
+ }
52
+
53
+ export function onCaughtError(errorValue: mixed, errorInfo: ErrorInfo): void {
54
+ let error;
55
+
56
+ // Typically, `errorValue` should be an error. However, other values such as
57
+ // strings (or even null) are sometimes thrown.
58
+ if (errorValue instanceof Error) {
59
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
60
+ * this parameters */
61
+ error = (errorValue: ExtendedError);
62
+ } else if (typeof errorValue === 'string') {
63
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
64
+ * this parameters */
65
+ error = (new SyntheticError(errorValue): ExtendedError);
66
+ } else {
67
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
68
+ * this parameters */
69
+ error = (new SyntheticError('Unspecified error'): ExtendedError);
70
+ }
71
+ try {
72
+ // $FlowFixMe[incompatible-use] this is in try/catch.
73
+ error.componentStack = errorInfo.componentStack;
74
+ error.isComponentError = true;
75
+ } catch {
76
+ // Ignored.
77
+ }
78
+
79
+ // Caught errors are not fatal.
80
+ handleException(error, false);
81
+ }
82
+
83
+ export function onRecoverableError(
84
+ errorValue: mixed,
85
+ errorInfo: ErrorInfo,
86
+ ): void {
87
+ let error;
88
+
89
+ // Typically, `errorValue` should be an error. However, other values such as
90
+ // strings (or even null) are sometimes thrown.
91
+ if (errorValue instanceof Error) {
92
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
93
+ * this parameters */
94
+ error = (errorValue: ExtendedError);
95
+ } else if (typeof errorValue === 'string') {
96
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
97
+ * this parameters */
98
+ error = (new SyntheticError(errorValue): ExtendedError);
99
+ } else {
100
+ /* $FlowFixMe[class-object-subtyping] added when improving typing for
101
+ * this parameters */
102
+ error = (new SyntheticError('Unspecified error'): ExtendedError);
103
+ }
104
+ try {
105
+ // $FlowFixMe[incompatible-use] this is in try/catch.
106
+ error.componentStack = errorInfo.componentStack;
107
+ error.isComponentError = true;
108
+ } catch {
109
+ // Ignored.
110
+ }
111
+
112
+ // Recoverable errors should only be warnings.
113
+ // This will make it a soft error in LogBox.
114
+ // TODO: improve the logging for recoverable errors in prod.
115
+ console.warn(error);
116
+ }
@@ -126,8 +126,8 @@ function reportException(
126
126
  }
127
127
 
128
128
  declare var console: {
129
- error: typeof console.error,
130
- _errorOriginal: typeof console.error,
129
+ error: (...data: $ReadOnlyArray<mixed>) => void,
130
+ _errorOriginal: (...data: $ReadOnlyArray<mixed>) => void,
131
131
  reportErrorsAsExceptions: boolean,
132
132
  ...
133
133
  };
@@ -15,9 +15,9 @@ const version: $ReadOnly<{
15
15
  prerelease: string | null,
16
16
  }> = {
17
17
  major: 0,
18
- minor: 74,
19
- patch: 3,
20
- prerelease: null,
18
+ minor: 75,
19
+ patch: 0,
20
+ prerelease: 'rc.3',
21
21
  };
22
22
 
23
23
  module.exports = {version};
@@ -42,7 +42,9 @@ if (__DEV__) {
42
42
  if (!Platform.isTesting) {
43
43
  const HMRClient = require('../Utilities/HMRClient');
44
44
 
45
- if (console._isPolyfilled) {
45
+ if (global.__FUSEBOX_HAS_FULL_CONSOLE_SUPPORT__) {
46
+ HMRClient.unstable_notifyFuseboxConsoleEnabled();
47
+ } else if (console._isPolyfilled) {
46
48
  // We assume full control over the console and send JavaScript logs to Metro.
47
49
  [
48
50
  'trace',
@@ -8,8 +8,8 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import NativePerformance from '../../src/private/webapis/performance/NativePerformance';
12
11
  import Performance from '../../src/private/webapis/performance/Performance';
12
+ import NativePerformance from '../../src/private/webapis/performance/specs/NativePerformance';
13
13
 
14
14
  // In case if the native implementation of the Performance API is available, use it,
15
15
  // otherwise fall back to the legacy/default one, which only defines 'Performance.now()'
@@ -19,11 +19,13 @@ if (NativePerformance) {
19
19
  } else {
20
20
  if (!global.performance) {
21
21
  // $FlowExpectedError[cannot-write]
22
- global.performance = ({
23
- now: function () {
22
+ global.performance = {
23
+ mark: () => {},
24
+ measure: () => {},
25
+ now: () => {
24
26
  const performanceNow = global.nativePerformanceNow || Date.now;
25
27
  return performanceNow();
26
28
  },
27
- }: {now?: () => number});
29
+ };
28
30
  }
29
31
  }
@@ -10,12 +10,52 @@
10
10
 
11
11
  'use strict';
12
12
 
13
+ import type {Domain} from '../../src/private/fusebox/setUpFuseboxReactDevToolsDispatcher';
14
+
13
15
  if (__DEV__) {
14
- let isWebSocketOpen = false;
15
- let ws = null;
16
+ // Register dispatcher on global, which can be used later by Chrome DevTools frontend
17
+ require('../../src/private/fusebox/setUpFuseboxReactDevToolsDispatcher');
16
18
 
19
+ // Install hook before React is loaded.
17
20
  const reactDevTools = require('react-devtools-core');
18
- const connectToDevTools = () => {
21
+ // This should be defined in DEV, otherwise error is expected.
22
+ const fuseboxReactDevToolsDispatcher =
23
+ global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__;
24
+ const reactDevToolsFuseboxGlobalBindingName =
25
+ fuseboxReactDevToolsDispatcher.BINDING_NAME;
26
+
27
+ const ReactNativeStyleAttributes = require('../Components/View/ReactNativeStyleAttributes');
28
+ const devToolsSettingsManager = require('../DevToolsSettings/DevToolsSettingsManager');
29
+ const resolveRNStyle = require('../StyleSheet/flattenStyle');
30
+
31
+ let disconnect = null;
32
+ function disconnectBackendFromReactDevToolsInFuseboxIfNeeded() {
33
+ if (disconnect != null) {
34
+ disconnect();
35
+ disconnect = null;
36
+ }
37
+ }
38
+
39
+ function connectToReactDevToolsInFusebox(domain: Domain) {
40
+ disconnect = reactDevTools.connectWithCustomMessagingProtocol({
41
+ onSubscribe: listener => {
42
+ domain.onMessage.addEventListener(listener);
43
+ },
44
+ onUnsubscribe: listener => {
45
+ domain.onMessage.removeEventListener(listener);
46
+ },
47
+ onMessage: (event, payload) => {
48
+ domain.sendMessage({event, payload});
49
+ },
50
+ settingsManager: devToolsSettingsManager,
51
+ nativeStyleEditorValidAttributes: Object.keys(ReactNativeStyleAttributes),
52
+ resolveRNStyle,
53
+ });
54
+ }
55
+
56
+ let isWebSocketOpen = false;
57
+ let ws = null;
58
+ function connectToWSBasedReactDevToolsFrontend() {
19
59
  if (ws !== null && isWebSocketOpen) {
20
60
  // If the DevTools backend is already connected, don't recreate the WebSocket.
21
61
  // This would break the connection.
@@ -61,12 +101,9 @@ if (__DEV__) {
61
101
  isWebSocketOpen = true;
62
102
  });
63
103
 
64
- const ReactNativeStyleAttributes = require('../Components/View/ReactNativeStyleAttributes');
65
- const devToolsSettingsManager = require('../DevToolsSettings/DevToolsSettingsManager');
66
-
67
104
  reactDevTools.connectToDevTools({
68
105
  isAppActive,
69
- resolveRNStyle: require('../StyleSheet/flattenStyle'),
106
+ resolveRNStyle,
70
107
  nativeStyleEditorValidAttributes: Object.keys(
71
108
  ReactNativeStyleAttributes,
72
109
  ),
@@ -74,9 +111,32 @@ if (__DEV__) {
74
111
  devToolsSettingsManager,
75
112
  });
76
113
  }
77
- };
114
+ }
115
+
116
+ // 1. If React DevTools has already been opened and initialized in Fusebox, bindings survive reloads
117
+ if (global[reactDevToolsFuseboxGlobalBindingName] != null) {
118
+ disconnectBackendFromReactDevToolsInFuseboxIfNeeded();
119
+ const domain =
120
+ fuseboxReactDevToolsDispatcher.initializeDomain('react-devtools');
121
+ connectToReactDevToolsInFusebox(domain);
122
+ }
123
+
124
+ // 2. If React DevTools panel in Fusebox was opened for the first time after the runtime has been created
125
+ // 2. OR if React DevTools frontend was re-initialized: Chrome DevTools was closed and then re-opened
126
+ global.__FUSEBOX_REACT_DEVTOOLS_DISPATCHER__.onDomainInitialization.addEventListener(
127
+ (domain: Domain) => {
128
+ if (domain.name === 'react-devtools') {
129
+ disconnectBackendFromReactDevToolsInFuseboxIfNeeded();
130
+ connectToReactDevToolsInFusebox(domain);
131
+ }
132
+ },
133
+ );
78
134
 
135
+ // 3. Fallback to attempting to connect WS-based RDT frontend
79
136
  const RCTNativeAppEventEmitter = require('../EventEmitter/RCTNativeAppEventEmitter');
80
- RCTNativeAppEventEmitter.addListener('RCTDevMenuShown', connectToDevTools);
81
- connectToDevTools(); // Try connecting once on load
137
+ RCTNativeAppEventEmitter.addListener(
138
+ 'RCTDevMenuShown',
139
+ connectToWSBasedReactDevToolsFrontend,
140
+ );
141
+ connectToWSBasedReactDevToolsFrontend(); // Try connecting once on load
82
142
  }
@@ -10,7 +10,9 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const {isNativeFunction} = require('../Utilities/FeatureDetection');
13
+ const ReactNativeFeatureFlags = require('../../src/private/featureflags/ReactNativeFeatureFlags');
14
+ const NativeReactNativeFeatureFlags =
15
+ require('../../src/private/featureflags/specs/NativeReactNativeFeatureFlags').default;
14
16
  const {polyfillGlobal} = require('../Utilities/PolyfillFunctions');
15
17
 
16
18
  if (__DEV__) {
@@ -19,14 +21,6 @@ if (__DEV__) {
19
21
  }
20
22
  }
21
23
 
22
- // Currently, Hermes `Promise` is implemented via Internal Bytecode.
23
- const hasHermesPromiseQueuedToJSVM =
24
- global.HermesInternal?.hasPromise?.() === true &&
25
- global.HermesInternal?.useEngineQueue?.() === true;
26
-
27
- const hasNativePromise = isNativeFunction(Promise);
28
- const hasPromiseQueuedToJSVM = hasNativePromise || hasHermesPromiseQueuedToJSVM;
29
-
30
24
  // In bridgeless mode, timers are host functions installed from cpp.
31
25
  if (global.RN$Bridgeless !== true) {
32
26
  /**
@@ -54,15 +48,49 @@ if (global.RN$Bridgeless !== true) {
54
48
  defineLazyTimer('cancelAnimationFrame');
55
49
  defineLazyTimer('requestIdleCallback');
56
50
  defineLazyTimer('cancelIdleCallback');
51
+ } else if (
52
+ // TODO remove this condition when bridgeless == modern scheduler everywhere.
53
+ NativeReactNativeFeatureFlags != null &&
54
+ // eslint-disable-next-line react-hooks/rules-of-hooks -- false positive due to `use` prefix
55
+ ReactNativeFeatureFlags.useModernRuntimeScheduler()
56
+ ) {
57
+ polyfillGlobal(
58
+ 'requestIdleCallback',
59
+ () =>
60
+ require('../../src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks')
61
+ .default.requestIdleCallback,
62
+ );
63
+
64
+ polyfillGlobal(
65
+ 'cancelIdleCallback',
66
+ () =>
67
+ require('../../src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks')
68
+ .default.cancelIdleCallback,
69
+ );
57
70
  }
58
71
 
59
- /**
60
- * Set up immediate APIs, which is required to use the same microtask queue
61
- * as the Promise.
62
- */
63
- if (hasPromiseQueuedToJSVM) {
64
- // When promise queues to the JSVM microtasks queue, we shim the immediate
65
- // APIs via `queueMicrotask` to maintain the backward compatibility.
72
+ // We need to check if the native module is available before accessing the
73
+ // feature flag, because otherwise the API would throw an error in the legacy
74
+ // architecture in OSS, where the native module isn't available.
75
+ if (
76
+ NativeReactNativeFeatureFlags != null &&
77
+ ReactNativeFeatureFlags.enableMicrotasks()
78
+ ) {
79
+ // This is the flag that tells React to use `queueMicrotask` to batch state
80
+ // updates, instead of using the scheduler to schedule a regular task.
81
+ // We use a global variable because we don't currently have any other
82
+ // mechanism to pass feature flags from RN to React in OSS.
83
+ global.RN$enableMicrotasksInReact = true;
84
+
85
+ polyfillGlobal(
86
+ 'queueMicrotask',
87
+ () =>
88
+ require('../../src/private/webapis/microtasks/specs/NativeMicrotasks')
89
+ .default.queueMicrotask,
90
+ );
91
+
92
+ // We shim the immediate APIs via `queueMicrotask` to maintain the backward
93
+ // compatibility.
66
94
  polyfillGlobal(
67
95
  'setImmediate',
68
96
  () => require('./Timers/immediateShim').setImmediate,
@@ -72,6 +100,12 @@ if (hasPromiseQueuedToJSVM) {
72
100
  () => require('./Timers/immediateShim').clearImmediate,
73
101
  );
74
102
  } else {
103
+ // Polyfill it with promise (regardless it's polyfilled or native) otherwise.
104
+ polyfillGlobal(
105
+ 'queueMicrotask',
106
+ () => require('./Timers/queueMicrotask.js').default,
107
+ );
108
+
75
109
  // When promise was polyfilled hence is queued to the RN microtask queue,
76
110
  // we polyfill the immediate APIs as aliases to the ReactNativeMicrotask APIs.
77
111
  // Note that in bridgeless mode, immediate APIs are installed from cpp.
@@ -86,18 +120,3 @@ if (hasPromiseQueuedToJSVM) {
86
120
  );
87
121
  }
88
122
  }
89
-
90
- /**
91
- * Set up the microtask queueing API, which is required to use the same
92
- * microtask queue as the Promise.
93
- */
94
- if (hasHermesPromiseQueuedToJSVM) {
95
- // Fast path for Hermes.
96
- polyfillGlobal('queueMicrotask', () => global.HermesInternal?.enqueueJob);
97
- } else {
98
- // Polyfill it with promise (regardless it's polyfilled or native) otherwise.
99
- polyfillGlobal(
100
- 'queueMicrotask',
101
- () => require('./Timers/queueMicrotask.js').default,
102
- );
103
- }
@@ -62,9 +62,9 @@ class DebuggingOverlayRegistry {
62
62
  constructor() {
63
63
  if (reactDevToolsHook?.reactDevtoolsAgent != null) {
64
64
  this.#onReactDevToolsAgentAttached(reactDevToolsHook.reactDevtoolsAgent);
65
- return;
66
65
  }
67
66
 
67
+ // There could be cases when frontend is disconnected and then connected again for the same React Native runtime.
68
68
  reactDevToolsHook?.on?.(
69
69
  'react-devtools',
70
70
  this.#onReactDevToolsAgentAttached,