@react-native-ohos/flash-list 1.8.3-rc.5 → 2.1.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.OpenSource +1 -1
- package/dist/AnimatedFlashList.d.ts +4 -28
- package/dist/AnimatedFlashList.d.ts.map +1 -1
- package/dist/AnimatedFlashList.js +5 -30
- package/dist/AnimatedFlashList.js.map +1 -1
- package/dist/FlashList.d.ts +1 -179
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +1 -599
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +285 -278
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/FlashListProps.js +5 -31
- package/dist/FlashListProps.js.map +1 -1
- package/dist/FlashListRef.d.ts +305 -0
- package/dist/FlashListRef.d.ts.map +1 -0
- package/dist/FlashListRef.js +2 -0
- package/dist/FlashListRef.js.map +1 -0
- package/dist/benchmark/AutoScrollHelper.d.ts +17 -40
- package/dist/benchmark/AutoScrollHelper.d.ts.map +1 -1
- package/dist/benchmark/AutoScrollHelper.js +59 -90
- package/dist/benchmark/AutoScrollHelper.js.map +1 -1
- package/dist/benchmark/JSFPSMonitor.d.ts +22 -45
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
- package/dist/benchmark/JSFPSMonitor.js +59 -87
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/roundToDecimalPlaces.d.ts +1 -24
- package/dist/benchmark/roundToDecimalPlaces.d.ts.map +1 -1
- package/dist/benchmark/roundToDecimalPlaces.js +4 -31
- package/dist/benchmark/roundToDecimalPlaces.js.map +1 -1
- package/dist/benchmark/useBenchmark.d.ts +40 -57
- package/dist/benchmark/useBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useBenchmark.js +119 -189
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useDataMultiplier.d.ts +8 -31
- package/dist/benchmark/useDataMultiplier.d.ts.map +1 -1
- package/dist/benchmark/useDataMultiplier.js +19 -47
- package/dist/benchmark/useDataMultiplier.js.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts +14 -35
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +92 -122
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
- package/dist/errors/ErrorMessages.d.ts +16 -0
- package/dist/errors/ErrorMessages.d.ts.map +1 -0
- package/dist/errors/ErrorMessages.js +16 -0
- package/dist/errors/ErrorMessages.js.map +1 -0
- package/dist/errors/WarningMessages.d.ts +6 -0
- package/dist/errors/WarningMessages.d.ts.map +1 -0
- package/dist/errors/WarningMessages.js +7 -0
- package/dist/errors/WarningMessages.js.map +1 -0
- package/dist/index.d.ts +15 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -54
- package/dist/index.js.map +1 -1
- package/dist/isNewArch.d.ts +2 -0
- package/dist/isNewArch.d.ts.map +1 -0
- package/dist/isNewArch.js +22 -0
- package/dist/isNewArch.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +6 -48
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +6 -45
- package/dist/native/config/PlatformHelper.android.js.map +1 -1
- package/dist/native/config/PlatformHelper.d.ts +6 -48
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.harmony.d.ts +29 -48
- package/dist/native/config/PlatformHelper.harmony.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.harmony.js +29 -44
- package/dist/native/config/PlatformHelper.harmony.js.map +1 -1
- package/dist/native/config/PlatformHelper.ios.d.ts +6 -48
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +6 -44
- package/dist/native/config/PlatformHelper.ios.js.map +1 -1
- package/dist/native/config/PlatformHelper.js +6 -45
- package/dist/native/config/PlatformHelper.js.map +1 -1
- package/dist/native/config/PlatformHelper.web.d.ts +6 -49
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +6 -47
- package/dist/native/config/PlatformHelper.web.js.map +1 -1
- package/dist/recyclerview/LayoutCommitObserver.d.ts +12 -0
- package/dist/recyclerview/LayoutCommitObserver.d.ts.map +1 -0
- package/dist/recyclerview/LayoutCommitObserver.js +58 -0
- package/dist/recyclerview/LayoutCommitObserver.js.map +1 -0
- package/dist/recyclerview/RecyclerView.d.ts +13 -0
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerView.js +368 -0
- package/dist/recyclerview/RecyclerView.js.map +1 -0
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts +46 -0
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js +10 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js.map +1 -0
- package/dist/recyclerview/RecyclerViewManager.d.ts +78 -0
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewManager.js +343 -0
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -0
- package/dist/recyclerview/RecyclerViewProps.d.ts +2 -0
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewProps.js +2 -0
- package/dist/recyclerview/RecyclerViewProps.js.map +1 -0
- package/dist/recyclerview/RenderStackManager.d.ts +86 -0
- package/dist/recyclerview/RenderStackManager.d.ts.map +1 -0
- package/dist/recyclerview/RenderStackManager.js +252 -0
- package/dist/recyclerview/RenderStackManager.js.map +1 -0
- package/dist/recyclerview/ViewHolder.d.ts +45 -0
- package/dist/recyclerview/ViewHolder.d.ts.map +1 -0
- package/dist/recyclerview/ViewHolder.js +94 -0
- package/dist/recyclerview/ViewHolder.js.map +1 -0
- package/dist/recyclerview/ViewHolderCollection.d.ts +63 -0
- package/dist/recyclerview/ViewHolderCollection.d.ts.map +1 -0
- package/dist/recyclerview/ViewHolderCollection.js +87 -0
- package/dist/recyclerview/ViewHolderCollection.js.map +1 -0
- package/dist/recyclerview/components/CompatScroller.d.ts +7 -0
- package/dist/recyclerview/components/CompatScroller.d.ts.map +1 -0
- package/dist/recyclerview/components/CompatScroller.js +7 -0
- package/dist/recyclerview/components/CompatScroller.js.map +1 -0
- package/dist/recyclerview/components/CompatView.d.ts +7 -0
- package/dist/recyclerview/components/CompatView.d.ts.map +1 -0
- package/dist/recyclerview/components/CompatView.js +7 -0
- package/dist/recyclerview/components/CompatView.js.map +1 -0
- package/dist/recyclerview/components/ScrollAnchor.d.ts +29 -0
- package/dist/recyclerview/components/ScrollAnchor.d.ts.map +1 -0
- package/dist/recyclerview/components/ScrollAnchor.js +33 -0
- package/dist/recyclerview/components/ScrollAnchor.js.map +1 -0
- package/dist/recyclerview/components/StickyHeaders.d.ts +38 -0
- package/dist/recyclerview/components/StickyHeaders.d.ts.map +1 -0
- package/dist/recyclerview/components/StickyHeaders.js +112 -0
- package/dist/recyclerview/components/StickyHeaders.js.map +1 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts +51 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts.map +1 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js +95 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js.map +1 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts +105 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js +202 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js.map +1 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts +14 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js +44 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js.map +1 -0
- package/dist/recyclerview/helpers/VelocityTracker.d.ts +29 -0
- package/dist/recyclerview/helpers/VelocityTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/VelocityTracker.js +64 -0
- package/dist/recyclerview/helpers/VelocityTracker.js.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts +17 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.js +132 -0
- package/dist/recyclerview/hooks/useBoundDetection.js.map +1 -0
- package/dist/recyclerview/hooks/useLayoutState.d.ts +14 -0
- package/dist/recyclerview/hooks/useLayoutState.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useLayoutState.js +38 -0
- package/dist/recyclerview/hooks/useLayoutState.js.map +1 -0
- package/dist/recyclerview/hooks/useMappingHelper.d.ts +9 -0
- package/dist/recyclerview/hooks/useMappingHelper.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useMappingHelper.js +15 -0
- package/dist/recyclerview/hooks/useMappingHelper.js.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts +25 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.js +67 -0
- package/dist/recyclerview/hooks/useOnLoad.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts +28 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js +507 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts +8 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.js +32 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclingState.d.ts +18 -0
- package/dist/recyclerview/hooks/useRecyclingState.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclingState.js +49 -0
- package/dist/recyclerview/hooks/useRecyclingState.js.map +1 -0
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts +27 -0
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useSecondaryProps.js +90 -0
- package/dist/recyclerview/hooks/useSecondaryProps.js.map +1 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts +15 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js +58 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts +10 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js +25 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js.map +1 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts +79 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.js +221 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts +296 -0
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/LayoutManager.js +279 -0
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts +51 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js +151 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts +81 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js +269 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js.map +1 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts +12 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts.map +1 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.js +14 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.js.map +1 -0
- package/dist/recyclerview/utils/componentUtils.d.ts +19 -0
- package/dist/recyclerview/utils/componentUtils.d.ts.map +1 -0
- package/dist/recyclerview/utils/componentUtils.js +27 -0
- package/dist/recyclerview/utils/componentUtils.js.map +1 -0
- package/dist/recyclerview/utils/findVisibleIndex.d.ts +24 -0
- package/dist/recyclerview/utils/findVisibleIndex.d.ts.map +1 -0
- package/dist/recyclerview/utils/findVisibleIndex.js +76 -0
- package/dist/recyclerview/utils/findVisibleIndex.js.map +1 -0
- package/dist/recyclerview/utils/measureLayout.d.ts +52 -0
- package/dist/recyclerview/utils/measureLayout.d.ts.map +1 -0
- package/dist/recyclerview/utils/measureLayout.js +99 -0
- package/dist/recyclerview/utils/measureLayout.js.map +1 -0
- package/dist/recyclerview/utils/measureLayout.web.d.ts +29 -0
- package/dist/recyclerview/utils/measureLayout.web.d.ts.map +1 -0
- package/dist/recyclerview/utils/measureLayout.web.js +79 -0
- package/dist/recyclerview/utils/measureLayout.web.js.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.d.ts +8 -0
- package/dist/recyclerview/viewability/ViewToken.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.js +2 -0
- package/dist/recyclerview/viewability/ViewToken.js.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts +26 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.js +98 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.js.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts +25 -0
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityManager.js +94 -0
- package/dist/recyclerview/viewability/ViewabilityManager.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/AverageWindow.d.ts +33 -43
- package/dist/utils/AverageWindow.d.ts.map +1 -1
- package/dist/utils/AverageWindow.js +66 -71
- package/dist/utils/AverageWindow.js.map +1 -1
- package/jestSetup.js +23 -37
- package/package.json +15 -24
- package/src/AnimatedFlashList.ts +2 -25
- package/src/FlashList.ts +1 -0
- package/src/FlashListProps.ts +109 -100
- package/src/FlashListRef.ts +320 -0
- package/src/benchmark/AutoScrollHelper.ts +0 -24
- package/src/benchmark/JSFPSMonitor.ts +2 -26
- package/src/benchmark/roundToDecimalPlaces.ts +0 -24
- package/src/benchmark/useBenchmark.ts +59 -105
- package/src/benchmark/useDataMultiplier.ts +0 -24
- package/src/benchmark/useFlatListBenchmark.ts +43 -32
- package/src/errors/ErrorMessages.ts +26 -0
- package/src/errors/WarningMessages.ts +9 -0
- package/src/index.ts +18 -46
- package/src/isNewArch.ts +25 -0
- package/src/native/config/PlatformHelper.android.ts +3 -49
- package/src/native/config/PlatformHelper.harmony.ts +3 -24
- package/src/native/config/PlatformHelper.ios.ts +3 -48
- package/src/native/config/PlatformHelper.ts +3 -49
- package/src/native/config/PlatformHelper.web.ts +4 -55
- package/src/recyclerview/LayoutCommitObserver.tsx +74 -0
- package/src/recyclerview/RecyclerView.tsx +616 -0
- package/src/recyclerview/RecyclerViewContextProvider.ts +65 -0
- package/src/recyclerview/RecyclerViewManager.ts +461 -0
- package/src/recyclerview/RecyclerViewProps.ts +1 -0
- package/src/recyclerview/RenderStackManager.ts +317 -0
- package/src/recyclerview/ViewHolder.tsx +180 -0
- package/src/recyclerview/ViewHolderCollection.tsx +193 -0
- package/src/recyclerview/components/CompatScroller.ts +9 -0
- package/src/recyclerview/components/CompatView.ts +9 -0
- package/src/recyclerview/components/ScrollAnchor.tsx +66 -0
- package/src/recyclerview/components/StickyHeaders.tsx +222 -0
- package/src/recyclerview/helpers/ConsecutiveNumbers.ts +120 -0
- package/src/recyclerview/helpers/EngagedIndicesTracker.ts +301 -0
- package/src/recyclerview/helpers/RenderTimeTracker.ts +50 -0
- package/src/recyclerview/helpers/VelocityTracker.ts +77 -0
- package/src/recyclerview/hooks/useBoundDetection.ts +176 -0
- package/src/recyclerview/hooks/useLayoutState.ts +55 -0
- package/src/recyclerview/hooks/useMappingHelper.ts +20 -0
- package/src/recyclerview/hooks/useOnLoad.ts +80 -0
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +633 -0
- package/src/recyclerview/hooks/useRecyclerViewManager.ts +42 -0
- package/src/recyclerview/hooks/useRecyclingState.ts +67 -0
- package/src/recyclerview/hooks/useSecondaryProps.tsx +124 -0
- package/src/recyclerview/hooks/useUnmountAwareCallbacks.ts +73 -0
- package/src/recyclerview/hooks/useUnmountFlag.ts +27 -0
- package/src/recyclerview/layout-managers/GridLayoutManager.ts +256 -0
- package/src/recyclerview/layout-managers/LayoutManager.ts +568 -0
- package/src/recyclerview/layout-managers/LinearLayoutManager.ts +171 -0
- package/src/recyclerview/layout-managers/MasonryLayoutManager.ts +323 -0
- package/src/recyclerview/utils/adjustOffsetForRTL.ts +17 -0
- package/src/recyclerview/utils/componentUtils.ts +28 -0
- package/src/recyclerview/utils/findVisibleIndex.ts +93 -0
- package/src/recyclerview/utils/measureLayout.ts +128 -0
- package/src/recyclerview/utils/measureLayout.web.ts +102 -0
- package/src/recyclerview/viewability/ViewToken.ts +7 -0
- package/src/{viewability → recyclerview/viewability}/ViewabilityHelper.ts +8 -33
- package/src/{viewability → recyclerview/viewability}/ViewabilityManager.ts +23 -46
- package/src/utils/AverageWindow.ts +33 -24
- package/dist/GridLayoutProviderWithProps.d.ts +0 -65
- package/dist/GridLayoutProviderWithProps.d.ts.map +0 -1
- package/dist/GridLayoutProviderWithProps.js +0 -138
- package/dist/GridLayoutProviderWithProps.js.map +0 -1
- package/dist/MasonryFlashList.d.ts +0 -74
- package/dist/MasonryFlashList.d.ts.map +0 -1
- package/dist/MasonryFlashList.js +0 -275
- package/dist/MasonryFlashList.js.map +0 -1
- package/dist/PureComponentWrapper.d.ts +0 -45
- package/dist/PureComponentWrapper.d.ts.map +0 -1
- package/dist/PureComponentWrapper.js +0 -60
- package/dist/PureComponentWrapper.js.map +0 -1
- package/dist/__tests__/AverageWindow.test.d.ts +0 -2
- package/dist/__tests__/AverageWindow.test.d.ts.map +0 -1
- package/dist/__tests__/AverageWindow.test.js +0 -69
- package/dist/__tests__/AverageWindow.test.js.map +0 -1
- package/dist/__tests__/ContentContainerUtils.test.d.ts +0 -2
- package/dist/__tests__/ContentContainerUtils.test.d.ts.map +0 -1
- package/dist/__tests__/ContentContainerUtils.test.js +0 -85
- package/dist/__tests__/ContentContainerUtils.test.js.map +0 -1
- package/dist/__tests__/FlashList.test.d.ts +0 -2
- package/dist/__tests__/FlashList.test.d.ts.map +0 -1
- package/dist/__tests__/FlashList.test.js +0 -792
- package/dist/__tests__/FlashList.test.js.map +0 -1
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts +0 -2
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts.map +0 -1
- package/dist/__tests__/GridLayoutProviderWithProps.test.js +0 -143
- package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +0 -1
- package/dist/__tests__/MasonryFlashList.test.d.ts +0 -2
- package/dist/__tests__/MasonryFlashList.test.d.ts.map +0 -1
- package/dist/__tests__/MasonryFlashList.test.js +0 -254
- package/dist/__tests__/MasonryFlashList.test.js.map +0 -1
- package/dist/__tests__/PlatformHelper.web.test.d.ts +0 -2
- package/dist/__tests__/PlatformHelper.web.test.d.ts.map +0 -1
- package/dist/__tests__/PlatformHelper.web.test.js +0 -33
- package/dist/__tests__/PlatformHelper.web.test.js.map +0 -1
- package/dist/__tests__/ViewabilityHelper.test.d.ts +0 -2
- package/dist/__tests__/ViewabilityHelper.test.d.ts.map +0 -1
- package/dist/__tests__/ViewabilityHelper.test.js +0 -187
- package/dist/__tests__/ViewabilityHelper.test.js.map +0 -1
- package/dist/__tests__/helpers/mountFlashList.d.ts +0 -19
- package/dist/__tests__/helpers/mountFlashList.d.ts.map +0 -1
- package/dist/__tests__/helpers/mountFlashList.js +0 -44
- package/dist/__tests__/helpers/mountFlashList.js.map +0 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +0 -18
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +0 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.js +0 -49
- package/dist/__tests__/helpers/mountMasonryFlashList.js.map +0 -1
- package/dist/__tests__/useBlankAreaTracker.test.d.ts +0 -2
- package/dist/__tests__/useBlankAreaTracker.test.d.ts.map +0 -1
- package/dist/__tests__/useBlankAreaTracker.test.js +0 -177
- package/dist/__tests__/useBlankAreaTracker.test.js.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.d.ts +0 -57
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.js +0 -90
- package/dist/benchmark/useBlankAreaTracker.js.map +0 -1
- package/dist/errors/CustomError.d.ts +0 -31
- package/dist/errors/CustomError.d.ts.map +0 -1
- package/dist/errors/CustomError.js +0 -37
- package/dist/errors/CustomError.js.map +0 -1
- package/dist/errors/ExceptionList.d.ts +0 -47
- package/dist/errors/ExceptionList.d.ts.map +0 -1
- package/dist/errors/ExceptionList.js +0 -49
- package/dist/errors/ExceptionList.js.map +0 -1
- package/dist/errors/Warnings.d.ts +0 -32
- package/dist/errors/Warnings.d.ts.map +0 -1
- package/dist/errors/Warnings.js +0 -36
- package/dist/errors/Warnings.js.map +0 -1
- package/dist/fabric/AutoLayoutNativeComponent.d.ts +0 -42
- package/dist/fabric/AutoLayoutNativeComponent.d.ts.map +0 -1
- package/dist/fabric/AutoLayoutNativeComponent.js +0 -29
- package/dist/fabric/AutoLayoutNativeComponent.js.map +0 -1
- package/dist/fabric/CellContainerNativeComponent.d.ts +0 -31
- package/dist/fabric/CellContainerNativeComponent.d.ts.map +0 -1
- package/dist/fabric/CellContainerNativeComponent.js +0 -29
- package/dist/fabric/CellContainerNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +0 -45
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.js +0 -71
- package/dist/native/auto-layout/AutoLayoutView.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +0 -28
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +0 -39
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +0 -26
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +0 -1
- package/dist/native/cell-container/CellContainer.android.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.android.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.android.js +0 -32
- package/dist/native/cell-container/CellContainer.android.js.map +0 -1
- package/dist/native/cell-container/CellContainer.d.ts +0 -31
- package/dist/native/cell-container/CellContainer.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.harmony.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.harmony.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.harmony.js +0 -32
- package/dist/native/cell-container/CellContainer.harmony.js.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.js +0 -32
- package/dist/native/cell-container/CellContainer.ios.js.map +0 -1
- package/dist/native/cell-container/CellContainer.js +0 -34
- package/dist/native/cell-container/CellContainer.js.map +0 -1
- package/dist/native/cell-container/CellContainer.web.d.ts +0 -30
- package/dist/native/cell-container/CellContainer.web.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.web.js +0 -36
- package/dist/native/cell-container/CellContainer.web.js.map +0 -1
- package/dist/utils/ContentContainerUtils.d.ts +0 -50
- package/dist/utils/ContentContainerUtils.d.ts.map +0 -1
- package/dist/utils/ContentContainerUtils.js +0 -71
- package/dist/utils/ContentContainerUtils.js.map +0 -1
- package/dist/viewability/ViewToken.d.ts +0 -31
- package/dist/viewability/ViewToken.d.ts.map +0 -1
- package/dist/viewability/ViewToken.js +0 -26
- package/dist/viewability/ViewToken.js.map +0 -1
- package/dist/viewability/ViewabilityHelper.d.ts +0 -49
- package/dist/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/dist/viewability/ViewabilityHelper.js +0 -130
- package/dist/viewability/ViewabilityHelper.js.map +0 -1
- package/dist/viewability/ViewabilityManager.d.ts +0 -48
- package/dist/viewability/ViewabilityManager.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.js +0 -131
- package/dist/viewability/ViewabilityManager.js.map +0 -1
- package/harmony/flash_list/BuildProfile.ets +0 -17
- package/harmony/flash_list/LICENSE +0 -7
- package/harmony/flash_list/build-profile.json5 +0 -8
- package/harmony/flash_list/hvigorfile.ts +0 -1
- package/harmony/flash_list/index.ets +0 -27
- package/harmony/flash_list/obfuscation-rules.txt +0 -18
- package/harmony/flash_list/oh-package.json5 +0 -24
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.cpp +0 -63
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.h +0 -54
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.cpp +0 -140
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.h +0 -66
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.cpp +0 -208
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.h +0 -78
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewEventEmitRequestHandler.h +0 -53
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewJSIBinder.h +0 -50
- package/harmony/flash_list/src/main/cpp/CMakeLists.txt +0 -12
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.cpp +0 -80
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.h +0 -64
- package/harmony/flash_list/src/main/cpp/CellContainerJSIBinder.h +0 -39
- package/harmony/flash_list/src/main/cpp/ComponentDescriptors.h +0 -40
- package/harmony/flash_list/src/main/cpp/EventEmitters.cpp +0 -40
- package/harmony/flash_list/src/main/cpp/EventEmitters.h +0 -48
- package/harmony/flash_list/src/main/cpp/FlashListPackage.h +0 -85
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.cpp +0 -87
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.h +0 -57
- package/harmony/flash_list/src/main/cpp/Props.cpp +0 -52
- package/harmony/flash_list/src/main/cpp/Props.h +0 -64
- package/harmony/flash_list/src/main/cpp/ShadowNodes.cpp +0 -34
- package/harmony/flash_list/src/main/cpp/ShadowNodes.h +0 -48
- package/harmony/flash_list/src/main/ets/Logger.ets +0 -64
- package/harmony/flash_list/src/main/ets/RNAutoLayoutShadow.ets +0 -154
- package/harmony/flash_list/src/main/ets/RNAutoLayoutView.ets +0 -277
- package/harmony/flash_list/src/main/ets/RNCellContainer.ets +0 -113
- package/harmony/flash_list/src/main/module.json5 +0 -9
- package/harmony/flash_list/src/main/resources/base/element/color.json +0 -8
- package/harmony/flash_list/src/main/resources/base/element/string.json +0 -16
- package/harmony/flash_list/src/main/resources/base/media/icon.png +0 -0
- package/harmony/flash_list/src/main/resources/base/profile/main_pages.json +0 -5
- package/harmony/flash_list/src/main/resources/en_US/element/string.json +0 -16
- package/harmony/flash_list/src/main/resources/zh_CN/element/string.json +0 -16
- package/harmony/flash_list.har +0 -0
- package/src/FlashList.tsx +0 -949
- package/src/GridLayoutProviderWithProps.ts +0 -204
- package/src/MasonryFlashList.tsx +0 -499
- package/src/PureComponentWrapper.tsx +0 -65
- package/src/benchmark/useBlankAreaTracker.ts +0 -141
- package/src/errors/CustomError.ts +0 -34
- package/src/errors/ExceptionList.ts +0 -52
- package/src/errors/Warnings.ts +0 -39
- package/src/fabric/AutoLayoutNativeComponent.ts +0 -52
- package/src/fabric/CellContainerNativeComponent.ts +0 -35
- package/src/native/auto-layout/AutoLayoutView.tsx +0 -97
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.harmony.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +0 -41
- package/src/native/cell-container/CellContainer.android.ts +0 -31
- package/src/native/cell-container/CellContainer.harmony.ts +0 -31
- package/src/native/cell-container/CellContainer.ios.ts +0 -31
- package/src/native/cell-container/CellContainer.tsx +0 -38
- package/src/native/cell-container/CellContainer.web.tsx +0 -33
- package/src/utils/ContentContainerUtils.ts +0 -116
- package/src/viewability/ViewToken.ts +0 -31
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages the recycling of rendered items in a virtualized list.
|
|
3
|
+
* This class handles tracking, recycling, and reusing item keys to optimize
|
|
4
|
+
* rendering performance by minimizing creation/destruction of components.
|
|
5
|
+
*/
|
|
6
|
+
export class RenderStackManager {
|
|
7
|
+
/**
|
|
8
|
+
* @param maxItemsInRecyclePool - Maximum number of items that can be in the recycle pool
|
|
9
|
+
*/
|
|
10
|
+
constructor(maxItemsInRecyclePool = Number.MAX_SAFE_INTEGER) {
|
|
11
|
+
this.disableRecycling = false;
|
|
12
|
+
this.maxItemsInRecyclePool = maxItemsInRecyclePool;
|
|
13
|
+
this.recycleKeyPools = new Map();
|
|
14
|
+
this.keyMap = new Map();
|
|
15
|
+
this.stableIdMap = new Map();
|
|
16
|
+
this.keyCounter = 0;
|
|
17
|
+
this.unProcessedIndices = new Set();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Synchronizes the render stack with the current state of data.
|
|
21
|
+
* This method is the core orchestrator that:
|
|
22
|
+
* 1. Recycles keys for items that are no longer valid
|
|
23
|
+
* 2. Updates existing keys for items that remain visible
|
|
24
|
+
* 3. Assigns new keys for newly visible items
|
|
25
|
+
* 4. Cleans up excess items to maintain the recycling pool size
|
|
26
|
+
*
|
|
27
|
+
* @param getStableId - Function to get a stable identifier for an item at a specific index
|
|
28
|
+
* @param getItemType - Function to get the type of an item at a specific index
|
|
29
|
+
* @param engagedIndices - Collection of indices that are currently visible or engaged
|
|
30
|
+
* @param dataLength - Total length of the data set
|
|
31
|
+
*/
|
|
32
|
+
sync(getStableId, getItemType, engagedIndices, dataLength) {
|
|
33
|
+
this.clearRecyclePool();
|
|
34
|
+
this.unProcessedIndices.clear();
|
|
35
|
+
// Recycle keys for items that are no longer valid or visible
|
|
36
|
+
this.keyMap.forEach((keyInfo, key) => {
|
|
37
|
+
const { index, stableId, itemType } = keyInfo;
|
|
38
|
+
if (index >= dataLength) {
|
|
39
|
+
this.recycleKey(key);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!this.disableRecycling) {
|
|
43
|
+
this.unProcessedIndices.add(index);
|
|
44
|
+
}
|
|
45
|
+
if (!engagedIndices.includes(index)) {
|
|
46
|
+
this.recycleKey(key);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const newStableId = getStableId(index);
|
|
50
|
+
const newItemType = getItemType(index);
|
|
51
|
+
if (stableId !== newStableId || itemType !== newItemType) {
|
|
52
|
+
this.recycleKey(key);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// First pass: process items that already have optimized keys
|
|
56
|
+
for (const index of engagedIndices) {
|
|
57
|
+
if (this.hasOptimizedKey(getStableId(index))) {
|
|
58
|
+
this.syncItem(index, getItemType(index), getStableId(index));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Second pass: process remaining items that need new keys
|
|
62
|
+
for (const index of engagedIndices) {
|
|
63
|
+
if (!this.hasOptimizedKey(getStableId(index))) {
|
|
64
|
+
this.syncItem(index, getItemType(index), getStableId(index));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// create indices that are not in the engagedIndices and less than dataLength
|
|
68
|
+
// select only indices that are not in the engagedIndices
|
|
69
|
+
const validIndicesInPool = [];
|
|
70
|
+
for (const keyInfo of this.keyMap.values()) {
|
|
71
|
+
const index = keyInfo.index;
|
|
72
|
+
if (index < dataLength && !engagedIndices.includes(index)) {
|
|
73
|
+
validIndicesInPool.push(index);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// First pass: process items that already have optimized keys
|
|
77
|
+
for (const index of validIndicesInPool) {
|
|
78
|
+
if (this.hasOptimizedKey(getStableId(index))) {
|
|
79
|
+
this.syncItem(index, getItemType(index), getStableId(index));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const index of validIndicesInPool) {
|
|
83
|
+
if (!this.hasOptimizedKey(getStableId(index))) {
|
|
84
|
+
this.syncItem(index, getItemType(index), getStableId(index));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Clean up stale items and manage the recycle pool size
|
|
88
|
+
this.cleanup(getStableId, getItemType, engagedIndices, dataLength);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Checks if a stable ID already has an assigned key
|
|
92
|
+
*/
|
|
93
|
+
hasOptimizedKey(stableId) {
|
|
94
|
+
return this.stableIdMap.has(stableId);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Cleans up stale keys and manages the recycle pool size.
|
|
98
|
+
* This ensures we don't maintain references to items that are no longer in the dataset,
|
|
99
|
+
* and limits the number of recycled items to avoid excessive memory usage.
|
|
100
|
+
*/
|
|
101
|
+
cleanup(getStableId, getItemType, engagedIndices, dataLength) {
|
|
102
|
+
const itemsToDelete = new Array();
|
|
103
|
+
// Remove items that are no longer in the dataset
|
|
104
|
+
for (const [key, keyInfo] of this.keyMap.entries()) {
|
|
105
|
+
const { index, itemType, stableId } = keyInfo;
|
|
106
|
+
const indexOutOfBounds = index >= dataLength;
|
|
107
|
+
const hasStableIdChanged = !indexOutOfBounds && getStableId(index) !== stableId;
|
|
108
|
+
if (indexOutOfBounds || hasStableIdChanged) {
|
|
109
|
+
const nextIndex = this.unProcessedIndices.values().next().value;
|
|
110
|
+
let shouldDeleteKey = true;
|
|
111
|
+
if (nextIndex !== undefined) {
|
|
112
|
+
const nextItemType = getItemType(nextIndex);
|
|
113
|
+
const nextStableId = getStableId(nextIndex);
|
|
114
|
+
if (itemType === nextItemType) {
|
|
115
|
+
this.syncItem(nextIndex, nextItemType, nextStableId);
|
|
116
|
+
shouldDeleteKey = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (shouldDeleteKey) {
|
|
120
|
+
this.deleteKeyFromRecyclePool(itemType, key);
|
|
121
|
+
this.stableIdMap.delete(stableId);
|
|
122
|
+
itemsToDelete.push(key);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const key of itemsToDelete) {
|
|
127
|
+
this.keyMap.delete(key);
|
|
128
|
+
}
|
|
129
|
+
// Limit the size of the recycle pool
|
|
130
|
+
const itemsRenderedForRecycling = this.keyMap.size - engagedIndices.length;
|
|
131
|
+
if (itemsRenderedForRecycling > this.maxItemsInRecyclePool) {
|
|
132
|
+
const deleteCount = itemsRenderedForRecycling - this.maxItemsInRecyclePool;
|
|
133
|
+
let deleted = 0;
|
|
134
|
+
// Use a for loop so we can break early once we've deleted enough items
|
|
135
|
+
const entries = Array.from(this.keyMap.entries()).reverse();
|
|
136
|
+
for (let i = 0; i < entries.length && deleted < deleteCount; i++) {
|
|
137
|
+
const [key, keyInfo] = entries[i];
|
|
138
|
+
const { index, itemType, stableId } = keyInfo;
|
|
139
|
+
if (!engagedIndices.includes(index)) {
|
|
140
|
+
this.deleteKeyFromRecyclePool(itemType, key);
|
|
141
|
+
this.stableIdMap.delete(stableId);
|
|
142
|
+
this.keyMap.delete(key);
|
|
143
|
+
deleted++;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Places a key back into its type-specific recycle pool for future reuse
|
|
150
|
+
*/
|
|
151
|
+
recycleKey(key) {
|
|
152
|
+
if (this.disableRecycling) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const keyInfo = this.keyMap.get(key);
|
|
156
|
+
if (!keyInfo) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const { itemType } = keyInfo;
|
|
160
|
+
// Add key back to its type's pool
|
|
161
|
+
const pool = this.getRecyclePoolForType(itemType);
|
|
162
|
+
pool.add(key);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Returns the current render stack containing all active keys and their metadata
|
|
166
|
+
*/
|
|
167
|
+
getRenderStack() {
|
|
168
|
+
return this.keyMap;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Syncs an individual item by assigning it an appropriate key.
|
|
172
|
+
* Will use an existing key if available, or generate a new one.
|
|
173
|
+
*
|
|
174
|
+
* @returns The key assigned to the item
|
|
175
|
+
*/
|
|
176
|
+
syncItem(index, itemType, stableId) {
|
|
177
|
+
// Try to reuse an existing key, or get one from the recycle pool, or generate a new one
|
|
178
|
+
const newKey = this.stableIdMap.get(stableId) ||
|
|
179
|
+
this.getKeyFromRecyclePool(itemType) ||
|
|
180
|
+
this.generateKey();
|
|
181
|
+
this.unProcessedIndices.delete(index);
|
|
182
|
+
const keyInfo = this.keyMap.get(newKey);
|
|
183
|
+
if (keyInfo) {
|
|
184
|
+
// Update an existing key's metadata
|
|
185
|
+
this.deleteKeyFromRecyclePool(itemType, newKey);
|
|
186
|
+
this.deleteKeyFromRecyclePool(keyInfo.itemType, newKey);
|
|
187
|
+
this.stableIdMap.delete(keyInfo.stableId);
|
|
188
|
+
keyInfo.index = index;
|
|
189
|
+
keyInfo.itemType = itemType;
|
|
190
|
+
keyInfo.stableId = stableId;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
// Create a new entry in the key map
|
|
194
|
+
this.keyMap.set(newKey, {
|
|
195
|
+
itemType,
|
|
196
|
+
index,
|
|
197
|
+
stableId,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
this.stableIdMap.set(stableId, newKey);
|
|
201
|
+
return newKey;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Clears all recycled keys from the pool, effectively resetting the recycling system.
|
|
205
|
+
* This operation does not affect currently active keys.
|
|
206
|
+
*/
|
|
207
|
+
clearRecyclePool() {
|
|
208
|
+
// iterate over all pools and clear them
|
|
209
|
+
for (const pool of this.recycleKeyPools.values()) {
|
|
210
|
+
pool.clear();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Generates a unique sequential key using an internal counter.
|
|
215
|
+
* @returns A unique key as a string
|
|
216
|
+
*/
|
|
217
|
+
generateKey() {
|
|
218
|
+
return (this.keyCounter++).toString();
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Removes a specific key from its type's recycle pool
|
|
222
|
+
*/
|
|
223
|
+
deleteKeyFromRecyclePool(itemType, key) {
|
|
224
|
+
var _a;
|
|
225
|
+
(_a = this.recycleKeyPools.get(itemType)) === null || _a === void 0 ? void 0 : _a.delete(key);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Gets or creates a recycle pool for a specific item type
|
|
229
|
+
*/
|
|
230
|
+
getRecyclePoolForType(itemType) {
|
|
231
|
+
let pool = this.recycleKeyPools.get(itemType);
|
|
232
|
+
if (!pool) {
|
|
233
|
+
pool = new Set();
|
|
234
|
+
this.recycleKeyPools.set(itemType, pool);
|
|
235
|
+
}
|
|
236
|
+
return pool;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Retrieves and removes a key from the type's recycle pool
|
|
240
|
+
* @returns A recycled key or undefined if none available
|
|
241
|
+
*/
|
|
242
|
+
getKeyFromRecyclePool(itemType) {
|
|
243
|
+
const pool = this.getRecyclePoolForType(itemType);
|
|
244
|
+
if (pool.size > 0) {
|
|
245
|
+
const key = pool.values().next().value;
|
|
246
|
+
pool.delete(key);
|
|
247
|
+
return key;
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=RenderStackManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderStackManager.js","sourceRoot":"","sources":["../../src/recyclerview/RenderStackManager.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAuB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CAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,QAAgB;QAC5C,IAAI,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;YACjB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACK,qBAAqB,CAAC,QAAgB;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAClB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViewHolder is a core component in FlashList that manages individual item rendering and layout.
|
|
3
|
+
* It handles the rendering of list items, separators, and manages layout updates for each item.
|
|
4
|
+
* The component is memoized to prevent unnecessary re-renders and includes layout comparison logic.
|
|
5
|
+
*/
|
|
6
|
+
import React, { RefObject } from "react";
|
|
7
|
+
import { FlashListProps, RenderTarget } from "../FlashListProps";
|
|
8
|
+
import { RVDimension, RVLayout } from "./layout-managers/LayoutManager";
|
|
9
|
+
import { CompatView } from "./components/CompatView";
|
|
10
|
+
/**
|
|
11
|
+
* Props interface for the ViewHolder component
|
|
12
|
+
* @template TItem - The type of item being rendered in the list
|
|
13
|
+
*/
|
|
14
|
+
export interface ViewHolderProps<TItem> {
|
|
15
|
+
/** Index of the item in the data array */
|
|
16
|
+
index: number;
|
|
17
|
+
/** Layout information for positioning and sizing the item */
|
|
18
|
+
layout: RVLayout;
|
|
19
|
+
/** Map to store refs for each ViewHolder instance, keyed by index */
|
|
20
|
+
refHolder: Map<number, RefObject<CompatView | null>>;
|
|
21
|
+
/** Additional data passed to renderItem that can trigger re-renders */
|
|
22
|
+
extraData: any;
|
|
23
|
+
/** Specifies the rendering target (e.g., "Cell", "StickyHeader") */
|
|
24
|
+
target: RenderTarget;
|
|
25
|
+
/** The actual item data to be rendered */
|
|
26
|
+
item: TItem;
|
|
27
|
+
/** The next item in the list, used for rendering separators */
|
|
28
|
+
trailingItem: TItem | undefined;
|
|
29
|
+
/** Function to render the item content */
|
|
30
|
+
renderItem: FlashListProps<TItem>["renderItem"];
|
|
31
|
+
/** Optional custom component to wrap each item */
|
|
32
|
+
CellRendererComponent?: FlashListProps<TItem>["CellRendererComponent"];
|
|
33
|
+
/** Optional component to render between items */
|
|
34
|
+
ItemSeparatorComponent?: FlashListProps<TItem>["ItemSeparatorComponent"];
|
|
35
|
+
/** Whether the list is horizontal or vertical */
|
|
36
|
+
horizontal?: FlashListProps<TItem>["horizontal"];
|
|
37
|
+
/** Callback when the item's size changes */
|
|
38
|
+
onSizeChanged?: (index: number, size: RVDimension) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Memoized ViewHolder component that prevents unnecessary re-renders by comparing props
|
|
42
|
+
* @template TItem - The type of item being rendered in the list
|
|
43
|
+
*/
|
|
44
|
+
export declare const ViewHolder: React.MemoExoticComponent<(<TItem>(props: ViewHolderProps<TItem>) => React.JSX.Element)>;
|
|
45
|
+
//# sourceMappingURL=ViewHolder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewHolder.d.ts","sourceRoot":"","sources":["../../src/recyclerview/ViewHolder.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,EACZ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@@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViewHolder is a core component in FlashList that manages individual item rendering and layout.
|
|
3
|
+
* It handles the rendering of list items, separators, and manages layout updates for each item.
|
|
4
|
+
* The component is memoized to prevent unnecessary re-renders and includes layout comparison logic.
|
|
5
|
+
*/
|
|
6
|
+
import React, { useCallback, useLayoutEffect, useMemo, useRef, } from "react";
|
|
7
|
+
import { CompatView } from "./components/CompatView";
|
|
8
|
+
/**
|
|
9
|
+
* Internal ViewHolder component that handles the actual rendering of list items
|
|
10
|
+
* @template TItem - The type of item being rendered in the list
|
|
11
|
+
*/
|
|
12
|
+
const ViewHolderInternal = (props) => {
|
|
13
|
+
// create ref for View
|
|
14
|
+
const viewRef = useRef(null);
|
|
15
|
+
const { index, refHolder, layout, onSizeChanged, renderItem, extraData, item, target, CellRendererComponent, ItemSeparatorComponent, trailingItem, horizontal, } = props;
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
refHolder.set(index, viewRef);
|
|
18
|
+
return () => {
|
|
19
|
+
if (refHolder.get(index) === viewRef) {
|
|
20
|
+
refHolder.delete(index);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}, [index, refHolder]);
|
|
24
|
+
const onLayout = useCallback((event) => {
|
|
25
|
+
onSizeChanged === null || onSizeChanged === void 0 ? void 0 : onSizeChanged(index, event.nativeEvent.layout);
|
|
26
|
+
}, [index, onSizeChanged]);
|
|
27
|
+
const separator = useMemo(() => {
|
|
28
|
+
return ItemSeparatorComponent && trailingItem !== undefined ? (React.createElement(ItemSeparatorComponent, { leadingItem: item, trailingItem: trailingItem })) : null;
|
|
29
|
+
}, [ItemSeparatorComponent, item, trailingItem]);
|
|
30
|
+
// console.log("ViewHolder re-render", index);
|
|
31
|
+
const children = useMemo(() => {
|
|
32
|
+
var _a;
|
|
33
|
+
return (_a = renderItem === null || renderItem === void 0 ? void 0 : renderItem({ item, index, extraData, target })) !== null && _a !== void 0 ? _a : null;
|
|
34
|
+
// TODO: Test more thoroughly
|
|
35
|
+
// We don't really to re-render the children when the index changes
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [item, extraData, target, renderItem]);
|
|
38
|
+
const style = {
|
|
39
|
+
flexDirection: horizontal ? "row" : "column",
|
|
40
|
+
position: target === "StickyHeader" ? "relative" : "absolute",
|
|
41
|
+
width: layout.enforcedWidth ? layout.width : undefined,
|
|
42
|
+
height: layout.enforcedHeight ? layout.height : undefined,
|
|
43
|
+
minHeight: layout.minHeight,
|
|
44
|
+
minWidth: layout.minWidth,
|
|
45
|
+
maxHeight: layout.maxHeight,
|
|
46
|
+
maxWidth: layout.maxWidth,
|
|
47
|
+
left: layout.x,
|
|
48
|
+
top: layout.y,
|
|
49
|
+
};
|
|
50
|
+
// TODO: Fix this type issue
|
|
51
|
+
const CompatContainer = (CellRendererComponent !== null && CellRendererComponent !== void 0 ? CellRendererComponent : CompatView);
|
|
52
|
+
return (React.createElement(CompatContainer, { ref: viewRef, onLayout: onLayout, style: style, index: index },
|
|
53
|
+
children,
|
|
54
|
+
separator));
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Memoized ViewHolder component that prevents unnecessary re-renders by comparing props
|
|
58
|
+
* @template TItem - The type of item being rendered in the list
|
|
59
|
+
*/
|
|
60
|
+
export const ViewHolder = React.memo(ViewHolderInternal, (prevProps, nextProps) => {
|
|
61
|
+
// compare all props and spread layout
|
|
62
|
+
return (prevProps.index === nextProps.index &&
|
|
63
|
+
areLayoutsEqual(prevProps.layout, nextProps.layout) &&
|
|
64
|
+
prevProps.refHolder === nextProps.refHolder &&
|
|
65
|
+
prevProps.onSizeChanged === nextProps.onSizeChanged &&
|
|
66
|
+
prevProps.extraData === nextProps.extraData &&
|
|
67
|
+
prevProps.target === nextProps.target &&
|
|
68
|
+
prevProps.item === nextProps.item &&
|
|
69
|
+
prevProps.renderItem === nextProps.renderItem &&
|
|
70
|
+
prevProps.CellRendererComponent === nextProps.CellRendererComponent &&
|
|
71
|
+
prevProps.ItemSeparatorComponent === nextProps.ItemSeparatorComponent &&
|
|
72
|
+
prevProps.trailingItem === nextProps.trailingItem &&
|
|
73
|
+
prevProps.horizontal === nextProps.horizontal);
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Compares two RVLayout objects to determine if they are equal
|
|
77
|
+
* Used in the memo comparison function to prevent unnecessary re-renders
|
|
78
|
+
* @param prevLayout - Previous layout object
|
|
79
|
+
* @param nextLayout - Next layout object
|
|
80
|
+
* @returns boolean indicating if layouts are equal
|
|
81
|
+
*/
|
|
82
|
+
function areLayoutsEqual(prevLayout, nextLayout) {
|
|
83
|
+
return (prevLayout.x === nextLayout.x &&
|
|
84
|
+
prevLayout.y === nextLayout.y &&
|
|
85
|
+
prevLayout.width === nextLayout.width &&
|
|
86
|
+
prevLayout.height === nextLayout.height &&
|
|
87
|
+
prevLayout.enforcedWidth === nextLayout.enforcedWidth &&
|
|
88
|
+
prevLayout.enforcedHeight === nextLayout.enforcedHeight &&
|
|
89
|
+
prevLayout.minWidth === nextLayout.minWidth &&
|
|
90
|
+
prevLayout.minHeight === nextLayout.minHeight &&
|
|
91
|
+
prevLayout.maxWidth === nextLayout.maxWidth &&
|
|
92
|
+
prevLayout.maxHeight === nextLayout.maxHeight);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=ViewHolder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewHolder.js","sourceRoot":"","sources":["../../src/recyclerview/ViewHolder.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,EAEZ,WAAW,EACX,eAAe,EACf,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAiCrD;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAS,KAA6B,EAAE,EAAE;IACnE,sBAAsB;IACtB,MAAM,OAAO,GAAG,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+1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViewHolderCollection is a container component that manages multiple ViewHolder instances.
|
|
3
|
+
* It handles the rendering of a collection of list items, manages layout updates,
|
|
4
|
+
* and coordinates with the RecyclerView context for layout changes.
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { FlashListProps } from "../FlashListProps";
|
|
8
|
+
import { ViewHolderProps } from "./ViewHolder";
|
|
9
|
+
import { RVDimension, RVLayout } from "./layout-managers/LayoutManager";
|
|
10
|
+
/**
|
|
11
|
+
* Props interface for the ViewHolderCollection component
|
|
12
|
+
* @template TItem - The type of items in the data array
|
|
13
|
+
*/
|
|
14
|
+
export interface ViewHolderCollectionProps<TItem> {
|
|
15
|
+
/** The data array to be rendered */
|
|
16
|
+
data: FlashListProps<TItem>["data"];
|
|
17
|
+
/** Map of indices to React keys for each rendered item */
|
|
18
|
+
renderStack: Map<string, {
|
|
19
|
+
index: number;
|
|
20
|
+
}>;
|
|
21
|
+
/** Function to get layout information for a specific index */
|
|
22
|
+
getLayout: (index: number) => RVLayout;
|
|
23
|
+
/** Ref to control layout updates from parent components */
|
|
24
|
+
viewHolderCollectionRef: React.Ref<ViewHolderCollectionRef>;
|
|
25
|
+
/** Map to store refs for each ViewHolder instance */
|
|
26
|
+
refHolder: ViewHolderProps<TItem>["refHolder"];
|
|
27
|
+
/** Callback when any item's size changes */
|
|
28
|
+
onSizeChanged: ViewHolderProps<TItem>["onSizeChanged"];
|
|
29
|
+
/** Function to render each item */
|
|
30
|
+
renderItem: FlashListProps<TItem>["renderItem"];
|
|
31
|
+
/** Additional data passed to renderItem that can trigger re-renders */
|
|
32
|
+
extraData: any;
|
|
33
|
+
/** Function to get the container's layout dimensions */
|
|
34
|
+
getChildContainerLayout: () => RVDimension | undefined;
|
|
35
|
+
/** Callback after layout effects are committed */
|
|
36
|
+
onCommitLayoutEffect: () => void;
|
|
37
|
+
/** Callback after effects are committed */
|
|
38
|
+
onCommitEffect: () => void;
|
|
39
|
+
/** Optional custom component to wrap each item */
|
|
40
|
+
CellRendererComponent?: FlashListProps<TItem>["CellRendererComponent"];
|
|
41
|
+
/** Optional component to render between items */
|
|
42
|
+
ItemSeparatorComponent?: FlashListProps<TItem>["ItemSeparatorComponent"];
|
|
43
|
+
/** Whether the list is horizontal or vertical */
|
|
44
|
+
horizontal: FlashListProps<TItem>["horizontal"];
|
|
45
|
+
/** Function to get the adjustment margin for the container.
|
|
46
|
+
* For startRenderingFromBottom, we need to adjust the height of the container
|
|
47
|
+
*/
|
|
48
|
+
getAdjustmentMargin: () => number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Ref interface for ViewHolderCollection that exposes methods to control layout updates
|
|
52
|
+
*/
|
|
53
|
+
export interface ViewHolderCollectionRef {
|
|
54
|
+
/** Forces a layout update by triggering a re-render */
|
|
55
|
+
commitLayout: () => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* ViewHolderCollection component that manages the rendering of multiple ViewHolder instances
|
|
59
|
+
* and handles layout updates for the entire collection
|
|
60
|
+
* @template TItem - The type of items in the data array
|
|
61
|
+
*/
|
|
62
|
+
export declare const ViewHolderCollection: <TItem>(props: ViewHolderCollectionProps<TItem>) => React.JSX.Element;
|
|
63
|
+
//# sourceMappingURL=ViewHolderCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewHolderCollection.d.ts","sourceRoot":"","sources":["../../src/recyclerview/ViewHolderCollection.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAA0D,MAAM,OAAO,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAIxE;;;GAGG;AACH,MAAM,WAAW,yBAAyB,CAAC,KAAK;IAC9C,oC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AAO,MAAM,oBAAoB,GAAI,KAAK,EACxC,OAAO,yBAAyB,CAAC,KAAK,CAAC,sBA4HxC,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViewHolderCollection is a container component that manages multiple ViewHolder instances.
|
|
3
|
+
* It handles the rendering of a collection of list items, manages layout updates,
|
|
4
|
+
* and coordinates with the RecyclerView context for layout changes.
|
|
5
|
+
*/
|
|
6
|
+
import React, { useEffect, useImperativeHandle, useLayoutEffect } from "react";
|
|
7
|
+
import { ViewHolder } from "./ViewHolder";
|
|
8
|
+
import { CompatView } from "./components/CompatView";
|
|
9
|
+
import { useRecyclerViewContext } from "./RecyclerViewContextProvider";
|
|
10
|
+
/**
|
|
11
|
+
* ViewHolderCollection component that manages the rendering of multiple ViewHolder instances
|
|
12
|
+
* and handles layout updates for the entire collection
|
|
13
|
+
* @template TItem - The type of items in the data array
|
|
14
|
+
*/
|
|
15
|
+
export const ViewHolderCollection = (props) => {
|
|
16
|
+
const { data, renderStack, getLayout, refHolder, onSizeChanged, renderItem, extraData, viewHolderCollectionRef, getChildContainerLayout, onCommitLayoutEffect, CellRendererComponent, ItemSeparatorComponent, onCommitEffect, horizontal, getAdjustmentMargin, } = props;
|
|
17
|
+
const [renderId, setRenderId] = React.useState(0);
|
|
18
|
+
const containerLayout = getChildContainerLayout();
|
|
19
|
+
const fixedContainerSize = horizontal
|
|
20
|
+
? containerLayout === null || containerLayout === void 0 ? void 0 : containerLayout.height
|
|
21
|
+
: containerLayout === null || containerLayout === void 0 ? void 0 : containerLayout.width;
|
|
22
|
+
const recyclerViewContext = useRecyclerViewContext();
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
if (renderId > 0) {
|
|
25
|
+
// console.log(
|
|
26
|
+
// "parent layout trigger due to child container size change",
|
|
27
|
+
// fixedContainerSize
|
|
28
|
+
// );
|
|
29
|
+
recyclerViewContext === null || recyclerViewContext === void 0 ? void 0 : recyclerViewContext.layout();
|
|
30
|
+
}
|
|
31
|
+
// we need to run this callback on when fixedContainerSize changes
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [fixedContainerSize]);
|
|
34
|
+
useLayoutEffect(() => {
|
|
35
|
+
if (renderId > 0) {
|
|
36
|
+
onCommitLayoutEffect === null || onCommitLayoutEffect === void 0 ? void 0 : onCommitLayoutEffect();
|
|
37
|
+
}
|
|
38
|
+
// we need to run this callback on when renderId changes
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [renderId]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (renderId > 0) {
|
|
43
|
+
onCommitEffect === null || onCommitEffect === void 0 ? void 0 : onCommitEffect();
|
|
44
|
+
}
|
|
45
|
+
// we need to run this callback on when renderId changes
|
|
46
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
+
}, [renderId]);
|
|
48
|
+
// Expose forceUpdate through ref
|
|
49
|
+
useImperativeHandle(viewHolderCollectionRef, () => ({
|
|
50
|
+
commitLayout: () => {
|
|
51
|
+
// This will trigger a re-render of the component
|
|
52
|
+
setRenderId((prev) => prev + 1);
|
|
53
|
+
},
|
|
54
|
+
}), [setRenderId]);
|
|
55
|
+
const hasData = data && data.length > 0;
|
|
56
|
+
const containerStyle = {
|
|
57
|
+
width: horizontal ? containerLayout === null || containerLayout === void 0 ? void 0 : containerLayout.width : undefined,
|
|
58
|
+
height: containerLayout === null || containerLayout === void 0 ? void 0 : containerLayout.height,
|
|
59
|
+
marginTop: horizontal ? undefined : getAdjustmentMargin(),
|
|
60
|
+
marginLeft: horizontal ? getAdjustmentMargin() : undefined,
|
|
61
|
+
// TODO: Temp workaround, useLayoutEffect doesn't block paint in some cases
|
|
62
|
+
// We need to investigate why this is happening
|
|
63
|
+
opacity: renderId > 0 ? 1 : 0,
|
|
64
|
+
};
|
|
65
|
+
// sort by index and log
|
|
66
|
+
// const sortedRenderStack = Array.from(renderStack.entries()).sort(
|
|
67
|
+
// ([, a], [, b]) => a.index - b.index
|
|
68
|
+
// );
|
|
69
|
+
// console.log(
|
|
70
|
+
// "sortedRenderStack",
|
|
71
|
+
// sortedRenderStack.map(([reactKey, { index }]) => {
|
|
72
|
+
// return `${index} => ${reactKey}`;
|
|
73
|
+
// })
|
|
74
|
+
// );
|
|
75
|
+
return (React.createElement(CompatView, { style: hasData && containerStyle }, containerLayout &&
|
|
76
|
+
hasData &&
|
|
77
|
+
Array.from(renderStack.entries(), ([reactKey, { index }]) => {
|
|
78
|
+
const item = data[index];
|
|
79
|
+
const trailingItem = ItemSeparatorComponent
|
|
80
|
+
? data[index + 1]
|
|
81
|
+
: undefined;
|
|
82
|
+
return (React.createElement(ViewHolder, { key: reactKey, index: index, item: item, trailingItem: trailingItem, layout: {
|
|
83
|
+
...getLayout(index),
|
|
84
|
+
}, refHolder: refHolder, onSizeChanged: onSizeChanged, target: "Cell", renderItem: renderItem, extraData: extraData, CellRendererComponent: CellRendererComponent, ItemSeparatorComponent: ItemSeparatorComponent, horizontal: horizontal }));
|
|
85
|
+
})));
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=ViewHolderCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewHolderCollection.js","sourceRoot":"","sources":["../../src/recyclerview/ViewHolderCollection.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAI/E,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAiDvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAAuC,EACvC,EAAE;IACF,MAAM,EACJ,IAAI,EACJ,WAAW,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AAM,YAAY,GAAG,sBAAsB;gBACzC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;gBACjB,CAAC,CAAC,SAAS,CAAC;YACd,OAAO,CACL,oBAAC,UAAU,IACT,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE;oBACN,GAAG,SAAS,CAAC,KAAK,CAAC;iBACpB,EACD,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAC,MAAM,EACb,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,UAAU,EAAE,UAAU,GACtB,CACH,CAAC;QACJ,CAAC,CAAC,CACO,CACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScrollView, Animated } from "react-native";
|
|
2
|
+
declare const AnimatedScrollView: Animated.AnimatedComponent<typeof ScrollView>;
|
|
3
|
+
/** Regular scroll view component */
|
|
4
|
+
export { ScrollView as CompatScroller };
|
|
5
|
+
/** Animated scroll view component for smooth scrolling animations */
|
|
6
|
+
export { AnimatedScrollView as CompatAnimatedScroller };
|
|
7
|
+
//# sourceMappingURL=CompatScroller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompatScroller.d.ts","sourceRoot":"","sources":["../../../src/recyclerview/components/CompatScroller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEpD,QAAA,MAAM,kBAAkB,+CAAsB,CAAC;AAE/C,oCAAoC;AACpC,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,CAAC;AAExC,qEAAqE;AACrE,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScrollView, Animated } from "react-native";
|
|
2
|
+
const AnimatedScrollView = Animated.ScrollView;
|
|
3
|
+
/** Regular scroll view component */
|
|
4
|
+
export { ScrollView as CompatScroller };
|
|
5
|
+
/** Animated scroll view component for smooth scrolling animations */
|
|
6
|
+
export { AnimatedScrollView as CompatAnimatedScroller };
|
|
7
|
+
//# sourceMappingURL=CompatScroller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompatScroller.js","sourceRoot":"","sources":["../../../src/recyclerview/components/CompatScroller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,UAAU,CAAC;AAE/C,oCAAoC;AACpC,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,CAAC;AAExC,qEAAqE;AACrE,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { View, Animated } from "react-native";
|
|
2
|
+
/** Regular view component */
|
|
3
|
+
export { View as CompatView };
|
|
4
|
+
declare const AnimatedView: Animated.AnimatedComponent<typeof View>;
|
|
5
|
+
/** Animated view component for smooth animations */
|
|
6
|
+
export { AnimatedView as CompatAnimatedView };
|
|
7
|
+
//# sourceMappingURL=CompatView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompatView.d.ts","sourceRoot":"","sources":["../../../src/recyclerview/components/CompatView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE9C,6BAA6B;AAC7B,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,CAAC;AAE9B,QAAA,MAAM,YAAY,yCAAgB,CAAC;AAEnC,oDAAoD;AACpD,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { View, Animated } from "react-native";
|
|
2
|
+
/** Regular view component */
|
|
3
|
+
export { View as CompatView };
|
|
4
|
+
const AnimatedView = Animated.View;
|
|
5
|
+
/** Animated view component for smooth animations */
|
|
6
|
+
export { AnimatedView as CompatAnimatedView };
|
|
7
|
+
//# sourceMappingURL=CompatView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompatView.js","sourceRoot":"","sources":["../../../src/recyclerview/components/CompatView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE9C,6BAA6B;AAC7B,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,CAAC;AAE9B,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC;AAEnC,oDAAoD;AACpD,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,CAAC"}
|