@office-iss/react-native-win32 0.0.0-canary.282 → 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 +79 -1
  3. package/CHANGELOG.md +28 -4
  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
@@ -32,11 +32,14 @@ const TESTS = [
32
32
  require('./GlobalEvalWithSourceUrlTest'),
33
33
  ];
34
34
 
35
- TESTS.forEach(
36
- /* $FlowFixMe[incompatible-call] (>=0.54.0 site=react_native_fb,react_native_
37
- * oss) This comment suppresses an error found when Flow v0.54 was deployed.
38
- * To see the error delete this comment and run Flow. */
39
- test => AppRegistry.registerComponent(test.displayName, () => test),
35
+ TESTS.forEach(test =>
36
+ AppRegistry.registerComponent(
37
+ test.displayName || test.name || '',
38
+ /* $FlowFixMe[incompatible-call] (>=0.54.0 site=react_native_fb,react_native_
39
+ * oss) This comment suppresses an error found when Flow v0.54 was deployed.
40
+ * To see the error delete this comment and run Flow. */
41
+ () => test,
42
+ ),
40
43
  );
41
44
 
42
45
  // Modules required for integration tests
@@ -78,7 +81,9 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> {
78
81
  * deployed. To see the error, delete this comment and run Flow.
79
82
  */
80
83
  style={styles.row}>
81
- <Text style={styles.testName}>{test.displayName}</Text>
84
+ <Text style={styles.testName}>
85
+ {test.displayName || test.name}
86
+ </Text>
82
87
  </TouchableOpacity>,
83
88
  <View style={styles.separator} />,
84
89
  ])}
@@ -26,7 +26,7 @@ function debug(...args: Array<void | Layout | string>) {
26
26
  // console.log.apply(null, arguments);
27
27
  }
28
28
 
29
- type Props = $ReadOnly<{||}>;
29
+ type Props = $ReadOnly<{}>;
30
30
 
31
31
  type State = {
32
32
  didAnimation: boolean,
@@ -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;