@react-native-ohos/flash-list 1.8.3 → 2.1.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. package/LICENSE +1 -1
  2. package/README.OpenSource +1 -1
  3. package/dist/AnimatedFlashList.d.ts +4 -28
  4. package/dist/AnimatedFlashList.d.ts.map +1 -1
  5. package/dist/AnimatedFlashList.js +5 -30
  6. package/dist/AnimatedFlashList.js.map +1 -1
  7. package/dist/FlashList.d.ts +1 -179
  8. package/dist/FlashList.d.ts.map +1 -1
  9. package/dist/FlashList.js +1 -599
  10. package/dist/FlashList.js.map +1 -1
  11. package/dist/FlashListProps.d.ts +285 -278
  12. package/dist/FlashListProps.d.ts.map +1 -1
  13. package/dist/FlashListProps.js +5 -31
  14. package/dist/FlashListProps.js.map +1 -1
  15. package/dist/FlashListRef.d.ts +305 -0
  16. package/dist/FlashListRef.d.ts.map +1 -0
  17. package/dist/FlashListRef.js +2 -0
  18. package/dist/FlashListRef.js.map +1 -0
  19. package/dist/benchmark/AutoScrollHelper.d.ts +17 -40
  20. package/dist/benchmark/AutoScrollHelper.d.ts.map +1 -1
  21. package/dist/benchmark/AutoScrollHelper.js +59 -90
  22. package/dist/benchmark/AutoScrollHelper.js.map +1 -1
  23. package/dist/benchmark/JSFPSMonitor.d.ts +22 -45
  24. package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
  25. package/dist/benchmark/JSFPSMonitor.js +59 -87
  26. package/dist/benchmark/JSFPSMonitor.js.map +1 -1
  27. package/dist/benchmark/roundToDecimalPlaces.d.ts +1 -24
  28. package/dist/benchmark/roundToDecimalPlaces.d.ts.map +1 -1
  29. package/dist/benchmark/roundToDecimalPlaces.js +4 -31
  30. package/dist/benchmark/roundToDecimalPlaces.js.map +1 -1
  31. package/dist/benchmark/useBenchmark.d.ts +40 -57
  32. package/dist/benchmark/useBenchmark.d.ts.map +1 -1
  33. package/dist/benchmark/useBenchmark.js +119 -189
  34. package/dist/benchmark/useBenchmark.js.map +1 -1
  35. package/dist/benchmark/useDataMultiplier.d.ts +8 -31
  36. package/dist/benchmark/useDataMultiplier.d.ts.map +1 -1
  37. package/dist/benchmark/useDataMultiplier.js +19 -47
  38. package/dist/benchmark/useDataMultiplier.js.map +1 -1
  39. package/dist/benchmark/useFlatListBenchmark.d.ts +14 -35
  40. package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
  41. package/dist/benchmark/useFlatListBenchmark.js +92 -122
  42. package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
  43. package/dist/errors/ErrorMessages.d.ts +16 -0
  44. package/dist/errors/ErrorMessages.d.ts.map +1 -0
  45. package/dist/errors/ErrorMessages.js +16 -0
  46. package/dist/errors/ErrorMessages.js.map +1 -0
  47. package/dist/errors/WarningMessages.d.ts +6 -0
  48. package/dist/errors/WarningMessages.d.ts.map +1 -0
  49. package/dist/errors/WarningMessages.js +7 -0
  50. package/dist/errors/WarningMessages.js.map +1 -0
  51. package/dist/index.d.ts +15 -36
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +19 -54
  54. package/dist/index.js.map +1 -1
  55. package/dist/isNewArch.d.ts +2 -0
  56. package/dist/isNewArch.d.ts.map +1 -0
  57. package/dist/isNewArch.js +22 -0
  58. package/dist/isNewArch.js.map +1 -0
  59. package/dist/native/config/PlatformHelper.android.d.ts +6 -48
  60. package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
  61. package/dist/native/config/PlatformHelper.android.js +6 -45
  62. package/dist/native/config/PlatformHelper.android.js.map +1 -1
  63. package/dist/native/config/PlatformHelper.d.ts +6 -48
  64. package/dist/native/config/PlatformHelper.d.ts.map +1 -1
  65. package/dist/native/config/PlatformHelper.harmony.d.ts +29 -48
  66. package/dist/native/config/PlatformHelper.harmony.d.ts.map +1 -1
  67. package/dist/native/config/PlatformHelper.harmony.js +29 -44
  68. package/dist/native/config/PlatformHelper.harmony.js.map +1 -1
  69. package/dist/native/config/PlatformHelper.ios.d.ts +6 -48
  70. package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
  71. package/dist/native/config/PlatformHelper.ios.js +6 -44
  72. package/dist/native/config/PlatformHelper.ios.js.map +1 -1
  73. package/dist/native/config/PlatformHelper.js +6 -45
  74. package/dist/native/config/PlatformHelper.js.map +1 -1
  75. package/dist/native/config/PlatformHelper.web.d.ts +6 -49
  76. package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
  77. package/dist/native/config/PlatformHelper.web.js +6 -47
  78. package/dist/native/config/PlatformHelper.web.js.map +1 -1
  79. package/dist/recyclerview/LayoutCommitObserver.d.ts +12 -0
  80. package/dist/recyclerview/LayoutCommitObserver.d.ts.map +1 -0
  81. package/dist/recyclerview/LayoutCommitObserver.js +58 -0
  82. package/dist/recyclerview/LayoutCommitObserver.js.map +1 -0
  83. package/dist/recyclerview/RecyclerView.d.ts +13 -0
  84. package/dist/recyclerview/RecyclerView.d.ts.map +1 -0
  85. package/dist/recyclerview/RecyclerView.js +368 -0
  86. package/dist/recyclerview/RecyclerView.js.map +1 -0
  87. package/dist/recyclerview/RecyclerViewContextProvider.d.ts +46 -0
  88. package/dist/recyclerview/RecyclerViewContextProvider.d.ts.map +1 -0
  89. package/dist/recyclerview/RecyclerViewContextProvider.js +10 -0
  90. package/dist/recyclerview/RecyclerViewContextProvider.js.map +1 -0
  91. package/dist/recyclerview/RecyclerViewManager.d.ts +78 -0
  92. package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -0
  93. package/dist/recyclerview/RecyclerViewManager.js +343 -0
  94. package/dist/recyclerview/RecyclerViewManager.js.map +1 -0
  95. package/dist/recyclerview/RecyclerViewProps.d.ts +2 -0
  96. package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -0
  97. package/dist/recyclerview/RecyclerViewProps.js +2 -0
  98. package/dist/recyclerview/RecyclerViewProps.js.map +1 -0
  99. package/dist/recyclerview/RenderStackManager.d.ts +86 -0
  100. package/dist/recyclerview/RenderStackManager.d.ts.map +1 -0
  101. package/dist/recyclerview/RenderStackManager.js +252 -0
  102. package/dist/recyclerview/RenderStackManager.js.map +1 -0
  103. package/dist/recyclerview/ViewHolder.d.ts +45 -0
  104. package/dist/recyclerview/ViewHolder.d.ts.map +1 -0
  105. package/dist/recyclerview/ViewHolder.js +94 -0
  106. package/dist/recyclerview/ViewHolder.js.map +1 -0
  107. package/dist/recyclerview/ViewHolderCollection.d.ts +63 -0
  108. package/dist/recyclerview/ViewHolderCollection.d.ts.map +1 -0
  109. package/dist/recyclerview/ViewHolderCollection.js +87 -0
  110. package/dist/recyclerview/ViewHolderCollection.js.map +1 -0
  111. package/dist/recyclerview/components/CompatScroller.d.ts +7 -0
  112. package/dist/recyclerview/components/CompatScroller.d.ts.map +1 -0
  113. package/dist/recyclerview/components/CompatScroller.js +7 -0
  114. package/dist/recyclerview/components/CompatScroller.js.map +1 -0
  115. package/dist/recyclerview/components/CompatView.d.ts +7 -0
  116. package/dist/recyclerview/components/CompatView.d.ts.map +1 -0
  117. package/dist/recyclerview/components/CompatView.js +7 -0
  118. package/dist/recyclerview/components/CompatView.js.map +1 -0
  119. package/dist/recyclerview/components/ScrollAnchor.d.ts +29 -0
  120. package/dist/recyclerview/components/ScrollAnchor.d.ts.map +1 -0
  121. package/dist/recyclerview/components/ScrollAnchor.js +33 -0
  122. package/dist/recyclerview/components/ScrollAnchor.js.map +1 -0
  123. package/dist/recyclerview/components/StickyHeaders.d.ts +38 -0
  124. package/dist/recyclerview/components/StickyHeaders.d.ts.map +1 -0
  125. package/dist/recyclerview/components/StickyHeaders.js +112 -0
  126. package/dist/recyclerview/components/StickyHeaders.js.map +1 -0
  127. package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts +51 -0
  128. package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts.map +1 -0
  129. package/dist/recyclerview/helpers/ConsecutiveNumbers.js +95 -0
  130. package/dist/recyclerview/helpers/ConsecutiveNumbers.js.map +1 -0
  131. package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts +105 -0
  132. package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts.map +1 -0
  133. package/dist/recyclerview/helpers/EngagedIndicesTracker.js +202 -0
  134. package/dist/recyclerview/helpers/EngagedIndicesTracker.js.map +1 -0
  135. package/dist/recyclerview/helpers/RenderTimeTracker.d.ts +14 -0
  136. package/dist/recyclerview/helpers/RenderTimeTracker.d.ts.map +1 -0
  137. package/dist/recyclerview/helpers/RenderTimeTracker.js +44 -0
  138. package/dist/recyclerview/helpers/RenderTimeTracker.js.map +1 -0
  139. package/dist/recyclerview/helpers/VelocityTracker.d.ts +29 -0
  140. package/dist/recyclerview/helpers/VelocityTracker.d.ts.map +1 -0
  141. package/dist/recyclerview/helpers/VelocityTracker.js +64 -0
  142. package/dist/recyclerview/helpers/VelocityTracker.js.map +1 -0
  143. package/dist/recyclerview/hooks/useBoundDetection.d.ts +17 -0
  144. package/dist/recyclerview/hooks/useBoundDetection.d.ts.map +1 -0
  145. package/dist/recyclerview/hooks/useBoundDetection.js +132 -0
  146. package/dist/recyclerview/hooks/useBoundDetection.js.map +1 -0
  147. package/dist/recyclerview/hooks/useLayoutState.d.ts +14 -0
  148. package/dist/recyclerview/hooks/useLayoutState.d.ts.map +1 -0
  149. package/dist/recyclerview/hooks/useLayoutState.js +38 -0
  150. package/dist/recyclerview/hooks/useLayoutState.js.map +1 -0
  151. package/dist/recyclerview/hooks/useMappingHelper.d.ts +9 -0
  152. package/dist/recyclerview/hooks/useMappingHelper.d.ts.map +1 -0
  153. package/dist/recyclerview/hooks/useMappingHelper.js +15 -0
  154. package/dist/recyclerview/hooks/useMappingHelper.js.map +1 -0
  155. package/dist/recyclerview/hooks/useOnLoad.d.ts +25 -0
  156. package/dist/recyclerview/hooks/useOnLoad.d.ts.map +1 -0
  157. package/dist/recyclerview/hooks/useOnLoad.js +67 -0
  158. package/dist/recyclerview/hooks/useOnLoad.js.map +1 -0
  159. package/dist/recyclerview/hooks/useRecyclerViewController.d.ts +28 -0
  160. package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -0
  161. package/dist/recyclerview/hooks/useRecyclerViewController.js +507 -0
  162. package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -0
  163. package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts +8 -0
  164. package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts.map +1 -0
  165. package/dist/recyclerview/hooks/useRecyclerViewManager.js +32 -0
  166. package/dist/recyclerview/hooks/useRecyclerViewManager.js.map +1 -0
  167. package/dist/recyclerview/hooks/useRecyclingState.d.ts +18 -0
  168. package/dist/recyclerview/hooks/useRecyclingState.d.ts.map +1 -0
  169. package/dist/recyclerview/hooks/useRecyclingState.js +49 -0
  170. package/dist/recyclerview/hooks/useRecyclingState.js.map +1 -0
  171. package/dist/recyclerview/hooks/useSecondaryProps.d.ts +27 -0
  172. package/dist/recyclerview/hooks/useSecondaryProps.d.ts.map +1 -0
  173. package/dist/recyclerview/hooks/useSecondaryProps.js +90 -0
  174. package/dist/recyclerview/hooks/useSecondaryProps.js.map +1 -0
  175. package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts +15 -0
  176. package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts.map +1 -0
  177. package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js +58 -0
  178. package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js.map +1 -0
  179. package/dist/recyclerview/hooks/useUnmountFlag.d.ts +10 -0
  180. package/dist/recyclerview/hooks/useUnmountFlag.d.ts.map +1 -0
  181. package/dist/recyclerview/hooks/useUnmountFlag.js +25 -0
  182. package/dist/recyclerview/hooks/useUnmountFlag.js.map +1 -0
  183. package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts +79 -0
  184. package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts.map +1 -0
  185. package/dist/recyclerview/layout-managers/GridLayoutManager.js +221 -0
  186. package/dist/recyclerview/layout-managers/GridLayoutManager.js.map +1 -0
  187. package/dist/recyclerview/layout-managers/LayoutManager.d.ts +296 -0
  188. package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -0
  189. package/dist/recyclerview/layout-managers/LayoutManager.js +279 -0
  190. package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -0
  191. package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts +51 -0
  192. package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts.map +1 -0
  193. package/dist/recyclerview/layout-managers/LinearLayoutManager.js +151 -0
  194. package/dist/recyclerview/layout-managers/LinearLayoutManager.js.map +1 -0
  195. package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts +81 -0
  196. package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts.map +1 -0
  197. package/dist/recyclerview/layout-managers/MasonryLayoutManager.js +269 -0
  198. package/dist/recyclerview/layout-managers/MasonryLayoutManager.js.map +1 -0
  199. package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts +12 -0
  200. package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts.map +1 -0
  201. package/dist/recyclerview/utils/adjustOffsetForRTL.js +14 -0
  202. package/dist/recyclerview/utils/adjustOffsetForRTL.js.map +1 -0
  203. package/dist/recyclerview/utils/componentUtils.d.ts +19 -0
  204. package/dist/recyclerview/utils/componentUtils.d.ts.map +1 -0
  205. package/dist/recyclerview/utils/componentUtils.js +27 -0
  206. package/dist/recyclerview/utils/componentUtils.js.map +1 -0
  207. package/dist/recyclerview/utils/findVisibleIndex.d.ts +24 -0
  208. package/dist/recyclerview/utils/findVisibleIndex.d.ts.map +1 -0
  209. package/dist/recyclerview/utils/findVisibleIndex.js +76 -0
  210. package/dist/recyclerview/utils/findVisibleIndex.js.map +1 -0
  211. package/dist/recyclerview/utils/measureLayout.d.ts +52 -0
  212. package/dist/recyclerview/utils/measureLayout.d.ts.map +1 -0
  213. package/dist/recyclerview/utils/measureLayout.js +99 -0
  214. package/dist/recyclerview/utils/measureLayout.js.map +1 -0
  215. package/dist/recyclerview/utils/measureLayout.web.d.ts +29 -0
  216. package/dist/recyclerview/utils/measureLayout.web.d.ts.map +1 -0
  217. package/dist/recyclerview/utils/measureLayout.web.js +79 -0
  218. package/dist/recyclerview/utils/measureLayout.web.js.map +1 -0
  219. package/dist/recyclerview/viewability/ViewToken.d.ts +8 -0
  220. package/dist/recyclerview/viewability/ViewToken.d.ts.map +1 -0
  221. package/dist/recyclerview/viewability/ViewToken.js +2 -0
  222. package/dist/recyclerview/viewability/ViewToken.js.map +1 -0
  223. package/dist/recyclerview/viewability/ViewabilityHelper.d.ts +26 -0
  224. package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +1 -0
  225. package/dist/recyclerview/viewability/ViewabilityHelper.js +98 -0
  226. package/dist/recyclerview/viewability/ViewabilityHelper.js.map +1 -0
  227. package/dist/recyclerview/viewability/ViewabilityManager.d.ts +25 -0
  228. package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +1 -0
  229. package/dist/recyclerview/viewability/ViewabilityManager.js +94 -0
  230. package/dist/recyclerview/viewability/ViewabilityManager.js.map +1 -0
  231. package/dist/tsconfig.tsbuildinfo +1 -1
  232. package/dist/utils/AverageWindow.d.ts +33 -43
  233. package/dist/utils/AverageWindow.d.ts.map +1 -1
  234. package/dist/utils/AverageWindow.js +66 -71
  235. package/dist/utils/AverageWindow.js.map +1 -1
  236. package/jestSetup.js +23 -37
  237. package/package.json +15 -24
  238. package/src/AnimatedFlashList.ts +2 -25
  239. package/src/FlashList.ts +1 -0
  240. package/src/FlashListProps.ts +109 -100
  241. package/src/FlashListRef.ts +320 -0
  242. package/src/benchmark/AutoScrollHelper.ts +0 -24
  243. package/src/benchmark/JSFPSMonitor.ts +2 -26
  244. package/src/benchmark/roundToDecimalPlaces.ts +0 -24
  245. package/src/benchmark/useBenchmark.ts +59 -105
  246. package/src/benchmark/useDataMultiplier.ts +0 -24
  247. package/src/benchmark/useFlatListBenchmark.ts +43 -32
  248. package/src/errors/ErrorMessages.ts +26 -0
  249. package/src/errors/WarningMessages.ts +9 -0
  250. package/src/index.ts +18 -46
  251. package/src/isNewArch.ts +25 -0
  252. package/src/native/config/PlatformHelper.android.ts +3 -49
  253. package/src/native/config/PlatformHelper.harmony.ts +3 -24
  254. package/src/native/config/PlatformHelper.ios.ts +3 -48
  255. package/src/native/config/PlatformHelper.ts +3 -49
  256. package/src/native/config/PlatformHelper.web.ts +4 -55
  257. package/src/recyclerview/LayoutCommitObserver.tsx +74 -0
  258. package/src/recyclerview/RecyclerView.tsx +616 -0
  259. package/src/recyclerview/RecyclerViewContextProvider.ts +65 -0
  260. package/src/recyclerview/RecyclerViewManager.ts +461 -0
  261. package/src/recyclerview/RecyclerViewProps.ts +1 -0
  262. package/src/recyclerview/RenderStackManager.ts +317 -0
  263. package/src/recyclerview/ViewHolder.tsx +180 -0
  264. package/src/recyclerview/ViewHolderCollection.tsx +193 -0
  265. package/src/recyclerview/components/CompatScroller.ts +9 -0
  266. package/src/recyclerview/components/CompatView.ts +9 -0
  267. package/src/recyclerview/components/ScrollAnchor.tsx +66 -0
  268. package/src/recyclerview/components/StickyHeaders.tsx +222 -0
  269. package/src/recyclerview/helpers/ConsecutiveNumbers.ts +120 -0
  270. package/src/recyclerview/helpers/EngagedIndicesTracker.ts +301 -0
  271. package/src/recyclerview/helpers/RenderTimeTracker.ts +50 -0
  272. package/src/recyclerview/helpers/VelocityTracker.ts +77 -0
  273. package/src/recyclerview/hooks/useBoundDetection.ts +176 -0
  274. package/src/recyclerview/hooks/useLayoutState.ts +55 -0
  275. package/src/recyclerview/hooks/useMappingHelper.ts +20 -0
  276. package/src/recyclerview/hooks/useOnLoad.ts +80 -0
  277. package/src/recyclerview/hooks/useRecyclerViewController.tsx +633 -0
  278. package/src/recyclerview/hooks/useRecyclerViewManager.ts +42 -0
  279. package/src/recyclerview/hooks/useRecyclingState.ts +67 -0
  280. package/src/recyclerview/hooks/useSecondaryProps.tsx +124 -0
  281. package/src/recyclerview/hooks/useUnmountAwareCallbacks.ts +73 -0
  282. package/src/recyclerview/hooks/useUnmountFlag.ts +27 -0
  283. package/src/recyclerview/layout-managers/GridLayoutManager.ts +256 -0
  284. package/src/recyclerview/layout-managers/LayoutManager.ts +568 -0
  285. package/src/recyclerview/layout-managers/LinearLayoutManager.ts +171 -0
  286. package/src/recyclerview/layout-managers/MasonryLayoutManager.ts +323 -0
  287. package/src/recyclerview/utils/adjustOffsetForRTL.ts +17 -0
  288. package/src/recyclerview/utils/componentUtils.ts +28 -0
  289. package/src/recyclerview/utils/findVisibleIndex.ts +93 -0
  290. package/src/recyclerview/utils/measureLayout.ts +128 -0
  291. package/src/recyclerview/utils/measureLayout.web.ts +102 -0
  292. package/src/recyclerview/viewability/ViewToken.ts +7 -0
  293. package/src/{viewability → recyclerview/viewability}/ViewabilityHelper.ts +8 -33
  294. package/src/{viewability → recyclerview/viewability}/ViewabilityManager.ts +23 -46
  295. package/src/utils/AverageWindow.ts +33 -24
  296. package/dist/GridLayoutProviderWithProps.d.ts +0 -65
  297. package/dist/GridLayoutProviderWithProps.d.ts.map +0 -1
  298. package/dist/GridLayoutProviderWithProps.js +0 -138
  299. package/dist/GridLayoutProviderWithProps.js.map +0 -1
  300. package/dist/MasonryFlashList.d.ts +0 -74
  301. package/dist/MasonryFlashList.d.ts.map +0 -1
  302. package/dist/MasonryFlashList.js +0 -275
  303. package/dist/MasonryFlashList.js.map +0 -1
  304. package/dist/PureComponentWrapper.d.ts +0 -45
  305. package/dist/PureComponentWrapper.d.ts.map +0 -1
  306. package/dist/PureComponentWrapper.js +0 -60
  307. package/dist/PureComponentWrapper.js.map +0 -1
  308. package/dist/benchmark/useBlankAreaTracker.d.ts +0 -57
  309. package/dist/benchmark/useBlankAreaTracker.d.ts.map +0 -1
  310. package/dist/benchmark/useBlankAreaTracker.js +0 -90
  311. package/dist/benchmark/useBlankAreaTracker.js.map +0 -1
  312. package/dist/errors/CustomError.d.ts +0 -31
  313. package/dist/errors/CustomError.d.ts.map +0 -1
  314. package/dist/errors/CustomError.js +0 -37
  315. package/dist/errors/CustomError.js.map +0 -1
  316. package/dist/errors/ExceptionList.d.ts +0 -47
  317. package/dist/errors/ExceptionList.d.ts.map +0 -1
  318. package/dist/errors/ExceptionList.js +0 -49
  319. package/dist/errors/ExceptionList.js.map +0 -1
  320. package/dist/errors/Warnings.d.ts +0 -32
  321. package/dist/errors/Warnings.d.ts.map +0 -1
  322. package/dist/errors/Warnings.js +0 -36
  323. package/dist/errors/Warnings.js.map +0 -1
  324. package/dist/fabric/AutoLayoutNativeComponent.d.ts +0 -42
  325. package/dist/fabric/AutoLayoutNativeComponent.d.ts.map +0 -1
  326. package/dist/fabric/AutoLayoutNativeComponent.js +0 -29
  327. package/dist/fabric/AutoLayoutNativeComponent.js.map +0 -1
  328. package/dist/fabric/CellContainerNativeComponent.d.ts +0 -31
  329. package/dist/fabric/CellContainerNativeComponent.d.ts.map +0 -1
  330. package/dist/fabric/CellContainerNativeComponent.js +0 -29
  331. package/dist/fabric/CellContainerNativeComponent.js.map +0 -1
  332. package/dist/native/auto-layout/AutoLayoutView.d.ts +0 -45
  333. package/dist/native/auto-layout/AutoLayoutView.d.ts.map +0 -1
  334. package/dist/native/auto-layout/AutoLayoutView.js +0 -71
  335. package/dist/native/auto-layout/AutoLayoutView.js.map +0 -1
  336. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +0 -27
  337. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +0 -1
  338. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +0 -29
  339. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +0 -1
  340. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +0 -28
  341. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +0 -1
  342. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts +0 -27
  343. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts.map +0 -1
  344. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js +0 -29
  345. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js.map +0 -1
  346. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +0 -27
  347. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +0 -1
  348. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +0 -29
  349. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +0 -1
  350. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +0 -29
  351. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +0 -1
  352. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +0 -39
  353. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +0 -1
  354. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +0 -26
  355. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +0 -1
  356. package/dist/native/cell-container/CellContainer.android.d.ts +0 -29
  357. package/dist/native/cell-container/CellContainer.android.d.ts.map +0 -1
  358. package/dist/native/cell-container/CellContainer.android.js +0 -32
  359. package/dist/native/cell-container/CellContainer.android.js.map +0 -1
  360. package/dist/native/cell-container/CellContainer.d.ts +0 -31
  361. package/dist/native/cell-container/CellContainer.d.ts.map +0 -1
  362. package/dist/native/cell-container/CellContainer.harmony.d.ts +0 -29
  363. package/dist/native/cell-container/CellContainer.harmony.d.ts.map +0 -1
  364. package/dist/native/cell-container/CellContainer.harmony.js +0 -32
  365. package/dist/native/cell-container/CellContainer.harmony.js.map +0 -1
  366. package/dist/native/cell-container/CellContainer.ios.d.ts +0 -29
  367. package/dist/native/cell-container/CellContainer.ios.d.ts.map +0 -1
  368. package/dist/native/cell-container/CellContainer.ios.js +0 -32
  369. package/dist/native/cell-container/CellContainer.ios.js.map +0 -1
  370. package/dist/native/cell-container/CellContainer.js +0 -34
  371. package/dist/native/cell-container/CellContainer.js.map +0 -1
  372. package/dist/native/cell-container/CellContainer.web.d.ts +0 -30
  373. package/dist/native/cell-container/CellContainer.web.d.ts.map +0 -1
  374. package/dist/native/cell-container/CellContainer.web.js +0 -36
  375. package/dist/native/cell-container/CellContainer.web.js.map +0 -1
  376. package/dist/utils/ContentContainerUtils.d.ts +0 -50
  377. package/dist/utils/ContentContainerUtils.d.ts.map +0 -1
  378. package/dist/utils/ContentContainerUtils.js +0 -71
  379. package/dist/utils/ContentContainerUtils.js.map +0 -1
  380. package/dist/viewability/ViewToken.d.ts +0 -31
  381. package/dist/viewability/ViewToken.d.ts.map +0 -1
  382. package/dist/viewability/ViewToken.js +0 -26
  383. package/dist/viewability/ViewToken.js.map +0 -1
  384. package/dist/viewability/ViewabilityHelper.d.ts +0 -49
  385. package/dist/viewability/ViewabilityHelper.d.ts.map +0 -1
  386. package/dist/viewability/ViewabilityHelper.js +0 -130
  387. package/dist/viewability/ViewabilityHelper.js.map +0 -1
  388. package/dist/viewability/ViewabilityManager.d.ts +0 -48
  389. package/dist/viewability/ViewabilityManager.d.ts.map +0 -1
  390. package/dist/viewability/ViewabilityManager.js +0 -131
  391. package/dist/viewability/ViewabilityManager.js.map +0 -1
  392. package/harmony/flash_list/BuildProfile.ets +0 -17
  393. package/harmony/flash_list/LICENSE +0 -7
  394. package/harmony/flash_list/build-profile.json5 +0 -8
  395. package/harmony/flash_list/hvigorfile.ts +0 -1
  396. package/harmony/flash_list/index.ets +0 -27
  397. package/harmony/flash_list/obfuscation-rules.txt +0 -18
  398. package/harmony/flash_list/oh-package.json5 +0 -24
  399. package/harmony/flash_list/src/main/cpp/AutoLayoutNode.cpp +0 -63
  400. package/harmony/flash_list/src/main/cpp/AutoLayoutNode.h +0 -54
  401. package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.cpp +0 -140
  402. package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.h +0 -66
  403. package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.cpp +0 -208
  404. package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.h +0 -78
  405. package/harmony/flash_list/src/main/cpp/AutoLayoutViewEventEmitRequestHandler.h +0 -53
  406. package/harmony/flash_list/src/main/cpp/AutoLayoutViewJSIBinder.h +0 -50
  407. package/harmony/flash_list/src/main/cpp/CMakeLists.txt +0 -12
  408. package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.cpp +0 -80
  409. package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.h +0 -64
  410. package/harmony/flash_list/src/main/cpp/CellContainerJSIBinder.h +0 -39
  411. package/harmony/flash_list/src/main/cpp/ComponentDescriptors.h +0 -40
  412. package/harmony/flash_list/src/main/cpp/EventEmitters.cpp +0 -40
  413. package/harmony/flash_list/src/main/cpp/EventEmitters.h +0 -48
  414. package/harmony/flash_list/src/main/cpp/FlashListPackage.h +0 -85
  415. package/harmony/flash_list/src/main/cpp/FlashListStackNode.cpp +0 -87
  416. package/harmony/flash_list/src/main/cpp/FlashListStackNode.h +0 -57
  417. package/harmony/flash_list/src/main/cpp/Props.cpp +0 -52
  418. package/harmony/flash_list/src/main/cpp/Props.h +0 -64
  419. package/harmony/flash_list/src/main/cpp/ShadowNodes.cpp +0 -34
  420. package/harmony/flash_list/src/main/cpp/ShadowNodes.h +0 -48
  421. package/harmony/flash_list/src/main/ets/Logger.ets +0 -64
  422. package/harmony/flash_list/src/main/ets/RNAutoLayoutShadow.ets +0 -154
  423. package/harmony/flash_list/src/main/ets/RNAutoLayoutView.ets +0 -277
  424. package/harmony/flash_list/src/main/ets/RNCellContainer.ets +0 -113
  425. package/harmony/flash_list/src/main/module.json5 +0 -9
  426. package/harmony/flash_list/src/main/resources/base/element/color.json +0 -8
  427. package/harmony/flash_list/src/main/resources/base/element/string.json +0 -16
  428. package/harmony/flash_list/src/main/resources/base/media/icon.png +0 -0
  429. package/harmony/flash_list/src/main/resources/base/profile/main_pages.json +0 -5
  430. package/harmony/flash_list/src/main/resources/en_US/element/string.json +0 -16
  431. package/harmony/flash_list/src/main/resources/zh_CN/element/string.json +0 -16
  432. package/harmony/flash_list.har +0 -0
  433. package/src/FlashList.tsx +0 -949
  434. package/src/GridLayoutProviderWithProps.ts +0 -204
  435. package/src/MasonryFlashList.tsx +0 -499
  436. package/src/PureComponentWrapper.tsx +0 -65
  437. package/src/benchmark/useBlankAreaTracker.ts +0 -141
  438. package/src/errors/CustomError.ts +0 -34
  439. package/src/errors/ExceptionList.ts +0 -52
  440. package/src/errors/Warnings.ts +0 -39
  441. package/src/fabric/AutoLayoutNativeComponent.ts +0 -52
  442. package/src/fabric/CellContainerNativeComponent.ts +0 -35
  443. package/src/native/auto-layout/AutoLayoutView.tsx +0 -97
  444. package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +0 -31
  445. package/src/native/auto-layout/AutoLayoutViewNativeComponent.harmony.ts +0 -31
  446. package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +0 -31
  447. package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +0 -31
  448. package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +0 -41
  449. package/src/native/cell-container/CellContainer.android.ts +0 -31
  450. package/src/native/cell-container/CellContainer.harmony.ts +0 -31
  451. package/src/native/cell-container/CellContainer.ios.ts +0 -31
  452. package/src/native/cell-container/CellContainer.tsx +0 -38
  453. package/src/native/cell-container/CellContainer.web.tsx +0 -33
  454. package/src/utils/ContentContainerUtils.ts +0 -116
  455. package/src/viewability/ViewToken.ts +0 -31
@@ -0,0 +1,568 @@
1
+ // Interface of layout manager for app's listviews
2
+
3
+ import { MultiTypeAverageWindow } from "../../utils/AverageWindow";
4
+ import { ConsecutiveNumbers } from "../helpers/ConsecutiveNumbers";
5
+ import {
6
+ findFirstVisibleIndex,
7
+ findLastVisibleIndex,
8
+ } from "../utils/findVisibleIndex";
9
+ import { areDimensionsNotEqual } from "../utils/measureLayout";
10
+ import { ErrorMessages } from "../../errors/ErrorMessages";
11
+
12
+ /**
13
+ * Base abstract class for layout managers in the recycler view system.
14
+ * Provides common functionality for managing item layouts and dimensions.
15
+ * Supports both horizontal and vertical layouts with dynamic item sizing.
16
+ */
17
+ export abstract class RVLayoutManager {
18
+ /** Whether the layout is horizontal (true) or vertical (false) */
19
+ protected horizontal: boolean;
20
+ /** Array of layout information for all items */
21
+ protected layouts: RVLayout[];
22
+ /** Dimensions of the visible window/viewport */
23
+ protected windowSize: RVDimension;
24
+ /** Maximum number of columns in the layout */
25
+ protected maxColumns: number;
26
+
27
+ /** Whether to optimize item placement for better space utilization */
28
+ protected optimizeItemArrangement: boolean;
29
+
30
+ /** Flag indicating if the layout requires repainting */
31
+ public requiresRepaint = false;
32
+
33
+ /** Optional callback to override default item layout */
34
+ private overrideItemLayout: (index: number, layout: SpanSizeInfo) => void;
35
+ /** Optional function to determine item type */
36
+ private getItemType: (index: number) => string;
37
+ /** Window for tracking average heights by item type */
38
+ private heightAverageWindow: MultiTypeAverageWindow;
39
+ /** Window for tracking average widths by item type */
40
+ private widthAverageWindow: MultiTypeAverageWindow;
41
+ /** Maximum number of items to process in a single layout pass */
42
+ private maxItemsToProcess = 250;
43
+ /** Information about item spans and sizes */
44
+ private spanSizeInfo: SpanSizeInfo = {};
45
+ /** Span tracker for each item */
46
+ private spanTracker: (number | undefined)[] = [];
47
+
48
+ /** Current max index with changed layout */
49
+ private currentMaxIndexWithChangedLayout = -1;
50
+
51
+ /**
52
+ * Last index that was skipped during layout computation.
53
+ * Used to determine if a layout needs to be recomputed.
54
+ */
55
+ private lastSkippedLayoutIndex = Number.MAX_VALUE;
56
+
57
+ constructor(params: LayoutParams, previousLayoutManager?: RVLayoutManager) {
58
+ this.heightAverageWindow = new MultiTypeAverageWindow(5, 200);
59
+ this.widthAverageWindow = new MultiTypeAverageWindow(5, 200);
60
+ this.getItemType = params.getItemType;
61
+ this.overrideItemLayout = params.overrideItemLayout;
62
+ this.layouts = previousLayoutManager?.layouts ?? [];
63
+ if (previousLayoutManager) {
64
+ this.updateLayoutParams(params);
65
+ } else {
66
+ this.horizontal = Boolean(params.horizontal);
67
+ this.windowSize = params.windowSize;
68
+ this.maxColumns = params.maxColumns ?? 1;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Gets the estimated width for an item based on its type.
74
+ * @param index Index of the item
75
+ * @returns Estimated width
76
+ */
77
+ protected getEstimatedWidth(index: number): number {
78
+ return this.widthAverageWindow.getCurrentValue(this.getItemType(index));
79
+ }
80
+
81
+ /**
82
+ * Gets the estimated height for an item based on its type.
83
+ * @param index Index of the item
84
+ * @returns Estimated height
85
+ */
86
+ protected getEstimatedHeight(index: number): number {
87
+ return this.heightAverageWindow.getCurrentValue(this.getItemType(index));
88
+ }
89
+
90
+ /**
91
+ * Abstract method to process layout information for items.
92
+ * @param layoutInfo Array of layout information for items
93
+ * @param itemCount Total number of items in the list
94
+ * @returns Index of first modified layout or void
95
+ */
96
+ protected abstract processLayoutInfo(
97
+ layoutInfo: RVLayoutInfo[],
98
+ itemCount: number
99
+ ): number | void;
100
+
101
+ /**
102
+ * Checks if the layout is horizontal.
103
+ * @returns True if horizontal, false if vertical
104
+ */
105
+ isHorizontal(): boolean {
106
+ return this.horizontal;
107
+ }
108
+
109
+ /**
110
+ * Gets the dimensions of the visible window.
111
+ * @returns Window dimensions
112
+ */
113
+ getWindowsSize(): RVDimension {
114
+ return this.windowSize;
115
+ }
116
+
117
+ /**
118
+ * Gets indices of items currently visible in the viewport.
119
+ * Uses binary search for efficient lookup.
120
+ * @param unboundDimensionStart Start position of viewport (start X or start Y)
121
+ * @param unboundDimensionEnd End position of viewport (end X or end Y)
122
+ * @returns ConsecutiveNumbers containing visible indices
123
+ */
124
+ getVisibleLayouts(
125
+ unboundDimensionStart: number,
126
+ unboundDimensionEnd: number
127
+ ): ConsecutiveNumbers {
128
+ // Find the first visible index
129
+ const firstVisibleIndex = findFirstVisibleIndex(
130
+ this.layouts,
131
+ unboundDimensionStart,
132
+ this.horizontal
133
+ );
134
+
135
+ // Find the last visible index
136
+ const lastVisibleIndex = findLastVisibleIndex(
137
+ this.layouts,
138
+ unboundDimensionEnd,
139
+ this.horizontal
140
+ );
141
+
142
+ // Collect the indices in the range
143
+ if (firstVisibleIndex !== -1 && lastVisibleIndex !== -1) {
144
+ return new ConsecutiveNumbers(firstVisibleIndex, lastVisibleIndex);
145
+ }
146
+ return ConsecutiveNumbers.EMPTY;
147
+ }
148
+
149
+ /**
150
+ * Removes layout information for specified indices and recomputes layout.
151
+ * @param indices Array of indices to remove
152
+ */
153
+ deleteLayout(indices: number[]): void {
154
+ // Sort indices in descending order
155
+ indices.sort((num1, num2) => num2 - num1);
156
+
157
+ // Remove elements from the array
158
+ for (const index of indices) {
159
+ this.layouts.splice(index, 1);
160
+ }
161
+ const startIndex = Math.min(...indices);
162
+ // Recompute layouts starting from the smallest index in the original indices array
163
+ this._recomputeLayouts(
164
+ this.getMinRecomputeIndex(startIndex),
165
+ this.getMaxRecomputeIndex(startIndex)
166
+ );
167
+ }
168
+
169
+ /**
170
+ * Updates layout information for items and recomputes layout if necessary.
171
+ * @param layoutInfo Array of layout information for items (real measurements)
172
+ * @param totalItemCount Total number of items in the list
173
+ */
174
+ modifyLayout(layoutInfo: RVLayoutInfo[], totalItemCount: number): void {
175
+ this.maxItemsToProcess = Math.max(
176
+ this.maxItemsToProcess,
177
+ layoutInfo.length * 10
178
+ );
179
+ let minRecomputeIndex = Number.MAX_VALUE;
180
+
181
+ if (this.layouts.length > totalItemCount) {
182
+ this.layouts.length = totalItemCount;
183
+ this.spanTracker.length = totalItemCount;
184
+ minRecomputeIndex = totalItemCount - 1; // <0 gets skipped so it's safe to set to totalItemCount - 1
185
+ }
186
+ // update average windows
187
+ minRecomputeIndex = Math.min(
188
+ minRecomputeIndex,
189
+ this.computeEstimatesAndMinMaxChangedLayout(layoutInfo)
190
+ );
191
+
192
+ if (this.layouts.length < totalItemCount && totalItemCount > 0) {
193
+ const startIndex = this.layouts.length;
194
+ this.layouts.length = totalItemCount;
195
+ this.spanTracker.length = totalItemCount;
196
+ for (let i = startIndex; i < totalItemCount; i++) {
197
+ this.getLayout(i);
198
+ this.getSpan(i);
199
+ }
200
+ this.recomputeLayouts(startIndex, totalItemCount - 1);
201
+ }
202
+
203
+ // compute minRecomputeIndex
204
+
205
+ minRecomputeIndex = Math.min(
206
+ minRecomputeIndex,
207
+ this.lastSkippedLayoutIndex,
208
+ this.computeMinIndexWithChangedSpan(layoutInfo),
209
+ this.processLayoutInfo(layoutInfo, totalItemCount) ?? minRecomputeIndex,
210
+ this.computeEstimatesAndMinMaxChangedLayout(layoutInfo)
211
+ );
212
+
213
+ if (minRecomputeIndex >= 0 && minRecomputeIndex < totalItemCount) {
214
+ const maxRecomputeIndex = this.getMaxRecomputeIndex(minRecomputeIndex);
215
+ this._recomputeLayouts(minRecomputeIndex, maxRecomputeIndex);
216
+ }
217
+ this.currentMaxIndexWithChangedLayout = -1;
218
+ }
219
+
220
+ /**
221
+ * Gets layout information for an item at the given index.
222
+ * Creates and initializes a new layout if one doesn't exist.
223
+ * @param index Index of the item
224
+ * @returns Layout information for the item
225
+ */
226
+ getLayout(index: number): RVLayout {
227
+ if (index >= this.layouts.length) {
228
+ throw new Error(ErrorMessages.indexOutOfBounds);
229
+ }
230
+ let layout = this.layouts[index];
231
+ if (!layout) {
232
+ // Create new layout with estimated dimensions
233
+ layout = {
234
+ x: 0,
235
+ y: 0,
236
+ width: 0,
237
+ height: 0,
238
+ };
239
+ this.layouts[index] = layout;
240
+ }
241
+ if (!layout.isWidthMeasured || !layout.isHeightMeasured) {
242
+ this.estimateLayout(index);
243
+ }
244
+ return layout;
245
+ }
246
+
247
+ /**
248
+ * Updates layout parameters and triggers recomputation if necessary.
249
+ * @param params New layout parameters
250
+ */
251
+ updateLayoutParams(params: LayoutParams) {
252
+ this.windowSize = params.windowSize;
253
+ this.horizontal = params.horizontal ?? this.horizontal;
254
+ this.maxColumns = params.maxColumns ?? this.maxColumns;
255
+ this.optimizeItemArrangement =
256
+ params.optimizeItemArrangement ?? this.optimizeItemArrangement;
257
+ }
258
+
259
+ getLayoutCount(): number {
260
+ return this.layouts.length;
261
+ }
262
+
263
+ /**
264
+ * Abstract method to recompute layouts for items in the given range.
265
+ * @param startIndex Starting index of items to recompute
266
+ * @param endIndex Ending index of items to recompute
267
+ */
268
+ abstract recomputeLayouts(startIndex: number, endIndex: number): void;
269
+
270
+ /**
271
+ * Abstract method to get the total size of the layout area.
272
+ * @returns RVDimension containing width and height of the layout
273
+ */
274
+ abstract getLayoutSize(): RVDimension;
275
+
276
+ /**
277
+ * Abstract method to estimate layout dimensions for an item.
278
+ * @param index Index of the item to estimate layout for
279
+ */
280
+ protected abstract estimateLayout(index: number): void;
281
+
282
+ /**
283
+ * Gets span for an item, applying any overrides.
284
+ * This is intended to be called during a relayout call. The value is tracked and used to determine if a span change has occurred.
285
+ * If skipTracking is true, the operation is not tracked. Can be useful if span is required outside of a relayout call.
286
+ * The tracker is used to call handleSpanChange if a span change has occurred before relayout call.
287
+ * // TODO: improve this contract.
288
+ * @param index Index of the item
289
+ * @returns Span for the item
290
+ */
291
+ protected getSpan(index: number, skipTracking = false): number {
292
+ this.spanSizeInfo.span = undefined;
293
+ this.overrideItemLayout(index, this.spanSizeInfo);
294
+ const span = Math.min(this.spanSizeInfo.span ?? 1, this.maxColumns);
295
+ if (!skipTracking) {
296
+ this.spanTracker[index] = span;
297
+ }
298
+ return span;
299
+ }
300
+
301
+ /**
302
+ * Method to handle span change for an item. Can be overridden by subclasses.
303
+ * @param index Index of the item
304
+ */
305
+ protected handleSpanChange(index: number) {}
306
+
307
+ /**
308
+ * Gets the maximum index to process in a single layout pass.
309
+ * @param startIndex Starting index
310
+ * @returns Maximum index to process
311
+ */
312
+ private getMaxRecomputeIndex(startIndex: number): number {
313
+ return Math.min(
314
+ Math.max(startIndex, this.currentMaxIndexWithChangedLayout) +
315
+ this.maxItemsToProcess,
316
+ this.layouts.length - 1
317
+ );
318
+ }
319
+
320
+ /**
321
+ * Gets the minimum index to process in a single layout pass.
322
+ * @param startIndex Starting index
323
+ * @returns Minimum index to process
324
+ */
325
+ private getMinRecomputeIndex(startIndex: number): number {
326
+ return startIndex;
327
+ }
328
+
329
+ private _recomputeLayouts(startIndex: number, endIndex: number): void {
330
+ this.recomputeLayouts(startIndex, endIndex);
331
+ if (
332
+ this.lastSkippedLayoutIndex >= startIndex &&
333
+ this.lastSkippedLayoutIndex <= endIndex
334
+ ) {
335
+ this.lastSkippedLayoutIndex = Number.MAX_VALUE;
336
+ }
337
+
338
+ if (endIndex + 1 < this.layouts.length) {
339
+ this.lastSkippedLayoutIndex = Math.min(
340
+ endIndex + 1,
341
+ this.lastSkippedLayoutIndex
342
+ );
343
+ const lastIndex = this.layouts.length - 1;
344
+ // Since layout managers derive height from last indices we need to make
345
+ // sure they're not too much out of sync.
346
+ if (this.layouts[lastIndex].y < this.layouts[endIndex].y) {
347
+ this.recomputeLayouts(this.lastSkippedLayoutIndex, lastIndex);
348
+ this.lastSkippedLayoutIndex = Number.MAX_VALUE;
349
+ }
350
+ }
351
+ }
352
+
353
+ /**
354
+ * Computes size estimates and finds the minimum recompute index.
355
+ * @param layoutInfo Array of layout information for items
356
+ * @returns Minimum index that needs recomputation
357
+ */
358
+ private computeEstimatesAndMinMaxChangedLayout(
359
+ layoutInfo: RVLayoutInfo[]
360
+ ): number {
361
+ let minRecomputeIndex = Number.MAX_VALUE;
362
+ for (const info of layoutInfo) {
363
+ const { index, dimensions } = info;
364
+ const storedLayout = this.layouts[index];
365
+ if (
366
+ index >= this.lastSkippedLayoutIndex ||
367
+ !storedLayout ||
368
+ !storedLayout.isHeightMeasured ||
369
+ !storedLayout.isWidthMeasured ||
370
+ areDimensionsNotEqual(storedLayout.height, dimensions.height) ||
371
+ areDimensionsNotEqual(storedLayout.width, dimensions.width)
372
+ ) {
373
+ minRecomputeIndex = Math.min(minRecomputeIndex, index);
374
+ this.currentMaxIndexWithChangedLayout = Math.max(
375
+ this.currentMaxIndexWithChangedLayout,
376
+ index
377
+ );
378
+ }
379
+ this.heightAverageWindow.addValue(
380
+ dimensions.height,
381
+ this.getItemType(index)
382
+ );
383
+ this.widthAverageWindow.addValue(
384
+ dimensions.width,
385
+ this.getItemType(index)
386
+ );
387
+ }
388
+ return minRecomputeIndex;
389
+ }
390
+
391
+ private computeMinIndexWithChangedSpan(layoutInfo: RVLayoutInfo[]): number {
392
+ let minIndexWithChangedSpan = Number.MAX_VALUE;
393
+ for (const info of layoutInfo) {
394
+ const { index } = info;
395
+ const span = this.getSpan(index, true);
396
+ const storedSpan = this.spanTracker[index];
397
+ if (span !== storedSpan) {
398
+ this.spanTracker[index] = span;
399
+ this.handleSpanChange(index);
400
+ minIndexWithChangedSpan = Math.min(minIndexWithChangedSpan, index);
401
+ }
402
+ }
403
+ return minIndexWithChangedSpan;
404
+ }
405
+ }
406
+
407
+ /**
408
+ * Configuration parameters for the layout manager
409
+ */
410
+ export interface LayoutParams {
411
+ /**
412
+ * The dimensions of the visible window/viewport that displays list items
413
+ * Used to determine which items are visible and need to be rendered
414
+ */
415
+ windowSize: RVDimension;
416
+
417
+ /**
418
+ * Determines if the list scrolls horizontally (true) or vertically (false)
419
+ * Affects how items are positioned and which dimension is used for scrolling
420
+ */
421
+ horizontal: boolean;
422
+
423
+ /**
424
+ * Maximum number of columns in a grid layout
425
+ * Controls how many items can be placed side by side
426
+ */
427
+ maxColumns: number;
428
+
429
+ /**
430
+ * When true, attempts to optimize item placement for better space utilization
431
+ * May affect the ordering of items to minimize empty space
432
+ */
433
+ optimizeItemArrangement: boolean;
434
+
435
+ /**
436
+ * Callback to manually override layout properties for specific items
437
+ * Allows custom control over span and size for individual items
438
+ */
439
+ overrideItemLayout: (index: number, layout: SpanSizeInfo) => void;
440
+
441
+ /**
442
+ * Function to determine the type of an item at a specific index
443
+ * Used for size estimation and optimization based on item types
444
+ */
445
+ getItemType: (index: number) => string;
446
+ }
447
+
448
+ /**
449
+ * Information about an item's layout including its index and dimensions
450
+ * Used when updating layout information for specific items
451
+ */
452
+ export interface RVLayoutInfo {
453
+ /**
454
+ * The index of the item in the data array
455
+ * Used to identify which item this layout information belongs to
456
+ */
457
+ index: number;
458
+
459
+ /**
460
+ * The width and height dimensions of the item
461
+ * Used to update the layout manager's knowledge of item sizes
462
+ */
463
+ dimensions: RVDimension;
464
+ }
465
+
466
+ /**
467
+ * Information about an item's span and size in a grid layout
468
+ * Used when overriding default layout behavior for specific items
469
+ */
470
+ export interface SpanSizeInfo {
471
+ /**
472
+ * Number of columns/cells this item should span horizontally
473
+ * Used in grid layouts to allow items to take up multiple columns
474
+ */
475
+ span?: number;
476
+
477
+ /**
478
+ * Custom size value for the item
479
+ * Can be used to override the default size calculation
480
+ */
481
+ size?: number;
482
+ }
483
+
484
+ /**
485
+ * Complete layout information for a list item
486
+ * Extends RVDimension with positioning and constraint properties
487
+ * Used to position and size ViewHolder components in the list
488
+ */
489
+ export interface RVLayout extends RVDimension {
490
+ /**
491
+ * X-coordinate (horizontal position) in pixels
492
+ * Used to position the item horizontally with absolute positioning
493
+ */
494
+ x: number;
495
+
496
+ /**
497
+ * Y-coordinate (vertical position) in pixels
498
+ * Used to position the item vertically with absolute positioning
499
+ */
500
+ y: number;
501
+
502
+ /**
503
+ * Indicates if the width has been measured from the actual rendered item
504
+ * When false, width may be an estimated value
505
+ */
506
+ isWidthMeasured?: boolean;
507
+
508
+ /**
509
+ * Indicates if the height has been measured from the actual rendered item
510
+ * When false, height may be an estimated value
511
+ */
512
+ isHeightMeasured?: boolean;
513
+
514
+ /**
515
+ * Minimum height constraint in pixels
516
+ * Applied to the ViewHolder's style to ensure item doesn't shrink below this value
517
+ */
518
+ minHeight?: number;
519
+
520
+ /**
521
+ * Minimum width constraint in pixels
522
+ * Applied to the ViewHolder's style to ensure item doesn't shrink below this value
523
+ */
524
+ minWidth?: number;
525
+
526
+ /**
527
+ * Maximum height constraint in pixels
528
+ * Applied to the ViewHolder's style to limit item's vertical growth
529
+ */
530
+ maxHeight?: number;
531
+
532
+ /**
533
+ * Maximum width constraint in pixels
534
+ * Applied to the ViewHolder's style to limit item's horizontal growth
535
+ */
536
+ maxWidth?: number;
537
+
538
+ /**
539
+ * When true, the width value is strictly enforced on the ViewHolder
540
+ * When false, the width is determined by content
541
+ */
542
+ enforcedWidth?: boolean;
543
+
544
+ /**
545
+ * When true, the height value is strictly enforced on the ViewHolder
546
+ * When false, the height is determined by content
547
+ */
548
+ enforcedHeight?: boolean;
549
+ }
550
+
551
+ /**
552
+ * Basic dimension interface representing width and height
553
+ * Used throughout the recycler view system to track item sizes
554
+ * and viewport dimensions
555
+ */
556
+ export interface RVDimension {
557
+ /**
558
+ * Width in pixels
559
+ * Used for horizontal measurement and positioning
560
+ */
561
+ width: number;
562
+
563
+ /**
564
+ * Height in pixels
565
+ * Used for vertical measurement and positioning
566
+ */
567
+ height: number;
568
+ }