react-native-reanimated 2.7.0 → 2.9.1

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 (83) hide show
  1. package/Common/cpp/Tools/RuntimeDecorator.cpp +17 -11
  2. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  3. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  4. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  5. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  6. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  8. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  10. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  11. package/android/.gradle/checksums/checksums.lock +0 -0
  12. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  13. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  14. package/android/CMakeLists.txt +21 -8
  15. package/android/build.gradle +23 -8
  16. package/android/react-native-reanimated-65-hermes.aar +0 -0
  17. package/android/react-native-reanimated-65-jsc.aar +0 -0
  18. package/android/react-native-reanimated-66-hermes.aar +0 -0
  19. package/android/react-native-reanimated-66-jsc.aar +0 -0
  20. package/android/react-native-reanimated-67-hermes.aar +0 -0
  21. package/android/react-native-reanimated-67-jsc.aar +0 -0
  22. package/android/react-native-reanimated-68-hermes.aar +0 -0
  23. package/android/react-native-reanimated-68-jsc.aar +0 -0
  24. package/android/react-native-reanimated-69-hermes.aar +0 -0
  25. package/android/react-native-reanimated-69-jsc.aar +0 -0
  26. package/android/rnVersionPatch/69/.gitkeep +0 -0
  27. package/android/src/main/cpp/NativeProxy.cpp +35 -14
  28. package/android/src/main/cpp/headers/NativeProxy.h +2 -0
  29. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +24 -1
  30. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +7 -5
  31. package/ios/native/NativeProxy.mm +6 -2
  32. package/ios/native/REAInitializer.mm +11 -1
  33. package/ios/sensor/ReanimatedSensor.m +2 -2
  34. package/lib/Animated.js +8 -30
  35. package/lib/index.js +5 -30
  36. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +1 -1
  37. package/lib/reanimated2/animation/sequence.js +0 -3
  38. package/lib/reanimated2/component/FlatList.js +3 -3
  39. package/lib/reanimated2/component/Image.js +4 -0
  40. package/lib/reanimated2/component/ScrollView.js +4 -0
  41. package/lib/reanimated2/component/Text.js +4 -0
  42. package/lib/reanimated2/component/View.js +4 -0
  43. package/lib/reanimated2/core.js +0 -5
  44. package/lib/reanimated2/hook/utils.js +0 -5
  45. package/lib/reanimated2/js-reanimated/global.js +25 -0
  46. package/lib/reanimated2/js-reanimated/index.js +0 -24
  47. package/lib/reanimated2/mock.js +6 -0
  48. package/lib/types/lib/Animated.d.ts +8 -0
  49. package/lib/types/lib/index.d.ts +4 -0
  50. package/lib/types/lib/reanimated2/component/Image.d.ts +3 -0
  51. package/lib/types/lib/reanimated2/component/ScrollView.d.ts +3 -0
  52. package/lib/types/lib/reanimated2/component/Text.d.ts +3 -0
  53. package/lib/types/lib/reanimated2/component/View.d.ts +3 -0
  54. package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +1 -3
  55. package/lib/types/lib/reanimated2/js-reanimated/global.d.ts +1 -0
  56. package/lib/types/lib/reanimated2/mock.d.ts +6 -0
  57. package/package.json +15 -9
  58. package/plugin.js +36 -21
  59. package/react-native-reanimated.d.ts +16 -7
  60. package/src/Animated.ts +13 -0
  61. package/src/index.ts +7 -0
  62. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +1 -1
  63. package/src/reanimated2/animation/sequence.ts +0 -5
  64. package/src/reanimated2/component/FlatList.tsx +3 -6
  65. package/src/reanimated2/component/Image.ts +6 -0
  66. package/src/reanimated2/component/ScrollView.ts +6 -0
  67. package/src/reanimated2/component/Text.ts +6 -0
  68. package/src/reanimated2/component/View.ts +6 -0
  69. package/src/reanimated2/core.ts +0 -5
  70. package/src/reanimated2/hook/useAnimatedSensor.ts +1 -3
  71. package/src/reanimated2/hook/utils.ts +0 -6
  72. package/src/reanimated2/js-reanimated/global.ts +33 -0
  73. package/src/reanimated2/js-reanimated/index.ts +0 -31
  74. package/src/reanimated2/mock.ts +6 -0
  75. package/android/react-native-reanimated-64-hermes.aar +0 -0
  76. package/android/react-native-reanimated-64-jsc.aar +0 -0
  77. package/lib/reanimated2/component/WrappedComponents.js +0 -9
  78. package/lib/reanimated2/component/index.js +0 -4
  79. package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +0 -8
  80. package/lib/types/lib/reanimated2/component/index.d.ts +0 -9
  81. package/src/Animated.js +0 -31
  82. package/src/reanimated2/component/WrappedComponents.ts +0 -11
  83. package/src/reanimated2/component/index.ts +0 -9
@@ -1,29 +1,5 @@
1
1
  import JSReanimated from './JSReanimated';
2
- import { shouldBeUseWeb } from '../PlatformChecker';
3
2
  const reanimatedJS = new JSReanimated();
4
- if (shouldBeUseWeb()) {
5
- global._frameTimestamp = null;
6
- global._setGlobalConsole = (_val) => {
7
- // noop
8
- };
9
- global._measure = () => {
10
- console.warn("[Reanimated] You can't use `measure` with Chrome Debugger or with web version");
11
- return {
12
- x: 0,
13
- y: 0,
14
- width: 0,
15
- height: 0,
16
- pageX: 0,
17
- pageY: 0,
18
- };
19
- };
20
- global._scrollTo = () => {
21
- console.warn("[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version");
22
- };
23
- global._setGestureState = () => {
24
- console.warn("[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version");
25
- };
26
- }
27
3
  export const _updatePropsJS = (updates, viewRef) => {
28
4
  if (viewRef._component) {
29
5
  const component = viewRef._component;
@@ -64,6 +64,12 @@ const ReanimatedV2 = {
64
64
  out: ID,
65
65
  inOut: ID,
66
66
  },
67
+ Extrapolation: {
68
+ EXTEND: 'extend',
69
+ CLAMP: 'clamp',
70
+ IDENTITY: 'identity',
71
+ },
67
72
  runOnJS: (fn) => fn,
73
+ runOnUI: (fn) => fn,
68
74
  };
69
75
  module.exports = Object.assign({}, ReanimatedV2);
@@ -0,0 +1,8 @@
1
+ export { default as createAnimatedComponent } from './createAnimatedComponent';
2
+ export { addWhitelistedNativeProps, addWhitelistedUIProps, } from './ConfigHelper';
3
+ export { default as Text } from './reanimated2/component/Text';
4
+ export { default as View } from './reanimated2/component/View';
5
+ export { default as ScrollView } from './reanimated2/component/ScrollView';
6
+ export { default as Image } from './reanimated2/component/Image';
7
+ export { default as FlatList } from './reanimated2/component/FlatList';
8
+ export * from './reanimated1';
@@ -0,0 +1,4 @@
1
+ import './reanimated2/js-reanimated/global';
2
+ export * from './reanimated1';
3
+ export * from './reanimated2';
4
+ export * as default from './Animated';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const AnimatedImage: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
3
+ export default AnimatedImage;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const AnimatedScrollView: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
3
+ export default AnimatedScrollView;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const AnimatedText: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
3
+ export default AnimatedText;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const AnimatedView: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
3
+ export default AnimatedView;
@@ -13,8 +13,6 @@ export declare type AnimatedSensor = {
13
13
  sensor: SensorValue3D | SensorValueRotation | null;
14
14
  unregister: () => void;
15
15
  isAvailable: boolean;
16
- config: {
17
- interval: number;
18
- };
16
+ config: SensorConfig;
19
17
  };
20
18
  export declare function useAnimatedSensor(sensorType: SensorType, userConfig?: SensorConfig): AnimatedSensor;
@@ -51,5 +51,11 @@ declare const ReanimatedV2: {
51
51
  out: (t: any) => any;
52
52
  inOut: (t: any) => any;
53
53
  };
54
+ Extrapolation: {
55
+ EXTEND: string;
56
+ CLAMP: string;
57
+ IDENTITY: string;
58
+ };
54
59
  runOnJS: (fn: any) => any;
60
+ runOnUI: (fn: any) => any;
55
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "2.7.0",
3
+ "version": "2.9.1",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "start": "node node_modules/react-native/local-cli/cli.js start",
@@ -34,10 +34,10 @@
34
34
  "clean:deep": "cd android && rm -rf .cxx .gradle build && cd ../Example/android && rm -rf .gradle build app/build && cd ../.. && yarn clean",
35
35
  "reset:deep": "yarn clean:deep && yarn setup"
36
36
  },
37
- "main": "lib/Animated.js",
38
- "module": "lib/Animated",
39
- "react-native": "src/Animated",
40
- "source": "src/Animated",
37
+ "main": "lib/index.js",
38
+ "module": "lib/index",
39
+ "react-native": "src/index",
40
+ "source": "src/index",
41
41
  "types": "react-native-reanimated.d.ts",
42
42
  "files": [
43
43
  "Common/",
@@ -74,6 +74,7 @@
74
74
  },
75
75
  "homepage": "https://github.com/software-mansion/react-native-reanimated#readme",
76
76
  "dependencies": {
77
+ "@babel/plugin-proposal-export-namespace-from": "^7.17.12",
77
78
  "@babel/plugin-transform-object-assign": "^7.16.7",
78
79
  "@babel/preset-typescript": "^7.16.7",
79
80
  "@types/invariant": "^2.2.35",
@@ -121,11 +122,11 @@
121
122
  "lint-staged": "^11.2.0",
122
123
  "madge": "^5.0.1",
123
124
  "prettier": "^2.5.1",
124
- "react": "17.0.2",
125
- "react-native": "0.68.0",
125
+ "react": "18.0.0",
126
+ "react-native": "0.69.1",
126
127
  "react-native-codegen": "^0.0.7",
127
128
  "react-native-gesture-handler": "^1.6.1",
128
- "react-test-renderer": "17.0.2",
129
+ "react-test-renderer": "18.0.0",
129
130
  "release-it": "^13.7.2",
130
131
  "typescript": "^4.1.3"
131
132
  },
@@ -154,5 +155,10 @@
154
155
  "commonjs",
155
156
  "module"
156
157
  ]
157
- }
158
+ },
159
+ "sideEffects": [
160
+ "./lib/reanimated2/core",
161
+ "./lib/reanimated2/js-reanimated/global",
162
+ "./lib/index"
163
+ ]
158
164
  }
package/plugin.js CHANGED
@@ -14,7 +14,6 @@ const functionArgsToWorkletize = new Map([
14
14
  ['useAnimatedScrollHandler', [0]],
15
15
  ['useAnimatedReaction', [0, 1]],
16
16
  ['useWorkletCallback', [0]],
17
- ['createWorklet', [0]],
18
17
  // animations' callbacks
19
18
  ['withTiming', [2]],
20
19
  ['withSpring', [2]],
@@ -331,7 +330,7 @@ function makeWorkletName(t, fun) {
331
330
  return '_f'; // fallback for ArrowFunctionExpression and unnamed FunctionExpression
332
331
  }
333
332
 
334
- function makeWorklet(t, fun, fileName) {
333
+ function makeWorklet(t, fun, state) {
335
334
  // Returns a new FunctionExpression which is a workletized version of provided
336
335
  // FunctionDeclaration, FunctionExpression, ArrowFunctionExpression or ObjectMethod.
337
336
 
@@ -358,7 +357,7 @@ function makeWorklet(t, fun, fileName) {
358
357
  '\n(' + (t.isObjectMethod(fun) ? 'function ' : '') + fun.toString() + '\n)';
359
358
 
360
359
  const transformed = transformSync(code, {
361
- filename: fileName,
360
+ filename: state.file.opts.filename,
362
361
  presets: ['@babel/preset-typescript'],
363
362
  plugins: [
364
363
  '@babel/plugin-transform-shorthand-properties',
@@ -445,11 +444,17 @@ function makeWorklet(t, fun, fileName) {
445
444
  );
446
445
  const workletHash = hash(funString);
447
446
 
447
+ let location = state.file.opts.filename;
448
+ if (state.opts.relativeSourceLocation) {
449
+ const path = require('path');
450
+ location = path.relative(state.cwd, location);
451
+ }
452
+
448
453
  const loc = fun && fun.node && fun.node.loc && fun.node.loc.start;
449
454
  if (loc) {
450
455
  const { line, column } = loc;
451
456
  if (typeof line === 'number' && typeof column === 'number') {
452
- fileName = `${fileName} (${line}:${column})`;
457
+ location = `${location} (${line}:${column})`;
453
458
  }
454
459
  }
455
460
 
@@ -490,7 +495,7 @@ function makeWorklet(t, fun, fileName) {
490
495
  t.identifier('__location'),
491
496
  false
492
497
  ),
493
- t.stringLiteral(fileName)
498
+ t.stringLiteral(location)
494
499
  )
495
500
  ),
496
501
  ];
@@ -518,7 +523,7 @@ function makeWorklet(t, fun, fileName) {
518
523
  return newFun;
519
524
  }
520
525
 
521
- function processWorkletFunction(t, fun, fileName) {
526
+ function processWorkletFunction(t, fun, state) {
522
527
  // Replaces FunctionDeclaration, FunctionExpression or ArrowFunctionExpression
523
528
  // with a workletized version of itself.
524
529
 
@@ -526,7 +531,7 @@ function processWorkletFunction(t, fun, fileName) {
526
531
  return;
527
532
  }
528
533
 
529
- const newFun = makeWorklet(t, fun, fileName);
534
+ const newFun = makeWorklet(t, fun, state);
530
535
 
531
536
  const replacement = t.callExpression(newFun, []);
532
537
 
@@ -546,14 +551,14 @@ function processWorkletFunction(t, fun, fileName) {
546
551
  );
547
552
  }
548
553
 
549
- function processWorkletObjectMethod(t, path, fileName) {
554
+ function processWorkletObjectMethod(t, path, state) {
550
555
  // Replaces ObjectMethod with a workletized version of itself.
551
556
 
552
557
  if (!t.isFunctionParent(path)) {
553
558
  return;
554
559
  }
555
560
 
556
- const newFun = makeWorklet(t, path, fileName);
561
+ const newFun = makeWorklet(t, path, state);
557
562
 
558
563
  const replacement = t.objectProperty(
559
564
  t.identifier(path.node.key.name),
@@ -563,7 +568,7 @@ function processWorkletObjectMethod(t, path, fileName) {
563
568
  path.replaceWith(replacement);
564
569
  }
565
570
 
566
- function processIfWorkletNode(t, fun, fileName) {
571
+ function processIfWorkletNode(t, fun, state) {
567
572
  fun.traverse({
568
573
  DirectiveLiteral(path) {
569
574
  const value = path.node.value;
@@ -581,14 +586,14 @@ function processIfWorkletNode(t, fun, fileName) {
581
586
  directive.value.value === 'worklet'
582
587
  )
583
588
  ) {
584
- processWorkletFunction(t, fun, fileName);
589
+ processWorkletFunction(t, fun, state);
585
590
  }
586
591
  }
587
592
  },
588
593
  });
589
594
  }
590
595
 
591
- function processIfGestureHandlerEventCallbackFunctionNode(t, fun, fileName) {
596
+ function processIfGestureHandlerEventCallbackFunctionNode(t, fun, state) {
592
597
  // Auto-workletizes React Native Gesture Handler callback functions.
593
598
  // Detects `Gesture.Tap().onEnd(<fun>)` or similar, but skips `something.onEnd(<fun>)`.
594
599
  // Supports method chaining as well, e.g. `Gesture.Tap().onStart(<fun1>).onUpdate(<fun2>).onEnd(<fun3>)`.
@@ -641,7 +646,7 @@ function processIfGestureHandlerEventCallbackFunctionNode(t, fun, fileName) {
641
646
  t.isCallExpression(fun.parent) &&
642
647
  isGestureObjectEventCallbackMethod(t, fun.parent.callee)
643
648
  ) {
644
- processWorkletFunction(t, fun, fileName);
649
+ processWorkletFunction(t, fun, state);
645
650
  }
646
651
  }
647
652
 
@@ -697,7 +702,7 @@ function isGestureObject(t, node) {
697
702
  );
698
703
  }
699
704
 
700
- function processWorklets(t, path, fileName) {
705
+ function processWorklets(t, path, state) {
701
706
  const name =
702
707
  path.node.callee.type === 'MemberExpression'
703
708
  ? path.node.callee.property.name
@@ -709,17 +714,17 @@ function processWorklets(t, path, fileName) {
709
714
  const properties = path.get('arguments.0.properties');
710
715
  for (const property of properties) {
711
716
  if (t.isObjectMethod(property)) {
712
- processWorkletObjectMethod(t, property, fileName);
717
+ processWorkletObjectMethod(t, property, state);
713
718
  } else {
714
719
  const value = property.get('value');
715
- processWorkletFunction(t, value, fileName);
720
+ processWorkletFunction(t, value, state);
716
721
  }
717
722
  }
718
723
  } else {
719
724
  const indexes = functionArgsToWorkletize.get(name);
720
725
  if (Array.isArray(indexes)) {
721
726
  indexes.forEach((index) => {
722
- processWorkletFunction(t, path.get(`arguments.${index}`), fileName);
727
+ processWorkletFunction(t, path.get(`arguments.${index}`), state);
723
728
  });
724
729
  }
725
730
  }
@@ -751,6 +756,16 @@ function isPossibleOptimization(fun) {
751
756
  return flags;
752
757
  }
753
758
 
759
+ const pluginProposalExportNamespaceFrom =
760
+ require('@babel/plugin-proposal-export-namespace-from').default;
761
+ const apiMock = {
762
+ assertVersion: () => {
763
+ // do nothing.
764
+ },
765
+ };
766
+ const ExportNamedDeclarationFn =
767
+ pluginProposalExportNamespaceFrom(apiMock).visitor.ExportNamedDeclaration;
768
+
754
769
  module.exports = function ({ types: t }) {
755
770
  return {
756
771
  pre() {
@@ -764,16 +779,16 @@ module.exports = function ({ types: t }) {
764
779
  visitor: {
765
780
  CallExpression: {
766
781
  enter(path, state) {
767
- processWorklets(t, path, state.file.opts.filename);
782
+ processWorklets(t, path, state);
768
783
  },
769
784
  },
770
785
  'FunctionDeclaration|FunctionExpression|ArrowFunctionExpression': {
771
786
  enter(path, state) {
772
- const fileName = state.file.opts.filename;
773
- processIfWorkletNode(t, path, fileName);
774
- processIfGestureHandlerEventCallbackFunctionNode(t, path, fileName);
787
+ processIfWorkletNode(t, path, state);
788
+ processIfGestureHandlerEventCallbackFunctionNode(t, path, state);
775
789
  },
776
790
  },
791
+ ExportNamedDeclaration: ExportNamedDeclarationFn,
777
792
  },
778
793
  };
779
794
  };
@@ -156,7 +156,7 @@ declare module 'react-native-reanimated' {
156
156
  : Record<string, unknown>;
157
157
 
158
158
  export type AnimateProps<P extends object> = {
159
- [K in keyof P]: P[K] | AnimatedNode<P[K]>;
159
+ [K in keyof Omit<P, 'style'>]: P[K] | AnimatedNode<P[K]>;
160
160
  } & {
161
161
  style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
162
162
  } & {
@@ -498,10 +498,17 @@ declare module 'react-native-reanimated' {
498
498
  interval: number;
499
499
  };
500
500
 
501
+ export type AnimatedSensor = {
502
+ sensor: SensorValue3D | SensorValueRotation | null;
503
+ unregister: () => void;
504
+ isAvailable: boolean;
505
+ config: SensorConfig;
506
+ };
507
+
501
508
  export function useAnimatedSensor(
502
509
  sensorType: SensorType,
503
510
  userConfig?: SensorConfig
504
- );
511
+ ): AnimatedSensor;
505
512
 
506
513
  export interface ExitAnimationsValues {
507
514
  currentOriginX: number;
@@ -614,14 +621,19 @@ declare module 'react-native-reanimated' {
614
621
  callback?: AnimationCallback
615
622
  ): number;
616
623
  export function cancelAnimation<T>(sharedValue: SharedValue<T>): void;
617
- export function withDelay<T extends AnimatableValue>(delayMS: number, delayedAnimation: T): T;
624
+ export function withDelay<T extends AnimatableValue>(
625
+ delayMS: number,
626
+ delayedAnimation: T
627
+ ): T;
618
628
  export function withRepeat<T extends AnimatableValue>(
619
629
  animation: T,
620
630
  numberOfReps?: number,
621
631
  reverse?: boolean,
622
632
  callback?: AnimationCallback
623
633
  ): T;
624
- export function withSequence<T extends AnimatableValue>(...animations: [T, ...T[]]): T;
634
+ export function withSequence<T extends AnimatableValue>(
635
+ ...animations: [T, ...T[]]
636
+ ): T;
625
637
 
626
638
  // reanimated2 functions
627
639
  export function runOnUI<A extends any[], R>(
@@ -638,9 +650,6 @@ declare module 'react-native-reanimated' {
638
650
  ): PropsAdapterFunction;
639
651
 
640
652
  export function processColor(color: number | string): number;
641
- export function createWorklet<A extends any[], R>(
642
- fn: (...args: A) => R
643
- ): (...args: Parameters<typeof fn>) => R;
644
653
 
645
654
  export function interpolateColor<T extends string | number>(
646
655
  value: number,
@@ -0,0 +1,13 @@
1
+ export { default as createAnimatedComponent } from './createAnimatedComponent';
2
+ export {
3
+ addWhitelistedNativeProps,
4
+ addWhitelistedUIProps,
5
+ } from './ConfigHelper';
6
+
7
+ export { default as Text } from './reanimated2/component/Text';
8
+ export { default as View } from './reanimated2/component/View';
9
+ export { default as ScrollView } from './reanimated2/component/ScrollView';
10
+ export { default as Image } from './reanimated2/component/Image';
11
+ export { default as FlatList } from './reanimated2/component/FlatList';
12
+ // @ts-ignore backward compatibility with treeshaking
13
+ export * from './reanimated1';
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ // tree-shaken side effects
2
+ import './reanimated2/js-reanimated/global';
3
+
4
+ // @ts-ignore backward compatibility with treeshaking
5
+ export * from './reanimated1';
6
+ export * from './reanimated2';
7
+ export * as default from './Animated';
@@ -11,7 +11,7 @@ export class NativeReanimated {
11
11
  private InnerNativeModule: any;
12
12
 
13
13
  constructor(native = true) {
14
- if (global.__reanimatedModuleProxy === undefined) {
14
+ if (global.__reanimatedModuleProxy === undefined && native) {
15
15
  const { ReanimatedModule } = NativeModules;
16
16
  ReanimatedModule?.installTurboModule();
17
17
  }
@@ -63,11 +63,6 @@ export function withSequence(
63
63
  now: Timestamp,
64
64
  previousAnimation: SequenceAnimation
65
65
  ): void {
66
- if (animations.length === 1) {
67
- throw Error(
68
- 'withSequence() animation require more than one animation as argument'
69
- );
70
- }
71
66
  animation.animationIndex = 0;
72
67
  if (previousAnimation === undefined) {
73
68
  previousAnimation = animations[
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { FlatList, FlatListProps, LayoutChangeEvent } from 'react-native';
3
- import WrappedComponents from './WrappedComponents';
3
+ import ReanimatedView from './View';
4
4
  import createAnimatedComponent from '../../createAnimatedComponent';
5
5
  import { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
6
6
 
@@ -11,12 +11,9 @@ const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
11
11
  onLayout: (event: LayoutChangeEvent) => void;
12
12
  }> = (props) => {
13
13
  return (
14
- <WrappedComponents.View
15
- layout={itemLayoutAnimation}
16
- onLayout={props.onLayout}
17
- >
14
+ <ReanimatedView layout={itemLayoutAnimation} onLayout={props.onLayout}>
18
15
  {props.children}
19
- </WrappedComponents.View>
16
+ </ReanimatedView>
20
17
  );
21
18
  };
22
19
 
@@ -0,0 +1,6 @@
1
+ import { Image } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+
4
+ const AnimatedImage = createAnimatedComponent(Image as any);
5
+
6
+ export default AnimatedImage;
@@ -0,0 +1,6 @@
1
+ import { ScrollView } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+
4
+ const AnimatedScrollView = createAnimatedComponent(ScrollView);
5
+
6
+ export default AnimatedScrollView;
@@ -0,0 +1,6 @@
1
+ import { Text } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+
4
+ const AnimatedText = createAnimatedComponent(Text as any);
5
+
6
+ export default AnimatedText;
@@ -0,0 +1,6 @@
1
+ import { View } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+
4
+ const AnimatedView = createAnimatedComponent(View);
5
+
6
+ export default AnimatedView;
@@ -333,11 +333,6 @@ if (!isWeb() && isConfigured()) {
333
333
  info: runOnJS(capturableConsole.info),
334
334
  };
335
335
  _setGlobalConsole(console);
336
- if (global.performance == null) {
337
- global.performance = {
338
- now: global._chronoNow,
339
- } as any; // due to conflict with lib.dom.d.ts -> Performance
340
- }
341
336
  })();
342
337
  }
343
338
 
@@ -19,9 +19,7 @@ export type AnimatedSensor = {
19
19
  sensor: SensorValue3D | SensorValueRotation | null;
20
20
  unregister: () => void;
21
21
  isAvailable: boolean;
22
- config: {
23
- interval: number;
24
- };
22
+ config: SensorConfig;
25
23
  };
26
24
 
27
25
  export function useAnimatedSensor(
@@ -44,12 +44,6 @@ export function useEvent<T extends NativeEvent<T>>(
44
44
  initRef.current.updateWorklet(handler);
45
45
  }
46
46
 
47
- useEffect(() => {
48
- return () => {
49
- initRef.current = null;
50
- };
51
- }, []);
52
-
53
47
  return initRef;
54
48
  }
55
49
 
@@ -0,0 +1,33 @@
1
+ // In order to keep bundle size down, we treat this file as a polyfill for Web.
2
+
3
+ import { shouldBeUseWeb } from '../PlatformChecker';
4
+
5
+ if (shouldBeUseWeb()) {
6
+ global._frameTimestamp = null;
7
+ global._setGlobalConsole = (_val) => {
8
+ // noop
9
+ };
10
+ global._measure = () => {
11
+ console.warn(
12
+ "[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
13
+ );
14
+ return {
15
+ x: 0,
16
+ y: 0,
17
+ width: 0,
18
+ height: 0,
19
+ pageX: 0,
20
+ pageY: 0,
21
+ };
22
+ };
23
+ global._scrollTo = () => {
24
+ console.warn(
25
+ "[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version"
26
+ );
27
+ };
28
+ global._setGestureState = () => {
29
+ console.warn(
30
+ "[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version"
31
+ );
32
+ };
33
+ }
@@ -1,5 +1,4 @@
1
1
  import JSReanimated from './JSReanimated';
2
- import { shouldBeUseWeb } from '../PlatformChecker';
3
2
  import { AnimatedStyle, StyleProps } from '../commonTypes';
4
3
 
5
4
  const reanimatedJS = new JSReanimated();
@@ -13,36 +12,6 @@ interface JSReanimatedComponent {
13
12
  };
14
13
  }
15
14
 
16
- if (shouldBeUseWeb()) {
17
- global._frameTimestamp = null;
18
- global._setGlobalConsole = (_val) => {
19
- // noop
20
- };
21
- global._measure = () => {
22
- console.warn(
23
- "[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
24
- );
25
- return {
26
- x: 0,
27
- y: 0,
28
- width: 0,
29
- height: 0,
30
- pageX: 0,
31
- pageY: 0,
32
- };
33
- };
34
- global._scrollTo = () => {
35
- console.warn(
36
- "[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version"
37
- );
38
- };
39
- global._setGestureState = () => {
40
- console.warn(
41
- "[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version"
42
- );
43
- };
44
- }
45
-
46
15
  export const _updatePropsJS = (
47
16
  updates: StyleProps | AnimatedStyle,
48
17
  viewRef: { _component?: JSReanimatedComponent }
@@ -65,8 +65,14 @@ const ReanimatedV2 = {
65
65
  out: ID,
66
66
  inOut: ID,
67
67
  },
68
+ Extrapolation: {
69
+ EXTEND: 'extend',
70
+ CLAMP: 'clamp',
71
+ IDENTITY: 'identity',
72
+ },
68
73
 
69
74
  runOnJS: (fn) => fn,
75
+ runOnUI: (fn) => fn,
70
76
  };
71
77
 
72
78
  module.exports = {
@@ -1,9 +0,0 @@
1
- import { Image, ScrollView, Text, View } from 'react-native';
2
- import createAnimatedComponent from '../../createAnimatedComponent';
3
- const WrappedComponents = {
4
- View: createAnimatedComponent(View),
5
- Text: createAnimatedComponent(Text),
6
- Image: createAnimatedComponent(Image),
7
- ScrollView: createAnimatedComponent(ScrollView),
8
- };
9
- export default WrappedComponents;