@office-iss/react-native-win32 0.71.5 → 0.72.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 +15 -3
- package/CHANGELOG.json +302 -47
- package/CHANGELOG.md +141 -27
- package/IntegrationTests/IntegrationTestHarnessTest.js +1 -0
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +1 -1
- package/Libraries/Alert/Alert.d.ts +4 -4
- package/Libraries/Alert/Alert.win32.js +1 -0
- package/Libraries/Animated/Animated.d.ts +17 -6
- package/Libraries/Animated/NativeAnimatedHelper.js +18 -6
- package/Libraries/Animated/NativeAnimatedHelper.win32.js +606 -0
- package/Libraries/Animated/bezier.js +1 -1
- package/Libraries/Animated/components/AnimatedFlatList.js +8 -3
- package/Libraries/Animated/components/AnimatedScrollView.js +4 -1
- package/Libraries/Animated/components/AnimatedSectionList.js +12 -3
- package/Libraries/Animated/createAnimatedComponent.js +26 -239
- package/Libraries/Animated/nodes/AnimatedColor.js +47 -80
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +167 -121
- package/Libraries/Animated/nodes/AnimatedNode.js +3 -5
- package/Libraries/Animated/nodes/AnimatedProps.js +7 -6
- package/Libraries/Animated/nodes/AnimatedStyle.js +42 -8
- package/Libraries/Animated/nodes/AnimatedTransform.js +1 -1
- package/Libraries/Animated/nodes/AnimatedValue.js +8 -12
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -1
- package/Libraries/Animated/useAnimatedProps.js +7 -10
- package/Libraries/BatchedBridge/MessageQueue.js +2 -1
- package/Libraries/BatchedBridge/NativeModules.d.ts +1 -1
- package/Libraries/BatchedBridge/NativeModules.js +1 -0
- package/Libraries/Blob/Blob.js +4 -0
- package/Libraries/Blob/FileReader.js +30 -2
- package/Libraries/Blob/URL.js +3 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +2 -2
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -3
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -3
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +6 -4
- package/Libraries/Components/Button.js +3 -2
- package/Libraries/Components/Button.win32.js +451 -0
- package/Libraries/Components/Clipboard/Clipboard.js +1 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -0
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +1 -0
- package/Libraries/Components/Pressable/Pressable.d.ts +1 -1
- package/Libraries/Components/Pressable/Pressable.js +1 -1
- package/Libraries/Components/RefreshControl/RefreshControl.js +1 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +1 -2
- package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +1 -2
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +12 -6
- package/Libraries/Components/ScrollView/ScrollView.d.ts +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +149 -91
- package/Libraries/Components/ScrollView/ScrollView.win32.js +1939 -0
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +16 -6
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +5 -7
- package/Libraries/Components/ScrollView/ScrollViewViewConfig.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -0
- package/Libraries/Components/Switch/Switch.js +3 -1
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +21 -11
- package/Libraries/Components/TextInput/InputAccessoryView.d.ts +1 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +11 -5
- package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +51 -0
- package/Libraries/Components/TextInput/TextInput.Types.win32.js +3 -0
- package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +1 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +15 -5
- package/Libraries/Components/TextInput/TextInput.flow.js +1 -1
- package/Libraries/Components/TextInput/TextInput.js +130 -103
- package/Libraries/Components/TextInput/TextInput.win32.js +202 -890
- package/Libraries/Components/Touchable/Touchable.d.ts +1 -1
- package/Libraries/Components/Touchable/Touchable.flow.js +30 -4
- package/Libraries/Components/Touchable/Touchable.js +6 -3
- package/Libraries/Components/Touchable/Touchable.win32.js +6 -3
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +2 -2
- package/Libraries/Components/Touchable/TouchableOpacity.js +3 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -2
- package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +189 -0
- package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlayNativeComponent.js +43 -0
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +26 -0
- package/Libraries/Components/View/View.js +71 -45
- package/Libraries/Components/View/View.win32.js +38 -16
- package/Libraries/Components/View/ViewAccessibility.d.ts +6 -6
- package/Libraries/Components/View/ViewAccessibility.js +10 -1
- package/Libraries/Components/View/ViewAccessibility.win32.d.ts +5 -5
- package/Libraries/Components/View/ViewNativeComponent.js +32 -8
- package/Libraries/Components/View/ViewPropTypes.d.ts +1 -1
- package/Libraries/Components/View/ViewPropTypes.js +1 -1
- package/Libraries/Components/View/ViewPropTypes.win32.d.ts +1 -1
- package/Libraries/Components/View/ViewPropTypes.win32.js +1 -1
- package/Libraries/Components/View/ViewWin32.js +3 -3
- package/Libraries/Core/Devtools/openFileInEditor.js +1 -0
- package/Libraries/Core/Devtools/openURLInBrowser.js +1 -0
- package/Libraries/Core/Devtools/parseErrorStack.js +2 -2
- package/Libraries/Core/Devtools/parseHermesStack.js +54 -34
- package/Libraries/Core/ExceptionsManager.js +2 -2
- package/Libraries/Core/InitializeCore.js +2 -1
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/ReactNativeVersionCheck.js +1 -9
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -9
- package/Libraries/Core/Timers/JSTimers.js +1 -1
- package/Libraries/Core/Timers/immediateShim.js +1 -0
- package/Libraries/Core/Timers/queueMicrotask.js +1 -1
- package/Libraries/Core/setUpAlert.js +1 -1
- package/Libraries/Core/setUpDOM.js +18 -0
- package/Libraries/Core/setUpDeveloperTools.js +1 -1
- package/Libraries/Core/setUpGlobals.js +5 -2
- package/Libraries/Core/setUpNavigator.js +6 -5
- package/Libraries/Core/setUpPerformance.js +23 -13
- package/Libraries/Core/setUpReactDevTools.js +2 -0
- package/Libraries/Core/setUpSegmentFetcher.js +0 -41
- package/Libraries/Core/setUpTimers.js +2 -2
- package/Libraries/DOM/Geometry/DOMRect.js +82 -0
- package/Libraries/DOM/Geometry/DOMRectReadOnly.js +188 -0
- package/Libraries/DOM/Nodes/ReactNativeElement.js +75 -0
- package/Libraries/DOM/Nodes/ReadOnlyElement.js +89 -0
- package/Libraries/DOM/Nodes/ReadOnlyNode.js +167 -0
- package/Libraries/DOM/OldStyleCollections/ArrayLikeUtils.js +46 -0
- package/Libraries/DOM/OldStyleCollections/DOMRectList.js +76 -0
- package/Libraries/DOM/OldStyleCollections/HTMLCollection.js +82 -0
- package/Libraries/DOM/OldStyleCollections/NodeList.js +104 -0
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.android.js +35 -0
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.d.ts +20 -0
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.ios.js +49 -0
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.win32.js +35 -0
- package/Libraries/{Utilities/NativeDevSplitBundleLoader.js → DevToolsSettings/NativeDevToolsSettingsManager.js} +7 -2
- package/Libraries/EventEmitter/NativeEventEmitter.d.ts +1 -2
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.d.ts +1 -2
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +9 -1
- package/Libraries/Events/EventPolyfill.js +1 -1
- package/Libraries/Image/AssetRegistry.js +1 -1
- package/Libraries/Image/AssetSourceResolver.js +3 -3
- package/Libraries/Image/Image.android.js +4 -1
- package/Libraries/Image/Image.d.ts +63 -2
- package/Libraries/Image/Image.ios.js +3 -0
- package/Libraries/Image/Image.win32.js +3 -0
- package/Libraries/Image/ImageBackground.js +1 -0
- package/Libraries/Image/ImageProps.js +1 -1
- package/Libraries/Image/ImageViewNativeComponent.js +4 -4
- package/Libraries/Image/RelativeImageStub.js +1 -1
- package/Libraries/Image/TextInlineImageNativeComponent.js +1 -1
- package/Libraries/Image/resolveAssetSource.js +1 -1
- package/Libraries/Inspector/DevtoolsOverlay.js +29 -19
- package/Libraries/Inspector/ElementBox.js +4 -1
- package/Libraries/Inspector/Inspector.js +5 -6
- package/Libraries/Inspector/Inspector.win32.js +7 -6
- package/Libraries/Inspector/InspectorOverlay.js +3 -3
- package/Libraries/Inspector/InspectorOverlay.win32.js +2 -1
- package/Libraries/Inspector/NetworkOverlay.js +1 -1
- package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -1
- package/Libraries/Interaction/PanResponder.js +5 -6
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -1
- package/Libraries/Linking/Linking.js +1 -4
- package/Libraries/Lists/FillRateHelper.js +4 -238
- package/Libraries/Lists/FlatList.d.ts +15 -22
- package/Libraries/Lists/FlatList.js +9 -6
- package/Libraries/Lists/SectionList.d.ts +10 -6
- package/Libraries/Lists/SectionList.js +5 -3
- package/Libraries/Lists/SectionListModern.js +3 -3
- package/Libraries/Lists/ViewabilityHelper.js +8 -344
- package/Libraries/Lists/VirtualizeUtils.js +4 -244
- package/Libraries/Lists/VirtualizedList.js +10 -1867
- package/Libraries/Lists/VirtualizedListContext.js +6 -104
- package/Libraries/Lists/VirtualizedSectionList.js +9 -602
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +1 -0
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/LogBox.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspector.js +1 -3
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +168 -0
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +3 -0
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +193 -0
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -0
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +2 -2
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.win32.js +7 -3
- package/Libraries/LogBox/UI/LogBoxMessage.js +87 -5
- package/Libraries/LogBox/UI/LogBoxNotification.js +5 -7
- package/Libraries/Modal/Modal.js +2 -2
- package/Libraries/NativeComponent/BaseViewConfig.android.js +32 -12
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +43 -19
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +43 -19
- package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +4 -1
- package/Libraries/NativeComponent/ViewConfig.js +1 -0
- package/Libraries/NativeComponent/ViewConfigIgnore.js +1 -4
- package/Libraries/Network/RCTNetworking.android.js +2 -2
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +1 -1
- package/Libraries/Pressability/Pressability.js +11 -5
- package/Libraries/Pressability/Pressability.win32.js +9 -3
- package/Libraries/ReactNative/AppContainer.js +7 -1
- package/Libraries/ReactNative/AppRegistry.d.ts +1 -1
- package/Libraries/ReactNative/AppRegistry.js +10 -13
- package/Libraries/ReactNative/FabricUIManager.js +24 -8
- package/Libraries/ReactNative/NativeUIManager.js +5 -5
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +10 -10
- package/Libraries/ReactNative/UIManager.js +142 -1
- package/Libraries/ReactNative/getCachedComponentWithDebugName.js +5 -5
- package/Libraries/ReactNative/getNativeComponentAttributes.js +1 -1
- package/Libraries/ReactNative/requireNativeComponent.d.ts +1 -1
- package/Libraries/ReactNative/requireNativeComponent.js +1 -1
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +26 -3
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +13 -1
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +13 -1
- package/Libraries/Renderer/public/ReactFabricPublicInstanceUtils.js +38 -0
- package/Libraries/Renderer/shims/ReactNativeTypes.js +38 -20
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +7 -7
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
- package/Libraries/Share/Share.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +115 -76
- package/Libraries/StyleSheet/StyleSheetTypes.js +188 -33
- package/Libraries/StyleSheet/flattenStyle.js +2 -0
- package/Libraries/StyleSheet/normalizeColor.js +1 -1
- package/Libraries/StyleSheet/processColor.js +1 -1
- package/Libraries/Text/Text.d.ts +12 -2
- package/Libraries/Text/Text.js +50 -41
- package/Libraries/Text/TextProps.js +3 -4
- package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
- package/Libraries/Types/CodegenTypes.js +1 -0
- package/Libraries/UTFSequence.js +3 -1
- package/Libraries/Utilities/Appearance.d.ts +10 -0
- package/Libraries/Utilities/Appearance.js +13 -0
- package/Libraries/Utilities/Dimensions.js +1 -1
- package/Libraries/Utilities/Dimensions.win32.js +1 -1
- package/Libraries/Utilities/GlobalPerformanceLogger.js +12 -1
- package/Libraries/Utilities/HMRClient.js +16 -10
- package/Libraries/Utilities/{createPerformanceLogger.d.ts → IPerformanceLogger.d.ts} +4 -4
- package/Libraries/Utilities/IPerformanceLogger.js +49 -0
- package/Libraries/Utilities/LoadingView.android.js +28 -11
- package/Libraries/Utilities/NativeAppearance.js +1 -0
- package/Libraries/Utilities/NativePlatformConstantsWin.js +1 -1
- package/Libraries/Utilities/PixelRatio.js +2 -2
- package/Libraries/Utilities/Platform.win32.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/__mocks__/PixelRatio.js +1 -1
- package/Libraries/Utilities/codegenNativeCommands.js +2 -0
- package/Libraries/Utilities/createPerformanceLogger.js +55 -43
- package/Libraries/Utilities/stringifySafe.js +2 -7
- package/Libraries/Utilities/useColorScheme.js +1 -1
- package/Libraries/Utilities/useWindowDimensions.js +3 -3
- package/Libraries/WebPerformance/EventCounts.js +78 -0
- package/Libraries/WebPerformance/MemoryInfo.js +54 -0
- package/Libraries/WebPerformance/NativePerformance.js +38 -0
- package/Libraries/WebPerformance/NativePerformanceObserver.js +22 -7
- package/Libraries/WebPerformance/Performance.js +312 -0
- package/Libraries/WebPerformance/PerformanceEntry.js +45 -0
- package/Libraries/WebPerformance/PerformanceEventTiming.js +38 -0
- package/Libraries/WebPerformance/PerformanceObserver.js +196 -101
- package/Libraries/WebPerformance/RawPerformanceEntry.js +87 -0
- package/Libraries/WebPerformance/ReactNativeStartupTiming.js +65 -0
- package/Libraries/WebPerformance/__mocks__/NativePerformance.js +65 -0
- package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +101 -0
- package/Libraries/YellowBox/YellowBoxDeprecated.js +1 -1
- package/Libraries/vendor/core/ErrorUtils.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.d.ts +2 -2
- package/Libraries/vendor/emitter/EventEmitter.js +9 -1
- package/flow/global.js +29 -4
- package/flow/jest.js +258 -164
- package/index.js +56 -42
- package/index.win32.js +56 -42
- package/interface.js +1 -1
- package/jest/local-setup.js +33 -0
- package/jest/mockComponent.js +4 -2
- package/jest/mockNativeComponent.js +1 -1
- package/jest/mockScrollView.js +2 -1
- package/jest/react-native-env.js +1 -3
- package/jest/setup.js +11 -8
- package/overrides.json +115 -85
- package/package.json +38 -28
- package/rn-get-polyfills.js +1 -1
- package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +68 -0
- package/src/Libraries/Components/View/ViewAccessibility.win32.d.ts +5 -5
- package/src/Libraries/Components/View/ViewPropTypes.win32.d.ts +1 -1
- package/types/index.d.ts +2 -6
- package/types/modules/Codegen.d.ts +4 -4
- package/types/modules/globals.d.ts +27 -25
- package/types/public/DeprecatedPropertiesAlias.d.ts +0 -20
- package/types/public/ReactNativeRenderer.d.ts +2 -7
- package/Libraries/Animated/createAnimatedComponentInjection.js +0 -48
- package/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js +0 -48
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.flow.js +0 -208
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.flow.js +0 -58
- package/Libraries/Components/DatePicker/DatePickerIOS.android.js +0 -47
- package/Libraries/Components/DatePicker/DatePickerIOS.d.ts +0 -92
- package/Libraries/Components/DatePicker/DatePickerIOS.flow.android.js +0 -14
- package/Libraries/Components/DatePicker/DatePickerIOS.flow.ios.js +0 -113
- package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +0 -242
- package/Libraries/Components/DatePicker/DatePickerIOS.win32.js +0 -47
- package/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js +0 -60
- package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +0 -26
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js +0 -45
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.d.ts +0 -62
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +0 -75
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.win32.js +0 -45
- package/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js +0 -33
- package/Libraries/Components/SafeAreaView/SafeAreaView.flow.js +0 -19
- package/Libraries/Components/Slider/Slider.d.ts +0 -132
- package/Libraries/Components/Slider/Slider.js +0 -282
- package/Libraries/Components/Slider/SliderNativeComponent.js +0 -56
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +0 -23
- package/Libraries/Interaction/Batchinator.js +0 -76
- package/Libraries/Interaction/BridgeSpyStallHandler.js +0 -63
- package/Libraries/Interaction/InteractionStallDebugger.js +0 -23
- package/Libraries/Interaction/PanResponder.flow.js +0 -257
- package/Libraries/Lists/CellRenderMask.js +0 -155
- package/Libraries/Lists/ChildListCollection.js +0 -72
- package/Libraries/Lists/StateSafePureComponent.js +0 -85
- package/Libraries/Lists/VirtualizedList.d.ts +0 -347
- package/Libraries/Lists/VirtualizedListCellRenderer.js +0 -259
- package/Libraries/Lists/VirtualizedListProps.js +0 -279
- package/Libraries/Performance/PureComponentDebug.js +0 -74
- package/Libraries/Reliability/UserFlow.js +0 -158
- package/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts +0 -149
- package/Libraries/Renderer/shims/ReactNativeTypes.d.ts +0 -141
- package/Libraries/Utilities/MatrixMath.js +0 -748
- package/Libraries/Utilities/buildStyleInterpolator.js +0 -209
- package/Libraries/Utilities/clamp.js +0 -23
- package/Libraries/Utilities/deprecatedPropType.js +0 -36
- package/Libraries/Utilities/groupByEveryN.js +0 -51
- package/Libraries/Utilities/mergeIntoFast.js +0 -26
- package/Libraries/Utilities/setAndForwardRef.js +0 -71
- package/Libraries/Utilities/truncate.js +0 -51
- package/flow/JSITimerInternalType.js +0 -30
- package/flow/use-sync-external-store.js +0 -19
|
@@ -8,19 +8,11 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
11
|
import View from '../Components/View/View';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import * as createAnimatedComponentInjection from './createAnimatedComponentInjection';
|
|
17
|
-
import NativeAnimatedHelper from './NativeAnimatedHelper';
|
|
18
|
-
import AnimatedProps from './nodes/AnimatedProps';
|
|
19
|
-
import invariant from 'invariant';
|
|
12
|
+
import useMergeRefs from '../Utilities/useMergeRefs';
|
|
13
|
+
import useAnimatedProps from './useAnimatedProps';
|
|
20
14
|
import * as React from 'react';
|
|
21
15
|
|
|
22
|
-
let animatedComponentNextId = 1;
|
|
23
|
-
|
|
24
16
|
export type AnimatedComponentType<
|
|
25
17
|
-Props: {+[string]: mixed, ...},
|
|
26
18
|
+Instance = mixed,
|
|
@@ -37,238 +29,33 @@ export type AnimatedComponentType<
|
|
|
37
29
|
Instance,
|
|
38
30
|
>;
|
|
39
31
|
|
|
40
|
-
function createAnimatedComponent<
|
|
41
|
-
Component: React.AbstractComponent<
|
|
42
|
-
): AnimatedComponentType<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
_attachNativeEvents() {
|
|
61
|
-
// Make sure to get the scrollable node for components that implement
|
|
62
|
-
// `ScrollResponder.Mixin`.
|
|
63
|
-
const scrollableNode = this._component?.getScrollableNode
|
|
64
|
-
? this._component.getScrollableNode()
|
|
65
|
-
: this._component;
|
|
66
|
-
|
|
67
|
-
for (const key in this.props) {
|
|
68
|
-
const prop = this.props[key];
|
|
69
|
-
if (prop instanceof AnimatedEvent && prop.__isNative) {
|
|
70
|
-
prop.__attach(scrollableNode, key);
|
|
71
|
-
this._eventDetachers.push(() => prop.__detach(scrollableNode, key));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
_detachNativeEvents() {
|
|
77
|
-
this._eventDetachers.forEach(remove => remove());
|
|
78
|
-
this._eventDetachers = [];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
_isFabric = (): boolean => {
|
|
82
|
-
// When called during the first render, `_component` is always null.
|
|
83
|
-
// Therefore, even if a component is rendered in Fabric, we can't detect
|
|
84
|
-
// that until ref is set, which happens sometime after the first render.
|
|
85
|
-
// In cases where this value switching between "false" and "true" on Fabric
|
|
86
|
-
// causes issues, add an additional check for _component nullity.
|
|
87
|
-
if (this._component == null) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
return (
|
|
91
|
-
// eslint-disable-next-line dot-notation
|
|
92
|
-
this._component['_internalInstanceHandle']?.stateNode?.canonical !=
|
|
93
|
-
null ||
|
|
94
|
-
// Some components have a setNativeProps function but aren't a host component
|
|
95
|
-
// such as lists like FlatList and SectionList. These should also use
|
|
96
|
-
// forceUpdate in Fabric since setNativeProps doesn't exist on the underlying
|
|
97
|
-
// host component. This crazy hack is essentially special casing those lists and
|
|
98
|
-
// ScrollView itself to use forceUpdate in Fabric.
|
|
99
|
-
// If these components end up using forwardRef then these hacks can go away
|
|
100
|
-
// as this._component would actually be the underlying host component and the above check
|
|
101
|
-
// would be sufficient.
|
|
102
|
-
(this._component.getNativeScrollRef != null &&
|
|
103
|
-
this._component.getNativeScrollRef() != null &&
|
|
104
|
-
// eslint-disable-next-line dot-notation
|
|
105
|
-
this._component.getNativeScrollRef()['_internalInstanceHandle']
|
|
106
|
-
?.stateNode?.canonical != null) ||
|
|
107
|
-
(this._component.getScrollResponder != null &&
|
|
108
|
-
this._component.getScrollResponder() != null &&
|
|
109
|
-
this._component.getScrollResponder().getNativeScrollRef != null &&
|
|
110
|
-
this._component.getScrollResponder().getNativeScrollRef() != null &&
|
|
111
|
-
this._component.getScrollResponder().getNativeScrollRef()[
|
|
112
|
-
// eslint-disable-next-line dot-notation
|
|
113
|
-
'_internalInstanceHandle'
|
|
114
|
-
]?.stateNode?.canonical != null)
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
_waitForUpdate = (): void => {
|
|
119
|
-
if (this._isFabric()) {
|
|
120
|
-
NativeAnimatedHelper.API.setWaitingForIdentifier(
|
|
121
|
-
this._animatedComponentId,
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
_markUpdateComplete = (): void => {
|
|
127
|
-
if (this._isFabric()) {
|
|
128
|
-
NativeAnimatedHelper.API.unsetWaitingForIdentifier(
|
|
129
|
-
this._animatedComponentId,
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// The system is best designed when setNativeProps is implemented. It is
|
|
135
|
-
// able to avoid re-rendering and directly set the attributes that changed.
|
|
136
|
-
// However, setNativeProps can only be implemented on leaf native
|
|
137
|
-
// components. If you want to animate a composite component, you need to
|
|
138
|
-
// re-render it. In this case, we have a fallback that uses forceUpdate.
|
|
139
|
-
// This fallback is also called in Fabric.
|
|
140
|
-
_animatedPropsCallback = (): void => {
|
|
141
|
-
if (this._component == null) {
|
|
142
|
-
// AnimatedProps is created in will-mount because it's used in render.
|
|
143
|
-
// But this callback may be invoked before mount in async mode,
|
|
144
|
-
// In which case we should defer the setNativeProps() call.
|
|
145
|
-
// React may throw away uncommitted work in async mode,
|
|
146
|
-
// So a deferred call won't always be invoked.
|
|
147
|
-
this._invokeAnimatedPropsCallbackOnMount = true;
|
|
148
|
-
} else if (
|
|
149
|
-
process.env.NODE_ENV === 'test' ||
|
|
150
|
-
// For animating properties of non-leaf/non-native components
|
|
151
|
-
typeof this._component.setNativeProps !== 'function' ||
|
|
152
|
-
// In Fabric, force animations to go through forceUpdate and skip setNativeProps
|
|
153
|
-
this._isFabric()
|
|
154
|
-
) {
|
|
155
|
-
this.forceUpdate();
|
|
156
|
-
} else if (!this._propsAnimated.__isNative) {
|
|
157
|
-
this._component.setNativeProps(
|
|
158
|
-
this._propsAnimated.__getAnimatedValue(),
|
|
159
|
-
);
|
|
160
|
-
} else {
|
|
161
|
-
throw new Error(
|
|
162
|
-
'Attempting to run JS driven animation on animated ' +
|
|
163
|
-
'node that has been moved to "native" earlier by starting an ' +
|
|
164
|
-
'animation with `useNativeDriver: true`',
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
_attachProps(nextProps: any) {
|
|
170
|
-
const oldPropsAnimated = this._propsAnimated;
|
|
171
|
-
|
|
172
|
-
this._propsAnimated = new AnimatedProps(
|
|
173
|
-
nextProps,
|
|
174
|
-
this._animatedPropsCallback,
|
|
175
|
-
);
|
|
176
|
-
this._propsAnimated.__attach();
|
|
177
|
-
|
|
178
|
-
// When you call detach, it removes the element from the parent list
|
|
179
|
-
// of children. If it goes to 0, then the parent also detaches itself
|
|
180
|
-
// and so on.
|
|
181
|
-
// An optimization is to attach the new elements and THEN detach the old
|
|
182
|
-
// ones instead of detaching and THEN attaching.
|
|
183
|
-
// This way the intermediate state isn't to go to 0 and trigger
|
|
184
|
-
// this expensive recursive detaching to then re-attach everything on
|
|
185
|
-
// the very next operation.
|
|
186
|
-
if (oldPropsAnimated) {
|
|
187
|
-
oldPropsAnimated.__restoreDefaultValues();
|
|
188
|
-
oldPropsAnimated.__detach();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
_setComponentRef: (ref: React.ElementRef<any>) => void = setAndForwardRef({
|
|
193
|
-
getForwardedRef: () => this.props.forwardedRef,
|
|
194
|
-
setLocalRef: ref => {
|
|
195
|
-
this._prevComponent = this._component;
|
|
196
|
-
this._component = ref;
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
render(): React.Node {
|
|
201
|
-
const animatedProps = this._propsAnimated.__getValue() || {};
|
|
202
|
-
|
|
203
|
-
const {style = {}, ...props} = animatedProps;
|
|
204
|
-
const {style: passthruStyle = {}, ...passthruProps} =
|
|
205
|
-
this.props.passthroughAnimatedPropExplicitValues || {};
|
|
206
|
-
const mergedStyle = {...style, ...passthruStyle};
|
|
207
|
-
|
|
208
|
-
// Force `collapsable` to be false so that native view is not flattened.
|
|
209
|
-
// Flattened views cannot be accurately referenced by a native driver.
|
|
210
|
-
return (
|
|
211
|
-
<Component
|
|
212
|
-
{...props}
|
|
213
|
-
{...passthruProps}
|
|
214
|
-
collapsable={false}
|
|
215
|
-
style={mergedStyle}
|
|
216
|
-
ref={this._setComponentRef}
|
|
217
|
-
/>
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
UNSAFE_componentWillMount() {
|
|
222
|
-
this._waitForUpdate();
|
|
223
|
-
this._attachProps(this.props);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
componentDidMount() {
|
|
227
|
-
if (this._invokeAnimatedPropsCallbackOnMount) {
|
|
228
|
-
this._invokeAnimatedPropsCallbackOnMount = false;
|
|
229
|
-
this._animatedPropsCallback();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
this._propsAnimated.setNativeView(this._component);
|
|
233
|
-
this._attachNativeEvents();
|
|
234
|
-
this._markUpdateComplete();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
UNSAFE_componentWillReceiveProps(newProps: any) {
|
|
238
|
-
this._waitForUpdate();
|
|
239
|
-
this._attachProps(newProps);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
componentDidUpdate(prevProps: any) {
|
|
243
|
-
if (this._component !== this._prevComponent) {
|
|
244
|
-
this._propsAnimated.setNativeView(this._component);
|
|
245
|
-
}
|
|
246
|
-
if (this._component !== this._prevComponent || prevProps !== this.props) {
|
|
247
|
-
this._detachNativeEvents();
|
|
248
|
-
this._attachNativeEvents();
|
|
249
|
-
}
|
|
250
|
-
this._markUpdateComplete();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
componentWillUnmount() {
|
|
254
|
-
this._propsAnimated && this._propsAnimated.__detach();
|
|
255
|
-
this._detachNativeEvents();
|
|
256
|
-
this._markUpdateComplete();
|
|
257
|
-
this._component = null;
|
|
258
|
-
this._prevComponent = null;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
32
|
+
export default function createAnimatedComponent<TProps: {...}, TInstance>(
|
|
33
|
+
Component: React.AbstractComponent<TProps, TInstance>,
|
|
34
|
+
): AnimatedComponentType<TProps, TInstance> {
|
|
35
|
+
return React.forwardRef((props, forwardedRef) => {
|
|
36
|
+
const [reducedProps, callbackRef] = useAnimatedProps<TProps, TInstance>(
|
|
37
|
+
// $FlowFixMe[incompatible-call]
|
|
38
|
+
props,
|
|
39
|
+
);
|
|
40
|
+
const ref = useMergeRefs<TInstance | null>(callbackRef, forwardedRef);
|
|
41
|
+
|
|
42
|
+
// Some components require explicit passthrough values for animation
|
|
43
|
+
// to work properly. For example, if an animated component is
|
|
44
|
+
// transformed and Pressable, onPress will not work after transform
|
|
45
|
+
// without these passthrough values.
|
|
46
|
+
// $FlowFixMe[prop-missing]
|
|
47
|
+
const {passthroughAnimatedPropExplicitValues, style} = reducedProps;
|
|
48
|
+
const {style: passthroughStyle, ...passthroughProps} =
|
|
49
|
+
passthroughAnimatedPropExplicitValues ?? {};
|
|
50
|
+
const mergedStyle = {...style, ...passthroughStyle};
|
|
261
51
|
|
|
262
|
-
return React.forwardRef(function AnimatedComponentWrapper(props, ref) {
|
|
263
52
|
return (
|
|
264
|
-
<
|
|
265
|
-
{...
|
|
266
|
-
{...
|
|
53
|
+
<Component
|
|
54
|
+
{...reducedProps}
|
|
55
|
+
{...passthroughProps}
|
|
56
|
+
style={mergedStyle}
|
|
57
|
+
ref={ref}
|
|
267
58
|
/>
|
|
268
59
|
);
|
|
269
60
|
});
|
|
270
61
|
}
|
|
271
|
-
|
|
272
|
-
// $FlowIgnore[incompatible-cast] - Will be compatible after refactors.
|
|
273
|
-
export default (createAnimatedComponentInjection.recordAndRetrieve() ??
|
|
274
|
-
createAnimatedComponent: typeof createAnimatedComponent);
|
|
@@ -18,7 +18,7 @@ import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
|
18
18
|
import normalizeColor from '../../StyleSheet/normalizeColor';
|
|
19
19
|
import {processColorObject} from '../../StyleSheet/PlatformColorValueTypes';
|
|
20
20
|
import NativeAnimatedHelper from '../NativeAnimatedHelper';
|
|
21
|
-
import AnimatedValue from './AnimatedValue';
|
|
21
|
+
import AnimatedValue, {flushValue} from './AnimatedValue';
|
|
22
22
|
import AnimatedWithChildren from './AnimatedWithChildren';
|
|
23
23
|
|
|
24
24
|
export type AnimatedColorConfig = $ReadOnly<{
|
|
@@ -43,10 +43,11 @@ type RgbaAnimatedValue = {
|
|
|
43
43
|
...
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
export type InputValue = ?(RgbaValue | RgbaAnimatedValue | ColorValue);
|
|
47
|
+
|
|
46
48
|
const NativeAnimatedAPI = NativeAnimatedHelper.API;
|
|
47
49
|
|
|
48
50
|
const defaultColor: RgbaValue = {r: 0, g: 0, b: 0, a: 1.0};
|
|
49
|
-
let _uniqueId = 1;
|
|
50
51
|
|
|
51
52
|
/* eslint no-bitwise: 0 */
|
|
52
53
|
function processColor(
|
|
@@ -113,22 +114,12 @@ export default class AnimatedColor extends AnimatedWithChildren {
|
|
|
113
114
|
b: AnimatedValue;
|
|
114
115
|
a: AnimatedValue;
|
|
115
116
|
nativeColor: ?NativeColorValue;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
b: string,
|
|
121
|
-
a: string,
|
|
122
|
-
...
|
|
123
|
-
},
|
|
124
|
-
...
|
|
125
|
-
} = {};
|
|
126
|
-
|
|
127
|
-
constructor(
|
|
128
|
-
valueIn?: ?(RgbaValue | RgbaAnimatedValue | ColorValue),
|
|
129
|
-
config?: ?AnimatedColorConfig,
|
|
130
|
-
) {
|
|
117
|
+
|
|
118
|
+
_suspendCallbacks: number = 0;
|
|
119
|
+
|
|
120
|
+
constructor(valueIn?: InputValue, config?: ?AnimatedColorConfig) {
|
|
131
121
|
super();
|
|
122
|
+
|
|
132
123
|
let value: RgbaValue | RgbaAnimatedValue | ColorValue =
|
|
133
124
|
valueIn ?? defaultColor;
|
|
134
125
|
if (isRgbaAnimatedValue(value)) {
|
|
@@ -156,7 +147,8 @@ export default class AnimatedColor extends AnimatedWithChildren {
|
|
|
156
147
|
this.b = new AnimatedValue(initColor.b);
|
|
157
148
|
this.a = new AnimatedValue(initColor.a);
|
|
158
149
|
}
|
|
159
|
-
|
|
150
|
+
|
|
151
|
+
if (config?.useNativeDriver) {
|
|
160
152
|
this.__makeNative();
|
|
161
153
|
}
|
|
162
154
|
}
|
|
@@ -174,25 +166,27 @@ export default class AnimatedColor extends AnimatedWithChildren {
|
|
|
174
166
|
|
|
175
167
|
const processedColor: RgbaValue | NativeColorValue =
|
|
176
168
|
processColor(value) ?? defaultColor;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
this.nativeColor
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
this.nativeColor
|
|
193
|
-
|
|
169
|
+
this._withSuspendedCallbacks(() => {
|
|
170
|
+
if (isRgbaValue(processedColor)) {
|
|
171
|
+
// $FlowIgnore[incompatible-type] - Type is verified above
|
|
172
|
+
const rgbaValue: RgbaValue = processedColor;
|
|
173
|
+
this.r.setValue(rgbaValue.r);
|
|
174
|
+
this.g.setValue(rgbaValue.g);
|
|
175
|
+
this.b.setValue(rgbaValue.b);
|
|
176
|
+
this.a.setValue(rgbaValue.a);
|
|
177
|
+
if (this.nativeColor != null) {
|
|
178
|
+
this.nativeColor = null;
|
|
179
|
+
shouldUpdateNodeConfig = true;
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
// $FlowIgnore[incompatible-type] - Type is verified above
|
|
183
|
+
const nativeColor: NativeColorValue = processedColor;
|
|
184
|
+
if (this.nativeColor !== nativeColor) {
|
|
185
|
+
this.nativeColor = nativeColor;
|
|
186
|
+
shouldUpdateNodeConfig = true;
|
|
187
|
+
}
|
|
194
188
|
}
|
|
195
|
-
}
|
|
189
|
+
});
|
|
196
190
|
|
|
197
191
|
if (this.__isNative) {
|
|
198
192
|
const nativeTag = this.__getNativeTag();
|
|
@@ -203,7 +197,12 @@ export default class AnimatedColor extends AnimatedWithChildren {
|
|
|
203
197
|
);
|
|
204
198
|
}
|
|
205
199
|
NativeAnimatedAPI.unsetWaitingForIdentifier(nativeTag.toString());
|
|
200
|
+
} else {
|
|
201
|
+
flushValue(this);
|
|
206
202
|
}
|
|
203
|
+
|
|
204
|
+
// $FlowFixMe[incompatible-call]
|
|
205
|
+
this.__callListeners(this.__getValue());
|
|
207
206
|
}
|
|
208
207
|
|
|
209
208
|
/**
|
|
@@ -240,50 +239,6 @@ export default class AnimatedColor extends AnimatedWithChildren {
|
|
|
240
239
|
this.a.extractOffset();
|
|
241
240
|
}
|
|
242
241
|
|
|
243
|
-
/**
|
|
244
|
-
* Adds an asynchronous listener to the value so you can observe updates from
|
|
245
|
-
* animations. This is useful because there is no way to synchronously read
|
|
246
|
-
* the value because it might be driven natively.
|
|
247
|
-
*
|
|
248
|
-
* Returns a string that serves as an identifier for the listener.
|
|
249
|
-
*/
|
|
250
|
-
addListener(callback: ColorListenerCallback): string {
|
|
251
|
-
const id = String(_uniqueId++);
|
|
252
|
-
const jointCallback = ({value: number}: any) => {
|
|
253
|
-
callback(this.__getValue());
|
|
254
|
-
};
|
|
255
|
-
this._listeners[id] = {
|
|
256
|
-
r: this.r.addListener(jointCallback),
|
|
257
|
-
g: this.g.addListener(jointCallback),
|
|
258
|
-
b: this.b.addListener(jointCallback),
|
|
259
|
-
a: this.a.addListener(jointCallback),
|
|
260
|
-
};
|
|
261
|
-
return id;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Unregister a listener. The `id` param shall match the identifier
|
|
266
|
-
* previously returned by `addListener()`.
|
|
267
|
-
*/
|
|
268
|
-
removeListener(id: string): void {
|
|
269
|
-
this.r.removeListener(this._listeners[id].r);
|
|
270
|
-
this.g.removeListener(this._listeners[id].g);
|
|
271
|
-
this.b.removeListener(this._listeners[id].b);
|
|
272
|
-
this.a.removeListener(this._listeners[id].a);
|
|
273
|
-
delete this._listeners[id];
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Remove all registered listeners.
|
|
278
|
-
*/
|
|
279
|
-
removeAllListeners(): void {
|
|
280
|
-
this.r.removeAllListeners();
|
|
281
|
-
this.g.removeAllListeners();
|
|
282
|
-
this.b.removeAllListeners();
|
|
283
|
-
this.a.removeAllListeners();
|
|
284
|
-
this._listeners = {};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
242
|
/**
|
|
288
243
|
* Stops any running animation or tracking. `callback` is invoked with the
|
|
289
244
|
* final value after stopping the animation, which is useful for updating
|
|
@@ -332,6 +287,18 @@ export default class AnimatedColor extends AnimatedWithChildren {
|
|
|
332
287
|
super.__detach();
|
|
333
288
|
}
|
|
334
289
|
|
|
290
|
+
_withSuspendedCallbacks(callback: () => void) {
|
|
291
|
+
this._suspendCallbacks++;
|
|
292
|
+
callback();
|
|
293
|
+
this._suspendCallbacks--;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
__callListeners(value: number): void {
|
|
297
|
+
if (this._suspendCallbacks === 0) {
|
|
298
|
+
super.__callListeners(value);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
335
302
|
__makeNative(platformConfig: ?PlatformConfig) {
|
|
336
303
|
this.r.__makeNative(platformConfig);
|
|
337
304
|
this.g.__makeNative(platformConfig);
|