react-native-reanimated 3.4.0 → 3.4.2

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 (148) hide show
  1. package/lib/module/Animated.js +60 -1
  2. package/lib/module/Animated.js.map +1 -1
  3. package/lib/module/createAnimatedComponent.js.map +1 -1
  4. package/lib/module/reanimated2/Easing.js +8 -0
  5. package/lib/module/reanimated2/Easing.js.map +1 -1
  6. package/lib/module/reanimated2/UpdateProps.js +2 -2
  7. package/lib/module/reanimated2/UpdateProps.js.map +1 -1
  8. package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
  9. package/lib/module/reanimated2/animation/decay.js.map +1 -1
  10. package/lib/module/reanimated2/animation/index.js +1 -1
  11. package/lib/module/reanimated2/animation/index.js.map +1 -1
  12. package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
  13. package/lib/module/reanimated2/animation/styleAnimation.js +2 -2
  14. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  15. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  16. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +6 -0
  17. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
  18. package/lib/module/reanimated2/animation/util.js +4 -19
  19. package/lib/module/reanimated2/animation/util.js.map +1 -1
  20. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  21. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  22. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  23. package/lib/module/reanimated2/core.js +16 -0
  24. package/lib/module/reanimated2/core.js.map +1 -1
  25. package/lib/module/reanimated2/fabricUtils.js +3 -1
  26. package/lib/module/reanimated2/fabricUtils.js.map +1 -1
  27. package/lib/module/reanimated2/globals.d.js.map +1 -1
  28. package/lib/module/reanimated2/helperTypes.js.map +1 -1
  29. package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
  30. package/lib/module/reanimated2/hook/index.js.map +1 -1
  31. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -1
  32. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  33. package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
  34. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  35. package/lib/module/reanimated2/hook/useAnimatedStyle.js +1 -1
  36. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  37. package/lib/module/reanimated2/hook/utils.js +2 -27
  38. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  39. package/lib/module/reanimated2/index.js.map +1 -1
  40. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  41. package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
  42. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  43. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  44. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  45. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  46. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  47. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  48. package/lib/module/reanimated2/mappers.js +1 -1
  49. package/lib/module/reanimated2/mappers.js.map +1 -1
  50. package/lib/module/reanimated2/mock.js +26 -0
  51. package/lib/module/reanimated2/mock.js.map +1 -1
  52. package/lib/module/reanimated2/mutables.js +0 -1
  53. package/lib/module/reanimated2/mutables.js.map +1 -1
  54. package/lib/module/reanimated2/platform-specific/checkCppVersion.js +3 -0
  55. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
  56. package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
  57. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
  58. package/lib/module/reanimated2/valueSetter.js +0 -1
  59. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  60. package/lib/module/setAndForwardRef.js.map +1 -1
  61. package/lib/typescript/Animated.d.ts +68 -3
  62. package/lib/typescript/createAnimatedComponent.d.ts +1 -26
  63. package/lib/typescript/reanimated2/Easing.d.ts +17 -9
  64. package/lib/typescript/reanimated2/UpdateProps.d.ts +5 -5
  65. package/lib/typescript/reanimated2/animation/commonTypes.d.ts +4 -3
  66. package/lib/typescript/reanimated2/animation/decay.d.ts +2 -4
  67. package/lib/typescript/reanimated2/animation/index.d.ts +3 -3
  68. package/lib/typescript/reanimated2/animation/springUtils.d.ts +1 -0
  69. package/lib/typescript/reanimated2/animation/styleAnimation.d.ts +2 -6
  70. package/lib/typescript/reanimated2/animation/timing.d.ts +4 -7
  71. package/lib/typescript/reanimated2/animation/transformationMatrix/matrixUtils.d.ts +1 -1
  72. package/lib/typescript/reanimated2/animation/util.d.ts +2 -4
  73. package/lib/typescript/reanimated2/commonTypes.d.ts +0 -4
  74. package/lib/typescript/reanimated2/component/FlatList.d.ts +2 -1
  75. package/lib/typescript/reanimated2/component/ScrollView.d.ts +1 -1
  76. package/lib/typescript/reanimated2/core.d.ts +12 -0
  77. package/lib/typescript/reanimated2/helperTypes.d.ts +11 -7
  78. package/lib/typescript/reanimated2/hook/commonTypes.d.ts +2 -2
  79. package/lib/typescript/reanimated2/hook/index.d.ts +1 -1
  80. package/lib/typescript/reanimated2/hook/useAnimatedGestureHandler.d.ts +2 -2
  81. package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +4 -4
  82. package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +4 -5
  83. package/lib/typescript/reanimated2/hook/utils.d.ts +3 -11
  84. package/lib/typescript/reanimated2/index.d.ts +3 -1
  85. package/lib/typescript/reanimated2/interpolateColor.d.ts +2 -3
  86. package/lib/typescript/reanimated2/js-reanimated/commonTypes.d.ts +1 -43
  87. package/lib/typescript/reanimated2/js-reanimated/index.d.ts +3 -2
  88. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +4 -4
  89. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -11
  90. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +3 -3
  91. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +13 -13
  92. package/lib/typescript/reanimated2/layoutReanimation/index.d.ts +1 -0
  93. package/lib/typescript/reanimated2/mappers.d.ts +0 -12
  94. package/lib/typescript/reanimated2/mock.d.ts +1 -76
  95. package/lib/typescript/reanimated2/mutables.d.ts +0 -1
  96. package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
  97. package/lib/typescript/reanimated2/valueSetter.d.ts +0 -1
  98. package/lib/typescript/setAndForwardRef.d.ts +1 -1
  99. package/package.json +3 -1
  100. package/src/Animated.ts +80 -6
  101. package/src/createAnimatedComponent.tsx +2 -2
  102. package/src/reanimated2/Easing.ts +18 -8
  103. package/src/reanimated2/UpdateProps.ts +13 -17
  104. package/src/reanimated2/animation/commonTypes.ts +3 -3
  105. package/src/reanimated2/animation/decay.ts +3 -1
  106. package/src/reanimated2/animation/index.ts +3 -3
  107. package/src/reanimated2/animation/springUtils.ts +2 -0
  108. package/src/reanimated2/animation/styleAnimation.ts +5 -5
  109. package/src/reanimated2/animation/timing.ts +6 -4
  110. package/src/reanimated2/animation/transformationMatrix/matrixUtils.tsx +4 -1
  111. package/src/reanimated2/animation/util.ts +5 -29
  112. package/src/reanimated2/commonTypes.ts +0 -25
  113. package/src/reanimated2/component/FlatList.tsx +3 -1
  114. package/src/reanimated2/component/ScrollView.tsx +1 -1
  115. package/src/reanimated2/core.ts +16 -0
  116. package/src/reanimated2/fabricUtils.ts +1 -0
  117. package/src/reanimated2/globals.d.ts +3 -3
  118. package/src/reanimated2/helperTypes.ts +17 -7
  119. package/src/reanimated2/hook/commonTypes.ts +2 -3
  120. package/src/reanimated2/hook/index.ts +4 -1
  121. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +2 -2
  122. package/src/reanimated2/hook/useAnimatedRef.ts +13 -10
  123. package/src/reanimated2/hook/useAnimatedStyle.ts +27 -26
  124. package/src/reanimated2/hook/utils.ts +5 -31
  125. package/src/reanimated2/index.ts +13 -1
  126. package/src/reanimated2/interpolateColor.ts +2 -2
  127. package/src/reanimated2/js-reanimated/commonTypes.ts +3 -3
  128. package/src/reanimated2/js-reanimated/index.ts +4 -3
  129. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -4
  130. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +5 -5
  131. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -3
  132. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -13
  133. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  134. package/src/reanimated2/mappers.ts +2 -2
  135. package/src/reanimated2/mock.ts +27 -0
  136. package/src/reanimated2/mutables.ts +0 -1
  137. package/src/reanimated2/platform-specific/checkCppVersion.ts +2 -0
  138. package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
  139. package/src/reanimated2/valueSetter.ts +0 -1
  140. package/src/setAndForwardRef.ts +1 -1
  141. package/lib/module/reanimated2/js-reanimated/Mapper.js +0 -69
  142. package/lib/module/reanimated2/js-reanimated/Mapper.js.map +0 -1
  143. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +0 -109
  144. package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +0 -1
  145. package/lib/typescript/reanimated2/js-reanimated/Mapper.d.ts +0 -14
  146. package/lib/typescript/reanimated2/js-reanimated/MapperRegistry.d.ts +0 -14
  147. package/src/reanimated2/js-reanimated/Mapper.ts +0 -94
  148. package/src/reanimated2/js-reanimated/MapperRegistry.ts +0 -133
@@ -1,4 +1,5 @@
1
- import type { AnimatedStyle, Context, NestedObjectValues, WorkletFunction, AnimationObject } from '../commonTypes';
1
+ import type { Context, NestedObjectValues, WorkletFunction, AnimationObject } from '../commonTypes';
2
+ import type { AnimatedStyle } from '../helperTypes';
2
3
  import type { DependencyList } from './commonTypes';
3
4
  import type { NativeSyntheticEvent } from 'react-native';
4
5
  interface Handler<T, TContext extends Context> extends WorkletFunction {
@@ -7,11 +8,6 @@ interface Handler<T, TContext extends Context> extends WorkletFunction {
7
8
  interface Handlers<T, TContext extends Context> {
8
9
  [key: string]: Handler<T, TContext> | undefined;
9
10
  }
10
- export interface UseHandlerContext<TContext extends Context> {
11
- context: TContext;
12
- doDependenciesDiffer: boolean;
13
- useWeb: boolean;
14
- }
15
11
  type useEventType = <T extends object>(handler: (e: T) => void, eventNames?: string[], rebuild?: boolean) => (e: NativeSyntheticEvent<T>) => void;
16
12
  export declare const useEvent: useEventType;
17
13
  type useHandlerType = <T, TContext extends Context = Record<string, never>>(handlers: Handlers<T, TContext>, deps?: DependencyList) => {
@@ -21,11 +17,7 @@ type useHandlerType = <T, TContext extends Context = Record<string, never>>(hand
21
17
  };
22
18
  export declare const useHandler: useHandlerType;
23
19
  export declare function buildWorkletsHash(handlers: Record<string, WorkletFunction> | Array<WorkletFunction>): string;
24
- export declare function buildDependencies(dependencies: DependencyList, handlers: Record<string, WorkletFunction | undefined>): Array<unknown>;
25
- export declare function areDependenciesEqual(nextDeps: DependencyList, prevDeps: DependencyList): boolean;
26
- export declare function hasColorProps(updates: AnimatedStyle): boolean;
27
- export declare function parseColors(updates: AnimatedStyle): void;
28
20
  export declare function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean;
29
21
  export declare function shallowEqual(a: any, b: any): boolean;
30
- export declare const validateAnimatedStyles: (styles: AnimatedStyle) => void;
22
+ export declare const validateAnimatedStyles: (styles: AnimatedStyle<any>) => void;
31
23
  export {};
@@ -14,4 +14,6 @@ export * from './commonTypes';
14
14
  export * from './frameCallback';
15
15
  export * from './pluginUtils';
16
16
  export * from './jestUtils';
17
- export type { AnimateProps } from './helperTypes';
17
+ export type { Adaptable, AdaptTransforms, AnimateProps, AnimatedProps, AnimatedTransform, TransformStyleTypes, AnimateStyle, AnimatedStyle, StylesOrDefault, } from './helperTypes';
18
+ export type { AnimatedScrollViewProps } from './component/ScrollView';
19
+ export type { FlatListPropsWithLayout } from './component/FlatList';
@@ -8,13 +8,13 @@ export type InterpolationOptions = {
8
8
  gamma?: number;
9
9
  useCorrectedHSVInterpolation?: boolean;
10
10
  };
11
- interface InterpolateRGB {
11
+ export interface InterpolateRGB {
12
12
  r: number[];
13
13
  g: number[];
14
14
  b: number[];
15
15
  a: number[];
16
16
  }
17
- interface InterpolateHSV {
17
+ export interface InterpolateHSV {
18
18
  h: number[];
19
19
  s: number[];
20
20
  v: number[];
@@ -35,4 +35,3 @@ export interface InterpolateConfig {
35
35
  }
36
36
  export declare function useInterpolateConfig(inputRange: readonly number[], outputRange: readonly (string | number)[], colorSpace?: ColorSpace, options?: InterpolationOptions): SharedValue<InterpolateConfig>;
37
37
  export declare const interpolateSharableColor: (value: number, interpolateConfig: SharedValue<InterpolateConfig>) => string | number;
38
- export {};
@@ -1,43 +1 @@
1
- import type { Timestamp, NestedObjectValues } from '../commonTypes';
2
- import type MutableValue from './MutableValue';
3
- export interface Mapper<T> {
4
- MAPPER_ID?: number;
5
- id: number;
6
- inputs: MutableValue<T>[];
7
- outputs: MutableValue<T>[];
8
- mapper: () => void;
9
- dirty: boolean;
10
- execute(): void;
11
- extractMutablesFromArray<T>(array: NestedObjectValues<MutableValue<T>>): MutableValue<T>[];
12
- }
13
- export interface MapperRegistry<T> {
14
- sortedMappers: Mapper<T>[];
15
- mappers: Map<number, Mapper<T>>;
16
- _module: JSReanimated;
17
- updatedSinceLastExecute: boolean;
18
- startMapper(mapper: Mapper<T>): number;
19
- stopMapper(id: number): void;
20
- execute(): void;
21
- updateOrder(): void;
22
- }
23
- export interface JSReanimated {
24
- _valueSetter?: <T>(value: T) => void;
25
- _renderRequested: boolean;
26
- _mapperRegistry: MapperRegistry<any>;
27
- _frames: ((timestamp: Timestamp) => void)[];
28
- timeProvider: {
29
- now: () => number;
30
- };
31
- pushFrame(frame: (timestamp: Timestamp) => void): void;
32
- maybeRequestRender(): void;
33
- _onRender(timestampMs: number): void;
34
- installCoreFunctions(valueSetter: <T>(value: T) => void): void;
35
- makeShareable<T>(value: T): T;
36
- makeMutable<T>(value: T): MutableValue<T>;
37
- makeRemote<T>(object: Record<string, any>): T;
38
- startMapper(mapper: () => void, inputs: NestedObjectValues<MutableValue<unknown>>[], outputs: NestedObjectValues<MutableValue<unknown>>[]): number;
39
- stopMapper(mapperId: number): void;
40
- registerEventHandler<T>(_: string, __: (event: T) => void): string;
41
- unregisterEventHandler(_: string): void;
42
- enableLayoutAnimations(): void;
43
- }
1
+ export {};
@@ -1,5 +1,6 @@
1
1
  import JSReanimated from './JSReanimated';
2
- import type { AnimatedStyle, StyleProps } from '../commonTypes';
2
+ import type { StyleProps } from '../commonTypes';
3
+ import type { AnimatedStyle } from '../helperTypes';
3
4
  declare const reanimatedJS: JSReanimated;
4
5
  interface JSReanimatedComponent {
5
6
  previousStyle: StyleProps;
@@ -10,7 +11,7 @@ interface JSReanimatedComponent {
10
11
  setAttribute: (key: string, props: unknown) => void;
11
12
  };
12
13
  }
13
- export declare const _updatePropsJS: (updates: StyleProps | AnimatedStyle, viewRef: {
14
+ export declare const _updatePropsJS: (updates: StyleProps | AnimatedStyle<any>, viewRef: {
14
15
  _component?: JSReanimatedComponent;
15
16
  }) => void;
16
17
  export default reanimatedJS;
@@ -1,9 +1,9 @@
1
1
  import type { AnimationFunction, LayoutAnimationAndConfig } from './commonTypes';
2
- import type { EasingFn } from '../../Easing';
2
+ import type { EasingFunction } from '../../Easing';
3
3
  import { BaseAnimationBuilder } from './BaseAnimationBuilder';
4
4
  import type { StyleProps } from '../../commonTypes';
5
5
  export declare class ComplexAnimationBuilder extends BaseAnimationBuilder {
6
- easingV?: EasingFn;
6
+ easingV?: EasingFunction;
7
7
  rotateV?: string;
8
8
  type?: AnimationFunction;
9
9
  dampingV?: number;
@@ -15,8 +15,8 @@ export declare class ComplexAnimationBuilder extends BaseAnimationBuilder {
15
15
  restSpeedThresholdV?: number;
16
16
  initialValues?: StyleProps;
17
17
  static createInstance: <T extends typeof BaseAnimationBuilder>(this: T) => InstanceType<T>;
18
- static easing<T extends typeof ComplexAnimationBuilder>(this: T, easingFunction: EasingFn): InstanceType<T>;
19
- easing(easingFunction: EasingFn): this;
18
+ static easing<T extends typeof ComplexAnimationBuilder>(this: T, easingFunction: EasingFunction): InstanceType<T>;
19
+ easing(easingFunction: EasingFunction): this;
20
20
  static rotate<T extends typeof ComplexAnimationBuilder>(this: T, degree: string): InstanceType<T>;
21
21
  rotate(degree: string): this;
22
22
  static springify<T extends typeof ComplexAnimationBuilder>(this: T, duration?: number): ComplexAnimationBuilder;
@@ -1,15 +1,4 @@
1
- import type { EasingFn } from '../../Easing';
2
1
  import type { KeyframeProps } from './commonTypes';
3
- import type { StyleProps } from '../../commonTypes';
4
- export interface KeyframePoint {
5
- duration: number;
6
- value: number | string;
7
- easing?: EasingFn;
8
- }
9
- export interface ParsedKeyframesDefinition {
10
- initialValues: StyleProps;
11
- keyframes: Record<string, KeyframePoint[]>;
12
- }
13
2
  export declare class ReanimatedKeyframe {
14
3
  constructor(definitions: Record<string, KeyframeProps>);
15
4
  duration(durationMs: number): ReanimatedKeyframe;
@@ -1,7 +1,7 @@
1
- import type { EasingFn } from '../../Easing';
1
+ import type { EasingFunction } from '../../Easing';
2
2
  import type { StyleProps } from '../../commonTypes';
3
3
  export interface KeyframeProps extends StyleProps {
4
- easing?: EasingFn;
4
+ easing?: EasingFunction;
5
5
  [key: string]: any;
6
6
  }
7
7
  export type LayoutAnimation = {
@@ -68,7 +68,7 @@ export interface ILayoutAnimationBuilder {
68
68
  }
69
69
  export interface BaseLayoutAnimationConfig {
70
70
  duration?: number;
71
- easing?: EasingFn;
71
+ easing?: EasingFunction;
72
72
  type?: AnimationFunction;
73
73
  damping?: number;
74
74
  dampingRatio?: number;
@@ -1,19 +1,19 @@
1
1
  import type { ILayoutAnimationBuilder, LayoutAnimationFunction } from '../animationBuilder/commonTypes';
2
2
  import { BaseAnimationBuilder } from '../animationBuilder';
3
- import type { EasingFn } from '../../Easing';
3
+ import type { EasingFunction } from '../../Easing';
4
4
  export declare class CurvedTransition extends BaseAnimationBuilder implements ILayoutAnimationBuilder {
5
- easingXV: EasingFn;
6
- easingYV: EasingFn;
7
- easingWidthV: EasingFn;
8
- easingHeightV: EasingFn;
5
+ easingXV: EasingFunction;
6
+ easingYV: EasingFunction;
7
+ easingWidthV: EasingFunction;
8
+ easingHeightV: EasingFunction;
9
9
  static createInstance<T extends typeof BaseAnimationBuilder>(this: T): InstanceType<T>;
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;
10
+ static easingX(easing: EasingFunction): CurvedTransition;
11
+ easingX(easing: EasingFunction): CurvedTransition;
12
+ static easingY(easing: EasingFunction): CurvedTransition;
13
+ easingY(easing: EasingFunction): CurvedTransition;
14
+ static easingWidth(easing: EasingFunction): CurvedTransition;
15
+ easingWidth(easing: EasingFunction): CurvedTransition;
16
+ static easingHeight(easing: EasingFunction): CurvedTransition;
17
+ easingHeight(easing: EasingFunction): CurvedTransition;
18
18
  build: () => LayoutAnimationFunction;
19
19
  }
@@ -3,3 +3,4 @@ export * from './animationBuilder';
3
3
  export * from './defaultAnimations';
4
4
  export * from './defaultTransitions';
5
5
  export * from './sharedTransitions';
6
+ export type { KeyframeProps } from './animationBuilder/commonTypes';
@@ -1,14 +1,2 @@
1
- import type { SharedValue } from './commonTypes';
2
- export type Mapper = {
3
- id: number;
4
- dirty: boolean;
5
- worklet: () => void;
6
- inputs: SharedValue<any>[];
7
- outputs?: SharedValue<any>[];
8
- };
9
- export declare function createMapperRegistry(): {
10
- start: (mapperID: number, worklet: () => void, inputs: SharedValue<any>[], outputs?: SharedValue<any>[]) => void;
11
- stop: (mapperID: number) => void;
12
- };
13
1
  export declare function startMapper(worklet: () => void, inputs?: any[], outputs?: any[]): number;
14
2
  export declare function stopMapper(mapperID: number): void;
@@ -1,76 +1 @@
1
- declare const NOOP: () => void;
2
- declare const ID: (t: any) => any;
3
- declare const IMMEDIATE_CB_INVOCATION: (cb: () => unknown) => unknown;
4
- declare class BaseAnimationMock {
5
- duration(_: number): this;
6
- delay(_: number): this;
7
- springify(_: number): this;
8
- damping(_: number): this;
9
- stiffness(_: number): this;
10
- withCallback(_: (finished: boolean) => void): this;
11
- randomDelay(): this;
12
- withInitialValues(): this;
13
- build(): () => {
14
- initialValues: {};
15
- animations: {};
16
- };
17
- }
18
- declare const ReanimatedV2: {
19
- useSharedValue: (v: any) => {
20
- value: any;
21
- };
22
- useDerivedValue: (a: any) => {
23
- value: any;
24
- };
25
- useAnimatedScrollHandler: () => () => void;
26
- useAnimatedGestureHandler: () => () => void;
27
- useAnimatedStyle: (cb: () => unknown) => unknown;
28
- useAnimatedRef: () => {
29
- current: null;
30
- };
31
- useAnimatedReaction: () => void;
32
- useAnimatedProps: (cb: () => unknown) => unknown;
33
- withTiming: (toValue: any, _: any, cb: any) => any;
34
- withSpring: (toValue: any, _: any, cb: any) => any;
35
- withDecay: (_: any, cb: any) => number;
36
- withDelay: (_: any, animationValue: any) => any;
37
- withSequence: (..._animations: any[]) => number;
38
- withRepeat: (animation: any) => any;
39
- cancelAnimation: () => void;
40
- measure: () => {
41
- x: number;
42
- y: number;
43
- width: number;
44
- height: number;
45
- pageX: number;
46
- pageY: number;
47
- };
48
- Easing: {
49
- linear: (t: any) => any;
50
- ease: (t: any) => any;
51
- quad: (t: any) => any;
52
- cubic: (t: any) => any;
53
- poly: (t: any) => any;
54
- sin: (t: any) => any;
55
- circle: (t: any) => any;
56
- exp: (t: any) => any;
57
- elastic: (t: any) => any;
58
- back: (t: any) => any;
59
- bounce: (t: any) => any;
60
- bezier: () => {
61
- factory: (t: any) => any;
62
- };
63
- bezierFn: (t: any) => any;
64
- steps: (t: any) => any;
65
- in: (t: any) => any;
66
- out: (t: any) => any;
67
- inOut: (t: any) => any;
68
- };
69
- Extrapolation: {
70
- EXTEND: string;
71
- CLAMP: string;
72
- IDENTITY: string;
73
- };
74
- runOnJS: (fn: any) => any;
75
- runOnUI: (fn: any) => any;
76
- };
1
+ export {};
@@ -1,5 +1,4 @@
1
1
  import type { SharedValue, ShareableSyncDataHolderRef } from './commonTypes';
2
- export { stopMapper } from './mappers';
3
2
  export declare function makeUIMutable<T>(initial: T, syncDataHolder?: ShareableSyncDataHolderRef<T>): {
4
3
  value: T;
5
4
  /**
@@ -3,4 +3,4 @@
3
3
  * with the version used to build the native part of the library in runtime.
4
4
  * Remember to keep this in sync with the version declared in `package.json`
5
5
  */
6
- export declare const jsVersion = "3.4.0";
6
+ export declare const jsVersion = "3.4.2";
@@ -1,2 +1 @@
1
- export { stopMapper } from './mappers';
2
1
  export declare function valueSetter(sv: any, value: any): void;
@@ -32,7 +32,7 @@ import type { MutableRefObject } from 'react';
32
32
  *
33
33
  * module.exports = MyViewWithRef;
34
34
  */
35
- export type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);
35
+ type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);
36
36
  declare function setAndForwardRef<T>({ getForwardedRef, setLocalRef, }: {
37
37
  getForwardedRef: ForwardedRef<T>;
38
38
  setLocalRef: (ref: T) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
@@ -20,6 +20,7 @@
20
20
  "format:ios": "find ios/ -iname *.h -o -iname *.m -o -iname *.mm -o -iname *.cpp | xargs clang-format -i --Werror",
21
21
  "format:android": "find android/src/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
22
22
  "format:common": "find Common/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
23
+ "find-unused-code:js": "yarn ts-prune --ignore \"index|.web.\" --error ",
23
24
  "type:check": "yarn tsc --noEmit && cd plugin && yarn type:check && cd ..",
24
25
  "type:check-api": "yarn tsc --noEmit --target es6 --module ESNext --jsx react-native --skipLibCheck true --allowSyntheticDefaultImports true --moduleResolution node --esModuleInterop true --strict true --forceConsistentCasingInFileNames true --resolveJsonModule true app/src/App.tsx",
25
26
  "prepare": "yarn plugin && bob build && husky install && yarn app",
@@ -147,6 +148,7 @@
147
148
  "react-native-web": "~0.18.12",
148
149
  "react-test-renderer": "17.0.2",
149
150
  "shelljs": "^0.8.5",
151
+ "ts-prune": "^0.10.3",
150
152
  "typescript": "^4.1.3"
151
153
  },
152
154
  "lint-staged": {
package/src/Animated.ts CHANGED
@@ -1,13 +1,87 @@
1
- export { default as createAnimatedComponent } from './createAnimatedComponent';
2
- export {
3
- addWhitelistedNativeProps,
4
- addWhitelistedUIProps,
1
+ import type { Extrapolate as _Extrapolate } from './reanimated2/interpolateColor';
2
+ import type { SharedValue as _SharedValue } from './reanimated2/commonTypes';
3
+ import type { DerivedValue as _DerivedValue } from './reanimated2/hook/useDerivedValue';
4
+ import type {
5
+ TransformStyleTypes as _TransformStyleTypes,
6
+ Adaptable as _Adaptable,
7
+ AdaptTransforms as _AdaptTransforms,
8
+ AnimatedTransform as _AnimatedTransform,
9
+ AnimateStyle as _AnimateStyle,
10
+ StylesOrDefault as _StylesOrDefault,
11
+ AnimateProps as _AnimateProps,
12
+ } from './reanimated2/helperTypes';
13
+ import type { EasingFunction as _EasingFunction } from './reanimated2/Easing';
14
+ import {
15
+ addWhitelistedNativeProps as _addWhitelistedNativeProps,
16
+ addWhitelistedUIProps as _addWhitelistedUIProps,
5
17
  } from './ConfigHelper';
18
+ import type { AnimatedScrollViewProps as _AnimatedScrollViewProps } from './reanimated2/component/ScrollView';
19
+ import type { FlatListPropsWithLayout as _FlatListPropsWithLayout } from './reanimated2/component/FlatList';
20
+ export { default as createAnimatedComponent } from './createAnimatedComponent';
6
21
 
7
22
  export { AnimatedText as Text } from './reanimated2/component/Text';
8
23
  export { AnimatedView as View } from './reanimated2/component/View';
9
24
  export { AnimatedScrollView as ScrollView } from './reanimated2/component/ScrollView';
10
25
  export { AnimatedImage as Image } from './reanimated2/component/Image';
11
26
  export { ReanimatedFlatList as FlatList } from './reanimated2/component/FlatList';
12
- export type { SharedValue } from './reanimated2/commonTypes';
13
- export type { AnimateStyle } from './reanimated2/helperTypes';
27
+ /**
28
+ * @deprecated Please import `Extrapolate` directly from `react-native-reanimated` instead of `Animated` namespace.
29
+ */
30
+ export type Extrapolate = typeof _Extrapolate;
31
+ /**
32
+ * @deprecated Please import `SharedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
33
+ */
34
+
35
+ export type SharedValue<T> = _SharedValue<T>;
36
+ /**
37
+ * @deprecated Please import `DerivedValue` directly from `react-native-reanimated` instead of `Animated` namespace.
38
+ */
39
+ export type DerivedValue<T> = _DerivedValue<T>;
40
+ /**
41
+ * @deprecated Please import `Adaptable` directly from `react-native-reanimated` instead of `Animated` namespace.
42
+ */
43
+ export type Adaptable<T> = _Adaptable<T>;
44
+ /**
45
+ * @deprecated Please import `TransformStyleTypes` directly from `react-native-reanimated` instead of `Animated` namespace.
46
+ * */
47
+ export type TransformStyleTypes = _TransformStyleTypes;
48
+ /**
49
+ * @deprecated Please import `AdaptTransforms` directly from `react-native-reanimated` instead of `Animated` namespace.
50
+ * */
51
+ export type AdaptTransforms<T> = _AdaptTransforms<T>;
52
+ /**
53
+ * @deprecated Please import `AnimatedTransform` directly from `react-native-reanimated` instead of `Animated` namespace.
54
+ */
55
+ export type AnimatedTransform = _AnimatedTransform;
56
+ /**
57
+ * @deprecated Please import `AnimateStyle` directly from `react-native-reanimated` instead of `Animated` namespace.
58
+ * */
59
+ export type AnimateStyle<S> = _AnimateStyle<S>;
60
+ /**
61
+ * @deprecated Please import `StylesOrDefault` directly from `react-native-reanimated` instead of `Animated` namespace.
62
+ * */
63
+ export type StylesOrDefault<S> = _StylesOrDefault<S>;
64
+ /**
65
+ * @deprecated Please import `AnimateProps` directly from `react-native-reanimated` instead of `Animated` namespace.
66
+ * */
67
+ export type AnimateProps<P extends object> = _AnimateProps<P>;
68
+ /**
69
+ * @deprecated Please import `EasingFunction` directly from `react-native-reanimated` instead of `Animated` namespace.
70
+ * */
71
+ export type EasingFunction = _EasingFunction;
72
+ /**
73
+ * @deprecated Please import `addWhitelistedNativeProps` directly from `react-native-reanimated` instead of `Animated` namespace.
74
+ * */
75
+ export const addWhitelistedNativeProps = _addWhitelistedNativeProps;
76
+ /**
77
+ * @deprecated Please import `addWhitelistedUIProps` directly from `react-native-reanimated` instead of `Animated` namespace.
78
+ * */
79
+ export const addWhitelistedUIProps = _addWhitelistedUIProps;
80
+ /**
81
+ * @deprecated Please import `AnimatedScrollViewProps` directly from `react-native-reanimated` instead of `Animated` namespace.
82
+ * */
83
+ export type AnimatedScrollViewProps = _AnimatedScrollViewProps;
84
+ /**
85
+ * @deprecated Please import `FlatListPropsWithLayout` directly from `react-native-reanimated` instead of `Animated` namespace.
86
+ * */
87
+ export type FlatListPropsWithLayout<T> = _FlatListPropsWithLayout<T>;
@@ -214,7 +214,7 @@ interface AnimatedProps extends Record<string, unknown> {
214
214
  initial?: SharedValue<StyleProps>;
215
215
  }
216
216
 
217
- export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
217
+ type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
218
218
  forwardedRef?: Ref<Component>;
219
219
  style?: NestedArray<StyleProps>;
220
220
  animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
@@ -247,7 +247,7 @@ interface ComponentRef extends Component {
247
247
  getAnimatableRef?: () => ComponentRef;
248
248
  }
249
249
 
250
- export interface InitialComponentProps extends Record<string, unknown> {
250
+ interface InitialComponentProps extends Record<string, unknown> {
251
251
  ref?: Ref<Component>;
252
252
  collapsable?: boolean;
253
253
  }
@@ -46,9 +46,19 @@ import { Bezier } from './Bezier';
46
46
  * - [`out`](docs/easing.html#out) runs an easing function backwards
47
47
  */
48
48
 
49
- export type EasingFn = (t: number) => number;
49
+ export type EasingFunction = (t: number) => number;
50
50
 
51
- export type EasingFactoryFn = { factory: () => EasingFn };
51
+ /**
52
+ * @deprecated Please use `EasingFunction` type instead.
53
+ */
54
+ export type EasingFn = EasingFunction;
55
+
56
+ export type EasingFunctionFactory = { factory: () => EasingFunction };
57
+
58
+ /**
59
+ * @deprecated Please use `EasingFunctionFactory` type instead.
60
+ */
61
+ export type EasingFactoryFn = EasingFunctionFactory;
52
62
  /**
53
63
  * A linear function, `f(t) = t`. Position correlates to elapsed time one to
54
64
  * one.
@@ -99,7 +109,7 @@ function cubic(t: number): number {
99
109
  * n = 4: http://easings.net/#easeInQuart
100
110
  * n = 5: http://easings.net/#easeInQuint
101
111
  */
102
- function poly(n: number): EasingFn {
112
+ function poly(n: number): EasingFunction {
103
113
  'worklet';
104
114
  return (t) => {
105
115
  'worklet';
@@ -147,7 +157,7 @@ function exp(t: number): number {
147
157
  *
148
158
  * http://easings.net/#easeInElastic
149
159
  */
150
- function elastic(bounciness = 1): EasingFn {
160
+ function elastic(bounciness = 1): EasingFunction {
151
161
  'worklet';
152
162
  const p = bounciness * Math.PI;
153
163
  return (t) => {
@@ -232,7 +242,7 @@ function bezierFn(
232
242
  /**
233
243
  * Runs an easing function forwards.
234
244
  */
235
- function in_(easing: EasingFn): EasingFn {
245
+ function in_(easing: EasingFunction): EasingFunction {
236
246
  'worklet';
237
247
  return easing;
238
248
  }
@@ -240,7 +250,7 @@ function in_(easing: EasingFn): EasingFn {
240
250
  /**
241
251
  * Runs an easing function backwards.
242
252
  */
243
- function out(easing: EasingFn): EasingFn {
253
+ function out(easing: EasingFunction): EasingFunction {
244
254
  'worklet';
245
255
  return (t) => {
246
256
  'worklet';
@@ -253,7 +263,7 @@ function out(easing: EasingFn): EasingFn {
253
263
  * forwards for half of the duration, then backwards for the rest of the
254
264
  * duration.
255
265
  */
256
- function inOut(easing: EasingFn): EasingFn {
266
+ function inOut(easing: EasingFunction): EasingFunction {
257
267
  'worklet';
258
268
  return (t) => {
259
269
  'worklet';
@@ -270,7 +280,7 @@ function inOut(easing: EasingFn): EasingFn {
270
280
  * steps in the animation, and the `roundToNextStep` parameter determines whether the animation
271
281
  * should start at the beginning or end of each step.
272
282
  */
273
- function steps(n = 10, roundToNextStep = true): EasingFn {
283
+ function steps(n = 10, roundToNextStep = true): EasingFunction {
274
284
  'worklet';
275
285
  return (t) => {
276
286
  'worklet';
@@ -1,11 +1,7 @@
1
1
  import type { MutableRefObject } from 'react';
2
2
  import { processColor } from './Colors';
3
- import type {
4
- AnimatedStyle,
5
- ShadowNodeWrapper,
6
- SharedValue,
7
- StyleProps,
8
- } from './commonTypes';
3
+ import type { ShadowNodeWrapper, SharedValue, StyleProps } from './commonTypes';
4
+ import type { AnimatedStyle } from './helperTypes';
9
5
  import { makeShareable } from './core';
10
6
  import type { Descriptor } from './hook/commonTypes';
11
7
  import { _updatePropsJS } from './js-reanimated';
@@ -14,7 +10,7 @@ import type { ViewRefSet } from './ViewDescriptorsSet';
14
10
  import { runOnUIImmediately } from './threads';
15
11
 
16
12
  // copied from react-native/Libraries/Components/View/ReactNativeStyleAttributes
17
- export const colorProps = [
13
+ const colorProps = [
18
14
  'backgroundColor',
19
15
  'borderBottomColor',
20
16
  'borderColor',
@@ -33,9 +29,9 @@ export const colorProps = [
33
29
 
34
30
  export const ColorProperties = makeShareable(colorProps);
35
31
 
36
- export let updateProps: (
32
+ let updateProps: (
37
33
  viewDescriptor: SharedValue<Descriptor[]>,
38
- updates: StyleProps | AnimatedStyle,
34
+ updates: StyleProps | AnimatedStyle<any>,
39
35
  maybeViewRef: ViewRefSet<any> | undefined
40
36
  ) => void;
41
37
 
@@ -63,10 +59,10 @@ if (shouldBeUseWeb()) {
63
59
 
64
60
  export const updatePropsJestWrapper = (
65
61
  viewDescriptors: SharedValue<Descriptor[]>,
66
- updates: AnimatedStyle,
62
+ updates: AnimatedStyle<any>,
67
63
  maybeViewRef: ViewRefSet<any> | undefined,
68
- animatedStyle: MutableRefObject<AnimatedStyle>,
69
- adapters: ((updates: AnimatedStyle) => void)[]
64
+ animatedStyle: MutableRefObject<AnimatedStyle<any>>,
65
+ adapters: ((updates: AnimatedStyle<any>) => void)[]
70
66
  ): void => {
71
67
  adapters.forEach((adapter) => {
72
68
  adapter(updates);
@@ -87,12 +83,12 @@ const createUpdatePropsManager = global._IS_FABRIC
87
83
  // Fabric
88
84
  const operations: {
89
85
  shadowNodeWrapper: ShadowNodeWrapper;
90
- updates: StyleProps | AnimatedStyle;
86
+ updates: StyleProps | AnimatedStyle<any>;
91
87
  }[] = [];
92
88
  return {
93
89
  update(
94
90
  viewDescriptors: SharedValue<Descriptor[]>,
95
- updates: StyleProps | AnimatedStyle
91
+ updates: StyleProps | AnimatedStyle<any>
96
92
  ) {
97
93
  viewDescriptors.value.forEach((viewDescriptor) => {
98
94
  operations.push({
@@ -117,12 +113,12 @@ const createUpdatePropsManager = global._IS_FABRIC
117
113
  const operations: {
118
114
  tag: number;
119
115
  name: string;
120
- updates: StyleProps | AnimatedStyle;
116
+ updates: StyleProps | AnimatedStyle<any>;
121
117
  }[] = [];
122
118
  return {
123
119
  update(
124
120
  viewDescriptors: SharedValue<Descriptor[]>,
125
- updates: StyleProps | AnimatedStyle
121
+ updates: StyleProps | AnimatedStyle<any>
126
122
  ) {
127
123
  viewDescriptors.value.forEach((viewDescriptor) => {
128
124
  operations.push({
@@ -151,7 +147,7 @@ runOnUIImmediately(() => {
151
147
  export interface UpdatePropsManager {
152
148
  update(
153
149
  viewDescriptors: SharedValue<Descriptor[]>,
154
- updates: StyleProps | AnimatedStyle
150
+ updates: StyleProps | AnimatedStyle<any>
155
151
  ): void;
156
152
  flush(): void;
157
153
  }