react-native-reanimated 2.3.1 → 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 (195) hide show
  1. package/android/build.gradle +3 -3
  2. package/android/react-native-reanimated-63-hermes.aar +0 -0
  3. package/android/react-native-reanimated-63-jsc.aar +0 -0
  4. package/android/react-native-reanimated-64-hermes.aar +0 -0
  5. package/android/react-native-reanimated-64-jsc.aar +0 -0
  6. package/android/react-native-reanimated-65-hermes.aar +0 -0
  7. package/android/react-native-reanimated-65-jsc.aar +0 -0
  8. package/android/react-native-reanimated-66-hermes.aar +0 -0
  9. package/android/react-native-reanimated-66-jsc.aar +0 -0
  10. package/android/react-native-reanimated-67-hermes.aar +0 -0
  11. package/android/react-native-reanimated-67-jsc.aar +0 -0
  12. package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
  13. package/ios/LayoutReanimation/REAAnimationsManager.m +4 -0
  14. package/ios/native/NativeMethods.h +1 -1
  15. package/ios/native/NativeProxy.mm +10 -2
  16. package/lib/{Animated.js → src/Animated.js} +0 -0
  17. package/lib/{ConfigHelper.js → src/ConfigHelper.js} +0 -0
  18. package/lib/{ReanimatedEventEmitter.js → src/ReanimatedEventEmitter.js} +0 -0
  19. package/lib/{ReanimatedModule.js → src/ReanimatedModule.js} +0 -0
  20. package/lib/{ReanimatedModule.macos.js → src/ReanimatedModule.macos.js} +0 -0
  21. package/lib/{ReanimatedModule.native.js → src/ReanimatedModule.native.js} +0 -0
  22. package/lib/{ReanimatedModule.windows.js → src/ReanimatedModule.windows.js} +0 -0
  23. package/lib/{ReanimatedModuleCompat.js → src/ReanimatedModuleCompat.js} +0 -0
  24. package/lib/{__mocks__ → src/__mocks__}/ReanimatedEventEmitter.js +0 -0
  25. package/lib/{__mocks__ → src/__mocks__}/ReanimatedModule.native.js +0 -0
  26. package/lib/{createAnimatedComponent.js → src/createAnimatedComponent.js} +0 -0
  27. package/lib/{index.js → src/index.js} +0 -0
  28. package/lib/{reanimated1 → src/reanimated1}/Easing.js +0 -0
  29. package/lib/{reanimated1 → src/reanimated1}/SpringConfig.js +0 -0
  30. package/lib/{reanimated1 → src/reanimated1}/Transitioning.js +0 -0
  31. package/lib/{reanimated1 → src/reanimated1}/animations/Animation.js +0 -0
  32. package/lib/{reanimated1 → src/reanimated1}/animations/SpringUtils.js +0 -0
  33. package/lib/{reanimated1 → src/reanimated1}/animations/backwardCompatibleAnimWrapper.js +0 -0
  34. package/lib/{reanimated1 → src/reanimated1}/animations/decay.js +0 -0
  35. package/lib/{reanimated1 → src/reanimated1}/animations/spring.js +0 -0
  36. package/lib/{reanimated1 → src/reanimated1}/animations/timing.js +0 -0
  37. package/lib/{reanimated1 → src/reanimated1}/base.js +0 -0
  38. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedAlways.js +0 -0
  39. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBezier.js +0 -0
  40. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBlock.js +0 -0
  41. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCall.js +0 -0
  42. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCallFunc.js +0 -0
  43. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClock.js +0 -0
  44. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClockTest.js +0 -0
  45. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCode.js +0 -0
  46. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedConcat.js +0 -0
  47. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCond.js +0 -0
  48. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedDebug.js +0 -0
  49. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedEvent.js +0 -0
  50. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedFunction.js +0 -0
  51. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedNode.js +0 -0
  52. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedOperator.js +0 -0
  53. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedParam.js +0 -0
  54. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedProps.js +0 -0
  55. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedSet.js +0 -0
  56. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStartClock.js +0 -0
  57. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStopClock.js +0 -0
  58. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStyle.js +0 -0
  59. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedTransform.js +0 -0
  60. package/lib/{reanimated1 → src/reanimated1}/core/AnimatedValue.js +0 -0
  61. package/lib/{reanimated1 → src/reanimated1}/core/Core.test.js +0 -0
  62. package/lib/{reanimated1 → src/reanimated1}/core/InternalAnimatedValue.js +0 -0
  63. package/lib/{reanimated1 → src/reanimated1}/core/__mocks__/AnimatedProps.js +0 -0
  64. package/lib/{reanimated1 → src/reanimated1}/core/createEventObjectProxyPolyfill.js +0 -0
  65. package/lib/{reanimated1 → src/reanimated1}/derived/__mocks__/evaluateOnce.js +0 -0
  66. package/lib/{reanimated1 → src/reanimated1}/derived/acc.js +0 -0
  67. package/lib/{reanimated1 → src/reanimated1}/derived/color.js +0 -0
  68. package/lib/{reanimated1 → src/reanimated1}/derived/diff.js +0 -0
  69. package/lib/{reanimated1 → src/reanimated1}/derived/diffClamp.js +0 -0
  70. package/lib/{reanimated1 → src/reanimated1}/derived/evaluateOnce.js +0 -0
  71. package/lib/{reanimated1 → src/reanimated1}/derived/index.js +0 -0
  72. package/lib/{reanimated1 → src/reanimated1}/derived/interpolate.js +0 -0
  73. package/lib/{reanimated1 → src/reanimated1}/derived/interpolateColors.js +0 -0
  74. package/lib/{reanimated1 → src/reanimated1}/derived/onChange.js +0 -0
  75. package/lib/{reanimated1 → src/reanimated1}/derived/useCode.js +0 -0
  76. package/lib/{reanimated1 → src/reanimated1}/index.js +0 -0
  77. package/lib/{reanimated1 → src/reanimated1}/operators.js +0 -0
  78. package/lib/{reanimated1 → src/reanimated1}/useValue.js +0 -0
  79. package/lib/{reanimated1 → src/reanimated1}/val.js +0 -0
  80. package/lib/{reanimated2 → src/reanimated2}/Bezier.js +0 -0
  81. package/lib/{reanimated2 → src/reanimated2}/Colors.js +1 -97
  82. package/lib/{reanimated2 → src/reanimated2}/Easing.js +5 -0
  83. package/lib/{reanimated2 → src/reanimated2}/NativeMethods.js +15 -5
  84. package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/NativeReanimated.js +0 -0
  85. package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/index.js +2 -2
  86. package/lib/{reanimated2 → src/reanimated2}/PlatformChecker.js +0 -0
  87. package/lib/{reanimated2 → src/reanimated2}/PropAdapters.js +0 -0
  88. package/lib/{reanimated2 → src/reanimated2}/UpdateProps.js +0 -0
  89. package/lib/{reanimated2 → src/reanimated2}/ViewDescriptorsSet.js +0 -0
  90. package/lib/{reanimated2 → src/reanimated2}/WorkletEventHandler.js +0 -0
  91. package/lib/{reanimated2 → src/reanimated2}/__mocks__/MutableValue.js +0 -0
  92. package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.js +0 -0
  93. package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.native.js +0 -0
  94. package/lib/{reanimated2 → src/reanimated2}/animation/commonTypes.js +0 -0
  95. package/lib/{reanimated2 → src/reanimated2}/animation/decay.js +0 -0
  96. package/lib/{reanimated2 → src/reanimated2}/animation/delay.js +0 -0
  97. package/lib/{reanimated2 → src/reanimated2}/animation/index.js +0 -0
  98. package/lib/{reanimated2 → src/reanimated2}/animation/repeat.js +0 -0
  99. package/lib/{reanimated2 → src/reanimated2}/animation/sequence.js +0 -0
  100. package/lib/{reanimated2 → src/reanimated2}/animation/spring.js +0 -0
  101. package/lib/{reanimated2 → src/reanimated2}/animation/styleAnimation.js +0 -0
  102. package/lib/{reanimated2 → src/reanimated2}/animation/timing.js +0 -0
  103. package/lib/{reanimated2 → src/reanimated2}/animation/util.js +0 -0
  104. package/lib/{reanimated2 → src/reanimated2}/commonTypes.js +0 -0
  105. package/lib/{reanimated2 → src/reanimated2}/component/FlatList.js +0 -0
  106. package/lib/{reanimated2 → src/reanimated2}/component/WrappedComponents.js +0 -0
  107. package/lib/{reanimated2 → src/reanimated2}/component/index.js +0 -0
  108. package/lib/{reanimated2 → src/reanimated2}/core.js +5 -3
  109. package/lib/{reanimated2 → src/reanimated2}/globals.d.ts +0 -0
  110. package/lib/{reanimated2 → src/reanimated2}/hook/Hooks.js +0 -0
  111. package/lib/{reanimated2 → src/reanimated2}/hook/commonTypes.js +0 -0
  112. package/lib/{reanimated2 → src/reanimated2}/hook/index.js +0 -0
  113. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedGestureHandler.js +1 -2
  114. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedReaction.js +0 -0
  115. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedRef.js +0 -0
  116. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedScrollHandler.js +0 -0
  117. package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedStyle.js +31 -14
  118. package/lib/{reanimated2 → src/reanimated2}/hook/useDerivedValue.js +0 -0
  119. package/lib/{reanimated2 → src/reanimated2}/hook/useSharedValue.js +0 -0
  120. package/lib/{reanimated2 → src/reanimated2}/hook/utils.js +14 -11
  121. package/lib/{reanimated2 → src/reanimated2}/index.js +2 -0
  122. package/lib/src/reanimated2/interpolateColor.js +98 -0
  123. package/lib/{reanimated2 → src/reanimated2}/interpolation.js +0 -0
  124. package/lib/{reanimated2 → src/reanimated2}/jestUtils.js +0 -0
  125. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/JSReanimated.js +1 -1
  126. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/Mapper.js +0 -0
  127. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MapperRegistry.js +0 -0
  128. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MutableValue.js +0 -0
  129. package/lib/{reanimated2/layoutReanimation/animationBuilder → src/reanimated2/js-reanimated}/commonTypes.js +0 -0
  130. package/lib/{reanimated2 → src/reanimated2}/js-reanimated/index.js +0 -0
  131. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/LayoutAnimationRepository.js +0 -0
  132. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +0 -0
  133. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +0 -0
  134. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/Keyframe.js +0 -0
  135. package/lib/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +1 -0
  136. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/index.js +0 -0
  137. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Bounce.js +0 -0
  138. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Default.js +0 -0
  139. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Fade.js +0 -0
  140. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Flip.js +0 -0
  141. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.js +0 -0
  142. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.js +0 -0
  143. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Roll.js +0 -0
  144. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Rotate.js +0 -0
  145. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Slide.js +0 -0
  146. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Stretch.js +0 -0
  147. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Zoom.js +0 -0
  148. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/index.js +0 -0
  149. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.js +0 -0
  150. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.js +0 -0
  151. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.js +0 -0
  152. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.js +0 -0
  153. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.js +0 -0
  154. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.js +0 -0
  155. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/index.js +0 -0
  156. package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/index.js +0 -0
  157. package/lib/{reanimated2 → src/reanimated2}/mock.js +0 -0
  158. package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.js +0 -0
  159. package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.web.js +0 -0
  160. package/lib/{reanimated2 → src/reanimated2}/utils.js +0 -0
  161. package/lib/{setAndForwardRef.js → src/setAndForwardRef.js} +0 -0
  162. package/mock.js +1 -0
  163. package/package.json +5 -3
  164. package/plugin.js +1 -0
  165. package/react-native-reanimated.d.ts +55 -1
  166. package/src/reanimated2/Colors.ts +6 -150
  167. package/src/reanimated2/Easing.ts +11 -0
  168. package/src/reanimated2/NativeMethods.ts +19 -6
  169. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +1 -0
  170. package/src/reanimated2/NativeReanimated/index.ts +2 -2
  171. package/src/reanimated2/animation/commonTypes.ts +44 -40
  172. package/src/reanimated2/animation/decay.ts +1 -1
  173. package/src/reanimated2/animation/delay.ts +2 -16
  174. package/src/reanimated2/animation/index.ts +7 -8
  175. package/src/reanimated2/animation/repeat.ts +2 -12
  176. package/src/reanimated2/animation/sequence.ts +3 -10
  177. package/src/reanimated2/animation/spring.ts +1 -1
  178. package/src/reanimated2/animation/styleAnimation.ts +1 -18
  179. package/src/reanimated2/animation/timing.ts +1 -1
  180. package/src/reanimated2/animation/util.ts +12 -9
  181. package/src/reanimated2/commonTypes.ts +48 -1
  182. package/src/reanimated2/core.ts +6 -6
  183. package/src/reanimated2/hook/commonTypes.ts +5 -0
  184. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -2
  185. package/src/reanimated2/hook/useAnimatedRef.ts +1 -5
  186. package/src/reanimated2/hook/useAnimatedStyle.ts +35 -16
  187. package/src/reanimated2/hook/utils.ts +18 -17
  188. package/src/reanimated2/index.ts +2 -0
  189. package/src/reanimated2/interpolateColor.ts +178 -0
  190. package/src/reanimated2/js-reanimated/JSReanimated.ts +3 -4
  191. package/src/reanimated2/js-reanimated/Mapper.ts +1 -1
  192. package/src/reanimated2/js-reanimated/MapperRegistry.ts +1 -1
  193. package/src/reanimated2/js-reanimated/commonTypes.ts +51 -0
  194. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +6 -2
  195. package/src/reanimated2/utils.ts +1 -1
@@ -96,10 +96,10 @@ while (!aar.exists()) {
96
96
  println "\n\n\n"
97
97
  println "****************************************************************************************"
98
98
  println "\n\n\n"
99
- println "WARNING reanimated - no version-specific reanimated AAR for react-native version " . minor . " found."
100
- println "Falling back to AAR for react-native version " . minorCopy
99
+ println "WARNING reanimated - no version-specific reanimated AAR for react-native version " + minor + " found."
100
+ println "Falling back to AAR for react-native version " + minorCopy
101
101
  println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
102
- println "Please post a pull request to implement support for react-native version " . minor . " to the reanimated repo."
102
+ println "Please post a pull request to implement support for react-native version " + minor + " to the reanimated repo."
103
103
  println "Thanks!"
104
104
  println "\n\n\n"
105
105
  println "****************************************************************************************"
@@ -5,10 +5,10 @@
5
5
  NS_ASSUME_NONNULL_BEGIN
6
6
 
7
7
  typedef NS_ENUM(NSInteger, ViewState) {
8
+ Inactive,
8
9
  Appearing,
9
10
  Disappearing,
10
11
  Layout,
11
- Inactive,
12
12
  ToRemove,
13
13
  };
14
14
 
@@ -150,6 +150,10 @@ typedef NS_ENUM(NSInteger, FrameConfigType) { EnteringFrame, ExitingFrame };
150
150
  NSMutableSet<NSNumber *> *roots = [NSMutableSet new];
151
151
  for (NSNumber *viewTag in _toRemove) {
152
152
  UIView *view = _viewForTag[viewTag];
153
+ if (view == nil) {
154
+ view = [_reaUiManager viewForReactTag:viewTag];
155
+ _viewForTag[viewTag] = view;
156
+ }
153
157
  [self findRoot:view roots:roots];
154
158
  }
155
159
  for (NSNumber *viewTag in roots) {
@@ -1,11 +1,11 @@
1
1
  #import <Foundation/Foundation.h>
2
+ #import <RNGestureHandlerStateManager.h>
2
3
  #import <React/RCTUIManager.h>
3
4
  #include <string>
4
5
  #import <string>
5
6
  #include <utility>
6
7
  #include <vector>
7
8
  #import <vector>
8
- #import "RNGestureHandlerStateManager.h"
9
9
 
10
10
  namespace reanimated {
11
11
 
@@ -3,6 +3,7 @@
3
3
  #import <React/RCTUIManager.h>
4
4
  #import <folly/json.h>
5
5
 
6
+ #import <RNGestureHandlerStateManager.h>
6
7
  #import "LayoutAnimationsProxy.h"
7
8
  #import "NativeMethods.h"
8
9
  #import "NativeProxy.h"
@@ -12,7 +13,6 @@
12
13
  #import "REAModule.h"
13
14
  #import "REANodesManager.h"
14
15
  #import "REAUIManager.h"
15
- #import "RNGestureHandlerStateManager.h"
16
16
 
17
17
  #if __has_include(<reacthermes/HermesExecutorFactory.h>)
18
18
  #import <reacthermes/HermesExecutorFactory.h>
@@ -246,7 +246,15 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
246
246
 
247
247
  [reanimatedModule.nodesManager registerEventHandler:^(NSString *eventName, id<RCTEvent> event) {
248
248
  std::string eventNameString([eventName UTF8String]);
249
- std::string eventAsString = folly::toJson(convertIdToFollyDynamic([event arguments][2]));
249
+
250
+ std::string eventAsString;
251
+ try {
252
+ eventAsString = folly::toJson(convertIdToFollyDynamic([event arguments][2]));
253
+ } catch (folly::json::parse_error &) {
254
+ // Events from other libraries may contain NaN or INF values which cannot be represented in JSON.
255
+ // See https://github.com/software-mansion/react-native-reanimated/issues/1776 for details.
256
+ return;
257
+ }
250
258
 
251
259
  eventAsString = "{ NativeMap:" + eventAsString + "}";
252
260
  jsi::Object global = module->runtime->global();
File without changes
File without changes
File without changes
File without changes
File without changes
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,
@@ -1,12 +1,21 @@
1
1
  import { findNodeHandle } from 'react-native';
2
- import { isChromeDebugger } from './PlatformChecker';
2
+ import { shouldBeUseWeb } from './PlatformChecker';
3
3
  export function getTag(view) {
4
4
  return findNodeHandle(view);
5
5
  }
6
+ const isNativeIndefined = shouldBeUseWeb();
6
7
  export function measure(animatedRef) {
7
8
  'worklet';
8
- if (!_WORKLET && !isChromeDebugger()) {
9
- throw new Error('(measure) method cannot be used on RN side!');
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
+ };
10
19
  }
11
20
  const viewTag = animatedRef();
12
21
  const result = _measure(viewTag);
@@ -17,7 +26,7 @@ export function measure(animatedRef) {
17
26
  }
18
27
  export function scrollTo(animatedRef, x, y, animated) {
19
28
  'worklet';
20
- if (!_WORKLET && !isChromeDebugger()) {
29
+ if (!_WORKLET || isNativeIndefined) {
21
30
  return;
22
31
  }
23
32
  const viewTag = animatedRef();
@@ -25,8 +34,9 @@ export function scrollTo(animatedRef, x, y, animated) {
25
34
  }
26
35
  export function setGestureState(handlerTag, newState) {
27
36
  'worklet';
28
- if (!_WORKLET && !isChromeDebugger()) {
37
+ if (!_WORKLET || isNativeIndefined) {
29
38
  console.warn('[Reanimated] You can not use setGestureState in non-worklet function.');
39
+ return;
30
40
  }
31
41
  _setGestureState(handlerTag, newState);
32
42
  }
@@ -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 {
@@ -275,9 +275,11 @@ if (!NativeReanimatedModule.useOnlyV1) {
275
275
  info: runOnJS(capturableConsole.info),
276
276
  };
277
277
  _setGlobalConsole(console);
278
- global.performance = {
279
- now: global._chronoNow,
280
- };
278
+ if (global.performance == null) {
279
+ global.performance = {
280
+ now: global._chronoNow,
281
+ };
282
+ }
281
283
  })();
282
284
  }
283
285
  }
@@ -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);