react-native-reanimated 2.13.0 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
  2. package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
  3. package/RNReanimated.podspec +2 -1
  4. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  5. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  6. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  7. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  8. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  9. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  10. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  11. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  12. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  13. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  14. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  15. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  16. package/android/.gradle/file-system.probe +0 -0
  17. package/android/CMakeLists.txt +191 -188
  18. package/android/build.gradle +386 -316
  19. package/android/react-native-reanimated-67-hermes.aar +0 -0
  20. package/android/react-native-reanimated-67-jsc.aar +0 -0
  21. package/android/react-native-reanimated-68-hermes.aar +0 -0
  22. package/android/react-native-reanimated-68-jsc.aar +0 -0
  23. package/android/react-native-reanimated-69-hermes.aar +0 -0
  24. package/android/react-native-reanimated-69-jsc.aar +0 -0
  25. package/android/react-native-reanimated-70-hermes.aar +0 -0
  26. package/android/react-native-reanimated-70-jsc.aar +0 -0
  27. package/android/react-native-reanimated-71-hermes.aar +0 -0
  28. package/android/react-native-reanimated-71-jsc.aar +0 -0
  29. package/android/src/main/cpp/NativeProxy.cpp +8 -0
  30. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  31. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +1 -1
  32. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  33. package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
  34. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  35. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  36. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +3 -30
  37. package/ios/REAModule.mm +2 -0
  38. package/ios/native/REAInitializer.mm +4 -0
  39. package/lib/createAnimatedComponent.js +6 -1
  40. package/lib/reanimated2/Colors.js +27 -11
  41. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +4 -0
  42. package/lib/reanimated2/animation/util.js +15 -15
  43. package/lib/reanimated2/globals.d.ts +2 -0
  44. package/lib/reanimated2/interpolateColor.js +79 -20
  45. package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -18
  46. package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -10
  47. package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +15 -10
  48. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -10
  49. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +24 -18
  50. package/lib/reanimated2/platform-specific/checkVersion.js +24 -0
  51. package/lib/reanimated2/platform-specific/checkVersion.web.js +6 -0
  52. package/lib/types/{Animated.d.ts → lib/Animated.d.ts} +0 -0
  53. package/lib/types/{ConfigHelper.d.ts → lib/ConfigHelper.d.ts} +0 -0
  54. package/lib/types/{ReanimatedEventEmitter.d.ts → lib/ReanimatedEventEmitter.d.ts} +0 -0
  55. package/lib/types/{ReanimatedModule.d.ts → lib/ReanimatedModule.d.ts} +0 -0
  56. package/lib/types/{ReanimatedModule.macos.d.ts → lib/ReanimatedModule.macos.d.ts} +0 -0
  57. package/lib/types/{ReanimatedModule.native.d.ts → lib/ReanimatedModule.native.d.ts} +0 -0
  58. package/lib/types/{ReanimatedModule.windows.d.ts → lib/ReanimatedModule.windows.d.ts} +0 -0
  59. package/lib/types/{ReanimatedModuleCompat.d.ts → lib/ReanimatedModuleCompat.d.ts} +0 -0
  60. package/lib/types/{createAnimatedComponent.d.ts → lib/createAnimatedComponent.d.ts} +0 -0
  61. package/lib/types/{index.d.ts → lib/index.d.ts} +0 -0
  62. package/lib/types/{index.web.d.ts → lib/index.web.d.ts} +0 -0
  63. package/lib/types/{reanimated2 → lib/reanimated2}/Bezier.d.ts +0 -0
  64. package/lib/types/{reanimated2 → lib/reanimated2}/Colors.d.ts +5 -3
  65. package/lib/types/{reanimated2 → lib/reanimated2}/Easing.d.ts +0 -0
  66. package/lib/types/{reanimated2 → lib/reanimated2}/NativeMethods.d.ts +0 -0
  67. package/lib/types/{reanimated2 → lib/reanimated2}/NativeReanimated/NativeReanimated.d.ts +0 -0
  68. package/lib/types/{reanimated2 → lib/reanimated2}/NativeReanimated/index.d.ts +0 -0
  69. package/lib/types/{reanimated2 → lib/reanimated2}/PlatformChecker.d.ts +0 -0
  70. package/lib/types/{reanimated2 → lib/reanimated2}/PropAdapters.d.ts +0 -0
  71. package/lib/types/{reanimated2 → lib/reanimated2}/UpdateProps.d.ts +0 -0
  72. package/lib/types/{reanimated2 → lib/reanimated2}/ViewDescriptorsSet.d.ts +0 -0
  73. package/lib/types/{reanimated2 → lib/reanimated2}/WorkletEventHandler.d.ts +0 -0
  74. package/lib/types/{reanimated2 → lib/reanimated2}/__mocks__/MutableValue.d.ts +0 -0
  75. package/lib/types/{reanimated2 → lib/reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
  76. package/lib/types/{reanimated2 → lib/reanimated2}/animation/commonTypes.d.ts +0 -0
  77. package/lib/types/{reanimated2 → lib/reanimated2}/animation/decay.d.ts +0 -0
  78. package/lib/types/{reanimated2 → lib/reanimated2}/animation/delay.d.ts +0 -0
  79. package/lib/types/{reanimated2 → lib/reanimated2}/animation/index.d.ts +0 -0
  80. package/lib/types/{reanimated2 → lib/reanimated2}/animation/repeat.d.ts +0 -0
  81. package/lib/types/{reanimated2 → lib/reanimated2}/animation/sequence.d.ts +0 -0
  82. package/lib/types/{reanimated2 → lib/reanimated2}/animation/spring.d.ts +0 -0
  83. package/lib/types/{reanimated2 → lib/reanimated2}/animation/styleAnimation.d.ts +0 -0
  84. package/lib/types/{reanimated2 → lib/reanimated2}/animation/timing.d.ts +0 -0
  85. package/lib/types/{reanimated2 → lib/reanimated2}/animation/util.d.ts +0 -0
  86. package/lib/types/{reanimated2 → lib/reanimated2}/commonTypes.d.ts +0 -0
  87. package/lib/types/{reanimated2 → lib/reanimated2}/component/FlatList.d.ts +0 -0
  88. package/lib/types/{reanimated2 → lib/reanimated2}/component/Image.d.ts +0 -0
  89. package/lib/types/{reanimated2 → lib/reanimated2}/component/ScrollView.d.ts +0 -0
  90. package/lib/types/{reanimated2 → lib/reanimated2}/component/Text.d.ts +0 -0
  91. package/lib/types/{reanimated2 → lib/reanimated2}/component/View.d.ts +0 -0
  92. package/lib/types/{reanimated2 → lib/reanimated2}/core.d.ts +0 -0
  93. package/lib/types/{reanimated2 → lib/reanimated2}/frameCallback/FrameCallbackRegistryJS.d.ts +0 -0
  94. package/lib/types/{reanimated2 → lib/reanimated2}/frameCallback/FrameCallbackRegistryUI.d.ts +0 -0
  95. package/lib/types/{reanimated2 → lib/reanimated2}/hook/Hooks.d.ts +0 -0
  96. package/lib/types/{reanimated2 → lib/reanimated2}/hook/commonTypes.d.ts +0 -0
  97. package/lib/types/{reanimated2 → lib/reanimated2}/hook/index.d.ts +0 -0
  98. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
  99. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedKeyboard.d.ts +0 -0
  100. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
  101. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedRef.d.ts +0 -0
  102. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedScrollHandler.d.ts +0 -0
  103. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedSensor.d.ts +0 -0
  104. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
  105. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useDerivedValue.d.ts +0 -0
  106. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useFrameCallback.d.ts +0 -0
  107. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useScrollViewOffset.d.ts +0 -0
  108. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useSharedValue.d.ts +0 -0
  109. package/lib/types/{reanimated2 → lib/reanimated2}/hook/utils.d.ts +0 -0
  110. package/lib/types/{reanimated2 → lib/reanimated2}/index.d.ts +0 -0
  111. package/lib/types/{reanimated2 → lib/reanimated2}/interpolateColor.d.ts +8 -2
  112. package/lib/types/{reanimated2 → lib/reanimated2}/interpolation.d.ts +0 -0
  113. package/lib/types/{reanimated2 → lib/reanimated2}/jestUtils.d.ts +0 -0
  114. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/JSReanimated.d.ts +0 -0
  115. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/Mapper.d.ts +0 -0
  116. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
  117. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
  118. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
  119. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/global.d.ts +0 -0
  120. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/index.d.ts +0 -0
  121. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
  122. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
  123. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
  124. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
  125. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +4 -0
  126. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
  127. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
  128. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
  129. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
  130. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
  131. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
  132. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
  133. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
  134. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
  135. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
  136. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
  137. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
  138. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
  139. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
  140. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
  141. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
  142. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
  143. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
  144. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
  145. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
  146. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/index.d.ts +0 -0
  147. package/lib/types/{reanimated2 → lib/reanimated2}/mock.d.ts +0 -0
  148. package/lib/types/{reanimated2 → lib/reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
  149. package/lib/types/{reanimated2 → lib/reanimated2}/platform-specific/RNRenderer.web.d.ts +0 -0
  150. package/lib/types/lib/reanimated2/platform-specific/checkVersion.d.ts +4 -0
  151. package/lib/types/lib/reanimated2/platform-specific/checkVersion.web.d.ts +5 -0
  152. package/lib/types/{reanimated2 → lib/reanimated2}/utils.d.ts +0 -0
  153. package/lib/types/{setAndForwardRef.d.ts → lib/setAndForwardRef.d.ts} +0 -0
  154. package/package.json +6 -6
  155. package/plugin.js +7 -3
  156. package/react-native-reanimated.d.ts +11 -2
  157. package/scripts/reanimated_utils.rb +7 -3
  158. package/src/createAnimatedComponent.tsx +8 -1
  159. package/src/reanimated2/Colors.ts +38 -11
  160. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +4 -0
  161. package/src/reanimated2/animation/util.ts +26 -15
  162. package/src/reanimated2/globals.d.ts +2 -0
  163. package/src/reanimated2/interpolateColor.ts +105 -21
  164. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +4 -0
  165. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  166. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  167. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  168. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  169. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  170. package/src/reanimated2/platform-specific/checkVersion.ts +28 -0
  171. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  172. package/android/react-native-reanimated-66-hermes.aar +0 -0
  173. package/android/react-native-reanimated-66-jsc.aar +0 -0
@@ -1,6 +1,6 @@
1
1
  def try_to_parse_react_native_package_json(node_modules_dir)
2
2
  react_native_package_json_path = File.join(node_modules_dir, 'react-native/package.json')
3
- if !File.exists?(react_native_package_json_path)
3
+ if !File.exist?(react_native_package_json_path)
4
4
  return nil
5
5
  end
6
6
  return JSON.parse(File.read(react_native_package_json_path))
@@ -17,7 +17,7 @@ def find_config()
17
17
  :react_native_common_dir => nil,
18
18
  }
19
19
 
20
- react_native_node_modules_dir = File.join(File.dirname(`cd #{Pod::Config.instance.installation_root.to_s} && node --print "require.resolve('react-native/package.json')"`), '..')
20
+ react_native_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
21
21
  react_native_json = try_to_parse_react_native_package_json(react_native_node_modules_dir)
22
22
 
23
23
  if react_native_json == nil
@@ -34,6 +34,9 @@ def find_config()
34
34
  result[:is_tvos_target] = react_native_json['name'] == 'react-native-tvos'
35
35
  result[:react_native_version] = react_native_json['version']
36
36
  result[:react_native_minor_version] = react_native_json['version'].split('.')[1].to_i
37
+ if result[:react_native_minor_version] == 0 # nightly
38
+ result[:react_native_minor_version] = 1000
39
+ end
37
40
  result[:react_native_node_modules_dir] = File.expand_path(react_native_node_modules_dir)
38
41
  result[:reanimated_node_modules_dir] = File.expand_path(File.join(__dir__, '..', '..'))
39
42
 
@@ -52,6 +55,7 @@ def assert_no_multiple_instances(react_native_info)
52
55
 
53
56
  lib_instances_in_react_native_node_modules = %x[find #{react_native_info[:react_native_node_modules_dir]} -name "package.json" | grep "/react-native-reanimated/package.json"]
54
57
  lib_instances_in_react_native_node_modules_array = lib_instances_in_react_native_node_modules.split("\n")
58
+ lib_instances_in_reanimated_node_modules_array = Array.new
55
59
  reanimated_instances = lib_instances_in_react_native_node_modules_array.length()
56
60
  if react_native_info[:react_native_node_modules_dir] != react_native_info[:reanimated_node_modules_dir]
57
61
  lib_instances_in_reanimated_node_modules = %x[find #{react_native_info[:reanimated_node_modules_dir]} -name "package.json" | grep "/react-native-reanimated/package.json"]
@@ -64,7 +68,7 @@ def assert_no_multiple_instances(react_native_info)
64
68
  location['/package.json'] = ''
65
69
  parsed_location += "- " + location + "\n"
66
70
  end
67
- raise "[react-native-reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsed_location
71
+ raise "[react-native-reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/next/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsed_location
68
72
  end
69
73
  end
70
74
 
@@ -241,7 +241,14 @@ export default function createAnimatedComponent(
241
241
 
242
242
  _attachNativeEvents() {
243
243
  const node = this._getEventViewRef();
244
- const viewTag = findNodeHandle(options?.setNativeProps ? this : node);
244
+ let viewTag = findNodeHandle(options?.setNativeProps ? this : node);
245
+ const componentName = Component.displayName || Component.name;
246
+
247
+ if (componentName?.endsWith('FlashList') && this._component) {
248
+ // @ts-ignore it's FlashList specific: https://github.com/Shopify/flash-list/blob/218f314e63806b4fe926741ef73f8b9cd6ebc7eb/src/FlashList.tsx#L824
249
+ viewTag = findNodeHandle(this._component.recyclerlistview_unsafe);
250
+ }
251
+
245
252
  for (const key in this.props) {
246
253
  const prop = this.props[key];
247
254
  if (prop instanceof AnimatedEvent) {
@@ -573,11 +573,12 @@ function HSVtoRGB(h: any, s?: any, v?: any) {
573
573
  export const hsvToColor = (
574
574
  h: number,
575
575
  s: number,
576
- v: number
576
+ v: number,
577
+ a: number
577
578
  ): number | string => {
578
579
  'worklet';
579
580
  const { r, g, b } = HSVtoRGB(h, s, v);
580
- return rgbaColor(r, g, b);
581
+ return rgbaColor(r, g, b, a);
581
582
  };
582
583
 
583
584
  export function processColorInitially(
@@ -634,19 +635,45 @@ export function processColor(color: unknown): number | null | undefined {
634
635
 
635
636
  export type ParsedColorArray = [number, number, number, number];
636
637
 
637
- export function convertToHSVA(color: unknown): ParsedColorArray {
638
+ export function convertToRGBA(color: unknown): ParsedColorArray {
638
639
  'worklet';
639
640
  const processedColor = processColorInitially(color)!; // argb;
640
641
  const a = (processedColor >>> 24) / 255;
641
- const r = (processedColor << 8) >>> 24;
642
- const g = (processedColor << 16) >>> 24;
643
- const b = (processedColor << 24) >>> 24;
644
- const { h, s, v } = RGBtoHSV(r, g, b);
645
- return [h, s, v, a];
642
+ const r = ((processedColor << 8) >>> 24) / 255;
643
+ const g = ((processedColor << 16) >>> 24) / 255;
644
+ const b = ((processedColor << 24) >>> 24) / 255;
645
+ return [r, g, b, a];
646
646
  }
647
647
 
648
- export function toRGBA(HSVA: ParsedColorArray): string {
648
+ export function rgbaArrayToRGBAColor(RGBA: ParsedColorArray): string {
649
649
  'worklet';
650
- const { r, g, b } = HSVtoRGB(HSVA[0], HSVA[1], HSVA[2]);
651
- return `rgba(${r}, ${g}, ${b}, ${HSVA[3]})`;
650
+ return `rgba(${Math.round(RGBA[0] * 255)}, ${Math.round(
651
+ RGBA[1] * 255
652
+ )}, ${Math.round(RGBA[2] * 255)}, ${RGBA[3]})`;
653
+ }
654
+
655
+ export function toLinearSpace(
656
+ RGBA: ParsedColorArray,
657
+ gamma = 2.2
658
+ ): ParsedColorArray {
659
+ 'worklet';
660
+ const res = [];
661
+ for (let i = 0; i < 3; ++i) {
662
+ res.push(Math.pow(RGBA[i], gamma));
663
+ }
664
+ res.push(RGBA[3]);
665
+ return res as ParsedColorArray;
666
+ }
667
+
668
+ export function toGammaSpace(
669
+ RGBA: ParsedColorArray,
670
+ gamma = 2.2
671
+ ): ParsedColorArray {
672
+ 'worklet';
673
+ const res = [];
674
+ for (let i = 0; i < 3; ++i) {
675
+ res.push(Math.pow(RGBA[i], 1 / gamma));
676
+ }
677
+ res.push(RGBA[3]);
678
+ return res as ParsedColorArray;
652
679
  }
@@ -6,6 +6,7 @@ import {
6
6
  AnimatedKeyboardInfo,
7
7
  } from '../commonTypes';
8
8
  import { Descriptor } from '../hook/commonTypes';
9
+ import { checkVersion } from '../platform-specific/checkVersion';
9
10
 
10
11
  export class NativeReanimated {
11
12
  native: boolean;
@@ -18,6 +19,9 @@ export class NativeReanimated {
18
19
  }
19
20
  this.InnerNativeModule = global.__reanimatedModuleProxy;
20
21
  this.native = native;
22
+ if (native) {
23
+ checkVersion();
24
+ }
21
25
  }
22
26
 
23
27
  installCoreFunctions(valueSetter: <T>(value: T) => void): void {
@@ -7,7 +7,14 @@ import {
7
7
  StyleLayoutAnimation,
8
8
  } from './commonTypes';
9
9
  /* global _WORKLET */
10
- import { ParsedColorArray, convertToHSVA, isColor, toRGBA } from '../Colors';
10
+ import {
11
+ ParsedColorArray,
12
+ isColor,
13
+ convertToRGBA,
14
+ rgbaArrayToRGBAColor,
15
+ toGammaSpace,
16
+ toLinearSpace,
17
+ } from '../Colors';
11
18
 
12
19
  import {
13
20
  AnimatedStyle,
@@ -125,55 +132,59 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
125
132
  return res;
126
133
  };
127
134
 
128
- const tab = ['H', 'S', 'V', 'A'];
135
+ const tab = ['R', 'G', 'B', 'A'];
129
136
  const colorOnStart = (
130
137
  animation: Animation<AnimationObject>,
131
138
  value: string | number,
132
139
  timestamp: Timestamp,
133
140
  previousAnimation: Animation<AnimationObject>
134
141
  ): void => {
135
- let HSVAValue: ParsedColorArray;
136
- let HSVACurrent: ParsedColorArray;
137
- let HSVAToValue: ParsedColorArray;
142
+ let RGBAValue: ParsedColorArray;
143
+ let RGBACurrent: ParsedColorArray;
144
+ let RGBAToValue: ParsedColorArray;
138
145
  const res: Array<number> = [];
139
146
  if (isColor(value)) {
140
- HSVACurrent = convertToHSVA(animation.current);
141
- HSVAValue = convertToHSVA(value);
147
+ RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
148
+ RGBAValue = toLinearSpace(convertToRGBA(value));
142
149
  if (animation.toValue) {
143
- HSVAToValue = convertToHSVA(animation.toValue);
150
+ RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));
144
151
  }
145
152
  }
146
153
  tab.forEach((i, index) => {
147
154
  animation[i] = Object.assign({}, animationCopy);
148
- animation[i].current = HSVACurrent[index];
149
- animation[i].toValue = HSVAToValue ? HSVAToValue[index] : undefined;
155
+ animation[i].current = RGBACurrent[index];
156
+ animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;
150
157
  animation[i].onStart(
151
158
  animation[i],
152
- HSVAValue[index],
159
+ RGBAValue[index],
153
160
  timestamp,
154
161
  previousAnimation ? previousAnimation[i] : undefined
155
162
  );
156
163
  res.push(animation[i].current);
157
164
  });
158
165
 
159
- animation.current = toRGBA(res as ParsedColorArray);
166
+ animation.current = rgbaArrayToRGBAColor(
167
+ toGammaSpace(res as ParsedColorArray)
168
+ );
160
169
  };
161
170
 
162
171
  const colorOnFrame = (
163
172
  animation: Animation<AnimationObject>,
164
173
  timestamp: Timestamp
165
174
  ): boolean => {
166
- const HSVACurrent = convertToHSVA(animation.current);
175
+ const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
167
176
  const res: Array<number> = [];
168
177
  let finished = true;
169
178
  tab.forEach((i, index) => {
170
- animation[i].current = HSVACurrent[index];
179
+ animation[i].current = RGBACurrent[index];
171
180
  // @ts-ignore: disable-next-line
172
181
  finished &= animation[i].onFrame(animation[i], timestamp);
173
182
  res.push(animation[i].current);
174
183
  });
175
184
 
176
- animation.current = toRGBA(res as ParsedColorArray);
185
+ animation.current = rgbaArrayToRGBAColor(
186
+ toGammaSpace(res as ParsedColorArray)
187
+ );
177
188
  return finished;
178
189
  };
179
190
 
@@ -9,6 +9,7 @@ import type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegis
9
9
 
10
10
  declare global {
11
11
  const _WORKLET: boolean;
12
+ const _REANIMATED_VERSION_CPP: string;
12
13
  const _frameTimestamp: number | null;
13
14
  const _eventTimestamp: number;
14
15
  const __reanimatedModuleProxy: NativeReanimated;
@@ -49,6 +50,7 @@ declare global {
49
50
  interface Global {
50
51
  _WORKLET: boolean;
51
52
  _IS_FABRIC: boolean;
53
+ _REANIMATED_VERSION_CPP: string;
52
54
  _frameTimestamp: number | null;
53
55
  _eventTimestamp: number;
54
56
  __reanimatedModuleProxy: NativeReanimated;
@@ -15,29 +15,96 @@ import { Extrapolate } from '../reanimated1/derived';
15
15
  import { SharedValue } from './commonTypes';
16
16
  import { useSharedValue } from './hook/useSharedValue';
17
17
 
18
+ export type InterpolationOptions = {
19
+ gamma?: number;
20
+ useCorrectedHSVInterpolation?: boolean;
21
+ };
22
+
18
23
  const interpolateColorsHSV = (
19
24
  value: number,
20
25
  inputRange: readonly number[],
21
- colors: InterpolateHSV
26
+ colors: InterpolateHSV,
27
+ options: InterpolationOptions
22
28
  ) => {
23
29
  'worklet';
24
- const h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
30
+ let h = 0;
31
+ const { useCorrectedHSVInterpolation = true } = options;
32
+ if (useCorrectedHSVInterpolation) {
33
+ // if the difference between hues in a range is > 180 deg
34
+ // then move the hue at the right end of the range +/- 360 deg
35
+ // and add the next point in the original place + 0.00001 with original hue
36
+ // to not break the next range
37
+ const correctedInputRange = [inputRange[0]];
38
+ const originalH = colors.h;
39
+ const correctedH = [originalH[0]];
40
+
41
+ for (let i = 1; i < originalH.length; ++i) {
42
+ const d = originalH[i] - originalH[i - 1];
43
+ if (originalH[i] > originalH[i - 1] && d > 0.5) {
44
+ correctedInputRange.push(inputRange[i]);
45
+ correctedInputRange.push(inputRange[i] + 0.00001);
46
+ correctedH.push(originalH[i] - 1);
47
+ correctedH.push(originalH[i]);
48
+ } else if (originalH[i] < originalH[i - 1] && d < -0.5) {
49
+ correctedInputRange.push(inputRange[i]);
50
+ correctedInputRange.push(inputRange[i] + 0.00001);
51
+ correctedH.push(originalH[i] + 1);
52
+ correctedH.push(originalH[i]);
53
+ } else {
54
+ correctedInputRange.push(inputRange[i]);
55
+ correctedH.push(originalH[i]);
56
+ }
57
+ }
58
+ h =
59
+ (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +
60
+ 1) %
61
+ 1;
62
+ } else {
63
+ h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
64
+ }
25
65
  const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);
26
66
  const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);
27
- return hsvToColor(h, s, v);
67
+ const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
68
+ return hsvToColor(h, s, v, a);
69
+ };
70
+
71
+ const toLinearSpace = (x: number[], gamma: number): number[] => {
72
+ 'worklet';
73
+ return x.map((v) => Math.pow(v / 255, gamma));
74
+ };
75
+
76
+ const toGammaSpace = (x: number, gamma: number): number => {
77
+ 'worklet';
78
+ return Math.round(Math.pow(x, 1 / gamma) * 255);
28
79
  };
29
80
 
30
81
  const interpolateColorsRGB = (
31
82
  value: number,
32
83
  inputRange: readonly number[],
33
- colors: InterpolateRGB
84
+ colors: InterpolateRGB,
85
+ options: InterpolationOptions
34
86
  ) => {
35
87
  '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);
88
+ const { gamma = 2.2 } = options;
89
+ let { r: outputR, g: outputG, b: outputB } = colors;
90
+ if (gamma !== 1) {
91
+ outputR = toLinearSpace(outputR, gamma);
92
+ outputG = toLinearSpace(outputG, gamma);
93
+ outputB = toLinearSpace(outputB, gamma);
94
+ }
95
+ const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);
96
+ const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);
97
+ const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);
39
98
  const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
40
- return rgbaColor(r, g, b, a);
99
+ if (gamma === 1) {
100
+ return rgbaColor(r, g, b, a);
101
+ }
102
+ return rgbaColor(
103
+ toGammaSpace(r, gamma),
104
+ toGammaSpace(g, gamma),
105
+ toGammaSpace(b, gamma),
106
+ a
107
+ );
41
108
  };
42
109
 
43
110
  interface InterpolateRGB {
@@ -74,6 +141,7 @@ interface InterpolateHSV {
74
141
  h: number[];
75
142
  s: number[];
76
143
  v: number[];
144
+ a: number[];
77
145
  }
78
146
 
79
147
  const getInterpolateHSV = (
@@ -83,36 +151,47 @@ const getInterpolateHSV = (
83
151
  const h = [];
84
152
  const s = [];
85
153
  const v = [];
154
+ const a = [];
86
155
  for (let i = 0; i < colors.length; ++i) {
87
156
  const color = colors[i];
88
- const processedColor = RGBtoHSV(processColor(color) as any);
89
- if (processedColor) {
90
- h.push(processedColor.h);
91
- s.push(processedColor.s);
92
- v.push(processedColor.v);
157
+ const processedColor = processColor(color) as any;
158
+ if (typeof processedColor === 'number') {
159
+ const processedHSVColor = RGBtoHSV(
160
+ red(processedColor),
161
+ green(processedColor),
162
+ blue(processedColor)
163
+ );
164
+
165
+ h.push(processedHSVColor.h);
166
+ s.push(processedHSVColor.s);
167
+ v.push(processedHSVColor.v);
168
+ a.push(opacity(processedColor));
93
169
  }
94
170
  }
95
- return { h, s, v };
171
+ return { h, s, v, a };
96
172
  };
97
173
 
98
174
  export const interpolateColor = (
99
175
  value: number,
100
176
  inputRange: readonly number[],
101
177
  outputRange: readonly (string | number)[],
102
- colorSpace: 'RGB' | 'HSV' = 'RGB'
178
+ colorSpace: 'RGB' | 'HSV' = 'RGB',
179
+ options: InterpolationOptions = {}
103
180
  ): string | number => {
104
181
  'worklet';
105
182
  if (colorSpace === 'HSV') {
106
183
  return interpolateColorsHSV(
107
184
  value,
108
185
  inputRange,
109
- getInterpolateHSV(outputRange)
186
+ getInterpolateHSV(outputRange),
187
+ options
110
188
  );
111
189
  } else if (colorSpace === 'RGB') {
112
190
  return interpolateColorsRGB(
113
191
  value,
114
192
  inputRange,
115
- getInterpolateRGB(outputRange)
193
+ getInterpolateRGB(outputRange),
194
+ options
116
195
  );
117
196
  }
118
197
  throw new Error(
@@ -130,18 +209,21 @@ export interface InterpolateConfig {
130
209
  outputRange: readonly (string | number)[];
131
210
  colorSpace: ColorSpace;
132
211
  cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
212
+ options: InterpolationOptions;
133
213
  }
134
214
 
135
215
  export function useInterpolateConfig(
136
216
  inputRange: readonly number[],
137
217
  outputRange: readonly (string | number)[],
138
- colorSpace = ColorSpace.RGB
218
+ colorSpace = ColorSpace.RGB,
219
+ options: InterpolationOptions = {}
139
220
  ): SharedValue<InterpolateConfig> {
140
221
  return useSharedValue({
141
222
  inputRange,
142
223
  outputRange,
143
224
  colorSpace,
144
- cache: makeMutable(null),
225
+ cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),
226
+ options,
145
227
  });
146
228
  }
147
229
 
@@ -159,7 +241,8 @@ export const interpolateSharableColor = (
159
241
  return interpolateColorsRGB(
160
242
  value,
161
243
  interpolateConfig.value.inputRange,
162
- colors as InterpolateRGB
244
+ colors as InterpolateRGB,
245
+ interpolateConfig.value.options
163
246
  );
164
247
  } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {
165
248
  if (!colors) {
@@ -169,7 +252,8 @@ export const interpolateSharableColor = (
169
252
  return interpolateColorsHSV(
170
253
  value,
171
254
  interpolateConfig.value.inputRange,
172
- colors as InterpolateHSV
255
+ colors as InterpolateHSV,
256
+ interpolateConfig.value.options
173
257
  );
174
258
  }
175
259
  throw new Error(
@@ -21,6 +21,8 @@ export interface EntryAnimationsValues {
21
21
  targetHeight: number;
22
22
  targetGlobalOriginX: number;
23
23
  targetGlobalOriginY: number;
24
+ windowWidth: number;
25
+ windowHeight: number;
24
26
  }
25
27
 
26
28
  export interface ExitAnimationsValues {
@@ -30,6 +32,8 @@ export interface ExitAnimationsValues {
30
32
  currentHeight: number;
31
33
  currentGlobalOriginX: number;
32
34
  currentGlobalOriginY: number;
35
+ windowWidth: number;
36
+ windowHeight: number;
33
37
  }
34
38
 
35
39
  export type EntryExitAnimationFunction = (
@@ -3,11 +3,8 @@ import {
3
3
  IEntryExitAnimationBuilder,
4
4
  } from '../animationBuilder/commonTypes';
5
5
  import { withSequence, withTiming } from '../../animation';
6
- import { Dimensions } from 'react-native';
7
6
  import { ComplexAnimationBuilder } from '../animationBuilder/ComplexAnimationBuilder';
8
7
 
9
- const { width, height } = Dimensions.get('window');
10
-
11
8
  export class BounceIn
12
9
  extends ComplexAnimationBuilder
13
10
  implements IEntryExitAnimationBuilder
@@ -82,7 +79,7 @@ export class BounceInDown
82
79
  const callback = this.callbackV;
83
80
  const initialValues = this.initialValues;
84
81
 
85
- return () => {
82
+ return (values) => {
86
83
  'worklet';
87
84
  return {
88
85
  animations: {
@@ -103,7 +100,7 @@ export class BounceInDown
103
100
  initialValues: {
104
101
  transform: [
105
102
  {
106
- translateY: height,
103
+ translateY: values.windowHeight,
107
104
  },
108
105
  ],
109
106
  ...initialValues,
@@ -137,7 +134,7 @@ export class BounceInUp
137
134
  const callback = this.callbackV;
138
135
  const initialValues = this.initialValues;
139
136
 
140
- return () => {
137
+ return (values) => {
141
138
  'worklet';
142
139
  return {
143
140
  animations: {
@@ -156,7 +153,7 @@ export class BounceInUp
156
153
  ],
157
154
  },
158
155
  initialValues: {
159
- transform: [{ translateY: -height }],
156
+ transform: [{ translateY: -values.windowHeight }],
160
157
  ...initialValues,
161
158
  },
162
159
  callback: callback,
@@ -188,7 +185,7 @@ export class BounceInLeft
188
185
  const callback = this.callbackV;
189
186
  const initialValues = this.initialValues;
190
187
 
191
- return () => {
188
+ return (values) => {
192
189
  'worklet';
193
190
  return {
194
191
  animations: {
@@ -207,7 +204,7 @@ export class BounceInLeft
207
204
  ],
208
205
  },
209
206
  initialValues: {
210
- transform: [{ translateX: -width }],
207
+ transform: [{ translateX: -values.windowWidth }],
211
208
  ...initialValues,
212
209
  },
213
210
  callback: callback,
@@ -239,7 +236,7 @@ export class BounceInRight
239
236
  const callback = this.callbackV;
240
237
  const initialValues = this.initialValues;
241
238
 
242
- return () => {
239
+ return (values) => {
243
240
  'worklet';
244
241
  return {
245
242
  animations: {
@@ -258,7 +255,7 @@ export class BounceInRight
258
255
  ],
259
256
  },
260
257
  initialValues: {
261
- transform: [{ translateX: width }],
258
+ transform: [{ translateX: values.windowWidth }],
262
259
  ...initialValues,
263
260
  },
264
261
  callback: callback,
@@ -341,7 +338,7 @@ export class BounceOutDown
341
338
  const callback = this.callbackV;
342
339
  const initialValues = this.initialValues;
343
340
 
344
- return () => {
341
+ return (values) => {
345
342
  'worklet';
346
343
  return {
347
344
  animations: {
@@ -353,7 +350,7 @@ export class BounceOutDown
353
350
  withTiming(-10, { duration: duration * 0.15 }),
354
351
  withTiming(10, { duration: duration * 0.15 }),
355
352
  withTiming(-20, { duration: duration * 0.15 }),
356
- withTiming(height, {
353
+ withTiming(values.windowHeight, {
357
354
  duration: duration * 0.55,
358
355
  })
359
356
  )
@@ -394,7 +391,7 @@ export class BounceOutUp
394
391
  const callback = this.callbackV;
395
392
  const initialValues = this.initialValues;
396
393
 
397
- return () => {
394
+ return (values) => {
398
395
  'worklet';
399
396
  return {
400
397
  animations: {
@@ -406,7 +403,7 @@ export class BounceOutUp
406
403
  withTiming(10, { duration: duration * 0.15 }),
407
404
  withTiming(-10, { duration: duration * 0.15 }),
408
405
  withTiming(20, { duration: duration * 0.15 }),
409
- withTiming(-height, {
406
+ withTiming(-values.windowHeight, {
410
407
  duration: duration * 0.55,
411
408
  })
412
409
  )
@@ -447,7 +444,7 @@ export class BounceOutLeft
447
444
  const callback = this.callbackV;
448
445
  const initialValues = this.initialValues;
449
446
 
450
- return () => {
447
+ return (values) => {
451
448
  'worklet';
452
449
  return {
453
450
  animations: {
@@ -459,7 +456,7 @@ export class BounceOutLeft
459
456
  withTiming(10, { duration: duration * 0.15 }),
460
457
  withTiming(-10, { duration: duration * 0.15 }),
461
458
  withTiming(20, { duration: duration * 0.15 }),
462
- withTiming(-width, {
459
+ withTiming(-values.windowWidth, {
463
460
  duration: duration * 0.55,
464
461
  })
465
462
  )
@@ -500,7 +497,7 @@ export class BounceOutRight
500
497
  const callback = this.callbackV;
501
498
  const initialValues = this.initialValues;
502
499
 
503
- return () => {
500
+ return (values) => {
504
501
  'worklet';
505
502
  return {
506
503
  animations: {
@@ -512,7 +509,7 @@ export class BounceOutRight
512
509
  withTiming(-10, { duration: duration * 0.15 }),
513
510
  withTiming(10, { duration: duration * 0.15 }),
514
511
  withTiming(-20, { duration: duration * 0.15 }),
515
- withTiming(width, {
512
+ withTiming(values.windowWidth, {
516
513
  duration: duration * 0.55,
517
514
  })
518
515
  )