@office-iss/react-native-win32 0.72.6 → 0.73.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 (272) hide show
  1. package/.flowconfig +15 -4
  2. package/CHANGELOG.json +531 -87
  3. package/CHANGELOG.md +213 -48
  4. package/IntegrationTests/PromiseTest.js +1 -0
  5. package/IntegrationTests/websocket_integration_test_server.js +1 -1
  6. package/Libraries/Animated/Animated.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +1 -1
  8. package/Libraries/Animated/NativeAnimatedHelper.js +14 -10
  9. package/Libraries/Animated/NativeAnimatedHelper.win32.js +16 -12
  10. package/Libraries/Animated/NativeAnimatedModule.js +6 -2
  11. package/Libraries/Animated/NativeAnimatedTurboModule.js +7 -4
  12. package/Libraries/Animated/animations/Animation.js +57 -3
  13. package/Libraries/Animated/animations/DecayAnimation.js +9 -0
  14. package/Libraries/Animated/animations/SpringAnimation.js +8 -0
  15. package/Libraries/Animated/animations/TimingAnimation.js +8 -0
  16. package/Libraries/Animated/components/AnimatedFlatList.js +2 -1
  17. package/Libraries/Animated/components/AnimatedScrollView.js +2 -0
  18. package/Libraries/Animated/components/AnimatedSectionList.js +2 -1
  19. package/Libraries/Animated/createAnimatedComponent.js +1 -0
  20. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  21. package/Libraries/Animated/nodes/AnimatedObject.js +146 -0
  22. package/Libraries/Animated/nodes/AnimatedProps.js +19 -7
  23. package/Libraries/Animated/nodes/AnimatedStyle.js +29 -55
  24. package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -17
  25. package/Libraries/Animated/shouldUseTurboAnimatedModule.js +17 -0
  26. package/Libraries/Animated/useAnimatedProps.js +9 -10
  27. package/Libraries/AppState/AppState.d.ts +1 -1
  28. package/Libraries/AppState/NativeAppState.js +8 -4
  29. package/Libraries/BatchedBridge/MessageQueue.js +45 -36
  30. package/Libraries/Blob/Blob.js +6 -2
  31. package/Libraries/Blob/BlobManager.js +9 -10
  32. package/Libraries/Blob/BlobRegistry.js +14 -9
  33. package/Libraries/Blob/File.js +1 -1
  34. package/Libraries/Blob/FileReader.js +1 -2
  35. package/Libraries/Components/Button/ButtonWin32.Props.d.ts +1 -1
  36. package/Libraries/Components/Button/ButtonWin32.Props.js.map +1 -1
  37. package/Libraries/Components/Button/ButtonWin32.d.ts +1 -1
  38. package/Libraries/Components/Button/ButtonWin32.js +1 -4
  39. package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
  40. package/Libraries/Components/Clipboard/Clipboard.d.ts +4 -4
  41. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +3 -1
  42. package/Libraries/Components/EnterString.win32.d.ts +1 -1
  43. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +26 -6
  44. package/Libraries/Components/Pressable/Pressable.js +3 -2
  45. package/Libraries/Components/Pressable/Pressable.win32.js +4 -3
  46. package/Libraries/Components/Pressable/useAndroidRippleForView.js +1 -1
  47. package/Libraries/Components/SafeAreaView/SafeAreaView.js +7 -7
  48. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +7 -8
  49. package/Libraries/Components/ScrollView/ScrollView.js +3 -1
  50. package/Libraries/Components/ScrollView/ScrollView.win32.js +3 -1
  51. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +39 -46
  52. package/Libraries/Components/Switch/Switch.js +1 -0
  53. package/Libraries/Components/Text/TextWin32.d.ts +1 -1
  54. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  55. package/Libraries/Components/TextInput/TextInput.d.ts +49 -7
  56. package/Libraries/Components/TextInput/TextInput.flow.js +43 -10
  57. package/Libraries/Components/TextInput/TextInput.js +62 -10
  58. package/Libraries/Components/TextInput/TextInput.win32.js +953 -206
  59. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +23 -0
  60. package/Libraries/Components/ToastAndroid/{ToastAndroid.ios.js → ToastAndroid.js} +9 -1
  61. package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +9 -1
  62. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +2 -2
  63. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  64. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  65. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  66. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  67. package/Libraries/Components/Touchable/TouchableOpacity.js +4 -1
  68. package/Libraries/Components/Touchable/TouchableWin32.d.ts +1 -1
  69. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  70. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -0
  71. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +16 -6
  72. package/Libraries/Components/View/ReactNativeStyleAttributes.js +9 -0
  73. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  74. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  75. package/Libraries/Components/View/View.js +46 -32
  76. package/Libraries/Components/View/View.win32.js +37 -6
  77. package/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  78. package/Libraries/Components/View/ViewNativeComponent.js +1 -0
  79. package/Libraries/Components/View/ViewPropTypes.js +18 -3
  80. package/Libraries/Components/View/ViewPropTypes.win32.js +30 -4
  81. package/Libraries/Components/View/ViewWin32.js +3 -2
  82. package/Libraries/Core/Devtools/loadBundleFromServer.js +152 -0
  83. package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -1
  84. package/Libraries/Core/ExceptionsManager.js +16 -7
  85. package/Libraries/Core/ExtendedError.js +12 -0
  86. package/Libraries/Core/ReactNativeVersion.js +3 -3
  87. package/Libraries/Core/ReactNativeVersionCheck.js +0 -2
  88. package/Libraries/Core/ReactNativeVersionCheck.win32.js +0 -2
  89. package/Libraries/Core/__mocks__/NativeExceptionsManager.js +20 -0
  90. package/Libraries/Core/setUpDeveloperTools.js +5 -1
  91. package/Libraries/Core/setUpIntersectionObserver.js +16 -0
  92. package/Libraries/{Components/ProgressBarAndroid/ProgressBarAndroid.ios.js → Core/setUpMutationObserver.js} +6 -2
  93. package/Libraries/Core/setUpPerformance.js +6 -13
  94. package/Libraries/Core/setUpPerformanceObserver.js +16 -0
  95. package/Libraries/Core/setUpRegeneratorRuntime.js +4 -2
  96. package/Libraries/DOM/Nodes/ReactNativeElement.js +135 -18
  97. package/Libraries/DOM/Nodes/ReadOnlyCharacterData.js +72 -0
  98. package/Libraries/DOM/Nodes/ReadOnlyElement.js +209 -21
  99. package/Libraries/DOM/Nodes/ReadOnlyNode.js +206 -17
  100. package/Libraries/DOM/Nodes/ReadOnlyText.js +30 -0
  101. package/Libraries/DOM/Nodes/Utilities/Traversal.js +54 -0
  102. package/Libraries/EventEmitter/NativeEventEmitter.d.ts +0 -6
  103. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +15 -4
  104. package/Libraries/Image/Image.android.js +8 -2
  105. package/Libraries/Image/Image.d.ts +1 -1
  106. package/Libraries/Image/Image.ios.js +4 -1
  107. package/Libraries/Image/Image.win32.js +6 -3
  108. package/Libraries/Image/ImageBackground.js +3 -0
  109. package/Libraries/Image/resolveAssetSource.win32.js +1 -1
  110. package/Libraries/Inspector/DevtoolsOverlay.js +6 -3
  111. package/Libraries/Inspector/NetworkOverlay.js +2 -2
  112. package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -5
  113. package/Libraries/Interaction/PanResponder.js +1 -4
  114. package/Libraries/IntersectionObserver/IntersectionObserver.js +252 -0
  115. package/Libraries/IntersectionObserver/IntersectionObserverEntry.js +140 -0
  116. package/Libraries/IntersectionObserver/IntersectionObserverManager.js +221 -0
  117. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +41 -0
  118. package/Libraries/IntersectionObserver/__mocks__/NativeIntersectionObserver.js +162 -0
  119. package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
  120. package/Libraries/Lists/FlatList.d.ts +2 -1
  121. package/Libraries/Lists/FlatList.js +15 -5
  122. package/Libraries/Lists/SectionList.js +4 -0
  123. package/Libraries/LogBox/Data/LogBoxLog.js +4 -1
  124. package/Libraries/LogBox/Data/LogBoxSymbolication.js +5 -2
  125. package/Libraries/LogBox/Data/parseLogBoxLog.js +57 -20
  126. package/Libraries/LogBox/UI/AnsiHighlight.js +1 -1
  127. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +24 -31
  128. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
  129. package/Libraries/LogBox/UI/LogBoxMessage.js +4 -7
  130. package/Libraries/MutationObserver/MutationObserver.js +184 -0
  131. package/Libraries/MutationObserver/MutationObserverManager.js +218 -0
  132. package/Libraries/MutationObserver/MutationRecord.js +82 -0
  133. package/Libraries/MutationObserver/NativeMutationObserver.js +58 -0
  134. package/Libraries/MutationObserver/__mocks__/NativeMutationObserver.js +327 -0
  135. package/Libraries/NativeComponent/BaseViewConfig.android.js +18 -3
  136. package/Libraries/NativeComponent/BaseViewConfig.ios.js +33 -0
  137. package/Libraries/NativeComponent/BaseViewConfig.win32.js +33 -0
  138. package/Libraries/NativeComponent/NativeComponentRegistry.js +3 -5
  139. package/Libraries/NativeModules/specs/NativeSourceCode.js +6 -6
  140. package/Libraries/Network/RCTNetworking.android.js +2 -1
  141. package/Libraries/Network/XMLHttpRequest.js +1 -1
  142. package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -4
  143. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +9 -2
  144. package/Libraries/Performance/QuickPerformanceLogger.js +1 -1
  145. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
  146. package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +1 -0
  147. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -1
  148. package/Libraries/Pressability/Pressability.js +28 -3
  149. package/Libraries/Pressability/Pressability.win32.js +30 -5
  150. package/Libraries/ReactNative/AppContainer.js +2 -3
  151. package/Libraries/ReactNative/AppRegistry.d.ts +0 -5
  152. package/Libraries/ReactNative/AppRegistry.js +66 -53
  153. package/Libraries/ReactNative/BridgelessUIManager.js +38 -9
  154. package/Libraries/ReactNative/FabricUIManager.js +143 -34
  155. package/Libraries/ReactNative/I18nManager.js +5 -11
  156. package/Libraries/ReactNative/NativeI18nManager.js +7 -5
  157. package/Libraries/ReactNative/PaperUIManager.win32.js +2 -2
  158. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +151 -0
  159. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +81 -0
  160. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +492 -0
  161. package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +32 -0
  162. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +19 -3
  163. package/Libraries/ReactNative/UIManager.js +8 -0
  164. package/Libraries/ReactNative/__mocks__/FabricUIManager.js +648 -0
  165. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +38 -2
  166. package/Libraries/Renderer/implementations/ReactFabric-dev.js +27 -27
  167. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
  168. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
  169. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +27 -27
  170. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -3
  171. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -3
  172. package/Libraries/Renderer/shims/ReactFabric.js +5 -6
  173. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -3
  174. package/Libraries/Renderer/shims/ReactNative.js +2 -3
  175. package/Libraries/Renderer/shims/ReactNativeTypes.js +35 -17
  176. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -3
  177. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -3
  178. package/Libraries/Settings/{Settings.android.js → Settings.js} +4 -4
  179. package/Libraries/Share/Share.d.ts +3 -9
  180. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +9 -4
  181. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +28 -13
  182. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +14 -4
  183. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -1
  184. package/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  185. package/Libraries/StyleSheet/StyleSheet.d.ts +10 -1
  186. package/Libraries/StyleSheet/StyleSheet.js +3 -0
  187. package/Libraries/StyleSheet/StyleSheet.win32.js +3 -0
  188. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +31 -17
  189. package/Libraries/StyleSheet/StyleSheetTypes.js +90 -6
  190. package/Libraries/StyleSheet/flattenStyle.js +4 -0
  191. package/Libraries/StyleSheet/private/_TransformStyle.js +16 -2
  192. package/Libraries/StyleSheet/processColor.js +1 -2
  193. package/Libraries/StyleSheet/processTransformOrigin.js +136 -0
  194. package/Libraries/StyleSheet/splitLayoutProps.js +1 -0
  195. package/Libraries/Text/Text.d.ts +5 -5
  196. package/Libraries/Text/Text.js +17 -10
  197. package/Libraries/Text/Text.win32.js +354 -0
  198. package/Libraries/Text/TextProps.win32.js +281 -0
  199. package/Libraries/TurboModule/TurboModuleRegistry.js +47 -7
  200. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
  201. package/Libraries/Types/CoreEventTypes.d.ts +5 -2
  202. package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -12
  203. package/Libraries/Utilities/NativeDeviceInfo.js +8 -9
  204. package/Libraries/Utilities/NativePlatformConstantsAndroid.js +23 -18
  205. package/Libraries/Utilities/NativePlatformConstantsIOS.js +16 -13
  206. package/Libraries/Utilities/NativePlatformConstantsWin.js +13 -10
  207. package/Libraries/Utilities/PerformanceLoggerContext.js +1 -1
  208. package/Libraries/Utilities/Platform.android.js +12 -8
  209. package/Libraries/Utilities/Platform.d.ts +1 -0
  210. package/Libraries/Utilities/Platform.flow.js +84 -0
  211. package/Libraries/Utilities/Platform.flow.win32.js +111 -0
  212. package/Libraries/Utilities/Platform.ios.js +12 -8
  213. package/Libraries/Utilities/Platform.win32.js +12 -8
  214. package/Libraries/Utilities/PolyfillFunctions.js +1 -1
  215. package/Libraries/Utilities/ReactNativeTestTools.js +1 -2
  216. package/Libraries/Utilities/SceneTracker.js +1 -1
  217. package/Libraries/Utilities/createPerformanceLogger.js +63 -32
  218. package/Libraries/Utilities/useColorScheme.js +7 -8
  219. package/Libraries/WebPerformance/MemoryInfo.js +1 -1
  220. package/Libraries/WebPerformance/NativePerformance.js +3 -8
  221. package/Libraries/WebPerformance/NativePerformanceObserver.js +4 -0
  222. package/Libraries/WebPerformance/Performance.js +42 -15
  223. package/Libraries/WebPerformance/PerformanceEntry.js +14 -6
  224. package/Libraries/WebPerformance/PerformanceEventTiming.js +18 -1
  225. package/Libraries/WebPerformance/ReactNativeStartupTiming.js +40 -14
  226. package/Libraries/WebPerformance/__mocks__/NativePerformance.js +4 -2
  227. package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +21 -3
  228. package/Libraries/promiseRejectionTrackingOptions.js +1 -3
  229. package/Libraries/vendor/emitter/EventEmitter.js +20 -18
  230. package/flow/global.js +1 -3
  231. package/flow/jest.js +5 -1
  232. package/{Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js → jest/ReactNativeInternalFeatureFlagsMock.js} +2 -1
  233. package/jest/__tests__/setup-test.js +18 -0
  234. package/jest/mockModal.js +6 -4
  235. package/jest/setup.js +61 -30
  236. package/jest.config.js +1 -1
  237. package/just-task.js +1 -0
  238. package/overrides.json +51 -46
  239. package/package.json +35 -33
  240. package/src/Libraries/Components/Button/ButtonWin32.Props.ts +1 -1
  241. package/src/Libraries/Components/Button/ButtonWin32.tsx +0 -2
  242. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +2 -2
  243. package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  244. package/src/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  245. package/src/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  246. package/types/experimental.d.ts +44 -0
  247. package/types/index.d.ts +2 -1
  248. package/types/modules/Devtools.d.ts +1 -0
  249. package/types/modules/globals.d.ts +16 -1
  250. package/IntegrationTests/BUCK +0 -32
  251. package/IntegrationTests/PropertiesUpdateTest.js +0 -29
  252. package/IntegrationTests/RCTRootViewIntegrationTestApp.js +0 -86
  253. package/IntegrationTests/ReactContentSizeUpdateTest.js +0 -89
  254. package/IntegrationTests/SizeFlexibilityUpdateTest.js +0 -106
  255. package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +0 -51
  256. package/Libraries/Components/TextInput/TextInput.Types.win32.js +0 -3
  257. package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +0 -1
  258. package/Libraries/Utilities/AcessibilityMapping.js +0 -154
  259. package/Libraries/Utilities/AcessibilityMapping.win32.js +0 -156
  260. package/Libraries/Utilities/NativeDevSplitBundleLoader.js +0 -19
  261. package/Libraries/Utilities/useColorScheme.win32.js +0 -26
  262. package/flow/use-sync-external-store.js +0 -20
  263. package/flow-typed/npm/base64-js_v1.x.x.js +0 -12
  264. package/flow-typed/npm/glob_v7.x.x.js +0 -79
  265. package/flow-typed/npm/pretty-format_v26.x.x.js +0 -49
  266. package/flow-typed/npm/promise_v8.x.x.js +0 -30
  267. package/flow-typed/npm/react-dom_v17.x.x.js +0 -139
  268. package/flow-typed/npm/react-test-renderer_v16.x.x.js +0 -79
  269. package/flow-typed/npm/stacktrace-parser_v0.1.x.js +0 -17
  270. package/flow-typed/npm/yargs_v17.x.x.js +0 -341
  271. package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +0 -68
  272. /package/Libraries/{Renderer/public → ReactNative/ReactFabricPublicInstance}/ReactFabricPublicInstanceUtils.js +0 -0
@@ -8,10 +8,18 @@
8
8
  * @flow strict
9
9
  */
10
10
 
11
- import type {HighResTimeStamp} from './PerformanceEntry';
11
+ import type {HighResTimeStamp, PerformanceEntryJSON} from './PerformanceEntry';
12
12
 
13
13
  import {PerformanceEntry} from './PerformanceEntry';
14
14
 
15
+ export type PerformanceEventTimingJSON = {
16
+ ...PerformanceEntryJSON,
17
+ processingStart: HighResTimeStamp,
18
+ processingEnd: HighResTimeStamp,
19
+ interactionId: number,
20
+ ...
21
+ };
22
+
15
23
  export class PerformanceEventTiming extends PerformanceEntry {
16
24
  processingStart: HighResTimeStamp;
17
25
  processingEnd: HighResTimeStamp;
@@ -35,4 +43,13 @@ export class PerformanceEventTiming extends PerformanceEntry {
35
43
  this.processingEnd = init.processingEnd ?? 0;
36
44
  this.interactionId = init.interactionId ?? 0;
37
45
  }
46
+
47
+ toJSON(): PerformanceEventTimingJSON {
48
+ return {
49
+ ...super.toJSON(),
50
+ processingStart: this.processingStart,
51
+ processingEnd: this.processingEnd,
52
+ interactionId: this.interactionId,
53
+ };
54
+ }
38
55
  }
@@ -11,23 +11,35 @@
11
11
 
12
12
  // flowlint unsafe-getters-setters:off
13
13
 
14
- import type {ReactNativeStartupTiming as ReactNativeStartupTimingType} from './NativePerformance';
14
+ type ReactNativeStartupTimingLike = {
15
+ startTime: ?number,
16
+ endTime: ?number,
17
+ initializeRuntimeStart: ?number,
18
+ initializeRuntimeEnd: ?number,
19
+ executeJavaScriptBundleEntryPointStart: ?number,
20
+ executeJavaScriptBundleEntryPointEnd: ?number,
21
+ };
15
22
 
16
23
  // Read-only object with RN startup timing information.
17
24
  // This is returned by the performance.reactNativeStartup API.
18
25
  export default class ReactNativeStartupTiming {
19
- // All time information here are in ms. To match web spec,
20
- // the default value for timings are zero if not present.
21
- // See https://www.w3.org/TR/performance-timeline/#performancetiming-interface
22
- _startTime = 0;
23
- _endTime = 0;
24
- _executeJavaScriptBundleEntryPointStart = 0;
25
- _executeJavaScriptBundleEntryPointEnd = 0;
26
+ // All time information here are in ms. The values may be null if not provided.
27
+ // We do NOT match web spect here for two reasons:
28
+ // 1. The `ReactNativeStartupTiming` is non-standard API
29
+ // 2. The timing information is relative to the time origin, which means `0` has valid meaning
30
+ _startTime: ?number;
31
+ _endTime: ?number;
32
+ _initializeRuntimeStart: ?number;
33
+ _initializeRuntimeEnd: ?number;
34
+ _executeJavaScriptBundleEntryPointStart: ?number;
35
+ _executeJavaScriptBundleEntryPointEnd: ?number;
26
36
 
27
- constructor(startUpTiming: ?ReactNativeStartupTimingType) {
37
+ constructor(startUpTiming: ?ReactNativeStartupTimingLike) {
28
38
  if (startUpTiming != null) {
29
39
  this._startTime = startUpTiming.startTime;
30
40
  this._endTime = startUpTiming.endTime;
41
+ this._initializeRuntimeStart = startUpTiming.initializeRuntimeStart;
42
+ this._initializeRuntimeEnd = startUpTiming.initializeRuntimeEnd;
31
43
  this._executeJavaScriptBundleEntryPointStart =
32
44
  startUpTiming.executeJavaScriptBundleEntryPointStart;
33
45
  this._executeJavaScriptBundleEntryPointEnd =
@@ -36,30 +48,44 @@ export default class ReactNativeStartupTiming {
36
48
  }
37
49
 
38
50
  /**
39
- * Start time of the RN app startup process. This is provided by the platform by implementing the `ReactMarker.setAppStartTime` API in the native platform code.
51
+ * Start time of the RN app startup process. This is provided by the platform by implementing the `ReactMarker.setAppStartTime` API in the native platform code.
40
52
  */
41
- get startTime(): number {
53
+ get startTime(): ?number {
42
54
  return this._startTime;
43
55
  }
44
56
 
45
57
  /**
46
58
  * End time of the RN app startup process. This is equal to `executeJavaScriptBundleEntryPointEnd`.
47
59
  */
48
- get endTime(): number {
60
+ get endTime(): ?number {
49
61
  return this._endTime;
50
62
  }
51
63
 
64
+ /**
65
+ * Start time when RN runtime get initialized. This is when RN infra first kicks in app startup process.
66
+ */
67
+ get initializeRuntimeStart(): ?number {
68
+ return this._initializeRuntimeStart;
69
+ }
70
+
71
+ /**
72
+ * End time when RN runtime get initialized. This is the last marker before ends of the app startup process.
73
+ */
74
+ get initializeRuntimeEnd(): ?number {
75
+ return this._initializeRuntimeEnd;
76
+ }
77
+
52
78
  /**
53
79
  * Start time of JS bundle being executed. This indicates the RN JS bundle is loaded and start to be evaluated.
54
80
  */
55
- get executeJavaScriptBundleEntryPointStart(): number {
81
+ get executeJavaScriptBundleEntryPointStart(): ?number {
56
82
  return this._executeJavaScriptBundleEntryPointStart;
57
83
  }
58
84
 
59
85
  /**
60
86
  * End time of JS bundle being executed. This indicates all the synchronous entry point jobs are finished.
61
87
  */
62
- get executeJavaScriptBundleEntryPointEnd(): number {
88
+ get executeJavaScriptBundleEntryPointEnd(): ?number {
63
89
  return this._executeJavaScriptBundleEntryPointEnd;
64
90
  }
65
91
  }
@@ -20,12 +20,12 @@ import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
20
20
  const marks: Map<string, number> = new Map();
21
21
 
22
22
  const NativePerformanceMock: NativePerformance = {
23
- mark: (name: string, startTime: number, duration: number): void => {
23
+ mark: (name: string, startTime: number): void => {
24
24
  NativePerformanceObserver?.logRawEntry({
25
25
  name,
26
26
  entryType: RawPerformanceEntryTypeValues.MARK,
27
27
  startTime,
28
- duration,
28
+ duration: 0,
29
29
  });
30
30
  marks.set(name, startTime);
31
31
  },
@@ -58,6 +58,8 @@ const NativePerformanceMock: NativePerformance = {
58
58
  endTime: 0,
59
59
  executeJavaScriptBundleEntryPointStart: 0,
60
60
  executeJavaScriptBundleEntryPointEnd: 0,
61
+ initializeRuntimeStart: 0,
62
+ initializeRuntimeEnd: 0,
61
63
  };
62
64
  },
63
65
  };
@@ -18,6 +18,7 @@ import type {
18
18
  import {RawPerformanceEntryTypeValues} from '../RawPerformanceEntry';
19
19
 
20
20
  const reportingType: Set<RawPerformanceEntryType> = new Set();
21
+ const isAlwaysLogged: Set<RawPerformanceEntryType> = new Set();
21
22
  const eventCounts: Map<string, number> = new Map();
22
23
  const durationThresholds: Map<RawPerformanceEntryType, number> = new Map();
23
24
  let entries: Array<RawPerformanceEntry> = [];
@@ -33,6 +34,19 @@ const NativePerformanceObserverMock: NativePerformanceObserver = {
33
34
  durationThresholds.delete(entryType);
34
35
  },
35
36
 
37
+ setIsBuffered: (
38
+ entryTypes: $ReadOnlyArray<RawPerformanceEntryType>,
39
+ isBuffered: boolean,
40
+ ) => {
41
+ for (const entryType of entryTypes) {
42
+ if (isBuffered) {
43
+ isAlwaysLogged.add(entryType);
44
+ } else {
45
+ isAlwaysLogged.delete(entryType);
46
+ }
47
+ }
48
+ },
49
+
36
50
  popPendingEntries: (): GetPendingEntriesResult => {
37
51
  const res = entries;
38
52
  entries = [];
@@ -47,7 +61,10 @@ const NativePerformanceObserverMock: NativePerformanceObserver = {
47
61
  },
48
62
 
49
63
  logRawEntry: (entry: RawPerformanceEntry) => {
50
- if (reportingType.has(entry.entryType)) {
64
+ if (
65
+ reportingType.has(entry.entryType) ||
66
+ isAlwaysLogged.has(entry.entryType)
67
+ ) {
51
68
  const durationThreshold = durationThresholds.get(entry.entryType);
52
69
  if (
53
70
  durationThreshold !== undefined &&
@@ -81,8 +98,9 @@ const NativePerformanceObserverMock: NativePerformanceObserver = {
81
98
  clearEntries: (entryType: RawPerformanceEntryType, entryName?: string) => {
82
99
  entries = entries.filter(
83
100
  e =>
84
- e.entryType === entryType &&
85
- (entryName == null || e.name === entryName),
101
+ (entryType !== RawPerformanceEntryTypeValues.UNDEFINED &&
102
+ e.entryType !== entryType) ||
103
+ (entryName != null && e.name !== entryName),
86
104
  );
87
105
  },
88
106
 
@@ -10,9 +10,7 @@
10
10
 
11
11
  import typeof {enable} from 'promise/setimmediate/rejection-tracking';
12
12
 
13
- type ExtractOptionsType = <P>(((options?: ?P) => void)) => P;
14
-
15
- let rejectionTrackingOptions: $Call<ExtractOptionsType, enable> = {
13
+ let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = {
16
14
  allRejections: true,
17
15
  onUnhandled: (id, rejection = {}) => {
18
16
  let message: string;
@@ -15,13 +15,13 @@ export interface EventSubscription {
15
15
  export interface IEventEmitter<TEventToArgsMap: {...}> {
16
16
  addListener<TEvent: $Keys<TEventToArgsMap>>(
17
17
  eventType: TEvent,
18
- listener: (...args: $ElementType<TEventToArgsMap, TEvent>) => mixed,
18
+ listener: (...args: TEventToArgsMap[TEvent]) => mixed,
19
19
  context?: mixed,
20
20
  ): EventSubscription;
21
21
 
22
22
  emit<TEvent: $Keys<TEventToArgsMap>>(
23
23
  eventType: TEvent,
24
- ...args: $ElementType<TEventToArgsMap, TEvent>
24
+ ...args: TEventToArgsMap[TEvent]
25
25
  ): void;
26
26
 
27
27
  removeAllListeners<TEvent: $Keys<TEventToArgsMap>>(eventType?: ?TEvent): void;
@@ -63,7 +63,7 @@ type Registry<TEventToArgsMap: {...}> = $ObjMap<
63
63
  export default class EventEmitter<TEventToArgsMap: {...}>
64
64
  implements IEventEmitter<TEventToArgsMap>
65
65
  {
66
- _registry: Registry<TEventToArgsMap> = {};
66
+ #registry: Registry<TEventToArgsMap> = {};
67
67
 
68
68
  /**
69
69
  * Registers a listener that is called when the supplied event is emitted.
@@ -71,7 +71,7 @@ export default class EventEmitter<TEventToArgsMap: {...}>
71
71
  */
72
72
  addListener<TEvent: $Keys<TEventToArgsMap>>(
73
73
  eventType: TEvent,
74
- listener: (...args: $ElementType<TEventToArgsMap, TEvent>) => mixed,
74
+ listener: (...args: TEventToArgsMap[TEvent]) => mixed,
75
75
  context: mixed,
76
76
  ): EventSubscription {
77
77
  if (typeof listener !== 'function') {
@@ -79,11 +79,12 @@ export default class EventEmitter<TEventToArgsMap: {...}>
79
79
  'EventEmitter.addListener(...): 2nd argument must be a function.',
80
80
  );
81
81
  }
82
- const registrations = allocate<_, _, TEventToArgsMap[TEvent]>(
83
- this._registry,
84
- eventType,
85
- );
86
- const registration: Registration<$ElementType<TEventToArgsMap, TEvent>> = {
82
+ const registrations = allocate<
83
+ TEventToArgsMap,
84
+ TEvent,
85
+ TEventToArgsMap[TEvent],
86
+ >(this.#registry, eventType);
87
+ const registration: Registration<TEventToArgsMap[TEvent]> = {
87
88
  context,
88
89
  listener,
89
90
  remove(): void {
@@ -103,13 +104,14 @@ export default class EventEmitter<TEventToArgsMap: {...}>
103
104
  */
104
105
  emit<TEvent: $Keys<TEventToArgsMap>>(
105
106
  eventType: TEvent,
106
- ...args: $ElementType<TEventToArgsMap, TEvent>
107
+ ...args: TEventToArgsMap[TEvent]
107
108
  ): void {
108
- const registrations: ?Set<
109
- Registration<$ElementType<TEventToArgsMap, TEvent>>,
110
- > = this._registry[eventType];
109
+ const registrations: ?Set<Registration<TEventToArgsMap[TEvent]>> =
110
+ this.#registry[eventType];
111
111
  if (registrations != null) {
112
- for (const registration of [...registrations]) {
112
+ // Copy `registrations` to take a snapshot when we invoke `emit`, in case
113
+ // registrations are added or removed when listeners are invoked.
114
+ for (const registration of Array.from(registrations)) {
113
115
  registration.listener.apply(registration.context, args);
114
116
  }
115
117
  }
@@ -122,9 +124,9 @@ export default class EventEmitter<TEventToArgsMap: {...}>
122
124
  eventType?: ?TEvent,
123
125
  ): void {
124
126
  if (eventType == null) {
125
- this._registry = {};
127
+ this.#registry = {};
126
128
  } else {
127
- delete this._registry[eventType];
129
+ delete this.#registry[eventType];
128
130
  }
129
131
  }
130
132
 
@@ -132,7 +134,7 @@ export default class EventEmitter<TEventToArgsMap: {...}>
132
134
  * Returns the number of registered listeners for the supplied event.
133
135
  */
134
136
  listenerCount<TEvent: $Keys<TEventToArgsMap>>(eventType: TEvent): number {
135
- const registrations: ?Set<Registration<mixed>> = this._registry[eventType];
137
+ const registrations: ?Set<Registration<mixed>> = this.#registry[eventType];
136
138
  return registrations == null ? 0 : registrations.size;
137
139
  }
138
140
  }
@@ -140,7 +142,7 @@ export default class EventEmitter<TEventToArgsMap: {...}>
140
142
  function allocate<
141
143
  TEventToArgsMap: {...},
142
144
  TEvent: $Keys<TEventToArgsMap>,
143
- TEventArgs: $ElementType<TEventToArgsMap, TEvent>,
145
+ TEventArgs: TEventToArgsMap[TEvent],
144
146
  >(
145
147
  registry: Registry<TEventToArgsMap>,
146
148
  eventType: TEvent,
package/flow/global.js CHANGED
@@ -27,9 +27,7 @@ declare var global: {
27
27
  },
28
28
 
29
29
  // setUpPerformance
30
- +performance: {
31
- +now: () => number,
32
- },
30
+ +performance: Performance,
33
31
 
34
32
  // setUpXHR
35
33
  +XMLHttpRequest: typeof XMLHttpRequest,
package/flow/jest.js CHANGED
@@ -38,6 +38,10 @@ type JestMockFn<TArguments: $ReadOnlyArray<any>, TReturn> = {
38
38
  * instantiated from this mock function.
39
39
  */
40
40
  instances: Array<TReturn>,
41
+ /**
42
+ * An array that contains the contexts for all calls of the mock function.
43
+ */
44
+ contexts: Array<mixed>,
41
45
  /**
42
46
  * An array that contains all the object results that have been
43
47
  * returned by this mock function call
@@ -673,7 +677,7 @@ interface JestExpectType {
673
677
  * Use .toBeInstanceOf(Class) to check that an object is an instance of a
674
678
  * class.
675
679
  */
676
- toBeInstanceOf(cls: Class<*>): void;
680
+ toBeInstanceOf(cls: Class<any>): void;
677
681
  /**
678
682
  * .toBeNull() is the same as .toBe(null) but the error messages are a bit
679
683
  * nicer.
@@ -5,8 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
+ * @flow strict
8
9
  */
9
10
 
10
11
  'use strict';
11
12
 
12
- module.exports = require('../UnimplementedViews/UnimplementedView');
13
+ module.exports = {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ * @format
9
+ * @oncall react_native
10
+ */
11
+
12
+ import NativeExceptionsManager from '../../Libraries/Core/NativeExceptionsManager';
13
+
14
+ test('NativeExceptionsManager is a mock', () => {
15
+ expect(jest.isMockFunction(NativeExceptionsManager.reportException)).toBe(
16
+ true,
17
+ );
18
+ });
package/jest/mockModal.js CHANGED
@@ -17,11 +17,13 @@ import typeof Modal from '../Libraries/Modal/Modal';
17
17
 
18
18
  function mockModal(BaseComponent: $FlowFixMe) {
19
19
  class ModalMock extends BaseComponent {
20
- render(): React.Element<Modal> {
20
+ render(): React.Element<Modal> | null {
21
+ if (this.props.visible === false) {
22
+ return null;
23
+ }
24
+
21
25
  return (
22
- <BaseComponent {...this.props}>
23
- {this.props.visible !== true ? null : this.props.children}
24
- </BaseComponent>
26
+ <BaseComponent {...this.props}>{this.props.children}</BaseComponent>
25
27
  );
26
28
  }
27
29
  }
package/jest/setup.js CHANGED
@@ -15,36 +15,50 @@ const mockComponent = jest.requireActual('./mockComponent');
15
15
  jest.requireActual('@react-native/js-polyfills/Object.es8');
16
16
  jest.requireActual('@react-native/js-polyfills/error-guard');
17
17
 
18
- global.__DEV__ = true;
19
-
20
- global.performance = {
21
- now: jest.fn(Date.now),
22
- };
23
-
24
- global.regeneratorRuntime = jest.requireActual('regenerator-runtime/runtime');
25
- global.window = global;
26
-
27
- global.requestAnimationFrame = function (callback) {
28
- return setTimeout(() => callback(jest.now()), 0);
29
- };
30
- global.cancelAnimationFrame = function (id) {
31
- clearTimeout(id);
32
- };
33
-
34
- // there's a __mock__ for it.
35
- jest.setMock(
36
- '../Libraries/vendor/core/ErrorUtils',
37
- require('../Libraries/vendor/core/ErrorUtils'),
38
- );
18
+ Object.defineProperties(global, {
19
+ __DEV__: {
20
+ configurable: true,
21
+ enumerable: true,
22
+ value: true,
23
+ writable: true,
24
+ },
25
+ cancelAnimationFrame: {
26
+ configurable: true,
27
+ enumerable: true,
28
+ value: id => clearTimeout(id),
29
+ writable: true,
30
+ },
31
+ performance: {
32
+ configurable: true,
33
+ enumerable: true,
34
+ value: {
35
+ now: jest.fn(Date.now),
36
+ },
37
+ writable: true,
38
+ },
39
+ regeneratorRuntime: {
40
+ configurable: true,
41
+ enumerable: true,
42
+ value: jest.requireActual('regenerator-runtime/runtime'),
43
+ writable: true,
44
+ },
45
+ requestAnimationFrame: {
46
+ configurable: true,
47
+ enumerable: true,
48
+ value: callback => setTimeout(() => callback(jest.now()), 0),
49
+ writable: true,
50
+ },
51
+ window: {
52
+ configurable: true,
53
+ enumerable: true,
54
+ value: global,
55
+ writable: true,
56
+ },
57
+ });
39
58
 
40
59
  jest
41
60
  .mock('../Libraries/Core/InitializeCore', () => {})
42
- .mock('../Libraries/Core/NativeExceptionsManager', () => ({
43
- __esModule: true,
44
- default: {
45
- reportException: jest.fn(),
46
- },
47
- }))
61
+ .mock('../Libraries/Core/NativeExceptionsManager')
48
62
  .mock('../Libraries/ReactNative/UIManager', () => ({
49
63
  AndroidViewPager: {
50
64
  Commands: {
@@ -95,9 +109,17 @@ jest
95
109
  Constants: {},
96
110
  },
97
111
  }))
98
- .mock('../Libraries/Image/Image', () =>
99
- mockComponent('../Libraries/Image/Image'),
100
- )
112
+ .mock('../Libraries/Image/Image', () => {
113
+ const Image = mockComponent('../Libraries/Image/Image');
114
+ Image.getSize = jest.fn();
115
+ Image.getSizeWithHeaders = jest.fn();
116
+ Image.prefetch = jest.fn();
117
+ Image.prefetchWithMetadata = jest.fn();
118
+ Image.queryCache = jest.fn();
119
+ Image.resolveAssetSource = jest.fn();
120
+
121
+ return Image;
122
+ })
101
123
  .mock('../Libraries/Text/Text', () =>
102
124
  mockComponent('../Libraries/Text/Text', MockNativeMethods),
103
125
  )
@@ -176,6 +198,8 @@ jest
176
198
  addEventListener: jest.fn(() => ({
177
199
  remove: jest.fn(),
178
200
  })),
201
+ removeEventListener: jest.fn(),
202
+ currentState: jest.fn(),
179
203
  }))
180
204
  .mock('../Libraries/Linking/Linking', () => ({
181
205
  openURL: jest.fn(),
@@ -374,4 +398,11 @@ jest
374
398
  __esModule: true,
375
399
  default: Component,
376
400
  };
401
+ })
402
+ // In tests, we can use the default version instead of the one using
403
+ // dependency injection.
404
+ .mock('../Libraries/ReactNative/RendererProxy', () => {
405
+ return jest.requireActual(
406
+ '../Libraries/ReactNative/RendererImplementation',
407
+ );
377
408
  });
package/jest.config.js CHANGED
@@ -8,7 +8,7 @@ module.exports = require('@rnx-kit/jest-preset')("win32", {
8
8
  transformIgnorePatterns: ['jest-runner'],
9
9
  fakeTimers: {
10
10
  enableGlobally: true,
11
- legacyFakeTimers: true,
11
+ legacyFakeTimers: false,
12
12
  },
13
13
  snapshotFormat: {
14
14
  escapeString: true,
package/just-task.js CHANGED
@@ -19,6 +19,7 @@ const {
19
19
  // Use the shared base configuration
20
20
  require('@rnw-scripts/just-task');
21
21
  require('@rnw-scripts/just-task/react-native-tasks');
22
+ require('@rnw-scripts/just-task/flow-tasks');
22
23
 
23
24
  option('production');
24
25
  option('clean');