react-native-nitro-list 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +250 -16
- package/android/build.gradle +5 -4
- package/android/src/main/java/com/nitrolist/HybridNitroRecyclerView.kt +26 -0
- package/android/src/main/java/com/nitrolist/HybridNitroRecyclerViewManager.kt +29 -0
- package/android/src/main/java/com/nitrolist/NitroListPackage.kt +13 -24
- package/android/src/main/java/com/nitrolist/NitroRecyclerAdapter.kt +32 -0
- package/android/src/main/java/com/nitrolist/NitroRecyclerViewHolder.kt +8 -0
- package/ios/HybridNitroList.swift +32 -15
- package/lib/commonjs/NitroList.js +9 -0
- package/lib/commonjs/NitroList.js.map +1 -0
- package/lib/commonjs/RecyclerList.internal.js +25 -0
- package/lib/commonjs/RecyclerList.internal.js.map +1 -0
- package/lib/commonjs/RecyclerList.js +171 -0
- package/lib/commonjs/RecyclerList.js.map +1 -0
- package/lib/commonjs/RecyclerList.types.js +6 -0
- package/lib/commonjs/RecyclerList.types.js.map +1 -0
- package/lib/commonjs/ReusableView.js +2 -0
- package/lib/commonjs/ReusableView.js.map +1 -0
- package/lib/commonjs/cell/Cell.js +2 -0
- package/lib/{module/specs/nitro-list.nitro.js.map → commonjs/cell/Cell.js.map} +1 -1
- package/lib/commonjs/cell/CellRecycler.js +62 -0
- package/lib/commonjs/cell/CellRecycler.js.map +1 -0
- package/lib/commonjs/cell/StableKey.js +10 -0
- package/lib/commonjs/cell/StableKey.js.map +1 -0
- package/lib/commonjs/debug/useDebugOverlay.js +15 -0
- package/lib/commonjs/debug/useDebugOverlay.js.map +1 -0
- package/lib/commonjs/getVisibleIndices.js +38 -0
- package/lib/commonjs/getVisibleIndices.js.map +1 -0
- package/lib/commonjs/hooks/useCellRenderer.js +62 -0
- package/lib/commonjs/hooks/useCellRenderer.js.map +1 -0
- package/lib/commonjs/hooks/useStableCallback.js +13 -0
- package/lib/commonjs/hooks/useStableCallback.js.map +1 -0
- package/lib/commonjs/index.js +7 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layout/EstimatedLayoutProvider.js +30 -0
- package/lib/commonjs/layout/EstimatedLayoutProvider.js.map +1 -0
- package/lib/commonjs/layout/LayoutEngine.js +21 -0
- package/lib/commonjs/layout/LayoutEngine.js.map +1 -0
- package/lib/commonjs/{specs/nitro-list.nitro.js → layout/LayoutProvider.js} +1 -1
- package/lib/commonjs/{specs/nitro-list.nitro.js.map → layout/LayoutProvider.js.map} +1 -1
- package/lib/commonjs/layout/LayoutRectangle.js +2 -0
- package/lib/commonjs/layout/LayoutRectangle.js.map +1 -0
- package/lib/commonjs/layout/MutableLinearLayout.js +65 -0
- package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -0
- package/lib/commonjs/layout/index.js +20 -0
- package/lib/commonjs/layout/index.js.map +1 -0
- package/lib/commonjs/measurement/MeasureLayout.js +20 -0
- package/lib/commonjs/measurement/MeasureLayout.js.map +1 -0
- package/lib/commonjs/measurement/useItemMeasurement.js +28 -0
- package/lib/commonjs/measurement/useItemMeasurement.js.map +1 -0
- package/lib/commonjs/native/NitroLayoutEngine.js +9 -0
- package/lib/commonjs/native/NitroLayoutEngine.js.map +1 -0
- package/lib/commonjs/native/NitroList.types.js +6 -0
- package/lib/commonjs/native/NitroList.types.js.map +1 -0
- package/lib/commonjs/native/NitroRecyclerView.js +9 -0
- package/lib/commonjs/native/NitroRecyclerView.js.map +1 -0
- package/lib/commonjs/prefetch/PrefetchHelper.js +39 -0
- package/lib/commonjs/prefetch/PrefetchHelper.js.map +1 -0
- package/lib/commonjs/specs/nitro-layout-engine.nitro.js +6 -0
- package/lib/commonjs/specs/nitro-layout-engine.nitro.js.map +1 -0
- package/lib/commonjs/utils/arrayEqual.js +15 -0
- package/lib/commonjs/utils/arrayEqual.js.map +1 -0
- package/lib/commonjs/utils/assertNever.js +10 -0
- package/lib/commonjs/utils/assertNever.js.map +1 -0
- package/lib/commonjs/utils/clamp.js +10 -0
- package/lib/commonjs/utils/clamp.js.map +1 -0
- package/lib/commonjs/utils/devAssert.js +12 -0
- package/lib/commonjs/utils/devAssert.js.map +1 -0
- package/lib/commonjs/utils/invariant.js +12 -0
- package/lib/commonjs/utils/invariant.js.map +1 -0
- package/lib/commonjs/utils/isDefined.js +10 -0
- package/lib/commonjs/utils/isDefined.js.map +1 -0
- package/lib/commonjs/utils/isNumber.js +10 -0
- package/lib/commonjs/utils/isNumber.js.map +1 -0
- package/lib/commonjs/utils/noop.js +10 -0
- package/lib/commonjs/utils/noop.js.map +1 -0
- package/lib/commonjs/utils/shallowEqual.js +22 -0
- package/lib/commonjs/utils/shallowEqual.js.map +1 -0
- package/lib/commonjs/utils/throttle.js +17 -0
- package/lib/commonjs/utils/throttle.js.map +1 -0
- package/lib/commonjs/viewability/ViewabilityHelper.js +121 -0
- package/lib/commonjs/viewability/ViewabilityHelper.js.map +1 -0
- package/lib/commonjs/windowing/ScrollMetrics.js +2 -0
- package/lib/commonjs/windowing/ScrollMetrics.js.map +1 -0
- package/lib/commonjs/windowing/findVisibleIndexRange.js +48 -0
- package/lib/commonjs/windowing/findVisibleIndexRange.js.map +1 -0
- package/lib/commonjs/windowing/index.js +20 -0
- package/lib/commonjs/windowing/index.js.map +1 -0
- package/lib/commonjs/windowing/useScrollMetrics.js +39 -0
- package/lib/commonjs/windowing/useScrollMetrics.js.map +1 -0
- package/lib/module/NitroList.js +5 -0
- package/lib/module/NitroList.js.map +1 -0
- package/lib/module/RecyclerList.internal.js +22 -0
- package/lib/module/RecyclerList.internal.js.map +1 -0
- package/lib/module/RecyclerList.js +166 -0
- package/lib/module/RecyclerList.js.map +1 -0
- package/lib/module/RecyclerList.types.js +4 -0
- package/lib/module/RecyclerList.types.js.map +1 -0
- package/lib/module/ReusableView.js +2 -0
- package/lib/module/ReusableView.js.map +1 -0
- package/lib/module/cell/Cell.js +2 -0
- package/lib/module/cell/Cell.js.map +1 -0
- package/lib/module/cell/CellRecycler.js +57 -0
- package/lib/module/cell/CellRecycler.js.map +1 -0
- package/lib/module/cell/StableKey.js +6 -0
- package/lib/module/cell/StableKey.js.map +1 -0
- package/lib/module/debug/useDebugOverlay.js +11 -0
- package/lib/module/debug/useDebugOverlay.js.map +1 -0
- package/lib/module/getVisibleIndices.js +34 -0
- package/lib/module/getVisibleIndices.js.map +1 -0
- package/lib/module/hooks/useCellRenderer.js +58 -0
- package/lib/module/hooks/useCellRenderer.js.map +1 -0
- package/lib/module/hooks/useStableCallback.js +9 -0
- package/lib/module/hooks/useStableCallback.js.map +1 -0
- package/lib/module/index.js +1 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/EstimatedLayoutProvider.js +25 -0
- package/lib/module/layout/EstimatedLayoutProvider.js.map +1 -0
- package/lib/module/layout/LayoutEngine.js +17 -0
- package/lib/module/layout/LayoutEngine.js.map +1 -0
- package/lib/module/layout/LayoutProvider.js +4 -0
- package/lib/module/layout/LayoutProvider.js.map +1 -0
- package/lib/module/layout/LayoutRectangle.js +2 -0
- package/lib/module/layout/LayoutRectangle.js.map +1 -0
- package/lib/module/layout/MutableLinearLayout.js +60 -0
- package/lib/module/layout/MutableLinearLayout.js.map +1 -0
- package/lib/module/layout/index.js +5 -0
- package/lib/module/layout/index.js.map +1 -0
- package/lib/module/measurement/MeasureLayout.js +16 -0
- package/lib/module/measurement/MeasureLayout.js.map +1 -0
- package/lib/module/measurement/useItemMeasurement.js +24 -0
- package/lib/module/measurement/useItemMeasurement.js.map +1 -0
- package/lib/module/native/NitroLayoutEngine.js +5 -0
- package/lib/module/native/NitroLayoutEngine.js.map +1 -0
- package/lib/module/native/NitroList.types.js +4 -0
- package/lib/module/native/NitroList.types.js.map +1 -0
- package/lib/module/native/NitroRecyclerView.js +5 -0
- package/lib/module/native/NitroRecyclerView.js.map +1 -0
- package/lib/module/prefetch/PrefetchHelper.js +34 -0
- package/lib/module/prefetch/PrefetchHelper.js.map +1 -0
- package/lib/module/specs/nitro-layout-engine.nitro.js +4 -0
- package/lib/module/specs/nitro-layout-engine.nitro.js.map +1 -0
- package/lib/module/utils/arrayEqual.js +11 -0
- package/lib/module/utils/arrayEqual.js.map +1 -0
- package/lib/module/utils/assertNever.js +6 -0
- package/lib/module/utils/assertNever.js.map +1 -0
- package/lib/module/utils/clamp.js +6 -0
- package/lib/module/utils/clamp.js.map +1 -0
- package/lib/module/utils/devAssert.js +8 -0
- package/lib/module/utils/devAssert.js.map +1 -0
- package/lib/module/utils/invariant.js +8 -0
- package/lib/module/utils/invariant.js.map +1 -0
- package/lib/module/utils/isDefined.js +6 -0
- package/lib/module/utils/isDefined.js.map +1 -0
- package/lib/module/utils/isNumber.js +6 -0
- package/lib/module/utils/isNumber.js.map +1 -0
- package/lib/module/utils/noop.js +6 -0
- package/lib/module/utils/noop.js.map +1 -0
- package/lib/module/utils/shallowEqual.js +18 -0
- package/lib/module/utils/shallowEqual.js.map +1 -0
- package/lib/module/utils/throttle.js +13 -0
- package/lib/module/utils/throttle.js.map +1 -0
- package/lib/module/viewability/ViewabilityHelper.js +116 -0
- package/lib/module/viewability/ViewabilityHelper.js.map +1 -0
- package/lib/module/windowing/ScrollMetrics.js +2 -0
- package/lib/module/windowing/ScrollMetrics.js.map +1 -0
- package/lib/module/windowing/findVisibleIndexRange.js +44 -0
- package/lib/module/windowing/findVisibleIndexRange.js.map +1 -0
- package/lib/module/windowing/index.js +5 -0
- package/lib/module/windowing/index.js.map +1 -0
- package/lib/module/windowing/useScrollMetrics.js +35 -0
- package/lib/module/windowing/useScrollMetrics.js.map +1 -0
- package/lib/typescript/src/NitroList.d.ts +5 -0
- package/lib/typescript/src/NitroList.d.ts.map +1 -0
- package/lib/typescript/src/RecyclerList.d.ts +26 -0
- package/lib/typescript/src/RecyclerList.d.ts.map +1 -0
- package/lib/typescript/src/RecyclerList.internal.d.ts +9 -0
- package/lib/typescript/src/RecyclerList.internal.d.ts.map +1 -0
- package/lib/typescript/src/RecyclerList.types.d.ts +18 -0
- package/lib/typescript/src/RecyclerList.types.d.ts.map +1 -0
- package/lib/typescript/src/ReusableView.d.ts +9 -0
- package/lib/typescript/src/ReusableView.d.ts.map +1 -0
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts +2 -0
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts.map +1 -0
- package/lib/typescript/src/cell/Cell.d.ts +13 -0
- package/lib/typescript/src/cell/Cell.d.ts.map +1 -0
- package/lib/typescript/src/cell/CellRecycler.d.ts +19 -0
- package/lib/typescript/src/cell/CellRecycler.d.ts.map +1 -0
- package/lib/typescript/src/cell/StableKey.d.ts +2 -0
- package/lib/typescript/src/cell/StableKey.d.ts.map +1 -0
- package/lib/typescript/src/debug/useDebugOverlay.d.ts +2 -0
- package/lib/typescript/src/debug/useDebugOverlay.d.ts.map +1 -0
- package/lib/typescript/src/getVisibleIndices.d.ts +8 -0
- package/lib/typescript/src/getVisibleIndices.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCellRenderer.d.ts +19 -0
- package/lib/typescript/src/hooks/useCellRenderer.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useStableCallback.d.ts +2 -0
- package/lib/typescript/src/hooks/useStableCallback.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts +15 -0
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts.map +1 -0
- package/lib/typescript/src/layout/LayoutEngine.d.ts +10 -0
- package/lib/typescript/src/layout/LayoutEngine.d.ts.map +1 -0
- package/lib/typescript/src/layout/LayoutProvider.d.ts +16 -0
- package/lib/typescript/src/layout/LayoutProvider.d.ts.map +1 -0
- package/lib/typescript/src/layout/LayoutRectangle.d.ts +11 -0
- package/lib/typescript/src/layout/LayoutRectangle.d.ts.map +1 -0
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts +22 -0
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts.map +1 -0
- package/lib/typescript/src/layout/index.d.ts +5 -0
- package/lib/typescript/src/layout/index.d.ts.map +1 -0
- package/lib/typescript/src/measurement/MeasureLayout.d.ts +10 -0
- package/lib/typescript/src/measurement/MeasureLayout.d.ts.map +1 -0
- package/lib/typescript/src/measurement/useItemMeasurement.d.ts +11 -0
- package/lib/typescript/src/measurement/useItemMeasurement.d.ts.map +1 -0
- package/lib/typescript/src/native/NitroLayoutEngine.d.ts +3 -0
- package/lib/typescript/src/native/NitroLayoutEngine.d.ts.map +1 -0
- package/lib/typescript/src/native/NitroList.types.d.ts +9 -0
- package/lib/typescript/src/native/NitroList.types.d.ts.map +1 -0
- package/lib/typescript/src/native/NitroRecyclerView.d.ts +5 -0
- package/lib/typescript/src/native/NitroRecyclerView.d.ts.map +1 -0
- package/lib/typescript/src/prefetch/PrefetchHelper.d.ts +17 -0
- package/lib/typescript/src/prefetch/PrefetchHelper.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +14 -0
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +1 -0
- package/lib/typescript/src/utils/arrayEqual.d.ts +2 -0
- package/lib/typescript/src/utils/arrayEqual.d.ts.map +1 -0
- package/lib/typescript/src/utils/assertNever.d.ts +2 -0
- package/lib/typescript/src/utils/assertNever.d.ts.map +1 -0
- package/lib/typescript/src/utils/clamp.d.ts +2 -0
- package/lib/typescript/src/utils/clamp.d.ts.map +1 -0
- package/lib/typescript/src/utils/devAssert.d.ts +2 -0
- package/lib/typescript/src/utils/devAssert.d.ts.map +1 -0
- package/lib/typescript/src/utils/invariant.d.ts +2 -0
- package/lib/typescript/src/utils/invariant.d.ts.map +1 -0
- package/lib/typescript/src/utils/isDefined.d.ts +2 -0
- package/lib/typescript/src/utils/isDefined.d.ts.map +1 -0
- package/lib/typescript/src/utils/isNumber.d.ts +2 -0
- package/lib/typescript/src/utils/isNumber.d.ts.map +1 -0
- package/lib/typescript/src/utils/noop.d.ts +2 -0
- package/lib/typescript/src/utils/noop.d.ts.map +1 -0
- package/lib/typescript/src/utils/shallowEqual.d.ts +2 -0
- package/lib/typescript/src/utils/shallowEqual.d.ts.map +1 -0
- package/lib/typescript/src/utils/throttle.d.ts +2 -0
- package/lib/typescript/src/utils/throttle.d.ts.map +1 -0
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts +50 -0
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/lib/typescript/src/windowing/ScrollMetrics.d.ts +11 -0
- package/lib/typescript/src/windowing/ScrollMetrics.d.ts.map +1 -0
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts +11 -0
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts.map +1 -0
- package/lib/typescript/src/windowing/index.d.ts +4 -0
- package/lib/typescript/src/windowing/index.d.ts.map +1 -0
- package/lib/typescript/src/windowing/useScrollMetrics.d.ts +14 -0
- package/lib/typescript/src/windowing/useScrollMetrics.d.ts.map +1 -0
- package/nitro.json +20 -13
- package/nitrogen/generated/android/NitroList+autolinking.cmake +2 -4
- package/nitrogen/generated/android/NitroListOnLoad.cpp +3 -13
- package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.cpp +69 -0
- package/nitrogen/generated/android/c++/{JHybridNitroListSpec.hpp → JHybridNitroLayoutEngineSpec.hpp} +12 -13
- package/nitrogen/generated/android/c++/JLayoutRectangle.hpp +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{HybridNitroListSpec.kt → HybridNitroLayoutEngineSpec.kt} +11 -13
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/LayoutRectangle.kt +47 -0
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.cpp +9 -9
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +50 -13
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +11 -5
- package/nitrogen/generated/ios/c++/{HybridNitroListSpecSwift.cpp → HybridNitroLayoutEngineSpecSwift.cpp} +2 -2
- package/nitrogen/generated/ios/c++/HybridNitroLayoutEngineSpecSwift.hpp +78 -0
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/{HybridNitroListSpec_cxx.swift → HybridNitroLayoutEngineSpec_cxx.swift} +35 -38
- package/nitrogen/generated/ios/swift/LayoutRectangle.swift +45 -0
- package/nitrogen/generated/shared/c++/{HybridNitroListSpec.cpp → HybridNitroLayoutEngineSpec.cpp} +4 -5
- package/nitrogen/generated/shared/c++/{HybridNitroListSpec.hpp → HybridNitroLayoutEngineSpec.hpp} +15 -14
- package/nitrogen/generated/shared/c++/LayoutRectangle.hpp +95 -0
- package/package.json +12 -4
- package/src/NitroList.ts +8 -0
- package/src/RecyclerList.internal.ts +38 -0
- package/src/RecyclerList.tsx +252 -0
- package/src/RecyclerList.types.ts +24 -0
- package/src/ReusableView.ts +12 -0
- package/src/__tests__/windowing/findVisibleIndexRange.test.ts +55 -0
- package/src/cell/Cell.ts +14 -0
- package/src/cell/CellRecycler.ts +66 -0
- package/src/cell/StableKey.ts +6 -0
- package/src/debug/useDebugOverlay.ts +14 -0
- package/src/getVisibleIndices.ts +53 -0
- package/src/hooks/useCellRenderer.ts +86 -0
- package/src/hooks/useStableCallback.ts +13 -0
- package/src/index.ts +2 -14
- package/src/layout/EstimatedLayoutProvider.ts +35 -0
- package/src/layout/LayoutEngine.ts +21 -0
- package/src/layout/LayoutProvider.ts +17 -0
- package/src/layout/LayoutRectangle.ts +10 -0
- package/src/layout/MutableLinearLayout.ts +79 -0
- package/src/layout/index.ts +4 -0
- package/src/measurement/MeasureLayout.ts +20 -0
- package/src/measurement/useItemMeasurement.ts +32 -0
- package/src/native/NitroLayoutEngine.ts +7 -0
- package/src/native/NitroList.types.ts +12 -0
- package/src/native/NitroRecyclerView.ts +8 -0
- package/src/prefetch/PrefetchHelper.ts +47 -0
- package/src/specs/nitro-layout-engine.nitro.ts +17 -0
- package/src/utils/arrayEqual.ts +13 -0
- package/src/utils/assertNever.ts +3 -0
- package/src/utils/clamp.ts +7 -0
- package/src/utils/devAssert.ts +8 -0
- package/src/utils/invariant.ts +8 -0
- package/src/utils/isDefined.ts +5 -0
- package/src/utils/isNumber.ts +3 -0
- package/src/utils/noop.ts +3 -0
- package/src/utils/shallowEqual.ts +34 -0
- package/src/utils/throttle.ts +13 -0
- package/src/viewability/ViewabilityHelper.ts +130 -0
- package/src/windowing/ScrollMetrics.ts +11 -0
- package/src/windowing/findVisibleIndexRange.ts +60 -0
- package/src/windowing/index.ts +3 -0
- package/src/windowing/useScrollMetrics.ts +56 -0
- package/android/src/main/java/com/nitrolist/HybridNitroList.kt +0 -27
- package/lib/module/specs/nitro-list.nitro.js +0 -4
- package/lib/typescript/src/specs/nitro-list.nitro.d.ts +0 -11
- package/lib/typescript/src/specs/nitro-list.nitro.d.ts.map +0 -1
- package/nitrogen/generated/android/c++/JHybridNitroListSpec.cpp +0 -56
- package/nitrogen/generated/android/c++/views/JHybridNitroListStateUpdater.cpp +0 -56
- package/nitrogen/generated/android/c++/views/JHybridNitroListStateUpdater.hpp +0 -49
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/views/HybridNitroListManager.kt +0 -50
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/views/HybridNitroListStateUpdater.kt +0 -23
- package/nitrogen/generated/ios/NitroListAutolinking.mm +0 -33
- package/nitrogen/generated/ios/NitroListAutolinking.swift +0 -25
- package/nitrogen/generated/ios/c++/HybridNitroListSpecSwift.hpp +0 -74
- package/nitrogen/generated/ios/c++/views/HybridNitroListComponent.mm +0 -96
- package/nitrogen/generated/ios/swift/HybridNitroListSpec.swift +0 -56
- package/nitrogen/generated/shared/c++/views/HybridNitroListComponent.cpp +0 -88
- package/nitrogen/generated/shared/c++/views/HybridNitroListComponent.hpp +0 -107
- package/nitrogen/generated/shared/json/NitroListConfig.json +0 -10
- package/src/specs/nitro-list.nitro.ts +0 -13
|
@@ -0,0 +1,171 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,OAA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;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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["RecyclerList.types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["ReusableView.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["cell/Cell.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CellRecycler = void 0;
|
|
7
|
+
const MAX_CELLS = 40;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Owns physical cell reuse.
|
|
11
|
+
* Stateful, imperative, React-agnostic.
|
|
12
|
+
*
|
|
13
|
+
* FlashList equivalent: CellRecycler
|
|
14
|
+
*/
|
|
15
|
+
class CellRecycler {
|
|
16
|
+
activeCells = new Map();
|
|
17
|
+
reusableCellsByType = new Map();
|
|
18
|
+
orderedCells = [];
|
|
19
|
+
nextCellId = 0;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reconcile visible indices against existing cells.
|
|
23
|
+
* Returns a stable ordered snapshot.
|
|
24
|
+
*/
|
|
25
|
+
reconcile(visibleIndices, getCellType) {
|
|
26
|
+
const visibleSet = new Set(visibleIndices);
|
|
27
|
+
|
|
28
|
+
// 1️⃣ Release cells no longer visible
|
|
29
|
+
for (const [index, cell] of this.activeCells) {
|
|
30
|
+
if (visibleSet.has(index)) continue;
|
|
31
|
+
this.activeCells.delete(index);
|
|
32
|
+
const orderedIndex = this.orderedCells.indexOf(cell);
|
|
33
|
+
if (orderedIndex !== -1) {
|
|
34
|
+
this.orderedCells.splice(orderedIndex, 1);
|
|
35
|
+
}
|
|
36
|
+
const pool = this.reusableCellsByType.get(cell.type) ?? [];
|
|
37
|
+
if (pool.length < MAX_CELLS) pool.push(cell);
|
|
38
|
+
this.reusableCellsByType.set(cell.type, pool);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 2️⃣ Acquire cells for newly visible indices
|
|
42
|
+
for (const index of visibleIndices) {
|
|
43
|
+
if (this.activeCells.has(index)) continue;
|
|
44
|
+
const type = getCellType(index);
|
|
45
|
+
const pool = this.reusableCellsByType.get(type);
|
|
46
|
+
let cell = pool?.pop();
|
|
47
|
+
if (!cell) {
|
|
48
|
+
cell = {
|
|
49
|
+
key: `cell-${this.nextCellId++}`,
|
|
50
|
+
type,
|
|
51
|
+
index
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
cell.index = index;
|
|
55
|
+
this.activeCells.set(index, cell);
|
|
56
|
+
this.orderedCells.push(cell);
|
|
57
|
+
}
|
|
58
|
+
return this.orderedCells;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.CellRecycler = CellRecycler;
|
|
62
|
+
//# sourceMappingURL=CellRecycler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAX_CELLS","CellRecycler","activeCells","Map","reusableCellsByType","orderedCells","nextCellId","reconcile","visibleIndices","getCellType","visibleSet","Set","index","cell","has","delete","orderedIndex","indexOf","splice","pool","get","type","length","push","set","pop","key","exports"],"sourceRoot":"../../../src","sources":["cell/CellRecycler.ts"],"mappings":";;;;;;AAEA,MAAMA,SAAS,GAAG,EAAE;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACO,MAA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AAGM,IAAI,EAAEM,GAAG,CAAC,CAAC;MAEtB,IAAI,CAACZ,IAAI,EAAE;QACTA,IAAI,GAAG;UACLa,GAAG,EAAE,QAAQ,IAAI,CAACpB,UAAU,EAAE,EAAE;UAChCe,IAAI;UACJT;QACF,CAAC;MACH;MAEAC,IAAI,CAACD,KAAK,GAAGA,KAAK;MAClB,IAAI,CAACV,WAAW,CAACsB,GAAG,CAACZ,KAAK,EAAEC,IAAI,CAAC;MACjC,IAAI,CAACR,YAAY,CAACkB,IAAI,CAACV,IAAI,CAAC;IAC9B;IAEA,OAAO,IAAI,CAACR,YAAY;EAC1B;AACF;AAACsB,OAAA,CAAA1B,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDebugOverlay = useDebugOverlay;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function useDebugOverlay(enabled, visibleCount) {
|
|
9
|
+
(0, _react.useEffect)(() => {
|
|
10
|
+
if (__DEV__ && enabled) {
|
|
11
|
+
console.log(`[RecyclerList] visible items: ${visibleCount}`);
|
|
12
|
+
}
|
|
13
|
+
}, [enabled, visibleCount]);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=useDebugOverlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","useDebugOverlay","enabled","visibleCount","useEffect","__DEV__","console","log"],"sourceRoot":"../../../src","sources":["debug/useDebugOverlay.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,eAAeA,CAC7BC,OAAgB,EAChBC,YAAoB,EACd;EACN,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIC,OAAO,IAAIH,OAAO,EAAE;MACtBI,OAAO,CAACC,GAAG,CACT,iCAAiCJ,YAAY,EAC/C,CAAC;IACH;EACF,CAAC,EAAE,CAACD,OAAO,EAAEC,YAAY,CAAC,CAAC;AAC7B","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getVisibleRange = getVisibleRange;
|
|
7
|
+
/**
|
|
8
|
+
* Binary-search based windowing.
|
|
9
|
+
* Returns indices intersecting viewport ± buffer.
|
|
10
|
+
*/
|
|
11
|
+
function getVisibleRange(layouts, metrics, bufferPx) {
|
|
12
|
+
if (layouts.length === 0 || metrics.height <= 0) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
const startY = Math.max(0, metrics.offsetY - bufferPx);
|
|
16
|
+
const endY = metrics.offsetY + metrics.height + bufferPx;
|
|
17
|
+
let low = 0;
|
|
18
|
+
let high = layouts.length - 1;
|
|
19
|
+
let first = layouts.length;
|
|
20
|
+
while (low <= high) {
|
|
21
|
+
const mid = low + high >> 1;
|
|
22
|
+
const rect = layouts[mid];
|
|
23
|
+
if (rect.y + rect.height >= startY) {
|
|
24
|
+
first = mid;
|
|
25
|
+
high = mid - 1;
|
|
26
|
+
} else {
|
|
27
|
+
low = mid + 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const visible = [];
|
|
31
|
+
for (let i = first; i < layouts.length; i++) {
|
|
32
|
+
const rect = layouts[i];
|
|
33
|
+
if (rect.y > endY) break;
|
|
34
|
+
visible.push(i);
|
|
35
|
+
}
|
|
36
|
+
return visible;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=getVisibleIndices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getVisibleRange","layouts","metrics","bufferPx","length","height","startY","Math","max","offsetY","endY","low","high","first","mid","rect","y","visible","i","push"],"sourceRoot":"../../src","sources":["getVisibleIndices.ts"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AACO,SAASA,eAAeA,CAC7BC,OAAmC,EACnCC,OAAsB,EACtBC,QAAgB,EACG;EACnB,IACEF,OAAO,CAACG,MAAM,KAAK,CAAC,IACpBF,OAAO,CAACG,MAAM,IAAI,CAAC,EACnB;IACA,OAAO,EAAE;EACX;EAEA,MAAMC,MAAM,GAAGC,IAAI,CAACC,GAAG,CACrB,CAAC,EACDN,OAAO,CAACO,OAAO,GAAGN,QACpB,CAAC;EAED,MAAMO,IAAI,GACRR,OAAO,CAACO,OAAO,GAAGP,OAAO,CAACG,MAAM,GAAGF,QAAQ;EAE7C,IAAIQ,GAAG,GAAG,CAAC;EACX,IAAIC,IAAI,GAAGX,OAAO,CAACG,MAAM,GAAG,CAAC;EAC7B,IAAIS,KAAK,GAAGZ,OAAO,CAACG,MAAM;EAE1B,OAAOO,GAAG,IAAIC,IAAI,EAAE;IAClB,MAAME,GAAG,GAAIH,GAAG,GAAGC,IAAI,IAAK,CAAC;IAC7B,MAAMG,IAAI,GAAGd,OAAO,CAACa,GAAG,CAAE;IAE1B,IAAIC,IAAI,CAACC,CAAC,GAAGD,IAAI,CAACV,MAAM,IAAIC,MAAM,EAAE;MAClCO,KAAK,GAAGC,GAAG;MACXF,IAAI,GAAGE,GAAG,GAAG,CAAC;IAChB,CAAC,MAAM;MACLH,GAAG,GAAGG,GAAG,GAAG,CAAC;IACf;EACF;EAEA,MAAMG,OAAiB,GAAG,EAAE;EAE5B,KAAK,IAAIC,CAAC,GAAGL,KAAK,EAAEK,CAAC,GAAGjB,OAAO,CAACG,MAAM,EAAEc,CAAC,EAAE,EAAE;IAC3C,MAAMH,IAAI,GAAGd,OAAO,CAACiB,CAAC,CAAE;IACxB,IAAIH,IAAI,CAACC,CAAC,GAAGN,IAAI,EAAE;IACnBO,OAAO,CAACE,IAAI,CAACD,CAAC,CAAC;EACjB;EAEA,OAAOD,OAAO;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAAE,sBAAA,GAAAF,OAAA;AAIA;AACA;AACA;AACA;AACA,MAAMG,aAAgC,GAAG,EAAE;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC7BC,OAAmC,EACnCC,OAAsB,EACtBC,QAAgB,EAChBC,WAAsC,EACrB;EACjB;AACF;AACA;EACE,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAAe,IAAIC,0BAAY,CAAC,CAAC,CAAC;;EAE5D;AACF;AACA;AACA;AACA;AACA;EACE,MAAMC,cAAc,GAAG,IAAAC,cAAO,EAC5B,MACER,OAAO,CAACS,MAAM,KAAK,CAAC,GAChBX,aAAa,GACb,IAAAY,4CAAqB,EACnBV,OAAO,EACPC,OAAO,EACPC,QACF,CAAC,EACP,CAACF,OAAO,EAAEC,OAAO,CAACU,OAAO,EAAEV,OAAO,CAACW,MAAM,EAAEV,QAAQ,CACrD,CAAC;;EAED;AACF;AACA;EACE,MAAM,CAACW,KAAK,EAAEC,QAAQ,CAAC,GACrB,IAAAC,eAAQ,EAAkB,EAAE,CAAC;;EAE/B;AACF;AACA;AACA;AACA;AACA;AACA;EACE,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,IAAI,GACRb,WAAW,CAACc,OAAO,CAACC,SAAS,CAC3BZ,cAAc,EACdJ,WACF,CAAC;IAEHW,QAAQ,CAACM,IAAI,IACXA,IAAI,CAACX,MAAM,KAAKQ,IAAI,CAACR,MAAM,IAC3BW,IAAI,CAACC,KAAK,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,KAAKL,IAAI,CAACM,CAAC,CAAC,CAAC,GAC/BH,IAAI,GACJH,IACN,CAAC;EACH,CAAC,EAAE,CAACV,cAAc,EAAEJ,WAAW,CAAC,CAAC;EAEjC,OAAOU,KAAK;AACd","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
Object.defineProperty(exports, "RecyclerList", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _RecyclerList.RecyclerList;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _RecyclerList = require("./RecyclerList");
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_RecyclerList","require"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["layout/LayoutProvider.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["layout/LayoutRectangle.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MutableLinearLayout = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* INTERNAL mutable layout record.
|
|
9
|
+
* This is intentionally mutable and never exposed publicly.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Mutable linear layout store.
|
|
14
|
+
* FlashList-style incremental relayout.
|
|
15
|
+
*/
|
|
16
|
+
class MutableLinearLayout {
|
|
17
|
+
constructor(initialHeights, width) {
|
|
18
|
+
this.layouts = [];
|
|
19
|
+
let y = 0;
|
|
20
|
+
for (const height of initialHeights) {
|
|
21
|
+
this.layouts.push({
|
|
22
|
+
x: 0,
|
|
23
|
+
y,
|
|
24
|
+
width,
|
|
25
|
+
height
|
|
26
|
+
});
|
|
27
|
+
y += height;
|
|
28
|
+
}
|
|
29
|
+
this.totalHeight = y;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Read-only snapshot for consumers.
|
|
34
|
+
* Returned type is immutable.
|
|
35
|
+
*/
|
|
36
|
+
getLayouts() {
|
|
37
|
+
return this.layouts;
|
|
38
|
+
}
|
|
39
|
+
getContentHeight() {
|
|
40
|
+
return this.totalHeight;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Update height of one item and shift following items.
|
|
45
|
+
* Returns true if layout changed.
|
|
46
|
+
*/
|
|
47
|
+
updateItemHeight(index, newHeight) {
|
|
48
|
+
const layout = this.layouts[index];
|
|
49
|
+
if (!layout) return false;
|
|
50
|
+
const delta = newHeight - layout.height;
|
|
51
|
+
if (delta === 0) return false;
|
|
52
|
+
|
|
53
|
+
// Update this item
|
|
54
|
+
layout.height = newHeight;
|
|
55
|
+
|
|
56
|
+
// Shift all items after this index
|
|
57
|
+
for (let i = index + 1; i < this.layouts.length; i++) {
|
|
58
|
+
this.layouts[i].y += delta;
|
|
59
|
+
}
|
|
60
|
+
this.totalHeight += delta;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.MutableLinearLayout = MutableLinearLayout;
|
|
65
|
+
//# sourceMappingURL=MutableLinearLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MutableLinearLayout","constructor","initialHeights","width","layouts","y","height","push","x","totalHeight","getLayouts","getContentHeight","updateItemHeight","index","newHeight","layout","delta","i","length","exports"],"sourceRoot":"../../../src","sources":["layout/MutableLinearLayout.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,CAAC;EAI/BC,WAAWA,CACTC,cAAiC,EACjCC,KAAa,EACb;IACA,IAAI,CAACC,OAAO,GAAG,EAAE;IACjB,IAAIC,CAAC,GAAG,CAAC;IAET,KAAK,MAAMC,MAAM,IAAIJ,cAAc,EAAE;MACnC,IAAI,CAACE,OAAO,CAACG,IAAI,CAAC;QAChBC,CAAC,EAAE,CAAC;QACJH,CAAC;QACDF,KAAK;QACLG;MACF,CAAC,CAAC;MACFD,CAAC,IAAIC,MAAM;IACb;IAEA,IAAI,CAACG,WAAW,GAAGJ,CAAC;EACtB;;EAEA;AACF;AACA;AACA;EACEK,UAAUA,CAAA,EAA+B;IACvC,OAAO,IAAI,CAACN,OAAO;EACrB;EAEAO,gBAAgBA,CAAA,EAAW;IACzB,OAAO,IAAI,CAACF,WAAW;EACzB;;EAEA;AACF;AACA;AACA;EACEG,gBAAgBA,CACdC,KAAa,EACbC,SAAiB,EACR;IACT,MAAMC,MAAM,GAAG,IAAI,CAACX,OAAO,CAACS,KAAK,CAAC;IAClC,IAAI,CAACE,MAAM,EAAE,OAAO,KAAK;IAEzB,MAAMC,KAAK,GAAGF,SAAS,GAAGC,MAAM,CAACT,MAAM;IACvC,IAAIU,KAAK,KAAK,CAAC,EAAE,OAAO,KAAK;;IAE7B;IACAD,MAAM,CAACT,MAAM,GAAGQ,SAAS;;IAEzB;IACA,KAAK,IAAIG,CAAC,GAAGJ,KAAK,GAAG,CAAC,EAAEI,CAAC,GAAG,IAAI,CAACb,OAAO,CAACc,MAAM,EAAED,CAAC,EAAE,EAAE;MACpD,IAAI,CAACb,OAAO,CAACa,CAAC,CAAC,CAAEZ,CAAC,IAAIW,KAAK;IAC7B;IAEA,IAAI,CAACP,WAAW,IAAIO,KAAK;IACzB,OAAO,IAAI;EACb;AACF;AAACG,OAAA,CAAAnB,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "EstimatedLayoutProvider", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _EstimatedLayoutProvider.EstimatedLayoutProvider;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "computeLayouts", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _LayoutEngine.computeLayouts;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _EstimatedLayoutProvider = require("./EstimatedLayoutProvider");
|
|
19
|
+
var _LayoutEngine = require("./LayoutEngine");
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_EstimatedLayoutProvider","require","_LayoutEngine"],"sourceRoot":"../../../src","sources":["layout/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAEA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA","ignoreList":[]}
|