react-native-reanimated 2.3.0-beta.2 → 2.3.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 (168) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +12 -3
  2. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
  3. package/Common/cpp/Registries/EventHandlerRegistry.cpp +2 -2
  4. package/Common/cpp/Registries/MapperRegistry.cpp +5 -5
  5. package/Common/cpp/SharedItems/FrozenObject.cpp +1 -3
  6. package/Common/cpp/SharedItems/ShareableValue.cpp +8 -10
  7. package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
  8. package/Common/cpp/Tools/JSIStoreValueUser.cpp +8 -8
  9. package/Common/cpp/Tools/Mapper.cpp +1 -1
  10. package/Common/cpp/Tools/RuntimeDecorator.cpp +40 -4
  11. package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -1
  12. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +5 -0
  13. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +6 -1
  14. package/Common/cpp/headers/Registries/EventHandlerRegistry.h +1 -0
  15. package/Common/cpp/headers/Registries/MapperRegistry.h +1 -0
  16. package/Common/cpp/headers/SharedItems/FrozenObject.h +4 -0
  17. package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +2 -0
  18. package/Common/cpp/headers/SharedItems/MutableValue.h +2 -0
  19. package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +3 -1
  20. package/Common/cpp/headers/SharedItems/RemoteObject.h +4 -1
  21. package/Common/cpp/headers/SharedItems/ShareableValue.h +2 -0
  22. package/Common/cpp/headers/SharedItems/SharedParent.h +9 -9
  23. package/Common/cpp/headers/SharedItems/ValueWrapper.h +32 -28
  24. package/Common/cpp/headers/SpecTools/ErrorHandler.h +1 -0
  25. package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
  26. package/Common/cpp/headers/Tools/JSIStoreValueUser.h +2 -5
  27. package/Common/cpp/headers/Tools/Mapper.h +2 -0
  28. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
  29. package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +1 -5
  30. package/Common/cpp/headers/Tools/RuntimeDecorator.h +10 -7
  31. package/Common/cpp/headers/Tools/Scheduler.h +2 -0
  32. package/Common/cpp/headers/Tools/WorkletEventHandler.h +2 -1
  33. package/Common/cpp/hidden_headers/Logger.h +2 -2
  34. package/Common/cpp/hidden_headers/LoggerInterface.h +1 -1
  35. package/README.md +1 -1
  36. package/RNReanimated.podspec +21 -3
  37. package/android/build.gradle +33 -13
  38. package/android/expo/linking.gradle +46 -0
  39. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
  40. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
  41. package/android/react-native-reanimated-63-hermes.aar +0 -0
  42. package/android/react-native-reanimated-63-jsc.aar +0 -0
  43. package/android/react-native-reanimated-64-hermes.aar +0 -0
  44. package/android/react-native-reanimated-64-jsc.aar +0 -0
  45. package/android/react-native-reanimated-65-hermes.aar +0 -0
  46. package/android/react-native-reanimated-65-jsc.aar +0 -0
  47. package/android/react-native-reanimated-66-hermes.aar +0 -0
  48. package/android/react-native-reanimated-66-jsc.aar +0 -0
  49. package/android/react-native-reanimated-67-hermes.aar +0 -0
  50. package/android/react-native-reanimated-67-jsc.aar +0 -0
  51. package/expo-module.config.json +3 -0
  52. package/ios/LayoutReanimation/REAAnimationsManager.m +65 -19
  53. package/ios/LayoutReanimation/REAUIManager.mm +101 -61
  54. package/ios/Nodes/REAPropsNode.m +1 -1
  55. package/ios/REAEventDispatcher.m +1 -1
  56. package/ios/REAModule.h +0 -2
  57. package/ios/REAModule.m +0 -3
  58. package/ios/REANodesManager.m +1 -0
  59. package/ios/RNGestureHandlerStateManager.h +5 -0
  60. package/ios/native/NativeMethods.h +5 -0
  61. package/ios/native/NativeMethods.mm +14 -6
  62. package/ios/native/NativeProxy.h +1 -0
  63. package/ios/native/NativeProxy.mm +84 -63
  64. package/ios/native/REAIOSErrorHandler.mm +19 -15
  65. package/ios/native/REAIOSLogger.mm +10 -6
  66. package/ios/native/REAIOSScheduler.mm +17 -10
  67. package/ios/native/REAInitializer.mm +39 -37
  68. package/ios/native/UIResponder+Reanimated.mm +2 -2
  69. package/lib/Animated.js +11 -5
  70. package/lib/ConfigHelper.js +121 -138
  71. package/lib/ReanimatedEventEmitter.js +0 -1
  72. package/lib/ReanimatedModule.js +0 -1
  73. package/lib/ReanimatedModule.macos.js +0 -1
  74. package/lib/ReanimatedModule.native.js +5 -6
  75. package/lib/ReanimatedModule.windows.js +0 -1
  76. package/lib/ReanimatedModuleCompat.js +64 -35
  77. package/lib/createAnimatedComponent.js +469 -499
  78. package/lib/index.js +11 -5
  79. package/lib/reanimated1/core/Core.test.js +1 -1
  80. package/lib/reanimated2/NativeMethods.js +7 -0
  81. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +3 -0
  82. package/lib/reanimated2/PropAdapters.js +0 -1
  83. package/lib/reanimated2/UpdateProps.js +1 -1
  84. package/lib/reanimated2/ViewDescriptorsSet.js +4 -2
  85. package/lib/reanimated2/animation/spring.js +2 -0
  86. package/lib/reanimated2/animation/styleAnimation.js +5 -1
  87. package/lib/reanimated2/animation/util.js +23 -0
  88. package/lib/reanimated2/component/FlatList.js +30 -0
  89. package/lib/reanimated2/component/WrappedComponents.js +9 -0
  90. package/lib/reanimated2/component/index.js +4 -0
  91. package/lib/reanimated2/core.js +34 -6
  92. package/lib/reanimated2/globals.d.ts +8 -0
  93. package/lib/reanimated2/js-reanimated/JSReanimated.js +4 -0
  94. package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
  95. package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
  96. package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
  97. package/lib/reanimated2/js-reanimated/index.js +10 -8
  98. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +14 -5
  99. package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +14 -14
  100. package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +8 -8
  101. package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +16 -16
  102. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -16
  103. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +4 -4
  104. package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
  105. package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
  106. package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
  107. package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
  108. package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
  109. package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
  110. package/lib/reanimated2/mock.js +3 -1
  111. package/lib/setAndForwardRef.js +14 -48
  112. package/mock.js +1 -1
  113. package/package.json +27 -23
  114. package/plugin.js +111 -110
  115. package/react-native-reanimated.d.ts +56 -27
  116. package/src/Animated.js +11 -5
  117. package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
  118. package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
  119. package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
  120. package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
  121. package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
  122. package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
  123. package/src/ReanimatedModuleCompat.ts +51 -0
  124. package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +278 -124
  125. package/src/reanimated1/core/Core.test.js +1 -1
  126. package/src/reanimated2/NativeMethods.ts +13 -1
  127. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -11
  128. package/src/reanimated2/PropAdapters.ts +0 -1
  129. package/src/reanimated2/UpdateProps.ts +1 -1
  130. package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
  131. package/src/reanimated2/animation/commonTypes.ts +4 -4
  132. package/src/reanimated2/animation/decay.ts +2 -2
  133. package/src/reanimated2/animation/delay.ts +3 -3
  134. package/src/reanimated2/animation/index.ts +7 -7
  135. package/src/reanimated2/animation/repeat.ts +4 -4
  136. package/src/reanimated2/animation/sequence.ts +2 -2
  137. package/src/reanimated2/animation/spring.ts +6 -5
  138. package/src/reanimated2/animation/styleAnimation.ts +24 -12
  139. package/src/reanimated2/animation/timing.ts +5 -5
  140. package/src/reanimated2/animation/util.ts +45 -6
  141. package/src/reanimated2/component/FlatList.tsx +44 -0
  142. package/src/reanimated2/component/WrappedComponents.ts +11 -0
  143. package/src/reanimated2/component/index.ts +9 -0
  144. package/src/reanimated2/core.ts +62 -17
  145. package/src/reanimated2/globals.d.ts +8 -0
  146. package/src/reanimated2/hook/useAnimatedStyle.ts +2 -2
  147. package/src/reanimated2/js-reanimated/JSReanimated.ts +15 -26
  148. package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
  149. package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
  150. package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
  151. package/src/reanimated2/js-reanimated/index.ts +31 -14
  152. package/src/reanimated2/layoutReanimation/{LayoutAnimationRepository.tsx → LayoutAnimationRepository.ts} +18 -5
  153. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
  154. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
  155. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
  156. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
  157. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
  158. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
  159. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
  160. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
  161. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +9 -9
  162. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
  163. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
  164. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
  165. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
  166. package/src/reanimated2/mock.ts +3 -1
  167. package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
  168. package/src/ReanimatedModuleCompat.js +0 -37
package/lib/index.js CHANGED
@@ -1,17 +1,15 @@
1
- import { Image, ScrollView, Text, View } from 'react-native';
1
+ import { LogBox } from 'react-native';
2
2
  import createAnimatedComponent from './createAnimatedComponent';
3
3
  import {
4
4
  addWhitelistedNativeProps,
5
5
  addWhitelistedUIProps,
6
6
  } from './ConfigHelper';
7
7
  import * as reanimated1 from './reanimated1';
8
+ import ReanimatedComponents from './reanimated2/component';
8
9
 
9
10
  const Animated = {
10
11
  // components
11
- View: createAnimatedComponent(View),
12
- Text: createAnimatedComponent(Text),
13
- Image: createAnimatedComponent(Image),
14
- ScrollView: createAnimatedComponent(ScrollView),
12
+ ...ReanimatedComponents,
15
13
  createAnimatedComponent,
16
14
  // configuration
17
15
  addWhitelistedNativeProps,
@@ -23,3 +21,11 @@ const Animated = {
23
21
  export * from './reanimated2';
24
22
  export * from './reanimated1';
25
23
  export default Animated;
24
+
25
+ // I think we can ignore this message as long as Gesture Handler doesn't
26
+ // try to load the Reanimated module. I figured it should be here instead of
27
+ // RNGH because this prevents the message from being displayed for all
28
+ // versions of RNGH.
29
+ LogBox.ignoreLogs([
30
+ 'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
31
+ ]);
@@ -5,7 +5,7 @@ import renderer from 'react-test-renderer';
5
5
 
6
6
  jest.mock('../../ReanimatedEventEmitter');
7
7
  jest.mock('../../ReanimatedModule');
8
- jest.mock('../../reanimated2/NativeReanimated');
8
+ jest.mock('../../reanimated2/NativeReanimated/NativeReanimated');
9
9
 
10
10
  describe('Core Animated components', () => {
11
11
  xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
@@ -23,3 +23,10 @@ export function scrollTo(animatedRef, x, y, animated) {
23
23
  const viewTag = animatedRef();
24
24
  _scrollTo(viewTag, x, y, animated);
25
25
  }
26
+ export function setGestureState(handlerTag, newState) {
27
+ 'worklet';
28
+ if (!_WORKLET && !isChromeDebugger()) {
29
+ console.warn('[Reanimated] You can not use setGestureState in non-worklet function.');
30
+ }
31
+ _setGestureState(handlerTag, newState);
32
+ }
@@ -31,4 +31,7 @@ export class NativeReanimated {
31
31
  getViewProp(viewTag, propName, callback) {
32
32
  return InnerNativeModule.getViewProp(viewTag, propName, callback);
33
33
  }
34
+ enableLayoutAnimations(flag) {
35
+ InnerNativeModule.enableLayoutAnimations(flag);
36
+ }
34
37
  }
@@ -1,4 +1,3 @@
1
- // @ts-ignore JS file
2
1
  import { addWhitelistedNativeProps } from '../ConfigHelper';
3
2
  export function createAnimatedPropAdapter(adapter, nativeProps) {
4
3
  const nativePropsToAdd = {};
@@ -19,7 +19,7 @@ export const colorProps = [
19
19
  'textShadowColor',
20
20
  'overlayColor',
21
21
  ];
22
- const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
22
+ export const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
23
23
  let updatePropsByPlatform;
24
24
  if (shouldBeUseWeb()) {
25
25
  updatePropsByPlatform = (_, updates, maybeViewRef) => {
@@ -1,5 +1,7 @@
1
1
  import { useRef } from 'react';
2
2
  import { makeMutable } from './core';
3
+ import { Platform } from 'react-native';
4
+ const scheduleUpdates = Platform.OS === 'web' ? requestAnimationFrame : setImmediate;
3
5
  export function makeViewDescriptorsSet() {
4
6
  const ref = useRef(null);
5
7
  if (ref.current === null) {
@@ -18,7 +20,7 @@ export function makeViewDescriptorsSet() {
18
20
  data.items.push(item);
19
21
  if (!data.waitForInsertSync) {
20
22
  data.waitForInsertSync = true;
21
- setImmediate(() => {
23
+ scheduleUpdates(() => {
22
24
  data.sharableViewDescriptors.value = data.items;
23
25
  data.waitForInsertSync = false;
24
26
  });
@@ -28,7 +30,7 @@ export function makeViewDescriptorsSet() {
28
30
  data.batchToRemove.add(viewTag);
29
31
  if (!data.waitForRemoveSync) {
30
32
  data.waitForRemoveSync = true;
31
- setImmediate(() => {
33
+ scheduleUpdates(() => {
32
34
  const items = [];
33
35
  for (const item of data.items) {
34
36
  if (data.batchToRemove.has(item.tag)) {
@@ -73,6 +73,8 @@ export function withSpring(toValue, userConfig, callback) {
73
73
  animation.velocity = 0;
74
74
  animation.current = toValue;
75
75
  }
76
+ // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one
77
+ animation.lastTimestamp = 0;
76
78
  return true;
77
79
  }
78
80
  return false;
@@ -1,5 +1,7 @@
1
1
  import { defineAnimation } from './util';
2
2
  import { withTiming } from './timing';
3
+ import { ColorProperties } from '../UpdateProps';
4
+ import { processColor } from '../Colors';
3
5
  // resolves path to value for nested objects
4
6
  // if path cannot be resolved returns undefined
5
7
  export function resolvePath(obj, path) {
@@ -15,7 +17,6 @@ export function resolvePath(obj, path) {
15
17
  return undefined;
16
18
  }, obj);
17
19
  }
18
- // set value at given path
19
20
  export function setPath(obj, path, value) {
20
21
  'worklet';
21
22
  const keys = Array.isArray(path) ? path : [path];
@@ -80,6 +81,9 @@ export function withStyleAnimation(styleAnimations) {
80
81
  else {
81
82
  stillGoing = true;
82
83
  }
84
+ if (ColorProperties.includes(currentEntry.path[0])) {
85
+ currentStyleAnimation.current = processColor(currentStyleAnimation.current);
86
+ }
83
87
  setPath(animation.current, currentEntry.path, currentStyleAnimation.current);
84
88
  }
85
89
  }
@@ -107,12 +107,35 @@ function decorateAnimation(animation) {
107
107
  animation.current = toRGBA(res);
108
108
  return finished;
109
109
  };
110
+ const arrayOnStart = (animation, value, timestamp, previousAnimation) => {
111
+ value.forEach((v, i) => {
112
+ animation[i] = Object.assign({}, animationCopy);
113
+ animation[i].current = v;
114
+ animation[i].toValue = animation.toValue[i];
115
+ animation[i].onStart(animation[i], v, timestamp, previousAnimation ? previousAnimation[i] : undefined);
116
+ });
117
+ animation.current = value;
118
+ };
119
+ const arrayOnFrame = (animation, timestamp) => {
120
+ let finished = true;
121
+ animation.current.forEach((v, i) => {
122
+ // @ts-ignore: disable-next-line
123
+ finished &= animation[i].onFrame(animation[i], timestamp);
124
+ animation.current[i] = animation[i].current;
125
+ });
126
+ return finished;
127
+ };
110
128
  animation.onStart = (animation, value, timestamp, previousAnimation) => {
111
129
  if (isColor(value)) {
112
130
  colorOnStart(animation, value, timestamp, previousAnimation);
113
131
  animation.onFrame = colorOnFrame;
114
132
  return;
115
133
  }
134
+ else if (Array.isArray(value)) {
135
+ arrayOnStart(animation, value, timestamp, previousAnimation);
136
+ animation.onFrame = arrayOnFrame;
137
+ return;
138
+ }
116
139
  else if (typeof value === 'string') {
117
140
  prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);
118
141
  animation.onFrame = prefNumberSuffOnFrame;
@@ -0,0 +1,30 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React from 'react';
13
+ import { FlatList } from 'react-native';
14
+ import WrappedComponents from './WrappedComponents';
15
+ import createAnimatedComponent from '../../createAnimatedComponent';
16
+ const AnimatedFlatList = createAnimatedComponent(FlatList);
17
+ const createCellRenderer = (itemLayoutAnimation) => {
18
+ const cellRenderer = (props) => {
19
+ return (<WrappedComponents.View layout={itemLayoutAnimation} onLayout={props.onLayout}>
20
+ {props.children}
21
+ </WrappedComponents.View>);
22
+ };
23
+ return cellRenderer;
24
+ };
25
+ const ReanimatedFlatlist = (_a) => {
26
+ var { itemLayoutAnimation } = _a, restProps = __rest(_a, ["itemLayoutAnimation"]);
27
+ const cellRenderer = React.useMemo(() => createCellRenderer(itemLayoutAnimation), []);
28
+ return (<AnimatedFlatList {...restProps} CellRendererComponent={cellRenderer}/>);
29
+ };
30
+ export default ReanimatedFlatlist;
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,4 @@
1
+ import ReanimatedFlatlist from './FlatList';
2
+ import WrappedComponents from './WrappedComponents';
3
+ const ReanimatedComponents = Object.assign(Object.assign({}, WrappedComponents), { FlatList: ReanimatedFlatlist });
4
+ export default ReanimatedComponents;
@@ -1,7 +1,7 @@
1
1
  /* global _WORKLET _getCurrentTime _frameTimestamp _eventTimestamp, _setGlobalConsole */
2
2
  import NativeReanimatedModule from './NativeReanimated';
3
3
  import { Platform } from 'react-native';
4
- import { nativeShouldBeMock, shouldBeUseWeb } from './PlatformChecker';
4
+ import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
5
5
  global.__reanimatedWorkletInit = function (worklet) {
6
6
  worklet.__worklet = true;
7
7
  };
@@ -135,7 +135,9 @@ function workletValueSetter(value) {
135
135
  (value !== null &&
136
136
  typeof value === 'object' &&
137
137
  value.onFrame !== undefined)) {
138
- const animation = typeof value === 'function' ? value() : value;
138
+ const animation = typeof value === 'function'
139
+ ? value()
140
+ : value;
139
141
  // prevent setting again to the same value
140
142
  // and triggering the mappers that treat this value as an input
141
143
  // this happens when the animation's target value(stored in animation.current until animation.onStart is called) is set to the same value as a current one(this._value)
@@ -196,7 +198,9 @@ function workletValueSetterJS(value) {
196
198
  typeof value === 'object' &&
197
199
  value.onFrame)) {
198
200
  // animated set
199
- const animation = typeof value === 'function' ? value() : value;
201
+ const animation = typeof value === 'function'
202
+ ? value()
203
+ : value;
200
204
  let initializeAnimation = (timestamp) => {
201
205
  animation.onStart(animation, this.value, timestamp, previousAnimation);
202
206
  };
@@ -256,9 +260,11 @@ export function runOnJS(fun) {
256
260
  }
257
261
  }
258
262
  if (!NativeReanimatedModule.useOnlyV1) {
259
- NativeReanimatedModule.installCoreFunctions(NativeReanimatedModule.native ? workletValueSetter : workletValueSetterJS);
260
- const capturableConsole = console;
261
- isConfigured() &&
263
+ NativeReanimatedModule.installCoreFunctions(NativeReanimatedModule.native
264
+ ? workletValueSetter
265
+ : workletValueSetterJS);
266
+ if (!isWeb() && isConfigured()) {
267
+ const capturableConsole = console;
262
268
  runOnUI(() => {
263
269
  'worklet';
264
270
  const console = {
@@ -269,5 +275,27 @@ if (!NativeReanimatedModule.useOnlyV1) {
269
275
  info: runOnJS(capturableConsole.info),
270
276
  };
271
277
  _setGlobalConsole(console);
278
+ global.performance = {
279
+ now: global._chronoNow,
280
+ };
272
281
  })();
282
+ }
283
+ }
284
+ let featuresConfig = {
285
+ enableLayoutAnimations: false,
286
+ setByUser: false,
287
+ };
288
+ export function enableLayoutAnimations(flag, isCallByUser = true) {
289
+ if (isCallByUser) {
290
+ featuresConfig = {
291
+ enableLayoutAnimations: flag,
292
+ setByUser: true,
293
+ };
294
+ NativeReanimatedModule.enableLayoutAnimations(flag);
295
+ }
296
+ else if (!featuresConfig.setByUser &&
297
+ featuresConfig.enableLayoutAnimations !== flag) {
298
+ featuresConfig.enableLayoutAnimations = flag;
299
+ NativeReanimatedModule.enableLayoutAnimations(flag);
300
+ }
273
301
  }
@@ -13,6 +13,7 @@ declare global {
13
13
  tag: number,
14
14
  flag: { value: boolean; _value: boolean }
15
15
  ) => void;
16
+ const _setGestureState: (handlerTag: number, newState: number) => void;
16
17
  const _updateProps: (
17
18
  tag: number,
18
19
  name: string,
@@ -25,13 +26,20 @@ declare global {
25
26
  y: number,
26
27
  animated: boolean
27
28
  ) => void;
29
+ const _chronoNow: () => number;
28
30
  namespace NodeJS {
29
31
  interface Global {
30
32
  __reanimatedWorkletInit: (worklet: WorkletFunction) => void;
31
33
  _setGlobalConsole: (console?: ReanimatedConsole) => void;
32
34
  _log: (s: string) => void;
35
+ _setGestureState: () => void;
33
36
  _WORKLET: boolean;
34
37
  __reanimatedModuleProxy: NativeReanimated;
38
+ _frameTimestamp: number | null;
39
+ _measure: () => MeasuredDimensions;
40
+ _scrollTo: () => void;
41
+ _chronoNow: () => number;
42
+ performance: { now: () => number };
35
43
  LayoutAnimationRepository: {
36
44
  configs: Record<string, unknown>;
37
45
  registerConfig(tag: number, config: Record<string, unknown>): void;
@@ -50,6 +50,7 @@ export default class JSReanimated extends NativeReanimated {
50
50
  return value;
51
51
  }
52
52
  makeMutable(value) {
53
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
53
54
  return new MutableValue(value, this._valueSetter);
54
55
  }
55
56
  makeRemote(object = {}) {
@@ -71,4 +72,7 @@ export default class JSReanimated extends NativeReanimated {
71
72
  unregisterEventHandler(_) {
72
73
  // noop
73
74
  }
75
+ enableLayoutAnimations() {
76
+ console.warn('[Reanimated] enableLayoutAnimations is not available for WEB yet');
77
+ }
74
78
  }
@@ -1,5 +1,3 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
1
  import MutableValue from './MutableValue';
4
2
  export default class Mapper {
5
3
  constructor(module, mapper, inputs = [], outputs = []) {
@@ -23,7 +21,10 @@ export default class Mapper {
23
21
  extractMutablesFromArray(array) {
24
22
  const res = [];
25
23
  function extractMutables(value) {
26
- if (value instanceof MutableValue) {
24
+ if (value == null) {
25
+ // return;
26
+ }
27
+ else if (value instanceof MutableValue) {
27
28
  res.push(value);
28
29
  }
29
30
  else if (Array.isArray(value)) {
@@ -1,5 +1,3 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
1
  export default class MapperRegistry {
4
2
  constructor(module) {
5
3
  this.sortedMappers = [];
@@ -78,7 +76,8 @@ export default class MapperRegistry {
78
76
  while (nodes.length)
79
77
  dfs(nodes[0]);
80
78
  const postArray = Object.keys(post).map((key) => {
81
- return [key, post[key]];
79
+ const num = parseInt(key);
80
+ return [num, post[num]];
82
81
  });
83
82
  postArray.sort((a, b) => {
84
83
  return b[1] - a[1];
@@ -95,9 +94,7 @@ export default class MapperRegistry {
95
94
  }
96
95
  }
97
96
  class Node {
98
- constructor(mapper, _parents = [], children = []) {
99
- this.mapper = null;
100
- this.children = [];
97
+ constructor(mapper, children = []) {
101
98
  this.mapper = mapper;
102
99
  this.children = children;
103
100
  }
@@ -1,5 +1,3 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
1
  export default class MutableValue {
4
2
  constructor(value, setter) {
5
3
  this._animation = null;
@@ -1,5 +1,3 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
1
  import JSReanimated from './JSReanimated';
4
2
  import { shouldBeUseWeb } from '../PlatformChecker';
5
3
  const reanimatedJS = new JSReanimated();
@@ -22,25 +20,29 @@ if (shouldBeUseWeb()) {
22
20
  global._scrollTo = () => {
23
21
  console.warn("[Reanimated] You can't use 'scrollTo' method with Chrome Debugger or with web version");
24
22
  };
23
+ global._setGestureState = () => {
24
+ console.warn("[Reanimated] You can't use 'setGestureState' method with Chrome Debugger or with web version");
25
+ };
25
26
  }
26
27
  export const _updatePropsJS = (updates, viewRef) => {
27
- if (viewRef === null || viewRef === void 0 ? void 0 : viewRef._component) {
28
+ if (viewRef._component) {
29
+ const component = viewRef._component;
28
30
  const [rawStyles] = Object.keys(updates).reduce((acc, key) => {
29
31
  const value = updates[key];
30
32
  const index = typeof value === 'function' ? 1 : 0;
31
33
  acc[index][key] = value;
32
34
  return acc;
33
35
  }, [{}, {}]);
34
- if (typeof viewRef._component.setNativeProps === 'function') {
35
- setNativeProps(viewRef._component, rawStyles);
36
+ if (typeof component.setNativeProps === 'function') {
37
+ setNativeProps(component, rawStyles);
36
38
  }
37
- else if (Object.keys(viewRef._component.props).length > 0) {
38
- Object.keys(viewRef._component.props).forEach((key) => {
39
+ else if (Object.keys(component.props).length > 0) {
40
+ Object.keys(component.props).forEach((key) => {
39
41
  if (!rawStyles[key]) {
40
42
  return;
41
43
  }
42
44
  const dashedKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
43
- viewRef._component._touchableNode.setAttribute(dashedKey, rawStyles[key]);
45
+ component._touchableNode.setAttribute(dashedKey, rawStyles[key]);
44
46
  });
45
47
  }
46
48
  else {
@@ -1,6 +1,8 @@
1
1
  /* global _stopObservingProgress, _startObservingProgress */
2
2
  import { runOnUI } from '../core';
3
3
  import { withStyleAnimation } from '../animation/styleAnimation';
4
+ import { ColorProperties } from '../UpdateProps';
5
+ import { processColor } from '../Colors';
4
6
  runOnUI(() => {
5
7
  'worklet';
6
8
  const configs = {};
@@ -34,12 +36,19 @@ runOnUI(() => {
34
36
  for (const key in layoutAnimation) {
35
37
  currentAnimation[key] = layoutAnimation[key];
36
38
  }
37
- enteringAnimationForTag[tag] = null;
38
39
  }
39
40
  const sv = configs[tag].sv;
40
41
  _stopObservingProgress(tag, false);
41
42
  _startObservingProgress(tag, sv);
42
- sv._value = Object.assign({}, sv._value, style.initialValues);
43
+ const backupColor = {};
44
+ for (const key in style.initialValues) {
45
+ if (ColorProperties.includes(key)) {
46
+ const value = style.initialValues[key];
47
+ backupColor[key] = value;
48
+ style.initialValues[key] = processColor(value);
49
+ }
50
+ }
51
+ sv.value = Object.assign({}, sv._value, style.initialValues);
43
52
  _stopObservingProgress(tag, false);
44
53
  const animation = withStyleAnimation(currentAnimation);
45
54
  animation.callback = (finished) => {
@@ -47,10 +56,10 @@ runOnUI(() => {
47
56
  _stopObservingProgress(tag, finished);
48
57
  }
49
58
  style.callback && style.callback(finished);
50
- if (type === 'entering') {
51
- enteringAnimationForTag[tag] = null;
52
- }
53
59
  };
60
+ if (backupColor) {
61
+ configs[tag].sv._value = Object.assign(Object.assign({}, configs[tag].sv.value), backupColor);
62
+ }
54
63
  configs[tag].sv.value = animation;
55
64
  _startObservingProgress(tag, sv);
56
65
  },
@@ -2,34 +2,34 @@ export const DefaultLayout = (values) => {
2
2
  'worklet';
3
3
  return {
4
4
  initialValues: {
5
- originX: values.originX,
6
- originY: values.originY,
7
- width: values.width,
8
- height: values.height,
5
+ originX: values.targetOriginX,
6
+ originY: values.targetOriginY,
7
+ width: values.targetWidth,
8
+ height: values.targetHeight,
9
9
  },
10
10
  animations: {},
11
11
  };
12
12
  };
13
- export const DefaultEntering = (targetValues) => {
13
+ export const DefaultEntering = (values) => {
14
14
  'worklet';
15
15
  return {
16
16
  initialValues: {
17
- originX: targetValues.originX,
18
- originY: targetValues.originY,
19
- width: targetValues.width,
20
- height: targetValues.height,
17
+ originX: values.targetOriginX,
18
+ originY: values.targetOriginY,
19
+ width: values.targetWidth,
20
+ height: values.targetHeight,
21
21
  },
22
22
  animations: {},
23
23
  };
24
24
  };
25
- export const DefaultExiting = (startValues) => {
25
+ export const DefaultExiting = (values) => {
26
26
  'worklet';
27
27
  return {
28
28
  initialValues: {
29
- originX: startValues.originX,
30
- originY: startValues.originY,
31
- width: startValues.width,
32
- height: startValues.height,
29
+ originX: values.currentOriginX,
30
+ originY: values.currentOriginY,
31
+ width: values.currentWidth,
32
+ height: values.currentHeight,
33
33
  },
34
34
  animations: {},
35
35
  };
@@ -14,7 +14,7 @@ export class FlipInXUp extends ComplexAnimationBuilder {
14
14
  transform: [
15
15
  { perspective: 500 },
16
16
  { rotateX: '90deg' },
17
- { translateY: -targetValues.height },
17
+ { translateY: -targetValues.targetHeight },
18
18
  ],
19
19
  },
20
20
  animations: {
@@ -48,7 +48,7 @@ export class FlipInYLeft extends ComplexAnimationBuilder {
48
48
  transform: [
49
49
  { perspective: 500 },
50
50
  { rotateY: '-90deg' },
51
- { translateX: -targetValues.width },
51
+ { translateX: -targetValues.targetWidth },
52
52
  ],
53
53
  },
54
54
  animations: {
@@ -82,7 +82,7 @@ export class FlipInXDown extends ComplexAnimationBuilder {
82
82
  transform: [
83
83
  { perspective: 500 },
84
84
  { rotateX: '-90deg' },
85
- { translateY: targetValues.height },
85
+ { translateY: targetValues.targetHeight },
86
86
  ],
87
87
  },
88
88
  animations: {
@@ -116,7 +116,7 @@ export class FlipInYRight extends ComplexAnimationBuilder {
116
116
  transform: [
117
117
  { perspective: 500 },
118
118
  { rotateY: '90deg' },
119
- { translateX: targetValues.width },
119
+ { translateX: targetValues.targetWidth },
120
120
  ],
121
121
  },
122
122
  animations: {
@@ -216,7 +216,7 @@ export class FlipOutXUp extends ComplexAnimationBuilder {
216
216
  { perspective: delayFunction(delay, animation(500, config)) },
217
217
  { rotateX: delayFunction(delay, animation('90deg', config)) },
218
218
  {
219
- translateY: delayFunction(delay, animation(-targetValues.height, config)),
219
+ translateY: delayFunction(delay, animation(-targetValues.currentHeight, config)),
220
220
  },
221
221
  ],
222
222
  },
@@ -252,7 +252,7 @@ export class FlipOutYLeft extends ComplexAnimationBuilder {
252
252
  { perspective: delayFunction(delay, animation(500, config)) },
253
253
  { rotateY: delayFunction(delay, animation('-90deg', config)) },
254
254
  {
255
- translateX: delayFunction(delay, animation(-targetValues.width, config)),
255
+ translateX: delayFunction(delay, animation(-targetValues.currentWidth, config)),
256
256
  },
257
257
  ],
258
258
  },
@@ -288,7 +288,7 @@ export class FlipOutXDown extends ComplexAnimationBuilder {
288
288
  { perspective: delayFunction(delay, animation(500, config)) },
289
289
  { rotateX: delayFunction(delay, animation('-90deg', config)) },
290
290
  {
291
- translateY: delayFunction(delay, animation(targetValues.height, config)),
291
+ translateY: delayFunction(delay, animation(targetValues.currentHeight, config)),
292
292
  },
293
293
  ],
294
294
  },
@@ -324,7 +324,7 @@ export class FlipOutYRight extends ComplexAnimationBuilder {
324
324
  { perspective: delayFunction(delay, animation(500, config)) },
325
325
  { rotateY: delayFunction(delay, animation('90deg', config)) },
326
326
  {
327
- translateX: delayFunction(delay, animation(targetValues.width, config)),
327
+ translateX: delayFunction(delay, animation(targetValues.currentWidth, config)),
328
328
  },
329
329
  ],
330
330
  },