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.
- package/ios/HybridNitroList.swift +10 -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 +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/recycler/CellPool.js +46 -0
- package/lib/commonjs/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/recycler/RecyclerList.js +224 -0
- package/lib/commonjs/recycler/RecyclerList.js.map +1 -0
- package/lib/commonjs/types/Axis.js +2 -0
- package/lib/commonjs/{layout/LayoutProvider.js.map → types/Axis.js.map} +1 -1
- package/lib/commonjs/types/CellKey.js +2 -0
- package/lib/{module/layout/LayoutProvider.js.map → commonjs/types/CellKey.js.map} +1 -1
- package/lib/commonjs/types/CellType.js +2 -0
- package/lib/commonjs/{layout/LayoutRectangle.js.map → types/CellType.js.map} +1 -1
- package/lib/commonjs/types/VisibleRange.js +2 -0
- package/lib/{module/layout/LayoutRectangle.js.map → commonjs/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/types/layout/LinearLayoutInput.js +6 -0
- 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/RecyclerCellInstance.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerCellInstance.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/RecyclerListProps.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerListProps.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/{layout/LayoutProvider.js → types/scroll/ScrollMetrics.js} +1 -1
- 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 +71 -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 +1 -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/recycler/CellPool.js +41 -0
- package/lib/module/recycler/CellPool.js.map +1 -0
- package/lib/module/recycler/RecyclerList.js +221 -0
- package/lib/module/recycler/RecyclerList.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 +2 -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/RecyclerCellInstance.js +4 -0
- package/lib/module/types/recycler/RecyclerCellInstance.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/RecyclerListProps.js +4 -0
- package/lib/module/types/recycler/RecyclerListProps.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 +67 -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 +1 -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/NitroList.types.d.ts +2 -2
- package/lib/typescript/src/native/NitroList.types.d.ts.map +1 -1
- package/lib/typescript/src/recycler/CellPool.d.ts +14 -0
- package/lib/typescript/src/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/recycler/RecyclerList.d.ts +4 -0
- package/lib/typescript/src/recycler/RecyclerList.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +2 -2
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +1 -1
- 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 +10 -0
- package/lib/typescript/src/types/CellKey.d.ts.map +1 -0
- package/lib/typescript/src/types/CellType.d.ts +11 -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/RecyclerCellInstance.d.ts +37 -0
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts +8 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts +66 -0
- package/lib/typescript/src/types/recycler/RecyclerListProps.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 +15 -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/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.cpp +7 -7
- package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/{JLayoutRectangle.hpp → JLayoutRect.hpp} +10 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/HybridNitroLayoutEngineSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{LayoutRectangle.kt → LayoutRect.kt} +5 -5
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +14 -14
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +3 -3
- package/nitrogen/generated/ios/c++/HybridNitroLayoutEngineSpecSwift.hpp +4 -4
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec_cxx.swift +5 -5
- package/nitrogen/generated/ios/swift/{LayoutRectangle.swift → LayoutRect.swift} +5 -5
- package/nitrogen/generated/shared/c++/HybridNitroLayoutEngineSpec.hpp +4 -4
- package/nitrogen/generated/shared/c++/{LayoutRectangle.hpp → LayoutRect.hpp} +11 -11
- package/package.json +1 -1
- 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 +1 -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/NitroList.types.ts +3 -2
- package/src/recycler/CellPool.ts +47 -0
- package/src/recycler/RecyclerList.tsx +304 -0
- package/src/specs/nitro-layout-engine.nitro.ts +2 -2
- package/src/types/Axis.ts +10 -0
- package/src/types/CellKey.ts +9 -0
- package/src/types/CellType.ts +10 -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/RecyclerCellInstance.ts +40 -0
- package/src/types/recycler/RecyclerItemRenderer.ts +8 -0
- package/src/types/recycler/RecyclerListProps.ts +74 -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 +78 -0
- package/src/windowing/index.ts +1 -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/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/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/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/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/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/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/viewability/ViewabilityHelper.ts +0 -130
- package/src/windowing/findVisibleIndexRange.ts +0 -60
|
@@ -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,40 @@
|
|
|
1
|
+
import type { CellKey } from "../CellKey"
|
|
2
|
+
import type { CellType } from "../CellType"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Physical reusable cell instance.
|
|
7
|
+
*
|
|
8
|
+
* Represents a single mounted view that can be rebound
|
|
9
|
+
* to different data items as scrolling occurs.
|
|
10
|
+
*
|
|
11
|
+
* Cross-platform equivalent:
|
|
12
|
+
* - Flutter: Element / RenderObject
|
|
13
|
+
* - Android: ViewHolder
|
|
14
|
+
* - iOS: UICollectionViewCell
|
|
15
|
+
*/
|
|
16
|
+
export interface RecyclerCellInstance {
|
|
17
|
+
/**
|
|
18
|
+
* Stable physical identity.
|
|
19
|
+
*
|
|
20
|
+
* Used as React key.
|
|
21
|
+
* MUST remain constant for the lifetime of the instance.
|
|
22
|
+
*/
|
|
23
|
+
readonly key: CellKey
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Logical data index currently bound to this instance.
|
|
27
|
+
*
|
|
28
|
+
* This value changes as the cell is recycled.
|
|
29
|
+
* - -1 may be used to indicate "unbound".
|
|
30
|
+
*/
|
|
31
|
+
index: number
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Logical compatibility type.
|
|
35
|
+
*
|
|
36
|
+
* Determines which instances can be reused together.
|
|
37
|
+
* Instances with different types MUST NOT be reused.
|
|
38
|
+
*/
|
|
39
|
+
readonly type: CellType
|
|
40
|
+
}
|
|
@@ -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 RecyclerList.
|
|
8
|
+
*
|
|
9
|
+
* Generic, data-driven, layout-deterministic API.
|
|
10
|
+
* This surface is intentionally minimal and stable.
|
|
11
|
+
*/
|
|
12
|
+
export interface RecyclerListProps<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,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,78 @@
|
|
|
1
|
+
import type { VisibleRange } from '../types/VisibleRange'
|
|
2
|
+
import type { VisibleRangeInput } from '../types/VisibleRangeInput'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Computes the visible item index range using binary search.
|
|
6
|
+
*
|
|
7
|
+
* Responsibilities:
|
|
8
|
+
* - Determine which items intersect the visible window
|
|
9
|
+
* - Stay independent of rendering and recycling
|
|
10
|
+
*
|
|
11
|
+
* Performance:
|
|
12
|
+
* - O(log n) to locate the first visible item
|
|
13
|
+
* - O(k) to expand to the last visible item (k = visible count)
|
|
14
|
+
*/
|
|
15
|
+
export function computeVisibleItemRange(
|
|
16
|
+
input: VisibleRangeInput
|
|
17
|
+
): VisibleRange | null {
|
|
18
|
+
const {
|
|
19
|
+
layouts,
|
|
20
|
+
offset,
|
|
21
|
+
viewportSize,
|
|
22
|
+
buffer,
|
|
23
|
+
isVertical,
|
|
24
|
+
} = input
|
|
25
|
+
|
|
26
|
+
const itemCount = layouts.length
|
|
27
|
+
if (itemCount === 0) return null
|
|
28
|
+
|
|
29
|
+
const windowStart = Math.max(0, offset - buffer)
|
|
30
|
+
const windowEnd = offset + viewportSize + buffer
|
|
31
|
+
|
|
32
|
+
// --------------------------------------------------
|
|
33
|
+
// Binary search:
|
|
34
|
+
// First item whose END >= windowStart
|
|
35
|
+
// --------------------------------------------------
|
|
36
|
+
let low = 0
|
|
37
|
+
let high = itemCount - 1
|
|
38
|
+
let firstVisibleIndex = itemCount
|
|
39
|
+
|
|
40
|
+
while (low <= high) {
|
|
41
|
+
const mid = (low + high) >>> 1
|
|
42
|
+
const rect = layouts[mid]!
|
|
43
|
+
|
|
44
|
+
const start = isVertical ? rect.y : rect.x
|
|
45
|
+
const size = isVertical ? rect.height : rect.width
|
|
46
|
+
const end = start + size
|
|
47
|
+
|
|
48
|
+
if (end >= windowStart) {
|
|
49
|
+
firstVisibleIndex = mid
|
|
50
|
+
high = mid - 1
|
|
51
|
+
} else {
|
|
52
|
+
low = mid + 1
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (firstVisibleIndex === itemCount) {
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// --------------------------------------------------
|
|
61
|
+
// Linear scan forward:
|
|
62
|
+
// Last item whose START <= windowEnd
|
|
63
|
+
// --------------------------------------------------
|
|
64
|
+
let lastVisibleIndex = firstVisibleIndex
|
|
65
|
+
|
|
66
|
+
for (let i = firstVisibleIndex + 1; i < itemCount; i++) {
|
|
67
|
+
const rect = layouts[i]!
|
|
68
|
+
const start = isVertical ? rect.y : rect.x
|
|
69
|
+
|
|
70
|
+
if (start > windowEnd) break
|
|
71
|
+
lastVisibleIndex = i
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
startIndex: firstVisibleIndex,
|
|
76
|
+
endIndex: lastVisibleIndex,
|
|
77
|
+
}
|
|
78
|
+
}
|
package/src/windowing/index.ts
CHANGED
|
@@ -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,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EC,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":[]}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useCellRenderer = useCellRenderer;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _CellRecycler = require("../cell/CellRecycler");
|
|
9
|
-
var _findVisibleIndexRange = require("../windowing/findVisibleIndexRange");
|
|
10
|
-
/**
|
|
11
|
-
* 🔒 Stable empty references (module-level)
|
|
12
|
-
* These MUST NOT be recreated per render.
|
|
13
|
-
*/
|
|
14
|
-
const EMPTY_INDICES = [];
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* React bridge for CellRecycler.
|
|
18
|
-
* FlashList equivalent: useCellRenderer
|
|
19
|
-
*
|
|
20
|
-
* Responsibilities:
|
|
21
|
-
* - Translate scroll state → visible indices
|
|
22
|
-
* - Ask recycler for physical cells
|
|
23
|
-
* - Commit results with referential stability
|
|
24
|
-
*
|
|
25
|
-
* Responsibilities it does NOT have:
|
|
26
|
-
* ❌ Layout mutation
|
|
27
|
-
* ❌ Measurement
|
|
28
|
-
* ❌ Rendering
|
|
29
|
-
*/
|
|
30
|
-
function useCellRenderer(layouts, metrics, bufferPx, getCellType) {
|
|
31
|
-
/**
|
|
32
|
-
* Recycler instance is stable across renders.
|
|
33
|
-
*/
|
|
34
|
-
const recyclerRef = (0, _react.useRef)(new _CellRecycler.CellRecycler());
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Compute visible indices.
|
|
38
|
-
* PURE + TOTAL:
|
|
39
|
-
* - Never throws
|
|
40
|
-
* - Always returns the same reference when empty
|
|
41
|
-
*/
|
|
42
|
-
const visibleIndices = (0, _react.useMemo)(() => layouts.length === 0 ? EMPTY_INDICES : (0, _findVisibleIndexRange.findVisibleIndexRange)(layouts, metrics, bufferPx), [layouts, metrics.offsetY, metrics.height, bufferPx]);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Physical cells to render.
|
|
46
|
-
*/
|
|
47
|
-
const [cells, setCells] = (0, _react.useState)([]);
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Reconcile visible indices → physical cells.
|
|
51
|
-
*
|
|
52
|
-
* FlashList invariant:
|
|
53
|
-
* - Only update state if identity truly changed
|
|
54
|
-
* - Prevents pointless re-renders
|
|
55
|
-
*/
|
|
56
|
-
(0, _react.useEffect)(() => {
|
|
57
|
-
const next = recyclerRef.current.reconcile(visibleIndices, getCellType);
|
|
58
|
-
setCells(prev => prev.length === next.length && prev.every((c, i) => c === next[i]) ? prev : next);
|
|
59
|
-
}, [visibleIndices, getCellType]);
|
|
60
|
-
return cells;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=useCellRenderer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_CellRecycler","_findVisibleIndexRange","EMPTY_INDICES","useCellRenderer","layouts","metrics","bufferPx","getCellType","recyclerRef","useRef","CellRecycler","visibleIndices","useMemo","length","findVisibleIndexRange","offsetY","height","cells","setCells","useState","useEffect","next","current","reconcile","prev","every","c","i"],"sourceRoot":"../../../src","sources":["hooks/useCellRenderer.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AACA,I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3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useStableCallback = useStableCallback;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
function useStableCallback(fn) {
|
|
9
|
-
const ref = (0, _react.useRef)(fn);
|
|
10
|
-
ref.current = fn;
|
|
11
|
-
return (0, _react.useCallback)((...args) => ref.current(...args), []);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=useStableCallback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","useStableCallback","fn","ref","useRef","current","useCallback","args"],"sourceRoot":"../../../src","sources":["hooks/useStableCallback.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,iBAAiBA,CAC/BC,EAAK,EACF;EACH,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAACF,EAAE,CAAC;EACtBC,GAAG,CAACE,OAAO,GAAGH,EAAE;EAEhB,OAAO,IAAAI,kBAAW,EACf,CAAC,GAAGC,IAAa,KAAKJ,GAAG,CAACE,OAAO,CAAC,GAAGE,IAAI,CAAC,EAC3C,EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.EstimatedLayoutProvider = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Layout provider using estimated item heights.
|
|
9
|
-
* Used before real measurements are available.
|
|
10
|
-
*/
|
|
11
|
-
class EstimatedLayoutProvider {
|
|
12
|
-
constructor(itemCount, itemHeight, width) {
|
|
13
|
-
this.itemCount = itemCount;
|
|
14
|
-
this.itemHeight = itemHeight;
|
|
15
|
-
this.width = width;
|
|
16
|
-
}
|
|
17
|
-
getItemCount() {
|
|
18
|
-
return this.itemCount;
|
|
19
|
-
}
|
|
20
|
-
getLayout(index) {
|
|
21
|
-
return {
|
|
22
|
-
x: 0,
|
|
23
|
-
y: index * this.itemHeight,
|
|
24
|
-
width: this.width,
|
|
25
|
-
height: this.itemHeight
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.EstimatedLayoutProvider = EstimatedLayoutProvider;
|
|
30
|
-
//# sourceMappingURL=EstimatedLayoutProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["EstimatedLayoutProvider","constructor","itemCount","itemHeight","width","getItemCount","getLayout","index","x","y","height","exports"],"sourceRoot":"../../../src","sources":["layout/EstimatedLayoutProvider.ts"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,CAA2B;EAK7DC,WAAWA,CACTC,SAAiB,EACjBC,UAAkB,EAClBC,KAAa,EACb;IACA,IAAI,CAACF,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,KAAK,GAAGA,KAAK;EACpB;EAEAC,YAAYA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACH,SAAS;EACvB;EAEAI,SAASA,CAACC,KAAa,EAAmB;IACxC,OAAO;MACLC,CAAC,EAAE,CAAC;MACJC,CAAC,EAAEF,KAAK,GAAG,IAAI,CAACJ,UAAU;MAC1BC,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBM,MAAM,EAAE,IAAI,CAACP;IACf,CAAC;EACH;AACF;AAACQ,OAAA,CAAAX,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.computeLayouts = computeLayouts;
|
|
7
|
-
/**
|
|
8
|
-
* Resolves layouts eagerly into a contiguous array.
|
|
9
|
-
* Pure, deterministic, and reusable.
|
|
10
|
-
*
|
|
11
|
-
* FlashList equivalent: internal layout resolver.
|
|
12
|
-
*/
|
|
13
|
-
function computeLayouts(provider) {
|
|
14
|
-
const count = provider.getItemCount();
|
|
15
|
-
const layouts = new Array(count);
|
|
16
|
-
for (let i = 0; i < count; i++) {
|
|
17
|
-
layouts[i] = provider.getLayout(i);
|
|
18
|
-
}
|
|
19
|
-
return layouts;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=LayoutEngine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["computeLayouts","provider","count","getItemCount","layouts","Array","i","getLayout"],"sourceRoot":"../../../src","sources":["layout/LayoutEngine.ts"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAcA,CAC5BC,QAAwB,EACI;EAC5B,MAAMC,KAAK,GAAGD,QAAQ,CAACE,YAAY,CAAC,CAAC;EACrC,MAAMC,OAA0B,GAAG,IAAIC,KAAK,CAACH,KAAK,CAAC;EAEnD,KAAK,IAAII,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,KAAK,EAAEI,CAAC,EAAE,EAAE;IAC9BF,OAAO,CAACE,CAAC,CAAC,GAAGL,QAAQ,CAACM,SAAS,CAACD,CAAC,CAAC;EACpC;EAEA,OAAOF,OAAO;AAChB","ignoreList":[]}
|