@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.
Files changed (174) hide show
  1. package/.eslintrc.js +11 -0
  2. package/.flowconfig +5 -4
  3. package/CHANGELOG.json +164 -47
  4. package/CHANGELOG.md +53 -28
  5. package/Libraries/Alert/Alert.js +3 -0
  6. package/Libraries/Animated/AnimatedEvent.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +7 -7
  8. package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
  9. package/Libraries/Animated/animations/Animation.js +11 -1
  10. package/Libraries/Animated/animations/DecayAnimation.js +1 -1
  11. package/Libraries/Animated/animations/SpringAnimation.js +1 -1
  12. package/Libraries/Animated/animations/TimingAnimation.js +2 -1
  13. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  14. package/Libraries/Animated/createAnimatedComponent.js +10 -9
  15. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  16. package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
  17. package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
  18. package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
  19. package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
  20. package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
  21. package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
  22. package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
  23. package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
  24. package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
  25. package/Libraries/Animated/useAnimatedProps.js +142 -7
  26. package/Libraries/BatchedBridge/NativeModules.js +2 -0
  27. package/Libraries/Blob/FileReader.js +1 -1
  28. package/Libraries/Blob/URL.js +2 -62
  29. package/Libraries/Blob/URLSearchParams.js +71 -0
  30. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
  31. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
  32. package/Libraries/Components/ScrollView/ScrollView.js +131 -169
  33. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  34. package/Libraries/Components/StatusBar/StatusBar.js +3 -1
  35. package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
  36. package/Libraries/Components/TextInput/TextInput.js +230 -94
  37. package/Libraries/Components/TextInput/TextInput.win32.js +230 -100
  38. package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
  39. package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
  40. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +2 -0
  41. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  42. package/Libraries/Components/View/ViewNativeComponent.js +0 -1
  43. package/Libraries/Components/View/ViewPropTypes.js +14 -0
  44. package/Libraries/Components/View/ViewPropTypes.win32.js +14 -0
  45. package/Libraries/Core/ExceptionsManager.js +2 -0
  46. package/Libraries/Core/InitializeCore.js +3 -1
  47. package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
  48. package/Libraries/Core/ReactNativeVersion.js +4 -4
  49. package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -1
  50. package/Libraries/Core/setUpErrorHandling.js +7 -1
  51. package/Libraries/Core/setUpGlobals.js +1 -0
  52. package/Libraries/Core/setUpReactRefresh.js +0 -4
  53. package/Libraries/Image/AssetSourceResolver.js +28 -1
  54. package/Libraries/Image/Image.android.js +9 -14
  55. package/Libraries/Image/Image.ios.js +11 -22
  56. package/Libraries/Image/Image.win32.js +11 -24
  57. package/Libraries/Image/ImageBackground.js +1 -8
  58. package/Libraries/Image/ImageUtils.js +9 -9
  59. package/Libraries/Image/ImageViewNativeComponent.js +1 -0
  60. package/Libraries/Inspector/Inspector.js +3 -2
  61. package/Libraries/Inspector/Inspector.win32.js +3 -2
  62. package/Libraries/Inspector/InspectorPanel.js +16 -10
  63. package/Libraries/Inspector/NetworkOverlay.js +1 -1
  64. package/Libraries/Interaction/TaskQueue.js +1 -0
  65. package/Libraries/Lists/FlatList.js +1 -1
  66. package/Libraries/Lists/SectionList.js +2 -2
  67. package/Libraries/Lists/SectionListModern.js +3 -3
  68. package/Libraries/LogBox/Data/LogBoxData.js +24 -3
  69. package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
  70. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
  71. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +9 -29
  72. package/Libraries/Modal/Modal.js +0 -1
  73. package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
  74. package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
  75. package/Libraries/NativeComponent/BaseViewConfig.win32.js +7 -0
  76. package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
  77. package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
  78. package/Libraries/Network/XMLHttpRequest.js +4 -2
  79. package/Libraries/ReactNative/AppContainer-dev.js +1 -5
  80. package/Libraries/ReactNative/AppContainer-prod.js +1 -5
  81. package/Libraries/ReactNative/AppContainer.js +0 -1
  82. package/Libraries/ReactNative/AppRegistry.js +0 -6
  83. package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
  84. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
  85. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
  86. package/Libraries/ReactNative/RendererImplementation.js +26 -4
  87. package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
  88. package/Libraries/ReactNative/renderApplication.js +0 -2
  89. package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
  90. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  91. package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
  92. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +57 -0
  93. package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
  94. package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
  95. package/Libraries/StyleSheet/processBoxShadow.js +211 -0
  96. package/Libraries/StyleSheet/processFilter.js +231 -42
  97. package/Libraries/Text/Text.js +394 -196
  98. package/Libraries/Text/Text.win32.js +442 -229
  99. package/Libraries/Text/TextNativeComponent.js +2 -1
  100. package/Libraries/Text/TextNativeComponent.win32.js +1 -1
  101. package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
  102. package/Libraries/Types/CodegenTypes.js +3 -1
  103. package/Libraries/Utilities/Appearance.js +108 -84
  104. package/Libraries/Utilities/DevLoadingView.js +2 -4
  105. package/Libraries/Utilities/HMRClient.js +2 -1
  106. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  107. package/Libraries/Utilities/createPerformanceLogger.js +0 -9
  108. package/Libraries/Utilities/stringifyViewConfig.js +22 -0
  109. package/Libraries/Utilities/useColorScheme.js +3 -3
  110. package/Libraries/WebSocket/WebSocket.js +1 -1
  111. package/Libraries/promiseRejectionTrackingOptions.js +1 -1
  112. package/Libraries/vendor/emitter/EventEmitter.js +6 -5
  113. package/flow/jest.js +2 -2
  114. package/index.js +3 -1
  115. package/index.win32.js +3 -1
  116. package/jest/mockComponent.js +4 -1
  117. package/jest/mockModal.js +1 -3
  118. package/jest/mockScrollView.js +1 -1
  119. package/jest/renderer.js +2 -2
  120. package/jest/setup.js +16 -13
  121. package/jest.config.js +1 -2
  122. package/overrides.json +22 -22
  123. package/package.json +30 -30
  124. package/src/private/animated/NativeAnimatedHelper.js +438 -0
  125. package/src/private/animated/NativeAnimatedHelper.win32.js +440 -0
  126. package/src/private/animated/NativeAnimatedValidation.js +64 -0
  127. package/src/private/components/HScrollViewNativeComponents.js +56 -0
  128. package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
  129. package/src/private/components/VScrollViewNativeComponents.js +48 -0
  130. package/src/private/components/useSyncOnScroll.js +48 -0
  131. package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
  132. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
  133. package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
  134. package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
  135. package/src/private/setup/setUpDOM.js +28 -0
  136. package/src/private/setup/setUpIntersectionObserver.js +27 -0
  137. package/src/private/setup/setUpMutationObserver.js +26 -0
  138. package/src/private/setup/setUpPerformanceObserver.js +64 -0
  139. package/src/private/specs/modules/NativeAppearance.js +3 -3
  140. package/src/private/specs/modules/NativeLinkingManager.js +1 -1
  141. package/src/private/specs/modules/NativePlatformConstantsWin.js +7 -0
  142. package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
  143. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
  144. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
  145. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
  146. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
  147. package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
  148. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
  149. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
  150. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
  151. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
  152. package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
  153. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
  154. package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
  155. package/src/private/webapis/performance/LongTasks.js +39 -0
  156. package/src/private/webapis/performance/Performance.js +22 -9
  157. package/src/private/webapis/performance/PerformanceEntry.js +36 -18
  158. package/src/private/webapis/performance/PerformanceObserver.js +29 -43
  159. package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
  160. package/src/private/webapis/performance/UserTiming.js +17 -12
  161. package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
  162. package/src-win/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  163. package/types/experimental.d.ts +20 -1
  164. package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
  165. package/Libraries/Animated/NativeAnimatedHelper.win32.js +0 -617
  166. package/Libraries/Core/setUpIntersectionObserver.js +0 -16
  167. package/Libraries/Core/setUpMutationObserver.js +0 -16
  168. package/Libraries/Core/setUpPerformanceObserver.js +0 -18
  169. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
  170. package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
  171. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
  172. package/src/private/core/setUpDOM.js +0 -18
  173. package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
  174. /package/src/private/{core → styles}/composeStyles.js +0 -0
@@ -1,617 +0,0 @@
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 '../vendor/emitter/EventEmitter';
12
- import type {EventConfig} from './AnimatedEvent';
13
- import type {AnimationConfig, EndCallback} from './animations/Animation';
14
- import type {
15
- AnimatedNodeConfig,
16
- AnimatingNodeConfig,
17
- EventMapping,
18
- } from './NativeAnimatedModule';
19
- import type {InterpolationConfigType} from './nodes/AnimatedInterpolation';
20
-
21
- import NativeEventEmitter from '../EventEmitter/NativeEventEmitter';
22
- import RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
23
- import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
24
- import Platform from '../Utilities/Platform';
25
- import NativeAnimatedNonTurboModule from './NativeAnimatedModule';
26
- import NativeAnimatedTurboModule from './NativeAnimatedTurboModule';
27
- import invariant from 'invariant';
28
-
29
- // TODO T69437152 @petetheheat - Delete this fork when Fabric ships to 100%.
30
- const NativeAnimatedModule =
31
- NativeAnimatedNonTurboModule ?? NativeAnimatedTurboModule;
32
-
33
- let __nativeAnimatedNodeTagCount = 1; /* used for animated nodes */
34
- let __nativeAnimationIdCount = 1; /* used for started animations */
35
-
36
- let nativeEventEmitter;
37
-
38
- let waitingForQueuedOperations = new Set<string>();
39
- let queueOperations = false;
40
- let queue: Array<() => void> = [];
41
- // $FlowFixMe
42
- let singleOpQueue: Array<any> = [];
43
-
44
- const useSingleOpBatching =
45
- Platform.OS === 'android' &&
46
- !!NativeAnimatedModule?.queueAndExecuteBatchedOperations &&
47
- ReactNativeFeatureFlags.animatedShouldUseSingleOp();
48
- let flushQueueTimeout = null;
49
-
50
- const eventListenerGetValueCallbacks: {
51
- [number]: (value: number) => void,
52
- } = {};
53
- const eventListenerAnimationFinishedCallbacks: {
54
- [number]: EndCallback,
55
- } = {};
56
- let globalEventEmitterGetValueListener: ?EventSubscription = null;
57
- let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null;
58
-
59
- const nativeOps: ?typeof NativeAnimatedModule = useSingleOpBatching
60
- ? ((function () {
61
- const apis = [
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
- return apis.reduce<{[string]: number}>((acc, functionName, i) => {
85
- // These indices need to be kept in sync with the indices in native (see NativeAnimatedModule in Java, or the equivalent for any other native platform).
86
- // $FlowFixMe[prop-missing]
87
- acc[functionName] = i + 1;
88
- return acc;
89
- }, {});
90
- })(): $FlowFixMe)
91
- : NativeAnimatedModule;
92
-
93
- /**
94
- * Wrappers around NativeAnimatedModule to provide flow and autocomplete support for
95
- * the native module methods, and automatic queue management on Android
96
- */
97
- const API = {
98
- getValue: function (
99
- tag: number,
100
- saveValueCallback: (value: number) => void,
101
- ): void {
102
- invariant(nativeOps, 'Native animated module is not available');
103
- if (useSingleOpBatching) {
104
- if (saveValueCallback) {
105
- eventListenerGetValueCallbacks[tag] = saveValueCallback;
106
- }
107
- // $FlowFixMe
108
- API.queueOperation(nativeOps.getValue, tag);
109
- } else {
110
- API.queueOperation(nativeOps.getValue, tag, saveValueCallback);
111
- }
112
- },
113
- setWaitingForIdentifier: function (id: string): void {
114
- waitingForQueuedOperations.add(id);
115
- queueOperations = true;
116
- if (
117
- ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush() &&
118
- flushQueueTimeout
119
- ) {
120
- clearTimeout(flushQueueTimeout);
121
- }
122
- },
123
- unsetWaitingForIdentifier: function (id: string): void {
124
- waitingForQueuedOperations.delete(id);
125
-
126
- if (waitingForQueuedOperations.size === 0) {
127
- queueOperations = false;
128
- API.disableQueue();
129
- }
130
- },
131
- disableQueue: function (): void {
132
- invariant(nativeOps, 'Native animated module is not available');
133
-
134
- if (ReactNativeFeatureFlags.animatedShouldDebounceQueueFlush()) {
135
- const prevTimeout = flushQueueTimeout;
136
- clearImmediate(prevTimeout);
137
- flushQueueTimeout = setImmediate(API.flushQueue);
138
- } else {
139
- API.flushQueue();
140
- }
141
- },
142
- flushQueue: function (): void {
143
- // GH: 11042 This invariant causes the win32 tester to not work
144
- // NativeAnimatedModule is not implemented in win32
145
- // // TODO: (T136971132)
146
- // invariant(
147
- // NativeAnimatedModule || process.env.NODE_ENV === 'test',
148
- // 'Native animated module is not available',
149
- // );
150
- flushQueueTimeout = null;
151
-
152
- // Early returns before calling any APIs
153
- if (useSingleOpBatching && singleOpQueue.length === 0) {
154
- return;
155
- }
156
- if (!useSingleOpBatching && queue.length === 0) {
157
- return;
158
- }
159
-
160
- if (useSingleOpBatching) {
161
- // Set up event listener for callbacks if it's not set up
162
- if (
163
- !globalEventEmitterGetValueListener ||
164
- !globalEventEmitterAnimationFinishedListener
165
- ) {
166
- setupGlobalEventEmitterListeners();
167
- }
168
- // Single op batching doesn't use callback functions, instead we
169
- // use RCTDeviceEventEmitter. This reduces overhead of sending lots of
170
- // JSI functions across to native code; but also, TM infrastructure currently
171
- // does not support packing a function into native arrays.
172
- NativeAnimatedModule?.queueAndExecuteBatchedOperations?.(singleOpQueue);
173
- singleOpQueue.length = 0;
174
- } else {
175
- Platform.OS === 'android' &&
176
- NativeAnimatedModule?.startOperationBatch?.();
177
-
178
- for (let q = 0, l = queue.length; q < l; q++) {
179
- queue[q]();
180
- }
181
- queue.length = 0;
182
- Platform.OS === 'android' &&
183
- NativeAnimatedModule?.finishOperationBatch?.();
184
- }
185
- },
186
- queueOperation: <Args: $ReadOnlyArray<mixed>, Fn: (...Args) => void>(
187
- fn: Fn,
188
- ...args: Args
189
- ): void => {
190
- if (useSingleOpBatching) {
191
- // Get the command ID from the queued function, and push that ID and any arguments needed to execute the operation
192
- // $FlowFixMe: surprise, fn is actually a number
193
- singleOpQueue.push(fn, ...args);
194
- return;
195
- }
196
-
197
- // If queueing is explicitly on, *or* the queue has not yet
198
- // been flushed, use the queue. This is to prevent operations
199
- // from being executed out of order.
200
- if (queueOperations || queue.length !== 0) {
201
- queue.push(() => fn(...args));
202
- } else {
203
- fn(...args);
204
- }
205
- },
206
- createAnimatedNode: function (tag: number, config: AnimatedNodeConfig): void {
207
- invariant(nativeOps, 'Native animated module is not available');
208
- API.queueOperation(nativeOps.createAnimatedNode, tag, config);
209
- },
210
- updateAnimatedNodeConfig: function (
211
- tag: number,
212
- config: AnimatedNodeConfig,
213
- ): void {
214
- invariant(nativeOps, 'Native animated module is not available');
215
- if (nativeOps.updateAnimatedNodeConfig) {
216
- API.queueOperation(nativeOps.updateAnimatedNodeConfig, tag, config);
217
- }
218
- },
219
- startListeningToAnimatedNodeValue: function (tag: number) {
220
- invariant(nativeOps, 'Native animated module is not available');
221
- API.queueOperation(nativeOps.startListeningToAnimatedNodeValue, tag);
222
- },
223
- stopListeningToAnimatedNodeValue: function (tag: number) {
224
- invariant(nativeOps, 'Native animated module is not available');
225
- API.queueOperation(nativeOps.stopListeningToAnimatedNodeValue, tag);
226
- },
227
- connectAnimatedNodes: function (parentTag: number, childTag: number): void {
228
- invariant(nativeOps, 'Native animated module is not available');
229
- API.queueOperation(nativeOps.connectAnimatedNodes, parentTag, childTag);
230
- },
231
- disconnectAnimatedNodes: function (
232
- parentTag: number,
233
- childTag: number,
234
- ): void {
235
- invariant(nativeOps, 'Native animated module is not available');
236
- API.queueOperation(nativeOps.disconnectAnimatedNodes, parentTag, childTag);
237
- },
238
- startAnimatingNode: function (
239
- animationId: number,
240
- nodeTag: number,
241
- config: AnimatingNodeConfig,
242
- endCallback: EndCallback,
243
- ): void {
244
- invariant(nativeOps, 'Native animated module is not available');
245
- if (useSingleOpBatching) {
246
- if (endCallback) {
247
- eventListenerAnimationFinishedCallbacks[animationId] = endCallback;
248
- }
249
- // $FlowFixMe
250
- API.queueOperation(
251
- // $FlowFixMe[incompatible-call]
252
- nativeOps.startAnimatingNode,
253
- animationId,
254
- nodeTag,
255
- config,
256
- );
257
- } else {
258
- API.queueOperation(
259
- nativeOps.startAnimatingNode,
260
- animationId,
261
- nodeTag,
262
- config,
263
- endCallback,
264
- );
265
- }
266
- },
267
- stopAnimation: function (animationId: number) {
268
- invariant(nativeOps, 'Native animated module is not available');
269
- API.queueOperation(nativeOps.stopAnimation, animationId);
270
- },
271
- setAnimatedNodeValue: function (nodeTag: number, value: number): void {
272
- invariant(nativeOps, 'Native animated module is not available');
273
- API.queueOperation(nativeOps.setAnimatedNodeValue, nodeTag, value);
274
- },
275
- setAnimatedNodeOffset: function (nodeTag: number, offset: number): void {
276
- invariant(nativeOps, 'Native animated module is not available');
277
- API.queueOperation(nativeOps.setAnimatedNodeOffset, nodeTag, offset);
278
- },
279
- flattenAnimatedNodeOffset: function (nodeTag: number): void {
280
- invariant(nativeOps, 'Native animated module is not available');
281
- API.queueOperation(nativeOps.flattenAnimatedNodeOffset, nodeTag);
282
- },
283
- extractAnimatedNodeOffset: function (nodeTag: number): void {
284
- invariant(nativeOps, 'Native animated module is not available');
285
- API.queueOperation(nativeOps.extractAnimatedNodeOffset, nodeTag);
286
- },
287
- connectAnimatedNodeToView: function (nodeTag: number, viewTag: number): void {
288
- invariant(nativeOps, 'Native animated module is not available');
289
- API.queueOperation(nativeOps.connectAnimatedNodeToView, nodeTag, viewTag);
290
- },
291
- disconnectAnimatedNodeFromView: function (
292
- nodeTag: number,
293
- viewTag: number,
294
- ): void {
295
- invariant(nativeOps, 'Native animated module is not available');
296
- API.queueOperation(
297
- nativeOps.disconnectAnimatedNodeFromView,
298
- nodeTag,
299
- viewTag,
300
- );
301
- },
302
- restoreDefaultValues: function (nodeTag: number): void {
303
- invariant(nativeOps, 'Native animated module is not available');
304
- // Backwards compat with older native runtimes, can be removed later.
305
- if (nativeOps.restoreDefaultValues != null) {
306
- API.queueOperation(nativeOps.restoreDefaultValues, nodeTag);
307
- }
308
- },
309
- dropAnimatedNode: function (tag: number): void {
310
- invariant(nativeOps, 'Native animated module is not available');
311
- API.queueOperation(nativeOps.dropAnimatedNode, tag);
312
- },
313
- addAnimatedEventToView: function (
314
- viewTag: number,
315
- eventName: string,
316
- eventMapping: EventMapping,
317
- ) {
318
- invariant(nativeOps, 'Native animated module is not available');
319
- API.queueOperation(
320
- nativeOps.addAnimatedEventToView,
321
- viewTag,
322
- eventName,
323
- eventMapping,
324
- );
325
- },
326
- removeAnimatedEventFromView(
327
- viewTag: number,
328
- eventName: string,
329
- animatedNodeTag: number,
330
- ) {
331
- invariant(nativeOps, 'Native animated module is not available');
332
- API.queueOperation(
333
- nativeOps.removeAnimatedEventFromView,
334
- viewTag,
335
- eventName,
336
- animatedNodeTag,
337
- );
338
- },
339
- };
340
-
341
- function setupGlobalEventEmitterListeners() {
342
- globalEventEmitterGetValueListener = RCTDeviceEventEmitter.addListener(
343
- 'onNativeAnimatedModuleGetValue',
344
- params => {
345
- const {tag} = params;
346
- const callback = eventListenerGetValueCallbacks[tag];
347
- if (!callback) {
348
- return;
349
- }
350
- callback(params.value);
351
- delete eventListenerGetValueCallbacks[tag];
352
- },
353
- );
354
- globalEventEmitterAnimationFinishedListener =
355
- RCTDeviceEventEmitter.addListener(
356
- 'onNativeAnimatedModuleAnimationFinished',
357
- params => {
358
- // TODO: remove Array.isArray once native changes have propagated
359
- const animations = Array.isArray(params) ? params : [params];
360
- for (const animation of animations) {
361
- const {animationId} = animation;
362
- const callback = eventListenerAnimationFinishedCallbacks[animationId];
363
- if (callback) {
364
- callback(animation);
365
- delete eventListenerAnimationFinishedCallbacks[animationId];
366
- }
367
- }
368
- },
369
- );
370
- }
371
-
372
- /**
373
- * Styles allowed by the native animated implementation.
374
- *
375
- * In general native animated implementation should support any numeric or color property that
376
- * doesn't need to be updated through the shadow view hierarchy (all non-layout properties).
377
- */
378
- const SUPPORTED_COLOR_STYLES = {
379
- backgroundColor: true,
380
- borderBottomColor: true,
381
- borderColor: true,
382
- borderEndColor: true,
383
- borderLeftColor: true,
384
- borderRightColor: true,
385
- borderStartColor: true,
386
- borderTopColor: true,
387
- color: true,
388
- tintColor: true,
389
- };
390
-
391
- const SUPPORTED_STYLES = {
392
- ...SUPPORTED_COLOR_STYLES,
393
- borderBottomEndRadius: true,
394
- borderBottomLeftRadius: true,
395
- borderBottomRightRadius: true,
396
- borderBottomStartRadius: true,
397
- borderEndEndRadius: true,
398
- borderEndStartRadius: true,
399
- borderRadius: true,
400
- borderTopEndRadius: true,
401
- borderTopLeftRadius: true,
402
- borderTopRightRadius: true,
403
- borderTopStartRadius: true,
404
- borderStartEndRadius: true,
405
- borderStartStartRadius: true,
406
- elevation: true,
407
- opacity: true,
408
- transform: true,
409
- zIndex: true,
410
- /* ios styles */
411
- shadowOpacity: true,
412
- shadowRadius: true,
413
- /* legacy android transform properties */
414
- scaleX: true,
415
- scaleY: true,
416
- translateX: true,
417
- translateY: true,
418
- };
419
-
420
- const SUPPORTED_TRANSFORMS = {
421
- translateX: true,
422
- translateY: true,
423
- scale: true,
424
- scaleX: true,
425
- scaleY: true,
426
- rotate: true,
427
- rotateX: true,
428
- rotateY: true,
429
- rotateZ: true,
430
- perspective: true,
431
- skewX: true,
432
- skewY: true,
433
- matrix: ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform(),
434
- };
435
-
436
- const SUPPORTED_INTERPOLATION_PARAMS = {
437
- inputRange: true,
438
- outputRange: true,
439
- extrapolate: true,
440
- extrapolateRight: true,
441
- extrapolateLeft: true,
442
- };
443
-
444
- function addWhitelistedStyleProp(prop: string): void {
445
- // $FlowFixMe[prop-missing]
446
- SUPPORTED_STYLES[prop] = true;
447
- }
448
-
449
- function addWhitelistedTransformProp(prop: string): void {
450
- // $FlowFixMe[prop-missing]
451
- SUPPORTED_TRANSFORMS[prop] = true;
452
- }
453
-
454
- function addWhitelistedInterpolationParam(param: string): void {
455
- // $FlowFixMe[prop-missing]
456
- SUPPORTED_INTERPOLATION_PARAMS[param] = true;
457
- }
458
-
459
- function isSupportedColorStyleProp(prop: string): boolean {
460
- // $FlowFixMe[invalid-computed-prop]
461
- return SUPPORTED_COLOR_STYLES[prop] === true;
462
- }
463
-
464
- function isSupportedStyleProp(prop: string): boolean {
465
- // $FlowFixMe[invalid-computed-prop]
466
- return SUPPORTED_STYLES[prop] === true;
467
- }
468
-
469
- function isSupportedTransformProp(prop: string): boolean {
470
- // $FlowFixMe[invalid-computed-prop]
471
- return SUPPORTED_TRANSFORMS[prop] === true;
472
- }
473
-
474
- function isSupportedInterpolationParam(param: string): boolean {
475
- // $FlowFixMe[invalid-computed-prop]
476
- return SUPPORTED_INTERPOLATION_PARAMS[param] === true;
477
- }
478
-
479
- function validateTransform(
480
- configs: Array<
481
- | {
482
- type: 'animated',
483
- property: string,
484
- nodeTag: ?number,
485
- ...
486
- }
487
- | {
488
- type: 'static',
489
- property: string,
490
- value: number | string,
491
- ...
492
- },
493
- >,
494
- ): void {
495
- configs.forEach(config => {
496
- if (!isSupportedTransformProp(config.property)) {
497
- throw new Error(
498
- `Property '${config.property}' is not supported by native animated module`,
499
- );
500
- }
501
- });
502
- }
503
-
504
- function validateStyles(styles: {[key: string]: ?number, ...}): void {
505
- for (const key in styles) {
506
- if (!isSupportedStyleProp(key)) {
507
- throw new Error(
508
- `Style property '${key}' is not supported by native animated module`,
509
- );
510
- }
511
- }
512
- }
513
-
514
- function validateInterpolation<OutputT: number | string>(
515
- config: InterpolationConfigType<OutputT>,
516
- ): void {
517
- for (const key in config) {
518
- if (!isSupportedInterpolationParam(key)) {
519
- throw new Error(
520
- `Interpolation property '${key}' is not supported by native animated module`,
521
- );
522
- }
523
- }
524
- }
525
-
526
- function generateNewNodeTag(): number {
527
- return __nativeAnimatedNodeTagCount++;
528
- }
529
-
530
- function generateNewAnimationId(): number {
531
- return __nativeAnimationIdCount++;
532
- }
533
-
534
- function assertNativeAnimatedModule(): void {
535
- invariant(NativeAnimatedModule, 'Native animated module is not available');
536
- }
537
-
538
- let _warnedMissingNativeAnimated = false;
539
-
540
- function shouldUseNativeDriver(
541
- config: $ReadOnly<{...AnimationConfig, ...}> | EventConfig,
542
- ): boolean {
543
- if (config.useNativeDriver == null) {
544
- console.warn(
545
- 'Animated: `useNativeDriver` was not specified. This is a required ' +
546
- 'option and must be explicitly set to `true` or `false`',
547
- );
548
- }
549
-
550
- if (config.useNativeDriver === true && !NativeAnimatedModule) {
551
- if (process.env.NODE_ENV !== 'test') {
552
- if (!_warnedMissingNativeAnimated) {
553
- console.warn(
554
- 'Animated: `useNativeDriver` is not supported because the native ' +
555
- 'animated module is missing. Falling back to JS-based animation. To ' +
556
- 'resolve this, add `RCTAnimation` module to this app, or remove ' +
557
- '`useNativeDriver`. ' +
558
- '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',
559
- );
560
- _warnedMissingNativeAnimated = true;
561
- }
562
- }
563
- return false;
564
- }
565
-
566
- return config.useNativeDriver || false;
567
- }
568
-
569
- function transformDataType(value: number | string): number | string {
570
- // Change the string type to number type so we can reuse the same logic in
571
- // iOS and Android platform
572
- if (typeof value !== 'string') {
573
- return value;
574
- }
575
-
576
- // Normalize degrees and radians to a number expressed in radians
577
- if (value.endsWith('deg')) {
578
- const degrees = parseFloat(value) || 0;
579
- return (degrees * Math.PI) / 180.0;
580
- } else if (value.endsWith('rad')) {
581
- return parseFloat(value) || 0;
582
- } else {
583
- return value;
584
- }
585
- }
586
-
587
- export default {
588
- API,
589
- isSupportedColorStyleProp,
590
- isSupportedStyleProp,
591
- isSupportedTransformProp,
592
- isSupportedInterpolationParam,
593
- addWhitelistedStyleProp,
594
- addWhitelistedTransformProp,
595
- addWhitelistedInterpolationParam,
596
- validateStyles,
597
- validateTransform,
598
- validateInterpolation,
599
- generateNewNodeTag,
600
- generateNewAnimationId,
601
- assertNativeAnimatedModule,
602
- shouldUseNativeDriver,
603
- transformDataType,
604
- // $FlowExpectedError[unsafe-getters-setters] - unsafe getter lint suppression
605
- // $FlowExpectedError[missing-type-arg] - unsafe getter lint suppression
606
- get nativeEventEmitter(): NativeEventEmitter {
607
- if (!nativeEventEmitter) {
608
- // $FlowFixMe[underconstrained-implicit-instantiation]
609
- nativeEventEmitter = new NativeEventEmitter(
610
- // 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
611
- // If you want to use the native module on other platforms, please remove this condition and test its behavior
612
- Platform.OS !== 'ios' ? null : NativeAnimatedModule,
613
- );
614
- }
615
- return nativeEventEmitter;
616
- },
617
- };
@@ -1,16 +0,0 @@
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 {polyfillGlobal} from '../Utilities/PolyfillFunctions';
12
-
13
- polyfillGlobal(
14
- 'IntersectionObserver',
15
- () => require('../IntersectionObserver/IntersectionObserver').default,
16
- );
@@ -1,16 +0,0 @@
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 {polyfillGlobal} from '../Utilities/PolyfillFunctions';
12
-
13
- polyfillGlobal(
14
- 'MutationObserver',
15
- () => require('../MutationObserver/MutationObserver').default,
16
- );
@@ -1,18 +0,0 @@
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 {polyfillGlobal} from '../Utilities/PolyfillFunctions';
12
-
13
- polyfillGlobal(
14
- 'PerformanceObserver',
15
- () =>
16
- require('../../src/private/webapis/performance/PerformanceObserver')
17
- .default,
18
- );
@@ -1,13 +0,0 @@
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
8
- * @format
9
- */
10
-
11
- export * from '../../src/private/specs/modules/NativeIntersectionObserver';
12
- import NativeIntersectionObserver from '../../src/private/specs/modules/NativeIntersectionObserver';
13
- export default NativeIntersectionObserver;
@@ -1,13 +0,0 @@
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
- export * from '../../src/private/specs/modules/NativeMutationObserver';
12
- import NativeMutationObserver from '../../src/private/specs/modules/NativeMutationObserver';
13
- export default NativeMutationObserver;