@office-iss/react-native-win32 0.78.2 → 0.79.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 +4 -1
- package/CHANGELOG.json +166 -38
- package/CHANGELOG.md +53 -22
- package/IntegrationTests/AccessibilityManagerTest.js +17 -12
- package/IntegrationTests/AppEventsTest.js +47 -32
- package/IntegrationTests/GlobalEvalWithSourceUrlTest.js +10 -14
- package/IntegrationTests/ImageCachePolicyTest.js +64 -81
- package/IntegrationTests/ImageSnapshotTest.js +17 -20
- package/IntegrationTests/IntegrationTestHarnessTest.js +34 -52
- package/IntegrationTests/IntegrationTestsApp.js +11 -6
- package/IntegrationTests/LayoutEventsTest.js +17 -12
- package/IntegrationTests/LoggingTestModule.js +2 -1
- package/IntegrationTests/PromiseTest.js +51 -43
- package/IntegrationTests/SimpleSnapshotTest.js +19 -24
- package/IntegrationTests/SyncMethodTest.js +9 -13
- package/IntegrationTests/TimersTest.js +3 -3
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +39 -18
- package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +2 -2
- package/Libraries/Alert/Alert.js +33 -10
- package/Libraries/Alert/Alert.win32.js +32 -9
- package/Libraries/Alert/NativeAlertManager.js +2 -2
- package/Libraries/Alert/RCTAlertManager.android.js +1 -1
- package/Libraries/Alert/RCTAlertManager.ios.js +1 -1
- package/Libraries/Alert/RCTAlertManager.js.flow +18 -0
- package/Libraries/Animated/Animated.js +8 -37
- package/Libraries/Animated/Animated.js.flow +15 -0
- package/Libraries/Animated/AnimatedExports.js +47 -0
- package/Libraries/Animated/AnimatedExports.js.flow +48 -0
- package/Libraries/Animated/AnimatedMock.js +1 -1
- package/Libraries/Animated/NativeAnimatedModule.js +2 -2
- package/Libraries/Animated/NativeAnimatedTurboModule.js +2 -2
- package/Libraries/Animated/animations/Animation.js +1 -4
- package/Libraries/Animated/createAnimatedComponent.js +3 -3
- package/Libraries/Animated/nodes/AnimatedObject.js +1 -0
- package/Libraries/Animated/nodes/AnimatedValue.js +30 -22
- package/Libraries/Animated/useAnimatedProps.js +4 -333
- package/Libraries/Animated/useAnimatedValue.js +1 -3
- package/Libraries/AppState/AppState.js +24 -7
- package/Libraries/AppState/NativeAppState.js +2 -2
- package/Libraries/BatchedBridge/BatchedBridge.js +4 -2
- package/Libraries/BatchedBridge/MessageQueue.js +5 -4
- package/Libraries/BatchedBridge/NativeModules.js +6 -4
- package/Libraries/Blob/Blob.js +5 -5
- package/Libraries/Blob/BlobManager.js +3 -2
- package/Libraries/Blob/BlobRegistry.js +3 -9
- package/Libraries/Blob/File.js +3 -2
- package/Libraries/Blob/FileReader.js +8 -174
- package/Libraries/Blob/FileReader_new.js +231 -0
- package/Libraries/Blob/FileReader_old.js +186 -0
- package/Libraries/Blob/NativeBlobModule.js +2 -2
- package/Libraries/Blob/NativeFileReaderModule.js +2 -2
- package/Libraries/Blob/URL.js +1 -1
- package/Libraries/Blob/URLSearchParams.js +9 -10
- package/Libraries/Blob/URLSearchParams.js.flow +23 -0
- package/Libraries/BugReporting/BugReporting.js +2 -2
- package/Libraries/BugReporting/NativeBugReporting.js +2 -2
- package/Libraries/BugReporting/dumpReactTree.js +2 -2
- package/Libraries/BugReporting/getReactData.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js +2 -2
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfoWin32.js +2 -2
- package/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js +2 -2
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.android.js +1 -1
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.ios.js +1 -1
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js.flow +20 -0
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.win32.js +1 -1
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +11 -11
- package/Libraries/Components/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +2 -2
- package/Libraries/Components/Button.js +6 -6
- package/Libraries/Components/Button.win32.js +6 -9
- package/Libraries/Components/Clipboard/Clipboard.js +1 -1
- package/Libraries/Components/Clipboard/NativeClipboard.js +2 -2
- package/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +2 -2
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +14 -100
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +64 -4
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +138 -0
- package/Libraries/Components/Keyboard/Keyboard.js +9 -9
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +24 -25
- package/Libraries/Components/Keyboard/NativeKeyboardObserver.js +2 -2
- package/Libraries/Components/LayoutConformance/LayoutConformance.js +7 -5
- package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
- package/Libraries/Components/Pressable/Pressable.js +28 -73
- package/Libraries/Components/Pressable/Pressable.win32.js +29 -75
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +17 -17
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +4 -47
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +13 -1
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +2 -2
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +54 -0
- package/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +2 -2
- package/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +2 -2
- package/Libraries/Components/RefreshControl/RefreshControl.js +17 -14
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +2 -1
- package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +2 -2
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +1 -1
- package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +1 -1
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +2 -2
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +2 -4
- package/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +2 -4
- package/Libraries/Components/ScrollView/ScrollView.js +139 -134
- package/Libraries/Components/ScrollView/ScrollViewCommands.js +3 -3
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +7 -9
- package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +5 -2
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +10 -11
- package/Libraries/Components/ScrollView/processDecelerationRate.js +1 -1
- package/Libraries/Components/Sound/NativeSoundManager.js +2 -2
- package/Libraries/Components/Sound/SoundManager.js +1 -1
- package/Libraries/Components/StaticRenderer.js +4 -4
- package/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +2 -2
- package/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +2 -2
- package/Libraries/Components/StatusBar/StatusBar.js +57 -31
- package/Libraries/Components/Switch/AndroidSwitchNativeComponent.js +2 -2
- package/Libraries/Components/Switch/Switch.js +74 -45
- package/Libraries/Components/Switch/SwitchNativeComponent.js +2 -2
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +33 -35
- package/Libraries/Components/TextInput/InputAccessoryView.js +5 -3
- package/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js +2 -2
- package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +2 -4
- package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +2 -4
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +5 -2
- package/Libraries/Components/TextInput/TextInput.flow.js +131 -121
- package/Libraries/Components/TextInput/TextInput.js +152 -149
- package/Libraries/Components/TextInput/TextInput.win32.js +154 -151
- package/Libraries/Components/TextInput/TextInputNativeCommands.js +1 -1
- package/Libraries/Components/TextInput/TextInputState.js +6 -20
- package/Libraries/Components/TextInput/TextInputState.win32.js +6 -20
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +1 -1
- package/Libraries/Components/ToastAndroid/NativeToastAndroid.js +2 -2
- package/Libraries/Components/ToastAndroid/ToastAndroid.android.js +1 -1
- package/Libraries/Components/ToastAndroid/ToastAndroid.d.ts +68 -6
- package/Libraries/Components/ToastAndroid/ToastAndroid.js +1 -1
- package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +1 -1
- package/Libraries/Components/Touchable/BoundingDimensions.js +1 -1
- package/Libraries/Components/Touchable/PooledClass.js +1 -1
- package/Libraries/Components/Touchable/Position.js +1 -1
- package/Libraries/Components/Touchable/Touchable.js +23 -23
- package/Libraries/Components/Touchable/Touchable.win32.js +23 -23
- package/Libraries/Components/Touchable/TouchableBounce.js +6 -6
- package/Libraries/Components/Touchable/TouchableHighlight.js +44 -23
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +102 -54
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +252 -47
- package/Libraries/Components/Touchable/TouchableOpacity.js +57 -15
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +114 -61
- package/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +2 -2
- package/Libraries/Components/UnimplementedViews/UnimplementedView.js +11 -3
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +17 -3
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -1
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -1
- package/Libraries/Components/View/View.js +2 -2
- package/Libraries/Components/View/View.win32.js +2 -2
- package/Libraries/Components/View/ViewAccessibility.js +245 -5
- package/Libraries/Components/View/ViewAccessibility.win32.js +245 -5
- package/Libraries/Components/View/ViewNativeComponent.js +2 -4
- package/Libraries/Components/View/ViewPropTypes.d.ts +14 -14
- package/Libraries/Components/View/ViewPropTypes.js +65 -253
- package/Libraries/Components/View/ViewPropTypes.win32.js +123 -312
- package/Libraries/Core/Devtools/getDevServer.js +1 -3
- package/Libraries/Core/Devtools/loadBundleFromServer.js +4 -2
- package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +4 -2
- package/Libraries/Core/Devtools/openFileInEditor.js +2 -4
- package/Libraries/Core/Devtools/openURLInBrowser.js +5 -4
- package/Libraries/Core/Devtools/parseErrorStack.js +4 -4
- package/Libraries/Core/Devtools/parseHermesStack.js +2 -2
- package/Libraries/Core/Devtools/symbolicateStackTrace.js +6 -5
- package/Libraries/Core/ExceptionsManager.js +6 -4
- package/Libraries/Core/InitializeCore.js +7 -3
- package/Libraries/Core/NativeExceptionsManager.js +2 -2
- package/Libraries/Core/RawEventEmitter.js +2 -2
- package/Libraries/Core/ReactFiberErrorDialog.js +2 -2
- package/Libraries/Core/ReactNativeVersion.js +3 -5
- package/Libraries/Core/ReactNativeVersionCheck.js +2 -4
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +2 -4
- package/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js +2 -2
- package/Libraries/Core/Timers/JSTimers.js +10 -8
- package/Libraries/Core/Timers/NativeTiming.js +2 -2
- package/Libraries/Core/Timers/immediateShim.js +2 -9
- package/Libraries/Core/polyfillPromise.js +1 -1
- package/Libraries/Core/registerCallableModule.js +1 -1
- package/Libraries/Core/setUpAlert.js +1 -1
- package/Libraries/Core/setUpBatchedBridge.js +13 -8
- package/Libraries/Core/setUpDeveloperTools.js +3 -35
- package/Libraries/Core/setUpErrorHandling.js +2 -2
- package/Libraries/Core/setUpReactDevTools.js +26 -6
- package/Libraries/Core/setUpReactRefresh.js +1 -1
- package/Libraries/Core/setUpTimers.js +45 -66
- package/Libraries/Core/setUpXHR.js +11 -8
- package/Libraries/Debugging/DebuggingOverlayNativeComponent.js +2 -2
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +10 -7
- package/Libraries/EventEmitter/NativeEventEmitter.js +8 -2
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +7 -5
- package/Libraries/EventEmitter/RCTEventEmitter.js +1 -1
- package/Libraries/EventEmitter/RCTNativeAppEventEmitter.js +1 -1
- package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +3 -2
- package/Libraries/Events/CustomEvent.js +3 -3
- package/Libraries/Events/EventPolyfill.js +2 -2
- package/Libraries/Image/AssetRegistry.js +8 -1
- package/Libraries/Image/AssetSourceResolver.js +4 -4
- package/Libraries/Image/Image.android.js +4 -2
- package/Libraries/Image/Image.ios.js +1 -1
- package/Libraries/Image/Image.js.flow +27 -0
- package/Libraries/Image/Image.win32.js +1 -1
- package/Libraries/Image/ImageBackground.js +2 -2
- package/Libraries/Image/ImageProps.js +109 -39
- package/Libraries/Image/ImageTypes.flow.js +16 -6
- package/Libraries/Image/ImageViewNativeComponent.js +8 -11
- package/Libraries/Image/NativeImageEditor.js +2 -2
- package/Libraries/Image/NativeImageLoaderAndroid.js +2 -2
- package/Libraries/Image/NativeImageLoaderIOS.js +2 -2
- package/Libraries/Image/NativeImageLoaderWin32.js +2 -2
- package/Libraries/Image/NativeImageStoreAndroid.js +2 -2
- package/Libraries/Image/NativeImageStoreIOS.js +2 -2
- package/Libraries/Image/RelativeImageStub.js +3 -1
- package/Libraries/Image/TextInlineImageNativeComponent.js +2 -4
- package/Libraries/Image/nativeImageSource.js +3 -3
- package/Libraries/Image/resolveAssetSource.js +4 -2
- package/Libraries/Image/resolveAssetSource.win32.js +1 -1
- package/Libraries/Interaction/FrameRateLogger.js +1 -1
- package/Libraries/Interaction/InteractionManager.js +20 -9
- package/Libraries/Interaction/InteractionManagerStub.js +10 -2
- package/Libraries/Interaction/JSEventLoopWatchdog.js +2 -2
- package/Libraries/Interaction/NativeFrameRateLogger.js +2 -2
- package/Libraries/Interaction/PanResponder.js +49 -46
- package/Libraries/Interaction/TaskQueue.js +4 -4
- package/Libraries/Interaction/TouchHistoryMath.js +27 -1
- package/Libraries/LayoutAnimation/LayoutAnimation.js +20 -6
- package/Libraries/Linking/Linking.d.ts +3 -3
- package/Libraries/Linking/Linking.js +10 -9
- package/Libraries/Linking/NativeIntentAndroid.js +2 -2
- package/Libraries/Linking/NativeLinkingManager.js +2 -2
- package/Libraries/Lists/FillRateHelper.js +4 -4
- package/Libraries/Lists/FlatList.js +30 -30
- package/Libraries/Lists/SectionList.js +10 -10
- package/Libraries/Lists/SectionListModern.js +9 -7
- package/Libraries/Lists/ViewabilityHelper.js +4 -3
- package/Libraries/Lists/VirtualizeUtils.js +3 -5
- package/Libraries/Lists/VirtualizedList.js +6 -6
- package/Libraries/Lists/VirtualizedListContext.js +5 -5
- package/Libraries/Lists/VirtualizedSectionList.js +5 -3
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +15 -15
- package/Libraries/LogBox/Data/LogBoxLog.js +51 -29
- package/Libraries/LogBox/Data/parseLogBoxLog.js +10 -10
- package/Libraries/LogBox/LogBox.js +22 -2
- package/Libraries/LogBox/LogBoxInspectorContainer.js +3 -3
- package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -3
- package/Libraries/LogBox/UI/AnsiHighlight.js +7 -3
- package/Libraries/LogBox/UI/LogBoxButton.js +8 -6
- package/Libraries/LogBox/UI/LogBoxInspector.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorBody.js +8 -2
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +50 -31
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +50 -31
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +11 -3
- package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +2 -0
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +8 -2
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +8 -2
- package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +2 -0
- package/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js +6 -4
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +5 -3
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +5 -3
- package/Libraries/LogBox/UI/LogBoxInspectorSection.js +2 -2
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +4 -4
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +5 -3
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.win32.js +5 -3
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +2 -2
- package/Libraries/LogBox/UI/LogBoxNotification.js +6 -2
- package/Libraries/LogBox/UI/LogBoxNotificationCountBadge.js +3 -1
- package/Libraries/LogBox/UI/LogBoxNotificationDismissButton.js +2 -0
- package/Libraries/LogBox/UI/LogBoxNotificationMessage.js +4 -1
- package/Libraries/Modal/Modal.js +82 -89
- package/Libraries/Modal/NativeModalManager.js +2 -2
- package/Libraries/Modal/RCTModalHostViewNativeComponent.js +2 -2
- package/Libraries/NativeComponent/BaseViewConfig.android.js +16 -6
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +19 -9
- package/Libraries/NativeComponent/BaseViewConfig.js.flow +14 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +19 -9
- package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +5 -1
- package/Libraries/NativeModules/specs/NativeDevMenu.js +2 -2
- package/Libraries/NativeModules/specs/NativeDevSettings.js +2 -2
- package/Libraries/NativeModules/specs/NativeDeviceEventManager.js +2 -2
- package/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js +2 -2
- package/Libraries/NativeModules/specs/NativeLogBox.js +2 -2
- package/Libraries/NativeModules/specs/NativeRedBox.js +2 -2
- package/Libraries/NativeModules/specs/NativeSourceCode.js +2 -2
- package/Libraries/Network/FormData.js +1 -1
- package/Libraries/Network/NativeNetworkingAndroid.js +2 -2
- package/Libraries/Network/NativeNetworkingIOS.js +2 -2
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.js.flow +44 -0
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +10 -685
- package/Libraries/Network/XMLHttpRequest_new.js +794 -0
- package/Libraries/Network/XMLHttpRequest_old.js +701 -0
- package/Libraries/Network/convertRequestBody.js +7 -4
- package/Libraries/Network/fetch.js +4 -3
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +2 -2
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +65 -63
- package/Libraries/Pressability/HoverState.js +1 -0
- package/Libraries/Pressability/HoverState.win32.js +1 -0
- package/Libraries/Pressability/Pressability.js +34 -34
- package/Libraries/Pressability/Pressability.win32.js +35 -35
- package/Libraries/Pressability/PressabilityDebug.js +2 -2
- package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +2 -2
- package/Libraries/Promise.js +2 -2
- package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +2 -2
- package/Libraries/PushNotificationIOS/PushNotificationIOS.js +119 -16
- package/Libraries/ReactNative/AppContainer-dev.js +4 -3
- package/Libraries/ReactNative/AppContainer.js +3 -3
- package/Libraries/ReactNative/AppRegistry.js +4 -4
- package/Libraries/ReactNative/BridgelessUIManager.js +4 -9
- package/Libraries/ReactNative/FabricUIManager.js +22 -10
- package/Libraries/ReactNative/I18nManager.js +4 -3
- package/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js +2 -2
- package/Libraries/ReactNative/NativeI18nManager.js +2 -2
- package/Libraries/ReactNative/NativeUIManager.js +2 -2
- package/Libraries/ReactNative/PaperUIManager.js +6 -6
- package/Libraries/ReactNative/PaperUIManager.win32.js +6 -6
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +7 -5
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +85 -30
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +3 -3
- package/Libraries/ReactNative/ReactNativeRuntimeDiagnostics.js +3 -3
- package/Libraries/ReactNative/RendererImplementation.js +12 -5
- package/Libraries/ReactNative/RootTag.js +1 -1
- package/Libraries/ReactNative/UIManager.d.ts +1 -0
- package/Libraries/ReactNative/UIManager.js +3 -3
- package/Libraries/ReactNative/UIManagerProperties.js +1 -1
- package/Libraries/ReactNative/getNativeComponentAttributes.js +10 -9
- package/Libraries/ReactNative/requireNativeComponent.js +3 -2
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +30 -10
- package/Libraries/Renderer/shims/ReactNativeTypes.js +40 -89
- package/Libraries/Settings/NativeSettingsManager.js +2 -2
- package/Libraries/Settings/Settings.ios.js +1 -1
- package/Libraries/Settings/Settings.js +3 -3
- package/Libraries/Settings/Settings.win32.js +3 -3
- package/Libraries/Share/NativeShareModule.js +2 -2
- package/Libraries/Share/Share.js +11 -4
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +22 -0
- package/Libraries/StyleSheet/Rect.js +2 -2
- package/Libraries/StyleSheet/StyleSheet.js +4 -3
- package/Libraries/StyleSheet/StyleSheet.win32.js +5 -4
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
- package/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +1 -1
- package/Libraries/StyleSheet/flattenStyle.js +1 -1
- package/Libraries/StyleSheet/normalizeColor.js +1 -1
- package/Libraries/StyleSheet/private/_TransformStyle.js +18 -18
- package/Libraries/StyleSheet/processAspectRatio.js +1 -1
- package/Libraries/StyleSheet/processBackgroundImage.js +138 -136
- package/Libraries/StyleSheet/processBoxShadow.js +4 -0
- package/Libraries/StyleSheet/processColor.js +2 -2
- package/Libraries/StyleSheet/processColorArray.js +1 -1
- package/Libraries/StyleSheet/processFilter.js +4 -0
- package/Libraries/StyleSheet/processFontVariant.js +1 -1
- package/Libraries/StyleSheet/processTransform.js +1 -1
- package/Libraries/StyleSheet/setNormalizedColorAlpha.js +1 -1
- package/Libraries/Text/Text.d.ts +1 -1
- package/Libraries/Text/Text.js +19 -17
- package/Libraries/Text/Text.win32.js +19 -17
- package/Libraries/Text/TextAncestor.js +2 -3
- package/Libraries/Text/TextNativeComponent.js +3 -3
- package/Libraries/Text/TextNativeComponent.win32.js +3 -3
- package/Libraries/Text/TextProps.js +134 -94
- package/Libraries/Text/TextProps.win32.js +134 -94
- package/Libraries/TurboModule/TurboModuleRegistry.js +1 -1
- package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +2 -2
- package/Libraries/Types/CodegenTypes.js +5 -4
- package/Libraries/Types/CoreEventTypes.js +119 -86
- package/Libraries/Types/CoreEventTypes.win32.js +131 -93
- package/Libraries/Types/ReactDevToolsTypes.js +4 -8
- package/Libraries/UTFSequence.js +4 -3
- package/Libraries/Utilities/Appearance.js +0 -8
- package/Libraries/Utilities/BackHandler.android.js +3 -3
- package/Libraries/Utilities/BackHandler.ios.js +7 -7
- package/Libraries/Utilities/BackHandler.js.flow +25 -0
- package/Libraries/Utilities/BackHandler.win32.js +3 -3
- package/Libraries/Utilities/DevLoadingView.js +1 -1
- package/Libraries/Utilities/DevSettings.js +15 -1
- package/Libraries/Utilities/DeviceInfo.js +1 -1
- package/Libraries/Utilities/DeviceInfo.win32.js +1 -1
- package/Libraries/Utilities/Dimensions.js +5 -0
- package/Libraries/Utilities/Dimensions.win32.js +5 -0
- package/Libraries/Utilities/FeatureDetection.js +2 -4
- package/Libraries/Utilities/FocusManager.win32.js +3 -3
- package/Libraries/Utilities/GlobalPerformanceLogger.js +1 -1
- package/Libraries/Utilities/HMRClient.js +7 -7
- package/Libraries/Utilities/HMRClientProdShim.js +1 -1
- package/Libraries/Utilities/NativeAppearance.js +2 -2
- package/Libraries/Utilities/NativeDevLoadingView.js +2 -2
- package/Libraries/Utilities/NativeDeviceInfo.js +2 -2
- package/Libraries/Utilities/NativePlatformConstantsAndroid.js +2 -2
- package/Libraries/Utilities/NativePlatformConstantsIOS.js +2 -2
- package/Libraries/Utilities/NativePlatformConstantsWin.js +2 -2
- package/Libraries/Utilities/Platform.android.js +6 -6
- package/Libraries/Utilities/Platform.ios.js +6 -6
- package/{flow/Position.js → Libraries/Utilities/Platform.js.flow} +3 -6
- package/Libraries/Utilities/Platform.win32.js +4 -4
- package/Libraries/Utilities/{Platform.flow.win32.js → PlatformTypes.js} +105 -14
- package/Libraries/Utilities/PolyfillFunctions.js +3 -5
- package/Libraries/Utilities/RCTLog.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +6 -6
- package/Libraries/Utilities/SceneTracker.js +1 -1
- package/Libraries/Utilities/__mocks__/GlobalPerformanceLogger.js +2 -2
- package/Libraries/Utilities/binaryToBase64.js +1 -1
- package/Libraries/Utilities/codegenNativeCommands.js +2 -2
- package/Libraries/Utilities/codegenNativeComponent.js +3 -3
- package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +1 -1
- package/Libraries/Utilities/defineLazyObjectProperty.js +1 -1
- package/Libraries/Utilities/differ/deepDiffer.js +6 -6
- package/Libraries/Utilities/differ/insetsDiffer.js +3 -3
- package/Libraries/Utilities/differ/matricesDiffer.js +3 -6
- package/Libraries/Utilities/differ/pointsDiffer.js +3 -3
- package/Libraries/Utilities/differ/sizesDiffer.js +3 -3
- package/Libraries/Utilities/dismissKeyboard.js +3 -2
- package/Libraries/Utilities/infoLog.js +1 -1
- package/Libraries/Utilities/logError.js +1 -1
- package/Libraries/Utilities/mapWithSeparator.js +1 -1
- package/Libraries/Utilities/stringifySafe.js +2 -2
- package/Libraries/Utilities/warnOnce.js +1 -1
- package/Libraries/Vibration/NativeVibration.js +2 -2
- package/Libraries/Vibration/Vibration.js +4 -4
- package/Libraries/WebSocket/NativeWebSocketModule.js +2 -2
- package/Libraries/WebSocket/WebSocket.js +8 -285
- package/Libraries/WebSocket/WebSocketEvent.js +2 -2
- package/Libraries/WebSocket/WebSocketInterceptor.js +39 -11
- package/Libraries/WebSocket/WebSocket_new.js +325 -0
- package/Libraries/WebSocket/WebSocket_old.js +297 -0
- package/Libraries/WebSocket/__mocks__/event-target-shim.js +1 -1
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +2 -4
- package/Libraries/vendor/core/ErrorUtils.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +21 -9
- package/flow/jest.js +14 -14
- package/index.js +153 -237
- package/index.win32.js +64 -55
- package/jest/mockScrollView.js +1 -1
- package/jest/setup.js +314 -264
- package/overrides.json +64 -75
- package/package.json +24 -25
- package/src/private/animated/createAnimatedPropsHook.js +360 -0
- package/src/private/animated/{useAnimatedPropsMemo.js → createAnimatedPropsMemoHook.js} +84 -32
- package/src/private/components/HScrollViewNativeComponents.js +2 -2
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +2 -2
- package/src/private/components/VScrollViewNativeComponents.js +1 -1
- package/src/private/debugging/ReactDevToolsSettingsManager.android.js +1 -1
- package/src/private/debugging/ReactDevToolsSettingsManager.win32.js +1 -1
- package/src/private/devmenu/DevMenu.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +53 -75
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +5 -7
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +10 -12
- package/{Libraries/Inspector → src/private/inspector}/BorderBox.js +3 -3
- package/{Libraries/Inspector → src/private/inspector}/BoxInspector.js +9 -6
- package/{Libraries/Inspector → src/private/inspector}/ElementBox.js +9 -8
- package/{Libraries/Inspector → src/private/inspector}/ElementProperties.js +20 -15
- package/{Libraries/Inspector → src/private/inspector}/Inspector.js +21 -18
- package/{Libraries/Inspector → src/private/inspector}/InspectorOverlay.js +11 -10
- package/{Libraries/Inspector → src/private/inspector}/InspectorPanel.js +17 -15
- package/{Libraries/Inspector → src/private/inspector}/NetworkOverlay.js +43 -27
- package/{Libraries/Inspector → src/private/inspector}/PerformanceOverlay.js +8 -6
- package/{Libraries/Inspector → src/private/inspector}/ReactDevToolsOverlay.js +11 -10
- package/{Libraries/Inspector → src/private/inspector}/StyleInspector.js +6 -6
- package/{Libraries/Network → src/private/inspector}/XHRInterceptor.js +5 -2
- package/{Libraries/Inspector → src/private/inspector}/getInspectorDataForViewAtPoint.js +6 -6
- package/{Libraries/Inspector → src/private/inspector}/resolveBoxStyle.js +5 -4
- package/src/private/renderer/errorhandling/ErrorHandlers.js +5 -5
- package/src/private/setup/setUpDOM.js +43 -3
- package/src/private/{specs → specs_DEPRECATED}/components/ActivityIndicatorViewNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/components/AndroidDrawerLayoutNativeComponent.js +7 -7
- package/src/private/{specs → specs_DEPRECATED}/components/AndroidHorizontalScrollContentViewNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/components/AndroidSwipeRefreshLayoutNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/components/AndroidSwitchNativeComponent.js +5 -5
- package/src/private/{specs → specs_DEPRECATED}/components/DebuggingOverlayNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/components/ProgressBarAndroidNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/components/PullToRefreshViewNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/components/RCTInputAccessoryViewNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/components/RCTModalHostViewNativeComponent.js +5 -5
- package/src/private/{specs → specs_DEPRECATED}/components/RCTSafeAreaViewNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/components/SwitchNativeComponent.js +5 -5
- package/src/private/{specs → specs_DEPRECATED}/components/UnimplementedNativeViewNativeComponent.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeAccessibilityManager.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeActionSheetManager.js +7 -7
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeAlertManager.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeAnimatedModule.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeAnimatedTurboModule.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeAppState.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeBlobModule.js +1 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeClipboard.js +1 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeDevMenu.js +0 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeDevSettings.js +0 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeDeviceInfo.js +8 -8
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeDialogManagerAndroid.js +4 -4
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeExceptionsManager.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeFrameRateLogger.js +1 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeI18nManager.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageEditor.js +9 -9
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageLoaderAndroid.js +1 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageLoaderIOS.js +1 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageLoaderWin32.js +1 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageStoreAndroid.js +1 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageStoreIOS.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeNetworkingIOS.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativePermissionsAndroid.js +5 -4
- package/src/private/{specs → specs_DEPRECATED}/modules/NativePlatformConstantsAndroid.js +4 -4
- package/src/private/{specs → specs_DEPRECATED}/modules/NativePlatformConstantsIOS.js +4 -4
- package/src/private/{specs → specs_DEPRECATED}/modules/NativePlatformConstantsWin.js +5 -10
- package/src/private/{specs → specs_DEPRECATED}/modules/NativePushNotificationManagerIOS.js +7 -7
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeSampleTurboModule.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeSettingsManager.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeShareModule.js +3 -3
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeSourceCode.js +2 -2
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeStatusBarManagerAndroid.js +4 -4
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeStatusBarManagerIOS.js +6 -6
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeToastAndroid.js +2 -2
- package/src/private/specs_DEPRECATED/modules/NativeUIManager.js +184 -0
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeVibration.js +1 -1
- package/src/private/{specs → specs_DEPRECATED}/modules/NativeWebSocketModule.js +1 -1
- package/{flow/react.js → src/private/types/HostComponent.js} +6 -5
- package/src/private/types/HostInstance.js +50 -0
- package/src/private/webapis/dom/events/CustomEvent.js +38 -0
- package/src/private/webapis/dom/events/Event.js +236 -0
- package/src/private/webapis/dom/events/EventHandlerAttributes.js +130 -0
- package/src/private/webapis/dom/events/EventTarget.js +436 -0
- package/src/private/webapis/dom/events/internals/EventInternals.js +120 -0
- package/src/private/webapis/dom/events/internals/EventTargetInternals.js +52 -0
- package/src/private/webapis/dom/nodes/ReactNativeDocument.js +121 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +82 -51
- package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +7 -6
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +26 -26
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +56 -78
- package/src/private/webapis/dom/nodes/internals/NodeInternals.js +144 -0
- package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentElementInstanceHandle.js +55 -0
- package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +44 -0
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +305 -194
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +2 -2
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +2 -2
- package/src/private/webapis/{dom/oldstylecollections → geometry}/DOMRectList.js +3 -3
- package/src/private/webapis/html/events/MessageEvent.js +56 -0
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +6 -6
- package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +1 -1
- package/src/private/webapis/intersectionobserver/{IntersectionObserverManager.js → internals/IntersectionObserverManager.js} +20 -17
- package/src/private/webapis/mutationobserver/MutationObserver.js +11 -11
- package/src/private/webapis/mutationobserver/{MutationObserverManager.js → internals/MutationObserverManager.js} +12 -14
- package/src/private/webapis/performance/EventTiming.js +1 -1
- package/src/private/webapis/performance/Performance.js +3 -3
- package/src/private/webapis/performance/PerformanceObserver.js +8 -8
- package/src/private/webapis/performance/{RawPerformanceEntry.js → internals/RawPerformanceEntry.js} +6 -6
- package/src/private/webapis/performance/{Utilities.js → internals/Utilities.js} +1 -1
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +1 -1
- package/src/private/webapis/websockets/events/CloseEvent.js +52 -0
- package/src/private/webapis/xhr/events/ProgressEvent.js +52 -0
- package/src/types/globals.d.ts +628 -0
- package/src-win/Libraries/Components/View/ViewPropTypes.d.ts +14 -14
- package/src-win/Libraries/Text/Text.d.ts +1 -1
- package/types/index.d.ts +2 -58
- package/Libraries/Animated/AnimatedWeb.js +0 -26
- package/Libraries/Inspector/Inspector.win32.js +0 -212
- package/Libraries/Inspector/InspectorOverlay.win32.js +0 -68
- package/Libraries/JSInspector/InspectorAgent.js +0 -27
- package/Libraries/JSInspector/JSInspector.js +0 -33
- package/Libraries/JSInspector/NetworkAgent.js +0 -295
- package/Libraries/Utilities/DebugEnvironment.js +0 -16
- package/Libraries/Utilities/Platform.flow.js +0 -91
- package/Libraries/YellowBox/YellowBoxDeprecated.d.ts +0 -19
- package/Libraries/YellowBox/YellowBoxDeprecated.js +0 -75
- package/src/private/specs/modules/NativeCPUTime.js +0 -24
- package/src/private/specs/modules/NativeFantom.js +0 -37
- package/src/private/specs/modules/NativeUIManager.js +0 -111
- package/types/modules/globals.d.ts +0 -599
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeAccessibilityInfo.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeAccessibilityInfoWin32.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeAppearance.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeBugReporting.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeDevLoadingView.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeDeviceEventManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeFileReaderModule.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeHeadlessJsTaskSupport.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeIntentAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeJSCHeapCapture.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeKeyboardObserver.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeLinkingManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeLogBox.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeModalManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeNetworkingAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeReactDevToolsSettingsManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeRedBox.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeSegmentFetcher.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeSoundManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeTiming.js +0 -0
- /package/src/private/webapis/dom/nodes/{utilities → internals}/Traversal.js +0 -0
- /package/src/private/webapis/{dom/geometry → geometry}/DOMRect.js +0 -0
- /package/src/private/webapis/{dom/geometry → geometry}/DOMRectReadOnly.js +0 -0
- /package/src/private/webapis/{dom/oldstylecollections → utils}/ArrayLikeUtils.js +0 -0
|
@@ -0,0 +1,701 @@
|
|
|
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;
|
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import typeof BlobT from '../Blob/Blob';
|
|
14
|
+
import typeof FormDataT from './FormData';
|
|
15
|
+
|
|
16
|
+
const Blob: BlobT = require('../Blob/Blob').default;
|
|
17
|
+
const binaryToBase64 = require('../Utilities/binaryToBase64').default;
|
|
18
|
+
const FormData: FormDataT = require('./FormData').default;
|
|
16
19
|
|
|
17
20
|
export type RequestBody =
|
|
18
21
|
| string
|
|
@@ -40,4 +43,4 @@ function convertRequestBody(body: RequestBody): Object {
|
|
|
40
43
|
return body;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
export default convertRequestBody;
|