react-native-windows 0.79.3 → 0.80.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 +12 -3
- package/Directory.Build.props +5 -2
- package/Libraries/Alert/Alert.d.ts +4 -1
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Alert/Alert.windows.js +3 -0
- package/Libraries/Alert/RCTAlertManager.js +17 -0
- package/Libraries/Animated/Animated.js.flow +1 -3
- package/Libraries/Animated/AnimatedEvent.js +4 -3
- package/Libraries/Animated/AnimatedExports.js +2 -2
- package/Libraries/Animated/AnimatedExports.js.flow +140 -0
- package/Libraries/Animated/AnimatedImplementation.js +2 -123
- package/Libraries/Animated/Easing.js +13 -15
- package/Libraries/Animated/animations/Animation.js +8 -4
- package/Libraries/Animated/components/AnimatedFlatList.js +7 -6
- package/Libraries/Animated/components/AnimatedScrollView.js +48 -42
- package/Libraries/Animated/components/AnimatedSectionList.js +11 -7
- package/Libraries/Animated/createAnimatedComponent.js +105 -57
- package/Libraries/Animated/nodes/AnimatedNode.js +4 -3
- package/Libraries/Animated/nodes/AnimatedProps.js +46 -26
- package/Libraries/Animated/nodes/AnimatedValue.js +16 -7
- package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -1
- package/Libraries/AppState/AppState.js +7 -2
- package/Libraries/BatchedBridge/MessageQueue.js +2 -2
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/BlobManager.js +1 -0
- package/Libraries/Blob/FileReader.js +219 -8
- package/Libraries/Blob/URL.js +37 -12
- package/Libraries/Blob/URLSearchParams.js +106 -31
- package/Libraries/Blob/URLSearchParams.js.flow +12 -7
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +1 -1
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js +17 -0
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +1 -0
- package/Libraries/Components/Button.d.ts +3 -0
- package/Libraries/Components/Button.js +1 -1
- package/Libraries/Components/Button.windows.js +27 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -3
- package/Libraries/{NewAppScreen/components/Colors.js → Components/DrawerAndroid/DrawerLayoutAndroid.ios.js} +6 -10
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +6 -66
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js.flow +18 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidFallback.js +71 -0
- package/Libraries/Components/Flyout/Flyout.js +11 -0
- package/Libraries/Components/Keyboard/Keyboard.js +5 -3
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +6 -3
- package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
- package/Libraries/Components/Popup/Popup.js +11 -0
- package/Libraries/Components/Pressable/Pressable.js +20 -4
- package/Libraries/Components/Pressable/Pressable.windows.js +20 -4
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +25 -3
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +29 -20
- package/Libraries/Components/RefreshControl/RefreshControl.js +1 -1
- package/Libraries/Components/RefreshControl/RefreshControl.windows.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.d.ts +3 -3
- package/Libraries/Components/ScrollView/ScrollView.js +132 -122
- package/Libraries/Components/ScrollView/ScrollView.windows.js +131 -122
- package/Libraries/Components/StaticRenderer.js +1 -1
- package/Libraries/Components/Switch/Switch.d.ts +3 -0
- package/Libraries/Components/Switch/Switch.js +8 -4
- package/Libraries/Components/Switch/Switch.windows.js +17 -4
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +2 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +2 -4
- package/Libraries/Components/TextInput/TextInput.d.ts +70 -33
- package/Libraries/Components/TextInput/TextInput.flow.js +100 -51
- package/Libraries/Components/TextInput/TextInput.flow.windows.js +1246 -0
- package/Libraries/Components/TextInput/TextInput.js +88 -1027
- package/Libraries/Components/TextInput/TextInput.windows.js +104 -1092
- package/Libraries/Components/TextInput/TextInputState.js +1 -1
- package/Libraries/Components/TextInput/TextInputState.windows.js +1 -1
- package/Libraries/Components/TextInput/WindowsTextInputNativeComponent.js +2 -1
- package/Libraries/{Modal/ModalInjection.js → Components/ToastAndroid/ToastAndroid.ios.js} +3 -5
- package/Libraries/Components/ToastAndroid/ToastAndroid.js +4 -32
- package/Libraries/Components/ToastAndroid/ToastAndroid.js.flow +109 -0
- package/Libraries/Components/ToastAndroid/ToastAndroidFallback.js +45 -0
- package/Libraries/Components/Touchable/Touchable.js +5 -5
- package/Libraries/Components/Touchable/Touchable.windows.js +5 -5
- package/Libraries/Components/Touchable/TouchableBounce.js +14 -7
- package/Libraries/Components/Touchable/TouchableBounce.windows.js +14 -7
- package/Libraries/Components/Touchable/TouchableHighlight.js +10 -7
- package/Libraries/Components/Touchable/TouchableHighlight.windows.js +10 -7
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +6 -6
- package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +6 -6
- package/Libraries/Components/Touchable/TouchableOpacity.js +13 -6
- package/Libraries/Components/Touchable/TouchableOpacity.windows.js +13 -6
- package/Libraries/Components/View/View.js +18 -21
- package/Libraries/Components/View/View.windows.js +39 -41
- package/Libraries/Components/View/ViewAccessibility.d.ts +8 -0
- package/Libraries/Components/View/ViewAccessibility.js +25 -1
- package/Libraries/Components/View/ViewAccessibility.windows.js +9 -1
- package/Libraries/Components/View/ViewPropTypes.js +49 -3
- package/Libraries/Components/View/ViewPropTypes.windows.js +50 -2
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/setUpReactDevTools.js +5 -5
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +3 -3
- package/Libraries/EventEmitter/NativeEventEmitter.js +9 -4
- package/Libraries/Image/AssetSourceResolver.js +17 -4
- package/Libraries/Image/AssetSourceResolver.windows.js +17 -4
- package/Libraries/Image/Image.d.ts +26 -10
- package/Libraries/Image/Image.js +17 -0
- package/Libraries/Image/Image.js.flow +5 -5
- package/Libraries/Image/Image.windows.js +13 -1
- package/Libraries/Image/ImageBackground.js +2 -0
- package/Libraries/Image/ImageInjection.js +1 -1
- package/Libraries/Image/ImageProps.js +22 -17
- package/Libraries/Image/ImageSource.js +3 -1
- package/Libraries/Image/ImageSourceUtils.js +4 -2
- package/Libraries/Image/ImageTypes.flow.js +1 -1
- package/Libraries/Interaction/InteractionManager.d.ts +13 -0
- package/Libraries/Interaction/InteractionManager.js +1 -1
- package/Libraries/Interaction/PanResponder.js +3 -3
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
- package/Libraries/Linking/Linking.js +1 -1
- package/Libraries/Lists/FlatList.d.ts +2 -2
- package/Libraries/Lists/FlatList.js +8 -11
- package/Libraries/Lists/SectionList.js +39 -42
- package/Libraries/Lists/SectionListModern.js +25 -34
- package/Libraries/Lists/VirtualizedList.js +1 -0
- package/Libraries/Lists/VirtualizedSectionList.js +1 -0
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/LogBoxNotificationContainer.js +1 -1
- package/Libraries/Modal/Modal.js +33 -7
- package/Libraries/Modal/Modal.windows.js +33 -10
- package/Libraries/NativeComponent/BaseViewConfig.android.js +2 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +2 -0
- package/Libraries/NativeComponent/BaseViewConfig.js +17 -0
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +3 -0
- package/Libraries/NativeComponent/PlatformBaseViewConfig.js +2 -2
- package/Libraries/NativeModules/specs/NativeDevMenu.js +2 -2
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.js +17 -0
- package/Libraries/Network/RCTNetworking.js.flow +1 -1
- package/Libraries/Network/RCTNetworking.windows.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +781 -10
- package/Libraries/Performance/Systrace.js +7 -7
- package/Libraries/Pressability/Pressability.js +1 -1
- package/Libraries/Pressability/Pressability.windows.js +1 -1
- package/Libraries/ReactNative/AppContainer-dev.js +5 -4
- package/Libraries/ReactNative/AppRegistry.flow.js +49 -0
- package/Libraries/ReactNative/AppRegistry.js +2 -322
- package/Libraries/ReactNative/AppRegistry.js.flow +23 -0
- package/Libraries/ReactNative/AppRegistryImpl.js +316 -0
- package/Libraries/ReactNative/FabricUIManager.js +10 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -4
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -4
- package/Libraries/ReactNative/RendererImplementation.js +10 -5
- package/Libraries/ReactNative/getNativeComponentAttributes.js +1 -0
- package/Libraries/ReactNative/renderApplication.js +9 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +3 -3
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow +51 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +4840 -4748
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +4947 -4829
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3998 -3888
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5005 -4948
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +2744 -2652
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5020 -4933
- package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -3
- package/Libraries/Settings/Settings.ios.js +1 -0
- package/Libraries/Settings/Settings.js +13 -19
- package/Libraries/Settings/SettingsFallback.js +33 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.js +15 -0
- package/Libraries/StyleSheet/PlatformColorValueTypesIOS.js +6 -0
- package/Libraries/StyleSheet/Rect.js +1 -0
- package/Libraries/StyleSheet/StyleSheet.js +31 -200
- package/Libraries/StyleSheet/StyleSheet.js.flow +188 -0
- package/Libraries/StyleSheet/StyleSheetExports.js +210 -0
- package/Libraries/StyleSheet/StyleSheetExports.js.flow +112 -0
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +130 -52
- package/Libraries/StyleSheet/flattenStyle.js +14 -4
- package/Libraries/StyleSheet/private/_TransformStyle.js +49 -21
- package/Libraries/StyleSheet/processBackgroundImage.js +670 -214
- package/Libraries/Text/Text.d.ts +2 -5
- package/Libraries/Text/Text.js +3 -3
- package/Libraries/Text/Text.windows.js +3 -3
- package/Libraries/Text/TextNativeComponent.js +0 -4
- package/Libraries/Text/TextProps.js +5 -33
- package/Libraries/Text/TextProps.windows.js +5 -32
- package/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
- package/Libraries/{Blob/__mocks__/BlobModule.js → Types/CodegenTypesNamespace.js} +4 -6
- package/Libraries/Types/CoreEventTypes.d.ts +6 -1
- package/Libraries/Types/CoreEventTypes.js +1 -1
- package/Libraries/Types/CoreEventTypes.windows.js +1 -1
- package/Libraries/Utilities/Appearance.js +2 -0
- package/Libraries/Utilities/BackHandler.js +17 -0
- package/Libraries/Utilities/DeviceInfo.js +2 -0
- package/Libraries/Utilities/Dimensions.js +1 -1
- package/Libraries/Utilities/Platform.js +17 -0
- package/Libraries/Utilities/PlatformTypes.js +11 -3
- package/Libraries/Utilities/ReactNativeTestTools.js +2 -2
- package/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
- package/Libraries/Utilities/codegenNativeComponent.d.ts +26 -0
- package/Libraries/WebSocket/WebSocket.js +313 -8
- package/Libraries/vendor/core/ErrorUtils.js +28 -2
- package/Libraries/vendor/emitter/EventEmitter.js +6 -2
- package/Microsoft.ReactNative/CompositionSwitcher.idl +8 -0
- package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +0 -6
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +197 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +34 -4
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +12 -0
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +36 -33
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +81 -0
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +5 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +148 -14
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputEventEmitter.cpp +29 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputEventEmitter.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +17 -34
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +2 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +16 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.h +1 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +9 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +1 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +4 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +34 -94
- package/Microsoft.ReactNative/Modules/SampleTurboModule.cpp +4 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.h +3 -0
- package/Microsoft.ReactNative/TurboModulesProvider.h +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.h +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/LongLivedJsiValue.h +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +4 -4
- package/PropertySheets/React.Cpp.props +4 -0
- package/README.md +2 -2
- package/ReactCommon/ReactCommon.vcxproj +9 -4
- package/ReactCommon/ReactCommon.vcxproj.filters +6 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +253 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +5 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +4 -8
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +184 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +22 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +2 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleWithJSIBindings.cpp +27 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +2 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +1 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityProps.cpp +308 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/DynamicEventPayload.cpp +42 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/css/CSSTokenizer.h +7 -51
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +10 -5
- package/Scripts/creaternwapp.cmd +9 -3
- package/Shared/Shared.vcxitems +3 -2
- package/Shared/Shared.vcxitems.filters +2 -1
- package/codegen/NativeAnimatedModuleSpec.g.h +2 -0
- package/codegen/NativeAnimatedTurboModuleSpec.g.h +2 -0
- package/codegen/NativePerformanceSpec.g.h +14 -0
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +151 -127
- package/codegen/NativeSampleTurboModuleSpec.g.h +14 -8
- package/codegen/react/components/rnwcore/EventEmitters.cpp +48 -48
- package/codegen/rnwcoreJSI-generated.cpp +159 -129
- package/codegen/rnwcoreJSI.h +534 -408
- package/index.js +51 -331
- package/index.windows.js +70 -352
- package/interface.js +0 -4
- package/jest/resolver.js +31 -0
- package/jest/setup.js +6 -2
- package/package.json +29 -28
- package/src/private/animated/NativeAnimatedHelper.js +21 -8
- package/src/private/animated/createAnimatedPropsHook.js +11 -16
- package/src/private/animated/createAnimatedPropsMemoHook.js +1 -2
- package/src/private/components/{SafeAreaView_INTERNAL_DO_NOT_USE.js → safeareaview/SafeAreaView_INTERNAL_DO_NOT_USE.js} +6 -6
- package/src/private/components/{HScrollViewNativeComponents.js → scrollview/HScrollViewNativeComponents.js} +8 -8
- package/src/private/components/scrollview/VScrollViewNativeComponents.js +25 -0
- package/src/private/{devmenu → devsupport/devmenu}/DevMenu.js +1 -1
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/BorderBox.js +3 -3
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/BoxInspector.js +6 -5
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementBox.js +8 -6
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementProperties.js +11 -10
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/Inspector.js +14 -12
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorOverlay.js +5 -4
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorPanel.js +9 -8
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/NetworkOverlay.js +10 -9
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ReactDevToolsOverlay.js +7 -7
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/StyleInspector.js +7 -6
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/XHRInterceptor.js +2 -2
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/getInspectorDataForViewAtPoint.js +4 -4
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/resolveBoxStyle.js +1 -1
- package/src/private/{inspector → devsupport/devmenu/perfmonitor}/PerformanceOverlay.js +6 -5
- package/src/private/{specs_DEPRECATED/modules → devsupport/devmenu/specs}/NativeDevMenu.js +2 -2
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.android.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.ios.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.windows.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/setUpFuseboxReactDevToolsDispatcher.js +1 -1
- package/src/private/{fusebox → devsupport/rndevtools}/specs/NativeReactDevToolsRuntimeSettingsModule.js +2 -2
- package/src/private/{specs_DEPRECATED/modules → devsupport/rndevtools/specs}/NativeReactDevToolsSettingsManager.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +82 -80
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +12 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +17 -13
- package/src/private/renderer/errorhandling/ErrorHandlers.js +2 -2
- package/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js +3 -0
- package/src/private/styles/composeStyles.js +12 -5
- package/src/private/types/HostComponent.js +1 -1
- package/src/private/types/HostInstance.js +67 -1
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +2 -5
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +5 -18
- package/src/private/webapis/dom/nodes/internals/NodeInternals.js +6 -0
- package/src/private/webapis/performance/Performance.js +1 -3
- package/src/private/webapis/performance/PerformanceEntry.js +6 -1
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -0
- package/src/private/webapis/performance/specs/NativePerformance.js +10 -1
- package/src/types/globals.d.ts +42 -0
- package/stubs/double-conversion/double-conversion.h +3 -1
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +4 -0
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +4 -0
- package/types/index.d.ts +6 -3
- package/types/public/ReactNativeTypes.d.ts +2 -2
- package/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js +0 -38
- package/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js +0 -22
- package/Libraries/Blob/FileReader_new.js +0 -231
- package/Libraries/Blob/FileReader_old.js +0 -186
- package/Libraries/Blob/__mocks__/FileReaderModule.js +0 -20
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +0 -32
- package/Libraries/Core/__mocks__/ErrorUtils.js +0 -33
- package/Libraries/Core/__mocks__/NativeExceptionsManager.js +0 -19
- package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +0 -49
- package/Libraries/Events/CustomEvent.js +0 -32
- package/Libraries/Events/EventPolyfill.js +0 -239
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +0 -118
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +0 -134
- package/Libraries/Network/XMLHttpRequest_new.js +0 -794
- package/Libraries/Network/XMLHttpRequest_old.js +0 -701
- package/Libraries/NewAppScreen/components/DebugInstructions.js +0 -41
- package/Libraries/NewAppScreen/components/DebugInstructions.windows.js +0 -30
- package/Libraries/NewAppScreen/components/Header.js +0 -77
- package/Libraries/NewAppScreen/components/HermesBadge.js +0 -53
- package/Libraries/NewAppScreen/components/LearnMoreLinks.js +0 -148
- package/Libraries/NewAppScreen/components/ReloadInstructions.js +0 -39
- package/Libraries/NewAppScreen/components/ReloadInstructions.windows.js +0 -31
- package/Libraries/NewAppScreen/components/logo.png +0 -0
- package/Libraries/NewAppScreen/index.js +0 -25
- package/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +0 -58
- package/Libraries/Utilities/__mocks__/BackHandler.js +0 -45
- package/Libraries/Utilities/__mocks__/GlobalPerformanceLogger.js +0 -16
- package/Libraries/Utilities/__mocks__/PixelRatio.js +0 -25
- package/Libraries/WebSocket/WebSocketEvent.js +0 -30
- package/Libraries/WebSocket/WebSocket_new.js +0 -325
- package/Libraries/WebSocket/WebSocket_old.js +0 -297
- package/Libraries/WebSocket/__mocks__/event-target-shim.js +0 -27
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +0 -30
- package/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js +0 -81
- package/jest/__tests__/setup-test.js +0 -18
- package/src/private/components/VScrollViewNativeComponents.js +0 -25
- package/src/private/utilities/ensureInstance.js +0 -21
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +0 -267
- package/types/modules/LaunchScreen.d.ts +0 -18
- /package/src/private/{devmenu → devsupport/devmenu}/DevMenu.d.ts +0 -0
- /package/src/private/{debugging → devsupport/rndevtools}/FuseboxSessionObserver.js +0 -0
|
@@ -1,701 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @flow
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
import type Performance from '../../src/private/webapis/performance/Performance';
|
|
14
|
-
import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger';
|
|
15
|
-
|
|
16
|
-
import {type EventSubscription} from '../vendor/emitter/EventEmitter';
|
|
17
|
-
import EventTarget from 'event-target-shim';
|
|
18
|
-
|
|
19
|
-
const BlobManager = require('../Blob/BlobManager').default;
|
|
20
|
-
const GlobalPerformanceLogger =
|
|
21
|
-
require('../Utilities/GlobalPerformanceLogger').default;
|
|
22
|
-
const RCTNetworking = require('./RCTNetworking').default;
|
|
23
|
-
const base64 = require('base64-js');
|
|
24
|
-
const invariant = require('invariant');
|
|
25
|
-
|
|
26
|
-
declare var performance: Performance;
|
|
27
|
-
|
|
28
|
-
const DEBUG_NETWORK_SEND_DELAY: false = false; // Set to a number of milliseconds when debugging
|
|
29
|
-
const LABEL_FOR_MISSING_URL_FOR_PROFILING = 'Unknown URL';
|
|
30
|
-
|
|
31
|
-
export type NativeResponseType = 'base64' | 'blob' | 'text';
|
|
32
|
-
export type ResponseType =
|
|
33
|
-
| ''
|
|
34
|
-
| 'arraybuffer'
|
|
35
|
-
| 'blob'
|
|
36
|
-
| 'document'
|
|
37
|
-
| 'json'
|
|
38
|
-
| 'text';
|
|
39
|
-
export type Response = ?Object | string;
|
|
40
|
-
|
|
41
|
-
type XHRInterceptor = interface {
|
|
42
|
-
requestSent(id: number, url: string, method: string, headers: Object): void,
|
|
43
|
-
responseReceived(
|
|
44
|
-
id: number,
|
|
45
|
-
url: string,
|
|
46
|
-
status: number,
|
|
47
|
-
headers: Object,
|
|
48
|
-
): void,
|
|
49
|
-
dataReceived(id: number, data: string): void,
|
|
50
|
-
loadingFinished(id: number, encodedDataLength: number): void,
|
|
51
|
-
loadingFailed(id: number, error: string): void,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// The native blob module is optional so inject it here if available.
|
|
55
|
-
if (BlobManager.isAvailable) {
|
|
56
|
-
BlobManager.addNetworkingHandler();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const UNSENT = 0;
|
|
60
|
-
const OPENED = 1;
|
|
61
|
-
const HEADERS_RECEIVED = 2;
|
|
62
|
-
const LOADING = 3;
|
|
63
|
-
const DONE = 4;
|
|
64
|
-
|
|
65
|
-
const SUPPORTED_RESPONSE_TYPES = {
|
|
66
|
-
arraybuffer: typeof global.ArrayBuffer === 'function',
|
|
67
|
-
blob: typeof global.Blob === 'function',
|
|
68
|
-
document: false,
|
|
69
|
-
json: true,
|
|
70
|
-
text: true,
|
|
71
|
-
'': true,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const REQUEST_EVENTS = [
|
|
75
|
-
'abort',
|
|
76
|
-
'error',
|
|
77
|
-
'load',
|
|
78
|
-
'loadstart',
|
|
79
|
-
'progress',
|
|
80
|
-
'timeout',
|
|
81
|
-
'loadend',
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
const XHR_EVENTS = REQUEST_EVENTS.concat('readystatechange');
|
|
85
|
-
|
|
86
|
-
class XMLHttpRequestEventTarget extends (EventTarget(
|
|
87
|
-
...REQUEST_EVENTS,
|
|
88
|
-
): typeof EventTarget) {
|
|
89
|
-
onload: ?Function;
|
|
90
|
-
onloadstart: ?Function;
|
|
91
|
-
onprogress: ?Function;
|
|
92
|
-
ontimeout: ?Function;
|
|
93
|
-
onerror: ?Function;
|
|
94
|
-
onabort: ?Function;
|
|
95
|
-
onloadend: ?Function;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Shared base for platform-specific XMLHttpRequest implementations.
|
|
100
|
-
*/
|
|
101
|
-
class XMLHttpRequest extends (EventTarget(...XHR_EVENTS): typeof EventTarget) {
|
|
102
|
-
static UNSENT: number = UNSENT;
|
|
103
|
-
static OPENED: number = OPENED;
|
|
104
|
-
static HEADERS_RECEIVED: number = HEADERS_RECEIVED;
|
|
105
|
-
static LOADING: number = LOADING;
|
|
106
|
-
static DONE: number = DONE;
|
|
107
|
-
|
|
108
|
-
static _interceptor: ?XHRInterceptor = null;
|
|
109
|
-
static _profiling: boolean = false;
|
|
110
|
-
|
|
111
|
-
UNSENT: number = UNSENT;
|
|
112
|
-
OPENED: number = OPENED;
|
|
113
|
-
HEADERS_RECEIVED: number = HEADERS_RECEIVED;
|
|
114
|
-
LOADING: number = LOADING;
|
|
115
|
-
DONE: number = DONE;
|
|
116
|
-
|
|
117
|
-
// EventTarget automatically initializes these to `null`.
|
|
118
|
-
onload: ?Function;
|
|
119
|
-
onloadstart: ?Function;
|
|
120
|
-
onprogress: ?Function;
|
|
121
|
-
ontimeout: ?Function;
|
|
122
|
-
onerror: ?Function;
|
|
123
|
-
onabort: ?Function;
|
|
124
|
-
onloadend: ?Function;
|
|
125
|
-
onreadystatechange: ?Function;
|
|
126
|
-
|
|
127
|
-
readyState: number = UNSENT;
|
|
128
|
-
responseHeaders: ?Object;
|
|
129
|
-
status: number = 0;
|
|
130
|
-
timeout: number = 0;
|
|
131
|
-
responseURL: ?string;
|
|
132
|
-
withCredentials: boolean = true;
|
|
133
|
-
|
|
134
|
-
upload: XMLHttpRequestEventTarget = new XMLHttpRequestEventTarget();
|
|
135
|
-
|
|
136
|
-
_requestId: ?number;
|
|
137
|
-
_subscriptions: Array<EventSubscription>;
|
|
138
|
-
|
|
139
|
-
_aborted: boolean = false;
|
|
140
|
-
_cachedResponse: Response;
|
|
141
|
-
_hasError: boolean = false;
|
|
142
|
-
_headers: Object;
|
|
143
|
-
_lowerCaseResponseHeaders: Object;
|
|
144
|
-
_method: ?string = null;
|
|
145
|
-
_perfKey: ?string = null;
|
|
146
|
-
_responseType: ResponseType;
|
|
147
|
-
_response: string = '';
|
|
148
|
-
_sent: boolean;
|
|
149
|
-
_url: ?string = null;
|
|
150
|
-
_timedOut: boolean = false;
|
|
151
|
-
_trackingName: ?string = null;
|
|
152
|
-
_incrementalEvents: boolean = false;
|
|
153
|
-
_startTime: ?number = null;
|
|
154
|
-
_performanceLogger: IPerformanceLogger = GlobalPerformanceLogger;
|
|
155
|
-
|
|
156
|
-
static __setInterceptor_DO_NOT_USE(interceptor: ?XHRInterceptor) {
|
|
157
|
-
XMLHttpRequest._interceptor = interceptor;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
static enableProfiling(enableProfiling: boolean): void {
|
|
161
|
-
XMLHttpRequest._profiling = enableProfiling;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
constructor() {
|
|
165
|
-
super();
|
|
166
|
-
this._reset();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
_reset(): void {
|
|
170
|
-
this.readyState = this.UNSENT;
|
|
171
|
-
this.responseHeaders = undefined;
|
|
172
|
-
this.status = 0;
|
|
173
|
-
delete this.responseURL;
|
|
174
|
-
|
|
175
|
-
this._requestId = null;
|
|
176
|
-
|
|
177
|
-
this._cachedResponse = undefined;
|
|
178
|
-
this._hasError = false;
|
|
179
|
-
this._headers = {};
|
|
180
|
-
this._response = '';
|
|
181
|
-
this._responseType = '';
|
|
182
|
-
this._sent = false;
|
|
183
|
-
this._lowerCaseResponseHeaders = {};
|
|
184
|
-
|
|
185
|
-
this._clearSubscriptions();
|
|
186
|
-
this._timedOut = false;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
get responseType(): ResponseType {
|
|
190
|
-
return this._responseType;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
set responseType(responseType: ResponseType): void {
|
|
194
|
-
if (this._sent) {
|
|
195
|
-
throw new Error(
|
|
196
|
-
"Failed to set the 'responseType' property on 'XMLHttpRequest': The " +
|
|
197
|
-
'response type cannot be set after the request has been sent.',
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
if (!SUPPORTED_RESPONSE_TYPES.hasOwnProperty(responseType)) {
|
|
201
|
-
console.warn(
|
|
202
|
-
`The provided value '${responseType}' is not a valid 'responseType'.`,
|
|
203
|
-
);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// redboxes early, e.g. for 'arraybuffer' on ios 7
|
|
208
|
-
invariant(
|
|
209
|
-
SUPPORTED_RESPONSE_TYPES[responseType] || responseType === 'document',
|
|
210
|
-
`The provided value '${responseType}' is unsupported in this environment.`,
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
if (responseType === 'blob') {
|
|
214
|
-
invariant(
|
|
215
|
-
BlobManager.isAvailable,
|
|
216
|
-
'Native module BlobModule is required for blob support',
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
this._responseType = responseType;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
get responseText(): string {
|
|
223
|
-
if (this._responseType !== '' && this._responseType !== 'text') {
|
|
224
|
-
throw new Error(
|
|
225
|
-
"The 'responseText' property is only available if 'responseType' " +
|
|
226
|
-
`is set to '' or 'text', but it is '${this._responseType}'.`,
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
if (this.readyState < LOADING) {
|
|
230
|
-
return '';
|
|
231
|
-
}
|
|
232
|
-
return this._response;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
get response(): Response {
|
|
236
|
-
const {responseType} = this;
|
|
237
|
-
if (responseType === '' || responseType === 'text') {
|
|
238
|
-
return this.readyState < LOADING || this._hasError ? '' : this._response;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (this.readyState !== DONE) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (this._cachedResponse !== undefined) {
|
|
246
|
-
return this._cachedResponse;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
switch (responseType) {
|
|
250
|
-
case 'document':
|
|
251
|
-
this._cachedResponse = null;
|
|
252
|
-
break;
|
|
253
|
-
|
|
254
|
-
case 'arraybuffer':
|
|
255
|
-
this._cachedResponse = base64.toByteArray(this._response).buffer;
|
|
256
|
-
break;
|
|
257
|
-
|
|
258
|
-
case 'blob':
|
|
259
|
-
if (typeof this._response === 'object' && this._response) {
|
|
260
|
-
this._cachedResponse = BlobManager.createFromOptions(this._response);
|
|
261
|
-
} else if (this._response === '') {
|
|
262
|
-
this._cachedResponse = BlobManager.createFromParts([]);
|
|
263
|
-
} else {
|
|
264
|
-
throw new Error(
|
|
265
|
-
'Invalid response for blob - expecting object, was ' +
|
|
266
|
-
`${typeof this._response}: ${this._response.trim()}`,
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
break;
|
|
270
|
-
|
|
271
|
-
case 'json':
|
|
272
|
-
try {
|
|
273
|
-
this._cachedResponse = JSON.parse(this._response);
|
|
274
|
-
} catch (_) {
|
|
275
|
-
this._cachedResponse = null;
|
|
276
|
-
}
|
|
277
|
-
break;
|
|
278
|
-
|
|
279
|
-
default:
|
|
280
|
-
this._cachedResponse = null;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return this._cachedResponse;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// exposed for testing
|
|
287
|
-
__didCreateRequest(requestId: number): void {
|
|
288
|
-
this._requestId = requestId;
|
|
289
|
-
|
|
290
|
-
XMLHttpRequest._interceptor &&
|
|
291
|
-
XMLHttpRequest._interceptor.requestSent(
|
|
292
|
-
requestId,
|
|
293
|
-
this._url || '',
|
|
294
|
-
this._method || 'GET',
|
|
295
|
-
this._headers,
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// exposed for testing
|
|
300
|
-
__didUploadProgress(
|
|
301
|
-
requestId: number,
|
|
302
|
-
progress: number,
|
|
303
|
-
total: number,
|
|
304
|
-
): void {
|
|
305
|
-
if (requestId === this._requestId) {
|
|
306
|
-
this.upload.dispatchEvent({
|
|
307
|
-
type: 'progress',
|
|
308
|
-
lengthComputable: true,
|
|
309
|
-
loaded: progress,
|
|
310
|
-
total,
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
__didReceiveResponse(
|
|
316
|
-
requestId: number,
|
|
317
|
-
status: number,
|
|
318
|
-
responseHeaders: ?Object,
|
|
319
|
-
responseURL: ?string,
|
|
320
|
-
): void {
|
|
321
|
-
if (requestId === this._requestId) {
|
|
322
|
-
this._perfKey != null &&
|
|
323
|
-
this._performanceLogger.stopTimespan(this._perfKey);
|
|
324
|
-
this.status = status;
|
|
325
|
-
this.setResponseHeaders(responseHeaders);
|
|
326
|
-
this.setReadyState(this.HEADERS_RECEIVED);
|
|
327
|
-
if (responseURL || responseURL === '') {
|
|
328
|
-
this.responseURL = responseURL;
|
|
329
|
-
} else {
|
|
330
|
-
delete this.responseURL;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
XMLHttpRequest._interceptor &&
|
|
334
|
-
XMLHttpRequest._interceptor.responseReceived(
|
|
335
|
-
requestId,
|
|
336
|
-
responseURL || this._url || '',
|
|
337
|
-
status,
|
|
338
|
-
responseHeaders || {},
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
__didReceiveData(requestId: number, response: string): void {
|
|
344
|
-
if (requestId !== this._requestId) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
this._response = response;
|
|
348
|
-
this._cachedResponse = undefined; // force lazy recomputation
|
|
349
|
-
this.setReadyState(this.LOADING);
|
|
350
|
-
|
|
351
|
-
XMLHttpRequest._interceptor &&
|
|
352
|
-
XMLHttpRequest._interceptor.dataReceived(requestId, response);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
__didReceiveIncrementalData(
|
|
356
|
-
requestId: number,
|
|
357
|
-
responseText: string,
|
|
358
|
-
progress: number,
|
|
359
|
-
total: number,
|
|
360
|
-
) {
|
|
361
|
-
if (requestId !== this._requestId) {
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
if (!this._response) {
|
|
365
|
-
this._response = responseText;
|
|
366
|
-
} else {
|
|
367
|
-
this._response += responseText;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (XMLHttpRequest._profiling) {
|
|
371
|
-
performance.mark(
|
|
372
|
-
'Track:XMLHttpRequest:Incremental Data: ' + this._getMeasureURL(),
|
|
373
|
-
);
|
|
374
|
-
}
|
|
375
|
-
XMLHttpRequest._interceptor &&
|
|
376
|
-
XMLHttpRequest._interceptor.dataReceived(requestId, responseText);
|
|
377
|
-
|
|
378
|
-
this.setReadyState(this.LOADING);
|
|
379
|
-
this.__didReceiveDataProgress(requestId, progress, total);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
__didReceiveDataProgress(
|
|
383
|
-
requestId: number,
|
|
384
|
-
loaded: number,
|
|
385
|
-
total: number,
|
|
386
|
-
): void {
|
|
387
|
-
if (requestId !== this._requestId) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
this.dispatchEvent({
|
|
391
|
-
type: 'progress',
|
|
392
|
-
lengthComputable: total >= 0,
|
|
393
|
-
loaded,
|
|
394
|
-
total,
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// exposed for testing
|
|
399
|
-
__didCompleteResponse(
|
|
400
|
-
requestId: number,
|
|
401
|
-
error: string,
|
|
402
|
-
timeOutError: boolean,
|
|
403
|
-
): void {
|
|
404
|
-
if (requestId === this._requestId) {
|
|
405
|
-
if (error) {
|
|
406
|
-
if (this._responseType === '' || this._responseType === 'text') {
|
|
407
|
-
this._response = error;
|
|
408
|
-
}
|
|
409
|
-
this._hasError = true;
|
|
410
|
-
if (timeOutError) {
|
|
411
|
-
this._timedOut = true;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
this._clearSubscriptions();
|
|
415
|
-
this._requestId = null;
|
|
416
|
-
this.setReadyState(this.DONE);
|
|
417
|
-
if (XMLHttpRequest._profiling && this._startTime != null) {
|
|
418
|
-
const start = this._startTime;
|
|
419
|
-
performance.measure('Track:XMLHttpRequest:' + this._getMeasureURL(), {
|
|
420
|
-
start,
|
|
421
|
-
end: performance.now(),
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
if (error) {
|
|
425
|
-
XMLHttpRequest._interceptor &&
|
|
426
|
-
XMLHttpRequest._interceptor.loadingFailed(requestId, error);
|
|
427
|
-
} else {
|
|
428
|
-
XMLHttpRequest._interceptor &&
|
|
429
|
-
XMLHttpRequest._interceptor.loadingFinished(
|
|
430
|
-
requestId,
|
|
431
|
-
this._response.length,
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
_clearSubscriptions(): void {
|
|
438
|
-
(this._subscriptions || []).forEach(sub => {
|
|
439
|
-
if (sub) {
|
|
440
|
-
sub.remove();
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
this._subscriptions = [];
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
getAllResponseHeaders(): ?string {
|
|
447
|
-
if (!this.responseHeaders) {
|
|
448
|
-
// according to the spec, return null if no response has been received
|
|
449
|
-
return null;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// Assign to non-nullable local variable.
|
|
453
|
-
const responseHeaders = this.responseHeaders;
|
|
454
|
-
|
|
455
|
-
const unsortedHeaders: Map<
|
|
456
|
-
string,
|
|
457
|
-
{lowerHeaderName: string, upperHeaderName: string, headerValue: string},
|
|
458
|
-
> = new Map();
|
|
459
|
-
for (const rawHeaderName of Object.keys(responseHeaders)) {
|
|
460
|
-
const headerValue = responseHeaders[rawHeaderName];
|
|
461
|
-
const lowerHeaderName = rawHeaderName.toLowerCase();
|
|
462
|
-
const header = unsortedHeaders.get(lowerHeaderName);
|
|
463
|
-
if (header) {
|
|
464
|
-
header.headerValue += ', ' + headerValue;
|
|
465
|
-
unsortedHeaders.set(lowerHeaderName, header);
|
|
466
|
-
} else {
|
|
467
|
-
unsortedHeaders.set(lowerHeaderName, {
|
|
468
|
-
lowerHeaderName,
|
|
469
|
-
upperHeaderName: rawHeaderName.toUpperCase(),
|
|
470
|
-
headerValue,
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// Sort in ascending order, with a being less than b if a's name is legacy-uppercased-byte less than b's name.
|
|
476
|
-
const sortedHeaders = [...unsortedHeaders.values()].sort((a, b) => {
|
|
477
|
-
if (a.upperHeaderName < b.upperHeaderName) {
|
|
478
|
-
return -1;
|
|
479
|
-
}
|
|
480
|
-
if (a.upperHeaderName > b.upperHeaderName) {
|
|
481
|
-
return 1;
|
|
482
|
-
}
|
|
483
|
-
return 0;
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
// Combine into single text response.
|
|
487
|
-
return (
|
|
488
|
-
sortedHeaders
|
|
489
|
-
.map(header => {
|
|
490
|
-
return header.lowerHeaderName + ': ' + header.headerValue;
|
|
491
|
-
})
|
|
492
|
-
.join('\r\n') + '\r\n'
|
|
493
|
-
);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
getResponseHeader(header: string): ?string {
|
|
497
|
-
const value = this._lowerCaseResponseHeaders[header.toLowerCase()];
|
|
498
|
-
return value !== undefined ? value : null;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
setRequestHeader(header: string, value: any): void {
|
|
502
|
-
if (this.readyState !== this.OPENED) {
|
|
503
|
-
throw new Error('Request has not been opened');
|
|
504
|
-
}
|
|
505
|
-
this._headers[header.toLowerCase()] = String(value);
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Custom extension for tracking origins of request.
|
|
510
|
-
*/
|
|
511
|
-
setTrackingName(trackingName: ?string): XMLHttpRequest {
|
|
512
|
-
this._trackingName = trackingName;
|
|
513
|
-
return this;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Custom extension for setting a custom performance logger
|
|
518
|
-
*/
|
|
519
|
-
setPerformanceLogger(performanceLogger: IPerformanceLogger): XMLHttpRequest {
|
|
520
|
-
this._performanceLogger = performanceLogger;
|
|
521
|
-
return this;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
open(method: string, url: string, async: ?boolean): void {
|
|
525
|
-
/* Other optional arguments are not supported yet */
|
|
526
|
-
if (this.readyState !== this.UNSENT) {
|
|
527
|
-
throw new Error('Cannot open, already sending');
|
|
528
|
-
}
|
|
529
|
-
if (async !== undefined && !async) {
|
|
530
|
-
// async is default
|
|
531
|
-
throw new Error('Synchronous http requests are not supported');
|
|
532
|
-
}
|
|
533
|
-
if (!url) {
|
|
534
|
-
throw new Error('Cannot load an empty url');
|
|
535
|
-
}
|
|
536
|
-
this._method = method.toUpperCase();
|
|
537
|
-
this._url = url;
|
|
538
|
-
this._aborted = false;
|
|
539
|
-
this.setReadyState(this.OPENED);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
send(data: any): void {
|
|
543
|
-
if (this.readyState !== this.OPENED) {
|
|
544
|
-
throw new Error('Request has not been opened');
|
|
545
|
-
}
|
|
546
|
-
if (this._sent) {
|
|
547
|
-
throw new Error('Request has already been sent');
|
|
548
|
-
}
|
|
549
|
-
this._sent = true;
|
|
550
|
-
const incrementalEvents =
|
|
551
|
-
this._incrementalEvents || !!this.onreadystatechange || !!this.onprogress;
|
|
552
|
-
|
|
553
|
-
this._subscriptions.push(
|
|
554
|
-
RCTNetworking.addListener('didSendNetworkData', args =>
|
|
555
|
-
this.__didUploadProgress(...args),
|
|
556
|
-
),
|
|
557
|
-
);
|
|
558
|
-
this._subscriptions.push(
|
|
559
|
-
RCTNetworking.addListener('didReceiveNetworkResponse', args =>
|
|
560
|
-
this.__didReceiveResponse(...args),
|
|
561
|
-
),
|
|
562
|
-
);
|
|
563
|
-
this._subscriptions.push(
|
|
564
|
-
RCTNetworking.addListener('didReceiveNetworkData', args =>
|
|
565
|
-
this.__didReceiveData(...args),
|
|
566
|
-
),
|
|
567
|
-
);
|
|
568
|
-
this._subscriptions.push(
|
|
569
|
-
RCTNetworking.addListener('didReceiveNetworkIncrementalData', args =>
|
|
570
|
-
this.__didReceiveIncrementalData(...args),
|
|
571
|
-
),
|
|
572
|
-
);
|
|
573
|
-
this._subscriptions.push(
|
|
574
|
-
RCTNetworking.addListener('didReceiveNetworkDataProgress', args =>
|
|
575
|
-
this.__didReceiveDataProgress(...args),
|
|
576
|
-
),
|
|
577
|
-
);
|
|
578
|
-
this._subscriptions.push(
|
|
579
|
-
RCTNetworking.addListener('didCompleteNetworkResponse', args =>
|
|
580
|
-
this.__didCompleteResponse(...args),
|
|
581
|
-
),
|
|
582
|
-
);
|
|
583
|
-
|
|
584
|
-
let nativeResponseType: NativeResponseType = 'text';
|
|
585
|
-
if (this._responseType === 'arraybuffer') {
|
|
586
|
-
nativeResponseType = 'base64';
|
|
587
|
-
}
|
|
588
|
-
if (this._responseType === 'blob') {
|
|
589
|
-
nativeResponseType = 'blob';
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
const doSend = () => {
|
|
593
|
-
const friendlyName = this._trackingName ?? this._url;
|
|
594
|
-
this._perfKey = 'network_XMLHttpRequest_' + String(friendlyName);
|
|
595
|
-
this._performanceLogger.startTimespan(this._perfKey);
|
|
596
|
-
this._startTime = performance.now();
|
|
597
|
-
invariant(
|
|
598
|
-
this._method,
|
|
599
|
-
'XMLHttpRequest method needs to be defined (%s).',
|
|
600
|
-
friendlyName,
|
|
601
|
-
);
|
|
602
|
-
invariant(
|
|
603
|
-
this._url,
|
|
604
|
-
'XMLHttpRequest URL needs to be defined (%s).',
|
|
605
|
-
friendlyName,
|
|
606
|
-
);
|
|
607
|
-
RCTNetworking.sendRequest(
|
|
608
|
-
this._method,
|
|
609
|
-
this._trackingName,
|
|
610
|
-
this._url,
|
|
611
|
-
this._headers,
|
|
612
|
-
data,
|
|
613
|
-
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found
|
|
614
|
-
* when making Flow check .android.js files. */
|
|
615
|
-
nativeResponseType,
|
|
616
|
-
incrementalEvents,
|
|
617
|
-
this.timeout,
|
|
618
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
619
|
-
this.__didCreateRequest.bind(this),
|
|
620
|
-
this.withCredentials,
|
|
621
|
-
);
|
|
622
|
-
};
|
|
623
|
-
if (DEBUG_NETWORK_SEND_DELAY) {
|
|
624
|
-
setTimeout(doSend, DEBUG_NETWORK_SEND_DELAY);
|
|
625
|
-
} else {
|
|
626
|
-
doSend();
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
abort(): void {
|
|
631
|
-
this._aborted = true;
|
|
632
|
-
if (this._requestId) {
|
|
633
|
-
RCTNetworking.abortRequest(this._requestId);
|
|
634
|
-
}
|
|
635
|
-
// only call onreadystatechange if there is something to abort,
|
|
636
|
-
// below logic is per spec
|
|
637
|
-
if (
|
|
638
|
-
!(
|
|
639
|
-
this.readyState === this.UNSENT ||
|
|
640
|
-
(this.readyState === this.OPENED && !this._sent) ||
|
|
641
|
-
this.readyState === this.DONE
|
|
642
|
-
)
|
|
643
|
-
) {
|
|
644
|
-
this._reset();
|
|
645
|
-
this.setReadyState(this.DONE);
|
|
646
|
-
}
|
|
647
|
-
// Reset again after, in case modified in handler
|
|
648
|
-
this._reset();
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
setResponseHeaders(responseHeaders: ?Object): void {
|
|
652
|
-
this.responseHeaders = responseHeaders || null;
|
|
653
|
-
const headers = responseHeaders || {};
|
|
654
|
-
this._lowerCaseResponseHeaders = Object.keys(headers).reduce<{
|
|
655
|
-
[string]: any,
|
|
656
|
-
}>((lcaseHeaders, headerName) => {
|
|
657
|
-
// $FlowFixMe[invalid-computed-prop]
|
|
658
|
-
lcaseHeaders[headerName.toLowerCase()] = headers[headerName];
|
|
659
|
-
return lcaseHeaders;
|
|
660
|
-
}, {});
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
setReadyState(newState: number): void {
|
|
664
|
-
this.readyState = newState;
|
|
665
|
-
this.dispatchEvent({type: 'readystatechange'});
|
|
666
|
-
if (newState === this.DONE) {
|
|
667
|
-
if (this._aborted) {
|
|
668
|
-
this.dispatchEvent({type: 'abort'});
|
|
669
|
-
} else if (this._hasError) {
|
|
670
|
-
if (this._timedOut) {
|
|
671
|
-
this.dispatchEvent({type: 'timeout'});
|
|
672
|
-
} else {
|
|
673
|
-
this.dispatchEvent({type: 'error'});
|
|
674
|
-
}
|
|
675
|
-
} else {
|
|
676
|
-
this.dispatchEvent({type: 'load'});
|
|
677
|
-
}
|
|
678
|
-
this.dispatchEvent({type: 'loadend'});
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
/* global EventListener */
|
|
683
|
-
addEventListener(type: string, listener: EventListener): void {
|
|
684
|
-
// If we dont' have a 'readystatechange' event handler, we don't
|
|
685
|
-
// have to send repeated LOADING events with incremental updates
|
|
686
|
-
// to responseText, which will avoid a bunch of native -> JS
|
|
687
|
-
// bridge traffic.
|
|
688
|
-
if (type === 'readystatechange' || type === 'progress') {
|
|
689
|
-
this._incrementalEvents = true;
|
|
690
|
-
}
|
|
691
|
-
super.addEventListener(type, listener);
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
_getMeasureURL(): string {
|
|
695
|
-
return (
|
|
696
|
-
this._trackingName ?? this._url ?? LABEL_FOR_MISSING_URL_FOR_PROFILING
|
|
697
|
-
);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
export default XMLHttpRequest;
|