@react-native-ohos/react-native-reanimated 3.18.1-rc.6 → 4.0.0-rc.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 (275) hide show
  1. package/compatibility.json +161 -0
  2. package/harmony/reanimated/BuildProfile.ets +1 -1
  3. package/harmony/reanimated/build-profile.json5 +8 -1
  4. package/harmony/reanimated/oh-package.json5 +3 -2
  5. package/harmony/reanimated/src/main/cpp/CMakeLists.txt +31 -40
  6. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +11 -16
  7. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +3 -4
  8. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +390 -0
  9. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +16 -0
  10. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +30 -0
  11. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.cpp +46 -0
  12. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.h +23 -0
  13. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.cpp +53 -0
  14. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.h +21 -0
  15. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.cpp +166 -0
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.h +71 -0
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.cpp +368 -0
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.h +53 -0
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.cpp +594 -0
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.h +67 -0
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.cpp +52 -0
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.h +26 -0
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.cpp +156 -0
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.h +76 -0
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +93 -0
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.h +33 -0
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.cpp +48 -0
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.h +31 -0
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +135 -0
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.h +61 -0
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +100 -0
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +44 -0
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.cpp +81 -0
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.h +53 -0
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +122 -0
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.h +38 -0
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +82 -0
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +63 -0
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +118 -0
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +174 -0
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +111 -0
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.cpp +196 -0
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.h +66 -0
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.cpp +134 -0
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +44 -0
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +174 -0
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +49 -0
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +45 -0
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +26 -0
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +90 -0
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +43 -0
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +17 -0
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +13 -0
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +127 -0
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +51 -0
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +145 -0
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +47 -0
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.cpp +69 -0
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.h +22 -0
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.cpp +66 -0
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.h +15 -0
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.cpp +28 -0
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.h +15 -0
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.cpp +13 -0
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.h +12 -0
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +157 -0
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +189 -0
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +76 -0
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +66 -0
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/configs.h +20 -0
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +136 -0
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +40 -0
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.cpp +38 -0
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.h +24 -0
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.cpp +58 -0
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.h +24 -0
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/blur.h +14 -0
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/brightness.h +14 -0
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/contrast.h +14 -0
  80. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/dropShadow.h +17 -0
  81. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/grayscale.h +14 -0
  82. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/hueRotate.h +14 -0
  83. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/invert.h +14 -0
  84. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/opacity.h +14 -0
  85. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/saturate.h +14 -0
  86. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/sepia.h +14 -0
  87. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +95 -0
  88. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +36 -0
  89. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.cpp +41 -0
  90. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.h +32 -0
  91. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +99 -0
  92. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +37 -0
  93. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +308 -0
  94. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +100 -0
  95. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.cpp +19 -0
  96. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +94 -0
  97. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.cpp +18 -0
  98. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.h +43 -0
  99. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +26 -0
  100. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +103 -0
  101. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +42 -0
  102. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +224 -0
  103. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.h +52 -0
  104. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +218 -0
  105. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +89 -0
  106. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.cpp +149 -0
  107. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.h +33 -0
  108. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +208 -0
  109. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.h +56 -0
  110. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.cpp +42 -0
  111. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.h +20 -0
  112. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.cpp +41 -0
  113. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.h +39 -0
  114. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.cpp +28 -0
  115. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.h +25 -0
  116. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.cpp +14 -0
  117. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.h +20 -0
  118. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.cpp +39 -0
  119. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.h +25 -0
  120. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +47 -0
  121. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.h +43 -0
  122. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +70 -0
  123. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.h +40 -0
  124. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +146 -0
  125. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +71 -0
  126. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +155 -0
  127. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +53 -0
  128. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +170 -0
  129. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +67 -0
  130. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/KeyframeProgressProvider.h +12 -0
  131. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +41 -0
  132. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +31 -0
  133. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +193 -0
  134. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +77 -0
  135. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +340 -0
  136. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +80 -0
  137. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +45 -0
  138. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +29 -0
  139. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +167 -0
  140. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +51 -0
  141. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +61 -0
  142. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +33 -0
  143. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.cpp +80 -0
  144. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.h +39 -0
  145. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +93 -0
  146. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +36 -0
  147. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +110 -0
  148. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +33 -0
  149. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +75 -0
  150. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +45 -0
  151. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.cpp +12 -0
  152. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.h +10 -0
  153. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.cpp +36 -0
  154. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.h +23 -0
  155. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +149 -0
  156. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +32 -0
  157. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +51 -39
  158. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +13 -15
  159. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +0 -3
  160. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +22 -53
  161. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +12 -8
  162. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +46 -37
  163. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +3 -10
  164. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -0
  165. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +25 -0
  166. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +160 -0
  167. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +71 -0
  168. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +161 -0
  169. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +65 -0
  170. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +4 -2
  171. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +62 -157
  172. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +38 -46
  173. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +79 -0
  174. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +81 -0
  175. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +864 -0
  176. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +214 -0
  177. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/{LayoutAnimationsProxy.cpp → LayoutAnimationsProxy_Legacy.cpp} +303 -276
  178. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +220 -0
  179. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +5 -65
  180. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +52 -82
  181. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.cpp +456 -0
  182. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.h +102 -0
  183. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +544 -0
  184. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.cpp +119 -0
  185. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.h +39 -0
  186. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +957 -552
  187. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +87 -111
  188. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +115 -163
  189. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +38 -54
  190. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +34 -36
  191. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +8 -0
  192. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +46 -58
  193. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +5 -9
  194. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.cpp +18 -0
  195. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.h +44 -0
  196. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +26 -57
  197. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +12 -33
  198. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +46 -0
  199. package/harmony/reanimated/src/main/cpp/Common/cpp/{worklets → reanimated}/Tools/ReanimatedVersion.h +3 -4
  200. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +60 -85
  201. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +1 -0
  202. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +0 -3
  203. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +266 -0
  204. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +36 -0
  205. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +36 -0
  206. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +23 -0
  207. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +3 -3
  208. package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +12 -1
  209. package/harmony/reanimated/src/main/ets/ReanimatedPackage.ts +1 -4
  210. package/harmony/reanimated.har +0 -0
  211. package/package.json +36 -18
  212. package/scripts/deploy.js +191 -0
  213. package/scripts/set-reanimated-version.js +37 -0
  214. package/scripts/update-version.js +119 -0
  215. package/scripts/validate-react-native-version.js +46 -0
  216. package/scripts/validate-worklets-build.js +17 -0
  217. package/scripts/validate-worklets-version.js +79 -0
  218. package/scripts/worklets-version.json +4 -0
  219. package/LICENSE +0 -21
  220. package/README.OpenSource +0 -11
  221. package/README.md +0 -10
  222. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +0 -68
  223. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +0 -68
  224. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +0 -147
  225. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +0 -14
  226. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +0 -5
  227. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +0 -19
  228. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +0 -47
  229. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +0 -59
  230. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +0 -27
  231. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +0 -25
  232. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +0 -94
  233. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +0 -49
  234. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +0 -8
  235. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +0 -39
  236. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +0 -326
  237. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +0 -345
  238. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +0 -52
  239. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +0 -35
  240. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +0 -10
  241. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +0 -342
  242. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +0 -47
  243. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +0 -16
  244. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +0 -20
  245. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +0 -20
  246. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +0 -29
  247. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +0 -16
  248. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +0 -26
  249. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +0 -199
  250. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +0 -95
  251. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +0 -72
  252. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +0 -49
  253. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +0 -20
  254. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +0 -22
  255. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +0 -29
  256. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +0 -41
  257. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +0 -16
  258. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +0 -19
  259. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +0 -112
  260. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +0 -127
  261. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +0 -53
  262. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +0 -22
  263. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +0 -191
  264. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +0 -155
  265. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +0 -90
  266. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +0 -36
  267. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +0 -182
  268. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +0 -22
  269. package/harmony/reanimated/src/main/cpp/ReanimatedLogger.cpp +0 -33
  270. package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +0 -61
  271. package/harmony/reanimated/src/main/cpp/WorkletsModule.h +0 -22
  272. package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +0 -89
  273. package/harmony/reanimated/src/main/cpp/patches/Fabric/ShadowTreeCloner.cpp +0 -95
  274. package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +0 -964
  275. package/harmony/reanimated/src/main/ets/WorkletsModule.ts +0 -15
@@ -0,0 +1,193 @@
1
+ #include <reanimated/CSS/progress/TransitionProgressProvider.h>
2
+
3
+ #include <limits>
4
+ #include <memory>
5
+ #include <string>
6
+ #include <unordered_set>
7
+
8
+ namespace reanimated::css {
9
+
10
+ // TransitionPropertyProgressProvider
11
+
12
+ TransitionPropertyProgressProvider::TransitionPropertyProgressProvider(
13
+ const double timestamp,
14
+ const double duration,
15
+ const double delay,
16
+ const EasingFunction &easingFunction)
17
+ : RawProgressProvider(timestamp, duration, delay), easingFunction_(easingFunction) {}
18
+
19
+ TransitionPropertyProgressProvider::TransitionPropertyProgressProvider(
20
+ const double timestamp,
21
+ const double duration,
22
+ const double delay,
23
+ const EasingFunction &easingFunction,
24
+ const double reversingShorteningFactor)
25
+ : RawProgressProvider(timestamp, duration, delay),
26
+ easingFunction_(easingFunction),
27
+ reversingShorteningFactor_(reversingShorteningFactor) {}
28
+
29
+ double TransitionPropertyProgressProvider::getGlobalProgress() const {
30
+ return rawProgress_.value_or(0);
31
+ }
32
+
33
+ double TransitionPropertyProgressProvider::getKeyframeProgress(const double fromOffset, const double toOffset) const {
34
+ if (fromOffset == toOffset) {
35
+ return 1;
36
+ }
37
+ return easingFunction_(getGlobalProgress());
38
+ }
39
+
40
+ double TransitionPropertyProgressProvider::getRemainingDelay(const double timestamp) const {
41
+ return delay_ - (timestamp - creationTimestamp_);
42
+ }
43
+
44
+ double TransitionPropertyProgressProvider::getReversingShorteningFactor() const {
45
+ return reversingShorteningFactor_;
46
+ }
47
+
48
+ TransitionProgressState TransitionPropertyProgressProvider::getState() const {
49
+ if (!rawProgress_.has_value()) {
50
+ return TransitionProgressState::Pending;
51
+ }
52
+ const auto rawProgress = rawProgress_.value();
53
+ if (rawProgress >= 1) {
54
+ return TransitionProgressState::Finished;
55
+ }
56
+ return TransitionProgressState::Running;
57
+ }
58
+
59
+ std::optional<double> TransitionPropertyProgressProvider::calculateRawProgress(const double timestamp) {
60
+ if (duration_ == 0) {
61
+ return 1;
62
+ }
63
+ return getElapsedTime(timestamp) / duration_;
64
+ }
65
+
66
+ double TransitionPropertyProgressProvider::getElapsedTime(const double timestamp) const {
67
+ return timestamp - (creationTimestamp_ + delay_);
68
+ }
69
+
70
+ // TransitionProgressProvider
71
+
72
+ TransitionProgressState TransitionProgressProvider::getState() const {
73
+ for (const auto &[_, propertyProgressProvider] : propertyProgressProviders_) {
74
+ if (propertyProgressProvider->getState() == TransitionProgressState::Running) {
75
+ return TransitionProgressState::Running;
76
+ }
77
+ }
78
+ return TransitionProgressState::Pending;
79
+ }
80
+
81
+ double TransitionProgressProvider::getMinDelay(const double timestamp) const {
82
+ if (propertyProgressProviders_.empty()) {
83
+ return 0;
84
+ }
85
+ auto minDelay = std::numeric_limits<double>::max();
86
+
87
+ for (const auto &[_, propertyProgressProvider] : propertyProgressProviders_) {
88
+ const auto remainingDelay = propertyProgressProvider->getRemainingDelay(timestamp);
89
+ if (remainingDelay < minDelay) {
90
+ minDelay = remainingDelay;
91
+ }
92
+ }
93
+
94
+ return minDelay;
95
+ }
96
+
97
+ TransitionPropertyProgressProviders TransitionProgressProvider::getPropertyProgressProviders() const {
98
+ return propertyProgressProviders_;
99
+ }
100
+
101
+ std::unordered_set<std::string> TransitionProgressProvider::getRemovedProperties() const {
102
+ return removedProperties_;
103
+ }
104
+
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;
111
+ }
112
+ }
113
+ }
114
+
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
+ }
125
+ }
126
+ }
127
+
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
+ }
139
+
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
+ }
155
+ }
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
+ }
163
+ }
164
+
165
+ void TransitionProgressProvider::update(const double timestamp) {
166
+ removedProperties_.clear();
167
+
168
+ for (const auto &[propertyName, propertyProgressProvider] : propertyProgressProviders_) {
169
+ propertyProgressProvider->update(timestamp);
170
+ if (propertyProgressProvider->getState() == TransitionProgressState::Finished) {
171
+ removedProperties_.insert(propertyName);
172
+ }
173
+ }
174
+ }
175
+
176
+ std::shared_ptr<TransitionPropertyProgressProvider>
177
+ TransitionProgressProvider::createReversingShorteningProgressProvider(
178
+ const double timestamp,
179
+ const CSSTransitionPropertySettings &propertySettings,
180
+ 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>(
186
+ timestamp,
187
+ propertySettings.duration * newReversingShorteningFactor,
188
+ propertySettings.delay < 0 ? newReversingShorteningFactor * propertySettings.delay : propertySettings.delay,
189
+ propertySettings.easingFunction,
190
+ newReversingShorteningFactor);
191
+ }
192
+
193
+ } // namespace reanimated::css
@@ -0,0 +1,77 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/configs/CSSTransitionConfig.h>
4
+ #include <reanimated/CSS/progress/KeyframeProgressProvider.h>
5
+ #include <reanimated/CSS/progress/RawProgressProvider.h>
6
+ #include <reanimated/CSS/utils/props.h>
7
+
8
+ #include <memory>
9
+ #include <string>
10
+ #include <unordered_map>
11
+ #include <unordered_set>
12
+
13
+ namespace reanimated::css {
14
+
15
+ enum class TransitionProgressState : std::uint8_t { Pending, Running, Finished };
16
+
17
+ class TransitionPropertyProgressProvider final : public KeyframeProgressProvider, public RawProgressProvider {
18
+ public:
19
+ TransitionPropertyProgressProvider(
20
+ double timestamp,
21
+ double duration,
22
+ double delay,
23
+ const EasingFunction &easingFunction);
24
+ TransitionPropertyProgressProvider(
25
+ double timestamp,
26
+ double duration,
27
+ double delay,
28
+ const EasingFunction &easingFunction,
29
+ double reversingShorteningFactor);
30
+
31
+ double getGlobalProgress() const override;
32
+ double getKeyframeProgress(double fromOffset, double toOffset) const override;
33
+ double getRemainingDelay(double timestamp) const;
34
+ double getReversingShorteningFactor() const;
35
+ TransitionProgressState getState() const;
36
+
37
+ protected:
38
+ std::optional<double> calculateRawProgress(double timestamp) override;
39
+
40
+ private:
41
+ EasingFunction easingFunction_;
42
+ double reversingShorteningFactor_ = 1;
43
+
44
+ double getElapsedTime(double timestamp) const;
45
+ };
46
+
47
+ using TransitionPropertyProgressProviders =
48
+ std::unordered_map<std::string, std::shared_ptr<TransitionPropertyProgressProvider>>;
49
+
50
+ class TransitionProgressProvider final {
51
+ public:
52
+ TransitionProgressState getState() const;
53
+ double getMinDelay(double timestamp) const;
54
+ TransitionPropertyProgressProviders getPropertyProgressProviders() const;
55
+ std::unordered_set<std::string> getRemovedProperties() const;
56
+
57
+ void discardFinishedProgressProviders();
58
+ void discardIrrelevantProgressProviders(const std::unordered_set<std::string> &transitionPropertyNames);
59
+ void runProgressProviders(
60
+ double timestamp,
61
+ const CSSTransitionPropertiesSettings &propertiesSettings,
62
+ const PropertyNames &changedPropertyNames,
63
+ const std::unordered_set<std::string> &reversedPropertyNames);
64
+ void update(double timestamp);
65
+
66
+ private:
67
+ TransitionPropertyProgressProviders propertyProgressProviders_;
68
+
69
+ std::unordered_set<std::string> removedProperties_;
70
+
71
+ std::shared_ptr<TransitionPropertyProgressProvider> createReversingShorteningProgressProvider(
72
+ double timestamp,
73
+ const CSSTransitionPropertySettings &propertySettings,
74
+ const TransitionPropertyProgressProvider &existingProgressProvider);
75
+ };
76
+
77
+ } // namespace reanimated::css
@@ -0,0 +1,340 @@
1
+ #include <reanimated/CSS/registries/CSSAnimationsRegistry.h>
2
+
3
+ #include <memory>
4
+ #include <string>
5
+ #include <unordered_map>
6
+ #include <utility>
7
+ #include <vector>
8
+
9
+ namespace reanimated::css {
10
+
11
+ bool CSSAnimationsRegistry::isEmpty() const {
12
+ // The registry is empty if has no registered animations and no updates
13
+ // stored in the updates registry
14
+ return UpdatesRegistry::isEmpty() && registry_.empty();
15
+ }
16
+
17
+ bool CSSAnimationsRegistry::hasUpdates() const {
18
+ return !runningAnimationIndicesMap_.empty() || !delayedAnimationsManager_.empty() || !animationsToRevertMap_.empty();
19
+ }
20
+
21
+ void CSSAnimationsRegistry::apply(
22
+ jsi::Runtime &rt,
23
+ const std::shared_ptr<const ShadowNode> &shadowNode,
24
+ const std::optional<std::vector<std::string>> &animationNames,
25
+ const CSSAnimationsMap &newAnimations,
26
+ const CSSAnimationSettingsUpdatesMap &settingsUpdates,
27
+ double timestamp) {
28
+ auto animationsVector = buildAnimationsVector(rt, shadowNode, animationNames, newAnimations);
29
+
30
+ const auto viewTag = shadowNode->getTag();
31
+ if (animationsVector.empty()) {
32
+ remove(viewTag);
33
+ return;
34
+ }
35
+
36
+ runningAnimationIndicesMap_[viewTag].clear();
37
+
38
+ std::vector<size_t> updatedIndices;
39
+ for (const auto &[index, _] : newAnimations) {
40
+ updatedIndices.push_back(index);
41
+ }
42
+ for (const auto &[index, _] : settingsUpdates) {
43
+ updatedIndices.push_back(index);
44
+ }
45
+
46
+ updateAnimationSettings(animationsVector, settingsUpdates, timestamp);
47
+ for (size_t i = 0; i < animationsVector.size(); ++i) {
48
+ scheduleOrActivateAnimation(i, animationsVector[i], timestamp);
49
+ }
50
+
51
+ auto animationToIndexMap = buildAnimationToIndexMap(animationsVector);
52
+ registry_.erase(viewTag);
53
+ registry_.emplace(viewTag, RegistryEntry{std::move(animationsVector), std::move(animationToIndexMap)});
54
+
55
+ updateViewAnimations(viewTag, updatedIndices, timestamp, false);
56
+ applyViewAnimationsStyle(viewTag, timestamp);
57
+ }
58
+
59
+ void CSSAnimationsRegistry::remove(const Tag viewTag) {
60
+ removeViewAnimations(viewTag);
61
+ removeFromUpdatesRegistry(viewTag);
62
+ registry_.erase(viewTag);
63
+ }
64
+
65
+ void CSSAnimationsRegistry::update(const double timestamp) {
66
+ // Activate all delayed animations that should start now
67
+ activateDelayedAnimations(timestamp);
68
+ // Update styles in the registry for views which animations were reverted
69
+ handleAnimationsToRevert(timestamp);
70
+
71
+ // Iterate over active animations and update them
72
+ for (auto it = runningAnimationIndicesMap_.begin(); it != runningAnimationIndicesMap_.end();) {
73
+ const auto viewTag = it->first;
74
+ const std::vector<size_t> animationIndices = {it->second.begin(), it->second.end()};
75
+ updateViewAnimations(viewTag, animationIndices, timestamp, true);
76
+
77
+ if (runningAnimationIndicesMap_[viewTag].empty()) {
78
+ it = runningAnimationIndicesMap_.erase(it);
79
+ } else {
80
+ ++it;
81
+ }
82
+ }
83
+ }
84
+
85
+ CSSAnimationsVector CSSAnimationsRegistry::buildAnimationsVector(
86
+ jsi::Runtime &rt,
87
+ const std::shared_ptr<const ShadowNode> &shadowNode,
88
+ const std::optional<std::vector<std::string>> &animationNames,
89
+ const std::optional<CSSAnimationsMap> &newAnimations) const {
90
+ const auto registryIt = registry_.find(shadowNode->getTag());
91
+
92
+ // If animationNames has no value, that means no animations were added,
93
+ // removed or reordered, so we can return the current animations vector from
94
+ // the registry
95
+ if (!animationNames.has_value()) {
96
+ if (registryIt != registry_.end()) {
97
+ return registryIt->second.animationsVector;
98
+ }
99
+ }
100
+
101
+ CSSAnimationsVector animationsVector;
102
+ const auto &animationNamesVector = animationNames.value();
103
+ const auto animationNamesSize = animationNamesVector.size();
104
+ animationsVector.reserve(animationNamesSize);
105
+
106
+ std::unordered_map<std::string, CSSAnimationsVector> oldAnimationsMap;
107
+ CSSAnimationsMap emptyAnimationsMap;
108
+ const auto &newAnimationsMap = newAnimations.value_or(emptyAnimationsMap);
109
+
110
+ if (registryIt != registry_.end()) {
111
+ const auto &oldAnimations = registryIt->second.animationsVector;
112
+
113
+ // Fill the map while maintaining reverse order (for quick pop from the end)
114
+ for (auto it = oldAnimations.rbegin(); it != oldAnimations.rend(); ++it) {
115
+ oldAnimationsMap[(*it)->getName()].emplace_back(*it);
116
+ }
117
+ }
118
+
119
+ for (size_t i = 0; i < animationNamesSize; ++i) {
120
+ const auto &newAnimationIt = newAnimationsMap.find(i);
121
+ if (newAnimationIt != newAnimationsMap.end()) {
122
+ animationsVector.emplace_back(newAnimationIt->second);
123
+ continue;
124
+ }
125
+
126
+ const auto &name = animationNamesVector[i];
127
+ const auto &oldAnimationIt = oldAnimationsMap.find(name);
128
+
129
+ if (oldAnimationIt == oldAnimationsMap.end()) {
130
+ throw std::runtime_error(
131
+ "[Reanimated] There is no animation with name " + name + " available to use at index " + std::to_string(i));
132
+ }
133
+
134
+ animationsVector.emplace_back(oldAnimationIt->second.back());
135
+ oldAnimationIt->second.pop_back();
136
+
137
+ if (oldAnimationIt->second.empty()) {
138
+ oldAnimationsMap.erase(oldAnimationIt);
139
+ }
140
+ }
141
+
142
+ return animationsVector;
143
+ }
144
+
145
+ CSSAnimationsRegistry::AnimationToIndexMap CSSAnimationsRegistry::buildAnimationToIndexMap(
146
+ const CSSAnimationsVector &animationsVector) const {
147
+ AnimationToIndexMap animationToIndexMap;
148
+
149
+ for (size_t i = 0; i < animationsVector.size(); ++i) {
150
+ animationToIndexMap[animationsVector[i]] = i;
151
+ }
152
+
153
+ return animationToIndexMap;
154
+ }
155
+
156
+ void CSSAnimationsRegistry::updateAnimationSettings(
157
+ const CSSAnimationsVector &animationsVector,
158
+ const CSSAnimationSettingsUpdatesMap &settingsUpdates,
159
+ const double timestamp) {
160
+ for (size_t i = 0; i < animationsVector.size(); ++i) {
161
+ const auto &animation = animationsVector[i];
162
+ const auto it = settingsUpdates.find(i);
163
+ if (it != settingsUpdates.end()) {
164
+ animation->updateSettings(it->second, timestamp);
165
+ }
166
+ }
167
+ }
168
+
169
+ void CSSAnimationsRegistry::updateViewAnimations(
170
+ const Tag viewTag,
171
+ const std::vector<size_t> &animationIndices,
172
+ const double timestamp,
173
+ const bool addToBatch) {
174
+ folly::dynamic result = folly::dynamic::object;
175
+ std::shared_ptr<const ShadowNode> shadowNode = nullptr;
176
+ bool hasUpdates = false;
177
+
178
+ for (const auto animationIndex : animationIndices) {
179
+ const auto &animation = registry_[viewTag].animationsVector[animationIndex];
180
+ if (!shadowNode) {
181
+ shadowNode = animation->getShadowNode();
182
+ }
183
+ if (animation->getState(timestamp) == AnimationProgressState::Pending) {
184
+ animation->run(timestamp);
185
+ }
186
+
187
+ bool updatesAddedToBatch = false;
188
+ const auto updates = animation->update(timestamp);
189
+ const auto newState = animation->getState(timestamp);
190
+
191
+ if (newState == AnimationProgressState::Finished) {
192
+ // Revert changes applied during animation if there is no forwards fill
193
+ // mode
194
+ if (addToBatch && !animation->hasForwardsFillMode()) {
195
+ // We also have to manually commit style values
196
+ // reverting the changes applied by the animation.
197
+ hasUpdates = addStyleUpdates(result, animation->getResetStyle(), false) || hasUpdates;
198
+ updatesAddedToBatch = true;
199
+ // We want to remove style changes applied by the animation that is
200
+ // finished and has no forwards fill mode. We cannot simply remove
201
+ // properties from the style in the registry as it may be overridden
202
+ // by the next animation. Instead, we are creating the new style
203
+ // object without reverted (finished without forwards fill mode)
204
+ // animations.
205
+ animationsToRevertMap_[viewTag].insert(animationIndex);
206
+ }
207
+ }
208
+
209
+ if (addToBatch && !updatesAddedToBatch) {
210
+ hasUpdates = addStyleUpdates(result, updates, true) || hasUpdates;
211
+ }
212
+ if (newState != AnimationProgressState::Running) {
213
+ runningAnimationIndicesMap_[viewTag].erase(animationIndex);
214
+ }
215
+ }
216
+
217
+ if (hasUpdates) {
218
+ addUpdatesToBatch(shadowNode, result);
219
+ }
220
+ }
221
+
222
+ void CSSAnimationsRegistry::scheduleOrActivateAnimation(
223
+ const size_t animationIndex,
224
+ const std::shared_ptr<CSSAnimation> &animation,
225
+ const double timestamp) {
226
+ // Remove the animation from delayed (if it is already added to
227
+ // delayed animations)
228
+ delayedAnimationsManager_.remove(animation);
229
+
230
+ const auto startTimestamp = animation->getStartTimestamp(timestamp);
231
+
232
+ if (startTimestamp > timestamp) {
233
+ // If the animation is delayed, schedule it for activation
234
+ // (Only if it isn't paused)
235
+ if (animation->getState(timestamp) != AnimationProgressState::Paused) {
236
+ delayedAnimationsManager_.add(startTimestamp, animation);
237
+ }
238
+ } else {
239
+ const auto viewTag = animation->getShadowNode()->getTag();
240
+ runningAnimationIndicesMap_[viewTag].insert(animationIndex);
241
+ }
242
+ }
243
+
244
+ void CSSAnimationsRegistry::removeViewAnimations(const Tag viewTag) {
245
+ const auto it = registry_.find(viewTag);
246
+ if (it == registry_.end()) {
247
+ return;
248
+ }
249
+
250
+ for (const auto &animation : it->second.animationsVector) {
251
+ delayedAnimationsManager_.remove(animation);
252
+ }
253
+ runningAnimationIndicesMap_.erase(viewTag);
254
+ }
255
+
256
+ void CSSAnimationsRegistry::applyViewAnimationsStyle(const Tag viewTag, const double timestamp) {
257
+ const auto it = registry_.find(viewTag);
258
+ // Remove the style from the registry if there are no animations for the view
259
+ if (it == registry_.end() || it->second.animationsVector.empty()) {
260
+ removeFromUpdatesRegistry(viewTag);
261
+ return;
262
+ }
263
+
264
+ folly::dynamic updatedStyle = folly::dynamic::object;
265
+ std::shared_ptr<const ShadowNode> shadowNode = nullptr;
266
+
267
+ for (const auto &animation : it->second.animationsVector) {
268
+ const auto startTimestamp = animation->getStartTimestamp(timestamp);
269
+
270
+ folly::dynamic style;
271
+ const auto &currentState = animation->getState(timestamp);
272
+ if (startTimestamp > timestamp && animation->hasBackwardsFillMode()) {
273
+ style = animation->getBackwardsFillStyle();
274
+ } else if (
275
+ currentState == AnimationProgressState::Running ||
276
+ // Animation is paused after start (was running before)
277
+ (currentState == AnimationProgressState::Paused && timestamp >= animation->getStartTimestamp(timestamp)) ||
278
+ // Animation is finished and has fill forwards fill mode
279
+ (currentState == AnimationProgressState::Finished && animation->hasForwardsFillMode())) {
280
+ style = animation->getCurrentInterpolationStyle();
281
+ }
282
+
283
+ if (!shadowNode) {
284
+ shadowNode = animation->getShadowNode();
285
+ }
286
+ if (style.isObject()) {
287
+ updatedStyle.update(style);
288
+ }
289
+ }
290
+
291
+ setInUpdatesRegistry(shadowNode, updatedStyle);
292
+ }
293
+
294
+ void CSSAnimationsRegistry::activateDelayedAnimations(const double timestamp) {
295
+ while (!delayedAnimationsManager_.empty() && delayedAnimationsManager_.top().timestamp <= timestamp) {
296
+ const auto [_, animation] = delayedAnimationsManager_.pop();
297
+ const auto viewTag = animation->getShadowNode()->getTag();
298
+
299
+ // Add only these animations which weren't removed in the meantime
300
+ if (registry_.find(viewTag) == registry_.end()) {
301
+ continue;
302
+ }
303
+
304
+ const auto &animationToIndexMap = registry_[viewTag].animationToIndexMap;
305
+ if (animationToIndexMap.find(animation) == animationToIndexMap.end()) {
306
+ continue;
307
+ }
308
+
309
+ const auto animationIndex = animationToIndexMap.at(animation);
310
+ runningAnimationIndicesMap_[viewTag].insert(animationIndex);
311
+ }
312
+ }
313
+
314
+ void CSSAnimationsRegistry::handleAnimationsToRevert(const double timestamp) {
315
+ for (const auto &[viewTag, _] : animationsToRevertMap_) {
316
+ applyViewAnimationsStyle(viewTag, timestamp);
317
+ }
318
+ animationsToRevertMap_.clear();
319
+ }
320
+
321
+ bool CSSAnimationsRegistry::addStyleUpdates(
322
+ folly::dynamic &target,
323
+ const folly::dynamic &updates,
324
+ bool shouldOverride) {
325
+ if (!updates.isObject()) {
326
+ return false;
327
+ }
328
+
329
+ bool hasUpdates = false;
330
+ for (const auto &[propertyName, propertyValue] : updates.items()) {
331
+ if (shouldOverride || !target.count(propertyName) || target[propertyName].isNull()) {
332
+ target[propertyName] = propertyValue;
333
+ hasUpdates = true;
334
+ }
335
+ }
336
+
337
+ return hasUpdates;
338
+ }
339
+
340
+ } // namespace reanimated::css
@@ -0,0 +1,80 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/configs/CSSAnimationConfig.h>
4
+ #include <reanimated/CSS/core/CSSAnimation.h>
5
+ #include <reanimated/CSS/utils/DelayedItemsManager.h>
6
+ #include <reanimated/CSS/utils/props.h>
7
+ #include <reanimated/Fabric/updates/UpdatesRegistry.h>
8
+
9
+ #include <memory>
10
+ #include <set>
11
+ #include <string>
12
+ #include <unordered_map>
13
+ #include <unordered_set>
14
+ #include <utility>
15
+ #include <vector>
16
+
17
+ namespace reanimated::css {
18
+
19
+ using CSSAnimationsMap = std::unordered_map<size_t, std::shared_ptr<CSSAnimation>>;
20
+ using CSSAnimationsVector = std::vector<std::shared_ptr<CSSAnimation>>;
21
+
22
+ class CSSAnimationsRegistry : public UpdatesRegistry, std::enable_shared_from_this<CSSAnimationsRegistry> {
23
+ public:
24
+ using SettingsUpdates = std::vector<std::pair<size_t, PartialCSSAnimationSettings>>;
25
+
26
+ bool isEmpty() const override;
27
+ bool hasUpdates() const;
28
+
29
+ void apply(
30
+ jsi::Runtime &rt,
31
+ const std::shared_ptr<const ShadowNode> &shadowNode,
32
+ const std::optional<std::vector<std::string>> &animationNames,
33
+ const CSSAnimationsMap &newAnimations,
34
+ const CSSAnimationSettingsUpdatesMap &settingsUpdates,
35
+ double timestamp);
36
+ void remove(Tag viewTag) override;
37
+
38
+ void update(double timestamp);
39
+
40
+ private:
41
+ using AnimationToIndexMap = std::unordered_map<std::shared_ptr<CSSAnimation>, size_t>;
42
+ using RunningAnimationIndicesMap = std::unordered_map<Tag, std::set<size_t>>;
43
+ using AnimationsToRevertMap = std::unordered_map<Tag, std::unordered_set<size_t>>;
44
+ struct RegistryEntry {
45
+ const CSSAnimationsVector animationsVector;
46
+ const AnimationToIndexMap animationToIndexMap;
47
+ };
48
+
49
+ using Registry = std::unordered_map<Tag, RegistryEntry>;
50
+
51
+ Registry registry_;
52
+
53
+ RunningAnimationIndicesMap runningAnimationIndicesMap_;
54
+ AnimationsToRevertMap animationsToRevertMap_;
55
+ DelayedItemsManager<std::shared_ptr<CSSAnimation>> delayedAnimationsManager_;
56
+
57
+ CSSAnimationsVector buildAnimationsVector(
58
+ jsi::Runtime &rt,
59
+ const std::shared_ptr<const ShadowNode> &shadowNode,
60
+ const std::optional<std::vector<std::string>> &animationNames,
61
+ const std::optional<CSSAnimationsMap> &newAnimations) const;
62
+ AnimationToIndexMap buildAnimationToIndexMap(const CSSAnimationsVector &animationsVector) const;
63
+ void updateAnimationSettings(
64
+ const CSSAnimationsVector &animationsVector,
65
+ const CSSAnimationSettingsUpdatesMap &settingsUpdates,
66
+ double timestamp);
67
+
68
+ void
69
+ updateViewAnimations(Tag viewTag, const std::vector<size_t> &animationIndices, double timestamp, bool addToBatch);
70
+ void
71
+ scheduleOrActivateAnimation(size_t animationIndex, const std::shared_ptr<CSSAnimation> &animation, double timestamp);
72
+ void removeViewAnimations(Tag viewTag);
73
+ void applyViewAnimationsStyle(Tag viewTag, double timestamp);
74
+ void activateDelayedAnimations(double timestamp);
75
+ void handleAnimationsToRevert(double timestamp);
76
+
77
+ static bool addStyleUpdates(folly::dynamic &target, const folly::dynamic &updates, bool shouldOverride);
78
+ };
79
+
80
+ } // namespace reanimated::css