@office-iss/react-native-win32 0.75.1 → 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 +172 -40
  4. package/CHANGELOG.md +57 -24
  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 +74 -15
  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 +27 -26
  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
@@ -12,26 +12,29 @@
12
12
 
13
13
  import type {PlatformConfig} from '../AnimatedPlatformConfig';
14
14
 
15
- import NativeAnimatedHelper from '../NativeAnimatedHelper';
15
+ import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
16
16
  import AnimatedNode from './AnimatedNode';
17
17
 
18
- export default class AnimatedWithChildren extends AnimatedNode {
19
- _children: Array<AnimatedNode>;
18
+ const {connectAnimatedNodes, disconnectAnimatedNodes} =
19
+ NativeAnimatedHelper.API;
20
20
 
21
- constructor() {
22
- super();
23
- this._children = [];
24
- }
21
+ export default class AnimatedWithChildren extends AnimatedNode {
22
+ _children: Array<AnimatedNode> = [];
25
23
 
26
24
  __makeNative(platformConfig: ?PlatformConfig) {
27
25
  if (!this.__isNative) {
28
26
  this.__isNative = true;
29
- for (const child of this._children) {
30
- child.__makeNative(platformConfig);
31
- NativeAnimatedHelper.API.connectAnimatedNodes(
32
- this.__getNativeTag(),
33
- child.__getNativeTag(),
34
- );
27
+
28
+ const children = this._children;
29
+ let length = children.length;
30
+ if (length > 0) {
31
+ const nativeTag = this.__getNativeTag();
32
+
33
+ for (let ii = 0; ii < length; ii++) {
34
+ const child = children[ii];
35
+ child.__makeNative(platformConfig);
36
+ connectAnimatedNodes(nativeTag, child.__getNativeTag());
37
+ }
35
38
  }
36
39
  }
37
40
  super.__makeNative(platformConfig);
@@ -45,10 +48,7 @@ export default class AnimatedWithChildren extends AnimatedNode {
45
48
  if (this.__isNative) {
46
49
  // Only accept "native" animated nodes as children
47
50
  child.__makeNative(this.__getPlatformConfig());
48
- NativeAnimatedHelper.API.connectAnimatedNodes(
49
- this.__getNativeTag(),
50
- child.__getNativeTag(),
51
- );
51
+ connectAnimatedNodes(this.__getNativeTag(), child.__getNativeTag());
52
52
  }
53
53
  }
54
54
 
@@ -59,10 +59,7 @@ export default class AnimatedWithChildren extends AnimatedNode {
59
59
  return;
60
60
  }
61
61
  if (this.__isNative && child.__isNative) {
62
- NativeAnimatedHelper.API.disconnectAnimatedNodes(
63
- this.__getNativeTag(),
64
- child.__getNativeTag(),
65
- );
62
+ disconnectAnimatedNodes(this.__getNativeTag(), child.__getNativeTag());
66
63
  }
67
64
  this._children.splice(index, 1);
68
65
  if (this._children.length === 0) {
@@ -77,7 +74,9 @@ export default class AnimatedWithChildren extends AnimatedNode {
77
74
  __callListeners(value: number): void {
78
75
  super.__callListeners(value);
79
76
  if (!this.__isNative) {
80
- for (const child of this._children) {
77
+ const children = this._children;
78
+ for (let ii = 0, length = children.length; ii < length; ii++) {
79
+ const child = children[ii];
81
80
  // $FlowFixMe[method-unbinding] added when improving typing for this parameters
82
81
  if (child.__getValue) {
83
82
  child.__callListeners(child.__getValue());
@@ -10,12 +10,16 @@
10
10
 
11
11
  'use strict';
12
12
 
13
+ import type {EventSubscription} from '../EventEmitter/NativeEventEmitter';
14
+
13
15
  import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
14
16
  import {isPublicInstance as isFabricPublicInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils';
15
17
  import useRefEffect from '../Utilities/useRefEffect';
16
18
  import {AnimatedEvent} from './AnimatedEvent';
17
- import NativeAnimatedHelper from './NativeAnimatedHelper';
19
+ import NativeAnimatedHelper from '../../src/private/animated/NativeAnimatedHelper';
20
+ import AnimatedNode from './nodes/AnimatedNode';
18
21
  import AnimatedProps from './nodes/AnimatedProps';
22
+ import AnimatedValue from './nodes/AnimatedValue';
19
23
  import {
20
24
  useCallback,
21
25
  useEffect,
@@ -32,6 +36,11 @@ type ReducedProps<TProps> = {
32
36
  };
33
37
  type CallbackRef<T> = T => mixed;
34
38
 
39
+ type AnimatedValueListeners = Array<{
40
+ propValue: AnimatedValue,
41
+ listenerId: string,
42
+ }>;
43
+
35
44
  export default function useAnimatedProps<TProps: {...}, TInstance>(
36
45
  props: TProps,
37
46
  ): [ReducedProps<TProps>, CallbackRef<TInstance | null>] {
@@ -49,6 +58,14 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
49
58
  );
50
59
  const useNativePropsInFabric =
51
60
  ReactNativeFeatureFlags.shouldUseSetNativePropsInFabric();
61
+ const useSetNativePropsInNativeAnimationsInFabric =
62
+ ReactNativeFeatureFlags.shouldUseSetNativePropsInNativeAnimationsInFabric();
63
+
64
+ const useAnimatedPropsLifecycle =
65
+ ReactNativeFeatureFlags.usePassiveEffectsForAnimations()
66
+ ? useAnimatedPropsLifecycle_passiveEffects
67
+ : useAnimatedPropsLifecycle_layoutEffects;
68
+
52
69
  useAnimatedPropsLifecycle(node);
53
70
 
54
71
  // TODO: This "effect" does three things:
@@ -87,7 +104,12 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
87
104
  if (isFabricNode) {
88
105
  // Call `scheduleUpdate` to synchronise Fiber and Shadow tree.
89
106
  // Must not be called in Paper.
90
- scheduleUpdate();
107
+ if (useSetNativePropsInNativeAnimationsInFabric) {
108
+ // $FlowFixMe[incompatible-use]
109
+ instance.setNativeProps(node.__getAnimatedValue());
110
+ } else {
111
+ scheduleUpdate();
112
+ }
91
113
  }
92
114
  return;
93
115
  }
@@ -139,6 +161,7 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
139
161
 
140
162
  const target = getEventTarget(instance);
141
163
  const events = [];
164
+ const animatedValueListeners: AnimatedValueListeners = [];
142
165
 
143
166
  for (const propName in props) {
144
167
  // $FlowFixMe[invalid-computed-prop]
@@ -146,6 +169,8 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
146
169
  if (propValue instanceof AnimatedEvent && propValue.__isNative) {
147
170
  propValue.__attach(target, propName);
148
171
  events.push([propName, propValue]);
172
+ // $FlowFixMe[incompatible-call] - the `addListenersToPropsValue` drills down the propValue.
173
+ addListenersToPropsValue(propValue, animatedValueListeners);
149
174
  }
150
175
  }
151
176
 
@@ -155,18 +180,25 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
155
180
  for (const [propName, propValue] of events) {
156
181
  propValue.__detach(target, propName);
157
182
  }
183
+
184
+ for (const {propValue, listenerId} of animatedValueListeners) {
185
+ propValue.removeListener(listenerId);
186
+ }
158
187
  };
159
188
  },
160
- [props, node, useNativePropsInFabric],
189
+ [
190
+ node,
191
+ useNativePropsInFabric,
192
+ useSetNativePropsInNativeAnimationsInFabric,
193
+ props,
194
+ ],
161
195
  );
162
196
  const callbackRef = useRefEffect<TInstance>(refEffect);
163
197
 
164
198
  return [reduceAnimatedProps<TProps>(node), callbackRef];
165
199
  }
166
200
 
167
- function reduceAnimatedProps<TProps>(
168
- node: AnimatedProps,
169
- ): ReducedProps<TProps> {
201
+ function reduceAnimatedProps<TProps>(node: AnimatedNode): ReducedProps<TProps> {
170
202
  // Force `collapsable` to be false so that the native view is not flattened.
171
203
  // Flattened views cannot be accurately referenced by the native driver.
172
204
  return {
@@ -175,6 +207,35 @@ function reduceAnimatedProps<TProps>(
175
207
  };
176
208
  }
177
209
 
210
+ function addListenersToPropsValue(
211
+ propValue: AnimatedValue,
212
+ accumulator: AnimatedValueListeners,
213
+ ) {
214
+ // propValue can be a scalar value, an array or an object.
215
+ if (propValue instanceof AnimatedValue) {
216
+ const listenerId = propValue.addListener(() => {});
217
+ accumulator.push({propValue, listenerId});
218
+ } else if (Array.isArray(propValue)) {
219
+ // An array can be an array of scalar values, arrays of arrays, or arrays of objects
220
+ for (const prop of propValue) {
221
+ addListenersToPropsValue(prop, accumulator);
222
+ }
223
+ } else if (propValue instanceof Object) {
224
+ addAnimatedValuesListenersToProps(propValue, accumulator);
225
+ }
226
+ }
227
+
228
+ function addAnimatedValuesListenersToProps(
229
+ props: AnimatedNode,
230
+ accumulator: AnimatedValueListeners,
231
+ ) {
232
+ for (const propName in props) {
233
+ // $FlowFixMe[prop-missing] - This is an object contained in a prop, but we don't know the exact type.
234
+ const propValue = props[propName];
235
+ addListenersToPropsValue(propValue, accumulator);
236
+ }
237
+ }
238
+
178
239
  /**
179
240
  * Manages the lifecycle of the supplied `AnimatedProps` by invoking `__attach`
180
241
  * and `__detach`. However, this is more complicated because `AnimatedProps`
@@ -182,7 +243,7 @@ function reduceAnimatedProps<TProps>(
182
243
  * nodes. So in order to optimize this, we avoid detaching until the next attach
183
244
  * unless we are unmounting.
184
245
  */
185
- function useAnimatedPropsLifecycle(node: AnimatedProps): void {
246
+ function useAnimatedPropsLifecycle_layoutEffects(node: AnimatedProps): void {
186
247
  const prevNodeRef = useRef<?AnimatedProps>(null);
187
248
  const isUnmountingRef = useRef<boolean>(false);
188
249
 
@@ -191,6 +252,20 @@ function useAnimatedPropsLifecycle(node: AnimatedProps): void {
191
252
  // if the queue is empty. When multiple animated components are mounted at
192
253
  // the same time. Only first component flushes the queue and the others will noop.
193
254
  NativeAnimatedHelper.API.flushQueue();
255
+ let drivenAnimationEndedListener: ?EventSubscription = null;
256
+ if (node.__isNative) {
257
+ drivenAnimationEndedListener =
258
+ NativeAnimatedHelper.nativeEventEmitter.addListener(
259
+ 'onUserDrivenAnimationEnded',
260
+ data => {
261
+ node.update();
262
+ },
263
+ );
264
+ }
265
+
266
+ return () => {
267
+ drivenAnimationEndedListener?.remove();
268
+ };
194
269
  });
195
270
 
196
271
  useLayoutEffect(() => {
@@ -220,6 +295,66 @@ function useAnimatedPropsLifecycle(node: AnimatedProps): void {
220
295
  }, [node]);
221
296
  }
222
297
 
298
+ /**
299
+ * Manages the lifecycle of the supplied `AnimatedProps` by invoking `__attach`
300
+ * and `__detach`. However, this is more complicated because `AnimatedProps`
301
+ * uses reference counting to determine when to recursively detach its children
302
+ * nodes. So in order to optimize this, we avoid detaching until the next attach
303
+ * unless we are unmounting.
304
+ *
305
+ * NOTE: unlike `useAnimatedPropsLifecycle_layoutEffects`, this version uses passive effects to setup animation graph.
306
+ */
307
+ function useAnimatedPropsLifecycle_passiveEffects(node: AnimatedProps): void {
308
+ const prevNodeRef = useRef<?AnimatedProps>(null);
309
+ const isUnmountingRef = useRef<boolean>(false);
310
+
311
+ useEffect(() => {
312
+ // It is ok for multiple components to call `flushQueue` because it noops
313
+ // if the queue is empty. When multiple animated components are mounted at
314
+ // the same time. Only first component flushes the queue and the others will noop.
315
+ NativeAnimatedHelper.API.flushQueue();
316
+ });
317
+
318
+ useEffect(() => {
319
+ isUnmountingRef.current = false;
320
+ return () => {
321
+ isUnmountingRef.current = true;
322
+ };
323
+ }, []);
324
+
325
+ useEffect(() => {
326
+ node.__attach();
327
+ let drivenAnimationEndedListener: ?EventSubscription = null;
328
+
329
+ if (node.__isNative) {
330
+ drivenAnimationEndedListener =
331
+ NativeAnimatedHelper.nativeEventEmitter.addListener(
332
+ 'onUserDrivenAnimationEnded',
333
+ data => {
334
+ node.update();
335
+ },
336
+ );
337
+ }
338
+ if (prevNodeRef.current != null) {
339
+ const prevNode = prevNodeRef.current;
340
+ // TODO: Stop restoring default values (unless `reset` is called).
341
+ prevNode.__restoreDefaultValues();
342
+ prevNode.__detach();
343
+ prevNodeRef.current = null;
344
+ }
345
+ return () => {
346
+ if (isUnmountingRef.current) {
347
+ // NOTE: Do not restore default values on unmount, see D18197735.
348
+ node.__detach();
349
+ } else {
350
+ prevNodeRef.current = node;
351
+ }
352
+
353
+ drivenAnimationEndedListener?.remove();
354
+ };
355
+ }, [node]);
356
+ }
357
+
223
358
  function getEventTarget<TInstance>(instance: TInstance): TInstance {
224
359
  return typeof instance === 'object' &&
225
360
  typeof instance?.getScrollableNode === 'function'
@@ -102,6 +102,7 @@ function genMethod(moduleID: number, methodID: number, type: MethodType) {
102
102
  // In case we reject, capture a useful stack trace here.
103
103
  /* $FlowFixMe[class-object-subtyping] added when improving typing for
104
104
  * this parameters */
105
+ // $FlowFixMe[incompatible-type]
105
106
  const enqueueingFrameError: ExtendedError = new Error();
106
107
  return new Promise((resolve, reject) => {
107
108
  BatchedBridge.enqueueNativeCall(
@@ -171,6 +172,7 @@ function updateErrorWithErrorData(
171
172
  ): ExtendedError {
172
173
  /* $FlowFixMe[class-object-subtyping] added when improving typing for this
173
174
  * parameters */
175
+ // $FlowFixMe[incompatible-return]
174
176
  return Object.assign(error, errorData || {});
175
177
  }
176
178
 
@@ -34,7 +34,7 @@ const EMPTY = 0;
34
34
  const LOADING = 1;
35
35
  const DONE = 2;
36
36
 
37
- class FileReader extends (EventTarget(...READER_EVENTS): any) {
37
+ class FileReader extends (EventTarget(...READER_EVENTS): typeof EventTarget) {
38
38
  static EMPTY: number = EMPTY;
39
39
  static LOADING: number = LOADING;
40
40
  static DONE: number = DONE;
@@ -27,7 +27,7 @@ if (
27
27
  }
28
28
  }
29
29
 
30
- /**
30
+ /*
31
31
  * To allow Blobs be accessed via `content://` URIs,
32
32
  * you need to register `BlobProvider` as a ContentProvider in your app's `AndroidManifest.xml`:
33
33
  *
@@ -52,67 +52,7 @@ if (
52
52
  * ```
53
53
  */
54
54
 
55
- // Small subset from whatwg-url: https://github.com/jsdom/whatwg-url/tree/master/src
56
- // The reference code bloat comes from Unicode issues with URLs, so those won't work here.
57
- export class URLSearchParams {
58
- _searchParams: Array<Array<string>> = [];
59
-
60
- constructor(params: any) {
61
- if (typeof params === 'object') {
62
- Object.keys(params).forEach(key => this.append(key, params[key]));
63
- }
64
- }
65
-
66
- append(key: string, value: string): void {
67
- this._searchParams.push([key, value]);
68
- }
69
-
70
- delete(name: string): void {
71
- throw new Error('URLSearchParams.delete is not implemented');
72
- }
73
-
74
- get(name: string): void {
75
- throw new Error('URLSearchParams.get is not implemented');
76
- }
77
-
78
- getAll(name: string): void {
79
- throw new Error('URLSearchParams.getAll is not implemented');
80
- }
81
-
82
- has(name: string): void {
83
- throw new Error('URLSearchParams.has is not implemented');
84
- }
85
-
86
- set(name: string, value: string): void {
87
- throw new Error('URLSearchParams.set is not implemented');
88
- }
89
-
90
- sort(): void {
91
- throw new Error('URLSearchParams.sort is not implemented');
92
- }
93
-
94
- // $FlowFixMe[unsupported-syntax]
95
- // $FlowFixMe[missing-local-annot]
96
- [Symbol.iterator]() {
97
- return this._searchParams[Symbol.iterator]();
98
- }
99
-
100
- toString(): string {
101
- if (this._searchParams.length === 0) {
102
- return '';
103
- }
104
- const last = this._searchParams.length - 1;
105
- return this._searchParams.reduce((acc, curr, index) => {
106
- return (
107
- acc +
108
- encodeURIComponent(curr[0]) +
109
- '=' +
110
- encodeURIComponent(curr[1]) +
111
- (index === last ? '' : '&')
112
- );
113
- }, '');
114
- }
115
- }
55
+ export {URLSearchParams} from './URLSearchParams';
116
56
 
117
57
  function validateBaseUrl(url: string) {
118
58
  // from this MIT-licensed gist: https://gist.github.com/dperini/729294
@@ -0,0 +1,71 @@
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
+ * @flow
9
+ */
10
+
11
+ // Small subset from whatwg-url: https://github.com/jsdom/whatwg-url/tree/master/src
12
+ // The reference code bloat comes from Unicode issues with URLs, so those won't work here.
13
+ export class URLSearchParams {
14
+ _searchParams: Array<Array<string>> = [];
15
+
16
+ constructor(params: any) {
17
+ if (typeof params === 'object') {
18
+ Object.keys(params).forEach(key => this.append(key, params[key]));
19
+ }
20
+ }
21
+
22
+ append(key: string, value: string): void {
23
+ this._searchParams.push([key, value]);
24
+ }
25
+
26
+ delete(name: string): void {
27
+ throw new Error('URLSearchParams.delete is not implemented');
28
+ }
29
+
30
+ get(name: string): void {
31
+ throw new Error('URLSearchParams.get is not implemented');
32
+ }
33
+
34
+ getAll(name: string): void {
35
+ throw new Error('URLSearchParams.getAll is not implemented');
36
+ }
37
+
38
+ has(name: string): void {
39
+ throw new Error('URLSearchParams.has is not implemented');
40
+ }
41
+
42
+ set(name: string, value: string): void {
43
+ throw new Error('URLSearchParams.set is not implemented');
44
+ }
45
+
46
+ sort(): void {
47
+ throw new Error('URLSearchParams.sort is not implemented');
48
+ }
49
+
50
+ // $FlowFixMe[unsupported-syntax]
51
+ // $FlowFixMe[missing-local-annot]
52
+ [Symbol.iterator]() {
53
+ return this._searchParams[Symbol.iterator]();
54
+ }
55
+
56
+ toString(): string {
57
+ if (this._searchParams.length === 0) {
58
+ return '';
59
+ }
60
+ const last = this._searchParams.length - 1;
61
+ return this._searchParams.reduce((acc, curr, index) => {
62
+ return (
63
+ acc +
64
+ encodeURIComponent(curr[0]) +
65
+ '=' +
66
+ encodeURIComponent(curr[1]) +
67
+ (index === last ? '' : '&')
68
+ );
69
+ }, '');
70
+ }
71
+ }
@@ -105,7 +105,7 @@ type Props = $ReadOnly<{|
105
105
  /**
106
106
  * The navigation view that will be rendered to the side of the screen and can be pulled in.
107
107
  */
108
- renderNavigationView: () => React.Element<any>,
108
+ renderNavigationView: () => React.MixedElement,
109
109
 
110
110
  /**
111
111
  * Make the drawer take the entire screen and draw the background of the
@@ -22,7 +22,7 @@ class RefreshControlMock extends React.Component<{...}> {
22
22
  componentDidMount() {
23
23
  RefreshControlMock.latestRef = this;
24
24
  }
25
- render(): React.Element<typeof RCTRefreshControl> {
25
+ render(): React.MixedElement {
26
26
  return <RCTRefreshControl />;
27
27
  }
28
28
  }