react-native-windows 0.76.3 → 0.77.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 (367) hide show
  1. package/.flowconfig +5 -1
  2. package/Libraries/ActionSheetIOS/ActionSheetIOS.d.ts +1 -0
  3. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +13 -0
  4. package/Libraries/Animated/AnimatedEvent.js +1 -1
  5. package/Libraries/Animated/AnimatedImplementation.js +2 -2
  6. package/Libraries/Animated/NativeAnimatedAllowlist.js +20 -9
  7. package/Libraries/Animated/animations/Animation.js +60 -25
  8. package/Libraries/Animated/animations/DecayAnimation.js +26 -38
  9. package/Libraries/Animated/animations/SpringAnimation.js +33 -39
  10. package/Libraries/Animated/animations/TimingAnimation.js +34 -42
  11. package/Libraries/Animated/components/AnimatedFlatList.js +1 -1
  12. package/Libraries/Animated/components/AnimatedSectionList.js +3 -1
  13. package/Libraries/Animated/createAnimatedComponent.js +60 -33
  14. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  15. package/Libraries/Animated/nodes/AnimatedInterpolation.js +1 -1
  16. package/Libraries/Animated/nodes/AnimatedNode.js +39 -45
  17. package/Libraries/Animated/nodes/AnimatedObject.js +13 -3
  18. package/Libraries/Animated/nodes/AnimatedProps.js +104 -46
  19. package/Libraries/Animated/nodes/AnimatedStyle.js +116 -39
  20. package/Libraries/Animated/nodes/AnimatedTransform.js +56 -23
  21. package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
  22. package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -3
  23. package/Libraries/Animated/useAnimatedProps.js +41 -35
  24. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
  25. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +77 -5
  26. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +82 -5
  27. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +4 -4
  28. package/Libraries/Components/Button.js +9 -4
  29. package/Libraries/Components/Button.windows.js +19 -5
  30. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +3 -1
  31. package/Libraries/Components/Glyph/Glyph.js +2 -1
  32. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +7 -0
  33. package/Libraries/Components/Popup/PopupNativeComponent.js +0 -1
  34. package/Libraries/Components/Pressable/Pressable.js +4 -4
  35. package/Libraries/Components/Pressable/Pressable.windows.js +10 -4
  36. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +13 -7
  37. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +3 -2
  38. package/Libraries/Components/SafeAreaView/SafeAreaView.js +4 -4
  39. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +0 -1
  40. package/Libraries/Components/ScrollView/ScrollView.js +49 -88
  41. package/Libraries/Components/ScrollView/ScrollViewCommands.js +1 -1
  42. package/Libraries/Components/ScrollView/ScrollViewContext.js +2 -0
  43. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +0 -2
  44. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.windows.js +0 -5
  45. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +8 -9
  46. package/Libraries/Components/Switch/Switch.js +8 -6
  47. package/Libraries/Components/Switch/Switch.windows.js +8 -6
  48. package/Libraries/Components/TextInput/InputAccessoryView.js +1 -1
  49. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +4 -4
  50. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +6 -4
  51. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +2 -1
  52. package/Libraries/Components/TextInput/TextInput.d.ts +27 -4
  53. package/Libraries/Components/TextInput/TextInput.flow.js +36 -19
  54. package/Libraries/Components/TextInput/TextInput.js +37 -13
  55. package/Libraries/Components/TextInput/TextInput.windows.js +47 -16
  56. package/Libraries/Components/TextInput/TextInputState.js +11 -13
  57. package/Libraries/Components/TextInput/TextInputState.windows.js +11 -13
  58. package/Libraries/Components/Touchable/BoundingDimensions.js +11 -3
  59. package/Libraries/Components/Touchable/Position.js +7 -2
  60. package/Libraries/Components/Touchable/Touchable.js +4 -0
  61. package/Libraries/Components/Touchable/Touchable.windows.js +4 -0
  62. package/Libraries/Components/Touchable/TouchableBounce.js +6 -2
  63. package/Libraries/Components/Touchable/TouchableBounce.windows.js +227 -0
  64. package/Libraries/Components/Touchable/TouchableHighlight.js +5 -5
  65. package/Libraries/Components/Touchable/TouchableHighlight.windows.js +5 -5
  66. package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +371 -0
  67. package/Libraries/Components/Touchable/TouchableOpacity.js +6 -5
  68. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +11 -5
  69. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -2
  70. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +9 -3
  71. package/Libraries/Components/View/ReactNativeStyleAttributes.js +6 -1
  72. package/Libraries/Components/View/View.js +4 -4
  73. package/Libraries/Components/View/View.windows.js +12 -5
  74. package/Libraries/Components/View/ViewAccessibility.d.ts +10 -0
  75. package/Libraries/Components/View/ViewAccessibility.windows.js +2 -0
  76. package/Libraries/Components/View/ViewNativeComponent.js +6 -98
  77. package/Libraries/Components/View/ViewPropTypes.d.ts +7 -0
  78. package/Libraries/Components/View/ViewPropTypes.js +0 -3
  79. package/Libraries/Components/View/ViewPropTypes.windows.js +2 -3
  80. package/Libraries/Core/ExceptionsManager.js +50 -29
  81. package/Libraries/Core/ReactNativeVersion.js +3 -3
  82. package/Libraries/Core/__mocks__/NativeExceptionsManager.js +0 -1
  83. package/Libraries/Core/setUpBatchedBridge.js +1 -10
  84. package/Libraries/Core/setUpDeveloperTools.js +1 -5
  85. package/Libraries/Core/setUpErrorHandling.js +20 -18
  86. package/Libraries/Core/setUpReactDevTools.js +107 -8
  87. package/Libraries/Core/setUpSegmentFetcher.js +1 -0
  88. package/Libraries/Core/setUpTimers.js +21 -18
  89. package/Libraries/Debugging/DebuggingOverlay.js +4 -5
  90. package/Libraries/Image/AssetSourceResolver.js +12 -1
  91. package/Libraries/Image/AssetSourceResolver.windows.js +12 -1
  92. package/Libraries/Image/Image.android.js +1 -5
  93. package/Libraries/Image/Image.d.ts +20 -29
  94. package/Libraries/Image/Image.ios.js +0 -2
  95. package/Libraries/Image/Image.windows.js +5 -1
  96. package/Libraries/Image/ImageBackground.js +2 -5
  97. package/Libraries/Image/ImageProps.js +7 -6
  98. package/Libraries/Image/ImageResizeMode.d.ts +8 -1
  99. package/Libraries/Image/ImageResizeMode.js +4 -1
  100. package/Libraries/Image/ImageSource.d.ts +0 -2
  101. package/Libraries/Image/ImageSource.js +0 -2
  102. package/Libraries/Image/ImageTypes.flow.js +11 -9
  103. package/Libraries/Image/ImageUtils.js +6 -3
  104. package/Libraries/Image/ImageViewNativeComponent.js +5 -3
  105. package/Libraries/Inspector/Inspector.js +1 -0
  106. package/Libraries/Inspector/NetworkOverlay.js +4 -0
  107. package/Libraries/Inspector/ReactDevToolsOverlay.js +8 -14
  108. package/Libraries/Inspector/getInspectorDataForViewAtPoint.js +3 -5
  109. package/Libraries/Interaction/InteractionManager.js +6 -1
  110. package/Libraries/Interaction/InteractionManagerStub.js +176 -0
  111. package/Libraries/Interaction/TouchHistoryMath.js +22 -19
  112. package/Libraries/JSInspector/NetworkAgent.js +1 -1
  113. package/Libraries/Lists/FlatList.d.ts +1 -2
  114. package/Libraries/Lists/FlatList.js +2 -2
  115. package/Libraries/Lists/SectionListModern.js +7 -7
  116. package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +2 -2
  117. package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
  118. package/Libraries/LogBox/Data/LogBoxData.js +3 -3
  119. package/Libraries/LogBox/LogBox.js +18 -5
  120. package/Libraries/LogBox/LogBoxInspectorContainer.js +1 -1
  121. package/Libraries/LogBox/LogBoxNotificationContainer.js +2 -2
  122. package/Libraries/LogBox/UI/AnsiHighlight.js +26 -17
  123. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +6 -1
  124. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.windows.js +6 -1
  125. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
  126. package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +1 -1
  127. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +1 -1
  128. package/Libraries/LogBox/UI/LogBoxMessage.js +2 -2
  129. package/Libraries/Modal/Modal.d.ts +12 -0
  130. package/Libraries/Modal/Modal.js +31 -4
  131. package/Libraries/Modal/Modal.windows.js +18 -0
  132. package/Libraries/NativeComponent/BaseViewConfig.android.js +72 -1
  133. package/Libraries/NativeComponent/BaseViewConfig.ios.js +2 -1
  134. package/Libraries/NativeComponent/BaseViewConfig.windows.js +3 -11
  135. package/Libraries/NativeComponent/NativeComponentRegistry.js +3 -3
  136. package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -1
  137. package/Libraries/Network/FormData.js +11 -3
  138. package/Libraries/Network/XHRInterceptor.js +63 -14
  139. package/Libraries/Network/XMLHttpRequest.js +26 -1
  140. package/Libraries/NewAppScreen/components/HermesBadge.js +1 -1
  141. package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +49 -2
  142. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +4 -4
  143. package/Libraries/Pressability/HoverState.js +2 -0
  144. package/Libraries/Pressability/Pressability.js +2 -3
  145. package/Libraries/Pressability/Pressability.windows.js +2 -3
  146. package/Libraries/Pressability/usePressability.js +4 -1
  147. package/Libraries/ReactNative/AppContainer.js +1 -1
  148. package/Libraries/ReactNative/AppRegistry.js +1 -11
  149. package/Libraries/ReactNative/DisplayMode.js +1 -1
  150. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -3
  151. package/Libraries/ReactNative/RendererImplementation.js +18 -17
  152. package/Libraries/ReactNative/getCachedComponentWithDebugName.js +1 -3
  153. package/Libraries/ReactNative/renderApplication.js +9 -8
  154. package/Libraries/ReactNative/requireNativeComponent.js +5 -2
  155. package/Libraries/Renderer/shims/ReactFabric.js +3 -3
  156. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -2
  157. package/Libraries/Renderer/shims/ReactNative.js +3 -3
  158. package/Libraries/Renderer/shims/ReactNativeTypes.js +22 -35
  159. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +5 -6
  160. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
  161. package/Libraries/StyleSheet/StyleSheet.js +7 -1
  162. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +13 -2
  163. package/Libraries/StyleSheet/StyleSheetTypes.js +24 -6
  164. package/Libraries/StyleSheet/processBackgroundImage.js +87 -110
  165. package/Libraries/StyleSheet/processTransform.js +3 -34
  166. package/Libraries/Text/Text.js +248 -249
  167. package/Libraries/Text/Text.windows.js +298 -292
  168. package/Libraries/Text/TextNativeComponent.js +0 -1
  169. package/Libraries/Text/TextProps.windows.js +2 -0
  170. package/Libraries/TurboModule/TurboModuleRegistry.js +5 -5
  171. package/Libraries/Types/CoreEventTypes.d.ts +3 -10
  172. package/Libraries/Types/CoreEventTypes.js +4 -6
  173. package/Libraries/Types/CoreEventTypes.windows.js +4 -6
  174. package/Libraries/Utilities/Appearance.js +3 -1
  175. package/Libraries/Utilities/BackHandler.android.js +6 -18
  176. package/Libraries/Utilities/BackHandler.d.ts +0 -4
  177. package/Libraries/Utilities/BackHandler.ios.js +0 -7
  178. package/Libraries/Utilities/BackHandler.windows.js +6 -18
  179. package/Libraries/Utilities/HMRClient.js +3 -4
  180. package/Libraries/Utilities/Platform.flow.js +2 -2
  181. package/Libraries/Utilities/Platform.flow.windows.js +3 -2
  182. package/Libraries/Utilities/__mocks__/BackHandler.js +3 -8
  183. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  184. package/Libraries/Utilities/useMergeRefs.js +26 -7
  185. package/Libraries/WebSocket/WebSocketEvent.js +4 -1
  186. package/Libraries/WebSocket/WebSocketInterceptor.js +31 -13
  187. package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +6 -5
  188. package/Libraries/promiseRejectionTrackingOptions.js +1 -1
  189. package/Microsoft.ReactNative/AsynchronousEventBeat.cpp +9 -8
  190. package/Microsoft.ReactNative/AsynchronousEventBeat.h +5 -5
  191. package/Microsoft.ReactNative/FBReactNativeSpec/FBReactNativeSpecJSI.h +5 -0
  192. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +2 -2
  193. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +197 -18
  194. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +19 -1
  195. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +13 -0
  196. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +1 -1
  197. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +6 -8
  198. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +2 -2
  199. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +3 -2
  200. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +1 -1
  201. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +24 -0
  202. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +5 -0
  203. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +12 -12
  204. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +4 -4
  205. package/Microsoft.ReactNative/Fabric/ImageRequest.cpp +4 -8
  206. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +16 -15
  207. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +15 -0
  208. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.h +9 -0
  209. package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +20 -1
  210. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +11 -6
  211. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  212. package/Microsoft.ReactNative/SynchronousEventBeat.cpp +14 -4
  213. package/Microsoft.ReactNative/SynchronousEventBeat.h +4 -2
  214. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.cpp +78 -0
  215. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.h +51 -0
  216. package/Microsoft.ReactNative.Cxx/ApiLoaders/JSRuntimeApi.inc +48 -0
  217. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.cpp +41 -0
  218. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.h +127 -0
  219. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi.inc +125 -0
  220. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_posix.cpp +16 -0
  221. package/Microsoft.ReactNative.Cxx/ApiLoaders/NodeApi_win.cpp +23 -0
  222. package/Microsoft.ReactNative.Cxx/JSI/decorator.h +834 -0
  223. package/Microsoft.ReactNative.Cxx/JSI/instrumentation.h +117 -0
  224. package/Microsoft.ReactNative.Cxx/JSI/jsi-inl.h +366 -0
  225. package/Microsoft.ReactNative.Cxx/JSI/jsi.cpp +560 -0
  226. package/Microsoft.ReactNative.Cxx/JSI/jsi.h +1611 -0
  227. package/Microsoft.ReactNative.Cxx/JSI/threadsafe.h +79 -0
  228. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +7 -11
  229. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +1 -1
  230. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.cpp +2878 -0
  231. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.h +36 -0
  232. package/Microsoft.ReactNative.Cxx/ReactCommon/CallInvoker.h +64 -0
  233. package/Microsoft.ReactNative.Cxx/ReactCommon/SchedulerPriority.h +22 -0
  234. package/{ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core → Microsoft.ReactNative.Cxx}/ReactCommon/TurboModule.cpp +63 -63
  235. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +165 -0
  236. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.cpp +105 -0
  237. package/{ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core → Microsoft.ReactNative.Cxx}/ReactCommon/TurboModuleUtils.h +57 -58
  238. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/AString.h +42 -0
  239. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Array.h +151 -0
  240. package/{ReactCommon/TEMP_UntilReactCommonUpdate → Microsoft.ReactNative.Cxx/ReactCommon}/react/bridging/Base.h +177 -154
  241. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +25 -0
  242. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bridging.h +21 -0
  243. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/CallbackWrapper.h +67 -0
  244. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +90 -0
  245. package/{ReactCommon/TEMP_UntilReactCommonUpdate → Microsoft.ReactNative.Cxx/ReactCommon}/react/bridging/Convert.h +170 -172
  246. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Error.h +51 -0
  247. package/{ReactCommon/TEMP_UntilReactCommonUpdate → Microsoft.ReactNative.Cxx/ReactCommon}/react/bridging/EventEmitter.h +134 -136
  248. package/{ReactCommon/TEMP_UntilReactCommonUpdate → Microsoft.ReactNative.Cxx/ReactCommon}/react/bridging/Function.h +283 -283
  249. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.cpp +63 -0
  250. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.h +61 -0
  251. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Object.h +93 -0
  252. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Promise.h +104 -0
  253. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Value.h +107 -0
  254. package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/flags.h +22 -0
  255. package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/react_native_assert.h +72 -0
  256. package/Microsoft.ReactNative.Cxx/node-api/js_native_api.h +553 -0
  257. package/Microsoft.ReactNative.Cxx/node-api/js_native_api_types.h +167 -0
  258. package/Microsoft.ReactNative.Cxx/node-api/js_runtime_api.h +186 -0
  259. package/Microsoft.ReactNative.Cxx/stubs/glog/logging.h +82 -0
  260. package/PropertySheets/Bundle.Common.targets +1 -1
  261. package/PropertySheets/Bundle.props +3 -0
  262. package/PropertySheets/Generated/PackageVersion.g.props +4 -4
  263. package/PropertySheets/ManagedCodeGen/Microsoft.ReactNative.Managed.CodeGen.targets +1 -1
  264. package/PropertySheets/OutputMSBuildProperties.targets +3 -1
  265. package/PropertySheets/React.Cpp.props +6 -0
  266. package/ReactCommon/ReactCommon.vcxproj +5 -0
  267. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +2 -3
  268. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +61 -0
  269. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +26 -23
  270. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +150 -0
  271. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +252 -0
  272. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +795 -0
  273. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/runtimescheduler/SchedulerPriorityUtils.h +59 -0
  274. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +227 -74
  275. package/Scripts/Microsoft.ReactNative.Managed.CodeGen.targets +1 -1
  276. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +97 -62
  277. package/Shared/InspectorPackagerConnection.cpp +3 -6
  278. package/Shared/InspectorPackagerConnection.h +2 -2
  279. package/Shared/InstanceManager.h +1 -1
  280. package/Shared/OInstance.h +1 -1
  281. package/Shared/Shared.vcxitems +17 -2
  282. package/Shared/Shared.vcxitems.filters +3 -1
  283. package/Shared/TurboModuleManager.cpp +29 -4
  284. package/codegen/NativeAccessibilityInfoSpec.g.h +27 -9
  285. package/codegen/NativeAccessibilityManagerSpec.g.h +19 -13
  286. package/codegen/NativeActionSheetManagerSpec.g.h +4 -0
  287. package/codegen/NativeExceptionsManagerSpec.g.h +1 -7
  288. package/codegen/NativeIntersectionObserverSpec.g.h +2 -0
  289. package/codegen/NativePerformanceSpec.g.h +127 -3
  290. package/codegen/NativeReactDevToolsRuntimeSettingsModuleSpec.g.h +67 -0
  291. package/codegen/NativeReactDevToolsSettingsManagerSpec.g.h +41 -0
  292. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +125 -137
  293. package/codegen/react/components/rnwcore/ComponentDescriptors.h +0 -1
  294. package/codegen/react/components/rnwcore/Props.cpp +1 -0
  295. package/codegen/react/components/rnwcore/Props.h +1 -0
  296. package/codegen/react/components/rnwcore/ShadowNodes.cpp +0 -1
  297. package/codegen/react/components/rnwcore/ShadowNodes.h +0 -11
  298. package/codegen/react/components/rnwcore/States.h +0 -12
  299. package/codegen/rnwcoreJSI-generated.cpp +219 -186
  300. package/codegen/rnwcoreJSI.h +942 -511
  301. package/index.js +10 -3
  302. package/index.windows.js +10 -3
  303. package/jest/setup.js +36 -1
  304. package/just-task.js +15 -0
  305. package/package.json +22 -22
  306. package/src/private/animated/NativeAnimatedHelper.js +18 -16
  307. package/src/private/animated/useAnimatedPropsMemo.js +356 -0
  308. package/src/private/components/HScrollViewNativeComponents.js +1 -27
  309. package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +11 -8
  310. package/src/private/components/VScrollViewNativeComponents.js +2 -25
  311. package/src/private/debugging/ReactDevToolsSettingsManager.android.js +20 -0
  312. package/src/private/debugging/ReactDevToolsSettingsManager.ios.js +30 -0
  313. package/src/private/debugging/ReactDevToolsSettingsManager.windows.js +20 -0
  314. package/src/private/{fusebox → debugging}/setUpFuseboxReactDevToolsDispatcher.js +6 -0
  315. package/src/private/devmenu/DevMenu.d.ts +20 -0
  316. package/src/private/devmenu/DevMenu.js +31 -0
  317. package/src/private/featureflags/ReactNativeFeatureFlags.js +95 -86
  318. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +8 -2
  319. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +17 -19
  320. package/src/private/fusebox/specs/NativeReactDevToolsRuntimeSettingsModule.js +34 -0
  321. package/src/private/setup/setUpDOM.js +14 -6
  322. package/src/private/setup/setUpMutationObserver.js +5 -0
  323. package/src/private/specs/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -0
  324. package/src/private/specs/components/RCTModalHostViewNativeComponent.js +8 -0
  325. package/src/private/specs/modules/NativeAccessibilityInfo.js +9 -0
  326. package/src/private/specs/modules/NativeAccessibilityManager.js +4 -0
  327. package/src/private/specs/modules/NativeActionSheetManager.js +2 -0
  328. package/src/private/specs/modules/NativeAppearance.js +4 -10
  329. package/src/private/specs/modules/NativeExceptionsManager.js +0 -12
  330. package/src/private/specs/modules/{NativeDevToolsSettingsManager.js → NativeReactDevToolsSettingsManager.js} +3 -5
  331. package/src/private/webapis/dom/geometry/DOMRect.js +2 -2
  332. package/src/private/webapis/dom/geometry/DOMRectReadOnly.js +2 -2
  333. package/src/private/webapis/dom/nodes/ReactNativeElement.js +2 -3
  334. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +102 -11
  335. package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +26 -0
  336. package/src/private/webapis/intersectionobserver/IntersectionObserverManager.js +1 -0
  337. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
  338. package/src/private/webapis/intersectionobserver/specs/__mocks__/NativeIntersectionObserver.js +9 -0
  339. package/src/private/webapis/performance/EventTiming.js +13 -8
  340. package/src/private/webapis/performance/Performance.js +66 -73
  341. package/src/private/webapis/performance/PerformanceEntry.js +2 -5
  342. package/src/private/webapis/performance/PerformanceObserver.js +65 -164
  343. package/src/private/webapis/performance/RawPerformanceEntry.js +1 -1
  344. package/src/private/webapis/performance/UserTiming.js +11 -7
  345. package/src/private/webapis/performance/Utilities.js +18 -0
  346. package/src/private/webapis/performance/specs/NativePerformance.js +71 -2
  347. package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +267 -0
  348. package/templates/cpp-lib/template.config.js +13 -7
  349. package/templates/templateUtils.js +10 -0
  350. package/types/index.d.ts +1 -1
  351. package/types/public/ReactNativeTypes.d.ts +4 -8
  352. package/Libraries/DevToolsSettings/DevToolsSettingsManager.android.js +0 -35
  353. package/Libraries/DevToolsSettings/DevToolsSettingsManager.d.ts +0 -20
  354. package/Libraries/DevToolsSettings/DevToolsSettingsManager.ios.js +0 -49
  355. package/Libraries/DevToolsSettings/DevToolsSettingsManager.windows.js +0 -35
  356. package/Libraries/DevToolsSettings/NativeDevToolsSettingsManager.js +0 -13
  357. package/Libraries/ReactNative/ReactFabricInternals.js +0 -17
  358. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +0 -101
  359. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +0 -569
  360. package/codegen/NativeDevToolsSettingsManagerSpec.g.h +0 -53
  361. package/codegen/NativePerformanceObserverSpec.g.h +0 -131
  362. package/src/private/components/useSyncOnScroll.js +0 -48
  363. package/src/private/webapis/performance/specs/NativePerformanceObserver.js +0 -61
  364. package/src/private/webapis/performance/specs/__mocks__/NativePerformance.js +0 -67
  365. package/src/private/webapis/performance/specs/__mocks__/NativePerformanceObserver.js +0 -127
  366. package/types/experimental.d.ts +0 -59
  367. /package/src/private/{fusebox → debugging}/FuseboxSessionObserver.js +0 -0
@@ -56,8 +56,8 @@ struct FabricUIManager final : public std::enable_shared_from_this<FabricUIManag
56
56
 
57
57
  private:
58
58
  void installFabricUIManager() noexcept;
59
- void initiateTransaction(facebook::react::MountingCoordinator::Shared mountingCoordinator);
60
- void performTransaction(facebook::react::MountingCoordinator::Shared const &mountingCoordinator);
59
+ void initiateTransaction(std::shared_ptr<const facebook::react::MountingCoordinator> mountingCoordinator);
60
+ void performTransaction(std::shared_ptr<const facebook::react::MountingCoordinator> const &mountingCoordinator);
61
61
  void RCTPerformMountInstructions(
62
62
  facebook::react::ShadowViewMutationList const &mutations,
63
63
  // facebook::react::RCTComponentViewRegistry* registry,
@@ -82,9 +82,9 @@ struct FabricUIManager final : public std::enable_shared_from_this<FabricUIManag
82
82
 
83
83
  // Inherited via SchedulerDelegate
84
84
  virtual void schedulerDidFinishTransaction(
85
- const facebook::react::MountingCoordinator::Shared &mountingCoordinator) override;
85
+ const std::shared_ptr<const facebook::react::MountingCoordinator> &mountingCoordinator) override;
86
86
  virtual void schedulerShouldRenderTransactions(
87
- const facebook::react::MountingCoordinator::Shared &mountingCoordinator) override;
87
+ const std::shared_ptr<const facebook::react::MountingCoordinator> &mountingCoordinator) override;
88
88
  virtual void schedulerDidRequestPreliminaryViewAllocation(const facebook::react::ShadowNode &shadowView) override;
89
89
  virtual void schedulerDidDispatchCommand(
90
90
  facebook::react::ShadowView const &shadowView,
@@ -10,15 +10,11 @@ namespace facebook::react {
10
10
  ImageRequest::ImageRequest(
11
11
  ImageSource imageSource,
12
12
  std::shared_ptr<const ImageTelemetry> telemetry,
13
+ SharedFunction<> resumeFunction,
13
14
  SharedFunction<> cancelationFunction)
14
- : imageSource_(std::move(imageSource)),
15
- telemetry_(std::move(telemetry)),
16
- cancelRequest_(std::move(cancelationFunction)) {
17
- coordinator_ = std::make_shared<ImageResponseObserverCoordinator>();
18
- }
19
-
20
- void ImageRequest::cancel() const {
21
- cancelRequest_();
15
+ : imageSource_(std::move(imageSource)), telemetry_(std::move(telemetry)) {
16
+ coordinator_ =
17
+ std::make_shared<ImageResponseObserverCoordinator>(std::move(resumeFunction), std::move(cancelationFunction));
22
18
  }
23
19
 
24
20
  const ImageSource &ImageRequest::getImageSource() const {
@@ -3,10 +3,10 @@
3
3
 
4
4
  #include "HostPlatformViewProps.h"
5
5
 
6
+ #include <react/featureflags/ReactNativeFeatureFlags.h>
6
7
  #include <react/renderer/components/view/conversions.h>
7
8
  #include <react/renderer/core/graphicsConversions.h>
8
9
  #include <react/renderer/core/propsConversions.h>
9
- #include <react/utils/CoreFeatures.h>
10
10
 
11
11
  namespace facebook::react {
12
12
 
@@ -17,36 +17,37 @@ HostPlatformViewProps::HostPlatformViewProps(
17
17
  bool shouldSetRawProps)
18
18
  : BaseViewProps(context, sourceProps, rawProps),
19
19
  windowsEvents(
20
- CoreFeatures::enablePropIteratorSetter ? sourceProps.windowsEvents
21
- : convertRawProp(context, rawProps, sourceProps.windowsEvents, {})),
20
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
21
+ ? sourceProps.windowsEvents
22
+ : convertRawProp(context, rawProps, sourceProps.windowsEvents, {})),
22
23
  enableFocusRing(
23
- CoreFeatures::enablePropIteratorSetter
24
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
24
25
  ? sourceProps.enableFocusRing
25
26
  : convertRawProp(context, rawProps, "enableFocusRing", sourceProps.enableFocusRing, true)),
26
27
  focusable(
27
- CoreFeatures::enablePropIteratorSetter
28
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
28
29
  ? sourceProps.focusable
29
30
  : convertRawProp(context, rawProps, "focusable", sourceProps.focusable, {})),
30
31
  tooltip(
31
- CoreFeatures::enablePropIteratorSetter
32
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
32
33
  ? sourceProps.tooltip
33
34
  : convertRawProp(context, rawProps, "tooltip", sourceProps.tooltip, {})),
34
35
  accessibilityPosInSet(
35
- CoreFeatures::enablePropIteratorSetter
36
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
36
37
  ? sourceProps.accessibilityPosInSet
37
38
  : convertRawProp(context, rawProps, "accessibilityPosInSet", sourceProps.accessibilityPosInSet, 0)),
38
39
  accessibilitySetSize(
39
- CoreFeatures::enablePropIteratorSetter
40
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
40
41
  ? sourceProps.accessibilitySetSize
41
42
  : convertRawProp(context, rawProps, "accessibilitySetSize", sourceProps.accessibilitySetSize, 0)),
42
43
  accessibilityLiveRegion(
43
- CoreFeatures::enablePropIteratorSetter ? sourceProps.accessibilityLiveRegion
44
- : convertRawProp(
45
- context,
46
- rawProps,
47
- "accessibilityLiveRegion",
48
- sourceProps.accessibilityLiveRegion,
49
- "none")) {}
44
+ ReactNativeFeatureFlags::enableCppPropsIteratorSetter() ? sourceProps.accessibilityLiveRegion
45
+ : convertRawProp(
46
+ context,
47
+ rawProps,
48
+ "accessibilityLiveRegion",
49
+ sourceProps.accessibilityLiveRegion,
50
+ "none")) {}
50
51
 
51
52
  #define WINDOWS_VIEW_EVENT_CASE(eventType) \
52
53
  case CONSTEXPR_RAW_PROPS_KEY_HASH("on" #eventType): { \
@@ -30,6 +30,16 @@ void AccessibilityInfo::isReduceMotionEnabled(std::function<void(bool)> const &o
30
30
  });
31
31
  }
32
32
 
33
+ void AccessibilityInfo::isInvertColorsEnabled(std::function<void(bool)> const &onSuccess) noexcept {
34
+ // TODO: implement ##14206
35
+ onSuccess(false);
36
+ }
37
+
38
+ void AccessibilityInfo::isHighTextContrastEnabled(std::function<void(bool)> const &onSuccess) noexcept {
39
+ // TODO: implement #14099
40
+ onSuccess(false);
41
+ }
42
+
33
43
  void AccessibilityInfo::isTouchExplorationEnabled(std::function<void(bool)> const &onSuccess) noexcept {
34
44
  onSuccess(UiaClientsAreListening());
35
45
  }
@@ -76,6 +86,11 @@ void AccessibilityInfo::getRecommendedTimeoutMillis(
76
86
  onSuccess(mSec);
77
87
  }
78
88
 
89
+ void AccessibilityInfo::isGrayscaleEnabled(std::function<void(bool)> const &onSuccess) noexcept {
90
+ // TODO: implement #14207
91
+ onSuccess(false);
92
+ }
93
+
79
94
  void AccessibilityInfo::isAccessibilityServiceEnabled(std::function<void(bool)> const &onSuccess) noexcept {
80
95
  onSuccess(false);
81
96
  }
@@ -17,6 +17,12 @@ struct AccessibilityInfo : public std::enable_shared_from_this<AccessibilityInfo
17
17
  REACT_METHOD(isReduceMotionEnabled)
18
18
  void isReduceMotionEnabled(std::function<void(bool)> const &onSuccess) noexcept;
19
19
 
20
+ REACT_METHOD(isInvertColorsEnabled)
21
+ void isInvertColorsEnabled(std::function<void(bool)> const &onSuccess) noexcept;
22
+
23
+ REACT_METHOD(isHighTextContrastEnabled)
24
+ void isHighTextContrastEnabled(std::function<void(bool)> const &onSuccess) noexcept;
25
+
20
26
  REACT_METHOD(isTouchExplorationEnabled)
21
27
  void isTouchExplorationEnabled(std::function<void(bool)> const &onSuccess) noexcept;
22
28
 
@@ -29,6 +35,9 @@ struct AccessibilityInfo : public std::enable_shared_from_this<AccessibilityInfo
29
35
  REACT_METHOD(getRecommendedTimeoutMillis)
30
36
  void getRecommendedTimeoutMillis(double mSec, std::function<void(double)> const &onSuccess) noexcept;
31
37
 
38
+ REACT_METHOD(isGrayscaleEnabled)
39
+ void isGrayscaleEnabled(std::function<void(bool)> const &onSuccess) noexcept;
40
+
32
41
  REACT_METHOD(isAccessibilityServiceEnabled)
33
42
  void isAccessibilityServiceEnabled(std::function<void(bool)> const &onSuccess) noexcept;
34
43
 
@@ -6,6 +6,9 @@
6
6
  #include <ReactPropertyBag.h>
7
7
  #include <winrt/Windows.Foundation.h>
8
8
 
9
+ #include <react/featureflags/ReactNativeFeatureFlags.h>
10
+ #include <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
11
+
9
12
  namespace Mso::React {
10
13
 
11
14
  //=============================================================================================
@@ -277,6 +280,18 @@ bool ReactOptions::EnableDefaultCrashHandler() const noexcept {
277
280
  return winrt::unbox_value_or<bool>(properties.Get(EnableDefaultCrashHandlerProperty()), false);
278
281
  }
279
282
 
283
+ class ReactNativeWindowsFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {
284
+ public:
285
+ bool disableEventLoopOnBridgeless() override {
286
+ return true; // Disable event loop until we are on a JSI version that supports microtasks
287
+ }
288
+
289
+ bool enableCppPropsIteratorSetter() override {
290
+ return true;
291
+ }
292
+ };
293
+
294
+ std::once_flag g_FlagInitFeatureFlags;
280
295
  //=============================================================================================
281
296
  // ReactHost implementation
282
297
  //=============================================================================================
@@ -284,7 +299,11 @@ bool ReactOptions::EnableDefaultCrashHandler() const noexcept {
284
299
  ReactHost::ReactHost(Mso::DispatchQueue const &queue) noexcept
285
300
  : Super{EnsureSerialQueue(queue)},
286
301
  m_options{Queue(), m_mutex},
287
- m_notifyWhenClosed{ReactHostRegistry::Register(*this), Queue(), m_mutex} {}
302
+ m_notifyWhenClosed{ReactHostRegistry::Register(*this), Queue(), m_mutex} {
303
+ std::call_once(g_FlagInitFeatureFlags, []() noexcept {
304
+ facebook::react::ReactNativeFeatureFlags::override(std::make_unique<ReactNativeWindowsFeatureFlags>());
305
+ });
306
+ }
288
307
 
289
308
  ReactHost::~ReactHost() noexcept {}
290
309
 
@@ -641,8 +641,10 @@ void ReactInstanceWin::InitializeBridgeless() noexcept {
641
641
  auto timerManager = std::make_shared<facebook::react::TimerManager>(std::move(timerRegistry));
642
642
  timerRegistryRaw->setTimerManager(timerManager);
643
643
 
644
- auto jsErrorHandlingFunc = [this](const facebook::react::JsErrorHandler::ParsedError &error) noexcept {
645
- OnJSError(std::move(error));
644
+ auto jsErrorHandlingFunc = [this](
645
+ facebook::jsi::Runtime &runtime,
646
+ const facebook::react::JsErrorHandler::ParsedError &error) noexcept {
647
+ OnJSError(runtime, std::move(error));
646
648
  };
647
649
 
648
650
  if (devSettings->useDirectDebugger) {
@@ -1263,16 +1265,19 @@ void ReactInstanceWin::OnError(const Mso::ErrorCode &errorCode) noexcept {
1263
1265
  }
1264
1266
 
1265
1267
  #ifdef USE_FABRIC
1266
- void ReactInstanceWin::OnJSError(const facebook::react::JsErrorHandler::ParsedError &error) noexcept {
1268
+ void ReactInstanceWin::OnJSError(
1269
+ facebook::jsi::Runtime &runtime,
1270
+ const facebook::react::JsErrorHandler::ParsedError &error) noexcept {
1267
1271
  ErrorInfo errorInfo;
1268
1272
  errorInfo.Message = error.message;
1269
1273
  auto errorCode = Mso::React::ReactErrorProvider().MakeErrorCode(Mso::React::ReactError{errorInfo.Message.c_str()});
1270
1274
 
1271
- for (const facebook::react::JsErrorHandler::ParsedError::StackFrame &frame : error.frames) {
1272
- errorInfo.Callstack.push_back({frame.fileName, frame.methodName, frame.lineNumber, frame.columnNumber});
1275
+ for (const facebook::react::JsErrorHandler::ParsedError::StackFrame &frame : error.stack) {
1276
+ errorInfo.Callstack.push_back(
1277
+ {frame.file.value(), frame.methodName, frame.lineNumber.value(), frame.column.value()});
1273
1278
  }
1274
1279
 
1275
- errorInfo.Id = error.exceptionId;
1280
+ errorInfo.Id = error.id;
1276
1281
 
1277
1282
  bool isFatal = error.isFatal;
1278
1283
 
@@ -141,7 +141,7 @@ class ReactInstanceWin final : public Mso::ActiveObject<IReactInstanceInternal>
141
141
  void OnError(const Mso::ErrorCode &errorcode) noexcept;
142
142
  void OnErrorWithMessage(const std::string &errorMessage) noexcept;
143
143
  #ifdef USE_FABRIC
144
- void OnJSError(const facebook::react::JsErrorHandler::ParsedError &error) noexcept;
144
+ void OnJSError(facebook::jsi::Runtime &runtime, const facebook::react::JsErrorHandler::ParsedError &error) noexcept;
145
145
  #endif
146
146
  void OnLiveReload() noexcept;
147
147
  void OnWaitingForDebugger() noexcept;
@@ -6,17 +6,27 @@
6
6
  namespace Microsoft::ReactNative {
7
7
 
8
8
  SynchronousEventBeat::SynchronousEventBeat(
9
- facebook::react::EventBeat::SharedOwnerBox const &ownerBox,
9
+ std::shared_ptr<facebook::react::EventBeat::OwnerBox> const ownerBox,
10
10
  const winrt::Microsoft::ReactNative::ReactContext &context,
11
11
  facebook::react::RuntimeExecutor runtimeExecutor,
12
12
  std::shared_ptr<facebook::react::RuntimeScheduler> runtimeScheduler)
13
- : EventBeat(ownerBox),
13
+ : EventBeat(ownerBox, *runtimeScheduler),
14
14
  m_context(context),
15
15
  m_runtimeExecutor(runtimeExecutor),
16
16
  m_runtimeScheduler(std::move(runtimeScheduler)) {}
17
17
 
18
+ void SynchronousEventBeat::beat(facebook::jsi::Runtime &runtime) const {
19
+ if (!this->isEventBeatRequested_) {
20
+ return;
21
+ }
22
+ isEventBeatRequested_ = false;
23
+ if (beatCallback_) {
24
+ beatCallback_(runtime);
25
+ }
26
+ }
27
+
18
28
  void SynchronousEventBeat::induce() const {
19
- if (!isRequested_) {
29
+ if (!isEventBeatRequested_) {
20
30
  return;
21
31
  }
22
32
 
@@ -26,7 +36,7 @@ void SynchronousEventBeat::induce() const {
26
36
  }
27
37
 
28
38
  void SynchronousEventBeat::lockExecutorAndBeat() const {
29
- if (!this->isRequested_) {
39
+ if (!this->isEventBeatRequested_) {
30
40
  return;
31
41
  }
32
42
 
@@ -11,12 +11,14 @@ namespace Microsoft::ReactNative {
11
11
  class SynchronousEventBeat final : public facebook::react::EventBeat {
12
12
  public:
13
13
  SynchronousEventBeat(
14
- facebook::react::EventBeat::SharedOwnerBox const &ownerBox,
14
+ std::shared_ptr<facebook::react::EventBeat::OwnerBox> const ownerBox,
15
15
  const winrt::Microsoft::ReactNative::ReactContext &context,
16
16
  facebook::react::RuntimeExecutor runtimeExecutor,
17
17
  std::shared_ptr<facebook::react::RuntimeScheduler> runtimeScheduler);
18
18
 
19
- void induce() const override;
19
+ void beat(facebook::jsi::Runtime &runtime) const;
20
+
21
+ void induce() const;
20
22
 
21
23
  void lockExecutorAndBeat() const;
22
24
 
@@ -0,0 +1,78 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "JSRuntimeApi.h"
5
+
6
+ EXTERN_C_START
7
+
8
+ // Default JSR function implementations if they are not found in the engine DLL.
9
+ extern napi_status NAPI_CDECL default_jsr_open_napi_env_scope(napi_env env, jsr_napi_env_scope *scope);
10
+ extern napi_status NAPI_CDECL default_jsr_close_napi_env_scope(napi_env env, jsr_napi_env_scope scope);
11
+ extern napi_status NAPI_CDECL default_jsr_get_description(napi_env env, const char **result);
12
+ extern napi_status NAPI_CDECL default_jsr_drain_microtasks(napi_env env, int32_t max_count_hint, bool *result);
13
+ extern napi_status NAPI_CDECL default_jsr_is_inspectable(napi_env env, bool *result);
14
+
15
+ extern napi_status NAPI_CDECL default_jsr_create_prepared_script(
16
+ napi_env env,
17
+ const uint8_t *script_utf8,
18
+ size_t script_length,
19
+ jsr_data_delete_cb script_delete_cb,
20
+ void *deleter_data,
21
+ const char *source_url,
22
+ jsr_prepared_script *result);
23
+ extern napi_status NAPI_CDECL default_jsr_delete_prepared_script(napi_env env, jsr_prepared_script prepared_script);
24
+ extern napi_status NAPI_CDECL
25
+ default_jsr_prepared_script_run(napi_env env, jsr_prepared_script prepared_script, napi_value *result);
26
+
27
+ EXTERN_C_END
28
+
29
+ namespace Microsoft::NodeApiJsi {
30
+
31
+ namespace {
32
+
33
+ struct JSRuntimeApiNames {
34
+ #define JSR_FUNC(func) static constexpr const char func[] = #func;
35
+ #define JSR_JSI_FUNC JSR_FUNC
36
+ #define JSR_PREPARED_SCRIPT JSR_FUNC
37
+ #include "JSRuntimeApi.inc"
38
+ };
39
+
40
+ // Prepared script functions either should be all loaded or we use all default functions.
41
+ void loadPreparedScriptFuncs() {
42
+ JSRuntimeApi *current = JSRuntimeApi::current();
43
+ bool useDefault = false;
44
+ #define JSR_PREPARED_SCRIPT(func) \
45
+ decltype(::func) *loaded_##func = \
46
+ reinterpret_cast<decltype(::func) *>(current->getFuncPtr(JSRuntimeApiNames::func)); \
47
+ useDefault = useDefault || loaded_##func == nullptr;
48
+ #include "JSRuntimeApi.inc"
49
+ #define JSR_PREPARED_SCRIPT(func) \
50
+ size_t offset_##func = offsetof(JSRuntimeApi, func); \
51
+ *reinterpret_cast<decltype(::func) **>(reinterpret_cast<char *>(current) + offset_##func) = \
52
+ useDefault ? &default_##func : loaded_##func;
53
+ #include "JSRuntimeApi.inc"
54
+ }
55
+
56
+ } // namespace
57
+
58
+ thread_local JSRuntimeApi *JSRuntimeApi::current_{};
59
+
60
+ JSRuntimeApi::JSRuntimeApi(IFuncResolver *funcResolver)
61
+ : NodeApi(funcResolver)
62
+ #define JSR_FUNC(func) \
63
+ , \
64
+ func(&ApiFuncResolver<JSRuntimeApi, decltype(::func) *, JSRuntimeApiNames::func, offsetof(JSRuntimeApi, func)>:: \
65
+ stub)
66
+ #define JSR_JSI_FUNC(func) \
67
+ , \
68
+ func(&ApiFuncResolver<JSRuntimeApi, decltype(::func) *, JSRuntimeApiNames::func, offsetof(JSRuntimeApi, func)>:: \
69
+ optionalStub<&default_##func>)
70
+ #define JSR_PREPARED_SCRIPT(func) \
71
+ , \
72
+ func(&ApiFuncResolver<JSRuntimeApi, decltype(::func) *, JSRuntimeApiNames::func, offsetof(JSRuntimeApi, func)>:: \
73
+ preloadStub<&loadPreparedScriptFuncs>)
74
+ #include "JSRuntimeApi.inc"
75
+ {
76
+ }
77
+
78
+ } // namespace Microsoft::NodeApiJsi
@@ -0,0 +1,51 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #ifndef APILOADERS_JSRUNTIMEAPI_H_
5
+ #define APILOADERS_JSRUNTIMEAPI_H_
6
+
7
+ #include <js_runtime_api.h>
8
+ #include "NodeApi.h"
9
+
10
+ namespace Microsoft::NodeApiJsi {
11
+
12
+ class JSRuntimeApi : public NodeApi {
13
+ public:
14
+ JSRuntimeApi(IFuncResolver *funcResolver);
15
+
16
+ static JSRuntimeApi *current() {
17
+ return current_;
18
+ }
19
+
20
+ static void setCurrent(JSRuntimeApi *current) {
21
+ NodeApi::setCurrent(current);
22
+ current_ = current;
23
+ }
24
+
25
+ class Scope : public NodeApi::Scope {
26
+ public:
27
+ Scope(JSRuntimeApi *api) : NodeApi::Scope(api), prevJSRuntimeApi_(JSRuntimeApi::current_) {
28
+ JSRuntimeApi::current_ = api;
29
+ }
30
+
31
+ ~Scope() {
32
+ JSRuntimeApi::current_ = prevJSRuntimeApi_;
33
+ }
34
+
35
+ private:
36
+ JSRuntimeApi *prevJSRuntimeApi_;
37
+ };
38
+
39
+ public:
40
+ #define JSR_FUNC(func) decltype(::func) *const func;
41
+ #define JSR_JSI_FUNC JSR_FUNC
42
+ #define JSR_PREPARED_SCRIPT JSR_FUNC
43
+ #include "JSRuntimeApi.inc"
44
+
45
+ private:
46
+ static thread_local JSRuntimeApi *current_;
47
+ };
48
+
49
+ } // namespace Microsoft::NodeApiJsi
50
+
51
+ #endif // !APILOADERS_JSRUNTIMEAPI_H_
@@ -0,0 +1,48 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #ifndef JSR_FUNC
5
+ #define JSR_FUNC(func)
6
+ #endif
7
+
8
+ #ifndef JSR_JSI_FUNC
9
+ #define JSR_JSI_FUNC(func)
10
+ #endif
11
+
12
+ #ifndef JSR_PREPARED_SCRIPT
13
+ #define JSR_PREPARED_SCRIPT(func)
14
+ #endif
15
+
16
+ // The JS runtime functions sorted alphabetically.
17
+ JSR_FUNC(jsr_collect_garbage)
18
+ JSR_FUNC(jsr_config_enable_gc_api)
19
+ JSR_FUNC(jsr_config_enable_inspector)
20
+ JSR_FUNC(jsr_config_set_inspector_break_on_start)
21
+ JSR_FUNC(jsr_config_set_inspector_port)
22
+ JSR_FUNC(jsr_config_set_inspector_runtime_name)
23
+ JSR_FUNC(jsr_config_set_script_cache)
24
+ JSR_FUNC(jsr_config_set_task_runner)
25
+ JSR_FUNC(jsr_create_config)
26
+ JSR_FUNC(jsr_create_runtime)
27
+ JSR_FUNC(jsr_delete_config)
28
+ JSR_FUNC(jsr_delete_runtime)
29
+ JSR_FUNC(jsr_get_and_clear_last_unhandled_promise_rejection)
30
+ JSR_FUNC(jsr_has_unhandled_promise_rejection)
31
+ JSR_FUNC(jsr_run_script)
32
+ JSR_FUNC(jsr_runtime_get_node_api_env)
33
+
34
+ // The JS runtime functions needed for JSI.
35
+ JSR_JSI_FUNC(jsr_close_napi_env_scope)
36
+ JSR_JSI_FUNC(jsr_drain_microtasks)
37
+ JSR_JSI_FUNC(jsr_get_description)
38
+ JSR_JSI_FUNC(jsr_is_inspectable)
39
+ JSR_JSI_FUNC(jsr_open_napi_env_scope)
40
+
41
+ // The JS runtime functions needed for prepared script.
42
+ JSR_PREPARED_SCRIPT(jsr_create_prepared_script)
43
+ JSR_PREPARED_SCRIPT(jsr_delete_prepared_script)
44
+ JSR_PREPARED_SCRIPT(jsr_prepared_script_run)
45
+
46
+ #undef JSR_FUNC
47
+ #undef JSR_JSI_FUNC
48
+ #undef JSR_PREPARED_SCRIPT
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "NodeApi.h"
5
+
6
+ namespace Microsoft::NodeApiJsi {
7
+
8
+ namespace {
9
+
10
+ struct NodeApiNames {
11
+ #define NODE_API_FUNC(func) static constexpr const char func[] = #func;
12
+ #include "NodeApi.inc"
13
+ };
14
+
15
+ } // namespace
16
+
17
+ LibFuncResolver::LibFuncResolver(const char *libName) : libHandle_(LibLoader::loadLib(libName)) {}
18
+
19
+ FuncPtr LibFuncResolver::getFuncPtr(const char *funcName) {
20
+ return LibLoader::getFuncPtr(libHandle_, funcName);
21
+ }
22
+
23
+ DelayLoadedApi::DelayLoadedApi(IFuncResolver *funcResolver) : funcResolver_(funcResolver) {}
24
+
25
+ DelayLoadedApi::~DelayLoadedApi() = default;
26
+
27
+ FuncPtr DelayLoadedApi::getFuncPtr(const char *funcName) {
28
+ return funcResolver_->getFuncPtr(funcName);
29
+ }
30
+
31
+ thread_local NodeApi *NodeApi::current_{};
32
+
33
+ NodeApi::NodeApi(IFuncResolver *funcResolver)
34
+ : DelayLoadedApi(funcResolver)
35
+ #define NODE_API_FUNC(func) \
36
+ , func(&ApiFuncResolver<NodeApi, decltype(::func) *, NodeApiNames::func, offsetof(NodeApi, func)>::stub)
37
+ #include "NodeApi.inc"
38
+ {
39
+ }
40
+
41
+ } // namespace Microsoft::NodeApiJsi
@@ -0,0 +1,127 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+ #ifndef APILOADERS_NODEAPI_H_
6
+ #define APILOADERS_NODEAPI_H_
7
+
8
+ #include <js_native_api.h>
9
+
10
+ namespace Microsoft::NodeApiJsi {
11
+
12
+ using LibHandle = struct LibHandle_t *;
13
+ using FuncPtr = struct FuncPtr_t *;
14
+
15
+ class LibLoader {
16
+ public:
17
+ static LibHandle loadLib(const char *libName);
18
+ static FuncPtr getFuncPtr(LibHandle libHandle, const char *funcName);
19
+ };
20
+
21
+ template <typename TApi, typename T, const char *funcName, size_t offset>
22
+ struct ApiFuncResolver;
23
+
24
+ template <typename TApi, typename TResult, const char *funcName, size_t offset, typename... TArgs>
25
+ struct ApiFuncResolver<TApi, TResult(NAPI_CDECL *)(TArgs...), funcName, offset> {
26
+ // Stub is a special function that loads the targeting function on the first call,
27
+ // replaces function pointer field with the loaded function, and executes the function.
28
+ // After this all future calls to the loaded function are going to be directly from
29
+ // the field and not use this Stub.
30
+ static TResult NAPI_CDECL stub(TArgs... args) {
31
+ using TFunc = TResult(NAPI_CDECL *)(TArgs...);
32
+ TApi *current = TApi::current();
33
+ TFunc func = reinterpret_cast<TFunc>(current->getFuncPtr(funcName));
34
+ *reinterpret_cast<TFunc *>(reinterpret_cast<char *>(current) + offset) = func;
35
+ return (*func)(args...);
36
+ }
37
+
38
+ // Optional stub tries to load target function on the first call and set it
39
+ // as the function pointer. If loading fails, then it uses provided default
40
+ // function implementation. The default function can either do the required
41
+ // work or return a failure.
42
+ template <TResult(NAPI_CDECL *defaultFunc)(TArgs...)>
43
+ static TResult NAPI_CDECL optionalStub(TArgs... args) {
44
+ using TFunc = TResult(NAPI_CDECL *)(TArgs...);
45
+ TApi *current = TApi::current();
46
+ TFunc func = reinterpret_cast<TFunc>(current->getFuncPtr(funcName));
47
+ if (func == nullptr) {
48
+ func = defaultFunc;
49
+ }
50
+ *reinterpret_cast<TFunc *>(reinterpret_cast<char *>(current) + offset) = func;
51
+ return (*func)(args...);
52
+ }
53
+
54
+ template <void (*preloadFunc)()>
55
+ static TResult NAPI_CDECL preloadStub(TArgs... args) {
56
+ using TFunc = TResult(NAPI_CDECL *)(TArgs...);
57
+ preloadFunc();
58
+ TApi *current = TApi::current();
59
+ TFunc func = *reinterpret_cast<TFunc *>(reinterpret_cast<char *>(current) + offset);
60
+ return (*func)(args...);
61
+ }
62
+ };
63
+
64
+ struct IFuncResolver {
65
+ virtual FuncPtr getFuncPtr(const char *funcName) = 0;
66
+ };
67
+
68
+ class LibFuncResolver : public IFuncResolver {
69
+ public:
70
+ LibFuncResolver(const char *libName);
71
+ FuncPtr getFuncPtr(const char *funcName) override;
72
+
73
+ private:
74
+ LibHandle libHandle_;
75
+ };
76
+
77
+ class DelayLoadedApi {
78
+ public:
79
+ DelayLoadedApi(IFuncResolver *funcResolver);
80
+ ~DelayLoadedApi();
81
+
82
+ FuncPtr getFuncPtr(const char *funcName);
83
+
84
+ DelayLoadedApi(const DelayLoadedApi &) = delete;
85
+ DelayLoadedApi &operator=(const DelayLoadedApi &) = delete;
86
+
87
+ private:
88
+ IFuncResolver *funcResolver_;
89
+ };
90
+
91
+ class NodeApi : public DelayLoadedApi {
92
+ public:
93
+ NodeApi(IFuncResolver *funcResolver);
94
+
95
+ static NodeApi *current() {
96
+ return current_;
97
+ }
98
+
99
+ static void setCurrent(NodeApi *current) {
100
+ current_ = current;
101
+ }
102
+
103
+ class Scope {
104
+ public:
105
+ Scope(NodeApi *nodeApi) : prevNodeApi_(NodeApi::current_) {
106
+ NodeApi::current_ = nodeApi;
107
+ }
108
+
109
+ ~Scope() {
110
+ NodeApi::current_ = prevNodeApi_;
111
+ }
112
+
113
+ private:
114
+ NodeApi *prevNodeApi_;
115
+ };
116
+
117
+ public:
118
+ #define NODE_API_FUNC(func) decltype(::func) *const func;
119
+ #include "NodeApi.inc"
120
+
121
+ private:
122
+ static thread_local NodeApi *current_;
123
+ };
124
+
125
+ } // namespace Microsoft::NodeApiJsi
126
+
127
+ #endif // !APILOADERS_NODEAPI_H_