@office-iss/react-native-win32 0.81.2 → 0.82.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 (209) hide show
  1. package/.flowconfig +3 -11
  2. package/CHANGELOG.json +118 -43
  3. package/CHANGELOG.md +45 -27
  4. package/IntegrationTests/IntegrationTestsApp.js +2 -2
  5. package/IntegrationTests/LayoutEventsTest.js +3 -3
  6. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -3
  7. package/Libraries/Alert/RCTAlertManager.android.js +4 -2
  8. package/Libraries/Animated/Animated.d.ts +2 -0
  9. package/Libraries/Animated/AnimatedEvent.js +1 -1
  10. package/Libraries/Animated/AnimatedExports.js.flow +1 -0
  11. package/Libraries/Animated/AnimatedImplementation.js +4 -2
  12. package/Libraries/Animated/AnimatedMock.js +1 -1
  13. package/Libraries/Animated/Easing.js +2 -0
  14. package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
  15. package/Libraries/Animated/animations/Animation.js +19 -20
  16. package/Libraries/Animated/animations/TimingAnimation.js +2 -0
  17. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  18. package/Libraries/Animated/components/AnimatedSectionList.js +1 -1
  19. package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
  20. package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
  21. package/Libraries/Animated/nodes/AnimatedNode.js +14 -7
  22. package/Libraries/Animated/nodes/AnimatedObject.js +7 -7
  23. package/Libraries/Animated/nodes/AnimatedProps.js +32 -32
  24. package/Libraries/Animated/nodes/AnimatedStyle.js +23 -21
  25. package/Libraries/Animated/nodes/AnimatedTransform.js +6 -6
  26. package/Libraries/Animated/nodes/AnimatedValue.js +18 -26
  27. package/Libraries/AppState/AppState.js +8 -4
  28. package/Libraries/BatchedBridge/BatchedBridge.js +1 -0
  29. package/Libraries/BatchedBridge/MessageQueue.js +5 -0
  30. package/Libraries/BatchedBridge/NativeModules.js +1 -1
  31. package/Libraries/Blob/BlobManager.js +1 -1
  32. package/Libraries/Blob/URLSearchParams.js +2 -0
  33. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -2
  34. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -2
  35. package/Libraries/Components/Button.js +1 -1
  36. package/Libraries/Components/Button.win32.js +1 -1
  37. package/Libraries/Components/Pressable/Pressable.js +10 -1
  38. package/Libraries/Components/Pressable/Pressable.win32.js +9 -0
  39. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  40. package/Libraries/Components/ScrollView/ScrollView.js +13 -4
  41. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  42. package/Libraries/Components/StatusBar/StatusBar.js +2 -2
  43. package/Libraries/Components/Switch/Switch.js +1 -1
  44. package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
  45. package/Libraries/Components/TextInput/TextInput.flow.win32.js +12 -5
  46. package/Libraries/Components/TextInput/TextInput.js +14 -5
  47. package/Libraries/Components/TextInput/TextInput.win32.js +15 -7
  48. package/Libraries/Components/TextInput/TextInputState.js +1 -1
  49. package/Libraries/Components/TextInput/TextInputState.win32.js +1 -1
  50. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +2 -3
  51. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  52. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  53. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  54. package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
  55. package/Libraries/Components/Touchable/TouchableWin32.js +1 -1
  56. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  57. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +3 -3
  58. package/Libraries/Components/View/View.js +81 -167
  59. package/Libraries/Components/View/View.win32.js +3 -1
  60. package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
  61. package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +1 -1
  62. package/Libraries/Core/ExceptionsManager.js +4 -2
  63. package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
  64. package/Libraries/Core/ReactNativeVersion.js +37 -10
  65. package/Libraries/Core/Timers/JSTimers.js +4 -1
  66. package/Libraries/Core/Timers/NativeTiming.js +1 -0
  67. package/Libraries/Core/Timers/immediateShim.js +2 -1
  68. package/Libraries/Core/Timers/queueMicrotask.js +1 -0
  69. package/Libraries/Core/setUpPerformance.js +3 -4
  70. package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
  71. package/Libraries/Image/Image.android.js +327 -111
  72. package/Libraries/Image/Image.ios.js +6 -1
  73. package/Libraries/Image/Image.win32.js +6 -1
  74. package/Libraries/Image/ImageSourceUtils.js +8 -2
  75. package/Libraries/Image/assetPaths.js +1 -1
  76. package/Libraries/Image/resolveAssetSource.js +1 -1
  77. package/Libraries/Image/resolveAssetSource.win32.js +6 -7
  78. package/Libraries/Interaction/InteractionManager.js +118 -167
  79. package/Libraries/Interaction/PanResponder.js +7 -52
  80. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -0
  81. package/Libraries/Lists/FlatList.js +5 -6
  82. package/Libraries/LogBox/Data/LogBoxData.js +5 -2
  83. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  84. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +2 -2
  85. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
  86. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +1 -1
  87. package/Libraries/Modal/Modal.js +3 -3
  88. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  89. package/Libraries/NativeComponent/ViewConfig.js +2 -2
  90. package/Libraries/Network/RCTNetworking.android.js +1 -1
  91. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  92. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  93. package/Libraries/Network/XMLHttpRequest.js +20 -5
  94. package/Libraries/Network/convertRequestBody.js +1 -1
  95. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
  96. package/Libraries/Pressability/HoverState.js +2 -0
  97. package/Libraries/Pressability/HoverState.win32.js +2 -0
  98. package/Libraries/Pressability/Pressability.js +1 -1
  99. package/Libraries/Pressability/Pressability.win32.js +1 -1
  100. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
  101. package/Libraries/ReactNative/AppRegistryImpl.js +4 -2
  102. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
  103. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
  104. package/Libraries/ReactNative/RendererImplementation.js +116 -116
  105. package/Libraries/ReactNative/UIManager.js +3 -3
  106. package/Libraries/ReactNative/renderApplication.js +1 -0
  107. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
  108. package/Libraries/Renderer/implementations/ReactFabric-dev.js +38 -35
  109. package/Libraries/Renderer/implementations/ReactFabric-prod.js +51 -22
  110. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +54 -24
  111. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +36 -33
  112. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5 -5
  113. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5 -5
  114. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
  115. package/Libraries/Share/Share.js +4 -0
  116. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
  117. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
  118. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +4 -0
  119. package/Libraries/StyleSheet/StyleSheet.d.ts +7 -22
  120. package/Libraries/StyleSheet/StyleSheetExports.js +2 -8
  121. package/Libraries/StyleSheet/StyleSheetExports.js.flow +11 -18
  122. package/Libraries/StyleSheet/flattenStyle.js +2 -2
  123. package/Libraries/StyleSheet/processAspectRatio.js +2 -0
  124. package/Libraries/StyleSheet/processFilter.js +5 -5
  125. package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
  126. package/Libraries/Text/Text.js +534 -234
  127. package/Libraries/Text/Text.win32.js +647 -274
  128. package/Libraries/Text/TextNativeComponent.js +2 -2
  129. package/Libraries/Text/TextNativeComponent.win32.js +2 -2
  130. package/Libraries/Utilities/Appearance.d.ts +3 -5
  131. package/Libraries/Utilities/Appearance.js +5 -17
  132. package/Libraries/Utilities/HMRClient.js +2 -1
  133. package/Libraries/Utilities/Platform.android.js +3 -3
  134. package/Libraries/Utilities/Platform.d.ts +1 -0
  135. package/Libraries/Utilities/Platform.ios.js +1 -1
  136. package/Libraries/Utilities/Platform.win32.js +3 -3
  137. package/Libraries/Utilities/PlatformTypes.js +1 -1
  138. package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
  139. package/Libraries/Utilities/SceneTracker.js +1 -1
  140. package/Libraries/Utilities/codegenNativeCommands.js +1 -1
  141. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  142. package/Libraries/Utilities/createPerformanceLogger.js +32 -0
  143. package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
  144. package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
  145. package/Libraries/Utilities/useMergeRefs.js +1 -1
  146. package/Libraries/WebSocket/WebSocketInterceptor.js +2 -0
  147. package/Libraries/promiseRejectionTrackingOptions.js +17 -31
  148. package/Libraries/vendor/emitter/EventEmitter.js +1 -1
  149. package/flow/bom.js.flow +223 -1
  150. package/flow/prettier.js.flow +14 -0
  151. package/index.js +14 -2
  152. package/index.win32.js +16 -2
  153. package/jest/local-setup.js +2 -2
  154. package/jest/mock.js +1 -1
  155. package/jest/mockComponent.js +9 -9
  156. package/jest/mockNativeComponent.js +3 -2
  157. package/jest/mocks/Modal.js +1 -1
  158. package/jest/mocks/ScrollView.js +1 -1
  159. package/jest/mocks/ViewNativeComponent.js +1 -1
  160. package/jest/setup.js +23 -12
  161. package/overrides.json +23 -23
  162. package/package.json +28 -27
  163. package/saveAssetPlugin.js +2 -2
  164. package/src/private/animated/NativeAnimatedHelper.js +16 -5
  165. package/src/private/animated/NativeAnimatedHelper.win32.js +16 -5
  166. package/src/private/animated/createAnimatedPropsHook.js +11 -60
  167. package/src/private/animated/createAnimatedPropsMemoHook.js +8 -54
  168. package/src/private/components/virtualview/VirtualView.js +43 -12
  169. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +93 -0
  170. package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
  171. package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
  172. package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -2
  173. package/src/private/featureflags/ReactNativeFeatureFlags.js +85 -52
  174. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
  175. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +15 -6
  176. package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
  177. package/src/private/setup/{setUpPerformanceObserver.js → setUpPerformanceModern.js} +43 -18
  178. package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -0
  179. package/src/private/types/HostInstance.js +4 -1
  180. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
  181. package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
  182. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
  183. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
  184. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
  185. package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
  186. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
  187. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +15 -12
  188. package/src/private/webapis/dom/oldstylecollections/NodeList.js +14 -11
  189. package/src/private/webapis/geometry/DOMRectList.js +2 -2
  190. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +19 -74
  191. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +0 -4
  192. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
  193. package/src/private/webapis/performance/EventTiming.js +40 -25
  194. package/src/private/webapis/performance/LongTasks.js +35 -2
  195. package/src/private/webapis/performance/Performance.js +347 -166
  196. package/src/private/webapis/performance/PerformanceEntry.js +40 -23
  197. package/src/private/webapis/performance/PerformanceObserver.js +37 -29
  198. package/src/private/webapis/performance/ReactNativeStartupTiming.js +3 -24
  199. package/src/private/webapis/performance/ResourceTiming.js +29 -18
  200. package/src/private/webapis/performance/UserTiming.js +92 -34
  201. package/src/private/webapis/performance/UserTimingExtensibility.js.flow +38 -0
  202. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -4
  203. package/src/private/webapis/performance/internals/Utilities.js +9 -0
  204. package/src/private/webapis/performance/specs/NativePerformance.js +23 -23
  205. package/src/private/webapis/structuredClone/structuredClone.js +10 -10
  206. package/src-win/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  207. package/Libraries/Interaction/InteractionManagerStub.js +0 -184
  208. package/Libraries/Interaction/TaskQueue.js +0 -183
  209. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -31
@@ -34,6 +34,9 @@ const RCTNetworking = require('./RCTNetworking').default;
34
34
  const base64 = require('base64-js');
35
35
  const invariant = require('invariant');
36
36
 
37
+ const PERFORMANCE_TRACK_NAME = 'Network (JS-initiated only)';
38
+ const PERFORMANCE_TRACK_GROUP = 'Chrome DevTools Temp Compat';
39
+
37
40
  declare var performance: Performance;
38
41
 
39
42
  const DEBUG_NETWORK_SEND_DELAY: false = false; // Set to a number of milliseconds when debugging
@@ -385,6 +388,9 @@ class XMLHttpRequest extends EventTarget {
385
388
  if (requestId !== this._requestId) {
386
389
  return;
387
390
  }
391
+
392
+ const start = XMLHttpRequest._profiling ? performance.now() : undefined;
393
+
388
394
  if (!this._response) {
389
395
  this._response = responseText;
390
396
  } else {
@@ -392,8 +398,12 @@ class XMLHttpRequest extends EventTarget {
392
398
  }
393
399
 
394
400
  if (XMLHttpRequest._profiling) {
395
- performance.mark(
396
- 'Track:XMLHttpRequest:Incremental Data: ' + this._getMeasureURL(),
401
+ console.timeStamp(
402
+ 'Incremental Data: ' + this._getMeasureURL(),
403
+ start,
404
+ undefined,
405
+ PERFORMANCE_TRACK_NAME,
406
+ PERFORMANCE_TRACK_GROUP,
397
407
  );
398
408
  }
399
409
  XMLHttpRequest._interceptor &&
@@ -442,10 +452,13 @@ class XMLHttpRequest extends EventTarget {
442
452
  this.setReadyState(this.DONE);
443
453
  if (XMLHttpRequest._profiling && this._startTime != null) {
444
454
  const start = this._startTime;
445
- performance.measure('Track:XMLHttpRequest:' + this._getMeasureURL(), {
455
+ console.timeStamp(
456
+ this._getMeasureURL(),
446
457
  start,
447
- end: performance.now(),
448
- });
458
+ undefined,
459
+ PERFORMANCE_TRACK_NAME,
460
+ PERFORMANCE_TRACK_GROUP,
461
+ );
449
462
  }
450
463
  if (error) {
451
464
  XMLHttpRequest._interceptor &&
@@ -646,6 +659,8 @@ class XMLHttpRequest extends EventTarget {
646
659
  this.withCredentials,
647
660
  );
648
661
  };
662
+ /* $FlowFixMe[constant-condition] Error discovered during Constant
663
+ * Condition roll out. See https://fburl.com/workplace/1v97vimq. */
649
664
  if (DEBUG_NETWORK_SEND_DELAY) {
650
665
  setTimeout(doSend, DEBUG_NETWORK_SEND_DELAY);
651
666
  } else {
@@ -36,7 +36,7 @@ function convertRequestBody(body: RequestBody): Object {
36
36
  return {formData: body.getParts()};
37
37
  }
38
38
  if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {
39
- /* $FlowFixMe[incompatible-call] : no way to assert that 'body' is indeed
39
+ /* $FlowFixMe[incompatible-type] : no way to assert that 'body' is indeed
40
40
  * an ArrayBufferView */
41
41
  return {base64: binaryToBase64(body)};
42
42
  }
@@ -8,6 +8,8 @@
8
8
  * @format
9
9
  */
10
10
 
11
+ import type {DialogOptions} from '../../src/private/specs_DEPRECATED/modules/NativeDialogManagerAndroid';
12
+
11
13
  import NativeDialogManagerAndroid from '../NativeModules/specs/NativeDialogManagerAndroid';
12
14
  import NativePermissionsAndroid from './NativePermissionsAndroid';
13
15
  import invariant from 'invariant';
@@ -249,24 +251,24 @@ class PermissionsAndroidImpl {
249
251
 
250
252
  if (shouldShowRationale && !!NativeDialogManagerAndroid) {
251
253
  return new Promise((resolve, reject) => {
252
- const options = {
254
+ /* $FlowFixMe[incompatible-exact] (>=0.111.0 site=react_native_fb)
255
+ * This comment suppresses an error found when Flow v0.111 was
256
+ * deployed. To see the error, delete this comment and run Flow.
257
+ */
258
+ const options: DialogOptions = {
253
259
  ...rationale,
254
260
  };
255
261
  NativeDialogManagerAndroid.showAlert(
256
- /* $FlowFixMe[incompatible-exact] (>=0.111.0 site=react_native_fb)
257
- * This comment suppresses an error found when Flow v0.111 was
258
- * deployed. To see the error, delete this comment and run Flow.
259
- */
260
262
  options,
261
263
  () => reject(new Error('Error showing rationale')),
262
264
  () =>
263
- // $FlowFixMe[incompatible-call]
265
+ // $FlowFixMe[incompatible-type]
264
266
  resolve(NativePermissionsAndroid.requestPermission(permission)),
265
267
  );
266
268
  });
267
269
  }
268
270
  }
269
- // $FlowFixMe[incompatible-return]
271
+ // $FlowFixMe[incompatible-type]
270
272
  return NativePermissionsAndroid.requestPermission(permission);
271
273
  }
272
274
 
@@ -291,8 +293,7 @@ class PermissionsAndroidImpl {
291
293
  NativePermissionsAndroid,
292
294
  'PermissionsAndroid is not installed correctly.',
293
295
  );
294
- // $FlowFixMe[incompatible-return]
295
- // $FlowFixMe[incompatible-call]
296
+ // $FlowFixMe[incompatible-type]
296
297
  return NativePermissionsAndroid.requestMultiplePermissions(permissions);
297
298
  }
298
299
  }
@@ -14,6 +14,8 @@ let isEnabled = false;
14
14
 
15
15
  /* $FlowFixMe[incompatible-type] Error found due to incomplete typing of
16
16
  * Platform.flow.js */
17
+ /* $FlowFixMe[invalid-compare] Error discovered during Constant Condition roll
18
+ * out. See https://fburl.com/workplace/4oq3zi07. */
17
19
  if (Platform.OS === 'web') {
18
20
  const canUseDOM = Boolean(
19
21
  typeof window !== 'undefined' &&
@@ -14,6 +14,8 @@ let isEnabled = false;
14
14
 
15
15
  /* $FlowFixMe[incompatible-type] Error found due to incomplete typing of
16
16
  * Platform.flow.js */
17
+ /* $FlowFixMe[invalid-compare] Error discovered during Constant Condition roll
18
+ * out. See https://fburl.com/workplace/4oq3zi07. */
17
19
  if (Platform.OS === 'web') {
18
20
  const canUseDOM = Boolean(
19
21
  typeof window !== 'undefined' &&
@@ -16,8 +16,8 @@ import type {
16
16
  MouseEvent,
17
17
  } from '../Types/CoreEventTypes';
18
18
 
19
+ import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
19
20
  import SoundManager from '../Components/Sound/SoundManager';
20
- import ReactNativeFeatureFlags from '../ReactNative/ReactNativeFeatureFlags';
21
21
  import UIManager from '../ReactNative/UIManager';
22
22
  import {type RectOrSize, normalizeRect} from '../StyleSheet/Rect';
23
23
  import {type PointerEvent} from '../Types/CoreEventTypes';
@@ -17,8 +17,8 @@ import type {
17
17
  MouseEvent,
18
18
  } from '../Types/CoreEventTypes';
19
19
 
20
+ import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
20
21
  import SoundManager from '../Components/Sound/SoundManager';
21
- import ReactNativeFeatureFlags from '../ReactNative/ReactNativeFeatureFlags';
22
22
  import UIManager from '../ReactNative/UIManager';
23
23
  import {type RectOrSize, normalizeRect} from '../StyleSheet/Rect';
24
24
  import {type PointerEvent} from '../Types/CoreEventTypes';
@@ -210,7 +210,7 @@ class PushNotificationIOS {
210
210
  NativePushNotificationManagerIOS,
211
211
  'PushNotificationManager is not available.',
212
212
  );
213
- // $FlowFixMe[prop-missing]
213
+ // $FlowFixMe[incompatible-type]
214
214
  NativePushNotificationManagerIOS.presentLocalNotification(details);
215
215
  }
216
216
 
@@ -235,7 +235,7 @@ class PushNotificationIOS {
235
235
  NativePushNotificationManagerIOS,
236
236
  'PushNotificationManager is not available.',
237
237
  );
238
- // $FlowFixMe[prop-missing]
238
+ // $FlowFixMe[incompatible-type]
239
239
  NativePushNotificationManagerIOS.scheduleLocalNotification(details);
240
240
  }
241
241
 
@@ -26,8 +26,6 @@ import createPerformanceLogger from '../Utilities/createPerformanceLogger';
26
26
  import SceneTracker from '../Utilities/SceneTracker';
27
27
  import {coerceDisplayMode} from './DisplayMode';
28
28
  import HeadlessJsTaskError from './HeadlessJsTaskError';
29
- import NativeHeadlessJsTaskSupport from './NativeHeadlessJsTaskSupport';
30
- import renderApplication from './renderApplication';
31
29
  import {unmountComponentAtNodeAndRemoveContainer} from './RendererProxy';
32
30
  import invariant from 'invariant';
33
31
 
@@ -86,6 +84,7 @@ export function registerComponent(
86
84
  ): string {
87
85
  const scopedPerformanceLogger = createPerformanceLogger();
88
86
  runnables[appKey] = (appParameters, displayMode) => {
87
+ const renderApplication = require('./renderApplication').default;
89
88
  renderApplication(
90
89
  componentProviderInstrumentationHook(
91
90
  componentProvider,
@@ -258,6 +257,9 @@ export function startHeadlessTask(
258
257
  taskKey: string,
259
258
  data: any,
260
259
  ): void {
260
+ const NativeHeadlessJsTaskSupport =
261
+ require('./NativeHeadlessJsTaskSupport').default;
262
+
261
263
  const taskProvider = taskProviders.get(taskKey);
262
264
  if (!taskProvider) {
263
265
  console.warn(`No task registered for key ${taskKey}`);
@@ -58,10 +58,12 @@ export default class ReactFabricHostComponent implements NativeMethods {
58
58
  }
59
59
 
60
60
  blur() {
61
+ // $FlowFixMe[incompatible-type] - Error supressed during the migration of HostInstance to ReactNativeElement
61
62
  TextInputState.blurTextInput(this);
62
63
  }
63
64
 
64
65
  focus() {
66
+ // $FlowFixMe[incompatible-type] - Error supressed during the migration of HostInstance to ReactNativeElement
65
67
  TextInputState.focusTextInput(this);
66
68
  }
67
69
 
@@ -132,7 +132,7 @@ export function getNodeFromPublicInstance(
132
132
  RendererProxy = require('../../ReactNative/RendererProxy');
133
133
  }
134
134
  return RendererProxy.getNodeFromInternalInstanceHandle(
135
- // $FlowExpectedError[incompatible-call] __internalInstanceHandle is always an InternalInstanceHandle from React when we get here.
135
+ // $FlowExpectedError[incompatible-type] __internalInstanceHandle is always an InternalInstanceHandle from React when we get here.
136
136
  publicInstance.__internalInstanceHandle,
137
137
  );
138
138
  }
@@ -143,10 +143,10 @@ export function getInternalInstanceHandleFromPublicInstance(
143
143
  // TODO(T174762768): Remove this once OSS versions of renderers will be synced.
144
144
  // $FlowExpectedError[prop-missing] Keeping this for backwards-compatibility with the renderers versions in open source.
145
145
  if (publicInstance._internalInstanceHandle != null) {
146
- // $FlowExpectedError[incompatible-return] Keeping this for backwards-compatibility with the renderers versions in open source.
146
+ // $FlowExpectedError[incompatible-type] Keeping this for backwards-compatibility with the renderers versions in open source.
147
147
  return publicInstance._internalInstanceHandle;
148
148
  }
149
149
 
150
- // $FlowExpectedError[incompatible-return] __internalInstanceHandle is always an InternalInstanceHandle from React when we get here.
150
+ // $FlowExpectedError[incompatible-type] __internalInstanceHandle is always an InternalInstanceHandle from React when we get here.
151
151
  return publicInstance.__internalInstanceHandle;
152
152
  }
@@ -9,19 +9,71 @@
9
9
  */
10
10
 
11
11
  import type {HostInstance} from '../../src/private/types/HostInstance';
12
- import type {
13
- InternalInstanceHandle,
14
- Node,
15
- } from '../Renderer/shims/ReactNativeTypes';
12
+ import typeof ReactFabricType from '../Renderer/shims/ReactFabric';
13
+ import typeof ReactNativeType from '../Renderer/shims/ReactNative';
14
+ import type {RootTag} from './RootTag';
16
15
 
17
16
  import {
18
17
  onCaughtError,
19
18
  onRecoverableError,
20
19
  onUncaughtError,
21
20
  } from '../../src/private/renderer/errorhandling/ErrorHandlers';
22
- import {type RootTag} from './RootTag';
23
21
  import * as React from 'react';
24
22
 
23
+ let cachedFabricRenderer;
24
+ let cachedPaperRenderer;
25
+
26
+ function getFabricRenderer(): ReactFabricType {
27
+ if (cachedFabricRenderer == null) {
28
+ cachedFabricRenderer = require('../Renderer/shims/ReactFabric').default;
29
+ }
30
+ return cachedFabricRenderer;
31
+ }
32
+
33
+ function getPaperRenderer(): ReactNativeType {
34
+ if (cachedPaperRenderer == null) {
35
+ cachedPaperRenderer = require('../Renderer/shims/ReactNative').default;
36
+ }
37
+ return cachedPaperRenderer;
38
+ }
39
+
40
+ const getMethod: (<MethodName: $Keys<ReactFabricType>>(
41
+ () => ReactFabricType,
42
+ MethodName,
43
+ ) => ReactFabricType[MethodName]) &
44
+ (<MethodName: $Keys<ReactNativeType>>(
45
+ () => ReactNativeType,
46
+ MethodName,
47
+ ) => ReactNativeType[MethodName]) = (getRenderer, methodName) => {
48
+ let cachedImpl;
49
+
50
+ // $FlowExpectedError[incompatible-type]
51
+ return function (arg1, arg2, arg3, arg4, arg5, arg6) {
52
+ if (cachedImpl == null) {
53
+ // $FlowExpectedError[prop-missing]
54
+ cachedImpl = getRenderer()[methodName];
55
+ }
56
+
57
+ // $FlowExpectedError[extra-arg]
58
+ return cachedImpl(arg1, arg2, arg3, arg4, arg5);
59
+ };
60
+ };
61
+
62
+ function getFabricMethod<MethodName: $Keys<ReactFabricType>>(
63
+ methodName: MethodName,
64
+ ): ReactFabricType[MethodName] {
65
+ return getMethod(getFabricRenderer, methodName);
66
+ }
67
+
68
+ function getPaperMethod<MethodName: $Keys<ReactNativeType>>(
69
+ methodName: MethodName,
70
+ ): ReactNativeType[MethodName] {
71
+ return getMethod(getPaperRenderer, methodName);
72
+ }
73
+
74
+ let cachedFabricRender;
75
+ let cachedPaperRender;
76
+
25
77
  export function renderElement({
26
78
  element,
27
79
  rootTag,
@@ -34,50 +86,30 @@ export function renderElement({
34
86
  useConcurrentRoot: boolean,
35
87
  }): void {
36
88
  if (useFabric) {
37
- require('../Renderer/shims/ReactFabric').default.render(
38
- element,
39
- rootTag,
40
- null,
41
- useConcurrentRoot,
42
- {
43
- onCaughtError,
44
- onUncaughtError,
45
- onRecoverableError,
46
- },
47
- );
89
+ if (cachedFabricRender == null) {
90
+ cachedFabricRender = getFabricRenderer().render;
91
+ }
92
+
93
+ cachedFabricRender(element, rootTag, null, useConcurrentRoot, {
94
+ onCaughtError,
95
+ onUncaughtError,
96
+ onRecoverableError,
97
+ });
48
98
  } else {
49
- require('../Renderer/shims/ReactNative').default.render(
50
- element,
51
- rootTag,
52
- undefined,
53
- {
54
- onCaughtError,
55
- onUncaughtError,
56
- onRecoverableError,
57
- },
58
- );
59
- }
60
- }
99
+ if (cachedPaperRender == null) {
100
+ cachedPaperRender = getPaperRenderer().render;
101
+ }
61
102
 
62
- export function findHostInstance_DEPRECATED<TElementType: React.ElementType>(
63
- // $FlowFixMe[incompatible-call]
64
- componentOrHandle: ?(React.ElementRef<TElementType> | number),
65
- ): ?HostInstance {
66
- return require('../Renderer/shims/ReactNative').default.findHostInstance_DEPRECATED(
67
- // $FlowFixMe[incompatible-call]
68
- componentOrHandle,
69
- );
103
+ cachedPaperRender(element, rootTag, undefined, {
104
+ onCaughtError,
105
+ onUncaughtError,
106
+ onRecoverableError,
107
+ });
108
+ }
70
109
  }
71
110
 
72
- export function findNodeHandle<TElementType: React.ElementType>(
73
- // $FlowFixMe[incompatible-call]
74
- componentOrHandle: ?(React.ElementRef<TElementType> | number),
75
- ): ?number {
76
- return require('../Renderer/shims/ReactNative').default.findNodeHandle(
77
- // $FlowFixMe[incompatible-call]
78
- componentOrHandle,
79
- );
80
- }
111
+ let cachedFabricDispatchCommand;
112
+ let cachedPaperDispatchCommand;
81
113
 
82
114
  export function dispatchCommand(
83
115
  handle: HostInstance,
@@ -87,90 +119,58 @@ export function dispatchCommand(
87
119
  if (global.RN$Bridgeless === true) {
88
120
  // Note: this function has the same implementation in the legacy and new renderer.
89
121
  // However, evaluating the old renderer comes with some side effects.
90
- return require('../Renderer/shims/ReactFabric').default.dispatchCommand(
91
- handle,
92
- command,
93
- args,
94
- );
122
+ if (cachedFabricDispatchCommand == null) {
123
+ cachedFabricDispatchCommand = getFabricRenderer().dispatchCommand;
124
+ }
125
+
126
+ return cachedFabricDispatchCommand(handle, command, args);
95
127
  } else {
96
- return require('../Renderer/shims/ReactNative').default.dispatchCommand(
97
- handle,
98
- command,
99
- args,
100
- );
128
+ if (cachedPaperDispatchCommand == null) {
129
+ cachedPaperDispatchCommand = getPaperRenderer().dispatchCommand;
130
+ }
131
+
132
+ return cachedPaperDispatchCommand(handle, command, args);
101
133
  }
102
134
  }
103
135
 
104
- export function sendAccessibilityEvent(
105
- handle: HostInstance,
106
- eventType: string,
107
- ): void {
108
- return require('../Renderer/shims/ReactNative').default.sendAccessibilityEvent(
109
- handle,
110
- eventType,
111
- );
112
- }
136
+ export const findHostInstance_DEPRECATED: <TElementType: React.ElementType>(
137
+ // $FlowExpectedError[incompatible-type]
138
+ componentOrHandle: ?(React.ElementRef<TElementType> | number),
139
+ ) => ?HostInstance = getPaperMethod('findHostInstance_DEPRECATED');
140
+
141
+ export const findNodeHandle: <TElementType: React.ElementType>(
142
+ // $FlowExpectedError[incompatible-type]
143
+ componentOrHandle: ?(React.ElementRef<TElementType> | number),
144
+ ) => ?number = getPaperMethod('findNodeHandle');
145
+
146
+ export const sendAccessibilityEvent: ReactNativeType['sendAccessibilityEvent'] =
147
+ getPaperMethod('sendAccessibilityEvent');
113
148
 
114
149
  /**
115
150
  * This method is used by AppRegistry to unmount a root when using the old
116
151
  * React Native renderer (Paper).
117
152
  */
118
- export function unmountComponentAtNodeAndRemoveContainer(rootTag: RootTag) {
119
- // $FlowExpectedError[incompatible-type] rootTag is an opaque type so we can't really cast it as is.
120
- const rootTagAsNumber: number = rootTag;
121
- require('../Renderer/shims/ReactNative').default.unmountComponentAtNodeAndRemoveContainer(
122
- rootTagAsNumber,
123
- );
124
- }
153
+ export const unmountComponentAtNodeAndRemoveContainer: (
154
+ rootTag: RootTag,
155
+ ) => void =
156
+ // $FlowExpectedError[incompatible-type]
157
+ getPaperMethod('unmountComponentAtNodeAndRemoveContainer');
125
158
 
126
- export function unstable_batchedUpdates<T>(
127
- fn: T => void,
128
- bookkeeping: T,
129
- ): void {
130
- // This doesn't actually do anything when batching updates for a Fabric root.
131
- return require('../Renderer/shims/ReactNative').default.unstable_batchedUpdates(
132
- fn,
133
- bookkeeping,
134
- );
135
- }
159
+ export const unstable_batchedUpdates: ReactNativeType['unstable_batchedUpdates'] =
160
+ getPaperMethod('unstable_batchedUpdates');
136
161
 
137
- export function isProfilingRenderer(): boolean {
138
- return Boolean(__DEV__);
139
- }
162
+ export const isChildPublicInstance: ReactNativeType['isChildPublicInstance'] =
163
+ getPaperMethod('isChildPublicInstance');
140
164
 
141
- export function isChildPublicInstance(
142
- parentInstance: HostInstance,
143
- childInstance: HostInstance,
144
- ): boolean {
145
- return require('../Renderer/shims/ReactNative').default.isChildPublicInstance(
146
- parentInstance,
147
- childInstance,
148
- );
149
- }
165
+ export const getNodeFromInternalInstanceHandle: ReactFabricType['getNodeFromInternalInstanceHandle'] =
166
+ getFabricMethod('getNodeFromInternalInstanceHandle');
150
167
 
151
- export function getNodeFromInternalInstanceHandle(
152
- internalInstanceHandle: InternalInstanceHandle,
153
- ): ?Node {
154
- // This is only available in Fabric
155
- return require('../Renderer/shims/ReactFabric').default.getNodeFromInternalInstanceHandle(
156
- internalInstanceHandle,
157
- );
158
- }
168
+ export const getPublicInstanceFromInternalInstanceHandle: ReactFabricType['getPublicInstanceFromInternalInstanceHandle'] =
169
+ getFabricMethod('getPublicInstanceFromInternalInstanceHandle');
159
170
 
160
- export function getPublicInstanceFromInternalInstanceHandle(
161
- internalInstanceHandle: InternalInstanceHandle,
162
- ): mixed /*PublicInstance | PublicTextInstance | null*/ {
163
- // This is only available in Fabric
164
- return require('../Renderer/shims/ReactFabric').default.getPublicInstanceFromInternalInstanceHandle(
165
- internalInstanceHandle,
166
- );
167
- }
171
+ export const getPublicInstanceFromRootTag: ReactFabricType['getPublicInstanceFromRootTag'] =
172
+ getFabricMethod('getPublicInstanceFromRootTag');
168
173
 
169
- export function getPublicInstanceFromRootTag(
170
- rootTag: number,
171
- ): mixed /*PublicRootInstance | null*/ {
172
- // This is only available in Fabric
173
- return require('../Renderer/shims/ReactFabric').default.getPublicInstanceFromRootTag(
174
- rootTag,
175
- );
174
+ export function isProfilingRenderer(): boolean {
175
+ return Boolean(__DEV__);
176
176
  }
@@ -45,7 +45,7 @@ const UIManager: UIManagerJSInterface = {
45
45
  FabricUIManager.measure(shadowNode, callback);
46
46
  } else {
47
47
  console.warn(`measure cannot find view with tag #${reactTag}`);
48
- // $FlowFixMe[incompatible-call]
48
+ // $FlowFixMe[incompatible-type]
49
49
  callback();
50
50
  }
51
51
  } else {
@@ -71,7 +71,7 @@ const UIManager: UIManagerJSInterface = {
71
71
  FabricUIManager.measureInWindow(shadowNode, callback);
72
72
  } else {
73
73
  console.warn(`measure cannot find view with tag #${reactTag}`);
74
- // $FlowFixMe[incompatible-call]
74
+ // $FlowFixMe[incompatible-type]
75
75
  callback();
76
76
  }
77
77
  } else {
@@ -182,7 +182,7 @@ const UIManager: UIManagerJSInterface = {
182
182
  UIManagerImpl.dispatchViewManagerCommand(
183
183
  reactTag,
184
184
  // We have some legacy components that are actually already using strings. ¯\_(ツ)_/¯
185
- // $FlowFixMe[incompatible-call]
185
+ // $FlowFixMe[incompatible-type]
186
186
  commandName,
187
187
  commandArgs,
188
188
  );
@@ -76,6 +76,7 @@ export default function renderApplication<Props: Object>(
76
76
  if (useOffscreen && displayMode != null) {
77
77
  // $FlowFixMe[incompatible-type]
78
78
  // $FlowFixMe[prop-missing]
79
+ // $FlowFixMe[missing-export]
79
80
  const Activity: ActivityType = React.unstable_Activity;
80
81
 
81
82
  renderable = (
@@ -86,7 +86,7 @@ module.exports = {
86
86
  // TODO: Remove when React has migrated to `createAttributePayload` and `diffAttributePayloads`
87
87
  get flattenStyle(): flattenStyle<DangerouslyImpreciseStyleProp> {
88
88
  // $FlowFixMe[underconstrained-implicit-instantiation]
89
- // $FlowFixMe[incompatible-return]
89
+ // $FlowFixMe[incompatible-type]
90
90
  return require('../StyleSheet/flattenStyle').default;
91
91
  },
92
92
  get ReactFiberErrorDialog(): ReactFiberErrorDialog {