@office-iss/react-native-win32 0.77.0-preview.3 → 0.78.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 +1 -1
- package/CHANGELOG.json +109 -16
- package/CHANGELOG.md +42 -10
- package/Libraries/Animated/animations/Animation.js +22 -1
- package/Libraries/Animated/animations/DecayAnimation.js +1 -0
- package/Libraries/Animated/animations/SpringAnimation.js +1 -0
- package/Libraries/Animated/animations/TimingAnimation.js +1 -0
- package/Libraries/Animated/nodes/AnimatedAddition.js +9 -2
- package/Libraries/Animated/nodes/AnimatedColor.js +4 -1
- package/Libraries/Animated/nodes/AnimatedDiffClamp.js +10 -2
- package/Libraries/Animated/nodes/AnimatedDivision.js +9 -2
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +5 -1
- package/Libraries/Animated/nodes/AnimatedModulo.js +5 -2
- package/Libraries/Animated/nodes/AnimatedMultiplication.js +9 -2
- package/Libraries/Animated/nodes/AnimatedNode.js +25 -46
- package/Libraries/Animated/nodes/AnimatedObject.js +9 -2
- package/Libraries/Animated/nodes/AnimatedProps.js +5 -1
- package/Libraries/Animated/nodes/AnimatedStyle.js +5 -1
- package/Libraries/Animated/nodes/AnimatedSubtraction.js +9 -2
- package/Libraries/Animated/nodes/AnimatedTracking.js +5 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +5 -1
- package/Libraries/Animated/nodes/AnimatedValue.js +49 -4
- package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -1
- package/Libraries/Animated/useAnimatedProps.js +0 -43
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +1 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +4 -1
- package/Libraries/Components/LayoutConformance/LayoutConformance.d.ts +21 -0
- package/Libraries/Components/LayoutConformance/LayoutConformance.js +59 -0
- package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +29 -0
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +5 -0
- package/Libraries/Components/TextInput/TextInput.flow.js +6 -0
- package/Libraries/Components/TextInput/TextInput.js +6 -0
- package/Libraries/Components/TextInput/TextInput.win32.js +6 -0
- package/Libraries/Components/View/ViewPropTypes.d.ts +0 -7
- package/Libraries/Components/View/ViewPropTypes.js +0 -9
- package/Libraries/Components/View/ViewPropTypes.win32.js +0 -9
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/setUpBatchedBridge.js +1 -16
- package/Libraries/EventEmitter/RCTEventEmitter.js +2 -6
- package/Libraries/Image/AssetSourceResolver.js +11 -0
- package/Libraries/Inspector/BorderBox.js +26 -14
- package/Libraries/Inspector/BoxInspector.js +60 -42
- package/Libraries/Inspector/ElementBox.js +55 -48
- package/Libraries/Inspector/StyleInspector.js +36 -30
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
- package/Libraries/Lists/FlatList.d.ts +1 -1
- package/Libraries/Modal/Modal.js +2 -0
- package/Libraries/NativeComponent/BaseViewConfig.android.js +0 -2
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +0 -2
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +0 -2
- package/Libraries/Network/RCTNetworking.android.js +24 -16
- package/Libraries/Network/RCTNetworking.ios.js +1 -46
- package/Libraries/Network/RCTNetworking.win32.js +1 -46
- package/Libraries/Network/RCTNetworkingEventDefinitions.flow.js +57 -0
- package/Libraries/PersonaCoin/PersonaCoin.js +1 -0
- package/Libraries/PersonaCoin/PersonaCoin.js.map +1 -1
- package/Libraries/ReactNative/UIManagerProperties.js +3 -1
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +15828 -26461
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3907 -2560
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4399 -2878
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +16102 -26908
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +4034 -2695
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4535 -3045
- package/Libraries/Renderer/shims/ReactNativeTypes.js +5 -6
- package/Libraries/StyleSheet/processTransform.js +6 -0
- package/Libraries/Text/Text.d.ts +6 -1
- package/Libraries/Text/TextProps.js +2 -2
- package/Libraries/Text/TextProps.win32.js +2 -2
- package/Libraries/Utilities/BackHandler.android.js +5 -4
- package/Libraries/Utilities/BackHandler.ios.js +4 -5
- package/Libraries/Utilities/BackHandler.win32.js +5 -4
- package/index.js +5 -0
- package/index.win32.js +5 -0
- package/overrides.json +14 -14
- package/package.json +20 -21
- package/src/private/animated/NativeAnimatedValidation.js +1 -1
- package/src/private/featureflags/ReactNativeFeatureFlags.js +32 -26
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +5 -5
- package/src/private/renderer/errorhandling/ErrorHandlers.js +12 -55
- package/src/private/specs/modules/{NativeJSCSamplingProfiler.js → NativeCPUTime.js} +7 -2
- package/src/private/specs/modules/NativeFantom.js +37 -0
- package/src/private/utilities/ensureInstance.js +21 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +49 -6
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +17 -9
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +11 -11
- package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +1 -1
- package/src/private/webapis/intersectionobserver/IntersectionObserverManager.js +1 -1
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
- package/src/private/webapis/performance/Performance.js +0 -12
- package/src/private/webapis/performance/specs/NativePerformance.js +0 -11
- package/src-win/Libraries/Components/View/ViewPropTypes.d.ts +0 -7
- package/src-win/Libraries/PersonaCoin/PersonaCoin.tsx +1 -0
- package/src-win/Libraries/Text/Text.d.ts +6 -1
- package/types/index.d.ts +1 -0
- package/Libraries/HeapCapture/HeapCapture.js +0 -29
- package/Libraries/HeapCapture/NativeJSCHeapCapture.js +0 -13
- package/Libraries/Performance/NativeJSCSamplingProfiler.js +0 -13
- package/Libraries/Performance/SamplingProfiler.js +0 -39
- package/Libraries/ReactNative/__mocks__/FabricUIManager.js +0 -334
- package/src/private/webapis/dom/nodes/specs/__mocks__/NativeDOMMock.js +0 -413
- package/src/private/webapis/intersectionobserver/specs/__mocks__/NativeIntersectionObserver.js +0 -181
- package/src/private/webapis/mutationobserver/specs/__mocks__/NativeMutationObserver.js +0 -327
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
|
|
12
11
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
13
12
|
|
|
14
13
|
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
15
14
|
import invariant from 'invariant';
|
|
16
15
|
|
|
17
|
-
const {startListeningToAnimatedNodeValue, stopListeningToAnimatedNodeValue} =
|
|
18
|
-
NativeAnimatedHelper.API;
|
|
19
|
-
|
|
20
16
|
type ValueListenerCallback = (state: {value: number, ...}) => mixed;
|
|
21
17
|
|
|
18
|
+
export type AnimatedNodeConfig = $ReadOnly<{
|
|
19
|
+
debugID?: string,
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
22
|
let _uniqueId = 1;
|
|
23
23
|
let _assertNativeAnimatedModule: ?() => void = () => {
|
|
24
24
|
NativeAnimatedHelper.assertNativeAnimatedModule();
|
|
@@ -29,9 +29,20 @@ let _assertNativeAnimatedModule: ?() => void = () => {
|
|
|
29
29
|
|
|
30
30
|
export default class AnimatedNode {
|
|
31
31
|
#listeners: Map<string, ValueListenerCallback> = new Map();
|
|
32
|
-
#updateSubscription: ?EventSubscription = null;
|
|
33
32
|
|
|
34
33
|
_platformConfig: ?PlatformConfig = undefined;
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
config?: ?$ReadOnly<{
|
|
37
|
+
...AnimatedNodeConfig,
|
|
38
|
+
...
|
|
39
|
+
}>,
|
|
40
|
+
) {
|
|
41
|
+
if (__DEV__) {
|
|
42
|
+
this.__debugID = config?.debugID;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
__attach(): void {}
|
|
36
47
|
__detach(): void {
|
|
37
48
|
this.removeAllListeners();
|
|
@@ -62,9 +73,6 @@ export default class AnimatedNode {
|
|
|
62
73
|
);
|
|
63
74
|
|
|
64
75
|
this._platformConfig = platformConfig;
|
|
65
|
-
if (this.#listeners.size > 0) {
|
|
66
|
-
this.#ensureUpdateSubscriptionExists();
|
|
67
|
-
}
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
/**
|
|
@@ -77,9 +85,6 @@ export default class AnimatedNode {
|
|
|
77
85
|
addListener(callback: (value: any) => mixed): string {
|
|
78
86
|
const id = String(_uniqueId++);
|
|
79
87
|
this.#listeners.set(id, callback);
|
|
80
|
-
if (this.__isNative) {
|
|
81
|
-
this.#ensureUpdateSubscriptionExists();
|
|
82
|
-
}
|
|
83
88
|
return id;
|
|
84
89
|
}
|
|
85
90
|
|
|
@@ -91,9 +96,6 @@ export default class AnimatedNode {
|
|
|
91
96
|
*/
|
|
92
97
|
removeListener(id: string): void {
|
|
93
98
|
this.#listeners.delete(id);
|
|
94
|
-
if (this.__isNative && this.#listeners.size === 0) {
|
|
95
|
-
this.#updateSubscription?.remove();
|
|
96
|
-
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/**
|
|
@@ -103,44 +105,12 @@ export default class AnimatedNode {
|
|
|
103
105
|
*/
|
|
104
106
|
removeAllListeners(): void {
|
|
105
107
|
this.#listeners.clear();
|
|
106
|
-
if (this.__isNative) {
|
|
107
|
-
this.#updateSubscription?.remove();
|
|
108
|
-
}
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
hasListeners(): boolean {
|
|
112
111
|
return this.#listeners.size > 0;
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
#ensureUpdateSubscriptionExists(): void {
|
|
116
|
-
if (this.#updateSubscription != null) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const nativeTag = this.__getNativeTag();
|
|
120
|
-
startListeningToAnimatedNodeValue(nativeTag);
|
|
121
|
-
const subscription: EventSubscription =
|
|
122
|
-
NativeAnimatedHelper.nativeEventEmitter.addListener(
|
|
123
|
-
'onAnimatedValueUpdate',
|
|
124
|
-
data => {
|
|
125
|
-
if (data.tag === nativeTag) {
|
|
126
|
-
this.__onAnimatedValueUpdateReceived(data.value);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
this.#updateSubscription = {
|
|
132
|
-
remove: () => {
|
|
133
|
-
// Only this function assigns to `this.#updateSubscription`.
|
|
134
|
-
if (this.#updateSubscription == null) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
this.#updateSubscription = null;
|
|
138
|
-
subscription.remove();
|
|
139
|
-
stopListeningToAnimatedNodeValue(nativeTag);
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
114
|
__onAnimatedValueUpdateReceived(value: number): void {
|
|
145
115
|
this.__callListeners(value);
|
|
146
116
|
}
|
|
@@ -197,4 +167,13 @@ export default class AnimatedNode {
|
|
|
197
167
|
toJSON(): mixed {
|
|
198
168
|
return this.__getValue();
|
|
199
169
|
}
|
|
170
|
+
|
|
171
|
+
__debugID: ?string = undefined;
|
|
172
|
+
|
|
173
|
+
__getDebugID(): ?string {
|
|
174
|
+
if (__DEV__) {
|
|
175
|
+
return this.__debugID;
|
|
176
|
+
}
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
200
179
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
14
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
15
|
+
import type {AnimatedNodeConfig} from './AnimatedNode';
|
|
15
16
|
|
|
16
17
|
import AnimatedNode from './AnimatedNode';
|
|
17
18
|
import AnimatedWithChildren from './AnimatedWithChildren';
|
|
@@ -99,8 +100,12 @@ export default class AnimatedObject extends AnimatedWithChildren {
|
|
|
99
100
|
/**
|
|
100
101
|
* Should only be called by `AnimatedObject.from`.
|
|
101
102
|
*/
|
|
102
|
-
constructor(
|
|
103
|
-
|
|
103
|
+
constructor(
|
|
104
|
+
nodes: $ReadOnlyArray<AnimatedNode>,
|
|
105
|
+
value: mixed,
|
|
106
|
+
config?: ?AnimatedNodeConfig,
|
|
107
|
+
) {
|
|
108
|
+
super(config);
|
|
104
109
|
this.#nodes = nodes;
|
|
105
110
|
this._value = value;
|
|
106
111
|
}
|
|
@@ -131,6 +136,7 @@ export default class AnimatedObject extends AnimatedWithChildren {
|
|
|
131
136
|
const node = nodes[ii];
|
|
132
137
|
node.__addChild(this);
|
|
133
138
|
}
|
|
139
|
+
super.__attach();
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
__detach(): void {
|
|
@@ -157,6 +163,7 @@ export default class AnimatedObject extends AnimatedWithChildren {
|
|
|
157
163
|
value: mapAnimatedNodes(this._value, node => {
|
|
158
164
|
return {nodeTag: node.__getNativeTag()};
|
|
159
165
|
}),
|
|
166
|
+
debugID: this.__getDebugID(),
|
|
160
167
|
};
|
|
161
168
|
}
|
|
162
169
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
12
|
+
import type {AnimatedNodeConfig} from './AnimatedNode';
|
|
12
13
|
import type {AnimatedStyleAllowlist} from './AnimatedStyle';
|
|
13
14
|
|
|
14
15
|
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
@@ -84,8 +85,9 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
84
85
|
inputProps: {[string]: mixed},
|
|
85
86
|
callback: () => void,
|
|
86
87
|
allowlist?: ?AnimatedPropsAllowlist,
|
|
88
|
+
config?: ?AnimatedNodeConfig,
|
|
87
89
|
) {
|
|
88
|
-
super();
|
|
90
|
+
super(config);
|
|
89
91
|
const [nodeKeys, nodes, props] = createAnimatedProps(inputProps, allowlist);
|
|
90
92
|
this.#nodeKeys = nodeKeys;
|
|
91
93
|
this.#nodes = nodes;
|
|
@@ -158,6 +160,7 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
158
160
|
const node = nodes[ii];
|
|
159
161
|
node.__addChild(this);
|
|
160
162
|
}
|
|
163
|
+
super.__attach();
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
__detach(): void {
|
|
@@ -268,6 +271,7 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
268
271
|
return {
|
|
269
272
|
type: 'props',
|
|
270
273
|
props: propsConfig,
|
|
274
|
+
debugID: this.__getDebugID(),
|
|
271
275
|
};
|
|
272
276
|
}
|
|
273
277
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
12
|
+
import type {AnimatedNodeConfig} from './AnimatedNode';
|
|
12
13
|
|
|
13
14
|
import {validateStyles} from '../../../src/private/animated/NativeAnimatedValidation';
|
|
14
15
|
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
|
|
@@ -112,8 +113,9 @@ export default class AnimatedStyle extends AnimatedWithChildren {
|
|
|
112
113
|
nodes: $ReadOnlyArray<AnimatedNode>,
|
|
113
114
|
style: {[string]: mixed},
|
|
114
115
|
inputStyle: any,
|
|
116
|
+
config?: ?AnimatedNodeConfig,
|
|
115
117
|
) {
|
|
116
|
-
super();
|
|
118
|
+
super(config);
|
|
117
119
|
this.#nodeKeys = nodeKeys;
|
|
118
120
|
this.#nodes = nodes;
|
|
119
121
|
this.#style = style;
|
|
@@ -199,6 +201,7 @@ export default class AnimatedStyle extends AnimatedWithChildren {
|
|
|
199
201
|
const node = nodes[ii];
|
|
200
202
|
node.__addChild(this);
|
|
201
203
|
}
|
|
204
|
+
super.__attach();
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
__detach(): void {
|
|
@@ -238,6 +241,7 @@ export default class AnimatedStyle extends AnimatedWithChildren {
|
|
|
238
241
|
return {
|
|
239
242
|
type: 'style',
|
|
240
243
|
style: styleConfig,
|
|
244
|
+
debugID: this.__getDebugID(),
|
|
241
245
|
};
|
|
242
246
|
}
|
|
243
247
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
14
14
|
import type {InterpolationConfigType} from './AnimatedInterpolation';
|
|
15
15
|
import type AnimatedNode from './AnimatedNode';
|
|
16
|
+
import type {AnimatedNodeConfig} from './AnimatedNode';
|
|
16
17
|
|
|
17
18
|
import AnimatedInterpolation from './AnimatedInterpolation';
|
|
18
19
|
import AnimatedValue from './AnimatedValue';
|
|
@@ -22,8 +23,12 @@ export default class AnimatedSubtraction extends AnimatedWithChildren {
|
|
|
22
23
|
_a: AnimatedNode;
|
|
23
24
|
_b: AnimatedNode;
|
|
24
25
|
|
|
25
|
-
constructor(
|
|
26
|
-
|
|
26
|
+
constructor(
|
|
27
|
+
a: AnimatedNode | number,
|
|
28
|
+
b: AnimatedNode | number,
|
|
29
|
+
config?: ?AnimatedNodeConfig,
|
|
30
|
+
) {
|
|
31
|
+
super(config);
|
|
27
32
|
this._a = typeof a === 'number' ? new AnimatedValue(a) : a;
|
|
28
33
|
this._b = typeof b === 'number' ? new AnimatedValue(b) : b;
|
|
29
34
|
}
|
|
@@ -47,6 +52,7 @@ export default class AnimatedSubtraction extends AnimatedWithChildren {
|
|
|
47
52
|
__attach(): void {
|
|
48
53
|
this._a.__addChild(this);
|
|
49
54
|
this._b.__addChild(this);
|
|
55
|
+
super.__attach();
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
__detach(): void {
|
|
@@ -59,6 +65,7 @@ export default class AnimatedSubtraction extends AnimatedWithChildren {
|
|
|
59
65
|
return {
|
|
60
66
|
type: 'subtraction',
|
|
61
67
|
input: [this._a.__getNativeTag(), this._b.__getNativeTag()],
|
|
68
|
+
debugID: this.__getDebugID(),
|
|
62
69
|
};
|
|
63
70
|
}
|
|
64
71
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
14
14
|
import type {EndCallback} from '../animations/Animation';
|
|
15
|
+
import type {AnimatedNodeConfig} from './AnimatedNode';
|
|
15
16
|
import type AnimatedValue from './AnimatedValue';
|
|
16
17
|
|
|
17
18
|
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
@@ -31,8 +32,9 @@ export default class AnimatedTracking extends AnimatedNode {
|
|
|
31
32
|
animationClass: any,
|
|
32
33
|
animationConfig: Object,
|
|
33
34
|
callback?: ?EndCallback,
|
|
35
|
+
config?: ?AnimatedNodeConfig,
|
|
34
36
|
) {
|
|
35
|
-
super();
|
|
37
|
+
super(config);
|
|
36
38
|
this._value = value;
|
|
37
39
|
this._parent = parent;
|
|
38
40
|
this._animationClass = animationClass;
|
|
@@ -65,6 +67,7 @@ export default class AnimatedTracking extends AnimatedNode {
|
|
|
65
67
|
let {platformConfig} = this._animationConfig;
|
|
66
68
|
this.__makeNative(platformConfig);
|
|
67
69
|
}
|
|
70
|
+
super.__attach();
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
__detach(): void {
|
|
@@ -95,6 +98,7 @@ export default class AnimatedTracking extends AnimatedNode {
|
|
|
95
98
|
animationConfig,
|
|
96
99
|
toValue: this._parent.__getNativeTag(),
|
|
97
100
|
value: this._value.__getNativeTag(),
|
|
101
|
+
debugID: this.__getDebugID(),
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
104
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
14
|
+
import type {AnimatedNodeConfig} from './AnimatedNode';
|
|
14
15
|
|
|
15
16
|
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
16
17
|
import {validateTransform} from '../../../src/private/animated/NativeAnimatedValidation';
|
|
@@ -70,8 +71,9 @@ export default class AnimatedTransform extends AnimatedWithChildren {
|
|
|
70
71
|
constructor(
|
|
71
72
|
nodes: $ReadOnlyArray<AnimatedNode>,
|
|
72
73
|
transforms: $ReadOnlyArray<Transform<>>,
|
|
74
|
+
config?: ?AnimatedNodeConfig,
|
|
73
75
|
) {
|
|
74
|
-
super();
|
|
76
|
+
super(config);
|
|
75
77
|
this.#nodes = nodes;
|
|
76
78
|
this._transforms = transforms;
|
|
77
79
|
}
|
|
@@ -115,6 +117,7 @@ export default class AnimatedTransform extends AnimatedWithChildren {
|
|
|
115
117
|
const node = nodes[ii];
|
|
116
118
|
node.__addChild(this);
|
|
117
119
|
}
|
|
120
|
+
super.__attach();
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
__detach(): void {
|
|
@@ -160,6 +163,7 @@ export default class AnimatedTransform extends AnimatedWithChildren {
|
|
|
160
163
|
return {
|
|
161
164
|
type: 'transform',
|
|
162
165
|
transforms: transformsConfig,
|
|
166
|
+
debugID: this.__getDebugID(),
|
|
163
167
|
};
|
|
164
168
|
}
|
|
165
169
|
}
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
|
|
13
12
|
import type Animation, {EndCallback} from '../animations/Animation';
|
|
14
13
|
import type {InterpolationConfigType} from './AnimatedInterpolation';
|
|
15
14
|
import type AnimatedNode from './AnimatedNode';
|
|
15
|
+
import type {AnimatedNodeConfig} from './AnimatedNode';
|
|
16
16
|
import type AnimatedTracking from './AnimatedTracking';
|
|
17
17
|
|
|
18
18
|
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
@@ -21,6 +21,7 @@ import AnimatedInterpolation from './AnimatedInterpolation';
|
|
|
21
21
|
import AnimatedWithChildren from './AnimatedWithChildren';
|
|
22
22
|
|
|
23
23
|
export type AnimatedValueConfig = $ReadOnly<{
|
|
24
|
+
...AnimatedNodeConfig,
|
|
24
25
|
useNativeDriver: boolean,
|
|
25
26
|
}>;
|
|
26
27
|
|
|
@@ -83,6 +84,8 @@ function _executeAsAnimatedBatch(id: string, operation: () => void) {
|
|
|
83
84
|
* See https://reactnative.dev/docs/animatedvalue
|
|
84
85
|
*/
|
|
85
86
|
export default class AnimatedValue extends AnimatedWithChildren {
|
|
87
|
+
#updateSubscription: ?EventSubscription = null;
|
|
88
|
+
|
|
86
89
|
_value: number;
|
|
87
90
|
_startingValue: number;
|
|
88
91
|
_offset: number;
|
|
@@ -90,7 +93,7 @@ export default class AnimatedValue extends AnimatedWithChildren {
|
|
|
90
93
|
_tracking: ?AnimatedTracking;
|
|
91
94
|
|
|
92
95
|
constructor(value: number, config?: ?AnimatedValueConfig) {
|
|
93
|
-
super();
|
|
96
|
+
super(config);
|
|
94
97
|
if (typeof value !== 'number') {
|
|
95
98
|
throw new Error('AnimatedValue: Attempting to set value to undefined');
|
|
96
99
|
}
|
|
@@ -102,8 +105,20 @@ export default class AnimatedValue extends AnimatedWithChildren {
|
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
|
|
108
|
+
__attach(): void {
|
|
106
109
|
if (this.__isNative) {
|
|
110
|
+
// NOTE: In theory, we should only need to call this when any listeners
|
|
111
|
+
// are added. However, there is a global `onUserDrivenAnimationEnded`
|
|
112
|
+
// listener that relies on `onAnimatedValueUpdate` having fired to update
|
|
113
|
+
// the values in JavaScript. If that listener is removed, this could be
|
|
114
|
+
// re-optimized.
|
|
115
|
+
this.#ensureUpdateSubscriptionExists();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
__detach(): void {
|
|
120
|
+
if (this.__isNative) {
|
|
121
|
+
this.#updateSubscription?.remove();
|
|
107
122
|
NativeAnimatedAPI.getValue(this.__getNativeTag(), value => {
|
|
108
123
|
this._value = value - this._offset;
|
|
109
124
|
});
|
|
@@ -116,6 +131,35 @@ export default class AnimatedValue extends AnimatedWithChildren {
|
|
|
116
131
|
return this._value + this._offset;
|
|
117
132
|
}
|
|
118
133
|
|
|
134
|
+
#ensureUpdateSubscriptionExists(): void {
|
|
135
|
+
if (this.#updateSubscription != null) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const nativeTag = this.__getNativeTag();
|
|
139
|
+
NativeAnimatedAPI.startListeningToAnimatedNodeValue(nativeTag);
|
|
140
|
+
const subscription: EventSubscription =
|
|
141
|
+
NativeAnimatedHelper.nativeEventEmitter.addListener(
|
|
142
|
+
'onAnimatedValueUpdate',
|
|
143
|
+
data => {
|
|
144
|
+
if (data.tag === nativeTag) {
|
|
145
|
+
this.__onAnimatedValueUpdateReceived(data.value);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
this.#updateSubscription = {
|
|
151
|
+
remove: () => {
|
|
152
|
+
// Only this function assigns to `this.#updateSubscription`.
|
|
153
|
+
if (this.#updateSubscription == null) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
this.#updateSubscription = null;
|
|
157
|
+
subscription.remove();
|
|
158
|
+
NativeAnimatedAPI.stopListeningToAnimatedNodeValue(nativeTag);
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
119
163
|
/**
|
|
120
164
|
* Directly set the value. This will stop any animations running on the value
|
|
121
165
|
* and update all the bound properties.
|
|
@@ -298,6 +342,7 @@ export default class AnimatedValue extends AnimatedWithChildren {
|
|
|
298
342
|
type: 'value',
|
|
299
343
|
value: this._value,
|
|
300
344
|
offset: this._offset,
|
|
345
|
+
debugID: this.__getDebugID(),
|
|
301
346
|
};
|
|
302
347
|
}
|
|
303
348
|
}
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
14
|
+
import type {AnimatedNodeConfig} from './AnimatedNode';
|
|
14
15
|
|
|
15
16
|
import AnimatedValue from './AnimatedValue';
|
|
16
17
|
import AnimatedWithChildren from './AnimatedWithChildren';
|
|
17
18
|
import invariant from 'invariant';
|
|
18
19
|
|
|
19
20
|
export type AnimatedValueXYConfig = $ReadOnly<{
|
|
21
|
+
...AnimatedNodeConfig,
|
|
20
22
|
useNativeDriver: boolean,
|
|
21
23
|
}>;
|
|
22
24
|
type ValueXYListenerCallback = (value: {x: number, y: number, ...}) => mixed;
|
|
@@ -49,7 +51,7 @@ export default class AnimatedValueXY extends AnimatedWithChildren {
|
|
|
49
51
|
},
|
|
50
52
|
config?: ?AnimatedValueXYConfig,
|
|
51
53
|
) {
|
|
52
|
-
super();
|
|
54
|
+
super(config);
|
|
53
55
|
const value: any = valueIn || {x: 0, y: 0}; // @flowfixme: shouldn't need `: any`
|
|
54
56
|
if (typeof value.x === 'number' && typeof value.y === 'number') {
|
|
55
57
|
this.x = new AnimatedValue(value.x);
|
|
@@ -17,9 +17,7 @@ import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNa
|
|
|
17
17
|
import {isPublicInstance as isFabricPublicInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils';
|
|
18
18
|
import useRefEffect from '../Utilities/useRefEffect';
|
|
19
19
|
import {AnimatedEvent} from './AnimatedEvent';
|
|
20
|
-
import AnimatedNode from './nodes/AnimatedNode';
|
|
21
20
|
import AnimatedProps from './nodes/AnimatedProps';
|
|
22
|
-
import AnimatedValue from './nodes/AnimatedValue';
|
|
23
21
|
import {
|
|
24
22
|
useCallback,
|
|
25
23
|
useEffect,
|
|
@@ -39,11 +37,6 @@ type CallbackRef<T> = T => mixed;
|
|
|
39
37
|
|
|
40
38
|
type UpdateCallback = () => void;
|
|
41
39
|
|
|
42
|
-
type AnimatedValueListeners = Array<{
|
|
43
|
-
propValue: AnimatedValue,
|
|
44
|
-
listenerId: string,
|
|
45
|
-
}>;
|
|
46
|
-
|
|
47
40
|
const useMemoOrAnimatedPropsMemo =
|
|
48
41
|
ReactNativeFeatureFlags.enableAnimatedPropsMemo()
|
|
49
42
|
? useAnimatedPropsMemo
|
|
@@ -169,7 +162,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
|
|
|
169
162
|
|
|
170
163
|
const target = getEventTarget(instance);
|
|
171
164
|
const events = [];
|
|
172
|
-
const animatedValueListeners: AnimatedValueListeners = [];
|
|
173
165
|
|
|
174
166
|
for (const propName in props) {
|
|
175
167
|
// $FlowFixMe[invalid-computed-prop]
|
|
@@ -177,8 +169,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
|
|
|
177
169
|
if (propValue instanceof AnimatedEvent && propValue.__isNative) {
|
|
178
170
|
propValue.__attach(target, propName);
|
|
179
171
|
events.push([propName, propValue]);
|
|
180
|
-
// $FlowFixMe[incompatible-call] - the `addListenersToPropsValue` drills down the propValue.
|
|
181
|
-
addListenersToPropsValue(propValue, animatedValueListeners);
|
|
182
172
|
}
|
|
183
173
|
}
|
|
184
174
|
|
|
@@ -188,10 +178,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
|
|
|
188
178
|
for (const [propName, propValue] of events) {
|
|
189
179
|
propValue.__detach(target, propName);
|
|
190
180
|
}
|
|
191
|
-
|
|
192
|
-
for (const {propValue, listenerId} of animatedValueListeners) {
|
|
193
|
-
propValue.removeListener(listenerId);
|
|
194
|
-
}
|
|
195
181
|
};
|
|
196
182
|
},
|
|
197
183
|
[node, useNativePropsInFabric, props],
|
|
@@ -215,35 +201,6 @@ function reduceAnimatedProps<TProps>(
|
|
|
215
201
|
};
|
|
216
202
|
}
|
|
217
203
|
|
|
218
|
-
function addListenersToPropsValue(
|
|
219
|
-
propValue: AnimatedValue,
|
|
220
|
-
accumulator: AnimatedValueListeners,
|
|
221
|
-
) {
|
|
222
|
-
// propValue can be a scalar value, an array or an object.
|
|
223
|
-
if (propValue instanceof AnimatedValue) {
|
|
224
|
-
const listenerId = propValue.addListener(() => {});
|
|
225
|
-
accumulator.push({propValue, listenerId});
|
|
226
|
-
} else if (Array.isArray(propValue)) {
|
|
227
|
-
// An array can be an array of scalar values, arrays of arrays, or arrays of objects
|
|
228
|
-
for (const prop of propValue) {
|
|
229
|
-
addListenersToPropsValue(prop, accumulator);
|
|
230
|
-
}
|
|
231
|
-
} else if (propValue instanceof Object) {
|
|
232
|
-
addAnimatedValuesListenersToProps(propValue, accumulator);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function addAnimatedValuesListenersToProps(
|
|
237
|
-
props: AnimatedNode,
|
|
238
|
-
accumulator: AnimatedValueListeners,
|
|
239
|
-
) {
|
|
240
|
-
for (const propName in props) {
|
|
241
|
-
// $FlowFixMe[prop-missing] - This is an object contained in a prop, but we don't know the exact type.
|
|
242
|
-
const propValue = props[propName];
|
|
243
|
-
addListenersToPropsValue(propValue, accumulator);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
204
|
/**
|
|
248
205
|
* Manages the lifecycle of the supplied `AnimatedProps` by invoking `__attach`
|
|
249
206
|
* and `__detach`. However, this is more complicated because `AnimatedProps`
|
|
@@ -105,7 +105,7 @@ export interface DrawerLayoutAndroidProps extends ViewProps {
|
|
|
105
105
|
* The navigation view that will be rendered to the side of the
|
|
106
106
|
* screen and can be pulled in.
|
|
107
107
|
*/
|
|
108
|
-
renderNavigationView: () => JSX.Element;
|
|
108
|
+
renderNavigationView: () => React.JSX.Element;
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Make the drawer take the entire screen and draw the background of
|
|
@@ -10,5 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
// $FlowFixMe[cannot-resolve-module]
|
|
14
|
+
import typeof DrawerLayoutAndroid from './DrawerLayoutAndroid.android';
|
|
15
|
+
|
|
13
16
|
module.exports =
|
|
14
|
-
require('../UnimplementedViews/UnimplementedView') as $FlowFixMe;
|
|
17
|
+
require('../UnimplementedViews/UnimplementedView') as $FlowFixMe as DrawerLayoutAndroid;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type * as React from 'react';
|
|
11
|
+
|
|
12
|
+
type LayoutConformanceProps = {
|
|
13
|
+
/**
|
|
14
|
+
* strict: Layout in accordance with W3C spec, even when breaking
|
|
15
|
+
* compatibility: Layout with the same behavior as previous versions of React Native
|
|
16
|
+
*/
|
|
17
|
+
mode: 'strict' | 'compatibility';
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const experimental_LayoutConformance: React.ComponentType<LayoutConformanceProps>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
13
|
+
import LayoutConformanceNativeComponent from './LayoutConformanceNativeComponent';
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
|
|
16
|
+
type Props = $ReadOnly<{
|
|
17
|
+
/**
|
|
18
|
+
* strict: Layout in accordance with W3C spec, even when breaking
|
|
19
|
+
* compatibility: Layout with the same behavior as previous versions of React Native
|
|
20
|
+
*/
|
|
21
|
+
mode: 'strict' | 'compatibility',
|
|
22
|
+
|
|
23
|
+
children: React.Node,
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
// We want a graceful fallback for apps using legacy arch, but need to know
|
|
27
|
+
// ahead of time whether the component is available, so we test for global.
|
|
28
|
+
// This does not correctly handle mixed arch apps (which is okay, since we just
|
|
29
|
+
// degrade the error experience).
|
|
30
|
+
const isFabricUIManagerInstalled = global?.nativeFabricUIManager != null;
|
|
31
|
+
|
|
32
|
+
function LayoutConformance(props: Props): React.Node {
|
|
33
|
+
return (
|
|
34
|
+
<LayoutConformanceNativeComponent {...props} style={styles.container} />
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function UnimplementedLayoutConformance(props: Props): React.Node {
|
|
39
|
+
if (__DEV__) {
|
|
40
|
+
const warnOnce = require('../../Utilities/warnOnce');
|
|
41
|
+
|
|
42
|
+
warnOnce(
|
|
43
|
+
'layoutconformance-unsupported',
|
|
44
|
+
'"LayoutConformance" is only supported in the New Architecture',
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return props.children;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default (isFabricUIManagerInstalled
|
|
52
|
+
? LayoutConformance
|
|
53
|
+
: UnimplementedLayoutConformance) as component(...Props);
|
|
54
|
+
|
|
55
|
+
const styles = StyleSheet.create({
|
|
56
|
+
container: {
|
|
57
|
+
display: 'contents',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
|
12
|
+
import type {ViewProps} from '../View/ViewPropTypes';
|
|
13
|
+
|
|
14
|
+
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
|
|
15
|
+
|
|
16
|
+
type Props = $ReadOnly<{
|
|
17
|
+
mode: 'strict' | 'compatibility',
|
|
18
|
+
...ViewProps,
|
|
19
|
+
}>;
|
|
20
|
+
|
|
21
|
+
const LayoutConformanceNativeComponent: HostComponent<Props> =
|
|
22
|
+
NativeComponentRegistry.get<Props>('LayoutConformance', () => ({
|
|
23
|
+
uiViewClassName: 'LayoutConformance',
|
|
24
|
+
validAttributes: {
|
|
25
|
+
mode: true,
|
|
26
|
+
},
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
export default LayoutConformanceNativeComponent;
|