react-native-nitro-list 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/ios/HybridNitroList.swift +10 -14
  2. package/lib/commonjs/cell/CellKeyGenerator.js +21 -0
  3. package/lib/commonjs/cell/CellKeyGenerator.js.map +1 -0
  4. package/lib/commonjs/cell/CellRecycler.js +48 -40
  5. package/lib/commonjs/cell/CellRecycler.js.map +1 -1
  6. package/lib/commonjs/cell/createCell.js +21 -0
  7. package/lib/commonjs/cell/createCell.js.map +1 -0
  8. package/lib/commonjs/cell/index.js +20 -0
  9. package/lib/commonjs/cell/index.js.map +1 -0
  10. package/lib/commonjs/getVisibleIndices.js.map +1 -1
  11. package/lib/commonjs/hooks/usePersistentCallback.js +36 -0
  12. package/lib/commonjs/hooks/usePersistentCallback.js.map +1 -0
  13. package/lib/commonjs/index.js +1 -1
  14. package/lib/commonjs/layout/MutableLinearLayout.js +78 -39
  15. package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -1
  16. package/lib/commonjs/layout/constants/layoutDefaults.js +19 -0
  17. package/lib/commonjs/layout/constants/layoutDefaults.js.map +1 -0
  18. package/lib/commonjs/layout/index.js +0 -18
  19. package/lib/commonjs/layout/index.js.map +1 -1
  20. package/lib/commonjs/recycler/CellPool.js +46 -0
  21. package/lib/commonjs/recycler/CellPool.js.map +1 -0
  22. package/lib/commonjs/recycler/RecyclerList.js +224 -0
  23. package/lib/commonjs/recycler/RecyclerList.js.map +1 -0
  24. package/lib/commonjs/types/Axis.js +2 -0
  25. package/lib/commonjs/{layout/LayoutProvider.js.map → types/Axis.js.map} +1 -1
  26. package/lib/commonjs/types/CellKey.js +2 -0
  27. package/lib/{module/layout/LayoutProvider.js.map → commonjs/types/CellKey.js.map} +1 -1
  28. package/lib/commonjs/types/CellType.js +2 -0
  29. package/lib/commonjs/{layout/LayoutRectangle.js.map → types/CellType.js.map} +1 -1
  30. package/lib/commonjs/types/VisibleRange.js +2 -0
  31. package/lib/{module/layout/LayoutRectangle.js.map → commonjs/types/VisibleRange.js.map} +1 -1
  32. package/lib/commonjs/{RecyclerList.types.js → types/VisibleRangeInput.js} +1 -1
  33. package/lib/commonjs/types/VisibleRangeInput.js.map +1 -0
  34. package/lib/commonjs/types/index.js +13 -0
  35. package/lib/commonjs/types/index.js.map +1 -0
  36. package/lib/commonjs/types/layout/LayoutRect.js +2 -0
  37. package/lib/commonjs/types/layout/LayoutRect.js.map +1 -0
  38. package/lib/commonjs/types/layout/LinearLayoutInput.js +6 -0
  39. package/lib/commonjs/types/layout/LinearLayoutInput.js.map +1 -0
  40. package/lib/commonjs/types/layout/MainAxisPadding.js +26 -0
  41. package/lib/commonjs/types/layout/MainAxisPadding.js.map +1 -0
  42. package/lib/commonjs/types/layout/index.js +2 -0
  43. package/lib/commonjs/types/layout/index.js.map +1 -0
  44. package/lib/commonjs/types/recycler/RecyclerCellInstance.js +6 -0
  45. package/lib/commonjs/types/recycler/RecyclerCellInstance.js.map +1 -0
  46. package/lib/commonjs/types/recycler/RecyclerItemRenderer.js +6 -0
  47. package/lib/commonjs/types/recycler/RecyclerItemRenderer.js.map +1 -0
  48. package/lib/commonjs/types/recycler/RecyclerListProps.js +6 -0
  49. package/lib/commonjs/types/recycler/RecyclerListProps.js.map +1 -0
  50. package/lib/commonjs/types/recycler/index.js +2 -0
  51. package/lib/commonjs/types/recycler/index.js.map +1 -0
  52. package/lib/commonjs/{layout/LayoutProvider.js → types/scroll/ScrollMetrics.js} +1 -1
  53. package/lib/commonjs/types/scroll/ScrollMetrics.js.map +1 -0
  54. package/lib/commonjs/types/scroll/index.js +2 -0
  55. package/lib/commonjs/types/scroll/index.js.map +1 -0
  56. package/lib/commonjs/windowing/computeVisibleItemRange.js +71 -0
  57. package/lib/commonjs/windowing/computeVisibleItemRange.js.map +1 -0
  58. package/lib/commonjs/windowing/index.js +3 -3
  59. package/lib/commonjs/windowing/index.js.map +1 -1
  60. package/lib/module/cell/CellKeyGenerator.js +16 -0
  61. package/lib/module/cell/CellKeyGenerator.js.map +1 -0
  62. package/lib/module/cell/CellRecycler.js +48 -39
  63. package/lib/module/cell/CellRecycler.js.map +1 -1
  64. package/lib/module/cell/createCell.js +17 -0
  65. package/lib/module/cell/createCell.js.map +1 -0
  66. package/lib/module/cell/index.js +7 -0
  67. package/lib/module/cell/index.js.map +1 -0
  68. package/lib/module/getVisibleIndices.js.map +1 -1
  69. package/lib/module/hooks/usePersistentCallback.js +33 -0
  70. package/lib/module/hooks/usePersistentCallback.js.map +1 -0
  71. package/lib/module/index.js +1 -1
  72. package/lib/module/index.js.map +1 -1
  73. package/lib/module/layout/MutableLinearLayout.js +78 -38
  74. package/lib/module/layout/MutableLinearLayout.js.map +1 -1
  75. package/lib/module/layout/constants/layoutDefaults.js +15 -0
  76. package/lib/module/layout/constants/layoutDefaults.js.map +1 -0
  77. package/lib/module/layout/index.js +0 -3
  78. package/lib/module/layout/index.js.map +1 -1
  79. package/lib/module/recycler/CellPool.js +41 -0
  80. package/lib/module/recycler/CellPool.js.map +1 -0
  81. package/lib/module/recycler/RecyclerList.js +221 -0
  82. package/lib/module/recycler/RecyclerList.js.map +1 -0
  83. package/lib/module/types/Axis.js +2 -0
  84. package/lib/module/types/Axis.js.map +1 -0
  85. package/lib/module/types/CellKey.js +2 -0
  86. package/lib/module/types/CellKey.js.map +1 -0
  87. package/lib/module/types/CellType.js +2 -0
  88. package/lib/module/types/CellType.js.map +1 -0
  89. package/lib/module/types/VisibleRange.js +2 -0
  90. package/lib/module/types/VisibleRange.js.map +1 -0
  91. package/lib/module/types/VisibleRangeInput.js +4 -0
  92. package/lib/module/types/VisibleRangeInput.js.map +1 -0
  93. package/lib/module/types/index.js +4 -0
  94. package/lib/module/types/index.js.map +1 -0
  95. package/lib/module/types/layout/LayoutRect.js +2 -0
  96. package/lib/module/types/layout/LayoutRect.js.map +1 -0
  97. package/lib/module/types/layout/LinearLayoutInput.js +4 -0
  98. package/lib/module/types/layout/LinearLayoutInput.js.map +1 -0
  99. package/lib/module/types/layout/MainAxisPadding.js +22 -0
  100. package/lib/module/types/layout/MainAxisPadding.js.map +1 -0
  101. package/lib/module/types/layout/index.js +2 -0
  102. package/lib/module/types/layout/index.js.map +1 -0
  103. package/lib/module/types/recycler/RecyclerCellInstance.js +4 -0
  104. package/lib/module/types/recycler/RecyclerCellInstance.js.map +1 -0
  105. package/lib/module/types/recycler/RecyclerItemRenderer.js +4 -0
  106. package/lib/module/types/recycler/RecyclerItemRenderer.js.map +1 -0
  107. package/lib/module/types/recycler/RecyclerListProps.js +4 -0
  108. package/lib/module/types/recycler/RecyclerListProps.js.map +1 -0
  109. package/lib/module/types/recycler/index.js +2 -0
  110. package/lib/module/types/recycler/index.js.map +1 -0
  111. package/lib/module/types/scroll/ScrollMetrics.js +4 -0
  112. package/lib/module/types/scroll/ScrollMetrics.js.map +1 -0
  113. package/lib/module/types/scroll/index.js +2 -0
  114. package/lib/module/types/scroll/index.js.map +1 -0
  115. package/lib/module/windowing/computeVisibleItemRange.js +67 -0
  116. package/lib/module/windowing/computeVisibleItemRange.js.map +1 -0
  117. package/lib/module/windowing/index.js +1 -1
  118. package/lib/module/windowing/index.js.map +1 -1
  119. package/lib/typescript/src/cell/Cell.d.ts +13 -4
  120. package/lib/typescript/src/cell/Cell.d.ts.map +1 -1
  121. package/lib/typescript/src/cell/CellKeyGenerator.d.ts +11 -0
  122. package/lib/typescript/src/cell/CellKeyGenerator.d.ts.map +1 -0
  123. package/lib/typescript/src/cell/CellRecycler.d.ts +19 -11
  124. package/lib/typescript/src/cell/CellRecycler.d.ts.map +1 -1
  125. package/lib/typescript/src/cell/createCell.d.ts +7 -0
  126. package/lib/typescript/src/cell/createCell.d.ts.map +1 -0
  127. package/lib/typescript/src/cell/index.d.ts +4 -0
  128. package/lib/typescript/src/cell/index.d.ts.map +1 -0
  129. package/lib/typescript/src/getVisibleIndices.d.ts +2 -2
  130. package/lib/typescript/src/getVisibleIndices.d.ts.map +1 -1
  131. package/lib/typescript/src/hooks/usePersistentCallback.d.ts +16 -0
  132. package/lib/typescript/src/hooks/usePersistentCallback.d.ts.map +1 -0
  133. package/lib/typescript/src/index.d.ts +1 -2
  134. package/lib/typescript/src/index.d.ts.map +1 -1
  135. package/lib/typescript/src/layout/MutableLinearLayout.d.ts +45 -13
  136. package/lib/typescript/src/layout/MutableLinearLayout.d.ts.map +1 -1
  137. package/lib/typescript/src/layout/constants/layoutDefaults.d.ts +13 -0
  138. package/lib/typescript/src/layout/constants/layoutDefaults.d.ts.map +1 -0
  139. package/lib/typescript/src/layout/index.d.ts +1 -4
  140. package/lib/typescript/src/layout/index.d.ts.map +1 -1
  141. package/lib/typescript/src/native/NitroList.types.d.ts +2 -2
  142. package/lib/typescript/src/native/NitroList.types.d.ts.map +1 -1
  143. package/lib/typescript/src/recycler/CellPool.d.ts +14 -0
  144. package/lib/typescript/src/recycler/CellPool.d.ts.map +1 -0
  145. package/lib/typescript/src/recycler/RecyclerList.d.ts +4 -0
  146. package/lib/typescript/src/recycler/RecyclerList.d.ts.map +1 -0
  147. package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +2 -2
  148. package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +1 -1
  149. package/lib/typescript/src/types/Axis.d.ts +11 -0
  150. package/lib/typescript/src/types/Axis.d.ts.map +1 -0
  151. package/lib/typescript/src/types/CellKey.d.ts +10 -0
  152. package/lib/typescript/src/types/CellKey.d.ts.map +1 -0
  153. package/lib/typescript/src/types/CellType.d.ts +11 -0
  154. package/lib/typescript/src/types/CellType.d.ts.map +1 -0
  155. package/lib/typescript/src/types/VisibleRange.d.ts +10 -0
  156. package/lib/typescript/src/types/VisibleRange.d.ts.map +1 -0
  157. package/lib/typescript/src/types/VisibleRangeInput.d.ts +35 -0
  158. package/lib/typescript/src/types/VisibleRangeInput.d.ts.map +1 -0
  159. package/lib/typescript/src/types/index.d.ts +8 -0
  160. package/lib/typescript/src/types/index.d.ts.map +1 -0
  161. package/lib/typescript/src/types/layout/LayoutRect.d.ts +15 -0
  162. package/lib/typescript/src/types/layout/LayoutRect.d.ts.map +1 -0
  163. package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts +10 -0
  164. package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts.map +1 -0
  165. package/lib/typescript/src/types/layout/MainAxisPadding.d.ts +20 -0
  166. package/lib/typescript/src/types/layout/MainAxisPadding.d.ts.map +1 -0
  167. package/lib/typescript/src/types/layout/index.d.ts +4 -0
  168. package/lib/typescript/src/types/layout/index.d.ts.map +1 -0
  169. package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts +37 -0
  170. package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts.map +1 -0
  171. package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts +8 -0
  172. package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts.map +1 -0
  173. package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts +66 -0
  174. package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts.map +1 -0
  175. package/lib/typescript/src/types/recycler/index.d.ts +4 -0
  176. package/lib/typescript/src/types/recycler/index.d.ts.map +1 -0
  177. package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts +15 -0
  178. package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts.map +1 -0
  179. package/lib/typescript/src/types/scroll/index.d.ts +2 -0
  180. package/lib/typescript/src/types/scroll/index.d.ts.map +1 -0
  181. package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts +15 -0
  182. package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts.map +1 -0
  183. package/lib/typescript/src/windowing/index.d.ts +1 -1
  184. package/lib/typescript/src/windowing/index.d.ts.map +1 -1
  185. package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.cpp +7 -7
  186. package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.hpp +1 -1
  187. package/nitrogen/generated/android/c++/{JLayoutRectangle.hpp → JLayoutRect.hpp} +10 -10
  188. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/HybridNitroLayoutEngineSpec.kt +1 -1
  189. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{LayoutRectangle.kt → LayoutRect.kt} +5 -5
  190. package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +14 -14
  191. package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +3 -3
  192. package/nitrogen/generated/ios/c++/HybridNitroLayoutEngineSpecSwift.hpp +4 -4
  193. package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +1 -1
  194. package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec_cxx.swift +5 -5
  195. package/nitrogen/generated/ios/swift/{LayoutRectangle.swift → LayoutRect.swift} +5 -5
  196. package/nitrogen/generated/shared/c++/HybridNitroLayoutEngineSpec.hpp +4 -4
  197. package/nitrogen/generated/shared/c++/{LayoutRectangle.hpp → LayoutRect.hpp} +11 -11
  198. package/package.json +1 -1
  199. package/src/cell/Cell.ts +13 -4
  200. package/src/cell/CellKeyGenerator.ts +17 -0
  201. package/src/cell/CellRecycler.ts +53 -43
  202. package/src/cell/createCell.ts +15 -0
  203. package/src/cell/index.ts +5 -0
  204. package/src/getVisibleIndices.ts +4 -2
  205. package/src/hooks/usePersistentCallback.ts +37 -0
  206. package/src/index.ts +1 -2
  207. package/src/layout/MutableLinearLayout.ts +91 -58
  208. package/src/layout/constants/layoutDefaults.ts +12 -0
  209. package/src/layout/index.ts +1 -4
  210. package/src/native/NitroList.types.ts +3 -2
  211. package/src/recycler/CellPool.ts +47 -0
  212. package/src/recycler/RecyclerList.tsx +304 -0
  213. package/src/specs/nitro-layout-engine.nitro.ts +2 -2
  214. package/src/types/Axis.ts +10 -0
  215. package/src/types/CellKey.ts +9 -0
  216. package/src/types/CellType.ts +10 -0
  217. package/src/types/VisibleRange.ts +9 -0
  218. package/src/types/VisibleRangeInput.ts +39 -0
  219. package/src/types/index.ts +15 -0
  220. package/src/types/layout/LayoutRect.ts +14 -0
  221. package/src/types/layout/LinearLayoutInput.ts +12 -0
  222. package/src/types/layout/MainAxisPadding.ts +23 -0
  223. package/src/types/layout/index.ts +3 -0
  224. package/src/types/recycler/RecyclerCellInstance.ts +40 -0
  225. package/src/types/recycler/RecyclerItemRenderer.ts +8 -0
  226. package/src/types/recycler/RecyclerListProps.ts +74 -0
  227. package/src/types/recycler/index.ts +3 -0
  228. package/src/types/scroll/ScrollMetrics.ts +18 -0
  229. package/src/types/scroll/index.ts +1 -0
  230. package/src/windowing/computeVisibleItemRange.ts +78 -0
  231. package/src/windowing/index.ts +1 -1
  232. package/lib/commonjs/RecyclerList.internal.js +0 -25
  233. package/lib/commonjs/RecyclerList.internal.js.map +0 -1
  234. package/lib/commonjs/RecyclerList.js +0 -171
  235. package/lib/commonjs/RecyclerList.js.map +0 -1
  236. package/lib/commonjs/RecyclerList.types.js.map +0 -1
  237. package/lib/commonjs/cell/StableKey.js +0 -10
  238. package/lib/commonjs/cell/StableKey.js.map +0 -1
  239. package/lib/commonjs/hooks/useCellRenderer.js +0 -62
  240. package/lib/commonjs/hooks/useCellRenderer.js.map +0 -1
  241. package/lib/commonjs/hooks/useStableCallback.js +0 -13
  242. package/lib/commonjs/hooks/useStableCallback.js.map +0 -1
  243. package/lib/commonjs/layout/EstimatedLayoutProvider.js +0 -30
  244. package/lib/commonjs/layout/EstimatedLayoutProvider.js.map +0 -1
  245. package/lib/commonjs/layout/LayoutEngine.js +0 -21
  246. package/lib/commonjs/layout/LayoutEngine.js.map +0 -1
  247. package/lib/commonjs/layout/LayoutRectangle.js +0 -2
  248. package/lib/commonjs/viewability/ViewabilityHelper.js +0 -121
  249. package/lib/commonjs/viewability/ViewabilityHelper.js.map +0 -1
  250. package/lib/commonjs/windowing/findVisibleIndexRange.js +0 -48
  251. package/lib/commonjs/windowing/findVisibleIndexRange.js.map +0 -1
  252. package/lib/module/RecyclerList.internal.js +0 -22
  253. package/lib/module/RecyclerList.internal.js.map +0 -1
  254. package/lib/module/RecyclerList.js +0 -166
  255. package/lib/module/RecyclerList.js.map +0 -1
  256. package/lib/module/RecyclerList.types.js +0 -4
  257. package/lib/module/RecyclerList.types.js.map +0 -1
  258. package/lib/module/cell/StableKey.js +0 -6
  259. package/lib/module/cell/StableKey.js.map +0 -1
  260. package/lib/module/hooks/useCellRenderer.js +0 -58
  261. package/lib/module/hooks/useCellRenderer.js.map +0 -1
  262. package/lib/module/hooks/useStableCallback.js +0 -9
  263. package/lib/module/hooks/useStableCallback.js.map +0 -1
  264. package/lib/module/layout/EstimatedLayoutProvider.js +0 -25
  265. package/lib/module/layout/EstimatedLayoutProvider.js.map +0 -1
  266. package/lib/module/layout/LayoutEngine.js +0 -17
  267. package/lib/module/layout/LayoutEngine.js.map +0 -1
  268. package/lib/module/layout/LayoutProvider.js +0 -4
  269. package/lib/module/layout/LayoutRectangle.js +0 -2
  270. package/lib/module/viewability/ViewabilityHelper.js +0 -116
  271. package/lib/module/viewability/ViewabilityHelper.js.map +0 -1
  272. package/lib/module/windowing/findVisibleIndexRange.js +0 -44
  273. package/lib/module/windowing/findVisibleIndexRange.js.map +0 -1
  274. package/lib/typescript/src/RecyclerList.d.ts +0 -26
  275. package/lib/typescript/src/RecyclerList.d.ts.map +0 -1
  276. package/lib/typescript/src/RecyclerList.internal.d.ts +0 -9
  277. package/lib/typescript/src/RecyclerList.internal.d.ts.map +0 -1
  278. package/lib/typescript/src/RecyclerList.types.d.ts +0 -18
  279. package/lib/typescript/src/RecyclerList.types.d.ts.map +0 -1
  280. package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts +0 -2
  281. package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts.map +0 -1
  282. package/lib/typescript/src/cell/StableKey.d.ts +0 -2
  283. package/lib/typescript/src/cell/StableKey.d.ts.map +0 -1
  284. package/lib/typescript/src/hooks/useCellRenderer.d.ts +0 -19
  285. package/lib/typescript/src/hooks/useCellRenderer.d.ts.map +0 -1
  286. package/lib/typescript/src/hooks/useStableCallback.d.ts +0 -2
  287. package/lib/typescript/src/hooks/useStableCallback.d.ts.map +0 -1
  288. package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts +0 -15
  289. package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts.map +0 -1
  290. package/lib/typescript/src/layout/LayoutEngine.d.ts +0 -10
  291. package/lib/typescript/src/layout/LayoutEngine.d.ts.map +0 -1
  292. package/lib/typescript/src/layout/LayoutProvider.d.ts +0 -16
  293. package/lib/typescript/src/layout/LayoutProvider.d.ts.map +0 -1
  294. package/lib/typescript/src/layout/LayoutRectangle.d.ts +0 -11
  295. package/lib/typescript/src/layout/LayoutRectangle.d.ts.map +0 -1
  296. package/lib/typescript/src/viewability/ViewabilityHelper.d.ts +0 -50
  297. package/lib/typescript/src/viewability/ViewabilityHelper.d.ts.map +0 -1
  298. package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts +0 -11
  299. package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts.map +0 -1
  300. package/src/RecyclerList.internal.ts +0 -38
  301. package/src/RecyclerList.tsx +0 -252
  302. package/src/RecyclerList.types.ts +0 -24
  303. package/src/__tests__/windowing/findVisibleIndexRange.test.ts +0 -55
  304. package/src/cell/StableKey.ts +0 -6
  305. package/src/hooks/useCellRenderer.ts +0 -86
  306. package/src/hooks/useStableCallback.ts +0 -13
  307. package/src/layout/EstimatedLayoutProvider.ts +0 -35
  308. package/src/layout/LayoutEngine.ts +0 -21
  309. package/src/layout/LayoutProvider.ts +0 -17
  310. package/src/layout/LayoutRectangle.ts +0 -10
  311. package/src/viewability/ViewabilityHelper.ts +0 -130
  312. package/src/windowing/findVisibleIndexRange.ts +0 -60
@@ -1 +0,0 @@
1
- {"version":3,"names":["ViewabilityHelper","lastVisible","Set","constructor","config","computeViewableItems","layouts","metrics","visibleNow","viewableItems","changed","viewportTop","offsetY","viewportBottom","height","threshold","itemVisiblePercentThreshold","i","length","layout","y","itemTop","itemBottom","visibleTop","Math","max","visibleBottom","min","visibleHeight","itemHeight","visibleRatio","add","push","index","isViewable","has"],"sourceRoot":"../../../src","sources":["viewability/ViewabilityHelper.ts"],"mappings":";;AAGA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,iBAAiB,CAAC;EAC7B;EACQC,WAAW,GAAG,IAAIC,GAAG,CAAS,CAAC;EAEvCC,WAAWA,CACQC,MAAyB,GAAG,CAAC,CAAC,EAC/C;IAAA,KADiBA,MAAyB,GAAzBA,MAAyB;EACzC;;EAEH;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,oBAAoBA,CAClBC,OAAmC,EACnCC,OAAsB,EAItB;IACA,MAAMC,UAAU,GAAG,IAAIN,GAAG,CAAS,CAAC;IACpC,MAAMO,aAA0B,GAAG,EAAE;IACrC,MAAMC,OAAoB,GAAG,EAAE;IAE/B,MAAMC,WAAW,GAAGJ,OAAO,CAACK,OAAO;IACnC,MAAMC,cAAc,GAAGF,WAAW,GAAGJ,OAAO,CAACO,MAAM;;IAEnD;IACA,MAAMC,SAAS,GACb,CAAC,IAAI,CAACX,MAAM,CAACY,2BAA2B,IAAI,CAAC,IAAI,GAAG;;IAEtD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;IACI,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGX,OAAO,CAACY,MAAM,EAAED,CAAC,EAAE,EAAE;MACvC,MAAME,MAAM,GAAGb,OAAO,CAACW,CAAC,CAAE;;MAE1B;MACA,IAAIE,MAAM,CAACC,CAAC,GAAGP,cAAc,EAAE;QAC7B;MACF;MAEA,MAAMQ,OAAO,GAAGF,MAAM,CAACC,CAAC;MACxB,MAAME,UAAU,GAAGH,MAAM,CAACC,CAAC,GAAGD,MAAM,CAACL,MAAM;;MAE3C;MACA,IAAIQ,UAAU,GAAGX,WAAW,EAAE;QAC5B;MACF;;MAEA;MACA,MAAMY,UAAU,GAAGC,IAAI,CAACC,GAAG,CAACJ,OAAO,EAAEV,WAAW,CAAC;MACjD,MAAMe,aAAa,GAAGF,IAAI,CAACG,GAAG,CAACL,UAAU,EAAET,cAAc,CAAC;MAE1D,MAAMe,aAAa,GAAGJ,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEC,aAAa,GAAGH,UAAU,CAAC;;MAE7D;MACA,MAAMM,UAAU,GACdV,MAAM,CAACL,MAAM,GAAG,CAAC,GAAGK,MAAM,CAACL,MAAM,GAAG,CAAC;MAEvC,MAAMgB,YAAY,GAAGF,aAAa,GAAGC,UAAU;MAE/C,IAAIC,YAAY,IAAIf,SAAS,EAAE;QAC7BP,UAAU,CAACuB,GAAG,CAACd,CAAC,CAAC;QACjBR,aAAa,CAACuB,IAAI,CAAC;UAAEC,KAAK,EAAEhB,CAAC;UAAEiB,UAAU,EAAE;QAAK,CAAC,CAAC;;QAElD;QACA,IAAI,CAAC,IAAI,CAACjC,WAAW,CAACkC,GAAG,CAAClB,CAAC,CAAC,EAAE;UAC5BP,OAAO,CAACsB,IAAI,CAAC;YAAEC,KAAK,EAAEhB,CAAC;YAAEiB,UAAU,EAAE;UAAK,CAAC,CAAC;QAC9C;MACF;IACF;;IAEA;AACJ;AACA;IACI,KAAK,MAAMD,KAAK,IAAI,IAAI,CAAChC,WAAW,EAAE;MACpC,IAAI,CAACO,UAAU,CAAC2B,GAAG,CAACF,KAAK,CAAC,EAAE;QAC1BvB,OAAO,CAACsB,IAAI,CAAC;UAAEC,KAAK;UAAEC,UAAU,EAAE;QAAM,CAAC,CAAC;MAC5C;IACF;;IAEA;IACA,IAAI,CAACjC,WAAW,GAAGO,UAAU;IAE7B,OAAO;MAAEC,aAAa;MAAEC;IAAQ,CAAC;EACnC;AACF","ignoreList":[]}
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Computes the contiguous range of item indices
5
- * intersecting the viewport expanded by bufferPx.
6
- *
7
- * PURE function. No allocations besides output.
8
- * FlashList-style windowing.
9
- */
10
- export function findVisibleIndexRange(layouts, metrics, bufferPx) {
11
- const count = layouts.length;
12
-
13
- // 🔒 CRITICAL GUARDS (FlashList-style)
14
- if (count === 0 || metrics.height <= 0 || bufferPx < 0) {
15
- return [];
16
- }
17
- const windowStart = Math.max(0, metrics.offsetY - bufferPx);
18
- const windowEnd = metrics.offsetY + metrics.height + bufferPx;
19
-
20
- // Binary search for first intersecting item
21
- let low = 0;
22
- let high = count - 1;
23
- let firstVisible = count;
24
- while (low <= high) {
25
- const mid = low + high >> 1;
26
- const rect = layouts[mid];
27
- if (rect.y + rect.height >= windowStart) {
28
- firstVisible = mid;
29
- high = mid - 1;
30
- } else {
31
- low = mid + 1;
32
- }
33
- }
34
-
35
- // Linear scan forward
36
- const visible = [];
37
- for (let i = firstVisible; i < count; i++) {
38
- const rect = layouts[i];
39
- if (rect.y > windowEnd) break;
40
- visible.push(i);
41
- }
42
- return visible;
43
- }
44
- //# sourceMappingURL=findVisibleIndexRange.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["findVisibleIndexRange","layouts","metrics","bufferPx","count","length","height","windowStart","Math","max","offsetY","windowEnd","low","high","firstVisible","mid","rect","y","visible","i","push"],"sourceRoot":"../../../src","sources":["windowing/findVisibleIndexRange.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qBAAqBA,CACnCC,OAAmC,EACnCC,OAAsB,EACtBC,QAAgB,EACG;EACnB,MAAMC,KAAK,GAAGH,OAAO,CAACI,MAAM;;EAE5B;EACA,IACED,KAAK,KAAK,CAAC,IACXF,OAAO,CAACI,MAAM,IAAI,CAAC,IACnBH,QAAQ,GAAG,CAAC,EACZ;IACA,OAAO,EAAE;EACX;EAEA,MAAMI,WAAW,GACfC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEP,OAAO,CAACQ,OAAO,GAAGP,QAAQ,CAAC;EAEzC,MAAMQ,SAAS,GACbT,OAAO,CAACQ,OAAO,GAAGR,OAAO,CAACI,MAAM,GAAGH,QAAQ;;EAE7C;EACA,IAAIS,GAAG,GAAG,CAAC;EACX,IAAIC,IAAI,GAAGT,KAAK,GAAG,CAAC;EACpB,IAAIU,YAAY,GAAGV,KAAK;EAExB,OAAOQ,GAAG,IAAIC,IAAI,EAAE;IAClB,MAAME,GAAG,GAAIH,GAAG,GAAGC,IAAI,IAAK,CAAC;IAC7B,MAAMG,IAAI,GAAGf,OAAO,CAACc,GAAG,CAAE;IAE1B,IAAIC,IAAI,CAACC,CAAC,GAAGD,IAAI,CAACV,MAAM,IAAIC,WAAW,EAAE;MACvCO,YAAY,GAAGC,GAAG;MAClBF,IAAI,GAAGE,GAAG,GAAG,CAAC;IAChB,CAAC,MAAM;MACLH,GAAG,GAAGG,GAAG,GAAG,CAAC;IACf;EACF;;EAEA;EACA,MAAMG,OAAiB,GAAG,EAAE;EAE5B,KAAK,IAAIC,CAAC,GAAGL,YAAY,EAAEK,CAAC,GAAGf,KAAK,EAAEe,CAAC,EAAE,EAAE;IACzC,MAAMH,IAAI,GAAGf,OAAO,CAACkB,CAAC,CAAE;IACxB,IAAIH,IAAI,CAACC,CAAC,GAAGN,SAAS,EAAE;IACxBO,OAAO,CAACE,IAAI,CAACD,CAAC,CAAC;EACjB;EAEA,OAAOD,OAAO;AAChB","ignoreList":[]}
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- /**
3
- * Public API — mirrors FlashList behavior, not internals.
4
- */
5
- export type RecyclerListProps = {
6
- containerWidth: number;
7
- itemCount?: number;
8
- itemHeights?: readonly number[];
9
- estimatedItemHeight?: number;
10
- renderBufferRatio?: number;
11
- getItemType?: (index: number) => string;
12
- renderItem: (index: number) => React.ReactElement;
13
- onPrefetch?: (indices: number[]) => void;
14
- onViewableItemsChanged?: (info: {
15
- viewableItems: {
16
- index: number;
17
- isViewable: boolean;
18
- }[];
19
- changed: {
20
- index: number;
21
- isViewable: boolean;
22
- }[];
23
- }) => void;
24
- };
25
- export declare function RecyclerList(props: RecyclerListProps): React.ReactElement;
26
- //# sourceMappingURL=RecyclerList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RecyclerList.d.ts","sourceRoot":"","sources":["../../../src/RecyclerList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAIN,MAAM,OAAO,CAAA;AAgBd;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACvC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,YAAY,CAAA;IACjD,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACxC,sBAAsB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC9B,aAAa,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,OAAO,CAAA;SAAE,EAAE,CAAA;QACvD,OAAO,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,OAAO,CAAA;SAAE,EAAE,CAAA;KAClD,KAAK,IAAI,CAAA;CACX,CAAA;AAQD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAyMzE"}
@@ -1,9 +0,0 @@
1
- import type { LayoutRectangle } from './layout/LayoutRectangle';
2
- import type { ScrollMetrics } from './windowing/ScrollMetrics';
3
- import type { Cell } from './cell/Cell';
4
- /**
5
- * INTERNAL hook.
6
- * MUST ALWAYS CALL hooks in the same order.
7
- */
8
- export declare function useRecyclerListInternal(layouts: readonly LayoutRectangle[], metrics: ScrollMetrics, bufferPx: number, getItemType: (index: number) => string): readonly Cell[];
9
- //# sourceMappingURL=RecyclerList.internal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RecyclerList.internal.d.ts","sourceRoot":"","sources":["../../../src/RecyclerList.internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAIvC;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GACrC,SAAS,IAAI,EAAE,CAmBjB"}
@@ -1,18 +0,0 @@
1
- import type React from 'react';
2
- export type RecyclerListProps = {
3
- /** Width of the list container (required) */
4
- readonly containerWidth: number;
5
- /** Total number of items (used with estimatedItemHeight) */
6
- readonly itemCount?: number;
7
- /** Explicit item heights (fast path, skips estimation) */
8
- readonly itemHeights?: readonly number[];
9
- /** Estimated item height when itemHeights not provided */
10
- readonly estimatedItemHeight?: number;
11
- /** Render buffer multiplier (FlashList-style, default ~1.3) */
12
- readonly renderBufferRatio?: number;
13
- /** Optional item type resolver for recycling */
14
- readonly getItemType?: (index: number) => string;
15
- /** Render function */
16
- readonly renderItem: (index: number) => React.ReactElement;
17
- };
18
- //# sourceMappingURL=RecyclerList.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RecyclerList.types.d.ts","sourceRoot":"","sources":["../../../src/RecyclerList.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAE/B,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAE3B,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAExC,0DAA0D;IAC1D,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAErC,+DAA+D;IAC/D,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAEnC,gDAAgD;IAChD,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAEhD,sBAAsB;IACtB,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,YAAY,CAAA;CAC3D,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=findVisibleIndexRange.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findVisibleIndexRange.test.d.ts","sourceRoot":"","sources":["../../../../../src/__tests__/windowing/findVisibleIndexRange.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export declare function getStableKey(slotKey: string, index: number): string;
2
- //# sourceMappingURL=StableKey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StableKey.d.ts","sourceRoot":"","sources":["../../../../src/cell/StableKey.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,MAAM,CAER"}
@@ -1,19 +0,0 @@
1
- import type { Cell } from '../cell/Cell';
2
- import type { LayoutRectangle } from '../layout/LayoutRectangle';
3
- import type { ScrollMetrics } from '../windowing/ScrollMetrics';
4
- /**
5
- * React bridge for CellRecycler.
6
- * FlashList equivalent: useCellRenderer
7
- *
8
- * Responsibilities:
9
- * - Translate scroll state → visible indices
10
- * - Ask recycler for physical cells
11
- * - Commit results with referential stability
12
- *
13
- * Responsibilities it does NOT have:
14
- * ❌ Layout mutation
15
- * ❌ Measurement
16
- * ❌ Rendering
17
- */
18
- export declare function useCellRenderer(layouts: readonly LayoutRectangle[], metrics: ScrollMetrics, bufferPx: number, getCellType: (index: number) => string): readonly Cell[];
19
- //# sourceMappingURL=useCellRenderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCellRenderer.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCellRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAQ/D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GACrC,SAAS,IAAI,EAAE,CAqDjB"}
@@ -1,2 +0,0 @@
1
- export declare function useStableCallback<T extends (...args: never[]) => unknown>(fn: T): T;
2
- //# sourceMappingURL=useStableCallback.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useStableCallback.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useStableCallback.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACvE,EAAE,EAAE,CAAC,GACJ,CAAC,CAQH"}
@@ -1,15 +0,0 @@
1
- import type { LayoutProvider } from './LayoutProvider';
2
- import type { LayoutRectangle } from './LayoutRectangle';
3
- /**
4
- * Layout provider using estimated item heights.
5
- * Used before real measurements are available.
6
- */
7
- export declare class EstimatedLayoutProvider implements LayoutProvider {
8
- private readonly itemCount;
9
- private readonly itemHeight;
10
- private readonly width;
11
- constructor(itemCount: number, itemHeight: number, width: number);
12
- getItemCount(): number;
13
- getLayout(index: number): LayoutRectangle;
14
- }
15
- //# sourceMappingURL=EstimatedLayoutProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EstimatedLayoutProvider.d.ts","sourceRoot":"","sources":["../../../../src/layout/EstimatedLayoutProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,cAAc;IAC5D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;gBAG5B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM;IAOf,YAAY,IAAI,MAAM;IAItB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe;CAQ1C"}
@@ -1,10 +0,0 @@
1
- import type { LayoutProvider } from './LayoutProvider';
2
- import type { LayoutRectangle } from './LayoutRectangle';
3
- /**
4
- * Resolves layouts eagerly into a contiguous array.
5
- * Pure, deterministic, and reusable.
6
- *
7
- * FlashList equivalent: internal layout resolver.
8
- */
9
- export declare function computeLayouts(provider: LayoutProvider): readonly LayoutRectangle[];
10
- //# sourceMappingURL=LayoutEngine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LayoutEngine.d.ts","sourceRoot":"","sources":["../../../../src/layout/LayoutEngine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,cAAc,GACvB,SAAS,eAAe,EAAE,CAS5B"}
@@ -1,16 +0,0 @@
1
- import type { LayoutRectangle } from './LayoutRectangle';
2
- /**
3
- * Provides layout information for items.
4
- * FlashList equivalent: LayoutProvider
5
- */
6
- export interface LayoutProvider {
7
- /**
8
- * Total number of items
9
- */
10
- getItemCount(): number;
11
- /**
12
- * Layout rectangle for a given index
13
- */
14
- getLayout(index: number): LayoutRectangle;
15
- }
16
- //# sourceMappingURL=LayoutProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LayoutProvider.d.ts","sourceRoot":"","sources":["../../../../src/layout/LayoutProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,YAAY,IAAI,MAAM,CAAA;IAEtB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAAA;CAC1C"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Immutable layout rectangle for a single item.
3
- * Equivalent to FlashList's Layout.
4
- */
5
- export interface LayoutRectangle {
6
- readonly x: number;
7
- readonly y: number;
8
- readonly width: number;
9
- readonly height: number;
10
- }
11
- //# sourceMappingURL=LayoutRectangle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LayoutRectangle.d.ts","sourceRoot":"","sources":["../../../../src/layout/LayoutRectangle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB"}
@@ -1,50 +0,0 @@
1
- import type { LayoutRectangle } from '../layout/LayoutRectangle';
2
- import type { ScrollMetrics } from '../windowing/ScrollMetrics';
3
- /**
4
- * Public token describing viewability state of an item.
5
- * Mirrors FlashList's ViewToken concept.
6
- */
7
- export type ViewToken = {
8
- index: number;
9
- isViewable: boolean;
10
- };
11
- /**
12
- * Configuration for viewability calculations.
13
- */
14
- export type ViewabilityConfig = {
15
- /**
16
- * Percentage (0–100) of item height that must be visible
17
- * for the item to be considered "viewable".
18
- */
19
- itemVisiblePercentThreshold?: number;
20
- };
21
- /**
22
- * ViewabilityHelper
23
- *
24
- * Pure observer:
25
- * - Does NOT affect layout
26
- * - Does NOT affect recycling
27
- * - Computes visibility based on layout + scroll metrics
28
- *
29
- * This class is intentionally stateful (lastVisible)
30
- * to compute "changed" items efficiently.
31
- */
32
- export declare class ViewabilityHelper {
33
- private readonly config;
34
- /** Previously visible indices */
35
- private lastVisible;
36
- constructor(config?: ViewabilityConfig);
37
- /**
38
- * Computes which items are viewable and which changed
39
- * since the last invocation.
40
- *
41
- * IMPORTANT:
42
- * - This method should be called AFTER windowing,
43
- * not on the full dataset.
44
- */
45
- computeViewableItems(layouts: readonly LayoutRectangle[], metrics: ScrollMetrics): {
46
- viewableItems: ViewToken[];
47
- changed: ViewToken[];
48
- };
49
- }
50
- //# sourceMappingURL=ViewabilityHelper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ViewabilityHelper.d.ts","sourceRoot":"","sources":["../../../../src/viewability/ViewabilityHelper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE/D;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAA;CACrC,CAAA;AAED;;;;;;;;;;GAUG;AACH,qBAAa,iBAAiB;IAK1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,iCAAiC;IACjC,OAAO,CAAC,WAAW,CAAoB;gBAGpB,MAAM,GAAE,iBAAsB;IAGjD;;;;;;;OAOG;IACH,oBAAoB,CAClB,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,OAAO,EAAE,aAAa,GACrB;QACD,aAAa,EAAE,SAAS,EAAE,CAAA;QAC1B,OAAO,EAAE,SAAS,EAAE,CAAA;KACrB;CAyEF"}
@@ -1,11 +0,0 @@
1
- import type { LayoutRectangle } from '../layout/LayoutRectangle';
2
- import type { ScrollMetrics } from './ScrollMetrics';
3
- /**
4
- * Computes the contiguous range of item indices
5
- * intersecting the viewport expanded by bufferPx.
6
- *
7
- * PURE function. No allocations besides output.
8
- * FlashList-style windowing.
9
- */
10
- export declare function findVisibleIndexRange(layouts: readonly LayoutRectangle[], metrics: ScrollMetrics, bufferPx: number): readonly number[];
11
- //# sourceMappingURL=findVisibleIndexRange.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findVisibleIndexRange.d.ts","sourceRoot":"","sources":["../../../../src/windowing/findVisibleIndexRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,GACf,SAAS,MAAM,EAAE,CA6CnB"}
@@ -1,38 +0,0 @@
1
- import type { LayoutRectangle } from './layout/LayoutRectangle'
2
- import type { ScrollMetrics } from './windowing/ScrollMetrics'
3
- import type { Cell } from './cell/Cell'
4
-
5
- import { useCellRenderer } from './hooks/useCellRenderer'
6
-
7
- /**
8
- * INTERNAL hook.
9
- * MUST ALWAYS CALL hooks in the same order.
10
- */
11
- export function useRecyclerListInternal(
12
- layouts: readonly LayoutRectangle[],
13
- metrics: ScrollMetrics,
14
- bufferPx: number,
15
- getItemType: (index: number) => string
16
- ): readonly Cell[] {
17
-
18
- /**
19
- * FlashList rule:
20
- * Hooks are ALWAYS called.
21
- * Inputs are guarded instead.
22
- */
23
- const safeLayouts =
24
- metrics.height > 0 ? layouts : EMPTY_LAYOUTS
25
-
26
- const safeBufferPx =
27
- metrics.height > 0 ? bufferPx : 0
28
-
29
- return useCellRenderer(
30
- safeLayouts,
31
- metrics,
32
- safeBufferPx,
33
- getItemType
34
- )
35
- }
36
-
37
- /** Stable empty reference */
38
- const EMPTY_LAYOUTS: readonly LayoutRectangle[] = []
@@ -1,252 +0,0 @@
1
- import React, {
2
- useMemo,
3
- useRef,
4
- useEffect,
5
- } from 'react'
6
- import {
7
- ScrollView,
8
- View,
9
- StyleSheet,
10
- } from 'react-native'
11
-
12
- import type { Cell } from './cell/Cell'
13
- import type { LayoutRectangle } from './layout/LayoutRectangle'
14
-
15
- import { useRecyclerListInternal } from './RecyclerList.internal'
16
- import { useScrollMetrics } from './windowing'
17
- import { MutableLinearLayout } from './layout/MutableLinearLayout'
18
- import { ViewabilityHelper } from './viewability/ViewabilityHelper'
19
- import { PrefetchHelper } from './prefetch/PrefetchHelper'
20
-
21
- /**
22
- * Public API — mirrors FlashList behavior, not internals.
23
- */
24
- export type RecyclerListProps = {
25
- containerWidth: number
26
- itemCount?: number
27
- itemHeights?: readonly number[]
28
- estimatedItemHeight?: number
29
- renderBufferRatio?: number
30
- getItemType?: (index: number) => string
31
- renderItem: (index: number) => React.ReactElement
32
- onPrefetch?: (indices: number[]) => void
33
- onViewableItemsChanged?: (info: {
34
- viewableItems: { index: number; isViewable: boolean }[]
35
- changed: { index: number; isViewable: boolean }[]
36
- }) => void
37
- }
38
-
39
- /**
40
- * FlashList invariant:
41
- * Never allow viewport height = 0 to gate windowing.
42
- */
43
- const DEFAULT_VIEWPORT_HEIGHT = 800
44
-
45
- export function RecyclerList(props: RecyclerListProps): React.ReactElement {
46
- const {
47
- containerWidth,
48
- itemCount,
49
- itemHeights,
50
- estimatedItemHeight = 80,
51
- renderBufferRatio = 1.3,
52
- getItemType = () => 'default',
53
- renderItem,
54
- onPrefetch,
55
- onViewableItemsChanged,
56
- } = props
57
-
58
- /**
59
- * 🚨 DEV WARNINGS ONLY (never throw in render!)
60
- */
61
- if (__DEV__) {
62
- if (!itemHeights && itemCount == null) {
63
- console.error(
64
- 'RecyclerList requires either itemCount or itemHeights.'
65
- )
66
- }
67
-
68
- if (itemHeights && itemCount != null) {
69
- console.error(
70
- 'Provide only one of itemCount or itemHeights.'
71
- )
72
- }
73
- }
74
-
75
- /**
76
- * STEP 1: Resolve item count safely (props only).
77
- * Never depend on hooks for structural decisions.
78
- */
79
- const itemLength =
80
- itemHeights?.length ??
81
- itemCount ??
82
- 0
83
-
84
- /**
85
- * STEP 2: Resolve initial heights (always defined).
86
- */
87
- const resolvedHeights = useMemo<readonly number[]>(() => {
88
- if (itemHeights) return itemHeights
89
-
90
- return Array.from(
91
- { length: itemLength },
92
- () => estimatedItemHeight
93
- )
94
- }, [itemHeights, itemLength, estimatedItemHeight])
95
-
96
- /**
97
- * STEP 3: Mutable layout lifecycle.
98
- * Recreate layout only when shape changes.
99
- */
100
- const layoutRef = useRef<MutableLinearLayout | null>(null)
101
- const lastLayoutKeyRef = useRef<string | null>(null)
102
-
103
- const layoutKey = `${containerWidth}-${itemLength}`
104
-
105
- if (
106
- !layoutRef.current ||
107
- lastLayoutKeyRef.current !== layoutKey
108
- ) {
109
- layoutRef.current = new MutableLinearLayout(
110
- resolvedHeights,
111
- containerWidth
112
- )
113
- lastLayoutKeyRef.current = layoutKey
114
- }
115
-
116
- /**
117
- * STEP 4: Read layout snapshot.
118
- */
119
- const layouts: readonly LayoutRectangle[] =
120
- layoutRef.current.getLayouts()
121
-
122
- const contentHeight =
123
- layoutRef.current.getContentHeight()
124
-
125
- /**
126
- * STEP 5: Scroll metrics.
127
- */
128
- const {
129
- metrics,
130
- onScroll,
131
- onLayout,
132
- } = useScrollMetrics()
133
-
134
- /**
135
- * STEP 6: Guard initial windowing.
136
- */
137
- const effectiveViewportHeight =
138
- metrics.height > 0
139
- ? metrics.height
140
- : DEFAULT_VIEWPORT_HEIGHT
141
-
142
- const bufferPx =
143
- effectiveViewportHeight * renderBufferRatio
144
-
145
- /**
146
- * STEP 7: Windowing + recycling.
147
- */
148
- const cells: readonly Cell[] =
149
- useRecyclerListInternal(
150
- layouts,
151
- metrics,
152
- bufferPx,
153
- getItemType
154
- )
155
-
156
- /**
157
- * STEP 8: Phase-1 observers.
158
- */
159
- const viewabilityRef = useRef(
160
- new ViewabilityHelper({
161
- itemVisiblePercentThreshold: 50,
162
- })
163
- )
164
-
165
- const prefetchRef = useRef(
166
- new PrefetchHelper()
167
- )
168
-
169
- useEffect(() => {
170
- prefetchRef.current = new PrefetchHelper()
171
- }, [itemLength])
172
-
173
- useEffect(() => {
174
- if (metrics.height === 0) return
175
-
176
- if (onViewableItemsChanged) {
177
- const visibleLayouts: LayoutRectangle[] = []
178
-
179
- for (const cell of cells) {
180
- const layout = layouts[cell.index]
181
- if (layout) visibleLayouts.push(layout)
182
- }
183
-
184
- const info =
185
- viewabilityRef.current.computeViewableItems(
186
- visibleLayouts,
187
- metrics
188
- )
189
-
190
- onViewableItemsChanged(info)
191
- }
192
-
193
- if (onPrefetch && itemLength > 0) {
194
- prefetchRef.current.runPrefetch(
195
- cells.map(c => c.index),
196
- itemLength,
197
- 5,
198
- onPrefetch
199
- )
200
- }
201
- }, [
202
- cells,
203
- metrics.offsetY,
204
- metrics.height,
205
- onViewableItemsChanged,
206
- onPrefetch,
207
- itemLength,
208
- layouts,
209
- ])
210
-
211
- /**
212
- * STEP 9: Render absolutely positioned cells.
213
- */
214
- return (
215
- <ScrollView
216
- style={styles.container}
217
- onLayout={onLayout}
218
- onScroll={onScroll}
219
- scrollEventThrottle={16}
220
- removeClippedSubviews
221
- >
222
- <View style={[styles.content, { height: contentHeight }]}>
223
- {cells.map(cell => {
224
- const layout = layouts[cell.index]
225
- if (!layout) return null
226
-
227
- return (
228
- <View
229
- key={cell.key}
230
- style={[
231
- styles.cell,
232
- {
233
- top: layout.y,
234
- width: layout.width,
235
- height: layout.height,
236
- },
237
- ]}
238
- >
239
- {renderItem(cell.index)}
240
- </View>
241
- )
242
- })}
243
- </View>
244
- </ScrollView>
245
- )
246
- }
247
-
248
- const styles = StyleSheet.create({
249
- container: { flex: 1 },
250
- content: { position: 'relative', width: '100%' },
251
- cell: { position: 'absolute', left: 0 },
252
- })
@@ -1,24 +0,0 @@
1
- import type React from 'react'
2
-
3
- export type RecyclerListProps = {
4
- /** Width of the list container (required) */
5
- readonly containerWidth: number
6
-
7
- /** Total number of items (used with estimatedItemHeight) */
8
- readonly itemCount?: number
9
-
10
- /** Explicit item heights (fast path, skips estimation) */
11
- readonly itemHeights?: readonly number[]
12
-
13
- /** Estimated item height when itemHeights not provided */
14
- readonly estimatedItemHeight?: number
15
-
16
- /** Render buffer multiplier (FlashList-style, default ~1.3) */
17
- readonly renderBufferRatio?: number
18
-
19
- /** Optional item type resolver for recycling */
20
- readonly getItemType?: (index: number) => string
21
-
22
- /** Render function */
23
- readonly renderItem: (index: number) => React.ReactElement
24
- }