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.
- package/.flowconfig +1 -3
- package/Chakra/ChakraHelpers.cpp +0 -1
- package/Directory.Build.props +3 -0
- package/Directory.Build.targets +1 -1
- package/Folly/TEMP_UntilFollyUpdate/dynamic-inl.h +1411 -0
- package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.cpp +336 -0
- package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.h +182 -0
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -0
- package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +1 -0
- package/Libraries/Alert/Alert.windows.js +2 -2
- package/Libraries/Animated/AnimatedImplementation.js +1 -1
- package/Libraries/Animated/NativeAnimatedHelper.js +55 -9
- package/Libraries/Animated/NativeAnimatedModule.js +1 -0
- package/Libraries/Animated/NativeAnimatedTurboModule.js +1 -0
- package/Libraries/Animated/animations/TimingAnimation.js +6 -11
- package/Libraries/Animated/createAnimatedComponent.js +2 -2
- package/Libraries/Animated/nodes/AnimatedColor.js +95 -29
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +19 -22
- package/Libraries/Animated/nodes/AnimatedNode.js +2 -2
- package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
- package/Libraries/AppState/AppState.js +1 -1
- package/Libraries/Blob/URL.js +7 -1
- package/Libraries/Components/Button.js +3 -0
- package/Libraries/Components/Button.windows.js +4 -0
- package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +5 -0
- package/Libraries/Components/Pressable/Pressable.js +3 -3
- package/Libraries/Components/Pressable/Pressable.windows.js +3 -3
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +47 -38
- package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +15 -7
- package/Libraries/Components/ScrollView/ScrollView.js +1 -1
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +16 -3
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +3 -1
- package/Libraries/Components/Slider/Slider.js +0 -2
- package/Libraries/Components/Slider/SliderNativeComponent.js +0 -1
- package/Libraries/Components/StatusBar/StatusBar.js +6 -1
- package/Libraries/Components/Switch/Switch.js +11 -1
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +114 -109
- package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +17 -9
- package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +13 -5
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +10 -0
- package/Libraries/Components/TextInput/TextInput.js +1 -8
- package/Libraries/Components/TextInput/TextInput.windows.js +4 -9
- package/Libraries/Components/TextInput/TextInputState.js +10 -2
- package/Libraries/Components/TextInput/TextInputState.windows.js +10 -3
- package/Libraries/Components/TextInput/WindowsTextInputNativeComponent.js +1 -1
- package/Libraries/Components/Touchable/TouchableBounce.js +1 -0
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -0
- package/Libraries/Components/Touchable/TouchableHighlight.windows.js +6 -5
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -0
- package/Libraries/Components/Touchable/TouchableOpacity.js +7 -1
- package/Libraries/Components/Touchable/TouchableOpacity.windows.js +11 -5
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +1 -0
- package/Libraries/Components/View/View.windows.js +33 -1
- package/Libraries/Components/View/ViewNativeComponent.js +68 -8
- package/Libraries/Components/View/ViewPropTypes.js +36 -4
- package/Libraries/Components/View/ViewPropTypes.windows.js +36 -4
- package/Libraries/Core/Devtools/parseHermesStack.js +1 -1
- package/Libraries/Core/ExceptionsManager.js +1 -1
- package/Libraries/Core/RawEventEmitter.js +38 -0
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/polyfillPromise.js +32 -0
- package/Libraries/Core/setUpReactDevTools.js +3 -2
- package/Libraries/EventEmitter/NativeEventEmitter.js +3 -3
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -1
- package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +3 -3
- package/Libraries/Events/CustomEvent.js +32 -0
- package/Libraries/Events/EventPolyfill.js +239 -0
- package/Libraries/Image/Image.android.js +0 -6
- package/Libraries/Image/Image.ios.js +0 -6
- package/Libraries/Image/Image.windows.js +2 -8
- package/Libraries/Image/ImageViewNativeComponent.js +18 -3
- package/Libraries/Image/TextInlineImageNativeComponent.js +23 -15
- package/Libraries/Inspector/Inspector.js +2 -4
- package/Libraries/Interaction/BridgeSpyStallHandler.js +4 -3
- package/Libraries/Interaction/InteractionManager.js +1 -12
- package/Libraries/Interaction/TaskQueue.js +5 -4
- package/Libraries/LayoutAnimation/LayoutAnimation.js +13 -0
- package/Libraries/Linking/Linking.js +1 -1
- package/Libraries/Lists/FlatList.js +27 -6
- package/Libraries/Lists/VirtualizedList.js +71 -55
- package/Libraries/Lists/VirtualizedListContext.js +7 -3
- package/Libraries/Lists/VirtualizedSectionList.js +2 -2
- package/Libraries/Lists/__tests__/{FillRateHelper-test.windows.js → FillRateHelper-test.js} +2 -2
- package/Libraries/Lists/__tests__/{FlatList-test.windows.js → FlatList-test.js} +2 -2
- package/Libraries/Lists/__tests__/{SectionList-test.windows.js → SectionList-test.js} +14 -14
- package/Libraries/Lists/__tests__/{VirtualizeUtils-test.windows.js → VirtualizeUtils-test.js} +3 -3
- package/Libraries/Lists/__tests__/{VirtualizedList-test.windows.js → VirtualizedList-test.js} +91 -42
- package/Libraries/Lists/__tests__/{VirtualizedSectionList-test.windows.js → VirtualizedSectionList-test.js} +13 -13
- package/Libraries/LogBox/Data/LogBoxData.js +2 -2
- package/Libraries/LogBox/Data/LogBoxLog.js +1 -1
- package/Libraries/LogBox/Data/LogBoxSymbolication.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/LogBox.js +2 -21
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -0
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +2 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +295 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +333 -0
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +334 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +0 -2
- package/Libraries/NativeComponent/PlatformBaseViewConfig.js +24 -0
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +7 -42
- package/Libraries/NativeComponent/ViewConfig.js +4 -4
- package/Libraries/NativeComponent/ViewConfigIgnore.js +54 -0
- package/Libraries/Network/FormData.js +7 -1
- package/Libraries/Pressability/Pressability.js +115 -46
- package/Libraries/Pressability/Pressability.windows.js +190 -74
- package/Libraries/Pressability/PressabilityDebug.js +5 -9
- package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +1 -0
- package/Libraries/ReactNative/AppContainer.js +1 -1
- package/Libraries/ReactNative/{DummyUIManager.js → BridgelessUIManager.js} +62 -40
- package/Libraries/ReactNative/PaperUIManager.windows.js +5 -5
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +39 -0
- package/Libraries/ReactNative/UIManager.js +2 -3
- package/Libraries/ReactNative/renderApplication.js +4 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +8 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +5908 -4906
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +2100 -1918
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +2567 -2352
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5610 -4844
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1710 -1556
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1830 -1639
- package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -1
- package/Libraries/StyleSheet/EdgeInsetsPropType.js +4 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +59 -66
- package/Libraries/StyleSheet/normalizeColor.js +1 -1
- package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +15 -0
- package/Libraries/StyleSheet/private/_TransformStyle.js +53 -0
- package/Libraries/StyleSheet/processTransform.windows.js +272 -0
- package/Libraries/Text/Text.js +13 -7
- package/Libraries/Text/Text.windows.js +16 -7
- package/Libraries/Text/TextNativeComponent.js +2 -0
- package/Libraries/Text/TextProps.js +10 -0
- package/Libraries/Types/CoreEventTypes.js +13 -1
- package/Libraries/Types/CoreEventTypes.windows.js +26 -1
- package/Libraries/Utilities/Appearance.js +0 -8
- package/Libraries/Utilities/HMRClient.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -0
- package/Libraries/Utilities/codegenNativeComponent.js +17 -6
- package/Libraries/Utilities/stringifySafe.js +4 -1
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +3 -3
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/vendor/emitter/_EmitterSubscription.js +1 -1
- package/Libraries/vendor/emitter/_EventEmitter.js +1 -1
- package/Libraries/vendor/emitter/_EventSubscription.js +1 -1
- package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +1 -4
- package/Microsoft.ReactNative/DynamicReader.cpp +3 -3
- package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -0
- package/Microsoft.ReactNative/Fabric/ComponentViewRegistry.cpp +36 -2
- package/Microsoft.ReactNative/Fabric/ComponentViewRegistry.h +1 -0
- package/Microsoft.ReactNative/Fabric/DWriteHelpers.cpp +19 -0
- package/Microsoft.ReactNative/Fabric/DWriteHelpers.h +13 -0
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +65 -19
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +2 -0
- package/Microsoft.ReactNative/Fabric/ParagraphComponentView.cpp +36 -10
- package/Microsoft.ReactNative/Fabric/ScrollViewComponentView.cpp +2 -0
- package/Microsoft.ReactNative/Fabric/SliderComponentView.cpp +107 -0
- package/Microsoft.ReactNative/Fabric/SliderComponentView.h +51 -0
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.cpp +109 -0
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.h +52 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentDescriptor.h +197 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentView.cpp +308 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentView.h +52 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputEventEmitter.cpp +31 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputEventEmitter.h +33 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputProps.cpp +81 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputProps.h +132 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputShadowNode.cpp +193 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputShadowNode.h +85 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputState.cpp +76 -0
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputState.h +99 -0
- package/Microsoft.ReactNative/Fabric/ViewComponentView.cpp +35 -3
- package/Microsoft.ReactNative/Fabric/ViewComponentView.h +1 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/rncore/EventEmitters.h +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/rncore/Props.h +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/slider/SliderMeasurementsManager.cpp +46 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/slider/SliderMeasurementsManager.h +30 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Color.cpp +2 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/conversions.h +1 -9
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/platform/cxx/react/renderer/graphics/Color.h +3 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +119 -57
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +18 -1
- package/Microsoft.ReactNative/IViewManager.idl +3 -3
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +13 -107
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +2 -2
- package/Microsoft.ReactNative/Modules/AppStateModule.cpp +2 -0
- package/Microsoft.ReactNative/Modules/AppStateModule.h +2 -0
- package/Microsoft.ReactNative/Modules/CreateModules.cpp +3 -3
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +7 -5
- package/Microsoft.ReactNative/Modules/TimingModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/TimingModule.h +2 -2
- package/Microsoft.ReactNative/ReactHost/{ReactContext.cpp → MsoReactContext.cpp} +1 -1
- package/Microsoft.ReactNative/ReactHost/{ReactContext.h → MsoReactContext.h} +0 -0
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +15 -2
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
- package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -1
- package/Microsoft.ReactNative/ReactInstanceSettings.idl +12 -2
- package/Microsoft.ReactNative/ReactPackageBuilder.cpp +1 -1
- package/Microsoft.ReactNative/ReactRootView.cpp +2 -1
- package/Microsoft.ReactNative/RedBox.cpp +3 -2
- package/Microsoft.ReactNative/TurboModulesProvider.cpp +3 -2
- package/Microsoft.ReactNative/TurboModulesProvider.h +4 -1
- package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +41 -0
- package/Microsoft.ReactNative/Utils/ValueUtils.cpp +3 -2
- package/Microsoft.ReactNative/Views/ControlViewManager.cpp +32 -0
- package/Microsoft.ReactNative/Views/ControlViewManager.h +11 -0
- package/Microsoft.ReactNative/Views/DevMenu.cpp +2 -2
- package/Microsoft.ReactNative/Views/FrameworkElementTransferProperties.cpp +13 -2
- package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +149 -22
- package/Microsoft.ReactNative/Views/Image/ImageViewManager.cpp +1 -1
- package/Microsoft.ReactNative/Views/Image/Microsoft.UI.Composition.Effects_Impl.h +5 -11
- package/Microsoft.ReactNative/Views/Image/ReactImage.cpp +2 -1
- package/Microsoft.ReactNative/Views/SliderViewManager.cpp +12 -4
- package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +1 -1
- package/Microsoft.ReactNative/Views/TextViewManager.cpp +2 -2
- package/Microsoft.ReactNative/Views/TouchEventHandler.cpp +163 -37
- package/Microsoft.ReactNative/Views/TouchEventHandler.h +11 -4
- package/Microsoft.ReactNative/Views/ViewPanel.cpp +3 -23
- package/Microsoft.ReactNative/Views/ViewPanel.h +2 -3
- package/Microsoft.ReactNative/Views/ViewViewManager.cpp +21 -0
- package/Microsoft.ReactNative/XamlUIService.cpp +1 -1
- package/Microsoft.ReactNative/XamlView.h +8 -3
- package/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h +3 -5
- package/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +11 -2
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +1 -0
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +19 -14
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +4 -0
- package/Microsoft.ReactNative.Cxx/JSValueReader.h +2 -2
- package/Microsoft.ReactNative.Cxx/JSValueWriter.h +5 -5
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +5 -1
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +2 -3
- package/Microsoft.ReactNative.Cxx/NativeModules.h +3 -3
- package/Microsoft.ReactNative.Cxx/ReactContext.h +3 -3
- package/Microsoft.ReactNative.Cxx/ReactNonAbiValue.h +3 -3
- package/Microsoft.ReactNative.Cxx/XamlUtils.h +44 -5
- package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +0 -6
- package/Mso/activeObject/activeObject.h +2 -2
- package/Mso/compilerAdapters/cppMacros.h +3 -5
- package/Mso/errorCode/errorProvider.h +2 -2
- package/Mso/errorCode/maybe.h +4 -4
- package/Mso/functional/functor.h +6 -6
- package/Mso/functional/functorRef.h +2 -2
- package/Mso/future/details/executor.h +2 -2
- package/Mso/future/details/futureFuncInl.h +4 -4
- package/Mso/future/details/ifuture.h +3 -3
- package/Mso/future/details/maybeInvoker.h +6 -6
- package/Mso/future/details/promiseGroupInl.h +4 -4
- package/Mso/future/details/promiseInl.h +4 -4
- package/Mso/future/details/resultTraits.h +4 -4
- package/Mso/future/details/whenAllInl.h +1 -1
- package/Mso/future/future.h +13 -13
- package/Mso/guid/msoGuidDetails.h +1 -1
- package/Mso/memoryApi/memoryApi.h +13 -7
- package/Mso/motifCpp/gTestAdapter.h +1 -1
- package/Mso/motifCpp/testInfo.h +7 -9
- package/Mso/object/make.h +8 -8
- package/Mso/object/objectRefCount.h +3 -5
- package/Mso/object/objectWithWeakRef.h +10 -14
- package/Mso/object/queryCast.h +4 -4
- package/Mso/object/refCountedObject.h +4 -4
- package/Mso/object/unknownObject.h +7 -7
- package/Mso/platformAdapters/windowsFirst.h +1 -1
- package/Mso/smartPtr/cntPtr.h +8 -8
- package/Mso/src/dispatchQueue/threadPoolScheduler_win.cpp +96 -4
- package/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +2 -2
- package/Mso/src/future/futureImpl.h +1 -1
- package/Mso/src/memoryApi/memoryApi.cpp +4 -4
- package/PropertySheets/CppAppConsumeCSharpModule.props +3 -0
- package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.props +26 -0
- package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.Common.props +12 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +1 -1
- package/PropertySheets/React.Cpp.props +13 -0
- package/PropertySheets/WinUI.props +3 -6
- package/ReactCommon/ReactCommon.vcxproj +2 -4
- package/ReactCommon/ReactCommon.vcxproj.filters +4 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/JSCRuntime.cpp +1480 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/decorator.h +753 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/jsi.h +1331 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +1431 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +103 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +87 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +61 -0
- package/ReactCommon/Yoga.cpp +1 -1
- package/Scripts/{Microsoft.ReactNative.ProjectReunion.nuspec → Microsoft.ReactNative.WindowsAppSDK.nuspec} +7 -9
- package/Scripts/OfficeReact.Win32.nuspec +1 -3
- package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -1
- package/Scripts/copyRNLibraries.js +8 -8
- package/Scripts/just.js +1 -1
- package/Scripts/rnw-dependencies.ps1 +41 -10
- package/Scripts/run-desktop-integration-tests.js +6 -6
- package/Shared/AbiSafe.h +3 -3
- package/Shared/BaseScriptStoreImpl.cpp +1 -1
- package/Shared/CppRuntimeOptions.h +50 -0
- package/Shared/CreateModules.h +4 -0
- package/Shared/DevSupportManager.cpp +34 -33
- package/Shared/DevSupportManager.h +1 -2
- package/Shared/HermesRuntimeHolder.cpp +23 -14
- package/Shared/HermesRuntimeHolder.h +8 -2
- package/Shared/IDevSupportManager.h +1 -2
- package/Shared/InspectorPackagerConnection.cpp +7 -5
- package/Shared/InspectorPackagerConnection.h +2 -2
- package/Shared/JSI/ChakraApi.cpp +0 -1
- package/Shared/JSI/ChakraRuntime.cpp +1 -2
- package/Shared/JSI/NapiJsiV8RuntimeHolder.h +1 -1
- package/Shared/JSI/RuntimeHolder.h +2 -0
- package/Shared/Modules/HttpModule.cpp +198 -0
- package/Shared/Modules/HttpModule.h +53 -0
- package/Shared/Modules/WebSocketModule.cpp +5 -1
- package/Shared/Modules/WebSocketModule.h +8 -5
- package/Shared/Networking/IHttpResource.h +53 -0
- package/Shared/{IWebSocketResource.h → Networking/IWebSocketResource.h} +3 -3
- package/Shared/Networking/OriginPolicy.h +15 -0
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +746 -0
- package/Shared/Networking/OriginPolicyHttpFilter.h +112 -0
- package/Shared/Networking/WinRTHttpResource.cpp +347 -0
- package/Shared/Networking/WinRTHttpResource.h +67 -0
- package/Shared/Networking/WinRTTypes.h +30 -0
- package/Shared/{WinRTWebSocketResource.cpp → Networking/WinRTWebSocketResource.cpp} +31 -22
- package/Shared/{WinRTWebSocketResource.h → Networking/WinRTWebSocketResource.h} +3 -3
- package/Shared/OInstance.cpp +37 -11
- package/Shared/RuntimeOptions.cpp +93 -15
- package/Shared/RuntimeOptions.h +22 -9
- package/Shared/Shared.vcxitems +126 -5
- package/Shared/Shared.vcxitems.filters +55 -15
- package/Shared/Threading/BatchingQueueThread.cpp +1 -1
- package/Shared/Utils/WinRTConversions.cpp +22 -0
- package/Shared/Utils/WinRTConversions.h +15 -0
- package/Shared/tracing/fbsystrace.h +2 -2
- package/codegen/NativeActionSheetManagerSpec.g.h +6 -0
- package/codegen/NativeAnimatedModuleSpec.g.h +43 -37
- package/codegen/NativeAnimatedTurboModuleSpec.g.h +43 -37
- package/codegen/NativePushNotificationManagerIOSSpec.g.h +2 -0
- package/codegen/react/components/rnwcore/ComponentDescriptors.h +0 -1
- package/codegen/react/components/rnwcore/EventEmitters.cpp +133 -0
- package/codegen/react/components/rnwcore/EventEmitters.h +0 -18
- package/codegen/react/components/rnwcore/Props.cpp +0 -13
- package/codegen/react/components/rnwcore/Props.h +0 -16
- package/codegen/react/components/rnwcore/ShadowNodes.cpp +0 -1
- package/codegen/react/components/rnwcore/ShadowNodes.h +0 -10
- package/include/Shared/cdebug.h +9 -9
- package/index.js +30 -25
- package/index.windows.js +30 -25
- package/jest/preprocessor.js +24 -107
- package/jest/preprocessor_DO_NOT_USE.js +122 -0
- package/metro.config.js +3 -70
- package/package.json +29 -28
- package/react-native.config.js +40 -6
- package/rntypes/index.d.ts +19 -7
- package/stubs/glog/logging.h +1 -1
- package/template/cpp-app/src/App.h +0 -4
- package/template/cs-app/src/App.xaml.cs +0 -5
- package/template/cs-app/src/MainPage.xaml.cs +1 -10
- package/template/cs-app-WinAppSDK/MyApp/App.xaml +16 -0
- package/template/cs-app-WinAppSDK/MyApp/App.xaml.cs +70 -0
- package/template/cs-app-WinAppSDK/MyApp/MainWindow.xaml +14 -0
- package/template/cs-app-WinAppSDK/MyApp/MainWindow.xaml.cs +38 -0
- package/template/cs-app-WinAppSDK/MyApp/Package.appxmanifest +48 -0
- package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-arm64.pubxml +19 -0
- package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-x64.pubxml +19 -0
- package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-x86.pubxml +19 -0
- package/template/cs-app-WinAppSDK/MyApp/Properties/launchSettings.json +10 -0
- package/template/cs-app-WinAppSDK/MyApp/app.manifest +15 -0
- package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +23 -0
- package/template/cs-app-WinAppSDK/proj/MyApp.csproj +49 -0
- package/template/cs-app-WinAppSDK/proj/MyApp.sln +43 -0
- package/template/cs-app-WinAppSDK/proj/NuGet.Config +17 -0
- package/template/metro.devMode.config.js +2 -51
- package/typings-index.js +5 -1
- package/typings-index.js.map +1 -1
- package/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +0 -44
- package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.android.js +0 -45
- package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +0 -123
- package/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.windows.js +0 -45
- package/Libraries/Components/View/ReactNativeViewViewConfig.js +0 -360
- package/Libraries/Components/View/ReactNativeViewViewConfig.windows.js +0 -390
- package/Libraries/Components/View/ReactNativeViewViewConfigAndroid.js +0 -83
- package/Libraries/ReactNative/UIManagerInjection.js +0 -15
- package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +0 -24527
- package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +0 -8309
- package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +0 -8961
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +0 -24948
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +0 -8400
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +0 -9049
- package/PropertySheets/CppEnablePackageReferences.props +0 -13
- package/Shared/IHttpResource.h +0 -34
- package/Shared/cdebug.cpp +0 -6
- package/include/Shared/ViewManager.h +0 -34
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "OriginPolicy.h"
|
|
7
|
+
|
|
8
|
+
// Windows API
|
|
9
|
+
#include <winrt/Windows.Foundation.h>
|
|
10
|
+
#include <winrt/Windows.Web.Http.Filters.h>
|
|
11
|
+
#include <winrt/Windows.Web.Http.h>
|
|
12
|
+
|
|
13
|
+
// Standard Library
|
|
14
|
+
#include <set>
|
|
15
|
+
|
|
16
|
+
namespace Microsoft::React::Networking {
|
|
17
|
+
|
|
18
|
+
class OriginPolicyHttpFilter
|
|
19
|
+
: public winrt::implements<OriginPolicyHttpFilter, winrt::Windows::Web::Http::Filters::IHttpFilter> {
|
|
20
|
+
public:
|
|
21
|
+
struct ConstWcharComparer {
|
|
22
|
+
bool operator()(const wchar_t *, const wchar_t *) const;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
static std::set<const wchar_t *, ConstWcharComparer> s_forbiddenMethods;
|
|
27
|
+
static std::set<const wchar_t *, ConstWcharComparer> s_simpleCorsMethods;
|
|
28
|
+
static std::set<const wchar_t *, ConstWcharComparer> s_simpleCorsRequestHeaderNames;
|
|
29
|
+
static std::set<const wchar_t *, ConstWcharComparer> s_simpleCorsResponseHeaderNames;
|
|
30
|
+
static std::set<const wchar_t *, ConstWcharComparer> s_simpleCorsContentTypeValues;
|
|
31
|
+
static std::set<const wchar_t *, ConstWcharComparer> s_corsForbiddenRequestHeaderNames;
|
|
32
|
+
static std::set<const wchar_t *, ConstWcharComparer> s_corsForbiddenRequestHeaderNamePrefixes;
|
|
33
|
+
static std::set<const wchar_t *, ConstWcharComparer> s_cookieSettingResponseHeaders;
|
|
34
|
+
|
|
35
|
+
// NOTE: Assumes static origin through owning client/resource/module/(React) instance's lifetime.
|
|
36
|
+
static winrt::Windows::Foundation::Uri s_origin;
|
|
37
|
+
|
|
38
|
+
struct AccessControlValues {
|
|
39
|
+
winrt::hstring AllowedOrigin;
|
|
40
|
+
winrt::hstring AllowedCredentials;
|
|
41
|
+
std::set<std::wstring> AllowedHeaders;
|
|
42
|
+
std::set<std::wstring> AllowedMethods;
|
|
43
|
+
std::set<std::wstring> ExposedHeaders;
|
|
44
|
+
size_t MaxAge;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
winrt::Windows::Web::Http::Filters::IHttpFilter m_innerFilter;
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
static void SetStaticOrigin(std::string &&url);
|
|
51
|
+
|
|
52
|
+
static bool IsSameOrigin(
|
|
53
|
+
winrt::Windows::Foundation::Uri const &u1,
|
|
54
|
+
winrt::Windows::Foundation::Uri const &u2) noexcept;
|
|
55
|
+
|
|
56
|
+
static winrt::Windows::Foundation::Uri GetOrigin(winrt::Windows::Foundation::Uri const &uri) noexcept;
|
|
57
|
+
|
|
58
|
+
static bool IsSimpleCorsRequest(winrt::Windows::Web::Http::HttpRequestMessage const &request) noexcept;
|
|
59
|
+
|
|
60
|
+
static bool AreSafeRequestHeaders(
|
|
61
|
+
winrt::Windows::Web::Http::Headers::HttpRequestHeaderCollection const &headers) noexcept;
|
|
62
|
+
|
|
63
|
+
static std::set<const wchar_t *> CorsUnsafeNotForbiddenRequestHeaderNames(
|
|
64
|
+
winrt::Windows::Web::Http::Headers::HttpRequestHeaderCollection const &headers) noexcept;
|
|
65
|
+
|
|
66
|
+
static AccessControlValues ExtractAccessControlValues(
|
|
67
|
+
winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::hstring> const &headers);
|
|
68
|
+
|
|
69
|
+
static bool IsCorsSafelistedRequestHeader(winrt::hstring const &name, winrt::hstring const &value) noexcept;
|
|
70
|
+
|
|
71
|
+
static bool IsCorsUnsafeRequestHeaderByte(wchar_t c) noexcept;
|
|
72
|
+
|
|
73
|
+
// Filter out Http-Only cookies from response headers to prevent malicious code from being sent to a malicious server
|
|
74
|
+
static void RemoveHttpOnlyCookiesFromResponseHeaders(
|
|
75
|
+
winrt::Windows::Web::Http::HttpResponseMessage const &response,
|
|
76
|
+
bool removeAll);
|
|
77
|
+
|
|
78
|
+
OriginPolicyHttpFilter(winrt::Windows::Web::Http::Filters::IHttpFilter &&innerFilter);
|
|
79
|
+
|
|
80
|
+
OriginPolicyHttpFilter();
|
|
81
|
+
|
|
82
|
+
OriginPolicy ValidateRequest(winrt::Windows::Web::Http::HttpRequestMessage const &request);
|
|
83
|
+
|
|
84
|
+
void ValidatePreflightResponse(
|
|
85
|
+
winrt::Windows::Web::Http::HttpRequestMessage const &request,
|
|
86
|
+
winrt::Windows::Web::Http::HttpResponseMessage const &response) const;
|
|
87
|
+
|
|
88
|
+
void ValidateResponse(
|
|
89
|
+
winrt::Windows::Web::Http::HttpResponseMessage const &response,
|
|
90
|
+
const OriginPolicy effectivePolicy) const;
|
|
91
|
+
|
|
92
|
+
void ValidateAllowOrigin(
|
|
93
|
+
winrt::hstring const &allowedOrigin,
|
|
94
|
+
winrt::hstring const &allowCredentials,
|
|
95
|
+
winrt::Windows::Foundation::IInspectable const &iArgs) const;
|
|
96
|
+
|
|
97
|
+
winrt::Windows::Foundation::IAsyncOperationWithProgress<
|
|
98
|
+
winrt::Windows::Web::Http::HttpResponseMessage,
|
|
99
|
+
winrt::Windows::Web::Http::HttpProgress>
|
|
100
|
+
SendPreflightAsync(winrt::Windows::Web::Http::HttpRequestMessage const &request) const;
|
|
101
|
+
|
|
102
|
+
#pragma region IHttpFilter
|
|
103
|
+
|
|
104
|
+
winrt::Windows::Foundation::IAsyncOperationWithProgress<
|
|
105
|
+
winrt::Windows::Web::Http::HttpResponseMessage,
|
|
106
|
+
winrt::Windows::Web::Http::HttpProgress>
|
|
107
|
+
SendRequestAsync(winrt::Windows::Web::Http::HttpRequestMessage const &request);
|
|
108
|
+
|
|
109
|
+
#pragma endregion IHttpFilter
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "WinRTHttpResource.h"
|
|
5
|
+
|
|
6
|
+
#include <CppRuntimeOptions.h>
|
|
7
|
+
#include <Utils/CppWinrtLessExceptions.h>
|
|
8
|
+
#include <Utils/WinRTConversions.h>
|
|
9
|
+
#include <utilities.h>
|
|
10
|
+
#include "OriginPolicyHttpFilter.h"
|
|
11
|
+
|
|
12
|
+
// Boost Libraries
|
|
13
|
+
#include <boost/algorithm/string.hpp>
|
|
14
|
+
|
|
15
|
+
// Windows API
|
|
16
|
+
#include <winrt/Windows.Security.Cryptography.h>
|
|
17
|
+
#include <winrt/Windows.Storage.Streams.h>
|
|
18
|
+
#include <winrt/Windows.Web.Http.Headers.h>
|
|
19
|
+
|
|
20
|
+
using std::function;
|
|
21
|
+
using std::scoped_lock;
|
|
22
|
+
using std::shared_ptr;
|
|
23
|
+
using std::string;
|
|
24
|
+
|
|
25
|
+
using winrt::fire_and_forget;
|
|
26
|
+
using winrt::hresult_error;
|
|
27
|
+
using winrt::to_hstring;
|
|
28
|
+
using winrt::to_string;
|
|
29
|
+
using winrt::Windows::Foundation::IInspectable;
|
|
30
|
+
using winrt::Windows::Foundation::Uri;
|
|
31
|
+
using winrt::Windows::Security::Cryptography::CryptographicBuffer;
|
|
32
|
+
using winrt::Windows::Storage::StorageFile;
|
|
33
|
+
using winrt::Windows::Storage::Streams::DataReader;
|
|
34
|
+
using winrt::Windows::Storage::Streams::UnicodeEncoding;
|
|
35
|
+
using winrt::Windows::Web::Http::HttpBufferContent;
|
|
36
|
+
using winrt::Windows::Web::Http::HttpMethod;
|
|
37
|
+
using winrt::Windows::Web::Http::HttpRequestMessage;
|
|
38
|
+
using winrt::Windows::Web::Http::HttpStreamContent;
|
|
39
|
+
using winrt::Windows::Web::Http::HttpStringContent;
|
|
40
|
+
using winrt::Windows::Web::Http::IHttpClient;
|
|
41
|
+
using winrt::Windows::Web::Http::IHttpContent;
|
|
42
|
+
using winrt::Windows::Web::Http::Headers::HttpMediaTypeHeaderValue;
|
|
43
|
+
|
|
44
|
+
namespace Microsoft::React::Networking {
|
|
45
|
+
|
|
46
|
+
#pragma region WinRTHttpResource
|
|
47
|
+
|
|
48
|
+
// TODO: Check for multi-thread issues if there are multiple instances.
|
|
49
|
+
/*static*/ int64_t WinRTHttpResource::s_lastRequestId = 0;
|
|
50
|
+
|
|
51
|
+
WinRTHttpResource::WinRTHttpResource(IHttpClient &&client) noexcept : m_client{std::move(client)} {}
|
|
52
|
+
|
|
53
|
+
WinRTHttpResource::WinRTHttpResource() noexcept : WinRTHttpResource(winrt::Windows::Web::Http::HttpClient()) {}
|
|
54
|
+
|
|
55
|
+
#pragma region IHttpResource
|
|
56
|
+
|
|
57
|
+
void WinRTHttpResource::SendRequest(
|
|
58
|
+
string &&method,
|
|
59
|
+
string &&url,
|
|
60
|
+
Headers &&headers,
|
|
61
|
+
BodyData &&bodyData,
|
|
62
|
+
string &&responseType,
|
|
63
|
+
bool useIncrementalUpdates,
|
|
64
|
+
int64_t timeout,
|
|
65
|
+
bool withCredentials,
|
|
66
|
+
std::function<void(int64_t)> &&callback) noexcept /*override*/ {
|
|
67
|
+
auto requestId = ++s_lastRequestId;
|
|
68
|
+
|
|
69
|
+
// Enforce supported args
|
|
70
|
+
assert(responseType == "text" || responseType == "base64");
|
|
71
|
+
|
|
72
|
+
if (callback) {
|
|
73
|
+
callback(requestId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
HttpMethod httpMethod{to_hstring(std::move(method))};
|
|
78
|
+
Uri uri{to_hstring(std::move(url))};
|
|
79
|
+
HttpRequestMessage request{httpMethod, uri};
|
|
80
|
+
|
|
81
|
+
auto args = winrt::make<RequestArgs>();
|
|
82
|
+
auto concreteArgs = args.as<RequestArgs>();
|
|
83
|
+
concreteArgs->RequestId = requestId;
|
|
84
|
+
concreteArgs->Headers = std::move(headers);
|
|
85
|
+
concreteArgs->Body = std::move(bodyData);
|
|
86
|
+
concreteArgs->IncrementalUpdates = useIncrementalUpdates;
|
|
87
|
+
concreteArgs->WithCredentials = withCredentials;
|
|
88
|
+
concreteArgs->IsText = responseType == "text";
|
|
89
|
+
concreteArgs->Timeout = timeout;
|
|
90
|
+
|
|
91
|
+
PerformSendRequest(std::move(request), args);
|
|
92
|
+
} catch (std::exception const &e) {
|
|
93
|
+
if (m_onError) {
|
|
94
|
+
m_onError(requestId, e.what());
|
|
95
|
+
}
|
|
96
|
+
} catch (hresult_error const &e) {
|
|
97
|
+
if (m_onError) {
|
|
98
|
+
m_onError(requestId, Utilities::HResultToString(e));
|
|
99
|
+
}
|
|
100
|
+
} catch (...) {
|
|
101
|
+
m_onError(requestId, "Unidentified error sending HTTP request");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void WinRTHttpResource::AbortRequest(int64_t requestId) noexcept /*override*/ {
|
|
106
|
+
ResponseOperation request{nullptr};
|
|
107
|
+
|
|
108
|
+
{
|
|
109
|
+
scoped_lock lock{m_mutex};
|
|
110
|
+
auto iter = m_responses.find(requestId);
|
|
111
|
+
if (iter == std::end(m_responses)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
request = iter->second;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
request.Cancel();
|
|
119
|
+
} catch (hresult_error const &e) {
|
|
120
|
+
m_onError(requestId, Utilities::HResultToString(e));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
void WinRTHttpResource::ClearCookies() noexcept /*override*/ {
|
|
125
|
+
assert(false);
|
|
126
|
+
// NOT IMPLEMENTED
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
void WinRTHttpResource::SetOnRequest(function<void(int64_t requestId)> &&handler) noexcept /*override*/ {
|
|
130
|
+
m_onRequest = std::move(handler);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
void WinRTHttpResource::SetOnResponse(function<void(int64_t requestId, Response &&response)> &&handler) noexcept
|
|
134
|
+
/*override*/ {
|
|
135
|
+
m_onResponse = std::move(handler);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
void WinRTHttpResource::SetOnData(function<void(int64_t requestId, string &&responseData)> &&handler) noexcept
|
|
139
|
+
/*override*/ {
|
|
140
|
+
m_onData = std::move(handler);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
void WinRTHttpResource::SetOnError(function<void(int64_t requestId, string &&errorMessage)> &&handler) noexcept
|
|
144
|
+
/*override*/ {
|
|
145
|
+
m_onError = std::move(handler);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#pragma endregion IHttpResource
|
|
149
|
+
|
|
150
|
+
void WinRTHttpResource::TrackResponse(int64_t requestId, ResponseOperation response) noexcept {
|
|
151
|
+
scoped_lock lock{m_mutex};
|
|
152
|
+
m_responses[requestId] = response;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
void WinRTHttpResource::UntrackResponse(int64_t requestId) noexcept {
|
|
156
|
+
scoped_lock lock{m_mutex};
|
|
157
|
+
m_responses.erase(requestId);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
fire_and_forget WinRTHttpResource::PerformSendRequest(HttpRequestMessage &&request, IInspectable const &args) noexcept {
|
|
161
|
+
// Keep references after coroutine suspension.
|
|
162
|
+
auto self = shared_from_this();
|
|
163
|
+
auto coRequest = std::move(request);
|
|
164
|
+
auto coArgs = args;
|
|
165
|
+
auto coReqArgs = coArgs.as<RequestArgs>();
|
|
166
|
+
|
|
167
|
+
// Ensure background thread
|
|
168
|
+
co_await winrt::resume_background();
|
|
169
|
+
|
|
170
|
+
HttpMediaTypeHeaderValue contentType{nullptr};
|
|
171
|
+
string contentEncoding;
|
|
172
|
+
string contentLength;
|
|
173
|
+
|
|
174
|
+
// Headers are generally case-insensitive
|
|
175
|
+
// https://www.ietf.org/rfc/rfc2616.txt section 4.2
|
|
176
|
+
for (auto &header : coReqArgs->Headers) {
|
|
177
|
+
if (boost::iequals(header.first.c_str(), "Content-Type")) {
|
|
178
|
+
bool success = HttpMediaTypeHeaderValue::TryParse(to_hstring(header.second), contentType);
|
|
179
|
+
if (!success && m_onError) {
|
|
180
|
+
co_return m_onError(coReqArgs->RequestId, "Failed to parse Content-Type");
|
|
181
|
+
}
|
|
182
|
+
} else if (boost::iequals(header.first.c_str(), "Content-Encoding")) {
|
|
183
|
+
contentEncoding = header.second;
|
|
184
|
+
} else if (boost::iequals(header.first.c_str(), "Content-Length")) {
|
|
185
|
+
contentLength = header.second;
|
|
186
|
+
} else if (boost::iequals(header.first.c_str(), "Authorization")) {
|
|
187
|
+
bool success =
|
|
188
|
+
coRequest.Headers().TryAppendWithoutValidation(to_hstring(header.first), to_hstring(header.second));
|
|
189
|
+
if (!success && m_onError) {
|
|
190
|
+
co_return m_onError(coReqArgs->RequestId, "Failed to append Authorization");
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
try {
|
|
194
|
+
coRequest.Headers().Append(to_hstring(header.first), to_hstring(header.second));
|
|
195
|
+
} catch (hresult_error const &e) {
|
|
196
|
+
if (self->m_onError) {
|
|
197
|
+
co_return self->m_onError(coReqArgs->RequestId, Utilities::HResultToString(e));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
IHttpContent content{nullptr};
|
|
204
|
+
if (BodyData::Type::String == coReqArgs->Body.Type) {
|
|
205
|
+
content = HttpStringContent{to_hstring(coReqArgs->Body.Data)};
|
|
206
|
+
} else if (BodyData::Type::Base64 == coReqArgs->Body.Type) {
|
|
207
|
+
auto buffer = CryptographicBuffer::DecodeFromBase64String(to_hstring(coReqArgs->Body.Data));
|
|
208
|
+
content = HttpBufferContent{buffer};
|
|
209
|
+
} else if (BodyData::Type::Uri == coReqArgs->Body.Type) {
|
|
210
|
+
auto file = co_await StorageFile::GetFileFromApplicationUriAsync(Uri{to_hstring(coReqArgs->Body.Data)});
|
|
211
|
+
auto stream = co_await file.OpenReadAsync();
|
|
212
|
+
content = HttpStreamContent{stream};
|
|
213
|
+
} else if (BodyData::Type::Form == coReqArgs->Body.Type) {
|
|
214
|
+
// #9535 - HTTP form data support
|
|
215
|
+
} else {
|
|
216
|
+
// BodyData::Type::Empty
|
|
217
|
+
// TODO: Error => unsupported??
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (content != nullptr) {
|
|
221
|
+
// Attach content headers
|
|
222
|
+
if (contentType) {
|
|
223
|
+
content.Headers().ContentType(contentType);
|
|
224
|
+
}
|
|
225
|
+
if (!contentEncoding.empty()) {
|
|
226
|
+
if (!content.Headers().ContentEncoding().TryParseAdd(to_hstring(contentEncoding))) {
|
|
227
|
+
if (m_onError) {
|
|
228
|
+
m_onError(coReqArgs->RequestId, "Failed to parse Content-Encoding");
|
|
229
|
+
}
|
|
230
|
+
co_return;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!contentLength.empty()) {
|
|
234
|
+
const auto contentLengthHeader = _atoi64(contentLength.c_str());
|
|
235
|
+
content.Headers().ContentLength(contentLengthHeader);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
coRequest.Content(content);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
try {
|
|
242
|
+
coRequest.Properties().Insert(L"RequestArgs", coArgs);
|
|
243
|
+
auto sendRequestOp = self->m_client.SendRequestAsync(coRequest);
|
|
244
|
+
self->TrackResponse(coReqArgs->RequestId, sendRequestOp);
|
|
245
|
+
|
|
246
|
+
co_await lessthrow_await_adapter<ResponseOperation>{sendRequestOp};
|
|
247
|
+
auto result = sendRequestOp.ErrorCode();
|
|
248
|
+
if (result < 0) {
|
|
249
|
+
if (self->m_onError) {
|
|
250
|
+
self->m_onError(coReqArgs->RequestId, Utilities::HResultToString(std::move(result)));
|
|
251
|
+
}
|
|
252
|
+
co_return self->UntrackResponse(coReqArgs->RequestId);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
auto response = sendRequestOp.GetResults();
|
|
256
|
+
if (response) {
|
|
257
|
+
if (self->m_onResponse) {
|
|
258
|
+
string url = to_string(response.RequestMessage().RequestUri().AbsoluteUri());
|
|
259
|
+
|
|
260
|
+
// Gather headers for both the response content and the response itself
|
|
261
|
+
// See Invoke-WebRequest PowerShell cmdlet or Chromium response handling
|
|
262
|
+
Headers responseHeaders;
|
|
263
|
+
for (auto header : response.Headers()) {
|
|
264
|
+
responseHeaders.emplace(to_string(header.Key()), to_string(header.Value()));
|
|
265
|
+
}
|
|
266
|
+
for (auto header : response.Content().Headers()) {
|
|
267
|
+
responseHeaders.emplace(to_string(header.Key()), to_string(header.Value()));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
self->m_onResponse(
|
|
271
|
+
coReqArgs->RequestId,
|
|
272
|
+
{static_cast<int32_t>(response.StatusCode()), std::move(url), std::move(responseHeaders)});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// #9534 - Support HTTP incremental updates
|
|
277
|
+
if (response && response.Content()) {
|
|
278
|
+
auto inputStream = co_await response.Content().ReadAsInputStreamAsync();
|
|
279
|
+
auto reader = DataReader{inputStream};
|
|
280
|
+
|
|
281
|
+
if (coReqArgs->IsText) {
|
|
282
|
+
reader.UnicodeEncoding(UnicodeEncoding::Utf8);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// #9510 - 10mb limit on fetch
|
|
286
|
+
co_await reader.LoadAsync(10 * 1024 * 1024);
|
|
287
|
+
auto length = reader.UnconsumedBufferLength();
|
|
288
|
+
|
|
289
|
+
if (coReqArgs->IsText) {
|
|
290
|
+
std::vector<uint8_t> data(length);
|
|
291
|
+
reader.ReadBytes(data);
|
|
292
|
+
string responseData = string(Common::Utilities::CheckedReinterpretCast<char *>(data.data()), data.size());
|
|
293
|
+
|
|
294
|
+
if (self->m_onData) {
|
|
295
|
+
self->m_onData(coReqArgs->RequestId, std::move(responseData));
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
auto buffer = reader.ReadBuffer(length);
|
|
299
|
+
auto data = CryptographicBuffer::EncodeToBase64String(buffer);
|
|
300
|
+
auto responseData = to_string(std::wstring_view(data));
|
|
301
|
+
|
|
302
|
+
if (self->m_onData) {
|
|
303
|
+
self->m_onData(coReqArgs->RequestId, std::move(responseData));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
if (self->m_onError) {
|
|
308
|
+
self->m_onError(coReqArgs->RequestId, response == nullptr ? "request failed" : "No response content");
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
} catch (std::exception const &e) {
|
|
312
|
+
if (self->m_onError) {
|
|
313
|
+
self->m_onError(coReqArgs->RequestId, e.what());
|
|
314
|
+
}
|
|
315
|
+
} catch (hresult_error const &e) {
|
|
316
|
+
if (self->m_onError) {
|
|
317
|
+
self->m_onError(coReqArgs->RequestId, Utilities::HResultToString(e));
|
|
318
|
+
}
|
|
319
|
+
} catch (...) {
|
|
320
|
+
if (self->m_onError) {
|
|
321
|
+
self->m_onError(coReqArgs->RequestId, "Unhandled exception during request");
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
self->UntrackResponse(coReqArgs->RequestId);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
#pragma endregion WinRTHttpResource
|
|
329
|
+
|
|
330
|
+
#pragma region IHttpResource
|
|
331
|
+
|
|
332
|
+
/*static*/ shared_ptr<IHttpResource> IHttpResource::Make() noexcept {
|
|
333
|
+
if (static_cast<OriginPolicy>(GetRuntimeOptionInt("Http.OriginPolicy")) == OriginPolicy::None) {
|
|
334
|
+
return std::make_shared<WinRTHttpResource>();
|
|
335
|
+
} else {
|
|
336
|
+
auto globalOrigin = GetRuntimeOptionString("Http.GlobalOrigin");
|
|
337
|
+
OriginPolicyHttpFilter::SetStaticOrigin(std::move(globalOrigin));
|
|
338
|
+
auto opFilter = winrt::make<OriginPolicyHttpFilter>();
|
|
339
|
+
auto client = winrt::Windows::Web::Http::HttpClient{opFilter};
|
|
340
|
+
|
|
341
|
+
return std::make_shared<WinRTHttpResource>(std::move(client));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
#pragma endregion IHttpResource
|
|
346
|
+
|
|
347
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "IHttpResource.h"
|
|
7
|
+
|
|
8
|
+
#include "WinRTTypes.h"
|
|
9
|
+
|
|
10
|
+
// Windows API
|
|
11
|
+
#include <winrt/Windows.Web.Http.h>
|
|
12
|
+
|
|
13
|
+
// Standard Library
|
|
14
|
+
#include <mutex>
|
|
15
|
+
|
|
16
|
+
namespace Microsoft::React::Networking {
|
|
17
|
+
|
|
18
|
+
class WinRTHttpResource : public IHttpResource, public std::enable_shared_from_this<WinRTHttpResource> {
|
|
19
|
+
static int64_t s_lastRequestId;
|
|
20
|
+
|
|
21
|
+
winrt::Windows::Web::Http::IHttpClient m_client;
|
|
22
|
+
std::mutex m_mutex;
|
|
23
|
+
std::unordered_map<int64_t, ResponseOperation> m_responses;
|
|
24
|
+
|
|
25
|
+
std::function<void(int64_t requestId)> m_onRequest;
|
|
26
|
+
std::function<void(int64_t requestId, Response &&response)> m_onResponse;
|
|
27
|
+
std::function<void(int64_t requestId, std::string &&responseData)> m_onData;
|
|
28
|
+
std::function<void(int64_t requestId, std::string &&errorMessage /*, bool isTimeout*/)> m_onError;
|
|
29
|
+
|
|
30
|
+
void TrackResponse(int64_t requestId, ResponseOperation response) noexcept;
|
|
31
|
+
|
|
32
|
+
void UntrackResponse(int64_t requestId) noexcept;
|
|
33
|
+
|
|
34
|
+
winrt::fire_and_forget PerformSendRequest(
|
|
35
|
+
winrt::Windows::Web::Http::HttpRequestMessage &&request,
|
|
36
|
+
winrt::Windows::Foundation::IInspectable const &args) noexcept;
|
|
37
|
+
|
|
38
|
+
public:
|
|
39
|
+
WinRTHttpResource() noexcept;
|
|
40
|
+
|
|
41
|
+
WinRTHttpResource(winrt::Windows::Web::Http::IHttpClient &&client) noexcept;
|
|
42
|
+
|
|
43
|
+
#pragma region IHttpResource
|
|
44
|
+
|
|
45
|
+
void SendRequest(
|
|
46
|
+
std::string &&method,
|
|
47
|
+
std::string &&url,
|
|
48
|
+
Headers &&headers,
|
|
49
|
+
BodyData &&bodyData,
|
|
50
|
+
std::string &&responseType,
|
|
51
|
+
bool useIncrementalUpdates,
|
|
52
|
+
int64_t timeout,
|
|
53
|
+
bool withCredentials,
|
|
54
|
+
std::function<void(int64_t)> &&callback) noexcept override;
|
|
55
|
+
void AbortRequest(int64_t requestId) noexcept override;
|
|
56
|
+
void ClearCookies() noexcept override;
|
|
57
|
+
|
|
58
|
+
#pragma endregion IHttpResource
|
|
59
|
+
|
|
60
|
+
void SetOnRequest(std::function<void(int64_t requestId)> &&handler) noexcept override;
|
|
61
|
+
void SetOnResponse(std::function<void(int64_t requestId, Response &&response)> &&handler) noexcept override;
|
|
62
|
+
void SetOnData(std::function<void(int64_t requestId, std::string &&responseData)> &&handler) noexcept override;
|
|
63
|
+
void SetOnError(std::function<void(int64_t requestId, std::string &&errorMessage /*, bool isTimeout*/)>
|
|
64
|
+
&&handler) noexcept override;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "IHttpResource.h"
|
|
7
|
+
|
|
8
|
+
// Windows API
|
|
9
|
+
#include <winrt/Windows.Web.Http.h>
|
|
10
|
+
|
|
11
|
+
// Standard Library
|
|
12
|
+
#include <mutex>
|
|
13
|
+
|
|
14
|
+
namespace Microsoft::React::Networking {
|
|
15
|
+
|
|
16
|
+
struct RequestArgs : public winrt::implements<RequestArgs, winrt::Windows::Foundation::IInspectable> {
|
|
17
|
+
int64_t RequestId;
|
|
18
|
+
IHttpResource::Headers Headers;
|
|
19
|
+
IHttpResource::BodyData Body;
|
|
20
|
+
bool IncrementalUpdates;
|
|
21
|
+
bool WithCredentials;
|
|
22
|
+
bool IsText;
|
|
23
|
+
int64_t Timeout;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
typedef winrt::Windows::Foundation::
|
|
27
|
+
IAsyncOperationWithProgress<winrt::Windows::Web::Http::HttpResponseMessage, winrt::Windows::Web::Http::HttpProgress>
|
|
28
|
+
ResponseOperation;
|
|
29
|
+
|
|
30
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
#include <Utilities.h>
|
|
7
7
|
#include <Utils/CppWinrtLessExceptions.h>
|
|
8
|
+
#include <Utils/WinRTConversions.h>
|
|
9
|
+
|
|
10
|
+
// MSO
|
|
11
|
+
#include <dispatchQueue/dispatchQueue.h>
|
|
8
12
|
|
|
9
13
|
// Windows API
|
|
10
14
|
#include <winrt/Windows.Foundation.Collections.h>
|
|
@@ -44,6 +48,7 @@ using winrt::Windows::Storage::Streams::IDataWriter;
|
|
|
44
48
|
using winrt::Windows::Storage::Streams::UnicodeEncoding;
|
|
45
49
|
|
|
46
50
|
namespace {
|
|
51
|
+
|
|
47
52
|
///
|
|
48
53
|
/// Implements an awaiter for Mso::DispatchQueue
|
|
49
54
|
///
|
|
@@ -72,20 +77,9 @@ auto resume_in_queue(const Mso::DispatchQueue &queue) noexcept {
|
|
|
72
77
|
return awaitable{queue};
|
|
73
78
|
} // resume_in_queue
|
|
74
79
|
|
|
75
|
-
string HResultToString(hresult_error const &e) {
|
|
76
|
-
std::stringstream stream;
|
|
77
|
-
stream << "[0x" << std::hex << e.code() << "] " << winrt::to_string(e.message());
|
|
78
|
-
|
|
79
|
-
return stream.str();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
string HResultToString(hresult &&result) {
|
|
83
|
-
return HResultToString(hresult_error(std::move(result), hresult_error::from_abi));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
80
|
} // namespace
|
|
87
81
|
|
|
88
|
-
namespace Microsoft::React {
|
|
82
|
+
namespace Microsoft::React::Networking {
|
|
89
83
|
|
|
90
84
|
// private
|
|
91
85
|
WinRTWebSocketResource::WinRTWebSocketResource(
|
|
@@ -134,12 +128,12 @@ IAsyncAction WinRTWebSocketResource::PerformConnect(Uri &&uri) noexcept {
|
|
|
134
128
|
}
|
|
135
129
|
} else {
|
|
136
130
|
if (self->m_errorHandler) {
|
|
137
|
-
self->m_errorHandler({HResultToString(std::move(result)), ErrorType::Connection});
|
|
131
|
+
self->m_errorHandler({Utilities::HResultToString(std::move(result)), ErrorType::Connection});
|
|
138
132
|
}
|
|
139
133
|
}
|
|
140
134
|
} catch (hresult_error const &e) {
|
|
141
135
|
if (self->m_errorHandler) {
|
|
142
|
-
self->m_errorHandler({HResultToString(e), ErrorType::Connection});
|
|
136
|
+
self->m_errorHandler({Utilities::HResultToString(e), ErrorType::Connection});
|
|
143
137
|
}
|
|
144
138
|
}
|
|
145
139
|
|
|
@@ -180,12 +174,12 @@ fire_and_forget WinRTWebSocketResource::PerformPing() noexcept {
|
|
|
180
174
|
}
|
|
181
175
|
} else {
|
|
182
176
|
if (self->m_errorHandler) {
|
|
183
|
-
self->m_errorHandler({HResultToString(std::move(result)), ErrorType::Ping});
|
|
177
|
+
self->m_errorHandler({Utilities::HResultToString(std::move(result)), ErrorType::Ping});
|
|
184
178
|
}
|
|
185
179
|
}
|
|
186
180
|
} catch (hresult_error const &e) {
|
|
187
181
|
if (self->m_errorHandler) {
|
|
188
|
-
self->m_errorHandler({HResultToString(e), ErrorType::Ping});
|
|
182
|
+
self->m_errorHandler({Utilities::HResultToString(e), ErrorType::Ping});
|
|
189
183
|
}
|
|
190
184
|
}
|
|
191
185
|
}
|
|
@@ -246,7 +240,7 @@ fire_and_forget WinRTWebSocketResource::PerformWrite(string &&message, bool isBi
|
|
|
246
240
|
}
|
|
247
241
|
} else {
|
|
248
242
|
if (self->m_errorHandler) {
|
|
249
|
-
self->m_errorHandler({HResultToString(std::move(result)), ErrorType::Send});
|
|
243
|
+
self->m_errorHandler({Utilities::HResultToString(std::move(result)), ErrorType::Send});
|
|
250
244
|
}
|
|
251
245
|
}
|
|
252
246
|
} catch (std::exception const &e) {
|
|
@@ -256,7 +250,7 @@ fire_and_forget WinRTWebSocketResource::PerformWrite(string &&message, bool isBi
|
|
|
256
250
|
} catch (hresult_error const &e) {
|
|
257
251
|
// TODO: Remove after fixing unit tests exceptions.
|
|
258
252
|
if (self->m_errorHandler) {
|
|
259
|
-
self->m_errorHandler({HResultToString(e), ErrorType::Ping});
|
|
253
|
+
self->m_errorHandler({Utilities::HResultToString(e), ErrorType::Ping});
|
|
260
254
|
}
|
|
261
255
|
}
|
|
262
256
|
}
|
|
@@ -278,7 +272,7 @@ fire_and_forget WinRTWebSocketResource::PerformClose() noexcept {
|
|
|
278
272
|
}
|
|
279
273
|
} catch (hresult_error const &e) {
|
|
280
274
|
if (m_errorHandler) {
|
|
281
|
-
m_errorHandler({HResultToString(e), ErrorType::Close});
|
|
275
|
+
m_errorHandler({Utilities::HResultToString(e), ErrorType::Close});
|
|
282
276
|
}
|
|
283
277
|
}
|
|
284
278
|
|
|
@@ -322,7 +316,22 @@ void WinRTWebSocketResource::Connect(string &&url, const Protocols &protocols, c
|
|
|
322
316
|
}
|
|
323
317
|
} catch (hresult_error const &e) {
|
|
324
318
|
if (self->m_errorHandler) {
|
|
325
|
-
|
|
319
|
+
string errorMessage;
|
|
320
|
+
ErrorType errorType;
|
|
321
|
+
// See
|
|
322
|
+
// https://docs.microsoft.com/uwp/api/windows.networking.sockets.messagewebsocketmessagereceivedeventargs.getdatareader?view=winrt-19041#remarks
|
|
323
|
+
if (e.code() == WININET_E_CONNECTION_ABORTED) {
|
|
324
|
+
errorMessage = "[0x80072EFE] Underlying TCP connection suddenly terminated";
|
|
325
|
+
errorType = ErrorType::Connection;
|
|
326
|
+
self->m_errorHandler({errorMessage, errorType});
|
|
327
|
+
|
|
328
|
+
// Note: We are not clear whether all read-related errors should close the socket.
|
|
329
|
+
self->Close(CloseCode::BadPayload, std::move(errorMessage));
|
|
330
|
+
} else {
|
|
331
|
+
errorMessage = Utilities::HResultToString(e);
|
|
332
|
+
errorType = ErrorType::Receive;
|
|
333
|
+
self->m_errorHandler({errorMessage, errorType});
|
|
334
|
+
}
|
|
326
335
|
}
|
|
327
336
|
}
|
|
328
337
|
});
|
|
@@ -346,7 +355,7 @@ void WinRTWebSocketResource::Connect(string &&url, const Protocols &protocols, c
|
|
|
346
355
|
uri = Uri{winrt::to_hstring(url)};
|
|
347
356
|
} catch (hresult_error const &e) {
|
|
348
357
|
if (m_errorHandler) {
|
|
349
|
-
m_errorHandler({HResultToString(e), ErrorType::Connection});
|
|
358
|
+
m_errorHandler({Utilities::HResultToString(e), ErrorType::Connection});
|
|
350
359
|
}
|
|
351
360
|
|
|
352
361
|
// Abort - Mark connection as concluded.
|
|
@@ -414,4 +423,4 @@ void WinRTWebSocketResource::SetOnError(function<void(Error &&)> &&handler) noex
|
|
|
414
423
|
|
|
415
424
|
#pragma endregion IWebSocketResource
|
|
416
425
|
|
|
417
|
-
} // namespace Microsoft::React
|
|
426
|
+
} // namespace Microsoft::React::Networking
|