react-native-reanimated 2.5.0 → 2.8.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 (221) hide show
  1. package/Common/cpp/SharedItems/ShareableValue.cpp +2 -2
  2. package/Common/cpp/Tools/RuntimeDecorator.cpp +0 -14
  3. package/RNReanimated.podspec +15 -6
  4. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  5. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  6. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  8. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  9. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  10. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  11. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  12. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  13. package/android/.gradle/checksums/checksums.lock +0 -0
  14. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  15. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  16. package/android/build.gradle +13 -23
  17. package/android/react-native-reanimated-64-hermes.aar +0 -0
  18. package/android/react-native-reanimated-64-jsc.aar +0 -0
  19. package/android/react-native-reanimated-65-hermes.aar +0 -0
  20. package/android/react-native-reanimated-65-jsc.aar +0 -0
  21. package/android/react-native-reanimated-66-hermes.aar +0 -0
  22. package/android/react-native-reanimated-66-jsc.aar +0 -0
  23. package/android/react-native-reanimated-67-hermes.aar +0 -0
  24. package/android/react-native-reanimated-67-jsc.aar +0 -0
  25. package/android/react-native-reanimated-68-hermes.aar +0 -0
  26. package/android/react-native-reanimated-68-jsc.aar +0 -0
  27. package/android/src/main/cpp/NativeProxy.cpp +22 -12
  28. package/android/src/main/cpp/headers/NativeProxy.h +2 -0
  29. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +11 -8
  30. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +13 -6
  31. package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
  32. package/ios/LayoutReanimation/REAAnimationsManager.m +2 -2
  33. package/ios/LayoutReanimation/REASnapshot.m +1 -1
  34. package/ios/LayoutReanimation/REAUIManager.h +1 -1
  35. package/ios/LayoutReanimation/REAUIManager.mm +4 -5
  36. package/ios/Nodes/REAAlwaysNode.h +1 -1
  37. package/ios/Nodes/REAAlwaysNode.m +5 -5
  38. package/ios/Nodes/REABezierNode.h +1 -1
  39. package/ios/Nodes/REABezierNode.m +4 -5
  40. package/ios/Nodes/REABlockNode.h +1 -1
  41. package/ios/Nodes/REABlockNode.m +2 -2
  42. package/ios/Nodes/REACallFuncNode.h +1 -1
  43. package/ios/Nodes/REACallFuncNode.m +5 -5
  44. package/ios/Nodes/REAClockNodes.h +1 -1
  45. package/ios/Nodes/REAClockNodes.m +4 -4
  46. package/ios/Nodes/REAConcatNode.h +1 -1
  47. package/ios/Nodes/REAConcatNode.m +3 -3
  48. package/ios/Nodes/REACondNode.h +1 -1
  49. package/ios/Nodes/REACondNode.m +3 -3
  50. package/ios/Nodes/READebugNode.h +1 -1
  51. package/ios/Nodes/READebugNode.m +3 -3
  52. package/ios/Nodes/REAEventNode.h +1 -2
  53. package/ios/Nodes/REAEventNode.m +3 -3
  54. package/ios/Nodes/REAFunctionNode.h +1 -1
  55. package/ios/Nodes/REAFunctionNode.m +3 -3
  56. package/ios/Nodes/REAJSCallNode.h +1 -1
  57. package/ios/Nodes/REAJSCallNode.m +3 -3
  58. package/ios/Nodes/REANode.m +2 -2
  59. package/ios/Nodes/REAOperatorNode.h +1 -1
  60. package/ios/Nodes/REAOperatorNode.m +2 -3
  61. package/ios/Nodes/REAParamNode.h +1 -1
  62. package/ios/Nodes/REAParamNode.m +4 -4
  63. package/ios/Nodes/REAPropsNode.h +1 -1
  64. package/ios/Nodes/REAPropsNode.m +4 -6
  65. package/ios/Nodes/REASetNode.h +1 -1
  66. package/ios/Nodes/REASetNode.m +4 -4
  67. package/ios/Nodes/REAStyleNode.h +1 -1
  68. package/ios/Nodes/REAStyleNode.m +2 -3
  69. package/ios/Nodes/REATransformNode.h +1 -1
  70. package/ios/Nodes/REATransformNode.m +2 -2
  71. package/ios/Nodes/REAValueNode.h +1 -3
  72. package/ios/Nodes/REAValueNode.m +1 -1
  73. package/ios/REAEventDispatcher.m +1 -1
  74. package/ios/REAModule.h +1 -1
  75. package/ios/REAModule.m +4 -5
  76. package/ios/REANodesManager.h +1 -2
  77. package/ios/REANodesManager.m +22 -24
  78. package/ios/Transitioning/RCTConvert+REATransition.h +1 -2
  79. package/ios/Transitioning/RCTConvert+REATransition.m +1 -1
  80. package/ios/Transitioning/REAAllTransitions.h +1 -1
  81. package/ios/Transitioning/REAAllTransitions.m +2 -3
  82. package/ios/Transitioning/REATransition.h +2 -3
  83. package/ios/Transitioning/REATransition.m +3 -4
  84. package/ios/Transitioning/REATransitionAnimation.m +1 -2
  85. package/ios/Transitioning/REATransitionManager.m +2 -4
  86. package/ios/Transitioning/REATransitionValues.m +2 -3
  87. package/ios/native/NativeMethods.h +1 -3
  88. package/ios/native/NativeMethods.mm +1 -1
  89. package/ios/native/NativeProxy.h +2 -2
  90. package/ios/native/NativeProxy.mm +20 -17
  91. package/ios/native/REAIOSErrorHandler.h +2 -4
  92. package/ios/native/REAIOSErrorHandler.mm +1 -1
  93. package/ios/native/REAIOSLogger.h +1 -3
  94. package/ios/native/REAIOSLogger.mm +1 -1
  95. package/ios/native/REAIOSScheduler.h +1 -3
  96. package/ios/native/REAIOSScheduler.mm +2 -2
  97. package/ios/native/REAInitializer.h +0 -7
  98. package/ios/native/REAInitializer.mm +2 -2
  99. package/ios/native/UIResponder+Reanimated.mm +3 -3
  100. package/ios/sensor/ReanimatedSensor.h +5 -1
  101. package/ios/sensor/ReanimatedSensor.m +49 -1
  102. package/ios/sensor/ReanimatedSensorContainer.h +1 -2
  103. package/ios/sensor/ReanimatedSensorContainer.m +2 -3
  104. package/lib/Animated.js +0 -9
  105. package/lib/ConfigHelper.js +0 -1
  106. package/lib/index.js +0 -9
  107. package/lib/reanimated2/Easing.js +9 -3
  108. package/lib/reanimated2/core.js +0 -36
  109. package/lib/reanimated2/globals.d.ts +1 -2
  110. package/lib/reanimated2/interpolateColor.js +11 -11
  111. package/lib/reanimated2/js-reanimated/index.js +3 -3
  112. package/lib/types/lib/ConfigHelper.d.ts +12 -0
  113. package/lib/types/lib/ReanimatedEventEmitter.d.ts +3 -0
  114. package/lib/types/lib/ReanimatedModule.d.ts +2 -0
  115. package/lib/types/lib/ReanimatedModule.macos.d.ts +2 -0
  116. package/lib/types/lib/ReanimatedModule.native.d.ts +2 -0
  117. package/lib/types/lib/ReanimatedModule.windows.d.ts +2 -0
  118. package/lib/types/lib/ReanimatedModuleCompat.d.ts +14 -0
  119. package/lib/types/lib/createAnimatedComponent.d.ts +33 -0
  120. package/lib/types/lib/reanimated2/Bezier.d.ts +6 -0
  121. package/lib/types/lib/reanimated2/Colors.d.ts +31 -0
  122. package/lib/types/lib/reanimated2/Easing.d.ts +172 -0
  123. package/lib/types/lib/reanimated2/NativeMethods.d.ts +14 -0
  124. package/lib/types/lib/reanimated2/NativeReanimated/NativeReanimated.d.ts +20 -0
  125. package/lib/types/lib/reanimated2/NativeReanimated/index.d.ts +3 -0
  126. package/lib/types/lib/reanimated2/PlatformChecker.d.ts +5 -0
  127. package/lib/types/lib/reanimated2/PropAdapters.d.ts +4 -0
  128. package/lib/types/lib/reanimated2/UpdateProps.d.ts +9 -0
  129. package/lib/types/lib/reanimated2/ViewDescriptorsSet.d.ts +20 -0
  130. package/lib/types/lib/reanimated2/WorkletEventHandler.d.ts +13 -0
  131. package/lib/types/lib/reanimated2/__mocks__/MutableValue.d.ts +5 -0
  132. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.d.ts +13 -0
  133. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.native.d.ts +13 -0
  134. package/lib/types/lib/reanimated2/animation/commonTypes.d.ts +27 -0
  135. package/lib/types/lib/reanimated2/animation/decay.d.ts +19 -0
  136. package/lib/types/lib/reanimated2/animation/delay.d.ts +7 -0
  137. package/lib/types/lib/reanimated2/animation/index.d.ts +9 -0
  138. package/lib/types/lib/reanimated2/animation/repeat.d.ts +12 -0
  139. package/lib/types/lib/reanimated2/animation/sequence.d.ts +7 -0
  140. package/lib/types/lib/reanimated2/animation/spring.d.ts +22 -0
  141. package/lib/types/lib/reanimated2/animation/styleAnimation.d.ts +7 -0
  142. package/lib/types/lib/reanimated2/animation/timing.d.ts +21 -0
  143. package/lib/types/lib/reanimated2/animation/util.d.ts +9 -0
  144. package/lib/types/lib/reanimated2/commonTypes.d.ts +79 -0
  145. package/lib/types/lib/reanimated2/component/FlatList.d.ts +9 -0
  146. package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +8 -0
  147. package/lib/types/lib/reanimated2/component/index.d.ts +9 -0
  148. package/lib/types/lib/reanimated2/core.d.ts +24 -0
  149. package/lib/types/lib/reanimated2/hook/Hooks.d.ts +5 -0
  150. package/lib/types/lib/reanimated2/hook/commonTypes.d.ts +14 -0
  151. package/lib/types/lib/reanimated2/hook/index.d.ts +10 -0
  152. package/lib/types/lib/reanimated2/hook/useAnimatedGestureHandler.d.ts +35 -0
  153. package/lib/types/lib/reanimated2/hook/useAnimatedReaction.d.ts +12 -0
  154. package/lib/types/lib/reanimated2/hook/useAnimatedRef.d.ts +3 -0
  155. package/lib/types/lib/reanimated2/hook/useAnimatedScrollHandler.d.ts +21 -0
  156. package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +18 -0
  157. package/lib/types/lib/reanimated2/hook/useAnimatedStyle.d.ts +11 -0
  158. package/lib/types/lib/reanimated2/hook/useDerivedValue.d.ts +4 -0
  159. package/lib/types/lib/reanimated2/hook/useSharedValue.d.ts +2 -0
  160. package/lib/types/lib/reanimated2/hook/utils.d.ts +28 -0
  161. package/lib/types/lib/reanimated2/index.d.ts +12 -0
  162. package/lib/types/lib/reanimated2/interpolateColor.d.ts +26 -0
  163. package/lib/types/lib/reanimated2/interpolation.d.ts +14 -0
  164. package/lib/types/lib/reanimated2/jestUtils.d.ts +12 -0
  165. package/lib/types/lib/reanimated2/js-reanimated/JSReanimated.d.ts +30 -0
  166. package/lib/types/lib/reanimated2/js-reanimated/Mapper.d.ts +14 -0
  167. package/lib/types/lib/reanimated2/js-reanimated/MapperRegistry.d.ts +14 -0
  168. package/lib/types/lib/reanimated2/js-reanimated/MutableValue.d.ts +14 -0
  169. package/lib/types/lib/reanimated2/js-reanimated/commonTypes.d.ts +44 -0
  170. package/lib/types/lib/reanimated2/js-reanimated/index.d.ts +15 -0
  171. package/lib/types/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.d.ts +1 -0
  172. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +22 -0
  173. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +38 -0
  174. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +25 -0
  175. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +77 -0
  176. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/index.d.ts +4 -0
  177. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +62 -0
  178. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Default.d.ts +4 -0
  179. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +42 -0
  180. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +50 -0
  181. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +18 -0
  182. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +10 -0
  183. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +18 -0
  184. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +34 -0
  185. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +34 -0
  186. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +18 -0
  187. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +66 -0
  188. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/index.d.ts +10 -0
  189. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +19 -0
  190. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +13 -0
  191. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +6 -0
  192. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +6 -0
  193. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +7 -0
  194. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +9 -0
  195. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/index.d.ts +6 -0
  196. package/lib/types/lib/reanimated2/layoutReanimation/index.d.ts +4 -0
  197. package/lib/types/lib/reanimated2/mock.d.ts +55 -0
  198. package/lib/types/lib/reanimated2/platform-specific/RNRenderer.d.ts +1 -0
  199. package/lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
  200. package/lib/types/lib/reanimated2/utils.d.ts +7 -0
  201. package/lib/types/lib/setAndForwardRef.d.ts +40 -0
  202. package/lib/types/react-native-reanimated-tests.d.ts +1 -0
  203. package/package.json +7 -9
  204. package/plugin.js +26 -32
  205. package/react-native-reanimated.d.ts +39 -30
  206. package/src/Animated.js +0 -9
  207. package/src/ConfigHelper.ts +0 -1
  208. package/src/createAnimatedComponent.tsx +1 -1
  209. package/src/reanimated2/Easing.ts +9 -3
  210. package/src/reanimated2/commonTypes.ts +0 -1
  211. package/src/reanimated2/component/FlatList.tsx +1 -1
  212. package/src/reanimated2/core.ts +0 -47
  213. package/src/reanimated2/globals.d.ts +1 -2
  214. package/src/reanimated2/hook/useAnimatedSensor.ts +1 -3
  215. package/src/reanimated2/interpolateColor.ts +11 -11
  216. package/src/reanimated2/jestUtils.ts +11 -0
  217. package/src/reanimated2/js-reanimated/index.ts +3 -3
  218. package/android/expo/linking.gradle +0 -46
  219. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +0 -12
  220. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +0 -26
  221. package/expo-module.config.json +0 -3
@@ -0,0 +1,55 @@
1
+ declare const NOOP: () => void;
2
+ declare const ID: (t: any) => any;
3
+ declare const IMMEDIATE_CB_INVOCATION: (cb: () => unknown) => unknown;
4
+ declare const ReanimatedV2: {
5
+ useSharedValue: (v: any) => {
6
+ value: any;
7
+ };
8
+ useDerivedValue: (a: any) => {
9
+ value: any;
10
+ };
11
+ useAnimatedScrollHandler: () => () => void;
12
+ useAnimatedGestureHandler: () => () => void;
13
+ useAnimatedStyle: (cb: () => unknown) => unknown;
14
+ useAnimatedRef: () => {
15
+ current: null;
16
+ };
17
+ useAnimatedReaction: () => void;
18
+ useAnimatedProps: (cb: () => unknown) => unknown;
19
+ withTiming: (toValue: any, _: any, cb: any) => any;
20
+ withSpring: (toValue: any, _: any, cb: any) => any;
21
+ withDecay: (_: any, cb: any) => number;
22
+ withDelay: (_: any, animationValue: any) => any;
23
+ withSequence: (..._animations: any[]) => number;
24
+ withRepeat: (animation: any) => any;
25
+ cancelAnimation: () => void;
26
+ measure: () => {
27
+ x: number;
28
+ y: number;
29
+ width: number;
30
+ height: number;
31
+ pageX: number;
32
+ pageY: number;
33
+ };
34
+ Easing: {
35
+ linear: (t: any) => any;
36
+ ease: (t: any) => any;
37
+ quad: (t: any) => any;
38
+ cubic: (t: any) => any;
39
+ poly: (t: any) => any;
40
+ sin: (t: any) => any;
41
+ circle: (t: any) => any;
42
+ exp: (t: any) => any;
43
+ elastic: (t: any) => any;
44
+ back: (t: any) => any;
45
+ bounce: (t: any) => any;
46
+ bezier: () => {
47
+ factory: (t: any) => any;
48
+ };
49
+ bezierFn: (t: any) => any;
50
+ in: (t: any) => any;
51
+ out: (t: any) => any;
52
+ inOut: (t: any) => any;
53
+ };
54
+ runOnJS: (fn: any) => any;
55
+ };
@@ -0,0 +1 @@
1
+ export { default as RNRenderer } from 'react-native/Libraries/Renderer/shims/ReactNative';
@@ -0,0 +1,7 @@
1
+ import { Component } from 'react';
2
+ import { RefObjectFunction } from './hook/commonTypes';
3
+ export interface ComponentCoords {
4
+ x: number;
5
+ y: number;
6
+ }
7
+ export declare function getRelativeCoords(parentRef: RefObjectFunction<Component>, x: number, y: number): ComponentCoords;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * imported from react-native
3
+ */
4
+ import { MutableRefObject } from 'react';
5
+ /**
6
+ * This is a helper function for when a component needs to be able to forward a ref
7
+ * to a child component, but still needs to have access to that component as part of
8
+ * its implementation.
9
+ *
10
+ * Its main use case is in wrappers for native components.
11
+ *
12
+ * Usage:
13
+ *
14
+ * class MyView extends React.Component {
15
+ * _nativeRef = null;
16
+ *
17
+ * _setNativeRef = setAndForwardRef({
18
+ * getForwardedRef: () => this.props.forwardedRef,
19
+ * setLocalRef: ref => {
20
+ * this._nativeRef = ref;
21
+ * },
22
+ * });
23
+ *
24
+ * render() {
25
+ * return <View ref={this._setNativeRef} />;
26
+ * }
27
+ * }
28
+ *
29
+ * const MyViewWithRef = React.forwardRef((props, ref) => (
30
+ * <MyView {...props} forwardedRef={ref} />
31
+ * ));
32
+ *
33
+ * module.exports = MyViewWithRef;
34
+ */
35
+ export declare type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);
36
+ declare function setAndForwardRef<T>({ getForwardedRef, setLocalRef, }: {
37
+ getForwardedRef: ForwardedRef<T>;
38
+ setLocalRef: (ref: T) => void;
39
+ }): (ref: T) => void;
40
+ export default setAndForwardRef;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "2.5.0",
3
+ "version": "2.8.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,10 +18,11 @@
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 && yarn type:generate:remove.js:from-src",
21
+ "type:generate": "yarn type:generate:clean && yarn type:generate:cp-js-src && yarn type:generate:tsc && yarn type:generate:tsc:declaration && 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
+ "type:generate:tsc:declaration": "yarn tsc --project tsconfig.json --pretty --declaration --emitDeclarationOnly --outDir lib/types",
25
26
  "type:generate:remove.ts": "find ./lib -type f -name \"*.ts\" -and -not -name \"*.d.ts\" -delete",
26
27
  "type:generate:remove.tsx": "find ./lib -type f -name \"*.tsx\" -and -not -name \"*.d.ts\" -delete",
27
28
  "type:generate:remove.js:from-src": "find ./src/reanimated2 -type f -name \"*.js\" -delete",
@@ -54,7 +55,6 @@
54
55
  "react-native-reanimated.d.ts",
55
56
  "mock.js",
56
57
  "plugin.js",
57
- "expo-module.config.json",
58
58
  "!__snapshots__",
59
59
  "!*.test.js",
60
60
  "!*.test.js.map"
@@ -75,24 +75,22 @@
75
75
  "homepage": "https://github.com/software-mansion/react-native-reanimated#readme",
76
76
  "dependencies": {
77
77
  "@babel/plugin-transform-object-assign": "^7.16.7",
78
+ "@babel/preset-typescript": "^7.16.7",
78
79
  "@types/invariant": "^2.2.35",
79
80
  "invariant": "^2.2.4",
80
81
  "lodash.isequal": "^4.5.0",
81
- "react-native-screens": "^3.11.1",
82
82
  "setimmediate": "^1.0.5",
83
83
  "string-hash-64": "^1.0.3"
84
84
  },
85
85
  "peerDependencies": {
86
- "@babel/preset-typescript": "*",
86
+ "@babel/core": "^7.0.0-0",
87
87
  "react": "*",
88
- "react-native": "*",
89
- "react-native-gesture-handler": "*"
88
+ "react-native": "*"
90
89
  },
91
90
  "devDependencies": {
92
91
  "@babel/core": "^7.17.2",
93
92
  "@babel/plugin-proposal-class-properties": "^7.16.7",
94
93
  "@babel/preset-env": "^7.16.11",
95
- "@babel/preset-typescript": "^7.16.7",
96
94
  "@react-native-community/bob": "^0.17.1",
97
95
  "@react-native-community/eslint-config": "^0.0.5",
98
96
  "@testing-library/jest-native": "^4.0.4",
@@ -124,7 +122,7 @@
124
122
  "madge": "^5.0.1",
125
123
  "prettier": "^2.5.1",
126
124
  "react": "17.0.2",
127
- "react-native": "0.68.0-rc.2",
125
+ "react-native": "0.68.0",
128
126
  "react-native-codegen": "^0.0.7",
129
127
  "react-native-gesture-handler": "^1.6.1",
130
128
  "react-test-renderer": "17.0.2",
package/plugin.js CHANGED
@@ -87,6 +87,7 @@ const blacklistedFunctions = new Set([
87
87
  'toString',
88
88
  'map',
89
89
  'filter',
90
+ 'findIndex',
90
91
  'forEach',
91
92
  'valueOf',
92
93
  'toPrecision',
@@ -330,7 +331,7 @@ function makeWorkletName(t, fun) {
330
331
  return '_f'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
331
332
  }
332
333
 
333
- function makeWorklet(t, fun, fileName) {
334
+ function makeWorklet(t, fun, state) {
334
335
  // Returns a new FunctionExpression which is a workletized version of provided
335
336
  // FunctionDeclaration, FunctionExpression, ArrowFunctionExpression or ObjectMethod.
336
337
 
@@ -357,7 +358,7 @@ function makeWorklet(t, fun, fileName) {
357
358
  '\n(' + (t.isObjectMethod(fun) ? 'function ' : '') + fun.toString() + '\n)';
358
359
 
359
360
  const transformed = transformSync(code, {
360
- filename: fileName,
361
+ filename: state.file.opts.filename,
361
362
  presets: ['@babel/preset-typescript'],
362
363
  plugins: [
363
364
  '@babel/plugin-transform-shorthand-properties',
@@ -444,11 +445,17 @@ function makeWorklet(t, fun, fileName) {
444
445
  );
445
446
  const workletHash = hash(funString);
446
447
 
448
+ let location = state.file.opts.filename;
449
+ if (state.opts.relativeSourceLocation) {
450
+ const path = require('path');
451
+ location = path.relative(state.cwd, location);
452
+ }
453
+
447
454
  const loc = fun && fun.node && fun.node.loc && fun.node.loc.start;
448
455
  if (loc) {
449
456
  const { line, column } = loc;
450
457
  if (typeof line === 'number' && typeof column === 'number') {
451
- fileName = `${fileName} (${line}:${column})`;
458
+ location = `${location} (${line}:${column})`;
452
459
  }
453
460
  }
454
461
 
@@ -489,7 +496,7 @@ function makeWorklet(t, fun, fileName) {
489
496
  t.identifier('__location'),
490
497
  false
491
498
  ),
492
- t.stringLiteral(fileName)
499
+ t.stringLiteral(location)
493
500
  )
494
501
  ),
495
502
  ];
@@ -510,18 +517,6 @@ function makeWorklet(t, fun, fileName) {
510
517
  );
511
518
  }
512
519
 
513
- statements.push(
514
- t.expressionStatement(
515
- t.callExpression(
516
- t.memberExpression(
517
- t.identifier('global'),
518
- t.identifier('__reanimatedWorkletInit'),
519
- false
520
- ),
521
- [privateFunctionId]
522
- )
523
- )
524
- );
525
520
  statements.push(t.returnStatement(privateFunctionId));
526
521
 
527
522
  const newFun = t.functionExpression(fun.id, [], t.blockStatement(statements));
@@ -529,7 +524,7 @@ function makeWorklet(t, fun, fileName) {
529
524
  return newFun;
530
525
  }
531
526
 
532
- function processWorkletFunction(t, fun, fileName) {
527
+ function processWorkletFunction(t, fun, state) {
533
528
  // Replaces FunctionDeclaration, FunctionExpression or ArrowFunctionExpression
534
529
  // with a workletized version of itself.
535
530
 
@@ -537,7 +532,7 @@ function processWorkletFunction(t, fun, fileName) {
537
532
  return;
538
533
  }
539
534
 
540
- const newFun = makeWorklet(t, fun, fileName);
535
+ const newFun = makeWorklet(t, fun, state);
541
536
 
542
537
  const replacement = t.callExpression(newFun, []);
543
538
 
@@ -557,14 +552,14 @@ function processWorkletFunction(t, fun, fileName) {
557
552
  );
558
553
  }
559
554
 
560
- function processWorkletObjectMethod(t, path, fileName) {
555
+ function processWorkletObjectMethod(t, path, state) {
561
556
  // Replaces ObjectMethod with a workletized version of itself.
562
557
 
563
558
  if (!t.isFunctionParent(path)) {
564
559
  return;
565
560
  }
566
561
 
567
- const newFun = makeWorklet(t, path, fileName);
562
+ const newFun = makeWorklet(t, path, state);
568
563
 
569
564
  const replacement = t.objectProperty(
570
565
  t.identifier(path.node.key.name),
@@ -574,7 +569,7 @@ function processWorkletObjectMethod(t, path, fileName) {
574
569
  path.replaceWith(replacement);
575
570
  }
576
571
 
577
- function processIfWorkletNode(t, fun, fileName) {
572
+ function processIfWorkletNode(t, fun, state) {
578
573
  fun.traverse({
579
574
  DirectiveLiteral(path) {
580
575
  const value = path.node.value;
@@ -592,14 +587,14 @@ function processIfWorkletNode(t, fun, fileName) {
592
587
  directive.value.value === 'worklet'
593
588
  )
594
589
  ) {
595
- processWorkletFunction(t, fun, fileName);
590
+ processWorkletFunction(t, fun, state);
596
591
  }
597
592
  }
598
593
  },
599
594
  });
600
595
  }
601
596
 
602
- function processIfGestureHandlerEventCallbackFunctionNode(t, fun, fileName) {
597
+ function processIfGestureHandlerEventCallbackFunctionNode(t, fun, state) {
603
598
  // Auto-workletizes React Native Gesture Handler callback functions.
604
599
  // Detects `Gesture.Tap().onEnd(<fun>)` or similar, but skips `something.onEnd(<fun>)`.
605
600
  // Supports method chaining as well, e.g. `Gesture.Tap().onStart(<fun1>).onUpdate(<fun2>).onEnd(<fun3>)`.
@@ -652,7 +647,7 @@ function processIfGestureHandlerEventCallbackFunctionNode(t, fun, fileName) {
652
647
  t.isCallExpression(fun.parent) &&
653
648
  isGestureObjectEventCallbackMethod(t, fun.parent.callee)
654
649
  ) {
655
- processWorkletFunction(t, fun, fileName);
650
+ processWorkletFunction(t, fun, state);
656
651
  }
657
652
  }
658
653
 
@@ -708,7 +703,7 @@ function isGestureObject(t, node) {
708
703
  );
709
704
  }
710
705
 
711
- function processWorklets(t, path, fileName) {
706
+ function processWorklets(t, path, state) {
712
707
  const name =
713
708
  path.node.callee.type === 'MemberExpression'
714
709
  ? path.node.callee.property.name
@@ -720,17 +715,17 @@ function processWorklets(t, path, fileName) {
720
715
  const properties = path.get('arguments.0.properties');
721
716
  for (const property of properties) {
722
717
  if (t.isObjectMethod(property)) {
723
- processWorkletObjectMethod(t, property, fileName);
718
+ processWorkletObjectMethod(t, property, state);
724
719
  } else {
725
720
  const value = property.get('value');
726
- processWorkletFunction(t, value, fileName);
721
+ processWorkletFunction(t, value, state);
727
722
  }
728
723
  }
729
724
  } else {
730
725
  const indexes = functionArgsToWorkletize.get(name);
731
726
  if (Array.isArray(indexes)) {
732
727
  indexes.forEach((index) => {
733
- processWorkletFunction(t, path.get(`arguments.${index}`), fileName);
728
+ processWorkletFunction(t, path.get(`arguments.${index}`), state);
734
729
  });
735
730
  }
736
731
  }
@@ -775,14 +770,13 @@ module.exports = function ({ types: t }) {
775
770
  visitor: {
776
771
  CallExpression: {
777
772
  enter(path, state) {
778
- processWorklets(t, path, state.file.opts.filename);
773
+ processWorklets(t, path, state);
779
774
  },
780
775
  },
781
776
  'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression': {
782
777
  enter(path, state) {
783
- const fileName = state.file.opts.filename;
784
- processIfWorkletNode(t, path, fileName);
785
- processIfGestureHandlerEventCallbackFunctionNode(t, path, fileName);
778
+ processIfWorkletNode(t, path, state);
779
+ processIfGestureHandlerEventCallbackFunctionNode(t, path, state);
786
780
  },
787
781
  },
788
782
  },
@@ -7,8 +7,6 @@ declare module 'react-native-reanimated' {
7
7
  ReactNode,
8
8
  Component,
9
9
  RefObject,
10
- ComponentType,
11
- ComponentProps,
12
10
  FunctionComponent,
13
11
  } from 'react';
14
12
  import {
@@ -31,7 +29,6 @@ declare module 'react-native-reanimated' {
31
29
  NativeScrollEvent,
32
30
  NativeSyntheticEvent,
33
31
  ColorValue,
34
- OpaqueColorValue,
35
32
  EasingFunction,
36
33
  } from 'react-native';
37
34
  import {
@@ -39,24 +36,24 @@ declare module 'react-native-reanimated' {
39
36
  PanGestureHandlerGestureEvent,
40
37
  } from 'react-native-gesture-handler';
41
38
 
42
- import('./src/reanimated2/globals');
39
+ import('./lib/reanimated2/globals');
43
40
 
44
41
  export type TimingAnimation =
45
- import('./src/reanimated2/animation/index').TimingAnimation;
42
+ import('./lib/types/lib/reanimated2/animation/index').TimingAnimation;
46
43
  export type SpringAnimation =
47
- import('./src/reanimated2/animation/index').SpringAnimation;
44
+ import('./lib/types/lib/reanimated2/animation/index').SpringAnimation;
48
45
  export type DecayAnimation =
49
- import('./src/reanimated2/animation/index').DecayAnimation;
46
+ import('./lib/types/lib/reanimated2/animation/index').DecayAnimation;
50
47
  export type DelayAnimation =
51
- import('./src/reanimated2/animation/commonTypes').DelayAnimation;
48
+ import('./lib/types/lib/reanimated2/animation/commonTypes').DelayAnimation;
52
49
  export type RepeatAnimation =
53
- import('./src/reanimated2/animation/index').RepeatAnimation;
50
+ import('./lib/types/lib/reanimated2/animation/index').RepeatAnimation;
54
51
  export type SequenceAnimation =
55
- import('./src/reanimated2/animation/index').SequenceAnimation;
52
+ import('./lib/types/lib/reanimated2/animation/index').SequenceAnimation;
56
53
  export type StyleLayoutAnimation =
57
- import('./src/reanimated2/animation/index').StyleLayoutAnimation;
54
+ import('./lib/types/lib/reanimated2/animation/index').StyleLayoutAnimation;
58
55
  export type Animation<T> =
59
- import('./src/reanimated2/commonTypes').Animation<T>;
56
+ import('./lib/types/lib/reanimated2/commonTypes').Animation<T>;
60
57
 
61
58
  namespace Animated {
62
59
  type Nullable<T> = T | null | undefined;
@@ -402,16 +399,16 @@ declare module 'react-native-reanimated' {
402
399
  value: Adaptable<number>,
403
400
  config: InterpolationConfig
404
401
  ): AnimatedNode<number>;
405
- export function interpolateColors(
402
+ export function interpolateColors<T extends string | number>(
406
403
  animationValue: Adaptable<number>,
407
404
  {
408
405
  inputRange,
409
406
  outputColorRange,
410
407
  }: {
411
408
  inputRange: ReadonlyArray<Adaptable<number>>;
412
- outputColorRange: ReadonlyArray<Adaptable<number | string>>;
409
+ outputColorRange: ReadonlyArray<Adaptable<T>>;
413
410
  }
414
- ): AnimatedNode<number | string>;
411
+ ): AnimatedNode<T>;
415
412
  export const max: BinaryOperator;
416
413
  export const min: BinaryOperator;
417
414
 
@@ -501,10 +498,17 @@ declare module 'react-native-reanimated' {
501
498
  interval: number;
502
499
  };
503
500
 
501
+ export type AnimatedSensor = {
502
+ sensor: SensorValue3D | SensorValueRotation | null;
503
+ unregister: () => void;
504
+ isAvailable: boolean;
505
+ config: SensorConfig;
506
+ };
507
+
504
508
  export function useAnimatedSensor(
505
509
  sensorType: SensorType,
506
510
  userConfig?: SensorConfig
507
- );
511
+ ): AnimatedSensor;
508
512
 
509
513
  export interface ExitAnimationsValues {
510
514
  currentOriginX: number;
@@ -602,29 +606,34 @@ declare module 'react-native-reanimated' {
602
606
  restDisplacementThreshold?: number;
603
607
  velocity?: number;
604
608
  }
605
- export function withTiming(
606
- toValue: AnimatableValue,
609
+ export function withTiming<T extends AnimatableValue>(
610
+ toValue: T,
607
611
  userConfig?: WithTimingConfig,
608
612
  callback?: AnimationCallback
609
- ): number;
610
- export function withSpring(
611
- toValue: AnimatableValue,
613
+ ): T;
614
+ export function withSpring<T extends AnimatableValue>(
615
+ toValue: T,
612
616
  userConfig?: WithSpringConfig,
613
617
  callback?: AnimationCallback
614
- ): number;
618
+ ): T;
615
619
  export function withDecay(
616
620
  userConfig: WithDecayConfig,
617
621
  callback?: AnimationCallback
618
622
  ): number;
619
623
  export function cancelAnimation<T>(sharedValue: SharedValue<T>): void;
620
- export function withDelay(delayMS: number, delayedAnimation: number): number;
621
- export function withRepeat(
622
- animation: number,
624
+ export function withDelay<T extends AnimatableValue>(
625
+ delayMS: number,
626
+ delayedAnimation: T
627
+ ): T;
628
+ export function withRepeat<T extends AnimatableValue>(
629
+ animation: T,
623
630
  numberOfReps?: number,
624
631
  reverse?: boolean,
625
632
  callback?: AnimationCallback
626
- ): number;
627
- export function withSequence(...animations: [number, ...number[]]): number;
633
+ ): T;
634
+ export function withSequence<T extends AnimatableValue>(
635
+ ...animations: [T, ...T[]]
636
+ ): T;
628
637
 
629
638
  // reanimated2 functions
630
639
  export function runOnUI<A extends any[], R>(
@@ -645,12 +654,12 @@ declare module 'react-native-reanimated' {
645
654
  fn: (...args: A) => R
646
655
  ): (...args: Parameters<typeof fn>) => R;
647
656
 
648
- export function interpolateColor(
657
+ export function interpolateColor<T extends string | number>(
649
658
  value: number,
650
659
  inputRange: readonly number[],
651
- outputRange: readonly (string | number)[],
660
+ outputRange: readonly T[],
652
661
  colorSpace?: 'RGB' | 'HSV'
653
- ): string | number;
662
+ ): T;
654
663
 
655
664
  export enum ColorSpace {
656
665
  RGB = 0,
package/src/Animated.js CHANGED
@@ -1,4 +1,3 @@
1
- import { LogBox } from 'react-native';
2
1
  import createAnimatedComponent from './createAnimatedComponent';
3
2
  import {
4
3
  addWhitelistedNativeProps,
@@ -21,11 +20,3 @@ const Animated = {
21
20
  export * from './reanimated2';
22
21
  export * from './reanimated1';
23
22
  export default Animated;
24
-
25
- // I think we can ignore this message as long as Gesture Handler doesn't
26
- // try to load the Reanimated module. I figured it should be here instead of
27
- // RNGH because this prevents the message from being displayed for all
28
- // versions of RNGH.
29
- LogBox.ignoreLogs([
30
- 'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
31
- ]);
@@ -78,7 +78,6 @@ let NATIVE_THREAD_PROPS_WHITELIST: Record<string, boolean> = {
78
78
  borderTopLeftRadius: true,
79
79
  borderTopRightRadius: true,
80
80
  borderTopStartRadius: true,
81
- opacity: true,
82
81
  elevation: true,
83
82
  fontSize: true,
84
83
  lineHeight: true,
@@ -161,7 +161,7 @@ interface ComponentRef extends Component {
161
161
  getScrollableNode?: () => ComponentRef;
162
162
  }
163
163
 
164
- interface InitialComponentProps extends Record<string, unknown> {
164
+ export interface InitialComponentProps extends Record<string, unknown> {
165
165
  ref?: Ref<Component>;
166
166
  collapsable?: boolean;
167
167
  }
@@ -109,7 +109,10 @@ function cubic(t: number): number {
109
109
  */
110
110
  function poly(n: number): EasingFn {
111
111
  'worklet';
112
- return (t) => Math.pow(t, n);
112
+ return (t) => {
113
+ 'worklet';
114
+ return Math.pow(t, n);
115
+ };
113
116
  }
114
117
 
115
118
  /**
@@ -171,7 +174,10 @@ function elastic(bounciness = 1): EasingFn {
171
174
  */
172
175
  function back(s = 1.70158): (t: number) => number {
173
176
  'worklet';
174
- return (t) => t * t * ((s + 1) * t - s);
177
+ return (t) => {
178
+ 'worklet';
179
+ return t * t * ((s + 1) * t - s);
180
+ };
175
181
  }
176
182
 
177
183
  /**
@@ -312,7 +318,7 @@ function createChecker(
312
318
  }
313
319
  // @ts-ignore this is implicitly any - TODO
314
320
  const res = worklet.apply(this, arguments);
315
- if (!_WORKLET && res && typeof res === 'function' && res.__worklet) {
321
+ if (!_WORKLET && res && typeof res === 'function' && res.__workletHash) {
316
322
  return createChecker(res, workletName, arguments);
317
323
  }
318
324
  return res;
@@ -51,7 +51,6 @@ export interface WorkletFunction {
51
51
  _closure?: Context;
52
52
  __workletHash?: number;
53
53
  __optimalization?: number;
54
- __worklet?: boolean;
55
54
  }
56
55
 
57
56
  export interface BasicWorkletFunction<T> extends WorkletFunction {
@@ -23,7 +23,7 @@ const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
23
23
  return cellRenderer;
24
24
  };
25
25
 
26
- interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
26
+ export interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
27
27
  itemLayoutAnimation?: ILayoutAnimationBuilder;
28
28
  }
29
29
 
@@ -4,7 +4,6 @@ import { Platform } from 'react-native';
4
4
  import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
5
5
  import {
6
6
  BasicWorkletFunction,
7
- WorkletFunction,
8
7
  ComplexWorkletFunction,
9
8
  SharedValue,
10
9
  AnimationObject,
@@ -14,10 +13,6 @@ import {
14
13
  import { Descriptor } from './hook/commonTypes';
15
14
  import JSReanimated from './js-reanimated/JSReanimated';
16
15
 
17
- global.__reanimatedWorkletInit = function (worklet: WorkletFunction) {
18
- worklet.__worklet = true;
19
- };
20
-
21
16
  if (global._setGlobalConsole === undefined) {
22
17
  // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
23
18
  global._setGlobalConsole = () => {
@@ -74,48 +69,6 @@ export const isConfiguredCheck: () => void = () => {
74
69
  }
75
70
  };
76
71
 
77
- function _toArrayReanimated<T>(object: Iterable<T> | ArrayLike<T> | T[]): T[] {
78
- 'worklet';
79
- if (Array.isArray(object)) {
80
- return object;
81
- }
82
- if (
83
- typeof Symbol !== 'undefined' &&
84
- (typeof Symbol === 'function' ? Symbol.iterator : '@@iterator') in
85
- Object(object)
86
- ) {
87
- return Array.from(object);
88
- }
89
- throw new Error(
90
- 'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
91
- );
92
- }
93
-
94
- function _mergeObjectsReanimated(): unknown {
95
- 'worklet';
96
- // we can't use rest parameters in worklets at the moment
97
- // eslint-disable-next-line prefer-rest-params
98
- const arr = Array.from(arguments);
99
- return Object.assign.apply(null, [arr[0], ...arr.slice(1)]);
100
- }
101
-
102
- global.__reanimatedWorkletInit = function (worklet: WorkletFunction) {
103
- worklet.__worklet = true;
104
-
105
- if (worklet._closure) {
106
- const closure = worklet._closure;
107
- Object.keys(closure).forEach((key) => {
108
- if (key === '_toConsumableArray') {
109
- closure[key] = _toArrayReanimated;
110
- }
111
-
112
- if (key === '_objectSpread') {
113
- closure[key] = _mergeObjectsReanimated;
114
- }
115
- });
116
- }
117
- };
118
-
119
72
  function pushFrame(frame: (timestamp: Timestamp) => void): void {
120
73
  (NativeReanimatedModule as JSReanimated).pushFrame(frame);
121
74
  }