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
@@ -5,7 +5,7 @@ import renderer from 'react-test-renderer';
5
5
 
6
6
  jest.mock('../../ReanimatedEventEmitter');
7
7
  jest.mock('../../ReanimatedModule');
8
- jest.mock('../../reanimated2/NativeReanimated');
8
+ jest.mock('../../reanimated2/NativeReanimated/NativeReanimated');
9
9
 
10
10
  describe('Core Animated components', () => {
11
11
  xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
File without changes
File without changes
File without changes
File without changes
@@ -8,9 +8,6 @@
8
8
  /* eslint no-bitwise: 0 */
9
9
  import { Platform } from 'react-native';
10
10
  import { makeRemote, makeShareable, isConfigured } from './core';
11
- import { interpolate } from './interpolation';
12
- // @ts-ignore JS file
13
- import { Extrapolate } from '../reanimated1/derived';
14
11
  // var INTEGER = '[-+]?\\d+';
15
12
  const NUMBER = '[-+]?\\d*\\.?\\d+';
16
13
  const PERCENTAGE = NUMBER + '%';
@@ -381,7 +378,7 @@ export const rgbaColor = (r, g, b, alpha = 1) => {
381
378
  }
382
379
  return c;
383
380
  };
384
- function RGBtoHSV(r, g, b) {
381
+ export function RGBtoHSV(r, g, b) {
385
382
  'worklet';
386
383
  /* eslint-disable */
387
384
  if (arguments.length === 1) {
@@ -522,96 +519,3 @@ export function toRGBA(HSVA) {
522
519
  const { r, g, b } = HSVtoRGB(HSVA[0], HSVA[1], HSVA[2]);
523
520
  return `rgba(${r}, ${g}, ${b}, ${HSVA[3]})`;
524
521
  }
525
- const interpolateColorsHSV = (value, inputRange, colors) => {
526
- 'worklet';
527
- const h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
528
- const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);
529
- const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);
530
- return hsvToColor(h, s, v);
531
- };
532
- const interpolateColorsRGB = (value, inputRange, colors) => {
533
- 'worklet';
534
- const r = interpolate(value, inputRange, colors.r, Extrapolate.CLAMP);
535
- const g = interpolate(value, inputRange, colors.g, Extrapolate.CLAMP);
536
- const b = interpolate(value, inputRange, colors.b, Extrapolate.CLAMP);
537
- const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
538
- return rgbaColor(r, g, b, a);
539
- };
540
- const BUFFER_SIZE = 200;
541
- const hashOrderRGBA = new ArrayBuffer(BUFFER_SIZE);
542
- let curentHashIndexRGBA = 0;
543
- const interpolateCacheRGBA = {};
544
- const getInterpolateCacheRGBA = (colors) => {
545
- 'worklet';
546
- const hash = colors.join('');
547
- const cache = interpolateCacheRGBA[hash];
548
- if (cache !== undefined) {
549
- return cache;
550
- }
551
- const r = [];
552
- const g = [];
553
- const b = [];
554
- const a = [];
555
- for (let i = 0; i < colors.length; ++i) {
556
- const color = colors[i];
557
- const proocessedColor = processColor(color);
558
- // explicit check in case if processedColor is 0
559
- if (proocessedColor !== null && proocessedColor !== undefined) {
560
- r.push(red(proocessedColor));
561
- g.push(green(proocessedColor));
562
- b.push(blue(proocessedColor));
563
- a.push(opacity(proocessedColor));
564
- }
565
- }
566
- const newCache = { r, g, b, a };
567
- const overrideHash = hashOrderRGBA[curentHashIndexRGBA];
568
- if (overrideHash) {
569
- delete interpolateCacheRGBA[overrideHash];
570
- }
571
- interpolateCacheRGBA[hash] = newCache;
572
- hashOrderRGBA[curentHashIndexRGBA] = hash;
573
- curentHashIndexRGBA = (curentHashIndexRGBA + 1) % BUFFER_SIZE;
574
- return newCache;
575
- };
576
- const hashOrderHSV = new ArrayBuffer(BUFFER_SIZE);
577
- let curentHashIndexHSV = 0;
578
- const interpolateCacheHSV = {};
579
- const getInterpolateCacheHSV = (colors) => {
580
- 'worklet';
581
- const hash = colors.join('');
582
- const cache = interpolateCacheHSV[hash];
583
- if (cache !== undefined) {
584
- return cache;
585
- }
586
- const h = [];
587
- const s = [];
588
- const v = [];
589
- for (let i = 0; i < colors.length; ++i) {
590
- const color = colors[i];
591
- const proocessedColor = RGBtoHSV(processColor(color));
592
- if (proocessedColor) {
593
- h.push(proocessedColor.h);
594
- s.push(proocessedColor.s);
595
- v.push(proocessedColor.v);
596
- }
597
- }
598
- const newCache = { h, s, v };
599
- const overrideHash = hashOrderHSV[curentHashIndexHSV];
600
- if (overrideHash) {
601
- delete interpolateCacheHSV[overrideHash];
602
- }
603
- interpolateCacheHSV[hash] = newCache;
604
- hashOrderHSV[curentHashIndexHSV] = hash;
605
- curentHashIndexHSV = (curentHashIndexHSV + 1) % BUFFER_SIZE;
606
- return newCache;
607
- };
608
- export const interpolateColor = (value, inputRange, outputRange, colorSpace = 'RGB') => {
609
- 'worklet';
610
- if (colorSpace === 'HSV') {
611
- return interpolateColorsHSV(value, inputRange, getInterpolateCacheHSV(outputRange));
612
- }
613
- else if (colorSpace === 'RGB') {
614
- return interpolateColorsRGB(value, inputRange, getInterpolateCacheRGBA(outputRange));
615
- }
616
- throw new Error(`invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`);
617
- };
@@ -149,6 +149,10 @@ function bezier(x1, y1, x2, y2) {
149
149
  },
150
150
  };
151
151
  }
152
+ function bezierFn(x1, y1, x2, y2) {
153
+ 'worklet';
154
+ return Bezier(x1, y1, x2, y2);
155
+ }
152
156
  /**
153
157
  * Runs an easing function forwards.
154
158
  */
@@ -194,6 +198,7 @@ const EasingObject = {
194
198
  back,
195
199
  bounce,
196
200
  bezier,
201
+ bezierFn,
197
202
  in: in_,
198
203
  out,
199
204
  inOut,
@@ -0,0 +1,42 @@
1
+ import { findNodeHandle } from 'react-native';
2
+ import { shouldBeUseWeb } from './PlatformChecker';
3
+ export function getTag(view) {
4
+ return findNodeHandle(view);
5
+ }
6
+ const isNativeIndefined = shouldBeUseWeb();
7
+ export function measure(animatedRef) {
8
+ 'worklet';
9
+ if (!_WORKLET || isNativeIndefined) {
10
+ console.warn('[reanimated.measure] method cannot be used for web or Chrome Debugger');
11
+ return {
12
+ x: NaN,
13
+ y: NaN,
14
+ width: NaN,
15
+ height: NaN,
16
+ pageX: NaN,
17
+ pageY: NaN,
18
+ };
19
+ }
20
+ const viewTag = animatedRef();
21
+ const result = _measure(viewTag);
22
+ if (result.x === -1234567) {
23
+ throw new Error(`The view with tag ${viewTag} could not be measured`);
24
+ }
25
+ return result;
26
+ }
27
+ export function scrollTo(animatedRef, x, y, animated) {
28
+ 'worklet';
29
+ if (!_WORKLET || isNativeIndefined) {
30
+ return;
31
+ }
32
+ const viewTag = animatedRef();
33
+ _scrollTo(viewTag, x, y, animated);
34
+ }
35
+ export function setGestureState(handlerTag, newState) {
36
+ 'worklet';
37
+ if (!_WORKLET || isNativeIndefined) {
38
+ console.warn('[Reanimated] You can not use setGestureState in non-worklet function.');
39
+ return;
40
+ }
41
+ _setGestureState(handlerTag, newState);
42
+ }
@@ -31,4 +31,7 @@ export class NativeReanimated {
31
31
  getViewProp(viewTag, propName, callback) {
32
32
  return InnerNativeModule.getViewProp(viewTag, propName, callback);
33
33
  }
34
+ enableLayoutAnimations(flag) {
35
+ InnerNativeModule.enableLayoutAnimations(flag);
36
+ }
34
37
  }
@@ -1,9 +1,9 @@
1
1
  import reanimatedJS from '../js-reanimated';
2
- import { nativeShouldBeMock } from '../PlatformChecker';
2
+ import { shouldBeUseWeb } from '../PlatformChecker';
3
3
  import { Platform } from 'react-native';
4
4
  import { NativeReanimated } from './NativeReanimated';
5
5
  let exportedModule;
6
- if (nativeShouldBeMock()) {
6
+ if (shouldBeUseWeb()) {
7
7
  exportedModule = reanimatedJS;
8
8
  }
9
9
  else {
@@ -19,7 +19,7 @@ export const colorProps = [
19
19
  'textShadowColor',
20
20
  'overlayColor',
21
21
  ];
22
- const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
22
+ export const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
23
23
  let updatePropsByPlatform;
24
24
  if (shouldBeUseWeb()) {
25
25
  updatePropsByPlatform = (_, updates, maybeViewRef) => {
@@ -1,5 +1,7 @@
1
1
  import { useRef } from 'react';
2
2
  import { makeMutable } from './core';
3
+ import { Platform } from 'react-native';
4
+ const scheduleUpdates = Platform.OS === 'web' ? requestAnimationFrame : setImmediate;
3
5
  export function makeViewDescriptorsSet() {
4
6
  const ref = useRef(null);
5
7
  if (ref.current === null) {
@@ -18,7 +20,7 @@ export function makeViewDescriptorsSet() {
18
20
  data.items.push(item);
19
21
  if (!data.waitForInsertSync) {
20
22
  data.waitForInsertSync = true;
21
- setImmediate(() => {
23
+ scheduleUpdates(() => {
22
24
  data.sharableViewDescriptors.value = data.items;
23
25
  data.waitForInsertSync = false;
24
26
  });
@@ -28,7 +30,7 @@ export function makeViewDescriptorsSet() {
28
30
  data.batchToRemove.add(viewTag);
29
31
  if (!data.waitForRemoveSync) {
30
32
  data.waitForRemoveSync = true;
31
- setImmediate(() => {
33
+ scheduleUpdates(() => {
32
34
  const items = [];
33
35
  for (const item of data.items) {
34
36
  if (data.batchToRemove.has(item.tag)) {
@@ -1,5 +1,7 @@
1
1
  import { defineAnimation } from './util';
2
2
  import { withTiming } from './timing';
3
+ import { ColorProperties } from '../UpdateProps';
4
+ import { processColor } from '../Colors';
3
5
  // resolves path to value for nested objects
4
6
  // if path cannot be resolved returns undefined
5
7
  export function resolvePath(obj, path) {
@@ -79,6 +81,9 @@ export function withStyleAnimation(styleAnimations) {
79
81
  else {
80
82
  stillGoing = true;
81
83
  }
84
+ if (ColorProperties.includes(currentEntry.path[0])) {
85
+ currentStyleAnimation.current = processColor(currentStyleAnimation.current);
86
+ }
82
87
  setPath(animation.current, currentEntry.path, currentStyleAnimation.current);
83
88
  }
84
89
  }
@@ -0,0 +1,30 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React from 'react';
13
+ import { FlatList } from 'react-native';
14
+ import WrappedComponents from './WrappedComponents';
15
+ import createAnimatedComponent from '../../createAnimatedComponent';
16
+ const AnimatedFlatList = createAnimatedComponent(FlatList);
17
+ const createCellRenderer = (itemLayoutAnimation) => {
18
+ const cellRenderer = (props) => {
19
+ return (<WrappedComponents.View layout={itemLayoutAnimation} onLayout={props.onLayout}>
20
+ {props.children}
21
+ </WrappedComponents.View>);
22
+ };
23
+ return cellRenderer;
24
+ };
25
+ const ReanimatedFlatlist = (_a) => {
26
+ var { itemLayoutAnimation } = _a, restProps = __rest(_a, ["itemLayoutAnimation"]);
27
+ const cellRenderer = React.useMemo(() => createCellRenderer(itemLayoutAnimation), []);
28
+ return (<AnimatedFlatList {...restProps} CellRendererComponent={cellRenderer}/>);
29
+ };
30
+ export default ReanimatedFlatlist;
@@ -0,0 +1,9 @@
1
+ import { Image, ScrollView, Text, View } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+ const WrappedComponents = {
4
+ View: createAnimatedComponent(View),
5
+ Text: createAnimatedComponent(Text),
6
+ Image: createAnimatedComponent(Image),
7
+ ScrollView: createAnimatedComponent(ScrollView),
8
+ };
9
+ export default WrappedComponents;
@@ -0,0 +1,4 @@
1
+ import ReanimatedFlatlist from './FlatList';
2
+ import WrappedComponents from './WrappedComponents';
3
+ const ReanimatedComponents = Object.assign(Object.assign({}, WrappedComponents), { FlatList: ReanimatedFlatlist });
4
+ export default ReanimatedComponents;
@@ -1,7 +1,7 @@
1
1
  /* global _WORKLET _getCurrentTime _frameTimestamp _eventTimestamp, _setGlobalConsole */
2
2
  import NativeReanimatedModule from './NativeReanimated';
3
3
  import { Platform } from 'react-native';
4
- import { nativeShouldBeMock, shouldBeUseWeb } from './PlatformChecker';
4
+ import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
5
5
  global.__reanimatedWorkletInit = function (worklet) {
6
6
  worklet.__worklet = true;
7
7
  };
@@ -263,8 +263,8 @@ if (!NativeReanimatedModule.useOnlyV1) {
263
263
  NativeReanimatedModule.installCoreFunctions(NativeReanimatedModule.native
264
264
  ? workletValueSetter
265
265
  : workletValueSetterJS);
266
- const capturableConsole = console;
267
- isConfigured() &&
266
+ if (!isWeb() && isConfigured()) {
267
+ const capturableConsole = console;
268
268
  runOnUI(() => {
269
269
  'worklet';
270
270
  const console = {
@@ -275,5 +275,29 @@ if (!NativeReanimatedModule.useOnlyV1) {
275
275
  info: runOnJS(capturableConsole.info),
276
276
  };
277
277
  _setGlobalConsole(console);
278
+ if (global.performance == null) {
279
+ global.performance = {
280
+ now: global._chronoNow,
281
+ };
282
+ }
278
283
  })();
284
+ }
285
+ }
286
+ let featuresConfig = {
287
+ enableLayoutAnimations: false,
288
+ setByUser: false,
289
+ };
290
+ export function enableLayoutAnimations(flag, isCallByUser = true) {
291
+ if (isCallByUser) {
292
+ featuresConfig = {
293
+ enableLayoutAnimations: flag,
294
+ setByUser: true,
295
+ };
296
+ NativeReanimatedModule.enableLayoutAnimations(flag);
297
+ }
298
+ else if (!featuresConfig.setByUser &&
299
+ featuresConfig.enableLayoutAnimations !== flag) {
300
+ featuresConfig.enableLayoutAnimations = flag;
301
+ NativeReanimatedModule.enableLayoutAnimations(flag);
302
+ }
279
303
  }
@@ -13,6 +13,7 @@ declare global {
13
13
  tag: number,
14
14
  flag: { value: boolean; _value: boolean }
15
15
  ) => void;
16
+ const _setGestureState: (handlerTag: number, newState: number) => void;
16
17
  const _updateProps: (
17
18
  tag: number,
18
19
  name: string,
@@ -25,16 +26,20 @@ declare global {
25
26
  y: number,
26
27
  animated: boolean
27
28
  ) => void;
29
+ const _chronoNow: () => number;
28
30
  namespace NodeJS {
29
31
  interface Global {
30
32
  __reanimatedWorkletInit: (worklet: WorkletFunction) => void;
31
33
  _setGlobalConsole: (console?: ReanimatedConsole) => void;
32
34
  _log: (s: string) => void;
35
+ _setGestureState: () => void;
33
36
  _WORKLET: boolean;
34
37
  __reanimatedModuleProxy: NativeReanimated;
35
38
  _frameTimestamp: number | null;
36
39
  _measure: () => MeasuredDimensions;
37
40
  _scrollTo: () => void;
41
+ _chronoNow: () => number;
42
+ performance: { now: () => number };
38
43
  LayoutAnimationRepository: {
39
44
  configs: Record<string, unknown>;
40
45
  registerConfig(tag: number, config: Record<string, unknown>): void;
@@ -1,4 +1,3 @@
1
- import { isWeb } from '../PlatformChecker';
2
1
  import { useEvent, useHandler } from './Hooks';
3
2
  export var EventType;
4
3
  (function (EventType) {
@@ -43,7 +42,7 @@ export function useAnimatedGestureHandler(handlers, dependencies) {
43
42
  handlers.onFinish(event, context, event.state === EventType.CANCELLED || event.state === EventType.FAILED);
44
43
  }
45
44
  };
46
- if (isWeb()) {
45
+ if (useWeb) {
47
46
  return handler;
48
47
  }
49
48
  return useEvent(handler, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], doDependenciesDiffer);
@@ -164,7 +164,11 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
164
164
  else {
165
165
  state.isAnimationCancelled = true;
166
166
  state.animations = [];
167
- updateProps(viewDescriptors, newValues, maybeViewRef);
167
+ const diff = styleDiff(oldValues, newValues);
168
+ state.last = Object.assign({}, oldValues, newValues);
169
+ if (diff) {
170
+ updateProps(viewDescriptors, newValues, maybeViewRef);
171
+ }
168
172
  }
169
173
  }
170
174
  function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsActive, animatedStyle, adapters = []) {
@@ -305,10 +309,10 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
305
309
  const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;
306
310
  useEffect(() => {
307
311
  let fun;
308
- let upadterFn = updater;
312
+ let updaterFn = updater;
309
313
  let optimalization = updater.__optimalization;
310
314
  if (adapters) {
311
- upadterFn = () => {
315
+ updaterFn = () => {
312
316
  'worklet';
313
317
  const newValues = updater();
314
318
  adaptersArray.forEach((adapter) => {
@@ -317,27 +321,40 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
317
321
  return newValues;
318
322
  };
319
323
  }
320
- if (canApplyOptimalisation(upadterFn) && !shouldBeUseWeb()) {
321
- if (hasColorProps(upadterFn())) {
322
- upadterFn = () => {
324
+ if (canApplyOptimalisation(updaterFn) && !shouldBeUseWeb()) {
325
+ if (hasColorProps(updaterFn())) {
326
+ updaterFn = () => {
327
+ 'worklet';
328
+ const newValues = updaterFn();
329
+ const oldValues = remoteState.last;
330
+ const diff = styleDiff(oldValues, newValues);
331
+ remoteState.last = Object.assign({}, oldValues, newValues);
332
+ parseColors(diff);
333
+ return diff;
334
+ };
335
+ }
336
+ else {
337
+ updaterFn = () => {
323
338
  'worklet';
324
- const style = upadterFn();
325
- parseColors(style);
326
- return style;
339
+ const newValues = updaterFn();
340
+ const oldValues = remoteState.last;
341
+ const diff = styleDiff(oldValues, newValues);
342
+ remoteState.last = Object.assign({}, oldValues, newValues);
343
+ return diff;
327
344
  };
328
345
  }
329
346
  }
330
347
  else if (!shouldBeUseWeb()) {
331
348
  optimalization = 0;
332
- upadterFn = () => {
349
+ updaterFn = () => {
333
350
  'worklet';
334
- const style = upadterFn();
351
+ const style = updaterFn();
335
352
  parseColors(style);
336
353
  return style;
337
354
  };
338
355
  }
339
356
  if (typeof updater.__optimalization !== undefined) {
340
- upadterFn.__optimalization = optimalization;
357
+ updaterFn.__optimalization = optimalization;
341
358
  }
342
359
  if (isJest()) {
343
360
  fun = () => {
@@ -348,10 +365,10 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
348
365
  else {
349
366
  fun = () => {
350
367
  'worklet';
351
- styleUpdater(sharableViewDescriptors, upadterFn, remoteState, maybeViewRef, animationsActive);
368
+ styleUpdater(sharableViewDescriptors, updaterFn, remoteState, maybeViewRef, animationsActive);
352
369
  };
353
370
  }
354
- const mapperId = startMapper(fun, inputs, [], upadterFn,
371
+ const mapperId = startMapper(fun, inputs, [], updaterFn,
355
372
  // TODO fix this
356
373
  sharableViewDescriptors);
357
374
  return () => {