react-native-nitro-list 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -44
- package/ios/HybridNitroList.swift +12 -14
- package/lib/commonjs/cell/CellKeyGenerator.js +21 -0
- package/lib/commonjs/cell/CellKeyGenerator.js.map +1 -0
- package/lib/commonjs/cell/CellRecycler.js +48 -40
- package/lib/commonjs/cell/CellRecycler.js.map +1 -1
- package/lib/commonjs/cell/createCell.js +21 -0
- package/lib/commonjs/cell/createCell.js.map +1 -0
- package/lib/commonjs/cell/index.js +20 -0
- package/lib/commonjs/cell/index.js.map +1 -0
- package/lib/commonjs/getVisibleIndices.js.map +1 -1
- package/lib/commonjs/hooks/usePersistentCallback.js +36 -0
- package/lib/commonjs/hooks/usePersistentCallback.js.map +1 -0
- package/lib/commonjs/index.js +31 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layout/MutableLinearLayout.js +78 -39
- package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -1
- package/lib/commonjs/layout/constants/layoutDefaults.js +19 -0
- package/lib/commonjs/layout/constants/layoutDefaults.js.map +1 -0
- package/lib/commonjs/layout/index.js +0 -18
- package/lib/commonjs/layout/index.js.map +1 -1
- package/lib/commonjs/native/NitroListView.js +20 -0
- package/lib/commonjs/native/NitroListView.js.map +1 -0
- package/lib/commonjs/recycler/CellPool.js +33 -0
- package/lib/commonjs/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/recycler/NitroList.js +223 -0
- package/lib/commonjs/recycler/NitroList.js.map +1 -0
- package/lib/commonjs/scroll/useScrollVelocity.js +20 -0
- package/lib/commonjs/scroll/useScrollVelocity.js.map +1 -0
- package/lib/commonjs/{native/NitroList.types.js → specs/NitroList.nitro.js} +1 -1
- package/lib/commonjs/{layout/LayoutProvider.js.map → specs/NitroList.nitro.js.map} +1 -1
- package/lib/commonjs/types/Axis.js +2 -0
- package/lib/{module/layout/LayoutProvider.js.map → commonjs/types/Axis.js.map} +1 -1
- package/lib/commonjs/types/CellKey.js +2 -0
- package/lib/commonjs/{layout/LayoutRectangle.js.map → types/CellKey.js.map} +1 -1
- package/lib/commonjs/types/CellType.js +27 -0
- package/lib/commonjs/types/CellType.js.map +1 -0
- package/lib/commonjs/types/VisibleRange.js +2 -0
- package/lib/commonjs/{native/NitroList.types.js.map → types/VisibleRange.js.map} +1 -1
- package/lib/commonjs/{RecyclerList.types.js → types/VisibleRangeInput.js} +1 -1
- package/lib/commonjs/types/VisibleRangeInput.js.map +1 -0
- package/lib/commonjs/types/index.js +13 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/layout/LayoutRect.js +2 -0
- package/lib/commonjs/types/layout/LayoutRect.js.map +1 -0
- package/lib/commonjs/{specs/nitro-layout-engine.nitro.js → types/layout/LinearLayoutInput.js} +1 -1
- package/lib/commonjs/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js +26 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/commonjs/types/layout/index.js +2 -0
- package/lib/commonjs/types/layout/index.js.map +1 -0
- package/lib/commonjs/types/recycler/CellPool.js +42 -0
- package/lib/commonjs/types/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/{layout/LayoutProvider.js → types/recycler/NitroListProps.js} +1 -1
- package/lib/commonjs/types/recycler/NitroListProps.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerCell.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerCell.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/commonjs/types/recycler/index.js +2 -0
- package/lib/commonjs/types/recycler/index.js.map +1 -0
- package/lib/commonjs/types/scroll/ScrollMetrics.js +6 -0
- package/lib/commonjs/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/commonjs/types/scroll/index.js +2 -0
- package/lib/commonjs/types/scroll/index.js.map +1 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js +61 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/commonjs/windowing/index.js +3 -3
- package/lib/commonjs/windowing/index.js.map +1 -1
- package/lib/module/cell/CellKeyGenerator.js +16 -0
- package/lib/module/cell/CellKeyGenerator.js.map +1 -0
- package/lib/module/cell/CellRecycler.js +48 -39
- package/lib/module/cell/CellRecycler.js.map +1 -1
- package/lib/module/cell/createCell.js +17 -0
- package/lib/module/cell/createCell.js.map +1 -0
- package/lib/module/cell/index.js +7 -0
- package/lib/module/cell/index.js.map +1 -0
- package/lib/module/getVisibleIndices.js.map +1 -1
- package/lib/module/hooks/usePersistentCallback.js +33 -0
- package/lib/module/hooks/usePersistentCallback.js.map +1 -0
- package/lib/module/index.js +5 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/MutableLinearLayout.js +78 -38
- package/lib/module/layout/MutableLinearLayout.js.map +1 -1
- package/lib/module/layout/constants/layoutDefaults.js +15 -0
- package/lib/module/layout/constants/layoutDefaults.js.map +1 -0
- package/lib/module/layout/index.js +0 -3
- package/lib/module/layout/index.js.map +1 -1
- package/lib/module/native/NitroListView.js +17 -0
- package/lib/module/native/NitroListView.js.map +1 -0
- package/lib/module/recycler/CellPool.js +28 -0
- package/lib/module/recycler/CellPool.js.map +1 -0
- package/lib/module/recycler/NitroList.js +220 -0
- package/lib/module/recycler/NitroList.js.map +1 -0
- package/lib/module/scroll/useScrollVelocity.js +16 -0
- package/lib/module/scroll/useScrollVelocity.js.map +1 -0
- package/lib/module/specs/NitroList.nitro.js +4 -0
- package/lib/module/specs/NitroList.nitro.js.map +1 -0
- package/lib/module/types/Axis.js +2 -0
- package/lib/module/types/Axis.js.map +1 -0
- package/lib/module/types/CellKey.js +2 -0
- package/lib/module/types/CellKey.js.map +1 -0
- package/lib/module/types/CellType.js +22 -0
- package/lib/module/types/CellType.js.map +1 -0
- package/lib/module/types/VisibleRange.js +2 -0
- package/lib/module/types/VisibleRange.js.map +1 -0
- package/lib/module/types/VisibleRangeInput.js +4 -0
- package/lib/module/types/VisibleRangeInput.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/layout/LayoutRect.js +2 -0
- package/lib/module/types/layout/LayoutRect.js.map +1 -0
- package/lib/module/types/layout/LinearLayoutInput.js +4 -0
- package/lib/module/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/module/types/layout/MainAxisPadding.js +22 -0
- package/lib/module/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/module/types/layout/index.js +2 -0
- package/lib/module/types/layout/index.js.map +1 -0
- package/lib/module/types/recycler/CellPool.js +37 -0
- package/lib/module/types/recycler/CellPool.js.map +1 -0
- package/lib/module/types/recycler/NitroListProps.js +4 -0
- package/lib/module/types/recycler/NitroListProps.js.map +1 -0
- package/lib/module/types/recycler/RecyclerCell.js +4 -0
- package/lib/module/types/recycler/RecyclerCell.js.map +1 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js +4 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/module/types/recycler/index.js +2 -0
- package/lib/module/types/recycler/index.js.map +1 -0
- package/lib/module/types/scroll/ScrollMetrics.js +4 -0
- package/lib/module/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/module/types/scroll/index.js +2 -0
- package/lib/module/types/scroll/index.js.map +1 -0
- package/lib/module/windowing/computeVisibleItemRange.js +57 -0
- package/lib/module/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/module/windowing/index.js +1 -1
- package/lib/module/windowing/index.js.map +1 -1
- package/lib/typescript/src/cell/Cell.d.ts +13 -4
- package/lib/typescript/src/cell/Cell.d.ts.map +1 -1
- package/lib/typescript/src/cell/CellKeyGenerator.d.ts +11 -0
- package/lib/typescript/src/cell/CellKeyGenerator.d.ts.map +1 -0
- package/lib/typescript/src/cell/CellRecycler.d.ts +19 -11
- package/lib/typescript/src/cell/CellRecycler.d.ts.map +1 -1
- package/lib/typescript/src/cell/createCell.d.ts +7 -0
- package/lib/typescript/src/cell/createCell.d.ts.map +1 -0
- package/lib/typescript/src/cell/index.d.ts +4 -0
- package/lib/typescript/src/cell/index.d.ts.map +1 -0
- package/lib/typescript/src/getVisibleIndices.d.ts +2 -2
- package/lib/typescript/src/getVisibleIndices.d.ts.map +1 -1
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts +16 -0
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts +45 -13
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts.map +1 -1
- package/lib/typescript/src/layout/constants/layoutDefaults.d.ts +13 -0
- package/lib/typescript/src/layout/constants/layoutDefaults.d.ts.map +1 -0
- package/lib/typescript/src/layout/index.d.ts +1 -4
- package/lib/typescript/src/layout/index.d.ts.map +1 -1
- package/lib/typescript/src/native/NitroListView.d.ts +20 -0
- package/lib/typescript/src/native/NitroListView.d.ts.map +1 -0
- package/lib/typescript/src/recycler/CellPool.d.ts +11 -0
- package/lib/typescript/src/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/recycler/NitroList.d.ts +4 -0
- package/lib/typescript/src/recycler/NitroList.d.ts.map +1 -0
- package/lib/typescript/src/scroll/useScrollVelocity.d.ts +2 -0
- package/lib/typescript/src/scroll/useScrollVelocity.d.ts.map +1 -0
- package/lib/typescript/src/specs/NitroList.nitro.d.ts +26 -0
- package/lib/typescript/src/specs/NitroList.nitro.d.ts.map +1 -0
- package/lib/typescript/src/types/Axis.d.ts +11 -0
- package/lib/typescript/src/types/Axis.d.ts.map +1 -0
- package/lib/typescript/src/types/CellKey.d.ts +2 -0
- package/lib/typescript/src/types/CellKey.d.ts.map +1 -0
- package/lib/typescript/src/types/CellType.d.ts +22 -0
- package/lib/typescript/src/types/CellType.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRange.d.ts +10 -0
- package/lib/typescript/src/types/VisibleRange.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts +35 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +8 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts +15 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts +10 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts +20 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/index.d.ts +4 -0
- package/lib/typescript/src/types/layout/index.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/CellPool.d.ts +16 -0
- package/lib/typescript/src/types/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/NitroListProps.d.ts +66 -0
- package/lib/typescript/src/types/recycler/NitroListProps.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerCell.d.ts +12 -0
- package/lib/typescript/src/types/recycler/RecyclerCell.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts +12 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/index.d.ts +4 -0
- package/lib/typescript/src/types/recycler/index.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts +15 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/index.d.ts +2 -0
- package/lib/typescript/src/types/scroll/index.d.ts.map +1 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts +19 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts.map +1 -0
- package/lib/typescript/src/windowing/index.d.ts +1 -1
- package/lib/typescript/src/windowing/index.d.ts.map +1 -1
- package/nitro.json +5 -5
- package/nitrogen/generated/android/NitroList+autolinking.cmake +2 -2
- package/nitrogen/generated/android/NitroListOnLoad.cpp +2 -2
- package/nitrogen/generated/android/c++/{JHybridNitroLayoutEngineSpec.cpp → JHybridNitroListSpec.cpp} +15 -15
- package/nitrogen/generated/android/c++/{JHybridNitroLayoutEngineSpec.hpp → JHybridNitroListSpec.hpp} +11 -11
- package/nitrogen/generated/android/c++/{JLayoutRectangle.hpp → JItemLayout.hpp} +10 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{HybridNitroLayoutEngineSpec.kt → HybridNitroListSpec.kt} +7 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{LayoutRectangle.kt → ItemLayout.kt} +5 -5
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.cpp +9 -9
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +27 -27
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +8 -8
- package/nitrogen/generated/ios/c++/{HybridNitroLayoutEngineSpecSwift.cpp → HybridNitroListSpecSwift.cpp} +2 -2
- package/nitrogen/generated/ios/c++/{HybridNitroLayoutEngineSpecSwift.hpp → HybridNitroListSpecSwift.hpp} +16 -16
- package/nitrogen/generated/ios/swift/HybridNitroListSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/{HybridNitroLayoutEngineSpec_cxx.swift → HybridNitroListSpec_cxx.swift} +23 -23
- package/nitrogen/generated/ios/swift/{LayoutRectangle.swift → ItemLayout.swift} +5 -5
- package/nitrogen/generated/shared/c++/{HybridNitroLayoutEngineSpec.cpp → HybridNitroListSpec.cpp} +4 -4
- package/nitrogen/generated/shared/c++/{HybridNitroLayoutEngineSpec.hpp → HybridNitroListSpec.hpp} +13 -13
- package/nitrogen/generated/shared/c++/{LayoutRectangle.hpp → ItemLayout.hpp} +11 -11
- package/package.json +5 -5
- package/src/cell/Cell.ts +13 -4
- package/src/cell/CellKeyGenerator.ts +17 -0
- package/src/cell/CellRecycler.ts +53 -43
- package/src/cell/createCell.ts +15 -0
- package/src/cell/index.ts +5 -0
- package/src/getVisibleIndices.ts +4 -2
- package/src/hooks/usePersistentCallback.ts +37 -0
- package/src/index.ts +7 -2
- package/src/layout/MutableLinearLayout.ts +91 -58
- package/src/layout/constants/layoutDefaults.ts +12 -0
- package/src/layout/index.ts +1 -4
- package/src/native/NitroListView.ts +22 -0
- package/src/recycler/CellPool.ts +33 -0
- package/src/recycler/NitroList.tsx +317 -0
- package/src/scroll/useScrollVelocity.ts +16 -0
- package/src/specs/NitroList.nitro.ts +29 -0
- package/src/types/Axis.ts +10 -0
- package/src/types/CellKey.ts +2 -0
- package/src/types/CellType.ts +9 -0
- package/src/types/VisibleRange.ts +9 -0
- package/src/types/VisibleRangeInput.ts +39 -0
- package/src/types/index.ts +15 -0
- package/src/types/layout/LayoutRect.ts +14 -0
- package/src/types/layout/LinearLayoutInput.ts +12 -0
- package/src/types/layout/MainAxisPadding.ts +23 -0
- package/src/types/layout/index.ts +3 -0
- package/src/types/recycler/CellPool.ts +45 -0
- package/src/types/recycler/NitroListProps.ts +74 -0
- package/src/types/recycler/RecyclerCell.ts +12 -0
- package/src/types/recycler/RecyclerItemRenderer.ts +12 -0
- package/src/types/recycler/index.ts +3 -0
- package/src/types/scroll/ScrollMetrics.ts +18 -0
- package/src/types/scroll/index.ts +1 -0
- package/src/windowing/computeVisibleItemRange.ts +82 -0
- package/src/windowing/index.ts +1 -1
- package/lib/commonjs/NitroList.js +0 -9
- package/lib/commonjs/NitroList.js.map +0 -1
- package/lib/commonjs/RecyclerList.internal.js +0 -25
- package/lib/commonjs/RecyclerList.internal.js.map +0 -1
- package/lib/commonjs/RecyclerList.js +0 -171
- package/lib/commonjs/RecyclerList.js.map +0 -1
- package/lib/commonjs/RecyclerList.types.js.map +0 -1
- package/lib/commonjs/cell/StableKey.js +0 -10
- package/lib/commonjs/cell/StableKey.js.map +0 -1
- package/lib/commonjs/hooks/useCellRenderer.js +0 -62
- package/lib/commonjs/hooks/useCellRenderer.js.map +0 -1
- package/lib/commonjs/hooks/useStableCallback.js +0 -13
- package/lib/commonjs/hooks/useStableCallback.js.map +0 -1
- package/lib/commonjs/layout/EstimatedLayoutProvider.js +0 -30
- package/lib/commonjs/layout/EstimatedLayoutProvider.js.map +0 -1
- package/lib/commonjs/layout/LayoutEngine.js +0 -21
- package/lib/commonjs/layout/LayoutEngine.js.map +0 -1
- package/lib/commonjs/layout/LayoutRectangle.js +0 -2
- package/lib/commonjs/native/NitroLayoutEngine.js +0 -9
- package/lib/commonjs/native/NitroLayoutEngine.js.map +0 -1
- package/lib/commonjs/native/NitroRecyclerView.js +0 -9
- package/lib/commonjs/native/NitroRecyclerView.js.map +0 -1
- package/lib/commonjs/specs/nitro-layout-engine.nitro.js.map +0 -1
- package/lib/commonjs/viewability/ViewabilityHelper.js +0 -121
- package/lib/commonjs/viewability/ViewabilityHelper.js.map +0 -1
- package/lib/commonjs/windowing/findVisibleIndexRange.js +0 -48
- package/lib/commonjs/windowing/findVisibleIndexRange.js.map +0 -1
- package/lib/module/NitroList.js +0 -5
- package/lib/module/NitroList.js.map +0 -1
- package/lib/module/RecyclerList.internal.js +0 -22
- package/lib/module/RecyclerList.internal.js.map +0 -1
- package/lib/module/RecyclerList.js +0 -166
- package/lib/module/RecyclerList.js.map +0 -1
- package/lib/module/RecyclerList.types.js +0 -4
- package/lib/module/RecyclerList.types.js.map +0 -1
- package/lib/module/cell/StableKey.js +0 -6
- package/lib/module/cell/StableKey.js.map +0 -1
- package/lib/module/hooks/useCellRenderer.js +0 -58
- package/lib/module/hooks/useCellRenderer.js.map +0 -1
- package/lib/module/hooks/useStableCallback.js +0 -9
- package/lib/module/hooks/useStableCallback.js.map +0 -1
- package/lib/module/layout/EstimatedLayoutProvider.js +0 -25
- package/lib/module/layout/EstimatedLayoutProvider.js.map +0 -1
- package/lib/module/layout/LayoutEngine.js +0 -17
- package/lib/module/layout/LayoutEngine.js.map +0 -1
- package/lib/module/layout/LayoutProvider.js +0 -4
- package/lib/module/layout/LayoutRectangle.js +0 -2
- package/lib/module/layout/LayoutRectangle.js.map +0 -1
- package/lib/module/native/NitroLayoutEngine.js +0 -5
- package/lib/module/native/NitroLayoutEngine.js.map +0 -1
- package/lib/module/native/NitroList.types.js +0 -4
- package/lib/module/native/NitroList.types.js.map +0 -1
- package/lib/module/native/NitroRecyclerView.js +0 -5
- package/lib/module/native/NitroRecyclerView.js.map +0 -1
- package/lib/module/specs/nitro-layout-engine.nitro.js +0 -4
- package/lib/module/specs/nitro-layout-engine.nitro.js.map +0 -1
- package/lib/module/viewability/ViewabilityHelper.js +0 -116
- package/lib/module/viewability/ViewabilityHelper.js.map +0 -1
- package/lib/module/windowing/findVisibleIndexRange.js +0 -44
- package/lib/module/windowing/findVisibleIndexRange.js.map +0 -1
- package/lib/typescript/src/NitroList.d.ts +0 -5
- package/lib/typescript/src/NitroList.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.d.ts +0 -26
- package/lib/typescript/src/RecyclerList.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.internal.d.ts +0 -9
- package/lib/typescript/src/RecyclerList.internal.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.types.d.ts +0 -18
- package/lib/typescript/src/RecyclerList.types.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts +0 -2
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts.map +0 -1
- package/lib/typescript/src/cell/StableKey.d.ts +0 -2
- package/lib/typescript/src/cell/StableKey.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCellRenderer.d.ts +0 -19
- package/lib/typescript/src/hooks/useCellRenderer.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useStableCallback.d.ts +0 -2
- package/lib/typescript/src/hooks/useStableCallback.d.ts.map +0 -1
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts +0 -15
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutEngine.d.ts +0 -10
- package/lib/typescript/src/layout/LayoutEngine.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutProvider.d.ts +0 -16
- package/lib/typescript/src/layout/LayoutProvider.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutRectangle.d.ts +0 -11
- package/lib/typescript/src/layout/LayoutRectangle.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroLayoutEngine.d.ts +0 -3
- package/lib/typescript/src/native/NitroLayoutEngine.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroList.types.d.ts +0 -9
- package/lib/typescript/src/native/NitroList.types.d.ts.map +0 -1
- package/lib/typescript/src/native/NitroRecyclerView.d.ts +0 -5
- package/lib/typescript/src/native/NitroRecyclerView.d.ts.map +0 -1
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +0 -14
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +0 -1
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts +0 -50
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts +0 -11
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts.map +0 -1
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +0 -56
- package/src/NitroList.ts +0 -8
- package/src/RecyclerList.internal.ts +0 -38
- package/src/RecyclerList.tsx +0 -252
- package/src/RecyclerList.types.ts +0 -24
- package/src/__tests__/windowing/findVisibleIndexRange.test.ts +0 -55
- package/src/cell/StableKey.ts +0 -6
- package/src/hooks/useCellRenderer.ts +0 -86
- package/src/hooks/useStableCallback.ts +0 -13
- package/src/layout/EstimatedLayoutProvider.ts +0 -35
- package/src/layout/LayoutEngine.ts +0 -21
- package/src/layout/LayoutProvider.ts +0 -17
- package/src/layout/LayoutRectangle.ts +0 -10
- package/src/native/NitroLayoutEngine.ts +0 -7
- package/src/native/NitroList.types.ts +0 -12
- package/src/native/NitroRecyclerView.ts +0 -8
- package/src/specs/nitro-layout-engine.nitro.ts +0 -17
- package/src/viewability/ViewabilityHelper.ts +0 -130
- package/src/windowing/findVisibleIndexRange.ts +0 -60
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridNitroListSpecSwift.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include "
|
|
10
|
+
#include "HybridNitroListSpec.hpp"
|
|
11
11
|
|
|
12
|
-
// Forward declaration of `
|
|
13
|
-
namespace NitroList { class
|
|
12
|
+
// Forward declaration of `HybridNitroListSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroList { class HybridNitroListSpec_cxx; }
|
|
14
14
|
|
|
15
|
-
// Forward declaration of `
|
|
16
|
-
namespace margelo::nitro::nitrolist { struct
|
|
15
|
+
// Forward declaration of `ItemLayout` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrolist { struct ItemLayout; }
|
|
17
17
|
|
|
18
|
-
#include "
|
|
18
|
+
#include "ItemLayout.hpp"
|
|
19
19
|
#include <vector>
|
|
20
20
|
|
|
21
21
|
#include "NitroList-Swift-Cxx-Umbrella.hpp"
|
|
@@ -23,25 +23,25 @@ namespace margelo::nitro::nitrolist { struct LayoutRectangle; }
|
|
|
23
23
|
namespace margelo::nitro::nitrolist {
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* The C++ part of
|
|
26
|
+
* The C++ part of HybridNitroListSpec_cxx.swift.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
28
|
+
* HybridNitroListSpecSwift (C++) accesses HybridNitroListSpec_cxx (Swift), and might
|
|
29
29
|
* contain some additional bridging code for C++ <> Swift interop.
|
|
30
30
|
*
|
|
31
31
|
* Since this obviously introduces an overhead, I hope at some point in
|
|
32
|
-
* the future,
|
|
32
|
+
* the future, HybridNitroListSpec_cxx can directly inherit from the C++ class HybridNitroListSpec
|
|
33
33
|
* to simplify the whole structure and memory management.
|
|
34
34
|
*/
|
|
35
|
-
class
|
|
35
|
+
class HybridNitroListSpecSwift: public virtual HybridNitroListSpec {
|
|
36
36
|
public:
|
|
37
37
|
// Constructor from a Swift instance
|
|
38
|
-
explicit
|
|
39
|
-
HybridObject(
|
|
38
|
+
explicit HybridNitroListSpecSwift(const NitroList::HybridNitroListSpec_cxx& swiftPart):
|
|
39
|
+
HybridObject(HybridNitroListSpec::TAG),
|
|
40
40
|
_swiftPart(swiftPart) { }
|
|
41
41
|
|
|
42
42
|
public:
|
|
43
43
|
// Get the Swift part
|
|
44
|
-
inline NitroList::
|
|
44
|
+
inline NitroList::HybridNitroListSpec_cxx& getSwiftPart() noexcept {
|
|
45
45
|
return _swiftPart;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -62,7 +62,7 @@ namespace margelo::nitro::nitrolist {
|
|
|
62
62
|
|
|
63
63
|
public:
|
|
64
64
|
// Methods
|
|
65
|
-
inline std::vector<
|
|
65
|
+
inline std::vector<ItemLayout> computeLayout(double containerWidth, const std::vector<double>& itemHeights) override {
|
|
66
66
|
auto __result = _swiftPart.computeLayout(std::forward<decltype(containerWidth)>(containerWidth), itemHeights);
|
|
67
67
|
if (__result.hasError()) [[unlikely]] {
|
|
68
68
|
std::rethrow_exception(__result.error());
|
|
@@ -72,7 +72,7 @@ namespace margelo::nitro::nitrolist {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
private:
|
|
75
|
-
NitroList::
|
|
75
|
+
NitroList::HybridNitroListSpec_cxx _swiftPart;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
} // namespace margelo::nitro::nitrolist
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroListSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridNitroListSpec``
|
|
12
|
+
public protocol HybridNitroListSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func computeLayout(containerWidth: Double, itemHeights: [Double]) throws -> [ItemLayout]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridNitroListSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject NitroList]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridNitroListSpec``
|
|
28
|
+
open class HybridNitroListSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridNitroListSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridNitroListSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is HybridNitroListSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridNitroListSpec`! Did you accidentally inherit from `HybridNitroListSpec_base` instead of `HybridNitroListSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridNitroListSpec_cxx(self as! HybridNitroListSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the NitroList HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of NitroList.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridNitroList : HybridNitroListSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridNitroListSpec = HybridNitroListSpec_protocol & HybridNitroListSpec_base
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridNitroListSpec_cxx.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -9,7 +9,7 @@ import Foundation
|
|
|
9
9
|
import NitroModules
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* A class implementation that bridges
|
|
12
|
+
* A class implementation that bridges HybridNitroListSpec over to C++.
|
|
13
13
|
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
14
|
*
|
|
15
15
|
* Also, some Swift types need to be bridged with special handling:
|
|
@@ -17,7 +17,7 @@ import NitroModules
|
|
|
17
17
|
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
18
|
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
19
|
*/
|
|
20
|
-
open class
|
|
20
|
+
open class HybridNitroListSpec_cxx {
|
|
21
21
|
/**
|
|
22
22
|
* The Swift <> C++ bridge's namespace (`margelo::nitro::nitrolist::bridge::swift`)
|
|
23
23
|
* from `NitroList-Swift-Cxx-Bridge.hpp`.
|
|
@@ -26,30 +26,30 @@ open class HybridNitroLayoutEngineSpec_cxx {
|
|
|
26
26
|
public typealias bridge = margelo.nitro.nitrolist.bridge.swift
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Holds an instance of the `
|
|
29
|
+
* Holds an instance of the `HybridNitroListSpec` Swift protocol.
|
|
30
30
|
*/
|
|
31
|
-
private var __implementation: any
|
|
31
|
+
private var __implementation: any HybridNitroListSpec
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
35
|
*/
|
|
36
|
-
private var __cxxPart: bridge.
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridNitroListSpec_
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Create a new `
|
|
39
|
+
* Create a new `HybridNitroListSpec_cxx` that wraps the given `HybridNitroListSpec`.
|
|
40
40
|
* All properties and methods bridge to C++ types.
|
|
41
41
|
*/
|
|
42
|
-
public init(_ implementation: any
|
|
42
|
+
public init(_ implementation: any HybridNitroListSpec) {
|
|
43
43
|
self.__implementation = implementation
|
|
44
44
|
self.__cxxPart = .init()
|
|
45
45
|
/* no base class */
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* Get the actual `
|
|
49
|
+
* Get the actual `HybridNitroListSpec` instance this class wraps.
|
|
50
50
|
*/
|
|
51
51
|
@inline(__always)
|
|
52
|
-
public func
|
|
52
|
+
public func getHybridNitroListSpec() -> any HybridNitroListSpec {
|
|
53
53
|
return __implementation
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -62,25 +62,25 @@ open class HybridNitroLayoutEngineSpec_cxx {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Casts an unsafe pointer to a `
|
|
66
|
-
* The pointer has to be a retained opaque `Unmanaged<
|
|
65
|
+
* Casts an unsafe pointer to a `HybridNitroListSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridNitroListSpec_cxx>`.
|
|
67
67
|
* This removes one strong reference from the object!
|
|
68
68
|
*/
|
|
69
|
-
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) ->
|
|
70
|
-
return Unmanaged<
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroListSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridNitroListSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
-
* The C++ part is a `std::shared_ptr<
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridNitroListSpec>`.
|
|
76
76
|
*/
|
|
77
|
-
public func getCxxPart() -> bridge.
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroListSpec_ {
|
|
78
78
|
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
79
|
if Bool(fromCxx: cachedCxxPart) {
|
|
80
80
|
return cachedCxxPart
|
|
81
81
|
} else {
|
|
82
|
-
let newCxxPart = bridge.
|
|
83
|
-
__cxxPart = bridge.
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridNitroListSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridNitroListSpec_(newCxxPart)
|
|
84
84
|
return newCxxPart
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -118,20 +118,20 @@ open class HybridNitroLayoutEngineSpec_cxx {
|
|
|
118
118
|
|
|
119
119
|
// Methods
|
|
120
120
|
@inline(__always)
|
|
121
|
-
public final func computeLayout(containerWidth: Double, itemHeights: bridge.std__vector_double_) -> bridge.
|
|
121
|
+
public final func computeLayout(containerWidth: Double, itemHeights: bridge.std__vector_double_) -> bridge.Result_std__vector_ItemLayout__ {
|
|
122
122
|
do {
|
|
123
123
|
let __result = try self.__implementation.computeLayout(containerWidth: containerWidth, itemHeights: itemHeights.map({ __item in __item }))
|
|
124
|
-
let __resultCpp = { () -> bridge.
|
|
125
|
-
var __vector = bridge.
|
|
124
|
+
let __resultCpp = { () -> bridge.std__vector_ItemLayout_ in
|
|
125
|
+
var __vector = bridge.create_std__vector_ItemLayout_(__result.count)
|
|
126
126
|
for __item in __result {
|
|
127
127
|
__vector.push_back(__item)
|
|
128
128
|
}
|
|
129
129
|
return __vector
|
|
130
130
|
}()
|
|
131
|
-
return bridge.
|
|
131
|
+
return bridge.create_Result_std__vector_ItemLayout__(__resultCpp)
|
|
132
132
|
} catch (let __error) {
|
|
133
133
|
let __exceptionPtr = __error.toCpp()
|
|
134
|
-
return bridge.
|
|
134
|
+
return bridge.create_Result_std__vector_ItemLayout__(__exceptionPtr)
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// ItemLayout.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -9,15 +9,15 @@ import Foundation
|
|
|
9
9
|
import NitroModules
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Represents an instance of `
|
|
12
|
+
* Represents an instance of `ItemLayout`, backed by a C++ struct.
|
|
13
13
|
*/
|
|
14
|
-
public typealias
|
|
14
|
+
public typealias ItemLayout = margelo.nitro.nitrolist.ItemLayout
|
|
15
15
|
|
|
16
|
-
public extension
|
|
16
|
+
public extension ItemLayout {
|
|
17
17
|
private typealias bridge = margelo.nitro.nitrolist.bridge.swift
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Create a new instance of `
|
|
20
|
+
* Create a new instance of `ItemLayout`.
|
|
21
21
|
*/
|
|
22
22
|
init(x: Double, y: Double, width: Double, height: Double) {
|
|
23
23
|
self.init(x, y, width, height)
|
package/nitrogen/generated/shared/c++/{HybridNitroLayoutEngineSpec.cpp → HybridNitroListSpec.cpp}
RENAMED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridNitroListSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "HybridNitroListSpec.hpp"
|
|
9
9
|
|
|
10
10
|
namespace margelo::nitro::nitrolist {
|
|
11
11
|
|
|
12
|
-
void
|
|
12
|
+
void HybridNitroListSpec::loadHybridMethods() {
|
|
13
13
|
// load base methods/properties
|
|
14
14
|
HybridObject::loadHybridMethods();
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridMethod("computeLayout", &
|
|
17
|
+
prototype.registerHybridMethod("computeLayout", &HybridNitroListSpec::computeLayout);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
package/nitrogen/generated/shared/c++/{HybridNitroLayoutEngineSpec.hpp → HybridNitroListSpec.hpp}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridNitroListSpec.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
-
// Forward declaration of `
|
|
17
|
-
namespace margelo::nitro::nitrolist { struct
|
|
16
|
+
// Forward declaration of `ItemLayout` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrolist { struct ItemLayout; }
|
|
18
18
|
|
|
19
|
-
#include "
|
|
19
|
+
#include "ItemLayout.hpp"
|
|
20
20
|
#include <vector>
|
|
21
21
|
|
|
22
22
|
namespace margelo::nitro::nitrolist {
|
|
@@ -24,25 +24,25 @@ namespace margelo::nitro::nitrolist {
|
|
|
24
24
|
using namespace margelo::nitro;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* An abstract base class for `
|
|
28
|
-
* Inherit this class to create instances of `
|
|
27
|
+
* An abstract base class for `NitroList`
|
|
28
|
+
* Inherit this class to create instances of `HybridNitroListSpec` in C++.
|
|
29
29
|
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
30
30
|
* @example
|
|
31
31
|
* ```cpp
|
|
32
|
-
* class
|
|
32
|
+
* class HybridNitroList: public HybridNitroListSpec {
|
|
33
33
|
* public:
|
|
34
|
-
*
|
|
34
|
+
* HybridNitroList(...): HybridObject(TAG) { ... }
|
|
35
35
|
* // ...
|
|
36
36
|
* };
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
class
|
|
39
|
+
class HybridNitroListSpec: public virtual HybridObject {
|
|
40
40
|
public:
|
|
41
41
|
// Constructor
|
|
42
|
-
explicit
|
|
42
|
+
explicit HybridNitroListSpec(): HybridObject(TAG) { }
|
|
43
43
|
|
|
44
44
|
// Destructor
|
|
45
|
-
~
|
|
45
|
+
~HybridNitroListSpec() override = default;
|
|
46
46
|
|
|
47
47
|
public:
|
|
48
48
|
// Properties
|
|
@@ -50,7 +50,7 @@ namespace margelo::nitro::nitrolist {
|
|
|
50
50
|
|
|
51
51
|
public:
|
|
52
52
|
// Methods
|
|
53
|
-
virtual std::vector<
|
|
53
|
+
virtual std::vector<ItemLayout> computeLayout(double containerWidth, const std::vector<double>& itemHeights) = 0;
|
|
54
54
|
|
|
55
55
|
protected:
|
|
56
56
|
// Hybrid Setup
|
|
@@ -58,7 +58,7 @@ namespace margelo::nitro::nitrolist {
|
|
|
58
58
|
|
|
59
59
|
protected:
|
|
60
60
|
// Tag for logging
|
|
61
|
-
static constexpr auto TAG = "
|
|
61
|
+
static constexpr auto TAG = "NitroList";
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
} // namespace margelo::nitro::nitrolist
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// ItemLayout.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
namespace margelo::nitro::nitrolist {
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* A struct which can be represented as a JavaScript object (
|
|
38
|
+
* A struct which can be represented as a JavaScript object (ItemLayout).
|
|
39
39
|
*/
|
|
40
|
-
struct
|
|
40
|
+
struct ItemLayout final {
|
|
41
41
|
public:
|
|
42
42
|
double x SWIFT_PRIVATE;
|
|
43
43
|
double y SWIFT_PRIVATE;
|
|
@@ -45,30 +45,30 @@ namespace margelo::nitro::nitrolist {
|
|
|
45
45
|
double height SWIFT_PRIVATE;
|
|
46
46
|
|
|
47
47
|
public:
|
|
48
|
-
|
|
49
|
-
explicit
|
|
48
|
+
ItemLayout() = default;
|
|
49
|
+
explicit ItemLayout(double x, double y, double width, double height): x(x), y(y), width(width), height(height) {}
|
|
50
50
|
|
|
51
51
|
public:
|
|
52
|
-
friend bool operator==(const
|
|
52
|
+
friend bool operator==(const ItemLayout& lhs, const ItemLayout& rhs) = default;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
} // namespace margelo::nitro::nitrolist
|
|
56
56
|
|
|
57
57
|
namespace margelo::nitro {
|
|
58
58
|
|
|
59
|
-
// C++
|
|
59
|
+
// C++ ItemLayout <> JS ItemLayout (object)
|
|
60
60
|
template <>
|
|
61
|
-
struct JSIConverter<margelo::nitro::nitrolist::
|
|
62
|
-
static inline margelo::nitro::nitrolist::
|
|
61
|
+
struct JSIConverter<margelo::nitro::nitrolist::ItemLayout> final {
|
|
62
|
+
static inline margelo::nitro::nitrolist::ItemLayout fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
63
|
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
-
return margelo::nitro::nitrolist::
|
|
64
|
+
return margelo::nitro::nitrolist::ItemLayout(
|
|
65
65
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "x"))),
|
|
66
66
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "y"))),
|
|
67
67
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
|
|
68
68
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrolist::
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrolist::ItemLayout& arg) {
|
|
72
72
|
jsi::Object obj(runtime);
|
|
73
73
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "x"), JSIConverter<double>::toJSI(runtime, arg.x));
|
|
74
74
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "y"), JSIConverter<double>::toJSI(runtime, arg.y));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-list",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "High-performance list for React Native powered by Nitro",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
7
7
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"workspaces": [
|
|
46
46
|
"example"
|
|
47
47
|
],
|
|
48
|
-
"repository": "https://github.com/
|
|
48
|
+
"repository": "https://github.com/pythonsst/nitro-list",
|
|
49
49
|
"author": "Shiv Shankar Tiwari",
|
|
50
50
|
"license": "MIT",
|
|
51
|
-
"bugs": "https://github.com/
|
|
52
|
-
"homepage": "https://github.com/
|
|
51
|
+
"bugs": "https://github.com/pythonsst/nitro-list/issues",
|
|
52
|
+
"homepage": "https://github.com/pythonsst/nitro-list#readme",
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public",
|
|
55
55
|
"registry": "https://registry.npmjs.org/"
|
package/src/cell/Cell.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
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
|
|
|
9
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Logical data index currently bound.
|
|
14
|
+
* Changes as the cell is recycled.
|
|
15
|
+
*/
|
|
10
16
|
index: number
|
|
11
17
|
|
|
12
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Compatibility type (row, header, etc).
|
|
20
|
+
* Determines reuse eligibility.
|
|
21
|
+
*/
|
|
13
22
|
readonly type: string
|
|
14
23
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CellKey } from '../types/CellKey'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Monotonic key generator for physical cell instances.
|
|
5
|
+
* Guarantees stable keys across the lifetime of the list.
|
|
6
|
+
*/
|
|
7
|
+
export class CellKeyGenerator {
|
|
8
|
+
private nextId = 0
|
|
9
|
+
|
|
10
|
+
next(): CellKey {
|
|
11
|
+
return this.nextId++
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
reset(): void {
|
|
15
|
+
this.nextId = 0
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/cell/CellRecycler.ts
CHANGED
|
@@ -1,66 +1,76 @@
|
|
|
1
1
|
import type { Cell } from './Cell'
|
|
2
|
-
|
|
3
|
-
const MAX_CELLS = 40
|
|
2
|
+
import { createCell } from './createCell'
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* FlashList equivalent: CellRecycler
|
|
5
|
+
* Manages physical cell reuse.
|
|
6
|
+
* Imperative and stateful by design.
|
|
7
|
+
* This is NOT React code.
|
|
10
8
|
*/
|
|
11
9
|
export class CellRecycler {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private
|
|
10
|
+
/**
|
|
11
|
+
* Active cells mapped by logical index.
|
|
12
|
+
*/
|
|
13
|
+
private readonly indexToCell = new Map<number, Cell>()
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Pool of detached reusable cells.
|
|
17
|
+
*/
|
|
18
|
+
private readonly recycledCells: Cell[] = []
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
|
-
* Reconcile
|
|
19
|
-
*
|
|
21
|
+
* Reconcile a contiguous visible index range
|
|
22
|
+
* into a stable list of physical cells.
|
|
23
|
+
*
|
|
24
|
+
* HOT PATH:
|
|
25
|
+
* - No index arrays
|
|
26
|
+
* - Minimal allocations
|
|
27
|
+
* - Deterministic
|
|
20
28
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
reconcileRange(
|
|
30
|
+
startIndex: number,
|
|
31
|
+
endIndex: number,
|
|
32
|
+
resolveCellType: (index: number) => string
|
|
24
33
|
): readonly Cell[] {
|
|
25
|
-
const
|
|
34
|
+
const nextActive: Cell[] = []
|
|
26
35
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
if (visibleSet.has(index)) continue
|
|
36
|
+
// Track which current indices are no longer visible
|
|
37
|
+
const unusedIndices = new Set(this.indexToCell.keys())
|
|
30
38
|
|
|
31
|
-
|
|
39
|
+
for (let index = startIndex; index <= endIndex; index++) {
|
|
40
|
+
unusedIndices.delete(index)
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
42
|
+
let cell = this.indexToCell.get(index)
|
|
43
|
+
if (cell) {
|
|
44
|
+
// Existing assignment — reuse
|
|
45
|
+
nextActive.push(cell)
|
|
46
|
+
continue
|
|
36
47
|
}
|
|
37
48
|
|
|
38
|
-
const
|
|
39
|
-
if (pool.length < MAX_CELLS) pool.push(cell)
|
|
40
|
-
this.reusableCellsByType.set(cell.type, pool)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 2️⃣ Acquire cells for newly visible indices
|
|
44
|
-
for (const index of visibleIndices) {
|
|
45
|
-
if (this.activeCells.has(index)) continue
|
|
49
|
+
const type = resolveCellType(index)
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
51
|
+
// Try to reuse a recycled cell of same type
|
|
52
|
+
const recycledIdx = this.recycledCells.findIndex(
|
|
53
|
+
c => c.type === type
|
|
54
|
+
)
|
|
50
55
|
|
|
51
|
-
if (
|
|
52
|
-
cell =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
index,
|
|
56
|
-
}
|
|
56
|
+
if (recycledIdx !== -1) {
|
|
57
|
+
cell = this.recycledCells.splice(recycledIdx, 1)[0]!
|
|
58
|
+
} else {
|
|
59
|
+
cell = createCell(type)
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
cell.index = index
|
|
60
|
-
this.
|
|
61
|
-
|
|
63
|
+
this.indexToCell.set(index, cell)
|
|
64
|
+
nextActive.push(cell)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Recycle cells that left the visible window
|
|
68
|
+
for (const index of unusedIndices) {
|
|
69
|
+
const cell = this.indexToCell.get(index)!
|
|
70
|
+
this.indexToCell.delete(index)
|
|
71
|
+
this.recycledCells.push(cell)
|
|
62
72
|
}
|
|
63
73
|
|
|
64
|
-
return
|
|
74
|
+
return nextActive
|
|
65
75
|
}
|
|
66
76
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Cell } from './Cell'
|
|
2
|
+
|
|
3
|
+
let nextCellId = 0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new physical cell with a stable identity.
|
|
7
|
+
* The key is generated ONCE and never changes.
|
|
8
|
+
*/
|
|
9
|
+
export function createCell(type: string): Cell {
|
|
10
|
+
return {
|
|
11
|
+
key: `cell-${nextCellId++}`, // stable physical identity
|
|
12
|
+
type,
|
|
13
|
+
index: -1, // assigned by recycler
|
|
14
|
+
}
|
|
15
|
+
}
|