react-native-windows 0.68.3 → 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/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 +14 -1
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
- package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -1
- package/Microsoft.ReactNative/ReactRootView.cpp +2 -1
- package/Microsoft.ReactNative/RedBox.cpp +3 -2
- 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 +10 -1
- 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 +1 -1
- 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/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/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/DevSupportManager.cpp +32 -36
- 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/RuntimeHolder.h +2 -0
- package/Shared/Modules/HttpModule.cpp +1 -1
- package/Shared/Modules/HttpModule.h +2 -2
- package/Shared/Modules/WebSocketModule.cpp +1 -1
- package/Shared/Modules/WebSocketModule.h +8 -5
- package/Shared/{IHttpResource.h → Networking/IHttpResource.h} +4 -4
- package/Shared/{IWebSocketResource.h → Networking/IWebSocketResource.h} +2 -2
- package/Shared/Networking/OriginPolicy.h +15 -0
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +746 -0
- package/Shared/Networking/OriginPolicyHttpFilter.h +112 -0
- package/Shared/{WinRTHttpResource.cpp → Networking/WinRTHttpResource.cpp} +129 -99
- package/Shared/{WinRTHttpResource.h → Networking/WinRTHttpResource.h} +8 -12
- package/Shared/Networking/WinRTTypes.h +30 -0
- package/Shared/{WinRTWebSocketResource.cpp → Networking/WinRTWebSocketResource.cpp} +2 -2
- package/Shared/{WinRTWebSocketResource.h → Networking/WinRTWebSocketResource.h} +3 -3
- package/Shared/OInstance.cpp +5 -5
- package/Shared/RuntimeOptions.cpp +93 -15
- package/Shared/RuntimeOptions.h +22 -9
- package/Shared/Shared.vcxitems +122 -7
- package/Shared/Shared.vcxitems.filters +40 -21
- package/Shared/Threading/BatchingQueueThread.cpp +1 -1
- 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/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
|
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
#include "WinRTHttpResource.h"
|
|
5
5
|
|
|
6
|
+
#include <CppRuntimeOptions.h>
|
|
6
7
|
#include <Utils/CppWinrtLessExceptions.h>
|
|
7
8
|
#include <Utils/WinRTConversions.h>
|
|
8
9
|
#include <utilities.h>
|
|
10
|
+
#include "OriginPolicyHttpFilter.h"
|
|
11
|
+
|
|
12
|
+
// Boost Libraries
|
|
13
|
+
#include <boost/algorithm/string.hpp>
|
|
9
14
|
|
|
10
15
|
// Windows API
|
|
11
16
|
#include <winrt/Windows.Security.Cryptography.h>
|
|
@@ -21,6 +26,7 @@ using winrt::fire_and_forget;
|
|
|
21
26
|
using winrt::hresult_error;
|
|
22
27
|
using winrt::to_hstring;
|
|
23
28
|
using winrt::to_string;
|
|
29
|
+
using winrt::Windows::Foundation::IInspectable;
|
|
24
30
|
using winrt::Windows::Foundation::Uri;
|
|
25
31
|
using winrt::Windows::Security::Cryptography::CryptographicBuffer;
|
|
26
32
|
using winrt::Windows::Storage::StorageFile;
|
|
@@ -35,7 +41,7 @@ using winrt::Windows::Web::Http::IHttpClient;
|
|
|
35
41
|
using winrt::Windows::Web::Http::IHttpContent;
|
|
36
42
|
using winrt::Windows::Web::Http::Headers::HttpMediaTypeHeaderValue;
|
|
37
43
|
|
|
38
|
-
namespace Microsoft::React {
|
|
44
|
+
namespace Microsoft::React::Networking {
|
|
39
45
|
|
|
40
46
|
#pragma region WinRTHttpResource
|
|
41
47
|
|
|
@@ -71,72 +77,18 @@ void WinRTHttpResource::SendRequest(
|
|
|
71
77
|
HttpMethod httpMethod{to_hstring(std::move(method))};
|
|
72
78
|
Uri uri{to_hstring(std::move(url))};
|
|
73
79
|
HttpRequestMessage request{httpMethod, uri};
|
|
74
|
-
HttpMediaTypeHeaderValue contentType{nullptr};
|
|
75
|
-
string contentEncoding;
|
|
76
|
-
string contentLength;
|
|
77
|
-
|
|
78
|
-
// Headers are generally case-insensitive
|
|
79
|
-
// https://www.ietf.org/rfc/rfc2616.txt section 4.2
|
|
80
|
-
for (auto &header : headers) {
|
|
81
|
-
if (_stricmp(header.first.c_str(), "content-type") == 0) {
|
|
82
|
-
bool success = HttpMediaTypeHeaderValue::TryParse(to_hstring(header.second), contentType);
|
|
83
|
-
if (!success && m_onError) {
|
|
84
|
-
return m_onError(requestId, "Failed to parse Content-Type");
|
|
85
|
-
}
|
|
86
|
-
} else if (_stricmp(header.first.c_str(), "content-encoding") == 0) {
|
|
87
|
-
contentEncoding = header.second;
|
|
88
|
-
} else if (_stricmp(header.first.c_str(), "content-length") == 0) {
|
|
89
|
-
contentLength = header.second;
|
|
90
|
-
} else if (_stricmp(header.first.c_str(), "authorization") == 0) {
|
|
91
|
-
bool success =
|
|
92
|
-
request.Headers().TryAppendWithoutValidation(to_hstring(header.first), to_hstring(header.second));
|
|
93
|
-
if (!success && m_onError) {
|
|
94
|
-
return m_onError(requestId, "Failed to append Authorization");
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
request.Headers().Append(to_hstring(header.first), to_hstring(header.second));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
IHttpContent content{nullptr};
|
|
102
|
-
if (BodyData::Type::String == bodyData.Type) {
|
|
103
|
-
content = HttpStringContent{to_hstring(bodyData.Data)};
|
|
104
|
-
} else if (BodyData::Type::Base64 == bodyData.Type) {
|
|
105
|
-
auto buffer = CryptographicBuffer::DecodeFromBase64String(to_hstring(bodyData.Data));
|
|
106
|
-
content = HttpBufferContent{buffer};
|
|
107
|
-
} else if (BodyData::Type::Uri == bodyData.Type) {
|
|
108
|
-
auto file = StorageFile::GetFileFromApplicationUriAsync(Uri{to_hstring(bodyData.Data)}).get();
|
|
109
|
-
auto stream = file.OpenReadAsync().get();
|
|
110
|
-
content = HttpStreamContent{stream};
|
|
111
|
-
} else if (BodyData::Type::Form == bodyData.Type) {
|
|
112
|
-
// TODO: Add support
|
|
113
|
-
} else {
|
|
114
|
-
// BodyData::Type::Empty
|
|
115
|
-
// TODO: Error 'cause unsupported??
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (content != nullptr) {
|
|
119
|
-
// Attach content headers
|
|
120
|
-
if (contentType) {
|
|
121
|
-
content.Headers().ContentType(contentType);
|
|
122
|
-
}
|
|
123
|
-
if (!contentEncoding.empty()) {
|
|
124
|
-
if (!content.Headers().ContentEncoding().TryParseAdd(to_hstring(contentEncoding))) {
|
|
125
|
-
if (m_onError) {
|
|
126
|
-
m_onError(requestId, "Failed to parse Content-Encoding");
|
|
127
|
-
}
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (!contentLength.empty()) {
|
|
132
|
-
const auto contentLengthHeader = _atoi64(contentLength.c_str()); // TODO: Alternatives to _atoi64?
|
|
133
|
-
content.Headers().ContentLength(contentLengthHeader);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
request.Content(content);
|
|
137
|
-
}
|
|
138
80
|
|
|
139
|
-
|
|
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);
|
|
140
92
|
} catch (std::exception const &e) {
|
|
141
93
|
if (m_onError) {
|
|
142
94
|
m_onError(requestId, e.what());
|
|
@@ -151,7 +103,7 @@ void WinRTHttpResource::SendRequest(
|
|
|
151
103
|
}
|
|
152
104
|
|
|
153
105
|
void WinRTHttpResource::AbortRequest(int64_t requestId) noexcept /*override*/ {
|
|
154
|
-
|
|
106
|
+
ResponseOperation request{nullptr};
|
|
155
107
|
|
|
156
108
|
{
|
|
157
109
|
scoped_lock lock{m_mutex};
|
|
@@ -183,7 +135,7 @@ void WinRTHttpResource::SetOnResponse(function<void(int64_t requestId, Response
|
|
|
183
135
|
m_onResponse = std::move(handler);
|
|
184
136
|
}
|
|
185
137
|
|
|
186
|
-
void WinRTHttpResource::SetOnData(function<void(int64_t requestId,
|
|
138
|
+
void WinRTHttpResource::SetOnData(function<void(int64_t requestId, string &&responseData)> &&handler) noexcept
|
|
187
139
|
/*override*/ {
|
|
188
140
|
m_onData = std::move(handler);
|
|
189
141
|
}
|
|
@@ -195,7 +147,7 @@ void WinRTHttpResource::SetOnError(function<void(int64_t requestId, string &&err
|
|
|
195
147
|
|
|
196
148
|
#pragma endregion IHttpResource
|
|
197
149
|
|
|
198
|
-
void WinRTHttpResource::TrackResponse(int64_t requestId,
|
|
150
|
+
void WinRTHttpResource::TrackResponse(int64_t requestId, ResponseOperation response) noexcept {
|
|
199
151
|
scoped_lock lock{m_mutex};
|
|
200
152
|
m_responses[requestId] = response;
|
|
201
153
|
}
|
|
@@ -205,70 +157,142 @@ void WinRTHttpResource::UntrackResponse(int64_t requestId) noexcept {
|
|
|
205
157
|
m_responses.erase(requestId);
|
|
206
158
|
}
|
|
207
159
|
|
|
208
|
-
fire_and_forget
|
|
209
|
-
WinRTHttpResource::PerformSendRequest(int64_t requestId, HttpRequestMessage &&request, bool textResponse) noexcept {
|
|
160
|
+
fire_and_forget WinRTHttpResource::PerformSendRequest(HttpRequestMessage &&request, IInspectable const &args) noexcept {
|
|
210
161
|
// Keep references after coroutine suspension.
|
|
211
162
|
auto self = shared_from_this();
|
|
212
163
|
auto coRequest = std::move(request);
|
|
164
|
+
auto coArgs = args;
|
|
165
|
+
auto coReqArgs = coArgs.as<RequestArgs>();
|
|
213
166
|
|
|
214
167
|
// Ensure background thread
|
|
215
168
|
co_await winrt::resume_background();
|
|
216
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
|
+
|
|
217
241
|
try {
|
|
242
|
+
coRequest.Properties().Insert(L"RequestArgs", coArgs);
|
|
218
243
|
auto sendRequestOp = self->m_client.SendRequestAsync(coRequest);
|
|
244
|
+
self->TrackResponse(coReqArgs->RequestId, sendRequestOp);
|
|
219
245
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
co_await lessthrow_await_adapter<ResponseType>{sendRequestOp};
|
|
246
|
+
co_await lessthrow_await_adapter<ResponseOperation>{sendRequestOp};
|
|
223
247
|
auto result = sendRequestOp.ErrorCode();
|
|
224
248
|
if (result < 0) {
|
|
225
249
|
if (self->m_onError) {
|
|
226
|
-
self->m_onError(
|
|
250
|
+
self->m_onError(coReqArgs->RequestId, Utilities::HResultToString(std::move(result)));
|
|
227
251
|
}
|
|
228
|
-
self->UntrackResponse(
|
|
229
|
-
co_return;
|
|
252
|
+
co_return self->UntrackResponse(coReqArgs->RequestId);
|
|
230
253
|
}
|
|
231
254
|
|
|
232
255
|
auto response = sendRequestOp.GetResults();
|
|
233
256
|
if (response) {
|
|
234
257
|
if (self->m_onResponse) {
|
|
235
|
-
|
|
258
|
+
string url = to_string(response.RequestMessage().RequestUri().AbsoluteUri());
|
|
236
259
|
|
|
237
260
|
// Gather headers for both the response content and the response itself
|
|
238
261
|
// See Invoke-WebRequest PowerShell cmdlet or Chromium response handling
|
|
262
|
+
Headers responseHeaders;
|
|
239
263
|
for (auto header : response.Headers()) {
|
|
240
|
-
|
|
264
|
+
responseHeaders.emplace(to_string(header.Key()), to_string(header.Value()));
|
|
241
265
|
}
|
|
242
266
|
for (auto header : response.Content().Headers()) {
|
|
243
|
-
|
|
267
|
+
responseHeaders.emplace(to_string(header.Key()), to_string(header.Value()));
|
|
244
268
|
}
|
|
245
|
-
|
|
269
|
+
|
|
246
270
|
self->m_onResponse(
|
|
247
|
-
|
|
271
|
+
coReqArgs->RequestId,
|
|
272
|
+
{static_cast<int32_t>(response.StatusCode()), std::move(url), std::move(responseHeaders)});
|
|
248
273
|
}
|
|
249
274
|
}
|
|
250
275
|
|
|
251
|
-
//
|
|
276
|
+
// #9534 - Support HTTP incremental updates
|
|
252
277
|
if (response && response.Content()) {
|
|
253
278
|
auto inputStream = co_await response.Content().ReadAsInputStreamAsync();
|
|
254
279
|
auto reader = DataReader{inputStream};
|
|
255
280
|
|
|
256
|
-
if (
|
|
281
|
+
if (coReqArgs->IsText) {
|
|
257
282
|
reader.UnicodeEncoding(UnicodeEncoding::Utf8);
|
|
258
283
|
}
|
|
259
284
|
|
|
260
|
-
//
|
|
261
|
-
// TODO: WHY????
|
|
285
|
+
// #9510 - 10mb limit on fetch
|
|
262
286
|
co_await reader.LoadAsync(10 * 1024 * 1024);
|
|
263
287
|
auto length = reader.UnconsumedBufferLength();
|
|
264
288
|
|
|
265
|
-
if (
|
|
289
|
+
if (coReqArgs->IsText) {
|
|
266
290
|
std::vector<uint8_t> data(length);
|
|
267
291
|
reader.ReadBytes(data);
|
|
268
292
|
string responseData = string(Common::Utilities::CheckedReinterpretCast<char *>(data.data()), data.size());
|
|
269
293
|
|
|
270
294
|
if (self->m_onData) {
|
|
271
|
-
self->m_onData(
|
|
295
|
+
self->m_onData(coReqArgs->RequestId, std::move(responseData));
|
|
272
296
|
}
|
|
273
297
|
} else {
|
|
274
298
|
auto buffer = reader.ReadBuffer(length);
|
|
@@ -276,32 +300,29 @@ WinRTHttpResource::PerformSendRequest(int64_t requestId, HttpRequestMessage &&re
|
|
|
276
300
|
auto responseData = to_string(std::wstring_view(data));
|
|
277
301
|
|
|
278
302
|
if (self->m_onData) {
|
|
279
|
-
self->m_onData(
|
|
303
|
+
self->m_onData(coReqArgs->RequestId, std::move(responseData));
|
|
280
304
|
}
|
|
281
305
|
}
|
|
282
306
|
} else {
|
|
283
307
|
if (self->m_onError) {
|
|
284
|
-
self->m_onError(
|
|
308
|
+
self->m_onError(coReqArgs->RequestId, response == nullptr ? "request failed" : "No response content");
|
|
285
309
|
}
|
|
286
310
|
}
|
|
287
311
|
} catch (std::exception const &e) {
|
|
288
312
|
if (self->m_onError) {
|
|
289
|
-
self->m_onError(
|
|
313
|
+
self->m_onError(coReqArgs->RequestId, e.what());
|
|
290
314
|
}
|
|
291
315
|
} catch (hresult_error const &e) {
|
|
292
316
|
if (self->m_onError) {
|
|
293
|
-
self->m_onError(
|
|
317
|
+
self->m_onError(coReqArgs->RequestId, Utilities::HResultToString(e));
|
|
294
318
|
}
|
|
295
319
|
} catch (...) {
|
|
296
320
|
if (self->m_onError) {
|
|
297
|
-
self->m_onError(
|
|
321
|
+
self->m_onError(coReqArgs->RequestId, "Unhandled exception during request");
|
|
298
322
|
}
|
|
299
323
|
}
|
|
300
324
|
|
|
301
|
-
self->UntrackResponse(
|
|
302
|
-
|
|
303
|
-
// TODO: keep? See https://devblogs.microsoft.com/oldnewthing/?p=106160
|
|
304
|
-
co_return;
|
|
325
|
+
self->UntrackResponse(coReqArgs->RequestId);
|
|
305
326
|
}
|
|
306
327
|
|
|
307
328
|
#pragma endregion WinRTHttpResource
|
|
@@ -309,9 +330,18 @@ WinRTHttpResource::PerformSendRequest(int64_t requestId, HttpRequestMessage &&re
|
|
|
309
330
|
#pragma region IHttpResource
|
|
310
331
|
|
|
311
332
|
/*static*/ shared_ptr<IHttpResource> IHttpResource::Make() noexcept {
|
|
312
|
-
|
|
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
|
+
}
|
|
313
343
|
}
|
|
314
344
|
|
|
315
345
|
#pragma endregion IHttpResource
|
|
316
346
|
|
|
317
|
-
} // namespace Microsoft::React
|
|
347
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
-
#include
|
|
6
|
+
#include "IHttpResource.h"
|
|
7
|
+
|
|
8
|
+
#include "WinRTTypes.h"
|
|
7
9
|
|
|
8
10
|
// Windows API
|
|
9
11
|
#include <winrt/Windows.Web.Http.h>
|
|
@@ -11,33 +13,27 @@
|
|
|
11
13
|
// Standard Library
|
|
12
14
|
#include <mutex>
|
|
13
15
|
|
|
14
|
-
namespace Microsoft::React {
|
|
16
|
+
namespace Microsoft::React::Networking {
|
|
15
17
|
|
|
16
18
|
class WinRTHttpResource : public IHttpResource, public std::enable_shared_from_this<WinRTHttpResource> {
|
|
17
|
-
typedef winrt::Windows::Foundation::IAsyncOperationWithProgress<
|
|
18
|
-
winrt::Windows::Web::Http::HttpResponseMessage,
|
|
19
|
-
winrt::Windows::Web::Http::HttpProgress>
|
|
20
|
-
ResponseType;
|
|
21
|
-
|
|
22
19
|
static int64_t s_lastRequestId;
|
|
23
20
|
|
|
24
21
|
winrt::Windows::Web::Http::IHttpClient m_client;
|
|
25
22
|
std::mutex m_mutex;
|
|
26
|
-
std::unordered_map<int64_t,
|
|
23
|
+
std::unordered_map<int64_t, ResponseOperation> m_responses;
|
|
27
24
|
|
|
28
25
|
std::function<void(int64_t requestId)> m_onRequest;
|
|
29
26
|
std::function<void(int64_t requestId, Response &&response)> m_onResponse;
|
|
30
27
|
std::function<void(int64_t requestId, std::string &&responseData)> m_onData;
|
|
31
28
|
std::function<void(int64_t requestId, std::string &&errorMessage /*, bool isTimeout*/)> m_onError;
|
|
32
29
|
|
|
33
|
-
void TrackResponse(int64_t requestId,
|
|
30
|
+
void TrackResponse(int64_t requestId, ResponseOperation response) noexcept;
|
|
34
31
|
|
|
35
32
|
void UntrackResponse(int64_t requestId) noexcept;
|
|
36
33
|
|
|
37
34
|
winrt::fire_and_forget PerformSendRequest(
|
|
38
|
-
int64_t requestId,
|
|
39
35
|
winrt::Windows::Web::Http::HttpRequestMessage &&request,
|
|
40
|
-
|
|
36
|
+
winrt::Windows::Foundation::IInspectable const &args) noexcept;
|
|
41
37
|
|
|
42
38
|
public:
|
|
43
39
|
WinRTHttpResource() noexcept;
|
|
@@ -68,4 +64,4 @@ class WinRTHttpResource : public IHttpResource, public std::enable_shared_from_t
|
|
|
68
64
|
&&handler) noexcept override;
|
|
69
65
|
};
|
|
70
66
|
|
|
71
|
-
} // namespace Microsoft::React
|
|
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
|
|
@@ -79,7 +79,7 @@ auto resume_in_queue(const Mso::DispatchQueue &queue) noexcept {
|
|
|
79
79
|
|
|
80
80
|
} // namespace
|
|
81
81
|
|
|
82
|
-
namespace Microsoft::React {
|
|
82
|
+
namespace Microsoft::React::Networking {
|
|
83
83
|
|
|
84
84
|
// private
|
|
85
85
|
WinRTWebSocketResource::WinRTWebSocketResource(
|
|
@@ -423,4 +423,4 @@ void WinRTWebSocketResource::SetOnError(function<void(Error &&)> &&handler) noex
|
|
|
423
423
|
|
|
424
424
|
#pragma endregion IWebSocketResource
|
|
425
425
|
|
|
426
|
-
} // namespace Microsoft::React
|
|
426
|
+
} // namespace Microsoft::React::Networking
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
#pragma once
|
|
5
5
|
|
|
6
|
-
#include <IWebSocketResource.h>
|
|
7
6
|
#include <dispatchQueue/dispatchQueue.h>
|
|
8
7
|
#include <eventWaitHandle/eventWaitHandle.h>
|
|
9
8
|
#include <winrt/Windows.Networking.Sockets.h>
|
|
10
9
|
#include <winrt/Windows.Storage.Streams.h>
|
|
10
|
+
#include "IWebSocketResource.h"
|
|
11
11
|
|
|
12
12
|
// Standard Library
|
|
13
13
|
#include <future>
|
|
14
14
|
#include <mutex>
|
|
15
15
|
#include <queue>
|
|
16
16
|
|
|
17
|
-
namespace Microsoft::React {
|
|
17
|
+
namespace Microsoft::React::Networking {
|
|
18
18
|
|
|
19
19
|
class WinRTWebSocketResource : public IWebSocketResource, public std::enable_shared_from_this<WinRTWebSocketResource> {
|
|
20
20
|
winrt::Windows::Networking::Sockets::IMessageWebSocket m_socket;
|
|
@@ -126,4 +126,4 @@ class WinRTWebSocketResource : public IWebSocketResource, public std::enable_sha
|
|
|
126
126
|
#pragma endregion IWebSocketResource
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
} // namespace Microsoft::React
|
|
129
|
+
} // namespace Microsoft::React::Networking
|
package/Shared/OInstance.cpp
CHANGED
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
#endif
|
|
38
38
|
|
|
39
39
|
#include <BatchingMessageQueueThread.h>
|
|
40
|
+
#include <CppRuntimeOptions.h>
|
|
40
41
|
#include <CreateModules.h>
|
|
41
42
|
#include <DevSettings.h>
|
|
42
43
|
#include <DevSupportManager.h>
|
|
43
44
|
#include <IReactRootView.h>
|
|
44
|
-
#include <RuntimeOptions.h>
|
|
45
45
|
#include <Shlwapi.h>
|
|
46
46
|
#include <WebSocketJSExecutorFactory.h>
|
|
47
47
|
#include <safeint.h>
|
|
@@ -254,7 +254,7 @@ InstanceImpl::InstanceImpl(
|
|
|
254
254
|
#endif
|
|
255
255
|
|
|
256
256
|
if (shouldStartHermesInspector(*m_devSettings)) {
|
|
257
|
-
m_devManager->
|
|
257
|
+
m_devManager->EnsureHermesInspector(m_devSettings->sourceBundleHost, m_devSettings->sourceBundlePort);
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
// Default (common) NativeModules
|
|
@@ -405,7 +405,7 @@ bool isHBCBundle(const std::string &bundle) {
|
|
|
405
405
|
// can be potentially huge.
|
|
406
406
|
// https://herbsutter.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/#comment-483
|
|
407
407
|
auto header = reinterpret_cast<const BundleHeader *>(&bundle[0]);
|
|
408
|
-
if (HBCBundleMagicNumber ==
|
|
408
|
+
if (HBCBundleMagicNumber == header->magic32.value) {
|
|
409
409
|
return true;
|
|
410
410
|
} else {
|
|
411
411
|
return false;
|
|
@@ -532,8 +532,8 @@ void InstanceImpl::loadBundleInternal(std::string &&jsBundleRelativePath, bool s
|
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
InstanceImpl::~InstanceImpl() {
|
|
535
|
-
if (m_devSettings
|
|
536
|
-
|
|
535
|
+
if (shouldStartHermesInspector(*m_devSettings) && m_devSettings->jsiRuntimeHolder) {
|
|
536
|
+
m_devSettings->jsiRuntimeHolder->teardown();
|
|
537
537
|
}
|
|
538
538
|
m_nativeQueue->quitSynchronous();
|
|
539
539
|
}
|