react-native-nitro-list 0.1.1 → 0.1.3
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.
- package/README.md +16 -44
- package/ios/HybridNitroList.swift +12 -14
- package/lib/commonjs/cell/CellKeyGenerator.js +21 -0
- package/lib/commonjs/cell/CellKeyGenerator.js.map +1 -0
- package/lib/commonjs/cell/CellRecycler.js +48 -40
- package/lib/commonjs/cell/CellRecycler.js.map +1 -1
- package/lib/commonjs/cell/createCell.js +21 -0
- package/lib/commonjs/cell/createCell.js.map +1 -0
- package/lib/commonjs/cell/index.js +20 -0
- package/lib/commonjs/cell/index.js.map +1 -0
- package/lib/commonjs/getVisibleIndices.js.map +1 -1
- package/lib/commonjs/hooks/usePersistentCallback.js +36 -0
- package/lib/commonjs/hooks/usePersistentCallback.js.map +1 -0
- package/lib/commonjs/index.js +31 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layout/MutableLinearLayout.js +78 -39
- package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -1
- package/lib/commonjs/layout/constants/layoutDefaults.js +19 -0
- package/lib/commonjs/layout/constants/layoutDefaults.js.map +1 -0
- package/lib/commonjs/layout/index.js +0 -18
- package/lib/commonjs/layout/index.js.map +1 -1
- package/lib/commonjs/native/NitroListView.js +20 -0
- package/lib/commonjs/native/NitroListView.js.map +1 -0
- package/lib/commonjs/recycler/CellPool.js +33 -0
- package/lib/commonjs/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/recycler/NitroList.js +223 -0
- package/lib/commonjs/recycler/NitroList.js.map +1 -0
- package/lib/commonjs/scroll/useScrollVelocity.js +20 -0
- package/lib/commonjs/scroll/useScrollVelocity.js.map +1 -0
- package/lib/commonjs/{native/NitroList.types.js → specs/NitroList.nitro.js} +1 -1
- package/lib/commonjs/{layout/LayoutProvider.js.map → specs/NitroList.nitro.js.map} +1 -1
- package/lib/commonjs/types/Axis.js +2 -0
- package/lib/{module/layout/LayoutProvider.js.map → commonjs/types/Axis.js.map} +1 -1
- package/lib/commonjs/types/CellKey.js +2 -0
- package/lib/commonjs/{layout/LayoutRectangle.js.map → types/CellKey.js.map} +1 -1
- package/lib/commonjs/types/CellType.js +27 -0
- package/lib/commonjs/types/CellType.js.map +1 -0
- package/lib/commonjs/types/VisibleRange.js +2 -0
- package/lib/commonjs/{native/NitroList.types.js.map → types/VisibleRange.js.map} +1 -1
- package/lib/commonjs/{RecyclerList.types.js → types/VisibleRangeInput.js} +1 -1
- package/lib/commonjs/types/VisibleRangeInput.js.map +1 -0
- package/lib/commonjs/types/index.js +13 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/layout/LayoutRect.js +2 -0
- package/lib/commonjs/types/layout/LayoutRect.js.map +1 -0
- package/lib/commonjs/{specs/nitro-layout-engine.nitro.js → types/layout/LinearLayoutInput.js} +1 -1
- package/lib/commonjs/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js +26 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/commonjs/types/layout/index.js +2 -0
- package/lib/commonjs/types/layout/index.js.map +1 -0
- package/lib/commonjs/types/recycler/CellPool.js +42 -0
- package/lib/commonjs/types/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/{layout/LayoutProvider.js → types/recycler/NitroListProps.js} +1 -1
- package/lib/commonjs/types/recycler/NitroListProps.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerCell.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerCell.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/commonjs/types/recycler/index.js +2 -0
- package/lib/commonjs/types/recycler/index.js.map +1 -0
- package/lib/commonjs/types/scroll/ScrollMetrics.js +6 -0
- package/lib/commonjs/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/commonjs/types/scroll/index.js +2 -0
- package/lib/commonjs/types/scroll/index.js.map +1 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js +61 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/commonjs/windowing/index.js +3 -3
- package/lib/commonjs/windowing/index.js.map +1 -1
- package/lib/module/cell/CellKeyGenerator.js +16 -0
- package/lib/module/cell/CellKeyGenerator.js.map +1 -0
- package/lib/module/cell/CellRecycler.js +48 -39
- package/lib/module/cell/CellRecycler.js.map +1 -1
- package/lib/module/cell/createCell.js +17 -0
- package/lib/module/cell/createCell.js.map +1 -0
- package/lib/module/cell/index.js +7 -0
- package/lib/module/cell/index.js.map +1 -0
- package/lib/module/getVisibleIndices.js.map +1 -1
- package/lib/module/hooks/usePersistentCallback.js +33 -0
- package/lib/module/hooks/usePersistentCallback.js.map +1 -0
- package/lib/module/index.js +5 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/MutableLinearLayout.js +78 -38
- package/lib/module/layout/MutableLinearLayout.js.map +1 -1
- package/lib/module/layout/constants/layoutDefaults.js +15 -0
- package/lib/module/layout/constants/layoutDefaults.js.map +1 -0
- package/lib/module/layout/index.js +0 -3
- package/lib/module/layout/index.js.map +1 -1
- package/lib/module/native/NitroListView.js +17 -0
- package/lib/module/native/NitroListView.js.map +1 -0
- package/lib/module/recycler/CellPool.js +28 -0
- package/lib/module/recycler/CellPool.js.map +1 -0
- package/lib/module/recycler/NitroList.js +220 -0
- package/lib/module/recycler/NitroList.js.map +1 -0
- package/lib/module/scroll/useScrollVelocity.js +16 -0
- package/lib/module/scroll/useScrollVelocity.js.map +1 -0
- package/lib/module/specs/NitroList.nitro.js +4 -0
- package/lib/module/specs/NitroList.nitro.js.map +1 -0
- package/lib/module/types/Axis.js +2 -0
- package/lib/module/types/Axis.js.map +1 -0
- package/lib/module/types/CellKey.js +2 -0
- package/lib/module/types/CellKey.js.map +1 -0
- package/lib/module/types/CellType.js +22 -0
- package/lib/module/types/CellType.js.map +1 -0
- package/lib/module/types/VisibleRange.js +2 -0
- package/lib/module/types/VisibleRange.js.map +1 -0
- package/lib/module/types/VisibleRangeInput.js +4 -0
- package/lib/module/types/VisibleRangeInput.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/layout/LayoutRect.js +2 -0
- package/lib/module/types/layout/LayoutRect.js.map +1 -0
- package/lib/module/types/layout/LinearLayoutInput.js +4 -0
- package/lib/module/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/module/types/layout/MainAxisPadding.js +22 -0
- package/lib/module/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/module/types/layout/index.js +2 -0
- package/lib/module/types/layout/index.js.map +1 -0
- package/lib/module/types/recycler/CellPool.js +37 -0
- package/lib/module/types/recycler/CellPool.js.map +1 -0
- package/lib/module/types/recycler/NitroListProps.js +4 -0
- package/lib/module/types/recycler/NitroListProps.js.map +1 -0
- package/lib/module/types/recycler/RecyclerCell.js +4 -0
- package/lib/module/types/recycler/RecyclerCell.js.map +1 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js +4 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/module/types/recycler/index.js +2 -0
- package/lib/module/types/recycler/index.js.map +1 -0
- package/lib/module/types/scroll/ScrollMetrics.js +4 -0
- package/lib/module/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/module/types/scroll/index.js +2 -0
- package/lib/module/types/scroll/index.js.map +1 -0
- package/lib/module/windowing/computeVisibleItemRange.js +57 -0
- package/lib/module/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/module/windowing/index.js +1 -1
- package/lib/module/windowing/index.js.map +1 -1
- package/lib/typescript/src/cell/Cell.d.ts +13 -4
- package/lib/typescript/src/cell/Cell.d.ts.map +1 -1
- package/lib/typescript/src/cell/CellKeyGenerator.d.ts +11 -0
- package/lib/typescript/src/cell/CellKeyGenerator.d.ts.map +1 -0
- package/lib/typescript/src/cell/CellRecycler.d.ts +19 -11
- package/lib/typescript/src/cell/CellRecycler.d.ts.map +1 -1
- package/lib/typescript/src/cell/createCell.d.ts +7 -0
- package/lib/typescript/src/cell/createCell.d.ts.map +1 -0
- package/lib/typescript/src/cell/index.d.ts +4 -0
- package/lib/typescript/src/cell/index.d.ts.map +1 -0
- package/lib/typescript/src/getVisibleIndices.d.ts +2 -2
- package/lib/typescript/src/getVisibleIndices.d.ts.map +1 -1
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts +16 -0
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts +45 -13
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts.map +1 -1
- package/lib/typescript/src/layout/constants/layoutDefaults.d.ts +13 -0
- package/lib/typescript/src/layout/constants/layoutDefaults.d.ts.map +1 -0
- package/lib/typescript/src/layout/index.d.ts +1 -4
- package/lib/typescript/src/layout/index.d.ts.map +1 -1
- package/lib/typescript/src/native/NitroListView.d.ts +20 -0
- package/lib/typescript/src/native/NitroListView.d.ts.map +1 -0
- package/lib/typescript/src/recycler/CellPool.d.ts +11 -0
- package/lib/typescript/src/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/recycler/NitroList.d.ts +4 -0
- package/lib/typescript/src/recycler/NitroList.d.ts.map +1 -0
- package/lib/typescript/src/scroll/useScrollVelocity.d.ts +2 -0
- package/lib/typescript/src/scroll/useScrollVelocity.d.ts.map +1 -0
- package/lib/typescript/src/specs/NitroList.nitro.d.ts +26 -0
- package/lib/typescript/src/specs/NitroList.nitro.d.ts.map +1 -0
- package/lib/typescript/src/types/Axis.d.ts +11 -0
- package/lib/typescript/src/types/Axis.d.ts.map +1 -0
- package/lib/typescript/src/types/CellKey.d.ts +2 -0
- package/lib/typescript/src/types/CellKey.d.ts.map +1 -0
- package/lib/typescript/src/types/CellType.d.ts +22 -0
- package/lib/typescript/src/types/CellType.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRange.d.ts +10 -0
- package/lib/typescript/src/types/VisibleRange.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts +35 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +8 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts +15 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts +10 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts +20 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/index.d.ts +4 -0
- package/lib/typescript/src/types/layout/index.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/CellPool.d.ts +16 -0
- package/lib/typescript/src/types/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/NitroListProps.d.ts +66 -0
- package/lib/typescript/src/types/recycler/NitroListProps.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerCell.d.ts +12 -0
- package/lib/typescript/src/types/recycler/RecyclerCell.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts +12 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/index.d.ts +4 -0
- package/lib/typescript/src/types/recycler/index.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts +15 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/index.d.ts +2 -0
- package/lib/typescript/src/types/scroll/index.d.ts.map +1 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts +19 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts.map +1 -0
- package/lib/typescript/src/windowing/index.d.ts +1 -1
- package/lib/typescript/src/windowing/index.d.ts.map +1 -1
- package/nitro.json +5 -5
- package/nitrogen/generated/android/NitroList+autolinking.cmake +2 -2
- package/nitrogen/generated/android/NitroListOnLoad.cpp +2 -2
- package/nitrogen/generated/android/c++/{JHybridNitroLayoutEngineSpec.cpp → JHybridNitroListSpec.cpp} +15 -15
- package/nitrogen/generated/android/c++/{JHybridNitroLayoutEngineSpec.hpp → JHybridNitroListSpec.hpp} +11 -11
- package/nitrogen/generated/android/c++/{JLayoutRectangle.hpp → JItemLayout.hpp} +10 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{HybridNitroLayoutEngineSpec.kt → HybridNitroListSpec.kt} +7 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{LayoutRectangle.kt → ItemLayout.kt} +5 -5
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.cpp +9 -9
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +27 -27
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +8 -8
- package/nitrogen/generated/ios/c++/{HybridNitroLayoutEngineSpecSwift.cpp → HybridNitroListSpecSwift.cpp} +2 -2
- package/nitrogen/generated/ios/c++/{HybridNitroLayoutEngineSpecSwift.hpp → HybridNitroListSpecSwift.hpp} +16 -16
- package/nitrogen/generated/ios/swift/HybridNitroListSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/{HybridNitroLayoutEngineSpec_cxx.swift → HybridNitroListSpec_cxx.swift} +23 -23
- package/nitrogen/generated/ios/swift/{LayoutRectangle.swift → ItemLayout.swift} +5 -5
- package/nitrogen/generated/shared/c++/{HybridNitroLayoutEngineSpec.cpp → HybridNitroListSpec.cpp} +4 -4
- package/nitrogen/generated/shared/c++/{HybridNitroLayoutEngineSpec.hpp → HybridNitroListSpec.hpp} +13 -13
- package/nitrogen/generated/shared/c++/{LayoutRectangle.hpp → ItemLayout.hpp} +11 -11
- package/package.json +5 -5
- package/src/cell/Cell.ts +13 -4
- package/src/cell/CellKeyGenerator.ts +17 -0
- package/src/cell/CellRecycler.ts +53 -43
- package/src/cell/createCell.ts +15 -0
- package/src/cell/index.ts +5 -0
- package/src/getVisibleIndices.ts +4 -2
- package/src/hooks/usePersistentCallback.ts +37 -0
- package/src/index.ts +7 -2
- package/src/layout/MutableLinearLayout.ts +91 -58
- package/src/layout/constants/layoutDefaults.ts +12 -0
- package/src/layout/index.ts +1 -4
- package/src/native/NitroListView.ts +22 -0
- package/src/recycler/CellPool.ts +33 -0
- package/src/recycler/NitroList.tsx +317 -0
- package/src/scroll/useScrollVelocity.ts +16 -0
- package/src/specs/NitroList.nitro.ts +29 -0
- package/src/types/Axis.ts +10 -0
- package/src/types/CellKey.ts +2 -0
- package/src/types/CellType.ts +9 -0
- package/src/types/VisibleRange.ts +9 -0
- package/src/types/VisibleRangeInput.ts +39 -0
- package/src/types/index.ts +15 -0
- package/src/types/layout/LayoutRect.ts +14 -0
- package/src/types/layout/LinearLayoutInput.ts +12 -0
- package/src/types/layout/MainAxisPadding.ts +23 -0
- package/src/types/layout/index.ts +3 -0
- package/src/types/recycler/CellPool.ts +45 -0
- package/src/types/recycler/NitroListProps.ts +74 -0
- package/src/types/recycler/RecyclerCell.ts +12 -0
- package/src/types/recycler/RecyclerItemRenderer.ts +12 -0
- package/src/types/recycler/index.ts +3 -0
- package/src/types/scroll/ScrollMetrics.ts +18 -0
- package/src/types/scroll/index.ts +1 -0
- package/src/windowing/computeVisibleItemRange.ts +82 -0
- package/src/windowing/index.ts +1 -1
- package/lib/commonjs/NitroList.js +0 -9
- package/lib/commonjs/NitroList.js.map +0 -1
- package/lib/commonjs/RecyclerList.internal.js +0 -25
- package/lib/commonjs/RecyclerList.internal.js.map +0 -1
- package/lib/commonjs/RecyclerList.js +0 -171
- package/lib/commonjs/RecyclerList.js.map +0 -1
- package/lib/commonjs/RecyclerList.types.js.map +0 -1
- package/lib/commonjs/cell/StableKey.js +0 -10
- package/lib/commonjs/cell/StableKey.js.map +0 -1
- package/lib/commonjs/hooks/useCellRenderer.js +0 -62
- package/lib/commonjs/hooks/useCellRenderer.js.map +0 -1
- package/lib/commonjs/hooks/useStableCallback.js +0 -13
- package/lib/commonjs/hooks/useStableCallback.js.map +0 -1
- package/lib/commonjs/layout/EstimatedLayoutProvider.js +0 -30
- package/lib/commonjs/layout/EstimatedLayoutProvider.js.map +0 -1
- package/lib/commonjs/layout/LayoutEngine.js +0 -21
- package/lib/commonjs/layout/LayoutEngine.js.map +0 -1
- package/lib/commonjs/layout/LayoutRectangle.js +0 -2
- package/lib/commonjs/native/NitroLayoutEngine.js +0 -9
- package/lib/commonjs/native/NitroLayoutEngine.js.map +0 -1
- package/lib/commonjs/native/NitroRecyclerView.js +0 -9
- package/lib/commonjs/native/NitroRecyclerView.js.map +0 -1
- package/lib/commonjs/specs/nitro-layout-engine.nitro.js.map +0 -1
- package/lib/commonjs/viewability/ViewabilityHelper.js +0 -121
- package/lib/commonjs/viewability/ViewabilityHelper.js.map +0 -1
- package/lib/commonjs/windowing/findVisibleIndexRange.js +0 -48
- package/lib/commonjs/windowing/findVisibleIndexRange.js.map +0 -1
- package/lib/module/NitroList.js +0 -5
- package/lib/module/NitroList.js.map +0 -1
- package/lib/module/RecyclerList.internal.js +0 -22
- package/lib/module/RecyclerList.internal.js.map +0 -1
- package/lib/module/RecyclerList.js +0 -166
- package/lib/module/RecyclerList.js.map +0 -1
- package/lib/module/RecyclerList.types.js +0 -4
- package/lib/module/RecyclerList.types.js.map +0 -1
- package/lib/module/cell/StableKey.js +0 -6
- package/lib/module/cell/StableKey.js.map +0 -1
- package/lib/module/hooks/useCellRenderer.js +0 -58
- package/lib/module/hooks/useCellRenderer.js.map +0 -1
- package/lib/module/hooks/useStableCallback.js +0 -9
- package/lib/module/hooks/useStableCallback.js.map +0 -1
- package/lib/module/layout/EstimatedLayoutProvider.js +0 -25
- package/lib/module/layout/EstimatedLayoutProvider.js.map +0 -1
- package/lib/module/layout/LayoutEngine.js +0 -17
- package/lib/module/layout/LayoutEngine.js.map +0 -1
- package/lib/module/layout/LayoutProvider.js +0 -4
- package/lib/module/layout/LayoutRectangle.js +0 -2
- package/lib/module/layout/LayoutRectangle.js.map +0 -1
- package/lib/module/native/NitroLayoutEngine.js +0 -5
- package/lib/module/native/NitroLayoutEngine.js.map +0 -1
- package/lib/module/native/NitroList.types.js +0 -4
- package/lib/module/native/NitroList.types.js.map +0 -1
- package/lib/module/native/NitroRecyclerView.js +0 -5
- package/lib/module/native/NitroRecyclerView.js.map +0 -1
- package/lib/module/specs/nitro-layout-engine.nitro.js +0 -4
- package/lib/module/specs/nitro-layout-engine.nitro.js.map +0 -1
- package/lib/module/viewability/ViewabilityHelper.js +0 -116
- package/lib/module/viewability/ViewabilityHelper.js.map +0 -1
- package/lib/module/windowing/findVisibleIndexRange.js +0 -44
- package/lib/module/windowing/findVisibleIndexRange.js.map +0 -1
- package/lib/typescript/src/NitroList.d.ts +0 -5
- package/lib/typescript/src/NitroList.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.d.ts +0 -26
- package/lib/typescript/src/RecyclerList.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.internal.d.ts +0 -9
- package/lib/typescript/src/RecyclerList.internal.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.types.d.ts +0 -18
- package/lib/typescript/src/RecyclerList.types.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts +0 -2
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts.map +0 -1
- package/lib/typescript/src/cell/StableKey.d.ts +0 -2
- package/lib/typescript/src/cell/StableKey.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCellRenderer.d.ts +0 -19
- package/lib/typescript/src/hooks/useCellRenderer.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useStableCallback.d.ts +0 -2
- package/lib/typescript/src/hooks/useStableCallback.d.ts.map +0 -1
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts +0 -15
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutEngine.d.ts +0 -10
- package/lib/typescript/src/layout/LayoutEngine.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutProvider.d.ts +0 -16
- package/lib/typescript/src/layout/LayoutProvider.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutRectangle.d.ts +0 -11
- package/lib/typescript/src/layout/LayoutRectangle.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroLayoutEngine.d.ts +0 -3
- package/lib/typescript/src/native/NitroLayoutEngine.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroList.types.d.ts +0 -9
- package/lib/typescript/src/native/NitroList.types.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroRecyclerView.d.ts +0 -5
- package/lib/typescript/src/native/NitroRecyclerView.d.ts.map +0 -1
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +0 -14
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +0 -1
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts +0 -50
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts +0 -11
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts.map +0 -1
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +0 -56
- package/src/NitroList.ts +0 -8
- package/src/RecyclerList.internal.ts +0 -38
- package/src/RecyclerList.tsx +0 -252
- package/src/RecyclerList.types.ts +0 -24
- package/src/__tests__/windowing/findVisibleIndexRange.test.ts +0 -55
- package/src/cell/StableKey.ts +0 -6
- package/src/hooks/useCellRenderer.ts +0 -86
- package/src/hooks/useStableCallback.ts +0 -13
- package/src/layout/EstimatedLayoutProvider.ts +0 -35
- package/src/layout/LayoutEngine.ts +0 -21
- package/src/layout/LayoutProvider.ts +0 -17
- package/src/layout/LayoutRectangle.ts +0 -10
- package/src/native/NitroLayoutEngine.ts +0 -7
- package/src/native/NitroList.types.ts +0 -12
- package/src/native/NitroRecyclerView.ts +0 -8
- package/src/specs/nitro-layout-engine.nitro.ts +0 -17
- package/src/viewability/ViewabilityHelper.ts +0 -130
- package/src/windowing/findVisibleIndexRange.ts +0 -60
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** * CellType is just a string, but we give it a name
|
|
2
|
+
* so the code is easier to read.
|
|
3
|
+
*/
|
|
4
|
+
export type CellType = string;
|
|
5
|
+
|
|
6
|
+
/** * This is an "Identity" function. It doesn't do anything
|
|
7
|
+
* to the computer, but it helps the human reading the code.
|
|
8
|
+
*/
|
|
9
|
+
export const cellType = (name: string): CellType => name;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { LayoutRect } from './layout/LayoutRect'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Input required to compute the visible item range.
|
|
5
|
+
*
|
|
6
|
+
* Pure contract:
|
|
7
|
+
* - No logic
|
|
8
|
+
* - No platform assumptions
|
|
9
|
+
* - Safe to share with native / tests
|
|
10
|
+
*/
|
|
11
|
+
export interface VisibleRangeInput {
|
|
12
|
+
/**
|
|
13
|
+
* Ordered, monotonic layouts along the main axis.
|
|
14
|
+
* Required for binary search correctness.
|
|
15
|
+
*/
|
|
16
|
+
readonly layouts: readonly LayoutRect[]
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Scroll offset along the main axis.
|
|
20
|
+
*/
|
|
21
|
+
readonly offset: number
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Viewport size along the main axis.
|
|
25
|
+
*/
|
|
26
|
+
readonly viewportSize: number
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Extra buffer before and after the viewport.
|
|
30
|
+
*/
|
|
31
|
+
readonly buffer: number
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Axis selector.
|
|
35
|
+
* true → vertical
|
|
36
|
+
* false → horizontal
|
|
37
|
+
*/
|
|
38
|
+
readonly isVertical: boolean
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type { Axis } from './Axis'
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
MainAxisPadding,
|
|
5
|
+
} from './layout/MainAxisPadding'
|
|
6
|
+
export {
|
|
7
|
+
ZERO_MAIN_AXIS_PADDING,
|
|
8
|
+
} from './layout/MainAxisPadding'
|
|
9
|
+
|
|
10
|
+
export type { LayoutRect } from './layout/LayoutRect'
|
|
11
|
+
export type { VisibleRange } from './VisibleRange'
|
|
12
|
+
export type { CellKey } from './CellKey'
|
|
13
|
+
export type { CellType } from './CellType'
|
|
14
|
+
|
|
15
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Absolute layout rectangle.
|
|
3
|
+
*
|
|
4
|
+
* Cross-platform equivalent of:
|
|
5
|
+
* - Flutter: Rect
|
|
6
|
+
* - Android: Rect
|
|
7
|
+
* - iOS: CGRect
|
|
8
|
+
*/
|
|
9
|
+
export interface LayoutRect {
|
|
10
|
+
readonly x: number
|
|
11
|
+
readonly y: number
|
|
12
|
+
readonly width: number
|
|
13
|
+
readonly height: number
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MainAxisPadding } from './MainAxisPadding'
|
|
2
|
+
|
|
3
|
+
export interface LinearLayoutInput {
|
|
4
|
+
readonly crossAxisSize: number
|
|
5
|
+
readonly itemMainAxisSizes: readonly number[]
|
|
6
|
+
|
|
7
|
+
/** Padding before/after content (main axis) */
|
|
8
|
+
readonly padding: MainAxisPadding
|
|
9
|
+
|
|
10
|
+
/** Space BETWEEN items (main axis) */
|
|
11
|
+
readonly itemSpacing?: number
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Padding applied along the main scroll axis.
|
|
3
|
+
*
|
|
4
|
+
* This is a layout-level concept (not visual styling).
|
|
5
|
+
*
|
|
6
|
+
* - vertical → top / bottom
|
|
7
|
+
* - horizontal → left / right
|
|
8
|
+
*
|
|
9
|
+
* Uses start/end to remain RTL-safe and platform-neutral.
|
|
10
|
+
*/
|
|
11
|
+
export interface MainAxisPadding {
|
|
12
|
+
readonly start: number
|
|
13
|
+
readonly end: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Shared zero-padding constant.
|
|
18
|
+
* Safe to reuse across layouts.
|
|
19
|
+
*/
|
|
20
|
+
export const ZERO_MAIN_AXIS_PADDING: MainAxisPadding = {
|
|
21
|
+
start: 0,
|
|
22
|
+
end: 0,
|
|
23
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CellType } from "../CellType"
|
|
2
|
+
import type { RecyclerCell } from "./RecyclerCell"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Owns recycled physical cells.
|
|
7
|
+
* Enforces hard caps.
|
|
8
|
+
*/
|
|
9
|
+
export class CellPool<T extends RecyclerCell> {
|
|
10
|
+
private readonly pools = new Map<CellType, T[]>()
|
|
11
|
+
private readonly maxPerType = new Map<CellType, number>()
|
|
12
|
+
|
|
13
|
+
hasType(type: CellType): boolean {
|
|
14
|
+
return this.pools.has(type)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
registerType(type: CellType, maxCount: number): void {
|
|
18
|
+
if (this.pools.has(type)) return
|
|
19
|
+
this.pools.set(type, [])
|
|
20
|
+
this.maxPerType.set(type, maxCount)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
acquire(type: CellType): T | null {
|
|
24
|
+
const bucket = this.pools.get(type)
|
|
25
|
+
if (!bucket || bucket.length === 0) return null
|
|
26
|
+
return bucket.pop() ?? null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
release(cell: T): void {
|
|
30
|
+
const bucket = this.pools.get(cell.type)
|
|
31
|
+
const max = this.maxPerType.get(cell.type)
|
|
32
|
+
if (!bucket || max === undefined) return
|
|
33
|
+
|
|
34
|
+
cell.index = -1
|
|
35
|
+
if (bucket.length >= max) return
|
|
36
|
+
|
|
37
|
+
bucket.push(cell)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
clear(): void {
|
|
41
|
+
for (const bucket of this.pools.values()) {
|
|
42
|
+
bucket.length = 0
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Axis } from '../Axis'
|
|
2
|
+
import type { CellType } from '../CellType'
|
|
3
|
+
import type { MainAxisPadding } from '../layout'
|
|
4
|
+
import type { RecyclerItemRenderer } from './RecyclerItemRenderer'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Public props for NitroList.
|
|
8
|
+
*
|
|
9
|
+
* Generic, data-driven, layout-deterministic API.
|
|
10
|
+
* This surface is intentionally minimal and stable.
|
|
11
|
+
*/
|
|
12
|
+
export interface NitroListProps<T> {
|
|
13
|
+
/**
|
|
14
|
+
* Scroll direction.
|
|
15
|
+
* Defaults to 'vertical'.
|
|
16
|
+
*/
|
|
17
|
+
readonly scrollDirection?: Axis
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Cross-axis size.
|
|
21
|
+
* - vertical → width
|
|
22
|
+
* - horizontal → height
|
|
23
|
+
*
|
|
24
|
+
* Required for deterministic layout.
|
|
25
|
+
*/
|
|
26
|
+
readonly containerCrossAxisSize: number
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Data source.
|
|
30
|
+
* Length is the single source of truth for item count.
|
|
31
|
+
*/
|
|
32
|
+
readonly data: readonly T[]
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Item sizes along the main axis.
|
|
36
|
+
* Must match data length.
|
|
37
|
+
*
|
|
38
|
+
* - vertical → heights
|
|
39
|
+
* - horizontal → widths
|
|
40
|
+
*/
|
|
41
|
+
readonly itemMainAxisSizes: readonly number[]
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Padding before and after content along the main axis.
|
|
45
|
+
*
|
|
46
|
+
* Defaults are applied internally by the layout engine.
|
|
47
|
+
*/
|
|
48
|
+
readonly padding?: MainAxisPadding
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Space BETWEEN items along the main axis.
|
|
52
|
+
*
|
|
53
|
+
* Defaults are applied internally by the layout engine.
|
|
54
|
+
*/
|
|
55
|
+
readonly itemSpacing?: number
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Extra render buffer as a ratio of viewport size.
|
|
59
|
+
* Used for overscan / pre-rendering.
|
|
60
|
+
*/
|
|
61
|
+
readonly bufferRatio?: number
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Logical cell type resolver.
|
|
65
|
+
* Determines recycling compatibility.
|
|
66
|
+
*/
|
|
67
|
+
readonly getCellType: (item: T, index: number) => CellType
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Item renderer.
|
|
71
|
+
* Receives stable cell identity and data.
|
|
72
|
+
*/
|
|
73
|
+
readonly renderItem: RecyclerItemRenderer<T>
|
|
74
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CellType } from '../CellType'
|
|
2
|
+
import type { CellKey } from '../CellKey'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Public contract for a physical recycler cell.
|
|
6
|
+
* Key type MUST be generic / opaque.
|
|
7
|
+
*/
|
|
8
|
+
export interface RecyclerCell<K = CellKey> {
|
|
9
|
+
readonly key: K
|
|
10
|
+
readonly type: CellType
|
|
11
|
+
index: number
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import type { RecyclerCell } from './RecyclerCell'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Public renderItem signature for RecyclerList.
|
|
6
|
+
* Renderers receive a stable physical cell contract.
|
|
7
|
+
*/
|
|
8
|
+
export type RecyclerItemRenderer<T> = (params: {
|
|
9
|
+
item: T
|
|
10
|
+
index: number
|
|
11
|
+
cell: RecyclerCell
|
|
12
|
+
}) => ReactNode
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Axis } from "../Axis"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Scroll state snapshot.
|
|
6
|
+
*
|
|
7
|
+
* Pure data — no platform or React coupling.
|
|
8
|
+
*/
|
|
9
|
+
export interface ScrollMetrics {
|
|
10
|
+
/** Scroll axis */
|
|
11
|
+
readonly axis: Axis
|
|
12
|
+
|
|
13
|
+
/** Offset along the main axis */
|
|
14
|
+
readonly offset: number
|
|
15
|
+
|
|
16
|
+
/** Viewport size along the main axis */
|
|
17
|
+
readonly viewportSize: number
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ScrollMetrics } from './ScrollMetrics'
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { LayoutRect } from "../types/layout"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export type VisibleRange = {
|
|
5
|
+
startIndex: number
|
|
6
|
+
endIndex: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Input = {
|
|
10
|
+
layouts: readonly LayoutRect[]
|
|
11
|
+
offset: number
|
|
12
|
+
viewportSize: number
|
|
13
|
+
buffer: number
|
|
14
|
+
isVertical: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Computes visible item range using binary search + forward scan.
|
|
19
|
+
* Type-safe and defensive against invalid indices.
|
|
20
|
+
*/
|
|
21
|
+
export function computeVisibleItemRange(
|
|
22
|
+
input: Input
|
|
23
|
+
): VisibleRange | null {
|
|
24
|
+
const {
|
|
25
|
+
layouts,
|
|
26
|
+
offset,
|
|
27
|
+
viewportSize,
|
|
28
|
+
buffer,
|
|
29
|
+
isVertical,
|
|
30
|
+
} = input
|
|
31
|
+
|
|
32
|
+
const count = layouts.length
|
|
33
|
+
if (count === 0) return null
|
|
34
|
+
|
|
35
|
+
const windowStart = Math.max(0, offset - buffer)
|
|
36
|
+
const windowEnd = offset + viewportSize + buffer
|
|
37
|
+
|
|
38
|
+
// ------------------------------
|
|
39
|
+
// Binary search: first visible
|
|
40
|
+
// ------------------------------
|
|
41
|
+
let low = 0
|
|
42
|
+
let high = count - 1
|
|
43
|
+
let first = count
|
|
44
|
+
|
|
45
|
+
while (low <= high) {
|
|
46
|
+
const mid = (low + high) >>> 1
|
|
47
|
+
const rect = layouts[mid]
|
|
48
|
+
if (!rect) break
|
|
49
|
+
|
|
50
|
+
const start = isVertical ? rect.y : rect.x
|
|
51
|
+
const size = isVertical ? rect.height : rect.width
|
|
52
|
+
|
|
53
|
+
if (start + size >= windowStart) {
|
|
54
|
+
first = mid
|
|
55
|
+
high = mid - 1
|
|
56
|
+
} else {
|
|
57
|
+
low = mid + 1
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (first === count) return null
|
|
62
|
+
|
|
63
|
+
// ------------------------------
|
|
64
|
+
// Linear scan: last visible
|
|
65
|
+
// ------------------------------
|
|
66
|
+
let last = first
|
|
67
|
+
|
|
68
|
+
for (let i = first + 1; i < count; i++) {
|
|
69
|
+
const rect = layouts[i]
|
|
70
|
+
if (!rect) break
|
|
71
|
+
|
|
72
|
+
const start = isVertical ? rect.y : rect.x
|
|
73
|
+
if (start > windowEnd) break
|
|
74
|
+
|
|
75
|
+
last = i
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
startIndex: first,
|
|
80
|
+
endIndex: last,
|
|
81
|
+
}
|
|
82
|
+
}
|
package/src/windowing/index.ts
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.NitroRecyclerView = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
const NitroRecyclerView = exports.NitroRecyclerView = (0, _reactNative.requireNativeComponent)('NitroRecyclerView');
|
|
9
|
-
//# sourceMappingURL=NitroList.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","NitroRecyclerView","exports","requireNativeComponent"],"sourceRoot":"../../src","sources":["NitroList.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAC5B,IAAAE,mCAAsB,EAAyB,mBAAmB,CAAC","ignoreList":[]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useRecyclerListInternal = useRecyclerListInternal;
|
|
7
|
-
var _useCellRenderer = require("./hooks/useCellRenderer");
|
|
8
|
-
/**
|
|
9
|
-
* INTERNAL hook.
|
|
10
|
-
* MUST ALWAYS CALL hooks in the same order.
|
|
11
|
-
*/
|
|
12
|
-
function useRecyclerListInternal(layouts, metrics, bufferPx, getItemType) {
|
|
13
|
-
/**
|
|
14
|
-
* FlashList rule:
|
|
15
|
-
* Hooks are ALWAYS called.
|
|
16
|
-
* Inputs are guarded instead.
|
|
17
|
-
*/
|
|
18
|
-
const safeLayouts = metrics.height > 0 ? layouts : EMPTY_LAYOUTS;
|
|
19
|
-
const safeBufferPx = metrics.height > 0 ? bufferPx : 0;
|
|
20
|
-
return (0, _useCellRenderer.useCellRenderer)(safeLayouts, metrics, safeBufferPx, getItemType);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Stable empty reference */
|
|
24
|
-
const EMPTY_LAYOUTS = [];
|
|
25
|
-
//# sourceMappingURL=RecyclerList.internal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_useCellRenderer","require","useRecyclerListInternal","layouts","metrics","bufferPx","getItemType","safeLayouts","height","EMPTY_LAYOUTS","safeBufferPx","useCellRenderer"],"sourceRoot":"../../src","sources":["RecyclerList.internal.ts"],"mappings":";;;;;;AAIA,IAAAA,gBAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CACrCC,OAAmC,EACnCC,OAAsB,EACtBC,QAAgB,EAChBC,WAAsC,EACrB;EAEjB;AACF;AACA;AACA;AACA;EACE,MAAMC,WAAW,GACfH,OAAO,CAACI,MAAM,GAAG,CAAC,GAAGL,OAAO,GAAGM,aAAa;EAE9C,MAAMC,YAAY,GAChBN,OAAO,CAACI,MAAM,GAAG,CAAC,GAAGH,QAAQ,GAAG,CAAC;EAEnC,OAAO,IAAAM,gCAAe,EACpBJ,WAAW,EACXH,OAAO,EACPM,YAAY,EACZJ,WACF,CAAC;AACH;;AAEA;AACA,MAAMG,aAAyC,GAAG,EAAE","ignoreList":[]}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.RecyclerList = RecyclerList;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _RecyclerList = require("./RecyclerList.internal");
|
|
10
|
-
var _windowing = require("./windowing");
|
|
11
|
-
var _MutableLinearLayout = require("./layout/MutableLinearLayout");
|
|
12
|
-
var _ViewabilityHelper = require("./viewability/ViewabilityHelper");
|
|
13
|
-
var _PrefetchHelper = require("./prefetch/PrefetchHelper");
|
|
14
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
-
/**
|
|
17
|
-
* Public API — mirrors FlashList behavior, not internals.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* FlashList invariant:
|
|
22
|
-
* Never allow viewport height = 0 to gate windowing.
|
|
23
|
-
*/
|
|
24
|
-
const DEFAULT_VIEWPORT_HEIGHT = 800;
|
|
25
|
-
function RecyclerList(props) {
|
|
26
|
-
const {
|
|
27
|
-
containerWidth,
|
|
28
|
-
itemCount,
|
|
29
|
-
itemHeights,
|
|
30
|
-
estimatedItemHeight = 80,
|
|
31
|
-
renderBufferRatio = 1.3,
|
|
32
|
-
getItemType = () => 'default',
|
|
33
|
-
renderItem,
|
|
34
|
-
onPrefetch,
|
|
35
|
-
onViewableItemsChanged
|
|
36
|
-
} = props;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 🚨 DEV WARNINGS ONLY (never throw in render!)
|
|
40
|
-
*/
|
|
41
|
-
if (__DEV__) {
|
|
42
|
-
if (!itemHeights && itemCount == null) {
|
|
43
|
-
console.error('RecyclerList requires either itemCount or itemHeights.');
|
|
44
|
-
}
|
|
45
|
-
if (itemHeights && itemCount != null) {
|
|
46
|
-
console.error('Provide only one of itemCount or itemHeights.');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* STEP 1: Resolve item count safely (props only).
|
|
52
|
-
* Never depend on hooks for structural decisions.
|
|
53
|
-
*/
|
|
54
|
-
const itemLength = itemHeights?.length ?? itemCount ?? 0;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* STEP 2: Resolve initial heights (always defined).
|
|
58
|
-
*/
|
|
59
|
-
const resolvedHeights = (0, _react.useMemo)(() => {
|
|
60
|
-
if (itemHeights) return itemHeights;
|
|
61
|
-
return Array.from({
|
|
62
|
-
length: itemLength
|
|
63
|
-
}, () => estimatedItemHeight);
|
|
64
|
-
}, [itemHeights, itemLength, estimatedItemHeight]);
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* STEP 3: Mutable layout lifecycle.
|
|
68
|
-
* Recreate layout only when shape changes.
|
|
69
|
-
*/
|
|
70
|
-
const layoutRef = (0, _react.useRef)(null);
|
|
71
|
-
const lastLayoutKeyRef = (0, _react.useRef)(null);
|
|
72
|
-
const layoutKey = `${containerWidth}-${itemLength}`;
|
|
73
|
-
if (!layoutRef.current || lastLayoutKeyRef.current !== layoutKey) {
|
|
74
|
-
layoutRef.current = new _MutableLinearLayout.MutableLinearLayout(resolvedHeights, containerWidth);
|
|
75
|
-
lastLayoutKeyRef.current = layoutKey;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* STEP 4: Read layout snapshot.
|
|
80
|
-
*/
|
|
81
|
-
const layouts = layoutRef.current.getLayouts();
|
|
82
|
-
const contentHeight = layoutRef.current.getContentHeight();
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* STEP 5: Scroll metrics.
|
|
86
|
-
*/
|
|
87
|
-
const {
|
|
88
|
-
metrics,
|
|
89
|
-
onScroll,
|
|
90
|
-
onLayout
|
|
91
|
-
} = (0, _windowing.useScrollMetrics)();
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* STEP 6: Guard initial windowing.
|
|
95
|
-
*/
|
|
96
|
-
const effectiveViewportHeight = metrics.height > 0 ? metrics.height : DEFAULT_VIEWPORT_HEIGHT;
|
|
97
|
-
const bufferPx = effectiveViewportHeight * renderBufferRatio;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* STEP 7: Windowing + recycling.
|
|
101
|
-
*/
|
|
102
|
-
const cells = (0, _RecyclerList.useRecyclerListInternal)(layouts, metrics, bufferPx, getItemType);
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* STEP 8: Phase-1 observers.
|
|
106
|
-
*/
|
|
107
|
-
const viewabilityRef = (0, _react.useRef)(new _ViewabilityHelper.ViewabilityHelper({
|
|
108
|
-
itemVisiblePercentThreshold: 50
|
|
109
|
-
}));
|
|
110
|
-
const prefetchRef = (0, _react.useRef)(new _PrefetchHelper.PrefetchHelper());
|
|
111
|
-
(0, _react.useEffect)(() => {
|
|
112
|
-
prefetchRef.current = new _PrefetchHelper.PrefetchHelper();
|
|
113
|
-
}, [itemLength]);
|
|
114
|
-
(0, _react.useEffect)(() => {
|
|
115
|
-
if (metrics.height === 0) return;
|
|
116
|
-
if (onViewableItemsChanged) {
|
|
117
|
-
const visibleLayouts = [];
|
|
118
|
-
for (const cell of cells) {
|
|
119
|
-
const layout = layouts[cell.index];
|
|
120
|
-
if (layout) visibleLayouts.push(layout);
|
|
121
|
-
}
|
|
122
|
-
const info = viewabilityRef.current.computeViewableItems(visibleLayouts, metrics);
|
|
123
|
-
onViewableItemsChanged(info);
|
|
124
|
-
}
|
|
125
|
-
if (onPrefetch && itemLength > 0) {
|
|
126
|
-
prefetchRef.current.runPrefetch(cells.map(c => c.index), itemLength, 5, onPrefetch);
|
|
127
|
-
}
|
|
128
|
-
}, [cells, metrics.offsetY, metrics.height, onViewableItemsChanged, onPrefetch, itemLength, layouts]);
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* STEP 9: Render absolutely positioned cells.
|
|
132
|
-
*/
|
|
133
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
134
|
-
style: styles.container,
|
|
135
|
-
onLayout: onLayout,
|
|
136
|
-
onScroll: onScroll,
|
|
137
|
-
scrollEventThrottle: 16,
|
|
138
|
-
removeClippedSubviews: true,
|
|
139
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
140
|
-
style: [styles.content, {
|
|
141
|
-
height: contentHeight
|
|
142
|
-
}],
|
|
143
|
-
children: cells.map(cell => {
|
|
144
|
-
const layout = layouts[cell.index];
|
|
145
|
-
if (!layout) return null;
|
|
146
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
147
|
-
style: [styles.cell, {
|
|
148
|
-
top: layout.y,
|
|
149
|
-
width: layout.width,
|
|
150
|
-
height: layout.height
|
|
151
|
-
}],
|
|
152
|
-
children: renderItem(cell.index)
|
|
153
|
-
}, cell.key);
|
|
154
|
-
})
|
|
155
|
-
})
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
const styles = _reactNative.StyleSheet.create({
|
|
159
|
-
container: {
|
|
160
|
-
flex: 1
|
|
161
|
-
},
|
|
162
|
-
content: {
|
|
163
|
-
position: 'relative',
|
|
164
|
-
width: '100%'
|
|
165
|
-
},
|
|
166
|
-
cell: {
|
|
167
|
-
position: 'absolute',
|
|
168
|
-
left: 0
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
//# sourceMappingURL=RecyclerList.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_RecyclerList","_windowing","_MutableLinearLayout","_ViewabilityHelper","_PrefetchHelper","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULT_VIEWPORT_HEIGHT","RecyclerList","props","containerWidth","itemCount","itemHeights","estimatedItemHeight","renderBufferRatio","getItemType","renderItem","onPrefetch","onViewableItemsChanged","__DEV__","console","error","itemLength","length","resolvedHeights","useMemo","Array","from","layoutRef","useRef","lastLayoutKeyRef","layoutKey","current","MutableLinearLayout","layouts","getLayouts","contentHeight","getContentHeight","metrics","onScroll","onLayout","useScrollMetrics","effectiveViewportHeight","height","bufferPx","cells","useRecyclerListInternal","viewabilityRef","ViewabilityHelper","itemVisiblePercentThreshold","prefetchRef","PrefetchHelper","useEffect","visibleLayouts","cell","layout","index","push","info","computeViewableItems","runPrefetch","map","c","offsetY","jsx","ScrollView","style","styles","container","scrollEventThrottle","removeClippedSubviews","children","View","content","top","y","width","key","StyleSheet","create","flex","position","left"],"sourceRoot":"../../src","sources":["RecyclerList.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AAA0D,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,C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KAAK,EAAE,CAACC,MAAM,CAACM,OAAO,EAAE;QAAE9B,MAAM,EAAEP;MAAc,CAAC,CAAE;MAAAmC,QAAA,EACtD1B,KAAK,CAACgB,GAAG,CAACP,IAAI,IAAI;QACjB,MAAMC,MAAM,GAAGrB,OAAO,CAACoB,IAAI,CAACE,KAAK,CAAC;QAClC,IAAI,CAACD,MAAM,EAAE,OAAO,IAAI;QAExB,oBACE,IAAApE,WAAA,CAAA6E,GAAA,EAACnF,YAAA,CAAA2F,IAAI;UAEHN,KAAK,EAAE,CACLC,MAAM,CAACb,IAAI,EACX;YACEoB,GAAG,EAAEnB,MAAM,CAACoB,CAAC;YACbC,KAAK,EAAErB,MAAM,CAACqB,KAAK;YACnBjC,MAAM,EAAEY,MAAM,CAACZ;UACjB,CAAC,CACD;UAAA4B,QAAA,EAEDvD,UAAU,CAACsC,IAAI,CAACE,KAAK;QAAC,GAVlBF,IAAI,CAACuB,GAWN,CAAC;MAEX,CAAC;IAAC,CACE;EAAC,CACG,CAAC;AAEjB;AAEA,MAAMV,MAAM,GAAGW,uBAAU,CAACC,MAAM,CAAC;EAC/BX,SAAS,EAAE;IAAEY,IAAI,EAAE;EAAE,CAAC;EACtBP,OAAO,EAAE;IAAEQ,QAAQ,EAAE,UAAU;IAAEL,KAAK,EAAE;EAAO,CAAC;EAChDtB,IAAI,EAAE;IAAE2B,QAAQ,EAAE,UAAU;IAAEC,IAAI,EAAE;EAAE;AACxC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["RecyclerList.types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getStableKey","slotKey","index"],"sourceRoot":"../../../src","sources":["cell/StableKey.ts"],"mappings":";;;;;;AAAO,SAASA,YAAYA,CAC1BC,OAAe,EACfC,KAAa,EACL;EACR,OAAO,GAAGD,OAAO,IAAIC,KAAK,EAAE;AAC9B","ignoreList":[]}
|