react-native-windows 0.68.1 → 0.69.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (392) hide show
  1. package/.flowconfig +1 -3
  2. package/Chakra/ChakraHelpers.cpp +0 -1
  3. package/Directory.Build.props +3 -0
  4. package/Directory.Build.targets +1 -1
  5. package/Folly/TEMP_UntilFollyUpdate/dynamic-inl.h +1411 -0
  6. package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.cpp +336 -0
  7. package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.h +182 -0
  8. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -0
  9. package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
  10. package/Libraries/Alert/Alert.windows.js +2 -2
  11. package/Libraries/Animated/AnimatedImplementation.js +1 -1
  12. package/Libraries/Animated/NativeAnimatedHelper.js +55 -9
  13. package/Libraries/Animated/NativeAnimatedModule.js +1 -0
  14. package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
  15. package/Libraries/Animated/animations/TimingAnimation.js +6 -11
  16. package/Libraries/Animated/createAnimatedComponent.js +2 -2
  17. package/Libraries/Animated/nodes/AnimatedColor.js +95 -29
  18. package/Libraries/Animated/nodes/AnimatedInterpolation.js +19 -22
  19. package/Libraries/Animated/nodes/AnimatedNode.js +2 -2
  20. package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
  21. package/Libraries/AppState/AppState.js +1 -1
  22. package/Libraries/Blob/URL.js +7 -1
  23. package/Libraries/Components/Button.js +3 -0
  24. package/Libraries/Components/Button.windows.js +4 -0
  25. package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +5 -0
  26. package/Libraries/Components/Pressable/Pressable.js +3 -3
  27. package/Libraries/Components/Pressable/Pressable.windows.js +3 -3
  28. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +47 -38
  29. package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +15 -7
  30. package/Libraries/Components/ScrollView/ScrollView.js +1 -1
  31. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +16 -3
  32. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +3 -1
  33. package/Libraries/Components/Slider/Slider.js +0 -2
  34. package/Libraries/Components/Slider/SliderNativeComponent.js +0 -1
  35. package/Libraries/Components/StatusBar/StatusBar.js +6 -1
  36. package/Libraries/Components/Switch/Switch.js +11 -1
  37. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +114 -109
  38. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +17 -9
  39. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +13 -5
  40. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +10 -0
  41. package/Libraries/Components/TextInput/TextInput.js +1 -8
  42. package/Libraries/Components/TextInput/TextInput.windows.js +4 -9
  43. package/Libraries/Components/TextInput/TextInputState.js +10 -2
  44. package/Libraries/Components/TextInput/TextInputState.windows.js +10 -3
  45. package/Libraries/Components/TextInput/WindowsTextInputNativeComponent.js +1 -1
  46. package/Libraries/Components/Touchable/TouchableBounce.js +1 -0
  47. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -0
  48. package/Libraries/Components/Touchable/TouchableHighlight.windows.js +6 -5
  49. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -0
  50. package/Libraries/Components/Touchable/TouchableOpacity.js +7 -1
  51. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +11 -5
  52. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -0
  53. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +2 -0
  54. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  55. package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +1 -0
  56. package/Libraries/Components/View/View.windows.js +33 -1
  57. package/Libraries/Components/View/ViewNativeComponent.js +68 -8
  58. package/Libraries/Components/View/ViewPropTypes.js +36 -4
  59. package/Libraries/Components/View/ViewPropTypes.windows.js +36 -4
  60. package/Libraries/Core/Devtools/parseHermesStack.js +1 -1
  61. package/Libraries/Core/ExceptionsManager.js +1 -1
  62. package/Libraries/Core/RawEventEmitter.js +38 -0
  63. package/Libraries/Core/ReactNativeVersion.js +2 -2
  64. package/Libraries/Core/polyfillPromise.js +32 -0
  65. package/Libraries/Core/setUpReactDevTools.js +3 -2
  66. package/Libraries/EventEmitter/NativeEventEmitter.js +3 -3
  67. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -1
  68. package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +3 -3
  69. package/Libraries/Events/CustomEvent.js +32 -0
  70. package/Libraries/Events/EventPolyfill.js +239 -0
  71. package/Libraries/Image/Image.android.js +0 -6
  72. package/Libraries/Image/Image.ios.js +0 -6
  73. package/Libraries/Image/Image.windows.js +2 -8
  74. package/Libraries/Image/ImageViewNativeComponent.js +18 -3
  75. package/Libraries/Image/TextInlineImageNativeComponent.js +23 -15
  76. package/Libraries/Inspector/Inspector.js +2 -4
  77. package/Libraries/Interaction/BridgeSpyStallHandler.js +4 -3
  78. package/Libraries/Interaction/InteractionManager.js +1 -12
  79. package/Libraries/Interaction/TaskQueue.js +5 -4
  80. package/Libraries/LayoutAnimation/LayoutAnimation.js +13 -0
  81. package/Libraries/Linking/Linking.js +1 -1
  82. package/Libraries/Lists/FlatList.js +27 -6
  83. package/Libraries/Lists/VirtualizedList.js +71 -55
  84. package/Libraries/Lists/VirtualizedListContext.js +7 -3
  85. package/Libraries/Lists/VirtualizedSectionList.js +2 -2
  86. package/Libraries/Lists/__tests__/{FillRateHelper-test.windows.js → FillRateHelper-test.js} +2 -2
  87. package/Libraries/Lists/__tests__/{FlatList-test.windows.js → FlatList-test.js} +2 -2
  88. package/Libraries/Lists/__tests__/{SectionList-test.windows.js → SectionList-test.js} +14 -14
  89. package/Libraries/Lists/__tests__/{VirtualizeUtils-test.windows.js → VirtualizeUtils-test.js} +3 -3
  90. package/Libraries/Lists/__tests__/{VirtualizedList-test.windows.js → VirtualizedList-test.js} +91 -42
  91. package/Libraries/Lists/__tests__/{VirtualizedSectionList-test.windows.js → VirtualizedSectionList-test.js} +13 -13
  92. package/Libraries/LogBox/Data/LogBoxData.js +2 -2
  93. package/Libraries/LogBox/Data/LogBoxLog.js +1 -1
  94. package/Libraries/LogBox/Data/LogBoxSymbolication.js +1 -1
  95. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  96. package/Libraries/LogBox/LogBox.js +2 -21
  97. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -0
  98. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +2 -1
  99. package/Libraries/NativeComponent/BaseViewConfig.android.js +295 -0
  100. package/Libraries/NativeComponent/BaseViewConfig.ios.js +333 -0
  101. package/Libraries/NativeComponent/BaseViewConfig.windows.js +334 -0
  102. package/Libraries/NativeComponent/NativeComponentRegistry.js +0 -2
  103. package/Libraries/NativeComponent/PlatformBaseViewConfig.js +24 -0
  104. package/Libraries/NativeComponent/StaticViewConfigValidator.js +7 -42
  105. package/Libraries/NativeComponent/ViewConfig.js +4 -4
  106. package/Libraries/NativeComponent/ViewConfigIgnore.js +54 -0
  107. package/Libraries/Network/FormData.js +7 -1
  108. package/Libraries/Pressability/Pressability.js +115 -46
  109. package/Libraries/Pressability/Pressability.windows.js +190 -74
  110. package/Libraries/Pressability/PressabilityDebug.js +5 -9
  111. package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
  112. package/Libraries/ReactNative/AppContainer.js +1 -1
  113. package/Libraries/ReactNative/{DummyUIManager.js → BridgelessUIManager.js} +62 -40
  114. package/Libraries/ReactNative/PaperUIManager.windows.js +5 -5
  115. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +39 -0
  116. package/Libraries/ReactNative/UIManager.js +2 -3
  117. package/Libraries/ReactNative/renderApplication.js +4 -0
  118. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +8 -0
  119. package/Libraries/Renderer/implementations/ReactFabric-dev.js +5908 -4906
  120. package/Libraries/Renderer/implementations/ReactFabric-prod.js +2100 -1918
  121. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +2567 -2352
  122. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5610 -4844
  123. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1710 -1556
  124. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1830 -1639
  125. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
  126. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -1
  127. package/Libraries/StyleSheet/EdgeInsetsPropType.js +4 -1
  128. package/Libraries/StyleSheet/StyleSheetTypes.js +59 -66
  129. package/Libraries/StyleSheet/normalizeColor.js +1 -1
  130. package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +15 -0
  131. package/Libraries/StyleSheet/private/_TransformStyle.js +53 -0
  132. package/Libraries/StyleSheet/processTransform.windows.js +272 -0
  133. package/Libraries/Text/Text.js +13 -7
  134. package/Libraries/Text/Text.windows.js +16 -7
  135. package/Libraries/Text/TextNativeComponent.js +2 -0
  136. package/Libraries/Text/TextProps.js +10 -0
  137. package/Libraries/Types/CoreEventTypes.js +13 -1
  138. package/Libraries/Types/CoreEventTypes.windows.js +26 -1
  139. package/Libraries/Utilities/Appearance.js +0 -8
  140. package/Libraries/Utilities/HMRClient.js +1 -1
  141. package/Libraries/Utilities/ReactNativeTestTools.js +1 -0
  142. package/Libraries/Utilities/codegenNativeComponent.js +17 -6
  143. package/Libraries/Utilities/stringifySafe.js +4 -1
  144. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +3 -3
  145. package/Libraries/WebSocket/WebSocket.js +1 -1
  146. package/Libraries/vendor/emitter/_EmitterSubscription.js +1 -1
  147. package/Libraries/vendor/emitter/_EventEmitter.js +1 -1
  148. package/Libraries/vendor/emitter/_EventSubscription.js +1 -1
  149. package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +1 -4
  150. package/Microsoft.ReactNative/DynamicReader.cpp +3 -3
  151. package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -0
  152. package/Microsoft.ReactNative/Fabric/ComponentViewRegistry.cpp +36 -2
  153. package/Microsoft.ReactNative/Fabric/ComponentViewRegistry.h +1 -0
  154. package/Microsoft.ReactNative/Fabric/DWriteHelpers.cpp +19 -0
  155. package/Microsoft.ReactNative/Fabric/DWriteHelpers.h +13 -0
  156. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +65 -19
  157. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +2 -0
  158. package/Microsoft.ReactNative/Fabric/ParagraphComponentView.cpp +36 -10
  159. package/Microsoft.ReactNative/Fabric/ScrollViewComponentView.cpp +2 -0
  160. package/Microsoft.ReactNative/Fabric/SliderComponentView.cpp +107 -0
  161. package/Microsoft.ReactNative/Fabric/SliderComponentView.h +51 -0
  162. package/Microsoft.ReactNative/Fabric/SwitchComponentView.cpp +109 -0
  163. package/Microsoft.ReactNative/Fabric/SwitchComponentView.h +52 -0
  164. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentDescriptor.h +197 -0
  165. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentView.cpp +308 -0
  166. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentView.h +52 -0
  167. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputEventEmitter.cpp +31 -0
  168. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputEventEmitter.h +33 -0
  169. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputProps.cpp +81 -0
  170. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputProps.h +132 -0
  171. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputShadowNode.cpp +193 -0
  172. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputShadowNode.h +85 -0
  173. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputState.cpp +76 -0
  174. package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputState.h +99 -0
  175. package/Microsoft.ReactNative/Fabric/ViewComponentView.cpp +35 -3
  176. package/Microsoft.ReactNative/Fabric/ViewComponentView.h +1 -0
  177. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/rncore/EventEmitters.h +5 -0
  178. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/rncore/Props.h +5 -0
  179. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/slider/SliderMeasurementsManager.cpp +46 -0
  180. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/slider/SliderMeasurementsManager.h +30 -0
  181. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Color.cpp +2 -0
  182. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/conversions.h +1 -9
  183. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h +3 -1
  184. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +119 -57
  185. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +18 -1
  186. package/Microsoft.ReactNative/IViewManager.idl +3 -3
  187. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +13 -107
  188. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +2 -2
  189. package/Microsoft.ReactNative/Modules/AppStateModule.cpp +2 -0
  190. package/Microsoft.ReactNative/Modules/AppStateModule.h +2 -0
  191. package/Microsoft.ReactNative/Modules/CreateModules.cpp +3 -3
  192. package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +7 -5
  193. package/Microsoft.ReactNative/Modules/TimingModule.cpp +2 -2
  194. package/Microsoft.ReactNative/Modules/TimingModule.h +2 -2
  195. package/Microsoft.ReactNative/ReactHost/{ReactContext.cpp → MsoReactContext.cpp} +1 -1
  196. package/Microsoft.ReactNative/ReactHost/{ReactContext.h → MsoReactContext.h} +0 -0
  197. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +15 -2
  198. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  199. package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -1
  200. package/Microsoft.ReactNative/ReactInstanceSettings.idl +12 -2
  201. package/Microsoft.ReactNative/ReactPackageBuilder.cpp +1 -1
  202. package/Microsoft.ReactNative/ReactRootView.cpp +2 -1
  203. package/Microsoft.ReactNative/RedBox.cpp +3 -2
  204. package/Microsoft.ReactNative/TurboModulesProvider.cpp +3 -2
  205. package/Microsoft.ReactNative/TurboModulesProvider.h +4 -1
  206. package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +41 -0
  207. package/Microsoft.ReactNative/Utils/ValueUtils.cpp +3 -2
  208. package/Microsoft.ReactNative/Views/ControlViewManager.cpp +32 -0
  209. package/Microsoft.ReactNative/Views/ControlViewManager.h +11 -0
  210. package/Microsoft.ReactNative/Views/DevMenu.cpp +2 -2
  211. package/Microsoft.ReactNative/Views/FrameworkElementTransferProperties.cpp +13 -2
  212. package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +149 -22
  213. package/Microsoft.ReactNative/Views/Image/ImageViewManager.cpp +1 -1
  214. package/Microsoft.ReactNative/Views/Image/Microsoft.UI.Composition.Effects_Impl.h +5 -11
  215. package/Microsoft.ReactNative/Views/Image/ReactImage.cpp +2 -1
  216. package/Microsoft.ReactNative/Views/SliderViewManager.cpp +12 -4
  217. package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +1 -1
  218. package/Microsoft.ReactNative/Views/TextViewManager.cpp +2 -2
  219. package/Microsoft.ReactNative/Views/TouchEventHandler.cpp +163 -37
  220. package/Microsoft.ReactNative/Views/TouchEventHandler.h +11 -4
  221. package/Microsoft.ReactNative/Views/ViewPanel.cpp +3 -23
  222. package/Microsoft.ReactNative/Views/ViewPanel.h +2 -3
  223. package/Microsoft.ReactNative/Views/ViewViewManager.cpp +21 -0
  224. package/Microsoft.ReactNative/XamlUIService.cpp +1 -1
  225. package/Microsoft.ReactNative/XamlView.h +8 -3
  226. package/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h +3 -5
  227. package/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h +1 -1
  228. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +11 -2
  229. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +1 -0
  230. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +19 -14
  231. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +4 -0
  232. package/Microsoft.ReactNative.Cxx/JSValueReader.h +2 -2
  233. package/Microsoft.ReactNative.Cxx/JSValueWriter.h +5 -5
  234. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +5 -1
  235. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +2 -3
  236. package/Microsoft.ReactNative.Cxx/NativeModules.h +3 -3
  237. package/Microsoft.ReactNative.Cxx/ReactContext.h +3 -3
  238. package/Microsoft.ReactNative.Cxx/ReactNonAbiValue.h +3 -3
  239. package/Microsoft.ReactNative.Cxx/XamlUtils.h +44 -5
  240. package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +0 -6
  241. package/Mso/activeObject/activeObject.h +2 -2
  242. package/Mso/compilerAdapters/cppMacros.h +3 -5
  243. package/Mso/errorCode/errorProvider.h +2 -2
  244. package/Mso/errorCode/maybe.h +4 -4
  245. package/Mso/functional/functor.h +6 -6
  246. package/Mso/functional/functorRef.h +2 -2
  247. package/Mso/future/details/executor.h +2 -2
  248. package/Mso/future/details/futureFuncInl.h +4 -4
  249. package/Mso/future/details/ifuture.h +3 -3
  250. package/Mso/future/details/maybeInvoker.h +6 -6
  251. package/Mso/future/details/promiseGroupInl.h +4 -4
  252. package/Mso/future/details/promiseInl.h +4 -4
  253. package/Mso/future/details/resultTraits.h +4 -4
  254. package/Mso/future/details/whenAllInl.h +1 -1
  255. package/Mso/future/future.h +13 -13
  256. package/Mso/guid/msoGuidDetails.h +1 -1
  257. package/Mso/memoryApi/memoryApi.h +13 -7
  258. package/Mso/motifCpp/gTestAdapter.h +1 -1
  259. package/Mso/motifCpp/testInfo.h +7 -9
  260. package/Mso/object/make.h +8 -8
  261. package/Mso/object/objectRefCount.h +3 -5
  262. package/Mso/object/objectWithWeakRef.h +10 -14
  263. package/Mso/object/queryCast.h +4 -4
  264. package/Mso/object/refCountedObject.h +4 -4
  265. package/Mso/object/unknownObject.h +7 -7
  266. package/Mso/platformAdapters/windowsFirst.h +1 -1
  267. package/Mso/smartPtr/cntPtr.h +8 -8
  268. package/Mso/src/dispatchQueue/threadPoolScheduler_win.cpp +96 -4
  269. package/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +2 -2
  270. package/Mso/src/future/futureImpl.h +1 -1
  271. package/Mso/src/memoryApi/memoryApi.cpp +4 -4
  272. package/PropertySheets/CppAppConsumeCSharpModule.props +3 -0
  273. package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.props +26 -0
  274. package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.Common.props +12 -0
  275. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  276. package/PropertySheets/JSEngine.props +1 -1
  277. package/PropertySheets/React.Cpp.props +13 -0
  278. package/PropertySheets/WinUI.props +3 -6
  279. package/ReactCommon/ReactCommon.vcxproj +2 -4
  280. package/ReactCommon/ReactCommon.vcxproj.filters +4 -1
  281. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/JSCRuntime.cpp +1480 -0
  282. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/decorator.h +753 -0
  283. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/jsi.h +1331 -0
  284. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +1431 -0
  285. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +103 -0
  286. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +87 -0
  287. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +61 -0
  288. package/ReactCommon/Yoga.cpp +1 -1
  289. package/Scripts/{Microsoft.ReactNative.ProjectReunion.nuspec → Microsoft.ReactNative.WindowsAppSDK.nuspec} +7 -9
  290. package/Scripts/OfficeReact.Win32.nuspec +1 -3
  291. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -1
  292. package/Scripts/copyRNLibraries.js +8 -8
  293. package/Scripts/just.js +1 -1
  294. package/Scripts/rnw-dependencies.ps1 +41 -10
  295. package/Scripts/run-desktop-integration-tests.js +6 -6
  296. package/Shared/AbiSafe.h +3 -3
  297. package/Shared/BaseScriptStoreImpl.cpp +1 -1
  298. package/Shared/CppRuntimeOptions.h +50 -0
  299. package/Shared/CreateModules.h +4 -0
  300. package/Shared/DevSupportManager.cpp +34 -33
  301. package/Shared/DevSupportManager.h +1 -2
  302. package/Shared/HermesRuntimeHolder.cpp +23 -14
  303. package/Shared/HermesRuntimeHolder.h +8 -2
  304. package/Shared/IDevSupportManager.h +1 -2
  305. package/Shared/InspectorPackagerConnection.cpp +7 -5
  306. package/Shared/InspectorPackagerConnection.h +2 -2
  307. package/Shared/JSI/ChakraApi.cpp +0 -1
  308. package/Shared/JSI/ChakraRuntime.cpp +1 -2
  309. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +1 -1
  310. package/Shared/JSI/RuntimeHolder.h +2 -0
  311. package/Shared/Modules/HttpModule.cpp +198 -0
  312. package/Shared/Modules/HttpModule.h +53 -0
  313. package/Shared/Modules/WebSocketModule.cpp +5 -1
  314. package/Shared/Modules/WebSocketModule.h +8 -5
  315. package/Shared/Networking/IHttpResource.h +53 -0
  316. package/Shared/{IWebSocketResource.h → Networking/IWebSocketResource.h} +3 -3
  317. package/Shared/Networking/OriginPolicy.h +15 -0
  318. package/Shared/Networking/OriginPolicyHttpFilter.cpp +746 -0
  319. package/Shared/Networking/OriginPolicyHttpFilter.h +112 -0
  320. package/Shared/Networking/WinRTHttpResource.cpp +347 -0
  321. package/Shared/Networking/WinRTHttpResource.h +67 -0
  322. package/Shared/Networking/WinRTTypes.h +30 -0
  323. package/Shared/{WinRTWebSocketResource.cpp → Networking/WinRTWebSocketResource.cpp} +31 -22
  324. package/Shared/{WinRTWebSocketResource.h → Networking/WinRTWebSocketResource.h} +3 -3
  325. package/Shared/OInstance.cpp +37 -11
  326. package/Shared/RuntimeOptions.cpp +93 -15
  327. package/Shared/RuntimeOptions.h +22 -9
  328. package/Shared/Shared.vcxitems +126 -5
  329. package/Shared/Shared.vcxitems.filters +55 -15
  330. package/Shared/Threading/BatchingQueueThread.cpp +1 -1
  331. package/Shared/Utils/WinRTConversions.cpp +22 -0
  332. package/Shared/Utils/WinRTConversions.h +15 -0
  333. package/Shared/tracing/fbsystrace.h +2 -2
  334. package/codegen/NativeActionSheetManagerSpec.g.h +6 -0
  335. package/codegen/NativeAnimatedModuleSpec.g.h +43 -37
  336. package/codegen/NativeAnimatedTurboModuleSpec.g.h +43 -37
  337. package/codegen/NativePushNotificationManagerIOSSpec.g.h +2 -0
  338. package/codegen/react/components/rnwcore/ComponentDescriptors.h +0 -1
  339. package/codegen/react/components/rnwcore/EventEmitters.cpp +133 -0
  340. package/codegen/react/components/rnwcore/EventEmitters.h +0 -18
  341. package/codegen/react/components/rnwcore/Props.cpp +0 -13
  342. package/codegen/react/components/rnwcore/Props.h +0 -16
  343. package/codegen/react/components/rnwcore/ShadowNodes.cpp +0 -1
  344. package/codegen/react/components/rnwcore/ShadowNodes.h +0 -10
  345. package/include/Shared/cdebug.h +9 -9
  346. package/index.js +30 -25
  347. package/index.windows.js +30 -25
  348. package/jest/preprocessor.js +24 -107
  349. package/jest/preprocessor_DO_NOT_USE.js +122 -0
  350. package/metro.config.js +3 -70
  351. package/package.json +29 -28
  352. package/react-native.config.js +40 -6
  353. package/rntypes/index.d.ts +19 -7
  354. package/stubs/glog/logging.h +1 -1
  355. package/template/cpp-app/src/App.h +0 -4
  356. package/template/cs-app/src/App.xaml.cs +0 -5
  357. package/template/cs-app/src/MainPage.xaml.cs +1 -10
  358. package/template/cs-app-WinAppSDK/MyApp/App.xaml +16 -0
  359. package/template/cs-app-WinAppSDK/MyApp/App.xaml.cs +70 -0
  360. package/template/cs-app-WinAppSDK/MyApp/MainWindow.xaml +14 -0
  361. package/template/cs-app-WinAppSDK/MyApp/MainWindow.xaml.cs +38 -0
  362. package/template/cs-app-WinAppSDK/MyApp/Package.appxmanifest +48 -0
  363. package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-arm64.pubxml +19 -0
  364. package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-x64.pubxml +19 -0
  365. package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-x86.pubxml +19 -0
  366. package/template/cs-app-WinAppSDK/MyApp/Properties/launchSettings.json +10 -0
  367. package/template/cs-app-WinAppSDK/MyApp/app.manifest +15 -0
  368. package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +23 -0
  369. package/template/cs-app-WinAppSDK/proj/MyApp.csproj +49 -0
  370. package/template/cs-app-WinAppSDK/proj/MyApp.sln +43 -0
  371. package/template/cs-app-WinAppSDK/proj/NuGet.Config +17 -0
  372. package/template/metro.devMode.config.js +2 -51
  373. package/typings-index.js +5 -1
  374. package/typings-index.js.map +1 -1
  375. package/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +0 -44
  376. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js +0 -45
  377. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +0 -123
  378. package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.windows.js +0 -45
  379. package/Libraries/Components/View/ReactNativeViewViewConfig.js +0 -360
  380. package/Libraries/Components/View/ReactNativeViewViewConfig.windows.js +0 -390
  381. package/Libraries/Components/View/ReactNativeViewViewConfigAndroid.js +0 -83
  382. package/Libraries/ReactNative/UIManagerInjection.js +0 -15
  383. package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +0 -24527
  384. package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +0 -8309
  385. package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +0 -8961
  386. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +0 -24948
  387. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +0 -8400
  388. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +0 -9049
  389. package/PropertySheets/CppEnablePackageReferences.props +0 -13
  390. package/Shared/IHttpResource.h +0 -34
  391. package/Shared/cdebug.cpp +0 -6
  392. package/include/Shared/ViewManager.h +0 -34
@@ -33,6 +33,9 @@
33
33
  #pragma warning(pop)
34
34
 
35
35
  #include <future>
36
+ #include <mutex>
37
+
38
+ #include <AppModel.h>
36
39
 
37
40
  #if _MSC_VER <= 1913
38
41
  // VC 19 (2015-2017.6) cannot optimize co_await/cppwinrt usage
@@ -67,13 +70,13 @@ std::future<std::pair<std::string, bool>> GetJavaScriptFromServerAsync(const std
67
70
 
68
71
  HRESULT hr = asyncRequest.ErrorCode();
69
72
  if (FAILED(hr)) {
70
- std::ostringstream sstream;
73
+ std::string error;
71
74
  if (hr == WININET_E_CANNOT_CONNECT) {
72
- sstream << "A connection with the server " << url << " could not be established\n\nIs the packager running?";
75
+ error = fmt::format("A connection with the server {} could not be established.\n\nIs the packager running?", url);
73
76
  } else {
74
- sstream << "Error " << std::hex << static_cast<int>(asyncRequest.ErrorCode()) << " downloading " << url;
77
+ error = fmt::format("Error 0x{:x} downloading {}.", static_cast<int>(asyncRequest.ErrorCode()), url);
75
78
  }
76
- co_return std::make_pair(sstream.str(), false);
79
+ co_return std::make_pair(error, false);
77
80
  }
78
81
 
79
82
  winrt::Windows::Web::Http::HttpResponseMessage response = asyncRequest.GetResults();
@@ -86,15 +89,15 @@ std::future<std::pair<std::string, bool>> GetJavaScriptFromServerAsync(const std
86
89
  uint32_t len = reader.UnconsumedBufferLength();
87
90
  std::string result;
88
91
  if (len > 0 || response.IsSuccessStatusCode()) {
89
- std::vector<uint8_t> data;
90
- data.resize(len);
91
- reader.ReadBytes(winrt::array_view(data.data(), data.data() + len));
92
+ std::string data;
92
93
  data.resize(len);
93
- result = std::string(data.begin(), data.end());
94
+ auto buf = reinterpret_cast<uint8_t *>(data.data());
95
+ static_assert(
96
+ sizeof(buf[0]) == sizeof(data[0]), "perf optimization relies on uint8_t and char being the same size");
97
+ reader.ReadBytes(winrt::array_view(buf, buf + len));
98
+ result = std::move(data);
94
99
  } else {
95
- std::ostringstream sstream;
96
- sstream << "HTTP Error " << static_cast<int>(response.StatusCode()) << " downloading " << url;
97
- result = sstream.str();
100
+ result = fmt::format("HTTP Error {} downloading {}.", static_cast<int>(response.StatusCode()), url);
98
101
  }
99
102
 
100
103
  co_return std::make_pair(std::move(result), response.IsSuccessStatusCode());
@@ -237,34 +240,32 @@ void DevSupportManager::StopPollingLiveReload() {
237
240
  m_cancellation_token = true;
238
241
  }
239
242
 
240
- void DevSupportManager::StartInspector(
243
+ void DevSupportManager::EnsureHermesInspector(
241
244
  [[maybe_unused]] const std::string &packagerHost,
242
245
  [[maybe_unused]] const uint16_t packagerPort) noexcept {
243
246
  #ifdef HERMES_ENABLE_DEBUGGER
244
- std::string packageName("RNW");
245
- if (auto currentPackage = winrt::Windows::ApplicationModel::Package::Current()) {
246
- packageName = winrt::to_string(currentPackage.DisplayName());
247
- }
247
+ static std::once_flag once;
248
+ std::call_once(once, [this, &packagerHost, packagerPort]() {
249
+ std::string packageName("RNW");
250
+ wchar_t fullName[PACKAGE_FULL_NAME_MAX_LENGTH]{};
251
+ UINT32 size = ARRAYSIZE(fullName);
252
+ if (SUCCEEDED(GetCurrentPackageFullName(&size, fullName))) {
253
+ // we are in an unpackaged app
254
+ packageName = winrt::to_string(fullName);
255
+ }
248
256
 
249
- std::string deviceName("RNWHost");
250
- auto hostNames = winrt::Windows::Networking::Connectivity::NetworkInformation::GetHostNames();
251
- if (hostNames && hostNames.First() && hostNames.First().Current()) {
252
- deviceName = winrt::to_string(hostNames.First().Current().DisplayName());
253
- }
257
+ std::string deviceName("RNWHost");
258
+ auto hostNames = winrt::Windows::Networking::Connectivity::NetworkInformation::GetHostNames();
259
+ if (hostNames && hostNames.First() && hostNames.First().Current()) {
260
+ deviceName = winrt::to_string(hostNames.First().Current().DisplayName());
261
+ }
254
262
 
255
- m_inspectorPackagerConnection = std::make_shared<InspectorPackagerConnection>(
256
- facebook::react::DevServerHelper::get_InspectorDeviceUrl(packagerHost, packagerPort, deviceName, packageName),
257
- m_BundleStatusProvider);
258
- m_inspectorPackagerConnection->connectAsync();
259
- #endif
260
- }
263
+ m_inspectorPackagerConnection = std::make_shared<InspectorPackagerConnection>(
264
+ facebook::react::DevServerHelper::get_InspectorDeviceUrl(packagerHost, packagerPort, deviceName, packageName),
265
+ m_BundleStatusProvider);
266
+ m_inspectorPackagerConnection->connectAsync();
267
+ });
261
268
 
262
- void DevSupportManager::StopInspector() noexcept {
263
- #ifdef HERMES_ENABLE_DEBUGGER
264
- if (m_inspectorPackagerConnection) {
265
- m_inspectorPackagerConnection->disconnectAsync();
266
- m_inspectorPackagerConnection = nullptr;
267
- }
268
269
  #endif
269
270
  }
270
271
 
@@ -50,8 +50,7 @@ class DevSupportManager final : public facebook::react::IDevSupportManager {
50
50
  std::function<void()> onChangeCallback) override;
51
51
  virtual void StopPollingLiveReload() override;
52
52
 
53
- virtual void StartInspector(const std::string &packagerHost, const uint16_t packagerPort) noexcept override;
54
- virtual void StopInspector() noexcept override;
53
+ virtual void EnsureHermesInspector(const std::string &packagerHost, const uint16_t packagerPort) noexcept override;
55
54
  virtual void UpdateBundleStatus(bool isLastDownloadSucess, int64_t updateTimestamp) noexcept override;
56
55
 
57
56
  private:
@@ -74,7 +74,15 @@ class HermesExecutorRuntimeAdapter final : public facebook::hermes::inspector::R
74
74
  } // namespace
75
75
 
76
76
  void HermesRuntimeHolder::crashHandler(int fileDescriptor) noexcept {
77
- HermesShim::hermesCrashHandler(static_cast<facebook::hermes::HermesRuntime &>(*m_runtime), fileDescriptor);
77
+ HermesShim::hermesCrashHandler(*m_hermesRuntime, fileDescriptor);
78
+ }
79
+
80
+ void HermesRuntimeHolder::teardown() noexcept {
81
+ #ifdef HERMES_ENABLE_DEBUGGER
82
+ if (auto devSettings = m_weakDevSettings.lock(); devSettings && devSettings->useDirectDebugger) {
83
+ facebook::hermes::inspector::chrome::disableDebugging(*m_hermesRuntime);
84
+ }
85
+ #endif
78
86
  }
79
87
 
80
88
  facebook::react::JSIEngineOverride HermesRuntimeHolder::getRuntimeType() noexcept {
@@ -84,43 +92,44 @@ facebook::react::JSIEngineOverride HermesRuntimeHolder::getRuntimeType() noexcep
84
92
  std::shared_ptr<jsi::Runtime> HermesRuntimeHolder::getRuntime() noexcept {
85
93
  std::call_once(m_once_flag, [this]() { initRuntime(); });
86
94
 
87
- if (!m_runtime)
95
+ if (!m_hermesRuntime)
88
96
  std::terminate();
89
97
 
90
98
  // Make sure that the runtime instance is not consumed from multiple threads.
91
99
  if (m_own_thread_id != std::this_thread::get_id())
92
100
  std::terminate();
93
101
 
94
- return m_runtime;
102
+ return m_hermesRuntime;
95
103
  }
96
104
 
97
105
  HermesRuntimeHolder::HermesRuntimeHolder(
98
106
  std::shared_ptr<facebook::react::DevSettings> devSettings,
99
107
  std::shared_ptr<facebook::react::MessageQueueThread> jsQueue) noexcept
100
- : m_devSettings(std::move(devSettings)), m_jsQueue(std::move(jsQueue)) {}
108
+ : m_weakDevSettings(devSettings), m_jsQueue(std::move(jsQueue)) {}
101
109
 
102
110
  void HermesRuntimeHolder::initRuntime() noexcept {
103
- auto hermesRuntime = makeHermesRuntimeSystraced(m_devSettings->enableDefaultCrashHandler);
104
-
105
- facebook::hermes::HermesRuntime &hermesRuntimeRef = *hermesRuntime;
111
+ auto devSettings = m_weakDevSettings.lock();
112
+ if (!devSettings)
113
+ std::terminate();
106
114
 
107
- m_runtime = std::move(hermesRuntime);
115
+ m_hermesRuntime = makeHermesRuntimeSystraced(devSettings->enableDefaultCrashHandler);
108
116
  m_own_thread_id = std::this_thread::get_id();
109
117
 
110
118
  #ifdef HERMES_ENABLE_DEBUGGER
111
- if (m_devSettings->useDirectDebugger) {
112
- auto adapter = std::make_unique<HermesExecutorRuntimeAdapter>(m_runtime, hermesRuntimeRef, m_jsQueue);
119
+ if (devSettings->useDirectDebugger) {
120
+ auto adapter = std::make_unique<HermesExecutorRuntimeAdapter>(m_hermesRuntime, *m_hermesRuntime, m_jsQueue);
113
121
  facebook::hermes::inspector::chrome::enableDebugging(
114
122
  std::move(adapter),
115
- m_devSettings->debuggerRuntimeName.empty() ? "Hermes React Native" : m_devSettings->debuggerRuntimeName);
123
+ devSettings->debuggerRuntimeName.empty() ? "Hermes React Native" : devSettings->debuggerRuntimeName);
116
124
  }
117
125
  #endif
118
126
 
119
127
  // Add js engine information to Error.prototype so in error reporting we
120
128
  // can send this information.
121
- auto errorPrototype =
122
- m_runtime->global().getPropertyAsObject(*m_runtime, "Error").getPropertyAsObject(*m_runtime, "prototype");
123
- errorPrototype.setProperty(*m_runtime, "jsEngine", "hermes");
129
+ auto errorPrototype = m_hermesRuntime->global()
130
+ .getPropertyAsObject(*m_hermesRuntime, "Error")
131
+ .getPropertyAsObject(*m_hermesRuntime, "prototype");
132
+ errorPrototype.setProperty(*m_hermesRuntime, "jsEngine", "hermes");
124
133
  }
125
134
 
126
135
  } // namespace react
@@ -9,6 +9,10 @@
9
9
 
10
10
  #include <DevSettings.h>
11
11
 
12
+ namespace facebook::hermes {
13
+ class HermesRuntime;
14
+ }
15
+
12
16
  namespace facebook {
13
17
  namespace react {
14
18
 
@@ -19,18 +23,20 @@ class HermesRuntimeHolder : public Microsoft::JSI::RuntimeHolderLazyInit {
19
23
 
20
24
  void crashHandler(int fileDescriptor) noexcept override;
21
25
 
26
+ void teardown() noexcept override;
27
+
22
28
  HermesRuntimeHolder(
23
29
  std::shared_ptr<facebook::react::DevSettings> devSettings,
24
30
  std::shared_ptr<facebook::react::MessageQueueThread> jsQueue) noexcept;
25
31
 
26
32
  private:
27
33
  void initRuntime() noexcept;
28
- std::shared_ptr<facebook::jsi::Runtime> m_runtime;
34
+ std::shared_ptr<facebook::hermes::HermesRuntime> m_hermesRuntime;
29
35
 
30
36
  std::once_flag m_once_flag;
31
37
  std::thread::id m_own_thread_id;
32
38
 
33
- std::shared_ptr<facebook::react::DevSettings> m_devSettings;
39
+ std::weak_ptr<facebook::react::DevSettings> m_weakDevSettings;
34
40
  std::shared_ptr<facebook::react::MessageQueueThread> m_jsQueue;
35
41
  };
36
42
 
@@ -22,8 +22,7 @@ struct IDevSupportManager {
22
22
  std::function<void()> onChangeCallback) = 0;
23
23
  virtual void StopPollingLiveReload() = 0;
24
24
 
25
- virtual void StartInspector(const std::string &packagerHost, const uint16_t packagerPort) noexcept = 0;
26
- virtual void StopInspector() noexcept = 0;
25
+ virtual void EnsureHermesInspector(const std::string &packagerHost, const uint16_t packagerPort) noexcept = 0;
27
26
  virtual void UpdateBundleStatus(bool isLastDownloadSucess, int64_t updateTimestamp) noexcept = 0;
28
27
  };
29
28
 
@@ -196,7 +196,8 @@ InspectorPackagerConnection::InspectorPackagerConnection(
196
196
  winrt::fire_and_forget InspectorPackagerConnection::disconnectAsync() {
197
197
  co_await winrt::resume_background();
198
198
  std::string reason("Explicit close");
199
- m_packagerWebSocketConnection->Close(Microsoft::React::WinRTWebSocketResource::CloseCode::GoingAway, reason);
199
+ m_packagerWebSocketConnection->Close(
200
+ Microsoft::React::Networking::WinRTWebSocketResource::CloseCode::GoingAway, reason);
200
201
  co_return;
201
202
  }
202
203
 
@@ -204,9 +205,10 @@ winrt::fire_and_forget InspectorPackagerConnection::connectAsync() {
204
205
  co_await winrt::resume_background();
205
206
 
206
207
  std::vector<winrt::Windows::Security::Cryptography::Certificates::ChainValidationResult> certExceptions;
207
- m_packagerWebSocketConnection = std::make_shared<Microsoft::React::WinRTWebSocketResource>(std::move(certExceptions));
208
+ m_packagerWebSocketConnection =
209
+ std::make_shared<Microsoft::React::Networking::WinRTWebSocketResource>(std::move(certExceptions));
208
210
 
209
- m_packagerWebSocketConnection->SetOnError([](const Microsoft::React::IWebSocketResource::Error &err) {
211
+ m_packagerWebSocketConnection->SetOnError([](const Microsoft::React::Networking::IWebSocketResource::Error &err) {
210
212
  facebook::react::tracing::error(err.Message.c_str());
211
213
  });
212
214
 
@@ -267,8 +269,8 @@ winrt::fire_and_forget InspectorPackagerConnection::connectAsync() {
267
269
  }
268
270
  });
269
271
 
270
- Microsoft::React::IWebSocketResource::Protocols protocols;
271
- Microsoft::React::IWebSocketResource::Options options;
272
+ Microsoft::React::Networking::IWebSocketResource::Protocols protocols;
273
+ Microsoft::React::Networking::IWebSocketResource::Options options;
272
274
  m_packagerWebSocketConnection->Connect(std::string{m_url}, protocols, options);
273
275
 
274
276
  co_return;
@@ -4,7 +4,7 @@
4
4
  #pragma once
5
5
 
6
6
  #include <InspectorProxy.h>
7
- #include <WinRTWebSocketResource.h>
7
+ #include <Networking/WinRTWebSocketResource.h>
8
8
  #include <jsinspector/InspectorInterfaces.h>
9
9
 
10
10
  namespace Microsoft::ReactNative {
@@ -42,7 +42,7 @@ class InspectorPackagerConnection final : public std::enable_shared_from_this<In
42
42
  void sendMessageToVM(int64_t pageId, std::string &&message);
43
43
 
44
44
  std::unordered_map<int64_t, std::unique_ptr<facebook::react::ILocalConnection>> m_localConnections;
45
- std::shared_ptr<Microsoft::React::WinRTWebSocketResource> m_packagerWebSocketConnection;
45
+ std::shared_ptr<Microsoft::React::Networking::WinRTWebSocketResource> m_packagerWebSocketConnection;
46
46
  std::shared_ptr<IBundleStatusProvider> m_bundleStatusProvider;
47
47
  std::string m_url;
48
48
  };
@@ -3,7 +3,6 @@
3
3
 
4
4
  #include "ChakraApi.h"
5
5
 
6
- #include <RuntimeOptions.h>
7
6
  #include <sstream>
8
7
  #include <utility>
9
8
  #include "Unicode.h"
@@ -4,7 +4,6 @@
4
4
  #include "ChakraRuntime.h"
5
5
  #include "ChakraRuntimeFactory.h"
6
6
 
7
- #include <RuntimeOptions.h>
8
7
  #include "Unicode.h"
9
8
  #include "Utilities.h"
10
9
 
@@ -991,7 +990,7 @@ size_t ChakraRuntime::JsiValueViewArgs::Size() const noexcept {
991
990
 
992
991
  ChakraRuntime::PropNameIDView::PropNameIDView(JsPropertyIdRef propertyId) noexcept
993
992
  : m_propertyId{
994
- make<facebook::jsi::PropNameID>(new (std::addressof(m_pointerStore)) ChakraPointerValueView(propertyId))} {}
993
+ make<facebook::jsi::PropNameID>(new(std::addressof(m_pointerStore)) ChakraPointerValueView(propertyId))} {}
995
994
 
996
995
  ChakraRuntime::PropNameIDView::~PropNameIDView() noexcept {}
997
996
 
@@ -22,7 +22,7 @@ class NapiJsiV8RuntimeHolder : public Microsoft::JSI::RuntimeHolderLazyInit {
22
22
  std::unique_ptr<facebook::jsi::PreparedScriptStore> &&preparedScriptStore) noexcept;
23
23
 
24
24
  private:
25
- static void ScheduleTaskCallback(
25
+ static void __cdecl ScheduleTaskCallback(
26
26
  napi_env env,
27
27
  napi_ext_task_callback taskCb,
28
28
  void *taskData,
@@ -18,6 +18,8 @@ struct RuntimeHolderLazyInit {
18
18
  virtual std::shared_ptr<facebook::jsi::Runtime> getRuntime() noexcept = 0;
19
19
  virtual facebook::react::JSIEngineOverride getRuntimeType() noexcept = 0;
20
20
 
21
+ virtual void teardown() noexcept {};
22
+
21
23
  // You can call this when a crash happens to attempt recording additional data
22
24
  // The fd supplied is a raw file stream an implementation might write JSON to
23
25
  virtual void crashHandler(int fileDescriptor) noexcept {};
@@ -0,0 +1,198 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "pch.h"
5
+
6
+ #include "HttpModule.h"
7
+
8
+ // React Native
9
+ #include <cxxreact/Instance.h>
10
+ #include <cxxreact/JsArgumentHelpers.h>
11
+
12
+ using facebook::react::Instance;
13
+ using folly::dynamic;
14
+ using std::shared_ptr;
15
+ using std::string;
16
+ using std::weak_ptr;
17
+
18
+ namespace {
19
+
20
+ using Microsoft::React::Networking::IHttpResource;
21
+
22
+ constexpr char moduleName[] = "Networking";
23
+
24
+ static void SendEvent(weak_ptr<Instance> weakReactInstance, string &&eventName, dynamic &&args) {
25
+ if (auto instance = weakReactInstance.lock()) {
26
+ instance->callJSFunction("RCTDeviceEventEmitter", "emit", dynamic::array(std::move(eventName), std::move(args)));
27
+ }
28
+ }
29
+
30
+ static shared_ptr<IHttpResource> CreateHttpResource(weak_ptr<Instance> weakReactInstance) {
31
+ auto resource = IHttpResource::Make();
32
+
33
+ resource->SetOnResponse([weakReactInstance](int64_t requestId, IHttpResource::Response &&response) {
34
+ dynamic headers = dynamic::object();
35
+ for (auto &header : response.Headers) {
36
+ headers[header.first] = header.second;
37
+ }
38
+
39
+ // TODO: Test response content.
40
+ dynamic args = dynamic::array(requestId, response.StatusCode, headers, response.Url);
41
+
42
+ SendEvent(weakReactInstance, "didReceiveNetworkResponse", std::move(args));
43
+ });
44
+
45
+ resource->SetOnData([weakReactInstance](int64_t requestId, std::string &&responseData) {
46
+ dynamic args = dynamic::array(requestId, std::move(responseData));
47
+
48
+ SendEvent(weakReactInstance, "didReceiveNetworkData", std::move(args));
49
+
50
+ // TODO: Move into separate method IF not executed right after onData()
51
+ SendEvent(weakReactInstance, "didCompleteNetworkResponse", dynamic::array(requestId));
52
+ });
53
+
54
+ resource->SetOnError([weakReactInstance](int64_t requestId, string &&message) {
55
+ dynamic args = dynamic::array(requestId, std::move(message));
56
+ // TODO: isTimeout errorArgs.push_back(true);
57
+
58
+ SendEvent(weakReactInstance, "didCompleteNetworkResponse", std::move(args));
59
+ });
60
+
61
+ return resource;
62
+ }
63
+
64
+ } // namespace
65
+
66
+ namespace Microsoft::React {
67
+
68
+ HttpModule::HttpModule() noexcept : m_holder{std::make_shared<ModuleHolder>()} {
69
+ m_holder->Module = this;
70
+ }
71
+
72
+ HttpModule::~HttpModule() noexcept /*override*/ {
73
+ m_holder->Module = nullptr;
74
+ }
75
+
76
+ #pragma region CxxModule
77
+
78
+ string HttpModule::getName() /*override*/ {
79
+ return moduleName;
80
+ }
81
+
82
+ std::map<string, dynamic> HttpModule::getConstants() {
83
+ return {};
84
+ }
85
+
86
+ // clang-format off
87
+ std::vector<facebook::xplat::module::CxxModule::Method> HttpModule::getMethods() {
88
+
89
+ auto weakHolder = weak_ptr<ModuleHolder>(m_holder);
90
+ auto holder = weakHolder.lock();
91
+ auto weakReactInstance = weak_ptr<Instance>(holder->Module->getInstance());
92
+
93
+ return
94
+ {
95
+ {
96
+ "sendRequest",
97
+ [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args, Callback cxxCallback)
98
+ {
99
+ auto holder = weakHolder.lock();
100
+ if (!holder) {
101
+ return;
102
+ }
103
+
104
+ auto resource = holder->Module->m_resource;
105
+ if (resource || (resource = CreateHttpResource(holder->Module->getInstance())))
106
+ {
107
+ IHttpResource::BodyData bodyData;
108
+ auto params = facebook::xplat::jsArgAsObject(args, 0);
109
+ auto data = params["data"];
110
+ auto stringData = data["string"];
111
+ if (!stringData.empty())
112
+ {
113
+ bodyData = {IHttpResource::BodyData::Type::String, stringData.getString()};
114
+ }
115
+ else
116
+ {
117
+ auto base64Data = data["base64"];
118
+ if (!base64Data.empty())
119
+ {
120
+ bodyData = {IHttpResource::BodyData::Type::Base64, base64Data.getString()};
121
+ }
122
+ else
123
+ {
124
+ auto uriData = data["uri"];
125
+ if (!uriData.empty())
126
+ {
127
+ bodyData = {IHttpResource::BodyData::Type::Uri, uriData.getString()};
128
+ }
129
+ }
130
+ }
131
+ //TODO: Support FORM data
132
+
133
+ IHttpResource::Headers headers;
134
+ for (auto& header : params["headers"].items()) {
135
+ headers.emplace(header.first.getString(), header.second.getString());
136
+ }
137
+
138
+ resource->SendRequest(
139
+ params["method"].asString(),
140
+ params["url"].asString(),
141
+ std::move(headers),
142
+ std::move(bodyData),
143
+ params["responseType"].asString(),
144
+ params["incrementalUpdates"].asBool(),
145
+ static_cast<int64_t>(params["timeout"].asDouble()),
146
+ false,//withCredentials,
147
+ [cxxCallback = std::move(cxxCallback)](int64_t requestId) {
148
+ cxxCallback({requestId});
149
+ }
150
+ );
151
+ } // If resource available
152
+ }
153
+ },
154
+ {
155
+ "abortRequest",
156
+ [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args)
157
+ {
158
+ auto holder = weakHolder.lock();
159
+ if (!holder)
160
+ {
161
+ return;
162
+ }
163
+
164
+ auto resource = holder->Module->m_resource;
165
+ if (resource || (resource = CreateHttpResource(holder->Module->getInstance())))
166
+ {
167
+ resource->AbortRequest(facebook::xplat::jsArgAsInt(args, 0));
168
+ }
169
+ }
170
+ },
171
+ {
172
+ "clearCookies",
173
+ [weakHolder = weak_ptr<ModuleHolder>(m_holder)](dynamic args)
174
+ {
175
+ auto holder = weakHolder.lock();
176
+ if (!holder)
177
+ {
178
+ return;
179
+ }
180
+
181
+ auto resource = holder->Module->m_resource;
182
+ if (resource || (resource = CreateHttpResource(holder->Module->getInstance())))
183
+ {
184
+ resource->ClearCookies();
185
+ }
186
+ }
187
+ }
188
+ };
189
+ }
190
+ // clang-format on
191
+
192
+ #pragma endregion CxxModule
193
+
194
+ /*extern*/ const char *GetHttpModuleName() noexcept {
195
+ return moduleName;
196
+ }
197
+
198
+ } // namespace Microsoft::React
@@ -0,0 +1,53 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include <Networking/IHttpResource.h>
7
+
8
+ // React Native
9
+ #include <cxxreact/CxxModule.h>
10
+
11
+ namespace Microsoft::React {
12
+
13
+ ///
14
+ /// Realizes <c>NativeModules</c> projection.
15
+ /// <remarks>See src\Libraries\Network\RCTNetworkingWinShared.js</remarks>
16
+ ///
17
+ class HttpModule : public facebook::xplat::module::CxxModule {
18
+ public:
19
+ enum MethodId { SendRequest = 0, AbortRequest = 1, ClearCookies = 2, LAST = ClearCookies };
20
+
21
+ HttpModule() noexcept;
22
+
23
+ ~HttpModule() noexcept override;
24
+
25
+ #pragma region CxxModule
26
+
27
+ /// <summary>
28
+ /// <see cref="facebook::xplat::module::CxxModule::getName" />
29
+ /// </summary>
30
+ std::string getName() override;
31
+
32
+ /// <summary>
33
+ /// <see cref="facebook::xplat::module::CxxModule::getConstants" />
34
+ /// </summary>
35
+ std::map<std::string, folly::dynamic> getConstants() override;
36
+
37
+ /// <summary>
38
+ /// <see cref="facebook::xplat::module::CxxModule::getMethods" />
39
+ /// </summary>
40
+ /// <remarks>See See react-native/Libraries/WebSocket/WebSocket.js</remarks>
41
+ std::vector<Method> getMethods() override;
42
+
43
+ #pragma endregion CxxModule
44
+
45
+ private:
46
+ struct ModuleHolder {
47
+ HttpModule *Module{nullptr};
48
+ };
49
+
50
+ std::shared_ptr<Networking::IHttpResource> m_resource;
51
+ std::shared_ptr<ModuleHolder> m_holder;
52
+ };
53
+ } // namespace Microsoft::React
@@ -26,8 +26,8 @@ using std::string;
26
26
  using std::weak_ptr;
27
27
 
28
28
  namespace {
29
- using Microsoft::React::IWebSocketResource;
30
29
  using Microsoft::React::WebSocketModule;
30
+ using Microsoft::React::Networking::IWebSocketResource;
31
31
 
32
32
  constexpr char moduleName[] = "WebSocketModule";
33
33
 
@@ -246,6 +246,10 @@ std::vector<facebook::xplat::module::CxxModule::Method> WebSocketModule::getMeth
246
246
  } // getMethods
247
247
  // clang-format on
248
248
 
249
+ /*extern*/ const char *GetWebSocketModuleName() noexcept {
250
+ return moduleName;
251
+ }
252
+
249
253
  /*extern*/ std::unique_ptr<facebook::xplat::module::CxxModule> CreateWebSocketModule() noexcept {
250
254
  return std::make_unique<WebSocketModule>();
251
255
  }
@@ -3,8 +3,10 @@
3
3
 
4
4
  #pragma once
5
5
 
6
+ #include <Networking/IWebSocketResource.h>
7
+
8
+ // React Native
6
9
  #include <cxxreact/CxxModule.h>
7
- #include "IWebSocketResource.h"
8
10
 
9
11
  namespace Microsoft::React {
10
12
 
@@ -25,12 +27,12 @@ class WebSocketModule : public facebook::xplat::module::CxxModule {
25
27
  /// Keeps <c>IWebSocketResource</c> instances identified by <c>id</c>.
26
28
  /// As defined in WebSocket.js.
27
29
  /// </summary>
28
- std::map<int64_t, std::shared_ptr<IWebSocketResource>> ResourceMap{};
30
+ std::map<int64_t, std::shared_ptr<Networking::IWebSocketResource>> ResourceMap{};
29
31
 
30
32
  /// <summary>
31
33
  /// Generates IWebSocketResource instances, defaulting to IWebSocketResource::Make.
32
34
  /// </summary>
33
- std::function<std::shared_ptr<IWebSocketResource>(std::string &&)> ResourceFactory;
35
+ std::function<std::shared_ptr<Networking::IWebSocketResource>(std::string &&)> ResourceFactory;
34
36
 
35
37
  /// <summary>
36
38
  /// Keeps a raw reference to the module object to lazily retrieve the React Instance as needed.
@@ -58,14 +60,15 @@ class WebSocketModule : public facebook::xplat::module::CxxModule {
58
60
 
59
61
  #pragma endregion CxxModule overrides
60
62
 
61
- void SetResourceFactory(std::function<std::shared_ptr<IWebSocketResource>(const std::string &)> &&resourceFactory);
63
+ void SetResourceFactory(
64
+ std::function<std::shared_ptr<Networking::IWebSocketResource>(const std::string &)> &&resourceFactory);
62
65
 
63
66
  private:
64
67
  /// <summary>
65
68
  /// Keeps <c>IWebSocketResource</c> instances identified by <c>id</c>.
66
69
  /// As defined in WebSocket.js.
67
70
  /// </summary>
68
- std::map<int64_t, std::shared_ptr<IWebSocketResource>> m_webSockets;
71
+ std::map<int64_t, std::shared_ptr<Networking::IWebSocketResource>> m_webSockets;
69
72
 
70
73
  /// <summary>
71
74
  /// Keeps members that can be accessed threads other than this module's owner accessible.