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,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useRef, useEffect, useState } from 'react';
|
|
4
|
+
import { ScrollView, View, StyleSheet } from 'react-native';
|
|
5
|
+
import { MutableLinearLayout } from '../layout/MutableLinearLayout';
|
|
6
|
+
import { computeVisibleItemRange } from '../windowing';
|
|
7
|
+
import { CellPool } from './CellPool';
|
|
8
|
+
|
|
9
|
+
/* =========================================================
|
|
10
|
+
* Constants
|
|
11
|
+
* =======================================================*/
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const DEFAULT_VIEWPORT_SIZE = 800;
|
|
14
|
+
const DEFAULT_ITEM_SIZE = 60;
|
|
15
|
+
const SCROLL_EVENT_THROTTLE = 16;
|
|
16
|
+
|
|
17
|
+
/* =========================================================
|
|
18
|
+
* RecyclerList
|
|
19
|
+
* =======================================================*/
|
|
20
|
+
|
|
21
|
+
export function RecyclerList(props) {
|
|
22
|
+
const {
|
|
23
|
+
scrollDirection = 'vertical',
|
|
24
|
+
containerCrossAxisSize,
|
|
25
|
+
data,
|
|
26
|
+
itemMainAxisSizes,
|
|
27
|
+
padding = {
|
|
28
|
+
start: 0,
|
|
29
|
+
end: 0
|
|
30
|
+
},
|
|
31
|
+
itemSpacing,
|
|
32
|
+
bufferRatio = 1.3,
|
|
33
|
+
getCellType,
|
|
34
|
+
renderItem
|
|
35
|
+
} = props;
|
|
36
|
+
const isVertical = scrollDirection === 'vertical';
|
|
37
|
+
const itemCount = data.length;
|
|
38
|
+
|
|
39
|
+
/* -------------------------------------------------------
|
|
40
|
+
* Controlled render
|
|
41
|
+
* -----------------------------------------------------*/
|
|
42
|
+
|
|
43
|
+
const [, forceRender] = useState(0);
|
|
44
|
+
|
|
45
|
+
/* -------------------------------------------------------
|
|
46
|
+
* Layout engine
|
|
47
|
+
* -----------------------------------------------------*/
|
|
48
|
+
|
|
49
|
+
const layoutEngineRef = useRef(null);
|
|
50
|
+
const layoutSignatureRef = useRef('');
|
|
51
|
+
const layoutSignature = [scrollDirection, containerCrossAxisSize, itemCount, itemMainAxisSizes, padding.start, padding.end, itemSpacing ?? 'default'].join('|');
|
|
52
|
+
if (!layoutEngineRef.current || layoutSignatureRef.current !== layoutSignature) {
|
|
53
|
+
const engine = new MutableLinearLayout(scrollDirection);
|
|
54
|
+
engine.compute({
|
|
55
|
+
crossAxisSize: containerCrossAxisSize,
|
|
56
|
+
itemMainAxisSizes,
|
|
57
|
+
padding,
|
|
58
|
+
itemSpacing
|
|
59
|
+
});
|
|
60
|
+
layoutEngineRef.current = engine;
|
|
61
|
+
layoutSignatureRef.current = layoutSignature;
|
|
62
|
+
}
|
|
63
|
+
const layouts = layoutEngineRef.current.getLayouts();
|
|
64
|
+
const contentSize = layoutEngineRef.current.getContentSize();
|
|
65
|
+
|
|
66
|
+
/* -------------------------------------------------------
|
|
67
|
+
* Scroll metrics
|
|
68
|
+
* -----------------------------------------------------*/
|
|
69
|
+
|
|
70
|
+
const scrollOffsetRef = useRef(0);
|
|
71
|
+
const viewportSizeRef = useRef(DEFAULT_VIEWPORT_SIZE);
|
|
72
|
+
|
|
73
|
+
/* -------------------------------------------------------
|
|
74
|
+
* Cell pool + physical cells
|
|
75
|
+
* -----------------------------------------------------*/
|
|
76
|
+
|
|
77
|
+
const cellPoolRef = useRef(new CellPool());
|
|
78
|
+
const activeCellsRef = useRef([]);
|
|
79
|
+
const nextCellKeyRef = useRef(0);
|
|
80
|
+
const createCell = type => ({
|
|
81
|
+
key: nextCellKeyRef.current++,
|
|
82
|
+
index: -1,
|
|
83
|
+
type
|
|
84
|
+
});
|
|
85
|
+
const MAX_CELLS = Math.ceil(viewportSizeRef.current / DEFAULT_ITEM_SIZE * bufferRatio) + 2;
|
|
86
|
+
|
|
87
|
+
/* -------------------------------------------------------
|
|
88
|
+
* Visible cell coordinator
|
|
89
|
+
* -----------------------------------------------------*/
|
|
90
|
+
|
|
91
|
+
const updateVisibleCells = () => {
|
|
92
|
+
const offset = scrollOffsetRef.current;
|
|
93
|
+
const viewportSize = viewportSizeRef.current;
|
|
94
|
+
const buffer = viewportSize * bufferRatio;
|
|
95
|
+
const range = computeVisibleItemRange({
|
|
96
|
+
layouts,
|
|
97
|
+
offset,
|
|
98
|
+
viewportSize,
|
|
99
|
+
buffer,
|
|
100
|
+
isVertical
|
|
101
|
+
});
|
|
102
|
+
if (!range) return;
|
|
103
|
+
const nextCells = [];
|
|
104
|
+
const used = new Set();
|
|
105
|
+
for (let index = range.startIndex; index <= range.endIndex; index++) {
|
|
106
|
+
const item = data[index];
|
|
107
|
+
if (item === undefined) continue;
|
|
108
|
+
const type = getCellType(item, index);
|
|
109
|
+
|
|
110
|
+
// Register type once, with hard cap
|
|
111
|
+
if (!cellPoolRef.current.hasType(type)) {
|
|
112
|
+
cellPoolRef.current.registerType(type, MAX_CELLS);
|
|
113
|
+
for (let i = 0; i < MAX_CELLS; i++) {
|
|
114
|
+
cellPoolRef.current.release(createCell(type));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
let cell = cellPoolRef.current.acquire(type);
|
|
118
|
+
if (!cell) {
|
|
119
|
+
const reuseIndex = activeCellsRef.current.findIndex(c => c.type === type);
|
|
120
|
+
if (reuseIndex === -1) continue;
|
|
121
|
+
cell = activeCellsRef.current.splice(reuseIndex, 1)[0];
|
|
122
|
+
}
|
|
123
|
+
cell.index = index;
|
|
124
|
+
nextCells.push(cell);
|
|
125
|
+
used.add(cell);
|
|
126
|
+
}
|
|
127
|
+
for (const cell of activeCellsRef.current) {
|
|
128
|
+
if (!used.has(cell)) {
|
|
129
|
+
cellPoolRef.current.release(cell);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
let changed = nextCells.length !== activeCellsRef.current.length;
|
|
133
|
+
if (!changed) {
|
|
134
|
+
for (let i = 0; i < nextCells.length; i++) {
|
|
135
|
+
if (nextCells[i] !== activeCellsRef.current[i]) {
|
|
136
|
+
changed = true;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (changed) {
|
|
142
|
+
activeCellsRef.current = nextCells;
|
|
143
|
+
forceRender(v => v + 1);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/* -------------------------------------------------------
|
|
148
|
+
* Scroll handlers
|
|
149
|
+
* -----------------------------------------------------*/
|
|
150
|
+
|
|
151
|
+
const frameScheduledRef = useRef(false);
|
|
152
|
+
const onScroll = e => {
|
|
153
|
+
scrollOffsetRef.current = isVertical ? e.nativeEvent.contentOffset.y : e.nativeEvent.contentOffset.x;
|
|
154
|
+
if (frameScheduledRef.current) return;
|
|
155
|
+
frameScheduledRef.current = true;
|
|
156
|
+
requestAnimationFrame(() => {
|
|
157
|
+
frameScheduledRef.current = false;
|
|
158
|
+
updateVisibleCells();
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
const onLayout = e => {
|
|
162
|
+
viewportSizeRef.current = isVertical ? e.nativeEvent.layout.height : e.nativeEvent.layout.width;
|
|
163
|
+
updateVisibleCells();
|
|
164
|
+
};
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
updateVisibleCells();
|
|
167
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
|
+
}, []);
|
|
169
|
+
|
|
170
|
+
/* -------------------------------------------------------
|
|
171
|
+
* Render
|
|
172
|
+
* -----------------------------------------------------*/
|
|
173
|
+
|
|
174
|
+
return /*#__PURE__*/_jsx(ScrollView, {
|
|
175
|
+
onScroll: onScroll,
|
|
176
|
+
onLayout: onLayout,
|
|
177
|
+
horizontal: !isVertical,
|
|
178
|
+
scrollEventThrottle: SCROLL_EVENT_THROTTLE,
|
|
179
|
+
removeClippedSubviews: true,
|
|
180
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
181
|
+
style: isVertical ? {
|
|
182
|
+
height: contentSize
|
|
183
|
+
} : {
|
|
184
|
+
width: contentSize
|
|
185
|
+
},
|
|
186
|
+
children: activeCellsRef.current.map(cell => {
|
|
187
|
+
const index = cell.index;
|
|
188
|
+
const layout = layouts[index];
|
|
189
|
+
const item = data[index];
|
|
190
|
+
if (!layout || item === undefined) return null;
|
|
191
|
+
return /*#__PURE__*/_jsx(View, {
|
|
192
|
+
style: [styles.cell, isVertical ? {
|
|
193
|
+
top: layout.y,
|
|
194
|
+
height: layout.height,
|
|
195
|
+
width: layout.width
|
|
196
|
+
} : {
|
|
197
|
+
left: layout.x,
|
|
198
|
+
width: layout.width,
|
|
199
|
+
height: layout.height
|
|
200
|
+
}],
|
|
201
|
+
children: renderItem({
|
|
202
|
+
item,
|
|
203
|
+
index,
|
|
204
|
+
cell
|
|
205
|
+
})
|
|
206
|
+
}, cell.key);
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* =========================================================
|
|
213
|
+
* Styles
|
|
214
|
+
* =======================================================*/
|
|
215
|
+
|
|
216
|
+
const styles = StyleSheet.create({
|
|
217
|
+
cell: {
|
|
218
|
+
position: 'absolute'
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
//# sourceMappingURL=RecyclerList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useRef","useEffect","useState","ScrollView","View","StyleSheet","MutableLinearLayout","computeVisibleItemRange","CellPool","jsx","_jsx","DEFAULT_VIEWPORT_SIZE","DEFAULT_ITEM_SIZE","SCROLL_EVENT_THROTTLE","RecyclerList","props","scrollDirection","containerCrossAxisSize","data","itemMainAxisSizes","padding","start","end","itemSpacing","bufferRatio","getCellType","renderItem","isVertical","itemCount","length","forceRender","layoutEngineRef","layoutSignatureRef","layoutSignature","join","current","engine","compute","crossAxisSize","layouts","getLayouts","contentSize","getContentSize","scrollOffsetRef","viewportSizeRef","cellPoolRef","activeCellsRef","nextCellKeyRef","createCell","type","key","index","MAX_CELLS","Math","ceil","updateVisibleCells","offset","viewportSize","buffer","range","nextCells","used","Set","startIndex","endIndex","item","undefined","hasType","registerType","i","release","cell","acquire","reuseIndex","findIndex","c","splice","push","add","has","changed","v","frameScheduledRef","onScroll","e","nativeEvent","contentOffset","y","x","requestAnimationFrame","onLayout","layout","height","width","horizontal","scrollEventThrottle","removeClippedSubviews","children","style","map","styles","top","left","create","position"],"sourceRoot":"../../../src","sources":["recycler/RecyclerList.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,SACEC,UAAU,EACVC,IAAI,EACJC,UAAU,QAGL,cAAc;AASrB,SAASC,mBAAmB,QAAQ,+BAA+B;AACnE,SAASC,uBAAuB,QAAQ,cAAc;AACtD,SAASC,QAAQ,QAAQ,YAAY;;AAErC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAIA,MAAMC,qBAAqB,GAAG,GAAG;AACjC,MAAMC,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,qBAAqB,GAAG,EAAE;;AAEhC;AACA;AACA;;AAEA,OAAO,SAASC,YAAYA,CAC1BC,KAA2B,EACP;EACpB,MAAM;IACJC,eAAe,GAAG,UAAU;IAC5BC,sBAAsB;IACtBC,IAAI;IACJC,iBAAiB;IACjBC,OAAO,GAAG;MAAEC,KAAK,EAAE,CAAC;MAAEC,GAAG,EAAE;IAAE,CAAC;IAC9BC,WAAW;IACX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QAAEiE,MAAM,EAAEnD;MAAY,CAAC,GACvB;QAAEoD,KAAK,EAAEpD;MAAY,CAC1B;MAAAwD,QAAA,EAEAnD,cAAc,CAACX,OAAO,CAACgE,GAAG,CAAC5B,IAAI,IAAI;QAClC,MAAMpB,KAAK,GAAGoB,IAAI,CAACpB,KAAK;QACxB,MAAMwC,MAAM,GAAGpD,OAAO,CAACY,KAAK,CAAC;QAC7B,MAAMc,IAAI,GAAG/C,IAAI,CAACiC,KAAK,CAAC;QAExB,IAAI,CAACwC,MAAM,IAAI1B,IAAI,KAAKC,SAAS,EAAE,OAAO,IAAI;QAE9C,oBACExD,IAAA,CAACN,IAAI;UAEH8F,KAAK,EAAE,CACLE,MAAM,CAAC7B,IAAI,EACX5C,UAAU,GACN;YACE0E,GAAG,EAAEV,MAAM,CAACJ,CAAC;YACbK,MAAM,EAAED,MAAM,CAACC,MAAM;YACrBC,KAAK,EAAEF,MAAM,CAACE;UAChB,CAAC,GACD;YACES,IAAI,EAAEX,MAAM,CAACH,CAAC;YACdK,KAAK,EAAEF,MAAM,CAACE,KAAK;YACnBD,MAAM,EAAED,MAAM,CAACC;UACjB,CAAC,CACL;UAAAK,QAAA,EAEDvE,UAAU,CAAC;YAAEuC,IAAI;YAAEd,KAAK;YAAEoB;UAAK,CAAC;QAAC,GAhB7BA,IAAI,CAACrB,GAiBN,CAAC;MAEX,CAAC;IAAC,CACE;EAAC,CACG,CAAC;AAEjB;;AAEA;AACA;AACA;;AAEA,MAAMkD,MAAM,GAAG/F,UAAU,CAACkG,MAAM,CAAC;EAC/BhC,IAAI,EAAE;IACJiC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/Axis.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/CellKey.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/CellType.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/VisibleRange.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/VisibleRangeInput.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ZERO_MAIN_AXIS_PADDING"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;AAKA,SACEA,sBAAsB,QACjB,0BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/layout/LayoutRect.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/layout/LinearLayoutInput.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Padding applied along the main scroll axis.
|
|
5
|
+
*
|
|
6
|
+
* This is a layout-level concept (not visual styling).
|
|
7
|
+
*
|
|
8
|
+
* - vertical → top / bottom
|
|
9
|
+
* - horizontal → left / right
|
|
10
|
+
*
|
|
11
|
+
* Uses start/end to remain RTL-safe and platform-neutral.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Shared zero-padding constant.
|
|
16
|
+
* Safe to reuse across layouts.
|
|
17
|
+
*/
|
|
18
|
+
export const ZERO_MAIN_AXIS_PADDING = {
|
|
19
|
+
start: 0,
|
|
20
|
+
end: 0
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=MainAxisPadding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ZERO_MAIN_AXIS_PADDING","start","end"],"sourceRoot":"../../../../src","sources":["types/layout/MainAxisPadding.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA,OAAO,MAAMA,sBAAuC,GAAG;EACrDC,KAAK,EAAE,CAAC;EACRC,GAAG,EAAE;AACP,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/layout/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/recycler/RecyclerCellInstance.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/recycler/RecyclerItemRenderer.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/recycler/RecyclerListProps.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/recycler/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/scroll/ScrollMetrics.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/scroll/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Computes the visible item index range using binary search.
|
|
5
|
+
*
|
|
6
|
+
* Responsibilities:
|
|
7
|
+
* - Determine which items intersect the visible window
|
|
8
|
+
* - Stay independent of rendering and recycling
|
|
9
|
+
*
|
|
10
|
+
* Performance:
|
|
11
|
+
* - O(log n) to locate the first visible item
|
|
12
|
+
* - O(k) to expand to the last visible item (k = visible count)
|
|
13
|
+
*/
|
|
14
|
+
export function computeVisibleItemRange(input) {
|
|
15
|
+
const {
|
|
16
|
+
layouts,
|
|
17
|
+
offset,
|
|
18
|
+
viewportSize,
|
|
19
|
+
buffer,
|
|
20
|
+
isVertical
|
|
21
|
+
} = input;
|
|
22
|
+
const itemCount = layouts.length;
|
|
23
|
+
if (itemCount === 0) return null;
|
|
24
|
+
const windowStart = Math.max(0, offset - buffer);
|
|
25
|
+
const windowEnd = offset + viewportSize + buffer;
|
|
26
|
+
|
|
27
|
+
// --------------------------------------------------
|
|
28
|
+
// Binary search:
|
|
29
|
+
// First item whose END >= windowStart
|
|
30
|
+
// --------------------------------------------------
|
|
31
|
+
let low = 0;
|
|
32
|
+
let high = itemCount - 1;
|
|
33
|
+
let firstVisibleIndex = itemCount;
|
|
34
|
+
while (low <= high) {
|
|
35
|
+
const mid = low + high >>> 1;
|
|
36
|
+
const rect = layouts[mid];
|
|
37
|
+
const start = isVertical ? rect.y : rect.x;
|
|
38
|
+
const size = isVertical ? rect.height : rect.width;
|
|
39
|
+
const end = start + size;
|
|
40
|
+
if (end >= windowStart) {
|
|
41
|
+
firstVisibleIndex = mid;
|
|
42
|
+
high = mid - 1;
|
|
43
|
+
} else {
|
|
44
|
+
low = mid + 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (firstVisibleIndex === itemCount) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// --------------------------------------------------
|
|
52
|
+
// Linear scan forward:
|
|
53
|
+
// Last item whose START <= windowEnd
|
|
54
|
+
// --------------------------------------------------
|
|
55
|
+
let lastVisibleIndex = firstVisibleIndex;
|
|
56
|
+
for (let i = firstVisibleIndex + 1; i < itemCount; i++) {
|
|
57
|
+
const rect = layouts[i];
|
|
58
|
+
const start = isVertical ? rect.y : rect.x;
|
|
59
|
+
if (start > windowEnd) break;
|
|
60
|
+
lastVisibleIndex = i;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
startIndex: firstVisibleIndex,
|
|
64
|
+
endIndex: lastVisibleIndex
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=computeVisibleItemRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["computeVisibleItemRange","input","layouts","offset","viewportSize","buffer","isVertical","itemCount","length","windowStart","Math","max","windowEnd","low","high","firstVisibleIndex","mid","rect","start","y","x","size","height","width","end","lastVisibleIndex","i","startIndex","endIndex"],"sourceRoot":"../../../src","sources":["windowing/computeVisibleItemRange.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,uBAAuBA,CACrCC,KAAwB,EACH;EACrB,MAAM;IACJC,OAAO;IACPC,MAAM;IACNC,YAAY;IACZC,MAAM;IACNC;EACF,CAAC,GAAGL,KAAK;EAET,MAAMM,SAAS,GAAGL,OAAO,CAACM,MAAM;EAChC,IAAID,SAAS,KAAK,CAAC,EAAE,OAAO,IAAI;EAEhC,MAAME,WAAW,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAER,MAAM,GAAGE,MAAM,CAAC;EAChD,MAAMO,SAAS,GAAGT,MAAM,GAAGC,YAAY,GAAGC,MAAM;;EAEhD;EACA;EACA;EACA;EACA,IAAIQ,GAAG,GAAG,CAAC;EACX,IAAIC,IAAI,GAAGP,SAAS,GAAG,CAAC;EACxB,IAAIQ,iBAAiB,GAAGR,SAAS;EAEjC,OAAOM,GAAG,IAAIC,IAAI,EAAE;IAClB,MAAME,GAAG,GAAIH,GAAG,GAAGC,IAAI,KAAM,CAAC;IAC9B,MAAMG,IAAI,GAAGf,OAAO,CAACc,GAAG,CAAE;IAE1B,MAAME,KAAK,GAAGZ,UAAU,GAAGW,IAAI,CAACE,CAAC,GAAGF,IAAI,CAACG,CAAC;IAC1C,MAAMC,IAAI,GAAGf,UAAU,GAAGW,IAAI,CAACK,MAAM,GAAGL,IAAI,CAACM,KAAK;IAClD,MAAMC,GAAG,GAAGN,KAAK,GAAGG,IAAI;IAExB,IAAIG,GAAG,IAAIf,WAAW,EAAE;MACtBM,iBAAiB,GAAGC,GAAG;MACvBF,IAAI,GAAGE,GAAG,GAAG,CAAC;IAChB,CAAC,MAAM;MACLH,GAAG,GAAGG,GAAG,GAAG,CAAC;IACf;EACF;EAEA,IAAID,iBAAiB,KAAKR,SAAS,EAAE;IACnC,OAAO,IAAI;EACb;;EAEA;EACA;EACA;EACA;EACA,IAAIkB,gBAAgB,GAAGV,iBAAiB;EAExC,KAAK,IAAIW,CAAC,GAAGX,iBAAiB,GAAG,CAAC,EAAEW,CAAC,GAAGnB,SAAS,EAAEmB,CAAC,EAAE,EAAE;IACtD,MAAMT,IAAI,GAAGf,OAAO,CAACwB,CAAC,CAAE;IACxB,MAAMR,KAAK,GAAGZ,UAAU,GAAGW,IAAI,CAACE,CAAC,GAAGF,IAAI,CAACG,CAAC;IAE1C,IAAIF,KAAK,GAAGN,SAAS,EAAE;IACvBa,gBAAgB,GAAGC,CAAC;EACtB;EAEA,OAAO;IACLC,UAAU,EAAEZ,iBAAiB;IAC7Ba,QAAQ,EAAEH;EACZ,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useScrollMetrics","computeVisibleItemRange"],"sourceRoot":"../../../src","sources":["windowing/index.ts"],"mappings":";;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,uBAAuB,QAAQ,2BAA2B","ignoreList":[]}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Physical reusable cell.
|
|
3
|
-
*
|
|
3
|
+
* Represents a single mounted view instance.
|
|
4
4
|
*/
|
|
5
5
|
export interface Cell {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Stable physical identity.
|
|
8
|
+
* Used as React key. NEVER changes.
|
|
9
|
+
*/
|
|
7
10
|
readonly key: string;
|
|
8
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Logical data index currently bound.
|
|
13
|
+
* Changes as the cell is recycled.
|
|
14
|
+
*/
|
|
9
15
|
index: number;
|
|
10
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Compatibility type (row, header, etc).
|
|
18
|
+
* Determines reuse eligibility.
|
|
19
|
+
*/
|
|
11
20
|
readonly type: string;
|
|
12
21
|
}
|
|
13
22
|
//# sourceMappingURL=Cell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cell.d.ts","sourceRoot":"","sources":["../../../../src/cell/Cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB
|
|
1
|
+
{"version":3,"file":"Cell.d.ts","sourceRoot":"","sources":["../../../../src/cell/Cell.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IAEb;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CellKey } from '../types/CellKey';
|
|
2
|
+
/**
|
|
3
|
+
* Monotonic key generator for physical cell instances.
|
|
4
|
+
* Guarantees stable keys across the lifetime of the list.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CellKeyGenerator {
|
|
7
|
+
private nextId;
|
|
8
|
+
next(): CellKey;
|
|
9
|
+
reset(): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=CellKeyGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CellKeyGenerator.d.ts","sourceRoot":"","sources":["../../../../src/cell/CellKeyGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAI;IAElB,IAAI,IAAI,OAAO;IAIf,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import type { Cell } from './Cell';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* FlashList equivalent: CellRecycler
|
|
3
|
+
* Manages physical cell reuse.
|
|
4
|
+
* Imperative and stateful by design.
|
|
5
|
+
* This is NOT React code.
|
|
7
6
|
*/
|
|
8
7
|
export declare class CellRecycler {
|
|
9
|
-
private readonly activeCells;
|
|
10
|
-
private readonly reusableCellsByType;
|
|
11
|
-
private readonly orderedCells;
|
|
12
|
-
private nextCellId;
|
|
13
8
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Returns a stable ordered snapshot.
|
|
9
|
+
* Active cells mapped by logical index.
|
|
16
10
|
*/
|
|
17
|
-
|
|
11
|
+
private readonly indexToCell;
|
|
12
|
+
/**
|
|
13
|
+
* Pool of detached reusable cells.
|
|
14
|
+
*/
|
|
15
|
+
private readonly recycledCells;
|
|
16
|
+
/**
|
|
17
|
+
* Reconcile a contiguous visible index range
|
|
18
|
+
* into a stable list of physical cells.
|
|
19
|
+
*
|
|
20
|
+
* HOT PATH:
|
|
21
|
+
* - No index arrays
|
|
22
|
+
* - Minimal allocations
|
|
23
|
+
* - Deterministic
|
|
24
|
+
*/
|
|
25
|
+
reconcileRange(startIndex: number, endIndex: number, resolveCellType: (index: number) => string): readonly Cell[];
|
|
18
26
|
}
|
|
19
27
|
//# sourceMappingURL=CellRecycler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellRecycler.d.ts","sourceRoot":"","sources":["../../../../src/cell/CellRecycler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"CellRecycler.d.ts","sourceRoot":"","sources":["../../../../src/cell/CellRecycler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAGlC;;;;GAIG;AACH,qBAAa,YAAY;IACvB;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0B;IAEtD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAa;IAE3C;;;;;;;;OAQG;IACH,cAAc,CACZ,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GACzC,SAAS,IAAI,EAAE;CA2CnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCell.d.ts","sourceRoot":"","sources":["../../../../src/cell/createCell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAIlC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAM7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cell/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LayoutRect } from './types/layout';
|
|
2
2
|
import type { ScrollMetrics } from './windowing/ScrollMetrics';
|
|
3
3
|
/**
|
|
4
4
|
* Binary-search based windowing.
|
|
5
5
|
* Returns indices intersecting viewport ± buffer.
|
|
6
6
|
*/
|
|
7
|
-
export declare function getVisibleRange(layouts: readonly
|
|
7
|
+
export declare function getVisibleRange(layouts: readonly LayoutRect[], metrics: ScrollMetrics, bufferPx: number): readonly number[];
|
|
8
8
|
//# sourceMappingURL=getVisibleIndices.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVisibleIndices.d.ts","sourceRoot":"","sources":["../../../src/getVisibleIndices.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getVisibleIndices.d.ts","sourceRoot":"","sources":["../../../src/getVisibleIndices.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAE9D;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,GACf,SAAS,MAAM,EAAE,CAyCnB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a function whose identity is stable across renders,
|
|
3
|
+
* but always invokes the latest provided implementation.
|
|
4
|
+
*
|
|
5
|
+
* Invariants:
|
|
6
|
+
* - Function reference NEVER changes
|
|
7
|
+
* - Logic is ALWAYS up to date
|
|
8
|
+
*
|
|
9
|
+
* This is critical for long-lived systems such as:
|
|
10
|
+
* - Recyclers
|
|
11
|
+
* - Effects
|
|
12
|
+
* - Native bridges
|
|
13
|
+
* - Event pipelines
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePersistentCallback<T extends (...args: never[]) => unknown>(fn: T): T;
|
|
16
|
+
//# sourceMappingURL=usePersistentCallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePersistentCallback.d.ts","sourceRoot":"","sources":["../../../../src/hooks/usePersistentCallback.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACvC,EAAE,EAAE,CAAC,GAAG,CAAC,CAkBV"}
|