react-native-reanimated-carousel 5.0.0-beta.8 → 5.1.0
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 +31 -29
- package/lib/commonjs/components/Carousel.js +1 -1
- package/lib/commonjs/components/Carousel.js.map +1 -1
- package/lib/commonjs/components/CarouselLayout.js +1 -1
- package/lib/commonjs/components/CarouselLayout.js.map +1 -1
- package/lib/commonjs/components/ItemLayout.js +1 -1
- package/lib/commonjs/components/ItemLayout.js.map +1 -1
- package/lib/commonjs/components/ItemRenderer.js +1 -1
- package/lib/commonjs/components/ItemRenderer.js.map +1 -1
- package/lib/commonjs/components/Pagination/PaginationItem.js +2 -0
- package/lib/commonjs/components/Pagination/PaginationItem.js.map +1 -0
- package/lib/commonjs/components/Pagination/index.js +1 -1
- package/lib/commonjs/components/Pagination/index.js.map +1 -1
- package/lib/commonjs/components/ScrollViewGesture.js +1 -1
- package/lib/commonjs/components/ScrollViewGesture.js.map +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
- package/lib/commonjs/hooks/useCarouselController.js +1 -1
- package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
- package/lib/commonjs/hooks/useInitProps.js +1 -1
- package/lib/commonjs/hooks/useInitProps.js.map +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
- package/lib/commonjs/hooks/usePanGestureProxy.js.map +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/commonjs/hooks/useUpdateGestureConfig.js.map +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layouts/index.js.map +1 -1
- package/lib/commonjs/layouts/normal.js +1 -1
- package/lib/commonjs/layouts/normal.js.map +1 -1
- package/lib/commonjs/layouts/parallax.js +1 -1
- package/lib/commonjs/layouts/parallax.js.map +1 -1
- package/lib/commonjs/layouts/stack.js +1 -1
- package/lib/commonjs/layouts/stack.js.map +1 -1
- package/lib/commonjs/public-types.js +2 -0
- package/lib/commonjs/public-types.js.map +1 -0
- package/lib/commonjs/store/index.js.map +1 -1
- package/lib/commonjs/utils/carousel-direction.js +2 -0
- package/lib/commonjs/utils/carousel-direction.js.map +1 -0
- package/lib/commonjs/utils/carousel-math.js +2 -0
- package/lib/commonjs/utils/carousel-math.js.map +1 -0
- package/lib/commonjs/utils/computed-with-auto-fill-data.js.map +1 -1
- package/lib/commonjs/utils/deal-with-animation.js +1 -1
- package/lib/commonjs/utils/deal-with-animation.js.map +1 -1
- package/lib/module/components/Carousel.js +1 -1
- package/lib/module/components/Carousel.js.map +1 -1
- package/lib/module/components/CarouselLayout.js +1 -1
- package/lib/module/components/CarouselLayout.js.map +1 -1
- package/lib/module/components/ItemLayout.js +1 -1
- package/lib/module/components/ItemLayout.js.map +1 -1
- package/lib/module/components/ItemRenderer.js +1 -1
- package/lib/module/components/ItemRenderer.js.map +1 -1
- package/lib/module/components/LazyView.js +1 -1
- package/lib/module/components/LazyView.js.map +1 -1
- package/lib/module/components/Pagination/PaginationItem.js +2 -0
- package/lib/module/components/Pagination/PaginationItem.js.map +1 -0
- package/lib/module/components/Pagination/index.js +1 -1
- package/lib/module/components/Pagination/index.js.map +1 -1
- package/lib/module/components/ScrollViewGesture.js +1 -1
- package/lib/module/components/ScrollViewGesture.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/hooks/useAutoPlay.js +1 -1
- package/lib/module/hooks/useAutoPlay.js.map +1 -1
- package/lib/module/hooks/useCarouselController.js +1 -1
- package/lib/module/hooks/useCarouselController.js.map +1 -1
- package/lib/module/hooks/useCheckMounted.js +1 -1
- package/lib/module/hooks/useCheckMounted.js.map +1 -1
- package/lib/module/hooks/useCommonVariables.js +1 -1
- package/lib/module/hooks/useCommonVariables.js.map +1 -1
- package/lib/module/hooks/useInitProps.js +1 -1
- package/lib/module/hooks/useInitProps.js.map +1 -1
- package/lib/module/hooks/useLayoutConfig.js +1 -1
- package/lib/module/hooks/useLayoutConfig.js.map +1 -1
- package/lib/module/hooks/useOffsetX.js +1 -1
- package/lib/module/hooks/useOffsetX.js.map +1 -1
- package/lib/module/hooks/useOnProgressChange.js +1 -1
- package/lib/module/hooks/useOnProgressChange.js.map +1 -1
- package/lib/module/hooks/usePanGestureProxy.js +1 -1
- package/lib/module/hooks/usePanGestureProxy.js.map +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/module/hooks/useUpdateGestureConfig.js +1 -1
- package/lib/module/hooks/useUpdateGestureConfig.js.map +1 -1
- package/lib/module/hooks/useVisibleRanges.js +1 -1
- package/lib/module/hooks/useVisibleRanges.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layouts/index.js +1 -1
- package/lib/module/layouts/index.js.map +1 -1
- package/lib/module/layouts/normal.js +1 -1
- package/lib/module/layouts/normal.js.map +1 -1
- package/lib/module/layouts/parallax.js +1 -1
- package/lib/module/layouts/parallax.js.map +1 -1
- package/lib/module/layouts/stack.js +1 -1
- package/lib/module/layouts/stack.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/public-types.js +2 -0
- package/lib/module/public-types.js.map +1 -0
- package/lib/module/store/index.js +1 -1
- package/lib/module/store/index.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/utils/carousel-direction.js +2 -0
- package/lib/module/utils/carousel-direction.js.map +1 -0
- package/lib/module/utils/carousel-math.js +2 -0
- package/lib/module/utils/carousel-math.js.map +1 -0
- package/lib/module/utils/compute-gesture-translation.js +1 -1
- package/lib/module/utils/compute-gesture-translation.js.map +1 -1
- package/lib/module/utils/compute-offset-if-size-changed.js +1 -1
- package/lib/module/utils/compute-offset-if-size-changed.js.map +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -1
- package/lib/module/utils/deal-with-animation.js +1 -1
- package/lib/module/utils/deal-with-animation.js.map +1 -1
- package/lib/module/utils/log.js +1 -1
- package/lib/module/utils/log.js.map +1 -1
- package/lib/module/utils/sanitize-animation-style.js +1 -1
- package/lib/module/utils/sanitize-animation-style.js.map +1 -1
- package/lib/typescript/commonjs/components/Carousel.d.ts +8 -0
- package/lib/typescript/commonjs/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/CarouselLayout.d.ts +5 -8
- package/lib/typescript/commonjs/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/ItemLayout.d.ts +21 -0
- package/lib/typescript/commonjs/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts +14 -0
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Pagination/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/ScrollViewGesture.d.ts +3 -4
- package/lib/typescript/commonjs/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/commonjs/constants/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts +29 -0
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts +18 -0
- package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useInitProps.d.ts +25 -0
- package/lib/typescript/commonjs/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts +8 -0
- package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts +13 -0
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts +12 -0
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/{hooks → commonjs/hooks}/usePanGestureProxy.d.ts +4 -3
- package/lib/typescript/commonjs/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts +9 -0
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/{hooks → commonjs/hooks}/useVisibleRanges.d.ts +6 -6
- package/lib/typescript/commonjs/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/{layouts → commonjs/layouts}/index.d.ts +0 -1
- package/lib/typescript/commonjs/layouts/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/normal.d.ts +15 -0
- package/lib/typescript/commonjs/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/parallax.d.ts +27 -0
- package/lib/typescript/commonjs/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/stack.d.ts +10 -0
- package/lib/typescript/commonjs/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/public-types.d.ts +171 -0
- package/lib/typescript/commonjs/public-types.d.ts.map +1 -0
- package/lib/typescript/{store → commonjs/store}/index.d.ts +8 -8
- package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +15 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/carousel-direction.d.ts +9 -0
- package/lib/typescript/commonjs/utils/carousel-direction.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/carousel-math.d.ts +28 -0
- package/lib/typescript/commonjs/utils/carousel-math.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/commonjs/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/log.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/sanitize-animation-style.d.ts.map +1 -0
- package/lib/typescript/module/components/Carousel.d.ts +8 -0
- package/lib/typescript/module/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/module/components/CarouselLayout.d.ts +14 -0
- package/lib/typescript/module/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/module/components/ItemLayout.d.ts +21 -0
- package/lib/typescript/module/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/module/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/module/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/module/components/LazyView.d.ts +8 -0
- package/lib/typescript/module/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts +14 -0
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/module/components/Pagination/index.d.ts +4 -0
- package/lib/typescript/module/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/module/components/ScrollViewGesture.d.ts +18 -0
- package/lib/typescript/module/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/module/constants/index.d.ts +9 -0
- package/lib/typescript/module/constants/index.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/module/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCarouselController.d.ts +29 -0
- package/lib/typescript/module/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCheckMounted.d.ts +3 -0
- package/lib/typescript/module/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCommonVariables.d.ts +18 -0
- package/lib/typescript/module/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useInitProps.d.ts +25 -0
- package/lib/typescript/module/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useLayoutConfig.d.ts +8 -0
- package/lib/typescript/module/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useOffsetX.d.ts +13 -0
- package/lib/typescript/module/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts +12 -0
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts +11 -0
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts +3 -0
- package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts +9 -0
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts +22 -0
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/layouts/index.d.ts +10 -0
- package/lib/typescript/module/layouts/index.d.ts.map +1 -0
- package/lib/typescript/module/layouts/normal.d.ts +15 -0
- package/lib/typescript/module/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/module/layouts/parallax.d.ts +27 -0
- package/lib/typescript/module/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/module/layouts/stack.d.ts +10 -0
- package/lib/typescript/module/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/public-types.d.ts +171 -0
- package/lib/typescript/module/public-types.d.ts.map +1 -0
- package/lib/typescript/module/store/index.d.ts +35 -0
- package/lib/typescript/module/store/index.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +15 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/utils/carousel-direction.d.ts +9 -0
- package/lib/typescript/module/utils/carousel-direction.d.ts.map +1 -0
- package/lib/typescript/module/utils/carousel-math.d.ts +28 -0
- package/lib/typescript/module/utils/carousel-math.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-gesture-translation.d.ts +9 -0
- package/lib/typescript/module/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts +6 -0
- package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts +23 -0
- package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/module/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/module/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/module/utils/log.d.ts +7 -0
- package/lib/typescript/module/utils/log.d.ts.map +1 -0
- package/lib/typescript/module/utils/sanitize-animation-style.d.ts +3 -0
- package/lib/typescript/module/utils/sanitize-animation-style.d.ts.map +1 -0
- package/package.json +31 -6
- package/scripts/codemods/v5.mjs +502 -0
- package/src/components/Carousel.tsx +5 -5
- package/src/components/CarouselLayout.tsx +52 -89
- package/src/components/ItemLayout.tsx +57 -48
- package/src/components/ItemRenderer.tsx +29 -18
- package/src/components/Pagination/PaginationItem.tsx +166 -0
- package/src/components/Pagination/index.tsx +105 -6
- package/src/components/ScrollViewGesture.tsx +92 -177
- package/src/hooks/useAutoPlay.ts +23 -18
- package/src/hooks/useCarouselController.tsx +196 -342
- package/src/hooks/useCommonVariables.ts +159 -71
- package/src/hooks/useInitProps.ts +161 -71
- package/src/hooks/useLayoutConfig.ts +21 -12
- package/src/hooks/useOffsetX.ts +6 -6
- package/src/hooks/useOnProgressChange.ts +23 -48
- package/src/hooks/usePanGestureProxy.ts +8 -8
- package/src/hooks/usePropsErrorBoundary.ts +32 -90
- package/src/hooks/useUpdateGestureConfig.ts +6 -3
- package/src/hooks/useVisibleRanges.tsx +6 -6
- package/src/index.tsx +14 -9
- package/src/layouts/index.tsx +0 -2
- package/src/layouts/normal.ts +14 -4
- package/src/layouts/parallax.ts +32 -59
- package/src/layouts/stack.ts +30 -70
- package/src/public-types.ts +209 -0
- package/src/store/index.tsx +7 -7
- package/src/types.ts +30 -322
- package/src/utils/carousel-direction.ts +39 -0
- package/src/utils/carousel-math.ts +156 -0
- package/src/utils/computed-with-auto-fill-data.ts +2 -2
- package/src/utils/deal-with-animation.ts +11 -9
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js +0 -2
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js.map +0 -1
- package/lib/commonjs/components/Pagination/Basic/index.js +0 -2
- package/lib/commonjs/components/Pagination/Basic/index.js.map +0 -1
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js +0 -2
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js.map +0 -1
- package/lib/commonjs/components/Pagination/Custom/index.js +0 -2
- package/lib/commonjs/components/Pagination/Custom/index.js.map +0 -1
- package/lib/commonjs/utils/compute-offset-if-data-changed.js +0 -2
- package/lib/commonjs/utils/compute-offset-if-data-changed.js.map +0 -1
- package/lib/commonjs/utils/handleroffset-direction.js +0 -2
- package/lib/commonjs/utils/handleroffset-direction.js.map +0 -1
- package/lib/module/components/Pagination/Basic/PaginationItem.js +0 -2
- package/lib/module/components/Pagination/Basic/PaginationItem.js.map +0 -1
- package/lib/module/components/Pagination/Basic/index.js +0 -2
- package/lib/module/components/Pagination/Basic/index.js.map +0 -1
- package/lib/module/components/Pagination/Custom/PaginationItem.js +0 -2
- package/lib/module/components/Pagination/Custom/PaginationItem.js.map +0 -1
- package/lib/module/components/Pagination/Custom/index.js +0 -2
- package/lib/module/components/Pagination/Custom/index.js.map +0 -1
- package/lib/module/utils/compute-offset-if-data-changed.js +0 -2
- package/lib/module/utils/compute-offset-if-data-changed.js.map +0 -1
- package/lib/module/utils/handleroffset-direction.js +0 -2
- package/lib/module/utils/handleroffset-direction.js.map +0 -1
- package/lib/typescript/components/Carousel.d.ts +0 -8
- package/lib/typescript/components/Carousel.d.ts.map +0 -1
- package/lib/typescript/components/CarouselLayout.d.ts.map +0 -1
- package/lib/typescript/components/ItemLayout.d.ts +0 -20
- package/lib/typescript/components/ItemLayout.d.ts.map +0 -1
- package/lib/typescript/components/ItemRenderer.d.ts +0 -23
- package/lib/typescript/components/ItemRenderer.d.ts.map +0 -1
- package/lib/typescript/components/LazyView.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts +0 -29
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Basic/index.d.ts +0 -23
- package/lib/typescript/components/Pagination/Basic/index.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts +0 -35
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Custom/index.d.ts +0 -26
- package/lib/typescript/components/Pagination/Custom/index.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/index.d.ts +0 -5
- package/lib/typescript/components/Pagination/index.d.ts.map +0 -1
- package/lib/typescript/components/ScrollViewGesture.d.ts.map +0 -1
- package/lib/typescript/constants/index.d.ts.map +0 -1
- package/lib/typescript/hooks/useAutoPlay.d.ts +0 -12
- package/lib/typescript/hooks/useAutoPlay.d.ts.map +0 -1
- package/lib/typescript/hooks/useCarouselController.d.ts +0 -28
- package/lib/typescript/hooks/useCarouselController.d.ts.map +0 -1
- package/lib/typescript/hooks/useCheckMounted.d.ts.map +0 -1
- package/lib/typescript/hooks/useCommonVariables.d.ts +0 -13
- package/lib/typescript/hooks/useCommonVariables.d.ts.map +0 -1
- package/lib/typescript/hooks/useInitProps.d.ts +0 -10
- package/lib/typescript/hooks/useInitProps.d.ts.map +0 -1
- package/lib/typescript/hooks/useLayoutConfig.d.ts +0 -8
- package/lib/typescript/hooks/useLayoutConfig.d.ts.map +0 -1
- package/lib/typescript/hooks/useOffsetX.d.ts +0 -13
- package/lib/typescript/hooks/useOffsetX.d.ts.map +0 -1
- package/lib/typescript/hooks/useOnProgressChange.d.ts +0 -11
- package/lib/typescript/hooks/useOnProgressChange.d.ts.map +0 -1
- package/lib/typescript/hooks/usePanGestureProxy.d.ts.map +0 -1
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +0 -5
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts.map +0 -1
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts +0 -6
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts.map +0 -1
- package/lib/typescript/hooks/useVisibleRanges.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -7
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/layouts/index.d.ts.map +0 -1
- package/lib/typescript/layouts/normal.d.ts +0 -13
- package/lib/typescript/layouts/normal.d.ts.map +0 -1
- package/lib/typescript/layouts/parallax.d.ts +0 -47
- package/lib/typescript/layouts/parallax.d.ts.map +0 -1
- package/lib/typescript/layouts/stack.d.ts +0 -38
- package/lib/typescript/layouts/stack.d.ts.map +0 -1
- package/lib/typescript/store/index.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -302
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/utils/compute-gesture-translation.d.ts.map +0 -1
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts +0 -9
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts.map +0 -1
- package/lib/typescript/utils/compute-offset-if-size-changed.d.ts.map +0 -1
- package/lib/typescript/utils/computed-with-auto-fill-data.d.ts.map +0 -1
- package/lib/typescript/utils/deal-with-animation.d.ts +0 -3
- package/lib/typescript/utils/deal-with-animation.d.ts.map +0 -1
- package/lib/typescript/utils/handleroffset-direction.d.ts +0 -4
- package/lib/typescript/utils/handleroffset-direction.d.ts.map +0 -1
- package/lib/typescript/utils/log.d.ts.map +0 -1
- package/lib/typescript/utils/sanitize-animation-style.d.ts.map +0 -1
- package/src/components/Pagination/Basic/PaginationItem.tsx +0 -149
- package/src/components/Pagination/Basic/index.tsx +0 -98
- package/src/components/Pagination/Custom/PaginationItem.tsx +0 -166
- package/src/components/Pagination/Custom/index.tsx +0 -111
- package/src/utils/compute-offset-if-data-changed.ts +0 -44
- package/src/utils/handleroffset-direction.ts +0 -18
- /package/lib/typescript/{components → commonjs/components}/LazyView.d.ts +0 -0
- /package/lib/typescript/{constants → commonjs/constants}/index.d.ts +0 -0
- /package/lib/typescript/{hooks → commonjs/hooks}/useCheckMounted.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/compute-gesture-translation.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/compute-offset-if-size-changed.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/computed-with-auto-fill-data.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/log.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/sanitize-animation-style.d.ts +0 -0
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import ts from "typescript";
|
|
8
|
+
|
|
9
|
+
const packageName = "react-native-reanimated-carousel";
|
|
10
|
+
const migrationPrompt = [
|
|
11
|
+
"Read https://rn-carousel.dev/migration-v5.md and upgrade",
|
|
12
|
+
"react-native-reanimated-carousel to v5 in this project, then summarize",
|
|
13
|
+
"what changed for my review.",
|
|
14
|
+
].join(" ");
|
|
15
|
+
const supportedExtensions = new Set([".js", ".jsx", ".ts", ".tsx"]);
|
|
16
|
+
const directPropRenames = new Map([
|
|
17
|
+
["autoPlay", "autoplay"],
|
|
18
|
+
["autoPlayInterval", "autoplayInterval"],
|
|
19
|
+
["customAnimation", "itemAnimation"],
|
|
20
|
+
["defaultScrollOffsetValue", "scrollOffsetValue"],
|
|
21
|
+
["enabled", "scrollEnabled"],
|
|
22
|
+
["windowSize", "renderWindowSize"],
|
|
23
|
+
]);
|
|
24
|
+
const exportedTypeRenames = new Map([
|
|
25
|
+
["ICarouselInstance", "CarouselRef"],
|
|
26
|
+
["ILayoutConfig", "CarouselLayout"],
|
|
27
|
+
["TAnimationStyle", "CarouselItemAnimation"],
|
|
28
|
+
["TCarouselProps", "CarouselProps"],
|
|
29
|
+
]);
|
|
30
|
+
const manualMigrationProps = new Set([
|
|
31
|
+
"autoFillData",
|
|
32
|
+
"customConfig",
|
|
33
|
+
"fixedDirection",
|
|
34
|
+
"height",
|
|
35
|
+
"maxScrollDistancePerSwipe",
|
|
36
|
+
"minScrollDistancePerSwipe",
|
|
37
|
+
"mode",
|
|
38
|
+
"modeConfig",
|
|
39
|
+
"onScrollEnd",
|
|
40
|
+
"scrollAnimationDuration",
|
|
41
|
+
"width",
|
|
42
|
+
"withAnimation",
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
function scriptKind(fileName) {
|
|
46
|
+
if (fileName.endsWith(".tsx")) return ts.ScriptKind.TSX;
|
|
47
|
+
if (fileName.endsWith(".jsx")) return ts.ScriptKind.JSX;
|
|
48
|
+
if (fileName.endsWith(".ts")) return ts.ScriptKind.TS;
|
|
49
|
+
return ts.ScriptKind.JS;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function importName(specifier) {
|
|
53
|
+
return (specifier.propertyName ?? specifier.name).text;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function jsxAttributeName(attribute) {
|
|
57
|
+
return ts.isJsxAttribute(attribute) && ts.isIdentifier(attribute.name)
|
|
58
|
+
? attribute.name.text
|
|
59
|
+
: undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function expressionFromBooleanAttribute(attribute) {
|
|
63
|
+
if (!attribute.initializer) return ts.factory.createTrue();
|
|
64
|
+
if (ts.isJsxExpression(attribute.initializer)) {
|
|
65
|
+
return attribute.initializer.expression ?? ts.factory.createTrue();
|
|
66
|
+
}
|
|
67
|
+
if (ts.isStringLiteral(attribute.initializer)) {
|
|
68
|
+
if (attribute.initializer.text === "false") return ts.factory.createFalse();
|
|
69
|
+
if (attribute.initializer.text === "true") return ts.factory.createTrue();
|
|
70
|
+
}
|
|
71
|
+
return ts.factory.createTrue();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function enumAttribute(name, condition, whenTrue, whenFalse) {
|
|
75
|
+
if (condition.kind === ts.SyntaxKind.TrueKeyword) {
|
|
76
|
+
return ts.factory.createJsxAttribute(
|
|
77
|
+
ts.factory.createIdentifier(name),
|
|
78
|
+
ts.factory.createStringLiteral(whenTrue)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (condition.kind === ts.SyntaxKind.FalseKeyword) {
|
|
82
|
+
return ts.factory.createJsxAttribute(
|
|
83
|
+
ts.factory.createIdentifier(name),
|
|
84
|
+
ts.factory.createStringLiteral(whenFalse)
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return ts.factory.createJsxAttribute(
|
|
89
|
+
ts.factory.createIdentifier(name),
|
|
90
|
+
ts.factory.createJsxExpression(
|
|
91
|
+
undefined,
|
|
92
|
+
ts.factory.createConditionalExpression(
|
|
93
|
+
condition,
|
|
94
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
95
|
+
ts.factory.createStringLiteral(whenTrue),
|
|
96
|
+
ts.factory.createToken(ts.SyntaxKind.ColonToken),
|
|
97
|
+
ts.factory.createStringLiteral(whenFalse)
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function renamedAttribute(attribute, name) {
|
|
104
|
+
return ts.factory.updateJsxAttribute(
|
|
105
|
+
attribute,
|
|
106
|
+
ts.factory.createIdentifier(name),
|
|
107
|
+
attribute.initializer
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function itemSizeAttribute(attributes) {
|
|
112
|
+
const itemWidth = attributes.find((attribute) => jsxAttributeName(attribute) === "itemWidth");
|
|
113
|
+
const itemHeight = attributes.find((attribute) => jsxAttributeName(attribute) === "itemHeight");
|
|
114
|
+
if (!itemWidth && !itemHeight) return undefined;
|
|
115
|
+
|
|
116
|
+
const vertical = attributes.find((attribute) => jsxAttributeName(attribute) === "vertical");
|
|
117
|
+
const verticalCondition = vertical
|
|
118
|
+
? expressionFromBooleanAttribute(vertical)
|
|
119
|
+
: ts.factory.createFalse();
|
|
120
|
+
|
|
121
|
+
let initializer;
|
|
122
|
+
if (itemWidth && itemHeight) {
|
|
123
|
+
if (verticalCondition.kind === ts.SyntaxKind.TrueKeyword) initializer = itemHeight.initializer;
|
|
124
|
+
else if (verticalCondition.kind === ts.SyntaxKind.FalseKeyword) initializer = itemWidth.initializer;
|
|
125
|
+
else {
|
|
126
|
+
const widthExpression = expressionFromBooleanAttribute(itemWidth);
|
|
127
|
+
const heightExpression = expressionFromBooleanAttribute(itemHeight);
|
|
128
|
+
initializer = ts.factory.createJsxExpression(
|
|
129
|
+
undefined,
|
|
130
|
+
ts.factory.createConditionalExpression(
|
|
131
|
+
verticalCondition,
|
|
132
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
133
|
+
heightExpression,
|
|
134
|
+
ts.factory.createToken(ts.SyntaxKind.ColonToken),
|
|
135
|
+
widthExpression
|
|
136
|
+
)
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
initializer = (itemWidth ?? itemHeight).initializer;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return ts.factory.createJsxAttribute(
|
|
144
|
+
ts.factory.createIdentifier("itemSize"),
|
|
145
|
+
initializer ?? ts.factory.createJsxExpression(undefined, ts.factory.createTrue())
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function snapModeAttribute(attributes) {
|
|
150
|
+
const snap = attributes.find((attribute) =>
|
|
151
|
+
["enableSnap", "snapEnabled"].includes(jsxAttributeName(attribute) ?? "")
|
|
152
|
+
);
|
|
153
|
+
const paging = attributes.find((attribute) => jsxAttributeName(attribute) === "pagingEnabled");
|
|
154
|
+
if (!snap && !paging) return undefined;
|
|
155
|
+
|
|
156
|
+
const snapCondition = snap
|
|
157
|
+
? expressionFromBooleanAttribute(snap)
|
|
158
|
+
: ts.factory.createTrue();
|
|
159
|
+
const pagingCondition = paging
|
|
160
|
+
? expressionFromBooleanAttribute(paging)
|
|
161
|
+
: ts.factory.createTrue();
|
|
162
|
+
|
|
163
|
+
if (snapCondition.kind === ts.SyntaxKind.FalseKeyword) {
|
|
164
|
+
return ts.factory.createJsxAttribute(
|
|
165
|
+
ts.factory.createIdentifier("snapMode"),
|
|
166
|
+
ts.factory.createStringLiteral("none")
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
if (
|
|
170
|
+
snapCondition.kind === ts.SyntaxKind.TrueKeyword &&
|
|
171
|
+
pagingCondition.kind === ts.SyntaxKind.TrueKeyword
|
|
172
|
+
) {
|
|
173
|
+
return ts.factory.createJsxAttribute(
|
|
174
|
+
ts.factory.createIdentifier("snapMode"),
|
|
175
|
+
ts.factory.createStringLiteral("page")
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
if (
|
|
179
|
+
snapCondition.kind === ts.SyntaxKind.TrueKeyword &&
|
|
180
|
+
pagingCondition.kind === ts.SyntaxKind.FalseKeyword
|
|
181
|
+
) {
|
|
182
|
+
return ts.factory.createJsxAttribute(
|
|
183
|
+
ts.factory.createIdentifier("snapMode"),
|
|
184
|
+
ts.factory.createStringLiteral("nearest")
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const modeExpression = ts.factory.createConditionalExpression(
|
|
189
|
+
pagingCondition,
|
|
190
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
191
|
+
ts.factory.createStringLiteral("page"),
|
|
192
|
+
ts.factory.createToken(ts.SyntaxKind.ColonToken),
|
|
193
|
+
ts.factory.createStringLiteral("nearest")
|
|
194
|
+
);
|
|
195
|
+
const expression =
|
|
196
|
+
snapCondition.kind === ts.SyntaxKind.TrueKeyword
|
|
197
|
+
? modeExpression
|
|
198
|
+
: ts.factory.createConditionalExpression(
|
|
199
|
+
snapCondition,
|
|
200
|
+
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
201
|
+
modeExpression,
|
|
202
|
+
ts.factory.createToken(ts.SyntaxKind.ColonToken),
|
|
203
|
+
ts.factory.createStringLiteral("none")
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
return ts.factory.createJsxAttribute(
|
|
207
|
+
ts.factory.createIdentifier("snapMode"),
|
|
208
|
+
ts.factory.createJsxExpression(undefined, expression)
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function migrateCarouselAttributes(properties, warnings, markChanged) {
|
|
213
|
+
const attributes = [...properties.properties];
|
|
214
|
+
const output = [];
|
|
215
|
+
const hasLoop = attributes.some((attribute) => jsxAttributeName(attribute) === "loop");
|
|
216
|
+
const generatedItemSize = itemSizeAttribute(attributes);
|
|
217
|
+
const generatedSnapMode = snapModeAttribute(attributes);
|
|
218
|
+
|
|
219
|
+
for (const attribute of attributes) {
|
|
220
|
+
const name = jsxAttributeName(attribute);
|
|
221
|
+
if (!name) {
|
|
222
|
+
output.push(attribute);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (name === "itemWidth" || name === "itemHeight") {
|
|
226
|
+
markChanged();
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (name === "enableSnap" || name === "snapEnabled" || name === "pagingEnabled") {
|
|
230
|
+
markChanged();
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (name === "vertical") {
|
|
235
|
+
markChanged();
|
|
236
|
+
output.push(
|
|
237
|
+
enumAttribute(
|
|
238
|
+
"orientation",
|
|
239
|
+
expressionFromBooleanAttribute(attribute),
|
|
240
|
+
"vertical",
|
|
241
|
+
"horizontal"
|
|
242
|
+
)
|
|
243
|
+
);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (name === "autoPlayReverse") {
|
|
247
|
+
markChanged();
|
|
248
|
+
output.push(
|
|
249
|
+
enumAttribute(
|
|
250
|
+
"autoplayDirection",
|
|
251
|
+
expressionFromBooleanAttribute(attribute),
|
|
252
|
+
"backward",
|
|
253
|
+
"forward"
|
|
254
|
+
)
|
|
255
|
+
);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (directPropRenames.has(name)) {
|
|
259
|
+
markChanged();
|
|
260
|
+
output.push(renamedAttribute(attribute, directPropRenames.get(name)));
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (manualMigrationProps.has(name)) warnings.add(name);
|
|
264
|
+
output.push(attribute);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (generatedItemSize) output.push(generatedItemSize);
|
|
268
|
+
if (generatedSnapMode) output.push(generatedSnapMode);
|
|
269
|
+
if (!hasLoop) {
|
|
270
|
+
markChanged();
|
|
271
|
+
output.push(
|
|
272
|
+
ts.factory.createJsxAttribute(
|
|
273
|
+
ts.factory.createIdentifier("loop"),
|
|
274
|
+
ts.factory.createJsxExpression(undefined, ts.factory.createTrue())
|
|
275
|
+
)
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return ts.factory.updateJsxAttributes(properties, output);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function transformSource(source, fileName = "source.tsx") {
|
|
283
|
+
const sourceFile = ts.createSourceFile(
|
|
284
|
+
fileName,
|
|
285
|
+
source,
|
|
286
|
+
ts.ScriptTarget.Latest,
|
|
287
|
+
true,
|
|
288
|
+
scriptKind(fileName)
|
|
289
|
+
);
|
|
290
|
+
const carouselNames = new Set();
|
|
291
|
+
const warnings = new Set();
|
|
292
|
+
let didTransform = false;
|
|
293
|
+
|
|
294
|
+
for (const statement of sourceFile.statements) {
|
|
295
|
+
if (
|
|
296
|
+
!ts.isImportDeclaration(statement) ||
|
|
297
|
+
!ts.isStringLiteral(statement.moduleSpecifier) ||
|
|
298
|
+
statement.moduleSpecifier.text !== packageName
|
|
299
|
+
) {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const clause = statement.importClause;
|
|
304
|
+
if (clause?.name) carouselNames.add(clause.name.text);
|
|
305
|
+
if (clause?.namedBindings && ts.isNamedImports(clause.namedBindings)) {
|
|
306
|
+
for (const specifier of clause.namedBindings.elements) {
|
|
307
|
+
if (importName(specifier) === "Carousel") carouselNames.add(specifier.name.text);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const transformer = (context) => {
|
|
313
|
+
const visit = (node) => {
|
|
314
|
+
if (
|
|
315
|
+
ts.isImportDeclaration(node) &&
|
|
316
|
+
ts.isStringLiteral(node.moduleSpecifier) &&
|
|
317
|
+
node.moduleSpecifier.text === packageName &&
|
|
318
|
+
node.importClause
|
|
319
|
+
) {
|
|
320
|
+
const clause = node.importClause;
|
|
321
|
+
const elements =
|
|
322
|
+
clause.namedBindings && ts.isNamedImports(clause.namedBindings)
|
|
323
|
+
? [...clause.namedBindings.elements]
|
|
324
|
+
: [];
|
|
325
|
+
|
|
326
|
+
const migratedElements = elements.map((specifier) => {
|
|
327
|
+
const currentImport = importName(specifier);
|
|
328
|
+
const replacement = exportedTypeRenames.get(currentImport);
|
|
329
|
+
if (!replacement) return specifier;
|
|
330
|
+
didTransform = true;
|
|
331
|
+
return ts.factory.updateImportSpecifier(
|
|
332
|
+
specifier,
|
|
333
|
+
specifier.isTypeOnly,
|
|
334
|
+
ts.factory.createIdentifier(replacement),
|
|
335
|
+
specifier.name
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
if (clause.name) {
|
|
340
|
+
didTransform = true;
|
|
341
|
+
const duplicate = migratedElements.some(
|
|
342
|
+
(specifier) =>
|
|
343
|
+
importName(specifier) === "Carousel" && specifier.name.text === clause.name.text
|
|
344
|
+
);
|
|
345
|
+
if (!duplicate) {
|
|
346
|
+
migratedElements.unshift(
|
|
347
|
+
ts.factory.createImportSpecifier(
|
|
348
|
+
false,
|
|
349
|
+
clause.name.text === "Carousel"
|
|
350
|
+
? undefined
|
|
351
|
+
: ts.factory.createIdentifier("Carousel"),
|
|
352
|
+
clause.name
|
|
353
|
+
)
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (!didTransform) return node;
|
|
359
|
+
|
|
360
|
+
return ts.factory.updateImportDeclaration(
|
|
361
|
+
node,
|
|
362
|
+
node.modifiers,
|
|
363
|
+
ts.factory.updateImportClause(
|
|
364
|
+
clause,
|
|
365
|
+
clause.isTypeOnly,
|
|
366
|
+
undefined,
|
|
367
|
+
ts.factory.createNamedImports(migratedElements)
|
|
368
|
+
),
|
|
369
|
+
node.moduleSpecifier,
|
|
370
|
+
node.attributes
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (
|
|
375
|
+
ts.isJsxSelfClosingElement(node) &&
|
|
376
|
+
ts.isIdentifier(node.tagName) &&
|
|
377
|
+
carouselNames.has(node.tagName.text)
|
|
378
|
+
) {
|
|
379
|
+
return ts.factory.updateJsxSelfClosingElement(
|
|
380
|
+
node,
|
|
381
|
+
node.tagName,
|
|
382
|
+
node.typeArguments,
|
|
383
|
+
migrateCarouselAttributes(node.attributes, warnings, () => {
|
|
384
|
+
didTransform = true;
|
|
385
|
+
})
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (
|
|
390
|
+
ts.isJsxOpeningElement(node) &&
|
|
391
|
+
ts.isIdentifier(node.tagName) &&
|
|
392
|
+
carouselNames.has(node.tagName.text)
|
|
393
|
+
) {
|
|
394
|
+
return ts.factory.updateJsxOpeningElement(
|
|
395
|
+
node,
|
|
396
|
+
node.tagName,
|
|
397
|
+
node.typeArguments,
|
|
398
|
+
migrateCarouselAttributes(node.attributes, warnings, () => {
|
|
399
|
+
didTransform = true;
|
|
400
|
+
})
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return ts.visitEachChild(node, visit, context);
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
return (root) => ts.visitNode(root, visit);
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
const result = ts.transform(sourceFile, [transformer]);
|
|
411
|
+
const transformed = result.transformed[0];
|
|
412
|
+
const output = didTransform
|
|
413
|
+
? ts
|
|
414
|
+
.createPrinter({ newLine: ts.NewLineKind.LineFeed })
|
|
415
|
+
.printFile(transformed)
|
|
416
|
+
.replace(/[ \t]+$/gm, "")
|
|
417
|
+
: source;
|
|
418
|
+
result.dispose();
|
|
419
|
+
|
|
420
|
+
return {
|
|
421
|
+
changed: didTransform && output.trimEnd() !== source.trimEnd(),
|
|
422
|
+
code: output,
|
|
423
|
+
warnings: [...warnings].sort(),
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
async function collectFiles(inputPath) {
|
|
428
|
+
const metadata = await stat(inputPath);
|
|
429
|
+
if (metadata.isFile()) {
|
|
430
|
+
return supportedExtensions.has(path.extname(inputPath)) ? [inputPath] : [];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const files = [];
|
|
434
|
+
for (const entry of await readdir(inputPath, { withFileTypes: true })) {
|
|
435
|
+
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
436
|
+
files.push(...(await collectFiles(path.join(inputPath, entry.name))));
|
|
437
|
+
}
|
|
438
|
+
return files;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export function completionOutput(dryRun) {
|
|
442
|
+
return [
|
|
443
|
+
dryRun
|
|
444
|
+
? "Mechanical migration preview complete; no files were written."
|
|
445
|
+
: "Mechanical migration complete.",
|
|
446
|
+
"Behavioral migration review is still required. Give this prompt to your AI agent:",
|
|
447
|
+
migrationPrompt,
|
|
448
|
+
].join("\n");
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async function main() {
|
|
452
|
+
const args = process.argv.slice(2);
|
|
453
|
+
const dryRun = args.includes("--dry");
|
|
454
|
+
const inputs = args.filter((arg) => arg !== "--dry");
|
|
455
|
+
if (inputs.length === 0) {
|
|
456
|
+
console.error("Usage: node scripts/codemods/v5.mjs [--dry] <file-or-directory> [...]");
|
|
457
|
+
process.exitCode = 2;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const files = (
|
|
462
|
+
await Promise.all(inputs.map((input) => collectFiles(path.resolve(process.cwd(), input))))
|
|
463
|
+
).flat();
|
|
464
|
+
let changed = 0;
|
|
465
|
+
|
|
466
|
+
for (const file of files) {
|
|
467
|
+
const source = await readFile(file, "utf8");
|
|
468
|
+
const result = transformSource(source, file);
|
|
469
|
+
if (!result.changed) {
|
|
470
|
+
if (result.warnings.length > 0) {
|
|
471
|
+
const relative = path.relative(process.cwd(), file);
|
|
472
|
+
console.warn(`review ${relative}`);
|
|
473
|
+
console.warn(
|
|
474
|
+
` manual migration still required for: ${result.warnings.map((name) => `\`${name}\``).join(", ")}`
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
changed += 1;
|
|
480
|
+
if (!dryRun) await writeFile(file, result.code);
|
|
481
|
+
const relative = path.relative(process.cwd(), file);
|
|
482
|
+
console.log(`${dryRun ? "would update" : "updated"} ${relative}`);
|
|
483
|
+
if (result.warnings.length > 0) {
|
|
484
|
+
console.warn(
|
|
485
|
+
` manual migration still required for: ${result.warnings.map((name) => `\`${name}\``).join(", ")}`
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
console.log(`${dryRun ? "would update" : "updated"} ${changed} file(s)`);
|
|
491
|
+
console.log(completionOutput(dryRun));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (
|
|
495
|
+
process.argv[1] &&
|
|
496
|
+
realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))
|
|
497
|
+
) {
|
|
498
|
+
main().catch((error) => {
|
|
499
|
+
console.error(error.stack ?? error.message);
|
|
500
|
+
process.exitCode = 1;
|
|
501
|
+
});
|
|
502
|
+
}
|
|
@@ -3,10 +3,10 @@ import { useCommonVariables } from "../hooks/useCommonVariables";
|
|
|
3
3
|
import { useInitProps } from "../hooks/useInitProps";
|
|
4
4
|
import { usePropsErrorBoundary } from "../hooks/usePropsErrorBoundary";
|
|
5
5
|
import { GlobalStateProvider } from "../store";
|
|
6
|
-
import type {
|
|
6
|
+
import type { CarouselProps, CarouselRef } from "../types";
|
|
7
7
|
import { CarouselLayout } from "./CarouselLayout";
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const CarouselImpl = React.forwardRef<CarouselRef, CarouselProps<unknown>>((_props, ref) => {
|
|
10
10
|
const props = useInitProps(_props);
|
|
11
11
|
const { dataLength } = props;
|
|
12
12
|
const commonVariables = useCommonVariables(props);
|
|
@@ -20,9 +20,9 @@ const Carousel = React.forwardRef<ICarouselInstance, TCarouselProps<any>>((_prop
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
type CarouselComponent = <T>(
|
|
23
|
-
props:
|
|
24
|
-
ref?: React.Ref<
|
|
23
|
+
props: CarouselProps<T> & {
|
|
24
|
+
ref?: React.Ref<CarouselRef>;
|
|
25
25
|
}
|
|
26
26
|
) => React.ReactElement;
|
|
27
27
|
|
|
28
|
-
export
|
|
28
|
+
export const Carousel = CarouselImpl as CarouselComponent;
|