@hps1978/react-native-web-tv 0.21.2-tv.0

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 (932) hide show
  1. package/APACHE-2.0.txt +201 -0
  2. package/LICENSE +22 -0
  3. package/README.md +164 -0
  4. package/THIRD_PARTY_NOTICES.md +15 -0
  5. package/dist/cjs/exports/AccessibilityInfo/index.js +99 -0
  6. package/dist/cjs/exports/ActivityIndicator/index.js +106 -0
  7. package/dist/cjs/exports/Alert/index.js +18 -0
  8. package/dist/cjs/exports/Animated/index.js +18 -0
  9. package/dist/cjs/exports/AppRegistry/AppContainer.js +47 -0
  10. package/dist/cjs/exports/AppRegistry/index.js +95 -0
  11. package/dist/cjs/exports/AppRegistry/renderApplication.js +55 -0
  12. package/dist/cjs/exports/AppState/index.js +63 -0
  13. package/dist/cjs/exports/Appearance/index.js +54 -0
  14. package/dist/cjs/exports/BackHandler/index.js +67 -0
  15. package/dist/cjs/exports/Button/index.js +70 -0
  16. package/dist/cjs/exports/CheckBox/index.js +112 -0
  17. package/dist/cjs/exports/Clipboard/index.js +61 -0
  18. package/dist/cjs/exports/DeviceEventEmitter/index.js +8 -0
  19. package/dist/cjs/exports/Dimensions/index.js +128 -0
  20. package/dist/cjs/exports/Easing/index.js +16 -0
  21. package/dist/cjs/exports/FlatList/index.js +19 -0
  22. package/dist/cjs/exports/I18nManager/index.js +30 -0
  23. package/dist/cjs/exports/Image/index.js +364 -0
  24. package/dist/cjs/exports/Image/types.js +1 -0
  25. package/dist/cjs/exports/ImageBackground/index.js +59 -0
  26. package/dist/cjs/exports/InputAccessoryView/index.js +8 -0
  27. package/dist/cjs/exports/InteractionManager/TaskQueue.js +93 -0
  28. package/dist/cjs/exports/InteractionManager/index.js +130 -0
  29. package/dist/cjs/exports/Keyboard/index.js +34 -0
  30. package/dist/cjs/exports/KeyboardAvoidingView/index.js +52 -0
  31. package/dist/cjs/exports/LayoutAnimation/index.js +17 -0
  32. package/dist/cjs/exports/Linking/index.js +109 -0
  33. package/dist/cjs/exports/LogBox/index.js +21 -0
  34. package/dist/cjs/exports/Modal/ModalAnimation.js +149 -0
  35. package/dist/cjs/exports/Modal/ModalContent.js +75 -0
  36. package/dist/cjs/exports/Modal/ModalFocusTrap.js +138 -0
  37. package/dist/cjs/exports/Modal/ModalPortal.js +43 -0
  38. package/dist/cjs/exports/Modal/index.js +106 -0
  39. package/dist/cjs/exports/NativeEventEmitter/index.js +16 -0
  40. package/dist/cjs/exports/NativeModules/index.js +21 -0
  41. package/dist/cjs/exports/PanResponder/Alternative.js +273 -0
  42. package/dist/cjs/exports/PanResponder/index.js +8 -0
  43. package/dist/cjs/exports/Picker/PickerItem.js +32 -0
  44. package/dist/cjs/exports/Picker/index.js +73 -0
  45. package/dist/cjs/exports/PixelRatio/index.js +55 -0
  46. package/dist/cjs/exports/Platform/index.js +31 -0
  47. package/dist/cjs/exports/Pressable/index.js +163 -0
  48. package/dist/cjs/exports/ProgressBar/index.js +81 -0
  49. package/dist/cjs/exports/RefreshControl/index.js +34 -0
  50. package/dist/cjs/exports/SafeAreaView/index.js +47 -0
  51. package/dist/cjs/exports/ScrollView/ScrollViewBase.js +153 -0
  52. package/dist/cjs/exports/ScrollView/index.js +637 -0
  53. package/dist/cjs/exports/ScrollView/types.js +1 -0
  54. package/dist/cjs/exports/SectionList/index.js +18 -0
  55. package/dist/cjs/exports/Share/index.js +53 -0
  56. package/dist/cjs/exports/StatusBar/index.js +24 -0
  57. package/dist/cjs/exports/StyleSheet/compiler/createReactDOMStyle.js +183 -0
  58. package/dist/cjs/exports/StyleSheet/compiler/hash.js +52 -0
  59. package/dist/cjs/exports/StyleSheet/compiler/hyphenateStyleName.js +28 -0
  60. package/dist/cjs/exports/StyleSheet/compiler/index.js +483 -0
  61. package/dist/cjs/exports/StyleSheet/compiler/normalizeColor.js +36 -0
  62. package/dist/cjs/exports/StyleSheet/compiler/normalizeValueWithProperty.js +38 -0
  63. package/dist/cjs/exports/StyleSheet/compiler/resolveShadowValue.js +38 -0
  64. package/dist/cjs/exports/StyleSheet/compiler/unitlessNumbers.js +80 -0
  65. package/dist/cjs/exports/StyleSheet/dom/createCSSStyleSheet.js +42 -0
  66. package/dist/cjs/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js +168 -0
  67. package/dist/cjs/exports/StyleSheet/dom/index.js +78 -0
  68. package/dist/cjs/exports/StyleSheet/index.js +190 -0
  69. package/dist/cjs/exports/StyleSheet/preprocess.js +222 -0
  70. package/dist/cjs/exports/StyleSheet/validate.js +89 -0
  71. package/dist/cjs/exports/Switch/index.js +194 -0
  72. package/dist/cjs/exports/TV/NativeTVNavigationEventEmitter.js +109 -0
  73. package/dist/cjs/exports/TV/TVEventControl.js +47 -0
  74. package/dist/cjs/exports/TV/TVEventHandler.js +41 -0
  75. package/dist/cjs/exports/TV/TVFocusEventHandler.js +36 -0
  76. package/dist/cjs/exports/TV/TVFocusGuideView.js +106 -0
  77. package/dist/cjs/exports/TV/TVTextScrollView.js +113 -0
  78. package/dist/cjs/exports/TV/tagForComponentOrHandle.js +44 -0
  79. package/dist/cjs/exports/TV/types.js +16 -0
  80. package/dist/cjs/exports/TV/useTVEventHandler.js +20 -0
  81. package/dist/cjs/exports/TV/utils.js +26 -0
  82. package/dist/cjs/exports/Text/TextAncestorContext.js +18 -0
  83. package/dist/cjs/exports/Text/index.js +199 -0
  84. package/dist/cjs/exports/Text/types.js +1 -0
  85. package/dist/cjs/exports/TextInput/index.js +443 -0
  86. package/dist/cjs/exports/TextInput/types.js +1 -0
  87. package/dist/cjs/exports/Touchable/BoundingDimensions.js +35 -0
  88. package/dist/cjs/exports/Touchable/Position.js +27 -0
  89. package/dist/cjs/exports/Touchable/ensurePositiveDelayProps.js +20 -0
  90. package/dist/cjs/exports/Touchable/index.js +839 -0
  91. package/dist/cjs/exports/TouchableHighlight/index.js +154 -0
  92. package/dist/cjs/exports/TouchableNativeFeedback/index.js +16 -0
  93. package/dist/cjs/exports/TouchableOpacity/index.js +123 -0
  94. package/dist/cjs/exports/TouchableWithoutFeedback/index.js +78 -0
  95. package/dist/cjs/exports/UIManager/index.js +133 -0
  96. package/dist/cjs/exports/Vibration/index.js +32 -0
  97. package/dist/cjs/exports/View/index.js +177 -0
  98. package/dist/cjs/exports/View/types.js +1 -0
  99. package/dist/cjs/exports/VirtualizedList/index.js +18 -0
  100. package/dist/cjs/exports/YellowBox/index.js +23 -0
  101. package/dist/cjs/exports/createElement/index.js +39 -0
  102. package/dist/cjs/exports/findNodeHandle/index.js +19 -0
  103. package/dist/cjs/exports/processColor/index.js +31 -0
  104. package/dist/cjs/exports/render/index.js +27 -0
  105. package/dist/cjs/exports/unmountComponentAtNode/index.js +18 -0
  106. package/dist/cjs/exports/useColorScheme/index.js +34 -0
  107. package/dist/cjs/exports/useLocaleContext/index.js +17 -0
  108. package/dist/cjs/exports/useWindowDimensions/index.js +41 -0
  109. package/dist/cjs/index.js +137 -0
  110. package/dist/cjs/modules/AccessibilityUtil/index.js +24 -0
  111. package/dist/cjs/modules/AccessibilityUtil/isDisabled.js +16 -0
  112. package/dist/cjs/modules/AccessibilityUtil/propsToAccessibilityComponent.js +60 -0
  113. package/dist/cjs/modules/AccessibilityUtil/propsToAriaRole.js +41 -0
  114. package/dist/cjs/modules/AssetRegistry/index.js +23 -0
  115. package/dist/cjs/modules/ImageLoader/index.js +149 -0
  116. package/dist/cjs/modules/SpatialManager/index.js +464 -0
  117. package/dist/cjs/modules/SpatialManager/mutationObserver.js +112 -0
  118. package/dist/cjs/modules/SpatialManager/scrollHandler.js +581 -0
  119. package/dist/cjs/modules/SpatialManager/utils.js +417 -0
  120. package/dist/cjs/modules/TextInputState/index.js +65 -0
  121. package/dist/cjs/modules/UnimplementedView/index.js +35 -0
  122. package/dist/cjs/modules/addEventListener/index.js +75 -0
  123. package/dist/cjs/modules/canUseDom/index.js +16 -0
  124. package/dist/cjs/modules/createDOMProps/index.js +896 -0
  125. package/dist/cjs/modules/dismissKeyboard/index.js +20 -0
  126. package/dist/cjs/modules/forwardedProps/index.js +188 -0
  127. package/dist/cjs/modules/getBoundingClientRect/index.js +23 -0
  128. package/dist/cjs/modules/isSelectionValid/index.js +22 -0
  129. package/dist/cjs/modules/isWebColor/index.js +16 -0
  130. package/dist/cjs/modules/mergeRefs/index.js +37 -0
  131. package/dist/cjs/modules/modality/index.js +196 -0
  132. package/dist/cjs/modules/multiplyStyleLengthValue/index.js +29 -0
  133. package/dist/cjs/modules/normalizeColor/index.js +36 -0
  134. package/dist/cjs/modules/pick/index.js +25 -0
  135. package/dist/cjs/modules/prefixStyles/index.js +19 -0
  136. package/dist/cjs/modules/prefixStyles/static.js +74 -0
  137. package/dist/cjs/modules/requestIdleCallback/index.js +33 -0
  138. package/dist/cjs/modules/setValueForStyles/dangerousStyleValue.js +49 -0
  139. package/dist/cjs/modules/setValueForStyles/index.js +45 -0
  140. package/dist/cjs/modules/unitlessNumbers/index.js +80 -0
  141. package/dist/cjs/modules/useElementLayout/index.js +91 -0
  142. package/dist/cjs/modules/useEvent/index.js +54 -0
  143. package/dist/cjs/modules/useHover/index.js +158 -0
  144. package/dist/cjs/modules/useLayoutEffect/index.js +22 -0
  145. package/dist/cjs/modules/useLocale/index.js +42 -0
  146. package/dist/cjs/modules/useLocale/isLocaleRTL.js +87 -0
  147. package/dist/cjs/modules/useMergeRefs/index.js +26 -0
  148. package/dist/cjs/modules/usePlatformMethods/index.js +34 -0
  149. package/dist/cjs/modules/usePressEvents/PressResponder.js +496 -0
  150. package/dist/cjs/modules/usePressEvents/index.js +40 -0
  151. package/dist/cjs/modules/useResponderEvents/ResponderEventTypes.js +51 -0
  152. package/dist/cjs/modules/useResponderEvents/ResponderSystem.js +598 -0
  153. package/dist/cjs/modules/useResponderEvents/ResponderTouchHistoryStore.js +175 -0
  154. package/dist/cjs/modules/useResponderEvents/createResponderEvent.js +152 -0
  155. package/dist/cjs/modules/useResponderEvents/index.js +79 -0
  156. package/dist/cjs/modules/useResponderEvents/utils.js +175 -0
  157. package/dist/cjs/modules/useStable/index.js +25 -0
  158. package/dist/cjs/modules/warnOnce/index.js +31 -0
  159. package/dist/cjs/types/index.js +1 -0
  160. package/dist/cjs/types/styles.js +1 -0
  161. package/dist/cjs/vendor/hash/index.js +52 -0
  162. package/dist/cjs/vendor/react-native/Animated/Animated.js +35 -0
  163. package/dist/cjs/vendor/react-native/Animated/AnimatedEvent.js +167 -0
  164. package/dist/cjs/vendor/react-native/Animated/AnimatedImplementation.js +582 -0
  165. package/dist/cjs/vendor/react-native/Animated/AnimatedMock.js +140 -0
  166. package/dist/cjs/vendor/react-native/Animated/AnimatedPlatformConfig.js +11 -0
  167. package/dist/cjs/vendor/react-native/Animated/Easing.js +253 -0
  168. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedHelper.js +480 -0
  169. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedModule.js +19 -0
  170. package/dist/cjs/vendor/react-native/Animated/NativeAnimatedTurboModule.js +19 -0
  171. package/dist/cjs/vendor/react-native/Animated/SpringConfig.js +72 -0
  172. package/dist/cjs/vendor/react-native/Animated/animations/Animation.js +59 -0
  173. package/dist/cjs/vendor/react-native/Animated/animations/DecayAnimation.js +74 -0
  174. package/dist/cjs/vendor/react-native/Animated/animations/SpringAnimation.js +226 -0
  175. package/dist/cjs/vendor/react-native/Animated/animations/TimingAnimation.js +120 -0
  176. package/dist/cjs/vendor/react-native/Animated/bezier.js +125 -0
  177. package/dist/cjs/vendor/react-native/Animated/components/AnimatedFlatList.js +30 -0
  178. package/dist/cjs/vendor/react-native/Animated/components/AnimatedImage.js +20 -0
  179. package/dist/cjs/vendor/react-native/Animated/components/AnimatedScrollView.js +30 -0
  180. package/dist/cjs/vendor/react-native/Animated/components/AnimatedSectionList.js +30 -0
  181. package/dist/cjs/vendor/react-native/Animated/components/AnimatedText.js +20 -0
  182. package/dist/cjs/vendor/react-native/Animated/components/AnimatedView.js +20 -0
  183. package/dist/cjs/vendor/react-native/Animated/createAnimatedComponent.js +52 -0
  184. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedAddition.js +53 -0
  185. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedColor.js +288 -0
  186. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js +57 -0
  187. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedDivision.js +70 -0
  188. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedInterpolation.js +269 -0
  189. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedModulo.js +50 -0
  190. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedMultiplication.js +53 -0
  191. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedNode.js +163 -0
  192. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedProps.js +145 -0
  193. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedStyle.js +128 -0
  194. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedSubtraction.js +53 -0
  195. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedTracking.js +76 -0
  196. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedTransform.js +113 -0
  197. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedValue.js +271 -0
  198. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedValueXY.js +191 -0
  199. package/dist/cjs/vendor/react-native/Animated/nodes/AnimatedWithChildren.js +77 -0
  200. package/dist/cjs/vendor/react-native/Animated/useAnimatedProps.js +158 -0
  201. package/dist/cjs/vendor/react-native/Batchinator/index.js +82 -0
  202. package/dist/cjs/vendor/react-native/EventEmitter/NativeEventEmitter.js +85 -0
  203. package/dist/cjs/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.js +24 -0
  204. package/dist/cjs/vendor/react-native/FillRateHelper/index.js +196 -0
  205. package/dist/cjs/vendor/react-native/FlatList/index.js +452 -0
  206. package/dist/cjs/vendor/react-native/JSEventLoopWatchdog/index.js +90 -0
  207. package/dist/cjs/vendor/react-native/LayoutAnimation/index.js +112 -0
  208. package/dist/cjs/vendor/react-native/PanResponder/index.js +420 -0
  209. package/dist/cjs/vendor/react-native/PooledClass/index.js +64 -0
  210. package/dist/cjs/vendor/react-native/ReactNative/ReactNativeFeatureFlags.js +23 -0
  211. package/dist/cjs/vendor/react-native/SectionList/index.js +150 -0
  212. package/dist/cjs/vendor/react-native/StaticContainer/index.js +43 -0
  213. package/dist/cjs/vendor/react-native/StaticRenderer/index.js +26 -0
  214. package/dist/cjs/vendor/react-native/TouchHistoryMath/index.js +105 -0
  215. package/dist/cjs/vendor/react-native/TurboModule/RCTExport.js +29 -0
  216. package/dist/cjs/vendor/react-native/TurboModule/TurboModuleRegistry.js +25 -0
  217. package/dist/cjs/vendor/react-native/Types/CoreEventTypes.js +11 -0
  218. package/dist/cjs/vendor/react-native/Utilities/Platform.js +8 -0
  219. package/dist/cjs/vendor/react-native/Utilities/clamp.js +25 -0
  220. package/dist/cjs/vendor/react-native/Utilities/setAndForwardRef.js +64 -0
  221. package/dist/cjs/vendor/react-native/Utilities/useMergeRefs.js +43 -0
  222. package/dist/cjs/vendor/react-native/Utilities/useRefEffect.js +42 -0
  223. package/dist/cjs/vendor/react-native/ViewabilityHelper/index.js +210 -0
  224. package/dist/cjs/vendor/react-native/VirtualizeUtils/index.js +180 -0
  225. package/dist/cjs/vendor/react-native/VirtualizedList/CellRenderMask.js +112 -0
  226. package/dist/cjs/vendor/react-native/VirtualizedList/ChildListCollection.js +75 -0
  227. package/dist/cjs/vendor/react-native/VirtualizedList/StateSafePureComponent.js +77 -0
  228. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js +159 -0
  229. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListContext.js +73 -0
  230. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListProps.js +6 -0
  231. package/dist/cjs/vendor/react-native/VirtualizedList/VirtualizedListRLVAdapter.js +951 -0
  232. package/dist/cjs/vendor/react-native/VirtualizedList/index.js +1506 -0
  233. package/dist/cjs/vendor/react-native/VirtualizedSectionList/index.js +388 -0
  234. package/dist/cjs/vendor/react-native/deepDiffer/index.js +73 -0
  235. package/dist/cjs/vendor/react-native/infoLog/index.js +22 -0
  236. package/dist/cjs/vendor/react-native/vendor/emitter/EventEmitter.js +104 -0
  237. package/dist/exports/AccessibilityInfo/index.js +94 -0
  238. package/dist/exports/AccessibilityInfo/index.js.flow +76 -0
  239. package/dist/exports/ActivityIndicator/index.js +100 -0
  240. package/dist/exports/ActivityIndicator/index.js.flow +88 -0
  241. package/dist/exports/Alert/index.js +13 -0
  242. package/dist/exports/Alert/index.js.flow +12 -0
  243. package/dist/exports/Animated/index.js +13 -0
  244. package/dist/exports/Animated/index.js.flow +13 -0
  245. package/dist/exports/AppRegistry/AppContainer.js +40 -0
  246. package/dist/exports/AppRegistry/AppContainer.js.flow +43 -0
  247. package/dist/exports/AppRegistry/index.js +88 -0
  248. package/dist/exports/AppRegistry/index.js.flow +59 -0
  249. package/dist/exports/AppRegistry/renderApplication.js +48 -0
  250. package/dist/exports/AppRegistry/renderApplication.js.flow +28 -0
  251. package/dist/exports/AppState/index.js +58 -0
  252. package/dist/exports/AppState/index.js.flow +31 -0
  253. package/dist/exports/Appearance/index.js +49 -0
  254. package/dist/exports/Appearance/index.js.flow +50 -0
  255. package/dist/exports/BackHandler/index.js +63 -0
  256. package/dist/exports/BackHandler/index.js.flow +77 -0
  257. package/dist/exports/Button/index.js +63 -0
  258. package/dist/exports/Button/index.js.flow +67 -0
  259. package/dist/exports/CheckBox/index.js +106 -0
  260. package/dist/exports/CheckBox/index.js.flow +108 -0
  261. package/dist/exports/Clipboard/index.js +56 -0
  262. package/dist/exports/Clipboard/index.js.flow +18 -0
  263. package/dist/exports/DeviceEventEmitter/index.js +2 -0
  264. package/dist/exports/Dimensions/index.js +122 -0
  265. package/dist/exports/Dimensions/index.js.flow +58 -0
  266. package/dist/exports/Easing/index.js +11 -0
  267. package/dist/exports/Easing/index.js.flow +11 -0
  268. package/dist/exports/FlatList/index.js +14 -0
  269. package/dist/exports/FlatList/index.js.flow +14 -0
  270. package/dist/exports/I18nManager/index.js +25 -0
  271. package/dist/exports/I18nManager/index.js.flow +34 -0
  272. package/dist/exports/Image/index.js +358 -0
  273. package/dist/exports/Image/index.js.flow +225 -0
  274. package/dist/exports/Image/types.js +0 -0
  275. package/dist/exports/Image/types.js.flow +94 -0
  276. package/dist/exports/ImageBackground/index.js +53 -0
  277. package/dist/exports/ImageBackground/index.js.flow +57 -0
  278. package/dist/exports/InputAccessoryView/index.js +2 -0
  279. package/dist/exports/InteractionManager/TaskQueue.js +87 -0
  280. package/dist/exports/InteractionManager/TaskQueue.js.flow +40 -0
  281. package/dist/exports/InteractionManager/index.js +124 -0
  282. package/dist/exports/InteractionManager/index.js.flow +99 -0
  283. package/dist/exports/Keyboard/index.js +29 -0
  284. package/dist/exports/Keyboard/index.js.flow +31 -0
  285. package/dist/exports/KeyboardAvoidingView/index.js +46 -0
  286. package/dist/exports/KeyboardAvoidingView/index.js.flow +30 -0
  287. package/dist/exports/LayoutAnimation/index.js +12 -0
  288. package/dist/exports/LayoutAnimation/index.js.flow +12 -0
  289. package/dist/exports/Linking/index.js +103 -0
  290. package/dist/exports/Linking/index.js.flow +30 -0
  291. package/dist/exports/LogBox/index.js +16 -0
  292. package/dist/exports/LogBox/index.js.flow +16 -0
  293. package/dist/exports/Modal/ModalAnimation.js +142 -0
  294. package/dist/exports/Modal/ModalAnimation.js.flow +94 -0
  295. package/dist/exports/Modal/ModalContent.js +69 -0
  296. package/dist/exports/Modal/ModalContent.js.flow +64 -0
  297. package/dist/exports/Modal/ModalFocusTrap.js +132 -0
  298. package/dist/exports/Modal/ModalFocusTrap.js.flow +39 -0
  299. package/dist/exports/Modal/ModalPortal.js +36 -0
  300. package/dist/exports/Modal/ModalPortal.js.flow +18 -0
  301. package/dist/exports/Modal/index.js +100 -0
  302. package/dist/exports/Modal/index.js.flow +83 -0
  303. package/dist/exports/NativeEventEmitter/index.js +11 -0
  304. package/dist/exports/NativeEventEmitter/index.js.flow +11 -0
  305. package/dist/exports/NativeModules/index.js +16 -0
  306. package/dist/exports/NativeModules/index.js.flow +16 -0
  307. package/dist/exports/PanResponder/Alternative.js +269 -0
  308. package/dist/exports/PanResponder/Alternative.js.flow +335 -0
  309. package/dist/exports/PanResponder/index.js +2 -0
  310. package/dist/exports/PanResponder/index.js.flow +4 -0
  311. package/dist/exports/Picker/PickerItem.js +26 -0
  312. package/dist/exports/Picker/PickerItem.js.flow +19 -0
  313. package/dist/exports/Picker/index.js +67 -0
  314. package/dist/exports/Picker/index.js.flow +74 -0
  315. package/dist/exports/PixelRatio/index.js +49 -0
  316. package/dist/exports/PixelRatio/index.js.flow +21 -0
  317. package/dist/exports/Platform/index.js +26 -0
  318. package/dist/exports/Platform/index.js.flow +26 -0
  319. package/dist/exports/Pressable/index.js +157 -0
  320. package/dist/exports/Pressable/index.js.flow +84 -0
  321. package/dist/exports/ProgressBar/index.js +75 -0
  322. package/dist/exports/ProgressBar/index.js.flow +72 -0
  323. package/dist/exports/RefreshControl/index.js +29 -0
  324. package/dist/exports/RefreshControl/index.js.flow +30 -0
  325. package/dist/exports/SafeAreaView/index.js +41 -0
  326. package/dist/exports/SafeAreaView/index.js.flow +38 -0
  327. package/dist/exports/ScrollView/ScrollViewBase.js +147 -0
  328. package/dist/exports/ScrollView/ScrollViewBase.js.flow +76 -0
  329. package/dist/exports/ScrollView/index.js +632 -0
  330. package/dist/exports/ScrollView/index.js.flow +126 -0
  331. package/dist/exports/ScrollView/types.js +0 -0
  332. package/dist/exports/ScrollView/types.js.flow +25 -0
  333. package/dist/exports/SectionList/index.js +13 -0
  334. package/dist/exports/SectionList/index.js.flow +13 -0
  335. package/dist/exports/Share/index.js +47 -0
  336. package/dist/exports/Share/index.js.flow +26 -0
  337. package/dist/exports/StatusBar/index.js +19 -0
  338. package/dist/exports/StatusBar/index.js.flow +16 -0
  339. package/dist/exports/StyleSheet/compiler/createReactDOMStyle.js +177 -0
  340. package/dist/exports/StyleSheet/compiler/createReactDOMStyle.js.flow +84 -0
  341. package/dist/exports/StyleSheet/compiler/hash.js +47 -0
  342. package/dist/exports/StyleSheet/compiler/hash.js.flow +18 -0
  343. package/dist/exports/StyleSheet/compiler/hyphenateStyleName.js +23 -0
  344. package/dist/exports/StyleSheet/compiler/hyphenateStyleName.js.flow +15 -0
  345. package/dist/exports/StyleSheet/compiler/index.js +476 -0
  346. package/dist/exports/StyleSheet/compiler/index.js.flow +180 -0
  347. package/dist/exports/StyleSheet/compiler/normalizeColor.js +30 -0
  348. package/dist/exports/StyleSheet/compiler/normalizeColor.js.flow +13 -0
  349. package/dist/exports/StyleSheet/compiler/normalizeValueWithProperty.js +32 -0
  350. package/dist/exports/StyleSheet/compiler/normalizeValueWithProperty.js.flow +24 -0
  351. package/dist/exports/StyleSheet/compiler/resolveShadowValue.js +32 -0
  352. package/dist/exports/StyleSheet/compiler/resolveShadowValue.js.flow +17 -0
  353. package/dist/exports/StyleSheet/compiler/unitlessNumbers.js +75 -0
  354. package/dist/exports/StyleSheet/compiler/unitlessNumbers.js.flow +73 -0
  355. package/dist/exports/StyleSheet/dom/createCSSStyleSheet.js +36 -0
  356. package/dist/exports/StyleSheet/dom/createCSSStyleSheet.js.flow +12 -0
  357. package/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js +163 -0
  358. package/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js.flow +52 -0
  359. package/dist/exports/StyleSheet/dom/index.js +73 -0
  360. package/dist/exports/StyleSheet/dom/index.js.flow +26 -0
  361. package/dist/exports/StyleSheet/index.js +185 -0
  362. package/dist/exports/StyleSheet/index.js.flow +97 -0
  363. package/dist/exports/StyleSheet/preprocess.js +212 -0
  364. package/dist/exports/StyleSheet/preprocess.js.flow +73 -0
  365. package/dist/exports/StyleSheet/validate.js +84 -0
  366. package/dist/exports/StyleSheet/validate.js.flow +46 -0
  367. package/dist/exports/Switch/index.js +188 -0
  368. package/dist/exports/Switch/index.js.flow +187 -0
  369. package/dist/exports/TV/NativeTVNavigationEventEmitter.js +103 -0
  370. package/dist/exports/TV/NativeTVNavigationEventEmitter.js.flow +89 -0
  371. package/dist/exports/TV/TVEventControl.js +44 -0
  372. package/dist/exports/TV/TVEventControl.js.flow +44 -0
  373. package/dist/exports/TV/TVEventHandler.js +37 -0
  374. package/dist/exports/TV/TVEventHandler.js.flow +59 -0
  375. package/dist/exports/TV/TVFocusEventHandler.js +33 -0
  376. package/dist/exports/TV/TVFocusEventHandler.js.flow +24 -0
  377. package/dist/exports/TV/TVFocusGuideView.js +98 -0
  378. package/dist/exports/TV/TVFocusGuideView.js.flow +121 -0
  379. package/dist/exports/TV/TVTextScrollView.js +106 -0
  380. package/dist/exports/TV/TVTextScrollView.js.flow +78 -0
  381. package/dist/exports/TV/tagForComponentOrHandle.js +39 -0
  382. package/dist/exports/TV/tagForComponentOrHandle.js.flow +16 -0
  383. package/dist/exports/TV/types.js +16 -0
  384. package/dist/exports/TV/types.js.flow +133 -0
  385. package/dist/exports/TV/useTVEventHandler.js +13 -0
  386. package/dist/exports/TV/useTVEventHandler.js.flow +10 -0
  387. package/dist/exports/TV/utils.js +23 -0
  388. package/dist/exports/TV/utils.js.flow +14 -0
  389. package/dist/exports/Text/TextAncestorContext.js +14 -0
  390. package/dist/exports/Text/TextAncestorContext.js.flow +15 -0
  391. package/dist/exports/Text/index.js +193 -0
  392. package/dist/exports/Text/index.js.flow +198 -0
  393. package/dist/exports/Text/types.js +0 -0
  394. package/dist/exports/Text/types.js.flow +65 -0
  395. package/dist/exports/TextInput/index.js +437 -0
  396. package/dist/exports/TextInput/index.js.flow +333 -0
  397. package/dist/exports/TextInput/types.js +0 -0
  398. package/dist/exports/TextInput/types.js.flow +65 -0
  399. package/dist/exports/Touchable/BoundingDimensions.js +29 -0
  400. package/dist/exports/Touchable/BoundingDimensions.js.flow +26 -0
  401. package/dist/exports/Touchable/Position.js +21 -0
  402. package/dist/exports/Touchable/Position.js.flow +18 -0
  403. package/dist/exports/Touchable/ensurePositiveDelayProps.js +14 -0
  404. package/dist/exports/Touchable/ensurePositiveDelayProps.js.flow +12 -0
  405. package/dist/exports/Touchable/index.js +835 -0
  406. package/dist/exports/Touchable/index.js.flow +849 -0
  407. package/dist/exports/TouchableHighlight/index.js +148 -0
  408. package/dist/exports/TouchableHighlight/index.js.flow +67 -0
  409. package/dist/exports/TouchableNativeFeedback/index.js +11 -0
  410. package/dist/exports/TouchableNativeFeedback/index.js.flow +11 -0
  411. package/dist/exports/TouchableOpacity/index.js +117 -0
  412. package/dist/exports/TouchableOpacity/index.js.flow +50 -0
  413. package/dist/exports/TouchableWithoutFeedback/index.js +72 -0
  414. package/dist/exports/TouchableWithoutFeedback/index.js.flow +65 -0
  415. package/dist/exports/UIManager/index.js +127 -0
  416. package/dist/exports/UIManager/index.js.flow +92 -0
  417. package/dist/exports/Vibration/index.js +27 -0
  418. package/dist/exports/Vibration/index.js.flow +21 -0
  419. package/dist/exports/View/index.js +171 -0
  420. package/dist/exports/View/index.js.flow +176 -0
  421. package/dist/exports/View/types.js +0 -0
  422. package/dist/exports/View/types.js.flow +225 -0
  423. package/dist/exports/VirtualizedList/index.js +13 -0
  424. package/dist/exports/VirtualizedList/index.js.flow +13 -0
  425. package/dist/exports/YellowBox/index.js +17 -0
  426. package/dist/exports/YellowBox/index.js.flow +16 -0
  427. package/dist/exports/createElement/index.js +34 -0
  428. package/dist/exports/createElement/index.js.flow +17 -0
  429. package/dist/exports/findNodeHandle/index.js +14 -0
  430. package/dist/exports/findNodeHandle/index.js.flow +11 -0
  431. package/dist/exports/processColor/index.js +25 -0
  432. package/dist/exports/processColor/index.js.flow +13 -0
  433. package/dist/exports/render/index.js +23 -0
  434. package/dist/exports/render/index.js.flow +15 -0
  435. package/dist/exports/unmountComponentAtNode/index.js +13 -0
  436. package/dist/exports/unmountComponentAtNode/index.js.flow +9 -0
  437. package/dist/exports/useColorScheme/index.js +28 -0
  438. package/dist/exports/useColorScheme/index.js.flow +16 -0
  439. package/dist/exports/useLocaleContext/index.js +13 -0
  440. package/dist/exports/useLocaleContext/index.js.flow +13 -0
  441. package/dist/exports/useWindowDimensions/index.js +36 -0
  442. package/dist/exports/useWindowDimensions/index.js.flow +16 -0
  443. package/dist/index.js +77 -0
  444. package/dist/index.js.flow +79 -0
  445. package/dist/modules/AccessibilityUtil/index.js +18 -0
  446. package/dist/modules/AccessibilityUtil/index.js.flow +18 -0
  447. package/dist/modules/AccessibilityUtil/isDisabled.js +11 -0
  448. package/dist/modules/AccessibilityUtil/isDisabled.js.flow +10 -0
  449. package/dist/modules/AccessibilityUtil/propsToAccessibilityComponent.js +54 -0
  450. package/dist/modules/AccessibilityUtil/propsToAccessibilityComponent.js.flow +34 -0
  451. package/dist/modules/AccessibilityUtil/propsToAriaRole.js +36 -0
  452. package/dist/modules/AccessibilityUtil/propsToAriaRole.js.flow +28 -0
  453. package/dist/modules/AssetRegistry/index.js +18 -0
  454. package/dist/modules/AssetRegistry/index.js.flow +23 -0
  455. package/dist/modules/ImageLoader/index.js +144 -0
  456. package/dist/modules/ImageLoader/index.js.flow +84 -0
  457. package/dist/modules/SpatialManager/index.js +460 -0
  458. package/dist/modules/SpatialManager/index.js.flow +66 -0
  459. package/dist/modules/SpatialManager/mutationObserver.js +105 -0
  460. package/dist/modules/SpatialManager/mutationObserver.js.flow +30 -0
  461. package/dist/modules/SpatialManager/scrollHandler.js +571 -0
  462. package/dist/modules/SpatialManager/scrollHandler.js.flow +90 -0
  463. package/dist/modules/SpatialManager/utils.js +405 -0
  464. package/dist/modules/SpatialManager/utils.js.flow +147 -0
  465. package/dist/modules/TextInputState/index.js +60 -0
  466. package/dist/modules/TextInputState/index.js.flow +60 -0
  467. package/dist/modules/UnimplementedView/index.js +31 -0
  468. package/dist/modules/UnimplementedView/index.js.flow +23 -0
  469. package/dist/modules/addEventListener/index.js +72 -0
  470. package/dist/modules/addEventListener/index.js.flow +34 -0
  471. package/dist/modules/canUseDom/index.js +11 -0
  472. package/dist/modules/canUseDom/index.js.flow +11 -0
  473. package/dist/modules/createDOMProps/index.js +891 -0
  474. package/dist/modules/createDOMProps/index.js.flow +36 -0
  475. package/dist/modules/dismissKeyboard/index.js +14 -0
  476. package/dist/modules/dismissKeyboard/index.js.flow +12 -0
  477. package/dist/modules/forwardedProps/index.js +184 -0
  478. package/dist/modules/forwardedProps/index.js.flow +184 -0
  479. package/dist/modules/getBoundingClientRect/index.js +18 -0
  480. package/dist/modules/getBoundingClientRect/index.js.flow +10 -0
  481. package/dist/modules/isSelectionValid/index.js +17 -0
  482. package/dist/modules/isSelectionValid/index.js.flow +9 -0
  483. package/dist/modules/isWebColor/index.js +11 -0
  484. package/dist/modules/isWebColor/index.js.flow +10 -0
  485. package/dist/modules/mergeRefs/index.js +31 -0
  486. package/dist/modules/mergeRefs/index.js.flow +11 -0
  487. package/dist/modules/modality/index.js +188 -0
  488. package/dist/modules/modality/index.js.flow +79 -0
  489. package/dist/modules/multiplyStyleLengthValue/index.js +24 -0
  490. package/dist/modules/multiplyStyleLengthValue/index.js.flow +14 -0
  491. package/dist/modules/normalizeColor/index.js +30 -0
  492. package/dist/modules/normalizeColor/index.js.flow +13 -0
  493. package/dist/modules/pick/index.js +20 -0
  494. package/dist/modules/pick/index.js.flow +11 -0
  495. package/dist/modules/prefixStyles/index.js +13 -0
  496. package/dist/modules/prefixStyles/index.js.flow +14 -0
  497. package/dist/modules/prefixStyles/static.js +68 -0
  498. package/dist/modules/requestIdleCallback/index.js +28 -0
  499. package/dist/modules/requestIdleCallback/index.js.flow +28 -0
  500. package/dist/modules/setValueForStyles/dangerousStyleValue.js +44 -0
  501. package/dist/modules/setValueForStyles/dangerousStyleValue.js.flow +25 -0
  502. package/dist/modules/setValueForStyles/index.js +40 -0
  503. package/dist/modules/setValueForStyles/index.js.flow +23 -0
  504. package/dist/modules/unitlessNumbers/index.js +75 -0
  505. package/dist/modules/unitlessNumbers/index.js.flow +73 -0
  506. package/dist/modules/useElementLayout/index.js +85 -0
  507. package/dist/modules/useElementLayout/index.js.flow +19 -0
  508. package/dist/modules/useEvent/index.js +48 -0
  509. package/dist/modules/useEvent/index.js.flow +29 -0
  510. package/dist/modules/useHover/index.js +153 -0
  511. package/dist/modules/useHover/index.js.flow +46 -0
  512. package/dist/modules/useLayoutEffect/index.js +16 -0
  513. package/dist/modules/useLayoutEffect/index.js.flow +16 -0
  514. package/dist/modules/useLocale/index.js +35 -0
  515. package/dist/modules/useLocale/index.js.flow +32 -0
  516. package/dist/modules/useLocale/isLocaleRTL.js +83 -0
  517. package/dist/modules/useLocale/isLocaleRTL.js.flow +58 -0
  518. package/dist/modules/useMergeRefs/index.js +19 -0
  519. package/dist/modules/useMergeRefs/index.js.flow +12 -0
  520. package/dist/modules/usePlatformMethods/index.js +29 -0
  521. package/dist/modules/usePlatformMethods/index.js.flow +22 -0
  522. package/dist/modules/usePressEvents/PressResponder.js +492 -0
  523. package/dist/modules/usePressEvents/PressResponder.js.flow +216 -0
  524. package/dist/modules/usePressEvents/index.js +36 -0
  525. package/dist/modules/usePressEvents/index.js.flow +16 -0
  526. package/dist/modules/useResponderEvents/ResponderEventTypes.js +41 -0
  527. package/dist/modules/useResponderEvents/ResponderEventTypes.js.flow +61 -0
  528. package/dist/modules/useResponderEvents/ResponderSystem.js +590 -0
  529. package/dist/modules/useResponderEvents/ResponderSystem.js.flow +269 -0
  530. package/dist/modules/useResponderEvents/ResponderTouchHistoryStore.js +170 -0
  531. package/dist/modules/useResponderEvents/ResponderTouchHistoryStore.js.flow +56 -0
  532. package/dist/modules/useResponderEvents/createResponderEvent.js +146 -0
  533. package/dist/modules/useResponderEvents/createResponderEvent.js.flow +51 -0
  534. package/dist/modules/useResponderEvents/index.js +73 -0
  535. package/dist/modules/useResponderEvents/index.js.flow +26 -0
  536. package/dist/modules/useResponderEvents/utils.js +165 -0
  537. package/dist/modules/useResponderEvents/utils.js.flow +46 -0
  538. package/dist/modules/useStable/index.js +19 -0
  539. package/dist/modules/useStable/index.js.flow +12 -0
  540. package/dist/modules/warnOnce/index.js +27 -0
  541. package/dist/modules/warnOnce/index.js.flow +22 -0
  542. package/dist/types/index.js +0 -0
  543. package/dist/types/index.js.flow +46 -0
  544. package/dist/types/styles.js +0 -0
  545. package/dist/types/styles.js.flow +279 -0
  546. package/dist/vendor/hash/index.js +47 -0
  547. package/dist/vendor/hash/index.js.flow +18 -0
  548. package/dist/vendor/react-native/Animated/Animated.js +29 -0
  549. package/dist/vendor/react-native/Animated/Animated.js.flow +35 -0
  550. package/dist/vendor/react-native/Animated/AnimatedEvent.js +162 -0
  551. package/dist/vendor/react-native/Animated/AnimatedEvent.js.flow +46 -0
  552. package/dist/vendor/react-native/Animated/AnimatedImplementation.js +579 -0
  553. package/dist/vendor/react-native/Animated/AnimatedImplementation.js.flow +605 -0
  554. package/dist/vendor/react-native/Animated/AnimatedMock.js +137 -0
  555. package/dist/vendor/react-native/Animated/AnimatedMock.js.flow +139 -0
  556. package/dist/vendor/react-native/Animated/AnimatedPlatformConfig.js +11 -0
  557. package/dist/vendor/react-native/Animated/AnimatedPlatformConfig.js.flow +13 -0
  558. package/dist/vendor/react-native/Animated/Easing.js +249 -0
  559. package/dist/vendor/react-native/Animated/Easing.js.flow +80 -0
  560. package/dist/vendor/react-native/Animated/NativeAnimatedHelper.js +460 -0
  561. package/dist/vendor/react-native/Animated/NativeAnimatedHelper.js.flow +396 -0
  562. package/dist/vendor/react-native/Animated/NativeAnimatedModule.js +16 -0
  563. package/dist/vendor/react-native/Animated/NativeAnimatedModule.js.flow +56 -0
  564. package/dist/vendor/react-native/Animated/NativeAnimatedTurboModule.js +16 -0
  565. package/dist/vendor/react-native/Animated/NativeAnimatedTurboModule.js.flow +53 -0
  566. package/dist/vendor/react-native/Animated/SpringConfig.js +69 -0
  567. package/dist/vendor/react-native/Animated/SpringConfig.js.flow +25 -0
  568. package/dist/vendor/react-native/Animated/animations/Animation.js +55 -0
  569. package/dist/vendor/react-native/Animated/animations/Animation.js.flow +45 -0
  570. package/dist/vendor/react-native/Animated/animations/DecayAnimation.js +70 -0
  571. package/dist/vendor/react-native/Animated/animations/DecayAnimation.js.flow +51 -0
  572. package/dist/vendor/react-native/Animated/animations/SpringAnimation.js +222 -0
  573. package/dist/vendor/react-native/Animated/animations/SpringAnimation.js.flow +110 -0
  574. package/dist/vendor/react-native/Animated/animations/TimingAnimation.js +116 -0
  575. package/dist/vendor/react-native/Animated/animations/TimingAnimation.js.flow +61 -0
  576. package/dist/vendor/react-native/Animated/bezier.js +122 -0
  577. package/dist/vendor/react-native/Animated/bezier.js.flow +35 -0
  578. package/dist/vendor/react-native/Animated/components/AnimatedFlatList.js +23 -0
  579. package/dist/vendor/react-native/Animated/components/AnimatedFlatList.js.flow +20 -0
  580. package/dist/vendor/react-native/Animated/components/AnimatedImage.js +14 -0
  581. package/dist/vendor/react-native/Animated/components/AnimatedImage.js.flow +15 -0
  582. package/dist/vendor/react-native/Animated/components/AnimatedScrollView.js +23 -0
  583. package/dist/vendor/react-native/Animated/components/AnimatedScrollView.js.flow +20 -0
  584. package/dist/vendor/react-native/Animated/components/AnimatedSectionList.js +23 -0
  585. package/dist/vendor/react-native/Animated/components/AnimatedSectionList.js.flow +20 -0
  586. package/dist/vendor/react-native/Animated/components/AnimatedText.js +14 -0
  587. package/dist/vendor/react-native/Animated/components/AnimatedText.js.flow +15 -0
  588. package/dist/vendor/react-native/Animated/components/AnimatedView.js +14 -0
  589. package/dist/vendor/react-native/Animated/components/AnimatedView.js.flow +15 -0
  590. package/dist/vendor/react-native/Animated/createAnimatedComponent.js +46 -0
  591. package/dist/vendor/react-native/Animated/createAnimatedComponent.js.flow +27 -0
  592. package/dist/vendor/react-native/Animated/nodes/AnimatedAddition.js +49 -0
  593. package/dist/vendor/react-native/Animated/nodes/AnimatedAddition.js.flow +30 -0
  594. package/dist/vendor/react-native/Animated/nodes/AnimatedColor.js +283 -0
  595. package/dist/vendor/react-native/Animated/nodes/AnimatedColor.js.flow +83 -0
  596. package/dist/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js +53 -0
  597. package/dist/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js.flow +32 -0
  598. package/dist/vendor/react-native/Animated/nodes/AnimatedDivision.js +66 -0
  599. package/dist/vendor/react-native/Animated/nodes/AnimatedDivision.js.flow +31 -0
  600. package/dist/vendor/react-native/Animated/nodes/AnimatedInterpolation.js +265 -0
  601. package/dist/vendor/react-native/Animated/nodes/AnimatedInterpolation.js.flow +69 -0
  602. package/dist/vendor/react-native/Animated/nodes/AnimatedModulo.js +46 -0
  603. package/dist/vendor/react-native/Animated/nodes/AnimatedModulo.js.flow +29 -0
  604. package/dist/vendor/react-native/Animated/nodes/AnimatedMultiplication.js +49 -0
  605. package/dist/vendor/react-native/Animated/nodes/AnimatedMultiplication.js.flow +30 -0
  606. package/dist/vendor/react-native/Animated/nodes/AnimatedNode.js +159 -0
  607. package/dist/vendor/react-native/Animated/nodes/AnimatedNode.js.flow +58 -0
  608. package/dist/vendor/react-native/Animated/nodes/AnimatedProps.js +141 -0
  609. package/dist/vendor/react-native/Animated/nodes/AnimatedProps.js.flow +35 -0
  610. package/dist/vendor/react-native/Animated/nodes/AnimatedStyle.js +124 -0
  611. package/dist/vendor/react-native/Animated/nodes/AnimatedStyle.js.flow +33 -0
  612. package/dist/vendor/react-native/Animated/nodes/AnimatedSubtraction.js +49 -0
  613. package/dist/vendor/react-native/Animated/nodes/AnimatedSubtraction.js.flow +30 -0
  614. package/dist/vendor/react-native/Animated/nodes/AnimatedTracking.js +72 -0
  615. package/dist/vendor/react-native/Animated/nodes/AnimatedTracking.js.flow +32 -0
  616. package/dist/vendor/react-native/Animated/nodes/AnimatedTransform.js +109 -0
  617. package/dist/vendor/react-native/Animated/nodes/AnimatedTransform.js.flow +26 -0
  618. package/dist/vendor/react-native/Animated/nodes/AnimatedValue.js +267 -0
  619. package/dist/vendor/react-native/Animated/nodes/AnimatedValue.js.flow +86 -0
  620. package/dist/vendor/react-native/Animated/nodes/AnimatedValueXY.js +187 -0
  621. package/dist/vendor/react-native/Animated/nodes/AnimatedValueXY.js.flow +84 -0
  622. package/dist/vendor/react-native/Animated/nodes/AnimatedWithChildren.js +73 -0
  623. package/dist/vendor/react-native/Animated/nodes/AnimatedWithChildren.js.flow +25 -0
  624. package/dist/vendor/react-native/Animated/useAnimatedProps.js +154 -0
  625. package/dist/vendor/react-native/Animated/useAnimatedProps.js.flow +37 -0
  626. package/dist/vendor/react-native/Batchinator/index.js +79 -0
  627. package/dist/vendor/react-native/Batchinator/index.js.flow +51 -0
  628. package/dist/vendor/react-native/EventEmitter/NativeEventEmitter.js +80 -0
  629. package/dist/vendor/react-native/EventEmitter/NativeEventEmitter.js.flow +42 -0
  630. package/dist/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.js +21 -0
  631. package/dist/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.js.flow +22 -0
  632. package/dist/vendor/react-native/FillRateHelper/index.js +192 -0
  633. package/dist/vendor/react-native/FillRateHelper/index.js.flow +80 -0
  634. package/dist/vendor/react-native/FlatList/index.js +446 -0
  635. package/dist/vendor/react-native/FlatList/index.js.flow +345 -0
  636. package/dist/vendor/react-native/JSEventLoopWatchdog/index.js +86 -0
  637. package/dist/vendor/react-native/JSEventLoopWatchdog/index.js.flow +75 -0
  638. package/dist/vendor/react-native/LayoutAnimation/index.js +108 -0
  639. package/dist/vendor/react-native/LayoutAnimation/index.js.flow +105 -0
  640. package/dist/vendor/react-native/PanResponder/index.js +416 -0
  641. package/dist/vendor/react-native/PanResponder/index.js.flow +496 -0
  642. package/dist/vendor/react-native/PooledClass/index.js +58 -0
  643. package/dist/vendor/react-native/ReactNative/ReactNativeFeatureFlags.js +20 -0
  644. package/dist/vendor/react-native/ReactNative/ReactNativeFeatureFlags.js.flow +49 -0
  645. package/dist/vendor/react-native/SectionList/index.js +144 -0
  646. package/dist/vendor/react-native/SectionList/index.js.flow +165 -0
  647. package/dist/vendor/react-native/StaticContainer/index.js +40 -0
  648. package/dist/vendor/react-native/StaticContainer/index.js.flow +45 -0
  649. package/dist/vendor/react-native/StaticRenderer/index.js +22 -0
  650. package/dist/vendor/react-native/StaticRenderer/index.js.flow +29 -0
  651. package/dist/vendor/react-native/TouchHistoryMath/index.js +100 -0
  652. package/dist/vendor/react-native/TurboModule/RCTExport.js +29 -0
  653. package/dist/vendor/react-native/TurboModule/RCTExport.js.flow +35 -0
  654. package/dist/vendor/react-native/TurboModule/TurboModuleRegistry.js +21 -0
  655. package/dist/vendor/react-native/TurboModule/TurboModuleRegistry.js.flow +16 -0
  656. package/dist/vendor/react-native/Types/CoreEventTypes.js +11 -0
  657. package/dist/vendor/react-native/Types/CoreEventTypes.js.flow +264 -0
  658. package/dist/vendor/react-native/Utilities/Platform.js +2 -0
  659. package/dist/vendor/react-native/Utilities/clamp.js +22 -0
  660. package/dist/vendor/react-native/Utilities/clamp.js.flow +14 -0
  661. package/dist/vendor/react-native/Utilities/setAndForwardRef.js +61 -0
  662. package/dist/vendor/react-native/Utilities/setAndForwardRef.js.flow +50 -0
  663. package/dist/vendor/react-native/Utilities/useMergeRefs.js +38 -0
  664. package/dist/vendor/react-native/Utilities/useMergeRefs.js.flow +28 -0
  665. package/dist/vendor/react-native/Utilities/useRefEffect.js +37 -0
  666. package/dist/vendor/react-native/Utilities/useRefEffect.js.flow +28 -0
  667. package/dist/vendor/react-native/ViewabilityHelper/index.js +206 -0
  668. package/dist/vendor/react-native/ViewabilityHelper/index.js.flow +111 -0
  669. package/dist/vendor/react-native/VirtualizeUtils/index.js +175 -0
  670. package/dist/vendor/react-native/VirtualizeUtils/index.js.flow +64 -0
  671. package/dist/vendor/react-native/VirtualizedList/CellRenderMask.js +106 -0
  672. package/dist/vendor/react-native/VirtualizedList/CellRenderMask.js.flow +29 -0
  673. package/dist/vendor/react-native/VirtualizedList/ChildListCollection.js +68 -0
  674. package/dist/vendor/react-native/VirtualizedList/ChildListCollection.js.flow +21 -0
  675. package/dist/vendor/react-native/VirtualizedList/StateSafePureComponent.js +70 -0
  676. package/dist/vendor/react-native/VirtualizedList/StateSafePureComponent.js.flow +28 -0
  677. package/dist/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js +151 -0
  678. package/dist/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js.flow +68 -0
  679. package/dist/vendor/react-native/VirtualizedList/VirtualizedListContext.js +64 -0
  680. package/dist/vendor/react-native/VirtualizedList/VirtualizedListContext.js.flow +61 -0
  681. package/dist/vendor/react-native/VirtualizedList/VirtualizedListProps.js +16 -0
  682. package/dist/vendor/react-native/VirtualizedList/VirtualizedListProps.js.flow +308 -0
  683. package/dist/vendor/react-native/VirtualizedList/VirtualizedListRLVAdapter.js +946 -0
  684. package/dist/vendor/react-native/VirtualizedList/VirtualizedListRLVAdapter.js.flow +172 -0
  685. package/dist/vendor/react-native/VirtualizedList/index.js +1498 -0
  686. package/dist/vendor/react-native/VirtualizedList/index.js.flow +307 -0
  687. package/dist/vendor/react-native/VirtualizedSectionList/index.js +382 -0
  688. package/dist/vendor/react-native/VirtualizedSectionList/index.js.flow +191 -0
  689. package/dist/vendor/react-native/deepDiffer/index.js +70 -0
  690. package/dist/vendor/react-native/deepDiffer/index.js.flow +67 -0
  691. package/dist/vendor/react-native/infoLog/index.js +19 -0
  692. package/dist/vendor/react-native/infoLog/index.js.flow +17 -0
  693. package/dist/vendor/react-native/vendor/emitter/EventEmitter.js +98 -0
  694. package/dist/vendor/react-native/vendor/emitter/EventEmitter.js.flow +54 -0
  695. package/package.json +60 -0
  696. package/src/exports/AccessibilityInfo/index.js +118 -0
  697. package/src/exports/ActivityIndicator/index.js +119 -0
  698. package/src/exports/Alert/index.js +14 -0
  699. package/src/exports/Animated/index.js +13 -0
  700. package/src/exports/AppRegistry/AppContainer.js +55 -0
  701. package/src/exports/AppRegistry/index.js +153 -0
  702. package/src/exports/AppRegistry/renderApplication.js +72 -0
  703. package/src/exports/AppState/index.js +81 -0
  704. package/src/exports/Appearance/index.js +65 -0
  705. package/src/exports/BackHandler/index.js +108 -0
  706. package/src/exports/Button/index.js +90 -0
  707. package/src/exports/CheckBox/index.js +143 -0
  708. package/src/exports/Clipboard/index.js +63 -0
  709. package/src/exports/DeviceEventEmitter/index.js +2 -0
  710. package/src/exports/Dimensions/index.js +160 -0
  711. package/src/exports/Easing/index.js +11 -0
  712. package/src/exports/FlatList/index.js +14 -0
  713. package/src/exports/I18nManager/index.js +35 -0
  714. package/src/exports/Image/index.js +443 -0
  715. package/src/exports/Image/types.js +103 -0
  716. package/src/exports/ImageBackground/index.js +73 -0
  717. package/src/exports/InputAccessoryView/index.js +2 -0
  718. package/src/exports/InteractionManager/TaskQueue.js +115 -0
  719. package/src/exports/InteractionManager/index.js +142 -0
  720. package/src/exports/Keyboard/index.js +28 -0
  721. package/src/exports/KeyboardAvoidingView/index.js +59 -0
  722. package/src/exports/LayoutAnimation/index.js +12 -0
  723. package/src/exports/Linking/index.js +124 -0
  724. package/src/exports/LogBox/index.js +17 -0
  725. package/src/exports/Modal/ModalAnimation.js +164 -0
  726. package/src/exports/Modal/ModalContent.js +87 -0
  727. package/src/exports/Modal/ModalFocusTrap.js +173 -0
  728. package/src/exports/Modal/ModalPortal.js +48 -0
  729. package/src/exports/Modal/index.js +151 -0
  730. package/src/exports/NativeEventEmitter/index.js +11 -0
  731. package/src/exports/NativeModules/index.js +17 -0
  732. package/src/exports/PanResponder/Alternative.js +408 -0
  733. package/src/exports/PanResponder/index.js +4 -0
  734. package/src/exports/Picker/PickerItem.js +26 -0
  735. package/src/exports/Picker/index.js +95 -0
  736. package/src/exports/PixelRatio/index.js +49 -0
  737. package/src/exports/Platform/index.js +26 -0
  738. package/src/exports/Pressable/index.js +253 -0
  739. package/src/exports/ProgressBar/index.js +92 -0
  740. package/src/exports/RefreshControl/index.js +52 -0
  741. package/src/exports/SafeAreaView/index.js +49 -0
  742. package/src/exports/ScrollView/ScrollViewBase.js +186 -0
  743. package/src/exports/ScrollView/index.js +768 -0
  744. package/src/exports/ScrollView/types.js +26 -0
  745. package/src/exports/SectionList/index.js +13 -0
  746. package/src/exports/Share/index.js +65 -0
  747. package/src/exports/StatusBar/index.js +22 -0
  748. package/src/exports/StyleSheet/compiler/createReactDOMStyle.js +214 -0
  749. package/src/exports/StyleSheet/compiler/hash.js +67 -0
  750. package/src/exports/StyleSheet/compiler/hyphenateStyleName.js +27 -0
  751. package/src/exports/StyleSheet/compiler/index.js +518 -0
  752. package/src/exports/StyleSheet/compiler/normalizeColor.js +34 -0
  753. package/src/exports/StyleSheet/compiler/normalizeValueWithProperty.js +40 -0
  754. package/src/exports/StyleSheet/compiler/resolveShadowValue.js +32 -0
  755. package/src/exports/StyleSheet/compiler/unitlessNumbers.js +76 -0
  756. package/src/exports/StyleSheet/dom/createCSSStyleSheet.js +40 -0
  757. package/src/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js +184 -0
  758. package/src/exports/StyleSheet/dom/index.js +90 -0
  759. package/src/exports/StyleSheet/index.js +197 -0
  760. package/src/exports/StyleSheet/preprocess.js +255 -0
  761. package/src/exports/StyleSheet/validate.js +93 -0
  762. package/src/exports/Switch/index.js +236 -0
  763. package/src/exports/TV/NativeTVNavigationEventEmitter.js +141 -0
  764. package/src/exports/TV/TVEventControl.js +56 -0
  765. package/src/exports/TV/TVEventHandler.js +58 -0
  766. package/src/exports/TV/TVFocusEventHandler.js +43 -0
  767. package/src/exports/TV/TVFocusGuideView.js +162 -0
  768. package/src/exports/TV/TVParallaxProperties.d.ts +42 -0
  769. package/src/exports/TV/TVTextScrollView.js +159 -0
  770. package/src/exports/TV/tagForComponentOrHandle.js +46 -0
  771. package/src/exports/TV/types.js +153 -0
  772. package/src/exports/TV/useTVEventHandler.js +24 -0
  773. package/src/exports/TV/utils.js +24 -0
  774. package/src/exports/Text/TextAncestorContext.js +17 -0
  775. package/src/exports/Text/index.js +241 -0
  776. package/src/exports/Text/types.js +121 -0
  777. package/src/exports/TextInput/index.js +503 -0
  778. package/src/exports/TextInput/types.js +97 -0
  779. package/src/exports/Touchable/BoundingDimensions.js +37 -0
  780. package/src/exports/Touchable/Position.js +26 -0
  781. package/src/exports/Touchable/ensurePositiveDelayProps.js +23 -0
  782. package/src/exports/Touchable/index.js +1026 -0
  783. package/src/exports/TouchableHighlight/index.js +218 -0
  784. package/src/exports/TouchableNativeFeedback/index.js +11 -0
  785. package/src/exports/TouchableOpacity/index.js +172 -0
  786. package/src/exports/TouchableWithoutFeedback/index.js +135 -0
  787. package/src/exports/UIManager/index.js +132 -0
  788. package/src/exports/Vibration/index.js +28 -0
  789. package/src/exports/View/index.js +218 -0
  790. package/src/exports/View/types.js +250 -0
  791. package/src/exports/VirtualizedList/index.js +13 -0
  792. package/src/exports/YellowBox/index.js +22 -0
  793. package/src/exports/createElement/index.js +43 -0
  794. package/src/exports/findNodeHandle/index.js +18 -0
  795. package/src/exports/processColor/index.js +29 -0
  796. package/src/exports/render/index.js +29 -0
  797. package/src/exports/unmountComponentAtNode/index.js +13 -0
  798. package/src/exports/useColorScheme/index.js +31 -0
  799. package/src/exports/useLocaleContext/index.js +13 -0
  800. package/src/exports/useWindowDimensions/index.js +36 -0
  801. package/src/index.js +79 -0
  802. package/src/modules/AccessibilityUtil/index.js +20 -0
  803. package/src/modules/AccessibilityUtil/isDisabled.js +15 -0
  804. package/src/modules/AccessibilityUtil/propsToAccessibilityComponent.js +58 -0
  805. package/src/modules/AccessibilityUtil/propsToAriaRole.js +42 -0
  806. package/src/modules/AssetRegistry/index.js +32 -0
  807. package/src/modules/ImageLoader/index.js +167 -0
  808. package/src/modules/SpatialManager/README.md +122 -0
  809. package/src/modules/SpatialManager/index.js +582 -0
  810. package/src/modules/SpatialManager/mutationObserver.js +119 -0
  811. package/src/modules/SpatialManager/scrollHandler.js +898 -0
  812. package/src/modules/SpatialManager/utils.js +529 -0
  813. package/src/modules/TextInputState/index.js +64 -0
  814. package/src/modules/UnimplementedView/index.js +31 -0
  815. package/src/modules/addEventListener/index.js +89 -0
  816. package/src/modules/canUseDom/index.js +16 -0
  817. package/src/modules/createDOMProps/index.js +979 -0
  818. package/src/modules/dismissKeyboard/index.js +16 -0
  819. package/src/modules/forwardedProps/index.js +189 -0
  820. package/src/modules/getBoundingClientRect/index.js +19 -0
  821. package/src/modules/isSelectionValid/index.js +19 -0
  822. package/src/modules/isWebColor/index.js +16 -0
  823. package/src/modules/mergeRefs/index.js +35 -0
  824. package/src/modules/modality/index.js +215 -0
  825. package/src/modules/multiplyStyleLengthValue/index.js +28 -0
  826. package/src/modules/normalizeColor/index.js +34 -0
  827. package/src/modules/pick/index.js +20 -0
  828. package/src/modules/prefixStyles/index.js +17 -0
  829. package/src/modules/prefixStyles/static.js +69 -0
  830. package/src/modules/requestIdleCallback/index.js +38 -0
  831. package/src/modules/setValueForStyles/dangerousStyleValue.js +52 -0
  832. package/src/modules/setValueForStyles/index.js +45 -0
  833. package/src/modules/unitlessNumbers/index.js +76 -0
  834. package/src/modules/useElementLayout/index.js +95 -0
  835. package/src/modules/useEvent/index.js +70 -0
  836. package/src/modules/useHover/index.js +197 -0
  837. package/src/modules/useLayoutEffect/index.js +20 -0
  838. package/src/modules/useLocale/index.js +60 -0
  839. package/src/modules/useLocale/isLocaleRTL.js +81 -0
  840. package/src/modules/useMergeRefs/index.js +21 -0
  841. package/src/modules/usePlatformMethods/index.js +39 -0
  842. package/src/modules/usePressEvents/PressResponder.js +625 -0
  843. package/src/modules/usePressEvents/index.js +44 -0
  844. package/src/modules/useResponderEvents/README.md +209 -0
  845. package/src/modules/useResponderEvents/ResponderEventTypes.js +83 -0
  846. package/src/modules/useResponderEvents/ResponderSystem.js +688 -0
  847. package/src/modules/useResponderEvents/ResponderTouchHistoryStore.js +219 -0
  848. package/src/modules/useResponderEvents/createResponderEvent.js +206 -0
  849. package/src/modules/useResponderEvents/index.js +91 -0
  850. package/src/modules/useResponderEvents/utils.js +179 -0
  851. package/src/modules/useStable/index.js +24 -0
  852. package/src/modules/warnOnce/index.js +29 -0
  853. package/src/types/index.js +76 -0
  854. package/src/types/styles.js +346 -0
  855. package/src/vendor/hash/index.js +60 -0
  856. package/src/vendor/react-native/Animated/Animated.js +41 -0
  857. package/src/vendor/react-native/Animated/AnimatedEvent.js +232 -0
  858. package/src/vendor/react-native/Animated/AnimatedImplementation.js +757 -0
  859. package/src/vendor/react-native/Animated/AnimatedMock.js +197 -0
  860. package/src/vendor/react-native/Animated/AnimatedPlatformConfig.js +13 -0
  861. package/src/vendor/react-native/Animated/Easing.js +253 -0
  862. package/src/vendor/react-native/Animated/NativeAnimatedHelper.js +603 -0
  863. package/src/vendor/react-native/Animated/NativeAnimatedModule.js +72 -0
  864. package/src/vendor/react-native/Animated/NativeAnimatedTurboModule.js +70 -0
  865. package/src/vendor/react-native/Animated/SpringConfig.js +103 -0
  866. package/src/vendor/react-native/Animated/animations/Animation.js +89 -0
  867. package/src/vendor/react-native/Animated/animations/DecayAnimation.js +120 -0
  868. package/src/vendor/react-native/Animated/animations/SpringAnimation.js +376 -0
  869. package/src/vendor/react-native/Animated/animations/TimingAnimation.js +177 -0
  870. package/src/vendor/react-native/Animated/bezier.js +153 -0
  871. package/src/vendor/react-native/Animated/components/AnimatedFlatList.js +30 -0
  872. package/src/vendor/react-native/Animated/components/AnimatedImage.js +23 -0
  873. package/src/vendor/react-native/Animated/components/AnimatedScrollView.js +30 -0
  874. package/src/vendor/react-native/Animated/components/AnimatedSectionList.js +30 -0
  875. package/src/vendor/react-native/Animated/components/AnimatedText.js +23 -0
  876. package/src/vendor/react-native/Animated/components/AnimatedView.js +21 -0
  877. package/src/vendor/react-native/Animated/createAnimatedComponent.js +65 -0
  878. package/src/vendor/react-native/Animated/nodes/AnimatedAddition.js +67 -0
  879. package/src/vendor/react-native/Animated/nodes/AnimatedColor.js +359 -0
  880. package/src/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js +75 -0
  881. package/src/vendor/react-native/Animated/nodes/AnimatedDivision.js +82 -0
  882. package/src/vendor/react-native/Animated/nodes/AnimatedInterpolation.js +375 -0
  883. package/src/vendor/react-native/Animated/nodes/AnimatedModulo.js +66 -0
  884. package/src/vendor/react-native/Animated/nodes/AnimatedMultiplication.js +66 -0
  885. package/src/vendor/react-native/Animated/nodes/AnimatedNode.js +197 -0
  886. package/src/vendor/react-native/Animated/nodes/AnimatedProps.js +171 -0
  887. package/src/vendor/react-native/Animated/nodes/AnimatedStyle.js +143 -0
  888. package/src/vendor/react-native/Animated/nodes/AnimatedSubtraction.js +66 -0
  889. package/src/vendor/react-native/Animated/nodes/AnimatedTracking.js +102 -0
  890. package/src/vendor/react-native/Animated/nodes/AnimatedTransform.js +121 -0
  891. package/src/vendor/react-native/Animated/nodes/AnimatedValue.js +306 -0
  892. package/src/vendor/react-native/Animated/nodes/AnimatedValueXY.js +226 -0
  893. package/src/vendor/react-native/Animated/nodes/AnimatedWithChildren.js +90 -0
  894. package/src/vendor/react-native/Animated/useAnimatedProps.js +188 -0
  895. package/src/vendor/react-native/Batchinator/index.js +76 -0
  896. package/src/vendor/react-native/EventEmitter/NativeEventEmitter.js +116 -0
  897. package/src/vendor/react-native/EventEmitter/RCTDeviceEventEmitter.js +22 -0
  898. package/src/vendor/react-native/FillRateHelper/index.js +253 -0
  899. package/src/vendor/react-native/FlatList/index.js +710 -0
  900. package/src/vendor/react-native/JSEventLoopWatchdog/index.js +87 -0
  901. package/src/vendor/react-native/LayoutAnimation/index.js +142 -0
  902. package/src/vendor/react-native/PanResponder/index.js +613 -0
  903. package/src/vendor/react-native/PooledClass/index.js +63 -0
  904. package/src/vendor/react-native/ReactNative/ReactNativeFeatureFlags.js +51 -0
  905. package/src/vendor/react-native/SHA +2 -0
  906. package/src/vendor/react-native/SectionList/index.js +254 -0
  907. package/src/vendor/react-native/StaticContainer/index.js +54 -0
  908. package/src/vendor/react-native/StaticRenderer/index.js +37 -0
  909. package/src/vendor/react-native/TouchHistoryMath/index.js +153 -0
  910. package/src/vendor/react-native/TurboModule/RCTExport.js +35 -0
  911. package/src/vendor/react-native/TurboModule/TurboModuleRegistry.js +28 -0
  912. package/src/vendor/react-native/Types/CoreEventTypes.js +291 -0
  913. package/src/vendor/react-native/Utilities/Platform.js +2 -0
  914. package/src/vendor/react-native/Utilities/clamp.js +23 -0
  915. package/src/vendor/react-native/Utilities/setAndForwardRef.js +71 -0
  916. package/src/vendor/react-native/Utilities/useMergeRefs.js +44 -0
  917. package/src/vendor/react-native/Utilities/useRefEffect.js +45 -0
  918. package/src/vendor/react-native/ViewabilityHelper/index.js +360 -0
  919. package/src/vendor/react-native/VirtualizeUtils/index.js +258 -0
  920. package/src/vendor/react-native/VirtualizedList/CellRenderMask.js +155 -0
  921. package/src/vendor/react-native/VirtualizedList/ChildListCollection.js +72 -0
  922. package/src/vendor/react-native/VirtualizedList/RLV_ADAPTER_STATUS.md +257 -0
  923. package/src/vendor/react-native/VirtualizedList/StateSafePureComponent.js +85 -0
  924. package/src/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js +247 -0
  925. package/src/vendor/react-native/VirtualizedList/VirtualizedListContext.js +118 -0
  926. package/src/vendor/react-native/VirtualizedList/VirtualizedListProps.js +318 -0
  927. package/src/vendor/react-native/VirtualizedList/VirtualizedListRLVAdapter.js +1120 -0
  928. package/src/vendor/react-native/VirtualizedList/index.js +2099 -0
  929. package/src/vendor/react-native/VirtualizedSectionList/index.js +616 -0
  930. package/src/vendor/react-native/deepDiffer/index.js +72 -0
  931. package/src/vendor/react-native/infoLog/index.js +20 -0
  932. package/src/vendor/react-native/vendor/emitter/EventEmitter.js +146 -0
@@ -0,0 +1,2099 @@
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
8
+ * @format
9
+ */
10
+
11
+ import type { LayoutEvent } from '../../../types';
12
+ import type {
13
+ ScrollEvent,
14
+ } from '../Types/CoreEventTypes';
15
+ import type {ViewToken} from '../ViewabilityHelper';
16
+ import type {
17
+ FrameMetricProps,
18
+ Item,
19
+ Props,
20
+ RenderItemProps,
21
+ RenderItemType,
22
+ Separators,
23
+ } from './VirtualizedListProps';
24
+
25
+ import RefreshControl from '../../../exports/RefreshControl';
26
+ import ScrollView from '../../../exports/ScrollView';
27
+ import TVFocusGuideView from '../../../exports/TV/TVFocusGuideView';
28
+ import View, { type ViewProps } from '../../../exports/View';
29
+ import StyleSheet from '../../../exports/StyleSheet';
30
+
31
+ import Batchinator from '../Batchinator';
32
+ import clamp from '../Utilities/clamp';
33
+ import infoLog from '../infoLog';
34
+ import {CellRenderMask} from './CellRenderMask';
35
+ import ChildListCollection from './ChildListCollection';
36
+ import FillRateHelper from '../FillRateHelper';
37
+ import StateSafePureComponent from './StateSafePureComponent';
38
+ import ViewabilityHelper from '../ViewabilityHelper';
39
+ import CellRenderer from './VirtualizedListCellRenderer';
40
+ import {
41
+ VirtualizedListCellContextProvider,
42
+ VirtualizedListContext,
43
+ VirtualizedListContextProvider,
44
+ } from './VirtualizedListContext.js';
45
+ import {
46
+ computeWindowedRenderLimits,
47
+ keyExtractor as defaultKeyExtractor,
48
+ } from '../VirtualizeUtils';
49
+ import invariant from 'fbjs/lib/invariant';
50
+ import nullthrows from 'nullthrows';
51
+ import * as React from 'react';
52
+ // import VirtualizedListRLVAdapter from './VirtualizedListRLVAdapter';
53
+ import I18nManager from '../../../exports/I18nManager';
54
+ import Platform from '../../../exports/Platform';
55
+
56
+ export type {RenderItemProps, RenderItemType, Separators};
57
+
58
+ const __DEV__ = process.env.NODE_ENV !== 'production';
59
+
60
+ const ON_EDGE_REACHED_EPSILON = 0.001;
61
+
62
+ let _usedIndexForKey = false;
63
+ let _keylessItemComponentName: string = '';
64
+
65
+ type ScrollResponderType = any;
66
+ type ViewStyleProp = $PropertyType<ViewProps, 'style'>;
67
+
68
+ type ViewabilityHelperCallbackTuple = {
69
+ viewabilityHelper: ViewabilityHelper,
70
+ onViewableItemsChanged: (info: {
71
+ viewableItems: Array<ViewToken>,
72
+ changed: Array<ViewToken>,
73
+ ...
74
+ }) => void,
75
+ ...
76
+ };
77
+
78
+ type State = {
79
+ renderMask: CellRenderMask,
80
+ cellsAroundViewport: {first: number, last: number},
81
+ };
82
+
83
+ /**
84
+ * Default Props Helper Functions
85
+ * Use the following helper functions for default values
86
+ */
87
+
88
+ // horizontalOrDefault(this.props.horizontal)
89
+ function horizontalOrDefault(horizontal: ?boolean) {
90
+ return horizontal ?? false;
91
+ }
92
+
93
+ // initialNumToRenderOrDefault(this.props.initialNumToRender)
94
+ function initialNumToRenderOrDefault(initialNumToRender: ?number) {
95
+ return initialNumToRender ?? 10;
96
+ }
97
+
98
+ // maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch)
99
+ function maxToRenderPerBatchOrDefault(maxToRenderPerBatch: ?number) {
100
+ return maxToRenderPerBatch ?? 10;
101
+ }
102
+
103
+ // onStartReachedThresholdOrDefault(this.props.onStartReachedThreshold)
104
+ function onStartReachedThresholdOrDefault(onStartReachedThreshold: ?number) {
105
+ return onStartReachedThreshold ?? 2;
106
+ }
107
+
108
+ // onEndReachedThresholdOrDefault(this.props.onEndReachedThreshold)
109
+ function onEndReachedThresholdOrDefault(onEndReachedThreshold: ?number) {
110
+ return onEndReachedThreshold ?? 2;
111
+ }
112
+
113
+ // getScrollingThreshold(visibleLength, onEndReachedThreshold)
114
+ function getScrollingThreshold(threshold: number, visibleLength: number) {
115
+ return (threshold * visibleLength) / 2;
116
+ }
117
+
118
+ // scrollEventThrottleOrDefault(this.props.scrollEventThrottle)
119
+ function scrollEventThrottleOrDefault(scrollEventThrottle: ?number) {
120
+ return scrollEventThrottle ?? 50;
121
+ }
122
+
123
+ // windowSizeOrDefault(this.props.windowSize)
124
+ function windowSizeOrDefault(windowSize: ?number) {
125
+ return windowSize ?? 21;
126
+ }
127
+
128
+ function findLastWhere<T>(
129
+ arr: $ReadOnlyArray<T>,
130
+ predicate: (element: T) => boolean,
131
+ ): T | null {
132
+ for (let i = arr.length - 1; i >= 0; i--) {
133
+ if (predicate(arr[i])) {
134
+ return arr[i];
135
+ }
136
+ }
137
+
138
+ return null;
139
+ }
140
+
141
+ /**
142
+ * Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist)
143
+ * and [`<SectionList>`](https://reactnative.dev/docs/sectionlist) components, which are also better
144
+ * documented. In general, this should only really be used if you need more flexibility than
145
+ * `FlatList` provides, e.g. for use with immutable data instead of plain arrays.
146
+ *
147
+ * Virtualization massively improves memory consumption and performance of large lists by
148
+ * maintaining a finite render window of active items and replacing all items outside of the render
149
+ * window with appropriately sized blank space. The window adapts to scrolling behavior, and items
150
+ * are rendered incrementally with low-pri (after any running interactions) if they are far from the
151
+ * visible area, or with hi-pri otherwise to minimize the potential of seeing blank space.
152
+ *
153
+ * Some caveats:
154
+ *
155
+ * - Internal state is not preserved when content scrolls out of the render window. Make sure all
156
+ * your data is captured in the item data or external stores like Flux, Redux, or Relay.
157
+ * - This is a `PureComponent` which means that it will not re-render if `props` remain shallow-
158
+ * equal. Make sure that everything your `renderItem` function depends on is passed as a prop
159
+ * (e.g. `extraData`) that is not `===` after updates, otherwise your UI may not update on
160
+ * changes. This includes the `data` prop and parent component state.
161
+ * - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously
162
+ * offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see
163
+ * blank content. This is a tradeoff that can be adjusted to suit the needs of each application,
164
+ * and we are working on improving it behind the scenes.
165
+ * - By default, the list looks for a `key` or `id` prop on each item and uses that for the React key.
166
+ * Alternatively, you can provide a custom `keyExtractor` prop.
167
+ * - As an effort to remove defaultProps, use helper functions when referencing certain props
168
+ *
169
+ */
170
+ class VirtualizedList extends StateSafePureComponent<Props, State> {
171
+ static contextType: typeof VirtualizedListContext = VirtualizedListContext;
172
+
173
+ // scrollToEnd may be janky without getItemLayout prop
174
+ scrollToEnd(params?: ?{animated?: ?boolean, ...}) {
175
+ const animated = params ? params.animated : true;
176
+ const veryLast = this.props.getItemCount(this.props.data) - 1;
177
+ if (veryLast < 0) {
178
+ return;
179
+ }
180
+ const frame = this.__getFrameMetricsApprox(veryLast, this.props);
181
+ const offset = Math.max(
182
+ 0,
183
+ frame.offset +
184
+ frame.length +
185
+ this._footerLength -
186
+ this._scrollMetrics.visibleLength,
187
+ );
188
+
189
+ if (this._scrollRef == null) {
190
+ return;
191
+ }
192
+
193
+ if (this._scrollRef.scrollTo == null) {
194
+ console.warn(
195
+ 'No scrollTo method provided. This may be because you have two nested ' +
196
+ 'VirtualizedLists with the same orientation, or because you are ' +
197
+ 'using a custom component that does not implement scrollTo.',
198
+ );
199
+ return;
200
+ }
201
+
202
+ this._scrollRef.scrollTo(
203
+ horizontalOrDefault(this.props.horizontal)
204
+ ? {x: offset, animated}
205
+ : {y: offset, animated},
206
+ );
207
+ }
208
+
209
+ // scrollToIndex may be janky without getItemLayout prop
210
+ scrollToIndex(params: {
211
+ animated?: ?boolean,
212
+ index: number,
213
+ viewOffset?: number,
214
+ viewPosition?: number,
215
+ ...
216
+ }): $FlowFixMe {
217
+ const {
218
+ data,
219
+ horizontal,
220
+ getItemCount,
221
+ getItemLayout,
222
+ onScrollToIndexFailed,
223
+ } = this.props;
224
+ const {animated, index, viewOffset, viewPosition} = params;
225
+ invariant(
226
+ index >= 0,
227
+ `scrollToIndex out of range: requested index ${index} but minimum is 0`,
228
+ );
229
+ invariant(
230
+ getItemCount(data) >= 1,
231
+ `scrollToIndex out of range: item length ${getItemCount(
232
+ data,
233
+ )} but minimum is 1`,
234
+ );
235
+ invariant(
236
+ index < getItemCount(data),
237
+ `scrollToIndex out of range: requested index ${index} is out of 0 to ${
238
+ getItemCount(data) - 1
239
+ }`,
240
+ );
241
+ if (!getItemLayout && index > this._highestMeasuredFrameIndex) {
242
+ invariant(
243
+ !!onScrollToIndexFailed,
244
+ 'scrollToIndex should be used in conjunction with getItemLayout or onScrollToIndexFailed, ' +
245
+ 'otherwise there is no way to know the location of offscreen indices or handle failures.',
246
+ );
247
+ onScrollToIndexFailed({
248
+ averageItemLength: this._averageCellLength,
249
+ highestMeasuredFrameIndex: this._highestMeasuredFrameIndex,
250
+ index,
251
+ });
252
+ return;
253
+ }
254
+ const frame = this.__getFrameMetricsApprox(Math.floor(index), this.props);
255
+ const offset =
256
+ Math.max(
257
+ 0,
258
+ this._getOffsetApprox(index, this.props) -
259
+ (viewPosition || 0) *
260
+ (this._scrollMetrics.visibleLength - frame.length),
261
+ ) - (viewOffset || 0);
262
+
263
+ if (this._scrollRef == null) {
264
+ return;
265
+ }
266
+
267
+ if (this._scrollRef.scrollTo == null) {
268
+ console.warn(
269
+ 'No scrollTo method provided. This may be because you have two nested ' +
270
+ 'VirtualizedLists with the same orientation, or because you are ' +
271
+ 'using a custom component that does not implement scrollTo.',
272
+ );
273
+ return;
274
+ }
275
+
276
+ this._scrollRef.scrollTo(
277
+ horizontal ? {x: offset, animated} : {y: offset, animated},
278
+ );
279
+ }
280
+
281
+ // scrollToItem may be janky without getItemLayout prop. Required linear scan through items -
282
+ // use scrollToIndex instead if possible.
283
+ scrollToItem(params: {
284
+ animated?: ?boolean,
285
+ item: Item,
286
+ viewOffset?: number,
287
+ viewPosition?: number,
288
+ ...
289
+ }) {
290
+ const {item} = params;
291
+ const {data, getItem, getItemCount} = this.props;
292
+ const itemCount = getItemCount(data);
293
+ for (let index = 0; index < itemCount; index++) {
294
+ if (getItem(data, index) === item) {
295
+ this.scrollToIndex({...params, index});
296
+ break;
297
+ }
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Scroll to a specific content pixel offset in the list.
303
+ *
304
+ * Param `offset` expects the offset to scroll to.
305
+ * In case of `horizontal` is true, the offset is the x-value,
306
+ * in any other case the offset is the y-value.
307
+ *
308
+ * Param `animated` (`true` by default) defines whether the list
309
+ * should do an animation while scrolling.
310
+ */
311
+ scrollToOffset(params: {animated?: ?boolean, offset: number, ...}) {
312
+ const {animated, offset} = params;
313
+
314
+ if (this._scrollRef == null) {
315
+ return;
316
+ }
317
+
318
+ if (this._scrollRef.scrollTo == null) {
319
+ console.warn(
320
+ 'No scrollTo method provided. This may be because you have two nested ' +
321
+ 'VirtualizedLists with the same orientation, or because you are ' +
322
+ 'using a custom component that does not implement scrollTo.',
323
+ );
324
+ return;
325
+ }
326
+
327
+ this._scrollRef.scrollTo(
328
+ horizontalOrDefault(this.props.horizontal)
329
+ ? {x: offset, animated}
330
+ : {y: offset, animated},
331
+ );
332
+ }
333
+
334
+ recordInteraction() {
335
+ this._nestedChildLists.forEach(childList => {
336
+ childList.recordInteraction();
337
+ });
338
+ this._viewabilityTuples.forEach(t => {
339
+ t.viewabilityHelper.recordInteraction();
340
+ });
341
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
342
+ }
343
+
344
+ flashScrollIndicators() {
345
+ if (this._scrollRef == null) {
346
+ return;
347
+ }
348
+
349
+ this._scrollRef.flashScrollIndicators();
350
+ }
351
+
352
+ /**
353
+ * Provides a handle to the underlying scroll responder.
354
+ * Note that `this._scrollRef` might not be a `ScrollView`, so we
355
+ * need to check that it responds to `getScrollResponder` before calling it.
356
+ */
357
+ getScrollResponder(): ?ScrollResponderType {
358
+ if (this._scrollRef && this._scrollRef.getScrollResponder) {
359
+ return this._scrollRef.getScrollResponder();
360
+ }
361
+ }
362
+
363
+ getScrollableNode(): ?number {
364
+ if (this._scrollRef && this._scrollRef.getScrollableNode) {
365
+ return this._scrollRef.getScrollableNode();
366
+ } else {
367
+ return this._scrollRef;
368
+ }
369
+ }
370
+
371
+ getScrollRef():
372
+ | ?React.ElementRef<typeof ScrollView>
373
+ | ?React.ElementRef<typeof View> {
374
+ if (this._scrollRef && this._scrollRef.getScrollRef) {
375
+ return this._scrollRef.getScrollRef();
376
+ } else {
377
+ return this._scrollRef;
378
+ }
379
+ }
380
+
381
+ _getCellKey(): string {
382
+ return this.context?.cellKey || 'rootList';
383
+ }
384
+
385
+ // $FlowFixMe[missing-local-annot]
386
+ _getScrollMetrics = () => {
387
+ return this._scrollMetrics;
388
+ };
389
+
390
+ hasMore(): boolean {
391
+ return this._hasMore;
392
+ }
393
+
394
+ // $FlowFixMe[missing-local-annot]
395
+ _getOutermostParentListRef = () => {
396
+ if (this._isNestedWithSameOrientation()) {
397
+ return this.context.getOutermostParentListRef();
398
+ } else {
399
+ return this;
400
+ }
401
+ };
402
+
403
+ _registerAsNestedChild = (childList: {
404
+ cellKey: string,
405
+ ref: React.ElementRef<typeof VirtualizedList>,
406
+ }): void => {
407
+ this._nestedChildLists.add(childList.ref, childList.cellKey);
408
+ if (this._hasInteracted) {
409
+ childList.ref.recordInteraction();
410
+ }
411
+ };
412
+
413
+ _unregisterAsNestedChild = (childList: {
414
+ ref: React.ElementRef<typeof VirtualizedList>,
415
+ }): void => {
416
+ this._nestedChildLists.remove(childList.ref);
417
+ };
418
+
419
+ state: State;
420
+
421
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
422
+ invertedWheelEventHandler: ?(ev: any) => void;
423
+
424
+ constructor(props: Props) {
425
+ super(props);
426
+ this._checkProps(props);
427
+ this._fillRateHelper = new FillRateHelper(this._getFrameMetrics);
428
+ this._updateCellsToRenderBatcher = new Batchinator(
429
+ this._updateCellsToRender,
430
+ this.props.updateCellsBatchingPeriod ?? 50,
431
+ );
432
+
433
+ if (this.props.viewabilityConfigCallbackPairs) {
434
+ this._viewabilityTuples = this.props.viewabilityConfigCallbackPairs.map(
435
+ pair => ({
436
+ viewabilityHelper: new ViewabilityHelper(pair.viewabilityConfig),
437
+ onViewableItemsChanged: pair.onViewableItemsChanged,
438
+ }),
439
+ );
440
+ } else {
441
+ const {onViewableItemsChanged, viewabilityConfig} = this.props;
442
+ if (onViewableItemsChanged) {
443
+ this._viewabilityTuples.push({
444
+ viewabilityHelper: new ViewabilityHelper(viewabilityConfig),
445
+ onViewableItemsChanged: onViewableItemsChanged,
446
+ });
447
+ }
448
+ }
449
+
450
+ const initialRenderRegion = VirtualizedList._initialRenderRegion(props);
451
+
452
+ this.state = {
453
+ cellsAroundViewport: initialRenderRegion,
454
+ renderMask: VirtualizedList._createRenderMask(props, initialRenderRegion),
455
+ };
456
+
457
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
458
+ // For issue https://github.com/necolas/react-native-web/issues/995
459
+ this.invertedWheelEventHandler = (ev: any) => {
460
+ const scrollOffset = this.props.horizontal ? ev.target.scrollLeft : ev.target.scrollTop;
461
+ const scrollLength = this.props.horizontal ? ev.target.scrollWidth : ev.target.scrollHeight;
462
+ const clientLength = this.props.horizontal ? ev.target.clientWidth : ev.target.clientHeight;
463
+ const isEventTargetScrollable = scrollLength > clientLength;
464
+ const delta = this.props.horizontal
465
+ ? ev.deltaX || ev.wheelDeltaX
466
+ : ev.deltaY || ev.wheelDeltaY;
467
+ let leftoverDelta = delta;
468
+ if (isEventTargetScrollable) {
469
+ leftoverDelta = delta < 0
470
+ ? Math.min(delta + scrollOffset, 0)
471
+ : Math.max(delta - (scrollLength - clientLength - scrollOffset), 0);
472
+ }
473
+ const targetDelta = delta - leftoverDelta;
474
+
475
+ if (this.props.inverted && this._scrollRef && this._scrollRef.getScrollableNode) {
476
+ const node = (this._scrollRef: any).getScrollableNode();
477
+ if (this.props.horizontal) {
478
+ ev.target.scrollLeft += targetDelta;
479
+ const nextScrollLeft = node.scrollLeft - leftoverDelta;
480
+ node.scrollLeft = !this.props.getItemLayout ? Math.min(nextScrollLeft, this._totalCellLength) : nextScrollLeft;
481
+ } else {
482
+ ev.target.scrollTop += targetDelta;
483
+ const nextScrollTop = node.scrollTop - leftoverDelta;
484
+ node.scrollTop = !this.props.getItemLayout ? Math.min(nextScrollTop, this._totalCellLength) : nextScrollTop;
485
+ }
486
+ ev.preventDefault();
487
+ }
488
+ };
489
+ }
490
+
491
+ _checkProps(props: Props) {
492
+ const {onScroll, windowSize, getItemCount, data, initialScrollIndex} =
493
+ props;
494
+
495
+ invariant(
496
+ // $FlowFixMe[prop-missing]
497
+ !onScroll || !onScroll.__isNative,
498
+ 'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' +
499
+ 'to support native onScroll events with useNativeDriver',
500
+ );
501
+ invariant(
502
+ windowSizeOrDefault(windowSize) > 0,
503
+ 'VirtualizedList: The windowSize prop must be present and set to a value greater than 0.',
504
+ );
505
+
506
+ invariant(
507
+ getItemCount,
508
+ 'VirtualizedList: The "getItemCount" prop must be provided',
509
+ );
510
+
511
+ const itemCount = getItemCount(data);
512
+
513
+ if (
514
+ initialScrollIndex != null &&
515
+ !this._hasTriggeredInitialScrollToIndex &&
516
+ (initialScrollIndex < 0 ||
517
+ (itemCount > 0 && initialScrollIndex >= itemCount)) &&
518
+ !this._hasWarned.initialScrollIndex
519
+ ) {
520
+ console.warn(
521
+ `initialScrollIndex "${initialScrollIndex}" is not valid (list has ${itemCount} items)`,
522
+ );
523
+ this._hasWarned.initialScrollIndex = true;
524
+ }
525
+
526
+ if (__DEV__ && !this._hasWarned.flexWrap) {
527
+ // $FlowFixMe[underconstrained-implicit-instantiation]
528
+ const flatStyles = StyleSheet.flatten(this.props.contentContainerStyle);
529
+ if (flatStyles != null && flatStyles.flexWrap === 'wrap') {
530
+ console.warn(
531
+ '`flexWrap: `wrap`` is not supported with the `VirtualizedList` components.' +
532
+ 'Consider using `numColumns` with `FlatList` instead.',
533
+ );
534
+ this._hasWarned.flexWrap = true;
535
+ }
536
+ }
537
+ }
538
+
539
+ static _createRenderMask(
540
+ props: Props,
541
+ cellsAroundViewport: {first: number, last: number},
542
+ additionalRegions?: ?$ReadOnlyArray<{first: number, last: number}>,
543
+ ): CellRenderMask {
544
+ const itemCount = props.getItemCount(props.data);
545
+
546
+ invariant(
547
+ cellsAroundViewport.first >= 0 &&
548
+ cellsAroundViewport.last >= cellsAroundViewport.first - 1 &&
549
+ cellsAroundViewport.last < itemCount,
550
+ `Invalid cells around viewport "[${cellsAroundViewport.first}, ${cellsAroundViewport.last}]" was passed to VirtualizedList._createRenderMask`,
551
+ );
552
+
553
+ const renderMask = new CellRenderMask(itemCount);
554
+
555
+ if (itemCount > 0) {
556
+ const allRegions = [cellsAroundViewport, ...(additionalRegions ?? [])];
557
+ for (const region of allRegions) {
558
+ renderMask.addCells(region);
559
+ }
560
+
561
+ // The initially rendered cells are retained as part of the
562
+ // "scroll-to-top" optimization
563
+ if (props.initialScrollIndex == null || props.initialScrollIndex <= 0) {
564
+ const initialRegion = VirtualizedList._initialRenderRegion(props);
565
+ renderMask.addCells(initialRegion);
566
+ }
567
+
568
+ // The layout coordinates of sticker headers may be off-screen while the
569
+ // actual header is on-screen. Keep the most recent before the viewport
570
+ // rendered, even if its layout coordinates are not in viewport.
571
+ const stickyIndicesSet = new Set(props.stickyHeaderIndices);
572
+ VirtualizedList._ensureClosestStickyHeader(
573
+ props,
574
+ stickyIndicesSet,
575
+ renderMask,
576
+ cellsAroundViewport.first,
577
+ );
578
+ }
579
+
580
+ return renderMask;
581
+ }
582
+
583
+ static _initialRenderRegion(props: Props): {first: number, last: number} {
584
+ const itemCount = props.getItemCount(props.data);
585
+
586
+ const firstCellIndex = Math.max(
587
+ 0,
588
+ Math.min(itemCount - 1, Math.floor(props.initialScrollIndex ?? 0)),
589
+ );
590
+
591
+ const lastCellIndex =
592
+ Math.min(
593
+ itemCount,
594
+ firstCellIndex + initialNumToRenderOrDefault(props.initialNumToRender),
595
+ ) - 1;
596
+
597
+ return {
598
+ first: firstCellIndex,
599
+ last: lastCellIndex,
600
+ };
601
+ }
602
+
603
+ static _ensureClosestStickyHeader(
604
+ props: Props,
605
+ stickyIndicesSet: Set<number>,
606
+ renderMask: CellRenderMask,
607
+ cellIdx: number,
608
+ ) {
609
+ const stickyOffset = props.ListHeaderComponent ? 1 : 0;
610
+
611
+ for (let itemIdx = cellIdx - 1; itemIdx >= 0; itemIdx--) {
612
+ if (stickyIndicesSet.has(itemIdx + stickyOffset)) {
613
+ renderMask.addCells({first: itemIdx, last: itemIdx});
614
+ break;
615
+ }
616
+ }
617
+ }
618
+
619
+ _adjustCellsAroundViewport(
620
+ props: Props,
621
+ cellsAroundViewport: {first: number, last: number},
622
+ ): {first: number, last: number} {
623
+ const {data, getItemCount} = props;
624
+ const onEndReachedThreshold = onEndReachedThresholdOrDefault(
625
+ props.onEndReachedThreshold,
626
+ );
627
+ const {contentLength, offset, visibleLength} = this._scrollMetrics;
628
+ const distanceFromEnd = contentLength - visibleLength - offset;
629
+
630
+ // Wait until the scroll view metrics have been set up. And until then,
631
+ // we will trust the initialNumToRender suggestion
632
+ if (visibleLength <= 0 || contentLength <= 0) {
633
+ return cellsAroundViewport.last >= getItemCount(data)
634
+ ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
635
+ : cellsAroundViewport;
636
+ }
637
+
638
+ let newCellsAroundViewport: {first: number, last: number};
639
+ if (props.disableVirtualization) {
640
+ const renderAhead =
641
+ distanceFromEnd < onEndReachedThreshold * visibleLength
642
+ ? maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch)
643
+ : 0;
644
+
645
+ newCellsAroundViewport = {
646
+ first: 0,
647
+ last: Math.min(
648
+ cellsAroundViewport.last + renderAhead,
649
+ getItemCount(data) - 1,
650
+ ),
651
+ };
652
+ } else {
653
+ // If we have a non-zero initialScrollIndex and run this before we've scrolled,
654
+ // we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex.
655
+ // So let's wait until we've scrolled the view to the right place. And until then,
656
+ // we will trust the initialScrollIndex suggestion.
657
+
658
+ // Thus, we want to recalculate the windowed render limits if any of the following hold:
659
+ // - initialScrollIndex is undefined or is 0
660
+ // - initialScrollIndex > 0 AND scrolling is complete
661
+ // - initialScrollIndex > 0 AND the end of the list is visible (this handles the case
662
+ // where the list is shorter than the visible area)
663
+ if (
664
+ props.initialScrollIndex &&
665
+ !this._scrollMetrics.offset &&
666
+ Math.abs(distanceFromEnd) >= Number.EPSILON
667
+ ) {
668
+ return cellsAroundViewport.last >= getItemCount(data)
669
+ ? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
670
+ : cellsAroundViewport;
671
+ }
672
+
673
+ newCellsAroundViewport = computeWindowedRenderLimits(
674
+ props,
675
+ maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch),
676
+ windowSizeOrDefault(props.windowSize),
677
+ cellsAroundViewport,
678
+ this.__getFrameMetricsApprox,
679
+ this._scrollMetrics,
680
+ );
681
+ invariant(
682
+ newCellsAroundViewport.last < getItemCount(data),
683
+ 'computeWindowedRenderLimits() should return range in-bounds',
684
+ );
685
+ }
686
+
687
+ if (this._nestedChildLists.size() > 0) {
688
+ // If some cell in the new state has a child list in it, we should only render
689
+ // up through that item, so that we give that list a chance to render.
690
+ // Otherwise there's churn from multiple child lists mounting and un-mounting
691
+ // their items.
692
+
693
+ // Will this prevent rendering if the nested list doesn't realize the end?
694
+ const childIdx = this._findFirstChildWithMore(
695
+ newCellsAroundViewport.first,
696
+ newCellsAroundViewport.last,
697
+ );
698
+
699
+ newCellsAroundViewport.last = childIdx ?? newCellsAroundViewport.last;
700
+ }
701
+
702
+ return newCellsAroundViewport;
703
+ }
704
+
705
+ _findFirstChildWithMore(first: number, last: number): number | null {
706
+ for (let ii = first; ii <= last; ii++) {
707
+ const cellKeyForIndex = this._indicesToKeys.get(ii);
708
+ if (
709
+ cellKeyForIndex != null &&
710
+ this._nestedChildLists.anyInCell(cellKeyForIndex, childList =>
711
+ childList.hasMore(),
712
+ )
713
+ ) {
714
+ return ii;
715
+ }
716
+ }
717
+
718
+ return null;
719
+ }
720
+
721
+ componentDidMount() {
722
+ if (this._isNestedWithSameOrientation()) {
723
+ this.context.registerAsNestedChild({
724
+ ref: this,
725
+ cellKey: this.context.cellKey,
726
+ });
727
+ }
728
+
729
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
730
+ this.setupWebWheelHandler();
731
+ }
732
+
733
+ componentWillUnmount() {
734
+ if (this._isNestedWithSameOrientation()) {
735
+ this.context.unregisterAsNestedChild({ref: this});
736
+ }
737
+ this._updateCellsToRenderBatcher.dispose({abort: true});
738
+ this._viewabilityTuples.forEach(tuple => {
739
+ tuple.viewabilityHelper.dispose();
740
+ });
741
+ this._fillRateHelper.deactivateAndFlush();
742
+
743
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
744
+ this.teardownWebWheelHandler();
745
+ }
746
+
747
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
748
+ setupWebWheelHandler() {
749
+ if (this._scrollRef && this._scrollRef.getScrollableNode) {
750
+ this._scrollRef.getScrollableNode().addEventListener('wheel',
751
+ this.invertedWheelEventHandler
752
+ );
753
+ } else {
754
+ setTimeout(() => this.setupWebWheelHandler(), 50);
755
+ return
756
+ }
757
+ }
758
+
759
+ // REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
760
+ teardownWebWheelHandler() {
761
+ if (this._scrollRef && this._scrollRef.getScrollableNode) {
762
+ this._scrollRef.getScrollableNode().removeEventListener('wheel',
763
+ this.invertedWheelEventHandler
764
+ );
765
+ }
766
+ }
767
+
768
+ static getDerivedStateFromProps(newProps: Props, prevState: State): State {
769
+ // first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
770
+ // sure we're rendering a reasonable range here.
771
+ const itemCount = newProps.getItemCount(newProps.data);
772
+ if (itemCount === prevState.renderMask.numCells()) {
773
+ return prevState;
774
+ }
775
+
776
+ const constrainedCells = VirtualizedList._constrainToItemCount(
777
+ prevState.cellsAroundViewport,
778
+ newProps,
779
+ );
780
+
781
+ return {
782
+ cellsAroundViewport: constrainedCells,
783
+ renderMask: VirtualizedList._createRenderMask(newProps, constrainedCells),
784
+ };
785
+ }
786
+
787
+ _pushCells(
788
+ cells: Array<Object>,
789
+ stickyHeaderIndices: Array<number>,
790
+ stickyIndicesFromProps: Set<number>,
791
+ first: number,
792
+ last: number,
793
+ inversionStyle: ViewStyleProp,
794
+ ) {
795
+ const {
796
+ CellRendererComponent,
797
+ ItemSeparatorComponent,
798
+ ListHeaderComponent,
799
+ ListItemComponent,
800
+ data,
801
+ debug,
802
+ getItem,
803
+ getItemCount,
804
+ getItemLayout,
805
+ horizontal,
806
+ renderItem,
807
+ } = this.props;
808
+ const stickyOffset = ListHeaderComponent ? 1 : 0;
809
+ const end = getItemCount(data) - 1;
810
+ let prevCellKey;
811
+ last = Math.min(end, last);
812
+
813
+ for (let ii = first; ii <= last; ii++) {
814
+ const item = getItem(data, ii);
815
+ const key = this._keyExtractor(item, ii, this.props);
816
+
817
+ this._indicesToKeys.set(ii, key);
818
+ if (stickyIndicesFromProps.has(ii + stickyOffset)) {
819
+ stickyHeaderIndices.push(cells.length);
820
+ }
821
+
822
+ const shouldListenForLayout =
823
+ getItemLayout == null || debug || this._fillRateHelper.enabled();
824
+
825
+ cells.push(
826
+ <CellRenderer
827
+ CellRendererComponent={CellRendererComponent}
828
+ ItemSeparatorComponent={ii < end ? ItemSeparatorComponent : undefined}
829
+ ListItemComponent={ListItemComponent}
830
+ cellKey={key}
831
+ horizontal={horizontal}
832
+ index={ii}
833
+ inversionStyle={inversionStyle}
834
+ item={item}
835
+ key={key}
836
+ prevCellKey={prevCellKey}
837
+ onUpdateSeparators={this._onUpdateSeparators}
838
+ onCellFocusCapture={e => this._onCellFocusCapture(key)}
839
+ onUnmount={this._onCellUnmount}
840
+ ref={ref => {
841
+ this._cellRefs[key] = ref;
842
+ }}
843
+ renderItem={renderItem}
844
+ {...(shouldListenForLayout && {
845
+ onCellLayout: this._onCellLayout,
846
+ })}
847
+ />,
848
+ );
849
+ prevCellKey = key;
850
+ }
851
+ }
852
+
853
+ static _constrainToItemCount(
854
+ cells: {first: number, last: number},
855
+ props: Props,
856
+ ): {first: number, last: number} {
857
+ const itemCount = props.getItemCount(props.data);
858
+ const last = Math.min(itemCount - 1, cells.last);
859
+
860
+ const maxToRenderPerBatch = maxToRenderPerBatchOrDefault(
861
+ props.maxToRenderPerBatch,
862
+ );
863
+
864
+ return {
865
+ first: clamp(0, itemCount - 1 - maxToRenderPerBatch, cells.first),
866
+ last,
867
+ };
868
+ }
869
+
870
+ _onUpdateSeparators = (keys: Array<?string>, newProps: Object) => {
871
+ keys.forEach(key => {
872
+ const ref = key != null && this._cellRefs[key];
873
+ ref && ref.updateSeparatorProps(newProps);
874
+ });
875
+ };
876
+
877
+ _isNestedWithSameOrientation(): boolean {
878
+ const nestedContext = this.context;
879
+ return !!(
880
+ nestedContext &&
881
+ !!nestedContext.horizontal === horizontalOrDefault(this.props.horizontal)
882
+ );
883
+ }
884
+
885
+ _getSpacerKey = (isVertical: boolean): string =>
886
+ isVertical ? 'height' : 'width';
887
+
888
+ _keyExtractor(
889
+ item: Item,
890
+ index: number,
891
+ props: {
892
+ keyExtractor?: ?(item: Item, index: number) => string,
893
+ ...
894
+ },
895
+ // $FlowFixMe[missing-local-annot]
896
+ ) {
897
+ if (props.keyExtractor != null) {
898
+ return props.keyExtractor(item, index);
899
+ }
900
+
901
+ const key = defaultKeyExtractor(item, index);
902
+ if (key === String(index)) {
903
+ _usedIndexForKey = true;
904
+ if (item.type && item.type.displayName) {
905
+ _keylessItemComponentName = item.type.displayName;
906
+ }
907
+ }
908
+ return key;
909
+ }
910
+
911
+ render(): React.Node {
912
+ // Use RLV adapter if layoutProvider prop is provided or if env var enables it
913
+ // const useRLVEngine = this.props.layoutProvider || process.env.RNW_USE_RLV_ENGINE === 'true';
914
+ // if (useRLVEngine) {
915
+ // return <VirtualizedListRLVAdapter {...this.props} />;
916
+ // }
917
+
918
+ this._checkProps(this.props);
919
+ const {ListEmptyComponent, ListFooterComponent, ListHeaderComponent} =
920
+ this.props;
921
+ const {data, horizontal} = this.props;
922
+ const inversionStyle = this.props.inverted
923
+ ? horizontalOrDefault(this.props.horizontal)
924
+ ? styles.horizontallyInverted
925
+ : styles.verticallyInverted
926
+ : null;
927
+ const cells: Array<any | React.Node> = [];
928
+ const stickyIndicesFromProps = new Set(this.props.stickyHeaderIndices);
929
+ const stickyHeaderIndices = [];
930
+
931
+ // 1. Add cell for ListHeaderComponent
932
+ if (ListHeaderComponent) {
933
+ if (stickyIndicesFromProps.has(0)) {
934
+ stickyHeaderIndices.push(0);
935
+ }
936
+ const element = React.isValidElement(ListHeaderComponent) ? (
937
+ ListHeaderComponent
938
+ ) : (
939
+ // $FlowFixMe[not-a-component]
940
+ // $FlowFixMe[incompatible-type-arg]
941
+ <ListHeaderComponent />
942
+ );
943
+ cells.push(
944
+ <VirtualizedListCellContextProvider
945
+ cellKey={this._getCellKey() + '-header'}
946
+ key="$header">
947
+ <View
948
+ onLayout={this._onLayoutHeader}
949
+ style={[
950
+ inversionStyle,
951
+ this.props.ListHeaderComponentStyle,
952
+ ]}>
953
+ {
954
+ // $FlowFixMe[incompatible-type] - Typing ReactNativeComponent revealed errors
955
+ element
956
+ }
957
+ </View>
958
+ </VirtualizedListCellContextProvider>,
959
+ );
960
+ }
961
+
962
+ // 2a. Add a cell for ListEmptyComponent if applicable
963
+ const itemCount = this.props.getItemCount(data);
964
+ if (itemCount === 0 && ListEmptyComponent) {
965
+ const element: React.Element<any> = ((React.isValidElement(
966
+ ListEmptyComponent,
967
+ ) ? (
968
+ ListEmptyComponent
969
+ ) : (
970
+ // $FlowFixMe[not-a-component]
971
+ // $FlowFixMe[incompatible-type-arg]
972
+ <ListEmptyComponent />
973
+ )): any);
974
+ cells.push(
975
+ <VirtualizedListCellContextProvider
976
+ cellKey={this._getCellKey() + '-empty'}
977
+ key="$empty">
978
+ {React.cloneElement(element, {
979
+ onLayout: (event: LayoutEvent) => {
980
+ this._onLayoutEmpty(event);
981
+ if (element.props.onLayout) {
982
+ element.props.onLayout(event);
983
+ }
984
+ },
985
+ style: [inversionStyle, element.props.style],
986
+ })}
987
+ </VirtualizedListCellContextProvider>,
988
+ );
989
+ }
990
+
991
+ // 2b. Add cells and spacers for each item
992
+ if (itemCount > 0) {
993
+ _usedIndexForKey = false;
994
+ _keylessItemComponentName = '';
995
+ const spacerKey = this._getSpacerKey(!horizontal);
996
+
997
+ const renderRegions = this.state.renderMask.enumerateRegions();
998
+ const lastSpacer = findLastWhere(renderRegions, r => r.isSpacer);
999
+
1000
+ for (const section of renderRegions) {
1001
+ if (section.isSpacer) {
1002
+ // Legacy behavior is to avoid spacers when virtualization is
1003
+ // disabled (including head spacers on initial render).
1004
+ if (this.props.disableVirtualization) {
1005
+ continue;
1006
+ }
1007
+
1008
+ // Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to
1009
+ // prevent the user for hyperscrolling into un-measured area because otherwise content will
1010
+ // likely jump around as it renders in above the viewport.
1011
+ const isLastSpacer = section === lastSpacer;
1012
+ const constrainToMeasured = isLastSpacer && !this.props.getItemLayout;
1013
+ const last = constrainToMeasured
1014
+ ? clamp(
1015
+ section.first - 1,
1016
+ section.last,
1017
+ this._highestMeasuredFrameIndex,
1018
+ )
1019
+ : section.last;
1020
+
1021
+ const firstMetrics = this.__getFrameMetricsApprox(
1022
+ section.first,
1023
+ this.props,
1024
+ );
1025
+ const lastMetrics = this.__getFrameMetricsApprox(last, this.props);
1026
+ const spacerSize =
1027
+ lastMetrics.offset + lastMetrics.length - firstMetrics.offset;
1028
+ cells.push(
1029
+ <View
1030
+ key={`$spacer-${section.first}`}
1031
+ style={{[spacerKey]: spacerSize}}
1032
+ />,
1033
+ );
1034
+ } else {
1035
+ this._pushCells(
1036
+ cells,
1037
+ stickyHeaderIndices,
1038
+ stickyIndicesFromProps,
1039
+ section.first,
1040
+ section.last,
1041
+ inversionStyle,
1042
+ );
1043
+ }
1044
+ }
1045
+
1046
+ if (!this._hasWarned.keys && _usedIndexForKey) {
1047
+ console.warn(
1048
+ 'VirtualizedList: missing keys for items, make sure to specify a key or id property on each ' +
1049
+ 'item or provide a custom keyExtractor.',
1050
+ _keylessItemComponentName,
1051
+ );
1052
+ this._hasWarned.keys = true;
1053
+ }
1054
+ }
1055
+
1056
+ // 3. Add cell for ListFooterComponent
1057
+ if (ListFooterComponent) {
1058
+ const element = React.isValidElement(ListFooterComponent) ? (
1059
+ ListFooterComponent
1060
+ ) : (
1061
+ // $FlowFixMe[not-a-component]
1062
+ // $FlowFixMe[incompatible-type-arg]
1063
+ <ListFooterComponent />
1064
+ );
1065
+ cells.push(
1066
+ <VirtualizedListCellContextProvider
1067
+ cellKey={this._getFooterCellKey()}
1068
+ key="$footer">
1069
+ <View
1070
+ onLayout={this._onLayoutFooter}
1071
+ style={[
1072
+ inversionStyle,
1073
+ this.props.ListFooterComponentStyle,
1074
+ ]}>
1075
+ {
1076
+ // $FlowFixMe[incompatible-type] - Typing ReactNativeComponent revealed errors
1077
+ element
1078
+ }
1079
+ </View>
1080
+ </VirtualizedListCellContextProvider>,
1081
+ );
1082
+ }
1083
+
1084
+ // 4. Render the ScrollView
1085
+ const scrollProps = {
1086
+ ...this.props,
1087
+ onContentSizeChange: this._onContentSizeChange,
1088
+ onLayout: this._onLayout,
1089
+ onScroll: this._onScroll,
1090
+ onScrollBeginDrag: this._onScrollBeginDrag,
1091
+ onScrollEndDrag: this._onScrollEndDrag,
1092
+ onMomentumScrollBegin: this._onMomentumScrollBegin,
1093
+ onMomentumScrollEnd: this._onMomentumScrollEnd,
1094
+ scrollEventThrottle: scrollEventThrottleOrDefault(
1095
+ this.props.scrollEventThrottle,
1096
+ ), // TODO: Android support
1097
+ invertStickyHeaders:
1098
+ this.props.invertStickyHeaders !== undefined
1099
+ ? this.props.invertStickyHeaders
1100
+ : this.props.inverted,
1101
+ stickyHeaderIndices,
1102
+ style: inversionStyle
1103
+ ? [inversionStyle, this.props.style]
1104
+ : this.props.style,
1105
+ };
1106
+
1107
+ this._hasMore = this.state.cellsAroundViewport.last < itemCount - 1;
1108
+
1109
+ const trapFocusHorizontal = I18nManager.isRTL
1110
+ ? {
1111
+ trapFocusRight:
1112
+ horizontalOrDefault(this.props.horizontal) &&
1113
+ this.state.cellsAroundViewport.first > 0,
1114
+ trapFocusLeft:
1115
+ horizontalOrDefault(this.props.horizontal) && this._hasMore,
1116
+ }
1117
+ : {
1118
+ trapFocusLeft:
1119
+ horizontalOrDefault(this.props.horizontal) &&
1120
+ this.state.cellsAroundViewport.first > 0,
1121
+ trapFocusRight:
1122
+ horizontalOrDefault(this.props.horizontal) && this._hasMore,
1123
+ };
1124
+
1125
+ const innerRet = (
1126
+ <VirtualizedListContextProvider
1127
+ value={{
1128
+ cellKey: null,
1129
+ getScrollMetrics: this._getScrollMetrics,
1130
+ horizontal: horizontalOrDefault(this.props.horizontal),
1131
+ getOutermostParentListRef: this._getOutermostParentListRef,
1132
+ registerAsNestedChild: this._registerAsNestedChild,
1133
+ unregisterAsNestedChild: this._unregisterAsNestedChild,
1134
+ }}>
1135
+ {Platform.isTV ? (
1136
+ <TVFocusGuideView
1137
+ style={[{flexGrow: 1, flexShrink: 1}, this.props.style]}
1138
+ // $FlowFixMe[incompatible-type] Internal sentinel used to identify VirtualizedList TVFocusGuideView
1139
+ tabIndex={-999} // To uniquely identify this as coming from FlatList
1140
+ {...trapFocusHorizontal}
1141
+ trapFocusUp={
1142
+ !horizontalOrDefault(this.props.horizontal) &&
1143
+ this.state.cellsAroundViewport.first > 0
1144
+ }
1145
+ trapFocusDown={
1146
+ !horizontalOrDefault(this.props.horizontal) && this._hasMore
1147
+ }>
1148
+ {React.cloneElement(
1149
+ (
1150
+ this.props.renderScrollComponent ||
1151
+ this._defaultRenderScrollComponent
1152
+ )(scrollProps),
1153
+ {
1154
+ ref: this._captureScrollRef,
1155
+ },
1156
+ cells,
1157
+ )}
1158
+ </TVFocusGuideView>
1159
+ ) : (
1160
+ React.cloneElement(
1161
+ (
1162
+ this.props.renderScrollComponent ||
1163
+ this._defaultRenderScrollComponent
1164
+ )(scrollProps),
1165
+ {
1166
+ ref: this._captureScrollRef,
1167
+ },
1168
+ cells,
1169
+ )
1170
+ )}
1171
+ </VirtualizedListContextProvider>
1172
+ );
1173
+ let ret: React.Node = innerRet;
1174
+ /* https://github.com/necolas/react-native-web/issues/2239: Re-enable when ScrollView.Context.Consumer is available.
1175
+ if (__DEV__) {
1176
+ ret = (
1177
+ <ScrollView.Context.Consumer>
1178
+ {scrollContext => {
1179
+ if (
1180
+ scrollContext != null &&
1181
+ !scrollContext.horizontal ===
1182
+ !horizontalOrDefault(this.props.horizontal) &&
1183
+ !this._hasWarned.nesting &&
1184
+ this.context == null &&
1185
+ this.props.scrollEnabled !== false
1186
+ ) {
1187
+ // TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170
1188
+ console.error(
1189
+ 'VirtualizedLists should never be nested inside plain ScrollViews with the same ' +
1190
+ 'orientation because it can break windowing and other functionality - use another ' +
1191
+ 'VirtualizedList-backed container instead.',
1192
+ );
1193
+ this._hasWarned.nesting = true;
1194
+ }
1195
+ return innerRet;
1196
+ }}
1197
+ </ScrollView.Context.Consumer>
1198
+ );
1199
+ }*/
1200
+ if (this.props.debug) {
1201
+ return (
1202
+ <View style={styles.debug}>
1203
+ {ret}
1204
+ {this._renderDebugOverlay()}
1205
+ </View>
1206
+ );
1207
+ } else {
1208
+ return ret;
1209
+ }
1210
+ }
1211
+
1212
+ componentDidUpdate(prevProps: Props) {
1213
+ const {data, extraData} = this.props;
1214
+ if (data !== prevProps.data || extraData !== prevProps.extraData) {
1215
+ // clear the viewableIndices cache to also trigger
1216
+ // the onViewableItemsChanged callback with the new data
1217
+ this._viewabilityTuples.forEach(tuple => {
1218
+ tuple.viewabilityHelper.resetViewableIndices();
1219
+ });
1220
+ }
1221
+ // The `this._hiPriInProgress` is guaranteeing a hiPri cell update will only happen
1222
+ // once per fiber update. The `_scheduleCellsToRenderUpdate` will set it to true
1223
+ // if a hiPri update needs to perform. If `componentDidUpdate` is triggered with
1224
+ // `this._hiPriInProgress=true`, means it's triggered by the hiPri update. The
1225
+ // `_scheduleCellsToRenderUpdate` will check this condition and not perform
1226
+ // another hiPri update.
1227
+ const hiPriInProgress = this._hiPriInProgress;
1228
+ this._scheduleCellsToRenderUpdate();
1229
+ // Make sure setting `this._hiPriInProgress` back to false after `componentDidUpdate`
1230
+ // is triggered with `this._hiPriInProgress = true`
1231
+ if (hiPriInProgress) {
1232
+ this._hiPriInProgress = false;
1233
+ }
1234
+ }
1235
+
1236
+ _averageCellLength = 0;
1237
+ _cellRefs: {[string]: null | CellRenderer<any>} = {};
1238
+ _fillRateHelper: FillRateHelper;
1239
+ _frames: {
1240
+ [string]: {
1241
+ inLayout?: boolean,
1242
+ index: number,
1243
+ length: number,
1244
+ offset: number,
1245
+ },
1246
+ } = {};
1247
+ _footerLength = 0;
1248
+ // Used for preventing scrollToIndex from being called multiple times for initialScrollIndex
1249
+ _hasTriggeredInitialScrollToIndex = false;
1250
+ _hasInteracted = false;
1251
+ _hasMore = false;
1252
+ _hasWarned: {[string]: boolean} = {};
1253
+ _headerLength = 0;
1254
+ _hiPriInProgress: boolean = false; // flag to prevent infinite hiPri cell limit update
1255
+ _highestMeasuredFrameIndex = 0;
1256
+ _indicesToKeys: Map<number, string> = new Map();
1257
+ _lastFocusedCellKey: ?string = null;
1258
+ _nestedChildLists: ChildListCollection<VirtualizedList> =
1259
+ new ChildListCollection();
1260
+ _offsetFromParentVirtualizedList: number = 0;
1261
+ _prevParentOffset: number = 0;
1262
+ // $FlowFixMe[missing-local-annot]
1263
+ _scrollMetrics = {
1264
+ contentLength: 0,
1265
+ dOffset: 0,
1266
+ dt: 10,
1267
+ offset: 0,
1268
+ timestamp: 0,
1269
+ velocity: 0,
1270
+ visibleLength: 0,
1271
+ zoomScale: 1,
1272
+ };
1273
+ _scrollRef: ?React.ElementRef<any> = null;
1274
+ _sentStartForContentLength = 0;
1275
+ _sentEndForContentLength = 0;
1276
+ _totalCellLength = 0;
1277
+ _totalCellsMeasured = 0;
1278
+ _updateCellsToRenderBatcher: Batchinator;
1279
+ _viewabilityTuples: Array<ViewabilityHelperCallbackTuple> = [];
1280
+
1281
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
1282
+ * LTI update could not be added via codemod */
1283
+ _captureScrollRef = ref => {
1284
+ this._scrollRef = ref;
1285
+ };
1286
+
1287
+ _computeBlankness() {
1288
+ this._fillRateHelper.computeBlankness(
1289
+ this.props,
1290
+ this.state.cellsAroundViewport,
1291
+ this._scrollMetrics,
1292
+ );
1293
+ }
1294
+
1295
+ /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
1296
+ * LTI update could not be added via codemod */
1297
+ _defaultRenderScrollComponent = props => {
1298
+ const onRefresh = props.onRefresh;
1299
+ if (this._isNestedWithSameOrientation()) {
1300
+ // $FlowFixMe[prop-missing] - Typing ReactNativeComponent revealed errors
1301
+ return <View {...props} />;
1302
+ } else if (onRefresh) {
1303
+ invariant(
1304
+ typeof props.refreshing === 'boolean',
1305
+ '`refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `' +
1306
+ JSON.stringify(props.refreshing ?? 'undefined') +
1307
+ '`',
1308
+ );
1309
+ return (
1310
+ // $FlowFixMe[prop-missing] Invalid prop usage
1311
+ // $FlowFixMe[incompatible-use]
1312
+ <ScrollView
1313
+ {...props}
1314
+ refreshControl={
1315
+ props.refreshControl == null ? (
1316
+ <RefreshControl
1317
+ // $FlowFixMe[incompatible-type]
1318
+ refreshing={props.refreshing}
1319
+ onRefresh={onRefresh}
1320
+ progressViewOffset={props.progressViewOffset}
1321
+ />
1322
+ ) : (
1323
+ props.refreshControl
1324
+ )
1325
+ }
1326
+ />
1327
+ );
1328
+ } else {
1329
+ // $FlowFixMe[prop-missing] Invalid prop usage
1330
+ // $FlowFixMe[incompatible-use]
1331
+ return <ScrollView {...props} />;
1332
+ }
1333
+ };
1334
+
1335
+ _onCellLayout = (e: LayoutEvent, cellKey: string, index: number): void => {
1336
+ const layout = e.nativeEvent.layout;
1337
+ const next = {
1338
+ offset: this._selectOffset(layout),
1339
+ length: this._selectLength(layout),
1340
+ index,
1341
+ inLayout: true,
1342
+ };
1343
+ const curr = this._frames[cellKey];
1344
+ if (
1345
+ !curr ||
1346
+ next.offset !== curr.offset ||
1347
+ next.length !== curr.length ||
1348
+ index !== curr.index
1349
+ ) {
1350
+ this._totalCellLength += next.length - (curr ? curr.length : 0);
1351
+ this._totalCellsMeasured += curr ? 0 : 1;
1352
+ this._averageCellLength =
1353
+ this._totalCellLength / this._totalCellsMeasured;
1354
+ this._frames[cellKey] = next;
1355
+ this._highestMeasuredFrameIndex = Math.max(
1356
+ this._highestMeasuredFrameIndex,
1357
+ index,
1358
+ );
1359
+ this._scheduleCellsToRenderUpdate();
1360
+ } else {
1361
+ this._frames[cellKey].inLayout = true;
1362
+ }
1363
+
1364
+ this._triggerRemeasureForChildListsInCell(cellKey);
1365
+
1366
+ this._computeBlankness();
1367
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1368
+ };
1369
+
1370
+ _onCellFocusCapture(cellKey: string) {
1371
+ this._lastFocusedCellKey = cellKey;
1372
+ this._updateCellsToRender();
1373
+ }
1374
+
1375
+ _onCellUnmount = (cellKey: string) => {
1376
+ delete this._cellRefs[cellKey];
1377
+ const curr = this._frames[cellKey];
1378
+ if (curr) {
1379
+ this._frames[cellKey] = {...curr, inLayout: false};
1380
+ }
1381
+ };
1382
+
1383
+ _triggerRemeasureForChildListsInCell(cellKey: string): void {
1384
+ this._nestedChildLists.forEachInCell(cellKey, childList => {
1385
+ childList.measureLayoutRelativeToContainingList();
1386
+ });
1387
+ }
1388
+
1389
+ measureLayoutRelativeToContainingList(): void {
1390
+ // TODO (T35574538): findNodeHandle sometimes crashes with "Unable to find
1391
+ // node on an unmounted component" during scrolling
1392
+ try {
1393
+ if (!this._scrollRef) {
1394
+ return;
1395
+ }
1396
+ // We are assuming that getOutermostParentListRef().getScrollRef()
1397
+ // is a non-null reference to a ScrollView
1398
+ this._scrollRef.measureLayout(
1399
+ this.context.getOutermostParentListRef().getScrollRef(),
1400
+ (x, y, width, height) => {
1401
+ this._offsetFromParentVirtualizedList = this._selectOffset({x, y});
1402
+ this._scrollMetrics.contentLength = this._selectLength({
1403
+ width,
1404
+ height,
1405
+ });
1406
+ const scrollMetrics = this._convertParentScrollMetrics(
1407
+ this.context.getScrollMetrics(),
1408
+ );
1409
+
1410
+ const metricsChanged =
1411
+ this._scrollMetrics.visibleLength !== scrollMetrics.visibleLength ||
1412
+ this._scrollMetrics.offset !== scrollMetrics.offset;
1413
+
1414
+ if (metricsChanged) {
1415
+ this._scrollMetrics.visibleLength = scrollMetrics.visibleLength;
1416
+ this._scrollMetrics.offset = scrollMetrics.offset;
1417
+
1418
+ // If metrics of the scrollView changed, then we triggered remeasure for child list
1419
+ // to ensure VirtualizedList has the right information.
1420
+ this._nestedChildLists.forEach(childList => {
1421
+ childList.measureLayoutRelativeToContainingList();
1422
+ });
1423
+ }
1424
+ },
1425
+ error => {
1426
+ console.warn(
1427
+ "VirtualizedList: Encountered an error while measuring a list's" +
1428
+ ' offset from its containing VirtualizedList.',
1429
+ );
1430
+ },
1431
+ );
1432
+ } catch (error) {
1433
+ console.warn(
1434
+ 'measureLayoutRelativeToContainingList threw an error',
1435
+ error.stack,
1436
+ );
1437
+ }
1438
+ }
1439
+
1440
+ _onLayout = (e: LayoutEvent) => {
1441
+ if (this._isNestedWithSameOrientation()) {
1442
+ // Need to adjust our scroll metrics to be relative to our containing
1443
+ // VirtualizedList before we can make claims about list item viewability
1444
+ this.measureLayoutRelativeToContainingList();
1445
+ } else {
1446
+ this._scrollMetrics.visibleLength = this._selectLength(
1447
+ e.nativeEvent.layout,
1448
+ );
1449
+ }
1450
+ this.props.onLayout && this.props.onLayout(e);
1451
+ this._scheduleCellsToRenderUpdate();
1452
+ this._maybeCallOnEdgeReached();
1453
+ };
1454
+
1455
+ _onLayoutEmpty = (e: LayoutEvent) => {
1456
+ this.props.onLayout && this.props.onLayout(e);
1457
+ };
1458
+
1459
+ _getFooterCellKey(): string {
1460
+ return this._getCellKey() + '-footer';
1461
+ }
1462
+
1463
+ _onLayoutFooter = (e: LayoutEvent) => {
1464
+ this._triggerRemeasureForChildListsInCell(this._getFooterCellKey());
1465
+ this._footerLength = this._selectLength(e.nativeEvent.layout);
1466
+ };
1467
+
1468
+ _onLayoutHeader = (e: LayoutEvent) => {
1469
+ this._headerLength = this._selectLength(e.nativeEvent.layout);
1470
+ };
1471
+
1472
+ // $FlowFixMe[missing-local-annot]
1473
+ _renderDebugOverlay() {
1474
+ const normalize =
1475
+ this._scrollMetrics.visibleLength /
1476
+ (this._scrollMetrics.contentLength || 1);
1477
+ const framesInLayout = [];
1478
+ const itemCount = this.props.getItemCount(this.props.data);
1479
+ for (let ii = 0; ii < itemCount; ii++) {
1480
+ const frame = this.__getFrameMetricsApprox(ii, this.props);
1481
+ /* $FlowFixMe[prop-missing] (>=0.68.0 site=react_native_fb) This comment
1482
+ * suppresses an error found when Flow v0.68 was deployed. To see the
1483
+ * error delete this comment and run Flow. */
1484
+ if (frame.inLayout) {
1485
+ framesInLayout.push(frame);
1486
+ }
1487
+ }
1488
+ const windowTop = this.__getFrameMetricsApprox(
1489
+ this.state.cellsAroundViewport.first,
1490
+ this.props,
1491
+ ).offset;
1492
+ const frameLast = this.__getFrameMetricsApprox(
1493
+ this.state.cellsAroundViewport.last,
1494
+ this.props,
1495
+ );
1496
+ const windowLen = frameLast.offset + frameLast.length - windowTop;
1497
+ const visTop = this._scrollMetrics.offset;
1498
+ const visLen = this._scrollMetrics.visibleLength;
1499
+
1500
+ return (
1501
+ <View style={[styles.debugOverlayBase, styles.debugOverlay]}>
1502
+ {framesInLayout.map((f, ii) => (
1503
+ <View
1504
+ key={'f' + ii}
1505
+ style={[
1506
+ styles.debugOverlayBase,
1507
+ styles.debugOverlayFrame,
1508
+ {
1509
+ top: f.offset * normalize,
1510
+ height: f.length * normalize,
1511
+ },
1512
+ ]}
1513
+ />
1514
+ ))}
1515
+ <View
1516
+ style={[
1517
+ styles.debugOverlayBase,
1518
+ styles.debugOverlayFrameLast,
1519
+ {
1520
+ top: windowTop * normalize,
1521
+ height: windowLen * normalize,
1522
+ },
1523
+ ]}
1524
+ />
1525
+ <View
1526
+ style={[
1527
+ styles.debugOverlayBase,
1528
+ styles.debugOverlayFrameVis,
1529
+ {
1530
+ top: visTop * normalize,
1531
+ height: visLen * normalize,
1532
+ },
1533
+ ]}
1534
+ />
1535
+ </View>
1536
+ );
1537
+ }
1538
+
1539
+ _selectLength(
1540
+ metrics: $ReadOnly<{
1541
+ height: number,
1542
+ width: number,
1543
+ ...
1544
+ }>,
1545
+ ): number {
1546
+ return !horizontalOrDefault(this.props.horizontal)
1547
+ ? metrics.height
1548
+ : metrics.width;
1549
+ }
1550
+
1551
+ _selectOffset(
1552
+ metrics: $ReadOnly<{
1553
+ x: number,
1554
+ y: number,
1555
+ ...
1556
+ }>,
1557
+ ): number {
1558
+ return !horizontalOrDefault(this.props.horizontal) ? metrics.y : metrics.x;
1559
+ }
1560
+
1561
+ _maybeCallOnEdgeReached() {
1562
+ const {
1563
+ data,
1564
+ getItemCount,
1565
+ onStartReached,
1566
+ onStartReachedThreshold,
1567
+ onEndReached,
1568
+ onEndReachedThreshold,
1569
+ initialScrollIndex,
1570
+ } = this.props;
1571
+ const {contentLength, visibleLength, offset} = this._scrollMetrics;
1572
+ let distanceFromStart = offset;
1573
+ let distanceFromEnd = contentLength - visibleLength - offset;
1574
+
1575
+ // Especially when oERT is zero it's necessary to 'floor' very small distance values to be 0
1576
+ // since debouncing causes us to not fire this event for every single "pixel" we scroll and can thus
1577
+ // be at the edge of the list with a distance approximating 0 but not quite there.
1578
+ if (distanceFromStart < ON_EDGE_REACHED_EPSILON) {
1579
+ distanceFromStart = 0;
1580
+ }
1581
+ if (distanceFromEnd < ON_EDGE_REACHED_EPSILON) {
1582
+ distanceFromEnd = 0;
1583
+ }
1584
+
1585
+ // TODO: T121172172 Look into why we're "defaulting" to a threshold of 2px
1586
+ // when oERT is not present (different from 2 viewports used elsewhere)
1587
+ const DEFAULT_THRESHOLD_PX = 2;
1588
+
1589
+ const startThreshold =
1590
+ onStartReachedThreshold != null
1591
+ ? onStartReachedThreshold * visibleLength
1592
+ : DEFAULT_THRESHOLD_PX;
1593
+ const endThreshold =
1594
+ onEndReachedThreshold != null
1595
+ ? onEndReachedThreshold * visibleLength
1596
+ : DEFAULT_THRESHOLD_PX;
1597
+ const isWithinStartThreshold = distanceFromStart <= startThreshold;
1598
+ const isWithinEndThreshold = distanceFromEnd <= endThreshold;
1599
+
1600
+ // First check if the user just scrolled within the end threshold
1601
+ // and call onEndReached only once for a given content length,
1602
+ // and only if onStartReached is not being executed
1603
+ if (
1604
+ onEndReached &&
1605
+ this.state.cellsAroundViewport.last === getItemCount(data) - 1 &&
1606
+ isWithinEndThreshold &&
1607
+ this._scrollMetrics.contentLength !== this._sentEndForContentLength
1608
+ ) {
1609
+ this._sentEndForContentLength = this._scrollMetrics.contentLength;
1610
+ onEndReached({distanceFromEnd});
1611
+ }
1612
+
1613
+ // Next check if the user just scrolled within the start threshold
1614
+ // and call onStartReached only once for a given content length,
1615
+ // and only if onEndReached is not being executed
1616
+ else if (
1617
+ onStartReached != null &&
1618
+ this.state.cellsAroundViewport.first === 0 &&
1619
+ isWithinStartThreshold &&
1620
+ this._scrollMetrics.contentLength !== this._sentStartForContentLength
1621
+ ) {
1622
+ // On initial mount when using initialScrollIndex the offset will be 0 initially
1623
+ // and will trigger an unexpected onStartReached. To avoid this we can use
1624
+ // timestamp to differentiate between the initial scroll metrics and when we actually
1625
+ // received the first scroll event.
1626
+ if (!initialScrollIndex || this._scrollMetrics.timestamp !== 0) {
1627
+ this._sentStartForContentLength = this._scrollMetrics.contentLength;
1628
+ onStartReached({distanceFromStart});
1629
+ }
1630
+ }
1631
+
1632
+ // If the user scrolls away from the start or end and back again,
1633
+ // cause onStartReached or onEndReached to be triggered again
1634
+ else {
1635
+ this._sentStartForContentLength = isWithinStartThreshold
1636
+ ? this._sentStartForContentLength
1637
+ : 0;
1638
+ this._sentEndForContentLength = isWithinEndThreshold
1639
+ ? this._sentEndForContentLength
1640
+ : 0;
1641
+ }
1642
+ }
1643
+
1644
+ _onContentSizeChange = (width: number, height: number) => {
1645
+ if (
1646
+ width > 0 &&
1647
+ height > 0 &&
1648
+ this.props.initialScrollIndex != null &&
1649
+ this.props.initialScrollIndex > 0 &&
1650
+ !this._hasTriggeredInitialScrollToIndex
1651
+ ) {
1652
+ if (this.props.contentOffset == null) {
1653
+ if (
1654
+ this.props.initialScrollIndex <
1655
+ this.props.getItemCount(this.props.data)
1656
+ ) {
1657
+ this.scrollToIndex({
1658
+ animated: false,
1659
+ index: nullthrows(this.props.initialScrollIndex),
1660
+ });
1661
+ } else {
1662
+ this.scrollToEnd({animated: false});
1663
+ }
1664
+ }
1665
+ this._hasTriggeredInitialScrollToIndex = true;
1666
+ }
1667
+ if (this.props.onContentSizeChange) {
1668
+ this.props.onContentSizeChange(width, height);
1669
+ }
1670
+ this._scrollMetrics.contentLength = this._selectLength({height, width});
1671
+ this._scheduleCellsToRenderUpdate();
1672
+ this._maybeCallOnEdgeReached();
1673
+ };
1674
+
1675
+ /* Translates metrics from a scroll event in a parent VirtualizedList into
1676
+ * coordinates relative to the child list.
1677
+ */
1678
+ _convertParentScrollMetrics = (metrics: {
1679
+ visibleLength: number,
1680
+ offset: number,
1681
+ ...
1682
+ }): $FlowFixMe => {
1683
+ // Offset of the top of the nested list relative to the top of its parent's viewport
1684
+ const offset = metrics.offset - this._offsetFromParentVirtualizedList;
1685
+ // Child's visible length is the same as its parent's
1686
+ const visibleLength = metrics.visibleLength;
1687
+ const dOffset = offset - this._scrollMetrics.offset;
1688
+ const contentLength = this._scrollMetrics.contentLength;
1689
+
1690
+ return {
1691
+ visibleLength,
1692
+ contentLength,
1693
+ offset,
1694
+ dOffset,
1695
+ };
1696
+ };
1697
+
1698
+ _onScroll = (e: Object) => {
1699
+ this._nestedChildLists.forEach(childList => {
1700
+ childList._onScroll(e);
1701
+ });
1702
+ if (this.props.onScroll) {
1703
+ this.props.onScroll(e);
1704
+ }
1705
+ const timestamp = e.timeStamp;
1706
+ let visibleLength = this._selectLength(e.nativeEvent.layoutMeasurement);
1707
+ let contentLength = this._selectLength(e.nativeEvent.contentSize);
1708
+ let offset = this._selectOffset(e.nativeEvent.contentOffset);
1709
+ let dOffset = offset - this._scrollMetrics.offset;
1710
+
1711
+ if (this._isNestedWithSameOrientation()) {
1712
+ if (this._scrollMetrics.contentLength === 0) {
1713
+ // Ignore scroll events until onLayout has been called and we
1714
+ // know our offset from our offset from our parent
1715
+ return;
1716
+ }
1717
+ ({visibleLength, contentLength, offset, dOffset} =
1718
+ this._convertParentScrollMetrics({
1719
+ visibleLength,
1720
+ offset,
1721
+ }));
1722
+ }
1723
+
1724
+ const dt = this._scrollMetrics.timestamp
1725
+ ? Math.max(1, timestamp - this._scrollMetrics.timestamp)
1726
+ : 1;
1727
+ const velocity = dOffset / dt;
1728
+
1729
+ if (
1730
+ dt > 500 &&
1731
+ this._scrollMetrics.dt > 500 &&
1732
+ contentLength > 5 * visibleLength &&
1733
+ !this._hasWarned.perf
1734
+ ) {
1735
+ infoLog(
1736
+ 'VirtualizedList: You have a large list that is slow to update - make sure your ' +
1737
+ 'renderItem function renders components that follow React performance best practices ' +
1738
+ 'like PureComponent, shouldComponentUpdate, etc.',
1739
+ {dt, prevDt: this._scrollMetrics.dt, contentLength},
1740
+ );
1741
+ this._hasWarned.perf = true;
1742
+ }
1743
+
1744
+ // For invalid negative values (w/ RTL), set this to 1.
1745
+ const zoomScale = e.nativeEvent.zoomScale < 0 ? 1 : e.nativeEvent.zoomScale;
1746
+ this._scrollMetrics = {
1747
+ contentLength,
1748
+ dt,
1749
+ dOffset,
1750
+ offset,
1751
+ timestamp,
1752
+ velocity,
1753
+ visibleLength,
1754
+ zoomScale,
1755
+ };
1756
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1757
+ if (!this.props) {
1758
+ return;
1759
+ }
1760
+ this._maybeCallOnEdgeReached();
1761
+ if (velocity !== 0) {
1762
+ this._fillRateHelper.activate();
1763
+ }
1764
+ this._computeBlankness();
1765
+ this._scheduleCellsToRenderUpdate();
1766
+ };
1767
+
1768
+ _scheduleCellsToRenderUpdate() {
1769
+ const {first, last} = this.state.cellsAroundViewport;
1770
+ const {offset, visibleLength, velocity} = this._scrollMetrics;
1771
+ const itemCount = this.props.getItemCount(this.props.data);
1772
+ let hiPri = false;
1773
+ const onStartReachedThreshold = onStartReachedThresholdOrDefault(
1774
+ this.props.onStartReachedThreshold,
1775
+ );
1776
+ const onEndReachedThreshold = onEndReachedThresholdOrDefault(
1777
+ this.props.onEndReachedThreshold,
1778
+ );
1779
+ // Mark as high priority if we're close to the start of the first item
1780
+ // But only if there are items before the first rendered item
1781
+ if (first > 0) {
1782
+ const distTop =
1783
+ offset - this.__getFrameMetricsApprox(first, this.props).offset;
1784
+ hiPri =
1785
+ distTop < 0 ||
1786
+ (velocity < -2 &&
1787
+ distTop <
1788
+ getScrollingThreshold(onStartReachedThreshold, visibleLength));
1789
+ }
1790
+ // Mark as high priority if we're close to the end of the last item
1791
+ // But only if there are items after the last rendered item
1792
+ if (!hiPri && last >= 0 && last < itemCount - 1) {
1793
+ const distBottom =
1794
+ this.__getFrameMetricsApprox(last, this.props).offset -
1795
+ (offset + visibleLength);
1796
+ hiPri =
1797
+ distBottom < 0 ||
1798
+ (velocity > 2 &&
1799
+ distBottom <
1800
+ getScrollingThreshold(onEndReachedThreshold, visibleLength));
1801
+ }
1802
+ // Only trigger high-priority updates if we've actually rendered cells,
1803
+ // and with that size estimate, accurately compute how many cells we should render.
1804
+ // Otherwise, it would just render as many cells as it can (of zero dimension),
1805
+ // each time through attempting to render more (limited by maxToRenderPerBatch),
1806
+ // starving the renderer from actually laying out the objects and computing _averageCellLength.
1807
+ // If this is triggered in an `componentDidUpdate` followed by a hiPri cellToRenderUpdate
1808
+ // We shouldn't do another hipri cellToRenderUpdate
1809
+ if (
1810
+ hiPri &&
1811
+ (this._averageCellLength || this.props.getItemLayout) &&
1812
+ !this._hiPriInProgress
1813
+ ) {
1814
+ this._hiPriInProgress = true;
1815
+ // Don't worry about interactions when scrolling quickly; focus on filling content as fast
1816
+ // as possible.
1817
+ this._updateCellsToRenderBatcher.dispose({abort: true});
1818
+ this._updateCellsToRender();
1819
+ return;
1820
+ } else {
1821
+ this._updateCellsToRenderBatcher.schedule();
1822
+ }
1823
+ }
1824
+
1825
+ _onScrollBeginDrag = (e: ScrollEvent): void => {
1826
+ this._nestedChildLists.forEach(childList => {
1827
+ childList._onScrollBeginDrag(e);
1828
+ });
1829
+ this._viewabilityTuples.forEach(tuple => {
1830
+ tuple.viewabilityHelper.recordInteraction();
1831
+ });
1832
+ this._hasInteracted = true;
1833
+ this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
1834
+ };
1835
+
1836
+ _onScrollEndDrag = (e: ScrollEvent): void => {
1837
+ this._nestedChildLists.forEach(childList => {
1838
+ childList._onScrollEndDrag(e);
1839
+ });
1840
+ const {velocity} = e.nativeEvent;
1841
+ if (velocity) {
1842
+ this._scrollMetrics.velocity = this._selectOffset(velocity);
1843
+ }
1844
+ this._computeBlankness();
1845
+ this.props.onScrollEndDrag && this.props.onScrollEndDrag(e);
1846
+ };
1847
+
1848
+ _onMomentumScrollBegin = (e: ScrollEvent): void => {
1849
+ this._nestedChildLists.forEach(childList => {
1850
+ childList._onMomentumScrollBegin(e);
1851
+ });
1852
+ this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
1853
+ };
1854
+
1855
+ _onMomentumScrollEnd = (e: ScrollEvent): void => {
1856
+ this._nestedChildLists.forEach(childList => {
1857
+ childList._onMomentumScrollEnd(e);
1858
+ });
1859
+ this._scrollMetrics.velocity = 0;
1860
+ this._computeBlankness();
1861
+ this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e);
1862
+ };
1863
+
1864
+ _updateCellsToRender = () => {
1865
+ this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1866
+
1867
+ this.setState((state, props) => {
1868
+ const cellsAroundViewport = this._adjustCellsAroundViewport(
1869
+ props,
1870
+ state.cellsAroundViewport,
1871
+ );
1872
+ const renderMask = VirtualizedList._createRenderMask(
1873
+ props,
1874
+ cellsAroundViewport,
1875
+ this._getNonViewportRenderRegions(props),
1876
+ );
1877
+
1878
+ if (
1879
+ cellsAroundViewport.first === state.cellsAroundViewport.first &&
1880
+ cellsAroundViewport.last === state.cellsAroundViewport.last &&
1881
+ renderMask.equals(state.renderMask)
1882
+ ) {
1883
+ return null;
1884
+ }
1885
+
1886
+ return {cellsAroundViewport, renderMask};
1887
+ });
1888
+ };
1889
+
1890
+ _createViewToken = (
1891
+ index: number,
1892
+ isViewable: boolean,
1893
+ props: FrameMetricProps,
1894
+ // $FlowFixMe[missing-local-annot]
1895
+ ) => {
1896
+ const {data, getItem} = props;
1897
+ const item = getItem(data, index);
1898
+ return {
1899
+ index,
1900
+ item,
1901
+ key: this._keyExtractor(item, index, props),
1902
+ isViewable,
1903
+ };
1904
+ };
1905
+
1906
+ /**
1907
+ * Gets an approximate offset to an item at a given index. Supports
1908
+ * fractional indices.
1909
+ */
1910
+ _getOffsetApprox = (index: number, props: FrameMetricProps): number => {
1911
+ if (Number.isInteger(index)) {
1912
+ return this.__getFrameMetricsApprox(index, props).offset;
1913
+ } else {
1914
+ const frameMetrics = this.__getFrameMetricsApprox(
1915
+ Math.floor(index),
1916
+ props,
1917
+ );
1918
+ const remainder = index - Math.floor(index);
1919
+ return frameMetrics.offset + remainder * frameMetrics.length;
1920
+ }
1921
+ };
1922
+
1923
+ __getFrameMetricsApprox: (
1924
+ index: number,
1925
+ props: FrameMetricProps,
1926
+ ) => {
1927
+ length: number,
1928
+ offset: number,
1929
+ ...
1930
+ } = (index, props) => {
1931
+ const frame = this._getFrameMetrics(index, props);
1932
+ if (frame && frame.index === index) {
1933
+ // check for invalid frames due to row re-ordering
1934
+ return frame;
1935
+ } else {
1936
+ const {data, getItemCount, getItemLayout} = props;
1937
+ invariant(
1938
+ index >= 0 && index < getItemCount(data),
1939
+ 'Tried to get frame for out of range index ' + index,
1940
+ );
1941
+ invariant(
1942
+ !getItemLayout,
1943
+ 'Should not have to estimate frames when a measurement metrics function is provided',
1944
+ );
1945
+ return {
1946
+ length: this._averageCellLength,
1947
+ offset: this._averageCellLength * index,
1948
+ };
1949
+ }
1950
+ };
1951
+
1952
+ _getFrameMetrics = (
1953
+ index: number,
1954
+ props: FrameMetricProps,
1955
+ ): ?{
1956
+ length: number,
1957
+ offset: number,
1958
+ index: number,
1959
+ inLayout?: boolean,
1960
+ ...
1961
+ } => {
1962
+ const {data, getItem, getItemCount, getItemLayout} = props;
1963
+ invariant(
1964
+ index >= 0 && index < getItemCount(data),
1965
+ 'Tried to get frame for out of range index ' + index,
1966
+ );
1967
+ const item = getItem(data, index);
1968
+ const frame = this._frames[this._keyExtractor(item, index, props)];
1969
+ if (!frame || frame.index !== index) {
1970
+ if (getItemLayout) {
1971
+ /* $FlowFixMe[prop-missing] (>=0.63.0 site=react_native_fb) This comment
1972
+ * suppresses an error found when Flow v0.63 was deployed. To see the error
1973
+ * delete this comment and run Flow. */
1974
+ return getItemLayout(data, index);
1975
+ }
1976
+ }
1977
+ return frame;
1978
+ };
1979
+
1980
+ _getNonViewportRenderRegions = (
1981
+ props: FrameMetricProps,
1982
+ ): $ReadOnlyArray<{
1983
+ first: number,
1984
+ last: number,
1985
+ }> => {
1986
+ // Keep a viewport's worth of content around the last focused cell to allow
1987
+ // random navigation around it without any blanking. E.g. tabbing from one
1988
+ // focused item out of viewport to another.
1989
+ if (
1990
+ !(this._lastFocusedCellKey && this._cellRefs[this._lastFocusedCellKey])
1991
+ ) {
1992
+ return [];
1993
+ }
1994
+
1995
+ const lastFocusedCellRenderer = this._cellRefs[this._lastFocusedCellKey];
1996
+ const focusedCellIndex = lastFocusedCellRenderer.props.index;
1997
+ const itemCount = props.getItemCount(props.data);
1998
+
1999
+ // The last cell we rendered may be at a new index. Bail if we don't know
2000
+ // where it is.
2001
+ if (
2002
+ focusedCellIndex >= itemCount ||
2003
+ this._keyExtractor(
2004
+ props.getItem(props.data, focusedCellIndex),
2005
+ focusedCellIndex,
2006
+ props,
2007
+ ) !== this._lastFocusedCellKey
2008
+ ) {
2009
+ return [];
2010
+ }
2011
+
2012
+ let first = focusedCellIndex;
2013
+ let heightOfCellsBeforeFocused = 0;
2014
+ for (
2015
+ let i = first - 1;
2016
+ i >= 0 && heightOfCellsBeforeFocused < this._scrollMetrics.visibleLength;
2017
+ i--
2018
+ ) {
2019
+ first--;
2020
+ heightOfCellsBeforeFocused += this.__getFrameMetricsApprox(
2021
+ i,
2022
+ props,
2023
+ ).length;
2024
+ }
2025
+
2026
+ let last = focusedCellIndex;
2027
+ let heightOfCellsAfterFocused = 0;
2028
+ for (
2029
+ let i = last + 1;
2030
+ i < itemCount &&
2031
+ heightOfCellsAfterFocused < this._scrollMetrics.visibleLength;
2032
+ i++
2033
+ ) {
2034
+ last++;
2035
+ heightOfCellsAfterFocused += this.__getFrameMetricsApprox(
2036
+ i,
2037
+ props,
2038
+ ).length;
2039
+ }
2040
+
2041
+ return [{first, last}];
2042
+ };
2043
+
2044
+ _updateViewableItems(
2045
+ props: FrameMetricProps,
2046
+ cellsAroundViewport: {first: number, last: number},
2047
+ ) {
2048
+ this._viewabilityTuples.forEach(tuple => {
2049
+ tuple.viewabilityHelper.onUpdate(
2050
+ props,
2051
+ this._scrollMetrics.offset,
2052
+ this._scrollMetrics.visibleLength,
2053
+ this._getFrameMetrics,
2054
+ this._createViewToken,
2055
+ tuple.onViewableItemsChanged,
2056
+ cellsAroundViewport,
2057
+ );
2058
+ });
2059
+ }
2060
+ }
2061
+
2062
+ const styles = StyleSheet.create({
2063
+ verticallyInverted: {
2064
+ transform: 'scaleY(-1)',
2065
+ },
2066
+ horizontallyInverted: {
2067
+ transform: 'scaleX(-1)',
2068
+ },
2069
+ debug: {
2070
+ flex: 1,
2071
+ },
2072
+ debugOverlayBase: {
2073
+ position: 'absolute',
2074
+ top: 0,
2075
+ right: 0,
2076
+ },
2077
+ debugOverlay: {
2078
+ bottom: 0,
2079
+ width: 20,
2080
+ borderColor: 'blue',
2081
+ borderWidth: 1,
2082
+ },
2083
+ debugOverlayFrame: {
2084
+ left: 0,
2085
+ backgroundColor: 'orange',
2086
+ },
2087
+ debugOverlayFrameLast: {
2088
+ left: 0,
2089
+ borderColor: 'green',
2090
+ borderWidth: 2,
2091
+ },
2092
+ debugOverlayFrameVis: {
2093
+ left: 0,
2094
+ borderColor: 'red',
2095
+ borderWidth: 2,
2096
+ },
2097
+ });
2098
+
2099
+ export default VirtualizedList;