react-native-reanimated 3.0.0 → 3.0.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 (42) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/createAnimatedComponent.js +12 -0
  3. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  4. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +3 -0
  5. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  6. package/lib/commonjs/reanimated2/initializers.js +1 -1
  7. package/lib/commonjs/reanimated2/initializers.js.map +1 -1
  8. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +5 -0
  9. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  10. package/lib/commonjs/reanimated2/mock.js.map +1 -1
  11. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +1 -1
  12. package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -1
  13. package/lib/commonjs/reanimated2/threads.js +10 -13
  14. package/lib/commonjs/reanimated2/threads.js.map +1 -1
  15. package/lib/commonjs/reanimated2/utils.js +1 -1
  16. package/lib/commonjs/reanimated2/utils.js.map +1 -1
  17. package/lib/module/createAnimatedComponent.js +12 -0
  18. package/lib/module/createAnimatedComponent.js.map +1 -1
  19. package/lib/module/reanimated2/hook/useAnimatedSensor.js +2 -0
  20. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  21. package/lib/module/reanimated2/initializers.js +1 -1
  22. package/lib/module/reanimated2/initializers.js.map +1 -1
  23. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +5 -0
  24. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  25. package/lib/module/reanimated2/mock.js.map +1 -1
  26. package/lib/module/reanimated2/platform-specific/checkVersion.js +1 -1
  27. package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -1
  28. package/lib/module/reanimated2/threads.js +10 -13
  29. package/lib/module/reanimated2/threads.js.map +1 -1
  30. package/lib/module/reanimated2/utils.js +1 -1
  31. package/lib/module/reanimated2/utils.js.map +1 -1
  32. package/mock.js +1 -211
  33. package/package.json +1 -1
  34. package/react-native-reanimated.d.ts +12 -429
  35. package/src/createAnimatedComponent.tsx +9 -0
  36. package/src/reanimated2/hook/useAnimatedSensor.ts +2 -0
  37. package/src/reanimated2/initializers.ts +1 -1
  38. package/src/reanimated2/layoutReanimation/animationsManager.ts +3 -0
  39. package/src/reanimated2/mock.ts +1 -1
  40. package/src/reanimated2/platform-specific/checkVersion.ts +1 -1
  41. package/src/reanimated2/threads.ts +10 -13
  42. package/src/reanimated2/utils.ts +1 -1
@@ -4,7 +4,6 @@
4
4
  declare module 'react-native-reanimated' {
5
5
  import {
6
6
  ComponentClass,
7
- ReactNode,
8
7
  Component,
9
8
  RefObject,
10
9
  FunctionComponent,
@@ -58,74 +57,14 @@ declare module 'react-native-reanimated' {
58
57
  import('./lib/types/lib/reanimated2/commonTypes').MeasuredDimensions;
59
58
 
60
59
  namespace Animated {
61
- type Nullable<T> = T | null | undefined;
62
- class AnimatedNode<T> {
63
- constructor(
64
- nodeConfig: object,
65
- inputNodes?: ReadonlyArray<AnimatedNode<any>>
66
- );
67
-
68
- isNativelyInitialized(): boolean;
69
- /**
70
- * ' __value' is not available at runtime on AnimatedNode<T>. It is
71
- * necessary to have some discriminating property on a type to know that
72
- * an AnimatedNode<number> and AnimatedNode<string> are not compatible types.
73
- */
74
- ' __value': T;
75
- }
76
- class AnimatedClock extends AnimatedNode<number> {
77
- constructor();
78
- }
79
-
80
- export enum Extrapolate {
81
- EXTEND = 'extend',
82
- CLAMP = 'clamp',
83
- IDENTITY = 'identity',
84
- }
85
-
86
- type ExtrapolateParameter =
87
- | Extrapolate
88
- | { extrapolateLeft?: Extrapolate; extrapolateRight?: Extrapolate };
89
-
90
- interface InterpolationConfig {
91
- inputRange: ReadonlyArray<Adaptable<number>>;
92
- outputRange: ReadonlyArray<Adaptable<number | string>>;
93
- extrapolate?: ExtrapolateParameter;
94
- extrapolateLeft?: Extrapolate;
95
- extrapolateRight?: Extrapolate;
96
- }
97
60
  type Value = string | number | boolean;
98
- class AnimatedValue<T extends Value> extends AnimatedNode<T> {
99
- constructor(value?: T);
100
-
101
- setValue(value: Adaptable<T>): void;
102
-
103
- interpolate(config: InterpolationConfig): AnimatedNode<number>;
104
- }
105
- export interface AnimationState {
106
- finished: AnimatedValue<number>;
107
- position: AnimatedValue<number>;
108
- time: AnimatedValue<number>;
109
- }
110
61
 
111
62
  export type SharedValue<T> = { value: T };
112
63
  export type DerivedValue<T> = Readonly<SharedValue<T>>;
113
- export type Mapping = { [key: string]: Mapping } | Adaptable<any>;
114
64
  export type Adaptable<T> =
115
65
  | T
116
- | AnimatedNode<T>
117
- | ReadonlyArray<T | AnimatedNode<T> | ReadonlyArray<T | AnimatedNode<T>>>
66
+ | ReadonlyArray<T | ReadonlyArray<T>>
118
67
  | SharedValue<T>;
119
- type BinaryOperator<T = number> = (
120
- left: Adaptable<number>,
121
- right: Adaptable<number>
122
- ) => AnimatedNode<T>;
123
- type UnaryOperator = (value: Adaptable<number>) => AnimatedNode<number>;
124
- type MultiOperator<T = number> = (
125
- a: Adaptable<number>,
126
- b: Adaptable<number>,
127
- ...others: Adaptable<number>[]
128
- ) => AnimatedNode<T>;
129
68
 
130
69
  export type TransformStyleTypes = TransformsStyle['transform'] extends
131
70
  | readonly (infer T)[]
@@ -146,13 +85,7 @@ declare module 'react-native-reanimated' {
146
85
  ? AnimateStyle<S[K]>
147
86
  : S[K] extends ColorValue | undefined
148
87
  ? S[K] | number
149
- :
150
- | S[K]
151
- | AnimatedNode<
152
- // allow `number` where `string` normally is to support colors
153
- S[K] extends ColorValue | undefined ? S[K] | number : S[K]
154
- >
155
- | SharedValue<AnimatableValue>;
88
+ : S[K] | SharedValue<AnimatableValue>;
156
89
  };
157
90
 
158
91
  export type StylesOrDefault<T> = 'style' extends keyof T
@@ -160,7 +93,7 @@ declare module 'react-native-reanimated' {
160
93
  : Record<string, unknown>;
161
94
 
162
95
  export type AnimateProps<P extends object> = {
163
- [K in keyof Omit<P, 'style'>]: P[K] | AnimatedNode<P[K]> | SharedValue<P[K]>;
96
+ [K in keyof Omit<P, 'style'>]: P[K] | SharedValue<P[K]>;
164
97
  } & {
165
98
  style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
166
99
  } & {
@@ -183,81 +116,7 @@ declare module 'react-native-reanimated' {
183
116
  sharedTransitionStyle?: ILayoutAnimationBuilder;
184
117
  };
185
118
 
186
- export interface PhysicsAnimationState extends AnimationState {
187
- velocity: AnimatedValue<number>;
188
- }
189
-
190
- export type DecayState = PhysicsAnimationState;
191
-
192
- export interface DecayConfig {
193
- deceleration: Adaptable<number>;
194
- }
195
- export interface BackwardCompatibleWrapper {
196
- start: (callback?: (data: { finished: boolean }) => any) => void;
197
- stop: () => void;
198
- }
199
-
200
- export interface TimingState extends AnimationState {
201
- frameTime: AnimatedValue<number>;
202
- }
203
- export type EasingNodeFunction = (
204
- value: Adaptable<number>
205
- ) => AnimatedNode<number>;
206
119
  export type EasingFunction = (value: number) => number;
207
- export interface TimingConfig {
208
- toValue: Adaptable<number>;
209
- duration: Adaptable<number>;
210
- easing: EasingNodeFunction;
211
- }
212
-
213
- export type SpringState = PhysicsAnimationState;
214
-
215
- export interface SpringConfig {
216
- damping: Adaptable<number>;
217
- mass: Adaptable<number>;
218
- stiffness: Adaptable<number>;
219
- overshootClamping: Adaptable<number> | boolean;
220
- restSpeedThreshold: Adaptable<number>;
221
- restDisplacementThreshold: Adaptable<number>;
222
- toValue: Adaptable<number>;
223
- }
224
- interface SpringConfigWithOrigamiTensionAndFriction {
225
- tension: Adaptable<number>;
226
- mass: Adaptable<number>;
227
- friction: Adaptable<number>;
228
- overshootClamping: Adaptable<number> | boolean;
229
- restSpeedThreshold: Adaptable<number>;
230
- restDisplacementThreshold: Adaptable<number>;
231
- toValue: Adaptable<number>;
232
- }
233
-
234
- interface SpringConfigWithBouncinessAndSpeed {
235
- bounciness: Adaptable<number>;
236
- mass: Adaptable<number>;
237
- speed: Adaptable<number>;
238
- overshootClamping: Adaptable<number> | boolean;
239
- restSpeedThreshold: Adaptable<number>;
240
- restDisplacementThreshold: Adaptable<number>;
241
- toValue: Adaptable<number>;
242
- }
243
-
244
- type SpringUtils = {
245
- makeDefaultConfig: () => SpringConfig;
246
- makeConfigFromBouncinessAndSpeed: (
247
- prevConfig: SpringConfigWithBouncinessAndSpeed
248
- ) => SpringConfig;
249
- makeConfigFromOrigamiTensionAndFriction: (
250
- prevConfig: SpringConfigWithOrigamiTensionAndFriction
251
- ) => SpringConfig;
252
- };
253
-
254
- export const SpringUtils: SpringUtils;
255
-
256
- type CodeProps = {
257
- exec?: AnimatedNode<number>;
258
- children?: () => AnimatedNode<number>;
259
- dependencies?: Array<any>;
260
- };
261
120
 
262
121
  // components
263
122
  export class View extends Component<AnimateProps<ViewProps>> {
@@ -280,8 +139,6 @@ declare module 'react-native-reanimated' {
280
139
  }
281
140
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
282
141
  export interface ScrollView extends ReactNativeScrollView {}
283
-
284
- export class Code extends Component<CodeProps> {}
285
142
  export interface FlatListPropsWithLayout<T> extends FlatListProps<T> {
286
143
  itemLayoutAnimation?: ILayoutAnimationBuilder;
287
144
  }
@@ -305,164 +162,6 @@ declare module 'react-native-reanimated' {
305
162
  options?: Options<P>
306
163
  ): FunctionComponent<AnimateProps<P>>;
307
164
 
308
- // classes
309
- export {
310
- AnimatedClock as Clock,
311
- AnimatedNode as Node,
312
- AnimatedValue as Value,
313
- };
314
-
315
- // base operations
316
- export const add: MultiOperator;
317
- export const sub: MultiOperator;
318
- export const multiply: MultiOperator;
319
- export const divide: MultiOperator;
320
- export const pow: MultiOperator;
321
- export const modulo: MultiOperator;
322
- export const sqrt: UnaryOperator;
323
- export const log: UnaryOperator;
324
- export const sin: UnaryOperator;
325
- export const cos: UnaryOperator;
326
- export const tan: UnaryOperator;
327
- export const acos: UnaryOperator;
328
- export const asin: UnaryOperator;
329
- export const atan: UnaryOperator;
330
- export const exp: UnaryOperator;
331
- export const round: UnaryOperator;
332
- export const floor: UnaryOperator;
333
- export const ceil: UnaryOperator;
334
- export const lessThan: BinaryOperator<0 | 1>;
335
- export const eq: BinaryOperator<0 | 1>;
336
- export const greaterThan: BinaryOperator<0 | 1>;
337
- export const lessOrEq: BinaryOperator<0 | 1>;
338
- export const greaterOrEq: BinaryOperator<0 | 1>;
339
- export const neq: BinaryOperator<0 | 1>;
340
- export const and: MultiOperator<0 | 1>;
341
- export const or: MultiOperator<0 | 1>;
342
- export function proc<T extends (Adaptable<Value> | undefined)[]>(
343
- func: (...args: T) => AnimatedNode<number>
344
- ): typeof func;
345
- export function defined(value: Adaptable<any>): AnimatedNode<0 | 1>;
346
- export function not(value: Adaptable<any>): AnimatedNode<0 | 1>;
347
- export function set<T extends Value>(
348
- valueToBeUpdated: AnimatedValue<T>,
349
- sourceNode: Adaptable<T>
350
- ): AnimatedNode<T>;
351
- export function concat(
352
- ...args: Array<Adaptable<string> | Adaptable<number>>
353
- ): AnimatedNode<string>;
354
- export function cond<T1 extends Value = number, T2 extends Value = number>(
355
- conditionNode: Adaptable<number>,
356
- ifNode: Adaptable<T1>,
357
- elseNode?: Adaptable<T2>
358
- ): AnimatedNode<T1 | T2>;
359
- export function block<T1 extends Value = number, T2 extends Value = any>(
360
- items: ReadonlyArray<Adaptable<T2>>
361
- ): AnimatedNode<T1>;
362
- export function call<T>(
363
- args: ReadonlyArray<T | AnimatedNode<T>>,
364
- callback: (args: ReadonlyArray<T>) => void
365
- ): AnimatedNode<0>;
366
- export function debug<T>(
367
- message: string,
368
- value: AnimatedNode<T>
369
- ): AnimatedNode<T>;
370
- export function onChange(
371
- value: Adaptable<number>,
372
- action: Adaptable<number>
373
- ): AnimatedNode<number>;
374
- export function startClock(clock: AnimatedClock): AnimatedNode<0>;
375
- export function stopClock(clock: AnimatedClock): AnimatedNode<0>;
376
- export function clockRunning(clock: AnimatedClock): AnimatedNode<0 | 1>;
377
- // the return type for `event` is a lie, but it's the same lie that
378
- // react-native makes within Animated
379
- type EventArgFunc<T> = (arg: T) => AnimatedNode<number>;
380
- type EventMapping<T> = T extends object
381
- ? { [K in keyof T]?: EventMapping<T[K]> | EventArgFunc<T[K]> }
382
- : Adaptable<T> | EventArgFunc<T>;
383
- type EventMappingArray<T> = T extends Array<any>
384
- ? { [I in keyof T]: EventMapping<T[I]> }
385
- : [EventMapping<T>];
386
- export function event<T>(
387
- argMapping: T extends never
388
- ? ReadonlyArray<Mapping>
389
- : Readonly<EventMappingArray<T>>,
390
- config?: {}
391
- ): (...args: any[]) => void;
392
-
393
- // derived operations
394
- export function abs(value: Adaptable<number>): AnimatedNode<number>;
395
- export function acc(value: Adaptable<number>): AnimatedNode<number>;
396
- export function color(
397
- r: Adaptable<number>,
398
- g: Adaptable<number>,
399
- b: Adaptable<number>,
400
- a?: Adaptable<number>
401
- ): AnimatedNode<number | string>;
402
- export function diff(value: Adaptable<number>): AnimatedNode<number>;
403
- export function diffClamp(
404
- value: Adaptable<number>,
405
- minVal: Adaptable<number>,
406
- maxVal: Adaptable<number>
407
- ): AnimatedNode<number>;
408
- export function interpolateNode(
409
- value: Adaptable<number>,
410
- config: InterpolationConfig
411
- ): AnimatedNode<number>;
412
- export function interpolateColors<T extends string | number>(
413
- animationValue: Adaptable<number>,
414
- {
415
- inputRange,
416
- outputColorRange,
417
- }: {
418
- inputRange: ReadonlyArray<Adaptable<number>>;
419
- outputColorRange: ReadonlyArray<Adaptable<T>>;
420
- }
421
- ): AnimatedNode<T>;
422
- export const max: BinaryOperator;
423
- export const min: BinaryOperator;
424
-
425
- // animations
426
- export function decay(
427
- clock: AnimatedClock,
428
- state: DecayState,
429
- config: DecayConfig
430
- ): AnimatedNode<number>;
431
- export function timing(
432
- clock: AnimatedClock,
433
- state: TimingState,
434
- config: TimingConfig
435
- ): AnimatedNode<number>;
436
- export function spring(
437
- clock: AnimatedClock,
438
- state: SpringState,
439
- config: SpringConfig
440
- ): AnimatedNode<number>;
441
- // backward compatible API
442
- export function spring(
443
- node: AnimatedNode<number>,
444
- config: SpringConfig
445
- ): BackwardCompatibleWrapper;
446
- export function timing(
447
- node: AnimatedNode<number>,
448
- config: TimingConfig
449
- ): BackwardCompatibleWrapper;
450
- export function decay(
451
- node: AnimatedNode<number>,
452
- config: DecayConfig
453
- ): BackwardCompatibleWrapper;
454
-
455
- // hooks
456
- export function useCode(
457
- exec: () =>
458
- | Nullable<AnimatedNode<number>[] | AnimatedNode<number>>
459
- | boolean,
460
- deps: Array<any>
461
- ): void;
462
- export function useValue<T extends Value>(
463
- initialValue: T
464
- ): AnimatedValue<T>;
465
-
466
165
  // configuration
467
166
  export function addWhitelistedNativeProps(props: {
468
167
  [key: string]: true;
@@ -475,7 +174,6 @@ declare module 'react-native-reanimated' {
475
174
  export type SharedValue<T> = Animated.SharedValue<T>;
476
175
  export type AnimateStyle<S> = Animated.AnimateStyle<S>;
477
176
  export type DerivedValue<T> = Animated.DerivedValue<T>;
478
- export type Mapping = Animated.Mapping;
479
177
  export type Adaptable<T> = Animated.Adaptable<T>;
480
178
  export type TransformStyleTypes = Animated.TransformStyleTypes;
481
179
  export type AdaptTransforms<T> = Animated.AdaptTransforms<T>;
@@ -527,6 +225,13 @@ declare module 'react-native-reanimated' {
527
225
 
528
226
  export type SensorValue3D = SharedValue<Value3D>;
529
227
 
228
+ export enum InterfaceOrientation {
229
+ ROTATION_0 = 0,
230
+ ROTATION_90 = 90,
231
+ ROTATION_180 = 180,
232
+ ROTATION_270 = 270,
233
+ }
234
+
530
235
  export type ValueRotation = {
531
236
  qw: number;
532
237
  qx: number;
@@ -1117,32 +822,6 @@ declare module 'react-native-reanimated' {
1117
822
  export class RollInRight extends ComplexAnimationBuilder {}
1118
823
  export class RollOutLeft extends ComplexAnimationBuilder {}
1119
824
  export class RollOutRight extends ComplexAnimationBuilder {}
1120
- interface EasingNodeStatic {
1121
- linear: Animated.EasingNodeFunction;
1122
- ease: Animated.EasingNodeFunction;
1123
- quad: Animated.EasingNodeFunction;
1124
- cubic: Animated.EasingNodeFunction;
1125
- poly(n: Animated.Adaptable<number>): Animated.EasingNodeFunction;
1126
- sin: Animated.EasingNodeFunction;
1127
- circle: Animated.EasingNodeFunction;
1128
- exp: Animated.EasingNodeFunction;
1129
- elastic(
1130
- bounciness?: Animated.Adaptable<number>
1131
- ): Animated.EasingNodeFunction;
1132
- back(s?: Animated.Adaptable<number>): Animated.EasingNodeFunction;
1133
- bounce: Animated.EasingNodeFunction;
1134
- bezier(
1135
- x1: number,
1136
- y1: number,
1137
- x2: number,
1138
- y2: number
1139
- ): Animated.EasingNodeFunction;
1140
- in(easing: Animated.EasingNodeFunction): Animated.EasingNodeFunction;
1141
- out(easing: Animated.EasingNodeFunction): Animated.EasingNodeFunction;
1142
- inOut(easing: Animated.EasingNodeFunction): Animated.EasingNodeFunction;
1143
- }
1144
-
1145
- export const EasingNode: EasingNodeStatic;
1146
825
 
1147
826
  interface EasingStatic {
1148
827
  linear: Animated.EasingFunction;
@@ -1175,106 +854,10 @@ declare module 'react-native-reanimated' {
1175
854
 
1176
855
  export const Easing: EasingStatic;
1177
856
 
1178
- export interface TransitioningViewProps extends ViewProps {
1179
- transition: ReactNode;
1180
- }
1181
-
1182
- export class TransitioningView extends Component<TransitioningViewProps> {
1183
- animateNextTransition(): void;
1184
- }
1185
-
1186
- export class Transitioning extends Component {
1187
- static View: typeof TransitioningView;
1188
- }
1189
-
1190
- export interface TransitionProps {
1191
- delayMs?: number;
1192
- durationMs?: number;
1193
- interpolation?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut';
1194
- propagation?: 'top' | 'bottom' | 'left' | 'right';
1195
- }
1196
-
1197
- export interface TransitionInOutProps extends TransitionProps {
1198
- type?:
1199
- | 'fade'
1200
- | 'scale'
1201
- | 'slide-top'
1202
- | 'slide-bottom'
1203
- | 'slide-right'
1204
- | 'slide-left';
1205
- }
1206
- export class Transition extends Component {
1207
- static In: ComponentClass<TransitionInOutProps>;
1208
- static Out: ComponentClass<TransitionInOutProps>;
1209
- static Change: ComponentClass<TransitionProps>;
1210
- static Together: ComponentClass<{}>;
1211
- static Sequence: ComponentClass<{}>;
1212
- }
1213
-
1214
- export class Clock extends Animated.Clock {}
1215
- export class Value<
1216
- T extends string | number | boolean
1217
- > extends Animated.Value<T> {}
1218
- export class Node<T> extends Animated.Node<T> {}
1219
- export const add: typeof Animated.add;
1220
- export const sub: typeof Animated.sub;
1221
- export const multiply: typeof Animated.multiply;
1222
- export const divide: typeof Animated.divide;
1223
- export const pow: typeof Animated.pow;
1224
- export const modulo: typeof Animated.modulo;
1225
- export const sqrt: typeof Animated.sqrt;
1226
- export const log: typeof Animated.log;
1227
- export const sin: typeof Animated.sin;
1228
- export const cos: typeof Animated.cos;
1229
- export const exp: typeof Animated.exp;
1230
- export const round: typeof Animated.round;
1231
- export const lessThan: typeof Animated.lessThan;
1232
- export const eq: typeof Animated.eq;
1233
- export const greaterThan: typeof Animated.greaterThan;
1234
- export const lessOrEq: typeof Animated.lessOrEq;
1235
- export const greaterOrEq: typeof Animated.greaterOrEq;
1236
- export const neq: typeof Animated.neq;
1237
- export const and: typeof Animated.and;
1238
- export const or: typeof Animated.or;
1239
- export const defined: typeof Animated.defined;
1240
- export const not: typeof Animated.not;
1241
- export const tan: typeof Animated.tan;
1242
- export const acos: typeof Animated.acos;
1243
- export const asin: typeof Animated.asin;
1244
- export const atan: typeof Animated.atan;
1245
- export const proc: typeof Animated.proc;
1246
- export const block: typeof Animated.block;
1247
- export const concat: typeof Animated.concat;
1248
- export const event: typeof Animated.event;
1249
- export const call: typeof Animated.call;
1250
- export const debug: typeof Animated.debug;
1251
- export const clockRunning: typeof Animated.clockRunning;
1252
- export const stopClock: typeof Animated.stopClock;
1253
- export const startClock: typeof Animated.startClock;
1254
- export const set: typeof Animated.set;
1255
- export const cond: typeof Animated.cond;
1256
- export const abs: typeof Animated.abs;
1257
- export const acc: typeof Animated.acc;
1258
- export const color: typeof Animated.color;
1259
- export const interpolateColors: typeof Animated.interpolateColors;
1260
- export const diff: typeof Animated.diff;
1261
- export const diffClamp: typeof Animated.diffClamp;
1262
- export const interpolateNode: typeof Animated.interpolateNode;
1263
- export const Extrapolate: typeof Animated.Extrapolate;
1264
- export const max: typeof Animated.max;
1265
- export const min: typeof Animated.min;
1266
- export const onChange: typeof Animated.onChange;
1267
- export const floor: typeof Animated.floor;
1268
- export const ceil: typeof Animated.ceil;
1269
- export const useCode: typeof Animated.useCode;
1270
- export const decay: typeof Animated.decay;
1271
- export const timing: typeof Animated.timing;
1272
- export const spring: typeof Animated.spring;
1273
- export const SpringUtils: typeof Animated.SpringUtils;
1274
- export const useValue: typeof Animated.useValue;
1275
- export const ReverseAnimation: typeof Animated.ReverseAnimation;
1276
857
  export function enableLayoutAnimations(flag: boolean): void;
1277
858
 
859
+ export const Extrapolate: typeof Extrapolation;
860
+
1278
861
  type AnimationFactoryType = (values: LayoutAnimationsValues) => StyleProps;
1279
862
 
1280
863
  export class SharedTransition implements ILayoutAnimationBuilder {
@@ -116,10 +116,16 @@ const has = <K extends string>(
116
116
  };
117
117
 
118
118
  function isInlineStyleTransform(transform: any): boolean {
119
+ if (!transform) {
120
+ return false;
121
+ }
119
122
  return transform.some((t: Record<string, any>) => hasInlineStyles(t));
120
123
  }
121
124
 
122
125
  function hasInlineStyles(style: StyleProps): boolean {
126
+ if (!style) {
127
+ return false;
128
+ }
123
129
  return Object.keys(style).some((key) => {
124
130
  const styleValue = style[key];
125
131
  return (
@@ -139,6 +145,9 @@ function extractSharedValuesMapFromProps(
139
145
  if (key === 'style') {
140
146
  const styles = flattenArray<StyleProps>(props.style ?? []);
141
147
  styles.forEach((style) => {
148
+ if (!style) {
149
+ return;
150
+ }
142
151
  for (const [key, styleValue] of Object.entries(style)) {
143
152
  if (isSharedValue(styleValue)) {
144
153
  inlineProps[key] = styleValue;
@@ -7,6 +7,7 @@ import {
7
7
  ValueRotation,
8
8
  IOSReferenceFrame,
9
9
  } from '../commonTypes';
10
+ import { flushImmediates } from '../threads';
10
11
 
11
12
  export type SensorConfig = {
12
13
  interval: number | 'auto';
@@ -144,6 +145,7 @@ export function useAnimatedSensor(
144
145
  }
145
146
  }
146
147
  sensorData.value = data;
148
+ flushImmediates();
147
149
  }
148
150
  );
149
151
 
@@ -128,7 +128,7 @@ function setupRequestAnimationFrame() {
128
128
  global.__frameTimestamp = undefined;
129
129
  });
130
130
  }
131
- // Reanimated currently does not support cancelling calbacks requested with
131
+ // Reanimated currently does not support cancelling callbacks requested with
132
132
  // requestAnimationFrame. We return -1 as identifier which isn't in line
133
133
  // with the spec but it should give users better clue in case they actually
134
134
  // attempt to store the value returned from rAF and use it for cancelling.
@@ -88,6 +88,9 @@ function createLayoutAnimationManager() {
88
88
  },
89
89
  stop(tag: number) {
90
90
  const value = mutableValuesForTag.get(tag);
91
+ if (!value) {
92
+ return;
93
+ }
91
94
  stopObservingProgress(tag, value, true, true);
92
95
  },
93
96
  };
@@ -28,7 +28,7 @@ class BaseAnimationMock {
28
28
  return this;
29
29
  }
30
30
 
31
- withCallback(_: (finsihed: boolean) => void) {
31
+ withCallback(_: (finished: boolean) => void) {
32
32
  return this;
33
33
  }
34
34
 
@@ -3,7 +3,7 @@
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
- const jsVersion = '3.0.0';
6
+ const jsVersion = '3.0.2';
7
7
 
8
8
  /**
9
9
  * Checks that native and js versions of reanimated match.
@@ -7,26 +7,27 @@ import {
7
7
  } from './shareables';
8
8
 
9
9
  const IS_JEST = isJest();
10
+ const IS_WEB = shouldBeUseWeb();
10
11
 
11
12
  let _runOnUIQueue: Array<[ComplexWorkletFunction<any[], any>, any[]]> = [];
12
13
 
13
14
  export function setupSetImmediate() {
14
15
  'worklet';
15
16
 
16
- let immediateCalbacks: Array<() => void> = [];
17
+ let immediateCallbacks: Array<() => void> = [];
17
18
 
18
19
  // @ts-ignore – typescript expects this to conform to NodeJS definition and expects the return value to be NodeJS.Immediate which is an object and not a number
19
20
  global.setImmediate = (callback: () => void): number => {
20
- immediateCalbacks.push(callback);
21
+ immediateCallbacks.push(callback);
21
22
  return -1;
22
23
  };
23
24
 
24
25
  global.__flushImmediates = () => {
25
- for (let index = 0; index < immediateCalbacks.length; index += 1) {
26
+ for (let index = 0; index < immediateCallbacks.length; index += 1) {
26
27
  // we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to setImmediate calls
27
- immediateCalbacks[index]();
28
+ immediateCallbacks[index]();
28
29
  }
29
- immediateCalbacks = [];
30
+ immediateCallbacks = [];
30
31
  };
31
32
  }
32
33
 
@@ -49,10 +50,8 @@ export const flushImmediates = shouldBeUseWeb()
49
50
  export function runOnUI<A extends any[], R>(
50
51
  worklet: ComplexWorkletFunction<A, R>
51
52
  ): (...args: A) => void {
52
- if (__DEV__ && !shouldBeUseWeb()) {
53
- if (worklet.__workletHash === undefined) {
54
- throw new Error('runOnUI() can only be used on worklets');
55
- }
53
+ if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {
54
+ throw new Error('runOnUI() can only be used on worklets');
56
55
  }
57
56
  return (...args) => {
58
57
  if (IS_JEST) {
@@ -98,10 +97,8 @@ export function runOnUI<A extends any[], R>(
98
97
  export function runOnUIImmediately<A extends any[], R>(
99
98
  worklet: ComplexWorkletFunction<A, R>
100
99
  ): (...args: A) => void {
101
- if (__DEV__) {
102
- if (worklet.__workletHash === undefined) {
103
- throw new Error('runOnUI() can only be used on worklets');
104
- }
100
+ if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {
101
+ throw new Error('runOnUI() can only be used on worklets');
105
102
  }
106
103
  return (...args) => {
107
104
  NativeReanimatedModule.scheduleOnUI(
@@ -30,5 +30,5 @@ export function getRelativeCoords(
30
30
 
31
31
  export function isSharedValue<T>(value: any): value is SharedValue<T> {
32
32
  'worklet';
33
- return typeof value === 'object' && value._isReanimatedSharedValue === true;
33
+ return value?._isReanimatedSharedValue === true;
34
34
  }