@react-native-ohos/react-native-reanimated 4.0.2-beta.1 → 4.1.0-beta.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 (196) hide show
  1. package/CHANGELOG.md +1070 -0
  2. package/LICENSE +21 -0
  3. package/README.md +842 -0
  4. package/compatibility.json +20 -26
  5. package/harmony/reanimated/BuildProfile.ets +1 -1
  6. package/harmony/reanimated/index.ets +4 -2
  7. package/harmony/reanimated/oh-package-lock.json5 +1 -1
  8. package/harmony/reanimated/oh-package.json5 +1 -1
  9. package/harmony/reanimated/src/main/cpp/CMakeLists.txt +23 -9
  10. package/harmony/reanimated/src/main/cpp/Common/NativeView/CMakeLists.txt +56 -0
  11. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/ComponentDescriptors.h +19 -0
  12. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryComponentDescriptor.h +30 -0
  13. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.cpp +15 -0
  14. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.h +41 -0
  15. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryState.h +30 -0
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +8 -9
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +3 -6
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +203 -150
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +1 -6
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +2 -7
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +0 -1
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +2 -18
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +11 -11
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +2 -6
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +4 -1
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +5 -0
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +8 -0
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +27 -46
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +20 -20
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +2 -2
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +3 -3
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +10 -2
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +5 -3
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +20 -17
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +5 -8
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +33 -66
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +29 -22
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +14 -2
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +8 -2
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +50 -91
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +43 -18
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.cpp +63 -0
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.h +37 -0
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.cpp +100 -0
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.h +49 -0
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimation.h +13 -0
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimationFactory.h +32 -0
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.cpp +156 -0
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.h +71 -0
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.cpp +141 -0
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.h +104 -0
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.cpp +97 -0
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.h +69 -0
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.cpp +89 -0
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.h +36 -0
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +12 -0
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +11 -2
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +2 -3
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +3 -5
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +3 -3
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +1 -1
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +38 -37
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +3 -6
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +54 -32
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +5 -7
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +46 -46
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +8 -7
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +4 -57
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.cpp +23 -0
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +10 -8
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.cpp +77 -0
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.h +38 -0
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +47 -68
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +21 -9
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +4 -1
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +35 -78
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +44 -13
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +13 -11
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +4 -0
  80. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +7 -3
  81. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +20 -27
  82. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +12 -9
  83. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +63 -36
  84. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +6 -8
  85. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +55 -46
  86. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +8 -5
  87. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +1 -2
  88. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +3 -2
  89. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +76 -71
  90. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +17 -14
  91. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +145 -273
  92. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +43 -44
  93. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +19 -19
  94. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +16 -12
  95. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +95 -114
  96. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +38 -25
  97. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +9 -34
  98. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +0 -10
  99. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.cpp +47 -0
  100. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.h +24 -0
  101. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.cpp +87 -0
  102. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.h +28 -0
  103. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.cpp +326 -0
  104. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.h +65 -0
  105. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.cpp +164 -0
  106. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.h +51 -0
  107. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +14 -66
  108. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +7 -18
  109. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.cpp +284 -0
  110. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.h +31 -0
  111. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +13 -132
  112. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +3 -21
  113. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/reversingShortening.h +43 -0
  114. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Compat/WorkletsApi.h +13 -0
  115. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.cpp +33 -0
  116. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.h +39 -0
  117. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.cpp +95 -0
  118. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.h +40 -0
  119. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +20 -23
  120. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +2 -6
  121. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +26 -18
  122. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +4 -8
  123. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +16 -28
  124. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +3 -4
  125. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -24
  126. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +17 -7
  127. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.cpp +152 -0
  128. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.h +86 -0
  129. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/PropsLayoutFilter.h +98 -0
  130. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +162 -28
  131. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +69 -11
  132. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +41 -17
  133. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +14 -3
  134. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/propNameFromString.h +130 -0
  135. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +1 -0
  136. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +5 -7
  137. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +7 -4
  138. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +52 -9
  139. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +174 -62
  140. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +12 -11
  141. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +251 -128
  142. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +23 -19
  143. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +34 -6
  144. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +71 -64
  145. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +938 -700
  146. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +123 -76
  147. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.cpp +313 -0
  148. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.h +18 -0
  149. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoSelector.h +41 -0
  150. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.cpp +113 -0
  151. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.h +73 -0
  152. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +4 -4
  153. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +23 -48
  154. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +13 -14
  155. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +20 -3
  156. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReaJSIUtils.h +227 -0
  157. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +51 -14
  158. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +2 -5
  159. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/SingleInstanceChecker.h +76 -0
  160. package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.cpp +353 -0
  161. package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.h +95 -0
  162. package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.cpp +140 -0
  163. package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.h +52 -0
  164. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.cpp +45 -0
  165. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.h +33 -0
  166. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryJSIBinder.h +20 -0
  167. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +112 -19
  168. package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +4 -2
  169. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +1 -1
  170. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +1 -1
  171. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +24 -1
  172. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +7 -2
  173. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +88 -57
  174. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +4 -2
  175. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +1 -1
  176. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +1 -1
  177. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +9 -7
  178. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +6 -5
  179. package/harmony/reanimated/src/main/cpp/TransformParser.h +1 -1
  180. package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/EventEmitters.h +19 -0
  181. package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/Props.h +31 -0
  182. package/harmony/reanimated/src/main/ets/KeyboardState.ts +11 -0
  183. package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +119 -19
  184. package/harmony/reanimated/src/main/ets/{ReanimatedPackage.ts → ReanimatedPackage.ets} +4 -3
  185. package/harmony/reanimated.har +0 -0
  186. package/package.json +52 -24
  187. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +0 -145
  188. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +0 -47
  189. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +0 -93
  190. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +0 -36
  191. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +0 -75
  192. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +0 -45
  193. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +0 -183
  194. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +0 -93
  195. package/harmony/reanimated/src/main/ets/AnimationManager.ts +0 -61
  196. /package/harmony/reanimated/{ts.ts → ts.ets} +0 -0
@@ -1,4 +1,5 @@
1
1
  #include <reanimated/CSS/misc/ViewStylesRepository.h>
2
+ #include <reanimated/Tools/FeatureFlags.h>
2
3
 
3
4
  #include <memory>
4
5
  #include <string>
@@ -13,13 +14,11 @@ ViewStylesRepository::ViewStylesRepository(
13
14
  jsi::Value ViewStylesRepository::getNodeProp(
14
15
  const std::shared_ptr<const ShadowNode> &shadowNode,
15
16
  const std::string &propName) {
16
- int tag = shadowNode->getTag();
17
-
18
- auto &cachedNode = shadowNodeCache_[tag];
19
- updateCacheIfNeeded(cachedNode, shadowNode);
17
+ const auto resolvedNode = getNewestNode(shadowNode);
18
+ const auto *layoutableShadowNode = dynamic_cast<const LayoutableShadowNode *>(resolvedNode.get());
20
19
 
21
20
  if (propName == "width" || propName == "height" || propName == "top" || propName == "left") {
22
- const auto &layoutMetrics = cachedNode.layoutMetrics;
21
+ const auto layoutMetrics = layoutableShadowNode ? layoutableShadowNode->layoutMetrics_ : LayoutMetrics{};
23
22
 
24
23
  if (propName == "width") {
25
24
  return {layoutMetrics.frame.size.width};
@@ -31,7 +30,13 @@ jsi::Value ViewStylesRepository::getNodeProp(
31
30
  return {layoutMetrics.frame.origin.x};
32
31
  }
33
32
  } else {
34
- const auto &viewProps = cachedNode.viewProps;
33
+ if (!layoutableShadowNode) {
34
+ return jsi::Value::undefined();
35
+ }
36
+ const auto viewProps = std::static_pointer_cast<const ViewProps>(resolvedNode->getProps());
37
+ if (!viewProps) {
38
+ return jsi::Value::undefined();
39
+ }
35
40
 
36
41
  if (propName == "opacity") {
37
42
  return {viewProps->opacity};
@@ -48,15 +53,7 @@ jsi::Value ViewStylesRepository::getNodeProp(
48
53
  jsi::Value ViewStylesRepository::getParentNodeProp(
49
54
  const std::shared_ptr<const ShadowNode> &shadowNode,
50
55
  const std::string &propName) {
51
- const auto surfaceId = shadowNode->getSurfaceId();
52
- const auto &shadowTreeRegistry = uiManager_->getShadowTreeRegistry();
53
-
54
- std::shared_ptr<const ShadowNode> parentNode = nullptr;
55
-
56
- shadowTreeRegistry.visit(surfaceId, [&](ShadowTree const &shadowTree) {
57
- auto currentRevision = shadowTree.getCurrentRevision();
58
- parentNode = dom::getParentNode(currentRevision.rootShadowNode, *shadowNode);
59
- });
56
+ const auto parentNode = getParentNode(shadowNode);
60
57
 
61
58
  if (!parentNode) {
62
59
  return jsi::Value::undefined();
@@ -65,37 +62,67 @@ jsi::Value ViewStylesRepository::getParentNodeProp(
65
62
  return getNodeProp(parentNode, propName);
66
63
  }
67
64
 
68
- folly::dynamic ViewStylesRepository::getStyleProp(const Tag tag, const PropertyPath &propertyPath) {
69
- auto animatedValue = getPropertyValue(animatedPropsRegistry_->get(tag), propertyPath);
70
- if (!animatedValue.isNull()) {
71
- return animatedValue;
65
+ std::shared_ptr<const ShadowNode> ViewStylesRepository::getNewestNode(
66
+ const std::shared_ptr<const ShadowNode> &shadowNode) const {
67
+ if constexpr (StaticFeatureFlags::getFlag("USE_ANIMATION_BACKEND")) {
68
+ // Backend mode has no commit hook (it returns before taking the updates-registry
69
+ // lock), so reading the live tree here cannot deadlock and needs no snapshot.
70
+ const auto newestNode = uiManager_->getNewestCloneOfShadowNode(*shadowNode);
71
+ return newestNode ? newestNode : shadowNode;
72
72
  }
73
73
 
74
- return getPropertyValue(staticPropsRegistry_->get(tag), propertyPath);
75
- }
74
+ // Resolve shadowNode against the last mounted root without the ShadowTree lock (the
75
+ // deadlock) that getNewestCloneOfShadowNode takes, falling back to the passed node.
76
+ // Mirrors RN's getShadowNodeInSubtree:
77
+ // https://github.com/facebook/react-native/blob/v0.86.0-rc.3/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp#L339
78
+ const auto it = lastMountedRootBySurface_.find(shadowNode->getSurfaceId());
79
+ if (it == lastMountedRootBySurface_.end()) {
80
+ return shadowNode;
81
+ }
82
+ const auto &root = it->second;
76
83
 
77
- void ViewStylesRepository::clearNodesCache() {
78
- shadowNodeCache_.clear();
84
+ if (ShadowNode::sameFamily(*root, *shadowNode)) {
85
+ return root;
86
+ }
87
+
88
+ const auto ancestors = shadowNode->getFamily().getAncestors(*root);
89
+ if (ancestors.empty()) {
90
+ return shadowNode;
91
+ }
92
+
93
+ const auto &deepest = ancestors.back();
94
+ return deepest.first.get().getChildren().at(deepest.second);
79
95
  }
80
96
 
81
- void ViewStylesRepository::updateCacheIfNeeded(
82
- CachedShadowNode &cachedNode,
83
- const std::shared_ptr<const ShadowNode> &shadowNode) {
84
- auto newestCloneOfShadowNode = uiManager_->getNewestCloneOfShadowNode(*shadowNode);
97
+ std::shared_ptr<const ShadowNode> ViewStylesRepository::getParentNode(
98
+ const std::shared_ptr<const ShadowNode> &shadowNode) const {
99
+ if constexpr (StaticFeatureFlags::getFlag("USE_ANIMATION_BACKEND")) {
100
+ // Backend mode resolves against the live tree (see getNewestNode).
101
+ std::shared_ptr<const ShadowNode> parentNode = nullptr;
102
+ uiManager_->getShadowTreeRegistry().visit(shadowNode->getSurfaceId(), [&](const ShadowTree &shadowTree) {
103
+ parentNode = dom::getParentNode(shadowTree.getCurrentRevision().rootShadowNode, *shadowNode);
104
+ });
105
+ return parentNode;
106
+ }
85
107
 
86
- // Check if newestCloneOfShadowNode is valid (is already mounted / not
87
- // yet unmounted)
88
- if (!newestCloneOfShadowNode) {
89
- return;
108
+ const auto it = lastMountedRootBySurface_.find(shadowNode->getSurfaceId());
109
+ if (it == lastMountedRootBySurface_.end()) {
110
+ return nullptr;
90
111
  }
112
+ return dom::getParentNode(it->second, *shadowNode);
113
+ }
114
+
115
+ void ViewStylesRepository::setLastMountedRoot(const RootShadowNode::Shared &rootShadowNode) {
116
+ lastMountedRootBySurface_[rootShadowNode->getSurfaceId()] = rootShadowNode;
117
+ }
91
118
 
92
- auto layoutableShadowNode = dynamic_cast<const LayoutableShadowNode *>(newestCloneOfShadowNode.get());
93
- if (!layoutableShadowNode) {
94
- return;
119
+ folly::dynamic ViewStylesRepository::getStyleProp(const Tag tag, const PropertyPath &propertyPath) {
120
+ auto animatedValue = getPropertyValue(animatedPropsRegistry_->get(tag), propertyPath);
121
+ if (!animatedValue.isNull()) {
122
+ return animatedValue;
95
123
  }
96
124
 
97
- cachedNode.layoutMetrics = layoutableShadowNode->layoutMetrics_;
98
- cachedNode.viewProps = std::static_pointer_cast<const ViewProps>(newestCloneOfShadowNode->getProps());
125
+ return getPropertyValue(staticPropsRegistry_->get(tag), propertyPath);
99
126
  }
100
127
 
101
128
  folly::dynamic ViewStylesRepository::getPropertyValue(const folly::dynamic &value, const PropertyPath &propertyPath) {
@@ -4,9 +4,11 @@
4
4
  #include <reanimated/CSS/registries/StaticPropsRegistry.h>
5
5
  #include <reanimated/Fabric/updates/AnimatedPropsRegistry.h>
6
6
 
7
+ #include <react/renderer/components/root/RootShadowNode.h>
7
8
  #include <react/renderer/components/view/ViewProps.h>
8
9
  #include <react/renderer/core/LayoutableShadowNode.h>
9
10
  #include <react/renderer/dom/DOM.h>
11
+ #include <react/renderer/uimanager/UIManager.h>
10
12
 
11
13
  #include <memory>
12
14
  #include <string>
@@ -17,11 +19,6 @@ namespace reanimated::css {
17
19
  using namespace facebook;
18
20
  using namespace react;
19
21
 
20
- struct CachedShadowNode {
21
- LayoutMetrics layoutMetrics;
22
- std::shared_ptr<const ViewProps> viewProps;
23
- };
24
-
25
22
  class ViewStylesRepository {
26
23
  public:
27
24
  ViewStylesRepository(
@@ -36,16 +33,17 @@ class ViewStylesRepository {
36
33
  jsi::Value getParentNodeProp(const std::shared_ptr<const ShadowNode> &shadowNode, const std::string &propName);
37
34
  folly::dynamic getStyleProp(Tag tag, const PropertyPath &propertyPath);
38
35
 
39
- void clearNodesCache();
36
+ void setLastMountedRoot(const RootShadowNode::Shared &rootShadowNode);
40
37
 
41
38
  private:
42
39
  std::shared_ptr<UIManager> uiManager_;
43
40
  std::shared_ptr<StaticPropsRegistry> staticPropsRegistry_;
44
41
  std::shared_ptr<AnimatedPropsRegistry> animatedPropsRegistry_;
45
42
 
46
- std::unordered_map<int, CachedShadowNode> shadowNodeCache_;
43
+ std::unordered_map<SurfaceId, RootShadowNode::Shared> lastMountedRootBySurface_;
47
44
 
48
- void updateCacheIfNeeded(CachedShadowNode &cachedNode, const std::shared_ptr<const ShadowNode> &shadowNode);
45
+ std::shared_ptr<const ShadowNode> getNewestNode(const std::shared_ptr<const ShadowNode> &shadowNode) const;
46
+ std::shared_ptr<const ShadowNode> getParentNode(const std::shared_ptr<const ShadowNode> &shadowNode) const;
49
47
 
50
48
  static folly::dynamic getPropertyValue(const folly::dynamic &value, const PropertyPath &propertyPath);
51
49
  };
@@ -12,12 +12,12 @@ AnimationProgressProvider::AnimationProgressProvider(
12
12
  const double iterationCount,
13
13
  const AnimationDirection direction,
14
14
  EasingFunction easingFunction,
15
- const std::shared_ptr<KeyframeEasingFunctions> &keyframeEasingFunctions)
15
+ const std::shared_ptr<KeyframeEasingConfigs> &keyframeEasingConfigs)
16
16
  : RawProgressProvider(timestamp, duration, delay),
17
17
  iterationCount_(iterationCount),
18
18
  direction_(direction),
19
19
  easingFunction_(std::move(easingFunction)),
20
- keyframeEasingFunctions_(keyframeEasingFunctions) {}
20
+ keyframeEasingConfigs_(keyframeEasingConfigs) {}
21
21
 
22
22
  void AnimationProgressProvider::setIterationCount(double iterationCount) {
23
23
  iterationCount_ = iterationCount;
@@ -39,34 +39,6 @@ double AnimationProgressProvider::getGlobalProgress() const {
39
39
  return applyAnimationDirection(rawProgress_.value_or(0));
40
40
  }
41
41
 
42
- AnimationProgressState AnimationProgressProvider::getState(const double timestamp) const {
43
- if (shouldFinish(timestamp)) {
44
- return AnimationProgressState::Finished;
45
- }
46
- if (pauseTimestamp_ > 0) {
47
- return AnimationProgressState::Paused;
48
- }
49
- if (timestamp < getStartTimestamp(timestamp) || !rawProgress_.has_value()) {
50
- return AnimationProgressState::Pending;
51
- }
52
- return AnimationProgressState::Running;
53
- }
54
-
55
- double AnimationProgressProvider::getPauseTimestamp() const {
56
- return pauseTimestamp_;
57
- }
58
-
59
- double AnimationProgressProvider::getTotalPausedTime(const double timestamp) const {
60
- return pauseTimestamp_ > 0 ? (totalPausedTime_ + (timestamp - pauseTimestamp_)) : totalPausedTime_;
61
- }
62
-
63
- double AnimationProgressProvider::getStartTimestamp(const double timestamp) const {
64
- // Start timestamp is the timestamp when the first animation keyframe
65
- // should be applied (it depends on the animation delay and the total
66
- // time when the animation was paused)
67
- return creationTimestamp_ + delay_ + getTotalPausedTime(timestamp);
68
- }
69
-
70
42
  double AnimationProgressProvider::getKeyframeProgress(const double fromOffset, const double toOffset) const {
71
43
  if (fromOffset == toOffset) {
72
44
  return 1;
@@ -76,14 +48,25 @@ double AnimationProgressProvider::getKeyframeProgress(const double fromOffset, c
76
48
 
77
49
  // Use the overridden easing function if it was overridden for the
78
50
  // current keyframe
79
- const auto easingFunctionIt = keyframeEasingFunctions_->find(fromOffset);
80
- if (easingFunctionIt != keyframeEasingFunctions_->end()) {
81
- return easingFunctionIt->second(keyframeProgress);
51
+ const auto easingConfigIt = keyframeEasingConfigs_->find(fromOffset);
52
+ if (easingConfigIt != keyframeEasingConfigs_->end()) {
53
+ return getEasingFunctionFromConfig(easingConfigIt->second)(keyframeProgress);
82
54
  }
83
55
 
84
56
  return easingFunction_(keyframeProgress);
85
57
  }
86
58
 
59
+ AnimationProgressState AnimationProgressProvider::getState() const {
60
+ return state_;
61
+ }
62
+
63
+ double AnimationProgressProvider::getStartTimestamp(const double timestamp) const {
64
+ // Start timestamp is the timestamp when the first animation keyframe
65
+ // should be applied (it depends on the animation delay and the total
66
+ // time when the animation was paused)
67
+ return creationTimestamp_ + delay_ + getTotalPausedTime(timestamp);
68
+ }
69
+
87
70
  void AnimationProgressProvider::pause(const double timestamp) {
88
71
  pauseTimestamp_ = timestamp;
89
72
  }
@@ -95,26 +78,21 @@ void AnimationProgressProvider::play(const double timestamp) {
95
78
  pauseTimestamp_ = 0;
96
79
  }
97
80
 
81
+ void AnimationProgressProvider::update(const double timestamp) {
82
+ RawProgressProvider::update(timestamp);
83
+ state_ = computeState(timestamp);
84
+ }
85
+
98
86
  void AnimationProgressProvider::resetProgress() {
99
87
  RawProgressProvider::resetProgress();
100
88
  currentIteration_ = 1;
101
89
  previousIterationsDuration_ = 0;
102
- }
103
-
104
- bool AnimationProgressProvider::shouldFinish(const double timestamp) const {
105
- if (iterationCount_ == 0) {
106
- return true;
107
- }
108
- if (iterationCount_ == -1) {
109
- return false;
110
- }
111
- const auto elapsedDuration = timestamp - getStartTimestamp(timestamp);
112
- return elapsedDuration >= duration_ * iterationCount_;
90
+ state_ = AnimationProgressState::Pending;
113
91
  }
114
92
 
115
93
  std::optional<double> AnimationProgressProvider::calculateRawProgress(const double timestamp) {
116
- const double currentIterationElapsedTime =
117
- timestamp - (creationTimestamp_ + delay_ + previousIterationsDuration_ + getTotalPausedTime(timestamp));
94
+ const double startTimestamp = getStartTimestamp(timestamp);
95
+ const double currentIterationElapsedTime = timestamp - (startTimestamp + previousIterationsDuration_);
118
96
 
119
97
  if (currentIterationElapsedTime < 0) {
120
98
  return std::nullopt;
@@ -132,6 +110,37 @@ std::optional<double> AnimationProgressProvider::calculateRawProgress(const doub
132
110
  return iterationProgress;
133
111
  }
134
112
 
113
+ double AnimationProgressProvider::getTotalPausedTime(const double timestamp) const {
114
+ if (pauseTimestamp_ > 0) {
115
+ return totalPausedTime_ + (timestamp - pauseTimestamp_);
116
+ }
117
+ return totalPausedTime_;
118
+ }
119
+
120
+ bool AnimationProgressProvider::shouldFinish(const double timestamp) const {
121
+ if (iterationCount_ == 0) {
122
+ return true;
123
+ }
124
+ if (iterationCount_ == -1) {
125
+ return false;
126
+ }
127
+ const auto elapsedDuration = timestamp - getStartTimestamp(timestamp);
128
+ return elapsedDuration >= duration_ * iterationCount_;
129
+ }
130
+
131
+ AnimationProgressState AnimationProgressProvider::computeState(const double timestamp) const {
132
+ if (shouldFinish(timestamp)) {
133
+ return AnimationProgressState::Finished;
134
+ }
135
+ if (pauseTimestamp_ > 0) {
136
+ return AnimationProgressState::Paused;
137
+ }
138
+ if (timestamp < getStartTimestamp(timestamp) || !rawProgress_.has_value()) {
139
+ return AnimationProgressState::Pending;
140
+ }
141
+ return AnimationProgressState::Running;
142
+ }
143
+
135
144
  double AnimationProgressProvider::updateIterationProgress(const double currentIterationElapsedTime) {
136
145
  if (duration_ == 0) {
137
146
  return 1;
@@ -26,7 +26,7 @@ class AnimationProgressProvider final : public KeyframeProgressProvider, public
26
26
  double iterationCount,
27
27
  AnimationDirection direction,
28
28
  EasingFunction easingFunction,
29
- const std::shared_ptr<KeyframeEasingFunctions> &keyframeEasingFunctions);
29
+ const std::shared_ptr<KeyframeEasingConfigs> &keyframeEasingConfigs);
30
30
 
31
31
  void setIterationCount(double iterationCount);
32
32
  void setDirection(AnimationDirection direction);
@@ -35,13 +35,13 @@ class AnimationProgressProvider final : public KeyframeProgressProvider, public
35
35
  AnimationDirection getDirection() const;
36
36
  double getGlobalProgress() const override;
37
37
  double getKeyframeProgress(double fromOffset, double toOffset) const override;
38
- AnimationProgressState getState(double timestamp) const;
39
- double getPauseTimestamp() const;
40
- double getTotalPausedTime(double timestamp) const;
38
+
39
+ AnimationProgressState getState() const;
41
40
  double getStartTimestamp(double timestamp) const;
42
41
 
43
42
  void pause(double timestamp);
44
43
  void play(double timestamp);
44
+ void update(double timestamp) override;
45
45
  void resetProgress() override;
46
46
 
47
47
  protected:
@@ -51,14 +51,17 @@ class AnimationProgressProvider final : public KeyframeProgressProvider, public
51
51
  double iterationCount_;
52
52
  AnimationDirection direction_;
53
53
  EasingFunction easingFunction_;
54
- std::shared_ptr<KeyframeEasingFunctions> keyframeEasingFunctions_;
54
+ std::shared_ptr<KeyframeEasingConfigs> keyframeEasingConfigs_;
55
55
 
56
+ AnimationProgressState state_ = AnimationProgressState::Pending;
56
57
  unsigned currentIteration_ = 1;
57
58
  double previousIterationsDuration_ = 0;
58
59
  double pauseTimestamp_ = 0;
59
60
  double totalPausedTime_ = 0;
60
61
 
62
+ double getTotalPausedTime(double timestamp) const;
61
63
  bool shouldFinish(double timestamp) const;
64
+ AnimationProgressState computeState(double timestamp) const;
62
65
 
63
66
  double updateIterationProgress(double currentIterationElapsedTime);
64
67
  double applyAnimationDirection(double iterationProgress) const;
@@ -15,11 +15,10 @@ void RawProgressProvider::setDelay(double delay) {
15
15
 
16
16
  void RawProgressProvider::resetProgress() {
17
17
  rawProgress_.reset();
18
- previousRawProgress_.reset();
19
18
  }
20
19
 
21
20
  void RawProgressProvider::update(const double timestamp) {
22
- previousRawProgress_ = rawProgress_;
21
+ lastTimestamp_ = timestamp;
23
22
 
24
23
  if (timestamp - creationTimestamp_ < delay_) {
25
24
  rawProgress_.reset();
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include <optional>
4
+
4
5
  namespace reanimated::css {
5
6
 
6
7
  class RawProgressProvider {
@@ -11,15 +12,15 @@ class RawProgressProvider {
11
12
  void setDelay(double delay);
12
13
 
13
14
  virtual void resetProgress();
14
- void update(double timestamp);
15
+ virtual void update(double timestamp);
15
16
 
16
17
  protected:
17
18
  double duration_;
18
19
  double delay_;
19
20
  double creationTimestamp_;
21
+ double lastTimestamp_{0};
20
22
 
21
23
  std::optional<double> rawProgress_;
22
- std::optional<double> previousRawProgress_;
23
24
 
24
25
  /**
25
26
  * Calculates the progress of the animation at the given timestamp without
@@ -1,9 +1,12 @@
1
1
  #include <reanimated/CSS/progress/TransitionProgressProvider.h>
2
2
 
3
+ #include <reanimated/CSS/utils/reversingShortening.h>
4
+
3
5
  #include <limits>
4
6
  #include <memory>
5
7
  #include <string>
6
8
  #include <unordered_set>
9
+ #include <utility>
7
10
 
8
11
  namespace reanimated::css {
9
12
 
@@ -13,17 +16,20 @@ TransitionPropertyProgressProvider::TransitionPropertyProgressProvider(
13
16
  const double timestamp,
14
17
  const double duration,
15
18
  const double delay,
16
- const EasingFunction &easingFunction)
17
- : RawProgressProvider(timestamp, duration, delay), easingFunction_(easingFunction) {}
19
+ EasingConfig easing)
20
+ : RawProgressProvider(timestamp, duration, delay),
21
+ easing_(std::move(easing)),
22
+ easingFunction_(getEasingFunctionFromConfig(easing_)) {}
18
23
 
19
24
  TransitionPropertyProgressProvider::TransitionPropertyProgressProvider(
20
25
  const double timestamp,
21
26
  const double duration,
22
27
  const double delay,
23
- const EasingFunction &easingFunction,
28
+ EasingConfig easing,
24
29
  const double reversingShorteningFactor)
25
30
  : RawProgressProvider(timestamp, duration, delay),
26
- easingFunction_(easingFunction),
31
+ easing_(std::move(easing)),
32
+ easingFunction_(getEasingFunctionFromConfig(easing_)),
27
33
  reversingShorteningFactor_(reversingShorteningFactor) {}
28
34
 
29
35
  double TransitionPropertyProgressProvider::getGlobalProgress() const {
@@ -41,17 +47,18 @@ double TransitionPropertyProgressProvider::getRemainingDelay(const double timest
41
47
  return delay_ - (timestamp - creationTimestamp_);
42
48
  }
43
49
 
44
- double TransitionPropertyProgressProvider::getReversingShorteningFactor() const {
45
- return reversingShorteningFactor_;
50
+ ReversingState TransitionPropertyProgressProvider::getReversingState() const {
51
+ return {reversingShorteningFactor_, creationTimestamp_ + delay_, duration_, delay_, easing_};
46
52
  }
47
53
 
48
54
  TransitionProgressState TransitionPropertyProgressProvider::getState() const {
55
+ // rawProgress_ is empty until the property's delay has passed
56
+ // (RawProgressProvider::update resets it while timestamp < creationTimestamp + delay)
49
57
  if (!rawProgress_.has_value()) {
50
58
  return TransitionProgressState::Pending;
51
59
  }
52
- const auto rawProgress = rawProgress_.value();
53
- if (rawProgress >= 1) {
54
- return TransitionProgressState::Finished;
60
+ if (rawProgress_.value() >= 1) {
61
+ return TransitionProgressState::Idle;
55
62
  }
56
63
  return TransitionProgressState::Running;
57
64
  }
@@ -70,12 +77,14 @@ double TransitionPropertyProgressProvider::getElapsedTime(const double timestamp
70
77
  // TransitionProgressProvider
71
78
 
72
79
  TransitionProgressState TransitionProgressProvider::getState() const {
73
- for (const auto &[_, propertyProgressProvider] : propertyProgressProviders_) {
74
- if (propertyProgressProvider->getState() == TransitionProgressState::Running) {
75
- return TransitionProgressState::Running;
80
+ for (const auto &[_, progressProvider] : propertyProgressProviders_) {
81
+ const auto state = progressProvider->getState();
82
+ if (state != TransitionProgressState::Idle) {
83
+ return state;
76
84
  }
77
85
  }
78
- return TransitionProgressState::Pending;
86
+
87
+ return TransitionProgressState::Idle;
79
88
  }
80
89
 
81
90
  double TransitionProgressProvider::getMinDelay(const double timestamp) const {
@@ -102,63 +111,51 @@ std::unordered_set<std::string> TransitionProgressProvider::getRemovedProperties
102
111
  return removedProperties_;
103
112
  }
104
113
 
105
- void TransitionProgressProvider::discardFinishedProgressProviders() {
106
- for (auto it = propertyProgressProviders_.begin(); it != propertyProgressProviders_.end();) {
107
- if (it->second->getState() == TransitionProgressState::Finished) {
108
- it = propertyProgressProviders_.erase(it);
109
- } else {
110
- ++it;
114
+ void TransitionProgressProvider::runProgressProvider(
115
+ const std::string &propertyName,
116
+ const bool isReversed,
117
+ const double timestamp) {
118
+
119
+ const auto &settings = propertySettings_.at(propertyName);
120
+
121
+ const auto providerIt = propertyProgressProviders_.find(propertyName);
122
+
123
+ if (providerIt != propertyProgressProviders_.end()) {
124
+ const auto &progressProvider = providerIt->second;
125
+ progressProvider->update(timestamp);
126
+
127
+ if (isReversed && progressProvider->getState() != TransitionProgressState::Idle) {
128
+ // Create reversing shortening progress provider for interrupted reversing transition
129
+ propertyProgressProviders_.insert_or_assign(
130
+ propertyName, createReversingShorteningProgressProvider(timestamp, settings, *progressProvider));
131
+ return;
111
132
  }
112
133
  }
134
+
135
+ // Create progress provider with the new settings
136
+ propertyProgressProviders_.insert_or_assign(
137
+ propertyName,
138
+ std::make_shared<TransitionPropertyProgressProvider>(
139
+ timestamp, settings.duration, settings.delay, settings.easingConfig));
113
140
  }
114
141
 
115
- void TransitionProgressProvider::discardIrrelevantProgressProviders(
116
- const std::unordered_set<std::string> &transitionPropertyNames) {
117
- for (auto it = propertyProgressProviders_.begin(); it != propertyProgressProviders_.end();) {
118
- // Remove property progress providers for properties not specified in the
119
- // transition property names
120
- if (transitionPropertyNames.find(it->first) == transitionPropertyNames.end()) {
121
- it = propertyProgressProviders_.erase(it);
122
- } else {
123
- ++it;
124
- }
142
+ void TransitionProgressProvider::removeProperties(const std::vector<std::string> &propertyNames) {
143
+ for (const auto &propertyName : propertyNames) {
144
+ propertyProgressProviders_.erase(propertyName);
125
145
  }
126
146
  }
127
147
 
128
- void TransitionProgressProvider::runProgressProviders(
129
- const double timestamp,
130
- const CSSTransitionPropertiesSettings &propertiesSettings,
131
- const PropertyNames &changedPropertyNames,
132
- const std::unordered_set<std::string> &reversedPropertyNames) {
133
- for (const auto &propertyName : changedPropertyNames) {
134
- const auto propertySettingsOptional = getTransitionPropertySettings(propertiesSettings, propertyName);
135
-
136
- if (!propertySettingsOptional.has_value()) {
137
- throw std::invalid_argument("[Reanimated] Property '" + propertyName + "' is not a valid transition property");
138
- }
148
+ void TransitionProgressProvider::removeProperty(const std::string &propertyName) {
149
+ propertyProgressProviders_.erase(propertyName);
150
+ }
139
151
 
140
- const auto &propertySettings = propertySettingsOptional.value();
141
- const auto it = propertyProgressProviders_.find(propertyName);
142
-
143
- if (it != propertyProgressProviders_.end()) {
144
- const auto &progressProvider = it->second;
145
- progressProvider->update(timestamp);
146
-
147
- if (reversedPropertyNames.find(propertyName) != reversedPropertyNames.end() &&
148
- progressProvider->getState() != TransitionProgressState::Finished) {
149
- // Create reversing shortening progress provider for interrupted
150
- // reversing transition
151
- propertyProgressProviders_.insert_or_assign(
152
- propertyName, createReversingShorteningProgressProvider(timestamp, propertySettings, *progressProvider));
153
- continue;
154
- }
152
+ void TransitionProgressProvider::discardFinishedProgressProviders() {
153
+ for (auto it = propertyProgressProviders_.begin(); it != propertyProgressProviders_.end();) {
154
+ if (it->second->getState() == TransitionProgressState::Idle) {
155
+ it = propertyProgressProviders_.erase(it);
156
+ } else {
157
+ ++it;
155
158
  }
156
-
157
- // Create progress provider with the new settings
158
- propertyProgressProviders_.insert_or_assign(
159
- propertyName,
160
- std::make_shared<TransitionPropertyProgressProvider>(
161
- timestamp, propertySettings.duration, propertySettings.delay, propertySettings.easingFunction));
162
159
  }
163
160
  }
164
161
 
@@ -167,7 +164,7 @@ void TransitionProgressProvider::update(const double timestamp) {
167
164
 
168
165
  for (const auto &[propertyName, propertyProgressProvider] : propertyProgressProviders_) {
169
166
  propertyProgressProvider->update(timestamp);
170
- if (propertyProgressProvider->getState() == TransitionProgressState::Finished) {
167
+ if (propertyProgressProvider->getState() == TransitionProgressState::Idle) {
171
168
  removedProperties_.insert(propertyName);
172
169
  }
173
170
  }
@@ -178,16 +175,24 @@ TransitionProgressProvider::createReversingShorteningProgressProvider(
178
175
  const double timestamp,
179
176
  const CSSTransitionPropertySettings &propertySettings,
180
177
  const TransitionPropertyProgressProvider &existingProgressProvider) {
181
- const auto oldProgress = existingProgressProvider.getKeyframeProgress(0, 1);
182
- const auto oldReversingShorteningFactor = existingProgressProvider.getReversingShorteningFactor();
183
- auto newReversingShorteningFactor = oldProgress * oldReversingShorteningFactor + (1 - oldReversingShorteningFactor);
184
-
185
- return std::make_shared<TransitionPropertyProgressProvider>(
178
+ const auto rs = reverseShorten(
179
+ existingProgressProvider.getReversingState(),
186
180
  timestamp,
187
- propertySettings.duration * newReversingShorteningFactor,
188
- propertySettings.delay < 0 ? newReversingShorteningFactor * propertySettings.delay : propertySettings.delay,
189
- propertySettings.easingFunction,
190
- newReversingShorteningFactor);
181
+ propertySettings.duration,
182
+ propertySettings.delay,
183
+ propertySettings.easingConfig);
184
+
185
+ return std::make_shared<TransitionPropertyProgressProvider>(timestamp, rs.duration, rs.delay, rs.easing, rs.factor);
186
+ }
187
+
188
+ void TransitionProgressProvider::setPropertySettings(const PropertiesSettingsMap &changedPropertiesSettings) {
189
+ for (const auto &[propertyName, propertySettings] : changedPropertiesSettings) {
190
+ propertySettings_[propertyName] = propertySettings;
191
+ }
192
+ }
193
+
194
+ CSSTransitionPropertySettings TransitionProgressProvider::getPropertySettings(const std::string &propertyName) const {
195
+ return propertySettings_.at(propertyName);
191
196
  }
192
197
 
193
198
  } // namespace reanimated::css