react-native-reanimated 2.3.3 → 2.5.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 (249) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +72 -0
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +30 -1
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +64 -39
  4. package/Common/cpp/Tools/RuntimeDecorator.cpp +2 -0
  5. package/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h +41 -0
  6. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +14 -0
  7. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +14 -0
  8. package/Common/cpp/headers/SharedItems/MutableValue.h +4 -1
  9. package/Common/cpp/headers/SharedItems/ShareableValue.h +3 -0
  10. package/Common/cpp/headers/SharedItems/ValueWrapper.h +3 -0
  11. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +11 -0
  12. package/Common/cpp/headers/Tools/RuntimeDecorator.h +2 -0
  13. package/LICENSE +1 -1
  14. package/README.md +2 -2
  15. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  16. package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
  17. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  18. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  19. package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
  20. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  21. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  22. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  23. package/android/.gradle/7.2/gc.properties +0 -0
  24. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  25. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  26. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  27. package/android/.gradle/checksums/checksums.lock +0 -0
  28. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  29. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  30. package/android/.gradle/vcs-1/gc.properties +0 -0
  31. package/android/CMakeLists.txt +198 -0
  32. package/android/README.md +15 -0
  33. package/android/build.gradle +686 -73
  34. package/android/empty.cpp +1 -0
  35. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  36. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  37. package/android/gradle.properties +25 -0
  38. package/android/gradlew +234 -0
  39. package/android/gradlew.bat +89 -0
  40. package/android/react-native-reanimated-64-hermes.aar +0 -0
  41. package/android/react-native-reanimated-64-jsc.aar +0 -0
  42. package/android/react-native-reanimated-65-hermes.aar +0 -0
  43. package/android/react-native-reanimated-65-jsc.aar +0 -0
  44. package/android/react-native-reanimated-66-hermes.aar +0 -0
  45. package/android/react-native-reanimated-66-jsc.aar +0 -0
  46. package/android/react-native-reanimated-67-hermes.aar +0 -0
  47. package/android/react-native-reanimated-67-jsc.aar +0 -0
  48. package/android/react-native-reanimated-68-hermes.aar +0 -0
  49. package/android/react-native-reanimated-68-jsc.aar +0 -0
  50. package/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java +412 -0
  51. package/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  52. package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  53. package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  54. package/android/rnVersionPatch/65/.gitkeep +0 -0
  55. package/android/rnVersionPatch/66/.gitkeep +0 -0
  56. package/android/rnVersionPatch/67/.gitkeep +0 -0
  57. package/android/rnVersionPatch/68/.gitkeep +0 -0
  58. package/android/rnVersionPatch/backup/.gitkeep +0 -0
  59. package/android/settings.gradle +1 -0
  60. package/android/spotless.gradle +9 -0
  61. package/android/src/{AndroidManifest.xml → main/AndroidManifest.xml} +0 -0
  62. package/android/src/main/cpp/AndroidErrorHandler.cpp +42 -0
  63. package/android/src/main/cpp/AndroidLogger.cpp +27 -0
  64. package/android/src/main/cpp/AndroidScheduler.cpp +59 -0
  65. package/android/src/main/cpp/JNIHelper.cpp +59 -0
  66. package/android/src/main/cpp/LayoutAnimations.cpp +103 -0
  67. package/android/src/main/cpp/NativeProxy.cpp +327 -0
  68. package/android/src/main/cpp/OnLoad.cpp +17 -0
  69. package/android/src/main/cpp/TurboModule.cpp +44 -0
  70. package/android/src/main/cpp/headers/AndroidErrorHandler.h +30 -0
  71. package/android/src/main/cpp/headers/AndroidLogger.h +16 -0
  72. package/android/src/main/cpp/headers/AndroidScheduler.h +41 -0
  73. package/android/src/main/cpp/headers/JNIHelper.h +30 -0
  74. package/android/src/main/cpp/headers/LayoutAnimations.h +42 -0
  75. package/android/src/main/cpp/headers/NativeProxy.h +170 -0
  76. package/android/src/main/cpp/headers/TurboModule.h +70 -0
  77. package/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java +15 -0
  78. package/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java +5 -0
  79. package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +8 -0
  80. package/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java +43 -0
  81. package/android/src/main/java/com/swmansion/reanimated/MapUtils.java +26 -0
  82. package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +117 -0
  83. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +285 -0
  84. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +682 -0
  85. package/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java +29 -0
  86. package/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java +251 -0
  87. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +96 -0
  88. package/android/src/main/java/com/swmansion/reanimated/Scheduler.java +51 -0
  89. package/android/src/main/java/com/swmansion/reanimated/UpdateContext.java +11 -0
  90. package/android/src/main/java/com/swmansion/reanimated/Utils.java +32 -0
  91. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +517 -0
  92. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +56 -0
  93. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +11 -0
  94. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +410 -0
  95. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  96. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +292 -0
  97. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +121 -0
  98. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +12 -0
  99. package/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java +29 -0
  100. package/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java +87 -0
  101. package/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java +24 -0
  102. package/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java +49 -0
  103. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java +38 -0
  104. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java +73 -0
  105. package/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java +36 -0
  106. package/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java +41 -0
  107. package/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java +33 -0
  108. package/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java +83 -0
  109. package/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java +5 -0
  110. package/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java +20 -0
  111. package/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java +41 -0
  112. package/android/src/main/java/com/swmansion/reanimated/nodes/Node.java +139 -0
  113. package/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java +37 -0
  114. package/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +377 -0
  115. package/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java +71 -0
  116. package/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java +153 -0
  117. package/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java +32 -0
  118. package/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java +40 -0
  119. package/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java +84 -0
  120. package/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java +40 -0
  121. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +41 -0
  122. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +40 -0
  123. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -0
  124. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +35 -0
  125. package/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java +84 -0
  126. package/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java +25 -0
  127. package/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java +86 -0
  128. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java +41 -0
  129. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java +161 -0
  130. package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
  131. package/ios/LayoutReanimation/REAAnimationsManager.m +18 -4
  132. package/ios/REAModule.m +8 -9
  133. package/ios/REANodesManager.h +4 -1
  134. package/ios/REANodesManager.m +75 -3
  135. package/ios/native/NativeMethods.h +1 -1
  136. package/ios/native/NativeProxy.mm +85 -5
  137. package/ios/sensor/ReanimatedSensor.h +21 -0
  138. package/ios/sensor/ReanimatedSensor.m +169 -0
  139. package/ios/sensor/ReanimatedSensorContainer.h +13 -0
  140. package/ios/sensor/ReanimatedSensorContainer.m +41 -0
  141. package/ios/sensor/ReanimatedSensorType.h +7 -0
  142. package/lib/ConfigHelper.js +2 -2
  143. package/lib/createAnimatedComponent.js +3 -4
  144. package/lib/reanimated1/core/AnimatedFunction.js +1 -1
  145. package/lib/reanimated1/derived/interpolate.js +2 -4
  146. package/lib/reanimated2/Colors.js +3 -98
  147. package/lib/reanimated2/Easing.js +5 -0
  148. package/lib/reanimated2/NativeMethods.js +15 -5
  149. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +25 -12
  150. package/lib/reanimated2/NativeReanimated/index.js +2 -6
  151. package/lib/reanimated2/ViewDescriptorsSet.js +2 -2
  152. package/lib/reanimated2/animation/styleAnimation.js +2 -1
  153. package/lib/reanimated2/core.js +30 -24
  154. package/lib/reanimated2/globals.d.ts +6 -0
  155. package/lib/reanimated2/hook/index.js +1 -0
  156. package/lib/reanimated2/hook/useAnimatedGestureHandler.js +1 -2
  157. package/lib/reanimated2/hook/useAnimatedSensor.js +66 -0
  158. package/lib/reanimated2/hook/useAnimatedStyle.js +31 -14
  159. package/lib/reanimated2/hook/utils.js +14 -11
  160. package/lib/reanimated2/index.js +2 -0
  161. package/lib/reanimated2/interpolateColor.js +98 -0
  162. package/lib/reanimated2/interpolation.js +1 -1
  163. package/lib/reanimated2/jestUtils.js +9 -4
  164. package/lib/reanimated2/js-reanimated/JSReanimated.js +24 -3
  165. package/lib/reanimated2/js-reanimated/commonTypes.js +1 -0
  166. package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +8 -0
  167. package/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +2 -1
  168. package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +32 -42
  169. package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +20 -38
  170. package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +32 -44
  171. package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -16
  172. package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -10
  173. package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  174. package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +20 -36
  175. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -20
  176. package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +8 -12
  177. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +32 -48
  178. package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +22 -18
  179. package/lib/reanimated2/mock.js +3 -2
  180. package/mock.js +6 -4
  181. package/package.json +44 -36
  182. package/plugin.js +3 -0
  183. package/react-native-reanimated.d.ts +102 -15
  184. package/src/ConfigHelper.ts +4 -4
  185. package/src/createAnimatedComponent.tsx +3 -3
  186. package/src/reanimated1/core/AnimatedFunction.js +1 -1
  187. package/src/reanimated1/derived/interpolate.js +2 -4
  188. package/src/reanimated2/Colors.ts +8 -151
  189. package/src/reanimated2/Easing.ts +11 -0
  190. package/src/reanimated2/NativeMethods.ts +19 -6
  191. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +42 -14
  192. package/src/reanimated2/NativeReanimated/index.ts +2 -8
  193. package/src/reanimated2/ViewDescriptorsSet.ts +2 -3
  194. package/src/reanimated2/animation/commonTypes.ts +44 -40
  195. package/src/reanimated2/animation/decay.ts +1 -1
  196. package/src/reanimated2/animation/delay.ts +2 -16
  197. package/src/reanimated2/animation/index.ts +8 -8
  198. package/src/reanimated2/animation/repeat.ts +2 -12
  199. package/src/reanimated2/animation/sequence.ts +3 -10
  200. package/src/reanimated2/animation/spring.ts +1 -1
  201. package/src/reanimated2/animation/styleAnimation.ts +11 -25
  202. package/src/reanimated2/animation/timing.ts +4 -2
  203. package/src/reanimated2/animation/util.ts +22 -20
  204. package/src/reanimated2/commonTypes.ts +68 -1
  205. package/src/reanimated2/component/FlatList.tsx +2 -1
  206. package/src/reanimated2/core.ts +35 -29
  207. package/src/reanimated2/globals.d.ts +6 -0
  208. package/src/reanimated2/hook/commonTypes.ts +5 -0
  209. package/src/reanimated2/hook/index.ts +1 -0
  210. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -2
  211. package/src/reanimated2/hook/useAnimatedRef.ts +1 -5
  212. package/src/reanimated2/hook/useAnimatedSensor.ts +91 -0
  213. package/src/reanimated2/hook/useAnimatedStyle.ts +35 -16
  214. package/src/reanimated2/hook/utils.ts +20 -18
  215. package/src/reanimated2/index.ts +2 -0
  216. package/src/reanimated2/interpolateColor.ts +178 -0
  217. package/src/reanimated2/interpolation.ts +2 -6
  218. package/src/reanimated2/jestUtils.ts +9 -4
  219. package/src/reanimated2/js-reanimated/JSReanimated.ts +28 -6
  220. package/src/reanimated2/js-reanimated/Mapper.ts +1 -1
  221. package/src/reanimated2/js-reanimated/MapperRegistry.ts +1 -1
  222. package/src/reanimated2/js-reanimated/commonTypes.ts +51 -0
  223. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +13 -0
  224. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -3
  225. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +51 -21
  226. package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +40 -10
  227. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +48 -12
  228. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +16 -4
  229. package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -2
  230. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +16 -4
  231. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +32 -8
  232. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -10
  233. package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +16 -4
  234. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +64 -16
  235. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +2 -1
  236. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +32 -21
  237. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +2 -1
  238. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +2 -1
  239. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +2 -1
  240. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +2 -1
  241. package/src/reanimated2/mock.ts +3 -2
  242. package/src/reanimated2/utils.ts +1 -1
  243. package/android/react-native-reanimated-63-hermes.aar +0 -0
  244. package/android/react-native-reanimated-63-jsc.aar +0 -0
  245. package/android/src/main/java/com/swmansion/reanimated/ReanimatedProxyPackage.java +0 -15
  246. package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
  247. package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
  248. package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
  249. package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
@@ -74,24 +74,28 @@ export class EntryExitTransition extends BaseAnimationBuilder {
74
74
  }
75
75
  }
76
76
  const mergedTransform = ((_c = exitingValues.initialValues.transform) !== null && _c !== void 0 ? _c : []).concat(((_d = enteringValues.animations.transform) !== null && _d !== void 0 ? _d : []).map((value) => {
77
- for (const transformProp of Object.keys(value)) {
78
- const current = value[transformProp].current;
79
- if (typeof current === 'string') {
80
- if (current.includes('deg'))
81
- return {
82
- [transformProp]: '0deg',
83
- };
84
- else
85
- return {
86
- [transformProp]: '0',
87
- };
88
- }
89
- else if (transformProp.includes('translate')) {
90
- return { [transformProp]: 0 };
91
- }
92
- else {
93
- return { [transformProp]: 1 };
94
- }
77
+ const objectKeys = Object.keys(value);
78
+ if ((objectKeys === null || objectKeys === void 0 ? void 0 : objectKeys.length) < 1) {
79
+ console.error(`[Reanimated]: \${value} is not a valid Transform object`);
80
+ return value;
81
+ }
82
+ const transformProp = objectKeys[0];
83
+ const current = value[transformProp].current;
84
+ if (typeof current === 'string') {
85
+ if (current.includes('deg'))
86
+ return {
87
+ [transformProp]: '0deg',
88
+ };
89
+ else
90
+ return {
91
+ [transformProp]: '0',
92
+ };
93
+ }
94
+ else if (transformProp.includes('translate')) {
95
+ return { [transformProp]: 0 };
96
+ }
97
+ else {
98
+ return { [transformProp]: 1 };
95
99
  }
96
100
  return value;
97
101
  }));
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- /* eslint-disable standard/no-callback-literal */
2
+ /* eslint-disable node/no-callback-literal */
3
3
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
4
  // @ts-nocheck
5
5
  const NOOP = () => {
@@ -58,7 +58,8 @@ const ReanimatedV2 = {
58
58
  elastic: ID,
59
59
  back: ID,
60
60
  bounce: ID,
61
- bezier: ID,
61
+ bezier: () => ({ factory: ID }),
62
+ bezierFn: ID,
62
63
  in: ID,
63
64
  out: ID,
64
65
  inOut: ID,
package/mock.js CHANGED
@@ -28,7 +28,7 @@ function simulateCallbackFactory(...params) {
28
28
  callback &&
29
29
  setTimeout(() => {
30
30
  // user defined callback
31
- // eslint-disable-next-line standard/no-callback-literal
31
+ // eslint-disable-next-line node/no-callback-literal
32
32
  callback(...params);
33
33
  }, 0);
34
34
  };
@@ -73,9 +73,9 @@ function createMockComponent(name) {
73
73
 
74
74
  function createTransitioningComponent(Component) {
75
75
  return class extends React.Component {
76
- static displayName = `Transitioning.${Component.displayName ||
77
- Component.name ||
78
- 'Component'}`;
76
+ static displayName = `Transitioning.${
77
+ Component.displayName || Component.name || 'Component'
78
+ }`;
79
79
 
80
80
  setNativeProps() {
81
81
  // noop
@@ -209,7 +209,9 @@ const Reanimated = {
209
209
  },
210
210
  diff: NOOP,
211
211
  diffClamp: NOOP,
212
+ interpolate: NOOP,
212
213
  interpolateNode: NOOP,
214
+ interpolateColor: NOOP,
213
215
  interpolateColors: NOOP,
214
216
  max: (a, b) => Math.max(getValue(a), getValue(b)),
215
217
  min: (a, b) => Math.min(getValue(a), getValue(b)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "2.3.3",
3
+ "version": "2.5.0",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "start": "node node_modules/react-native/local-cli/cli.js start",
@@ -18,13 +18,20 @@
18
18
  "format:common": "find Common/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
19
19
  "release": "npm login && release-it",
20
20
  "type:check": "yarn tsc --noEmit",
21
- "type:generate": "yarn type:generate:clean && yarn type:generate:cp-js-src && yarn type:generate:tsc && yarn type:generate:remove.ts && yarn type:generate:remove.tsx",
21
+ "type:generate": "yarn type:generate:clean && yarn type:generate:cp-js-src && yarn type:generate:tsc && yarn type:generate:remove.ts && yarn type:generate:remove.tsx && yarn type:generate:remove.js:from-src",
22
22
  "type:generate:clean": "rm -rf lib/ && mkdir lib/",
23
23
  "type:generate:cp-js-src": "cp -RL src/* lib/",
24
24
  "type:generate:tsc": "yarn tsc",
25
25
  "type:generate:remove.ts": "find ./lib -type f -name \"*.ts\" -and -not -name \"*.d.ts\" -delete",
26
26
  "type:generate:remove.tsx": "find ./lib -type f -name \"*.tsx\" -and -not -name \"*.d.ts\" -delete",
27
- "prepare": "husky install"
27
+ "type:generate:remove.js:from-src": "find ./src/reanimated2 -type f -name \"*.js\" -delete",
28
+ "prepare": "husky install",
29
+ "circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular ./src",
30
+ "setup": "yarn && cd Example && yarn && cd ios && pod install --verbose && cd ../..",
31
+ "clean": "rm -rf node_modules && cd Example && rm -rf node_modules && cd ios && pod deintegrate && cd ../..",
32
+ "reset": "yarn clean && yarn setup",
33
+ "clean:deep": "cd android && rm -rf .cxx .gradle build && cd ../Example/android && rm -rf .gradle build app/build && cd ../.. && yarn clean",
34
+ "reset:deep": "yarn clean:deep && yarn setup"
28
35
  },
29
36
  "main": "lib/Animated.js",
30
37
  "module": "lib/Animated",
@@ -35,7 +42,6 @@
35
42
  "Common/",
36
43
  "src/",
37
44
  "lib/",
38
- "libSo/",
39
45
  "android/src/main/AndroidManifest.xml",
40
46
  "android/src/main/java/",
41
47
  "android/build.gradle",
@@ -68,55 +74,57 @@
68
74
  },
69
75
  "homepage": "https://github.com/software-mansion/react-native-reanimated#readme",
70
76
  "dependencies": {
71
- "@babel/plugin-transform-object-assign": "^7.10.4",
77
+ "@babel/plugin-transform-object-assign": "^7.16.7",
72
78
  "@types/invariant": "^2.2.35",
73
79
  "invariant": "^2.2.4",
74
80
  "lodash.isequal": "^4.5.0",
75
- "mockdate": "^3.0.2",
76
- "react-native-screens": "^3.4.0",
81
+ "react-native-screens": "^3.11.1",
82
+ "setimmediate": "^1.0.5",
77
83
  "string-hash-64": "^1.0.3"
78
84
  },
79
85
  "peerDependencies": {
86
+ "@babel/preset-typescript": "*",
80
87
  "react": "*",
81
88
  "react-native": "*",
82
89
  "react-native-gesture-handler": "*"
83
90
  },
84
91
  "devDependencies": {
85
- "@babel/core": "^7.7.5",
86
- "@babel/plugin-proposal-class-properties": "^7.7.4",
87
- "@babel/preset-env": "^7.7.6",
88
- "@babel/preset-typescript": "^7.7.4",
89
- "@react-native-community/bob": "^0.14.3",
92
+ "@babel/core": "^7.17.2",
93
+ "@babel/plugin-proposal-class-properties": "^7.16.7",
94
+ "@babel/preset-env": "^7.16.11",
95
+ "@babel/preset-typescript": "^7.16.7",
96
+ "@react-native-community/bob": "^0.17.1",
90
97
  "@react-native-community/eslint-config": "^0.0.5",
91
- "@testing-library/jest-native": "^3.4.3",
98
+ "@testing-library/jest-native": "^4.0.4",
92
99
  "@testing-library/react-hooks": "^5.0.3",
93
100
  "@testing-library/react-native": "^7.1.0",
94
- "@types/babel-types": "^7.0.9",
95
- "@types/babel__core": "^7.1.12",
96
- "@types/babel__generator": "^7.6.2",
97
- "@types/babel__traverse": "^7.0.15",
98
- "@types/jest": "^26.0.15",
99
- "@types/react-native": "^0.65.1",
100
- "@typescript-eslint/eslint-plugin": "^4.15.1",
101
- "@typescript-eslint/parser": "^4.15.1",
102
- "babel-eslint": "^10.0.3",
103
- "babel-jest": "^26.6.3",
101
+ "@types/babel-types": "^7.0.11",
102
+ "@types/babel__core": "^7.1.18",
103
+ "@types/babel__generator": "^7.6.4",
104
+ "@types/babel__traverse": "^7.14.2",
105
+ "@types/jest": "^27.4.0",
106
+ "@types/react-native": "^0.66.15",
107
+ "@typescript-eslint/eslint-plugin": "^5.11.0",
108
+ "@typescript-eslint/parser": "^5.11.0",
109
+ "babel-eslint": "^10.1.0",
110
+ "babel-jest": "^27.5.1",
104
111
  "babel-plugin-module-resolver": "^4.1.0",
105
- "clang-format": "^1.5.0",
106
- "eslint": "^7.31.0",
107
- "eslint-config-prettier": "^6.4.0",
108
- "eslint-config-standard": "^14.1.0",
109
- "eslint-import-resolver-babel-module": "^5.2.0",
110
- "eslint-plugin-import": "^2.18.2",
111
- "eslint-plugin-node": "^10.0.0",
112
- "eslint-plugin-promise": "^4.2.1",
113
- "eslint-plugin-standard": "^4.0.1",
114
- "husky": "^7.0.0",
115
- "jest": "^26.6.3",
112
+ "clang-format": "^1.6.0",
113
+ "eslint": "^8.8.0",
114
+ "eslint-config-prettier": "^8.3.0",
115
+ "eslint-config-standard": "^16.0.3",
116
+ "eslint-import-resolver-babel-module": "^5.3.1",
117
+ "eslint-plugin-import": "^2.25.4",
118
+ "eslint-plugin-node": "^11.1.0",
119
+ "eslint-plugin-promise": "^6.0.0",
120
+ "eslint-plugin-standard": "^5.0.0",
121
+ "husky": "^7.0.4",
122
+ "jest": "^27.5.1",
116
123
  "lint-staged": "^11.2.0",
117
- "prettier": "^2.2.1",
124
+ "madge": "^5.0.1",
125
+ "prettier": "^2.5.1",
118
126
  "react": "17.0.2",
119
- "react-native": "0.67.0-rc.4",
127
+ "react-native": "0.68.0-rc.2",
120
128
  "react-native-codegen": "^0.0.7",
121
129
  "react-native-gesture-handler": "^1.6.1",
122
130
  "react-test-renderer": "17.0.2",
package/plugin.js CHANGED
@@ -30,7 +30,9 @@ const objectHooks = new Set([
30
30
  const globals = new Set([
31
31
  'this',
32
32
  'console',
33
+ 'performance',
33
34
  '_setGlobalConsole',
35
+ '_chronoNow',
34
36
  'Date',
35
37
  'Array',
36
38
  'ArrayBuffer',
@@ -158,6 +160,7 @@ const gestureHandlerBuilderMethods = new Set([
158
160
  'onEnd',
159
161
  'onFinalize',
160
162
  'onUpdate',
163
+ 'onChange',
161
164
  'onTouchesDown',
162
165
  'onTouchesMove',
163
166
  'onTouchesUp',
@@ -16,6 +16,7 @@ declare module 'react-native-reanimated' {
16
16
  TextProps,
17
17
  ImageProps,
18
18
  ScrollViewProps,
19
+ FlatListProps,
19
20
  StyleProp,
20
21
  RegisteredStyle,
21
22
  ViewStyle,
@@ -38,16 +39,24 @@ declare module 'react-native-reanimated' {
38
39
  PanGestureHandlerGestureEvent,
39
40
  } from 'react-native-gesture-handler';
40
41
 
41
- export {
42
- Animation,
43
- TimingAnimation,
44
- SpringAnimation,
45
- DecayAnimation,
46
- DelayAnimation,
47
- RepeatAnimation,
48
- SequenceAnimation,
49
- StyleLayoutAnimation,
50
- } from './src/reanimated2/animation/index';
42
+ import('./src/reanimated2/globals');
43
+
44
+ export type TimingAnimation =
45
+ import('./src/reanimated2/animation/index').TimingAnimation;
46
+ export type SpringAnimation =
47
+ import('./src/reanimated2/animation/index').SpringAnimation;
48
+ export type DecayAnimation =
49
+ import('./src/reanimated2/animation/index').DecayAnimation;
50
+ export type DelayAnimation =
51
+ import('./src/reanimated2/animation/commonTypes').DelayAnimation;
52
+ export type RepeatAnimation =
53
+ import('./src/reanimated2/animation/index').RepeatAnimation;
54
+ export type SequenceAnimation =
55
+ import('./src/reanimated2/animation/index').SequenceAnimation;
56
+ export type StyleLayoutAnimation =
57
+ import('./src/reanimated2/animation/index').StyleLayoutAnimation;
58
+ export type Animation<T> =
59
+ import('./src/reanimated2/commonTypes').Animation<T>;
51
60
 
52
61
  namespace Animated {
53
62
  type Nullable<T> = T | null | undefined;
@@ -145,10 +154,14 @@ declare module 'react-native-reanimated' {
145
154
  >;
146
155
  };
147
156
 
157
+ export type StylesOrDefault<T> = 'style' extends keyof T
158
+ ? T['style']
159
+ : Record<string, unknown>;
160
+
148
161
  export type AnimateProps<P extends object> = {
149
- [K in keyof P]: K extends 'style'
150
- ? StyleProp<AnimateStyle<P[K]>>
151
- : P[K] | AnimatedNode<P[K]>;
162
+ [K in keyof P]: P[K] | AnimatedNode<P[K]>;
163
+ } & {
164
+ style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
152
165
  } & {
153
166
  animatedProps?: Partial<AnimateProps<P>>;
154
167
  layout?:
@@ -247,20 +260,31 @@ declare module 'react-native-reanimated' {
247
260
  export class View extends Component<AnimateProps<ViewProps>> {
248
261
  getNode(): ReactNativeView;
249
262
  }
263
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
264
+ export interface View extends ReactNativeView {}
250
265
  export class Text extends Component<AnimateProps<TextProps>> {
251
266
  getNode(): ReactNativeText;
252
267
  }
268
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
269
+ export interface Text extends ReactNativeText {}
253
270
  export class Image extends Component<AnimateProps<ImageProps>> {
254
271
  getNode(): ReactNativeImage;
255
272
  }
273
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
274
+ export interface Image extends ReactNativeImage {}
256
275
  export class ScrollView extends Component<AnimateProps<ScrollViewProps>> {
257
276
  getNode(): ReactNativeScrollView;
258
277
  }
278
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
279
+ export interface ScrollView extends ReactNativeScrollView {}
280
+
259
281
  export class Code extends Component<CodeProps> {}
260
- export class FlatList extends Component<AnimateProps<FlatList>> {
282
+ export class FlatList<T> extends Component<AnimateProps<FlatListProps<T>>> {
261
283
  itemLayoutAnimation: ILayoutAnimationBuilder;
262
284
  getNode(): ReactNativeFlatList;
263
285
  }
286
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
287
+ export interface FlatList<T> extends ReactNativeView<T> {}
264
288
 
265
289
  type Options<P> = {
266
290
  setNativeProps: (ref: any, props: P) => void;
@@ -465,6 +489,23 @@ declare module 'react-native-reanimated' {
465
489
  targetGlobalOriginY: number;
466
490
  }
467
491
 
492
+ export enum SensorType {
493
+ ACCELEROMETER = 1,
494
+ GYROSCOPE = 2,
495
+ GRAVITY = 3,
496
+ MAGNETIC_FIELD = 4,
497
+ ROTATION = 5,
498
+ }
499
+
500
+ export type SensorConfig = {
501
+ interval: number;
502
+ };
503
+
504
+ export function useAnimatedSensor(
505
+ sensorType: SensorType,
506
+ userConfig?: SensorConfig
507
+ );
508
+
468
509
  export interface ExitAnimationsValues {
469
510
  currentOriginX: number;
470
511
  currentOriginY: number;
@@ -541,9 +582,10 @@ declare module 'react-native-reanimated' {
541
582
  finished?: boolean,
542
583
  current?: AnimatableValue
543
584
  ) => void;
585
+ export type EasingFunctionFactory = { factory: () => EasingFunction };
544
586
  export interface WithTimingConfig {
545
587
  duration?: number;
546
- easing?: EasingFunction;
588
+ easing?: EasingFunction | EasingFunctionFactory;
547
589
  }
548
590
  export interface WithDecayConfig {
549
591
  deceleration?: number;
@@ -610,6 +652,42 @@ declare module 'react-native-reanimated' {
610
652
  colorSpace?: 'RGB' | 'HSV'
611
653
  ): string | number;
612
654
 
655
+ export enum ColorSpace {
656
+ RGB = 0,
657
+ HSV = 1,
658
+ }
659
+
660
+ export interface InterpolateRGB {
661
+ r: number[];
662
+ g: number[];
663
+ b: number[];
664
+ a: number[];
665
+ }
666
+
667
+ export interface InterpolateHSV {
668
+ h: number[];
669
+ s: number[];
670
+ v: number[];
671
+ }
672
+
673
+ export interface InterpolateConfig {
674
+ inputRange: readonly number[];
675
+ outputRange: readonly (string | number)[];
676
+ colorSpace: ColorSpace;
677
+ cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
678
+ }
679
+
680
+ export function useInterpolateConfig(
681
+ inputRange: readonly number[],
682
+ outputRange: readonly (string | number)[],
683
+ colorSpace?: ColorSpace
684
+ ): SharedValue<InterpolateConfig>;
685
+
686
+ export function interpolateSharableColor(
687
+ value: number,
688
+ interpolateConfig: SharedValue<InterpolateConfig>
689
+ ): string | number;
690
+
613
691
  export function makeMutable<T>(initialValue: T): SharedValue<T>;
614
692
 
615
693
  type DependencyList = ReadonlyArray<any>;
@@ -777,6 +855,9 @@ declare module 'react-native-reanimated' {
777
855
  callback: (finished: boolean) => void
778
856
  ): ComplexAnimationBuilder;
779
857
 
858
+ static withInitialValues(values: StyleProps): BaseAnimationBuilder;
859
+ withInitialValues(values: StyleProps): BaseAnimationBuilder;
860
+
780
861
  static easing(easingFunction: EasingFunction): ComplexAnimationBuilder;
781
862
  easing(easingFunction: EasingFunction): ComplexAnimationBuilder;
782
863
  static springify(): ComplexAnimationBuilder;
@@ -981,6 +1062,12 @@ declare module 'react-native-reanimated' {
981
1062
  y1: number,
982
1063
  x2: number,
983
1064
  y2: number
1065
+ ): { factory: () => Animated.EasingFunction };
1066
+ bezierFn(
1067
+ x1: number,
1068
+ y1: number,
1069
+ x2: number,
1070
+ y2: number
984
1071
  ): Animated.EasingFunction;
985
1072
  in(easing: Animated.EasingFunction): Animated.EasingFunction;
986
1073
  out(easing: Animated.EasingFunction): Animated.EasingFunction;
@@ -1,4 +1,4 @@
1
- import ReanimatedModule from './ReanimatedModule';
1
+ import { configureProps as jsiConfigureProps } from './reanimated2/core';
2
2
 
3
3
  /**
4
4
  * Styles allowed to be direcly updated in UI thread
@@ -107,9 +107,9 @@ let NATIVE_THREAD_PROPS_WHITELIST: Record<string, boolean> = {
107
107
  };
108
108
 
109
109
  function configureProps(): void {
110
- ReanimatedModule.configureProps(
111
- Object.keys(NATIVE_THREAD_PROPS_WHITELIST),
112
- Object.keys(UI_THREAD_PROPS_WHITELIST)
110
+ jsiConfigureProps(
111
+ Object.keys(UI_THREAD_PROPS_WHITELIST),
112
+ Object.keys(NATIVE_THREAD_PROPS_WHITELIST)
113
113
  );
114
114
  }
115
115
 
@@ -194,6 +194,7 @@ export default function createAnimatedComponent(
194
194
  _viewTag = -1;
195
195
  _isFirstRender = true;
196
196
  animatedStyle: { value: StyleProps } = { value: {} };
197
+ initialStyle = {};
197
198
  sv: SharedValue<null | Record<string, unknown>> | null;
198
199
  _propsAnimated?: PropsAnimated;
199
200
  _component: ComponentRef | null = null;
@@ -606,13 +607,12 @@ export default function createAnimatedComponent(
606
607
  // this is how we recognize styles returned by useAnimatedStyle
607
608
  style.viewsRef.add(this);
608
609
  if (this._isFirstRender) {
609
- return {
610
+ this.initialStyle = {
610
611
  ...style.initial.value,
611
612
  ...initialUpdaterRun<StyleProps>(style.initial.updater),
612
613
  };
613
- } else {
614
- return style.initial.value;
615
614
  }
615
+ return this.initialStyle;
616
616
  } else {
617
617
  return style;
618
618
  }
@@ -37,7 +37,7 @@ export function createAnimatedFunction(cb) {
37
37
  for (let i = 0; i < params.length; i++) {
38
38
  params[i] = createAnimatedParam();
39
39
  }
40
- // eslint-disable-next-line standard/no-callback-literal
40
+ // eslint-disable-next-line node/no-callback-literal
41
41
  const what = cb(...params);
42
42
  const func = new AnimatedFunction(what, ...params);
43
43
  return (...args) => {
@@ -128,15 +128,13 @@ export default function interpolate(value, config) {
128
128
  const right = extrapolateRight || extrapolate;
129
129
  let output = interpolateInternal(value, inputRange, outputRange);
130
130
 
131
- if (left === Extrapolate.EXTEND) {
132
- } else if (left === Extrapolate.CLAMP) {
131
+ if (left === Extrapolate.CLAMP) {
133
132
  output = cond(lessThan(value, inputRange[0]), outputRange[0], output);
134
133
  } else if (left === Extrapolate.IDENTITY) {
135
134
  output = cond(lessThan(value, inputRange[0]), value, output);
136
135
  }
137
136
 
138
- if (right === Extrapolate.EXTEND) {
139
- } else if (right === Extrapolate.CLAMP) {
137
+ if (right === Extrapolate.CLAMP) {
140
138
  output = cond(
141
139
  greaterThan(value, inputRange[inputRange.length - 1]),
142
140
  outputRange[outputRange.length - 1],