react-native-nitro-list 0.0.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +28 -15
- package/lib/commonjs/NitroList.js +9 -0
- package/lib/commonjs/NitroList.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/CellKeyGenerator.js +21 -0
- package/lib/commonjs/cell/CellKeyGenerator.js.map +1 -0
- package/lib/commonjs/cell/CellRecycler.js +70 -0
- package/lib/commonjs/cell/CellRecycler.js.map +1 -0
- 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/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/usePersistentCallback.js +36 -0
- package/lib/commonjs/hooks/usePersistentCallback.js.map +1 -0
- package/lib/commonjs/index.js +7 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layout/MutableLinearLayout.js +104 -0
- package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -0
- 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 +2 -0
- package/lib/commonjs/{specs/nitro-list.nitro.js.map → layout/index.js.map} +1 -1
- 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/{specs/nitro-list.nitro.js → native/NitroList.types.js} +1 -1
- 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/recycler/CellPool.js +46 -0
- package/lib/commonjs/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/recycler/RecyclerList.js +224 -0
- package/lib/commonjs/recycler/RecyclerList.js.map +1 -0
- package/lib/commonjs/specs/nitro-layout-engine.nitro.js +6 -0
- package/lib/commonjs/specs/nitro-layout-engine.nitro.js.map +1 -0
- package/lib/commonjs/types/Axis.js +2 -0
- package/lib/commonjs/types/Axis.js.map +1 -0
- package/lib/commonjs/types/CellKey.js +2 -0
- package/lib/commonjs/types/CellKey.js.map +1 -0
- package/lib/commonjs/types/CellType.js +2 -0
- package/lib/commonjs/types/CellType.js.map +1 -0
- package/lib/commonjs/types/VisibleRange.js +2 -0
- package/lib/commonjs/types/VisibleRange.js.map +1 -0
- package/lib/commonjs/types/VisibleRangeInput.js +6 -0
- package/lib/commonjs/types/VisibleRangeInput.js.map +1 -0
- package/lib/commonjs/types/index.js +13 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/layout/LayoutRect.js +2 -0
- package/lib/commonjs/types/layout/LayoutRect.js.map +1 -0
- package/lib/commonjs/types/layout/LinearLayoutInput.js +6 -0
- package/lib/commonjs/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js +26 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/commonjs/types/layout/index.js +2 -0
- package/lib/commonjs/types/layout/index.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerCellInstance.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerCellInstance.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerListProps.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerListProps.js.map +1 -0
- package/lib/commonjs/types/recycler/index.js +2 -0
- package/lib/commonjs/types/recycler/index.js.map +1 -0
- package/lib/commonjs/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/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/windowing/ScrollMetrics.js +2 -0
- package/lib/commonjs/windowing/ScrollMetrics.js.map +1 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js +71 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/commonjs/windowing/index.js +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/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/CellKeyGenerator.js +16 -0
- package/lib/module/cell/CellKeyGenerator.js.map +1 -0
- package/lib/module/cell/CellRecycler.js +66 -0
- package/lib/module/cell/CellRecycler.js.map +1 -0
- 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/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/usePersistentCallback.js +33 -0
- package/lib/module/hooks/usePersistentCallback.js.map +1 -0
- package/lib/module/index.js +1 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/MutableLinearLayout.js +100 -0
- package/lib/module/layout/MutableLinearLayout.js.map +1 -0
- 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 +2 -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/recycler/CellPool.js +41 -0
- package/lib/module/recycler/CellPool.js.map +1 -0
- package/lib/module/recycler/RecyclerList.js +221 -0
- package/lib/module/recycler/RecyclerList.js.map +1 -0
- package/lib/module/specs/nitro-layout-engine.nitro.js +4 -0
- package/lib/module/specs/nitro-layout-engine.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 +2 -0
- package/lib/module/types/CellType.js.map +1 -0
- package/lib/module/types/VisibleRange.js +2 -0
- package/lib/module/types/VisibleRange.js.map +1 -0
- package/lib/module/types/VisibleRangeInput.js +4 -0
- package/lib/module/types/VisibleRangeInput.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/layout/LayoutRect.js +2 -0
- package/lib/module/types/layout/LayoutRect.js.map +1 -0
- package/lib/module/types/layout/LinearLayoutInput.js +4 -0
- package/lib/module/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/module/types/layout/MainAxisPadding.js +22 -0
- package/lib/module/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/module/types/layout/index.js +2 -0
- package/lib/module/types/layout/index.js.map +1 -0
- package/lib/module/types/recycler/RecyclerCellInstance.js +4 -0
- package/lib/module/types/recycler/RecyclerCellInstance.js.map +1 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js +4 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/module/types/recycler/RecyclerListProps.js +4 -0
- package/lib/module/types/recycler/RecyclerListProps.js.map +1 -0
- package/lib/module/types/recycler/index.js +2 -0
- package/lib/module/types/recycler/index.js.map +1 -0
- package/lib/module/types/scroll/ScrollMetrics.js +4 -0
- package/lib/module/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/module/types/scroll/index.js +2 -0
- package/lib/module/types/scroll/index.js.map +1 -0
- package/lib/module/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/windowing/ScrollMetrics.js +2 -0
- package/lib/module/windowing/ScrollMetrics.js.map +1 -0
- package/lib/module/windowing/computeVisibleItemRange.js +67 -0
- package/lib/module/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/module/windowing/index.js +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/ReusableView.d.ts +9 -0
- package/lib/typescript/src/ReusableView.d.ts.map +1 -0
- package/lib/typescript/src/cell/Cell.d.ts +22 -0
- package/lib/typescript/src/cell/Cell.d.ts.map +1 -0
- 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 +27 -0
- package/lib/typescript/src/cell/CellRecycler.d.ts.map +1 -0
- 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/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/usePersistentCallback.d.ts +16 -0
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts +54 -0
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts.map +1 -0
- 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 +2 -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/recycler/CellPool.d.ts +14 -0
- package/lib/typescript/src/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/recycler/RecyclerList.d.ts +4 -0
- package/lib/typescript/src/recycler/RecyclerList.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +14 -0
- package/lib/typescript/src/specs/nitro-layout-engine.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 +10 -0
- package/lib/typescript/src/types/CellKey.d.ts.map +1 -0
- package/lib/typescript/src/types/CellType.d.ts +11 -0
- package/lib/typescript/src/types/CellType.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRange.d.ts +10 -0
- package/lib/typescript/src/types/VisibleRange.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts +35 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +8 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts +15 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts +10 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts +20 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/index.d.ts +4 -0
- package/lib/typescript/src/types/layout/index.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts +37 -0
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts +8 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts +66 -0
- package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/index.d.ts +4 -0
- package/lib/typescript/src/types/recycler/index.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts +15 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/index.d.ts +2 -0
- package/lib/typescript/src/types/scroll/index.d.ts.map +1 -0
- package/lib/typescript/src/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/windowing/ScrollMetrics.d.ts +11 -0
- package/lib/typescript/src/windowing/ScrollMetrics.d.ts.map +1 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts +15 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts.map +1 -0
- package/lib/typescript/src/windowing/index.d.ts +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++/JLayoutRect.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/LayoutRect.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/LayoutRect.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++/LayoutRect.hpp +95 -0
- package/package.json +12 -4
- package/src/NitroList.ts +8 -0
- package/src/ReusableView.ts +12 -0
- package/src/cell/Cell.ts +23 -0
- package/src/cell/CellKeyGenerator.ts +17 -0
- package/src/cell/CellRecycler.ts +76 -0
- package/src/cell/createCell.ts +15 -0
- package/src/cell/index.ts +5 -0
- package/src/debug/useDebugOverlay.ts +14 -0
- package/src/getVisibleIndices.ts +55 -0
- package/src/hooks/usePersistentCallback.ts +37 -0
- package/src/index.ts +1 -14
- package/src/layout/MutableLinearLayout.ts +112 -0
- package/src/layout/constants/layoutDefaults.ts +12 -0
- package/src/layout/index.ts +1 -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 +13 -0
- package/src/native/NitroRecyclerView.ts +8 -0
- package/src/prefetch/PrefetchHelper.ts +47 -0
- package/src/recycler/CellPool.ts +47 -0
- package/src/recycler/RecyclerList.tsx +304 -0
- package/src/specs/nitro-layout-engine.nitro.ts +17 -0
- package/src/types/Axis.ts +10 -0
- package/src/types/CellKey.ts +9 -0
- package/src/types/CellType.ts +10 -0
- package/src/types/VisibleRange.ts +9 -0
- package/src/types/VisibleRangeInput.ts +39 -0
- package/src/types/index.ts +15 -0
- package/src/types/layout/LayoutRect.ts +14 -0
- package/src/types/layout/LinearLayoutInput.ts +12 -0
- package/src/types/layout/MainAxisPadding.ts +23 -0
- package/src/types/layout/index.ts +3 -0
- package/src/types/recycler/RecyclerCellInstance.ts +40 -0
- package/src/types/recycler/RecyclerItemRenderer.ts +8 -0
- package/src/types/recycler/RecyclerListProps.ts +74 -0
- package/src/types/recycler/index.ts +3 -0
- package/src/types/scroll/ScrollMetrics.ts +18 -0
- package/src/types/scroll/index.ts +1 -0
- package/src/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/windowing/ScrollMetrics.ts +11 -0
- package/src/windowing/computeVisibleItemRange.ts +78 -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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridNitroLayoutEngineSpec_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 HybridNitroLayoutEngineSpec 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 HybridNitroLayoutEngineSpec_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 HybridNitroListSpec_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 `HybridNitroLayoutEngineSpec` Swift protocol.
|
|
30
30
|
*/
|
|
31
|
-
private var __implementation: any
|
|
31
|
+
private var __implementation: any HybridNitroLayoutEngineSpec
|
|
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_HybridNitroLayoutEngineSpec_
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Create a new `
|
|
39
|
+
* Create a new `HybridNitroLayoutEngineSpec_cxx` that wraps the given `HybridNitroLayoutEngineSpec`.
|
|
40
40
|
* All properties and methods bridge to C++ types.
|
|
41
41
|
*/
|
|
42
|
-
public init(_ implementation: any
|
|
42
|
+
public init(_ implementation: any HybridNitroLayoutEngineSpec) {
|
|
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 `HybridNitroLayoutEngineSpec` instance this class wraps.
|
|
50
50
|
*/
|
|
51
51
|
@inline(__always)
|
|
52
|
-
public func
|
|
52
|
+
public func getHybridNitroLayoutEngineSpec() -> any HybridNitroLayoutEngineSpec {
|
|
53
53
|
return __implementation
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -62,25 +62,25 @@ open class HybridNitroListSpec_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 `HybridNitroLayoutEngineSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridNitroLayoutEngineSpec_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) -> HybridNitroLayoutEngineSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridNitroLayoutEngineSpec_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<HybridNitroLayoutEngineSpec>`.
|
|
76
76
|
*/
|
|
77
|
-
public func getCxxPart() -> bridge.
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroLayoutEngineSpec_ {
|
|
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_HybridNitroLayoutEngineSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridNitroLayoutEngineSpec_(newCxxPart)
|
|
84
84
|
return newCxxPart
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -114,27 +114,24 @@ open class HybridNitroListSpec_cxx {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
// Properties
|
|
117
|
-
|
|
118
|
-
@inline(__always)
|
|
119
|
-
get {
|
|
120
|
-
return self.__implementation.isRed
|
|
121
|
-
}
|
|
122
|
-
@inline(__always)
|
|
123
|
-
set {
|
|
124
|
-
self.__implementation.isRed = newValue
|
|
125
|
-
}
|
|
126
|
-
}
|
|
117
|
+
|
|
127
118
|
|
|
128
119
|
// Methods
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
120
|
+
@inline(__always)
|
|
121
|
+
public final func computeLayout(containerWidth: Double, itemHeights: bridge.std__vector_double_) -> bridge.Result_std__vector_LayoutRect__ {
|
|
122
|
+
do {
|
|
123
|
+
let __result = try self.__implementation.computeLayout(containerWidth: containerWidth, itemHeights: itemHeights.map({ __item in __item }))
|
|
124
|
+
let __resultCpp = { () -> bridge.std__vector_LayoutRect_ in
|
|
125
|
+
var __vector = bridge.create_std__vector_LayoutRect_(__result.count)
|
|
126
|
+
for __item in __result {
|
|
127
|
+
__vector.push_back(__item)
|
|
128
|
+
}
|
|
129
|
+
return __vector
|
|
130
|
+
}()
|
|
131
|
+
return bridge.create_Result_std__vector_LayoutRect__(__resultCpp)
|
|
132
|
+
} catch (let __error) {
|
|
133
|
+
let __exceptionPtr = __error.toCpp()
|
|
134
|
+
return bridge.create_Result_std__vector_LayoutRect__(__exceptionPtr)
|
|
135
|
+
}
|
|
139
136
|
}
|
|
140
137
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LayoutRect.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
|
+
/**
|
|
12
|
+
* Represents an instance of `LayoutRect`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias LayoutRect = margelo.nitro.nitrolist.LayoutRect
|
|
15
|
+
|
|
16
|
+
public extension LayoutRect {
|
|
17
|
+
private typealias bridge = margelo.nitro.nitrolist.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `LayoutRect`.
|
|
21
|
+
*/
|
|
22
|
+
init(x: Double, y: Double, width: Double, height: Double) {
|
|
23
|
+
self.init(x, y, width, height)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@inline(__always)
|
|
27
|
+
var x: Double {
|
|
28
|
+
return self.__x
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var y: Double {
|
|
33
|
+
return self.__y
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@inline(__always)
|
|
37
|
+
var width: Double {
|
|
38
|
+
return self.__width
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@inline(__always)
|
|
42
|
+
var height: Double {
|
|
43
|
+
return self.__height
|
|
44
|
+
}
|
|
45
|
+
}
|
package/nitrogen/generated/shared/c++/{HybridNitroListSpec.cpp → HybridNitroLayoutEngineSpec.cpp}
RENAMED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridNitroLayoutEngineSpec.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 "HybridNitroLayoutEngineSpec.hpp"
|
|
9
9
|
|
|
10
10
|
namespace margelo::nitro::nitrolist {
|
|
11
11
|
|
|
12
|
-
void
|
|
12
|
+
void HybridNitroLayoutEngineSpec::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.
|
|
18
|
-
prototype.registerHybridSetter("isRed", &HybridNitroListSpec::setIsRed);
|
|
17
|
+
prototype.registerHybridMethod("computeLayout", &HybridNitroLayoutEngineSpec::computeLayout);
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
|
package/nitrogen/generated/shared/c++/{HybridNitroListSpec.hpp → HybridNitroLayoutEngineSpec.hpp}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridNitroLayoutEngineSpec.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,43 +13,44 @@
|
|
|
13
13
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
+
// Forward declaration of `LayoutRect` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrolist { struct LayoutRect; }
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
#include "LayoutRect.hpp"
|
|
20
|
+
#include <vector>
|
|
19
21
|
|
|
20
22
|
namespace margelo::nitro::nitrolist {
|
|
21
23
|
|
|
22
24
|
using namespace margelo::nitro;
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
|
-
* An abstract base class for `
|
|
26
|
-
* Inherit this class to create instances of `
|
|
27
|
+
* An abstract base class for `NitroLayoutEngine`
|
|
28
|
+
* Inherit this class to create instances of `HybridNitroLayoutEngineSpec` in C++.
|
|
27
29
|
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
28
30
|
* @example
|
|
29
31
|
* ```cpp
|
|
30
|
-
* class
|
|
32
|
+
* class HybridNitroLayoutEngine: public HybridNitroLayoutEngineSpec {
|
|
31
33
|
* public:
|
|
32
|
-
*
|
|
34
|
+
* HybridNitroLayoutEngine(...): HybridObject(TAG) { ... }
|
|
33
35
|
* // ...
|
|
34
36
|
* };
|
|
35
37
|
* ```
|
|
36
38
|
*/
|
|
37
|
-
class
|
|
39
|
+
class HybridNitroLayoutEngineSpec: public virtual HybridObject {
|
|
38
40
|
public:
|
|
39
41
|
// Constructor
|
|
40
|
-
explicit
|
|
42
|
+
explicit HybridNitroLayoutEngineSpec(): HybridObject(TAG) { }
|
|
41
43
|
|
|
42
44
|
// Destructor
|
|
43
|
-
~
|
|
45
|
+
~HybridNitroLayoutEngineSpec() override = default;
|
|
44
46
|
|
|
45
47
|
public:
|
|
46
48
|
// Properties
|
|
47
|
-
|
|
48
|
-
virtual void setIsRed(bool isRed) = 0;
|
|
49
|
+
|
|
49
50
|
|
|
50
51
|
public:
|
|
51
52
|
// Methods
|
|
52
|
-
|
|
53
|
+
virtual std::vector<LayoutRect> computeLayout(double containerWidth, const std::vector<double>& itemHeights) = 0;
|
|
53
54
|
|
|
54
55
|
protected:
|
|
55
56
|
// Hybrid Setup
|
|
@@ -57,7 +58,7 @@ namespace margelo::nitro::nitrolist {
|
|
|
57
58
|
|
|
58
59
|
protected:
|
|
59
60
|
// Tag for logging
|
|
60
|
-
static constexpr auto TAG = "
|
|
61
|
+
static constexpr auto TAG = "NitroLayoutEngine";
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
} // namespace margelo::nitro::nitrolist
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LayoutRect.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::nitrolist {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (LayoutRect).
|
|
39
|
+
*/
|
|
40
|
+
struct LayoutRect final {
|
|
41
|
+
public:
|
|
42
|
+
double x SWIFT_PRIVATE;
|
|
43
|
+
double y SWIFT_PRIVATE;
|
|
44
|
+
double width SWIFT_PRIVATE;
|
|
45
|
+
double height SWIFT_PRIVATE;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
LayoutRect() = default;
|
|
49
|
+
explicit LayoutRect(double x, double y, double width, double height): x(x), y(y), width(width), height(height) {}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
friend bool operator==(const LayoutRect& lhs, const LayoutRect& rhs) = default;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace margelo::nitro::nitrolist
|
|
56
|
+
|
|
57
|
+
namespace margelo::nitro {
|
|
58
|
+
|
|
59
|
+
// C++ LayoutRect <> JS LayoutRect (object)
|
|
60
|
+
template <>
|
|
61
|
+
struct JSIConverter<margelo::nitro::nitrolist::LayoutRect> final {
|
|
62
|
+
static inline margelo::nitro::nitrolist::LayoutRect fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
+
return margelo::nitro::nitrolist::LayoutRect(
|
|
65
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "x"))),
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "y"))),
|
|
67
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrolist::LayoutRect& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "x"), JSIConverter<double>::toJSI(runtime, arg.x));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "y"), JSIConverter<double>::toJSI(runtime, arg.y));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
|
|
77
|
+
return obj;
|
|
78
|
+
}
|
|
79
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
80
|
+
if (!value.isObject()) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
jsi::Object obj = value.getObject(runtime);
|
|
84
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "x")))) return false;
|
|
88
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "y")))) return false;
|
|
89
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
|
|
90
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-list",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "react-native-nitro-list is a react native package built with Nitro",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"react-native": "src/index",
|
|
9
9
|
"source": "src/index",
|
|
10
10
|
"scripts": {
|
|
11
|
+
"publish:release": "./scripts/publish.sh",
|
|
12
|
+
"test": "npx jest --passWithNoTests",
|
|
13
|
+
"test:watch": "npx jest --watch",
|
|
11
14
|
"typecheck": "tsc --noEmit",
|
|
12
15
|
"clean": "git clean -dfX",
|
|
13
16
|
"release": "semantic-release",
|
|
@@ -57,12 +60,14 @@
|
|
|
57
60
|
"@semantic-release/git": "^10.0.1",
|
|
58
61
|
"@types/jest": "^29.5.12",
|
|
59
62
|
"@types/react": "19.2.0",
|
|
60
|
-
"
|
|
63
|
+
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
64
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
65
|
+
"nitrogen": "^0.32.0",
|
|
61
66
|
"react": "19.2.0",
|
|
62
67
|
"react-native": "0.83",
|
|
63
68
|
"react-native-builder-bob": "^0.40.17",
|
|
64
69
|
"react-native-nitro-modules": "0.32.0",
|
|
65
|
-
"
|
|
70
|
+
"react-test-renderer": "^19.2.0",
|
|
66
71
|
"semantic-release": "^25.0.2",
|
|
67
72
|
"typescript": "^5.8.3"
|
|
68
73
|
},
|
|
@@ -118,5 +123,8 @@
|
|
|
118
123
|
}
|
|
119
124
|
]
|
|
120
125
|
]
|
|
126
|
+
},
|
|
127
|
+
"dependencies": {
|
|
128
|
+
"nitro-modules": "^0.1.1"
|
|
121
129
|
}
|
|
122
|
-
}
|
|
130
|
+
}
|
package/src/NitroList.ts
ADDED
package/src/cell/Cell.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Physical reusable cell.
|
|
3
|
+
* Represents a single mounted view instance.
|
|
4
|
+
*/
|
|
5
|
+
export interface Cell {
|
|
6
|
+
/**
|
|
7
|
+
* Stable physical identity.
|
|
8
|
+
* Used as React key. NEVER changes.
|
|
9
|
+
*/
|
|
10
|
+
readonly key: string
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Logical data index currently bound.
|
|
14
|
+
* Changes as the cell is recycled.
|
|
15
|
+
*/
|
|
16
|
+
index: number
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Compatibility type (row, header, etc).
|
|
20
|
+
* Determines reuse eligibility.
|
|
21
|
+
*/
|
|
22
|
+
readonly type: string
|
|
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
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Cell } from './Cell'
|
|
2
|
+
import { createCell } from './createCell'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Manages physical cell reuse.
|
|
6
|
+
* Imperative and stateful by design.
|
|
7
|
+
* This is NOT React code.
|
|
8
|
+
*/
|
|
9
|
+
export class CellRecycler {
|
|
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[] = []
|
|
19
|
+
|
|
20
|
+
/**
|
|
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
|
|
28
|
+
*/
|
|
29
|
+
reconcileRange(
|
|
30
|
+
startIndex: number,
|
|
31
|
+
endIndex: number,
|
|
32
|
+
resolveCellType: (index: number) => string
|
|
33
|
+
): readonly Cell[] {
|
|
34
|
+
const nextActive: Cell[] = []
|
|
35
|
+
|
|
36
|
+
// Track which current indices are no longer visible
|
|
37
|
+
const unusedIndices = new Set(this.indexToCell.keys())
|
|
38
|
+
|
|
39
|
+
for (let index = startIndex; index <= endIndex; index++) {
|
|
40
|
+
unusedIndices.delete(index)
|
|
41
|
+
|
|
42
|
+
let cell = this.indexToCell.get(index)
|
|
43
|
+
if (cell) {
|
|
44
|
+
// Existing assignment — reuse
|
|
45
|
+
nextActive.push(cell)
|
|
46
|
+
continue
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const type = resolveCellType(index)
|
|
50
|
+
|
|
51
|
+
// Try to reuse a recycled cell of same type
|
|
52
|
+
const recycledIdx = this.recycledCells.findIndex(
|
|
53
|
+
c => c.type === type
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if (recycledIdx !== -1) {
|
|
57
|
+
cell = this.recycledCells.splice(recycledIdx, 1)[0]!
|
|
58
|
+
} else {
|
|
59
|
+
cell = createCell(type)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
cell.index = index
|
|
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)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return nextActive
|
|
75
|
+
}
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
export function useDebugOverlay(
|
|
4
|
+
enabled: boolean,
|
|
5
|
+
visibleCount: number
|
|
6
|
+
): void {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (__DEV__ && enabled) {
|
|
9
|
+
console.log(
|
|
10
|
+
`[RecyclerList] visible items: ${visibleCount}`
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
}, [enabled, visibleCount])
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import type { LayoutRect } from './types/layout'
|
|
4
|
+
import type { ScrollMetrics } from './windowing/ScrollMetrics'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Binary-search based windowing.
|
|
8
|
+
* Returns indices intersecting viewport ± buffer.
|
|
9
|
+
*/
|
|
10
|
+
export function getVisibleRange(
|
|
11
|
+
layouts: readonly LayoutRect[],
|
|
12
|
+
metrics: ScrollMetrics,
|
|
13
|
+
bufferPx: number
|
|
14
|
+
): readonly number[] {
|
|
15
|
+
if (
|
|
16
|
+
layouts.length === 0 ||
|
|
17
|
+
metrics.height <= 0
|
|
18
|
+
) {
|
|
19
|
+
return []
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const startY = Math.max(
|
|
23
|
+
0,
|
|
24
|
+
metrics.offsetY - bufferPx
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const endY =
|
|
28
|
+
metrics.offsetY + metrics.height + bufferPx
|
|
29
|
+
|
|
30
|
+
let low = 0
|
|
31
|
+
let high = layouts.length - 1
|
|
32
|
+
let first = layouts.length
|
|
33
|
+
|
|
34
|
+
while (low <= high) {
|
|
35
|
+
const mid = (low + high) >> 1
|
|
36
|
+
const rect = layouts[mid]!
|
|
37
|
+
|
|
38
|
+
if (rect.y + rect.height >= startY) {
|
|
39
|
+
first = mid
|
|
40
|
+
high = mid - 1
|
|
41
|
+
} else {
|
|
42
|
+
low = mid + 1
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const visible: number[] = []
|
|
47
|
+
|
|
48
|
+
for (let i = first; i < layouts.length; i++) {
|
|
49
|
+
const rect = layouts[i]!
|
|
50
|
+
if (rect.y > endY) break
|
|
51
|
+
visible.push(i)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return visible
|
|
55
|
+
}
|