@office-iss/react-native-win32 0.0.0-canary.284 → 0.0.0-canary.285
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/CHANGELOG.json +40 -1
- package/CHANGELOG.md +20 -8
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +38 -17
- package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +2 -2
- package/Libraries/Alert/Alert.flow.js +62 -0
- package/Libraries/Alert/Alert.js +4 -27
- package/Libraries/Alert/Alert.win32.js +5 -27
- package/Libraries/Alert/NativeAlertManager.js +2 -2
- package/Libraries/Alert/RCTAlertManager.flow.js +20 -0
- package/Libraries/Animated/NativeAnimatedModule.js +2 -2
- package/Libraries/Animated/NativeAnimatedTurboModule.js +2 -2
- package/Libraries/Animated/createAnimatedComponent.js +3 -3
- package/Libraries/Animated/useAnimatedProps.js +4 -294
- package/Libraries/AppState/NativeAppState.js +2 -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/URLSearchParams.js +1 -2
- package/Libraries/BugReporting/NativeBugReporting.js +2 -2
- 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/ActivityIndicator/ActivityIndicatorViewNativeComponent.js +2 -2
- package/Libraries/Components/Clipboard/NativeClipboard.js +2 -2
- package/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +2 -2
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +2 -1
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +14 -18
- package/Libraries/Components/Keyboard/NativeKeyboardObserver.js +2 -2
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +2 -2
- package/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +2 -2
- package/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +2 -2
- package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +2 -2
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollContentViewNativeComponent.js +2 -2
- package/Libraries/Components/Sound/NativeSoundManager.js +2 -2
- package/Libraries/Components/StatusBar/NativeStatusBarManagerAndroid.js +2 -2
- package/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +2 -2
- package/Libraries/Components/Switch/AndroidSwitchNativeComponent.js +2 -2
- package/Libraries/Components/Switch/SwitchNativeComponent.js +2 -2
- package/Libraries/Components/TextInput/InputAccessoryView.js +4 -2
- package/Libraries/Components/TextInput/RCTInputAccessoryViewNativeComponent.js +2 -2
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -1
- package/Libraries/Components/TextInput/TextInput.flow.js +98 -88
- package/Libraries/Components/TextInput/TextInput.js +103 -96
- package/Libraries/Components/TextInput/TextInput.win32.js +105 -98
- package/Libraries/Components/TextInput/TextInputState.js +3 -1
- package/Libraries/Components/TextInput/TextInputState.win32.js +3 -1
- package/Libraries/Components/ToastAndroid/NativeToastAndroid.js +2 -2
- package/Libraries/Components/ToastAndroid/ToastAndroid.android.js +1 -1
- 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/TouchableBounce.js +1 -1
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +1 -1
- package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -2
- package/Libraries/Components/UnimplementedViews/UnimplementedNativeViewNativeComponent.js +2 -2
- package/Libraries/Components/UnimplementedViews/UnimplementedView.js +2 -2
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -1
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -1
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -1
- package/Libraries/Components/View/View.js +1 -1
- package/Libraries/Components/View/View.win32.js +1 -1
- 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 +5 -4
- package/Libraries/Core/ExceptionsManager.js +6 -4
- package/Libraries/Core/InitializeCore.js +5 -2
- package/Libraries/Core/NativeExceptionsManager.js +2 -2
- package/Libraries/Core/ReactFiberErrorDialog.js +2 -2
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- 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 +1 -1
- package/Libraries/Core/Timers/NativeTiming.js +2 -2
- package/Libraries/Core/Timers/immediateShim.js +2 -9
- package/Libraries/Core/setUpBatchedBridge.js +4 -3
- package/Libraries/Core/setUpDeveloperTools.js +2 -7
- package/Libraries/Core/setUpErrorHandling.js +1 -6
- package/Libraries/Core/setUpReactDevTools.js +22 -4
- package/Libraries/Core/setUpTimers.js +17 -17
- package/Libraries/Core/setUpXHR.js +1 -1
- package/Libraries/Debugging/DebuggingOverlayNativeComponent.js +2 -2
- package/Libraries/EventEmitter/RCTEventEmitter.js +1 -1
- package/Libraries/EventEmitter/RCTNativeAppEventEmitter.js +1 -1
- package/Libraries/Image/AssetRegistry.js +3 -1
- package/Libraries/Image/AssetSourceResolver.js +1 -1
- package/Libraries/Image/Image.android.js +3 -1
- package/Libraries/Image/Image.ios.js +1 -1
- package/Libraries/Image/Image.win32.js +1 -1
- package/Libraries/Image/ImageBackground.js +1 -1
- package/Libraries/Image/ImageViewNativeComponent.js +4 -5
- 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/nativeImageSource.js +1 -1
- package/Libraries/Image/resolveAssetSource.js +4 -2
- package/Libraries/Interaction/FrameRateLogger.js +1 -1
- package/Libraries/Interaction/InteractionManager.js +8 -6
- package/Libraries/Interaction/InteractionManagerStub.js +1 -1
- package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -1
- package/Libraries/Interaction/NativeFrameRateLogger.js +2 -2
- package/Libraries/Interaction/PanResponder.js +2 -2
- package/Libraries/Interaction/TaskQueue.js +1 -1
- package/Libraries/Interaction/TouchHistoryMath.js +1 -1
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
- package/Libraries/Linking/Linking.d.ts +3 -3
- package/Libraries/Linking/Linking.js +10 -8
- package/Libraries/Linking/NativeIntentAndroid.js +2 -2
- package/Libraries/Linking/NativeLinkingManager.js +2 -2
- package/Libraries/Lists/FillRateHelper.js +1 -1
- package/Libraries/Lists/FlatList.js +1 -1
- package/Libraries/Lists/ViewabilityHelper.js +1 -1
- package/Libraries/Lists/VirtualizeUtils.js +1 -3
- package/Libraries/Lists/VirtualizedList.js +1 -1
- package/Libraries/Lists/VirtualizedListContext.js +1 -3
- package/Libraries/Lists/VirtualizedSectionList.js +1 -1
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/Modal/Modal.js +3 -3
- package/Libraries/Modal/NativeModalManager.js +2 -2
- package/Libraries/Modal/RCTModalHostViewNativeComponent.js +2 -2
- 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/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.win32.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +11 -685
- package/Libraries/Network/XMLHttpRequest_new.js +790 -0
- package/Libraries/Network/XMLHttpRequest_old.js +697 -0
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +2 -2
- package/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +2 -2
- package/Libraries/ReactNative/AppContainer-dev.js +2 -2
- package/Libraries/ReactNative/AppContainer.js +1 -1
- package/Libraries/ReactNative/AppRegistry.js +1 -1
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -1
- package/Libraries/ReactNative/FabricUIManager.js +18 -8
- package/Libraries/ReactNative/I18nManager.js +1 -1
- 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 +2 -3
- package/Libraries/ReactNative/PaperUIManager.win32.js +2 -3
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +85 -31
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +1 -1
- package/Libraries/ReactNative/ReactNativeRuntimeDiagnostics.js +1 -1
- package/Libraries/ReactNative/RendererImplementation.js +9 -0
- 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 +6 -5
- package/Libraries/ReactNative/requireNativeComponent.js +2 -1
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +9 -4
- package/Libraries/Renderer/shims/ReactNativeTypes.js +5 -1
- package/Libraries/Settings/NativeSettingsManager.js +2 -2
- package/Libraries/Settings/Settings.ios.js +1 -1
- package/Libraries/Settings/Settings.js +1 -1
- package/Libraries/Settings/Settings.win32.js +1 -1
- package/Libraries/Share/NativeShareModule.js +2 -2
- package/Libraries/Share/Share.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.js +2 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +2 -1
- package/Libraries/StyleSheet/processBoxShadow.js +4 -0
- package/Libraries/StyleSheet/processColorArray.js +1 -1
- package/Libraries/Text/Text.js +1 -1
- package/Libraries/Text/Text.win32.js +1 -1
- package/Libraries/Text/TextAncestor.js +1 -1
- package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +2 -2
- package/Libraries/Types/CoreEventTypes.js +2 -0
- package/Libraries/Types/CoreEventTypes.win32.js +2 -0
- package/Libraries/Utilities/Appearance.js +0 -8
- 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/ReactNativeTestTools.js +3 -4
- package/Libraries/Utilities/dismissKeyboard.js +2 -1
- package/Libraries/Vibration/NativeVibration.js +2 -2
- package/Libraries/WebSocket/NativeWebSocketModule.js +2 -2
- package/Libraries/WebSocket/WebSocket.js +8 -285
- package/Libraries/WebSocket/WebSocketEvent.js +1 -1
- 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/index.js +25 -26
- package/index.win32.js +25 -26
- package/jest/mockScrollView.js +1 -1
- package/jest/setup.js +91 -65
- package/overrides.json +30 -42
- package/package.json +16 -16
- package/src/private/animated/createAnimatedPropsHook.js +360 -0
- package/src/private/animated/{useAnimatedPropsMemo.js → createAnimatedPropsMemoHook.js} +84 -32
- package/src/private/components/HScrollViewNativeComponents.js +1 -1
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +2 -2
- package/src/private/debugging/ReactDevToolsSettingsManager.android.js +1 -1
- package/src/private/debugging/ReactDevToolsSettingsManager.win32.js +1 -1
- package/src/private/devmenu/DevMenu.js +1 -1
- package/src/private/featureflags/ReactNativeFeatureFlags.js +23 -30
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +2 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -7
- 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 +8 -8
- package/{Libraries/Inspector → src/private/inspector}/ElementProperties.js +14 -12
- package/{Libraries/Inspector → src/private/inspector}/Inspector.js +18 -15
- package/{Libraries/Inspector → src/private/inspector}/InspectorOverlay.js +5 -5
- package/{Libraries/Inspector → src/private/inspector}/InspectorPanel.js +12 -10
- package/{Libraries/Inspector → src/private/inspector}/NetworkOverlay.js +35 -20
- package/{Libraries/Inspector → src/private/inspector}/PerformanceOverlay.js +5 -5
- package/{Libraries/Inspector → src/private/inspector}/ReactDevToolsOverlay.js +9 -8
- package/{Libraries/Inspector → src/private/inspector}/StyleInspector.js +6 -6
- package/{Libraries/Network → src/private/inspector}/XHRInterceptor.js +1 -1
- package/{Libraries/Inspector → src/private/inspector}/getInspectorDataForViewAtPoint.js +5 -3
- package/{Libraries/Inspector → src/private/inspector}/resolveBoxStyle.js +3 -2
- package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -4
- package/src/private/setup/setUpDOM.js +7 -2
- 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/webapis/dom/events/CustomEvent.js +40 -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 +120 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +48 -25
- package/src/private/webapis/dom/nodes/ReadOnlyCharacterData.js +6 -5
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +25 -25
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +55 -77
- 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 +43 -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 +63 -0
- package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +1 -1
- package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +12 -9
- package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +4 -6
- package/src/private/webapis/websockets/events/CloseEvent.js +54 -0
- package/src/private/webapis/xhr/events/ProgressEvent.js +54 -0
- package/types/index.d.ts +0 -5
- package/Libraries/Animated/AnimatedWeb.js +0 -44
- 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 -296
- package/Libraries/Utilities/DebugEnvironment.js +0 -16
- package/Libraries/YellowBox/YellowBoxDeprecated.d.ts +0 -19
- package/Libraries/YellowBox/YellowBoxDeprecated.js +0 -76
- package/src/private/specs/modules/NativeCPUTime.js +0 -24
- package/src/private/specs/modules/NativeFantom.js +0 -43
- /package/src/private/{specs → specs_DEPRECATED}/components/ActivityIndicatorViewNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/AndroidDrawerLayoutNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/AndroidHorizontalScrollContentViewNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/AndroidSwipeRefreshLayoutNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/AndroidSwitchNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/DebuggingOverlayNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/ProgressBarAndroidNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/PullToRefreshViewNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/RCTInputAccessoryViewNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/RCTModalHostViewNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/RCTSafeAreaViewNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/SwitchNativeComponent.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/components/UnimplementedNativeViewNativeComponent.js +0 -0
- /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/NativeAccessibilityManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeActionSheetManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeAlertManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeAnimatedModule.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeAnimatedTurboModule.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeAppState.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeAppearance.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeBlobModule.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeBugReporting.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeClipboard.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/NativeDeviceInfo.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeDialogManagerAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeExceptionsManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeFileReaderModule.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeFrameRateLogger.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeHeadlessJsTaskSupport.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeI18nManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageEditor.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageLoaderAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageLoaderIOS.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageLoaderWin32.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageStoreAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeImageStoreIOS.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/NativeNetworkingIOS.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativePermissionsAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativePlatformConstantsAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativePlatformConstantsIOS.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativePlatformConstantsWin.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativePushNotificationManagerIOS.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/NativeSampleTurboModule.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeSegmentFetcher.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeSettingsManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeShareModule.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeSoundManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeSourceCode.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeStatusBarManagerAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeStatusBarManagerIOS.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeTiming.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeToastAndroid.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeUIManager.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeVibration.js +0 -0
- /package/src/private/{specs → specs_DEPRECATED}/modules/NativeWebSocketModule.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
|
@@ -8,301 +8,11 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
12
|
-
import type {AnimatedPropsAllowlist} from './nodes/AnimatedProps';
|
|
11
|
+
import type {AnimatedPropsHook} from '../../src/private/animated/createAnimatedPropsHook';
|
|
13
12
|
|
|
14
|
-
import
|
|
15
|
-
import {useAnimatedPropsMemo} from '../../src/private/animated/useAnimatedPropsMemo';
|
|
16
|
-
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
17
|
-
import {isPublicInstance as isFabricPublicInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils';
|
|
18
|
-
import useRefEffect from '../Utilities/useRefEffect';
|
|
19
|
-
import {AnimatedEvent} from './AnimatedEvent';
|
|
20
|
-
import AnimatedNode from './nodes/AnimatedNode';
|
|
21
|
-
import AnimatedProps from './nodes/AnimatedProps';
|
|
22
|
-
import AnimatedValue from './nodes/AnimatedValue';
|
|
23
|
-
import {
|
|
24
|
-
useCallback,
|
|
25
|
-
useEffect,
|
|
26
|
-
useInsertionEffect,
|
|
27
|
-
useReducer,
|
|
28
|
-
useRef,
|
|
29
|
-
} from 'react';
|
|
30
|
-
|
|
31
|
-
type ReducedProps<TProps> = {
|
|
32
|
-
...TProps,
|
|
33
|
-
collapsable: boolean,
|
|
34
|
-
...
|
|
35
|
-
};
|
|
36
|
-
type CallbackRef<T> = T => mixed;
|
|
37
|
-
|
|
38
|
-
type UpdateCallback = () => void;
|
|
39
|
-
|
|
40
|
-
type AnimatedValueListeners = Array<{
|
|
41
|
-
propValue: AnimatedValue,
|
|
42
|
-
listenerId: string,
|
|
43
|
-
}>;
|
|
44
|
-
|
|
45
|
-
export default function useAnimatedProps<TProps: {...}, TInstance>(
|
|
46
|
-
props: TProps,
|
|
47
|
-
allowlist?: ?AnimatedPropsAllowlist,
|
|
48
|
-
): [ReducedProps<TProps>, CallbackRef<TInstance | null>] {
|
|
49
|
-
const [, scheduleUpdate] = useReducer<number, void>(count => count + 1, 0);
|
|
50
|
-
const onUpdateRef = useRef<UpdateCallback | null>(null);
|
|
51
|
-
const timerRef = useRef<TimeoutID | null>(null);
|
|
52
|
-
|
|
53
|
-
const node = useAnimatedPropsMemo(
|
|
54
|
-
() => new AnimatedProps(props, () => onUpdateRef.current?.(), allowlist),
|
|
55
|
-
[allowlist, props],
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const useNativePropsInFabric =
|
|
59
|
-
ReactNativeFeatureFlags.shouldUseSetNativePropsInFabric();
|
|
60
|
-
|
|
61
|
-
useAnimatedPropsLifecycle(node);
|
|
62
|
-
|
|
63
|
-
// TODO: This "effect" does three things:
|
|
64
|
-
//
|
|
65
|
-
// 1) Call `setNativeView`.
|
|
66
|
-
// 2) Update `onUpdateRef`.
|
|
67
|
-
// 3) Update listeners for `AnimatedEvent` props.
|
|
68
|
-
//
|
|
69
|
-
// Ideally, each of these would be separate "effects" so that they are not
|
|
70
|
-
// unnecessarily re-run when irrelevant dependencies change. For example, we
|
|
71
|
-
// should be able to hoist all `AnimatedEvent` props and only do #3 if either
|
|
72
|
-
// the `AnimatedEvent` props change or `instance` changes.
|
|
73
|
-
//
|
|
74
|
-
// But there is no way to transparently compose three separate callback refs,
|
|
75
|
-
// so we just combine them all into one for now.
|
|
76
|
-
const refEffect = useCallback(
|
|
77
|
-
(instance: TInstance) => {
|
|
78
|
-
// NOTE: This may be called more often than necessary (e.g. when `props`
|
|
79
|
-
// changes), but `setNativeView` already optimizes for that.
|
|
80
|
-
node.setNativeView(instance);
|
|
81
|
-
|
|
82
|
-
// NOTE: When using the JS animation driver, this callback is called on
|
|
83
|
-
// every animation frame. When using the native driver, this callback is
|
|
84
|
-
// called when the animation completes.
|
|
85
|
-
onUpdateRef.current = () => {
|
|
86
|
-
if (process.env.NODE_ENV === 'test') {
|
|
87
|
-
// Check 1: this is a test.
|
|
88
|
-
// call `scheduleUpdate` to bypass use of setNativeProps.
|
|
89
|
-
return scheduleUpdate();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const isFabricNode = isFabricInstance(instance);
|
|
93
|
-
if (node.__isNative) {
|
|
94
|
-
// Check 2: this is an animation driven by native.
|
|
95
|
-
// In native driven animations, this callback is only called once the animation completes.
|
|
96
|
-
if (isFabricNode) {
|
|
97
|
-
// Call `scheduleUpdate` to synchronise Fiber and Shadow tree.
|
|
98
|
-
// Must not be called in Paper.
|
|
99
|
-
scheduleUpdate();
|
|
100
|
-
}
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
typeof instance !== 'object' ||
|
|
106
|
-
typeof instance?.setNativeProps !== 'function'
|
|
107
|
-
) {
|
|
108
|
-
// Check 3: the instance does not support setNativeProps. Call `scheduleUpdate`.
|
|
109
|
-
return scheduleUpdate();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!isFabricNode) {
|
|
113
|
-
// Check 4: this is a paper instance, call setNativeProps.
|
|
114
|
-
// $FlowIgnore[not-a-function] - Assume it's still a function.
|
|
115
|
-
// $FlowFixMe[incompatible-use]
|
|
116
|
-
return instance.setNativeProps(node.__getAnimatedValue());
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!useNativePropsInFabric) {
|
|
120
|
-
// Check 5: setNativeProps are disabled.
|
|
121
|
-
return scheduleUpdate();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// This is a Fabric instance and setNativeProps is supported.
|
|
125
|
-
|
|
126
|
-
// $FlowIgnore[not-a-function] - Assume it's still a function.
|
|
127
|
-
// $FlowFixMe[incompatible-use]
|
|
128
|
-
instance.setNativeProps(node.__getAnimatedValue());
|
|
129
|
-
|
|
130
|
-
// Keeping state of Fiber tree and Shadow tree in sync.
|
|
131
|
-
//
|
|
132
|
-
// This is done by calling `scheduleUpdate` which will trigger a commit.
|
|
133
|
-
// However, React commit is not fast enough to drive animations.
|
|
134
|
-
// This is where setNativeProps comes in handy but the state between
|
|
135
|
-
// Fiber tree and Shadow tree needs to be kept in sync.
|
|
136
|
-
// The goal is to call `scheduleUpdate` as little as possible to maintain
|
|
137
|
-
// performance but frequently enough to keep state in sync.
|
|
138
|
-
// Debounce is set to 48ms, which is 3 * the duration of a frame.
|
|
139
|
-
// 3 frames was the highest value where flickering state was not observed.
|
|
140
|
-
if (timerRef.current != null) {
|
|
141
|
-
clearTimeout(timerRef.current);
|
|
142
|
-
}
|
|
143
|
-
timerRef.current = setTimeout(() => {
|
|
144
|
-
timerRef.current = null;
|
|
145
|
-
scheduleUpdate();
|
|
146
|
-
}, 48);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const target = getEventTarget(instance);
|
|
150
|
-
const events = [];
|
|
151
|
-
const animatedValueListeners: AnimatedValueListeners = [];
|
|
152
|
-
|
|
153
|
-
for (const propName in props) {
|
|
154
|
-
// $FlowFixMe[invalid-computed-prop]
|
|
155
|
-
const propValue = props[propName];
|
|
156
|
-
if (propValue instanceof AnimatedEvent && propValue.__isNative) {
|
|
157
|
-
propValue.__attach(target, propName);
|
|
158
|
-
events.push([propName, propValue]);
|
|
159
|
-
// $FlowFixMe[incompatible-call] - the `addListenersToPropsValue` drills down the propValue.
|
|
160
|
-
addListenersToPropsValue(propValue, animatedValueListeners);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return () => {
|
|
165
|
-
onUpdateRef.current = null;
|
|
166
|
-
|
|
167
|
-
for (const [propName, propValue] of events) {
|
|
168
|
-
propValue.__detach(target, propName);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
for (const {propValue, listenerId} of animatedValueListeners) {
|
|
172
|
-
propValue.removeListener(listenerId);
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
},
|
|
176
|
-
[node, useNativePropsInFabric, props],
|
|
177
|
-
);
|
|
178
|
-
const callbackRef = useRefEffect<TInstance>(refEffect);
|
|
179
|
-
|
|
180
|
-
return [reduceAnimatedProps<TProps>(node, props), callbackRef];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function reduceAnimatedProps<TProps>(
|
|
184
|
-
node: AnimatedProps,
|
|
185
|
-
props: TProps,
|
|
186
|
-
): ReducedProps<TProps> {
|
|
187
|
-
// Force `collapsable` to be false so that the native view is not flattened.
|
|
188
|
-
// Flattened views cannot be accurately referenced by the native driver.
|
|
189
|
-
return {
|
|
190
|
-
...node.__getValueWithStaticProps(props),
|
|
191
|
-
collapsable: false,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function addListenersToPropsValue(
|
|
196
|
-
propValue: AnimatedValue,
|
|
197
|
-
accumulator: AnimatedValueListeners,
|
|
198
|
-
) {
|
|
199
|
-
// propValue can be a scalar value, an array or an object.
|
|
200
|
-
if (propValue instanceof AnimatedValue) {
|
|
201
|
-
const listenerId = propValue.addListener(() => {});
|
|
202
|
-
accumulator.push({propValue, listenerId});
|
|
203
|
-
} else if (Array.isArray(propValue)) {
|
|
204
|
-
// An array can be an array of scalar values, arrays of arrays, or arrays of objects
|
|
205
|
-
for (const prop of propValue) {
|
|
206
|
-
addListenersToPropsValue(prop, accumulator);
|
|
207
|
-
}
|
|
208
|
-
} else if (propValue instanceof Object) {
|
|
209
|
-
addAnimatedValuesListenersToProps(propValue, accumulator);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function addAnimatedValuesListenersToProps(
|
|
214
|
-
props: AnimatedNode,
|
|
215
|
-
accumulator: AnimatedValueListeners,
|
|
216
|
-
) {
|
|
217
|
-
for (const propName in props) {
|
|
218
|
-
// $FlowFixMe[prop-missing] - This is an object contained in a prop, but we don't know the exact type.
|
|
219
|
-
const propValue = props[propName];
|
|
220
|
-
addListenersToPropsValue(propValue, accumulator);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
13
|
+
import createAnimatedPropsHook from '../../src/private/animated/createAnimatedPropsHook';
|
|
223
14
|
|
|
224
15
|
/**
|
|
225
|
-
*
|
|
226
|
-
* and `__detach`. However, this is more complicated because `AnimatedProps`
|
|
227
|
-
* uses reference counting to determine when to recursively detach its children
|
|
228
|
-
* nodes. So in order to optimize this, we avoid detaching until the next attach
|
|
229
|
-
* unless we are unmounting.
|
|
16
|
+
* @deprecated
|
|
230
17
|
*/
|
|
231
|
-
|
|
232
|
-
const prevNodeRef = useRef<?AnimatedProps>(null);
|
|
233
|
-
const isUnmountingRef = useRef<boolean>(false);
|
|
234
|
-
|
|
235
|
-
useEffect(() => {
|
|
236
|
-
// It is ok for multiple components to call `flushQueue` because it noops
|
|
237
|
-
// if the queue is empty. When multiple animated components are mounted at
|
|
238
|
-
// the same time. Only first component flushes the queue and the others will noop.
|
|
239
|
-
NativeAnimatedHelper.API.flushQueue();
|
|
240
|
-
let drivenAnimationEndedListener: ?EventSubscription = null;
|
|
241
|
-
if (node.__isNative) {
|
|
242
|
-
drivenAnimationEndedListener =
|
|
243
|
-
NativeAnimatedHelper.nativeEventEmitter.addListener(
|
|
244
|
-
'onUserDrivenAnimationEnded',
|
|
245
|
-
data => {
|
|
246
|
-
node.update();
|
|
247
|
-
},
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return () => {
|
|
252
|
-
drivenAnimationEndedListener?.remove();
|
|
253
|
-
};
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
useInsertionEffect(() => {
|
|
257
|
-
isUnmountingRef.current = false;
|
|
258
|
-
return () => {
|
|
259
|
-
isUnmountingRef.current = true;
|
|
260
|
-
};
|
|
261
|
-
}, []);
|
|
262
|
-
|
|
263
|
-
useInsertionEffect(() => {
|
|
264
|
-
node.__attach();
|
|
265
|
-
if (prevNodeRef.current != null) {
|
|
266
|
-
const prevNode = prevNodeRef.current;
|
|
267
|
-
// TODO: Stop restoring default values (unless `reset` is called).
|
|
268
|
-
prevNode.__restoreDefaultValues();
|
|
269
|
-
prevNode.__detach();
|
|
270
|
-
prevNodeRef.current = null;
|
|
271
|
-
}
|
|
272
|
-
return () => {
|
|
273
|
-
if (isUnmountingRef.current) {
|
|
274
|
-
// NOTE: Do not restore default values on unmount, see D18197735.
|
|
275
|
-
node.__detach();
|
|
276
|
-
} else {
|
|
277
|
-
prevNodeRef.current = node;
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
}, [node]);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function getEventTarget<TInstance>(instance: TInstance): TInstance {
|
|
284
|
-
return typeof instance === 'object' &&
|
|
285
|
-
typeof instance?.getScrollableNode === 'function'
|
|
286
|
-
? // $FlowFixMe[incompatible-use] - Legacy instance assumptions.
|
|
287
|
-
instance.getScrollableNode()
|
|
288
|
-
: instance;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// $FlowFixMe[unclear-type] - Legacy instance assumptions.
|
|
292
|
-
function isFabricInstance(instance: any): boolean {
|
|
293
|
-
return (
|
|
294
|
-
isFabricPublicInstance(instance) ||
|
|
295
|
-
// Some components have a setNativeProps function but aren't a host component
|
|
296
|
-
// such as lists like FlatList and SectionList. These should also use
|
|
297
|
-
// forceUpdate in Fabric since setNativeProps doesn't exist on the underlying
|
|
298
|
-
// host component. This crazy hack is essentially special casing those lists and
|
|
299
|
-
// ScrollView itself to use forceUpdate in Fabric.
|
|
300
|
-
// If these components end up using forwardRef then these hacks can go away
|
|
301
|
-
// as instance would actually be the underlying host component and the above check
|
|
302
|
-
// would be sufficient.
|
|
303
|
-
isFabricPublicInstance(instance?.getNativeScrollRef?.()) ||
|
|
304
|
-
isFabricPublicInstance(
|
|
305
|
-
instance?.getScrollResponder?.()?.getNativeScrollRef?.(),
|
|
306
|
-
)
|
|
307
|
-
);
|
|
308
|
-
}
|
|
18
|
+
export default createAnimatedPropsHook(null) as AnimatedPropsHook;
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export * from '../../src/private/
|
|
12
|
-
import NativeAppState from '../../src/private/
|
|
11
|
+
export * from '../../src/private/specs_DEPRECATED/modules/NativeAppState';
|
|
12
|
+
import NativeAppState from '../../src/private/specs_DEPRECATED/modules/NativeAppState';
|
|
13
13
|
export default NativeAppState;
|
|
@@ -8,179 +8,13 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import
|
|
11
|
+
import typeof FileReader from './FileReader_old';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
// Use a global instead of a flag from ReactNativeFeatureFlags because this will
|
|
14
|
+
// be read before apps have a chance to set overrides.
|
|
15
|
+
const useBuiltInEventTarget = global.RN$useBuiltInEventTarget?.();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type ReaderResult = string | ArrayBuffer;
|
|
23
|
-
|
|
24
|
-
const READER_EVENTS = [
|
|
25
|
-
'abort',
|
|
26
|
-
'error',
|
|
27
|
-
'load',
|
|
28
|
-
'loadstart',
|
|
29
|
-
'loadend',
|
|
30
|
-
'progress',
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const EMPTY = 0;
|
|
34
|
-
const LOADING = 1;
|
|
35
|
-
const DONE = 2;
|
|
36
|
-
|
|
37
|
-
class FileReader extends (EventTarget(...READER_EVENTS): typeof EventTarget) {
|
|
38
|
-
static EMPTY: number = EMPTY;
|
|
39
|
-
static LOADING: number = LOADING;
|
|
40
|
-
static DONE: number = DONE;
|
|
41
|
-
|
|
42
|
-
EMPTY: number = EMPTY;
|
|
43
|
-
LOADING: number = LOADING;
|
|
44
|
-
DONE: number = DONE;
|
|
45
|
-
|
|
46
|
-
_readyState: ReadyState;
|
|
47
|
-
_error: ?Error;
|
|
48
|
-
_result: ?ReaderResult;
|
|
49
|
-
_aborted: boolean = false;
|
|
50
|
-
|
|
51
|
-
constructor() {
|
|
52
|
-
super();
|
|
53
|
-
this._reset();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
_reset(): void {
|
|
57
|
-
this._readyState = EMPTY;
|
|
58
|
-
this._error = null;
|
|
59
|
-
this._result = null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
_setReadyState(newState: ReadyState) {
|
|
63
|
-
this._readyState = newState;
|
|
64
|
-
this.dispatchEvent({type: 'readystatechange'});
|
|
65
|
-
if (newState === DONE) {
|
|
66
|
-
if (this._aborted) {
|
|
67
|
-
this.dispatchEvent({type: 'abort'});
|
|
68
|
-
} else if (this._error) {
|
|
69
|
-
this.dispatchEvent({type: 'error'});
|
|
70
|
-
} else {
|
|
71
|
-
this.dispatchEvent({type: 'load'});
|
|
72
|
-
}
|
|
73
|
-
this.dispatchEvent({type: 'loadend'});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
readAsArrayBuffer(blob: ?Blob): void {
|
|
78
|
-
this._aborted = false;
|
|
79
|
-
|
|
80
|
-
if (blob == null) {
|
|
81
|
-
throw new TypeError(
|
|
82
|
-
"Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'",
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
NativeFileReaderModule.readAsDataURL(blob.data).then(
|
|
87
|
-
(text: string) => {
|
|
88
|
-
if (this._aborted) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const base64 = text.split(',')[1];
|
|
93
|
-
const typedArray = toByteArray(base64);
|
|
94
|
-
|
|
95
|
-
this._result = typedArray.buffer;
|
|
96
|
-
this._setReadyState(DONE);
|
|
97
|
-
},
|
|
98
|
-
error => {
|
|
99
|
-
if (this._aborted) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
this._error = error;
|
|
103
|
-
this._setReadyState(DONE);
|
|
104
|
-
},
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
readAsDataURL(blob: ?Blob): void {
|
|
109
|
-
this._aborted = false;
|
|
110
|
-
|
|
111
|
-
if (blob == null) {
|
|
112
|
-
throw new TypeError(
|
|
113
|
-
"Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'",
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
NativeFileReaderModule.readAsDataURL(blob.data).then(
|
|
118
|
-
(text: string) => {
|
|
119
|
-
if (this._aborted) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
this._result = text;
|
|
123
|
-
this._setReadyState(DONE);
|
|
124
|
-
},
|
|
125
|
-
error => {
|
|
126
|
-
if (this._aborted) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
this._error = error;
|
|
130
|
-
this._setReadyState(DONE);
|
|
131
|
-
},
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
readAsText(blob: ?Blob, encoding: string = 'UTF-8'): void {
|
|
136
|
-
this._aborted = false;
|
|
137
|
-
|
|
138
|
-
if (blob == null) {
|
|
139
|
-
throw new TypeError(
|
|
140
|
-
"Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob'",
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
NativeFileReaderModule.readAsText(blob.data, encoding).then(
|
|
145
|
-
(text: string) => {
|
|
146
|
-
if (this._aborted) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
this._result = text;
|
|
150
|
-
this._setReadyState(DONE);
|
|
151
|
-
},
|
|
152
|
-
error => {
|
|
153
|
-
if (this._aborted) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
this._error = error;
|
|
157
|
-
this._setReadyState(DONE);
|
|
158
|
-
},
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
abort() {
|
|
163
|
-
this._aborted = true;
|
|
164
|
-
// only call onreadystatechange if there is something to abort, as per spec
|
|
165
|
-
if (this._readyState !== EMPTY && this._readyState !== DONE) {
|
|
166
|
-
this._reset();
|
|
167
|
-
this._setReadyState(DONE);
|
|
168
|
-
}
|
|
169
|
-
// Reset again after, in case modified in handler
|
|
170
|
-
this._reset();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
get readyState(): ReadyState {
|
|
174
|
-
return this._readyState;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
get error(): ?Error {
|
|
178
|
-
return this._error;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
get result(): ?ReaderResult {
|
|
182
|
-
return this._result;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export default FileReader;
|
|
17
|
+
export default (useBuiltInEventTarget
|
|
18
|
+
? // $FlowExpectedError[incompatible-cast]
|
|
19
|
+
require('./FileReader_new').default
|
|
20
|
+
: require('./FileReader_old').default) as FileReader;
|