@office-iss/react-native-win32 0.75.2 → 0.76.0-preview.2
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 +191 -47
- package/CHANGELOG.md +63 -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/Keyboard/KeyboardAvoidingView.js +17 -0
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +131 -169
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +3 -0
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +10 -0
- 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 +23 -1
- 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/setUpDeveloperTools.js +5 -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 +9 -1
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +17 -1
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +17 -1
- 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 +12 -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 +152 -2
- package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
- package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
- package/Libraries/StyleSheet/processBoxShadow.js +209 -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 +8 -6
- 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 +32 -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 +29 -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 +12 -98
- 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
|
@@ -0,0 +1,438 @@
|
|
|
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 {EventSubscription} from '../../../Libraries/vendor/emitter/EventEmitter';
|
|
12
|
+
import type {EventConfig} from '../../../Libraries/Animated/AnimatedEvent';
|
|
13
|
+
import type {
|
|
14
|
+
AnimationConfig,
|
|
15
|
+
EndCallback,
|
|
16
|
+
} from '../../../Libraries/Animated/animations/Animation';
|
|
17
|
+
import type {
|
|
18
|
+
AnimatedNodeConfig,
|
|
19
|
+
EventMapping,
|
|
20
|
+
} from '../../../Libraries/Animated/NativeAnimatedModule';
|
|
21
|
+
|
|
22
|
+
import * as ReactNativeFeatureFlags from '../featureflags/ReactNativeFeatureFlags';
|
|
23
|
+
import NativeEventEmitter from '../../../Libraries/EventEmitter/NativeEventEmitter';
|
|
24
|
+
import RCTDeviceEventEmitter from '../../../Libraries/EventEmitter/RCTDeviceEventEmitter';
|
|
25
|
+
import Platform from '../../../Libraries/Utilities/Platform';
|
|
26
|
+
import NativeAnimatedNonTurboModule from '../../../Libraries/Animated/NativeAnimatedModule';
|
|
27
|
+
import NativeAnimatedTurboModule from '../../../Libraries/Animated/NativeAnimatedTurboModule';
|
|
28
|
+
import invariant from 'invariant';
|
|
29
|
+
import nullthrows from 'nullthrows';
|
|
30
|
+
|
|
31
|
+
// TODO T69437152 @petetheheat - Delete this fork when Fabric ships to 100%.
|
|
32
|
+
const NativeAnimatedModule: typeof NativeAnimatedTurboModule =
|
|
33
|
+
NativeAnimatedNonTurboModule ?? NativeAnimatedTurboModule;
|
|
34
|
+
|
|
35
|
+
let __nativeAnimatedNodeTagCount = 1; /* used for animated nodes */
|
|
36
|
+
let __nativeAnimationIdCount = 1; /* used for started animations */
|
|
37
|
+
|
|
38
|
+
let nativeEventEmitter;
|
|
39
|
+
|
|
40
|
+
let waitingForQueuedOperations = new Set<string>();
|
|
41
|
+
let queueOperations = false;
|
|
42
|
+
let queue: Array<() => void> = [];
|
|
43
|
+
let singleOpQueue: Array<mixed> = [];
|
|
44
|
+
|
|
45
|
+
const isSingleOpBatching =
|
|
46
|
+
Platform.OS === 'android' &&
|
|
47
|
+
NativeAnimatedModule?.queueAndExecuteBatchedOperations != null &&
|
|
48
|
+
ReactNativeFeatureFlags.animatedShouldUseSingleOp();
|
|
49
|
+
let flushQueueTimeout = null;
|
|
50
|
+
|
|
51
|
+
const eventListenerGetValueCallbacks: {
|
|
52
|
+
[number]: (value: number) => void,
|
|
53
|
+
} = {};
|
|
54
|
+
const eventListenerAnimationFinishedCallbacks: {
|
|
55
|
+
[number]: EndCallback,
|
|
56
|
+
} = {};
|
|
57
|
+
let globalEventEmitterGetValueListener: ?EventSubscription = null;
|
|
58
|
+
let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null;
|
|
59
|
+
|
|
60
|
+
function createNativeOperations(): $NonMaybeType<typeof NativeAnimatedModule> {
|
|
61
|
+
const methodNames = [
|
|
62
|
+
'createAnimatedNode', // 1
|
|
63
|
+
'updateAnimatedNodeConfig', // 2
|
|
64
|
+
'getValue', // 3
|
|
65
|
+
'startListeningToAnimatedNodeValue', // 4
|
|
66
|
+
'stopListeningToAnimatedNodeValue', // 5
|
|
67
|
+
'connectAnimatedNodes', // 6
|
|
68
|
+
'disconnectAnimatedNodes', // 7
|
|
69
|
+
'startAnimatingNode', // 8
|
|
70
|
+
'stopAnimation', // 9
|
|
71
|
+
'setAnimatedNodeValue', // 10
|
|
72
|
+
'setAnimatedNodeOffset', // 11
|
|
73
|
+
'flattenAnimatedNodeOffset', // 12
|
|
74
|
+
'extractAnimatedNodeOffset', // 13
|
|
75
|
+
'connectAnimatedNodeToView', // 14
|
|
76
|
+
'disconnectAnimatedNodeFromView', // 15
|
|
77
|
+
'restoreDefaultValues', // 16
|
|
78
|
+
'dropAnimatedNode', // 17
|
|
79
|
+
'addAnimatedEventToView', // 18
|
|
80
|
+
'removeAnimatedEventFromView', // 19
|
|
81
|
+
'addListener', // 20
|
|
82
|
+
'removeListener', // 21
|
|
83
|
+
];
|
|
84
|
+
const nativeOperations: {
|
|
85
|
+
[$Values<typeof methodNames>]: (...$ReadOnlyArray<mixed>) => void,
|
|
86
|
+
} = {};
|
|
87
|
+
if (isSingleOpBatching) {
|
|
88
|
+
for (let ii = 0, length = methodNames.length; ii < length; ii++) {
|
|
89
|
+
const methodName = methodNames[ii];
|
|
90
|
+
const operationID = ii + 1;
|
|
91
|
+
nativeOperations[methodName] = (...args) => {
|
|
92
|
+
// `singleOpQueue` is a flat array of operation IDs and arguments, which
|
|
93
|
+
// is possible because # arguments is fixed for each operation. For more
|
|
94
|
+
// details, see `NativeAnimatedModule.queueAndExecuteBatchedOperations`.
|
|
95
|
+
singleOpQueue.push(operationID, ...args);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
for (let ii = 0, length = methodNames.length; ii < length; ii++) {
|
|
100
|
+
const methodName = methodNames[ii];
|
|
101
|
+
nativeOperations[methodName] = (...args) => {
|
|
102
|
+
const method = nullthrows(NativeAnimatedModule)[methodName];
|
|
103
|
+
// If queueing is explicitly on, *or* the queue has not yet
|
|
104
|
+
// been flushed, use the queue. This is to prevent operations
|
|
105
|
+
// from being executed out of order.
|
|
106
|
+
if (queueOperations || queue.length !== 0) {
|
|
107
|
+
// $FlowExpectedError[incompatible-call] - Dynamism.
|
|
108
|
+
queue.push(() => method(...args));
|
|
109
|
+
} else {
|
|
110
|
+
// $FlowExpectedError[incompatible-call] - Dynamism.
|
|
111
|
+
method(...args);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// $FlowExpectedError[incompatible-return] - Dynamism.
|
|
117
|
+
return nativeOperations;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const NativeOperations = createNativeOperations();
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Wrappers around NativeAnimatedModule to provide flow and autocomplete support for
|
|
124
|
+
* the native module methods, and automatic queue management on Android
|
|
125
|
+
*/
|
|
126
|
+
const API = {
|
|
127
|
+
getValue: (isSingleOpBatching
|
|
128
|
+
? (tag, saveValueCallback) => {
|
|
129
|
+
if (saveValueCallback) {
|
|
130
|
+
eventListenerGetValueCallbacks[tag] = saveValueCallback;
|
|
131
|
+
}
|
|
132
|
+
/* $FlowExpectedError[incompatible-call] - `saveValueCallback` is handled
|
|
133
|
+
differently when `isSingleOpBatching` is enabled. */
|
|
134
|
+
NativeOperations.getValue(tag);
|
|
135
|
+
}
|
|
136
|
+
: (tag, saveValueCallback) => {
|
|
137
|
+
NativeOperations.getValue(tag, saveValueCallback);
|
|
138
|
+
}) as $NonMaybeType<typeof NativeAnimatedModule>['getValue'],
|
|
139
|
+
|
|
140
|
+
setWaitingForIdentifier(id: string): void {
|
|
141
|
+
waitingForQueuedOperations.add(id);
|
|
142
|
+
queueOperations = true;
|
|
143
|
+
if (
|
|
144
|
+
ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush() &&
|
|
145
|
+
flushQueueTimeout
|
|
146
|
+
) {
|
|
147
|
+
clearTimeout(flushQueueTimeout);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
unsetWaitingForIdentifier(id: string): void {
|
|
152
|
+
waitingForQueuedOperations.delete(id);
|
|
153
|
+
|
|
154
|
+
if (waitingForQueuedOperations.size === 0) {
|
|
155
|
+
queueOperations = false;
|
|
156
|
+
API.disableQueue();
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
disableQueue(): void {
|
|
161
|
+
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
|
162
|
+
|
|
163
|
+
if (ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush()) {
|
|
164
|
+
const prevTimeout = flushQueueTimeout;
|
|
165
|
+
clearImmediate(prevTimeout);
|
|
166
|
+
flushQueueTimeout = setImmediate(API.flushQueue);
|
|
167
|
+
} else {
|
|
168
|
+
API.flushQueue();
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
flushQueue: (isSingleOpBatching
|
|
173
|
+
? (): void => {
|
|
174
|
+
// TODO: (T136971132)
|
|
175
|
+
invariant(
|
|
176
|
+
NativeAnimatedModule || process.env.NODE_ENV === 'test',
|
|
177
|
+
'Native animated module is not available',
|
|
178
|
+
);
|
|
179
|
+
flushQueueTimeout = null;
|
|
180
|
+
|
|
181
|
+
if (singleOpQueue.length === 0) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Set up event listener for callbacks if it's not set up
|
|
186
|
+
ensureGlobalEventEmitterListeners();
|
|
187
|
+
|
|
188
|
+
// Single op batching doesn't use callback functions, instead we
|
|
189
|
+
// use RCTDeviceEventEmitter. This reduces overhead of sending lots of
|
|
190
|
+
// JSI functions across to native code; but also, TM infrastructure currently
|
|
191
|
+
// does not support packing a function into native arrays.
|
|
192
|
+
NativeAnimatedModule?.queueAndExecuteBatchedOperations?.(singleOpQueue);
|
|
193
|
+
singleOpQueue.length = 0;
|
|
194
|
+
}
|
|
195
|
+
: (): void => {
|
|
196
|
+
// TODO: (T136971132)
|
|
197
|
+
invariant(
|
|
198
|
+
NativeAnimatedModule || process.env.NODE_ENV === 'test',
|
|
199
|
+
'Native animated module is not available',
|
|
200
|
+
);
|
|
201
|
+
flushQueueTimeout = null;
|
|
202
|
+
|
|
203
|
+
if (queue.length === 0) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (Platform.OS === 'android') {
|
|
208
|
+
NativeAnimatedModule?.startOperationBatch?.();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
for (let q = 0, l = queue.length; q < l; q++) {
|
|
212
|
+
queue[q]();
|
|
213
|
+
}
|
|
214
|
+
queue.length = 0;
|
|
215
|
+
|
|
216
|
+
if (Platform.OS === 'android') {
|
|
217
|
+
NativeAnimatedModule?.finishOperationBatch?.();
|
|
218
|
+
}
|
|
219
|
+
}) as () => void,
|
|
220
|
+
|
|
221
|
+
createAnimatedNode(tag: number, config: AnimatedNodeConfig): void {
|
|
222
|
+
NativeOperations.createAnimatedNode(tag, config);
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
updateAnimatedNodeConfig(tag: number, config: AnimatedNodeConfig): void {
|
|
226
|
+
NativeOperations.updateAnimatedNodeConfig?.(tag, config);
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
startListeningToAnimatedNodeValue(tag: number): void {
|
|
230
|
+
NativeOperations.startListeningToAnimatedNodeValue(tag);
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
stopListeningToAnimatedNodeValue(tag: number): void {
|
|
234
|
+
NativeOperations.stopListeningToAnimatedNodeValue(tag);
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
connectAnimatedNodes(parentTag: number, childTag: number): void {
|
|
238
|
+
NativeOperations.connectAnimatedNodes(parentTag, childTag);
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
disconnectAnimatedNodes(parentTag: number, childTag: number): void {
|
|
242
|
+
NativeOperations.disconnectAnimatedNodes(parentTag, childTag);
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
startAnimatingNode: (isSingleOpBatching
|
|
246
|
+
? (animationId, nodeTag, config, endCallback) => {
|
|
247
|
+
if (endCallback) {
|
|
248
|
+
eventListenerAnimationFinishedCallbacks[animationId] = endCallback;
|
|
249
|
+
}
|
|
250
|
+
/* $FlowExpectedError[incompatible-call] - `endCallback` is handled
|
|
251
|
+
differently when `isSingleOpBatching` is enabled. */
|
|
252
|
+
NativeOperations.startAnimatingNode(animationId, nodeTag, config);
|
|
253
|
+
}
|
|
254
|
+
: (animationId, nodeTag, config, endCallback) => {
|
|
255
|
+
NativeOperations.startAnimatingNode(
|
|
256
|
+
animationId,
|
|
257
|
+
nodeTag,
|
|
258
|
+
config,
|
|
259
|
+
endCallback,
|
|
260
|
+
);
|
|
261
|
+
}) as $NonMaybeType<typeof NativeAnimatedModule>['startAnimatingNode'],
|
|
262
|
+
|
|
263
|
+
stopAnimation(animationId: number) {
|
|
264
|
+
NativeOperations.stopAnimation(animationId);
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
setAnimatedNodeValue(nodeTag: number, value: number): void {
|
|
268
|
+
NativeOperations.setAnimatedNodeValue(nodeTag, value);
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
setAnimatedNodeOffset(nodeTag: number, offset: number): void {
|
|
272
|
+
NativeOperations.setAnimatedNodeOffset(nodeTag, offset);
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
flattenAnimatedNodeOffset(nodeTag: number): void {
|
|
276
|
+
NativeOperations.flattenAnimatedNodeOffset(nodeTag);
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
extractAnimatedNodeOffset(nodeTag: number): void {
|
|
280
|
+
NativeOperations.extractAnimatedNodeOffset(nodeTag);
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
connectAnimatedNodeToView(nodeTag: number, viewTag: number): void {
|
|
284
|
+
NativeOperations.connectAnimatedNodeToView(nodeTag, viewTag);
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
disconnectAnimatedNodeFromView(nodeTag: number, viewTag: number): void {
|
|
288
|
+
NativeOperations.disconnectAnimatedNodeFromView(nodeTag, viewTag);
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
restoreDefaultValues(nodeTag: number): void {
|
|
292
|
+
NativeOperations.restoreDefaultValues?.(nodeTag);
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
dropAnimatedNode(tag: number): void {
|
|
296
|
+
NativeOperations.dropAnimatedNode(tag);
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
addAnimatedEventToView(
|
|
300
|
+
viewTag: number,
|
|
301
|
+
eventName: string,
|
|
302
|
+
eventMapping: EventMapping,
|
|
303
|
+
) {
|
|
304
|
+
NativeOperations.addAnimatedEventToView(viewTag, eventName, eventMapping);
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
removeAnimatedEventFromView(
|
|
308
|
+
viewTag: number,
|
|
309
|
+
eventName: string,
|
|
310
|
+
animatedNodeTag: number,
|
|
311
|
+
) {
|
|
312
|
+
NativeOperations.removeAnimatedEventFromView(
|
|
313
|
+
viewTag,
|
|
314
|
+
eventName,
|
|
315
|
+
animatedNodeTag,
|
|
316
|
+
);
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
function ensureGlobalEventEmitterListeners() {
|
|
321
|
+
if (
|
|
322
|
+
globalEventEmitterGetValueListener &&
|
|
323
|
+
globalEventEmitterAnimationFinishedListener
|
|
324
|
+
) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
globalEventEmitterGetValueListener = RCTDeviceEventEmitter.addListener(
|
|
328
|
+
'onNativeAnimatedModuleGetValue',
|
|
329
|
+
params => {
|
|
330
|
+
const {tag} = params;
|
|
331
|
+
const callback = eventListenerGetValueCallbacks[tag];
|
|
332
|
+
if (!callback) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
callback(params.value);
|
|
336
|
+
delete eventListenerGetValueCallbacks[tag];
|
|
337
|
+
},
|
|
338
|
+
);
|
|
339
|
+
globalEventEmitterAnimationFinishedListener =
|
|
340
|
+
RCTDeviceEventEmitter.addListener(
|
|
341
|
+
'onNativeAnimatedModuleAnimationFinished',
|
|
342
|
+
params => {
|
|
343
|
+
// TODO: remove Array.isArray once native changes have propagated
|
|
344
|
+
const animations = Array.isArray(params) ? params : [params];
|
|
345
|
+
for (const animation of animations) {
|
|
346
|
+
const {animationId} = animation;
|
|
347
|
+
const callback = eventListenerAnimationFinishedCallbacks[animationId];
|
|
348
|
+
if (callback) {
|
|
349
|
+
callback(animation);
|
|
350
|
+
delete eventListenerAnimationFinishedCallbacks[animationId];
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function generateNewNodeTag(): number {
|
|
358
|
+
return __nativeAnimatedNodeTagCount++;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function generateNewAnimationId(): number {
|
|
362
|
+
return __nativeAnimationIdCount++;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function assertNativeAnimatedModule(): void {
|
|
366
|
+
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
let _warnedMissingNativeAnimated = false;
|
|
370
|
+
|
|
371
|
+
function shouldUseNativeDriver(
|
|
372
|
+
config: $ReadOnly<{...AnimationConfig, ...}> | EventConfig,
|
|
373
|
+
): boolean {
|
|
374
|
+
if (config.useNativeDriver == null) {
|
|
375
|
+
console.warn(
|
|
376
|
+
'Animated: `useNativeDriver` was not specified. This is a required ' +
|
|
377
|
+
'option and must be explicitly set to `true` or `false`',
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (config.useNativeDriver === true && !NativeAnimatedModule) {
|
|
382
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
383
|
+
if (!_warnedMissingNativeAnimated) {
|
|
384
|
+
console.warn(
|
|
385
|
+
'Animated: `useNativeDriver` is not supported because the native ' +
|
|
386
|
+
'animated module is missing. Falling back to JS-based animation. To ' +
|
|
387
|
+
'resolve this, add `RCTAnimation` module to this app, or remove ' +
|
|
388
|
+
'`useNativeDriver`. ' +
|
|
389
|
+
'Make sure to run `bundle exec pod install` first. Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md',
|
|
390
|
+
);
|
|
391
|
+
_warnedMissingNativeAnimated = true;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return config.useNativeDriver || false;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function transformDataType(value: number | string): number | string {
|
|
401
|
+
// Change the string type to number type so we can reuse the same logic in
|
|
402
|
+
// iOS and Android platform
|
|
403
|
+
if (typeof value !== 'string') {
|
|
404
|
+
return value;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Normalize degrees and radians to a number expressed in radians
|
|
408
|
+
if (value.endsWith('deg')) {
|
|
409
|
+
const degrees = parseFloat(value) || 0;
|
|
410
|
+
return (degrees * Math.PI) / 180.0;
|
|
411
|
+
} else if (value.endsWith('rad')) {
|
|
412
|
+
return parseFloat(value) || 0;
|
|
413
|
+
} else {
|
|
414
|
+
return value;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export default {
|
|
419
|
+
API,
|
|
420
|
+
generateNewNodeTag,
|
|
421
|
+
generateNewAnimationId,
|
|
422
|
+
assertNativeAnimatedModule,
|
|
423
|
+
shouldUseNativeDriver,
|
|
424
|
+
transformDataType,
|
|
425
|
+
// $FlowExpectedError[unsafe-getters-setters] - unsafe getter lint suppression
|
|
426
|
+
// $FlowExpectedError[missing-type-arg] - unsafe getter lint suppression
|
|
427
|
+
get nativeEventEmitter(): NativeEventEmitter {
|
|
428
|
+
if (!nativeEventEmitter) {
|
|
429
|
+
// $FlowFixMe[underconstrained-implicit-instantiation]
|
|
430
|
+
nativeEventEmitter = new NativeEventEmitter(
|
|
431
|
+
// T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
|
|
432
|
+
// If you want to use the native module on other platforms, please remove this condition and test its behavior
|
|
433
|
+
Platform.OS !== 'ios' ? null : NativeAnimatedModule,
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
return nativeEventEmitter;
|
|
437
|
+
},
|
|
438
|
+
};
|