@office-iss/react-native-win32 0.69.0 → 0.70.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 (154) hide show
  1. package/.eslintrc.js +0 -1
  2. package/.flowconfig +5 -1
  3. package/CHANGELOG.json +194 -32
  4. package/CHANGELOG.md +79 -19
  5. package/IntegrationTests/AsyncStorageTest.js +20 -4
  6. package/IntegrationTests/BUCK +2 -2
  7. package/IntegrationTests/LayoutEventsTest.js +4 -1
  8. package/IntegrationTests/{launchWebSocketServer.command → launchWebSocketServer.sh} +3 -9
  9. package/Libraries/Alert/Alert.js +18 -4
  10. package/Libraries/Alert/Alert.win32.js +2 -0
  11. package/Libraries/Alert/NativeAlertManager.js +1 -0
  12. package/Libraries/Animated/Animated.js +2 -2
  13. package/Libraries/Animated/AnimatedEvent.js +7 -4
  14. package/Libraries/Animated/AnimatedImplementation.js +17 -3
  15. package/Libraries/Animated/AnimatedMock.js +7 -2
  16. package/Libraries/Animated/NativeAnimatedHelper.js +220 -95
  17. package/Libraries/Animated/NativeAnimatedModule.js +3 -0
  18. package/Libraries/Animated/NativeAnimatedTurboModule.js +3 -0
  19. package/Libraries/Animated/animations/SpringAnimation.js +3 -3
  20. package/Libraries/Animated/animations/TimingAnimation.js +3 -3
  21. package/Libraries/Animated/createAnimatedComponent.js +8 -1
  22. package/Libraries/Animated/nodes/AnimatedAddition.js +3 -1
  23. package/Libraries/Animated/nodes/AnimatedColor.js +50 -29
  24. package/Libraries/Animated/nodes/AnimatedDiffClamp.js +3 -1
  25. package/Libraries/Animated/nodes/AnimatedDivision.js +3 -1
  26. package/Libraries/Animated/nodes/AnimatedInterpolation.js +22 -21
  27. package/Libraries/Animated/nodes/AnimatedModulo.js +3 -1
  28. package/Libraries/Animated/nodes/AnimatedMultiplication.js +3 -2
  29. package/Libraries/Animated/nodes/AnimatedProps.js +20 -12
  30. package/Libraries/Animated/nodes/AnimatedStyle.js +19 -16
  31. package/Libraries/Animated/nodes/AnimatedSubtraction.js +3 -1
  32. package/Libraries/Animated/nodes/AnimatedTransform.js +5 -5
  33. package/Libraries/Animated/nodes/AnimatedValue.js +14 -5
  34. package/Libraries/Animated/nodes/AnimatedValueXY.js +28 -1
  35. package/Libraries/Animated/useAnimatedProps.js +1 -0
  36. package/Libraries/AppState/AppState.js +0 -32
  37. package/Libraries/BatchedBridge/MessageQueue.js +21 -15
  38. package/Libraries/BatchedBridge/NativeModules.js +3 -4
  39. package/Libraries/Blob/FileReader.js +0 -6
  40. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +0 -20
  41. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +0 -20
  42. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -0
  43. package/Libraries/Components/Keyboard/Keyboard.js +0 -11
  44. package/Libraries/Components/Pressable/Pressable.js +2 -0
  45. package/Libraries/Components/Pressable/Pressable.win32.js +2 -0
  46. package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +1 -3
  47. package/Libraries/Components/SafeAreaView/SafeAreaView.js +3 -30
  48. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +4 -32
  49. package/Libraries/Components/ScrollView/ScrollView.js +13 -11
  50. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +5 -3
  51. package/Libraries/Components/StatusBar/StatusBar.js +10 -7
  52. package/Libraries/Components/TextInput/InputAccessoryView.js +14 -13
  53. package/Libraries/Components/TextInput/TextInput.js +12 -2
  54. package/Libraries/Components/Touchable/PooledClass.js +16 -4
  55. package/Libraries/Components/Touchable/Touchable.js +50 -1
  56. package/Libraries/Components/Touchable/Touchable.win32.js +972 -0
  57. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +6 -2
  58. package/Libraries/Components/View/ReactNativeStyleAttributes.js +0 -7
  59. package/Libraries/Components/View/ViewPropTypes.js +3 -8
  60. package/Libraries/Components/View/ViewPropTypes.win32.js +3 -8
  61. package/Libraries/Core/ExceptionsManager.js +2 -0
  62. package/Libraries/Core/ReactNativeVersion.js +2 -2
  63. package/Libraries/Core/Timers/JSTimers.js +2 -2
  64. package/Libraries/Core/polyfillPromise.js +0 -32
  65. package/Libraries/Core/setUpBatchedBridge.js +5 -1
  66. package/Libraries/Core/setUpPerformance.js +1 -1
  67. package/Libraries/EventEmitter/NativeEventEmitter.js +0 -13
  68. package/Libraries/Image/AssetSourceResolver.js +2 -2
  69. package/Libraries/Image/Image.android.js +5 -3
  70. package/Libraries/Image/Image.ios.js +6 -3
  71. package/Libraries/Image/Image.win32.js +6 -3
  72. package/Libraries/Image/ImageSource.js +7 -5
  73. package/Libraries/Inspector/ElementBox.js +2 -2
  74. package/Libraries/Inspector/NetworkOverlay.js +13 -8
  75. package/Libraries/Interaction/PanResponder.js +16 -14
  76. package/Libraries/Linking/Linking.js +0 -11
  77. package/Libraries/Lists/FlatList.js +3 -2
  78. package/Libraries/Lists/SectionList.js +2 -0
  79. package/Libraries/Lists/ViewabilityHelper.js +7 -3
  80. package/Libraries/Lists/VirtualizeUtils.js +33 -20
  81. package/Libraries/Lists/VirtualizedList.js +93 -47
  82. package/Libraries/Lists/VirtualizedListContext.js +1 -0
  83. package/Libraries/Lists/VirtualizedSectionList.js +14 -9
  84. package/Libraries/Lists/__tests__/VirtualizeUtils-test.js +19 -18
  85. package/Libraries/Lists/__tests__/VirtualizedList-test.js +10 -6
  86. package/Libraries/LogBox/Data/LogBoxData.js +1 -1
  87. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  88. package/Libraries/LogBox/LogBox.js +3 -1
  89. package/Libraries/LogBox/UI/AnsiHighlight.js +2 -0
  90. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +3 -0
  91. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +0 -3
  92. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +8 -3
  93. package/Libraries/NativeComponent/BaseViewConfig.android.js +9 -18
  94. package/Libraries/NativeComponent/BaseViewConfig.ios.js +26 -12
  95. package/Libraries/NativeComponent/BaseViewConfig.win32.js +26 -12
  96. package/Libraries/Network/XMLHttpRequest.js +9 -11
  97. package/Libraries/Performance/PureComponentDebug.js +1 -0
  98. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +9 -1
  99. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +16 -0
  100. package/Libraries/Pressability/Pressability.js +26 -16
  101. package/Libraries/Pressability/Pressability.win32.js +26 -16
  102. package/Libraries/Promise.js +0 -1
  103. package/Libraries/ReactNative/AppRegistry.js +16 -13
  104. package/Libraries/ReactNative/BridgelessUIManager.js +2 -0
  105. package/Libraries/ReactNative/PaperUIManager.js +9 -9
  106. package/Libraries/ReactNative/PaperUIManager.win32.js +7 -8
  107. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +12 -0
  108. package/Libraries/ReactNative/ReactNativeRuntimeDiagnostics.js +68 -0
  109. package/Libraries/ReactNative/getNativeComponentAttributes.js +6 -7
  110. package/Libraries/ReactNative/renderApplication.js +1 -1
  111. package/Libraries/Renderer/implementations/ReactFabric-dev.js +4443 -3615
  112. package/Libraries/Renderer/implementations/ReactFabric-prod.js +1496 -1170
  113. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +1694 -1356
  114. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +4439 -3588
  115. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1583 -1249
  116. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1719 -1372
  117. package/Libraries/Storage/AsyncStorage.js +7 -1
  118. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +8 -0
  119. package/Libraries/StyleSheet/flattenStyle.js +1 -1
  120. package/Libraries/StyleSheet/processTransform.js +2 -0
  121. package/Libraries/StyleSheet/splitLayoutProps.js +2 -0
  122. package/Libraries/Text/Text.js +15 -7
  123. package/Libraries/Types/CoreEventTypes.js +137 -11
  124. package/Libraries/Types/CoreEventTypes.win32.js +147 -22
  125. package/Libraries/Utilities/Dimensions.js +0 -13
  126. package/Libraries/Utilities/Dimensions.win32.js +0 -9
  127. package/Libraries/Utilities/HMRClient.js +3 -3
  128. package/Libraries/Utilities/Platform.ios.js +0 -7
  129. package/Libraries/Utilities/ReactNativeTestTools.js +3 -1
  130. package/Libraries/Utilities/codegenNativeCommands.js +11 -2
  131. package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
  132. package/Libraries/Utilities/stringifySafe.js +3 -1
  133. package/Libraries/Utilities/truncate.js +1 -1
  134. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +2 -2
  135. package/Libraries/Vibration/Vibration.js +1 -1
  136. package/Libraries/WebSocket/WebSocket.js +1 -0
  137. package/Libraries/vendor/emitter/EventEmitter.js +105 -12
  138. package/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js +73 -117
  139. package/flow/JSITimerInternalType.js +30 -0
  140. package/jest/assetFileTransformer.js +3 -2
  141. package/jest/setup.js +4 -0
  142. package/jest.config.js +0 -1
  143. package/overrides.json +23 -16
  144. package/package.json +23 -24
  145. package/rntypes/index.d.ts +0 -1
  146. package/src/rntypes/index.d.ts +0 -1
  147. package/Libraries/vendor/emitter/EventSubscription.js +0 -19
  148. package/Libraries/vendor/emitter/_EmitterSubscription.js +0 -62
  149. package/Libraries/vendor/emitter/_EventEmitter.js +0 -184
  150. package/Libraries/vendor/emitter/_EventSubscription.js +0 -45
  151. package/Libraries/vendor/emitter/_EventSubscriptionVendor.js +0 -108
  152. package/jest/preprocessor.js +0 -40
  153. package/jest/preprocessor_DO_NOT_USE.js +0 -122
  154. package/src/Libraries/Lists/__tests__/__snapshots__/VirtualizeUtils-test.js.snap +0 -3
@@ -8,40 +8,41 @@
8
8
  * @format
9
9
  */
10
10
 
11
- const Batchinator = require('../Interaction/Batchinator');
12
- const FillRateHelper = require('./FillRateHelper');
13
- const ReactNative = require('../Renderer/shims/ReactNative');
14
- const RefreshControl = require('../Components/RefreshControl/RefreshControl');
15
- const ScrollView = require('../Components/ScrollView/ScrollView');
16
- const StyleSheet = require('../StyleSheet/StyleSheet');
17
- const View = require('../Components/View/View');
18
- const ViewabilityHelper = require('./ViewabilityHelper');
19
-
20
- const flattenStyle = require('../StyleSheet/flattenStyle');
21
- const infoLog = require('../Utilities/infoLog');
22
- const invariant = require('invariant');
23
-
24
- import {
25
- keyExtractor as defaultKeyExtractor,
26
- computeWindowedRenderLimits,
27
- } from './VirtualizeUtils';
28
-
29
- import * as React from 'react';
30
11
  import type {ScrollResponderType} from '../Components/ScrollView/ScrollView';
31
12
  import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
13
+ import type {LayoutEvent, ScrollEvent} from '../Types/CoreEventTypes';
32
14
  import type {
33
15
  ViewabilityConfig,
34
- ViewToken,
35
16
  ViewabilityConfigCallbackPair,
17
+ ViewToken,
36
18
  } from './ViewabilityHelper';
37
- import type {LayoutEvent} from '../Types/CoreEventTypes';
19
+
38
20
  import {
21
+ type ChildListState,
22
+ type ListDebugInfo,
39
23
  VirtualizedListCellContextProvider,
40
24
  VirtualizedListContext,
41
25
  VirtualizedListContextProvider,
42
- type ChildListState,
43
- type ListDebugInfo,
44
26
  } from './VirtualizedListContext.js';
27
+ import {
28
+ computeWindowedRenderLimits,
29
+ keyExtractor as defaultKeyExtractor,
30
+ } from './VirtualizeUtils';
31
+ import * as React from 'react';
32
+
33
+ const RefreshControl = require('../Components/RefreshControl/RefreshControl');
34
+ const ScrollView = require('../Components/ScrollView/ScrollView');
35
+ const View = require('../Components/View/View');
36
+ const Batchinator = require('../Interaction/Batchinator');
37
+ const ReactNative = require('../Renderer/shims/ReactNative');
38
+ const flattenStyle = require('../StyleSheet/flattenStyle');
39
+ const StyleSheet = require('../StyleSheet/StyleSheet');
40
+ const infoLog = require('../Utilities/infoLog');
41
+ const FillRateHelper = require('./FillRateHelper');
42
+ const ViewabilityHelper = require('./ViewabilityHelper');
43
+ const invariant = require('invariant');
44
+
45
+ const ON_END_REACHED_EPSILON = 0.001;
45
46
 
46
47
  type Item = any;
47
48
 
@@ -219,7 +220,8 @@ type OptionalProps = {|
219
220
  * How far from the end (in units of visible length of the list) the bottom edge of the
220
221
  * list must be from the end of the content to trigger the `onEndReached` callback.
221
222
  * Thus a value of 0.5 will trigger `onEndReached` when the end of the content is
222
- * within half the visible length of the list.
223
+ * within half the visible length of the list. A value of 0 will not trigger until scrolling
224
+ * to the very end of the list.
223
225
  */
224
226
  onEndReachedThreshold?: ?number,
225
227
  /**
@@ -1192,14 +1194,22 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1192
1194
  _averageCellLength = 0;
1193
1195
  // Maps a cell key to the set of keys for all outermost child lists within that cell
1194
1196
  _cellKeysToChildListKeys: Map<string, Set<string>> = new Map();
1195
- _cellRefs = {};
1197
+ _cellRefs: {[string]: null | CellRenderer} = {};
1196
1198
  _fillRateHelper: FillRateHelper;
1197
- _frames = {};
1199
+ _frames: {
1200
+ [string]: {
1201
+ inLayout?: boolean,
1202
+ index: number,
1203
+ length: number,
1204
+ offset: number,
1205
+ },
1206
+ } = {};
1198
1207
  _footerLength = 0;
1199
- _hasDoneInitialScroll = false;
1208
+ // Used for preventing scrollToIndex from being called multiple times for initialScrollIndex
1209
+ _hasTriggeredInitialScrollToIndex = false;
1200
1210
  _hasInteracted = false;
1201
1211
  _hasMore = false;
1202
- _hasWarned = {};
1212
+ _hasWarned: {[string]: boolean} = {};
1203
1213
  _headerLength = 0;
1204
1214
  _hiPriInProgress: boolean = false; // flag to prevent infinite hiPri cell limit update
1205
1215
  _highestMeasuredFrameIndex = 0;
@@ -1222,6 +1232,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1222
1232
  timestamp: 0,
1223
1233
  velocity: 0,
1224
1234
  visibleLength: 0,
1235
+ zoomScale: 1,
1225
1236
  };
1226
1237
  _scrollRef: ?React.ElementRef<any> = null;
1227
1238
  _sentEndForContentLength = 0;
@@ -1230,6 +1241,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1230
1241
  _updateCellsToRenderBatcher: Batchinator;
1231
1242
  _viewabilityTuples: Array<ViewabilityHelperCallbackTuple> = [];
1232
1243
 
1244
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
1245
+ * LTI update could not be added via codemod */
1233
1246
  _captureScrollRef = ref => {
1234
1247
  this._scrollRef = ref;
1235
1248
  };
@@ -1242,6 +1255,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1242
1255
  );
1243
1256
  }
1244
1257
 
1258
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
1259
+ * LTI update could not be added via codemod */
1245
1260
  _defaultRenderScrollComponent = props => {
1246
1261
  const onRefresh = props.onRefresh;
1247
1262
  if (this._isNestedWithSameOrientation()) {
@@ -1261,6 +1276,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1261
1276
  refreshControl={
1262
1277
  props.refreshControl == null ? (
1263
1278
  <RefreshControl
1279
+ // $FlowFixMe[incompatible-type]
1264
1280
  refreshing={props.refreshing}
1265
1281
  onRefresh={onRefresh}
1266
1282
  progressViewOffset={props.progressViewOffset}
@@ -1507,13 +1523,22 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1507
1523
  const {data, getItemCount, onEndReached, onEndReachedThreshold} =
1508
1524
  this.props;
1509
1525
  const {contentLength, visibleLength, offset} = this._scrollMetrics;
1510
- const distanceFromEnd = contentLength - visibleLength - offset;
1526
+ let distanceFromEnd = contentLength - visibleLength - offset;
1527
+
1528
+ // Especially when oERT is zero it's necessary to 'floor' very small distanceFromEnd values to be 0
1529
+ // since debouncing causes us to not fire this event for every single "pixel" we scroll and can thus
1530
+ // be at the "end" of the list with a distanceFromEnd approximating 0 but not quite there.
1531
+ if (distanceFromEnd < ON_END_REACHED_EPSILON) {
1532
+ distanceFromEnd = 0;
1533
+ }
1534
+
1535
+ // TODO: T121172172 Look into why we're "defaulting" to a threshold of 2 when oERT is not present
1511
1536
  const threshold =
1512
1537
  onEndReachedThreshold != null ? onEndReachedThreshold * visibleLength : 2;
1513
1538
  if (
1514
1539
  onEndReached &&
1515
1540
  this.state.last === getItemCount(data) - 1 &&
1516
- distanceFromEnd < threshold &&
1541
+ distanceFromEnd <= threshold &&
1517
1542
  this._scrollMetrics.contentLength !== this._sentEndForContentLength
1518
1543
  ) {
1519
1544
  // Only call onEndReached once for a given content length
@@ -1532,7 +1557,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1532
1557
  height > 0 &&
1533
1558
  this.props.initialScrollIndex != null &&
1534
1559
  this.props.initialScrollIndex > 0 &&
1535
- !this._hasDoneInitialScroll
1560
+ !this._hasTriggeredInitialScrollToIndex
1536
1561
  ) {
1537
1562
  if (this.props.contentOffset == null) {
1538
1563
  this.scrollToIndex({
@@ -1540,7 +1565,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1540
1565
  index: this.props.initialScrollIndex,
1541
1566
  });
1542
1567
  }
1543
- this._hasDoneInitialScroll = true;
1568
+ this._hasTriggeredInitialScrollToIndex = true;
1544
1569
  }
1545
1570
  if (this.props.onContentSizeChange) {
1546
1571
  this.props.onContentSizeChange(width, height);
@@ -1618,6 +1643,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1618
1643
  );
1619
1644
  this._hasWarned.perf = true;
1620
1645
  }
1646
+
1647
+ // For invalid negative values (w/ RTL), set this to 1.
1648
+ const zoomScale = e.nativeEvent.zoomScale < 0 ? 1 : e.nativeEvent.zoomScale;
1621
1649
  this._scrollMetrics = {
1622
1650
  contentLength,
1623
1651
  dt,
@@ -1626,6 +1654,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1626
1654
  timestamp,
1627
1655
  velocity,
1628
1656
  visibleLength,
1657
+ zoomScale,
1629
1658
  };
1630
1659
  this._updateViewableItems(this.props.data);
1631
1660
  if (!this.props) {
@@ -1688,7 +1717,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1688
1717
  }
1689
1718
  }
1690
1719
 
1691
- _onScrollBeginDrag = (e): void => {
1720
+ _onScrollBeginDrag = (e: ScrollEvent): void => {
1692
1721
  this._nestedChildLists.forEach(childList => {
1693
1722
  childList.ref && childList.ref._onScrollBeginDrag(e);
1694
1723
  });
@@ -1699,7 +1728,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1699
1728
  this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
1700
1729
  };
1701
1730
 
1702
- _onScrollEndDrag = (e): void => {
1731
+ _onScrollEndDrag = (e: ScrollEvent): void => {
1703
1732
  this._nestedChildLists.forEach(childList => {
1704
1733
  childList.ref && childList.ref._onScrollEndDrag(e);
1705
1734
  });
@@ -1711,14 +1740,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1711
1740
  this.props.onScrollEndDrag && this.props.onScrollEndDrag(e);
1712
1741
  };
1713
1742
 
1714
- _onMomentumScrollBegin = (e): void => {
1743
+ _onMomentumScrollBegin = (e: ScrollEvent): void => {
1715
1744
  this._nestedChildLists.forEach(childList => {
1716
1745
  childList.ref && childList.ref._onMomentumScrollBegin(e);
1717
1746
  });
1718
1747
  this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
1719
1748
  };
1720
1749
 
1721
- _onMomentumScrollEnd = (e): void => {
1750
+ _onMomentumScrollEnd = (e: ScrollEvent): void => {
1722
1751
  this._nestedChildLists.forEach(childList => {
1723
1752
  childList.ref && childList.ref._onMomentumScrollEnd(e);
1724
1753
  });
@@ -1747,6 +1776,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1747
1776
  | $TEMPORARY$object<{first: number, last: number}>
1748
1777
  );
1749
1778
  const {contentLength, offset, visibleLength} = this._scrollMetrics;
1779
+ const distanceFromEnd = contentLength - visibleLength - offset;
1750
1780
  if (!isVirtualizationDisabled) {
1751
1781
  // If we run this with bogus data, we'll force-render window {first: 0, last: 0},
1752
1782
  // and wipe out the initialNumToRender rendered elements.
@@ -1757,7 +1787,17 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1757
1787
  // we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex.
1758
1788
  // So let's wait until we've scrolled the view to the right place. And until then,
1759
1789
  // we will trust the initialScrollIndex suggestion.
1760
- if (!this.props.initialScrollIndex || this._hasDoneInitialScroll) {
1790
+
1791
+ // Thus, we want to recalculate the windowed render limits if any of the following hold:
1792
+ // - initialScrollIndex is undefined or is 0
1793
+ // - initialScrollIndex > 0 AND scrolling is complete
1794
+ // - initialScrollIndex > 0 AND the end of the list is visible (this handles the case
1795
+ // where the list is shorter than the visible area)
1796
+ if (
1797
+ !this.props.initialScrollIndex ||
1798
+ this._scrollMetrics.offset ||
1799
+ Math.abs(distanceFromEnd) < Number.EPSILON
1800
+ ) {
1761
1801
  newState = computeWindowedRenderLimits(
1762
1802
  this.props.data,
1763
1803
  this.props.getItemCount,
@@ -1770,7 +1810,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1770
1810
  }
1771
1811
  }
1772
1812
  } else {
1773
- const distanceFromEnd = contentLength - visibleLength - offset;
1774
1813
  const renderAhead =
1775
1814
  distanceFromEnd < onEndReachedThreshold * visibleLength
1776
1815
  ? maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch)
@@ -1864,15 +1903,15 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1864
1903
  'Tried to get frame for out of range index ' + index,
1865
1904
  );
1866
1905
  const item = getItem(data, index);
1867
- let frame = item && this._frames[this._keyExtractor(item, index)];
1906
+ const frame = item && this._frames[this._keyExtractor(item, index)];
1868
1907
  if (!frame || frame.index !== index) {
1869
1908
  if (getItemLayout) {
1870
- frame = getItemLayout(data, index);
1909
+ /* $FlowFixMe[prop-missing] (>=0.63.0 site=react_native_fb) This comment
1910
+ * suppresses an error found when Flow v0.63 was deployed. To see the error
1911
+ * delete this comment and run Flow. */
1912
+ return getItemLayout(data, index);
1871
1913
  }
1872
1914
  }
1873
- /* $FlowFixMe[prop-missing] (>=0.63.0 site=react_native_fb) This comment
1874
- * suppresses an error found when Flow v0.63 was deployed. To see the error
1875
- * delete this comment and run Flow. */
1876
1915
  return frame;
1877
1916
  };
1878
1917
 
@@ -1998,7 +2037,12 @@ class CellRenderer extends React.Component<
1998
2037
  );
1999
2038
  };
2000
2039
 
2001
- _renderElement(renderItem, ListItemComponent, item, index) {
2040
+ _renderElement(
2041
+ renderItem: any,
2042
+ ListItemComponent: any,
2043
+ item: any,
2044
+ index: any,
2045
+ ) {
2002
2046
  if (renderItem && ListItemComponent) {
2003
2047
  console.warn(
2004
2048
  'VirtualizedList: Both ListItemComponent and renderItem props are present. ListItemComponent will take' +
@@ -2062,9 +2106,11 @@ class CellRenderer extends React.Component<
2062
2106
  : this._onLayout;
2063
2107
  // NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
2064
2108
  // called explicitly by `ScrollViewStickyHeader`.
2065
- const itemSeparator = ItemSeparatorComponent && (
2066
- <ItemSeparatorComponent {...this.state.separatorProps} />
2067
- );
2109
+ const itemSeparator = React.isValidElement(ItemSeparatorComponent)
2110
+ ? ItemSeparatorComponent
2111
+ : ItemSeparatorComponent && (
2112
+ <ItemSeparatorComponent {...this.state.separatorProps} />
2113
+ );
2068
2114
  const cellStyle = inversionStyle
2069
2115
  ? horizontal
2070
2116
  ? [styles.rowReverse, inversionStyle]
@@ -47,6 +47,7 @@ type Context = $ReadOnly<{
47
47
  timestamp: number,
48
48
  velocity: number,
49
49
  visibleLength: number,
50
+ zoomScale: number,
50
51
  },
51
52
  horizontal: ?boolean,
52
53
  getOutermostParentListRef: () => VirtualizedList,
@@ -8,11 +8,12 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import invariant from 'invariant';
12
11
  import type {ViewToken} from './ViewabilityHelper';
12
+
13
13
  import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
14
- import {View, VirtualizedList} from 'react-native';
14
+ import invariant from 'invariant';
15
15
  import * as React from 'react';
16
+ import {View, VirtualizedList} from 'react-native';
16
17
 
17
18
  type Item = any;
18
19
 
@@ -147,6 +148,7 @@ class VirtualizedSectionList<
147
148
  viewOffset,
148
149
  index,
149
150
  };
151
+ // $FlowFixMe[incompatible-use]
150
152
  this._listRef.scrollToIndex(toIndexParams);
151
153
  }
152
154
 
@@ -390,21 +392,24 @@ class VirtualizedSectionList<
390
392
  }
391
393
  };
392
394
 
393
- _updatePropsFor = (cellKey, value) => {
395
+ _updatePropsFor = (cellKey: string, value: any) => {
394
396
  const updateProps = this._updatePropsMap[cellKey];
395
397
  if (updateProps != null) {
396
398
  updateProps(value);
397
399
  }
398
400
  };
399
401
 
400
- _updateHighlightFor = (cellKey, value) => {
402
+ _updateHighlightFor = (cellKey: string, value: boolean) => {
401
403
  const updateHighlight = this._updateHighlightMap[cellKey];
402
404
  if (updateHighlight != null) {
403
405
  updateHighlight(value);
404
406
  }
405
407
  };
406
408
 
407
- _setUpdateHighlightFor = (cellKey, updateHighlightFn) => {
409
+ _setUpdateHighlightFor = (
410
+ cellKey: string,
411
+ updateHighlightFn: ?(boolean) => void,
412
+ ) => {
408
413
  if (updateHighlightFn != null) {
409
414
  this._updateHighlightMap[cellKey] = updateHighlightFn;
410
415
  } else {
@@ -412,7 +417,7 @@ class VirtualizedSectionList<
412
417
  }
413
418
  };
414
419
 
415
- _setUpdatePropsFor = (cellKey, updatePropsFn) => {
420
+ _setUpdatePropsFor = (cellKey: string, updatePropsFn: ?(boolean) => void) => {
416
421
  if (updatePropsFn != null) {
417
422
  this._updatePropsMap[cellKey] = updatePropsFn;
418
423
  } else {
@@ -444,10 +449,10 @@ class VirtualizedSectionList<
444
449
  return null;
445
450
  }
446
451
 
447
- _updateHighlightMap = {};
448
- _updatePropsMap = {};
452
+ _updateHighlightMap: {[string]: (boolean) => void} = {};
453
+ _updatePropsMap: {[string]: void | (boolean => void)} = {};
449
454
  _listRef: ?React.ElementRef<typeof VirtualizedList>;
450
- _captureRef = ref => {
455
+ _captureRef = (ref: null | React$ElementRef<Class<VirtualizedList>>) => {
451
456
  this._listRef = ref;
452
457
  };
453
458
  }
@@ -48,9 +48,9 @@ describe('elementsThatOverlapOffsets', function () {
48
48
  offset: 100 * index,
49
49
  };
50
50
  }
51
- expect(elementsThatOverlapOffsets(offsets, 100, getFrameMetrics)).toEqual([
52
- 0, 2, 3, 4,
53
- ]);
51
+ expect(
52
+ elementsThatOverlapOffsets(offsets, 100, getFrameMetrics, 1),
53
+ ).toEqual([0, 2, 3, 4]);
54
54
  });
55
55
  it('handles variable length', function () {
56
56
  const offsets = [150, 250, 900];
@@ -62,29 +62,30 @@ describe('elementsThatOverlapOffsets', function () {
62
62
  {offset: 950, length: 150},
63
63
  ];
64
64
  expect(
65
- elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]),
65
+ elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii], 1),
66
66
  ).toEqual([1, 1, 3]);
67
67
  });
68
- it('handles out of bounds', function () {
69
- const offsets = [150, 900];
70
- const frames = [
71
- {offset: 0, length: 50},
72
- {offset: 50, length: 150},
73
- {offset: 250, length: 100},
74
- ];
68
+ it('handles frame boundaries', function () {
69
+ const offsets = [0, 100, 200, 300];
70
+ function getFrameMetrics(index: number) {
71
+ return {
72
+ length: 100,
73
+ offset: 100 * index,
74
+ };
75
+ }
75
76
  expect(
76
- elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]),
77
- ).toEqual([1]);
77
+ elementsThatOverlapOffsets(offsets, 100, getFrameMetrics, 1),
78
+ ).toEqual([0, 0, 1, 2]);
78
79
  });
79
- it('errors on non-increasing offsets', function () {
80
- const offsets = [150, 50];
80
+ it('handles out of bounds', function () {
81
+ const offsets = [-100, 150, 900];
81
82
  const frames = [
82
83
  {offset: 0, length: 50},
83
84
  {offset: 50, length: 150},
84
85
  {offset: 250, length: 100},
85
86
  ];
86
- expect(() => {
87
- elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]);
88
- }).toThrowErrorMatchingSnapshot();
87
+ expect(
88
+ elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii], 1),
89
+ ).toEqual([undefined, 1]);
89
90
  });
90
91
  });
@@ -384,7 +384,7 @@ describe('VirtualizedList', () => {
384
384
 
385
385
  const instance = component.getInstance();
386
386
 
387
- instance._onLayout({nativeEvent: {layout}});
387
+ instance._onLayout({nativeEvent: {layout, zoomScale: 1}});
388
388
 
389
389
  const initialContentHeight = props.initialNumToRender * ITEM_HEIGHT;
390
390
 
@@ -885,6 +885,7 @@ it('adjusts render area with non-zero initialScrollIndex', () => {
885
885
  viewport: {width: 10, height: 50},
886
886
  content: {width: 10, height: 200},
887
887
  });
888
+ simulateScroll(component, {x: 0, y: 10}); // simulate scroll offset for initialScrollIndex
888
889
 
889
890
  performAllBatches();
890
891
  });
@@ -914,8 +915,8 @@ it('renders new items when data is updated with non-zero initialScrollIndex', ()
914
915
 
915
916
  ReactTestRenderer.act(() => {
916
917
  simulateLayout(component, {
917
- viewport: {width: 10, height: 50},
918
- content: {width: 10, height: 200},
918
+ viewport: {width: 10, height: 20},
919
+ content: {width: 10, height: 20},
919
920
  });
920
921
  performAllBatches();
921
922
  });
@@ -1490,7 +1491,7 @@ it('calls _onCellLayout properly', () => {
1490
1491
  );
1491
1492
  const cell = virtualList._cellRefs.i4;
1492
1493
  const event = {
1493
- nativeEvent: {layout: {x: 0, y: 0, width: 50, height: 50}},
1494
+ nativeEvent: {layout: {x: 0, y: 0, width: 50, height: 50}, zoomScale: 1},
1494
1495
  };
1495
1496
  cell._onLayout(event);
1496
1497
  expect(mock).toHaveBeenCalledWith(event, 'i4', 3);
@@ -1544,7 +1545,9 @@ function simulateLayout(component, args) {
1544
1545
 
1545
1546
  function simulateViewportLayout(component, dimensions) {
1546
1547
  lastViewportLayout = dimensions;
1547
- component.getInstance()._onLayout({nativeEvent: {layout: dimensions}});
1548
+ component
1549
+ .getInstance()
1550
+ ._onLayout({nativeEvent: {layout: dimensions}, zoomScale: 1});
1548
1551
  }
1549
1552
 
1550
1553
  function simulateContentLayout(component, dimensions) {
@@ -1558,7 +1561,7 @@ function simulateCellLayout(component, items, itemIndex, dimensions) {
1558
1561
  const instance = component.getInstance();
1559
1562
  const cellKey = instance._keyExtractor(items[itemIndex], itemIndex);
1560
1563
  instance._onCellLayout(
1561
- {nativeEvent: {layout: dimensions}},
1564
+ {nativeEvent: {layout: dimensions, zoomScale: 1}},
1562
1565
  cellKey,
1563
1566
  itemIndex,
1564
1567
  );
@@ -1570,6 +1573,7 @@ function simulateScroll(component, position) {
1570
1573
  contentOffset: position,
1571
1574
  contentSize: lastContentLayout,
1572
1575
  layoutMeasurement: lastViewportLayout,
1576
+ zoomScale: 1,
1573
1577
  },
1574
1578
  });
1575
1579
  }
@@ -133,7 +133,7 @@ function handleUpdate(): void {
133
133
  }
134
134
  }
135
135
 
136
- function appendNewLog(newLog) {
136
+ function appendNewLog(newLog: LogBoxLog) {
137
137
  // Don't want store these logs because they trigger a
138
138
  // state update when we add them to the store.
139
139
  if (isMessageIgnored(newLog.message.content)) {
@@ -316,7 +316,7 @@ export function parseLogBoxLog(args: $ReadOnlyArray<mixed>): {|
316
316
  |} {
317
317
  const message = args[0];
318
318
  let argsWithoutComponentStack = [];
319
- let componentStack = [];
319
+ let componentStack: ComponentStack = [];
320
320
 
321
321
  // Extract component stack from warnings like "Some warning%s".
322
322
  if (
@@ -39,7 +39,7 @@ if (__DEV__) {
39
39
  let originalConsoleError;
40
40
  let originalConsoleWarn;
41
41
  let consoleErrorImpl;
42
- let consoleWarnImpl;
42
+ let consoleWarnImpl: (...args: Array<mixed>) => void;
43
43
 
44
44
  let isLogBoxInstalled: boolean = false;
45
45
 
@@ -166,6 +166,8 @@ if (__DEV__) {
166
166
  }
167
167
  };
168
168
 
169
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
170
+ * LTI update could not be added via codemod */
169
171
  const registerError = (...args): void => {
170
172
  // Let errors within LogBox itself fall through.
171
173
  if (LogBoxData.isLogBoxErrorMessage(args[0])) {
@@ -63,6 +63,8 @@ export default function Ansi({
63
63
  }
64
64
  });
65
65
 
66
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
67
+ * LTI update could not be added via codemod */
66
68
  const getText = (content, key) => {
67
69
  if (key === 1) {
68
70
  // Remove the vertical bar after line numbers
@@ -32,15 +32,18 @@ function LogBoxInspectorCodeFrame(props: Props): React.Node {
32
32
  }
33
33
 
34
34
  function getFileName() {
35
+ // $FlowFixMe[incompatible-use]
35
36
  const matches = /[^/]*$/.exec(codeFrame.fileName);
36
37
  if (matches && matches.length > 0) {
37
38
  return matches[0];
38
39
  }
39
40
 
41
+ // $FlowFixMe[incompatible-use]
40
42
  return codeFrame.fileName;
41
43
  }
42
44
 
43
45
  function getLocation() {
46
+ // $FlowFixMe[incompatible-use]
44
47
  const location = codeFrame.location;
45
48
  if (location != null) {
46
49
  return ` (${location.row}:${
@@ -45,9 +45,6 @@ function LogBoxInspectorSourceMapStatus(props: Props): React.Node {
45
45
  animation,
46
46
  rotate: animated.interpolate({
47
47
  inputRange: [0, 1],
48
- /* $FlowFixMe[speculation-ambiguous] (>=0.38.0) - Flow error
49
- * detected during the deployment of v0.38.0. To see the error,
50
- * remove this comment and run flow */
51
48
  outputRange: ['0deg', '360deg'],
52
49
  }),
53
50
  });
@@ -8,6 +8,10 @@
8
8
  * @format
9
9
  */
10
10
 
11
+ import type {StackFrame} from '../../Core/NativeExceptionsManager';
12
+ import type {Stack} from '../Data/LogBoxSymbolication';
13
+ import type LogBoxLog from '../Data/LogBoxLog';
14
+
11
15
  import * as React from 'react';
12
16
  import StyleSheet from '../../StyleSheet/StyleSheet';
13
17
  import Text from '../../Text/Text';
@@ -18,8 +22,6 @@ import LogBoxInspectorStackFrame from './LogBoxInspectorStackFrame';
18
22
  import LogBoxInspectorSection from './LogBoxInspectorSection';
19
23
  import * as LogBoxStyle from './LogBoxStyle';
20
24
  import openFileInEditor from '../../Core/Devtools/openFileInEditor';
21
- import type {Stack} from '../Data/LogBoxSymbolication';
22
- import type LogBoxLog from '../Data/LogBoxLog';
23
25
 
24
26
  type Props = $ReadOnly<{|
25
27
  log: LogBoxLog,
@@ -111,7 +113,10 @@ function LogBoxInspectorStackFrames(props: Props): React.Node {
111
113
  );
112
114
  }
113
115
 
114
- function StackFrameList(props) {
116
+ function StackFrameList(props: {
117
+ list: Stack | Array<StackFrame>,
118
+ status: string | 'COMPLETE' | 'FAILED' | 'NONE' | 'PENDING',
119
+ }) {
115
120
  return (
116
121
  <>
117
122
  {props.list.map((frame, index) => {
@@ -64,24 +64,24 @@ const bubblingEventTypes = {
64
64
  bubbled: 'onPointerDown',
65
65
  },
66
66
  },
67
- topPointerEnter2: {
67
+ topPointerEnter: {
68
68
  phasedRegistrationNames: {
69
- captured: 'onPointerEnter2Capture',
70
- bubbled: 'onPointerEnter2',
69
+ captured: 'onPointerEnterCapture',
70
+ bubbled: 'onPointerEnter',
71
71
  skipBubbling: true,
72
72
  },
73
73
  },
74
- topPointerLeave2: {
74
+ topPointerLeave: {
75
75
  phasedRegistrationNames: {
76
- captured: 'onPointerLeave2Capture',
77
- bubbled: 'onPointerLeave2',
76
+ captured: 'onPointerLeaveCapture',
77
+ bubbled: 'onPointerLeave',
78
78
  skipBubbling: true,
79
79
  },
80
80
  },
81
- topPointerMove2: {
81
+ topPointerMove: {
82
82
  phasedRegistrationNames: {
83
- captured: 'onPointerMove2Capture',
84
- bubbled: 'onPointerMove2',
83
+ captured: 'onPointerMoveCapture',
84
+ bubbled: 'onPointerMove',
85
85
  },
86
86
  },
87
87
  topPointerUp: {
@@ -96,15 +96,6 @@ const directEventTypes = {
96
96
  topAccessibilityAction: {
97
97
  registrationName: 'onAccessibilityAction',
98
98
  },
99
- topPointerEnter: {
100
- registrationName: 'onPointerEnter',
101
- },
102
- topPointerLeave: {
103
- registrationName: 'onPointerLeave',
104
- },
105
- topPointerMove: {
106
- registrationName: 'onPointerMove',
107
- },
108
99
  onGestureHandlerEvent: DynamicallyInjectedByGestureHandler({
109
100
  registrationName: 'onGestureHandlerEvent',
110
101
  }),