react-native-reanimated 2.3.0-beta.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +9 -0
  2. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
  3. package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
  4. package/Common/cpp/Tools/RuntimeDecorator.cpp +38 -2
  5. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +3 -0
  6. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +5 -0
  7. package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
  8. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +2 -0
  9. package/Common/cpp/headers/Tools/RuntimeDecorator.h +8 -7
  10. package/README.md +1 -1
  11. package/RNReanimated.podspec +20 -3
  12. package/android/build.gradle +31 -5
  13. package/android/expo/linking.gradle +46 -0
  14. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
  15. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
  16. package/android/react-native-reanimated-63-hermes.aar +0 -0
  17. package/android/react-native-reanimated-63-jsc.aar +0 -0
  18. package/android/react-native-reanimated-64-hermes.aar +0 -0
  19. package/android/react-native-reanimated-64-jsc.aar +0 -0
  20. package/android/react-native-reanimated-65-hermes.aar +0 -0
  21. package/android/react-native-reanimated-65-jsc.aar +0 -0
  22. package/android/react-native-reanimated-66-hermes.aar +0 -0
  23. package/android/react-native-reanimated-66-jsc.aar +0 -0
  24. package/android/react-native-reanimated-67-hermes.aar +0 -0
  25. package/android/react-native-reanimated-67-jsc.aar +0 -0
  26. package/expo-module.config.json +3 -0
  27. package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
  28. package/ios/LayoutReanimation/REAAnimationsManager.m +68 -19
  29. package/ios/LayoutReanimation/REAUIManager.mm +63 -18
  30. package/ios/Nodes/REAPropsNode.m +1 -1
  31. package/ios/REAEventDispatcher.m +1 -1
  32. package/ios/REAModule.h +0 -2
  33. package/ios/REAModule.m +0 -3
  34. package/ios/REANodesManager.m +1 -0
  35. package/ios/RNGestureHandlerStateManager.h +5 -0
  36. package/ios/native/NativeMethods.h +5 -0
  37. package/ios/native/NativeMethods.mm +8 -1
  38. package/ios/native/NativeProxy.h +1 -0
  39. package/ios/native/NativeProxy.mm +19 -3
  40. package/ios/native/REAInitializer.mm +7 -3
  41. package/lib/src/Animated.js +31 -0
  42. package/lib/{ConfigHelper.js → src/ConfigHelper.js} +0 -0
  43. package/lib/{ReanimatedEventEmitter.js → src/ReanimatedEventEmitter.js} +0 -0
  44. package/lib/{ReanimatedModule.js → src/ReanimatedModule.js} +0 -0
  45. package/lib/{ReanimatedModule.macos.js → src/ReanimatedModule.macos.js} +0 -0
  46. package/lib/{ReanimatedModule.native.js → src/ReanimatedModule.native.js} +0 -0
  47. package/lib/{ReanimatedModule.windows.js → src/ReanimatedModule.windows.js} +0 -0
  48. package/lib/{ReanimatedModuleCompat.js → src/ReanimatedModuleCompat.js} +0 -0
  49. package/lib/{__mocks__ → src/__mocks__}/ReanimatedEventEmitter.js +0 -0
  50. package/lib/{__mocks__ → src/__mocks__}/ReanimatedModule.native.js +0 -0
  51. package/lib/{createAnimatedComponent.js → src/createAnimatedComponent.js} +55 -37
  52. package/lib/src/index.js +31 -0
  53. package/lib/{reanimated1 → src/reanimated1}/Easing.js +0 -0
  54. package/lib/{reanimated1 → src/reanimated1}/SpringConfig.js +0 -0
  55. package/lib/{reanimated1 → src/reanimated1}/Transitioning.js +0 -0
  56. package/lib/{reanimated1 → src/reanimated1}/animations/Animation.js +0 -0
  57. package/lib/{reanimated1 → src/reanimated1}/animations/SpringUtils.js +0 -0
  58. package/lib/{reanimated1 → src/reanimated1}/animations/backwardCompatibleAnimWrapper.js +0 -0
  59. package/lib/{reanimated1 → src/reanimated1}/animations/decay.js +0 -0
  60. package/lib/{reanimated1 → src/reanimated1}/animations/spring.js +0 -0
  61. package/lib/{reanimated1 → src/reanimated1}/animations/timing.js +0 -0
  62. package/lib/{reanimated1 → src/reanimated1}/base.js +0 -0
  63. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedAlways.js +0 -0
  64. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBezier.js +0 -0
  65. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBlock.js +0 -0
  66. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCall.js +0 -0
  67. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCallFunc.js +0 -0
  68. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClock.js +0 -0
  69. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClockTest.js +0 -0
  70. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCode.js +0 -0
  71. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedConcat.js +0 -0
  72. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCond.js +0 -0
  73. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedDebug.js +0 -0
  74. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedEvent.js +0 -0
  75. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedFunction.js +0 -0
  76. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedNode.js +0 -0
  77. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedOperator.js +0 -0
  78. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedParam.js +0 -0
  79. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedProps.js +0 -0
  80. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedSet.js +0 -0
  81. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStartClock.js +0 -0
  82. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStopClock.js +0 -0
  83. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStyle.js +0 -0
  84. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedTransform.js +0 -0
  85. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedValue.js +0 -0
  86. package/lib/{reanimated1 → src/reanimated1}/core/Core.test.js +1 -1
  87. package/lib/{reanimated1 → src/reanimated1}/core/InternalAnimatedValue.js +0 -0
  88. package/lib/{reanimated1 → src/reanimated1}/core/__mocks__/AnimatedProps.js +0 -0
  89. package/lib/{reanimated1 → src/reanimated1}/core/createEventObjectProxyPolyfill.js +0 -0
  90. package/lib/{reanimated1 → src/reanimated1}/derived/__mocks__/evaluateOnce.js +0 -0
  91. package/lib/{reanimated1 → src/reanimated1}/derived/acc.js +0 -0
  92. package/lib/{reanimated1 → src/reanimated1}/derived/color.js +0 -0
  93. package/lib/{reanimated1 → src/reanimated1}/derived/diff.js +0 -0
  94. package/lib/{reanimated1 → src/reanimated1}/derived/diffClamp.js +0 -0
  95. package/lib/{reanimated1 → src/reanimated1}/derived/evaluateOnce.js +0 -0
  96. package/lib/{reanimated1 → src/reanimated1}/derived/index.js +0 -0
  97. package/lib/{reanimated1 → src/reanimated1}/derived/interpolate.js +0 -0
  98. package/lib/{reanimated1 → src/reanimated1}/derived/interpolateColors.js +0 -0
  99. package/lib/{reanimated1 → src/reanimated1}/derived/onChange.js +0 -0
  100. package/lib/{reanimated1 → src/reanimated1}/derived/useCode.js +0 -0
  101. package/lib/{reanimated1 → src/reanimated1}/index.js +0 -0
  102. package/lib/{reanimated1 → src/reanimated1}/operators.js +0 -0
  103. package/lib/{reanimated1 → src/reanimated1}/useValue.js +0 -0
  104. package/lib/{reanimated1 → src/reanimated1}/val.js +0 -0
  105. package/lib/{reanimated2 → src/reanimated2}/Bezier.js +0 -0
  106. package/lib/{reanimated2 → src/reanimated2}/Colors.js +1 -97
  107. package/lib/{reanimated2 → src/reanimated2}/Easing.js +5 -0
  108. package/lib/src/reanimated2/NativeMethods.js +42 -0
  109. package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/NativeReanimated.js +3 -0
  110. package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/index.js +2 -2
  111. package/lib/{reanimated2 → src/reanimated2}/PlatformChecker.js +0 -0
  112. package/lib/{reanimated2 → src/reanimated2}/PropAdapters.js +0 -0
  113. package/lib/{reanimated2 → src/reanimated2}/UpdateProps.js +1 -1
  114. package/lib/{reanimated2 → src/reanimated2}/ViewDescriptorsSet.js +4 -2
  115. package/lib/{reanimated2 → src/reanimated2}/WorkletEventHandler.js +0 -0
  116. package/lib/{reanimated2 → src/reanimated2}/__mocks__/MutableValue.js +0 -0
  117. package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.js +0 -0
  118. package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.native.js +0 -0
  119. package/lib/{reanimated2 → src/reanimated2}/animation/commonTypes.js +0 -0
  120. package/lib/{reanimated2 → src/reanimated2}/animation/decay.js +0 -0
  121. package/lib/{reanimated2 → src/reanimated2}/animation/delay.js +0 -0
  122. package/lib/{reanimated2 → src/reanimated2}/animation/index.js +0 -0
  123. package/lib/{reanimated2 → src/reanimated2}/animation/repeat.js +0 -0
  124. package/lib/{reanimated2 → src/reanimated2}/animation/sequence.js +0 -0
  125. package/lib/{reanimated2 → src/reanimated2}/animation/spring.js +0 -0
  126. package/lib/{reanimated2 → src/reanimated2}/animation/styleAnimation.js +5 -0
  127. package/lib/{reanimated2 → src/reanimated2}/animation/timing.js +0 -0
  128. package/lib/{reanimated2 → src/reanimated2}/animation/util.js +0 -0
  129. package/lib/{reanimated2 → src/reanimated2}/commonTypes.js +0 -0
  130. package/lib/src/reanimated2/component/FlatList.js +30 -0
  131. package/lib/src/reanimated2/component/WrappedComponents.js +9 -0
  132. package/lib/src/reanimated2/component/index.js +4 -0
  133. package/lib/{reanimated2 → src/reanimated2}/core.js +27 -3
  134. package/lib/{reanimated2 → src/reanimated2}/globals.d.ts +5 -0
  135. package/lib/{reanimated2 → src/reanimated2}/hook/Hooks.js +0 -0
  136. package/lib/{reanimated2 → src/reanimated2}/hook/commonTypes.js +0 -0
  137. package/lib/{reanimated2 → src/reanimated2}/hook/index.js +0 -0
  138. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedGestureHandler.js +1 -2
  139. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedReaction.js +0 -0
  140. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedRef.js +0 -0
  141. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedScrollHandler.js +0 -0
  142. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedStyle.js +31 -14
  143. package/lib/{reanimated2 → src/reanimated2}/hook/useDerivedValue.js +0 -0
  144. package/lib/{reanimated2 → src/reanimated2}/hook/useSharedValue.js +0 -0
  145. package/lib/{reanimated2 → src/reanimated2}/hook/utils.js +14 -11
  146. package/lib/{reanimated2 → src/reanimated2}/index.js +2 -0
  147. package/lib/src/reanimated2/interpolateColor.js +98 -0
  148. package/lib/{reanimated2 → src/reanimated2}/interpolation.js +0 -0
  149. package/lib/{reanimated2 → src/reanimated2}/jestUtils.js +0 -0
  150. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/JSReanimated.js +4 -1
  151. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/Mapper.js +4 -1
  152. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MapperRegistry.js +0 -0
  153. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MutableValue.js +0 -0
  154. package/lib/{reanimated2/layoutReanimation/animationBuilder → src/reanimated2/js-reanimated}/commonTypes.js +0 -0
  155. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/index.js +3 -0
  156. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/LayoutAnimationRepository.js +14 -5
  157. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +0 -0
  158. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +0 -0
  159. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/Keyframe.js +0 -0
  160. package/lib/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +1 -0
  161. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/index.js +0 -0
  162. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Bounce.js +0 -0
  163. package/lib/src/reanimated2/layoutReanimation/defaultAnimations/Default.js +36 -0
  164. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Fade.js +0 -0
  165. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Flip.js +8 -8
  166. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.js +0 -0
  167. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.js +0 -0
  168. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Roll.js +0 -0
  169. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Rotate.js +16 -16
  170. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Slide.js +16 -16
  171. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Stretch.js +0 -0
  172. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Zoom.js +4 -4
  173. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/index.js +0 -0
  174. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
  175. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
  176. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
  177. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
  178. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
  179. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
  180. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/index.js +0 -0
  181. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/index.js +0 -0
  182. package/lib/{reanimated2 → src/reanimated2}/mock.js +0 -0
  183. package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.js +0 -0
  184. package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.web.js +0 -0
  185. package/lib/{reanimated2 → src/reanimated2}/utils.js +0 -0
  186. package/lib/{setAndForwardRef.js → src/setAndForwardRef.js} +0 -0
  187. package/mock.js +2 -1
  188. package/package.json +7 -4
  189. package/plugin.js +11 -3
  190. package/react-native-reanimated.d.ts +94 -23
  191. package/src/Animated.js +11 -5
  192. package/src/createAnimatedComponent.tsx +86 -43
  193. package/src/reanimated1/core/Core.test.js +1 -1
  194. package/src/reanimated2/Colors.ts +6 -150
  195. package/src/reanimated2/Easing.ts +11 -0
  196. package/src/reanimated2/NativeMethods.ts +31 -6
  197. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -0
  198. package/src/reanimated2/NativeReanimated/index.ts +2 -2
  199. package/src/reanimated2/UpdateProps.ts +1 -1
  200. package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
  201. package/src/reanimated2/animation/commonTypes.ts +44 -40
  202. package/src/reanimated2/animation/decay.ts +1 -1
  203. package/src/reanimated2/animation/delay.ts +2 -16
  204. package/src/reanimated2/animation/index.ts +7 -8
  205. package/src/reanimated2/animation/repeat.ts +2 -12
  206. package/src/reanimated2/animation/sequence.ts +3 -10
  207. package/src/reanimated2/animation/spring.ts +1 -1
  208. package/src/reanimated2/animation/styleAnimation.ts +10 -18
  209. package/src/reanimated2/animation/timing.ts +1 -1
  210. package/src/reanimated2/animation/util.ts +12 -9
  211. package/src/reanimated2/commonTypes.ts +48 -1
  212. package/src/reanimated2/component/FlatList.tsx +44 -0
  213. package/src/reanimated2/component/WrappedComponents.ts +11 -0
  214. package/src/reanimated2/component/index.ts +9 -0
  215. package/src/reanimated2/core.ts +39 -6
  216. package/src/reanimated2/globals.d.ts +5 -0
  217. package/src/reanimated2/hook/commonTypes.ts +5 -0
  218. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -2
  219. package/src/reanimated2/hook/useAnimatedRef.ts +1 -5
  220. package/src/reanimated2/hook/useAnimatedStyle.ts +35 -16
  221. package/src/reanimated2/hook/utils.ts +18 -17
  222. package/src/reanimated2/index.ts +2 -0
  223. package/src/reanimated2/interpolateColor.ts +178 -0
  224. package/src/reanimated2/js-reanimated/JSReanimated.ts +9 -4
  225. package/src/reanimated2/js-reanimated/Mapper.ts +4 -2
  226. package/src/reanimated2/js-reanimated/MapperRegistry.ts +1 -1
  227. package/src/reanimated2/js-reanimated/commonTypes.ts +51 -0
  228. package/src/reanimated2/js-reanimated/index.ts +5 -0
  229. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +18 -5
  230. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
  231. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
  232. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
  233. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
  234. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
  235. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
  236. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
  237. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
  238. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +15 -11
  239. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
  240. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
  241. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
  242. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
  243. package/src/reanimated2/utils.ts +1 -1
  244. package/lib/Animated.js +0 -25
  245. package/lib/index.js +0 -25
  246. package/lib/reanimated2/NativeMethods.js +0 -25
  247. package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -36
@@ -0,0 +1,178 @@
1
+ import {
2
+ hsvToColor,
3
+ RGBtoHSV,
4
+ rgbaColor,
5
+ processColor,
6
+ red,
7
+ green,
8
+ blue,
9
+ opacity,
10
+ } from './Colors';
11
+ import { makeMutable } from './core';
12
+ import { interpolate } from './interpolation';
13
+ // @ts-ignore JS file
14
+ import { Extrapolate } from '../reanimated1/derived';
15
+ import { SharedValue } from './commonTypes';
16
+ import { useSharedValue } from './hook/useSharedValue';
17
+
18
+ const interpolateColorsHSV = (
19
+ value: number,
20
+ inputRange: readonly number[],
21
+ colors: InterpolateHSV
22
+ ) => {
23
+ 'worklet';
24
+ const h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
25
+ const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);
26
+ const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);
27
+ return hsvToColor(h, s, v);
28
+ };
29
+
30
+ const interpolateColorsRGB = (
31
+ value: number,
32
+ inputRange: readonly number[],
33
+ colors: InterpolateRGB
34
+ ) => {
35
+ 'worklet';
36
+ const r = interpolate(value, inputRange, colors.r, Extrapolate.CLAMP);
37
+ const g = interpolate(value, inputRange, colors.g, Extrapolate.CLAMP);
38
+ const b = interpolate(value, inputRange, colors.b, Extrapolate.CLAMP);
39
+ const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
40
+ return rgbaColor(r, g, b, a);
41
+ };
42
+
43
+ interface InterpolateRGB {
44
+ r: number[];
45
+ g: number[];
46
+ b: number[];
47
+ a: number[];
48
+ }
49
+
50
+ const getInterpolateRGB = (
51
+ colors: readonly (string | number)[]
52
+ ): InterpolateRGB => {
53
+ 'worklet';
54
+
55
+ const r = [];
56
+ const g = [];
57
+ const b = [];
58
+ const a = [];
59
+ for (let i = 0; i < colors.length; ++i) {
60
+ const color = colors[i];
61
+ const proocessedColor = processColor(color);
62
+ // explicit check in case if processedColor is 0
63
+ if (proocessedColor !== null && proocessedColor !== undefined) {
64
+ r.push(red(proocessedColor));
65
+ g.push(green(proocessedColor));
66
+ b.push(blue(proocessedColor));
67
+ a.push(opacity(proocessedColor));
68
+ }
69
+ }
70
+ return { r, g, b, a };
71
+ };
72
+
73
+ interface InterpolateHSV {
74
+ h: number[];
75
+ s: number[];
76
+ v: number[];
77
+ }
78
+
79
+ const getInterpolateHSV = (
80
+ colors: readonly (string | number)[]
81
+ ): InterpolateHSV => {
82
+ 'worklet';
83
+ const h = [];
84
+ const s = [];
85
+ const v = [];
86
+ for (let i = 0; i < colors.length; ++i) {
87
+ const color = colors[i];
88
+ const proocessedColor = RGBtoHSV(processColor(color) as any);
89
+ if (proocessedColor) {
90
+ h.push(proocessedColor.h);
91
+ s.push(proocessedColor.s);
92
+ v.push(proocessedColor.v);
93
+ }
94
+ }
95
+ return { h, s, v };
96
+ };
97
+
98
+ export const interpolateColor = (
99
+ value: number,
100
+ inputRange: readonly number[],
101
+ outputRange: readonly (string | number)[],
102
+ colorSpace: 'RGB' | 'HSV' = 'RGB'
103
+ ): string | number => {
104
+ 'worklet';
105
+ if (colorSpace === 'HSV') {
106
+ return interpolateColorsHSV(
107
+ value,
108
+ inputRange,
109
+ getInterpolateHSV(outputRange)
110
+ );
111
+ } else if (colorSpace === 'RGB') {
112
+ return interpolateColorsRGB(
113
+ value,
114
+ inputRange,
115
+ getInterpolateRGB(outputRange)
116
+ );
117
+ }
118
+ throw new Error(
119
+ `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`
120
+ );
121
+ };
122
+
123
+ export enum ColorSpace {
124
+ RGB = 0,
125
+ HSV = 1,
126
+ }
127
+
128
+ export interface InterpolateConfig {
129
+ inputRange: readonly number[];
130
+ outputRange: readonly (string | number)[];
131
+ colorSpace: ColorSpace;
132
+ cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
133
+ }
134
+
135
+ export function useInterpolateConfig(
136
+ inputRange: readonly number[],
137
+ outputRange: readonly (string | number)[],
138
+ colorSpace = ColorSpace.RGB
139
+ ): SharedValue<InterpolateConfig> {
140
+ return useSharedValue({
141
+ inputRange,
142
+ outputRange,
143
+ colorSpace,
144
+ cache: makeMutable(null),
145
+ });
146
+ }
147
+
148
+ export const interpolateSharableColor = (
149
+ value: number,
150
+ interpolateConfig: SharedValue<InterpolateConfig>
151
+ ): string | number => {
152
+ 'worklet';
153
+ let colors = interpolateConfig.value.cache.value;
154
+ if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {
155
+ if (!colors) {
156
+ colors = getInterpolateRGB(interpolateConfig.value.outputRange);
157
+ interpolateConfig.value.cache.value = colors;
158
+ }
159
+ return interpolateColorsRGB(
160
+ value,
161
+ interpolateConfig.value.inputRange,
162
+ colors as InterpolateRGB
163
+ );
164
+ } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {
165
+ if (!colors) {
166
+ colors = getInterpolateHSV(interpolateConfig.value.outputRange);
167
+ interpolateConfig.value.cache.value = colors;
168
+ }
169
+ return interpolateColorsHSV(
170
+ value,
171
+ interpolateConfig.value.inputRange,
172
+ colors as InterpolateHSV
173
+ );
174
+ }
175
+ throw new Error(
176
+ `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`
177
+ );
178
+ };
@@ -1,15 +1,14 @@
1
1
  import MapperRegistry from './MapperRegistry';
2
- import MutableValue from './MutableValue';
3
2
  import Mapper from './Mapper';
3
+ import MutableValue from './MutableValue';
4
4
  import { NativeReanimated } from '../NativeReanimated/NativeReanimated';
5
- import { Timestamp } from '../animation/commonTypes';
6
- import { NestedObjectValues } from '../commonTypes';
5
+ import { Timestamp, NestedObjectValues } from '../commonTypes';
7
6
 
8
7
  export default class JSReanimated extends NativeReanimated {
9
8
  _valueSetter?: <T>(value: T) => void = undefined;
10
9
 
11
10
  _renderRequested = false;
12
- _mapperRegistry = new MapperRegistry(this);
11
+ _mapperRegistry: MapperRegistry<any> = new MapperRegistry(this);
13
12
  _frames: ((timestamp: Timestamp) => void)[] = [];
14
13
  timeProvider: { now: () => number };
15
14
 
@@ -98,4 +97,10 @@ export default class JSReanimated extends NativeReanimated {
98
97
  unregisterEventHandler(_: string): void {
99
98
  // noop
100
99
  }
100
+
101
+ enableLayoutAnimations() {
102
+ console.warn(
103
+ '[Reanimated] enableLayoutAnimations is not available for WEB yet'
104
+ );
105
+ }
101
106
  }
@@ -1,5 +1,5 @@
1
1
  import { NestedObjectValues } from '../commonTypes';
2
- import JSReanimated from './JSReanimated';
2
+ import { JSReanimated } from './commonTypes';
3
3
  import MutableValue from './MutableValue';
4
4
 
5
5
  export default class Mapper<T> {
@@ -43,7 +43,9 @@ export default class Mapper<T> {
43
43
  const res: MutableValue<T>[] = [];
44
44
 
45
45
  function extractMutables(value: NestedObjectValues<MutableValue<T>>) {
46
- if (value instanceof MutableValue) {
46
+ if (value == null) {
47
+ // return;
48
+ } else if (value instanceof MutableValue) {
47
49
  res.push(value);
48
50
  } else if (Array.isArray(value)) {
49
51
  value.forEach((v) => extractMutables(v));
@@ -1,4 +1,4 @@
1
- import JSReanimated from './JSReanimated';
1
+ import { JSReanimated } from './commonTypes';
2
2
  import Mapper from './Mapper';
3
3
 
4
4
  export default class MapperRegistry<T> {
@@ -0,0 +1,51 @@
1
+ import { Timestamp, NestedObjectValues } from '../commonTypes';
2
+ import MutableValue from './MutableValue';
3
+
4
+ export interface Mapper<T> {
5
+ MAPPER_ID?: number;
6
+ id: number;
7
+ inputs: MutableValue<T>[];
8
+ outputs: MutableValue<T>[];
9
+ mapper: () => void;
10
+ dirty: boolean;
11
+ execute(): void;
12
+ extractMutablesFromArray<T>(
13
+ array: NestedObjectValues<MutableValue<T>>
14
+ ): MutableValue<T>[];
15
+ }
16
+
17
+ export interface MapperRegistry<T> {
18
+ sortedMappers: Mapper<T>[];
19
+ mappers: Map<number, Mapper<T>>;
20
+ _module: JSReanimated;
21
+ updatedSinceLastExecute: boolean;
22
+ startMapper(mapper: Mapper<T>): number;
23
+ stopMapper(id: number): void;
24
+ execute(): void;
25
+ updateOrder(): void;
26
+ }
27
+
28
+ export interface JSReanimated {
29
+ _valueSetter?: <T>(value: T) => void;
30
+ _renderRequested: boolean;
31
+ _mapperRegistry: MapperRegistry<any>;
32
+ _frames: ((timestamp: Timestamp) => void)[];
33
+ timeProvider: { now: () => number };
34
+ pushFrame(frame: (timestamp: Timestamp) => void): void;
35
+ getTimestamp(): number;
36
+ maybeRequestRender(): void;
37
+ _onRender(timestampMs: number): void;
38
+ installCoreFunctions(valueSetter: <T>(value: T) => void): void;
39
+ makeShareable<T>(value: T): T;
40
+ makeMutable<T>(value: T): MutableValue<T>;
41
+ makeRemote<T>(object: Record<string, any>): T;
42
+ startMapper(
43
+ mapper: () => void,
44
+ inputs: NestedObjectValues<MutableValue<unknown>>[],
45
+ outputs: NestedObjectValues<MutableValue<unknown>>[]
46
+ ): number;
47
+ stopMapper(mapperId: number): void;
48
+ registerEventHandler<T>(_: string, __: (event: T) => void): string;
49
+ unregisterEventHandler(_: string): void;
50
+ enableLayoutAnimations(): void;
51
+ }
@@ -36,6 +36,11 @@ if (shouldBeUseWeb()) {
36
36
  "[Reanimated] You can't use 'scrollTo' method with Chrome Debugger or with web version"
37
37
  );
38
38
  };
39
+ global._setGestureState = () => {
40
+ console.warn(
41
+ "[Reanimated] You can't use 'setGestureState' method with Chrome Debugger or with web version"
42
+ );
43
+ };
39
44
  }
40
45
 
41
46
  export const _updatePropsJS = (
@@ -1,6 +1,8 @@
1
1
  /* global _stopObservingProgress, _startObservingProgress */
2
2
  import { runOnUI } from '../core';
3
3
  import { withStyleAnimation } from '../animation/styleAnimation';
4
+ import { ColorProperties } from '../UpdateProps';
5
+ import { processColor } from '../Colors';
4
6
 
5
7
  runOnUI(() => {
6
8
  'worklet';
@@ -36,13 +38,22 @@ runOnUI(() => {
36
38
  for (const key in layoutAnimation) {
37
39
  currentAnimation[key] = layoutAnimation[key];
38
40
  }
39
- enteringAnimationForTag[tag] = null;
40
41
  }
41
42
 
42
43
  const sv: { value: boolean; _value: boolean } = configs[tag].sv;
43
44
  _stopObservingProgress(tag, false);
44
45
  _startObservingProgress(tag, sv);
45
- sv._value = Object.assign({}, sv._value, style.initialValues);
46
+
47
+ const backupColor: Record<string, string> = {};
48
+ for (const key in style.initialValues) {
49
+ if (ColorProperties.includes(key)) {
50
+ const value = style.initialValues[key];
51
+ backupColor[key] = value;
52
+ style.initialValues[key] = processColor(value);
53
+ }
54
+ }
55
+
56
+ sv.value = Object.assign({}, sv._value, style.initialValues);
46
57
  _stopObservingProgress(tag, false);
47
58
  const animation = withStyleAnimation(currentAnimation);
48
59
 
@@ -51,10 +62,12 @@ runOnUI(() => {
51
62
  _stopObservingProgress(tag, finished);
52
63
  }
53
64
  style.callback && style.callback(finished);
54
- if (type === 'entering') {
55
- enteringAnimationForTag[tag] = null;
56
- }
57
65
  };
66
+
67
+ if (backupColor) {
68
+ configs[tag].sv._value = { ...configs[tag].sv.value, ...backupColor };
69
+ }
70
+
58
71
  configs[tag].sv.value = animation;
59
72
  _startObservingProgress(tag, sv);
60
73
  },
@@ -14,32 +14,43 @@ export type LayoutAnimation = {
14
14
 
15
15
  export type AnimationFunction = (a?: any, b?: any, c?: any) => any; // this is just a temporary mock
16
16
 
17
- export interface EntryExitAnimationsValues {
18
- originX: number;
19
- originY: number;
20
- width: number;
21
- height: number;
22
- globalOriginX: number;
23
- globalOriginY: number;
17
+ export interface EntryAnimationsValues {
18
+ targetOriginX: number;
19
+ targetOriginY: number;
20
+ targetWidth: number;
21
+ targetHeight: number;
22
+ targetGlobalOriginX: number;
23
+ targetGlobalOriginY: number;
24
+ }
25
+
26
+ export interface ExitAnimationsValues {
27
+ currentOriginX: number;
28
+ currentOriginY: number;
29
+ currentWidth: number;
30
+ currentHeight: number;
31
+ currentGlobalOriginX: number;
32
+ currentGlobalOriginY: number;
24
33
  }
25
34
 
26
35
  export type EntryExitAnimationFunction = (
27
- targetValues: EntryExitAnimationsValues
36
+ targetValues: EntryAnimationsValues | ExitAnimationsValues
28
37
  ) => LayoutAnimation;
29
38
 
39
+ export type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;
40
+
30
41
  export interface LayoutAnimationsValues {
31
- originX: number;
32
- originY: number;
33
- width: number;
34
- height: number;
35
- globalOriginX: number;
36
- globalOriginY: number;
37
- boriginX: number;
38
- boriginY: number;
39
- bwidth: number;
40
- bheight: number;
41
- bglobalOriginX: number;
42
- bglobalOriginY: number;
42
+ currentOriginX: number;
43
+ currentOriginY: number;
44
+ currentWidth: number;
45
+ currentHeight: number;
46
+ currentGlobalOriginX: number;
47
+ currentGlobalOriginY: number;
48
+ targetOriginX: number;
49
+ targetOriginY: number;
50
+ targetWidth: number;
51
+ targetHeight: number;
52
+ targetGlobalOriginX: number;
53
+ targetGlobalOriginY: number;
43
54
  windowWidth: number;
44
55
  windowHeight: number;
45
56
  }
@@ -76,3 +87,11 @@ export type LayoutAnimationAndConfig = [
76
87
  export interface IEntryExitAnimationBuilder {
77
88
  build: () => EntryExitAnimationFunction;
78
89
  }
90
+
91
+ export interface IEntryAnimationBuilder {
92
+ build: () => AnimationConfigFunction<EntryAnimationsValues>;
93
+ }
94
+
95
+ export interface IExitAnimationBuilder {
96
+ build: () => AnimationConfigFunction<ExitAnimationsValues>;
97
+ }
@@ -4,8 +4,12 @@ export { Keyframe } from './Keyframe';
4
4
  export {
5
5
  LayoutAnimation,
6
6
  AnimationFunction,
7
- EntryExitAnimationsValues,
7
+ EntryAnimationsValues,
8
+ ExitAnimationsValues,
8
9
  EntryExitAnimationFunction,
10
+ AnimationConfigFunction,
11
+ IEntryAnimationBuilder,
12
+ IExitAnimationBuilder,
9
13
  LayoutAnimationsValues,
10
14
  LayoutAnimationFunction,
11
15
  ILayoutAnimationBuilder,
@@ -1,42 +1,48 @@
1
1
  import {
2
2
  LayoutAnimationFunction,
3
- EntryExitAnimationFunction,
3
+ EntryAnimationsValues,
4
+ ExitAnimationsValues,
5
+ AnimationConfigFunction,
4
6
  } from '../animationBuilder/commonTypes';
5
7
 
6
8
  export const DefaultLayout: LayoutAnimationFunction = (values) => {
7
9
  'worklet';
8
10
  return {
9
11
  initialValues: {
10
- originX: values.originX,
11
- originY: values.originY,
12
- width: values.width,
13
- height: values.height,
12
+ originX: values.targetOriginX,
13
+ originY: values.targetOriginY,
14
+ width: values.targetWidth,
15
+ height: values.targetHeight,
14
16
  },
15
17
  animations: {},
16
18
  };
17
19
  };
18
20
 
19
- export const DefaultEntering: EntryExitAnimationFunction = (targetValues) => {
21
+ export const DefaultEntering: AnimationConfigFunction<EntryAnimationsValues> = (
22
+ values
23
+ ) => {
20
24
  'worklet';
21
25
  return {
22
26
  initialValues: {
23
- originX: targetValues.originX,
24
- originY: targetValues.originY,
25
- width: targetValues.width,
26
- height: targetValues.height,
27
+ originX: values.targetOriginX,
28
+ originY: values.targetOriginY,
29
+ width: values.targetWidth,
30
+ height: values.targetHeight,
27
31
  },
28
32
  animations: {},
29
33
  };
30
34
  };
31
35
 
32
- export const DefaultExiting: EntryExitAnimationFunction = (startValues) => {
36
+ export const DefaultExiting: AnimationConfigFunction<ExitAnimationsValues> = (
37
+ values
38
+ ) => {
33
39
  'worklet';
34
40
  return {
35
41
  initialValues: {
36
- originX: startValues.originX,
37
- originY: startValues.originY,
38
- width: startValues.width,
39
- height: startValues.height,
42
+ originX: values.currentOriginX,
43
+ originY: values.currentOriginY,
44
+ width: values.currentWidth,
45
+ height: values.currentHeight,
40
46
  },
41
47
  animations: {},
42
48
  };