@office-iss/react-native-win32 0.0.0-canary.283 → 0.0.0-canary.284

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 (244) hide show
  1. package/.flowconfig +1 -1
  2. package/CHANGELOG.json +40 -1
  3. package/CHANGELOG.md +20 -8
  4. package/IntegrationTests/AccessibilityManagerTest.js +17 -12
  5. package/IntegrationTests/AppEventsTest.js +47 -32
  6. package/IntegrationTests/GlobalEvalWithSourceUrlTest.js +10 -14
  7. package/IntegrationTests/ImageCachePolicyTest.js +64 -81
  8. package/IntegrationTests/ImageSnapshotTest.js +17 -20
  9. package/IntegrationTests/IntegrationTestHarnessTest.js +34 -52
  10. package/IntegrationTests/IntegrationTestsApp.js +11 -6
  11. package/IntegrationTests/LayoutEventsTest.js +1 -1
  12. package/IntegrationTests/LoggingTestModule.js +2 -1
  13. package/IntegrationTests/PromiseTest.js +51 -43
  14. package/IntegrationTests/SimpleSnapshotTest.js +19 -24
  15. package/IntegrationTests/SyncMethodTest.js +9 -13
  16. package/IntegrationTests/TimersTest.js +3 -3
  17. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +3 -3
  18. package/Libraries/Alert/Alert.js +1 -1
  19. package/Libraries/Alert/Alert.win32.js +1 -1
  20. package/Libraries/Alert/RCTAlertManager.android.js +1 -1
  21. package/Libraries/Alert/RCTAlertManager.ios.js +1 -1
  22. package/Libraries/Animated/AnimatedMock.js +1 -1
  23. package/Libraries/Animated/AnimatedWeb.js +27 -9
  24. package/Libraries/Animated/nodes/AnimatedValue.js +35 -13
  25. package/Libraries/Animated/useAnimatedProps.js +47 -85
  26. package/Libraries/AppState/AppState.js +1 -1
  27. package/Libraries/BatchedBridge/BatchedBridge.js +4 -2
  28. package/Libraries/BatchedBridge/MessageQueue.js +2 -2
  29. package/Libraries/BatchedBridge/NativeModules.js +4 -3
  30. package/Libraries/Blob/Blob.js +4 -4
  31. package/Libraries/Blob/BlobManager.js +3 -2
  32. package/Libraries/Blob/BlobRegistry.js +3 -9
  33. package/Libraries/Blob/File.js +3 -2
  34. package/Libraries/Blob/FileReader.js +1 -1
  35. package/Libraries/BugReporting/BugReporting.js +2 -2
  36. package/Libraries/BugReporting/dumpReactTree.js +2 -2
  37. package/Libraries/BugReporting/getReactData.js +1 -1
  38. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.android.js +1 -1
  39. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.ios.js +1 -1
  40. package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.win32.js +1 -1
  41. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +5 -5
  42. package/Libraries/Components/Button.js +2 -2
  43. package/Libraries/Components/Button.win32.js +2 -2
  44. package/Libraries/Components/Clipboard/Clipboard.js +1 -1
  45. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +7 -7
  46. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +1 -2
  47. package/Libraries/Components/Keyboard/Keyboard.js +9 -9
  48. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +4 -4
  49. package/Libraries/Components/Pressable/Pressable.js +4 -4
  50. package/Libraries/Components/Pressable/Pressable.win32.js +4 -4
  51. package/Libraries/Components/Pressable/useAndroidRippleForView.js +9 -9
  52. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +10 -11
  53. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +1 -1
  54. package/Libraries/Components/RefreshControl/RefreshControl.js +9 -9
  55. package/Libraries/Components/ScrollView/ScrollView.js +32 -26
  56. package/Libraries/Components/ScrollView/ScrollViewCommands.js +2 -2
  57. package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +2 -2
  58. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  59. package/Libraries/Components/ScrollView/processDecelerationRate.js +1 -1
  60. package/Libraries/Components/Sound/SoundManager.js +1 -1
  61. package/Libraries/Components/StaticRenderer.js +4 -4
  62. package/Libraries/Components/StatusBar/StatusBar.js +33 -18
  63. package/Libraries/Components/Switch/Switch.js +6 -6
  64. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +31 -31
  65. package/Libraries/Components/TextInput/InputAccessoryView.js +2 -2
  66. package/Libraries/Components/TextInput/TextInput.flow.js +35 -35
  67. package/Libraries/Components/TextInput/TextInput.js +35 -35
  68. package/Libraries/Components/TextInput/TextInput.win32.js +35 -35
  69. package/Libraries/Components/TextInput/TextInputNativeCommands.js +1 -1
  70. package/Libraries/Components/ToastAndroid/ToastAndroid.d.ts +68 -6
  71. package/Libraries/Components/Touchable/TouchableBounce.js +5 -5
  72. package/Libraries/Components/Touchable/TouchableHighlight.js +11 -11
  73. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +14 -14
  74. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +6 -6
  75. package/Libraries/Components/Touchable/TouchableOpacity.js +6 -6
  76. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -2
  77. package/Libraries/Components/UnimplementedViews/UnimplementedView.js +9 -1
  78. package/Libraries/Components/View/ViewAccessibility.js +2 -2
  79. package/Libraries/Components/View/ViewAccessibility.win32.js +2 -2
  80. package/Libraries/Components/View/ViewPropTypes.js +22 -22
  81. package/Libraries/Components/View/ViewPropTypes.win32.js +22 -22
  82. package/Libraries/Core/RawEventEmitter.js +2 -2
  83. package/Libraries/Core/ReactNativeVersion.js +3 -5
  84. package/Libraries/Core/Timers/JSTimers.js +3 -3
  85. package/Libraries/Core/polyfillPromise.js +1 -1
  86. package/Libraries/Core/registerCallableModule.js +1 -1
  87. package/Libraries/Core/setUpAlert.js +1 -1
  88. package/Libraries/Core/setUpDeveloperTools.js +0 -2
  89. package/Libraries/Core/setUpErrorHandling.js +6 -1
  90. package/Libraries/Core/setUpReactDevTools.js +1 -1
  91. package/Libraries/Core/setUpTimers.js +35 -56
  92. package/Libraries/Core/setUpXHR.js +5 -5
  93. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -1
  94. package/Libraries/Events/CustomEvent.js +2 -2
  95. package/Libraries/Image/AssetRegistry.js +6 -1
  96. package/Libraries/Image/AssetSourceResolver.js +2 -2
  97. package/Libraries/Image/ImageProps.js +17 -17
  98. package/Libraries/Image/nativeImageSource.js +2 -2
  99. package/Libraries/Inspector/ElementProperties.js +4 -3
  100. package/Libraries/Inspector/Inspector.js +1 -1
  101. package/Libraries/Inspector/Inspector.win32.js +1 -1
  102. package/Libraries/Inspector/InspectorOverlay.js +4 -3
  103. package/Libraries/Inspector/InspectorOverlay.win32.js +3 -3
  104. package/Libraries/Inspector/InspectorPanel.js +6 -6
  105. package/Libraries/Inspector/NetworkOverlay.js +6 -5
  106. package/Libraries/Inspector/PerformanceOverlay.js +2 -1
  107. package/Libraries/Inspector/resolveBoxStyle.js +2 -2
  108. package/Libraries/Interaction/InteractionManager.js +3 -2
  109. package/Libraries/Interaction/PanResponder.js +6 -6
  110. package/Libraries/Interaction/TouchHistoryMath.js +26 -0
  111. package/Libraries/JSInspector/NetworkAgent.js +2 -1
  112. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
  113. package/Libraries/Linking/Linking.js +0 -1
  114. package/Libraries/Lists/FlatList.js +9 -10
  115. package/Libraries/Lists/SectionList.js +7 -9
  116. package/Libraries/Lists/SectionListModern.js +6 -6
  117. package/Libraries/LogBox/Data/LogBoxData.js +14 -14
  118. package/Libraries/LogBox/Data/LogBoxLog.js +51 -29
  119. package/Libraries/LogBox/Data/parseLogBoxLog.js +10 -10
  120. package/Libraries/LogBox/LogBox.js +13 -1
  121. package/Libraries/LogBox/LogBoxInspectorContainer.js +3 -3
  122. package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -3
  123. package/Libraries/LogBox/UI/LogBoxButton.js +4 -4
  124. package/Libraries/LogBox/UI/LogBoxInspectorBody.js +8 -2
  125. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +50 -31
  126. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +50 -31
  127. package/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js +2 -2
  128. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +2 -2
  129. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +2 -2
  130. package/Libraries/LogBox/UI/LogBoxInspectorSection.js +2 -2
  131. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +2 -2
  132. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +2 -2
  133. package/Libraries/Modal/Modal.js +7 -7
  134. package/Libraries/Network/XMLHttpRequest.js +1 -1
  135. package/Libraries/Network/convertRequestBody.js +3 -1
  136. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +4 -4
  137. package/Libraries/Pressability/Pressability.js +10 -10
  138. package/Libraries/Pressability/Pressability.win32.js +10 -10
  139. package/Libraries/Pressability/PressabilityDebug.js +2 -2
  140. package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +2 -2
  141. package/Libraries/Promise.js +2 -2
  142. package/Libraries/ReactNative/AppContainer.js +2 -2
  143. package/Libraries/ReactNative/BridgelessUIManager.js +3 -8
  144. package/Libraries/ReactNative/I18nManager.js +3 -2
  145. package/Libraries/ReactNative/PaperUIManager.js +1 -1
  146. package/Libraries/ReactNative/PaperUIManager.win32.js +1 -1
  147. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +2 -2
  148. package/Libraries/ReactNative/ReactNativeRuntimeDiagnostics.js +2 -2
  149. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +3 -2
  150. package/Libraries/StyleSheet/Rect.js +2 -2
  151. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  152. package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
  153. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
  154. package/Libraries/StyleSheet/private/_TransformStyle.js +18 -18
  155. package/Libraries/StyleSheet/processBackgroundImage.js +138 -136
  156. package/Libraries/Text/TextAncestor.js +1 -2
  157. package/Libraries/TurboModule/TurboModuleRegistry.js +1 -1
  158. package/Libraries/Types/CodegenTypes.js +2 -1
  159. package/Libraries/Types/CoreEventTypes.js +40 -40
  160. package/Libraries/Types/CoreEventTypes.win32.js +40 -40
  161. package/Libraries/UTFSequence.js +2 -2
  162. package/Libraries/Utilities/BackHandler.android.js +2 -2
  163. package/Libraries/Utilities/BackHandler.ios.js +2 -2
  164. package/Libraries/Utilities/BackHandler.win32.js +2 -2
  165. package/Libraries/Utilities/HMRClient.js +2 -2
  166. package/Libraries/Utilities/Platform.android.js +4 -4
  167. package/Libraries/Utilities/Platform.flow.js +8 -8
  168. package/Libraries/Utilities/Platform.flow.win32.js +8 -8
  169. package/Libraries/Utilities/Platform.ios.js +4 -4
  170. package/Libraries/Utilities/Platform.win32.js +2 -2
  171. package/Libraries/Utilities/ReactNativeTestTools.js +3 -2
  172. package/Libraries/Utilities/codegenNativeCommands.js +2 -2
  173. package/Libraries/Utilities/codegenNativeComponent.js +2 -2
  174. package/Libraries/Utilities/differ/deepDiffer.js +3 -3
  175. package/Libraries/Utilities/stringifySafe.js +2 -2
  176. package/Libraries/Vibration/Vibration.js +1 -1
  177. package/Libraries/WebSocket/WebSocketEvent.js +1 -1
  178. package/Libraries/YellowBox/YellowBoxDeprecated.js +4 -3
  179. package/Libraries/vendor/core/ErrorUtils.js +1 -1
  180. package/flow/jest.js +14 -14
  181. package/index.js +16 -13
  182. package/index.win32.js +16 -13
  183. package/jest/setup.js +214 -197
  184. package/overrides.json +26 -26
  185. package/package.json +16 -16
  186. package/src/private/featureflags/ReactNativeFeatureFlags.js +11 -30
  187. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +3 -2
  188. package/src/private/specs/components/ActivityIndicatorViewNativeComponent.js +2 -2
  189. package/src/private/specs/components/AndroidDrawerLayoutNativeComponent.js +6 -6
  190. package/src/private/specs/components/AndroidHorizontalScrollContentViewNativeComponent.js +2 -2
  191. package/src/private/specs/components/AndroidSwipeRefreshLayoutNativeComponent.js +2 -2
  192. package/src/private/specs/components/AndroidSwitchNativeComponent.js +4 -4
  193. package/src/private/specs/components/DebuggingOverlayNativeComponent.js +2 -2
  194. package/src/private/specs/components/ProgressBarAndroidNativeComponent.js +2 -2
  195. package/src/private/specs/components/PullToRefreshViewNativeComponent.js +2 -2
  196. package/src/private/specs/components/RCTInputAccessoryViewNativeComponent.js +2 -2
  197. package/src/private/specs/components/RCTModalHostViewNativeComponent.js +4 -4
  198. package/src/private/specs/components/RCTSafeAreaViewNativeComponent.js +2 -2
  199. package/src/private/specs/components/SwitchNativeComponent.js +4 -4
  200. package/src/private/specs/components/UnimplementedNativeViewNativeComponent.js +2 -2
  201. package/src/private/specs/modules/NativeAccessibilityManager.js +2 -2
  202. package/src/private/specs/modules/NativeActionSheetManager.js +7 -7
  203. package/src/private/specs/modules/NativeAlertManager.js +2 -2
  204. package/src/private/specs/modules/NativeAnimatedModule.js +2 -2
  205. package/src/private/specs/modules/NativeAnimatedTurboModule.js +2 -2
  206. package/src/private/specs/modules/NativeAppState.js +3 -3
  207. package/src/private/specs/modules/NativeBlobModule.js +1 -1
  208. package/src/private/specs/modules/NativeClipboard.js +1 -1
  209. package/src/private/specs/modules/NativeDeviceInfo.js +8 -8
  210. package/src/private/specs/modules/NativeDialogManagerAndroid.js +4 -4
  211. package/src/private/specs/modules/NativeExceptionsManager.js +2 -2
  212. package/src/private/specs/modules/NativeFantom.js +6 -0
  213. package/src/private/specs/modules/NativeFrameRateLogger.js +1 -1
  214. package/src/private/specs/modules/NativeI18nManager.js +2 -2
  215. package/src/private/specs/modules/NativeImageEditor.js +9 -9
  216. package/src/private/specs/modules/NativeImageLoaderAndroid.js +1 -1
  217. package/src/private/specs/modules/NativeImageLoaderIOS.js +1 -1
  218. package/src/private/specs/modules/NativeImageLoaderWin32.js +1 -1
  219. package/src/private/specs/modules/NativeImageStoreAndroid.js +1 -1
  220. package/src/private/specs/modules/NativeImageStoreIOS.js +3 -3
  221. package/src/private/specs/modules/NativeNetworkingIOS.js +2 -2
  222. package/src/private/specs/modules/NativePlatformConstantsAndroid.js +4 -4
  223. package/src/private/specs/modules/NativePlatformConstantsIOS.js +4 -4
  224. package/src/private/specs/modules/NativePlatformConstantsWin.js +5 -10
  225. package/src/private/specs/modules/NativePushNotificationManagerIOS.js +7 -7
  226. package/src/private/specs/modules/NativeSampleTurboModule.js +2 -2
  227. package/src/private/specs/modules/NativeSettingsManager.js +2 -2
  228. package/src/private/specs/modules/NativeShareModule.js +3 -3
  229. package/src/private/specs/modules/NativeSourceCode.js +2 -2
  230. package/src/private/specs/modules/NativeStatusBarManagerAndroid.js +4 -4
  231. package/src/private/specs/modules/NativeStatusBarManagerIOS.js +6 -6
  232. package/src/private/specs/modules/NativeToastAndroid.js +2 -2
  233. package/src/private/specs/modules/NativeVibration.js +1 -1
  234. package/src/private/specs/modules/NativeWebSocketModule.js +1 -1
  235. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +2 -2
  236. package/src/private/webapis/intersectionobserver/{IntersectionObserverManager.js → internals/IntersectionObserverManager.js} +9 -9
  237. package/src/private/webapis/mutationobserver/MutationObserver.js +2 -2
  238. package/src/private/webapis/mutationobserver/{MutationObserverManager.js → internals/MutationObserverManager.js} +8 -8
  239. package/src/private/webapis/performance/EventTiming.js +1 -1
  240. package/src/private/webapis/performance/Performance.js +3 -3
  241. package/src/private/webapis/performance/PerformanceObserver.js +2 -2
  242. package/src/private/webapis/performance/{RawPerformanceEntry.js → internals/RawPerformanceEntry.js} +6 -6
  243. package/src/private/webapis/performance/{Utilities.js → internals/Utilities.js} +1 -1
  244. package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +1 -1
@@ -10,7 +10,8 @@
10
10
  'use strict';
11
11
 
12
12
  const invariant = require('invariant');
13
- const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');
13
+ const BatchedBridge =
14
+ require('react-native/Libraries/BatchedBridge/BatchedBridge').default;
14
15
 
15
16
  const LoggingTestModule = {
16
17
  logToConsole: function (str) {
@@ -10,69 +10,77 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const React = require('react');
14
- const ReactNative = require('react-native');
15
- const {View} = ReactNative;
16
- const {TestModule} = ReactNative.NativeModules;
13
+ import * as React from 'react';
14
+ import {useEffect, useRef} from 'react';
15
+ import {NativeModules, View} from 'react-native';
17
16
 
18
- class PromiseTest extends React.Component<{...}> {
19
- shouldResolve: boolean = false;
20
- shouldReject: boolean = false;
21
- shouldSucceedAsync: boolean = false;
22
- shouldThrowAsync: boolean = false;
17
+ const {TestModule} = NativeModules;
23
18
 
24
- componentDidMount() {
25
- // $FlowFixMe[unused-promise]
26
- Promise.all([
27
- this.testShouldResolve(),
28
- this.testShouldReject(),
29
- this.testShouldSucceedAsync(),
30
- this.testShouldThrowAsync(),
31
- ]).then(() =>
32
- TestModule.markTestPassed(
33
- this.shouldResolve &&
34
- this.shouldReject &&
35
- this.shouldSucceedAsync &&
36
- this.shouldThrowAsync,
37
- ),
38
- );
39
- }
19
+ function PromiseTest(): React.Node {
20
+ const shouldResolve = useRef(false);
21
+ const shouldReject = useRef(false);
22
+ const shouldSucceedAsync = useRef(false);
23
+ const shouldThrowAsync = useRef(false);
40
24
 
41
- testShouldResolve: () => any = () => {
25
+ const testShouldResolve = () => {
42
26
  return TestModule.shouldResolve()
43
- .then(() => (this.shouldResolve = true))
44
- .catch(() => (this.shouldResolve = false));
27
+ .then(() => {
28
+ shouldResolve.current = true;
29
+ })
30
+ .catch(() => {
31
+ shouldResolve.current = false;
32
+ });
45
33
  };
46
34
 
47
- testShouldReject: () => any = () => {
35
+ const testShouldReject = () => {
48
36
  return TestModule.shouldReject()
49
- .then(() => (this.shouldReject = false))
50
- .catch(() => (this.shouldReject = true));
37
+ .then(() => {
38
+ shouldReject.current = false;
39
+ })
40
+ .catch(() => {
41
+ shouldReject.current = true;
42
+ });
51
43
  };
52
44
 
53
- testShouldSucceedAsync: () => Promise<any> = async (): Promise<any> => {
45
+ const testShouldSucceedAsync = async () => {
54
46
  try {
55
47
  await TestModule.shouldResolve();
56
- this.shouldSucceedAsync = true;
48
+ shouldSucceedAsync.current = true;
57
49
  } catch (e) {
58
- this.shouldSucceedAsync = false;
50
+ shouldSucceedAsync.current = false;
59
51
  }
60
52
  };
61
53
 
62
- testShouldThrowAsync: () => Promise<any> = async (): Promise<any> => {
54
+ const testShouldThrowAsync = async () => {
63
55
  try {
64
56
  await TestModule.shouldReject();
65
- this.shouldThrowAsync = false;
57
+ shouldThrowAsync.current = false;
66
58
  } catch (e) {
67
- this.shouldThrowAsync = true;
59
+ shouldThrowAsync.current = true;
68
60
  }
69
61
  };
70
62
 
71
- render(): React.Node {
72
- return <View />;
73
- }
74
- }
63
+ useEffect(() => {
64
+ async function runTests() {
65
+ await Promise.all([
66
+ testShouldResolve(),
67
+ testShouldReject(),
68
+ testShouldSucceedAsync(),
69
+ testShouldThrowAsync(),
70
+ ]);
75
71
 
76
- PromiseTest.displayName = 'PromiseTest';
72
+ TestModule.markTestPassed(
73
+ shouldResolve.current &&
74
+ shouldReject.current &&
75
+ shouldSucceedAsync.current &&
76
+ shouldThrowAsync.current,
77
+ );
78
+ }
79
+
80
+ runTests().catch(console.error);
81
+ }, []);
82
+
83
+ return <View />;
84
+ }
77
85
 
78
- module.exports = PromiseTest;
86
+ export default PromiseTest;
@@ -10,32 +10,29 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const React = require('react');
14
- const ReactNative = require('react-native');
13
+ import * as React from 'react';
14
+ import {useEffect} from 'react';
15
+ import {NativeModules, StyleSheet, View} from 'react-native';
15
16
 
16
- const {StyleSheet, View} = ReactNative;
17
- const {TestModule} = ReactNative.NativeModules;
17
+ const {TestModule} = NativeModules;
18
18
 
19
- class SimpleSnapshotTest extends React.Component<{...}> {
20
- componentDidMount(): void {
19
+ function SimpleSnapshotTest(): React.Node {
20
+ const done = (success: boolean) => {
21
+ TestModule.markTestPassed(success);
22
+ };
23
+ useEffect(() => {
21
24
  if (!TestModule.verifySnapshot) {
22
25
  throw new Error('TestModule.verifySnapshot not defined.');
23
26
  }
24
- requestAnimationFrame(() => TestModule.verifySnapshot(this.done));
25
- }
26
-
27
- done: (success: boolean) => void = (success: boolean) => {
28
- TestModule.markTestPassed(success);
29
- };
30
-
31
- render(): React.Node {
32
- return (
33
- <View style={styles.container}>
34
- <View style={styles.box1} />
35
- <View style={styles.box2} />
36
- </View>
37
- );
38
- }
27
+ requestAnimationFrame(() => TestModule.verifySnapshot(done));
28
+ }, []);
29
+
30
+ return (
31
+ <View style={styles.container}>
32
+ <View style={styles.box1} />
33
+ <View style={styles.box2} />
34
+ </View>
35
+ );
39
36
  }
40
37
 
41
38
  const styles = StyleSheet.create({
@@ -57,6 +54,4 @@ const styles = StyleSheet.create({
57
54
  },
58
55
  });
59
56
 
60
- SimpleSnapshotTest.displayName = 'SimpleSnapshotTest';
61
-
62
- module.exports = SimpleSnapshotTest;
57
+ export default SimpleSnapshotTest;
@@ -10,14 +10,14 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const React = require('react');
14
- const ReactNative = require('react-native');
15
- const {View} = ReactNative;
13
+ import * as React from 'react';
14
+ import {useEffect} from 'react';
15
+ import {NativeModules, View} from 'react-native';
16
16
 
17
- const {TestModule, RNTesterTestModule} = ReactNative.NativeModules;
17
+ const {TestModule, RNTesterTestModule} = NativeModules;
18
18
 
19
- class SyncMethodTest extends React.Component<{...}> {
20
- componentDidMount(): void {
19
+ function SyncMethodTest(): React.Node {
20
+ useEffect(() => {
21
21
  if (
22
22
  RNTesterTestModule.echoString('test string value') !== 'test string value'
23
23
  ) {
@@ -41,13 +41,9 @@ class SyncMethodTest extends React.Component<{...}> {
41
41
  );
42
42
  }
43
43
  });
44
- }
44
+ }, []);
45
45
 
46
- render(): React.Node {
47
- return <View />;
48
- }
46
+ return <View />;
49
47
  }
50
48
 
51
- SyncMethodTest.displayName = 'SyncMethodTest';
52
-
53
- module.exports = SyncMethodTest;
49
+ export default SyncMethodTest;
@@ -15,12 +15,12 @@ const ReactNative = require('react-native');
15
15
  const {StyleSheet, Text, View} = ReactNative;
16
16
  const {TestModule} = ReactNative.NativeModules;
17
17
 
18
- type Props = $ReadOnly<{||}>;
18
+ type Props = $ReadOnly<{}>;
19
19
 
20
- type State = {|
20
+ type State = {
21
21
  count: number,
22
22
  done: boolean,
23
- |};
23
+ };
24
24
 
25
25
  type ImmediateID = Object;
26
26
 
@@ -40,7 +40,7 @@ const ActionSheetIOS = {
40
40
  * See https://reactnative.dev/docs/actionsheetios#showactionsheetwithoptions
41
41
  */
42
42
  showActionSheetWithOptions(
43
- options: {|
43
+ options: {
44
44
  +title?: ?string,
45
45
  +message?: ?string,
46
46
  +options: Array<string>,
@@ -52,7 +52,7 @@ const ActionSheetIOS = {
52
52
  +disabledButtonTintColor?: ColorValue | ProcessedColorValue,
53
53
  +userInterfaceStyle?: string,
54
54
  +disabledButtonIndices?: Array<number>,
55
- |},
55
+ },
56
56
  callback: (buttonIndex: number) => void,
57
57
  ) {
58
58
  invariant(
@@ -172,4 +172,4 @@ const ActionSheetIOS = {
172
172
  },
173
173
  };
174
174
 
175
- module.exports = ActionSheetIOS;
175
+ export default ActionSheetIOS;
@@ -174,4 +174,4 @@ class Alert {
174
174
  }
175
175
  }
176
176
 
177
- module.exports = Alert;
177
+ export default Alert;
@@ -93,4 +93,4 @@ class Alert {
93
93
  }
94
94
  }
95
95
 
96
- module.exports = Alert;
96
+ export default Alert;
@@ -11,7 +11,7 @@ import NativeDialogManagerAndroid from '../NativeModules/specs/NativeDialogManag
11
11
 
12
12
  function emptyCallback() {}
13
13
 
14
- module.exports = {
14
+ export default {
15
15
  alertWithArgs: function (args, callback) {
16
16
  // TODO(5998984): Polyfill it correctly with DialogManagerAndroid
17
17
  if (!NativeDialogManagerAndroid) {
@@ -12,7 +12,7 @@ import type {Args} from './NativeAlertManager';
12
12
 
13
13
  import NativeAlertManager from './NativeAlertManager';
14
14
 
15
- module.exports = {
15
+ export default {
16
16
  alertWithArgs(
17
17
  args: Args,
18
18
  callback: (id: number, value: string) => void,
@@ -192,4 +192,4 @@ export default {
192
192
  forkEvent: AnimatedImplementation.forkEvent,
193
193
  unforkEvent: AnimatedImplementation.unforkEvent,
194
194
  Event: AnimatedEvent,
195
- };
195
+ } as typeof AnimatedImplementation;
@@ -10,17 +10,35 @@
10
10
 
11
11
  'use strict';
12
12
 
13
+ import type {AnimatedComponentType} from './createAnimatedComponent';
14
+
13
15
  import AnimatedImplementation from './AnimatedImplementation';
16
+ import React from 'react';
14
17
 
15
18
  export default {
16
19
  ...AnimatedImplementation,
17
- /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive
18
- * types. Plain intrinsic components can't be typed like this */
19
- div: (AnimatedImplementation.createAnimatedComponent('div'): $FlowFixMe),
20
- /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive
21
- * types. Plain intrinsic components can't be typed like this */
22
- span: (AnimatedImplementation.createAnimatedComponent('span'): $FlowFixMe),
23
- /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive
24
- * types. Plain intrinsic components can't be typed like this */
25
- img: (AnimatedImplementation.createAnimatedComponent('img'): $FlowFixMe),
20
+ div: AnimatedImplementation.createAnimatedComponent<
21
+ React.PropsOf<'div'>,
22
+ mixed,
23
+ >(
24
+ /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive
25
+ * types. Plain intrinsic components can't be typed like this */
26
+ 'div',
27
+ ) as AnimatedComponentType<React.PropsOf<'div'>>,
28
+ span: AnimatedImplementation.createAnimatedComponent<
29
+ React.PropsOf<'span'>,
30
+ mixed,
31
+ >(
32
+ /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive
33
+ * types. Plain intrinsic components can't be typed like this */
34
+ 'span',
35
+ ) as AnimatedComponentType<React.PropsOf<'span'>>,
36
+ img: AnimatedImplementation.createAnimatedComponent<
37
+ React.PropsOf<'img'>,
38
+ mixed,
39
+ >(
40
+ /* $FlowFixMe[incompatible-call] createAnimatedComponent expects to receive
41
+ * types. Plain intrinsic components can't be typed like this */
42
+ 'img',
43
+ ) as AnimatedComponentType<React.PropsOf<'img'>>,
26
44
  };
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
12
+ import type {PlatformConfig} from '../AnimatedPlatformConfig';
12
13
  import type Animation, {EndCallback} from '../animations/Animation';
13
14
  import type {InterpolationConfigType} from './AnimatedInterpolation';
14
15
  import type AnimatedNode from './AnimatedNode';
@@ -84,6 +85,7 @@ function _executeAsAnimatedBatch(id: string, operation: () => void) {
84
85
  * See https://reactnative.dev/docs/animatedvalue
85
86
  */
86
87
  export default class AnimatedValue extends AnimatedWithChildren {
88
+ #listenerCount: number = 0;
87
89
  #updateSubscription: ?EventSubscription = null;
88
90
 
89
91
  _value: number;
@@ -105,20 +107,8 @@ export default class AnimatedValue extends AnimatedWithChildren {
105
107
  }
106
108
  }
107
109
 
108
- __attach(): void {
110
+ __detach() {
109
111
  if (this.__isNative) {
110
- // NOTE: In theory, we should only need to call this when any listeners
111
- // are added. However, there is a global `onUserDrivenAnimationEnded`
112
- // listener that relies on `onAnimatedValueUpdate` having fired to update
113
- // the values in JavaScript. If that listener is removed, this could be
114
- // re-optimized.
115
- this.#ensureUpdateSubscriptionExists();
116
- }
117
- }
118
-
119
- __detach(): void {
120
- if (this.__isNative) {
121
- this.#updateSubscription?.remove();
122
112
  NativeAnimatedAPI.getValue(this.__getNativeTag(), value => {
123
113
  this._value = value - this._offset;
124
114
  });
@@ -131,6 +121,38 @@ export default class AnimatedValue extends AnimatedWithChildren {
131
121
  return this._value + this._offset;
132
122
  }
133
123
 
124
+ __makeNative(platformConfig: ?PlatformConfig): void {
125
+ super.__makeNative(platformConfig);
126
+ if (this.#listenerCount > 0) {
127
+ this.#ensureUpdateSubscriptionExists();
128
+ }
129
+ }
130
+
131
+ addListener(callback: (value: any) => mixed): string {
132
+ const id = super.addListener(callback);
133
+ this.#listenerCount++;
134
+ if (this.__isNative) {
135
+ this.#ensureUpdateSubscriptionExists();
136
+ }
137
+ return id;
138
+ }
139
+
140
+ removeListener(id: string): void {
141
+ super.removeListener(id);
142
+ this.#listenerCount--;
143
+ if (this.__isNative && this.#listenerCount === 0) {
144
+ this.#updateSubscription?.remove();
145
+ }
146
+ }
147
+
148
+ removeAllListeners(): void {
149
+ super.removeAllListeners();
150
+ this.#listenerCount = 0;
151
+ if (this.__isNative) {
152
+ this.#updateSubscription?.remove();
153
+ }
154
+ }
155
+
134
156
  #ensureUpdateSubscriptionExists(): void {
135
157
  if (this.#updateSubscription != null) {
136
158
  return;
@@ -17,13 +17,13 @@ import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNa
17
17
  import {isPublicInstance as isFabricPublicInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils';
18
18
  import useRefEffect from '../Utilities/useRefEffect';
19
19
  import {AnimatedEvent} from './AnimatedEvent';
20
+ import AnimatedNode from './nodes/AnimatedNode';
20
21
  import AnimatedProps from './nodes/AnimatedProps';
22
+ import AnimatedValue from './nodes/AnimatedValue';
21
23
  import {
22
24
  useCallback,
23
25
  useEffect,
24
26
  useInsertionEffect,
25
- useLayoutEffect,
26
- useMemo,
27
27
  useReducer,
28
28
  useRef,
29
29
  } from 'react';
@@ -37,10 +37,10 @@ type CallbackRef<T> = T => mixed;
37
37
 
38
38
  type UpdateCallback = () => void;
39
39
 
40
- const useMemoOrAnimatedPropsMemo =
41
- ReactNativeFeatureFlags.enableAnimatedPropsMemo()
42
- ? useAnimatedPropsMemo
43
- : useMemo;
40
+ type AnimatedValueListeners = Array<{
41
+ propValue: AnimatedValue,
42
+ listenerId: string,
43
+ }>;
44
44
 
45
45
  export default function useAnimatedProps<TProps: {...}, TInstance>(
46
46
  props: TProps,
@@ -50,28 +50,14 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
50
50
  const onUpdateRef = useRef<UpdateCallback | null>(null);
51
51
  const timerRef = useRef<TimeoutID | null>(null);
52
52
 
53
- const allowlistIfEnabled = ReactNativeFeatureFlags.enableAnimatedAllowlist()
54
- ? allowlist
55
- : null;
56
-
57
- const node = useMemoOrAnimatedPropsMemo(
58
- () =>
59
- new AnimatedProps(
60
- props,
61
- () => onUpdateRef.current?.(),
62
- allowlistIfEnabled,
63
- ),
64
- [allowlistIfEnabled, props],
53
+ const node = useAnimatedPropsMemo(
54
+ () => new AnimatedProps(props, () => onUpdateRef.current?.(), allowlist),
55
+ [allowlist, props],
65
56
  );
66
57
 
67
58
  const useNativePropsInFabric =
68
59
  ReactNativeFeatureFlags.shouldUseSetNativePropsInFabric();
69
60
 
70
- const useAnimatedPropsLifecycle =
71
- ReactNativeFeatureFlags.useInsertionEffectsForAnimations()
72
- ? useAnimatedPropsLifecycle_insertionEffects
73
- : useAnimatedPropsLifecycle_layoutEffects;
74
-
75
61
  useAnimatedPropsLifecycle(node);
76
62
 
77
63
  // TODO: This "effect" does three things:
@@ -162,6 +148,7 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
162
148
 
163
149
  const target = getEventTarget(instance);
164
150
  const events = [];
151
+ const animatedValueListeners: AnimatedValueListeners = [];
165
152
 
166
153
  for (const propName in props) {
167
154
  // $FlowFixMe[invalid-computed-prop]
@@ -169,6 +156,8 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
169
156
  if (propValue instanceof AnimatedEvent && propValue.__isNative) {
170
157
  propValue.__attach(target, propName);
171
158
  events.push([propName, propValue]);
159
+ // $FlowFixMe[incompatible-call] - the `addListenersToPropsValue` drills down the propValue.
160
+ addListenersToPropsValue(propValue, animatedValueListeners);
172
161
  }
173
162
  }
174
163
 
@@ -178,6 +167,10 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
178
167
  for (const [propName, propValue] of events) {
179
168
  propValue.__detach(target, propName);
180
169
  }
170
+
171
+ for (const {propValue, listenerId} of animatedValueListeners) {
172
+ propValue.removeListener(listenerId);
173
+ }
181
174
  };
182
175
  },
183
176
  [node, useNativePropsInFabric, props],
@@ -194,13 +187,40 @@ function reduceAnimatedProps<TProps>(
194
187
  // Force `collapsable` to be false so that the native view is not flattened.
195
188
  // Flattened views cannot be accurately referenced by the native driver.
196
189
  return {
197
- ...(ReactNativeFeatureFlags.enableAnimatedPropsMemo()
198
- ? node.__getValueWithStaticProps(props)
199
- : node.__getValue()),
190
+ ...node.__getValueWithStaticProps(props),
200
191
  collapsable: false,
201
192
  };
202
193
  }
203
194
 
195
+ function addListenersToPropsValue(
196
+ propValue: AnimatedValue,
197
+ accumulator: AnimatedValueListeners,
198
+ ) {
199
+ // propValue can be a scalar value, an array or an object.
200
+ if (propValue instanceof AnimatedValue) {
201
+ const listenerId = propValue.addListener(() => {});
202
+ accumulator.push({propValue, listenerId});
203
+ } else if (Array.isArray(propValue)) {
204
+ // An array can be an array of scalar values, arrays of arrays, or arrays of objects
205
+ for (const prop of propValue) {
206
+ addListenersToPropsValue(prop, accumulator);
207
+ }
208
+ } else if (propValue instanceof Object) {
209
+ addAnimatedValuesListenersToProps(propValue, accumulator);
210
+ }
211
+ }
212
+
213
+ function addAnimatedValuesListenersToProps(
214
+ props: AnimatedNode,
215
+ accumulator: AnimatedValueListeners,
216
+ ) {
217
+ for (const propName in props) {
218
+ // $FlowFixMe[prop-missing] - This is an object contained in a prop, but we don't know the exact type.
219
+ const propValue = props[propName];
220
+ addListenersToPropsValue(propValue, accumulator);
221
+ }
222
+ }
223
+
204
224
  /**
205
225
  * Manages the lifecycle of the supplied `AnimatedProps` by invoking `__attach`
206
226
  * and `__detach`. However, this is more complicated because `AnimatedProps`
@@ -208,7 +228,7 @@ function reduceAnimatedProps<TProps>(
208
228
  * nodes. So in order to optimize this, we avoid detaching until the next attach
209
229
  * unless we are unmounting.
210
230
  */
211
- function useAnimatedPropsLifecycle_layoutEffects(node: AnimatedProps): void {
231
+ function useAnimatedPropsLifecycle(node: AnimatedProps): void {
212
232
  const prevNodeRef = useRef<?AnimatedProps>(null);
213
233
  const isUnmountingRef = useRef<boolean>(false);
214
234
 
@@ -233,51 +253,6 @@ function useAnimatedPropsLifecycle_layoutEffects(node: AnimatedProps): void {
233
253
  };
234
254
  });
235
255
 
236
- useLayoutEffect(() => {
237
- isUnmountingRef.current = false;
238
- return () => {
239
- isUnmountingRef.current = true;
240
- };
241
- }, []);
242
-
243
- useLayoutEffect(() => {
244
- node.__attach();
245
- if (prevNodeRef.current != null) {
246
- const prevNode = prevNodeRef.current;
247
- // TODO: Stop restoring default values (unless `reset` is called).
248
- prevNode.__restoreDefaultValues();
249
- prevNode.__detach();
250
- prevNodeRef.current = null;
251
- }
252
- return () => {
253
- if (isUnmountingRef.current) {
254
- // NOTE: Do not restore default values on unmount, see D18197735.
255
- node.__detach();
256
- } else {
257
- prevNodeRef.current = node;
258
- }
259
- };
260
- }, [node]);
261
- }
262
-
263
- /**
264
- * Manages the lifecycle of the supplied `AnimatedProps` by invoking `__attach`
265
- * and `__detach`. However, this is more complicated because `AnimatedProps`
266
- * uses reference counting to determine when to recursively detach its children
267
- * nodes. So in order to optimize this, we avoid detaching until the next attach
268
- * unless we are unmounting.
269
- */
270
- function useAnimatedPropsLifecycle_insertionEffects(node: AnimatedProps): void {
271
- const prevNodeRef = useRef<?AnimatedProps>(null);
272
- const isUnmountingRef = useRef<boolean>(false);
273
-
274
- useEffect(() => {
275
- // It is ok for multiple components to call `flushQueue` because it noops
276
- // if the queue is empty. When multiple animated components are mounted at
277
- // the same time. Only first component flushes the queue and the others will noop.
278
- NativeAnimatedHelper.API.flushQueue();
279
- });
280
-
281
256
  useInsertionEffect(() => {
282
257
  isUnmountingRef.current = false;
283
258
  return () => {
@@ -287,17 +262,6 @@ function useAnimatedPropsLifecycle_insertionEffects(node: AnimatedProps): void {
287
262
 
288
263
  useInsertionEffect(() => {
289
264
  node.__attach();
290
- let drivenAnimationEndedListener: ?EventSubscription = null;
291
-
292
- if (node.__isNative) {
293
- drivenAnimationEndedListener =
294
- NativeAnimatedHelper.nativeEventEmitter.addListener(
295
- 'onUserDrivenAnimationEnded',
296
- data => {
297
- node.update();
298
- },
299
- );
300
- }
301
265
  if (prevNodeRef.current != null) {
302
266
  const prevNode = prevNodeRef.current;
303
267
  // TODO: Stop restoring default values (unless `reset` is called).
@@ -312,8 +276,6 @@ function useAnimatedPropsLifecycle_insertionEffects(node: AnimatedProps): void {
312
276
  } else {
313
277
  prevNodeRef.current = node;
314
278
  }
315
-
316
- drivenAnimationEndedListener?.remove();
317
279
  };
318
280
  }, [node]);
319
281
  }
@@ -125,4 +125,4 @@ class AppState {
125
125
  }
126
126
  }
127
127
 
128
- module.exports = (new AppState(): AppState);
128
+ export default (new AppState(): AppState);
@@ -10,7 +10,9 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const MessageQueue = require('./MessageQueue');
13
+ import typeof MessageQueueT from './MessageQueue';
14
+
15
+ const MessageQueue: MessageQueueT = require('./MessageQueue').default;
14
16
 
15
17
  const BatchedBridge: MessageQueue = new MessageQueue();
16
18
 
@@ -25,4 +27,4 @@ Object.defineProperty(global, '__fbBatchedBridge', {
25
27
  value: BatchedBridge,
26
28
  });
27
29
 
28
- module.exports = BatchedBridge;
30
+ export default BatchedBridge;