@office-iss/react-native-win32 0.75.2 → 0.76.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/.eslintrc.js +11 -0
- package/.flowconfig +5 -4
- package/CHANGELOG.json +164 -47
- package/CHANGELOG.md +53 -28
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +7 -7
- package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
- package/Libraries/Animated/animations/Animation.js +11 -1
- package/Libraries/Animated/animations/DecayAnimation.js +1 -1
- package/Libraries/Animated/animations/SpringAnimation.js +1 -1
- package/Libraries/Animated/animations/TimingAnimation.js +2 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +10 -9
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
- package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
- package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
- package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
- package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
- package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
- package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
- package/Libraries/Animated/useAnimatedProps.js +142 -7
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/FileReader.js +1 -1
- package/Libraries/Blob/URL.js +2 -62
- package/Libraries/Blob/URLSearchParams.js +71 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +131 -169
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
- package/Libraries/Components/TextInput/TextInput.js +230 -94
- package/Libraries/Components/TextInput/TextInput.win32.js +230 -100
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +2 -0
- package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/Libraries/Components/View/ViewNativeComponent.js +0 -1
- package/Libraries/Components/View/ViewPropTypes.js +14 -0
- package/Libraries/Components/View/ViewPropTypes.win32.js +14 -0
- package/Libraries/Core/ExceptionsManager.js +2 -0
- package/Libraries/Core/InitializeCore.js +3 -1
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
- package/Libraries/Core/ReactNativeVersion.js +4 -4
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
- package/Libraries/Core/setUpErrorHandling.js +7 -1
- package/Libraries/Core/setUpGlobals.js +1 -0
- package/Libraries/Core/setUpReactRefresh.js +0 -4
- package/Libraries/Image/AssetSourceResolver.js +28 -1
- package/Libraries/Image/Image.android.js +9 -14
- package/Libraries/Image/Image.ios.js +11 -22
- package/Libraries/Image/Image.win32.js +11 -24
- package/Libraries/Image/ImageBackground.js +1 -8
- package/Libraries/Image/ImageUtils.js +9 -9
- package/Libraries/Image/ImageViewNativeComponent.js +1 -0
- package/Libraries/Inspector/Inspector.js +3 -2
- package/Libraries/Inspector/Inspector.win32.js +3 -2
- package/Libraries/Inspector/InspectorPanel.js +16 -10
- package/Libraries/Inspector/NetworkOverlay.js +1 -1
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/Lists/FlatList.js +1 -1
- package/Libraries/Lists/SectionList.js +2 -2
- package/Libraries/Lists/SectionListModern.js +3 -3
- package/Libraries/LogBox/Data/LogBoxData.js +24 -3
- package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +9 -29
- package/Libraries/Modal/Modal.js +0 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +7 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
- package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
- package/Libraries/Network/XMLHttpRequest.js +4 -2
- package/Libraries/ReactNative/AppContainer-dev.js +1 -5
- package/Libraries/ReactNative/AppContainer-prod.js +1 -5
- package/Libraries/ReactNative/AppContainer.js +0 -1
- package/Libraries/ReactNative/AppRegistry.js +0 -6
- package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
- package/Libraries/ReactNative/RendererImplementation.js +26 -4
- package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
- package/Libraries/ReactNative/renderApplication.js +0 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +57 -0
- package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
- package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
- package/Libraries/StyleSheet/processBoxShadow.js +211 -0
- package/Libraries/StyleSheet/processFilter.js +231 -42
- package/Libraries/Text/Text.js +394 -196
- package/Libraries/Text/Text.win32.js +442 -229
- package/Libraries/Text/TextNativeComponent.js +2 -1
- package/Libraries/Text/TextNativeComponent.win32.js +1 -1
- package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
- package/Libraries/Types/CodegenTypes.js +3 -1
- package/Libraries/Utilities/Appearance.js +108 -84
- package/Libraries/Utilities/DevLoadingView.js +2 -4
- package/Libraries/Utilities/HMRClient.js +2 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +0 -9
- package/Libraries/Utilities/stringifyViewConfig.js +22 -0
- package/Libraries/Utilities/useColorScheme.js +3 -3
- package/Libraries/WebSocket/WebSocket.js +1 -1
- package/Libraries/promiseRejectionTrackingOptions.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.js +6 -5
- package/flow/jest.js +2 -2
- package/index.js +3 -1
- package/index.win32.js +3 -1
- package/jest/mockComponent.js +4 -1
- package/jest/mockModal.js +1 -3
- package/jest/mockScrollView.js +1 -1
- package/jest/renderer.js +2 -2
- package/jest/setup.js +16 -13
- package/jest.config.js +1 -2
- package/overrides.json +22 -22
- package/package.json +30 -30
- package/src/private/animated/NativeAnimatedHelper.js +438 -0
- package/src/private/animated/NativeAnimatedHelper.win32.js +440 -0
- package/src/private/animated/NativeAnimatedValidation.js +64 -0
- package/src/private/components/HScrollViewNativeComponents.js +56 -0
- package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
- package/src/private/components/VScrollViewNativeComponents.js +48 -0
- package/src/private/components/useSyncOnScroll.js +48 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
- package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
- package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
- package/src/private/setup/setUpDOM.js +28 -0
- package/src/private/setup/setUpIntersectionObserver.js +27 -0
- package/src/private/setup/setUpMutationObserver.js +26 -0
- package/src/private/setup/setUpPerformanceObserver.js +64 -0
- package/src/private/specs/modules/NativeAppearance.js +3 -3
- package/src/private/specs/modules/NativeLinkingManager.js +1 -1
- package/src/private/specs/modules/NativePlatformConstantsWin.js +7 -0
- package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
- package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
- package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
- package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
- package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
- package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
- package/src/private/webapis/performance/LongTasks.js +39 -0
- package/src/private/webapis/performance/Performance.js +22 -9
- package/src/private/webapis/performance/PerformanceEntry.js +36 -18
- package/src/private/webapis/performance/PerformanceObserver.js +29 -43
- package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
- package/src/private/webapis/performance/UserTiming.js +17 -12
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
- package/src-win/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
- package/types/experimental.d.ts +20 -1
- package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
- package/Libraries/Animated/NativeAnimatedHelper.win32.js +0 -617
- package/Libraries/Core/setUpIntersectionObserver.js +0 -16
- package/Libraries/Core/setUpMutationObserver.js +0 -16
- package/Libraries/Core/setUpPerformanceObserver.js +0 -18
- package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
- package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
- package/src/private/core/setUpDOM.js +0 -18
- package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
- /package/src/private/{core → styles}/composeStyles.js +0 -0
|
@@ -14,44 +14,74 @@ import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
|
14
14
|
|
|
15
15
|
import {findNodeHandle} from '../../ReactNative/RendererProxy';
|
|
16
16
|
import {AnimatedEvent} from '../AnimatedEvent';
|
|
17
|
-
import NativeAnimatedHelper from '
|
|
17
|
+
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
18
18
|
import AnimatedNode from './AnimatedNode';
|
|
19
|
-
import AnimatedObject
|
|
19
|
+
import AnimatedObject from './AnimatedObject';
|
|
20
20
|
import AnimatedStyle from './AnimatedStyle';
|
|
21
21
|
import invariant from 'invariant';
|
|
22
22
|
|
|
23
|
-
function createAnimatedProps(
|
|
23
|
+
function createAnimatedProps(
|
|
24
|
+
inputProps: Object,
|
|
25
|
+
): [$ReadOnlyArray<string>, $ReadOnlyArray<AnimatedNode>, Object] {
|
|
26
|
+
const nodeKeys: Array<string> = [];
|
|
27
|
+
const nodes: Array<AnimatedNode> = [];
|
|
24
28
|
const props: Object = {};
|
|
25
|
-
|
|
29
|
+
|
|
30
|
+
const keys = Object.keys(inputProps);
|
|
31
|
+
for (let ii = 0, length = keys.length; ii < length; ii++) {
|
|
32
|
+
const key = keys[ii];
|
|
26
33
|
const value = inputProps[key];
|
|
34
|
+
|
|
27
35
|
if (key === 'style') {
|
|
28
|
-
|
|
36
|
+
const node = new AnimatedStyle(value);
|
|
37
|
+
nodeKeys.push(key);
|
|
38
|
+
nodes.push(node);
|
|
39
|
+
props[key] = node;
|
|
29
40
|
} else if (value instanceof AnimatedNode) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
const node = value;
|
|
42
|
+
nodeKeys.push(key);
|
|
43
|
+
nodes.push(node);
|
|
44
|
+
props[key] = node;
|
|
33
45
|
} else {
|
|
34
|
-
|
|
46
|
+
const node = AnimatedObject.from(value);
|
|
47
|
+
if (node == null) {
|
|
48
|
+
props[key] = value;
|
|
49
|
+
} else {
|
|
50
|
+
nodeKeys.push(key);
|
|
51
|
+
nodes.push(node);
|
|
52
|
+
props[key] = node;
|
|
53
|
+
}
|
|
35
54
|
}
|
|
36
55
|
}
|
|
37
|
-
|
|
56
|
+
|
|
57
|
+
return [nodeKeys, nodes, props];
|
|
38
58
|
}
|
|
39
59
|
|
|
40
60
|
export default class AnimatedProps extends AnimatedNode {
|
|
61
|
+
#nodeKeys: $ReadOnlyArray<string>;
|
|
62
|
+
#nodes: $ReadOnlyArray<AnimatedNode>;
|
|
63
|
+
|
|
64
|
+
_animatedView: any = null;
|
|
41
65
|
_props: Object;
|
|
42
|
-
_animatedView: any;
|
|
43
66
|
_callback: () => void;
|
|
44
67
|
|
|
45
|
-
constructor(
|
|
68
|
+
constructor(inputProps: Object, callback: () => void) {
|
|
46
69
|
super();
|
|
47
|
-
|
|
70
|
+
const [nodeKeys, nodes, props] = createAnimatedProps(inputProps);
|
|
71
|
+
this.#nodeKeys = nodeKeys;
|
|
72
|
+
this.#nodes = nodes;
|
|
73
|
+
this._props = props;
|
|
48
74
|
this._callback = callback;
|
|
49
75
|
}
|
|
50
76
|
|
|
51
77
|
__getValue(): Object {
|
|
52
78
|
const props: {[string]: any | ((...args: any) => void)} = {};
|
|
53
|
-
|
|
79
|
+
|
|
80
|
+
const keys = Object.keys(this._props);
|
|
81
|
+
for (let ii = 0, length = keys.length; ii < length; ii++) {
|
|
82
|
+
const key = keys[ii];
|
|
54
83
|
const value = this._props[key];
|
|
84
|
+
|
|
55
85
|
if (value instanceof AnimatedNode) {
|
|
56
86
|
props[key] = value.__getValue();
|
|
57
87
|
} else if (value instanceof AnimatedEvent) {
|
|
@@ -66,21 +96,23 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
66
96
|
|
|
67
97
|
__getAnimatedValue(): Object {
|
|
68
98
|
const props: {[string]: any} = {};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
99
|
+
|
|
100
|
+
const nodeKeys = this.#nodeKeys;
|
|
101
|
+
const nodes = this.#nodes;
|
|
102
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
103
|
+
const key = nodeKeys[ii];
|
|
104
|
+
const node = nodes[ii];
|
|
105
|
+
props[key] = node.__getAnimatedValue();
|
|
74
106
|
}
|
|
107
|
+
|
|
75
108
|
return props;
|
|
76
109
|
}
|
|
77
110
|
|
|
78
111
|
__attach(): void {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
112
|
+
const nodes = this.#nodes;
|
|
113
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
114
|
+
const node = nodes[ii];
|
|
115
|
+
node.__addChild(this);
|
|
84
116
|
}
|
|
85
117
|
}
|
|
86
118
|
|
|
@@ -88,12 +120,14 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
88
120
|
if (this.__isNative && this._animatedView) {
|
|
89
121
|
this.__disconnectAnimatedView();
|
|
90
122
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
123
|
+
this._animatedView = null;
|
|
124
|
+
|
|
125
|
+
const nodes = this.#nodes;
|
|
126
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
127
|
+
const node = nodes[ii];
|
|
128
|
+
node.__removeChild(this);
|
|
96
129
|
}
|
|
130
|
+
|
|
97
131
|
super.__detach();
|
|
98
132
|
}
|
|
99
133
|
|
|
@@ -102,11 +136,10 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
102
136
|
}
|
|
103
137
|
|
|
104
138
|
__makeNative(platformConfig: ?PlatformConfig): void {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
139
|
+
const nodes = this.#nodes;
|
|
140
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
141
|
+
const node = nodes[ii];
|
|
142
|
+
node.__makeNative(platformConfig);
|
|
110
143
|
}
|
|
111
144
|
|
|
112
145
|
if (!this.__isNative) {
|
|
@@ -170,14 +203,18 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
170
203
|
}
|
|
171
204
|
|
|
172
205
|
__getNativeConfig(): Object {
|
|
206
|
+
const platformConfig = this.__getPlatformConfig();
|
|
173
207
|
const propsConfig: {[string]: number} = {};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
208
|
+
|
|
209
|
+
const nodeKeys = this.#nodeKeys;
|
|
210
|
+
const nodes = this.#nodes;
|
|
211
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
212
|
+
const key = nodeKeys[ii];
|
|
213
|
+
const node = nodes[ii];
|
|
214
|
+
node.__makeNative(platformConfig);
|
|
215
|
+
propsConfig[key] = node.__getNativeTag();
|
|
180
216
|
}
|
|
217
|
+
|
|
181
218
|
return {
|
|
182
219
|
type: 'props',
|
|
183
220
|
props: propsConfig,
|
|
@@ -12,116 +12,160 @@
|
|
|
12
12
|
|
|
13
13
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
14
14
|
|
|
15
|
+
import {validateStyles} from '../../../src/private/animated/NativeAnimatedValidation';
|
|
15
16
|
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
16
17
|
import flattenStyle from '../../StyleSheet/flattenStyle';
|
|
17
18
|
import Platform from '../../Utilities/Platform';
|
|
18
|
-
import NativeAnimatedHelper from '../NativeAnimatedHelper';
|
|
19
19
|
import AnimatedNode from './AnimatedNode';
|
|
20
|
-
import AnimatedObject
|
|
20
|
+
import AnimatedObject from './AnimatedObject';
|
|
21
21
|
import AnimatedTransform from './AnimatedTransform';
|
|
22
22
|
import AnimatedWithChildren from './AnimatedWithChildren';
|
|
23
23
|
|
|
24
24
|
function createAnimatedStyle(
|
|
25
|
-
inputStyle:
|
|
25
|
+
inputStyle: {[string]: mixed},
|
|
26
26
|
keepUnanimatedValues: boolean,
|
|
27
|
-
): Object {
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
): [$ReadOnlyArray<string>, $ReadOnlyArray<AnimatedNode>, Object] {
|
|
28
|
+
const nodeKeys: Array<string> = [];
|
|
29
|
+
const nodes: Array<AnimatedNode> = [];
|
|
30
|
+
const style: {[string]: any} = {};
|
|
31
|
+
|
|
32
|
+
const keys = Object.keys(inputStyle);
|
|
33
|
+
for (let ii = 0, length = keys.length; ii < length; ii++) {
|
|
34
|
+
const key = keys[ii];
|
|
35
|
+
const value = inputStyle[key];
|
|
36
|
+
|
|
33
37
|
if (value != null && key === 'transform') {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
const node = ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform()
|
|
39
|
+
? AnimatedObject.from(value)
|
|
40
|
+
: // $FlowFixMe[incompatible-call] - `value` is mixed.
|
|
41
|
+
new AnimatedTransform(value);
|
|
42
|
+
if (node == null) {
|
|
43
|
+
if (keepUnanimatedValues) {
|
|
44
|
+
style[key] = value;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
nodeKeys.push(key);
|
|
48
|
+
nodes.push(node);
|
|
49
|
+
style[key] = node;
|
|
50
|
+
}
|
|
38
51
|
} else if (value instanceof AnimatedNode) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
const node = value;
|
|
53
|
+
nodeKeys.push(key);
|
|
54
|
+
nodes.push(node);
|
|
55
|
+
style[key] = value;
|
|
56
|
+
} else {
|
|
57
|
+
const node = AnimatedObject.from(value);
|
|
58
|
+
if (node == null) {
|
|
59
|
+
if (keepUnanimatedValues) {
|
|
60
|
+
style[key] = value;
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
nodeKeys.push(key);
|
|
64
|
+
nodes.push(node);
|
|
65
|
+
style[key] = node;
|
|
66
|
+
}
|
|
44
67
|
}
|
|
45
68
|
}
|
|
46
|
-
|
|
69
|
+
|
|
70
|
+
return [nodeKeys, nodes, style];
|
|
47
71
|
}
|
|
48
72
|
|
|
49
73
|
export default class AnimatedStyle extends AnimatedWithChildren {
|
|
74
|
+
#nodeKeys: $ReadOnlyArray<string>;
|
|
75
|
+
#nodes: $ReadOnlyArray<AnimatedNode>;
|
|
76
|
+
|
|
50
77
|
_inputStyle: any;
|
|
51
|
-
_style:
|
|
78
|
+
_style: {[string]: any};
|
|
52
79
|
|
|
53
|
-
constructor(
|
|
80
|
+
constructor(inputStyle: any) {
|
|
54
81
|
super();
|
|
55
|
-
this._inputStyle =
|
|
56
|
-
|
|
82
|
+
this._inputStyle = inputStyle;
|
|
83
|
+
const [nodeKeys, nodes, style] = createAnimatedStyle(
|
|
84
|
+
// NOTE: This null check should not be necessary, but the types are not
|
|
85
|
+
// strong nor enforced as of this writing. This check should be hoisted
|
|
86
|
+
// to instantiation sites.
|
|
87
|
+
flattenStyle(inputStyle) ?? {},
|
|
88
|
+
Platform.OS !== 'web',
|
|
89
|
+
);
|
|
90
|
+
this.#nodeKeys = nodeKeys;
|
|
91
|
+
this.#nodes = nodes;
|
|
92
|
+
this._style = style;
|
|
57
93
|
}
|
|
58
94
|
|
|
59
95
|
__getValue(): Object | Array<Object> {
|
|
60
|
-
const
|
|
61
|
-
|
|
96
|
+
const style: {[string]: any} = {};
|
|
97
|
+
|
|
98
|
+
const keys = Object.keys(this._style);
|
|
99
|
+
for (let ii = 0, length = keys.length; ii < length; ii++) {
|
|
100
|
+
const key = keys[ii];
|
|
62
101
|
const value = this._style[key];
|
|
102
|
+
|
|
63
103
|
if (value instanceof AnimatedNode) {
|
|
64
|
-
|
|
104
|
+
style[key] = value.__getValue();
|
|
65
105
|
} else {
|
|
66
|
-
|
|
106
|
+
style[key] = value;
|
|
67
107
|
}
|
|
68
108
|
}
|
|
69
109
|
|
|
70
|
-
return Platform.OS === 'web' ? [this._inputStyle,
|
|
110
|
+
return Platform.OS === 'web' ? [this._inputStyle, style] : style;
|
|
71
111
|
}
|
|
72
112
|
|
|
73
113
|
__getAnimatedValue(): Object {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
114
|
+
const style: {[string]: any} = {};
|
|
115
|
+
|
|
116
|
+
const nodeKeys = this.#nodeKeys;
|
|
117
|
+
const nodes = this.#nodes;
|
|
118
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
119
|
+
const key = nodeKeys[ii];
|
|
120
|
+
const node = nodes[ii];
|
|
121
|
+
style[key] = node.__getAnimatedValue();
|
|
80
122
|
}
|
|
81
|
-
|
|
123
|
+
|
|
124
|
+
return style;
|
|
82
125
|
}
|
|
83
126
|
|
|
84
127
|
__attach(): void {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
128
|
+
const nodes = this.#nodes;
|
|
129
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
130
|
+
const node = nodes[ii];
|
|
131
|
+
node.__addChild(this);
|
|
90
132
|
}
|
|
91
133
|
}
|
|
92
134
|
|
|
93
135
|
__detach(): void {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
136
|
+
const nodes = this.#nodes;
|
|
137
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
138
|
+
const node = nodes[ii];
|
|
139
|
+
node.__removeChild(this);
|
|
99
140
|
}
|
|
100
141
|
super.__detach();
|
|
101
142
|
}
|
|
102
143
|
|
|
103
144
|
__makeNative(platformConfig: ?PlatformConfig) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
145
|
+
const nodes = this.#nodes;
|
|
146
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
147
|
+
const node = nodes[ii];
|
|
148
|
+
node.__makeNative(platformConfig);
|
|
109
149
|
}
|
|
110
150
|
super.__makeNative(platformConfig);
|
|
111
151
|
}
|
|
112
152
|
|
|
113
153
|
__getNativeConfig(): Object {
|
|
154
|
+
const platformConfig = this.__getPlatformConfig();
|
|
114
155
|
const styleConfig: {[string]: ?number} = {};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
156
|
+
|
|
157
|
+
const nodeKeys = this.#nodeKeys;
|
|
158
|
+
const nodes = this.#nodes;
|
|
159
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
160
|
+
const key = nodeKeys[ii];
|
|
161
|
+
const node = nodes[ii];
|
|
162
|
+
node.__makeNative(platformConfig);
|
|
163
|
+
styleConfig[key] = node.__getNativeTag();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (__DEV__) {
|
|
167
|
+
validateStyles(styleConfig);
|
|
123
168
|
}
|
|
124
|
-
NativeAnimatedHelper.validateStyles(styleConfig);
|
|
125
169
|
return {
|
|
126
170
|
type: 'style',
|
|
127
171
|
style: styleConfig,
|
|
@@ -14,7 +14,7 @@ import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
|
14
14
|
import type {EndCallback} from '../animations/Animation';
|
|
15
15
|
import type AnimatedValue from './AnimatedValue';
|
|
16
16
|
|
|
17
|
-
import NativeAnimatedHelper from '
|
|
17
|
+
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
18
18
|
import AnimatedNode from './AnimatedNode';
|
|
19
19
|
|
|
20
20
|
export default class AnimatedTracking extends AnimatedNode {
|
|
@@ -12,119 +12,154 @@
|
|
|
12
12
|
|
|
13
13
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import {validateTransform} from '../../../src/private/animated/NativeAnimatedValidation';
|
|
16
|
+
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
16
17
|
import AnimatedNode from './AnimatedNode';
|
|
17
18
|
import AnimatedWithChildren from './AnimatedWithChildren';
|
|
18
19
|
|
|
20
|
+
type Transform<T = AnimatedNode> = {
|
|
21
|
+
[string]:
|
|
22
|
+
| number
|
|
23
|
+
| string
|
|
24
|
+
| T
|
|
25
|
+
| $ReadOnlyArray<number | string | T>
|
|
26
|
+
| {[string]: number | string | T},
|
|
27
|
+
};
|
|
28
|
+
|
|
19
29
|
export default class AnimatedTransform extends AnimatedWithChildren {
|
|
20
|
-
|
|
30
|
+
// NOTE: For potentially historical reasons, some operations only operate on
|
|
31
|
+
// the first level of AnimatedNode instances. This optimizes that bevavior.
|
|
32
|
+
#shallowNodes: $ReadOnlyArray<AnimatedNode>;
|
|
33
|
+
|
|
34
|
+
_transforms: $ReadOnlyArray<Transform<>>;
|
|
21
35
|
|
|
22
|
-
constructor(transforms: $ReadOnlyArray<
|
|
36
|
+
constructor(transforms: $ReadOnlyArray<Transform<>>) {
|
|
23
37
|
super();
|
|
24
38
|
this._transforms = transforms;
|
|
25
|
-
}
|
|
26
39
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
const shallowNodes = [];
|
|
41
|
+
// NOTE: This check should not be necessary, but the types are not enforced
|
|
42
|
+
// as of this writing. This check should be hoisted to instantiation sites.
|
|
43
|
+
if (Array.isArray(transforms)) {
|
|
44
|
+
for (let ii = 0, length = transforms.length; ii < length; ii++) {
|
|
45
|
+
const transform = transforms[ii];
|
|
46
|
+
// There should be exactly one property in `transform`.
|
|
47
|
+
for (const key in transform) {
|
|
48
|
+
const value = transform[key];
|
|
49
|
+
if (value instanceof AnimatedNode) {
|
|
50
|
+
shallowNodes.push(value);
|
|
51
|
+
}
|
|
33
52
|
}
|
|
34
53
|
}
|
|
35
|
-
}
|
|
54
|
+
}
|
|
55
|
+
this.#shallowNodes = shallowNodes;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
__makeNative(platformConfig: ?PlatformConfig) {
|
|
59
|
+
const nodes = this.#shallowNodes;
|
|
60
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
61
|
+
const node = nodes[ii];
|
|
62
|
+
node.__makeNative(platformConfig);
|
|
63
|
+
}
|
|
36
64
|
super.__makeNative(platformConfig);
|
|
37
65
|
}
|
|
38
66
|
|
|
39
|
-
__getValue(): $ReadOnlyArray<
|
|
40
|
-
return this.
|
|
67
|
+
__getValue(): $ReadOnlyArray<Transform<any>> {
|
|
68
|
+
return mapTransforms(this._transforms, animatedNode =>
|
|
69
|
+
animatedNode.__getValue(),
|
|
70
|
+
);
|
|
41
71
|
}
|
|
42
72
|
|
|
43
|
-
__getAnimatedValue(): $ReadOnlyArray<
|
|
44
|
-
return this.
|
|
73
|
+
__getAnimatedValue(): $ReadOnlyArray<Transform<any>> {
|
|
74
|
+
return mapTransforms(this._transforms, animatedNode =>
|
|
75
|
+
animatedNode.__getAnimatedValue(),
|
|
76
|
+
);
|
|
45
77
|
}
|
|
46
78
|
|
|
47
79
|
__attach(): void {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
80
|
+
const nodes = this.#shallowNodes;
|
|
81
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
82
|
+
const node = nodes[ii];
|
|
83
|
+
node.__addChild(this);
|
|
84
|
+
}
|
|
56
85
|
}
|
|
57
86
|
|
|
58
87
|
__detach(): void {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
88
|
+
const nodes = this.#shallowNodes;
|
|
89
|
+
for (let ii = 0, length = nodes.length; ii < length; ii++) {
|
|
90
|
+
const node = nodes[ii];
|
|
91
|
+
node.__removeChild(this);
|
|
92
|
+
}
|
|
67
93
|
super.__detach();
|
|
68
94
|
}
|
|
69
95
|
|
|
70
96
|
__getNativeConfig(): any {
|
|
71
|
-
const
|
|
97
|
+
const transformsConfig: Array<any> = [];
|
|
72
98
|
|
|
73
|
-
this._transforms
|
|
99
|
+
const transforms = this._transforms;
|
|
100
|
+
for (let ii = 0, length = transforms.length; ii < length; ii++) {
|
|
101
|
+
const transform = transforms[ii];
|
|
102
|
+
// There should be exactly one property in `transform`.
|
|
74
103
|
for (const key in transform) {
|
|
75
104
|
const value = transform[key];
|
|
76
105
|
if (value instanceof AnimatedNode) {
|
|
77
|
-
|
|
106
|
+
transformsConfig.push({
|
|
78
107
|
type: 'animated',
|
|
79
108
|
property: key,
|
|
80
109
|
nodeTag: value.__getNativeTag(),
|
|
81
110
|
});
|
|
82
111
|
} else {
|
|
83
|
-
|
|
112
|
+
transformsConfig.push({
|
|
84
113
|
type: 'static',
|
|
85
114
|
property: key,
|
|
115
|
+
/* $FlowFixMe[incompatible-call] - `value` can be an array or an
|
|
116
|
+
object. This is not currently handled by `transformDataType`.
|
|
117
|
+
Migrating to `TransformObject` might solve this. */
|
|
86
118
|
value: NativeAnimatedHelper.transformDataType(value),
|
|
87
119
|
});
|
|
88
120
|
}
|
|
89
121
|
}
|
|
90
|
-
}
|
|
122
|
+
}
|
|
91
123
|
|
|
92
|
-
|
|
124
|
+
if (__DEV__) {
|
|
125
|
+
validateTransform(transformsConfig);
|
|
126
|
+
}
|
|
93
127
|
return {
|
|
94
128
|
type: 'transform',
|
|
95
|
-
transforms:
|
|
129
|
+
transforms: transformsConfig,
|
|
96
130
|
};
|
|
97
131
|
}
|
|
132
|
+
}
|
|
98
133
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
result[key] = value;
|
|
134
|
+
function mapTransforms<T>(
|
|
135
|
+
transforms: $ReadOnlyArray<Transform<>>,
|
|
136
|
+
mapFunction: AnimatedNode => T,
|
|
137
|
+
): $ReadOnlyArray<Transform<T>> {
|
|
138
|
+
return transforms.map(transform => {
|
|
139
|
+
const result: Transform<T> = {};
|
|
140
|
+
// There should be exactly one property in `transform`.
|
|
141
|
+
for (const key in transform) {
|
|
142
|
+
const value = transform[key];
|
|
143
|
+
if (value instanceof AnimatedNode) {
|
|
144
|
+
result[key] = mapFunction(value);
|
|
145
|
+
} else if (Array.isArray(value)) {
|
|
146
|
+
result[key] = value.map(element =>
|
|
147
|
+
element instanceof AnimatedNode ? mapFunction(element) : element,
|
|
148
|
+
);
|
|
149
|
+
} else if (typeof value === 'object') {
|
|
150
|
+
const object: {[string]: number | string | T} = {};
|
|
151
|
+
for (const propertyName in value) {
|
|
152
|
+
const propertyValue = value[propertyName];
|
|
153
|
+
object[propertyName] =
|
|
154
|
+
propertyValue instanceof AnimatedNode
|
|
155
|
+
? mapFunction(propertyValue)
|
|
156
|
+
: propertyValue;
|
|
125
157
|
}
|
|
158
|
+
result[key] = object;
|
|
159
|
+
} else {
|
|
160
|
+
result[key] = value;
|
|
126
161
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
});
|
|
130
165
|
}
|
|
@@ -16,7 +16,7 @@ import type AnimatedNode from './AnimatedNode';
|
|
|
16
16
|
import type AnimatedTracking from './AnimatedTracking';
|
|
17
17
|
|
|
18
18
|
import InteractionManager from '../../Interaction/InteractionManager';
|
|
19
|
-
import NativeAnimatedHelper from '
|
|
19
|
+
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
20
20
|
import AnimatedInterpolation from './AnimatedInterpolation';
|
|
21
21
|
import AnimatedWithChildren from './AnimatedWithChildren';
|
|
22
22
|
|
|
@@ -49,6 +49,7 @@ const NativeAnimatedAPI = NativeAnimatedHelper.API;
|
|
|
49
49
|
* transform which can receive values from multiple parents.
|
|
50
50
|
*/
|
|
51
51
|
export function flushValue(rootNode: AnimatedNode): void {
|
|
52
|
+
// eslint-disable-next-line func-call-spacing
|
|
52
53
|
const leaves = new Set<{update: () => void, ...}>();
|
|
53
54
|
function findAnimatedStyles(node: AnimatedNode) {
|
|
54
55
|
// $FlowFixMe[prop-missing]
|