react-native-reanimated 2.5.0 → 2.6.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 (123) hide show
  1. package/RNReanimated.podspec +15 -6
  2. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  3. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  4. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  5. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  6. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  8. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  9. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  10. package/android/.gradle/checksums/checksums.lock +0 -0
  11. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  12. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  13. package/android/build.gradle +13 -23
  14. package/ios/REANodesManager.m +1 -1
  15. package/ios/sensor/ReanimatedSensor.h +4 -0
  16. package/ios/sensor/ReanimatedSensor.m +48 -0
  17. package/ios/sensor/ReanimatedSensorContainer.h +0 -1
  18. package/ios/sensor/ReanimatedSensorContainer.m +0 -1
  19. package/lib/reanimated2/interpolateColor.js +11 -11
  20. package/lib/reanimated2/js-reanimated/index.js +3 -3
  21. package/lib/types/lib/ConfigHelper.d.ts +12 -0
  22. package/lib/types/lib/ReanimatedEventEmitter.d.ts +3 -0
  23. package/lib/types/lib/ReanimatedModule.d.ts +2 -0
  24. package/lib/types/lib/ReanimatedModule.macos.d.ts +2 -0
  25. package/lib/types/lib/ReanimatedModule.native.d.ts +2 -0
  26. package/lib/types/lib/ReanimatedModule.windows.d.ts +2 -0
  27. package/lib/types/lib/ReanimatedModuleCompat.d.ts +14 -0
  28. package/lib/types/lib/createAnimatedComponent.d.ts +33 -0
  29. package/lib/types/lib/reanimated2/Bezier.d.ts +6 -0
  30. package/lib/types/lib/reanimated2/Colors.d.ts +31 -0
  31. package/lib/types/lib/reanimated2/Easing.d.ts +172 -0
  32. package/lib/types/lib/reanimated2/NativeMethods.d.ts +14 -0
  33. package/lib/types/lib/reanimated2/NativeReanimated/NativeReanimated.d.ts +20 -0
  34. package/lib/types/lib/reanimated2/NativeReanimated/index.d.ts +3 -0
  35. package/lib/types/lib/reanimated2/PlatformChecker.d.ts +5 -0
  36. package/lib/types/lib/reanimated2/PropAdapters.d.ts +4 -0
  37. package/lib/types/lib/reanimated2/UpdateProps.d.ts +9 -0
  38. package/lib/types/lib/reanimated2/ViewDescriptorsSet.d.ts +20 -0
  39. package/lib/types/lib/reanimated2/WorkletEventHandler.d.ts +13 -0
  40. package/lib/types/lib/reanimated2/__mocks__/MutableValue.d.ts +5 -0
  41. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.d.ts +13 -0
  42. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.native.d.ts +13 -0
  43. package/lib/types/lib/reanimated2/animation/commonTypes.d.ts +27 -0
  44. package/lib/types/lib/reanimated2/animation/decay.d.ts +19 -0
  45. package/lib/types/lib/reanimated2/animation/delay.d.ts +7 -0
  46. package/lib/types/lib/reanimated2/animation/index.d.ts +9 -0
  47. package/lib/types/lib/reanimated2/animation/repeat.d.ts +12 -0
  48. package/lib/types/lib/reanimated2/animation/sequence.d.ts +7 -0
  49. package/lib/types/lib/reanimated2/animation/spring.d.ts +22 -0
  50. package/lib/types/lib/reanimated2/animation/styleAnimation.d.ts +7 -0
  51. package/lib/types/lib/reanimated2/animation/timing.d.ts +21 -0
  52. package/lib/types/lib/reanimated2/animation/util.d.ts +9 -0
  53. package/lib/types/lib/reanimated2/commonTypes.d.ts +80 -0
  54. package/lib/types/lib/reanimated2/component/FlatList.d.ts +9 -0
  55. package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +8 -0
  56. package/lib/types/lib/reanimated2/component/index.d.ts +9 -0
  57. package/lib/types/lib/reanimated2/core.d.ts +24 -0
  58. package/lib/types/lib/reanimated2/hook/Hooks.d.ts +5 -0
  59. package/lib/types/lib/reanimated2/hook/commonTypes.d.ts +14 -0
  60. package/lib/types/lib/reanimated2/hook/index.d.ts +10 -0
  61. package/lib/types/lib/reanimated2/hook/useAnimatedGestureHandler.d.ts +35 -0
  62. package/lib/types/lib/reanimated2/hook/useAnimatedReaction.d.ts +12 -0
  63. package/lib/types/lib/reanimated2/hook/useAnimatedRef.d.ts +3 -0
  64. package/lib/types/lib/reanimated2/hook/useAnimatedScrollHandler.d.ts +21 -0
  65. package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +20 -0
  66. package/lib/types/lib/reanimated2/hook/useAnimatedStyle.d.ts +11 -0
  67. package/lib/types/lib/reanimated2/hook/useDerivedValue.d.ts +4 -0
  68. package/lib/types/lib/reanimated2/hook/useSharedValue.d.ts +2 -0
  69. package/lib/types/lib/reanimated2/hook/utils.d.ts +28 -0
  70. package/lib/types/lib/reanimated2/index.d.ts +12 -0
  71. package/lib/types/lib/reanimated2/interpolateColor.d.ts +26 -0
  72. package/lib/types/lib/reanimated2/interpolation.d.ts +14 -0
  73. package/lib/types/lib/reanimated2/jestUtils.d.ts +12 -0
  74. package/lib/types/lib/reanimated2/js-reanimated/JSReanimated.d.ts +30 -0
  75. package/lib/types/lib/reanimated2/js-reanimated/Mapper.d.ts +14 -0
  76. package/lib/types/lib/reanimated2/js-reanimated/MapperRegistry.d.ts +14 -0
  77. package/lib/types/lib/reanimated2/js-reanimated/MutableValue.d.ts +14 -0
  78. package/lib/types/lib/reanimated2/js-reanimated/commonTypes.d.ts +44 -0
  79. package/lib/types/lib/reanimated2/js-reanimated/index.d.ts +15 -0
  80. package/lib/types/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.d.ts +1 -0
  81. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +22 -0
  82. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +38 -0
  83. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +25 -0
  84. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +77 -0
  85. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/index.d.ts +4 -0
  86. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +62 -0
  87. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Default.d.ts +4 -0
  88. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +42 -0
  89. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +50 -0
  90. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +18 -0
  91. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +10 -0
  92. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +18 -0
  93. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +34 -0
  94. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +34 -0
  95. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +18 -0
  96. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +66 -0
  97. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/index.d.ts +10 -0
  98. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +19 -0
  99. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +13 -0
  100. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +6 -0
  101. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +6 -0
  102. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +7 -0
  103. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +9 -0
  104. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/index.d.ts +6 -0
  105. package/lib/types/lib/reanimated2/layoutReanimation/index.d.ts +4 -0
  106. package/lib/types/lib/reanimated2/mock.d.ts +55 -0
  107. package/lib/types/lib/reanimated2/platform-specific/RNRenderer.d.ts +1 -0
  108. package/lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
  109. package/lib/types/lib/reanimated2/utils.d.ts +7 -0
  110. package/lib/types/lib/setAndForwardRef.d.ts +40 -0
  111. package/lib/types/react-native-reanimated-tests.d.ts +1 -0
  112. package/package.json +4 -4
  113. package/plugin.js +1 -0
  114. package/react-native-reanimated.d.ts +26 -29
  115. package/src/createAnimatedComponent.tsx +1 -1
  116. package/src/reanimated2/component/FlatList.tsx +1 -1
  117. package/src/reanimated2/interpolateColor.ts +11 -11
  118. package/src/reanimated2/jestUtils.ts +11 -0
  119. package/src/reanimated2/js-reanimated/index.ts +3 -3
  120. package/android/expo/linking.gradle +0 -46
  121. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +0 -12
  122. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +0 -26
  123. package/expo-module.config.json +0 -3
@@ -0,0 +1,66 @@
1
+ import { IEntryExitAnimationBuilder, EntryExitAnimationFunction, EntryAnimationsValues, ExitAnimationsValues, AnimationConfigFunction, IEntryAnimationBuilder, IExitAnimationBuilder } from '../animationBuilder/commonTypes';
2
+ import { ComplexAnimationBuilder } from '../animationBuilder';
3
+ export declare class ZoomIn extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
4
+ static createInstance(): ZoomIn;
5
+ build: () => EntryExitAnimationFunction;
6
+ }
7
+ export declare class ZoomInRotate extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
8
+ static createInstance(): ZoomInRotate;
9
+ build: () => EntryExitAnimationFunction;
10
+ }
11
+ export declare class ZoomInLeft extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
12
+ static createInstance(): ZoomInLeft;
13
+ build: () => EntryExitAnimationFunction;
14
+ }
15
+ export declare class ZoomInRight extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
16
+ static createInstance(): ZoomInRight;
17
+ build: () => EntryExitAnimationFunction;
18
+ }
19
+ export declare class ZoomInUp extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
20
+ static createInstance(): ZoomInUp;
21
+ build: () => EntryExitAnimationFunction;
22
+ }
23
+ export declare class ZoomInDown extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
24
+ static createInstance(): ZoomInDown;
25
+ build: () => EntryExitAnimationFunction;
26
+ }
27
+ export declare class ZoomInEasyUp extends ComplexAnimationBuilder implements IEntryAnimationBuilder {
28
+ static createInstance(): ZoomInEasyUp;
29
+ build: () => AnimationConfigFunction<EntryAnimationsValues>;
30
+ }
31
+ export declare class ZoomInEasyDown extends ComplexAnimationBuilder implements IEntryAnimationBuilder {
32
+ static createInstance(): ZoomInEasyDown;
33
+ build: () => AnimationConfigFunction<EntryAnimationsValues>;
34
+ }
35
+ export declare class ZoomOut extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
36
+ static createInstance(): ZoomOut;
37
+ build: () => EntryExitAnimationFunction;
38
+ }
39
+ export declare class ZoomOutRotate extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
40
+ static createInstance(): ZoomOutRotate;
41
+ build: () => EntryExitAnimationFunction;
42
+ }
43
+ export declare class ZoomOutLeft extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
44
+ static createInstance(): ZoomOutLeft;
45
+ build: () => EntryExitAnimationFunction;
46
+ }
47
+ export declare class ZoomOutRight extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
48
+ static createInstance(): ZoomOutRight;
49
+ build: () => EntryExitAnimationFunction;
50
+ }
51
+ export declare class ZoomOutUp extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
52
+ static createInstance(): ZoomOutUp;
53
+ build: () => EntryExitAnimationFunction;
54
+ }
55
+ export declare class ZoomOutDown extends ComplexAnimationBuilder implements IEntryExitAnimationBuilder {
56
+ static createInstance(): ZoomOutDown;
57
+ build: () => EntryExitAnimationFunction;
58
+ }
59
+ export declare class ZoomOutEasyUp extends ComplexAnimationBuilder implements IExitAnimationBuilder {
60
+ static createInstance(): ZoomOutEasyUp;
61
+ build: () => AnimationConfigFunction<ExitAnimationsValues>;
62
+ }
63
+ export declare class ZoomOutEasyDown extends ComplexAnimationBuilder implements IExitAnimationBuilder {
64
+ static createInstance(): ZoomOutEasyDown;
65
+ build: () => AnimationConfigFunction<ExitAnimationsValues>;
66
+ }
@@ -0,0 +1,10 @@
1
+ export * from './Flip';
2
+ export * from './Stretch';
3
+ export * from './Fade';
4
+ export * from './Slide';
5
+ export * from './Zoom';
6
+ export * from './Bounce';
7
+ export * from './Lightspeed';
8
+ export * from './Pinwheel';
9
+ export * from './Rotate';
10
+ export * from './Roll';
@@ -0,0 +1,19 @@
1
+ import { ILayoutAnimationBuilder, LayoutAnimationFunction } from '../animationBuilder/commonTypes';
2
+ import { BaseAnimationBuilder } from '../animationBuilder';
3
+ import { EasingFn } from '../../Easing';
4
+ export declare class CurvedTransition extends BaseAnimationBuilder implements ILayoutAnimationBuilder {
5
+ easingXV: EasingFn;
6
+ easingYV: EasingFn;
7
+ easingWidthV: EasingFn;
8
+ easingHeightV: EasingFn;
9
+ static createInstance(): CurvedTransition;
10
+ static easingX(easing: EasingFn): CurvedTransition;
11
+ easingX(easing: EasingFn): CurvedTransition;
12
+ static easingY(easing: EasingFn): CurvedTransition;
13
+ easingY(easing: EasingFn): CurvedTransition;
14
+ static easingWidth(easing: EasingFn): CurvedTransition;
15
+ easingWidth(easing: EasingFn): CurvedTransition;
16
+ static easingHeight(easing: EasingFn): CurvedTransition;
17
+ easingHeight(easing: EasingFn): CurvedTransition;
18
+ build: () => LayoutAnimationFunction;
19
+ }
@@ -0,0 +1,13 @@
1
+ import { ILayoutAnimationBuilder, LayoutAnimationFunction } from '../animationBuilder/commonTypes';
2
+ import { BaseAnimationBuilder } from '../animationBuilder';
3
+ export declare class EntryExitTransition extends BaseAnimationBuilder implements ILayoutAnimationBuilder {
4
+ enteringV: BaseAnimationBuilder | typeof BaseAnimationBuilder;
5
+ exitingV: BaseAnimationBuilder | typeof BaseAnimationBuilder;
6
+ static createInstance(): EntryExitTransition;
7
+ static entering(animation: BaseAnimationBuilder | typeof BaseAnimationBuilder): EntryExitTransition;
8
+ entering(animation: BaseAnimationBuilder | typeof BaseAnimationBuilder): EntryExitTransition;
9
+ static exiting(animation: BaseAnimationBuilder | typeof BaseAnimationBuilder): EntryExitTransition;
10
+ exiting(animation: BaseAnimationBuilder | typeof BaseAnimationBuilder): EntryExitTransition;
11
+ build: () => LayoutAnimationFunction;
12
+ }
13
+ export declare function combineTransition(exiting: BaseAnimationBuilder | typeof BaseAnimationBuilder, entering: BaseAnimationBuilder | typeof BaseAnimationBuilder): EntryExitTransition;
@@ -0,0 +1,6 @@
1
+ import { ILayoutAnimationBuilder, LayoutAnimationFunction } from '../animationBuilder/commonTypes';
2
+ import { BaseAnimationBuilder } from '../animationBuilder';
3
+ export declare class FadingTransition extends BaseAnimationBuilder implements ILayoutAnimationBuilder {
4
+ static createInstance(): FadingTransition;
5
+ build: () => LayoutAnimationFunction;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { ILayoutAnimationBuilder, LayoutAnimationFunction } from '../animationBuilder/commonTypes';
2
+ import { BaseAnimationBuilder } from '../animationBuilder';
3
+ export declare class JumpingTransition extends BaseAnimationBuilder implements ILayoutAnimationBuilder {
4
+ static createInstance(): JumpingTransition;
5
+ build: () => LayoutAnimationFunction;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { ComplexAnimationBuilder } from '../animationBuilder/ComplexAnimationBuilder';
2
+ import { ILayoutAnimationBuilder, LayoutAnimationFunction } from '../animationBuilder/commonTypes';
3
+ export declare class LinearTransition extends ComplexAnimationBuilder implements ILayoutAnimationBuilder {
4
+ static createInstance(): LinearTransition;
5
+ build: () => LayoutAnimationFunction;
6
+ }
7
+ export declare const Layout: typeof LinearTransition;
@@ -0,0 +1,9 @@
1
+ import { ILayoutAnimationBuilder, LayoutAnimationFunction } from '../animationBuilder/commonTypes';
2
+ import { BaseAnimationBuilder } from '../animationBuilder';
3
+ export declare class SequencedTransition extends BaseAnimationBuilder implements ILayoutAnimationBuilder {
4
+ reversed: boolean;
5
+ static createInstance(): SequencedTransition;
6
+ static reverse(): SequencedTransition;
7
+ reverse(): SequencedTransition;
8
+ build: () => LayoutAnimationFunction;
9
+ }
@@ -0,0 +1,6 @@
1
+ export * from './LinearTransition';
2
+ export * from './FadingTransition';
3
+ export * from './SequencedTransition';
4
+ export * from './JumpingTransition';
5
+ export * from './CurvedTransition';
6
+ export * from './EntryExitTransition';
@@ -0,0 +1,4 @@
1
+ import './LayoutAnimationRepository';
2
+ export * from './animationBuilder';
3
+ export * from './defaultAnimations';
4
+ export * from './defaultTransitions';
@@ -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.6.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"
@@ -124,7 +124,7 @@
124
124
  "madge": "^5.0.1",
125
125
  "prettier": "^2.5.1",
126
126
  "react": "17.0.2",
127
- "react-native": "0.68.0-rc.2",
127
+ "react-native": "0.68.0",
128
128
  "react-native-codegen": "^0.0.7",
129
129
  "react-native-gesture-handler": "^1.6.1",
130
130
  "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',
@@ -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
 
@@ -602,29 +599,29 @@ declare module 'react-native-reanimated' {
602
599
  restDisplacementThreshold?: number;
603
600
  velocity?: number;
604
601
  }
605
- export function withTiming(
606
- toValue: AnimatableValue,
602
+ export function withTiming<T extends AnimatableValue>(
603
+ toValue: T,
607
604
  userConfig?: WithTimingConfig,
608
605
  callback?: AnimationCallback
609
- ): number;
610
- export function withSpring(
611
- toValue: AnimatableValue,
606
+ ): T;
607
+ export function withSpring<T extends AnimatableValue>(
608
+ toValue: T,
612
609
  userConfig?: WithSpringConfig,
613
610
  callback?: AnimationCallback
614
- ): number;
611
+ ): T;
615
612
  export function withDecay(
616
613
  userConfig: WithDecayConfig,
617
614
  callback?: AnimationCallback
618
615
  ): number;
619
616
  export function cancelAnimation<T>(sharedValue: SharedValue<T>): void;
620
- export function withDelay(delayMS: number, delayedAnimation: number): number;
621
- export function withRepeat(
622
- animation: number,
617
+ export function withDelay<T extends AnimatableValue>(delayMS: number, delayedAnimation: T): T;
618
+ export function withRepeat<T extends AnimatableValue>(
619
+ animation: T,
623
620
  numberOfReps?: number,
624
621
  reverse?: boolean,
625
622
  callback?: AnimationCallback
626
- ): number;
627
- export function withSequence(...animations: [number, ...number[]]): number;
623
+ ): T;
624
+ export function withSequence<T extends AnimatableValue>(...animations: [T, ...T[]]): T;
628
625
 
629
626
  // reanimated2 functions
630
627
  export function runOnUI<A extends any[], R>(
@@ -645,12 +642,12 @@ declare module 'react-native-reanimated' {
645
642
  fn: (...args: A) => R
646
643
  ): (...args: Parameters<typeof fn>) => R;
647
644
 
648
- export function interpolateColor(
645
+ export function interpolateColor<T extends string | number>(
649
646
  value: number,
650
647
  inputRange: readonly number[],
651
- outputRange: readonly (string | number)[],
648
+ outputRange: readonly T[],
652
649
  colorSpace?: 'RGB' | 'HSV'
653
- ): string | number;
650
+ ): T;
654
651
 
655
652
  export enum ColorSpace {
656
653
  RGB = 0,
@@ -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
  }
@@ -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
 
@@ -58,13 +58,13 @@ const getInterpolateRGB = (
58
58
  const a = [];
59
59
  for (let i = 0; i < colors.length; ++i) {
60
60
  const color = colors[i];
61
- const proocessedColor = processColor(color);
61
+ const processedColor = processColor(color);
62
62
  // explicit check in case if processedColor is 0
63
- if (proocessedColor !== null && proocessedColor !== undefined) {
64
- r.push(red(proocessedColor));
65
- g.push(green(proocessedColor));
66
- b.push(blue(proocessedColor));
67
- a.push(opacity(proocessedColor));
63
+ if (processedColor !== null && processedColor !== undefined) {
64
+ r.push(red(processedColor));
65
+ g.push(green(processedColor));
66
+ b.push(blue(processedColor));
67
+ a.push(opacity(processedColor));
68
68
  }
69
69
  }
70
70
  return { r, g, b, a };
@@ -85,11 +85,11 @@ const getInterpolateHSV = (
85
85
  const v = [];
86
86
  for (let i = 0; i < colors.length; ++i) {
87
87
  const color = colors[i];
88
- const proocessedColor = RGBtoHSV(processColor(color) as any);
89
- if (proocessedColor) {
90
- h.push(proocessedColor.h);
91
- s.push(proocessedColor.s);
92
- v.push(proocessedColor.v);
88
+ const processedColor = RGBtoHSV(processColor(color) as any);
89
+ if (processedColor) {
90
+ h.push(processedColor.h);
91
+ s.push(processedColor.s);
92
+ v.push(processedColor.v);
93
93
  }
94
94
  }
95
95
  return { h, s, v };
@@ -2,6 +2,17 @@
2
2
  // @ts-nocheck
3
3
  import { jestResetJsReanimatedModule } from './core';
4
4
 
5
+ declare global {
6
+ // eslint-disable-next-line @typescript-eslint/no-namespace
7
+ namespace jest {
8
+ interface Matchers<R> {
9
+ toHaveAnimatedStyle(
10
+ style: Record<string, unknown>[] | Record<string, unknown>
11
+ ): R;
12
+ }
13
+ }
14
+ }
15
+
5
16
  let config = {
6
17
  fps: 60,
7
18
  };
@@ -20,7 +20,7 @@ if (shouldBeUseWeb()) {
20
20
  };
21
21
  global._measure = () => {
22
22
  console.warn(
23
- "[Reanimated] You can't use 'measue' method with Chrome Debugger or with web version"
23
+ "[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
24
24
  );
25
25
  return {
26
26
  x: 0,
@@ -33,12 +33,12 @@ if (shouldBeUseWeb()) {
33
33
  };
34
34
  global._scrollTo = () => {
35
35
  console.warn(
36
- "[Reanimated] You can't use 'scrollTo' method with Chrome Debugger or with web version"
36
+ "[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version"
37
37
  );
38
38
  };
39
39
  global._setGestureState = () => {
40
40
  console.warn(
41
- "[Reanimated] You can't use 'setGestureState' method with Chrome Debugger or with web version"
41
+ "[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version"
42
42
  );
43
43
  };
44
44
  }
@@ -1,46 +0,0 @@
1
- def isExpoLinked = false
2
- rootProject.getSubprojects().forEach({ project ->
3
- if (project.plugins.hasPlugin("com.android.application")) {
4
- if (project.configurations.implementation.getDependencies().find { dep -> dep.name == "expo" }) {
5
- isExpoLinked = true
6
- }
7
- }
8
- })
9
-
10
- def safeExtGet(prop, fallback) {
11
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
12
- }
13
-
14
- if (isExpoLinked) {
15
- apply plugin: 'com.android.library'
16
-
17
- android {
18
- // Disable aar bundling to fix the error when running `gradle assembleRelease` over `gradle :app:assembleRelease`
19
- // which will throw `Direct local .aar file dependencies are not supported when building an AAR.`
20
- tasks.whenTaskAdded { task ->
21
- if (['bundleDebugAar', 'bundleReleaseAar'].contains(task.name)) {
22
- task.enabled = false
23
- }
24
- }
25
-
26
- compileSdkVersion safeExtGet('compileSdkVersion', 30)
27
-
28
- sourceSets {
29
- main.manifest.srcFile 'src/AndroidManifest.xml'
30
- main.java.srcDirs = [ 'expo/src/main/java' ]
31
- }
32
-
33
- libraryVariants.all {
34
- generateBuildConfigProvider?.get()?.enabled = false
35
- }
36
- }
37
-
38
- dependencies {
39
- implementation 'com.facebook.react:react-native:+'
40
- implementation project(':expo-modules-core')
41
-
42
- project.configurations.default.artifacts.each { artifact ->
43
- api files(artifact.file)
44
- }
45
- }
46
- }
@@ -1,12 +0,0 @@
1
- package com.swmansion.reanimated;
2
-
3
- import com.facebook.react.bridge.JavaScriptContextHolder;
4
- import com.facebook.react.bridge.ReactApplicationContext;
5
-
6
- public class EXReanimatedAdapter {
7
- public static void registerJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext) {
8
- NodesManager nodesManager =
9
- reactApplicationContext.getNativeModule(ReanimatedModule.class).getNodesManager();
10
- nodesManager.initWithContext(reactApplicationContext);
11
- }
12
- }
@@ -1,26 +0,0 @@
1
- package expo.modules.adapters.reanimated;
2
-
3
- import android.content.Context;
4
-
5
- import com.facebook.react.bridge.JavaScriptContextHolder;
6
- import com.facebook.react.bridge.ReactApplicationContext;
7
- import com.swmansion.reanimated.EXReanimatedAdapter;
8
-
9
- import java.util.Collections;
10
- import java.util.List;
11
-
12
- import expo.modules.core.interfaces.Package;
13
- import expo.modules.core.interfaces.ReactNativeHostHandler;
14
-
15
- public class EXReanimatedPackage implements Package {
16
- @Override
17
- public List<? extends ReactNativeHostHandler> createReactNativeHostHandlers(Context context) {
18
- final ReactNativeHostHandler handler = new ReactNativeHostHandler() {
19
- @Override
20
- public void onRegisterJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext, boolean useDeveloperSupport) {
21
- EXReanimatedAdapter.registerJSIModules(reactApplicationContext, jsContext);
22
- }
23
- };
24
- return Collections.singletonList(handler);
25
- }
26
- }
@@ -1,3 +0,0 @@
1
- {
2
- "platforms": ["android"]
3
- }