react-native-reanimated 3.0.0-rc.5 → 3.0.0-rc.7

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 (58) hide show
  1. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +97 -15
  2. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +32 -8
  3. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +16 -1
  4. package/Common/cpp/NativeModules/NativeReanimatedModule.h +8 -1
  5. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +17 -0
  6. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -0
  7. package/Common/cpp/Tools/RuntimeDecorator.cpp +2 -1
  8. package/RNReanimated.podspec +2 -1
  9. package/android/CMakeLists.txt +1 -1
  10. package/android/build.gradle +9 -4
  11. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +16 -25
  12. package/android/src/main/cpp/LayoutAnimations.cpp +42 -50
  13. package/android/src/main/cpp/LayoutAnimations.h +17 -3
  14. package/android/src/main/cpp/NativeProxy.cpp +64 -5
  15. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +1 -1
  16. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +208 -223
  17. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +7 -5
  18. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +5 -3
  19. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +1 -1
  20. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +20 -7
  21. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/62/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +8 -44
  22. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +15 -61
  23. package/ios/LayoutReanimation/REAAnimationsManager.h +18 -8
  24. package/ios/LayoutReanimation/REAAnimationsManager.m +197 -162
  25. package/ios/LayoutReanimation/REAUIManager.mm +63 -70
  26. package/ios/REAModule.mm +11 -5
  27. package/ios/native/NativeProxy.mm +49 -47
  28. package/ios/native/REAInitializer.mm +9 -0
  29. package/lib/commonjs/createAnimatedComponent.js +26 -26
  30. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  31. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +31 -0
  32. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  33. package/lib/commonjs/reanimated2/core.js +9 -9
  34. package/lib/commonjs/reanimated2/core.js.map +1 -1
  35. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  36. package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js +23 -62
  37. package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +1 -1
  38. package/lib/module/createAnimatedComponent.js +27 -26
  39. package/lib/module/createAnimatedComponent.js.map +1 -1
  40. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +29 -0
  41. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  42. package/lib/module/reanimated2/core.js +7 -9
  43. package/lib/module/reanimated2/core.js.map +1 -1
  44. package/lib/module/reanimated2/globals.d.js.map +1 -1
  45. package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js +22 -61
  46. package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +1 -1
  47. package/package.json +2 -2
  48. package/scripts/reanimated_utils.rb +3 -2
  49. package/src/createAnimatedComponent.tsx +48 -39
  50. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +43 -0
  51. package/src/reanimated2/core.ts +19 -10
  52. package/src/reanimated2/globals.d.ts +12 -6
  53. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +24 -50
  54. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -55
  55. package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Default.js.map +0 -1
  56. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -40
  57. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Default.js.map +0 -1
  58. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +0 -49
@@ -138,7 +138,8 @@ function workletValueSetter(value) {
138
138
  animation.onStart(animation, this.value, timestamp, previousAnimation);
139
139
  };
140
140
 
141
- initializeAnimation(getTimestamp());
141
+ const currentTimestamp = getTimestamp();
142
+ initializeAnimation(currentTimestamp);
142
143
 
143
144
  const step = timestamp => {
144
145
  if (animation.cancelled) {
@@ -163,13 +164,7 @@ function workletValueSetter(value) {
163
164
  };
164
165
 
165
166
  this._animation = animation;
166
-
167
- if (_frameTimestamp) {
168
- // frame
169
- step(_frameTimestamp);
170
- } else {
171
- requestAnimationFrame(step);
172
- }
167
+ step(currentTimestamp);
173
168
  } else {
174
169
  // prevent setting again to the same value
175
170
  // and triggering the mappers that treat this value as an input
@@ -226,7 +221,7 @@ function workletValueSetterJS(value) {
226
221
  };
227
222
 
228
223
  this._animation = animation;
229
- requestFrame(step);
224
+ step(getTimestamp());
230
225
  } else {
231
226
  this._setValue && this._setValue(value);
232
227
  }
@@ -303,6 +298,9 @@ export function enableLayoutAnimations(flag) {
303
298
  NativeReanimatedModule.enableLayoutAnimations(flag);
304
299
  }
305
300
  }
301
+ export function configureLayoutAnimations(viewTag, type, config, viewSharedValue) {
302
+ NativeReanimatedModule.configureLayoutAnimation(viewTag, type, config, viewSharedValue);
303
+ }
306
304
  export function configureProps(uiProps, nativeProps) {
307
305
  if (!nativeShouldBeMock()) {
308
306
  NativeReanimatedModule.configureProps(uiProps, nativeProps);
@@ -1 +1 @@
1
- {"version":3,"names":["NativeReanimatedModule","Platform","nativeShouldBeMock","shouldBeUseWeb","isWeb","global","_setGlobalConsole","undefined","testWorklet","throwUninitializedReanimatedException","Error","checkPluginState","throwError","__workletHash","isConfigured","isConfiguredCheck","pushFrame","frame","requestFrame","native","requestAnimationFrame","_WORKLET","_log","s","console","log","runOnUI","worklet","makeShareable","value","getViewProp","viewTag","propName","_IS_FABRIC","Promise","resolve","reject","result","substr","_getTimestamp","getTimestamp","_frameTimestamp","_eventTimestamp","_getCurrentTime","OS","workletValueSetter","previousAnimation","_animation","cancelled","onFrame","animation","_value","current","isHigherOrder","callback","initializeAnimation","timestamp","onStart","step","finished","workletValueSetterJS","_setValue","makeMutable","makeRemote","object","startMapper","mapper","inputs","outputs","updater","viewDescriptors","stopMapper","mapperId","runOnJS","fun","__callAsync","installCoreFunctions","capturableConsole","debug","warn","error","info","featuresConfig","enableLayoutAnimations","setByUser","flag","isCallByUser","configureProps","uiProps","nativeProps","jestResetJsReanimatedModule","jestResetModule"],"sources":["core.ts"],"sourcesContent":["/* global _WORKLET _getCurrentTime _frameTimestamp _eventTimestamp _setGlobalConsole */\nimport NativeReanimatedModule from './NativeReanimated';\nimport { Platform } from 'react-native';\nimport { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';\nimport {\n BasicWorkletFunction,\n ComplexWorkletFunction,\n SharedValue,\n AnimationObject,\n AnimatableValue,\n Timestamp,\n} from './commonTypes';\nimport { Descriptor } from './hook/commonTypes';\nimport JSReanimated from './js-reanimated/JSReanimated';\n\nif (global._setGlobalConsole === undefined) {\n // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1\n global._setGlobalConsole = () => {\n // noop\n };\n}\n\nexport type ReanimatedConsole = Pick<\n Console,\n 'debug' | 'log' | 'warn' | 'info' | 'error'\n>;\n\nexport type WorkletValue =\n | (() => AnimationObject)\n | AnimationObject\n | AnimatableValue\n | Descriptor;\ninterface WorkletValueSetterContext {\n _animation?: AnimationObject | null;\n _value?: AnimatableValue | Descriptor;\n value?: AnimatableValue;\n _setValue?: (val: AnimatableValue | Descriptor) => void;\n}\n\nconst testWorklet: BasicWorkletFunction<void> = () => {\n 'worklet';\n};\n\nconst throwUninitializedReanimatedException = () => {\n throw new Error(\n \"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \\n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \\n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache\"\n );\n};\n\nexport const checkPluginState: (throwError: boolean) => boolean = (\n throwError = true\n) => {\n if (!testWorklet.__workletHash && !shouldBeUseWeb()) {\n if (throwError) {\n throwUninitializedReanimatedException();\n }\n return false;\n }\n return true;\n};\n\nexport const isConfigured: (throwError?: boolean) => boolean = (\n throwError = false\n) => {\n return checkPluginState(throwError);\n};\n\nexport const isConfiguredCheck: () => void = () => {\n checkPluginState(true);\n};\n\nfunction pushFrame(frame: (timestamp: Timestamp) => void): void {\n (NativeReanimatedModule as JSReanimated).pushFrame(frame);\n}\n\nexport function requestFrame(frame: (timestamp: Timestamp) => void): void {\n 'worklet';\n if (NativeReanimatedModule.native) {\n requestAnimationFrame(frame);\n } else {\n pushFrame(frame);\n }\n}\n\nglobal._WORKLET = false;\nglobal._log = function (s: string) {\n console.log(s);\n};\n\nexport function runOnUI<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n return makeShareable(worklet);\n}\n\nexport function makeShareable<T>(value: T): T {\n isConfiguredCheck();\n return NativeReanimatedModule.makeShareable(value);\n}\n\nexport function getViewProp<T>(viewTag: string, propName: string): Promise<T> {\n if (global._IS_FABRIC) {\n throw new Error(\n '[react-native-reanimated] `getViewProp` is not supported on Fabric yet'\n );\n }\n\n return new Promise((resolve, reject) => {\n return NativeReanimatedModule.getViewProp(\n viewTag,\n propName,\n (result: T) => {\n if (typeof result === 'string' && result.substr(0, 6) === 'error:') {\n reject(result);\n } else {\n resolve(result);\n }\n }\n );\n });\n}\n\nlet _getTimestamp: () => number;\nif (nativeShouldBeMock()) {\n _getTimestamp = () => {\n return (NativeReanimatedModule as JSReanimated).getTimestamp();\n };\n} else {\n _getTimestamp = () => {\n 'worklet';\n if (_frameTimestamp) {\n return _frameTimestamp;\n }\n if (_eventTimestamp) {\n return _eventTimestamp;\n }\n return _getCurrentTime();\n };\n}\n\nexport function getTimestamp(): number {\n 'worklet';\n if (Platform.OS === 'web') {\n return (NativeReanimatedModule as JSReanimated).getTimestamp();\n }\n return _getTimestamp();\n}\n\nfunction workletValueSetter<T extends WorkletValue>(\n this: WorkletValueSetterContext,\n value: T\n): void {\n 'worklet';\n const previousAnimation = this._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n this._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame !== undefined)\n ) {\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n // 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)\n // built in animations that are not higher order(withTiming, withSpring) hold target value in .current\n if (this._value === animation.current && !animation.isHigherOrder) {\n animation.callback && animation.callback(true);\n return;\n }\n // animated set\n const initializeAnimation = (timestamp: number) => {\n animation.onStart(animation, this.value, timestamp, previousAnimation);\n };\n initializeAnimation(getTimestamp());\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.finished = true;\n animation.timestamp = timestamp;\n this._value = animation.current;\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestAnimationFrame(step);\n }\n };\n\n this._animation = animation;\n\n if (_frameTimestamp) {\n // frame\n step(_frameTimestamp);\n } else {\n requestAnimationFrame(step);\n }\n } else {\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n if (this._value === value) {\n return;\n }\n this._value = value as Descriptor | AnimatableValue;\n }\n}\n\n// We cannot use pushFrame\n// so we use own implementation for js\nfunction workletValueSetterJS<T extends WorkletValue>(\n this: WorkletValueSetterContext,\n value: T\n): void {\n const previousAnimation = this._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n this._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame)\n ) {\n // animated set\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n let initializeAnimation: ((timestamp: number) => void) | null = (\n timestamp: number\n ) => {\n animation.onStart(animation, this.value, timestamp, previousAnimation);\n };\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n if (initializeAnimation) {\n initializeAnimation(timestamp);\n initializeAnimation = null; // prevent closure from keeping ref to previous animation\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n this._setValue && this._setValue(animation.current as AnimatableValue);\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestFrame(step);\n }\n };\n\n this._animation = animation;\n\n requestFrame(step);\n } else {\n this._setValue && this._setValue(value as AnimatableValue | Descriptor);\n }\n}\n\nexport function makeMutable<T>(value: T): SharedValue<T> {\n isConfiguredCheck();\n return NativeReanimatedModule.makeMutable(value);\n}\n\nexport function makeRemote<T>(object = {}): T {\n isConfiguredCheck();\n return NativeReanimatedModule.makeRemote(object);\n}\n\nexport function startMapper(\n mapper: () => void,\n inputs: any[] = [],\n outputs: any[] = [],\n updater: () => void = () => {\n // noop\n },\n viewDescriptors: Descriptor[] | SharedValue<Descriptor[]> = []\n): number {\n isConfiguredCheck();\n return NativeReanimatedModule.startMapper(\n mapper,\n inputs,\n outputs,\n updater,\n viewDescriptors\n );\n}\n\nexport function stopMapper(mapperId: number): void {\n NativeReanimatedModule.stopMapper(mapperId);\n}\n\nexport interface RunOnJSFunction<A extends any[], R> {\n __callAsync?: (...args: A) => void;\n (...args: A): R;\n}\n\nexport function runOnJS<A extends any[], R>(\n fun: RunOnJSFunction<A, R>\n): () => void {\n 'worklet';\n if (!_WORKLET) {\n return fun;\n }\n if (!fun.__callAsync) {\n throw new Error(\n \"Attempting to call runOnJS with an object that is not a host function. Using runOnJS is only possible with methods that are defined on the main React-Native Javascript thread and that aren't marked as worklets\"\n );\n } else {\n return fun.__callAsync;\n }\n}\n\nNativeReanimatedModule.installCoreFunctions(\n NativeReanimatedModule.native\n ? (workletValueSetter as <T>(value: T) => void)\n : (workletValueSetterJS as <T>(value: T) => void)\n);\n\nif (!isWeb() && isConfigured()) {\n const capturableConsole = console;\n runOnUI(() => {\n 'worklet';\n const console = {\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n };\n _setGlobalConsole(console);\n })();\n}\n\ntype FeaturesConfig = {\n enableLayoutAnimations: boolean;\n setByUser: boolean;\n};\n\nlet featuresConfig: FeaturesConfig = {\n enableLayoutAnimations: false,\n setByUser: false,\n};\n\nexport function enableLayoutAnimations(\n flag: boolean,\n isCallByUser = true\n): void {\n if (isCallByUser) {\n featuresConfig = {\n enableLayoutAnimations: flag,\n setByUser: true,\n };\n NativeReanimatedModule.enableLayoutAnimations(flag);\n } else if (\n !featuresConfig.setByUser &&\n featuresConfig.enableLayoutAnimations !== flag\n ) {\n featuresConfig.enableLayoutAnimations = flag;\n NativeReanimatedModule.enableLayoutAnimations(flag);\n }\n}\n\nexport function configureProps(uiProps: string[], nativeProps: string[]): void {\n if (!nativeShouldBeMock()) {\n NativeReanimatedModule.configureProps(uiProps, nativeProps);\n }\n}\n\nexport function jestResetJsReanimatedModule() {\n (NativeReanimatedModule as JSReanimated).jestResetModule();\n}\n"],"mappings":"AAAA;AACA,OAAOA,sBAAP,MAAmC,oBAAnC;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,kBAAT,EAA6BC,cAA7B,EAA6C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,cAAc,CAACE,SAAhB,IACAF,cAAc,CAACC,sBAAf,KAA0CE,IAFrC,EAGL;IACAH,cAAc,CAACC,sBAAf,GAAwCE,IAAxC;IACArF,sBAAsB,CAACmF,sBAAvB,CAA8CE,IAA9C;EACD;AACF;AAED,OAAO,SAASE,cAAT,CAAwBC,OAAxB,EAA2CC,WAA3C,EAAwE;EAC7E,IAAI,CAACvF,kBAAkB,EAAvB,EAA2B;IACzBF,sBAAsB,CAACuF,cAAvB,CAAsCC,OAAtC,EAA+CC,WAA/C;EACD;AACF;AAED,OAAO,SAASC,2BAAT,GAAuC;EAC3C1F,sBAAD,CAAyC2F,eAAzC;AACD"}
1
+ {"version":3,"names":["NativeReanimatedModule","Platform","nativeShouldBeMock","shouldBeUseWeb","isWeb","global","_setGlobalConsole","undefined","testWorklet","throwUninitializedReanimatedException","Error","checkPluginState","throwError","__workletHash","isConfigured","isConfiguredCheck","pushFrame","frame","requestFrame","native","requestAnimationFrame","_WORKLET","_log","s","console","log","runOnUI","worklet","makeShareable","value","getViewProp","viewTag","propName","_IS_FABRIC","Promise","resolve","reject","result","substr","_getTimestamp","getTimestamp","_frameTimestamp","_eventTimestamp","_getCurrentTime","OS","workletValueSetter","previousAnimation","_animation","cancelled","onFrame","animation","_value","current","isHigherOrder","callback","initializeAnimation","timestamp","onStart","currentTimestamp","step","finished","workletValueSetterJS","_setValue","makeMutable","makeRemote","object","startMapper","mapper","inputs","outputs","updater","viewDescriptors","stopMapper","mapperId","runOnJS","fun","__callAsync","installCoreFunctions","capturableConsole","debug","warn","error","info","featuresConfig","enableLayoutAnimations","setByUser","flag","isCallByUser","configureLayoutAnimations","type","config","viewSharedValue","configureLayoutAnimation","configureProps","uiProps","nativeProps","jestResetJsReanimatedModule","jestResetModule"],"sources":["core.ts"],"sourcesContent":["/* global _WORKLET _getCurrentTime _frameTimestamp _eventTimestamp _setGlobalConsole */\nimport NativeReanimatedModule from './NativeReanimated';\nimport { Platform } from 'react-native';\nimport { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';\nimport {\n BasicWorkletFunction,\n ComplexWorkletFunction,\n SharedValue,\n AnimationObject,\n AnimatableValue,\n Timestamp,\n} from './commonTypes';\nimport { Descriptor } from './hook/commonTypes';\nimport JSReanimated from './js-reanimated/JSReanimated';\nimport { LayoutAnimationFunction } from './layoutReanimation';\n\nif (global._setGlobalConsole === undefined) {\n // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1\n global._setGlobalConsole = () => {\n // noop\n };\n}\n\nexport type ReanimatedConsole = Pick<\n Console,\n 'debug' | 'log' | 'warn' | 'info' | 'error'\n>;\n\nexport type WorkletValue =\n | (() => AnimationObject)\n | AnimationObject\n | AnimatableValue\n | Descriptor;\ninterface WorkletValueSetterContext {\n _animation?: AnimationObject | null;\n _value?: AnimatableValue | Descriptor;\n value?: AnimatableValue;\n _setValue?: (val: AnimatableValue | Descriptor) => void;\n}\n\nconst testWorklet: BasicWorkletFunction<void> = () => {\n 'worklet';\n};\n\nconst throwUninitializedReanimatedException = () => {\n throw new Error(\n \"Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \\n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \\n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache\"\n );\n};\n\nexport const checkPluginState: (throwError: boolean) => boolean = (\n throwError = true\n) => {\n if (!testWorklet.__workletHash && !shouldBeUseWeb()) {\n if (throwError) {\n throwUninitializedReanimatedException();\n }\n return false;\n }\n return true;\n};\n\nexport const isConfigured: (throwError?: boolean) => boolean = (\n throwError = false\n) => {\n return checkPluginState(throwError);\n};\n\nexport const isConfiguredCheck: () => void = () => {\n checkPluginState(true);\n};\n\nfunction pushFrame(frame: (timestamp: Timestamp) => void): void {\n (NativeReanimatedModule as JSReanimated).pushFrame(frame);\n}\n\nexport function requestFrame(frame: (timestamp: Timestamp) => void): void {\n 'worklet';\n if (NativeReanimatedModule.native) {\n requestAnimationFrame(frame);\n } else {\n pushFrame(frame);\n }\n}\n\nglobal._WORKLET = false;\nglobal._log = function (s: string) {\n console.log(s);\n};\n\nexport function runOnUI<A extends any[], R>(\n worklet: ComplexWorkletFunction<A, R>\n): (...args: A) => void {\n return makeShareable(worklet);\n}\n\nexport function makeShareable<T>(value: T): T {\n isConfiguredCheck();\n return NativeReanimatedModule.makeShareable(value);\n}\n\nexport function getViewProp<T>(viewTag: string, propName: string): Promise<T> {\n if (global._IS_FABRIC) {\n throw new Error(\n '[react-native-reanimated] `getViewProp` is not supported on Fabric yet'\n );\n }\n\n return new Promise((resolve, reject) => {\n return NativeReanimatedModule.getViewProp(\n viewTag,\n propName,\n (result: T) => {\n if (typeof result === 'string' && result.substr(0, 6) === 'error:') {\n reject(result);\n } else {\n resolve(result);\n }\n }\n );\n });\n}\n\nlet _getTimestamp: () => number;\nif (nativeShouldBeMock()) {\n _getTimestamp = () => {\n return (NativeReanimatedModule as JSReanimated).getTimestamp();\n };\n} else {\n _getTimestamp = () => {\n 'worklet';\n if (_frameTimestamp) {\n return _frameTimestamp;\n }\n if (_eventTimestamp) {\n return _eventTimestamp;\n }\n return _getCurrentTime();\n };\n}\n\nexport function getTimestamp(): number {\n 'worklet';\n if (Platform.OS === 'web') {\n return (NativeReanimatedModule as JSReanimated).getTimestamp();\n }\n return _getTimestamp();\n}\n\nfunction workletValueSetter<T extends WorkletValue>(\n this: WorkletValueSetterContext,\n value: T\n): void {\n 'worklet';\n const previousAnimation = this._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n this._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame !== undefined)\n ) {\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n // 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)\n // built in animations that are not higher order(withTiming, withSpring) hold target value in .current\n if (this._value === animation.current && !animation.isHigherOrder) {\n animation.callback && animation.callback(true);\n return;\n }\n // animated set\n const initializeAnimation = (timestamp: number) => {\n animation.onStart(animation, this.value, timestamp, previousAnimation);\n };\n const currentTimestamp = getTimestamp();\n initializeAnimation(currentTimestamp);\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.finished = true;\n animation.timestamp = timestamp;\n this._value = animation.current;\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestAnimationFrame(step);\n }\n };\n\n this._animation = animation;\n step(currentTimestamp);\n } else {\n // prevent setting again to the same value\n // and triggering the mappers that treat this value as an input\n if (this._value === value) {\n return;\n }\n this._value = value as Descriptor | AnimatableValue;\n }\n}\n\n// We cannot use pushFrame\n// so we use own implementation for js\nfunction workletValueSetterJS<T extends WorkletValue>(\n this: WorkletValueSetterContext,\n value: T\n): void {\n const previousAnimation = this._animation;\n if (previousAnimation) {\n previousAnimation.cancelled = true;\n this._animation = null;\n }\n if (\n typeof value === 'function' ||\n (value !== null &&\n typeof value === 'object' &&\n (value as AnimationObject).onFrame)\n ) {\n // animated set\n const animation: AnimationObject =\n typeof value === 'function'\n ? (value as () => AnimationObject)()\n : (value as AnimationObject);\n let initializeAnimation: ((timestamp: number) => void) | null = (\n timestamp: number\n ) => {\n animation.onStart(animation, this.value, timestamp, previousAnimation);\n };\n const step = (timestamp: number) => {\n if (animation.cancelled) {\n animation.callback && animation.callback(false /* finished */);\n return;\n }\n if (initializeAnimation) {\n initializeAnimation(timestamp);\n initializeAnimation = null; // prevent closure from keeping ref to previous animation\n }\n const finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n this._setValue && this._setValue(animation.current as AnimatableValue);\n if (finished) {\n animation.callback && animation.callback(true /* finished */);\n } else {\n requestFrame(step);\n }\n };\n\n this._animation = animation;\n step(getTimestamp());\n } else {\n this._setValue && this._setValue(value as AnimatableValue | Descriptor);\n }\n}\n\nexport function makeMutable<T>(value: T): SharedValue<T> {\n isConfiguredCheck();\n return NativeReanimatedModule.makeMutable(value);\n}\n\nexport function makeRemote<T>(object = {}): T {\n isConfiguredCheck();\n return NativeReanimatedModule.makeRemote(object);\n}\n\nexport function startMapper(\n mapper: () => void,\n inputs: any[] = [],\n outputs: any[] = [],\n updater: () => void = () => {\n // noop\n },\n viewDescriptors: Descriptor[] | SharedValue<Descriptor[]> = []\n): number {\n isConfiguredCheck();\n return NativeReanimatedModule.startMapper(\n mapper,\n inputs,\n outputs,\n updater,\n viewDescriptors\n );\n}\n\nexport function stopMapper(mapperId: number): void {\n NativeReanimatedModule.stopMapper(mapperId);\n}\n\nexport interface RunOnJSFunction<A extends any[], R> {\n __callAsync?: (...args: A) => void;\n (...args: A): R;\n}\n\nexport function runOnJS<A extends any[], R>(\n fun: RunOnJSFunction<A, R>\n): () => void {\n 'worklet';\n if (!_WORKLET) {\n return fun;\n }\n if (!fun.__callAsync) {\n throw new Error(\n \"Attempting to call runOnJS with an object that is not a host function. Using runOnJS is only possible with methods that are defined on the main React-Native Javascript thread and that aren't marked as worklets\"\n );\n } else {\n return fun.__callAsync;\n }\n}\n\nNativeReanimatedModule.installCoreFunctions(\n NativeReanimatedModule.native\n ? (workletValueSetter as <T>(value: T) => void)\n : (workletValueSetterJS as <T>(value: T) => void)\n);\n\nif (!isWeb() && isConfigured()) {\n const capturableConsole = console;\n runOnUI(() => {\n 'worklet';\n const console = {\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n };\n _setGlobalConsole(console);\n })();\n}\n\ntype FeaturesConfig = {\n enableLayoutAnimations: boolean;\n setByUser: boolean;\n};\n\nlet featuresConfig: FeaturesConfig = {\n enableLayoutAnimations: false,\n setByUser: false,\n};\n\nexport function enableLayoutAnimations(\n flag: boolean,\n isCallByUser = true\n): void {\n if (isCallByUser) {\n featuresConfig = {\n enableLayoutAnimations: flag,\n setByUser: true,\n };\n NativeReanimatedModule.enableLayoutAnimations(flag);\n } else if (\n !featuresConfig.setByUser &&\n featuresConfig.enableLayoutAnimations !== flag\n ) {\n featuresConfig.enableLayoutAnimations = flag;\n NativeReanimatedModule.enableLayoutAnimations(flag);\n }\n}\n\nexport function configureLayoutAnimations(\n viewTag: number,\n type: string,\n config: LayoutAnimationFunction | Keyframe,\n viewSharedValue: SharedValue<null | Record<string, unknown>> | null\n): void {\n NativeReanimatedModule.configureLayoutAnimation(\n viewTag,\n type,\n config,\n viewSharedValue\n );\n}\n\nexport function configureProps(uiProps: string[], nativeProps: string[]): void {\n if (!nativeShouldBeMock()) {\n NativeReanimatedModule.configureProps(uiProps, nativeProps);\n }\n}\n\nexport function jestResetJsReanimatedModule() {\n (NativeReanimatedModule as JSReanimated).jestResetModule();\n}\n"],"mappings":"AAAA;AACA,OAAOA,sBAAP,MAAmC,oBAAnC;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,kBAAT,EAA6BC,cAA7B,EAA6CC,KAA7C,QAA0D,mBAA1D;;AAaA,IAAIC,MAAM,CAACC,iBAAP,KAA6BC,SAAjC,EAA4C;EAC1C;EACAF,MAAM,CAACC,iBAAP,GAA2B,MAAM,CAC/B;EACD,CAFD;AAGD;;AAmBD,MAAME,WAAuC,GAAG,MAAM;EACpD;AACD,CAFD;;AAIA,MAAMC,qCAAqC,GAAG,MAAM;EAClD,MAAM,IAAIC,KAAJ,CACJ,4cADI,CAAN;AAGD,CAJD;;AAMA,OAAO,MAAMC,gBAAkD,GAAG,YAE7D;EAAA,IADHC,UACG,uEADU,IACV;;EACH,IAAI,CAACJ,WAAW,CAACK,aAAb,IAA8B,CAACV,cAAc,EAAjD,EAAqD;IACnD,IAAIS,UAAJ,EAAgB;MACdH,qCAAqC;IACtC;;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AT,GAAuC;EAC3ChG,sBAAD,CAAyCiG,eAAzC;AACD"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["import type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n} from './commonTypes';\nimport type { ReanimatedConsole } from './core';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { ShadowNodeWrapper } from './hook/commonTypes';\nimport type { NativeReanimated } from './NativeReanimated/NativeReanimated';\n\ndeclare global {\n const _WORKLET: boolean;\n const _IS_FABRIC: boolean;\n const _frameTimestamp: number | null;\n const _eventTimestamp: number;\n const __reanimatedModuleProxy: NativeReanimated;\n const _setGlobalConsole: (console?: ReanimatedConsole) => void;\n const _log: (s: string) => void;\n const _getCurrentTime: () => number;\n const _stopObservingProgress: (tag: number, flag: boolean) => void;\n const _startObservingProgress: (\n tag: number,\n flag: { value: boolean; _value: boolean }\n ) => void;\n const _setGestureState: (handlerTag: number, newState: number) => void;\n const _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n const _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n const _removeShadowNodeFromRegistry: (\n shadowNodeWrapper: ShadowNodeWrapper\n ) => void;\n const _measure: (viewTag: number) => MeasuredDimensions;\n const _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n const _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n const _chronoNow: () => number;\n const performance: { now: () => number };\n const LayoutAnimationRepository: {\n configs: Record<string, unknown>;\n registerConfig(tag: number, config: Record<string, unknown>): void;\n removeConfig(tag: number): void;\n startAnimationForTag(tag: number, type: string, yogaValues: unknown): void;\n };\n const ReanimatedDataMock: {\n now: () => number;\n };\n const _frameCallbackRegistry: FrameCallbackRegistryUI;\n\n namespace NodeJS {\n interface Global {\n _WORKLET: boolean;\n _IS_FABRIC: boolean;\n _frameTimestamp: number | null;\n _eventTimestamp: number;\n __reanimatedModuleProxy: NativeReanimated;\n _setGlobalConsole: (console?: ReanimatedConsole) => void;\n _log: (s: string) => void;\n _getCurrentTime: () => number;\n _stopObservingProgress: (tag: number, flag: boolean) => void;\n _startObservingProgress: (\n tag: number,\n flag: { value: boolean; _value: boolean }\n ) => void;\n _setGestureState: (handlerTag: number, newState: number) => void;\n _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n _removeShadowNodeFromRegistry: (\n shadowNodeWrapper: ShadowNodeWrapper\n ) => void;\n _measure: (viewTag: number) => MeasuredDimensions;\n _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n _chronoNow: () => number;\n performance: { now: () => number };\n LayoutAnimationRepository: {\n configs: Record<string, unknown>;\n registerConfig(tag: number, config: Record<string, unknown>): void;\n removeConfig(tag: number): void;\n startAnimationForTag(\n tag: number,\n type: string,\n yogaValues: unknown\n ): void;\n };\n ReanimatedDataMock: {\n now: () => number;\n };\n _frameCallbackRegistry: FrameCallbackRegistryUI;\n }\n }\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["import type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n} from './commonTypes';\nimport type { ReanimatedConsole } from './core';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { ShadowNodeWrapper } from './hook/commonTypes';\nimport type { NativeReanimated } from './NativeReanimated/NativeReanimated';\n\ndeclare global {\n const _WORKLET: boolean;\n const _IS_FABRIC: boolean;\n const _REANIMATED_VERSION_CPP: string;\n const _frameTimestamp: number | null;\n const _eventTimestamp: number;\n const __reanimatedModuleProxy: NativeReanimated;\n const _setGlobalConsole: (console?: ReanimatedConsole) => void;\n const _log: (s: string) => void;\n const _getCurrentTime: () => number;\n const _stopObservingProgress: (\n tag: number,\n cancelled: boolean,\n removeView: boolean\n ) => void;\n const _startObservingProgress: (\n tag: number,\n viewSharedValue: { value: unknown; _value: unknown },\n type: string\n ) => void;\n const _setGestureState: (handlerTag: number, newState: number) => void;\n const _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n const _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n const _removeShadowNodeFromRegistry: (\n shadowNodeWrapper: ShadowNodeWrapper\n ) => void;\n const _measure: (viewTag: number) => MeasuredDimensions;\n const _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n const _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n const _chronoNow: () => number;\n const performance: { now: () => number };\n const LayoutAnimationRepository: {\n configs: Record<string, unknown>;\n registerConfig(tag: number, config: Record<string, unknown>): void;\n removeConfig(tag: number): void;\n startAnimationForTag(tag: number, type: string, yogaValues: unknown): void;\n };\n const ReanimatedDataMock: {\n now: () => number;\n };\n const _frameCallbackRegistry: FrameCallbackRegistryUI;\n\n namespace NodeJS {\n interface Global {\n _WORKLET: boolean;\n _IS_FABRIC: boolean;\n _REANIMATED_VERSION_CPP: string;\n _frameTimestamp: number | null;\n _eventTimestamp: number;\n __reanimatedModuleProxy: NativeReanimated;\n _setGlobalConsole: (console?: ReanimatedConsole) => void;\n _log: (s: string) => void;\n _getCurrentTime: () => number;\n _stopObservingProgress: (tag: number, flag: boolean) => void;\n _startObservingProgress: (\n tag: number,\n flag: { value: boolean; _value: boolean }\n ) => void;\n _setGestureState: (handlerTag: number, newState: number) => void;\n _updatePropsPaper: (\n tag: number,\n name: string,\n updates: StyleProps | AnimatedStyle\n ) => void;\n _updatePropsFabric: (\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void;\n _removeShadowNodeFromRegistry: (\n shadowNodeWrapper: ShadowNodeWrapper\n ) => void;\n _measure: (viewTag: number) => MeasuredDimensions;\n _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n _dispatchCommand: (\n shadowNodeWrapper: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void;\n _chronoNow: () => number;\n performance: { now: () => number };\n LayoutAnimationRepository: {\n startAnimationForTag(\n tag: number,\n type: string,\n yogaValues: Record<string, number>,\n config: LayoutAnimationFunction | Keyframe,\n viewSharedValue: { value: unknown; _value: unknown }\n ): void;\n };\n ReanimatedDataMock: {\n now: () => number;\n };\n _frameCallbackRegistry: FrameCallbackRegistryUI;\n }\n }\n}\n"],"mappings":""}
@@ -1,89 +1,50 @@
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
+ import { LogBox } from 'react-native';
5
+ LogBox.ignoreLogs(['Overriding previous layout animation with']);
6
6
  runOnUI(() => {
7
7
  'worklet';
8
8
 
9
- const configs = Object.create(null);
10
9
  const enteringAnimationForTag = {};
11
10
  global.LayoutAnimationRepository = {
12
- configs,
13
-
14
- registerConfig(tag, config) {
15
- configs[tag] = config;
16
- enteringAnimationForTag[tag] = null;
17
- },
18
-
19
- removeConfig(tag) {
20
- delete configs[tag];
21
- delete enteringAnimationForTag[tag];
22
- },
23
-
24
- startAnimationForTag(tag, type, yogaValues) {
25
- if (configs[tag] == null) {
26
- return; // :(
27
- }
28
-
29
- const style = configs[tag][type](yogaValues);
11
+ startAnimationForTag(tag, type, yogaValues, config, viewSharedValue) {
12
+ const style = config(yogaValues);
30
13
  let currentAnimation = style.animations;
31
14
 
32
15
  if (type === 'entering') {
33
- enteringAnimationForTag[tag] = style;
34
- } else if (type === 'layout' && enteringAnimationForTag[tag] !== null) {
35
- const entryAniamtion = enteringAnimationForTag[tag].animations;
36
- const layoutAnimation = style.animations;
37
- currentAnimation = {};
38
-
39
- for (const key in entryAniamtion) {
40
- currentAnimation[key] = entryAniamtion[key];
41
- }
42
-
43
- for (const key in layoutAnimation) {
44
- currentAnimation[key] = layoutAnimation[key];
16
+ enteringAnimationForTag[tag] = currentAnimation;
17
+ } else if (type === 'layout') {
18
+ // When layout animation is requested, but entering is still running, we merge
19
+ // new layout animation targets into the ongoing animation
20
+ const enteringAnimation = enteringAnimationForTag[tag];
21
+
22
+ if (enteringAnimation) {
23
+ currentAnimation = { ...enteringAnimation,
24
+ ...style.animations
25
+ };
45
26
  }
46
27
  }
47
28
 
48
- const sv = configs[tag].sv;
49
-
50
- _stopObservingProgress(tag, false);
51
-
52
- _startObservingProgress(tag, sv);
53
-
54
- const backupColor = {};
55
-
56
- for (const key in style.initialValues) {
57
- if (ColorProperties.includes(key)) {
58
- const value = style.initialValues[key];
59
- backupColor[key] = value;
60
- style.initialValues[key] = processColor(value);
61
- }
62
- }
63
-
64
- sv.value = Object.assign({}, sv._value, style.initialValues);
65
-
66
- _stopObservingProgress(tag, false);
29
+ _stopObservingProgress(tag, false, false);
67
30
 
31
+ viewSharedValue._value = Object.assign({}, viewSharedValue._value, style.initialValues);
68
32
  const animation = withStyleAnimation(currentAnimation);
69
33
 
70
34
  animation.callback = finished => {
71
35
  if (finished) {
72
- _stopObservingProgress(tag, finished);
36
+ delete enteringAnimationForTag[tag];
37
+ const shouldRemoveView = type === 'exiting';
38
+
39
+ _stopObservingProgress(tag, finished, shouldRemoveView);
73
40
  }
74
41
 
75
42
  style.callback && style.callback(finished);
76
43
  };
77
44
 
78
- if (backupColor) {
79
- configs[tag].sv._value = { ...configs[tag].sv.value,
80
- ...backupColor
81
- };
82
- }
83
-
84
- configs[tag].sv.value = animation;
45
+ viewSharedValue.value = animation;
85
46
 
86
- _startObservingProgress(tag, sv);
47
+ _startObservingProgress(tag, viewSharedValue, type);
87
48
  }
88
49
 
89
50
  };
@@ -1 +1 @@
1
- {"version":3,"names":["runOnUI","withStyleAnimation","ColorProperties","processColor","configs","Object","create","enteringAnimationForTag","global","LayoutAnimationRepository","registerConfig","tag","config","removeConfig","startAnimationForTag","type","yogaValues","style","currentAnimation","animations","entryAniamtion","layoutAnimation","key","sv","_stopObservingProgress","_startObservingProgress","backupColor","initialValues","includes","value","assign","_value","animation","callback","finished"],"sources":["LayoutAnimationRepository.ts"],"sourcesContent":["/* global _stopObservingProgress, _startObservingProgress */\nimport { runOnUI } from '../core';\nimport { withStyleAnimation } from '../animation/styleAnimation';\nimport { ColorProperties } from '../UpdateProps';\nimport { processColor } from '../Colors';\n\nrunOnUI(() => {\n 'worklet';\n\n const configs: Record<string, any> = Object.create(null);\n const enteringAnimationForTag: Record<string, any> = {};\n\n global.LayoutAnimationRepository = {\n configs,\n registerConfig(tag, config) {\n configs[tag] = config;\n enteringAnimationForTag[tag] = null;\n },\n removeConfig(tag) {\n delete configs[tag];\n delete enteringAnimationForTag[tag];\n },\n startAnimationForTag(tag, type, yogaValues) {\n if (configs[tag] == null) {\n return; // :(\n }\n const style = configs[tag][type](yogaValues);\n let currentAnimation = style.animations;\n if (type === 'entering') {\n enteringAnimationForTag[tag] = style;\n } else if (type === 'layout' && enteringAnimationForTag[tag] !== null) {\n const entryAniamtion = enteringAnimationForTag[tag].animations;\n const layoutAnimation = style.animations;\n currentAnimation = {};\n for (const key in entryAniamtion) {\n currentAnimation[key] = entryAniamtion[key];\n }\n for (const key in layoutAnimation) {\n currentAnimation[key] = layoutAnimation[key];\n }\n }\n\n const sv: { value: boolean; _value: boolean } = configs[tag].sv;\n _stopObservingProgress(tag, false);\n _startObservingProgress(tag, sv);\n\n const backupColor: Record<string, string> = {};\n for (const key in style.initialValues) {\n if (ColorProperties.includes(key)) {\n const value = style.initialValues[key];\n backupColor[key] = value;\n style.initialValues[key] = processColor(value);\n }\n }\n\n sv.value = Object.assign({}, sv._value, style.initialValues);\n _stopObservingProgress(tag, false);\n const animation = withStyleAnimation(currentAnimation);\n\n animation.callback = (finished?: boolean) => {\n if (finished) {\n _stopObservingProgress(tag, finished);\n }\n style.callback && style.callback(finished);\n };\n\n if (backupColor) {\n configs[tag].sv._value = { ...configs[tag].sv.value, ...backupColor };\n }\n\n configs[tag].sv.value = animation;\n _startObservingProgress(tag, sv);\n },\n };\n})();\n"],"mappings":"AAAA;AACA,SAASA,OAAT,QAAwB,SAAxB;AACA,SAASC,kBAAT,QAAmC,6BAAnC;AACA,SAASC,eAAT,QAAgC,gBAAhC;AACA,SAASC,YAAT,QAA6B,WAA7B;AAEAH,OAAO,CAAC,MAAM;EACZ;;EAEA,MAAMI,OAA4B,GAAGC,MAAM,CAACC,MAAP,CAAc,IAAd,CAArC;EACA,MAAMC,uBAA4C,GAAG,EAArD;EAEAC,MAAM,CAACC,yBAAP,GAAmC;IACjCL,OADiC;;IAEjCM,cAAc,CAACC,GAAD,EAAMC,MAAN,EAAc;MAC1BR,OAAO,CAACO,GAAD,CAAP,GAAeC,MAAf;MACAL,uBAAuB,CAACI,GAAD,CAAvB,GAA+B,IAA/B;IACD,CALgC;;IAMjCE,YAAY,CAACF,GAAD,EAAM;MAChB,OAAOP,OAAO,CAACO,GAAD,CAAd;MACA,OAAOJ,uBAAuB,CAACI,GAAD,CAA9B;IACD,CATgC;;IAUjCG,oBAAoB,CAACH,GAAD,EAAMI,IAAN,EAAYC,UAAZ,EAAwB;MAC1C,IAAIZ,OAAO,CAACO,GAAD,CAAP,IAAgB,IAApB,EAA0B;QACxB,OADwB,CAChB;MACT;;MACD,MAAMM,KAAK,GAAGb,OAAO,CAACO,GAAD,CAAP,CAAaI,IAAb,EAAmBC,UAAnB,CAAd;MACA,IAAIE,gBAAgB,GAAGD,KAAK,CAACE,UAA7B;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;;MACAH,sBAAsB,CAACb,GAAD,EAAM,KAAN,CAAtB;;MACA,MAAMqB,SAAS,GAAG/B,kBAAkB,CAACiB,gBAAD,CAApC;;MAEAc,SAAS,CAACC,QAAV,GAAsBC,QAAD,IAAwB;QAC3C,IAAIA,QAAJ,EAAc;UACZV,sBAAsB,CAACb,GAAD,EAAMuB,QAAN,CAAtB;QACD;;QACDjB,KAAK,CAACgB,QAAN,IAAkBhB,KAAK,CAACgB,QAAN,CAAeC,QAAf,CAAlB;MACD,CALD;;MAOA,IAAIR,WAAJ,EAAiB;QACftB,OAAO,CAACO,GAAD,CAAP,CAAaY,EAAb,CAAgBQ,MAAhB,GAAyB,EAAE,GAAG3B,OAAO,CAACO,GAAD,CAAP,CAAaY,EAAb,CAAgBM,KAArB;UAA4B,GAAGH;QAA/B,CAAzB;MACD;;MAEDtB,OAAO,CAACO,GAAD,CAAP,CAAaY,EAAb,CAAgBM,KAAhB,GAAwBG,SAAxB;;MACAP,uBAAuB,CAACd,GAAD,EAAMY,EAAN,CAAvB;IACD;;EA5DgC,CAAnC;AA8DD,CApEM,CAAP"}
1
+ {"version":3,"names":["runOnUI","withStyleAnimation","LogBox","ignoreLogs","enteringAnimationForTag","global","LayoutAnimationRepository","startAnimationForTag","tag","type","yogaValues","config","viewSharedValue","style","currentAnimation","animations","enteringAnimation","_stopObservingProgress","_value","Object","assign","initialValues","animation","callback","finished","shouldRemoveView","value","_startObservingProgress"],"sources":["LayoutAnimationRepository.ts"],"sourcesContent":["/* global _stopObservingProgress, _startObservingProgress */\nimport { runOnUI } from '../core';\nimport { withStyleAnimation } from '../animation/styleAnimation';\nimport { LogBox } from 'react-native';\n\nLogBox.ignoreLogs(['Overriding previous layout animation with']);\n\nrunOnUI(() => {\n 'worklet';\n\n const enteringAnimationForTag: Record<string, any> = {};\n\n global.LayoutAnimationRepository = {\n startAnimationForTag(tag, type, yogaValues, config, viewSharedValue) {\n const style = config(yogaValues);\n let currentAnimation = style.animations;\n\n if (type === 'entering') {\n enteringAnimationForTag[tag] = currentAnimation;\n } else if (type === 'layout') {\n // When layout animation is requested, but entering is still running, we merge\n // new layout animation targets into the ongoing animation\n const enteringAnimation = enteringAnimationForTag[tag];\n if (enteringAnimation) {\n currentAnimation = { ...enteringAnimation, ...style.animations };\n }\n }\n _stopObservingProgress(tag, false, false);\n viewSharedValue._value = Object.assign(\n {},\n viewSharedValue._value,\n style.initialValues\n );\n const animation = withStyleAnimation(currentAnimation);\n\n animation.callback = (finished?: boolean) => {\n if (finished) {\n delete enteringAnimationForTag[tag];\n const shouldRemoveView = type === 'exiting';\n _stopObservingProgress(tag, finished, shouldRemoveView);\n }\n style.callback && style.callback(finished);\n };\n\n viewSharedValue.value = animation;\n _startObservingProgress(tag, viewSharedValue, type);\n },\n };\n})();\n"],"mappings":"AAAA;AACA,SAASA,OAAT,QAAwB,SAAxB;AACA,SAASC,kBAAT,QAAmC,6BAAnC;AACA,SAASC,MAAT,QAAuB,cAAvB;AAEAA,MAAM,CAACC,UAAP,CAAkB,CAAC,2CAAD,CAAlB;AAEAH,OAAO,CAAC,MAAM;EACZ;;EAEA,MAAMI,uBAA4C,GAAG,EAArD;EAEAC,MAAM,CAACC,yBAAP,GAAmC;IACjCC,oBAAoB,CAACC,GAAD,EAAMC,IAAN,EAAYC,UAAZ,EAAwBC,MAAxB,EAAgCC,eAAhC,EAAiD;MACnE,MAAMC,KAAK,GAAGF,MAAM,CAACD,UAAD,CAApB;MACA,IAAII,gBAAgB,GAAGD,KAAK,CAACE,UAA7B;;MAEA,IAAIN,IAAI,KAAK,UAAb,EAAyB;QACvBL,uBAAuB,CAACI,GAAD,CAAvB,GAA+BM,gBAA/B;MACD,CAFD,MAEO,IAAIL,IAAI,KAAK,QAAb,EAAuB;QAC5B;QACA;QACA,MAAMO,iBAAiB,GAAGZ,uBAAuB,CAACI,GAAD,CAAjD;;QACA,IAAIQ,iBAAJ,EAAuB;UACrBF,gBAAgB,GAAG,EAAE,GAAGE,iBAAL;YAAwB,GAAGH,KAAK,CAACE;UAAjC,CAAnB;QACD;MACF;;MACDE,sBAAsB,CAACT,GAAD,EAAM,KAAN,EAAa,KAAb,CAAtB;;MACAI,eAAe,CAACM,MAAhB,GAAyBC,MAAM,CAACC,MAAP,CACvB,EADuB,EAEvBR,eAAe,CAACM,MAFO,EAGvBL,KAAK,CAACQ,aAHiB,CAAzB;MAKA,MAAMC,SAAS,GAAGrB,kBAAkB,CAACa,gBAAD,CAApC;;MAEAQ,SAAS,CAACC,QAAV,GAAsBC,QAAD,IAAwB;QAC3C,IAAIA,QAAJ,EAAc;UACZ,OAAOpB,uBAAuB,CAACI,GAAD,CAA9B;UACA,MAAMiB,gBAAgB,GAAGhB,IAAI,KAAK,SAAlC;;UACAQ,sBAAsB,CAACT,GAAD,EAAMgB,QAAN,EAAgBC,gBAAhB,CAAtB;QACD;;QACDZ,KAAK,CAACU,QAAN,IAAkBV,KAAK,CAACU,QAAN,CAAeC,QAAf,CAAlB;MACD,CAPD;;MASAZ,eAAe,CAACc,KAAhB,GAAwBJ,SAAxB;;MACAK,uBAAuB,CAACnB,GAAD,EAAMI,eAAN,EAAuBH,IAAvB,CAAvB;IACD;;EAlCgC,CAAnC;AAoCD,CAzCM,CAAP"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "3.0.0-rc.5",
3
+ "version": "3.0.0-rc.7",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
@@ -76,7 +76,6 @@
76
76
  "dependencies": {
77
77
  "@babel/plugin-transform-object-assign": "^7.16.7",
78
78
  "@babel/preset-typescript": "^7.16.7",
79
- "@types/invariant": "^2.2.35",
80
79
  "invariant": "^2.2.4",
81
80
  "lodash.isequal": "^4.5.0",
82
81
  "setimmediate": "^1.0.5",
@@ -101,6 +100,7 @@
101
100
  "@types/babel__core": "^7.1.18",
102
101
  "@types/babel__generator": "^7.6.4",
103
102
  "@types/babel__traverse": "^7.14.2",
103
+ "@types/invariant": "^2.2.35",
104
104
  "@types/jest": "^27.4.0",
105
105
  "@types/react-native": "^0.66.0",
106
106
  "@typescript-eslint/eslint-plugin": "^5.11.0",
@@ -17,7 +17,7 @@ def find_config()
17
17
  :react_native_common_dir => nil,
18
18
  }
19
19
 
20
- react_native_node_modules_dir = File.join(File.dirname(`cd #{Pod::Config.instance.installation_root.to_s} && node --print "require.resolve('react-native/package.json')"`), '..')
20
+ react_native_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
21
21
  react_native_json = try_to_parse_react_native_package_json(react_native_node_modules_dir)
22
22
 
23
23
  if react_native_json == nil
@@ -52,6 +52,7 @@ def assert_no_multiple_instances(react_native_info)
52
52
 
53
53
  lib_instances_in_react_native_node_modules = %x[find #{react_native_info[:react_native_node_modules_dir]} -name "package.json" | grep "/react-native-reanimated/package.json"]
54
54
  lib_instances_in_react_native_node_modules_array = lib_instances_in_react_native_node_modules.split("\n")
55
+ lib_instances_in_reanimated_node_modules_array = Array.new
55
56
  reanimated_instances = lib_instances_in_react_native_node_modules_array.length()
56
57
  if react_native_info[:react_native_node_modules_dir] != react_native_info[:reanimated_node_modules_dir]
57
58
  lib_instances_in_reanimated_node_modules = %x[find #{react_native_info[:reanimated_node_modules_dir]} -name "package.json" | grep "/react-native-reanimated/package.json"]
@@ -64,7 +65,7 @@ def assert_no_multiple_instances(react_native_info)
64
65
  location['/package.json'] = ''
65
66
  parsed_location += "- " + location + "\n"
66
67
  end
67
- raise "[react-native-reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsed_location
68
+ raise "[react-native-reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/next/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsed_location
68
69
  end
69
70
  end
70
71
 
@@ -8,14 +8,10 @@ import { adaptViewConfig } from './ConfigHelper';
8
8
  import { RNRenderer } from './reanimated2/platform-specific/RNRenderer';
9
9
  import {
10
10
  makeMutable,
11
- runOnUI,
11
+ configureLayoutAnimations,
12
12
  enableLayoutAnimations,
13
+ runOnUI,
13
14
  } from './reanimated2/core';
14
- import {
15
- DefaultEntering,
16
- DefaultExiting,
17
- DefaultLayout,
18
- } from './reanimated2/layoutReanimation/defaultAnimations/Default';
19
15
  import {
20
16
  isJest,
21
17
  isChromeDebugger,
@@ -26,6 +22,7 @@ import {
26
22
  BaseAnimationBuilder,
27
23
  EntryExitAnimationFunction,
28
24
  ILayoutAnimationBuilder,
25
+ LayoutAnimationFunction,
29
26
  } from './reanimated2/layoutReanimation';
30
27
  import {
31
28
  SharedValue,
@@ -43,6 +40,25 @@ function dummyListener() {
43
40
  // event is used.
44
41
  }
45
42
 
43
+ function maybeBuild(
44
+ layoutAnimationOrBuilder:
45
+ | ILayoutAnimationBuilder
46
+ | LayoutAnimationFunction
47
+ | Keyframe
48
+ ): LayoutAnimationFunction | Keyframe {
49
+ const isAnimationBuilder = (
50
+ value: ILayoutAnimationBuilder | LayoutAnimationFunction | Keyframe
51
+ ): value is ILayoutAnimationBuilder =>
52
+ 'build' in layoutAnimationOrBuilder &&
53
+ typeof layoutAnimationOrBuilder.build === 'function';
54
+
55
+ if (isAnimationBuilder(layoutAnimationOrBuilder)) {
56
+ return layoutAnimationOrBuilder.build();
57
+ } else {
58
+ return layoutAnimationOrBuilder;
59
+ }
60
+ }
61
+
46
62
  type NestedArray<T> = T | NestedArray<T>[];
47
63
  function flattenArray<T>(array: NestedArray<T>): T[] {
48
64
  if (!Array.isArray(array)) {
@@ -399,42 +415,35 @@ export default function createAnimatedComponent(
399
415
  setLocalRef: (ref) => {
400
416
  // TODO update config
401
417
  const tag = findNodeHandle(ref);
402
- if (
403
- !shouldBeUseWeb() &&
404
- (this.props.layout || this.props.entering || this.props.exiting) &&
405
- tag != null
406
- ) {
407
- enableLayoutAnimations(true, false);
408
- let layout = this.props.layout ? this.props.layout : DefaultLayout;
409
- let entering = this.props.entering
410
- ? this.props.entering
411
- : DefaultEntering;
412
- let exiting = this.props.exiting
413
- ? this.props.exiting
414
- : DefaultExiting;
415
-
416
- if (has('build', layout)) {
417
- layout = layout.build();
418
+ const { layout, entering, exiting } = this.props;
419
+ if ((layout || entering || exiting) && tag != null) {
420
+ if (!shouldBeUseWeb()) {
421
+ enableLayoutAnimations(true, false);
418
422
  }
419
-
420
- if (has('build', entering)) {
421
- entering = entering.build() as EntryExitAnimationFunction;
423
+ if (layout) {
424
+ configureLayoutAnimations(
425
+ tag,
426
+ 'layout',
427
+ maybeBuild(layout),
428
+ this.sv
429
+ );
422
430
  }
423
-
424
- if (has('build', exiting)) {
425
- exiting = exiting.build() as EntryExitAnimationFunction;
431
+ if (entering) {
432
+ configureLayoutAnimations(
433
+ tag,
434
+ 'entering',
435
+ maybeBuild(entering),
436
+ this.sv
437
+ );
438
+ }
439
+ if (exiting) {
440
+ configureLayoutAnimations(
441
+ tag,
442
+ 'exiting',
443
+ maybeBuild(exiting),
444
+ this.sv
445
+ );
426
446
  }
427
-
428
- const config = {
429
- layout,
430
- entering,
431
- exiting,
432
- sv: this.sv,
433
- };
434
- runOnUI(() => {
435
- 'worklet';
436
- global.LayoutAnimationRepository.registerConfig(tag, config);
437
- })();
438
447
  }
439
448
 
440
449
  if (ref !== this._component) {
@@ -6,6 +6,8 @@ import {
6
6
  AnimatedKeyboardInfo,
7
7
  } from '../commonTypes';
8
8
  import { Descriptor } from '../hook/commonTypes';
9
+ import { LayoutAnimationFunction } from '../layoutReanimation';
10
+ import { version as jsVersion } from '../../../package.json';
9
11
 
10
12
  export class NativeReanimated {
11
13
  native: boolean;
@@ -18,6 +20,33 @@ export class NativeReanimated {
18
20
  }
19
21
  this.InnerNativeModule = global.__reanimatedModuleProxy;
20
22
  this.native = native;
23
+ if (native) {
24
+ this.checkVersion();
25
+ }
26
+ }
27
+
28
+ checkVersion(): void {
29
+ const cppVersion = global._REANIMATED_VERSION_CPP;
30
+ const ok = (() => {
31
+ if (
32
+ jsVersion.match(/^\d+\.\d+\.\d+$/) &&
33
+ cppVersion.match(/^\d+\.\d+\.\d+$/)
34
+ ) {
35
+ // x.y.z, compare only major and minor, skip patch
36
+ const [jsMajor, jsMinor] = jsVersion.split('.');
37
+ const [cppMajor, cppMinor] = cppVersion.split('.');
38
+ return jsMajor === cppMajor && jsMinor === cppMinor;
39
+ } else {
40
+ // alpha, beta or rc, compare everything
41
+ return jsVersion === cppVersion;
42
+ }
43
+ })();
44
+ if (!ok) {
45
+ console.error(
46
+ `[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`
47
+ );
48
+ // TODO: detect Expo managed workflow
49
+ }
21
50
  }
22
51
 
23
52
  installCoreFunctions(valueSetter: <T>(value: T) => void): void {
@@ -91,6 +120,20 @@ export class NativeReanimated {
91
120
  return this.InnerNativeModule.getViewProp(viewTag, propName, callback);
92
121
  }
93
122
 
123
+ configureLayoutAnimation(
124
+ viewTag: number,
125
+ type: string,
126
+ config: Keyframe | LayoutAnimationFunction,
127
+ viewSharedValue: SharedValue<null | Record<string, unknown>> | null
128
+ ) {
129
+ this.InnerNativeModule.configureLayoutAnimation(
130
+ viewTag,
131
+ type,
132
+ config,
133
+ viewSharedValue
134
+ );
135
+ }
136
+
94
137
  enableLayoutAnimations(flag: boolean): void {
95
138
  this.InnerNativeModule.enableLayoutAnimations(flag);
96
139
  }
@@ -12,6 +12,7 @@ import {
12
12
  } from './commonTypes';
13
13
  import { Descriptor } from './hook/commonTypes';
14
14
  import JSReanimated from './js-reanimated/JSReanimated';
15
+ import { LayoutAnimationFunction } from './layoutReanimation';
15
16
 
16
17
  if (global._setGlobalConsole === undefined) {
17
18
  // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
@@ -178,7 +179,8 @@ function workletValueSetter<T extends WorkletValue>(
178
179
  const initializeAnimation = (timestamp: number) => {
179
180
  animation.onStart(animation, this.value, timestamp, previousAnimation);
180
181
  };
181
- initializeAnimation(getTimestamp());
182
+ const currentTimestamp = getTimestamp();
183
+ initializeAnimation(currentTimestamp);
182
184
  const step = (timestamp: number) => {
183
185
  if (animation.cancelled) {
184
186
  animation.callback && animation.callback(false /* finished */);
@@ -196,13 +198,7 @@ function workletValueSetter<T extends WorkletValue>(
196
198
  };
197
199
 
198
200
  this._animation = animation;
199
-
200
- if (_frameTimestamp) {
201
- // frame
202
- step(_frameTimestamp);
203
- } else {
204
- requestAnimationFrame(step);
205
- }
201
+ step(currentTimestamp);
206
202
  } else {
207
203
  // prevent setting again to the same value
208
204
  // and triggering the mappers that treat this value as an input
@@ -260,8 +256,7 @@ function workletValueSetterJS<T extends WorkletValue>(
260
256
  };
261
257
 
262
258
  this._animation = animation;
263
-
264
- requestFrame(step);
259
+ step(getTimestamp());
265
260
  } else {
266
261
  this._setValue && this._setValue(value as AnimatableValue | Descriptor);
267
262
  }
@@ -371,6 +366,20 @@ export function enableLayoutAnimations(
371
366
  }
372
367
  }
373
368
 
369
+ export function configureLayoutAnimations(
370
+ viewTag: number,
371
+ type: string,
372
+ config: LayoutAnimationFunction | Keyframe,
373
+ viewSharedValue: SharedValue<null | Record<string, unknown>> | null
374
+ ): void {
375
+ NativeReanimatedModule.configureLayoutAnimation(
376
+ viewTag,
377
+ type,
378
+ config,
379
+ viewSharedValue
380
+ );
381
+ }
382
+
374
383
  export function configureProps(uiProps: string[], nativeProps: string[]): void {
375
384
  if (!nativeShouldBeMock()) {
376
385
  NativeReanimatedModule.configureProps(uiProps, nativeProps);