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,56 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// JHybridNitroListStateUpdater.cpp
|
|
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
|
-
#include "JHybridNitroListStateUpdater.hpp"
|
|
9
|
-
#include "views/HybridNitroListComponent.hpp"
|
|
10
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
11
|
-
|
|
12
|
-
namespace margelo::nitro::nitrolist::views {
|
|
13
|
-
|
|
14
|
-
using namespace facebook;
|
|
15
|
-
using ConcreteStateData = react::ConcreteState<HybridNitroListState>;
|
|
16
|
-
|
|
17
|
-
void JHybridNitroListStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
18
|
-
jni::alias_ref<JHybridNitroListSpec::javaobject> javaView,
|
|
19
|
-
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface) {
|
|
20
|
-
JHybridNitroListSpec* view = javaView->cthis();
|
|
21
|
-
|
|
22
|
-
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
23
|
-
jobject rawStateWrapper = stateWrapperInterface.get();
|
|
24
|
-
if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) {
|
|
25
|
-
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
26
|
-
}
|
|
27
|
-
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
28
|
-
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
|
|
29
|
-
|
|
30
|
-
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
|
|
31
|
-
auto concreteState = std::dynamic_pointer_cast<const ConcreteStateData>(state);
|
|
32
|
-
const HybridNitroListState& data = concreteState->getData();
|
|
33
|
-
const std::optional<HybridNitroListProps>& maybeProps = data.getProps();
|
|
34
|
-
if (!maybeProps.has_value()) {
|
|
35
|
-
// Props aren't set yet!
|
|
36
|
-
throw std::runtime_error("HybridNitroListState's data doesn't contain any props!");
|
|
37
|
-
}
|
|
38
|
-
const HybridNitroListProps& props = maybeProps.value();
|
|
39
|
-
if (props.isRed.isDirty) {
|
|
40
|
-
view->setIsRed(props.isRed.value);
|
|
41
|
-
// TODO: Set isDirty = false
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Update hybridRef if it changed
|
|
45
|
-
if (props.hybridRef.isDirty) {
|
|
46
|
-
// hybridRef changed - call it with new this
|
|
47
|
-
const auto& maybeFunc = props.hybridRef.value;
|
|
48
|
-
if (maybeFunc.has_value()) {
|
|
49
|
-
std::shared_ptr<JHybridNitroListSpec> shared = javaView->cthis()->shared_cast<JHybridNitroListSpec>();
|
|
50
|
-
maybeFunc.value()(shared);
|
|
51
|
-
}
|
|
52
|
-
// TODO: Set isDirty = false
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
} // namespace margelo::nitro::nitrolist::views
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// JHybridNitroListStateUpdater.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
|
-
#ifndef RN_SERIALIZABLE_STATE
|
|
11
|
-
#error NitroList was compiled without the 'RN_SERIALIZABLE_STATE' flag. This flag is required for Nitro Views - set it in your CMakeLists!
|
|
12
|
-
#endif
|
|
13
|
-
|
|
14
|
-
#include <fbjni/fbjni.h>
|
|
15
|
-
#include <react/fabric/StateWrapperImpl.h>
|
|
16
|
-
#include <react/fabric/CoreComponentsRegistry.h>
|
|
17
|
-
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
18
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
19
|
-
#include <NitroModules/JStateWrapper.hpp>
|
|
20
|
-
#include "JHybridNitroListSpec.hpp"
|
|
21
|
-
#include "views/HybridNitroListComponent.hpp"
|
|
22
|
-
|
|
23
|
-
namespace margelo::nitro::nitrolist::views {
|
|
24
|
-
|
|
25
|
-
using namespace facebook;
|
|
26
|
-
|
|
27
|
-
class JHybridNitroListStateUpdater: public jni::JavaClass<JHybridNitroListStateUpdater> {
|
|
28
|
-
public:
|
|
29
|
-
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrolist/views/HybridNitroListStateUpdater;";
|
|
30
|
-
|
|
31
|
-
public:
|
|
32
|
-
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
|
-
jni::alias_ref<JHybridNitroListSpec::javaobject> view,
|
|
34
|
-
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface);
|
|
35
|
-
|
|
36
|
-
public:
|
|
37
|
-
static void registerNatives() {
|
|
38
|
-
// Register JNI calls
|
|
39
|
-
javaClassStatic()->registerNatives({
|
|
40
|
-
makeNativeMethod("updateViewProps", JHybridNitroListStateUpdater::updateViewProps),
|
|
41
|
-
});
|
|
42
|
-
// Register React Native view component descriptor
|
|
43
|
-
auto provider = react::concreteComponentDescriptorProvider<HybridNitroListComponentDescriptor>();
|
|
44
|
-
auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry();
|
|
45
|
-
providerRegistry->add(provider);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
} // namespace margelo::nitro::nitrolist::views
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridNitroListManager.kt
|
|
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
|
-
package com.margelo.nitro.nitrolist.views
|
|
9
|
-
|
|
10
|
-
import android.view.View
|
|
11
|
-
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
12
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
13
|
-
import com.facebook.react.uimanager.StateWrapper
|
|
14
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
15
|
-
import com.nitrolist.*
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Represents the React Native `ViewManager` for the "NitroList" Nitro HybridView.
|
|
19
|
-
*/
|
|
20
|
-
open class HybridNitroListManager: SimpleViewManager<View>() {
|
|
21
|
-
private val views = hashMapOf<View, HybridNitroList>()
|
|
22
|
-
|
|
23
|
-
override fun getName(): String {
|
|
24
|
-
return "NitroList"
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
28
|
-
val hybridView = HybridNitroList(reactContext)
|
|
29
|
-
val view = hybridView.view
|
|
30
|
-
views[view] = hybridView
|
|
31
|
-
return view
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override fun onDropViewInstance(view: View) {
|
|
35
|
-
super.onDropViewInstance(view)
|
|
36
|
-
views.remove(view)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
40
|
-
val hybridView = views[view] ?: throw Error("Couldn't find view $view in local views table!")
|
|
41
|
-
|
|
42
|
-
// 1. Update each prop individually
|
|
43
|
-
hybridView.beforeUpdate()
|
|
44
|
-
HybridNitroListStateUpdater.updateViewProps(hybridView, stateWrapper)
|
|
45
|
-
hybridView.afterUpdate()
|
|
46
|
-
|
|
47
|
-
// 2. Continue in base View props
|
|
48
|
-
return super.updateState(view, props, stateWrapper)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridNitroListStateUpdater.kt
|
|
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
|
-
package com.margelo.nitro.nitrolist.views
|
|
9
|
-
|
|
10
|
-
import com.facebook.react.uimanager.StateWrapper
|
|
11
|
-
import com.margelo.nitro.nitrolist.*
|
|
12
|
-
|
|
13
|
-
internal class HybridNitroListStateUpdater {
|
|
14
|
-
companion object {
|
|
15
|
-
/**
|
|
16
|
-
* Updates the props for [view] through C++.
|
|
17
|
-
* The [state] prop is expected to contain [view]'s props as wrapped Fabric state.
|
|
18
|
-
*/
|
|
19
|
-
@Suppress("KotlinJniMissingFunction")
|
|
20
|
-
@JvmStatic
|
|
21
|
-
external fun updateViewProps(view: HybridNitroListSpec, state: StateWrapper)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// NitroListAutolinking.mm
|
|
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/Foundation.h>
|
|
9
|
-
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
-
#import "NitroList-Swift-Cxx-Umbrella.hpp"
|
|
11
|
-
#import <type_traits>
|
|
12
|
-
|
|
13
|
-
#include "HybridNitroListSpecSwift.hpp"
|
|
14
|
-
|
|
15
|
-
@interface NitroListAutolinking : NSObject
|
|
16
|
-
@end
|
|
17
|
-
|
|
18
|
-
@implementation NitroListAutolinking
|
|
19
|
-
|
|
20
|
-
+ (void) load {
|
|
21
|
-
using namespace margelo::nitro;
|
|
22
|
-
using namespace margelo::nitro::nitrolist;
|
|
23
|
-
|
|
24
|
-
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
-
"NitroList",
|
|
26
|
-
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
-
std::shared_ptr<HybridNitroListSpec> hybridObject = NitroList::NitroListAutolinking::createNitroList();
|
|
28
|
-
return hybridObject;
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// NitroListAutolinking.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
|
-
public final class NitroListAutolinking {
|
|
9
|
-
public typealias bridge = margelo.nitro.nitrolist.bridge.swift
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates an instance of a Swift class that implements `HybridNitroListSpec`,
|
|
13
|
-
* and wraps it in a Swift class that can directly interop with C++ (`HybridNitroListSpec_cxx`)
|
|
14
|
-
*
|
|
15
|
-
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
-
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridNitroList`).
|
|
17
|
-
*/
|
|
18
|
-
public static func createNitroList() -> bridge.std__shared_ptr_HybridNitroListSpec_ {
|
|
19
|
-
let hybridObject = HybridNitroList()
|
|
20
|
-
return { () -> bridge.std__shared_ptr_HybridNitroListSpec_ in
|
|
21
|
-
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
-
return __cxxWrapped.getCxxPart()
|
|
23
|
-
}()
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridNitroListSpecSwift.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
|
-
#include "HybridNitroListSpec.hpp"
|
|
11
|
-
|
|
12
|
-
// Forward declaration of `HybridNitroListSpec_cxx` to properly resolve imports.
|
|
13
|
-
namespace NitroList { class HybridNitroListSpec_cxx; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
#include "NitroList-Swift-Cxx-Umbrella.hpp"
|
|
20
|
-
|
|
21
|
-
namespace margelo::nitro::nitrolist {
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The C++ part of HybridNitroListSpec_cxx.swift.
|
|
25
|
-
*
|
|
26
|
-
* HybridNitroListSpecSwift (C++) accesses HybridNitroListSpec_cxx (Swift), and might
|
|
27
|
-
* contain some additional bridging code for C++ <> Swift interop.
|
|
28
|
-
*
|
|
29
|
-
* Since this obviously introduces an overhead, I hope at some point in
|
|
30
|
-
* the future, HybridNitroListSpec_cxx can directly inherit from the C++ class HybridNitroListSpec
|
|
31
|
-
* to simplify the whole structure and memory management.
|
|
32
|
-
*/
|
|
33
|
-
class HybridNitroListSpecSwift: public virtual HybridNitroListSpec {
|
|
34
|
-
public:
|
|
35
|
-
// Constructor from a Swift instance
|
|
36
|
-
explicit HybridNitroListSpecSwift(const NitroList::HybridNitroListSpec_cxx& swiftPart):
|
|
37
|
-
HybridObject(HybridNitroListSpec::TAG),
|
|
38
|
-
_swiftPart(swiftPart) { }
|
|
39
|
-
|
|
40
|
-
public:
|
|
41
|
-
// Get the Swift part
|
|
42
|
-
inline NitroList::HybridNitroListSpec_cxx& getSwiftPart() noexcept {
|
|
43
|
-
return _swiftPart;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public:
|
|
47
|
-
inline size_t getExternalMemorySize() noexcept override {
|
|
48
|
-
return _swiftPart.getMemorySize();
|
|
49
|
-
}
|
|
50
|
-
void dispose() noexcept override {
|
|
51
|
-
_swiftPart.dispose();
|
|
52
|
-
}
|
|
53
|
-
std::string toString() override {
|
|
54
|
-
return _swiftPart.toString();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public:
|
|
58
|
-
// Properties
|
|
59
|
-
inline bool getIsRed() noexcept override {
|
|
60
|
-
return _swiftPart.isRed();
|
|
61
|
-
}
|
|
62
|
-
inline void setIsRed(bool isRed) noexcept override {
|
|
63
|
-
_swiftPart.setIsRed(std::forward<decltype(isRed)>(isRed));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public:
|
|
67
|
-
// Methods
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
private:
|
|
71
|
-
NitroList::HybridNitroListSpec_cxx _swiftPart;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
} // namespace margelo::nitro::nitrolist
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridNitroListComponent.mm
|
|
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 "HybridNitroListComponent.hpp"
|
|
9
|
-
#import <memory>
|
|
10
|
-
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
11
|
-
#import <React/RCTViewComponentView.h>
|
|
12
|
-
#import <React/RCTComponentViewFactory.h>
|
|
13
|
-
#import <React/UIView+ComponentViewProtocol.h>
|
|
14
|
-
#import <NitroModules/NitroDefines.hpp>
|
|
15
|
-
#import <UIKit/UIKit.h>
|
|
16
|
-
|
|
17
|
-
#import "HybridNitroListSpecSwift.hpp"
|
|
18
|
-
#import "NitroList-Swift-Cxx-Umbrella.hpp"
|
|
19
|
-
|
|
20
|
-
using namespace facebook;
|
|
21
|
-
using namespace margelo::nitro::nitrolist;
|
|
22
|
-
using namespace margelo::nitro::nitrolist::views;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Represents the React Native View holder for the Nitro "NitroList" HybridView.
|
|
26
|
-
*/
|
|
27
|
-
@interface HybridNitroListComponent: RCTViewComponentView
|
|
28
|
-
@end
|
|
29
|
-
|
|
30
|
-
@implementation HybridNitroListComponent {
|
|
31
|
-
std::shared_ptr<HybridNitroListSpecSwift> _hybridView;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
+ (void) load {
|
|
35
|
-
[super load];
|
|
36
|
-
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridNitroListComponent class]];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
+ (react::ComponentDescriptorProvider) componentDescriptorProvider {
|
|
40
|
-
return react::concreteComponentDescriptorProvider<HybridNitroListComponentDescriptor>();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
- (instancetype) init {
|
|
44
|
-
if (self = [super init]) {
|
|
45
|
-
std::shared_ptr<HybridNitroListSpec> hybridView = NitroList::NitroListAutolinking::createNitroList();
|
|
46
|
-
_hybridView = std::dynamic_pointer_cast<HybridNitroListSpecSwift>(hybridView);
|
|
47
|
-
[self updateView];
|
|
48
|
-
}
|
|
49
|
-
return self;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
- (void) updateView {
|
|
53
|
-
// 1. Get Swift part
|
|
54
|
-
NitroList::HybridNitroListSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
55
|
-
|
|
56
|
-
// 2. Get UIView*
|
|
57
|
-
void* viewUnsafe = swiftPart.getView();
|
|
58
|
-
UIView* view = (__bridge_transfer UIView*) viewUnsafe;
|
|
59
|
-
|
|
60
|
-
// 3. Update RCTViewComponentView's [contentView]
|
|
61
|
-
[self setContentView:view];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
65
|
-
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
66
|
-
// 1. Downcast props
|
|
67
|
-
const auto& newViewPropsConst = *std::static_pointer_cast<HybridNitroListProps const>(props);
|
|
68
|
-
auto& newViewProps = const_cast<HybridNitroListProps&>(newViewPropsConst);
|
|
69
|
-
NitroList::HybridNitroListSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
70
|
-
|
|
71
|
-
// 2. Update each prop individually
|
|
72
|
-
swiftPart.beforeUpdate();
|
|
73
|
-
|
|
74
|
-
// isRed: boolean
|
|
75
|
-
if (newViewProps.isRed.isDirty) {
|
|
76
|
-
swiftPart.setIsRed(newViewProps.isRed.value);
|
|
77
|
-
newViewProps.isRed.isDirty = false;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
swiftPart.afterUpdate();
|
|
81
|
-
|
|
82
|
-
// 3. Update hybridRef if it changed
|
|
83
|
-
if (newViewProps.hybridRef.isDirty) {
|
|
84
|
-
// hybridRef changed - call it with new this
|
|
85
|
-
const auto& maybeFunc = newViewProps.hybridRef.value;
|
|
86
|
-
if (maybeFunc.has_value()) {
|
|
87
|
-
maybeFunc.value()(_hybridView);
|
|
88
|
-
}
|
|
89
|
-
newViewProps.hybridRef.isDirty = false;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// 4. Continue in base class
|
|
93
|
-
[super updateProps:props oldProps:oldProps];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@end
|
|
@@ -1,56 +0,0 @@
|
|
|
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, HybridView {
|
|
13
|
-
// Properties
|
|
14
|
-
var isRed: Bool { get set }
|
|
15
|
-
|
|
16
|
-
// Methods
|
|
17
|
-
|
|
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,88 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridNitroListComponent.cpp
|
|
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
|
-
#include "HybridNitroListComponent.hpp"
|
|
9
|
-
|
|
10
|
-
#include <string>
|
|
11
|
-
#include <exception>
|
|
12
|
-
#include <utility>
|
|
13
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
-
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
-
#include <NitroModules/PropNameIDCache.hpp>
|
|
16
|
-
#include <react/renderer/core/RawValue.h>
|
|
17
|
-
#include <react/renderer/core/ShadowNode.h>
|
|
18
|
-
#include <react/renderer/core/ComponentDescriptor.h>
|
|
19
|
-
#include <react/renderer/components/view/ViewProps.h>
|
|
20
|
-
|
|
21
|
-
namespace margelo::nitro::nitrolist::views {
|
|
22
|
-
|
|
23
|
-
extern const char HybridNitroListComponentName[] = "NitroList";
|
|
24
|
-
|
|
25
|
-
HybridNitroListProps::HybridNitroListProps(const react::PropsParserContext& context,
|
|
26
|
-
const HybridNitroListProps& sourceProps,
|
|
27
|
-
const react::RawProps& rawProps):
|
|
28
|
-
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
29
|
-
isRed([&]() -> CachedProp<bool> {
|
|
30
|
-
try {
|
|
31
|
-
const react::RawValue* rawValue = rawProps.at("isRed", nullptr, nullptr);
|
|
32
|
-
if (rawValue == nullptr) return sourceProps.isRed;
|
|
33
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
34
|
-
return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.isRed);
|
|
35
|
-
} catch (const std::exception& exc) {
|
|
36
|
-
throw std::runtime_error(std::string("NitroList.isRed: ") + exc.what());
|
|
37
|
-
}
|
|
38
|
-
}()),
|
|
39
|
-
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridNitroListSpec>& /* ref */)>>> {
|
|
40
|
-
try {
|
|
41
|
-
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
42
|
-
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
43
|
-
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
44
|
-
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridNitroListSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
|
|
45
|
-
} catch (const std::exception& exc) {
|
|
46
|
-
throw std::runtime_error(std::string("NitroList.hybridRef: ") + exc.what());
|
|
47
|
-
}
|
|
48
|
-
}()) { }
|
|
49
|
-
|
|
50
|
-
HybridNitroListProps::HybridNitroListProps(const HybridNitroListProps& other):
|
|
51
|
-
react::ViewProps(),
|
|
52
|
-
isRed(other.isRed),
|
|
53
|
-
hybridRef(other.hybridRef) { }
|
|
54
|
-
|
|
55
|
-
bool HybridNitroListProps::filterObjectKeys(const std::string& propName) {
|
|
56
|
-
switch (hashString(propName)) {
|
|
57
|
-
case hashString("isRed"): return true;
|
|
58
|
-
case hashString("hybridRef"): return true;
|
|
59
|
-
default: return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
HybridNitroListComponentDescriptor::HybridNitroListComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
|
|
64
|
-
: ConcreteComponentDescriptor(parameters,
|
|
65
|
-
react::RawPropsParser(/* enableJsiParser */ true)) {}
|
|
66
|
-
|
|
67
|
-
std::shared_ptr<const react::Props> HybridNitroListComponentDescriptor::cloneProps(const react::PropsParserContext& context,
|
|
68
|
-
const std::shared_ptr<const react::Props>& props,
|
|
69
|
-
react::RawProps rawProps) const {
|
|
70
|
-
// 1. Prepare raw props parser
|
|
71
|
-
rawProps.parse(rawPropsParser_);
|
|
72
|
-
// 2. Copy props with Nitro's cached copy constructor
|
|
73
|
-
return HybridNitroListShadowNode::Props(context, /* & */ rawProps, props);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
#ifdef ANDROID
|
|
77
|
-
void HybridNitroListComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
78
|
-
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
79
|
-
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
80
|
-
auto& concreteShadowNode = dynamic_cast<HybridNitroListShadowNode&>(shadowNode);
|
|
81
|
-
const HybridNitroListProps& props = concreteShadowNode.getConcreteProps();
|
|
82
|
-
HybridNitroListState state;
|
|
83
|
-
state.setProps(props);
|
|
84
|
-
concreteShadowNode.setStateData(std::move(state));
|
|
85
|
-
}
|
|
86
|
-
#endif
|
|
87
|
-
|
|
88
|
-
} // namespace margelo::nitro::nitrolist::views
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridNitroListComponent.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
|
-
#include <optional>
|
|
11
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
12
|
-
#include <NitroModules/NitroHash.hpp>
|
|
13
|
-
#include <NitroModules/CachedProp.hpp>
|
|
14
|
-
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
-
#include <react/renderer/core/PropsParserContext.h>
|
|
16
|
-
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
-
#include <react/renderer/components/view/ViewProps.h>
|
|
18
|
-
|
|
19
|
-
#include <memory>
|
|
20
|
-
#include "HybridNitroListSpec.hpp"
|
|
21
|
-
#include <functional>
|
|
22
|
-
#include <optional>
|
|
23
|
-
|
|
24
|
-
namespace margelo::nitro::nitrolist::views {
|
|
25
|
-
|
|
26
|
-
using namespace facebook;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The name of the actual native View.
|
|
30
|
-
*/
|
|
31
|
-
extern const char HybridNitroListComponentName[];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Props for the "NitroList" View.
|
|
35
|
-
*/
|
|
36
|
-
class HybridNitroListProps final: public react::ViewProps {
|
|
37
|
-
public:
|
|
38
|
-
HybridNitroListProps() = default;
|
|
39
|
-
HybridNitroListProps(const HybridNitroListProps&);
|
|
40
|
-
HybridNitroListProps(const react::PropsParserContext& context,
|
|
41
|
-
const HybridNitroListProps& sourceProps,
|
|
42
|
-
const react::RawProps& rawProps);
|
|
43
|
-
|
|
44
|
-
public:
|
|
45
|
-
CachedProp<bool> isRed;
|
|
46
|
-
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridNitroListSpec>& /* ref */)>>> hybridRef;
|
|
47
|
-
|
|
48
|
-
private:
|
|
49
|
-
static bool filterObjectKeys(const std::string& propName);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* State for the "NitroList" View.
|
|
54
|
-
*/
|
|
55
|
-
class HybridNitroListState final {
|
|
56
|
-
public:
|
|
57
|
-
HybridNitroListState() = default;
|
|
58
|
-
|
|
59
|
-
public:
|
|
60
|
-
void setProps(const HybridNitroListProps& props) { _props.emplace(props); }
|
|
61
|
-
const std::optional<HybridNitroListProps>& getProps() const { return _props; }
|
|
62
|
-
|
|
63
|
-
public:
|
|
64
|
-
#ifdef ANDROID
|
|
65
|
-
HybridNitroListState(const HybridNitroListState& /* previousState */, folly::dynamic /* data */) {}
|
|
66
|
-
folly::dynamic getDynamic() const {
|
|
67
|
-
throw std::runtime_error("HybridNitroListState does not support folly!");
|
|
68
|
-
}
|
|
69
|
-
react::MapBuffer getMapBuffer() const {
|
|
70
|
-
throw std::runtime_error("HybridNitroListState does not support MapBuffer!");
|
|
71
|
-
};
|
|
72
|
-
#endif
|
|
73
|
-
|
|
74
|
-
private:
|
|
75
|
-
std::optional<HybridNitroListProps> _props;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The Shadow Node for the "NitroList" View.
|
|
80
|
-
*/
|
|
81
|
-
using HybridNitroListShadowNode = react::ConcreteViewShadowNode<HybridNitroListComponentName /* "HybridNitroList" */,
|
|
82
|
-
HybridNitroListProps /* custom props */,
|
|
83
|
-
react::ViewEventEmitter /* default */,
|
|
84
|
-
HybridNitroListState /* custom state */>;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The Component Descriptor for the "NitroList" View.
|
|
88
|
-
*/
|
|
89
|
-
class HybridNitroListComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridNitroListShadowNode> {
|
|
90
|
-
public:
|
|
91
|
-
HybridNitroListComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
92
|
-
|
|
93
|
-
public:
|
|
94
|
-
/**
|
|
95
|
-
* A faster path for cloning props - reuses the caching logic from `HybridNitroListProps`.
|
|
96
|
-
*/
|
|
97
|
-
std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
|
|
98
|
-
const std::shared_ptr<const react::Props>& props,
|
|
99
|
-
react::RawProps rawProps) const override;
|
|
100
|
-
#ifdef ANDROID
|
|
101
|
-
void adopt(react::ShadowNode& shadowNode) const override;
|
|
102
|
-
#endif
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/* The actual view for "NitroList" needs to be implemented in platform-specific code. */
|
|
106
|
-
|
|
107
|
-
} // namespace margelo::nitro::nitrolist::views
|