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
@@ -20,7 +20,6 @@ import type {
20
20
  AnimationObject,
21
21
  Timestamp,
22
22
  AdapterWorkletFunction,
23
- AnimatedStyle,
24
23
  BasicWorkletFunction,
25
24
  BasicWorkletFunctionOptional,
26
25
  NestedObjectValues,
@@ -33,26 +32,26 @@ import type {
33
32
  TextStyle,
34
33
  ViewStyle,
35
34
  } from 'react-native';
36
- import type { AnimateStyle } from '../helperTypes';
35
+ import type { AnimatedStyle } from '../helperTypes';
37
36
 
38
37
  export interface AnimatedStyleResult {
39
38
  viewDescriptors: ViewDescriptorsSet;
40
- initial: AnimatedStyle;
39
+ initial: AnimatedStyle<any>;
41
40
  viewsRef: ViewRefSet<any>;
42
- animatedStyle?: MutableRefObject<AnimatedStyle>;
41
+ animatedStyle?: MutableRefObject<AnimatedStyle<any>>;
43
42
  }
44
43
 
45
44
  interface AnimatedState {
46
- last: AnimatedStyle;
47
- animations: AnimatedStyle;
45
+ last: AnimatedStyle<any>;
46
+ animations: AnimatedStyle<any>;
48
47
  isAnimationRunning: boolean;
49
48
  isAnimationCancelled: boolean;
50
49
  }
51
50
 
52
51
  interface AnimationRef {
53
52
  initial: {
54
- value: AnimatedStyle;
55
- updater: () => AnimatedStyle;
53
+ value: AnimatedStyle<any>;
54
+ updater: () => AnimatedStyle<any>;
56
55
  };
57
56
  remoteState: AnimatedState;
58
57
  viewDescriptors: ViewDescriptorsSet;
@@ -60,9 +59,9 @@ interface AnimationRef {
60
59
 
61
60
  function prepareAnimation(
62
61
  frameTimestamp: number,
63
- animatedProp: AnimatedStyle,
64
- lastAnimation: AnimatedStyle,
65
- lastValue: AnimatedStyle
62
+ animatedProp: AnimatedStyle<any>,
63
+ lastAnimation: AnimatedStyle<any>,
64
+ lastValue: AnimatedStyle<any>
66
65
  ): void {
67
66
  'worklet';
68
67
  if (Array.isArray(animatedProp)) {
@@ -119,10 +118,10 @@ function prepareAnimation(
119
118
  }
120
119
 
121
120
  function runAnimations(
122
- animation: AnimatedStyle,
121
+ animation: AnimatedStyle<any>,
123
122
  timestamp: Timestamp,
124
123
  key: number | string,
125
- result: AnimatedStyle,
124
+ result: AnimatedStyle<any>,
126
125
  animationsActive: SharedValue<boolean>
127
126
  ): boolean {
128
127
  'worklet';
@@ -181,7 +180,7 @@ function runAnimations(
181
180
 
182
181
  function styleUpdater(
183
182
  viewDescriptors: SharedValue<Descriptor[]>,
184
- updater: BasicWorkletFunction<AnimatedStyle>,
183
+ updater: BasicWorkletFunction<AnimatedStyle<any>>,
185
184
  state: AnimatedState,
186
185
  maybeViewRef: ViewRefSet<any> | undefined,
187
186
  animationsActive: SharedValue<boolean>
@@ -217,7 +216,7 @@ function styleUpdater(
217
216
  return;
218
217
  }
219
218
 
220
- const updates: AnimatedStyle = {};
219
+ const updates: AnimatedStyle<any> = {};
221
220
  let allFinished = true;
222
221
  for (const propName in animations) {
223
222
  const finished = runAnimations(
@@ -269,15 +268,15 @@ function styleUpdater(
269
268
 
270
269
  function jestStyleUpdater(
271
270
  viewDescriptors: SharedValue<Descriptor[]>,
272
- updater: BasicWorkletFunction<AnimatedStyle>,
271
+ updater: BasicWorkletFunction<AnimatedStyle<any>>,
273
272
  state: AnimatedState,
274
273
  maybeViewRef: ViewRefSet<any> | undefined,
275
274
  animationsActive: SharedValue<boolean>,
276
- animatedStyle: MutableRefObject<AnimatedStyle>,
275
+ animatedStyle: MutableRefObject<AnimatedStyle<any>>,
277
276
  adapters: AdapterWorkletFunction[] = []
278
277
  ): void {
279
278
  'worklet';
280
- const animations: AnimatedStyle = state.animations ?? {};
279
+ const animations: AnimatedStyle<any> = state.animations ?? {};
281
280
  const newValues = updater() ?? {};
282
281
  const oldValues = state.last;
283
282
 
@@ -307,7 +306,7 @@ function jestStyleUpdater(
307
306
  return;
308
307
  }
309
308
 
310
- const updates: AnimatedStyle = {};
309
+ const updates: AnimatedStyle<any> = {};
311
310
  let allFinished = true;
312
311
  Object.keys(animations).forEach((propName) => {
313
312
  const finished = runAnimations(
@@ -400,8 +399,10 @@ function checkSharedValueUsage(
400
399
  }
401
400
  }
402
401
 
403
- // TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
404
- type AnimatedStyleProp<T> = AnimateStyle<T> | RegisteredStyle<AnimateStyle<T>>;
402
+ // This type is kept for backward compatibility.
403
+ export type AnimatedStyleProp<T> =
404
+ | AnimatedStyle<T>
405
+ | RegisteredStyle<AnimatedStyle<T>>;
405
406
 
406
407
  // TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
407
408
  type useAnimatedStyleType = <
@@ -411,7 +412,7 @@ type useAnimatedStyleType = <
411
412
  deps?: DependencyList | null
412
413
  ) => T;
413
414
 
414
- export const useAnimatedStyle = function <T extends AnimatedStyle>(
415
+ export const useAnimatedStyle = function <T extends AnimatedStyle<any>>(
415
416
  // animated style cannot be an array
416
417
  updater: BasicWorkletFunction<T extends Array<unknown> ? never : T>,
417
418
  dependencies?: DependencyList,
@@ -440,9 +441,9 @@ For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/
440
441
  : [];
441
442
  const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;
442
443
  const animationsActive = useSharedValue<boolean>(true);
443
- const animatedStyle: MutableRefObject<AnimatedStyle> = useRef<AnimatedStyle>(
444
- {}
445
- );
444
+ const animatedStyle: MutableRefObject<AnimatedStyle<any>> = useRef<
445
+ AnimatedStyle<any>
446
+ >({});
446
447
 
447
448
  // build dependencies
448
449
  if (!dependencies) {
@@ -453,7 +454,7 @@ For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/
453
454
  adaptersHash && dependencies.push(adaptersHash);
454
455
 
455
456
  if (!initRef.current) {
456
- const initialStyle: AnimatedStyle = initialUpdaterRun(updater);
457
+ const initialStyle: AnimatedStyle<any> = initialUpdaterRun(updater);
457
458
  validateAnimatedStyles(initialStyle);
458
459
  initRef.current = {
459
460
  initial: {
@@ -1,17 +1,15 @@
1
1
  import type { MutableRefObject } from 'react';
2
2
  import { useEffect, useRef } from 'react';
3
- import { processColor } from '../Colors';
4
3
  import type {
5
- AnimatedStyle,
6
4
  Context,
7
5
  NativeEvent,
8
6
  NestedObjectValues,
9
7
  WorkletFunction,
10
8
  AnimationObject,
11
9
  } from '../commonTypes';
10
+ import type { AnimatedStyle } from '../helperTypes';
12
11
  import { makeRemote } from '../core';
13
12
  import { isWeb, isJest } from '../PlatformChecker';
14
- import { colorProps } from '../UpdateProps';
15
13
  import WorkletEventHandler from '../WorkletEventHandler';
16
14
  import type { ContextWithDependencies, DependencyList } from './commonTypes';
17
15
  import type { NativeSyntheticEvent } from 'react-native';
@@ -23,7 +21,7 @@ interface Handlers<T, TContext extends Context> {
23
21
  [key: string]: Handler<T, TContext> | undefined;
24
22
  }
25
23
 
26
- export interface UseHandlerContext<TContext extends Context> {
24
+ interface UseHandlerContext<TContext extends Context> {
27
25
  context: TContext;
28
26
  doDependenciesDiffer: boolean;
29
27
  useWeb: boolean;
@@ -104,7 +102,7 @@ export function buildWorkletsHash(
104
102
  }
105
103
 
106
104
  // builds dependencies array for gesture handlers
107
- export function buildDependencies(
105
+ function buildDependencies(
108
106
  dependencies: DependencyList,
109
107
  handlers: Record<string, WorkletFunction | undefined>
110
108
  ): Array<unknown> {
@@ -126,7 +124,7 @@ export function buildDependencies(
126
124
  }
127
125
 
128
126
  // this is supposed to work as useEffect comparison
129
- export function areDependenciesEqual(
127
+ function areDependenciesEqual(
130
128
  nextDeps: DependencyList,
131
129
  prevDeps: DependencyList
132
130
  ): boolean {
@@ -156,30 +154,6 @@ export function areDependenciesEqual(
156
154
  return areHookInputsEqual(nextDeps, prevDeps);
157
155
  }
158
156
 
159
- export function hasColorProps(updates: AnimatedStyle): boolean {
160
- const colorPropsSet = new Set(colorProps);
161
- for (const key in updates) {
162
- if (colorPropsSet.has(key)) {
163
- return true;
164
- }
165
- }
166
- return false;
167
- }
168
-
169
- export function parseColors(updates: AnimatedStyle): void {
170
- 'worklet';
171
- for (const key in updates) {
172
- if (colorProps.indexOf(key) !== -1) {
173
- // value could be an animation in which case processColor will recognize it and will return undefined
174
- // -> in such a case we don't want to override style of that key
175
- const processedColor = processColor(updates[key]);
176
- if (processedColor !== undefined) {
177
- updates[key] = processedColor;
178
- }
179
- }
180
- }
181
- }
182
-
183
157
  export function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean {
184
158
  'worklet';
185
159
  if (Array.isArray(prop)) {
@@ -209,7 +183,7 @@ export function shallowEqual(a: any, b: any) {
209
183
  return true;
210
184
  }
211
185
 
212
- export const validateAnimatedStyles = (styles: AnimatedStyle): void => {
186
+ export const validateAnimatedStyles = (styles: AnimatedStyle<any>): void => {
213
187
  'worklet';
214
188
  if (typeof styles !== 'object') {
215
189
  throw new Error(
@@ -15,4 +15,16 @@ export * from './commonTypes';
15
15
  export * from './frameCallback';
16
16
  export * from './pluginUtils';
17
17
  export * from './jestUtils';
18
- export type { AnimateProps } from './helperTypes';
18
+ export type {
19
+ Adaptable,
20
+ AdaptTransforms,
21
+ AnimateProps,
22
+ AnimatedProps,
23
+ AnimatedTransform,
24
+ TransformStyleTypes,
25
+ AnimateStyle,
26
+ AnimatedStyle,
27
+ StylesOrDefault,
28
+ } from './helperTypes';
29
+ export type { AnimatedScrollViewProps } from './component/ScrollView';
30
+ export type { FlatListPropsWithLayout } from './component/FlatList';
@@ -111,7 +111,7 @@ const interpolateColorsRGB = (
111
111
  );
112
112
  };
113
113
 
114
- interface InterpolateRGB {
114
+ export interface InterpolateRGB {
115
115
  r: number[];
116
116
  g: number[];
117
117
  b: number[];
@@ -141,7 +141,7 @@ const getInterpolateRGB = (
141
141
  return { r, g, b, a };
142
142
  };
143
143
 
144
- interface InterpolateHSV {
144
+ export interface InterpolateHSV {
145
145
  h: number[];
146
146
  s: number[];
147
147
  v: number[];
@@ -1,7 +1,7 @@
1
1
  import type { Timestamp, NestedObjectValues } from '../commonTypes';
2
2
  import type MutableValue from './MutableValue';
3
3
 
4
- export interface Mapper<T> {
4
+ interface Mapper<T> {
5
5
  MAPPER_ID?: number;
6
6
  id: number;
7
7
  inputs: MutableValue<T>[];
@@ -14,7 +14,7 @@ export interface Mapper<T> {
14
14
  ): MutableValue<T>[];
15
15
  }
16
16
 
17
- export interface MapperRegistry<T> {
17
+ interface MapperRegistry<T> {
18
18
  sortedMappers: Mapper<T>[];
19
19
  mappers: Map<number, Mapper<T>>;
20
20
  _module: JSReanimated;
@@ -25,7 +25,7 @@ export interface MapperRegistry<T> {
25
25
  updateOrder(): void;
26
26
  }
27
27
 
28
- export interface JSReanimated {
28
+ interface JSReanimated {
29
29
  _valueSetter?: <T>(value: T) => void;
30
30
  _renderRequested: boolean;
31
31
  _mapperRegistry: MapperRegistry<any>;
@@ -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
  import { isWeb } from '../PlatformChecker';
4
5
 
5
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -47,13 +48,13 @@ interface JSReanimatedComponent {
47
48
  }
48
49
 
49
50
  export const _updatePropsJS = (
50
- updates: StyleProps | AnimatedStyle,
51
+ updates: StyleProps | AnimatedStyle<any>,
51
52
  viewRef: { _component?: JSReanimatedComponent }
52
53
  ): void => {
53
54
  if (viewRef._component) {
54
55
  const component = viewRef._component;
55
56
  const [rawStyles] = Object.keys(updates).reduce(
56
- (acc: [StyleProps, AnimatedStyle], key) => {
57
+ (acc: [StyleProps, AnimatedStyle<any>], key) => {
57
58
  const value = updates[key];
58
59
  const index = typeof value === 'function' ? 1 : 0;
59
60
  acc[index][key] = value;
@@ -4,12 +4,12 @@ import type {
4
4
  BaseBuilderAnimationConfig,
5
5
  LayoutAnimationAndConfig,
6
6
  } from './commonTypes';
7
- import type { EasingFn } from '../../Easing';
7
+ import type { EasingFunction } from '../../Easing';
8
8
  import { BaseAnimationBuilder } from './BaseAnimationBuilder';
9
9
  import type { StyleProps } from '../../commonTypes';
10
10
 
11
11
  export class ComplexAnimationBuilder extends BaseAnimationBuilder {
12
- easingV?: EasingFn;
12
+ easingV?: EasingFunction;
13
13
  rotateV?: string;
14
14
  type?: AnimationFunction;
15
15
  dampingV?: number;
@@ -27,13 +27,13 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
27
27
 
28
28
  static easing<T extends typeof ComplexAnimationBuilder>(
29
29
  this: T,
30
- easingFunction: EasingFn
30
+ easingFunction: EasingFunction
31
31
  ) {
32
32
  const instance = this.createInstance();
33
33
  return instance.easing(easingFunction);
34
34
  }
35
35
 
36
- easing(easingFunction: EasingFn): this {
36
+ easing(easingFunction: EasingFunction): this {
37
37
  this.easingV = easingFunction;
38
38
  return this;
39
39
  }
@@ -1,4 +1,4 @@
1
- import type { EasingFn } from '../../Easing';
1
+ import type { EasingFunction } from '../../Easing';
2
2
  import { Easing } from '../../Easing';
3
3
  import { withDelay, withSequence, withTiming } from '../../animation';
4
4
  import type {
@@ -8,12 +8,12 @@ import type {
8
8
  KeyframeProps,
9
9
  } from './commonTypes';
10
10
  import type { TransformProperty, StyleProps } from '../../commonTypes';
11
- export interface KeyframePoint {
11
+ interface KeyframePoint {
12
12
  duration: number;
13
13
  value: number | string;
14
- easing?: EasingFn;
14
+ easing?: EasingFunction;
15
15
  }
16
- export interface ParsedKeyframesDefinition {
16
+ interface ParsedKeyframesDefinition {
17
17
  initialValues: StyleProps;
18
18
  keyframes: Record<string, KeyframePoint[]>;
19
19
  }
@@ -113,7 +113,7 @@ class InnerKeyframe implements IEntryExitAnimationBuilder {
113
113
  key: string;
114
114
  value: string | number;
115
115
  currentKeyPoint: number;
116
- easing?: EasingFn;
116
+ easing?: EasingFunction;
117
117
  }): void => {
118
118
  if (!(key in parsedKeyframes)) {
119
119
  throw Error(
@@ -1,8 +1,8 @@
1
- import type { EasingFn } from '../../Easing';
1
+ import type { EasingFunction } from '../../Easing';
2
2
  import type { StyleProps } from '../../commonTypes';
3
3
 
4
4
  export interface KeyframeProps extends StyleProps {
5
- easing?: EasingFn;
5
+ easing?: EasingFunction;
6
6
  [key: string]: any;
7
7
  }
8
8
 
@@ -96,7 +96,7 @@ export interface ILayoutAnimationBuilder {
96
96
 
97
97
  export interface BaseLayoutAnimationConfig {
98
98
  duration?: number;
99
- easing?: EasingFn;
99
+ easing?: EasingFunction;
100
100
  type?: AnimationFunction;
101
101
  damping?: number;
102
102
  dampingRatio?: number;
@@ -3,7 +3,7 @@ import type {
3
3
  LayoutAnimationFunction,
4
4
  } from '../animationBuilder/commonTypes';
5
5
  import { BaseAnimationBuilder } from '../animationBuilder';
6
- import type { EasingFn } from '../../Easing';
6
+ import type { EasingFunction } from '../../Easing';
7
7
  import { Easing } from '../../Easing';
8
8
  import { withTiming } from '../../animation';
9
9
 
@@ -11,10 +11,10 @@ export class CurvedTransition
11
11
  extends BaseAnimationBuilder
12
12
  implements ILayoutAnimationBuilder
13
13
  {
14
- easingXV: EasingFn = Easing.in(Easing.ease);
15
- easingYV: EasingFn = Easing.out(Easing.ease);
16
- easingWidthV: EasingFn = Easing.in(Easing.exp);
17
- easingHeightV: EasingFn = Easing.out(Easing.exp);
14
+ easingXV: EasingFunction = Easing.in(Easing.ease);
15
+ easingYV: EasingFunction = Easing.out(Easing.ease);
16
+ easingWidthV: EasingFunction = Easing.in(Easing.exp);
17
+ easingHeightV: EasingFunction = Easing.out(Easing.exp);
18
18
 
19
19
  static createInstance<T extends typeof BaseAnimationBuilder>(
20
20
  this: T
@@ -22,42 +22,42 @@ export class CurvedTransition
22
22
  return new CurvedTransition() as InstanceType<T>;
23
23
  }
24
24
 
25
- static easingX(easing: EasingFn): CurvedTransition {
25
+ static easingX(easing: EasingFunction): CurvedTransition {
26
26
  const instance = this.createInstance();
27
27
  return instance.easingX(easing);
28
28
  }
29
29
 
30
- easingX(easing: EasingFn): CurvedTransition {
30
+ easingX(easing: EasingFunction): CurvedTransition {
31
31
  this.easingXV = easing;
32
32
  return this;
33
33
  }
34
34
 
35
- static easingY(easing: EasingFn): CurvedTransition {
35
+ static easingY(easing: EasingFunction): CurvedTransition {
36
36
  const instance = this.createInstance();
37
37
  return instance.easingY(easing);
38
38
  }
39
39
 
40
- easingY(easing: EasingFn): CurvedTransition {
40
+ easingY(easing: EasingFunction): CurvedTransition {
41
41
  this.easingYV = easing;
42
42
  return this;
43
43
  }
44
44
 
45
- static easingWidth(easing: EasingFn): CurvedTransition {
45
+ static easingWidth(easing: EasingFunction): CurvedTransition {
46
46
  const instance = this.createInstance();
47
47
  return instance.easingWidth(easing);
48
48
  }
49
49
 
50
- easingWidth(easing: EasingFn): CurvedTransition {
50
+ easingWidth(easing: EasingFunction): CurvedTransition {
51
51
  this.easingWidthV = easing;
52
52
  return this;
53
53
  }
54
54
 
55
- static easingHeight(easing: EasingFn): CurvedTransition {
55
+ static easingHeight(easing: EasingFunction): CurvedTransition {
56
56
  const instance = this.createInstance();
57
57
  return instance.easingHeight(easing);
58
58
  }
59
59
 
60
- easingHeight(easing: EasingFn): CurvedTransition {
60
+ easingHeight(easing: EasingFunction): CurvedTransition {
61
61
  this.easingHeightV = easing;
62
62
  return this;
63
63
  }
@@ -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';
@@ -5,7 +5,7 @@ import { isSharedValue } from './utils';
5
5
 
6
6
  const IS_JEST = isJest();
7
7
 
8
- export type Mapper = {
8
+ type Mapper = {
9
9
  id: number;
10
10
  dirty: boolean;
11
11
  worklet: () => void;
@@ -13,7 +13,7 @@ export type Mapper = {
13
13
  outputs?: SharedValue<any>[];
14
14
  };
15
15
 
16
- export function createMapperRegistry() {
16
+ function createMapperRegistry() {
17
17
  'worklet';
18
18
  const mappers = new Map();
19
19
  let sortedMappers: Mapper[] = [];
@@ -1,6 +1,8 @@
1
1
  /* eslint-disable node/no-callback-literal */
2
2
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
3
  // @ts-nocheck
4
+ import { SensorType } from './commonTypes';
5
+
4
6
  const NOOP = () => {
5
7
  // noop
6
8
  };
@@ -54,6 +56,31 @@ const ReanimatedV2 = {
54
56
  useAnimatedRef: () => ({ current: null }),
55
57
  useAnimatedReaction: NOOP,
56
58
  useAnimatedProps: IMMEDIATE_CB_INVOCATION,
59
+ SensorType: SensorType,
60
+ useAnimatedSensor: () => ({
61
+ sensor: {
62
+ value: {
63
+ x: 0,
64
+ y: 0,
65
+ z: 0,
66
+ interfaceOrientation: 0,
67
+ qw: 0,
68
+ qx: 0,
69
+ qy: 0,
70
+ qz: 0,
71
+ yaw: 0,
72
+ pitch: 0,
73
+ roll: 0,
74
+ },
75
+ },
76
+ unregister: NOOP,
77
+ isAvailable: false,
78
+ config: {
79
+ interval: 0,
80
+ adjustToInterfaceOrientation: false,
81
+ iosReferenceFrame: 0,
82
+ },
83
+ }),
57
84
 
58
85
  withTiming: (toValue, _, cb) => {
59
86
  cb && cb(true);
@@ -7,7 +7,6 @@ import {
7
7
  } from './shareables';
8
8
  import { runOnUI } from './threads';
9
9
  import { valueSetter } from './valueSetter';
10
- export { stopMapper } from './mappers';
11
10
 
12
11
  export function makeUIMutable<T>(
13
12
  initial: T,
@@ -15,6 +15,8 @@ export function checkCppVersion() {
15
15
  }
16
16
  }
17
17
 
18
+ // This is used only in test files, therefore it is reported by ts-prune (which is desired)
19
+ // ts-prune-ignore-next
18
20
  export function matchVersion(version1: string, version2: string) {
19
21
  if (version1.match(/^\d+\.\d+\.\d+$/) && version2.match(/^\d+\.\d+\.\d+$/)) {
20
22
  // x.y.z, compare only major and minor, skip patch
@@ -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 const jsVersion = '3.4.0';
6
+ export const jsVersion = '3.4.2';
@@ -1,6 +1,5 @@
1
1
  import type { AnimationObject, AnimatableValue } from './commonTypes';
2
2
  import type { Descriptor } from './hook/commonTypes';
3
- export { stopMapper } from './mappers';
4
3
 
5
4
  export function valueSetter(sv: any, value: any): void {
6
5
  'worklet';
@@ -35,7 +35,7 @@ import type { MutableRefObject } from 'react';
35
35
  * module.exports = MyViewWithRef;
36
36
  */
37
37
 
38
- export type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);
38
+ type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);
39
39
 
40
40
  function setAndForwardRef<T>({
41
41
  getForwardedRef,
@@ -1,69 +0,0 @@
1
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
- import { shouldBeUseWeb } from '../PlatformChecker';
5
- import MutableValue from './MutableValue';
6
- export default class Mapper {
7
- constructor(module, mapper) {
8
- let inputs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
9
- let outputs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
10
- _defineProperty(this, "id", void 0);
11
- _defineProperty(this, "inputs", void 0);
12
- _defineProperty(this, "outputs", void 0);
13
- _defineProperty(this, "mapper", void 0);
14
- _defineProperty(this, "dirty", true);
15
- this.id = Mapper.MAPPER_ID++;
16
- this.inputs = this.extractMutablesFromArray(inputs);
17
- this.outputs = this.extractMutablesFromArray(outputs);
18
- this.mapper = mapper;
19
- const markDirty = () => {
20
- this.dirty = true;
21
- module.maybeRequestRender();
22
- };
23
- this.inputs.forEach(input => {
24
- input.addListener(markDirty);
25
- });
26
- }
27
- execute() {
28
- this.dirty = false;
29
- this.mapper();
30
- }
31
- extractMutablesFromArray(array) {
32
- const res = [];
33
- function extractMutables(value) {
34
- if (value == null) {
35
- // return;
36
- } else if (value instanceof MutableValue) {
37
- res.push(value);
38
- } else if (Array.isArray(value)) {
39
- value.forEach(v => extractMutables(v));
40
- } else if (isWebDomElement(value)) {
41
- // do nothing on dom elements
42
- // without this check, we get a "Maximum call size exceeded error"
43
- } else if (typeof value === 'object') {
44
- Object.keys(value).forEach(key => {
45
- extractMutables(value[key]);
46
- });
47
- }
48
- }
49
- extractMutables(array);
50
- return res;
51
- }
52
- }
53
- _defineProperty(Mapper, "MAPPER_ID", 1);
54
- function isWebDomElement(value) {
55
- if (!shouldBeUseWeb()) {
56
- return false;
57
- }
58
-
59
- // https://stackoverflow.com/a/384380/7869175
60
- function isWebNode(o) {
61
- return typeof Node === 'object' ? o instanceof Node : o && typeof o === 'object' && typeof o.nodeType === 'number' && typeof o.nodeName === 'string';
62
- }
63
- function isWebElement(o) {
64
- return typeof HTMLElement === 'object' ? o instanceof HTMLElement // DOM2
65
- : o && typeof o === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string';
66
- }
67
- return isWebNode(value) || isWebElement(value);
68
- }
69
- //# sourceMappingURL=Mapper.js.map