react-native-reanimated 3.4.1 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/lib/module/Animated.js +60 -1
  2. package/lib/module/Animated.js.map +1 -1
  3. package/lib/module/createAnimatedComponent.js.map +1 -1
  4. package/lib/module/reanimated2/Easing.js +8 -0
  5. package/lib/module/reanimated2/Easing.js.map +1 -1
  6. package/lib/module/reanimated2/UpdateProps.js +2 -2
  7. package/lib/module/reanimated2/UpdateProps.js.map +1 -1
  8. package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
  9. package/lib/module/reanimated2/animation/decay.js.map +1 -1
  10. package/lib/module/reanimated2/animation/index.js +1 -1
  11. package/lib/module/reanimated2/animation/index.js.map +1 -1
  12. package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
  13. package/lib/module/reanimated2/animation/styleAnimation.js +2 -2
  14. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  15. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  16. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +6 -0
  17. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
  18. package/lib/module/reanimated2/animation/util.js +4 -19
  19. package/lib/module/reanimated2/animation/util.js.map +1 -1
  20. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  21. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  22. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  23. package/lib/module/reanimated2/fabricUtils.js +3 -1
  24. package/lib/module/reanimated2/fabricUtils.js.map +1 -1
  25. package/lib/module/reanimated2/globals.d.js.map +1 -1
  26. package/lib/module/reanimated2/helperTypes.js.map +1 -1
  27. package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
  28. package/lib/module/reanimated2/hook/index.js.map +1 -1
  29. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -1
  30. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  31. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  32. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  33. package/lib/module/reanimated2/hook/useAnimatedStyle.js +1 -1
  34. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  35. package/lib/module/reanimated2/hook/utils.js +2 -27
  36. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  37. package/lib/module/reanimated2/index.js.map +1 -1
  38. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  39. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  40. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  41. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  42. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  43. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  44. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  45. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  46. package/lib/module/reanimated2/mappers.js +1 -1
  47. package/lib/module/reanimated2/mappers.js.map +1 -1
  48. package/lib/module/reanimated2/mock.js +26 -0
  49. package/lib/module/reanimated2/mock.js.map +1 -1
  50. package/lib/module/reanimated2/mutables.js +0 -1
  51. package/lib/module/reanimated2/mutables.js.map +1 -1
  52. package/lib/module/reanimated2/platform-specific/checkCppVersion.js +3 -0
  53. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
  54. package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
  55. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
  56. package/lib/module/reanimated2/valueSetter.js +0 -1
  57. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  58. package/lib/module/setAndForwardRef.js.map +1 -1
  59. package/lib/typescript/Animated.d.ts +68 -3
  60. package/lib/typescript/createAnimatedComponent.d.ts +1 -26
  61. package/lib/typescript/reanimated2/Easing.d.ts +17 -9
  62. package/lib/typescript/reanimated2/UpdateProps.d.ts +5 -5
  63. package/lib/typescript/reanimated2/animation/commonTypes.d.ts +4 -3
  64. package/lib/typescript/reanimated2/animation/decay.d.ts +2 -4
  65. package/lib/typescript/reanimated2/animation/index.d.ts +3 -3
  66. package/lib/typescript/reanimated2/animation/springUtils.d.ts +1 -0
  67. package/lib/typescript/reanimated2/animation/styleAnimation.d.ts +2 -6
  68. package/lib/typescript/reanimated2/animation/timing.d.ts +4 -7
  69. package/lib/typescript/reanimated2/animation/transformationMatrix/matrixUtils.d.ts +1 -1
  70. package/lib/typescript/reanimated2/animation/util.d.ts +2 -4
  71. package/lib/typescript/reanimated2/commonTypes.d.ts +0 -4
  72. package/lib/typescript/reanimated2/component/FlatList.d.ts +2 -1
  73. package/lib/typescript/reanimated2/component/ScrollView.d.ts +1 -1
  74. package/lib/typescript/reanimated2/helperTypes.d.ts +11 -7
  75. package/lib/typescript/reanimated2/hook/commonTypes.d.ts +2 -2
  76. package/lib/typescript/reanimated2/hook/index.d.ts +1 -1
  77. package/lib/typescript/reanimated2/hook/useAnimatedGestureHandler.d.ts +2 -2
  78. package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +4 -4
  79. package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +4 -5
  80. package/lib/typescript/reanimated2/hook/utils.d.ts +3 -11
  81. package/lib/typescript/reanimated2/index.d.ts +3 -1
  82. package/lib/typescript/reanimated2/interpolateColor.d.ts +2 -3
  83. package/lib/typescript/reanimated2/js-reanimated/commonTypes.d.ts +1 -43
  84. package/lib/typescript/reanimated2/js-reanimated/index.d.ts +3 -2
  85. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +4 -4
  86. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -11
  87. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +3 -3
  88. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +13 -13
  89. package/lib/typescript/reanimated2/layoutReanimation/index.d.ts +1 -0
  90. package/lib/typescript/reanimated2/mappers.d.ts +0 -12
  91. package/lib/typescript/reanimated2/mock.d.ts +1 -76
  92. package/lib/typescript/reanimated2/mutables.d.ts +0 -1
  93. package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
  94. package/lib/typescript/reanimated2/valueSetter.d.ts +0 -1
  95. package/lib/typescript/setAndForwardRef.d.ts +1 -1
  96. package/package.json +3 -1
  97. package/src/Animated.ts +80 -6
  98. package/src/createAnimatedComponent.tsx +2 -2
  99. package/src/reanimated2/Easing.ts +18 -8
  100. package/src/reanimated2/UpdateProps.ts +13 -17
  101. package/src/reanimated2/animation/commonTypes.ts +3 -3
  102. package/src/reanimated2/animation/decay.ts +3 -1
  103. package/src/reanimated2/animation/index.ts +3 -3
  104. package/src/reanimated2/animation/springUtils.ts +2 -0
  105. package/src/reanimated2/animation/styleAnimation.ts +5 -5
  106. package/src/reanimated2/animation/timing.ts +6 -4
  107. package/src/reanimated2/animation/transformationMatrix/matrixUtils.tsx +4 -1
  108. package/src/reanimated2/animation/util.ts +5 -29
  109. package/src/reanimated2/commonTypes.ts +0 -25
  110. package/src/reanimated2/component/FlatList.tsx +3 -1
  111. package/src/reanimated2/component/ScrollView.tsx +1 -1
  112. package/src/reanimated2/fabricUtils.ts +1 -0
  113. package/src/reanimated2/globals.d.ts +3 -3
  114. package/src/reanimated2/helperTypes.ts +17 -7
  115. package/src/reanimated2/hook/commonTypes.ts +2 -3
  116. package/src/reanimated2/hook/index.ts +4 -1
  117. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +2 -2
  118. package/src/reanimated2/hook/useAnimatedRef.ts +13 -10
  119. package/src/reanimated2/hook/useAnimatedStyle.ts +27 -26
  120. package/src/reanimated2/hook/utils.ts +5 -31
  121. package/src/reanimated2/index.ts +13 -1
  122. package/src/reanimated2/interpolateColor.ts +2 -2
  123. package/src/reanimated2/js-reanimated/commonTypes.ts +3 -3
  124. package/src/reanimated2/js-reanimated/index.ts +4 -3
  125. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -4
  126. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +5 -5
  127. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -3
  128. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -13
  129. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  130. package/src/reanimated2/mappers.ts +2 -2
  131. package/src/reanimated2/mock.ts +27 -0
  132. package/src/reanimated2/mutables.ts +0 -1
  133. package/src/reanimated2/platform-specific/checkCppVersion.ts +2 -0
  134. package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
  135. package/src/reanimated2/valueSetter.ts +0 -1
  136. package/src/setAndForwardRef.ts +1 -1
  137. package/lib/module/reanimated2/js-reanimated/Mapper.js +0 -69
  138. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +0 -1
  139. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +0 -109
  140. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +0 -1
  141. package/lib/typescript/reanimated2/js-reanimated/Mapper.d.ts +0 -14
  142. package/lib/typescript/reanimated2/js-reanimated/MapperRegistry.d.ts +0 -14
  143. package/src/reanimated2/js-reanimated/Mapper.ts +0 -94
  144. package/src/reanimated2/js-reanimated/MapperRegistry.ts +0 -133
@@ -1 +1 @@
1
- {"version":3,"names":["React","Component","forwardRef","FlatList","StyleSheet","AnimatedView","createAnimatedComponent","AnimatedFlatList","createCellRenderer","itemLayoutAnimation","cellStyle","cellRenderer","props","createElement","layout","onLayout","style","children","ReanimatedFlatList","ref","restProps","inverted","horizontal","styles","horizontallyInverted","verticallyInverted","undefined","scrollEventThrottle","useMemo","_extends","CellRendererComponent","create","transform","scaleY","scaleX"],"sources":["FlatList.tsx"],"sourcesContent":["import type { ForwardedRef } from 'react';\nimport React, { Component, forwardRef } from 'react';\nimport type { FlatListProps, LayoutChangeEvent } from 'react-native';\nimport { FlatList, StyleSheet } from 'react-native';\nimport { AnimatedView } from './View';\nimport createAnimatedComponent from '../../createAnimatedComponent';\nimport type { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';\nimport type { StyleProps } from '../commonTypes';\nimport type { AnimateProps } from '../helperTypes';\n\nconst AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;\n\ninterface AnimatedFlatListProps {\n onLayout: (event: LayoutChangeEvent) => void;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children: React.ReactNode;\n inverted?: boolean;\n horizontal?: boolean;\n}\n\nconst createCellRenderer = (\n itemLayoutAnimation?: ILayoutAnimationBuilder,\n cellStyle?: StyleProps\n) => {\n const cellRenderer = (props: AnimatedFlatListProps) => {\n return (\n <AnimatedView\n // TODO TYPESCRIPT This is temporary cast is to get rid of .d.ts file.\n layout={itemLayoutAnimation as any}\n onLayout={props.onLayout}\n style={cellStyle}>\n {props.children}\n </AnimatedView>\n );\n };\n\n return cellRenderer;\n};\n\ninterface ReanimatedFlatListPropsWithLayout<T> extends FlatListProps<T> {\n itemLayoutAnimation?: ILayoutAnimationBuilder;\n}\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ndeclare class ReanimatedFlatListClass<T> extends Component<\n AnimateProps<ReanimatedFlatListPropsWithLayout<T>>\n> {\n getNode(): FlatList;\n}\n\nexport interface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {\n itemLayoutAnimation?: ILayoutAnimationBuilder;\n}\n\nexport const ReanimatedFlatList = forwardRef(\n (props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {\n const { itemLayoutAnimation, ...restProps } = props;\n\n const cellStyle = restProps?.inverted\n ? restProps?.horizontal\n ? styles.horizontallyInverted\n : styles.verticallyInverted\n : undefined;\n\n // Set default scrollEventThrottle, because user expects\n // to have continuous scroll events and\n // react-native defaults it to 50 for FlatLists.\n // We set it to 1 so we have peace until\n // there are 960 fps screens.\n if (!('scrollEventThrottle' in restProps)) {\n restProps.scrollEventThrottle = 1;\n }\n\n const cellRenderer = React.useMemo(\n () => createCellRenderer(itemLayoutAnimation, cellStyle),\n [cellStyle]\n );\n\n return (\n <AnimatedFlatList\n ref={ref}\n {...restProps}\n CellRendererComponent={cellRenderer}\n />\n );\n }\n // TODO TYPESCRIPT this was a cast before\n // ) as <T>(\n // props: ReanimatedFlatListProps<T> & RefAttributes<FlatList<any>>\n // ) => React.ReactElement;\n);\n\nconst styles = StyleSheet.create({\n verticallyInverted: { transform: [{ scaleY: -1 }] },\n horizontallyInverted: { transform: [{ scaleX: -1 }] },\n});\n\nexport type ReanimatedFlatList<T> = typeof ReanimatedFlatListClass<T> &\n FlatList<T>;\n"],"mappings":";AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,UAAU,QAAQ,OAAO;AAEpD,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,SAASC,YAAY,QAAQ,QAAQ;AACrC,OAAOC,uBAAuB,MAAM,+BAA+B;AAKnE,MAAMC,gBAAgB,GAAGD,uBAAuB,CAACH,QAAQ,CAAe;AAUxE,MAAMK,kBAAkB,GAAGA,CACzBC,mBAA6C,EAC7CC,SAAsB,KACnB;EACH,MAAMC,YAAY,GAAIC,KAA4B,IAAK;IACrD,oBACEZ,KAAA,CAAAa,aAAA,CAACR;IACC;IAAA;MACAS,MAAM,EAAEL,mBAA2B;MACnCM,QAAQ,EAAEH,KAAK,CAACG,QAAS;MACzBC,KAAK,EAAEN;IAAU,GAChBE,KAAK,CAACK,QAAQ,CACF;EAEnB,CAAC;EAED,OAAON,YAAY;AACrB,CAAC;;AAMD;;AAWA,OAAO,MAAMO,kBAAkB,gBAAGhB,UAAU,CAC1C,CAACU,KAAmC,EAAEO,GAA2B,KAAK;EACpE,MAAM;IAAEV,mBAAmB;IAAE,GAAGW;EAAU,CAAC,GAAGR,KAAK;EAEnD,MAAMF,SAAS,GAAGU,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEC,QAAQ,GACjCD,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEE,UAAU,GACnBC,MAAM,CAACC,oBAAoB,GAC3BD,MAAM,CAACE,kBAAkB,GAC3BC,SAAS;;EAEb;EACA;EACA;EACA;EACA;EACA,IAAI,EAAE,qBAAqB,IAAIN,SAAS,CAAC,EAAE;IACzCA,SAAS,CAACO,mBAAmB,GAAG,CAAC;EACnC;EAEA,MAAMhB,YAAY,GAAGX,KAAK,CAAC4B,OAAO,CAChC,MAAMpB,kBAAkB,CAACC,mBAAmB,EAAEC,SAAS,CAAC,EACxD,CAACA,SAAS,CAAC,CACZ;EAED,oBACEV,KAAA,CAAAa,aAAA,CAACN,gBAAgB,EAAAsB,QAAA;IACfV,GAAG,EAAEA;EAAI,GACLC,SAAS;IACbU,qBAAqB,EAAEnB;EAAa,GACpC;AAEN;AACA;AACA;AACA;AACA;AAAA,CACD;;AAED,MAAMY,MAAM,GAAGnB,UAAU,CAAC2B,MAAM,CAAC;EAC/BN,kBAAkB,EAAE;IAAEO,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;EAAE,CAAC;EACnDT,oBAAoB,EAAE;IAAEQ,SAAS,EAAE,CAAC;MAAEE,MAAM,EAAE,CAAC;IAAE,CAAC;EAAE;AACtD,CAAC,CAAC"}
1
+ {"version":3,"names":["React","Component","forwardRef","FlatList","StyleSheet","AnimatedView","createAnimatedComponent","AnimatedFlatList","createCellRenderer","itemLayoutAnimation","cellStyle","cellRenderer","props","createElement","layout","onLayout","style","children","ReanimatedFlatList","ref","restProps","inverted","horizontal","styles","horizontallyInverted","verticallyInverted","undefined","scrollEventThrottle","useMemo","_extends","CellRendererComponent","create","transform","scaleY","scaleX"],"sources":["FlatList.tsx"],"sourcesContent":["import type { ForwardedRef } from 'react';\nimport React, { Component, forwardRef } from 'react';\nimport type { FlatListProps, LayoutChangeEvent } from 'react-native';\nimport { FlatList, StyleSheet } from 'react-native';\nimport { AnimatedView } from './View';\nimport createAnimatedComponent from '../../createAnimatedComponent';\nimport type { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';\nimport type { StyleProps } from '../commonTypes';\nimport type { AnimateProps } from '../helperTypes';\n\nconst AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;\n\ninterface AnimatedFlatListProps {\n onLayout: (event: LayoutChangeEvent) => void;\n // implicit `children` prop has been removed in @types/react^18.0.0\n children: React.ReactNode;\n inverted?: boolean;\n horizontal?: boolean;\n}\n\nconst createCellRenderer = (\n itemLayoutAnimation?: ILayoutAnimationBuilder,\n cellStyle?: StyleProps\n) => {\n const cellRenderer = (props: AnimatedFlatListProps) => {\n return (\n <AnimatedView\n // TODO TYPESCRIPT This is temporary cast is to get rid of .d.ts file.\n layout={itemLayoutAnimation as any}\n onLayout={props.onLayout}\n style={cellStyle}>\n {props.children}\n </AnimatedView>\n );\n };\n\n return cellRenderer;\n};\n\ninterface ReanimatedFlatListPropsWithLayout<T> extends FlatListProps<T> {\n itemLayoutAnimation?: ILayoutAnimationBuilder;\n}\n\nexport type FlatListPropsWithLayout<T> = ReanimatedFlatListPropsWithLayout<T>;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ndeclare class ReanimatedFlatListClass<T> extends Component<\n AnimateProps<ReanimatedFlatListPropsWithLayout<T>>\n> {\n getNode(): FlatList;\n}\n\ninterface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {\n itemLayoutAnimation?: ILayoutAnimationBuilder;\n}\n\nexport const ReanimatedFlatList = forwardRef(\n (props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {\n const { itemLayoutAnimation, ...restProps } = props;\n\n const cellStyle = restProps?.inverted\n ? restProps?.horizontal\n ? styles.horizontallyInverted\n : styles.verticallyInverted\n : undefined;\n\n // Set default scrollEventThrottle, because user expects\n // to have continuous scroll events and\n // react-native defaults it to 50 for FlatLists.\n // We set it to 1 so we have peace until\n // there are 960 fps screens.\n if (!('scrollEventThrottle' in restProps)) {\n restProps.scrollEventThrottle = 1;\n }\n\n const cellRenderer = React.useMemo(\n () => createCellRenderer(itemLayoutAnimation, cellStyle),\n [cellStyle]\n );\n\n return (\n <AnimatedFlatList\n ref={ref}\n {...restProps}\n CellRendererComponent={cellRenderer}\n />\n );\n }\n // TODO TYPESCRIPT this was a cast before\n // ) as <T>(\n // props: ReanimatedFlatListProps<T> & RefAttributes<FlatList<any>>\n // ) => React.ReactElement;\n);\n\nconst styles = StyleSheet.create({\n verticallyInverted: { transform: [{ scaleY: -1 }] },\n horizontallyInverted: { transform: [{ scaleX: -1 }] },\n});\n\nexport type ReanimatedFlatList<T> = typeof ReanimatedFlatListClass<T> &\n FlatList<T>;\n"],"mappings":";AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,UAAU,QAAQ,OAAO;AAEpD,SAASC,QAAQ,EAAEC,UAAU,QAAQ,cAAc;AACnD,SAASC,YAAY,QAAQ,QAAQ;AACrC,OAAOC,uBAAuB,MAAM,+BAA+B;AAKnE,MAAMC,gBAAgB,GAAGD,uBAAuB,CAACH,QAAQ,CAAe;AAUxE,MAAMK,kBAAkB,GAAGA,CACzBC,mBAA6C,EAC7CC,SAAsB,KACnB;EACH,MAAMC,YAAY,GAAIC,KAA4B,IAAK;IACrD,oBACEZ,KAAA,CAAAa,aAAA,CAACR;IACC;IAAA;MACAS,MAAM,EAAEL,mBAA2B;MACnCM,QAAQ,EAAEH,KAAK,CAACG,QAAS;MACzBC,KAAK,EAAEN;IAAU,GAChBE,KAAK,CAACK,QAAQ,CACF;EAEnB,CAAC;EAED,OAAON,YAAY;AACrB,CAAC;;AAQD;;AAWA,OAAO,MAAMO,kBAAkB,gBAAGhB,UAAU,CAC1C,CAACU,KAAmC,EAAEO,GAA2B,KAAK;EACpE,MAAM;IAAEV,mBAAmB;IAAE,GAAGW;EAAU,CAAC,GAAGR,KAAK;EAEnD,MAAMF,SAAS,GAAGU,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEC,QAAQ,GACjCD,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEE,UAAU,GACnBC,MAAM,CAACC,oBAAoB,GAC3BD,MAAM,CAACE,kBAAkB,GAC3BC,SAAS;;EAEb;EACA;EACA;EACA;EACA;EACA,IAAI,EAAE,qBAAqB,IAAIN,SAAS,CAAC,EAAE;IACzCA,SAAS,CAACO,mBAAmB,GAAG,CAAC;EACnC;EAEA,MAAMhB,YAAY,GAAGX,KAAK,CAAC4B,OAAO,CAChC,MAAMpB,kBAAkB,CAACC,mBAAmB,EAAEC,SAAS,CAAC,EACxD,CAACA,SAAS,CAAC,CACZ;EAED,oBACEV,KAAA,CAAAa,aAAA,CAACN,gBAAgB,EAAAsB,QAAA;IACfV,GAAG,EAAEA;EAAI,GACLC,SAAS;IACbU,qBAAqB,EAAEnB;EAAa,GACpC;AAEN;AACA;AACA;AACA;AACA;AAAA,CACD;;AAED,MAAMY,MAAM,GAAGnB,UAAU,CAAC2B,MAAM,CAAC;EAC/BN,kBAAkB,EAAE;IAAEO,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;EAAE,CAAC;EACnDT,oBAAoB,EAAE;IAAEQ,SAAS,EAAE,CAAC;MAAEE,MAAM,EAAE,CAAC;IAAE,CAAC;EAAE;AACtD,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["React","Component","forwardRef","ScrollView","createAnimatedComponent","useAnimatedRef","useScrollViewOffset","AnimatedScrollViewComponent","AnimatedScrollView","props","ref","scrollViewOffset","restProps","aref","scrollEventThrottle","createElement","_extends"],"sources":["ScrollView.tsx"],"sourcesContent":["import type { ForwardedRef, RefObject } from 'react';\nimport React, { Component, forwardRef } from 'react';\nimport type { ScrollViewProps } from 'react-native';\nimport { ScrollView } from 'react-native';\nimport createAnimatedComponent from '../../createAnimatedComponent';\nimport type { SharedValue } from '../commonTypes';\nimport type { AnimateProps } from '../helperTypes';\nimport { useAnimatedRef, useScrollViewOffset } from '../hook';\n\ninterface AnimatedScrollViewProps extends ScrollViewProps {\n scrollViewOffset?: SharedValue<number>;\n}\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ndeclare class AnimatedScrollViewClass extends Component<\n AnimateProps<AnimatedScrollViewProps>\n> {\n getNode(): ScrollView;\n}\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\ninterface AnimatedScrollViewInterface extends ScrollView {\n getNode(): ScrollView;\n}\n\nconst AnimatedScrollViewComponent = createAnimatedComponent(\n ScrollView as any\n) as any;\n\n// type AnimatedScrollViewFC = React.FC<AnimatedScrollViewProps>;\n\nexport const AnimatedScrollView: AnimatedScrollView = forwardRef(\n (props: AnimatedScrollViewProps, ref: ForwardedRef<AnimatedScrollView>) => {\n const { scrollViewOffset, ...restProps } = props;\n const aref = ref === null ? useAnimatedRef<ScrollView>() : ref;\n\n if (scrollViewOffset) {\n useScrollViewOffset(\n aref as RefObject<AnimatedScrollView>,\n scrollViewOffset\n );\n }\n\n // Set default scrollEventThrottle, because user expects\n // to have continuous scroll events.\n // We set it to 1 so we have peace until\n // there are 960 fps screens.\n if (!('scrollEventThrottle' in restProps)) {\n restProps.scrollEventThrottle = 1;\n }\n\n return <AnimatedScrollViewComponent ref={aref} {...restProps} />;\n }\n) as unknown as AnimatedScrollView;\n\nexport type AnimatedScrollView = typeof AnimatedScrollViewClass &\n AnimatedScrollViewInterface;\n"],"mappings":";AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,UAAU,QAAQ,OAAO;AAEpD,SAASC,UAAU,QAAQ,cAAc;AACzC,OAAOC,uBAAuB,MAAM,+BAA+B;AAGnE,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,SAAS;;AAM7D;;AAMA;AACA;AAKA,MAAMC,2BAA2B,GAAGH,uBAAuB,CACzDD,UAAU,CACJ;;AAER;;AAEA,OAAO,MAAMK,kBAAsC,gBAAGN,UAAU,CAC9D,CAACO,KAA8B,EAAEC,GAAqC,KAAK;EACzE,MAAM;IAAEC,gBAAgB;IAAE,GAAGC;EAAU,CAAC,GAAGH,KAAK;EAChD,MAAMI,IAAI,GAAGH,GAAG,KAAK,IAAI,GAAGL,cAAc,EAAc,GAAGK,GAAG;EAE9D,IAAIC,gBAAgB,EAAE;IACpBL,mBAAmB,CACjBO,IAAI,EACJF,gBAAgB,CACjB;EACH;;EAEA;EACA;EACA;EACA;EACA,IAAI,EAAE,qBAAqB,IAAIC,SAAS,CAAC,EAAE;IACzCA,SAAS,CAACE,mBAAmB,GAAG,CAAC;EACnC;EAEA,oBAAOd,KAAA,CAAAe,aAAA,CAACR,2BAA2B,EAAAS,QAAA;IAACN,GAAG,EAAEG;EAAK,GAAKD,SAAS,EAAI;AAClE,CAAC,CAC+B"}
1
+ {"version":3,"names":["React","Component","forwardRef","ScrollView","createAnimatedComponent","useAnimatedRef","useScrollViewOffset","AnimatedScrollViewComponent","AnimatedScrollView","props","ref","scrollViewOffset","restProps","aref","scrollEventThrottle","createElement","_extends"],"sources":["ScrollView.tsx"],"sourcesContent":["import type { ForwardedRef, RefObject } from 'react';\nimport React, { Component, forwardRef } from 'react';\nimport type { ScrollViewProps } from 'react-native';\nimport { ScrollView } from 'react-native';\nimport createAnimatedComponent from '../../createAnimatedComponent';\nimport type { SharedValue } from '../commonTypes';\nimport type { AnimateProps } from '../helperTypes';\nimport { useAnimatedRef, useScrollViewOffset } from '../hook';\n\nexport interface AnimatedScrollViewProps extends ScrollViewProps {\n scrollViewOffset?: SharedValue<number>;\n}\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ndeclare class AnimatedScrollViewClass extends Component<\n AnimateProps<AnimatedScrollViewProps>\n> {\n getNode(): ScrollView;\n}\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\ninterface AnimatedScrollViewInterface extends ScrollView {\n getNode(): ScrollView;\n}\n\nconst AnimatedScrollViewComponent = createAnimatedComponent(\n ScrollView as any\n) as any;\n\n// type AnimatedScrollViewFC = React.FC<AnimatedScrollViewProps>;\n\nexport const AnimatedScrollView: AnimatedScrollView = forwardRef(\n (props: AnimatedScrollViewProps, ref: ForwardedRef<AnimatedScrollView>) => {\n const { scrollViewOffset, ...restProps } = props;\n const aref = ref === null ? useAnimatedRef<ScrollView>() : ref;\n\n if (scrollViewOffset) {\n useScrollViewOffset(\n aref as RefObject<AnimatedScrollView>,\n scrollViewOffset\n );\n }\n\n // Set default scrollEventThrottle, because user expects\n // to have continuous scroll events.\n // We set it to 1 so we have peace until\n // there are 960 fps screens.\n if (!('scrollEventThrottle' in restProps)) {\n restProps.scrollEventThrottle = 1;\n }\n\n return <AnimatedScrollViewComponent ref={aref} {...restProps} />;\n }\n) as unknown as AnimatedScrollView;\n\nexport type AnimatedScrollView = typeof AnimatedScrollViewClass &\n AnimatedScrollViewInterface;\n"],"mappings":";AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,UAAU,QAAQ,OAAO;AAEpD,SAASC,UAAU,QAAQ,cAAc;AACzC,OAAOC,uBAAuB,MAAM,+BAA+B;AAGnE,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,SAAS;;AAM7D;;AAMA;AACA;AAKA,MAAMC,2BAA2B,GAAGH,uBAAuB,CACzDD,UAAU,CACJ;;AAER;;AAEA,OAAO,MAAMK,kBAAsC,gBAAGN,UAAU,CAC9D,CAACO,KAA8B,EAAEC,GAAqC,KAAK;EACzE,MAAM;IAAEC,gBAAgB;IAAE,GAAGC;EAAU,CAAC,GAAGH,KAAK;EAChD,MAAMI,IAAI,GAAGH,GAAG,KAAK,IAAI,GAAGL,cAAc,EAAc,GAAGK,GAAG;EAE9D,IAAIC,gBAAgB,EAAE;IACpBL,mBAAmB,CACjBO,IAAI,EACJF,gBAAgB,CACjB;EACH;;EAEA;EACA;EACA;EACA;EACA,IAAI,EAAE,qBAAqB,IAAIC,SAAS,CAAC,EAAE;IACzCA,SAAS,CAACE,mBAAmB,GAAG,CAAC;EACnC;EAEA,oBAAOd,KAAA,CAAAe,aAAA,CAACR,2BAA2B,EAAAS,QAAA;IAACN,GAAG,EAAEG;EAAK,GAAKD,SAAS,EAAI;AAClE,CAAC,CAC+B"}
@@ -3,7 +3,9 @@
3
3
  let findHostInstance_DEPRECATED;
4
4
  if (global._IS_FABRIC) {
5
5
  try {
6
- findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
6
+ findHostInstance_DEPRECATED =
7
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
8
+ require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
7
9
  } catch (e) {
8
10
  throw new Error('[Reanimated] Cannot import `findHostInstance_DEPRECATED`.');
9
11
  }
@@ -1 +1 @@
1
- {"version":3,"names":["findHostInstance_DEPRECATED","global","_IS_FABRIC","require","e","Error","getShadowNodeWrapperFromRef","ref","_internalInstanceHandle","stateNode","node"],"sources":["fabricUtils.ts"],"sourcesContent":["/* eslint-disable camelcase */\n\nimport type { ShadowNodeWrapper } from './commonTypes';\n\ninterface HostInstance {\n _internalInstanceHandle: {\n stateNode: {\n node: ShadowNodeWrapper;\n };\n };\n}\n\nlet findHostInstance_DEPRECATED: (ref: React.Component) => HostInstance;\nif (global._IS_FABRIC) {\n try {\n findHostInstance_DEPRECATED =\n require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;\n } catch (e) {\n throw new Error(\n '[Reanimated] Cannot import `findHostInstance_DEPRECATED`.'\n );\n }\n}\n\nexport function getShadowNodeWrapperFromRef(\n ref: React.Component\n): ShadowNodeWrapper {\n return findHostInstance_DEPRECATED(ref)._internalInstanceHandle.stateNode\n .node;\n}\n"],"mappings":"AAAA;;AAYA,IAAIA,2BAAmE;AACvE,IAAIC,MAAM,CAACC,UAAU,EAAE;EACrB,IAAI;IACFF,2BAA2B,GACzBG,OAAO,CAAC,mDAAmD,CAAC,CAACH,2BAA2B;EAC5F,CAAC,CAAC,OAAOI,CAAC,EAAE;IACV,MAAM,IAAIC,KAAK,CACb,2DAA2D,CAC5D;EACH;AACF;AAEA,OAAO,SAASC,2BAA2BA,CACzCC,GAAoB,EACD;EACnB,OAAOP,2BAA2B,CAACO,GAAG,CAAC,CAACC,uBAAuB,CAACC,SAAS,CACtEC,IAAI;AACT"}
1
+ {"version":3,"names":["findHostInstance_DEPRECATED","global","_IS_FABRIC","require","e","Error","getShadowNodeWrapperFromRef","ref","_internalInstanceHandle","stateNode","node"],"sources":["fabricUtils.ts"],"sourcesContent":["/* eslint-disable camelcase */\n\nimport type { ShadowNodeWrapper } from './commonTypes';\n\ninterface HostInstance {\n _internalInstanceHandle: {\n stateNode: {\n node: ShadowNodeWrapper;\n };\n };\n}\n\nlet findHostInstance_DEPRECATED: (ref: React.Component) => HostInstance;\nif (global._IS_FABRIC) {\n try {\n findHostInstance_DEPRECATED =\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;\n } catch (e) {\n throw new Error(\n '[Reanimated] Cannot import `findHostInstance_DEPRECATED`.'\n );\n }\n}\n\nexport function getShadowNodeWrapperFromRef(\n ref: React.Component\n): ShadowNodeWrapper {\n return findHostInstance_DEPRECATED(ref)._internalInstanceHandle.stateNode\n .node;\n}\n"],"mappings":"AAAA;;AAYA,IAAIA,2BAAmE;AACvE,IAAIC,MAAM,CAACC,UAAU,EAAE;EACrB,IAAI;IACFF,2BAA2B;IACzB;IACAG,OAAO,CAAC,mDAAmD,CAAC,CAACH,2BAA2B;EAC5F,CAAC,CAAC,OAAOI,CAAC,EAAE;IACV,MAAM,IAAIC,KAAK,CACb,2DAA2D,CAC5D;EACH;AACF;AAEA,OAAO,SAASC,2BAA2BA,CACzCC,GAAoB,EACD;EACnB,OAAOP,2BAA2B,CAACO,GAAG,CAAC,CAACC,uBAAuB,CAACC,SAAS,CACtEC,IAAI;AACT"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-var */\nimport type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n MapperRegistry,\n ShareableRef,\n ShareableSyncDataHolderRef,\n ShadowNodeWrapper,\n ComplexWorkletFunction,\n} from './commonTypes';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { NativeReanimatedModule } from './NativeReanimated/NativeReanimated';\nimport type { SensorContainer } from './SensorContainer';\nimport type { LayoutAnimationsManager } from './layoutReanimation/animationsManager';\nimport type { ProgressTransitionRegister } from './layoutReanimation/sharedTransitions';\nimport type { UpdatePropsManager } from './UpdateProps';\n\ndeclare global {\n var _REANIMATED_IS_REDUCED_MOTION: boolean | undefined;\n var _IS_FABRIC: boolean | undefined;\n var _REANIMATED_VERSION_CPP: string | undefined;\n var _REANIMATED_VERSION_BABEL_PLUGIN: string | undefined;\n var __reanimatedModuleProxy: NativeReanimatedModule | undefined;\n var evalWithSourceMap:\n | ((js: string, sourceURL: string, sourceMap: string) => any)\n | undefined;\n var evalWithSourceUrl: ((js: string, sourceURL: string) => any) | undefined;\n var _log: (s: string) => void;\n var _notifyAboutProgress: (\n tag: number,\n value: Record<string, unknown>,\n isSharedTransition: boolean\n ) => void;\n var _notifyAboutEnd: (tag: number, removeView: boolean) => void;\n var _setGestureState: (handlerTag: number, newState: number) => void;\n var _makeShareableClone: <T>(value: T) => ShareableRef<T>;\n var _updateDataSynchronously: (\n dataHolder: ShareableSyncDataHolderRef<any>,\n data: ShareableRef<any>\n ) => void;\n var _scheduleOnJS: (\n fun: ComplexWorkletFunction<A, R>,\n args?: unknown[]\n ) => void;\n var _updatePropsPaper:\n | ((\n operations: {\n tag: number;\n name: string;\n updates: StyleProps | AnimatedStyle;\n }[]\n ) => void)\n | undefined;\n var _updatePropsFabric:\n | ((\n operations: {\n shadowNodeWrapper: ShadowNodeWrapper;\n updates: StyleProps | AnimatedStyle;\n }[]\n ) => void)\n | undefined;\n var _removeFromPropsRegistry: (viewTags: number[]) => void | undefined;\n var _measurePaper: ((viewTag: number) => MeasuredDimensions) | undefined;\n var _measureFabric:\n | ((shadowNodeWrapper: ShadowNodeWrapper) => MeasuredDimensions)\n | undefined;\n var _scrollToPaper:\n | ((viewTag: number, x: number, y: number, animated: boolean) => void)\n | undefined;\n var _dispatchCommandPaper:\n | ((viewTag: number, commandName: string, args: Array<unknown>) => void)\n | undefined;\n var _dispatchCommandFabric:\n | ((\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void)\n | undefined;\n var __ErrorUtils: {\n reportFatalError: (error: Error) => void;\n };\n var _frameCallbackRegistry: FrameCallbackRegistryUI;\n var console: Console;\n var __frameTimestamp: number | undefined;\n var __flushAnimationFrame: (timestamp: number) => void;\n var __workletsCache: Map<string, any>;\n var __handleCache: WeakMap<object, any>;\n var __callMicrotasks: () => void;\n var __mapperRegistry: MapperRegistry;\n var __sensorContainer: SensorContainer;\n var _maybeFlushUIUpdatesQueue: () => void;\n var LayoutAnimationsManager: LayoutAnimationsManager;\n var UpdatePropsManager: UpdatePropsManager;\n var ProgressTransitionRegister: ProgressTransitionRegister;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-var */\nimport type {\n StyleProps,\n MeasuredDimensions,\n MapperRegistry,\n ShareableRef,\n ShareableSyncDataHolderRef,\n ShadowNodeWrapper,\n ComplexWorkletFunction,\n} from './commonTypes';\nimport type { AnimatedStyle } from './helperTypes';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { NativeReanimatedModule } from './NativeReanimated/NativeReanimated';\nimport type { SensorContainer } from './SensorContainer';\nimport type { LayoutAnimationsManager } from './layoutReanimation/animationsManager';\nimport type { ProgressTransitionRegister } from './layoutReanimation/sharedTransitions';\nimport type { UpdatePropsManager } from './UpdateProps';\n\ndeclare global {\n var _REANIMATED_IS_REDUCED_MOTION: boolean | undefined;\n var _IS_FABRIC: boolean | undefined;\n var _REANIMATED_VERSION_CPP: string | undefined;\n var _REANIMATED_VERSION_BABEL_PLUGIN: string | undefined;\n var __reanimatedModuleProxy: NativeReanimatedModule | undefined;\n var evalWithSourceMap:\n | ((js: string, sourceURL: string, sourceMap: string) => any)\n | undefined;\n var evalWithSourceUrl: ((js: string, sourceURL: string) => any) | undefined;\n var _log: (s: string) => void;\n var _notifyAboutProgress: (\n tag: number,\n value: Record<string, unknown>,\n isSharedTransition: boolean\n ) => void;\n var _notifyAboutEnd: (tag: number, removeView: boolean) => void;\n var _setGestureState: (handlerTag: number, newState: number) => void;\n var _makeShareableClone: <T>(value: T) => ShareableRef<T>;\n var _updateDataSynchronously: (\n dataHolder: ShareableSyncDataHolderRef<any>,\n data: ShareableRef<any>\n ) => void;\n var _scheduleOnJS: (\n fun: ComplexWorkletFunction<A, R>,\n args?: unknown[]\n ) => void;\n var _updatePropsPaper:\n | ((\n operations: {\n tag: number;\n name: string;\n updates: StyleProps | AnimatedStyle<any>;\n }[]\n ) => void)\n | undefined;\n var _updatePropsFabric:\n | ((\n operations: {\n shadowNodeWrapper: ShadowNodeWrapper;\n updates: StyleProps | AnimatedStyle<any>;\n }[]\n ) => void)\n | undefined;\n var _removeFromPropsRegistry: (viewTags: number[]) => void | undefined;\n var _measurePaper: ((viewTag: number) => MeasuredDimensions) | undefined;\n var _measureFabric:\n | ((shadowNodeWrapper: ShadowNodeWrapper) => MeasuredDimensions)\n | undefined;\n var _scrollToPaper:\n | ((viewTag: number, x: number, y: number, animated: boolean) => void)\n | undefined;\n var _dispatchCommandPaper:\n | ((viewTag: number, commandName: string, args: Array<unknown>) => void)\n | undefined;\n var _dispatchCommandFabric:\n | ((\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void)\n | undefined;\n var __ErrorUtils: {\n reportFatalError: (error: Error) => void;\n };\n var _frameCallbackRegistry: FrameCallbackRegistryUI;\n var console: Console;\n var __frameTimestamp: number | undefined;\n var __flushAnimationFrame: (timestamp: number) => void;\n var __workletsCache: Map<string, any>;\n var __handleCache: WeakMap<object, any>;\n var __callMicrotasks: () => void;\n var __mapperRegistry: MapperRegistry;\n var __sensorContainer: SensorContainer;\n var _maybeFlushUIUpdatesQueue: () => void;\n var LayoutAnimationsManager: LayoutAnimationsManager;\n var UpdatePropsManager: UpdatePropsManager;\n var ProgressTransitionRegister: ProgressTransitionRegister;\n}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["helperTypes.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/*\nThis file is a legacy remainder of manual types from react-native-reanimated.d.ts file. \nI wasn't able to get rid of all of them from the code. \nThey should be treated as a temporary solution\nuntil time comes to refactor the code and get necessary types right. \nThis will not be easy though! \n*/\n\nimport type {\n ColorValue,\n StyleProp,\n TransformsStyle as RNTransformsStyle,\n} from 'react-native';\nimport type {\n AnimatableValue,\n BaseAnimationBuilder,\n EntryExitAnimationFunction,\n LayoutAnimationFunction,\n SharedValue,\n} from '.';\nimport type { ReanimatedKeyframe } from './layoutReanimation/animationBuilder/Keyframe';\nimport type { SharedTransition } from './layoutReanimation/sharedTransitions';\nimport type { DependencyList } from './hook/commonTypes';\n\ntype Adaptable<T> = T | ReadonlyArray<T | ReadonlyArray<T>> | SharedValue<T>;\n\ntype AdaptTransforms<T> = {\n [P in keyof T]: Adaptable<T[P]>;\n};\n\ntype TransformsStyle = Pick<RNTransformsStyle, 'transform'>;\n\ntype TransformStyleTypes = TransformsStyle['transform'] extends\n | readonly (infer T)[]\n | undefined\n ? T\n : never;\ntype AnimatedTransform = AdaptTransforms<TransformStyleTypes>[];\n\nexport type AnimateStyle<S> = {\n [K in keyof S]: K extends 'transform'\n ? AnimatedTransform\n : S[K] extends ReadonlyArray<any>\n ? ReadonlyArray<AnimateStyle<S[K][0]>>\n : S[K] extends object\n ? AnimateStyle<S[K]>\n : S[K] extends ColorValue | undefined\n ? S[K] | number\n : S[K] | SharedValue<AnimatableValue>;\n};\n\n// provided types can either be their original types (like backgroundColor: pink)\n// or inline shared values/derived values\ntype MaybeSharedValue<S> = {\n [K in keyof S]: S[K] | Readonly<SharedValue<Extract<S[K], AnimatableValue>>>;\n};\n\ntype StylesOrDefault<T> = 'style' extends keyof T\n ? MaybeSharedValue<T['style']>\n : Record<string, unknown>;\n\ntype EntryOrExitLayoutType =\n | BaseAnimationBuilder\n | typeof BaseAnimationBuilder\n | EntryExitAnimationFunction\n | ReanimatedKeyframe;\n\n/* \n Style type properties (properties that extends StyleProp<ViewStyle>)\n can be defined with other property names than \"style\". For example `contentContainerStyle` in FlatList.\n Type definition for all style type properties should act similarly, hence we\n pick keys with 'Style' substring with the use of this utility type.\n*/\ntype PickStyleProps<T> = Pick<\n T,\n {\n [Key in keyof T]-?: Key extends `${string}Style` ? Key : never;\n }[keyof T]\n>;\n\ntype StyleAnimatedProps<P extends object> = {\n [K in keyof PickStyleProps<P>]: StyleProp<\n AnimateStyle<P[K] | MaybeSharedValue<P[K]>>\n >;\n};\n\ntype JustStyleAnimatedProp<P extends object> = {\n style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;\n};\n\ntype NonStyleAnimatedProps<P extends object> = {\n [K in keyof Omit<P, keyof PickStyleProps<P> | 'style'>]:\n | P[K]\n | SharedValue<P[K]>;\n};\n\ntype LayoutProps = {\n layout?:\n | BaseAnimationBuilder\n | LayoutAnimationFunction\n | typeof BaseAnimationBuilder;\n entering?: EntryOrExitLayoutType;\n exiting?: EntryOrExitLayoutType;\n};\n\ntype SharedTransitionProps = {\n sharedTransitionTag?: string;\n sharedTransitionStyle?: SharedTransition;\n};\n\ntype AnimatedPropsProp<P extends object> = NonStyleAnimatedProps<P> &\n JustStyleAnimatedProp<P> &\n StyleAnimatedProps<P> &\n LayoutProps &\n SharedTransitionProps;\n\nexport type AnimateProps<P extends object> = NonStyleAnimatedProps<P> &\n JustStyleAnimatedProp<P> &\n StyleAnimatedProps<P> &\n LayoutProps &\n SharedTransitionProps & {\n animatedProps?: Partial<AnimatedPropsProp<P>>;\n };\n\nexport type AnimatedProps<P extends object> = AnimateProps<P>;\n\nexport type AnimatedPropsAdapterFunction = (\n props: Record<string, unknown>\n) => void;\n\nexport type useAnimatedPropsType = <T extends object>(\n updater: () => Partial<T>,\n deps?: DependencyList | null,\n adapters?:\n | AnimatedPropsAdapterFunction\n | AnimatedPropsAdapterFunction[]\n | null\n) => Partial<T>;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["helperTypes.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/*\nThis file is a legacy remainder of manual types from react-native-reanimated.d.ts file. \nI wasn't able to get rid of all of them from the code. \nThey should be treated as a temporary solution\nuntil time comes to refactor the code and get necessary types right. \nThis will not be easy though! \n*/\n\nimport type {\n ColorValue,\n StyleProp,\n TransformsStyle as RNTransformsStyle,\n} from 'react-native';\nimport type {\n AnimatableValue,\n BaseAnimationBuilder,\n EntryExitAnimationFunction,\n LayoutAnimationFunction,\n SharedValue,\n} from '.';\nimport type { ReanimatedKeyframe } from './layoutReanimation/animationBuilder/Keyframe';\nimport type { SharedTransition } from './layoutReanimation/sharedTransitions';\nimport type { DependencyList } from './hook/commonTypes';\n\nexport type Adaptable<T> =\n | T\n | ReadonlyArray<T | ReadonlyArray<T>>\n | SharedValue<T>;\n\nexport type AdaptTransforms<T> = {\n [P in keyof T]: Adaptable<T[P]>;\n};\n\ntype TransformsStyle = Pick<RNTransformsStyle, 'transform'>;\n\nexport type TransformStyleTypes = TransformsStyle['transform'] extends\n | readonly (infer T)[]\n | string\n | undefined\n ? T\n : never;\nexport type AnimatedTransform = AdaptTransforms<TransformStyleTypes>[];\n\n/**\n * @deprecated Please use `AnimatedStyle` type instead.\n */\nexport type AnimateStyle<S> = {\n [K in keyof S]: K extends 'transform'\n ? AnimatedTransform\n : S[K] extends ReadonlyArray<any>\n ? ReadonlyArray<AnimateStyle<S[K][0]>>\n : S[K] extends object\n ? AnimateStyle<S[K]>\n : S[K] extends ColorValue | undefined\n ? S[K] | number\n : S[K] | SharedValue<AnimatableValue>;\n};\n\nexport type AnimatedStyle<S> = AnimateStyle<S>;\n\n// provided types can either be their original types (like backgroundColor: pink)\n// or inline shared values/derived values\ntype MaybeSharedValue<S> = {\n [K in keyof S]: S[K] | Readonly<SharedValue<Extract<S[K], AnimatableValue>>>;\n};\n\nexport type StylesOrDefault<T> = 'style' extends keyof T\n ? MaybeSharedValue<T['style']>\n : Record<string, unknown>;\n\ntype EntryOrExitLayoutType =\n | BaseAnimationBuilder\n | typeof BaseAnimationBuilder\n | EntryExitAnimationFunction\n | ReanimatedKeyframe;\n\n/* \n Style type properties (properties that extends StyleProp<ViewStyle>)\n can be defined with other property names than \"style\". For example `contentContainerStyle` in FlatList.\n Type definition for all style type properties should act similarly, hence we\n pick keys with 'Style' substring with the use of this utility type.\n*/\ntype PickStyleProps<T> = Pick<\n T,\n {\n [Key in keyof T]-?: Key extends `${string}Style` ? Key : never;\n }[keyof T]\n>;\n\ntype StyleAnimatedProps<P extends object> = {\n [K in keyof PickStyleProps<P>]: StyleProp<\n AnimatedStyle<P[K] | MaybeSharedValue<P[K]>>\n >;\n};\n\ntype JustStyleAnimatedProp<P extends object> = {\n style?: StyleProp<AnimatedStyle<StylesOrDefault<P>>>;\n};\n\ntype NonStyleAnimatedProps<P extends object> = {\n [K in keyof Omit<P, keyof PickStyleProps<P> | 'style'>]:\n | P[K]\n | SharedValue<P[K]>;\n};\n\ntype LayoutProps = {\n layout?:\n | BaseAnimationBuilder\n | LayoutAnimationFunction\n | typeof BaseAnimationBuilder;\n entering?: EntryOrExitLayoutType;\n exiting?: EntryOrExitLayoutType;\n};\n\ntype SharedTransitionProps = {\n sharedTransitionTag?: string;\n sharedTransitionStyle?: SharedTransition;\n};\n\ntype AnimatedPropsProp<P extends object> = NonStyleAnimatedProps<P> &\n JustStyleAnimatedProp<P> &\n StyleAnimatedProps<P> &\n LayoutProps &\n SharedTransitionProps;\n\nexport type AnimateProps<P extends object> = NonStyleAnimatedProps<P> &\n JustStyleAnimatedProp<P> &\n StyleAnimatedProps<P> &\n LayoutProps &\n SharedTransitionProps & {\n animatedProps?: Partial<AnimatedPropsProp<P>>;\n };\n\n// ts-prune-ignore-next This will be used soon\nexport type AnimatedProps<P extends object> = AnimateProps<P>;\n\nexport type AnimatedPropsAdapterFunction = (\n props: Record<string, unknown>\n) => void;\n\nexport type useAnimatedPropsType = <T extends object>(\n updater: () => Partial<T>,\n deps?: DependencyList | null,\n adapters?:\n | AnimatedPropsAdapterFunction\n | AnimatedPropsAdapterFunction[]\n | null\n) => Partial<T>;\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import type { Context, ShadowNodeWrapper } from '../commonTypes';\n\nexport type DependencyList = Array<unknown> | undefined;\n\nexport interface ContextWithDependencies<TContext extends Context> {\n context: TContext;\n savedDependencies: DependencyList;\n}\n\nexport interface Descriptor {\n tag: number;\n name: string;\n shadowNodeWrapper: ShadowNodeWrapper;\n}\n\nexport interface RefObjectFunction<T> {\n current: T | null;\n (component?: T):\n | number // Paper\n | ShadowNodeWrapper // Fabric\n | HTMLElement; // web\n}\n\nexport type AnimatedRef<T> = RefObjectFunction<T>;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import type { Component } from 'react';\nimport type { Context, ShadowNodeWrapper } from '../commonTypes';\n\nexport type DependencyList = Array<unknown> | undefined;\n\nexport interface ContextWithDependencies<TContext extends Context> {\n context: TContext;\n savedDependencies: DependencyList;\n}\n\nexport interface Descriptor {\n tag: number;\n name: string;\n shadowNodeWrapper: ShadowNodeWrapper;\n}\n\nexport interface AnimatedRef<T extends Component> {\n current: T | null;\n (component?: T):\n | number // Paper\n | ShadowNodeWrapper // Fabric\n | HTMLElement; // web\n}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":["useAnimatedProps","useEvent","useHandler","useWorkletCallback","useSharedValue","useReducedMotion","useAnimatedStyle","useAnimatedGestureHandler","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useDerivedValue","useAnimatedSensor","useFrameCallback","useAnimatedKeyboard","useScrollViewOffset"],"sources":["index.ts"],"sourcesContent":["export type { DependencyList, AnimatedRef } from './commonTypes';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n} from './Hooks';\nexport { useSharedValue } from './useSharedValue';\nexport { useReducedMotion } from './useReducedMotion';\nexport { useAnimatedStyle } from './useAnimatedStyle';\nexport type { AnimatedStyleResult } from './useAnimatedStyle';\nexport { useAnimatedGestureHandler } from './useAnimatedGestureHandler';\nexport type {\n GestureHandlerEvent,\n GestureHandlers,\n} from './useAnimatedGestureHandler';\nexport { useAnimatedReaction } from './useAnimatedReaction';\nexport type { AnimatedReactionWorkletFunction } from './useAnimatedReaction';\nexport { useAnimatedRef } from './useAnimatedRef';\nexport { useAnimatedScrollHandler } from './useAnimatedScrollHandler';\nexport type { ScrollHandler, ScrollHandlers } from './useAnimatedScrollHandler';\nexport { useDerivedValue } from './useDerivedValue';\nexport type { DerivedValue } from './useDerivedValue';\nexport { useAnimatedSensor } from './useAnimatedSensor';\nexport { useFrameCallback } from './useFrameCallback';\nexport type { FrameCallback } from './useFrameCallback';\nexport { useAnimatedKeyboard } from './useAnimatedKeyboard';\nexport { useScrollViewOffset } from './useScrollViewOffset';\n"],"mappings":"AACA,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,kBAAkB,QACb,SAAS;AAChB,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,yBAAyB,QAAQ,6BAA6B;AAKvE,SAASC,mBAAmB,QAAQ,uBAAuB;AAE3D,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,mBAAmB,QAAQ,uBAAuB"}
1
+ {"version":3,"names":["useAnimatedProps","useEvent","useHandler","useWorkletCallback","useSharedValue","useReducedMotion","useAnimatedStyle","useAnimatedGestureHandler","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useDerivedValue","useAnimatedSensor","useFrameCallback","useAnimatedKeyboard","useScrollViewOffset"],"sources":["index.ts"],"sourcesContent":["export type { DependencyList, AnimatedRef } from './commonTypes';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n} from './Hooks';\nexport { useSharedValue } from './useSharedValue';\nexport { useReducedMotion } from './useReducedMotion';\nexport { useAnimatedStyle } from './useAnimatedStyle';\nexport type {\n AnimatedStyleResult,\n AnimatedStyleProp,\n} from './useAnimatedStyle';\nexport { useAnimatedGestureHandler } from './useAnimatedGestureHandler';\nexport type {\n GestureHandlerEvent,\n GestureHandlers,\n} from './useAnimatedGestureHandler';\nexport { useAnimatedReaction } from './useAnimatedReaction';\nexport type { AnimatedReactionWorkletFunction } from './useAnimatedReaction';\nexport { useAnimatedRef } from './useAnimatedRef';\nexport { useAnimatedScrollHandler } from './useAnimatedScrollHandler';\nexport type { ScrollHandler, ScrollHandlers } from './useAnimatedScrollHandler';\nexport { useDerivedValue } from './useDerivedValue';\nexport type { DerivedValue } from './useDerivedValue';\nexport { useAnimatedSensor } from './useAnimatedSensor';\nexport { useFrameCallback } from './useFrameCallback';\nexport type { FrameCallback } from './useFrameCallback';\nexport { useAnimatedKeyboard } from './useAnimatedKeyboard';\nexport { useScrollViewOffset } from './useScrollViewOffset';\n"],"mappings":"AACA,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,kBAAkB,QACb,SAAS;AAChB,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,gBAAgB,QAAQ,oBAAoB;AAKrD,SAASC,yBAAyB,QAAQ,6BAA6B;AAKvE,SAASC,mBAAmB,QAAQ,uBAAuB;AAE3D,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,wBAAwB,QAAQ,4BAA4B;AAErE,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,mBAAmB,QAAQ,uBAAuB"}
@@ -1,5 +1,5 @@
1
1
  import { useEvent, useHandler } from './Hooks';
2
- export const EventType = {
2
+ const EventType = {
3
3
  UNDETERMINED: 0,
4
4
  FAILED: 1,
5
5
  BEGAN: 2,
@@ -1 +1 @@
1
- {"version":3,"names":["useEvent","useHandler","EventType","UNDETERMINED","FAILED","BEGAN","CANCELLED","ACTIVE","END","useAnimatedGestureHandler","handlers","dependencies","context","doDependenciesDiffer","useWeb","handler","e","event","nativeEvent","state","onStart","onActive","oldState","onEnd","onFail","onCancel","onFinish"],"sources":["useAnimatedGestureHandler.ts"],"sourcesContent":["import type { Context, WorkletFunction, NativeEvent } from '../commonTypes';\nimport type { DependencyList } from './commonTypes';\nimport { useEvent, useHandler } from './Hooks';\n\ninterface Handler<T, TContext extends Context> extends WorkletFunction {\n (event: T, context: TContext, isCanceledOrFailed?: boolean): void;\n}\n\nexport interface GestureHandlers<T, TContext extends Context> {\n [key: string]: Handler<T, TContext> | undefined;\n onStart?: Handler<T, TContext>;\n onActive?: Handler<T, TContext>;\n onEnd?: Handler<T, TContext>;\n onFail?: Handler<T, TContext>;\n onCancel?: Handler<T, TContext>;\n onFinish?: Handler<T, TContext>;\n}\n\nexport const EventType = {\n UNDETERMINED: 0,\n FAILED: 1,\n BEGAN: 2,\n CANCELLED: 3,\n ACTIVE: 4,\n END: 5,\n};\n\nexport interface GestureHandlerNativeEvent {\n handlerTag: number;\n numberOfPointers: number;\n state: (typeof EventType)[keyof typeof EventType];\n}\n\nexport interface GestureHandlerEvent<T> extends NativeEvent<T> {\n nativeEvent: T;\n}\n\ntype InferArgument<T> = T extends GestureHandlerEvent<infer E>\n ? E extends GestureHandlerNativeEvent\n ? E\n : never\n : never;\n\nexport function useAnimatedGestureHandler<\n T extends GestureHandlerEvent<any>,\n TContext extends Context = Context,\n Payload = InferArgument<T>\n>(\n handlers: GestureHandlers<Payload, TContext>,\n dependencies?: DependencyList\n): (e: T) => void {\n const { context, doDependenciesDiffer, useWeb } = useHandler<\n Payload,\n TContext\n >(handlers, dependencies);\n\n const handler = (e: T) => {\n 'worklet';\n const event = useWeb ? e.nativeEvent : e;\n\n if (event.state === EventType.BEGAN && handlers.onStart) {\n handlers.onStart(event, context);\n }\n if (event.state === EventType.ACTIVE && handlers.onActive) {\n handlers.onActive(event, context);\n }\n if (\n event.oldState === EventType.ACTIVE &&\n event.state === EventType.END &&\n handlers.onEnd\n ) {\n handlers.onEnd(event, context);\n }\n if (\n event.oldState === EventType.BEGAN &&\n event.state === EventType.FAILED &&\n handlers.onFail\n ) {\n handlers.onFail(event, context);\n }\n if (\n event.oldState === EventType.ACTIVE &&\n event.state === EventType.CANCELLED &&\n handlers.onCancel\n ) {\n handlers.onCancel(event, context);\n }\n if (\n (event.oldState === EventType.BEGAN ||\n event.oldState === EventType.ACTIVE) &&\n event.state !== EventType.BEGAN &&\n event.state !== EventType.ACTIVE &&\n handlers.onFinish\n ) {\n handlers.onFinish(\n event,\n context,\n event.state === EventType.CANCELLED || event.state === EventType.FAILED\n );\n }\n };\n\n if (useWeb) {\n return handler;\n }\n\n return useEvent<T>(\n handler,\n ['onGestureHandlerStateChange', 'onGestureHandlerEvent'],\n doDependenciesDiffer\n ) as unknown as (e: T) => void; // this is not correct but we want to make GH think it receives a function\n}\n"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,UAAU,QAAQ,SAAS;AAgB9C,OAAO,MAAMC,SAAS,GAAG;EACvBC,YAAY,EAAE,CAAC;EACfC,MAAM,EAAE,CAAC;EACTC,KAAK,EAAE,CAAC;EACRC,SAAS,EAAE,CAAC;EACZC,MAAM,EAAE,CAAC;EACTC,GAAG,EAAE;AACP,CAAC;AAkBD,OAAO,SAASC,yBAAyBA,CAKvCC,QAA4C,EAC5CC,YAA6B,EACb;EAChB,MAAM;IAAEC,OAAO;IAAEC,oBAAoB;IAAEC;EAAO,CAAC,GAAGb,UAAU,CAG1DS,QAAQ,EAAEC,YAAY,CAAC;EAEzB,MAAMI,OAAO,GAAIC,CAAI,IAAK;IACxB,SAAS;;IACT,MAAMC,KAAK,GAAGH,MAAM,GAAGE,CAAC,CAACE,WAAW,GAAGF,CAAC;IAExC,IAAIC,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACG,KAAK,IAAIK,QAAQ,CAACU,OAAO,EAAE;MACvDV,QAAQ,CAACU,OAAO,CAACH,KAAK,EAAEL,OAAO,CAAC;IAClC;IACA,IAAIK,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACK,MAAM,IAAIG,QAAQ,CAACW,QAAQ,EAAE;MACzDX,QAAQ,CAACW,QAAQ,CAACJ,KAAK,EAAEL,OAAO,CAAC;IACnC;IACA,IACEK,KAAK,CAACK,QAAQ,KAAKpB,SAAS,CAACK,MAAM,IACnCU,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACM,GAAG,IAC7BE,QAAQ,CAACa,KAAK,EACd;MACAb,QAAQ,CAACa,KAAK,CAACN,KAAK,EAAEL,OAAO,CAAC;IAChC;IACA,IACEK,KAAK,CAACK,QAAQ,KAAKpB,SAAS,CAACG,KAAK,IAClCY,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACE,MAAM,IAChCM,QAAQ,CAACc,MAAM,EACf;MACAd,QAAQ,CAACc,MAAM,CAACP,KAAK,EAAEL,OAAO,CAAC;IACjC;IACA,IACEK,KAAK,CAACK,QAAQ,KAAKpB,SAAS,CAACK,MAAM,IACnCU,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACI,SAAS,IACnCI,QAAQ,CAACe,QAAQ,EACjB;MACAf,QAAQ,CAACe,QAAQ,CAACR,KAAK,EAAEL,OAAO,CAAC;IACnC;IACA,IACE,CAACK,KAAK,CAACK,QAAQ,KAAKpB,SAAS,CAACG,KAAK,IACjCY,KAAK,CAACK,QAAQ,KAAKpB,SAAS,CAACK,MAAM,KACrCU,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACG,KAAK,IAC/BY,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACK,MAAM,IAChCG,QAAQ,CAACgB,QAAQ,EACjB;MACAhB,QAAQ,CAACgB,QAAQ,CACfT,KAAK,EACLL,OAAO,EACPK,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACI,SAAS,IAAIW,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACE,MAAM,CACxE;IACH;EACF,CAAC;EAED,IAAIU,MAAM,EAAE;IACV,OAAOC,OAAO;EAChB;EAEA,OAAOf,QAAQ,CACbe,OAAO,EACP,CAAC,6BAA6B,EAAE,uBAAuB,CAAC,EACxDF,oBAAoB,CACrB,CAA8B,CAAC;AAClC"}
1
+ {"version":3,"names":["useEvent","useHandler","EventType","UNDETERMINED","FAILED","BEGAN","CANCELLED","ACTIVE","END","useAnimatedGestureHandler","handlers","dependencies","context","doDependenciesDiffer","useWeb","handler","e","event","nativeEvent","state","onStart","onActive","oldState","onEnd","onFail","onCancel","onFinish"],"sources":["useAnimatedGestureHandler.ts"],"sourcesContent":["import type { Context, WorkletFunction, NativeEvent } from '../commonTypes';\nimport type { DependencyList } from './commonTypes';\nimport { useEvent, useHandler } from './Hooks';\n\ninterface Handler<T, TContext extends Context> extends WorkletFunction {\n (event: T, context: TContext, isCanceledOrFailed?: boolean): void;\n}\n\nexport interface GestureHandlers<T, TContext extends Context> {\n [key: string]: Handler<T, TContext> | undefined;\n onStart?: Handler<T, TContext>;\n onActive?: Handler<T, TContext>;\n onEnd?: Handler<T, TContext>;\n onFail?: Handler<T, TContext>;\n onCancel?: Handler<T, TContext>;\n onFinish?: Handler<T, TContext>;\n}\n\nconst EventType = {\n UNDETERMINED: 0,\n FAILED: 1,\n BEGAN: 2,\n CANCELLED: 3,\n ACTIVE: 4,\n END: 5,\n};\n\ninterface GestureHandlerNativeEvent {\n handlerTag: number;\n numberOfPointers: number;\n state: (typeof EventType)[keyof typeof EventType];\n}\n\nexport interface GestureHandlerEvent<T> extends NativeEvent<T> {\n nativeEvent: T;\n}\n\ntype InferArgument<T> = T extends GestureHandlerEvent<infer E>\n ? E extends GestureHandlerNativeEvent\n ? E\n : never\n : never;\n\nexport function useAnimatedGestureHandler<\n T extends GestureHandlerEvent<any>,\n TContext extends Context = Context,\n Payload = InferArgument<T>\n>(\n handlers: GestureHandlers<Payload, TContext>,\n dependencies?: DependencyList\n): (e: T) => void {\n const { context, doDependenciesDiffer, useWeb } = useHandler<\n Payload,\n TContext\n >(handlers, dependencies);\n\n const handler = (e: T) => {\n 'worklet';\n const event = useWeb ? e.nativeEvent : e;\n\n if (event.state === EventType.BEGAN && handlers.onStart) {\n handlers.onStart(event, context);\n }\n if (event.state === EventType.ACTIVE && handlers.onActive) {\n handlers.onActive(event, context);\n }\n if (\n event.oldState === EventType.ACTIVE &&\n event.state === EventType.END &&\n handlers.onEnd\n ) {\n handlers.onEnd(event, context);\n }\n if (\n event.oldState === EventType.BEGAN &&\n event.state === EventType.FAILED &&\n handlers.onFail\n ) {\n handlers.onFail(event, context);\n }\n if (\n event.oldState === EventType.ACTIVE &&\n event.state === EventType.CANCELLED &&\n handlers.onCancel\n ) {\n handlers.onCancel(event, context);\n }\n if (\n (event.oldState === EventType.BEGAN ||\n event.oldState === EventType.ACTIVE) &&\n event.state !== EventType.BEGAN &&\n event.state !== EventType.ACTIVE &&\n handlers.onFinish\n ) {\n handlers.onFinish(\n event,\n context,\n event.state === EventType.CANCELLED || event.state === EventType.FAILED\n );\n }\n };\n\n if (useWeb) {\n return handler;\n }\n\n return useEvent<T>(\n handler,\n ['onGestureHandlerStateChange', 'onGestureHandlerEvent'],\n doDependenciesDiffer\n ) as unknown as (e: T) => void; // this is not correct but we want to make GH think it receives a function\n}\n"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,UAAU,QAAQ,SAAS;AAgB9C,MAAMC,SAAS,GAAG;EAChBC,YAAY,EAAE,CAAC;EACfC,MAAM,EAAE,CAAC;EACTC,KAAK,EAAE,CAAC;EACRC,SAAS,EAAE,CAAC;EACZC,MAAM,EAAE,CAAC;EACTC,GAAG,EAAE;AACP,CAAC;AAkBD,OAAO,SAASC,yBAAyBA,CAKvCC,QAA4C,EAC5CC,YAA6B,EACb;EAChB,MAAM;IAAEC,OAAO;IAAEC,oBAAoB;IAAEC;EAAO,CAAC,GAAGb,UAAU,CAG1DS,QAAQ,EAAEC,YAAY,CAAC;EAEzB,MAAMI,OAAO,GAAIC,CAAI,IAAK;IACxB,SAAS;;IACT,MAAMC,KAAK,GAAGH,MAAM,GAAGE,CAAC,CAACE,WAAW,GAAGF,CAAC;IAExC,IAAIC,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACG,KAAK,IAAIK,QAAQ,CAACU,OAAO,EAAE;MACvDV,QAAQ,CAACU,OAAO,CAACH,KAAK,EAAEL,OAAO,CAAC;IAClC;IACA,IAAIK,KAAK,CAACE,KAAK,KAAKjB,SAAS,CAACK,MAAM,IAAIG,QAAQ,CAACW,QAAQ,EAAE;MACzDX,QAAQ,CAACW,QAAQ,CAACJ,KAAK,EAAEL,OAAO,CAAC;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{ useSharedValue } from './useSharedValue';
3
3
  import { getShadowNodeWrapperFromRef } from '../fabricUtils';
4
4
  import { makeShareableCloneRecursive, registerShareableMapping } from '../shareables';
5
5
  import { findNodeHandle } from 'react-native';
6
- function getComponentOrScrollableRef(component) {
6
+ function getComponentOrScrollable(component) {
7
7
  if (global._IS_FABRIC && component.getNativeScrollRef) {
8
8
  return component.getNativeScrollRef();
9
9
  } else if (!global._IS_FABRIC && component.getScrollableNode) {
@@ -19,7 +19,7 @@ export function useAnimatedRef() {
19
19
  const fun = component => {
20
20
  // enters when ref is set by attaching to a component
21
21
  if (component) {
22
- tag.value = getTagValueFunction(getComponentOrScrollableRef(component));
22
+ tag.value = getTagValueFunction(getComponentOrScrollable(component));
23
23
  fun.current = component;
24
24
  }
25
25
  return tag.value;
@@ -1 +1 @@
1
- {"version":3,"names":["useRef","useSharedValue","getShadowNodeWrapperFromRef","makeShareableCloneRecursive","registerShareableMapping","findNodeHandle","getComponentOrScrollableRef","component","global","_IS_FABRIC","getNativeScrollRef","getScrollableNode","getTagValueFunction","useAnimatedRef","tag","ref","current","fun","value","remoteRef","__init"],"sources":["useAnimatedRef.ts"],"sourcesContent":["import type { Component } from 'react';\nimport { useRef } from 'react';\nimport { useSharedValue } from './useSharedValue';\nimport type { AnimatedRef, RefObjectFunction } from './commonTypes';\nimport type { ShadowNodeWrapper } from '../commonTypes';\nimport { getShadowNodeWrapperFromRef } from '../fabricUtils';\nimport {\n makeShareableCloneRecursive,\n registerShareableMapping,\n} from '../shareables';\nimport { findNodeHandle } from 'react-native';\n\ninterface ComponentRef extends Component {\n getNativeScrollRef?: () => ComponentRef;\n getScrollableNode?: () => ComponentRef;\n}\n\nfunction getComponentOrScrollableRef(component: ComponentRef): ComponentRef {\n if (global._IS_FABRIC && component.getNativeScrollRef) {\n return component.getNativeScrollRef();\n } else if (!global._IS_FABRIC && component.getScrollableNode) {\n return component.getScrollableNode();\n }\n return component;\n}\n\nconst getTagValueFunction = global._IS_FABRIC\n ? getShadowNodeWrapperFromRef\n : findNodeHandle;\n\nexport function useAnimatedRef<T extends ComponentRef>(): AnimatedRef<T> {\n const tag = useSharedValue<number | ShadowNodeWrapper | null>(-1);\n const ref = useRef<RefObjectFunction<T>>();\n\n if (!ref.current) {\n const fun: RefObjectFunction<T> = <RefObjectFunction<T>>((component) => {\n // enters when ref is set by attaching to a component\n if (component) {\n tag.value = getTagValueFunction(getComponentOrScrollableRef(component));\n fun.current = component;\n }\n return tag.value;\n });\n\n fun.current = null;\n\n const remoteRef = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return () => tag.value;\n },\n });\n registerShareableMapping(fun, remoteRef);\n ref.current = fun;\n }\n\n return ref.current;\n}\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,cAAc,QAAQ,kBAAkB;AAGjD,SAASC,2BAA2B,QAAQ,gBAAgB;AAC5D,SACEC,2BAA2B,EAC3BC,wBAAwB,QACnB,eAAe;AACtB,SAASC,cAAc,QAAQ,cAAc;AAO7C,SAASC,2BAA2BA,CAACC,SAAuB,EAAgB;EAC1E,IAAIC,MAAM,CAACC,UAAU,IAAIF,SAAS,CAACG,kBAAkB,EAAE;IACrD,OAAOH,SAAS,CAACG,kBAAkB,EAAE;EACvC,CAAC,MAAM,IAAI,CAACF,MAAM,CAACC,UAAU,IAAIF,SAAS,CAACI,iBAAiB,EAAE;IAC5D,OAAOJ,SAAS,CAACI,iBAAiB,EAAE;EACtC;EACA,OAAOJ,SAAS;AAClB;AAEA,MAAMK,mBAAmB,GAAGJ,MAAM,CAACC,UAAU,GACzCP,2BAA2B,GAC3BG,cAAc;AAElB,OAAO,SAASQ,cAAcA,CAAA,EAA2C;EACvE,MAAMC,GAAG,GAAGb,cAAc,CAAoC,CAAC,CAAC,CAAC;EACjE,MAAMc,GAAG,GAAGf,MAAM,EAAwB;EAE1C,IAAI,CAACe,GAAG,CAACC,OAAO,EAAE;IAChB,MAAMC,GAAyB,GAA2BV,SAAS,IAAK;MACtE;MACA,IAAIA,SAAS,EAAE;QACbO,GAAG,CAACI,KAAK,GAAGN,mBAAmB,CAACN,2BAA2B,CAACC,SAAS,CAAC,CAAC;QACvEU,GAAG,CAACD,OAAO,GAAGT,SAAS;MACzB;MACA,OAAOO,GAAG,CAACI,KAAK;IAClB,CAAE;IAEFD,GAAG,CAACD,OAAO,GAAG,IAAI;IAElB,MAAMG,SAAS,GAAGhB,2BAA2B,CAAC;MAC5CiB,MAAM,EAAEA,CAAA,KAAM;QACZ,SAAS;;QACT,OAAO,MAAMN,GAAG,CAACI,KAAK;MACxB;IACF,CAAC,CAAC;IACFd,wBAAwB,CAACa,GAAG,EAAEE,SAAS,CAAC;IACxCJ,GAAG,CAACC,OAAO,GAAGC,GAAG;EACnB;EAEA,OAAOF,GAAG,CAACC,OAAO;AACpB"}
1
+ {"version":3,"names":["useRef","useSharedValue","getShadowNodeWrapperFromRef","makeShareableCloneRecursive","registerShareableMapping","findNodeHandle","getComponentOrScrollable","component","global","_IS_FABRIC","getNativeScrollRef","getScrollableNode","getTagValueFunction","useAnimatedRef","tag","ref","current","fun","value","remoteRef","__init"],"sources":["useAnimatedRef.ts"],"sourcesContent":["import type { Component } from 'react';\nimport { useRef } from 'react';\nimport { useSharedValue } from './useSharedValue';\nimport type { AnimatedRef } from './commonTypes';\nimport type { ShadowNodeWrapper } from '../commonTypes';\nimport { getShadowNodeWrapperFromRef } from '../fabricUtils';\nimport {\n makeShareableCloneRecursive,\n registerShareableMapping,\n} from '../shareables';\nimport { findNodeHandle } from 'react-native';\ninterface MaybeScrollableComponent extends Component {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getNativeScrollRef?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getScrollableNode?: any;\n}\n\nfunction getComponentOrScrollable(component: MaybeScrollableComponent) {\n if (global._IS_FABRIC && component.getNativeScrollRef) {\n return component.getNativeScrollRef();\n } else if (!global._IS_FABRIC && component.getScrollableNode) {\n return component.getScrollableNode();\n }\n return component;\n}\n\nconst getTagValueFunction = global._IS_FABRIC\n ? getShadowNodeWrapperFromRef\n : findNodeHandle;\n\nexport function useAnimatedRef<\n T extends MaybeScrollableComponent\n>(): AnimatedRef<T> {\n const tag = useSharedValue<number | ShadowNodeWrapper | null>(-1);\n const ref = useRef<AnimatedRef<T>>();\n\n if (!ref.current) {\n const fun: AnimatedRef<T> = <AnimatedRef<T>>((component) => {\n // enters when ref is set by attaching to a component\n if (component) {\n tag.value = getTagValueFunction(getComponentOrScrollable(component));\n fun.current = component;\n }\n return tag.value;\n });\n\n fun.current = null;\n\n const remoteRef = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return () => tag.value;\n },\n });\n registerShareableMapping(fun, remoteRef);\n ref.current = fun;\n }\n\n return ref.current;\n}\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,cAAc,QAAQ,kBAAkB;AAGjD,SAASC,2BAA2B,QAAQ,gBAAgB;AAC5D,SACEC,2BAA2B,EAC3BC,wBAAwB,QACnB,eAAe;AACtB,SAASC,cAAc,QAAQ,cAAc;AAQ7C,SAASC,wBAAwBA,CAACC,SAAmC,EAAE;EACrE,IAAIC,MAAM,CAACC,UAAU,IAAIF,SAAS,CAACG,kBAAkB,EAAE;IACrD,OAAOH,SAAS,CAACG,kBAAkB,EAAE;EACvC,CAAC,MAAM,IAAI,CAACF,MAAM,CAACC,UAAU,IAAIF,SAAS,CAACI,iBAAiB,EAAE;IAC5D,OAAOJ,SAAS,CAACI,iBAAiB,EAAE;EACtC;EACA,OAAOJ,SAAS;AAClB;AAEA,MAAMK,mBAAmB,GAAGJ,MAAM,CAACC,UAAU,GACzCP,2BAA2B,GAC3BG,cAAc;AAElB,OAAO,SAASQ,cAAcA,CAAA,EAEV;EAClB,MAAMC,GAAG,GAAGb,cAAc,CAAoC,CAAC,CAAC,CAAC;EACjE,MAAMc,GAAG,GAAGf,MAAM,EAAkB;EAEpC,IAAI,CAACe,GAAG,CAACC,OAAO,EAAE;IAChB,MAAMC,GAAmB,GAAqBV,SAAS,IAAK;MAC1D;MACA,IAAIA,SAAS,EAAE;QACbO,GAAG,CAACI,KAAK,GAAGN,mBAAmB,CAACN,wBAAwB,CAACC,SAAS,CAAC,CAAC;QACpEU,GAAG,CAACD,OAAO,GAAGT,SAAS;MACzB;MACA,OAAOO,GAAG,CAACI,KAAK;IAClB,CAAE;IAEFD,GAAG,CAACD,OAAO,GAAG,IAAI;IAElB,MAAMG,SAAS,GAAGhB,2BAA2B,CAAC;MAC5CiB,MAAM,EAAEA,CAAA,KAAM;QACZ,SAAS;;QACT,OAAO,MAAMN,GAAG,CAACI,KAAK;MACxB;IACF,CAAC,CAAC;IACFd,wBAAwB,CAACa,GAAG,EAAEE,SAAS,CAAC;IACxCJ,GAAG,CAACC,OAAO,GAAGC,GAAG;EACnB;EAEA,OAAOF,GAAG,CAACC,OAAO;AACpB"}
@@ -260,7 +260,7 @@ function checkSharedValueUsage(prop, currentKey) {
260
260
  }
261
261
  }
262
262
 
263
- // TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
263
+ // This type is kept for backward compatibility.
264
264
 
265
265
  // TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
266
266
 
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","startMapper","stopMapper","makeRemote","updateProps","updatePropsJestWrapper","initialUpdaterRun","NativeReanimatedModule","useSharedValue","buildWorkletsHash","isAnimated","shallowEqual","validateAnimatedStyles","makeViewDescriptorsSet","makeViewsRefSet","isJest","shouldBeUseWeb","prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","global","__frameTimestamp","performance","now","frame","isAnimationCancelled","isAnimationRunning","updates","propName","requestAnimationFrame","jestStyleUpdater","animatedStyle","adapters","arguments","length","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","initRef","inputs","values","_closure","_dependencies","__DEV__","__workletHash","adaptersArray","adaptersHash","push","initialStyle","initial","remoteState","sharableViewDescriptors","native","fun","updaterFn","adapter","mapperId"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\nimport { startMapper, stopMapper, makeRemote } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport NativeReanimatedModule from '../NativeReanimated';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport type { DependencyList, Descriptor } from './commonTypes';\nimport type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';\nimport { makeViewDescriptorsSet, makeViewsRefSet } from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport type {\n AnimationObject,\n Timestamp,\n AdapterWorkletFunction,\n AnimatedStyle,\n BasicWorkletFunction,\n BasicWorkletFunctionOptional,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n} from '../commonTypes';\nimport type {\n ImageStyle,\n RegisteredStyle,\n TextStyle,\n ViewStyle,\n} from 'react-native';\nimport type { AnimateStyle } from '../helperTypes';\n\nexport interface AnimatedStyleResult {\n viewDescriptors: ViewDescriptorsSet;\n initial: AnimatedStyle;\n viewsRef: ViewRefSet<any>;\n animatedStyle?: MutableRefObject<AnimatedStyle>;\n}\n\ninterface AnimatedState {\n last: AnimatedStyle;\n animations: AnimatedStyle;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimationRef {\n initial: {\n value: AnimatedStyle;\n updater: () => AnimatedStyle;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle,\n lastAnimation: AnimatedStyle,\n lastValue: AnimatedStyle\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle>,\n adapters: AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (\n typeof prop === 'object' &&\n prop !== null &&\n prop.value === undefined\n ) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop !== null &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype AnimatedStyleProp<T> = AnimateStyle<T> | RegisteredStyle<AnimateStyle<T>>;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype useAnimatedStyleType = <\n T extends AnimatedStyleProp<ViewStyle | ImageStyle | TextStyle>\n>(\n updater: () => T,\n deps?: DependencyList | null\n) => T;\n\nexport const useAnimatedStyle = function <T extends AnimatedStyle>(\n // animated style cannot be an array\n updater: BasicWorkletFunction<T extends Array<unknown> ? never : T>,\n dependencies?: DependencyList,\n adapters?: AdapterWorkletFunction | AdapterWorkletFunction[]\n): AnimatedStyleResult {\n const viewsRef: ViewRefSet<any> = makeViewsRefSet();\n const initRef = useRef<AnimationRef>();\n let inputs = Object.values(updater._closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `useAnimatedStyle was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.\n\nFor more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/web-support#web-without-a-babel-plugin`\n );\n }\n }\n const adaptersArray: AdapterWorkletFunction[] = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const animationsActive = useSharedValue<boolean>(true);\n const animatedStyle: MutableRefObject<AnimatedStyle> = useRef<AnimatedStyle>(\n {}\n );\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!initRef.current) {\n const initialStyle: AnimatedStyle = initialUpdaterRun(updater);\n validateAnimatedStyles(initialStyle);\n initRef.current = {\n initial: {\n value: initialStyle,\n updater: updater,\n },\n remoteState: makeRemote<AnimatedState>({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { initial, remoteState, viewDescriptors } = initRef.current!;\n const sharableViewDescriptors = viewDescriptors.sharableViewDescriptors;\n const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;\n\n dependencies.push(sharableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater as BasicWorkletFunctionOptional<T>;\n if (adapters) {\n updaterFn = () => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n };\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n sharableViewDescriptors,\n updater,\n remoteState,\n maybeViewRef,\n animationsActive,\n animatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n sharableViewDescriptors,\n updaterFn,\n remoteState,\n maybeViewRef,\n animationsActive\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n animationsActive.value = true;\n return () => {\n animationsActive.value = false;\n };\n }, []);\n\n checkSharedValueUsage(initial.value);\n\n if (isJest()) {\n return { viewDescriptors, initial, viewsRef, animatedStyle };\n } else {\n return { viewDescriptors, initial, viewsRef };\n }\n // TODO TYPESCRIPT This temporary cast is to get rid of .d.ts file.\n} as useAnimatedStyleType;\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,WAAW,EAAEC,UAAU,EAAEC,UAAU,QAAQ,SAAS;AAC7D,OAAOC,WAAW,IAAIC,sBAAsB,QAAQ,gBAAgB;AACpE,SAASC,iBAAiB,QAAQ,cAAc;AAChD,OAAOC,sBAAsB,MAAM,qBAAqB;AACxD,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,iBAAiB,EACjBC,UAAU,EACVC,YAAY,EACZC,sBAAsB,QACjB,SAAS;AAGhB,SAASC,sBAAsB,EAAEC,eAAe,QAAQ,uBAAuB;AAC/E,SAASC,MAAM,EAAEC,cAAc,QAAQ,oBAAoB;AA2C3D,SAASC,gBAAgBA,CACvBC,cAAsB,EACtBC,YAA2B,EAC3BC,aAA4B,EAC5BC,SAAwB,EAClB;EACN,SAAS;;EACT,IAAIC,KAAK,CAACC,OAAO,CAACJ,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACK,OAAO,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;MACpCT,gBAAgB,CACdC,cAAc,EACdO,IAAI,EACJL,aAAa,IAAIA,aAAa,CAACM,KAAK,CAAC,EACrCL,SAAS,IAAIA,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AS,CAAC;QACpB,CAAC,CAAC;QACF,OAAOA,SAAS;MAClB,CAAC;IACH;IAEA,IAAIrC,MAAM,EAAE,EAAE;MACZgF,GAAG,GAAGA,CAAA,KAAM;QACV,SAAS;;QACT3B,gBAAgB,CACdyB,uBAAuB,EACvB7C,OAAO,EACP4C,WAAW,EACX1C,YAAY,EACZV,gBAAgB,EAChB6B,aAAa,EACbkB,aAAa,CACd;MACH,CAAC;IACH,CAAC,MAAM;MACLQ,GAAG,GAAGA,CAAA,KAAM;QACV,SAAS;;QACTjD,YAAY,CACV+C,uBAAuB,EACvBG,SAAS,EACTJ,WAAW,EACX1C,YAAY,EACZV,gBAAgB,CACjB;MACH,CAAC;IACH;IACA,MAAM0D,QAAQ,GAAGjG,WAAW,CAAC8F,GAAG,EAAEd,MAAM,CAAC;IACzC,OAAO,MAAM;MACX/E,UAAU,CAACgG,QAAQ,CAAC;IACtB,CAAC;EACH,CAAC,EAAEpB,YAAY,CAAC;EAEhB/E,SAAS,CAAC,MAAM;IACdyC,gBAAgB,CAACX,KAAK,GAAG,IAAI;IAC7B,OAAO,MAAM;MACXW,gBAAgB,CAACX,KAAK,GAAG,KAAK;IAChC,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN4C,qBAAqB,CAACkB,OAAO,CAAC9D,KAAK,CAAC;EAEpC,IAAId,MAAM,EAAE,EAAE;IACZ,OAAO;MAAEgC,eAAe;MAAE4C,OAAO;MAAEZ,QAAQ;MAAEV;IAAc,CAAC;EAC9D,CAAC,MAAM;IACL,OAAO;MAAEtB,eAAe;MAAE4C,OAAO;MAAEZ;IAAS,CAAC;EAC/C;EACA;AACF,CAAyB"}
1
+ {"version":3,"names":["useEffect","useRef","startMapper","stopMapper","makeRemote","updateProps","updatePropsJestWrapper","initialUpdaterRun","NativeReanimatedModule","useSharedValue","buildWorkletsHash","isAnimated","shallowEqual","validateAnimatedStyles","makeViewDescriptorsSet","makeViewsRefSet","isJest","shouldBeUseWeb","prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","global","__frameTimestamp","performance","now","frame","isAnimationCancelled","isAnimationRunning","updates","propName","requestAnimationFrame","jestStyleUpdater","animatedStyle","adapters","arguments","length","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","initRef","inputs","values","_closure","_dependencies","__DEV__","__workletHash","adaptersArray","adaptersHash","push","initialStyle","initial","remoteState","sharableViewDescriptors","native","fun","updaterFn","adapter","mapperId"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\n\nimport { startMapper, stopMapper, makeRemote } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport NativeReanimatedModule from '../NativeReanimated';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport type { DependencyList, Descriptor } from './commonTypes';\nimport type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';\nimport { makeViewDescriptorsSet, makeViewsRefSet } from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport type {\n AnimationObject,\n Timestamp,\n AdapterWorkletFunction,\n BasicWorkletFunction,\n BasicWorkletFunctionOptional,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n} from '../commonTypes';\nimport type {\n ImageStyle,\n RegisteredStyle,\n TextStyle,\n ViewStyle,\n} from 'react-native';\nimport type { AnimatedStyle } from '../helperTypes';\n\nexport interface AnimatedStyleResult {\n viewDescriptors: ViewDescriptorsSet;\n initial: AnimatedStyle<any>;\n viewsRef: ViewRefSet<any>;\n animatedStyle?: MutableRefObject<AnimatedStyle<any>>;\n}\n\ninterface AnimatedState {\n last: AnimatedStyle<any>;\n animations: AnimatedStyle<any>;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimationRef {\n initial: {\n value: AnimatedStyle<any>;\n updater: () => AnimatedStyle<any>;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle<any>,\n lastAnimation: AnimatedStyle<any>,\n lastValue: AnimatedStyle<any>\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle<any>,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle<any>,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle<any>>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle<any>>,\n adapters: AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle<any> = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle<any> = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (\n typeof prop === 'object' &&\n prop !== null &&\n prop.value === undefined\n ) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop !== null &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\n// This type is kept for backward compatibility.\nexport type AnimatedStyleProp<T> =\n | AnimatedStyle<T>\n | RegisteredStyle<AnimatedStyle<T>>;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype useAnimatedStyleType = <\n T extends AnimatedStyleProp<ViewStyle | ImageStyle | TextStyle>\n>(\n updater: () => T,\n deps?: DependencyList | null\n) => T;\n\nexport const useAnimatedStyle = function <T extends AnimatedStyle<any>>(\n // animated style cannot be an array\n updater: BasicWorkletFunction<T extends Array<unknown> ? never : T>,\n dependencies?: DependencyList,\n adapters?: AdapterWorkletFunction | AdapterWorkletFunction[]\n): AnimatedStyleResult {\n const viewsRef: ViewRefSet<any> = makeViewsRefSet();\n const initRef = useRef<AnimationRef>();\n let inputs = Object.values(updater._closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `useAnimatedStyle was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.\n\nFor more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/web-support#web-without-a-babel-plugin`\n );\n }\n }\n const adaptersArray: AdapterWorkletFunction[] = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const animationsActive = useSharedValue<boolean>(true);\n const animatedStyle: MutableRefObject<AnimatedStyle<any>> = useRef<\n AnimatedStyle<any>\n >({});\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!initRef.current) {\n const initialStyle: AnimatedStyle<any> = initialUpdaterRun(updater);\n validateAnimatedStyles(initialStyle);\n initRef.current = {\n initial: {\n value: initialStyle,\n updater: updater,\n },\n remoteState: makeRemote<AnimatedState>({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { initial, remoteState, viewDescriptors } = initRef.current!;\n const sharableViewDescriptors = viewDescriptors.sharableViewDescriptors;\n const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;\n\n dependencies.push(sharableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater as BasicWorkletFunctionOptional<T>;\n if (adapters) {\n updaterFn = () => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n };\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n sharableViewDescriptors,\n updater,\n remoteState,\n maybeViewRef,\n animationsActive,\n animatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n sharableViewDescriptors,\n updaterFn,\n remoteState,\n maybeViewRef,\n animationsActive\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n animationsActive.value = true;\n return () => {\n animationsActive.value = false;\n };\n }, []);\n\n checkSharedValueUsage(initial.value);\n\n if (isJest()) {\n return { viewDescriptors, initial, viewsRef, animatedStyle };\n } else {\n return { viewDescriptors, initial, viewsRef };\n }\n // TODO TYPESCRIPT This temporary cast is to get rid of .d.ts file.\n} as useAnimatedStyleType;\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,WAAW,EAAEC,UAAU,EAAEC,UAAU,QAAQ,SAAS;AAC7D,OAAOC,WAAW,IAAIC,sBAAsB,QAAQ,gBAAgB;AACpE,SAASC,iBAAiB,QAAQ,cAAc;AAChD,OAAOC,sBAAsB,MAAM,qBAAqB;AACxD,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,iBAAiB,EACjBC,UAAU,EACVC,YAAY,EACZC,sBAAsB,QACjB,SAAS;AAGhB,SAASC,sBAAsB,EAAEC,eAAe,QAAQ,uBAAuB;AAC/E,SAASC,MAAM,EAAEC,cAAc,QAAQ,oBAAoB;AA0C3D,SAASC,gBAAgBA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,CAAC,MAAM;IACL,OAAO;MAAEtB,eAAe;MAAE4C,OAAO;MAAEZ;IAAS,CAAC;EAC/C;EACA;AACF,CAAyB"}
@@ -1,8 +1,6 @@
1
1
  import { useEffect, useRef } from 'react';
2
- import { processColor } from '../Colors';
3
2
  import { makeRemote } from '../core';
4
3
  import { isWeb, isJest } from '../PlatformChecker';
5
- import { colorProps } from '../UpdateProps';
6
4
  import WorkletEventHandler from '../WorkletEventHandler';
7
5
 
8
6
  // TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
@@ -59,7 +57,7 @@ export function buildWorkletsHash(handlers) {
59
57
  }
60
58
 
61
59
  // builds dependencies array for gesture handlers
62
- export function buildDependencies(dependencies, handlers) {
60
+ function buildDependencies(dependencies, handlers) {
63
61
  const handlersList = Object.values(handlers).filter(handler => handler !== undefined);
64
62
  if (!dependencies) {
65
63
  dependencies = handlersList.map(handler => {
@@ -75,7 +73,7 @@ export function buildDependencies(dependencies, handlers) {
75
73
  }
76
74
 
77
75
  // this is supposed to work as useEffect comparison
78
- export function areDependenciesEqual(nextDeps, prevDeps) {
76
+ function areDependenciesEqual(nextDeps, prevDeps) {
79
77
  function is(x, y) {
80
78
  /* eslint-disable no-self-compare */
81
79
  return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
@@ -96,29 +94,6 @@ export function areDependenciesEqual(nextDeps, prevDeps) {
96
94
  }
97
95
  return areHookInputsEqual(nextDeps, prevDeps);
98
96
  }
99
- export function hasColorProps(updates) {
100
- const colorPropsSet = new Set(colorProps);
101
- for (const key in updates) {
102
- if (colorPropsSet.has(key)) {
103
- return true;
104
- }
105
- }
106
- return false;
107
- }
108
- export function parseColors(updates) {
109
- 'worklet';
110
-
111
- for (const key in updates) {
112
- if (colorProps.indexOf(key) !== -1) {
113
- // value could be an animation in which case processColor will recognize it and will return undefined
114
- // -> in such a case we don't want to override style of that key
115
- const processedColor = processColor(updates[key]);
116
- if (processedColor !== undefined) {
117
- updates[key] = processedColor;
118
- }
119
- }
120
- }
121
- }
122
97
  export function isAnimated(prop) {
123
98
  'worklet';
124
99
 
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","processColor","makeRemote","isWeb","isJest","colorProps","WorkletEventHandler","useEvent","handler","eventNames","arguments","length","undefined","rebuild","initRef","current","updateWorklet","useHandler","handlers","dependencies","context","savedDependencies","buildDependencies","doDependenciesDiffer","areDependenciesEqual","useWeb","buildWorkletsHash","Object","values","reduce","acc","worklet","__workletHash","toString","handlersList","filter","map","workletHash","closure","_closure","push","nextDeps","prevDeps","is","x","y","objectIs","areHookInputsEqual","i","hasColorProps","updates","colorPropsSet","Set","key","has","parseColors","indexOf","processedColor","isAnimated","prop","Array","isArray","some","onFrame","shallowEqual","a","b","aKeys","keys","bKeys","validateAnimatedStyles","styles","Error"],"sources":["utils.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\nimport { processColor } from '../Colors';\nimport type {\n AnimatedStyle,\n Context,\n NativeEvent,\n NestedObjectValues,\n WorkletFunction,\n AnimationObject,\n} from '../commonTypes';\nimport { makeRemote } from '../core';\nimport { isWeb, isJest } from '../PlatformChecker';\nimport { colorProps } from '../UpdateProps';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport type { ContextWithDependencies, DependencyList } from './commonTypes';\nimport type { NativeSyntheticEvent } from 'react-native';\ninterface Handler<T, TContext extends Context> extends WorkletFunction {\n (event: T, context: TContext): void;\n}\n\ninterface Handlers<T, TContext extends Context> {\n [key: string]: Handler<T, TContext> | undefined;\n}\n\nexport interface UseHandlerContext<TContext extends Context> {\n context: TContext;\n doDependenciesDiffer: boolean;\n useWeb: boolean;\n}\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype useEventType = <T extends object>(\n handler: (e: T) => void,\n eventNames?: string[],\n rebuild?: boolean\n) => (e: NativeSyntheticEvent<T>) => void;\n\nexport const useEvent = function <T extends NativeEvent<T>>(\n handler: (event: T) => void,\n eventNames: string[] = [],\n rebuild = false\n): MutableRefObject<WorkletEventHandler<T> | null> {\n const initRef = useRef<WorkletEventHandler<T> | null>(null);\n if (initRef.current === null) {\n initRef.current = new WorkletEventHandler(handler, eventNames);\n } else if (rebuild) {\n initRef.current.updateWorklet(handler);\n }\n\n return initRef;\n // TODO TYPESCRIPT This cast is to get rid of .d.ts file.\n} as unknown as useEventType;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype useHandlerType = <T, TContext extends Context = Record<string, never>>(\n handlers: Handlers<T, TContext>,\n deps?: DependencyList\n) => { context: TContext; doDependenciesDiffer: boolean; useWeb: boolean };\n\nexport const useHandler = function <T, TContext extends Context>(\n handlers: Handlers<T, TContext>,\n dependencies?: DependencyList\n): UseHandlerContext<TContext> {\n const initRef = useRef<ContextWithDependencies<TContext> | null>(null);\n if (initRef.current === null) {\n initRef.current = {\n context: makeRemote<TContext>({} as TContext),\n savedDependencies: [],\n };\n }\n\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n\n const { context, savedDependencies } = initRef.current;\n\n dependencies = buildDependencies(dependencies, handlers);\n\n const doDependenciesDiffer = !areDependenciesEqual(\n dependencies,\n savedDependencies\n );\n initRef.current.savedDependencies = dependencies;\n const useWeb = isWeb() || isJest();\n\n return { context, doDependenciesDiffer, useWeb };\n // TODO TYPESCRIPT This temporary cast is to get rid of .d.ts file.\n} as useHandlerType;\n\n// builds one big hash from multiple worklets' hashes\nexport function buildWorkletsHash(\n handlers: Record<string, WorkletFunction> | Array<WorkletFunction>\n): string {\n return Object.values(handlers).reduce(\n (acc: string, worklet: WorkletFunction) =>\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n acc + worklet.__workletHash!.toString(),\n ''\n );\n}\n\n// builds dependencies array for gesture handlers\nexport function buildDependencies(\n dependencies: DependencyList,\n handlers: Record<string, WorkletFunction | undefined>\n): Array<unknown> {\n const handlersList: WorkletFunction[] = Object.values(handlers).filter(\n (handler) => handler !== undefined\n ) as WorkletFunction[];\n if (!dependencies) {\n dependencies = handlersList.map((handler) => {\n return {\n workletHash: handler.__workletHash,\n closure: handler._closure,\n };\n });\n } else {\n dependencies.push(buildWorkletsHash(handlersList));\n }\n\n return dependencies;\n}\n\n// this is supposed to work as useEffect comparison\nexport function areDependenciesEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n): boolean {\n function is(x: number, y: number) {\n /* eslint-disable no-self-compare */\n return (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y);\n /* eslint-enable no-self-compare */\n }\n const objectIs: (nextDeps: unknown, prevDeps: unknown) => boolean =\n typeof Object.is === 'function' ? Object.is : is;\n\n function areHookInputsEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n ): boolean {\n if (!nextDeps || !prevDeps || prevDeps.length !== nextDeps.length) {\n return false;\n }\n for (let i = 0; i < prevDeps.length; ++i) {\n if (!objectIs(nextDeps[i], prevDeps[i])) {\n return false;\n }\n }\n return true;\n }\n\n return areHookInputsEqual(nextDeps, prevDeps);\n}\n\nexport function hasColorProps(updates: AnimatedStyle): boolean {\n const colorPropsSet = new Set(colorProps);\n for (const key in updates) {\n if (colorPropsSet.has(key)) {\n return true;\n }\n }\n return false;\n}\n\nexport function parseColors(updates: AnimatedStyle): void {\n 'worklet';\n for (const key in updates) {\n if (colorProps.indexOf(key) !== -1) {\n // value could be an animation in which case processColor will recognize it and will return undefined\n // -> in such a case we don't want to override style of that key\n const processedColor = processColor(updates[key]);\n if (processedColor !== undefined) {\n updates[key] = processedColor;\n }\n }\n }\n}\n\nexport function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean {\n 'worklet';\n if (Array.isArray(prop)) {\n return prop.some(isAnimated);\n } else if (typeof prop === 'object' && prop !== null) {\n if (prop.onFrame !== undefined) {\n return true;\n } else {\n return Object.values(prop).some(isAnimated);\n }\n }\n return false;\n}\n\nexport function shallowEqual(a: any, b: any) {\n 'worklet';\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (let i = 0; i < aKeys.length; i++) {\n if (a[aKeys[i]] !== b[aKeys[i]]) {\n return false;\n }\n }\n return true;\n}\n\nexport const validateAnimatedStyles = (styles: AnimatedStyle): void => {\n 'worklet';\n if (typeof styles !== 'object') {\n throw new Error(\n `useAnimatedStyle has to return an object, found ${typeof styles} instead`\n );\n } else if (Array.isArray(styles)) {\n throw new Error(\n 'useAnimatedStyle has to return an object and cannot return static styles combined with dynamic ones. Please do merging where a component receives props.'\n );\n }\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,YAAY,QAAQ,WAAW;AASxC,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,KAAK,EAAEC,MAAM,QAAQ,oBAAoB;AAClD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,OAAOC,mBAAmB,MAAM,wBAAwB;;AAiBxD;;AAOA,OAAO,MAAMC,QAAQ,GAAG,SAAAA,CACtBC,OAA2B,EAGsB;EAAA,IAFjDC,UAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,IACzBG,OAAO,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEf,MAAMI,OAAO,GAAGd,MAAM,CAAgC,IAAI,CAAC;EAC3D,IAAIc,OAAO,CAACC,OAAO,KAAK,IAAI,EAAE;IAC5BD,OAAO,CAACC,OAAO,GAAG,IAAIT,mBAAmB,CAACE,OAAO,EAAEC,UAAU,CAAC;EAChE,CAAC,MAAM,IAAII,OAAO,EAAE;IAClBC,OAAO,CAACC,OAAO,CAACC,aAAa,CAACR,OAAO,CAAC;EACxC;EAEA,OAAOM,OAAO;EACd;AACF,CAA4B;;AAE5B;;AAMA,OAAO,MAAMG,UAAU,GAAG,SAAAA,CACxBC,QAA+B,EA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C,CAAC;EAC5B,IAAIC,KAAK,CAACxD,MAAM,KAAK0D,KAAK,CAAC1D,MAAM,EAAE;IACjC,OAAO,KAAK;EACd;EACA,KAAK,IAAIqC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGmB,KAAK,CAACxD,MAAM,EAAEqC,CAAC,EAAE,EAAE;IACrC,IAAIiB,CAAC,CAACE,KAAK,CAACnB,CAAC,CAAC,CAAC,KAAKkB,CAAC,CAACC,KAAK,CAACnB,CAAC,CAAC,CAAC,EAAE;MAC/B,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb;AAEA,OAAO,MAAMsB,sBAAsB,GAAIC,MAAqB,IAAW;EACrE,SAAS;;EACT,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,MAAM,IAAIC,KAAK,CACZ,mDAAkD,OAAOD,MAAO,UAAS,CAC3E;EACH,CAAC,MAAM,IAAIX,KAAK,CAACC,OAAO,CAACU,MAAM,CAAC,EAAE;IAChC,MAAM,IAAIC,KAAK,CACb,0JAA0J,CAC3J;EACH;AACF,CAAC"}
1
+ {"version":3,"names":["useEffect","useRef","makeRemote","isWeb","isJest","WorkletEventHandler","useEvent","handler","eventNames","arguments","length","undefined","rebuild","initRef","current","updateWorklet","useHandler","handlers","dependencies","context","savedDependencies","buildDependencies","doDependenciesDiffer","areDependenciesEqual","useWeb","buildWorkletsHash","Object","values","reduce","acc","worklet","__workletHash","toString","handlersList","filter","map","workletHash","closure","_closure","push","nextDeps","prevDeps","is","x","y","objectIs","areHookInputsEqual","i","isAnimated","prop","Array","isArray","some","onFrame","shallowEqual","a","b","aKeys","keys","bKeys","validateAnimatedStyles","styles","Error"],"sources":["utils.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useEffect, useRef } from 'react';\nimport type {\n Context,\n NativeEvent,\n NestedObjectValues,\n WorkletFunction,\n AnimationObject,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\nimport { makeRemote } from '../core';\nimport { isWeb, isJest } from '../PlatformChecker';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport type { ContextWithDependencies, DependencyList } from './commonTypes';\nimport type { NativeSyntheticEvent } from 'react-native';\ninterface Handler<T, TContext extends Context> extends WorkletFunction {\n (event: T, context: TContext): void;\n}\n\ninterface Handlers<T, TContext extends Context> {\n [key: string]: Handler<T, TContext> | undefined;\n}\n\ninterface UseHandlerContext<TContext extends Context> {\n context: TContext;\n doDependenciesDiffer: boolean;\n useWeb: boolean;\n}\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype useEventType = <T extends object>(\n handler: (e: T) => void,\n eventNames?: string[],\n rebuild?: boolean\n) => (e: NativeSyntheticEvent<T>) => void;\n\nexport const useEvent = function <T extends NativeEvent<T>>(\n handler: (event: T) => void,\n eventNames: string[] = [],\n rebuild = false\n): MutableRefObject<WorkletEventHandler<T> | null> {\n const initRef = useRef<WorkletEventHandler<T> | null>(null);\n if (initRef.current === null) {\n initRef.current = new WorkletEventHandler(handler, eventNames);\n } else if (rebuild) {\n initRef.current.updateWorklet(handler);\n }\n\n return initRef;\n // TODO TYPESCRIPT This cast is to get rid of .d.ts file.\n} as unknown as useEventType;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype useHandlerType = <T, TContext extends Context = Record<string, never>>(\n handlers: Handlers<T, TContext>,\n deps?: DependencyList\n) => { context: TContext; doDependenciesDiffer: boolean; useWeb: boolean };\n\nexport const useHandler = function <T, TContext extends Context>(\n handlers: Handlers<T, TContext>,\n dependencies?: DependencyList\n): UseHandlerContext<TContext> {\n const initRef = useRef<ContextWithDependencies<TContext> | null>(null);\n if (initRef.current === null) {\n initRef.current = {\n context: makeRemote<TContext>({} as TContext),\n savedDependencies: [],\n };\n }\n\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n\n const { context, savedDependencies } = initRef.current;\n\n dependencies = buildDependencies(dependencies, handlers);\n\n const doDependenciesDiffer = !areDependenciesEqual(\n dependencies,\n savedDependencies\n );\n initRef.current.savedDependencies = dependencies;\n const useWeb = isWeb() || isJest();\n\n return { context, doDependenciesDiffer, useWeb };\n // TODO TYPESCRIPT This temporary cast is to get rid of .d.ts file.\n} as useHandlerType;\n\n// builds one big hash from multiple worklets' hashes\nexport function buildWorkletsHash(\n handlers: Record<string, WorkletFunction> | Array<WorkletFunction>\n): string {\n return Object.values(handlers).reduce(\n (acc: string, worklet: WorkletFunction) =>\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n acc + worklet.__workletHash!.toString(),\n ''\n );\n}\n\n// builds dependencies array for gesture handlers\nfunction buildDependencies(\n dependencies: DependencyList,\n handlers: Record<string, WorkletFunction | undefined>\n): Array<unknown> {\n const handlersList: WorkletFunction[] = Object.values(handlers).filter(\n (handler) => handler !== undefined\n ) as WorkletFunction[];\n if (!dependencies) {\n dependencies = handlersList.map((handler) => {\n return {\n workletHash: handler.__workletHash,\n closure: handler._closure,\n };\n });\n } else {\n dependencies.push(buildWorkletsHash(handlersList));\n }\n\n return dependencies;\n}\n\n// this is supposed to work as useEffect comparison\nfunction areDependenciesEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n): boolean {\n function is(x: number, y: number) {\n /* eslint-disable no-self-compare */\n return (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y);\n /* eslint-enable no-self-compare */\n }\n const objectIs: (nextDeps: unknown, prevDeps: unknown) => boolean =\n typeof Object.is === 'function' ? Object.is : is;\n\n function areHookInputsEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n ): boolean {\n if (!nextDeps || !prevDeps || prevDeps.length !== nextDeps.length) {\n return false;\n }\n for (let i = 0; i < prevDeps.length; ++i) {\n if (!objectIs(nextDeps[i], prevDeps[i])) {\n return false;\n }\n }\n return true;\n }\n\n return areHookInputsEqual(nextDeps, prevDeps);\n}\n\nexport function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean {\n 'worklet';\n if (Array.isArray(prop)) {\n return prop.some(isAnimated);\n } else if (typeof prop === 'object' && prop !== null) {\n if (prop.onFrame !== undefined) {\n return true;\n } else {\n return Object.values(prop).some(isAnimated);\n }\n }\n return false;\n}\n\nexport function shallowEqual(a: any, b: any) {\n 'worklet';\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (let i = 0; i < aKeys.length; i++) {\n if (a[aKeys[i]] !== b[aKeys[i]]) {\n return false;\n }\n }\n return true;\n}\n\nexport const validateAnimatedStyles = (styles: AnimatedStyle<any>): void => {\n 'worklet';\n if (typeof styles !== 'object') {\n throw new Error(\n `useAnimatedStyle has to return an object, found ${typeof styles} instead`\n );\n } else if (Array.isArray(styles)) {\n throw new Error(\n 'useAnimatedStyle has to return an object and cannot return static styles combined with dynamic ones. Please do merging where a component receives props.'\n );\n }\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AASzC,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,KAAK,EAAEC,MAAM,QAAQ,oBAAoB;AAClD,OAAOC,mBAAmB,MAAM,wBAAwB;;AAiBxD;;AAOA,OAAO,MAAMC,QAAQ,GAAG,SAAAA,CACtBC,OAA2B,EAGsB;EAAA,IAFjDC,UAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,IACzBG,OAAO,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEf,MAAMI,OAAO,GAAGZ,MAAM,CAAgC,IAAI,CAAC;EAC3D,IAAIY,OAAO,CAACC,OAAO,KAAK,IAAI,EAAE;IAC5BD,OAAO,CAACC,OAAO,GAAG,IAAIT,mBAAmB,CAACE,OAAO,EAAEC,UAAU,CAAC;EAChE,CAAC,MAAM,IAAII,OAAO,EAAE;IAClBC,OAAO,CAACC,OAAO,CAACC,aAAa,CA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D,OAAOD,MAAO,UAAS,CAC3E;EACH,CAAC,MAAM,IAAIX,KAAK,CAACC,OAAO,CAACU,MAAM,CAAC,EAAE;IAChC,MAAM,IAAIC,KAAK,CACb,0JAA0J,CAC3J;EACH;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './publicGlobals';\n\nexport * from './core';\nexport * from './hook';\nexport * from './animation';\nexport * from './interpolation';\nexport * from './interpolateColor';\nexport * from './Easing';\nexport * from './NativeMethods';\nexport * from './Colors';\nexport * from './PropAdapters';\nexport * from './layoutReanimation';\nexport * from './utils';\nexport * from './commonTypes';\nexport * from './frameCallback';\nexport * from './pluginUtils';\nexport * from './jestUtils';\nexport type { AnimateProps } from './helperTypes';\n"],"mappings":"AAAA,OAAO,iBAAiB;AAExB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,oBAAoB;AAClC,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,aAAa"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import './publicGlobals';\n\nexport * from './core';\nexport * from './hook';\nexport * from './animation';\nexport * from './interpolation';\nexport * from './interpolateColor';\nexport * from './Easing';\nexport * from './NativeMethods';\nexport * from './Colors';\nexport * from './PropAdapters';\nexport * from './layoutReanimation';\nexport * from './utils';\nexport * from './commonTypes';\nexport * from './frameCallback';\nexport * from './pluginUtils';\nexport * from './jestUtils';\nexport type {\n Adaptable,\n AdaptTransforms,\n AnimateProps,\n AnimatedProps,\n AnimatedTransform,\n TransformStyleTypes,\n AnimateStyle,\n AnimatedStyle,\n StylesOrDefault,\n} from './helperTypes';\nexport type { AnimatedScrollViewProps } from './component/ScrollView';\nexport type { FlatListPropsWithLayout } from './component/FlatList';\n"],"mappings":"AAAA,OAAO,iBAAiB;AAExB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,oBAAoB;AAClC,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","interpolate","useSharedValue","Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","arguments","Error","ColorSpace","useInterpolateConfig","RGB","cache","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport type { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\ninterface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\ninterface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): string;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): number;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n}\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB,\n interpolateConfig.value.options\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV,\n interpolateConfig.value.options\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,OAAO,QACF,UAAU;AACjB,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,SAASC,cAAc,QAAQ,uBAAuB;AAEtD,OAAO,MAAMC,WAAW,GAAG;EACzBC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,QAAQ,EAAE;AACZ,CAAC;AAOD,MAAMC,oBAAoB,GAAGA,CAC3BC,KAAa,EACbC,UAA6B,EAC7BC,MAAsB,EACtBC,OAA6B,KAC1B;EACH,SAAS;;EACT,IAAIC,CAAC,GAAG,CAAC;EACT,MAAM;IAAEC,4BAA4B,GAAG;EAAK,CAAC,GAAGF,OAAO;EACvD,IAAIE,4BAA4B,EAAE;IAChC;IACA;IACA;IACA;IACA,MAAMC,mBAAmB,GAAG,CAACL,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAMM,SAAS,GAAGL,MAAM,CAACE,CAAC;IAC1B,MAAMI,UAAU,GAAG,CAACD,SAAS,CAAC,CAAC,CAAC,CAAC;IAEjC,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,SAAS,CAACG,MAAM,EAAE,EAAED,CAAC,EAAE;MACzC,MAAME,CAAC,GAAGJ,SAAS,CAACE,CAAC,CAAC,GAAGF,SAAS,CAACE,CAAC,GAAG,CAAC,CAAC;MACzC,IAAIF,SAAS,CAACE,CAAC,CAAC,GAAGF,SAAS,CAACE,CAAC,GAAG,CAAC,CAAC,IAAIE,CAAC,GAAG,GAAG,EAAE;QAC9CL,mBAAmB,CAACM,IAAI,CAACX,UAAU,CAACQ,C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SAAS;;EACT,IAAI7C,MAAM,GAAG6C,iBAAiB,CAAC/C,KAAK,CAAC6C,KAAK,CAAC7C,KAAK;EAChD,IAAI+C,iBAAiB,CAAC/C,KAAK,CAACuC,UAAU,KAAKG,UAAU,CAACE,GAAG,EAAE;IACzD,IAAI,CAAC1C,MAAM,EAAE;MACXA,MAAM,GAAG6B,iBAAiB,CAACgB,iBAAiB,CAAC/C,KAAK,CAACsC,WAAW,CAAC;MAC/DS,iBAAiB,CAAC/C,KAAK,CAAC6C,KAAK,CAAC7C,KAAK,GAAGE,MAAM;IAC9C;IACA,OAAOsB,oBAAoB,CACzBxB,KAAK,EACL+C,iBAAiB,CAAC/C,KAAK,CAACC,UAAU,EAClCC,MAAM,EACN6C,iBAAiB,CAAC/C,KAAK,CAACG,OAAO,CAChC;EACH,CAAC,MAAM,IAAI4C,iBAAiB,CAAC/C,KAAK,CAACuC,UAAU,KAAKG,UAAU,CAACM,GAAG,EAAE;IAChE,IAAI,CAAC9C,MAAM,EAAE;MACXA,MAAM,GAAGiC,iBAAiB,CAACY,iBAAiB,CAAC/C,KAAK,CAACsC,WAAW,CAAC;MAC/DS,iBAAiB,CAAC/C,KAAK,CAAC6C,KAAK,CAAC7C,KAAK,GAAGE,MAAM;IAC9C;IACA,OAAOH,oBAAoB,CACzBC,KAAK,EACL+C,iBAAiB,CAAC/C,KAAK,CAACC,UAAU,EAClCC,MAAM,EACN6C,iBAAiB,CAAC/C,KAAK,CAACG,OAAO,CAChC;EACH;EACA,MAAM,IAAIsC,KAAK,CACZ,iCAAgCM,iBAAiB,CAAC/C,KAAK,CAACuC,UAAW,wCAAuC,CAC5G;AACH,CAAC"}
1
+ {"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","interpolate","useSharedValue","Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","arguments","Error","ColorSpace","useInterpolateConfig","RGB","cache","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport type { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\nexport interface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\nexport interface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): string;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): number;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n}\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB,\n interpolateConfig.value.options\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV,\n interpolateConfig.value.options\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,OAAO,QACF,UAAU;AACjB,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,SAASC,cAAc,QAAQ,uBAAuB;AAEtD,OAAO,MAAMC,WAAW,GAAG;EACzBC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,QAAQ,EAAE;AACZ,CAAC;AAOD,MAAMC,oBAAoB,GAAGA,CAC3BC,KAAa,EACbC,UAA6B,EAC7BC,MAAsB,EACtBC,OAA6B,KAC1B;EACH,SAAS;;EACT,IAAIC,CAAC,GAAG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