react-native-nitro-list 0.0.1 → 0.1.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 (336) hide show
  1. package/README.md +250 -16
  2. package/android/build.gradle +5 -4
  3. package/android/src/main/java/com/nitrolist/HybridNitroRecyclerView.kt +26 -0
  4. package/android/src/main/java/com/nitrolist/HybridNitroRecyclerViewManager.kt +29 -0
  5. package/android/src/main/java/com/nitrolist/NitroListPackage.kt +13 -24
  6. package/android/src/main/java/com/nitrolist/NitroRecyclerAdapter.kt +32 -0
  7. package/android/src/main/java/com/nitrolist/NitroRecyclerViewHolder.kt +8 -0
  8. package/ios/HybridNitroList.swift +32 -15
  9. package/lib/commonjs/NitroList.js +9 -0
  10. package/lib/commonjs/NitroList.js.map +1 -0
  11. package/lib/commonjs/RecyclerList.internal.js +25 -0
  12. package/lib/commonjs/RecyclerList.internal.js.map +1 -0
  13. package/lib/commonjs/RecyclerList.js +171 -0
  14. package/lib/commonjs/RecyclerList.js.map +1 -0
  15. package/lib/commonjs/RecyclerList.types.js +6 -0
  16. package/lib/commonjs/RecyclerList.types.js.map +1 -0
  17. package/lib/commonjs/ReusableView.js +2 -0
  18. package/lib/commonjs/ReusableView.js.map +1 -0
  19. package/lib/commonjs/cell/Cell.js +2 -0
  20. package/lib/{module/specs/nitro-list.nitro.js.map → commonjs/cell/Cell.js.map} +1 -1
  21. package/lib/commonjs/cell/CellRecycler.js +62 -0
  22. package/lib/commonjs/cell/CellRecycler.js.map +1 -0
  23. package/lib/commonjs/cell/StableKey.js +10 -0
  24. package/lib/commonjs/cell/StableKey.js.map +1 -0
  25. package/lib/commonjs/debug/useDebugOverlay.js +15 -0
  26. package/lib/commonjs/debug/useDebugOverlay.js.map +1 -0
  27. package/lib/commonjs/getVisibleIndices.js +38 -0
  28. package/lib/commonjs/getVisibleIndices.js.map +1 -0
  29. package/lib/commonjs/hooks/useCellRenderer.js +62 -0
  30. package/lib/commonjs/hooks/useCellRenderer.js.map +1 -0
  31. package/lib/commonjs/hooks/useStableCallback.js +13 -0
  32. package/lib/commonjs/hooks/useStableCallback.js.map +1 -0
  33. package/lib/commonjs/index.js +7 -5
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/layout/EstimatedLayoutProvider.js +30 -0
  36. package/lib/commonjs/layout/EstimatedLayoutProvider.js.map +1 -0
  37. package/lib/commonjs/layout/LayoutEngine.js +21 -0
  38. package/lib/commonjs/layout/LayoutEngine.js.map +1 -0
  39. package/lib/commonjs/{specs/nitro-list.nitro.js → layout/LayoutProvider.js} +1 -1
  40. package/lib/commonjs/{specs/nitro-list.nitro.js.map → layout/LayoutProvider.js.map} +1 -1
  41. package/lib/commonjs/layout/LayoutRectangle.js +2 -0
  42. package/lib/commonjs/layout/LayoutRectangle.js.map +1 -0
  43. package/lib/commonjs/layout/MutableLinearLayout.js +65 -0
  44. package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -0
  45. package/lib/commonjs/layout/index.js +20 -0
  46. package/lib/commonjs/layout/index.js.map +1 -0
  47. package/lib/commonjs/measurement/MeasureLayout.js +20 -0
  48. package/lib/commonjs/measurement/MeasureLayout.js.map +1 -0
  49. package/lib/commonjs/measurement/useItemMeasurement.js +28 -0
  50. package/lib/commonjs/measurement/useItemMeasurement.js.map +1 -0
  51. package/lib/commonjs/native/NitroLayoutEngine.js +9 -0
  52. package/lib/commonjs/native/NitroLayoutEngine.js.map +1 -0
  53. package/lib/commonjs/native/NitroList.types.js +6 -0
  54. package/lib/commonjs/native/NitroList.types.js.map +1 -0
  55. package/lib/commonjs/native/NitroRecyclerView.js +9 -0
  56. package/lib/commonjs/native/NitroRecyclerView.js.map +1 -0
  57. package/lib/commonjs/prefetch/PrefetchHelper.js +39 -0
  58. package/lib/commonjs/prefetch/PrefetchHelper.js.map +1 -0
  59. package/lib/commonjs/specs/nitro-layout-engine.nitro.js +6 -0
  60. package/lib/commonjs/specs/nitro-layout-engine.nitro.js.map +1 -0
  61. package/lib/commonjs/utils/arrayEqual.js +15 -0
  62. package/lib/commonjs/utils/arrayEqual.js.map +1 -0
  63. package/lib/commonjs/utils/assertNever.js +10 -0
  64. package/lib/commonjs/utils/assertNever.js.map +1 -0
  65. package/lib/commonjs/utils/clamp.js +10 -0
  66. package/lib/commonjs/utils/clamp.js.map +1 -0
  67. package/lib/commonjs/utils/devAssert.js +12 -0
  68. package/lib/commonjs/utils/devAssert.js.map +1 -0
  69. package/lib/commonjs/utils/invariant.js +12 -0
  70. package/lib/commonjs/utils/invariant.js.map +1 -0
  71. package/lib/commonjs/utils/isDefined.js +10 -0
  72. package/lib/commonjs/utils/isDefined.js.map +1 -0
  73. package/lib/commonjs/utils/isNumber.js +10 -0
  74. package/lib/commonjs/utils/isNumber.js.map +1 -0
  75. package/lib/commonjs/utils/noop.js +10 -0
  76. package/lib/commonjs/utils/noop.js.map +1 -0
  77. package/lib/commonjs/utils/shallowEqual.js +22 -0
  78. package/lib/commonjs/utils/shallowEqual.js.map +1 -0
  79. package/lib/commonjs/utils/throttle.js +17 -0
  80. package/lib/commonjs/utils/throttle.js.map +1 -0
  81. package/lib/commonjs/viewability/ViewabilityHelper.js +121 -0
  82. package/lib/commonjs/viewability/ViewabilityHelper.js.map +1 -0
  83. package/lib/commonjs/windowing/ScrollMetrics.js +2 -0
  84. package/lib/commonjs/windowing/ScrollMetrics.js.map +1 -0
  85. package/lib/commonjs/windowing/findVisibleIndexRange.js +48 -0
  86. package/lib/commonjs/windowing/findVisibleIndexRange.js.map +1 -0
  87. package/lib/commonjs/windowing/index.js +20 -0
  88. package/lib/commonjs/windowing/index.js.map +1 -0
  89. package/lib/commonjs/windowing/useScrollMetrics.js +39 -0
  90. package/lib/commonjs/windowing/useScrollMetrics.js.map +1 -0
  91. package/lib/module/NitroList.js +5 -0
  92. package/lib/module/NitroList.js.map +1 -0
  93. package/lib/module/RecyclerList.internal.js +22 -0
  94. package/lib/module/RecyclerList.internal.js.map +1 -0
  95. package/lib/module/RecyclerList.js +166 -0
  96. package/lib/module/RecyclerList.js.map +1 -0
  97. package/lib/module/RecyclerList.types.js +4 -0
  98. package/lib/module/RecyclerList.types.js.map +1 -0
  99. package/lib/module/ReusableView.js +2 -0
  100. package/lib/module/ReusableView.js.map +1 -0
  101. package/lib/module/cell/Cell.js +2 -0
  102. package/lib/module/cell/Cell.js.map +1 -0
  103. package/lib/module/cell/CellRecycler.js +57 -0
  104. package/lib/module/cell/CellRecycler.js.map +1 -0
  105. package/lib/module/cell/StableKey.js +6 -0
  106. package/lib/module/cell/StableKey.js.map +1 -0
  107. package/lib/module/debug/useDebugOverlay.js +11 -0
  108. package/lib/module/debug/useDebugOverlay.js.map +1 -0
  109. package/lib/module/getVisibleIndices.js +34 -0
  110. package/lib/module/getVisibleIndices.js.map +1 -0
  111. package/lib/module/hooks/useCellRenderer.js +58 -0
  112. package/lib/module/hooks/useCellRenderer.js.map +1 -0
  113. package/lib/module/hooks/useStableCallback.js +9 -0
  114. package/lib/module/hooks/useStableCallback.js.map +1 -0
  115. package/lib/module/index.js +1 -3
  116. package/lib/module/index.js.map +1 -1
  117. package/lib/module/layout/EstimatedLayoutProvider.js +25 -0
  118. package/lib/module/layout/EstimatedLayoutProvider.js.map +1 -0
  119. package/lib/module/layout/LayoutEngine.js +17 -0
  120. package/lib/module/layout/LayoutEngine.js.map +1 -0
  121. package/lib/module/layout/LayoutProvider.js +4 -0
  122. package/lib/module/layout/LayoutProvider.js.map +1 -0
  123. package/lib/module/layout/LayoutRectangle.js +2 -0
  124. package/lib/module/layout/LayoutRectangle.js.map +1 -0
  125. package/lib/module/layout/MutableLinearLayout.js +60 -0
  126. package/lib/module/layout/MutableLinearLayout.js.map +1 -0
  127. package/lib/module/layout/index.js +5 -0
  128. package/lib/module/layout/index.js.map +1 -0
  129. package/lib/module/measurement/MeasureLayout.js +16 -0
  130. package/lib/module/measurement/MeasureLayout.js.map +1 -0
  131. package/lib/module/measurement/useItemMeasurement.js +24 -0
  132. package/lib/module/measurement/useItemMeasurement.js.map +1 -0
  133. package/lib/module/native/NitroLayoutEngine.js +5 -0
  134. package/lib/module/native/NitroLayoutEngine.js.map +1 -0
  135. package/lib/module/native/NitroList.types.js +4 -0
  136. package/lib/module/native/NitroList.types.js.map +1 -0
  137. package/lib/module/native/NitroRecyclerView.js +5 -0
  138. package/lib/module/native/NitroRecyclerView.js.map +1 -0
  139. package/lib/module/prefetch/PrefetchHelper.js +34 -0
  140. package/lib/module/prefetch/PrefetchHelper.js.map +1 -0
  141. package/lib/module/specs/nitro-layout-engine.nitro.js +4 -0
  142. package/lib/module/specs/nitro-layout-engine.nitro.js.map +1 -0
  143. package/lib/module/utils/arrayEqual.js +11 -0
  144. package/lib/module/utils/arrayEqual.js.map +1 -0
  145. package/lib/module/utils/assertNever.js +6 -0
  146. package/lib/module/utils/assertNever.js.map +1 -0
  147. package/lib/module/utils/clamp.js +6 -0
  148. package/lib/module/utils/clamp.js.map +1 -0
  149. package/lib/module/utils/devAssert.js +8 -0
  150. package/lib/module/utils/devAssert.js.map +1 -0
  151. package/lib/module/utils/invariant.js +8 -0
  152. package/lib/module/utils/invariant.js.map +1 -0
  153. package/lib/module/utils/isDefined.js +6 -0
  154. package/lib/module/utils/isDefined.js.map +1 -0
  155. package/lib/module/utils/isNumber.js +6 -0
  156. package/lib/module/utils/isNumber.js.map +1 -0
  157. package/lib/module/utils/noop.js +6 -0
  158. package/lib/module/utils/noop.js.map +1 -0
  159. package/lib/module/utils/shallowEqual.js +18 -0
  160. package/lib/module/utils/shallowEqual.js.map +1 -0
  161. package/lib/module/utils/throttle.js +13 -0
  162. package/lib/module/utils/throttle.js.map +1 -0
  163. package/lib/module/viewability/ViewabilityHelper.js +116 -0
  164. package/lib/module/viewability/ViewabilityHelper.js.map +1 -0
  165. package/lib/module/windowing/ScrollMetrics.js +2 -0
  166. package/lib/module/windowing/ScrollMetrics.js.map +1 -0
  167. package/lib/module/windowing/findVisibleIndexRange.js +44 -0
  168. package/lib/module/windowing/findVisibleIndexRange.js.map +1 -0
  169. package/lib/module/windowing/index.js +5 -0
  170. package/lib/module/windowing/index.js.map +1 -0
  171. package/lib/module/windowing/useScrollMetrics.js +35 -0
  172. package/lib/module/windowing/useScrollMetrics.js.map +1 -0
  173. package/lib/typescript/src/NitroList.d.ts +5 -0
  174. package/lib/typescript/src/NitroList.d.ts.map +1 -0
  175. package/lib/typescript/src/RecyclerList.d.ts +26 -0
  176. package/lib/typescript/src/RecyclerList.d.ts.map +1 -0
  177. package/lib/typescript/src/RecyclerList.internal.d.ts +9 -0
  178. package/lib/typescript/src/RecyclerList.internal.d.ts.map +1 -0
  179. package/lib/typescript/src/RecyclerList.types.d.ts +18 -0
  180. package/lib/typescript/src/RecyclerList.types.d.ts.map +1 -0
  181. package/lib/typescript/src/ReusableView.d.ts +9 -0
  182. package/lib/typescript/src/ReusableView.d.ts.map +1 -0
  183. package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts +2 -0
  184. package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts.map +1 -0
  185. package/lib/typescript/src/cell/Cell.d.ts +13 -0
  186. package/lib/typescript/src/cell/Cell.d.ts.map +1 -0
  187. package/lib/typescript/src/cell/CellRecycler.d.ts +19 -0
  188. package/lib/typescript/src/cell/CellRecycler.d.ts.map +1 -0
  189. package/lib/typescript/src/cell/StableKey.d.ts +2 -0
  190. package/lib/typescript/src/cell/StableKey.d.ts.map +1 -0
  191. package/lib/typescript/src/debug/useDebugOverlay.d.ts +2 -0
  192. package/lib/typescript/src/debug/useDebugOverlay.d.ts.map +1 -0
  193. package/lib/typescript/src/getVisibleIndices.d.ts +8 -0
  194. package/lib/typescript/src/getVisibleIndices.d.ts.map +1 -0
  195. package/lib/typescript/src/hooks/useCellRenderer.d.ts +19 -0
  196. package/lib/typescript/src/hooks/useCellRenderer.d.ts.map +1 -0
  197. package/lib/typescript/src/hooks/useStableCallback.d.ts +2 -0
  198. package/lib/typescript/src/hooks/useStableCallback.d.ts.map +1 -0
  199. package/lib/typescript/src/index.d.ts +2 -4
  200. package/lib/typescript/src/index.d.ts.map +1 -1
  201. package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts +15 -0
  202. package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts.map +1 -0
  203. package/lib/typescript/src/layout/LayoutEngine.d.ts +10 -0
  204. package/lib/typescript/src/layout/LayoutEngine.d.ts.map +1 -0
  205. package/lib/typescript/src/layout/LayoutProvider.d.ts +16 -0
  206. package/lib/typescript/src/layout/LayoutProvider.d.ts.map +1 -0
  207. package/lib/typescript/src/layout/LayoutRectangle.d.ts +11 -0
  208. package/lib/typescript/src/layout/LayoutRectangle.d.ts.map +1 -0
  209. package/lib/typescript/src/layout/MutableLinearLayout.d.ts +22 -0
  210. package/lib/typescript/src/layout/MutableLinearLayout.d.ts.map +1 -0
  211. package/lib/typescript/src/layout/index.d.ts +5 -0
  212. package/lib/typescript/src/layout/index.d.ts.map +1 -0
  213. package/lib/typescript/src/measurement/MeasureLayout.d.ts +10 -0
  214. package/lib/typescript/src/measurement/MeasureLayout.d.ts.map +1 -0
  215. package/lib/typescript/src/measurement/useItemMeasurement.d.ts +11 -0
  216. package/lib/typescript/src/measurement/useItemMeasurement.d.ts.map +1 -0
  217. package/lib/typescript/src/native/NitroLayoutEngine.d.ts +3 -0
  218. package/lib/typescript/src/native/NitroLayoutEngine.d.ts.map +1 -0
  219. package/lib/typescript/src/native/NitroList.types.d.ts +9 -0
  220. package/lib/typescript/src/native/NitroList.types.d.ts.map +1 -0
  221. package/lib/typescript/src/native/NitroRecyclerView.d.ts +5 -0
  222. package/lib/typescript/src/native/NitroRecyclerView.d.ts.map +1 -0
  223. package/lib/typescript/src/prefetch/PrefetchHelper.d.ts +17 -0
  224. package/lib/typescript/src/prefetch/PrefetchHelper.d.ts.map +1 -0
  225. package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +14 -0
  226. package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +1 -0
  227. package/lib/typescript/src/utils/arrayEqual.d.ts +2 -0
  228. package/lib/typescript/src/utils/arrayEqual.d.ts.map +1 -0
  229. package/lib/typescript/src/utils/assertNever.d.ts +2 -0
  230. package/lib/typescript/src/utils/assertNever.d.ts.map +1 -0
  231. package/lib/typescript/src/utils/clamp.d.ts +2 -0
  232. package/lib/typescript/src/utils/clamp.d.ts.map +1 -0
  233. package/lib/typescript/src/utils/devAssert.d.ts +2 -0
  234. package/lib/typescript/src/utils/devAssert.d.ts.map +1 -0
  235. package/lib/typescript/src/utils/invariant.d.ts +2 -0
  236. package/lib/typescript/src/utils/invariant.d.ts.map +1 -0
  237. package/lib/typescript/src/utils/isDefined.d.ts +2 -0
  238. package/lib/typescript/src/utils/isDefined.d.ts.map +1 -0
  239. package/lib/typescript/src/utils/isNumber.d.ts +2 -0
  240. package/lib/typescript/src/utils/isNumber.d.ts.map +1 -0
  241. package/lib/typescript/src/utils/noop.d.ts +2 -0
  242. package/lib/typescript/src/utils/noop.d.ts.map +1 -0
  243. package/lib/typescript/src/utils/shallowEqual.d.ts +2 -0
  244. package/lib/typescript/src/utils/shallowEqual.d.ts.map +1 -0
  245. package/lib/typescript/src/utils/throttle.d.ts +2 -0
  246. package/lib/typescript/src/utils/throttle.d.ts.map +1 -0
  247. package/lib/typescript/src/viewability/ViewabilityHelper.d.ts +50 -0
  248. package/lib/typescript/src/viewability/ViewabilityHelper.d.ts.map +1 -0
  249. package/lib/typescript/src/windowing/ScrollMetrics.d.ts +11 -0
  250. package/lib/typescript/src/windowing/ScrollMetrics.d.ts.map +1 -0
  251. package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts +11 -0
  252. package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts.map +1 -0
  253. package/lib/typescript/src/windowing/index.d.ts +4 -0
  254. package/lib/typescript/src/windowing/index.d.ts.map +1 -0
  255. package/lib/typescript/src/windowing/useScrollMetrics.d.ts +14 -0
  256. package/lib/typescript/src/windowing/useScrollMetrics.d.ts.map +1 -0
  257. package/nitro.json +20 -13
  258. package/nitrogen/generated/android/NitroList+autolinking.cmake +2 -4
  259. package/nitrogen/generated/android/NitroListOnLoad.cpp +3 -13
  260. package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.cpp +69 -0
  261. package/nitrogen/generated/android/c++/{JHybridNitroListSpec.hpp → JHybridNitroLayoutEngineSpec.hpp} +12 -13
  262. package/nitrogen/generated/android/c++/JLayoutRectangle.hpp +69 -0
  263. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{HybridNitroListSpec.kt → HybridNitroLayoutEngineSpec.kt} +11 -13
  264. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/LayoutRectangle.kt +47 -0
  265. package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.cpp +9 -9
  266. package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +50 -13
  267. package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +11 -5
  268. package/nitrogen/generated/ios/c++/{HybridNitroListSpecSwift.cpp → HybridNitroLayoutEngineSpecSwift.cpp} +2 -2
  269. package/nitrogen/generated/ios/c++/HybridNitroLayoutEngineSpecSwift.hpp +78 -0
  270. package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +56 -0
  271. package/nitrogen/generated/ios/swift/{HybridNitroListSpec_cxx.swift → HybridNitroLayoutEngineSpec_cxx.swift} +35 -38
  272. package/nitrogen/generated/ios/swift/LayoutRectangle.swift +45 -0
  273. package/nitrogen/generated/shared/c++/{HybridNitroListSpec.cpp → HybridNitroLayoutEngineSpec.cpp} +4 -5
  274. package/nitrogen/generated/shared/c++/{HybridNitroListSpec.hpp → HybridNitroLayoutEngineSpec.hpp} +15 -14
  275. package/nitrogen/generated/shared/c++/LayoutRectangle.hpp +95 -0
  276. package/package.json +12 -4
  277. package/src/NitroList.ts +8 -0
  278. package/src/RecyclerList.internal.ts +38 -0
  279. package/src/RecyclerList.tsx +252 -0
  280. package/src/RecyclerList.types.ts +24 -0
  281. package/src/ReusableView.ts +12 -0
  282. package/src/__tests__/windowing/findVisibleIndexRange.test.ts +55 -0
  283. package/src/cell/Cell.ts +14 -0
  284. package/src/cell/CellRecycler.ts +66 -0
  285. package/src/cell/StableKey.ts +6 -0
  286. package/src/debug/useDebugOverlay.ts +14 -0
  287. package/src/getVisibleIndices.ts +53 -0
  288. package/src/hooks/useCellRenderer.ts +86 -0
  289. package/src/hooks/useStableCallback.ts +13 -0
  290. package/src/index.ts +2 -14
  291. package/src/layout/EstimatedLayoutProvider.ts +35 -0
  292. package/src/layout/LayoutEngine.ts +21 -0
  293. package/src/layout/LayoutProvider.ts +17 -0
  294. package/src/layout/LayoutRectangle.ts +10 -0
  295. package/src/layout/MutableLinearLayout.ts +79 -0
  296. package/src/layout/index.ts +4 -0
  297. package/src/measurement/MeasureLayout.ts +20 -0
  298. package/src/measurement/useItemMeasurement.ts +32 -0
  299. package/src/native/NitroLayoutEngine.ts +7 -0
  300. package/src/native/NitroList.types.ts +12 -0
  301. package/src/native/NitroRecyclerView.ts +8 -0
  302. package/src/prefetch/PrefetchHelper.ts +47 -0
  303. package/src/specs/nitro-layout-engine.nitro.ts +17 -0
  304. package/src/utils/arrayEqual.ts +13 -0
  305. package/src/utils/assertNever.ts +3 -0
  306. package/src/utils/clamp.ts +7 -0
  307. package/src/utils/devAssert.ts +8 -0
  308. package/src/utils/invariant.ts +8 -0
  309. package/src/utils/isDefined.ts +5 -0
  310. package/src/utils/isNumber.ts +3 -0
  311. package/src/utils/noop.ts +3 -0
  312. package/src/utils/shallowEqual.ts +34 -0
  313. package/src/utils/throttle.ts +13 -0
  314. package/src/viewability/ViewabilityHelper.ts +130 -0
  315. package/src/windowing/ScrollMetrics.ts +11 -0
  316. package/src/windowing/findVisibleIndexRange.ts +60 -0
  317. package/src/windowing/index.ts +3 -0
  318. package/src/windowing/useScrollMetrics.ts +56 -0
  319. package/android/src/main/java/com/nitrolist/HybridNitroList.kt +0 -27
  320. package/lib/module/specs/nitro-list.nitro.js +0 -4
  321. package/lib/typescript/src/specs/nitro-list.nitro.d.ts +0 -11
  322. package/lib/typescript/src/specs/nitro-list.nitro.d.ts.map +0 -1
  323. package/nitrogen/generated/android/c++/JHybridNitroListSpec.cpp +0 -56
  324. package/nitrogen/generated/android/c++/views/JHybridNitroListStateUpdater.cpp +0 -56
  325. package/nitrogen/generated/android/c++/views/JHybridNitroListStateUpdater.hpp +0 -49
  326. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/views/HybridNitroListManager.kt +0 -50
  327. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/views/HybridNitroListStateUpdater.kt +0 -23
  328. package/nitrogen/generated/ios/NitroListAutolinking.mm +0 -33
  329. package/nitrogen/generated/ios/NitroListAutolinking.swift +0 -25
  330. package/nitrogen/generated/ios/c++/HybridNitroListSpecSwift.hpp +0 -74
  331. package/nitrogen/generated/ios/c++/views/HybridNitroListComponent.mm +0 -96
  332. package/nitrogen/generated/ios/swift/HybridNitroListSpec.swift +0 -56
  333. package/nitrogen/generated/shared/c++/views/HybridNitroListComponent.cpp +0 -88
  334. package/nitrogen/generated/shared/c++/views/HybridNitroListComponent.hpp +0 -107
  335. package/nitrogen/generated/shared/json/NitroListConfig.json +0 -10
  336. package/src/specs/nitro-list.nitro.ts +0 -13
@@ -0,0 +1,10 @@
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
+ }
@@ -0,0 +1,79 @@
1
+ import type { LayoutRectangle } from './LayoutRectangle'
2
+
3
+ /**
4
+ * INTERNAL mutable layout record.
5
+ * This is intentionally mutable and never exposed publicly.
6
+ */
7
+ type MutableLayoutRectangle = {
8
+ x: number
9
+ y: number
10
+ width: number
11
+ height: number
12
+ }
13
+
14
+ /**
15
+ * Mutable linear layout store.
16
+ * FlashList-style incremental relayout.
17
+ */
18
+ export class MutableLinearLayout {
19
+ private readonly layouts: MutableLayoutRectangle[]
20
+ private totalHeight: number
21
+
22
+ constructor(
23
+ initialHeights: readonly number[],
24
+ width: number
25
+ ) {
26
+ this.layouts = []
27
+ let y = 0
28
+
29
+ for (const height of initialHeights) {
30
+ this.layouts.push({
31
+ x: 0,
32
+ y,
33
+ width,
34
+ height,
35
+ })
36
+ y += height
37
+ }
38
+
39
+ this.totalHeight = y
40
+ }
41
+
42
+ /**
43
+ * Read-only snapshot for consumers.
44
+ * Returned type is immutable.
45
+ */
46
+ getLayouts(): readonly LayoutRectangle[] {
47
+ return this.layouts
48
+ }
49
+
50
+ getContentHeight(): number {
51
+ return this.totalHeight
52
+ }
53
+
54
+ /**
55
+ * Update height of one item and shift following items.
56
+ * Returns true if layout changed.
57
+ */
58
+ updateItemHeight(
59
+ index: number,
60
+ newHeight: number
61
+ ): boolean {
62
+ const layout = this.layouts[index]
63
+ if (!layout) return false
64
+
65
+ const delta = newHeight - layout.height
66
+ if (delta === 0) return false
67
+
68
+ // Update this item
69
+ layout.height = newHeight
70
+
71
+ // Shift all items after this index
72
+ for (let i = index + 1; i < this.layouts.length; i++) {
73
+ this.layouts[i]!.y += delta
74
+ }
75
+
76
+ this.totalHeight += delta
77
+ return true
78
+ }
79
+ }
@@ -0,0 +1,4 @@
1
+ export type { LayoutRectangle } from './LayoutRectangle'
2
+ export type { LayoutProvider } from './LayoutProvider'
3
+ export { EstimatedLayoutProvider } from './EstimatedLayoutProvider'
4
+ export { computeLayouts } from './LayoutEngine'
@@ -0,0 +1,20 @@
1
+ import type { LayoutChangeEvent } from 'react-native'
2
+
3
+ export interface MeasuredLayout {
4
+ readonly width: number
5
+ readonly height: number
6
+ }
7
+
8
+ /**
9
+ * Extracts stable layout measurements from RN onLayout event.
10
+ */
11
+ export function measureLayout(
12
+ event: LayoutChangeEvent
13
+ ): MeasuredLayout {
14
+ const { width, height } = event.nativeEvent.layout
15
+
16
+ return {
17
+ width,
18
+ height,
19
+ }
20
+ }
@@ -0,0 +1,32 @@
1
+ import { useCallback, useRef } from 'react'
2
+ import type { LayoutChangeEvent } from 'react-native'
3
+
4
+ /**
5
+ * Hook to measure a rendered item safely.
6
+ *
7
+ * Guarantees:
8
+ * - No duplicate height reports
9
+ * - No render loops
10
+ * - Stable callback identity
11
+ */
12
+ export function useItemMeasurement(
13
+ index: number,
14
+ onMeasured: (index: number, height: number) => void
15
+ ) {
16
+ const lastHeightRef = useRef<number | null>(null)
17
+
18
+ const onLayout = useCallback(
19
+ (e: LayoutChangeEvent) => {
20
+ const height = e.nativeEvent.layout.height
21
+
22
+ // Ignore identical measurements
23
+ if (lastHeightRef.current === height) return
24
+
25
+ lastHeightRef.current = height
26
+ onMeasured(index, height)
27
+ },
28
+ [index, onMeasured]
29
+ )
30
+
31
+ return onLayout
32
+ }
@@ -0,0 +1,7 @@
1
+ import { NitroModules } from 'react-native-nitro-modules'
2
+ import type { NitroLayoutEngine as NitroLayoutEngineSpec } from '../specs/nitro-layout-engine.nitro'
3
+
4
+ export const NitroLayoutEngine =
5
+ NitroModules.createHybridObject<NitroLayoutEngineSpec>(
6
+ 'NitroLayoutEngine'
7
+ )
@@ -0,0 +1,12 @@
1
+ import type { LayoutRectangle } from '../layout/LayoutRectangle'
2
+
3
+ /**
4
+ * JS runtime interface backed by Nitro (JSI).
5
+ * Must match native HybridNitroList exactly.
6
+ */
7
+ export interface NitroList {
8
+ computeLayout(
9
+ containerWidth: number,
10
+ itemHeights: readonly number[]
11
+ ): readonly LayoutRectangle[]
12
+ }
@@ -0,0 +1,8 @@
1
+ import { requireNativeComponent } from 'react-native'
2
+
3
+ export type NitroRecyclerViewProps = {
4
+ itemCount: number
5
+ }
6
+
7
+ export const NitroRecyclerView =
8
+ requireNativeComponent<NitroRecyclerViewProps>('NitroRecyclerView')
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Callback invoked when new items should be prefetched.
3
+ */
4
+ export type PrefetchCallback = (indices: number[]) => void
5
+
6
+ /**
7
+ * PrefetchHelper
8
+ *
9
+ * Stateless with respect to layout.
10
+ * Only tracks what has already been prefetched to avoid duplication.
11
+ *
12
+ * Designed to be driven by *visible window*, not scroll events.
13
+ */
14
+ export class PrefetchHelper {
15
+ private lastPrefetched = new Set<number>()
16
+
17
+ runPrefetch(
18
+ visibleIndices: readonly number[],
19
+ itemCount: number,
20
+ aheadCount: number,
21
+ onPrefetch: PrefetchCallback
22
+ ) {
23
+ if (visibleIndices.length === 0) return
24
+
25
+ const lastVisible =
26
+ visibleIndices[visibleIndices.length - 1]!
27
+
28
+ const start = lastVisible + 1
29
+ const end = Math.min(
30
+ itemCount - 1,
31
+ start + aheadCount
32
+ )
33
+
34
+ const toPrefetch: number[] = []
35
+
36
+ for (let i = start; i <= end; i++) {
37
+ if (!this.lastPrefetched.has(i)) {
38
+ this.lastPrefetched.add(i)
39
+ toPrefetch.push(i)
40
+ }
41
+ }
42
+
43
+ if (toPrefetch.length > 0) {
44
+ onPrefetch(toPrefetch)
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,17 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules'
2
+
3
+ export interface LayoutRectangle {
4
+ readonly x: number
5
+ readonly y: number
6
+ readonly width: number
7
+ readonly height: number
8
+ }
9
+
10
+ export interface NitroLayoutEngine
11
+ extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
12
+
13
+ computeLayout(
14
+ containerWidth: number,
15
+ itemHeights: readonly number[]
16
+ ): readonly LayoutRectangle[]
17
+ }
@@ -0,0 +1,13 @@
1
+ export function arrayEqual<T>(
2
+ a: readonly T[],
3
+ b: readonly T[]
4
+ ): boolean {
5
+ if (a === b) return true
6
+ if (a.length !== b.length) return false
7
+
8
+ for (let i = 0; i < a.length; i++) {
9
+ if (!Object.is(a[i], b[i])) return false
10
+ }
11
+
12
+ return true
13
+ }
@@ -0,0 +1,3 @@
1
+ export function assertNever(x: never): never {
2
+ throw new Error(`Unexpected value: ${String(x)}`)
3
+ }
@@ -0,0 +1,7 @@
1
+ export function clamp(
2
+ value: number,
3
+ min: number,
4
+ max: number
5
+ ): number {
6
+ return Math.min(Math.max(value, min), max)
7
+ }
@@ -0,0 +1,8 @@
1
+ export function devAssert(
2
+ condition: boolean,
3
+ message: string
4
+ ): void {
5
+ if (__DEV__ && !condition) {
6
+ throw new Error(`RecyclerList: ${message}`)
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ export function invariant(
2
+ condition: unknown,
3
+ message: string
4
+ ): asserts condition {
5
+ if (!condition) {
6
+ throw new Error(`Invariant failed: ${message}`)
7
+ }
8
+ }
@@ -0,0 +1,5 @@
1
+ export function isDefined<T>(
2
+ value: T | undefined | null
3
+ ): value is T {
4
+ return value !== undefined && value !== null
5
+ }
@@ -0,0 +1,3 @@
1
+ export function isNumber(value: unknown): value is number {
2
+ return typeof value === 'number' && !Number.isNaN(value)
3
+ }
@@ -0,0 +1,3 @@
1
+ export function noop(): void {
2
+ // intentionally empty
3
+ }
@@ -0,0 +1,34 @@
1
+ export function shallowEqual(
2
+ a: unknown,
3
+ b: unknown
4
+ ): boolean {
5
+ if (Object.is(a, b)) return true
6
+
7
+ if (
8
+ typeof a !== 'object' ||
9
+ typeof b !== 'object' ||
10
+ a === null ||
11
+ b === null
12
+ ) {
13
+ return false
14
+ }
15
+
16
+ const aKeys = Object.keys(a as object)
17
+ const bKeys = Object.keys(b as object)
18
+
19
+ if (aKeys.length !== bKeys.length) return false
20
+
21
+ for (const key of aKeys) {
22
+ if (
23
+ !(key in (b as object)) ||
24
+ !Object.is(
25
+ (a as Record<string, unknown>)[key],
26
+ (b as Record<string, unknown>)[key]
27
+ )
28
+ ) {
29
+ return false
30
+ }
31
+ }
32
+
33
+ return true
34
+ }
@@ -0,0 +1,13 @@
1
+ export function throttle<T extends (...args: never[]) => void>(
2
+ fn: T,
3
+ ms: number
4
+ ): T {
5
+ let last = 0
6
+ return ((...args: never[]) => {
7
+ const now = Date.now()
8
+ if (now - last > ms) {
9
+ last = now
10
+ fn(...args)
11
+ }
12
+ }) as T
13
+ }
@@ -0,0 +1,130 @@
1
+ import type { LayoutRectangle } from '../layout/LayoutRectangle'
2
+ import type { ScrollMetrics } from '../windowing/ScrollMetrics'
3
+
4
+ /**
5
+ * Public token describing viewability state of an item.
6
+ * Mirrors FlashList's ViewToken concept.
7
+ */
8
+ export type ViewToken = {
9
+ index: number
10
+ isViewable: boolean
11
+ }
12
+
13
+ /**
14
+ * Configuration for viewability calculations.
15
+ */
16
+ export type ViewabilityConfig = {
17
+ /**
18
+ * Percentage (0–100) of item height that must be visible
19
+ * for the item to be considered "viewable".
20
+ */
21
+ itemVisiblePercentThreshold?: number
22
+ }
23
+
24
+ /**
25
+ * ViewabilityHelper
26
+ *
27
+ * Pure observer:
28
+ * - Does NOT affect layout
29
+ * - Does NOT affect recycling
30
+ * - Computes visibility based on layout + scroll metrics
31
+ *
32
+ * This class is intentionally stateful (lastVisible)
33
+ * to compute "changed" items efficiently.
34
+ */
35
+ export class ViewabilityHelper {
36
+ /** Previously visible indices */
37
+ private lastVisible = new Set<number>()
38
+
39
+ constructor(
40
+ private readonly config: ViewabilityConfig = {}
41
+ ) {}
42
+
43
+ /**
44
+ * Computes which items are viewable and which changed
45
+ * since the last invocation.
46
+ *
47
+ * IMPORTANT:
48
+ * - This method should be called AFTER windowing,
49
+ * not on the full dataset.
50
+ */
51
+ computeViewableItems(
52
+ layouts: readonly LayoutRectangle[],
53
+ metrics: ScrollMetrics
54
+ ): {
55
+ viewableItems: ViewToken[]
56
+ changed: ViewToken[]
57
+ } {
58
+ const visibleNow = new Set<number>()
59
+ const viewableItems: ViewToken[] = []
60
+ const changed: ViewToken[] = []
61
+
62
+ const viewportTop = metrics.offsetY
63
+ const viewportBottom = viewportTop + metrics.height
64
+
65
+ // Normalize threshold into [0, 1]
66
+ const threshold =
67
+ (this.config.itemVisiblePercentThreshold ?? 0) / 100
68
+
69
+ /**
70
+ * NOTE:
71
+ * We intentionally iterate layouts sequentially,
72
+ * but EXIT EARLY when items are completely below viewport.
73
+ *
74
+ * This keeps complexity near O(visibleItems),
75
+ * not O(totalItems).
76
+ */
77
+ for (let i = 0; i < layouts.length; i++) {
78
+ const layout = layouts[i]!
79
+
80
+ // If item is completely below viewport, stop
81
+ if (layout.y > viewportBottom) {
82
+ break
83
+ }
84
+
85
+ const itemTop = layout.y
86
+ const itemBottom = layout.y + layout.height
87
+
88
+ // If item is completely above viewport, skip
89
+ if (itemBottom < viewportTop) {
90
+ continue
91
+ }
92
+
93
+ // Compute visible intersection
94
+ const visibleTop = Math.max(itemTop, viewportTop)
95
+ const visibleBottom = Math.min(itemBottom, viewportBottom)
96
+
97
+ const visibleHeight = Math.max(0, visibleBottom - visibleTop)
98
+
99
+ // Guard against zero-height items
100
+ const itemHeight =
101
+ layout.height > 0 ? layout.height : 1
102
+
103
+ const visibleRatio = visibleHeight / itemHeight
104
+
105
+ if (visibleRatio >= threshold) {
106
+ visibleNow.add(i)
107
+ viewableItems.push({ index: i, isViewable: true })
108
+
109
+ // Newly visible
110
+ if (!this.lastVisible.has(i)) {
111
+ changed.push({ index: i, isViewable: true })
112
+ }
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Items that were visible before but not anymore
118
+ */
119
+ for (const index of this.lastVisible) {
120
+ if (!visibleNow.has(index)) {
121
+ changed.push({ index, isViewable: false })
122
+ }
123
+ }
124
+
125
+ // Update snapshot
126
+ this.lastVisible = visibleNow
127
+
128
+ return { viewableItems, changed }
129
+ }
130
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Immutable snapshot of scroll state.
3
+ * FlashList terminology.
4
+ */
5
+ export interface ScrollMetrics {
6
+ /** Vertical scroll offset */
7
+ offsetY: number
8
+
9
+ /** Viewport height */
10
+ height: number
11
+ }
@@ -0,0 +1,60 @@
1
+ import type { LayoutRectangle } from '../layout/LayoutRectangle'
2
+ import type { ScrollMetrics } from './ScrollMetrics'
3
+
4
+ /**
5
+ * Computes the contiguous range of item indices
6
+ * intersecting the viewport expanded by bufferPx.
7
+ *
8
+ * PURE function. No allocations besides output.
9
+ * FlashList-style windowing.
10
+ */
11
+ export function findVisibleIndexRange(
12
+ layouts: readonly LayoutRectangle[],
13
+ metrics: ScrollMetrics,
14
+ bufferPx: number
15
+ ): readonly number[] {
16
+ const count = layouts.length
17
+
18
+ // 🔒 CRITICAL GUARDS (FlashList-style)
19
+ if (
20
+ count === 0 ||
21
+ metrics.height <= 0 ||
22
+ bufferPx < 0
23
+ ) {
24
+ return []
25
+ }
26
+
27
+ const windowStart =
28
+ Math.max(0, metrics.offsetY - bufferPx)
29
+
30
+ const windowEnd =
31
+ metrics.offsetY + metrics.height + bufferPx
32
+
33
+ // Binary search for first intersecting item
34
+ let low = 0
35
+ let high = count - 1
36
+ let firstVisible = count
37
+
38
+ while (low <= high) {
39
+ const mid = (low + high) >> 1
40
+ const rect = layouts[mid]!
41
+
42
+ if (rect.y + rect.height >= windowStart) {
43
+ firstVisible = mid
44
+ high = mid - 1
45
+ } else {
46
+ low = mid + 1
47
+ }
48
+ }
49
+
50
+ // Linear scan forward
51
+ const visible: number[] = []
52
+
53
+ for (let i = firstVisible; i < count; i++) {
54
+ const rect = layouts[i]!
55
+ if (rect.y > windowEnd) break
56
+ visible.push(i)
57
+ }
58
+
59
+ return visible
60
+ }
@@ -0,0 +1,3 @@
1
+ export type { ScrollMetrics } from './ScrollMetrics'
2
+ export { findVisibleIndexRange } from './findVisibleIndexRange'
3
+ export { useScrollMetrics } from './useScrollMetrics'
@@ -0,0 +1,56 @@
1
+ import { useCallback, useState } from 'react'
2
+ import type {
3
+ LayoutChangeEvent,
4
+ NativeScrollEvent,
5
+ NativeSyntheticEvent,
6
+ } from 'react-native'
7
+ import type { ScrollMetrics } from './ScrollMetrics'
8
+
9
+ /**
10
+ * Scroll metrics hook.
11
+ * Provides stable scroll snapshot + handlers.
12
+ *
13
+ * FlashList equivalent: useScrollMetrics
14
+ */
15
+ export function useScrollMetrics(): {
16
+ metrics: ScrollMetrics
17
+ onScroll: (e: NativeSyntheticEvent<NativeScrollEvent>) => void
18
+ onLayout: (e: LayoutChangeEvent) => void
19
+ } {
20
+ const [metrics, setMetrics] = useState<ScrollMetrics>({
21
+ offsetY: 0,
22
+ height: 0,
23
+ })
24
+
25
+ const onScroll = useCallback(
26
+ (e: NativeSyntheticEvent<NativeScrollEvent>) => {
27
+ const offsetY = e.nativeEvent.contentOffset.y
28
+
29
+ setMetrics(prev =>
30
+ prev.offsetY === offsetY
31
+ ? prev
32
+ : { ...prev, offsetY }
33
+ )
34
+ },
35
+ []
36
+ )
37
+
38
+ const onLayout = useCallback(
39
+ (e: LayoutChangeEvent) => {
40
+ const height = e.nativeEvent.layout.height
41
+
42
+ setMetrics(prev =>
43
+ prev.height === height
44
+ ? prev
45
+ : { ...prev, height }
46
+ )
47
+ },
48
+ []
49
+ )
50
+
51
+ return {
52
+ metrics,
53
+ onScroll,
54
+ onLayout,
55
+ }
56
+ }
@@ -1,27 +0,0 @@
1
- package com.nitrolist
2
-
3
- import android.graphics.Color
4
- import android.view.View
5
- import androidx.annotation.Keep
6
- import com.facebook.proguard.annotations.DoNotStrip
7
- import com.facebook.react.uimanager.ThemedReactContext
8
- import com.margelo.nitro.nitrolist.HybridNitroListSpec
9
-
10
- @Keep
11
- @DoNotStrip
12
- class HybridNitroList(val context: ThemedReactContext): HybridNitroListSpec() {
13
- // View
14
- override val view: View = View(context)
15
-
16
- // Props
17
- private var _isRed = false
18
- override var isRed: Boolean
19
- get() = _isRed
20
- set(value) {
21
- _isRed = value
22
- view.setBackgroundColor(
23
- if (value) Color.RED
24
- else Color.BLACK
25
- )
26
- }
27
- }
@@ -1,4 +0,0 @@
1
- "use strict";
2
-
3
- export {};
4
- //# sourceMappingURL=nitro-list.nitro.js.map
@@ -1,11 +0,0 @@
1
- import type { HybridView, HybridViewProps, HybridViewMethods } from 'react-native-nitro-modules';
2
- export interface NitroListProps extends HybridViewProps {
3
- isRed: boolean;
4
- }
5
- export interface NitroListMethods extends HybridViewMethods {
6
- }
7
- export type NitroList = HybridView<NitroListProps, NitroListMethods, {
8
- ios: 'swift';
9
- android: 'kotlin';
10
- }>;
11
- //# sourceMappingURL=nitro-list.nitro.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nitro-list.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/nitro-list.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AAEnC,MAAM,WAAW,cAAe,SAAQ,eAAe;IACpD,KAAK,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;CAAG;AAE9D,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,cAAc,EAAE,gBAAgB,EAAE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAA"}