@office-iss/react-native-win32 0.72.8 → 0.73.0-preview.2

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 (277) hide show
  1. package/.flowconfig +15 -5
  2. package/CHANGELOG.json +530 -101
  3. package/CHANGELOG.md +213 -56
  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/AccessibilityInfo/AccessibilityInfo.d.ts +1 -5
  36. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +7 -48
  37. package/Libraries/Components/Button/ButtonWin32.Props.d.ts +1 -1
  38. package/Libraries/Components/Button/ButtonWin32.Props.js.map +1 -1
  39. package/Libraries/Components/Button/ButtonWin32.d.ts +1 -1
  40. package/Libraries/Components/Button/ButtonWin32.js +1 -4
  41. package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
  42. package/Libraries/Components/Clipboard/Clipboard.d.ts +4 -4
  43. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +3 -1
  44. package/Libraries/Components/EnterString.win32.d.ts +1 -1
  45. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +26 -6
  46. package/Libraries/Components/Pressable/Pressable.js +3 -2
  47. package/Libraries/Components/Pressable/Pressable.win32.js +4 -3
  48. package/Libraries/Components/Pressable/useAndroidRippleForView.js +1 -1
  49. package/Libraries/Components/SafeAreaView/SafeAreaView.js +7 -7
  50. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +7 -8
  51. package/Libraries/Components/ScrollView/ScrollView.js +3 -1
  52. package/Libraries/Components/ScrollView/ScrollView.win32.js +3 -1
  53. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +39 -46
  54. package/Libraries/Components/Switch/Switch.js +1 -0
  55. package/Libraries/Components/Text/TextWin32.d.ts +1 -1
  56. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  57. package/Libraries/Components/TextInput/TextInput.d.ts +49 -7
  58. package/Libraries/Components/TextInput/TextInput.flow.js +43 -10
  59. package/Libraries/Components/TextInput/TextInput.js +62 -10
  60. package/Libraries/Components/TextInput/TextInput.win32.js +953 -206
  61. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +23 -0
  62. package/Libraries/Components/ToastAndroid/{ToastAndroid.ios.js → ToastAndroid.js} +9 -1
  63. package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +9 -1
  64. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +2 -2
  65. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  66. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  67. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  68. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  69. package/Libraries/Components/Touchable/TouchableOpacity.js +4 -1
  70. package/Libraries/Components/Touchable/TouchableWin32.d.ts +1 -1
  71. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  72. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -0
  73. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +16 -6
  74. package/Libraries/Components/View/ReactNativeStyleAttributes.js +9 -0
  75. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  76. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  77. package/Libraries/Components/View/View.js +46 -32
  78. package/Libraries/Components/View/View.win32.js +37 -6
  79. package/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  80. package/Libraries/Components/View/ViewNativeComponent.js +1 -0
  81. package/Libraries/Components/View/ViewPropTypes.js +18 -3
  82. package/Libraries/Components/View/ViewPropTypes.win32.js +30 -4
  83. package/Libraries/Components/View/ViewWin32.js +3 -2
  84. package/Libraries/Core/Devtools/loadBundleFromServer.js +152 -0
  85. package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -1
  86. package/Libraries/Core/ExceptionsManager.js +16 -7
  87. package/Libraries/Core/ExtendedError.js +12 -0
  88. package/Libraries/Core/ReactNativeVersion.js +3 -3
  89. package/Libraries/Core/ReactNativeVersionCheck.js +0 -2
  90. package/Libraries/Core/ReactNativeVersionCheck.win32.js +0 -2
  91. package/Libraries/Core/__mocks__/NativeExceptionsManager.js +20 -0
  92. package/Libraries/Core/setUpDeveloperTools.js +5 -1
  93. package/Libraries/Core/setUpIntersectionObserver.js +16 -0
  94. package/Libraries/{Components/ProgressBarAndroid/ProgressBarAndroid.ios.js → Core/setUpMutationObserver.js} +6 -2
  95. package/Libraries/Core/setUpPerformance.js +6 -13
  96. package/Libraries/Core/setUpPerformanceObserver.js +16 -0
  97. package/Libraries/Core/setUpRegeneratorRuntime.js +4 -2
  98. package/Libraries/DOM/Nodes/ReactNativeElement.js +135 -18
  99. package/Libraries/DOM/Nodes/ReadOnlyCharacterData.js +72 -0
  100. package/Libraries/DOM/Nodes/ReadOnlyElement.js +209 -21
  101. package/Libraries/DOM/Nodes/ReadOnlyNode.js +206 -17
  102. package/Libraries/DOM/Nodes/ReadOnlyText.js +30 -0
  103. package/Libraries/DOM/Nodes/Utilities/Traversal.js +54 -0
  104. package/Libraries/EventEmitter/NativeEventEmitter.d.ts +0 -6
  105. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +15 -4
  106. package/Libraries/Image/Image.android.js +8 -2
  107. package/Libraries/Image/Image.d.ts +1 -1
  108. package/Libraries/Image/Image.ios.js +4 -1
  109. package/Libraries/Image/Image.win32.js +6 -3
  110. package/Libraries/Image/ImageBackground.js +3 -0
  111. package/Libraries/Image/resolveAssetSource.win32.js +1 -1
  112. package/Libraries/Inspector/DevtoolsOverlay.js +6 -3
  113. package/Libraries/Inspector/NetworkOverlay.js +2 -2
  114. package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -5
  115. package/Libraries/Interaction/PanResponder.js +1 -4
  116. package/Libraries/IntersectionObserver/IntersectionObserver.js +252 -0
  117. package/Libraries/IntersectionObserver/IntersectionObserverEntry.js +140 -0
  118. package/Libraries/IntersectionObserver/IntersectionObserverManager.js +221 -0
  119. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +41 -0
  120. package/Libraries/IntersectionObserver/__mocks__/NativeIntersectionObserver.js +162 -0
  121. package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
  122. package/Libraries/Lists/FlatList.d.ts +2 -1
  123. package/Libraries/Lists/FlatList.js +15 -5
  124. package/Libraries/Lists/SectionList.js +4 -0
  125. package/Libraries/LogBox/Data/LogBoxData.js +2 -1
  126. package/Libraries/LogBox/Data/LogBoxLog.js +4 -1
  127. package/Libraries/LogBox/Data/LogBoxSymbolication.js +5 -2
  128. package/Libraries/LogBox/Data/parseLogBoxLog.js +57 -20
  129. package/Libraries/LogBox/UI/AnsiHighlight.js +1 -1
  130. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +24 -31
  131. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
  132. package/Libraries/LogBox/UI/LogBoxMessage.js +4 -7
  133. package/Libraries/MutationObserver/MutationObserver.js +184 -0
  134. package/Libraries/MutationObserver/MutationObserverManager.js +218 -0
  135. package/Libraries/MutationObserver/MutationRecord.js +82 -0
  136. package/Libraries/MutationObserver/NativeMutationObserver.js +58 -0
  137. package/Libraries/MutationObserver/__mocks__/NativeMutationObserver.js +327 -0
  138. package/Libraries/NativeComponent/BaseViewConfig.android.js +18 -3
  139. package/Libraries/NativeComponent/BaseViewConfig.ios.js +33 -0
  140. package/Libraries/NativeComponent/BaseViewConfig.win32.js +33 -0
  141. package/Libraries/NativeComponent/NativeComponentRegistry.js +13 -9
  142. package/Libraries/NativeModules/specs/NativeSourceCode.js +6 -6
  143. package/Libraries/Network/RCTNetworking.android.js +2 -1
  144. package/Libraries/Network/XMLHttpRequest.js +1 -1
  145. package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -4
  146. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +9 -2
  147. package/Libraries/Performance/QuickPerformanceLogger.js +1 -1
  148. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
  149. package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +1 -0
  150. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -1
  151. package/Libraries/Pressability/Pressability.js +28 -3
  152. package/Libraries/Pressability/Pressability.win32.js +30 -5
  153. package/Libraries/ReactNative/AppContainer.js +2 -3
  154. package/Libraries/ReactNative/AppRegistry.d.ts +0 -5
  155. package/Libraries/ReactNative/AppRegistry.js +66 -53
  156. package/Libraries/ReactNative/BridgelessUIManager.js +38 -9
  157. package/Libraries/ReactNative/FabricUIManager.js +143 -34
  158. package/Libraries/ReactNative/I18nManager.js +5 -11
  159. package/Libraries/ReactNative/NativeI18nManager.js +7 -5
  160. package/Libraries/ReactNative/PaperUIManager.win32.js +2 -2
  161. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +151 -0
  162. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +81 -0
  163. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +492 -0
  164. package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +32 -0
  165. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +19 -3
  166. package/Libraries/ReactNative/UIManager.js +8 -0
  167. package/Libraries/ReactNative/__mocks__/FabricUIManager.js +648 -0
  168. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +38 -2
  169. package/Libraries/Renderer/implementations/ReactFabric-dev.js +27 -27
  170. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
  171. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
  172. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +27 -27
  173. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -3
  174. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -3
  175. package/Libraries/Renderer/shims/ReactFabric.js +5 -6
  176. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -3
  177. package/Libraries/Renderer/shims/ReactNative.js +2 -3
  178. package/Libraries/Renderer/shims/ReactNativeTypes.js +35 -17
  179. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -3
  180. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -3
  181. package/Libraries/Settings/{Settings.android.js → Settings.js} +4 -4
  182. package/Libraries/Share/Share.d.ts +3 -9
  183. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +9 -4
  184. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +28 -13
  185. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +14 -4
  186. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -1
  187. package/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  188. package/Libraries/StyleSheet/StyleSheet.d.ts +10 -1
  189. package/Libraries/StyleSheet/StyleSheet.js +3 -0
  190. package/Libraries/StyleSheet/StyleSheet.win32.js +3 -0
  191. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +31 -17
  192. package/Libraries/StyleSheet/StyleSheetTypes.js +90 -6
  193. package/Libraries/StyleSheet/flattenStyle.js +4 -0
  194. package/Libraries/StyleSheet/private/_TransformStyle.js +16 -2
  195. package/Libraries/StyleSheet/processColor.js +1 -2
  196. package/Libraries/StyleSheet/processTransformOrigin.js +136 -0
  197. package/Libraries/StyleSheet/splitLayoutProps.js +1 -0
  198. package/Libraries/Text/Text.d.ts +5 -5
  199. package/Libraries/Text/Text.js +17 -10
  200. package/Libraries/Text/Text.win32.js +354 -0
  201. package/Libraries/Text/TextProps.win32.js +281 -0
  202. package/Libraries/TurboModule/TurboModuleRegistry.js +47 -7
  203. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
  204. package/Libraries/Types/CoreEventTypes.d.ts +5 -2
  205. package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -12
  206. package/Libraries/Utilities/NativeDeviceInfo.js +8 -9
  207. package/Libraries/Utilities/NativePlatformConstantsAndroid.js +23 -18
  208. package/Libraries/Utilities/NativePlatformConstantsIOS.js +16 -13
  209. package/Libraries/Utilities/NativePlatformConstantsWin.js +13 -10
  210. package/Libraries/Utilities/PerformanceLoggerContext.js +1 -1
  211. package/Libraries/Utilities/Platform.android.js +12 -8
  212. package/Libraries/Utilities/Platform.d.ts +1 -0
  213. package/Libraries/Utilities/Platform.flow.js +84 -0
  214. package/Libraries/Utilities/Platform.flow.win32.js +111 -0
  215. package/Libraries/Utilities/Platform.ios.js +12 -8
  216. package/Libraries/Utilities/Platform.win32.js +12 -8
  217. package/Libraries/Utilities/PolyfillFunctions.js +1 -1
  218. package/Libraries/Utilities/ReactNativeTestTools.js +1 -2
  219. package/Libraries/Utilities/SceneTracker.js +1 -1
  220. package/Libraries/Utilities/createPerformanceLogger.js +63 -32
  221. package/Libraries/Utilities/useColorScheme.js +7 -8
  222. package/Libraries/WebPerformance/MemoryInfo.js +1 -1
  223. package/Libraries/WebPerformance/NativePerformance.js +3 -8
  224. package/Libraries/WebPerformance/NativePerformanceObserver.js +4 -0
  225. package/Libraries/WebPerformance/Performance.js +42 -15
  226. package/Libraries/WebPerformance/PerformanceEntry.js +14 -6
  227. package/Libraries/WebPerformance/PerformanceEventTiming.js +18 -1
  228. package/Libraries/WebPerformance/ReactNativeStartupTiming.js +40 -14
  229. package/Libraries/WebPerformance/__mocks__/NativePerformance.js +4 -2
  230. package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +21 -3
  231. package/Libraries/promiseRejectionTrackingOptions.js +21 -9
  232. package/Libraries/vendor/emitter/EventEmitter.js +17 -17
  233. package/flow/global.js +1 -3
  234. package/flow/jest.js +5 -1
  235. package/{Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js → jest/ReactNativeInternalFeatureFlagsMock.js} +2 -1
  236. package/jest/__tests__/setup-test.js +18 -0
  237. package/jest/mockModal.js +6 -4
  238. package/jest/setup.js +61 -30
  239. package/jest.config.js +1 -1
  240. package/just-task.js +1 -0
  241. package/overrides.json +54 -60
  242. package/package.json +35 -33
  243. package/src/Libraries/Components/Button/ButtonWin32.Props.ts +1 -1
  244. package/src/Libraries/Components/Button/ButtonWin32.tsx +0 -2
  245. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +2 -2
  246. package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  247. package/src/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  248. package/src/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  249. package/types/experimental.d.ts +44 -0
  250. package/types/index.d.ts +2 -1
  251. package/types/modules/Devtools.d.ts +1 -0
  252. package/types/modules/globals.d.ts +16 -1
  253. package/IntegrationTests/BUCK +0 -32
  254. package/IntegrationTests/PropertiesUpdateTest.js +0 -29
  255. package/IntegrationTests/RCTRootViewIntegrationTestApp.js +0 -86
  256. package/IntegrationTests/ReactContentSizeUpdateTest.js +0 -89
  257. package/IntegrationTests/SizeFlexibilityUpdateTest.js +0 -106
  258. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfoWin32.js +0 -37
  259. package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +0 -51
  260. package/Libraries/Components/TextInput/TextInput.Types.win32.js +0 -3
  261. package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +0 -1
  262. package/Libraries/Utilities/AcessibilityMapping.js +0 -154
  263. package/Libraries/Utilities/AcessibilityMapping.win32.js +0 -156
  264. package/Libraries/Utilities/NativeDevSplitBundleLoader.js +0 -19
  265. package/Libraries/Utilities/useColorScheme.win32.js +0 -26
  266. package/flow/use-sync-external-store.js +0 -20
  267. package/flow-typed/npm/base64-js_v1.x.x.js +0 -12
  268. package/flow-typed/npm/glob_v7.x.x.js +0 -79
  269. package/flow-typed/npm/pretty-format_v26.x.x.js +0 -49
  270. package/flow-typed/npm/promise_v8.x.x.js +0 -30
  271. package/flow-typed/npm/react-dom_v17.x.x.js +0 -139
  272. package/flow-typed/npm/react-test-renderer_v16.x.x.js +0 -79
  273. package/flow-typed/npm/stacktrace-parser_v0.1.x.js +0 -17
  274. package/flow-typed/npm/yargs_v17.x.x.js +0 -341
  275. package/src/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +0 -161
  276. package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +0 -68
  277. /package/Libraries/{Renderer/public → ReactNative/ReactFabricPublicInstance}/ReactFabricPublicInstanceUtils.js +0 -0
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ /**
12
+ * This module handles the communication between the React Native renderer
13
+ * and all the intersection observers that are currently observing any targets.
14
+ *
15
+ * In order to reduce the communication between native and JavaScript,
16
+ * we register a single notication callback in native, and then we handle how
17
+ * to notify each entry to the right intersection observer when we receive all
18
+ * the notifications together.
19
+ */
20
+
21
+ import type ReactNativeElement from '../DOM/Nodes/ReactNativeElement';
22
+ import type IntersectionObserver, {
23
+ IntersectionObserverCallback,
24
+ } from './IntersectionObserver';
25
+ import type IntersectionObserverEntry from './IntersectionObserverEntry';
26
+
27
+ import {getShadowNode} from '../DOM/Nodes/ReadOnlyNode';
28
+ import * as Systrace from '../Performance/Systrace';
29
+ import warnOnce from '../Utilities/warnOnce';
30
+ import {createIntersectionObserverEntry} from './IntersectionObserverEntry';
31
+ import NativeIntersectionObserver from './NativeIntersectionObserver';
32
+
33
+ export type IntersectionObserverId = number;
34
+
35
+ let nextIntersectionObserverId: IntersectionObserverId = 1;
36
+ let isConnected: boolean = false;
37
+
38
+ const registeredIntersectionObservers: Map<
39
+ IntersectionObserverId,
40
+ {observer: IntersectionObserver, callback: IntersectionObserverCallback},
41
+ > = new Map();
42
+
43
+ /**
44
+ * Registers the given intersection observer and returns a unique ID for it,
45
+ * which is required to start observing targets.
46
+ */
47
+ export function registerObserver(
48
+ observer: IntersectionObserver,
49
+ callback: IntersectionObserverCallback,
50
+ ): IntersectionObserverId {
51
+ const intersectionObserverId = nextIntersectionObserverId;
52
+ nextIntersectionObserverId++;
53
+ registeredIntersectionObservers.set(intersectionObserverId, {
54
+ observer,
55
+ callback,
56
+ });
57
+ return intersectionObserverId;
58
+ }
59
+
60
+ /**
61
+ * Unregisters the given intersection observer.
62
+ * This should only be called when an observer is no longer observing any
63
+ * targets.
64
+ */
65
+ export function unregisterObserver(
66
+ intersectionObserverId: IntersectionObserverId,
67
+ ): void {
68
+ const deleted = registeredIntersectionObservers.delete(
69
+ intersectionObserverId,
70
+ );
71
+ if (deleted && registeredIntersectionObservers.size === 0) {
72
+ NativeIntersectionObserver?.disconnect();
73
+ isConnected = false;
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Starts observing a target on a specific intersection observer.
79
+ * If this is the first target being observed, this also sets up the centralized
80
+ * notification callback in native.
81
+ */
82
+ export function observe({
83
+ intersectionObserverId,
84
+ target,
85
+ }: {
86
+ intersectionObserverId: IntersectionObserverId,
87
+ target: ReactNativeElement,
88
+ }): void {
89
+ if (NativeIntersectionObserver == null) {
90
+ warnNoNativeIntersectionObserver();
91
+ return;
92
+ }
93
+
94
+ const registeredObserver = registeredIntersectionObservers.get(
95
+ intersectionObserverId,
96
+ );
97
+ if (registeredObserver == null) {
98
+ console.error(
99
+ `IntersectionObserverManager: could not start observing target because IntersectionObserver with ID ${intersectionObserverId} was not registered.`,
100
+ );
101
+ return;
102
+ }
103
+
104
+ const targetShadowNode = getShadowNode(target);
105
+ if (targetShadowNode == null) {
106
+ console.error(
107
+ 'IntersectionObserverManager: could not find reference to host node from target',
108
+ );
109
+ return;
110
+ }
111
+
112
+ if (!isConnected) {
113
+ NativeIntersectionObserver.connect(notifyIntersectionObservers);
114
+ isConnected = true;
115
+ }
116
+
117
+ return NativeIntersectionObserver.observe({
118
+ intersectionObserverId,
119
+ targetShadowNode,
120
+ thresholds: registeredObserver.observer.thresholds,
121
+ });
122
+ }
123
+
124
+ export function unobserve(
125
+ intersectionObserverId: number,
126
+ target: ReactNativeElement,
127
+ ): void {
128
+ if (NativeIntersectionObserver == null) {
129
+ warnNoNativeIntersectionObserver();
130
+ return;
131
+ }
132
+
133
+ const registeredObserver = registeredIntersectionObservers.get(
134
+ intersectionObserverId,
135
+ );
136
+ if (registeredObserver == null) {
137
+ console.error(
138
+ `IntersectionObserverManager: could not stop observing target because IntersectionObserver with ID ${intersectionObserverId} was not registered.`,
139
+ );
140
+ return;
141
+ }
142
+
143
+ const targetShadowNode = getShadowNode(target);
144
+ if (targetShadowNode == null) {
145
+ console.error(
146
+ 'IntersectionObserverManager: could not find reference to host node from target',
147
+ );
148
+ return;
149
+ }
150
+
151
+ NativeIntersectionObserver.unobserve(
152
+ intersectionObserverId,
153
+ targetShadowNode,
154
+ );
155
+ }
156
+
157
+ /**
158
+ * This function is called from native when there are `IntersectionObserver`
159
+ * entries to dispatch.
160
+ */
161
+ function notifyIntersectionObservers(): void {
162
+ Systrace.beginEvent(
163
+ 'IntersectionObserverManager.notifyIntersectionObservers',
164
+ );
165
+ try {
166
+ doNotifyIntersectionObservers();
167
+ } finally {
168
+ Systrace.endEvent();
169
+ }
170
+ }
171
+
172
+ function doNotifyIntersectionObservers(): void {
173
+ if (NativeIntersectionObserver == null) {
174
+ warnNoNativeIntersectionObserver();
175
+ return;
176
+ }
177
+
178
+ const nativeEntries = NativeIntersectionObserver.takeRecords();
179
+
180
+ const entriesByObserver: Map<
181
+ IntersectionObserverId,
182
+ Array<IntersectionObserverEntry>,
183
+ > = new Map();
184
+
185
+ for (const nativeEntry of nativeEntries) {
186
+ let list = entriesByObserver.get(nativeEntry.intersectionObserverId);
187
+ if (list == null) {
188
+ list = [];
189
+ entriesByObserver.set(nativeEntry.intersectionObserverId, list);
190
+ }
191
+ list.push(createIntersectionObserverEntry(nativeEntry));
192
+ }
193
+
194
+ for (const [
195
+ intersectionObserverId,
196
+ entriesForObserver,
197
+ ] of entriesByObserver) {
198
+ const registeredObserver = registeredIntersectionObservers.get(
199
+ intersectionObserverId,
200
+ );
201
+ if (!registeredObserver) {
202
+ // This could happen if the observer is disconnected between commit
203
+ // and mount. In this case, we can just ignore the entries.
204
+ return;
205
+ }
206
+
207
+ const {observer, callback} = registeredObserver;
208
+ try {
209
+ callback.call(observer, entriesForObserver, observer);
210
+ } catch (error) {
211
+ console.error(error);
212
+ }
213
+ }
214
+ }
215
+
216
+ function warnNoNativeIntersectionObserver() {
217
+ warnOnce(
218
+ 'missing-native-intersection-observer',
219
+ 'Missing native implementation of IntersectionObserver',
220
+ );
221
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ * @format
9
+ */
10
+
11
+ import type {TurboModule} from '../TurboModule/RCTExport';
12
+
13
+ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
14
+
15
+ export type NativeIntersectionObserverEntry = {
16
+ intersectionObserverId: number,
17
+ targetInstanceHandle: mixed,
18
+ targetRect: $ReadOnlyArray<number>, // It's actually a tuple with x, y, width and height
19
+ rootRect: $ReadOnlyArray<number>, // It's actually a tuple with x, y, width and height
20
+ intersectionRect: ?$ReadOnlyArray<number>, // It's actually a tuple with x, y, width and height
21
+ isIntersectingAboveThresholds: boolean,
22
+ time: number,
23
+ };
24
+
25
+ export type NativeIntersectionObserverObserveOptions = {
26
+ intersectionObserverId: number,
27
+ targetShadowNode: mixed,
28
+ thresholds: $ReadOnlyArray<number>,
29
+ };
30
+
31
+ export interface Spec extends TurboModule {
32
+ +observe: (options: NativeIntersectionObserverObserveOptions) => void;
33
+ +unobserve: (intersectionObserverId: number, targetShadowNode: mixed) => void;
34
+ +connect: (notifyIntersectionObserversCallback: () => void) => void;
35
+ +disconnect: () => void;
36
+ +takeRecords: () => $ReadOnlyArray<NativeIntersectionObserverEntry>;
37
+ }
38
+
39
+ export default (TurboModuleRegistry.get<Spec>(
40
+ 'NativeIntersectionObserverCxx',
41
+ ): ?Spec);
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import type ReactNativeElement from '../../DOM/Nodes/ReactNativeElement';
12
+ import type IntersectionObserver from '../IntersectionObserver';
13
+ import type {
14
+ NativeIntersectionObserverEntry,
15
+ NativeIntersectionObserverObserveOptions,
16
+ Spec,
17
+ } from '../NativeIntersectionObserver';
18
+
19
+ import {getShadowNode} from '../../DOM/Nodes/ReadOnlyNode';
20
+ import {getFabricUIManager} from '../../ReactNative/__mocks__/FabricUIManager';
21
+ import invariant from 'invariant';
22
+ import nullthrows from 'nullthrows';
23
+
24
+ type ObserverState = {
25
+ thresholds: $ReadOnlyArray<number>,
26
+ intersecting: boolean,
27
+ currentThreshold: ?number,
28
+ };
29
+
30
+ type Observation = {
31
+ ...NativeIntersectionObserverObserveOptions,
32
+ state: ObserverState,
33
+ };
34
+
35
+ let pendingRecords: Array<NativeIntersectionObserverEntry> = [];
36
+ let callback: ?() => void;
37
+ let observations: Array<Observation> = [];
38
+
39
+ const FabricUIManagerMock = nullthrows(getFabricUIManager());
40
+
41
+ function createRecordFromObservation(
42
+ observation: Observation,
43
+ ): NativeIntersectionObserverEntry {
44
+ return {
45
+ intersectionObserverId: observation.intersectionObserverId,
46
+ targetInstanceHandle: FabricUIManagerMock.__getInstanceHandleFromNode(
47
+ // $FlowExpectedError[incompatible-call]
48
+ observation.targetShadowNode,
49
+ ),
50
+ targetRect: observation.state.intersecting ? [0, 0, 1, 1] : [20, 20, 1, 1],
51
+ rootRect: [0, 0, 10, 10],
52
+ intersectionRect: observation.state.intersecting ? [0, 0, 1, 1] : null,
53
+ isIntersectingAboveThresholds: observation.state.intersecting,
54
+ time: performance.now(),
55
+ };
56
+ }
57
+
58
+ function notifyIntersectionObservers(): void {
59
+ callback?.();
60
+ }
61
+
62
+ const NativeIntersectionObserverMock = {
63
+ observe: (options: NativeIntersectionObserverObserveOptions): void => {
64
+ invariant(
65
+ observations.find(
66
+ observation =>
67
+ observation.intersectionObserverId ===
68
+ options.intersectionObserverId &&
69
+ observation.targetShadowNode === options.targetShadowNode,
70
+ ) == null,
71
+ 'unexpected duplicate call to observe',
72
+ );
73
+ const observation = {
74
+ ...options,
75
+ state: {
76
+ thresholds: options.thresholds,
77
+ intersecting: false,
78
+ currentThreshold: null,
79
+ },
80
+ };
81
+ observations.push(observation);
82
+ pendingRecords.push(createRecordFromObservation(observation));
83
+ setImmediate(notifyIntersectionObservers);
84
+ },
85
+ unobserve: (
86
+ intersectionObserverId: number,
87
+ targetShadowNode: mixed,
88
+ ): void => {
89
+ const observationIndex = observations.findIndex(
90
+ observation =>
91
+ observation.intersectionObserverId === intersectionObserverId &&
92
+ observation.targetShadowNode === targetShadowNode,
93
+ );
94
+ invariant(
95
+ observationIndex !== -1,
96
+ 'unexpected duplicate call to unobserve',
97
+ );
98
+ observations.splice(observationIndex, 1);
99
+ },
100
+ connect: (notifyIntersectionObserversCallback: () => void): void => {
101
+ invariant(callback == null, 'unexpected call to connect');
102
+ invariant(
103
+ notifyIntersectionObserversCallback != null,
104
+ 'unexpected null notify intersection observers callback',
105
+ );
106
+ callback = notifyIntersectionObserversCallback;
107
+ },
108
+ disconnect: (): void => {
109
+ invariant(callback != null, 'unexpected call to disconnect');
110
+ callback = null;
111
+ },
112
+ takeRecords: (): $ReadOnlyArray<NativeIntersectionObserverEntry> => {
113
+ const currentRecords = pendingRecords;
114
+ pendingRecords = [];
115
+ return currentRecords;
116
+ },
117
+ __forceTransitionForTests: (
118
+ observer: IntersectionObserver,
119
+ target: ReactNativeElement,
120
+ ) => {
121
+ const targetShadowNode = getShadowNode(target);
122
+ const observation = observations.find(
123
+ obs =>
124
+ obs.intersectionObserverId === observer.__getObserverID() &&
125
+ obs.targetShadowNode === targetShadowNode,
126
+ );
127
+ invariant(
128
+ observation != null,
129
+ 'cannot force transition on an unobserved target',
130
+ );
131
+ if (observation.state.intersecting) {
132
+ observation.state.intersecting = false;
133
+ observation.state.currentThreshold = null;
134
+ } else {
135
+ observation.state.intersecting = true;
136
+ observation.state.currentThreshold = observation.thresholds[0];
137
+ }
138
+ pendingRecords.push(createRecordFromObservation(observation));
139
+ setImmediate(notifyIntersectionObservers);
140
+ },
141
+ __getObservationsForTests: (
142
+ observer: IntersectionObserver,
143
+ ): Array<{targetShadowNode: mixed, thresholds: $ReadOnlyArray<number>}> => {
144
+ const intersectionObserverId = observer.__getObserverID();
145
+ return observations
146
+ .filter(
147
+ observation =>
148
+ observation.intersectionObserverId === intersectionObserverId,
149
+ )
150
+ .map(observation => ({
151
+ targetShadowNode: observation.targetShadowNode,
152
+ thresholds: observation.thresholds,
153
+ }));
154
+ },
155
+ __isConnected: (): boolean => {
156
+ return callback != null;
157
+ },
158
+ };
159
+
160
+ (NativeIntersectionObserverMock: Spec);
161
+
162
+ export default NativeIntersectionObserverMock;
@@ -49,7 +49,7 @@ function configureNext(
49
49
  onAnimationDidEnd?: OnAnimationDidEndCallback,
50
50
  onAnimationDidFail?: OnAnimationDidFailCallback,
51
51
  ) {
52
- if (Platform.isTesting) {
52
+ if (Platform.isDisableAnimations) {
53
53
  return;
54
54
  }
55
55
 
@@ -12,6 +12,7 @@ import type {
12
12
  ListRenderItem,
13
13
  ViewToken,
14
14
  VirtualizedListProps,
15
+ ViewabilityConfig,
15
16
  } from '@react-native/virtualized-lists';
16
17
  import type {ScrollViewComponent} from '../Components/ScrollView/ScrollView';
17
18
  import type {StyleProp} from '../StyleSheet/StyleSheet';
@@ -144,7 +145,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
144
145
  /**
145
146
  * See `ViewabilityHelper` for flow type and further documentation.
146
147
  */
147
- viewabilityConfig?: any | undefined;
148
+ viewabilityConfig?: ViewabilityConfig | undefined;
148
149
 
149
150
  /**
150
151
  * Note: may have bugs (missing content) in some circumstances - use at your own risk.
@@ -36,7 +36,7 @@ type RequiredProps<ItemT> = {|
36
36
  * An array (or array-like list) of items to render. Other data types can be
37
37
  * used by targeting VirtualizedList directly.
38
38
  */
39
- data: ?$ArrayLike<ItemT>,
39
+ data: ?$ReadOnly<$ArrayLike<ItemT>>,
40
40
  |};
41
41
  type OptionalProps<ItemT> = {|
42
42
  /**
@@ -91,7 +91,7 @@ type OptionalProps<ItemT> = {|
91
91
  * specify `ItemSeparatorComponent`.
92
92
  */
93
93
  getItemLayout?: (
94
- data: ?$ArrayLike<ItemT>,
94
+ data: ?$ReadOnly<$ArrayLike<ItemT>>,
95
95
  index: number,
96
96
  ) => {
97
97
  length: number,
@@ -436,7 +436,16 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
436
436
  * see the error delete this comment and run Flow. */
437
437
  viewabilityConfig: this.props.viewabilityConfig,
438
438
  onViewableItemsChanged: this._createOnViewableItemsChanged(
439
- this.props.onViewableItemsChanged,
439
+ // NOTE: we use a wrapper function to allow the actual callback to change
440
+ // while still keeping the function provided to native to be stable
441
+ (...args) => {
442
+ invariant(
443
+ this.props.onViewableItemsChanged,
444
+ 'Changing the nullability of onViewableItemsChanged is not supported. ' +
445
+ 'Once a function or null is supplied that cannot be changed.',
446
+ );
447
+ return this.props.onViewableItemsChanged(...args);
448
+ },
440
449
  ),
441
450
  });
442
451
  }
@@ -450,8 +459,9 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
450
459
  'changing the number of columns to force a fresh render of the component.',
451
460
  );
452
461
  invariant(
453
- prevProps.onViewableItemsChanged === this.props.onViewableItemsChanged,
454
- 'Changing onViewableItemsChanged on the fly is not supported',
462
+ (prevProps.onViewableItemsChanged == null) ===
463
+ (this.props.onViewableItemsChanged == null),
464
+ 'Changing onViewableItemsChanged nullability on the fly is not supported',
455
465
  );
456
466
  invariant(
457
467
  !deepDiffer(prevProps.viewabilityConfig, this.props.viewabilityConfig),
@@ -244,6 +244,10 @@ export default class SectionList<
244
244
  const stickySectionHeadersEnabled =
245
245
  _stickySectionHeadersEnabled ?? Platform.OS === 'ios';
246
246
  return (
247
+ /* $FlowFixMe[incompatible-type] Error revealed after improved builtin
248
+ * React utility types */
249
+ /* $FlowFixMe[incompatible-type] Error revealed after improved builtin
250
+ * React utility types */
247
251
  <VirtualizedSectionList
248
252
  {...restProps}
249
253
  stickySectionHeadersEnabled={stickySectionHeadersEnabled}
@@ -30,6 +30,7 @@ export type LogData = $ReadOnly<{|
30
30
  message: Message,
31
31
  category: Category,
32
32
  componentStack: ComponentStack,
33
+ stack?: string,
33
34
  |}>;
34
35
 
35
36
  export type Observer = (
@@ -198,7 +199,7 @@ export function addLog(log: LogData): void {
198
199
  // otherwise spammy logs would pause rendering.
199
200
  setImmediate(() => {
200
201
  try {
201
- const stack = parseErrorStack(errorForStackTrace?.stack);
202
+ const stack = parseErrorStack(log.stack ?? errorForStackTrace?.stack);
202
203
 
203
204
  appendNewLog(
204
205
  new LogBoxLog({
@@ -31,6 +31,7 @@ export type LogBoxLogData = $ReadOnly<{|
31
31
  componentStack: ComponentStack,
32
32
  codeFrame?: ?CodeFrame,
33
33
  isComponentError: boolean,
34
+ extraData?: mixed,
34
35
  |}>;
35
36
 
36
37
  class LogBoxLog {
@@ -43,6 +44,7 @@ class LogBoxLog {
43
44
  level: LogLevel;
44
45
  codeFrame: ?CodeFrame;
45
46
  isComponentError: boolean;
47
+ extraData: mixed | void;
46
48
  symbolicated:
47
49
  | $ReadOnly<{|error: null, stack: null, status: 'NONE'|}>
48
50
  | $ReadOnly<{|error: null, stack: null, status: 'PENDING'|}>
@@ -62,6 +64,7 @@ class LogBoxLog {
62
64
  this.componentStack = data.componentStack;
63
65
  this.codeFrame = data.codeFrame;
64
66
  this.isComponentError = data.isComponentError;
67
+ this.extraData = data.extraData;
65
68
  this.count = 1;
66
69
  }
67
70
 
@@ -91,7 +94,7 @@ class LogBoxLog {
91
94
  handleSymbolicate(callback?: (status: SymbolicationStatus) => void): void {
92
95
  if (this.symbolicated.status !== 'PENDING') {
93
96
  this.updateStatus(null, null, null, callback);
94
- LogBoxSymbolication.symbolicate(this.stack).then(
97
+ LogBoxSymbolication.symbolicate(this.stack, this.extraData).then(
95
98
  data => {
96
99
  this.updateStatus(null, data?.stack, data?.codeFrame, callback);
97
100
  },
@@ -51,10 +51,13 @@ export function deleteStack(stack: Stack): void {
51
51
  cache.delete(stack);
52
52
  }
53
53
 
54
- export function symbolicate(stack: Stack): Promise<SymbolicatedStackTrace> {
54
+ export function symbolicate(
55
+ stack: Stack,
56
+ extraData?: mixed,
57
+ ): Promise<SymbolicatedStackTrace> {
55
58
  let promise = cache.get(stack);
56
59
  if (promise == null) {
57
- promise = symbolicateStackTrace(stack).then(sanitize);
60
+ promise = symbolicateStackTrace(stack, extraData).then(sanitize);
58
61
  cache.set(stack, promise);
59
62
  }
60
63