@react-native-ohos/react-native-reanimated 3.18.2-rc.2 → 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 (282) hide show
  1. package/compatibility.json +161 -0
  2. package/harmony/reanimated/BuildProfile.ets +16 -16
  3. package/harmony/reanimated/build-profile.json5 +18 -11
  4. package/harmony/reanimated/oh-package.json5 +12 -11
  5. package/harmony/reanimated/src/main/cpp/CMakeLists.txt +31 -40
  6. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +81 -86
  7. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +46 -47
  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 +113 -101
  158. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +49 -51
  159. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +46 -49
  160. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +56 -96
  161. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +37 -33
  162. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +104 -95
  163. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +22 -29
  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 +11 -9
  171. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +137 -232
  172. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +82 -90
  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} +897 -870
  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 +31 -91
  180. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +146 -176
  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 +1376 -971
  187. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +228 -252
  188. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +183 -231
  189. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +93 -109
  190. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +54 -56
  191. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +28 -20
  192. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +58 -70
  193. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +31 -35
  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 +67 -98
  197. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +114 -135
  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 +18 -19
  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 +5 -1
  209. package/harmony/reanimated/src/main/ets/ReanimatedPackage.ts +1 -4
  210. package/harmony/reanimated/src/main/module.json5 +12 -12
  211. package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
  212. package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
  213. package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
  214. package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
  215. package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
  216. package/harmony/reanimated/ts.ts +6 -6
  217. package/harmony/reanimated.har +0 -0
  218. package/package.json +68 -50
  219. package/scripts/deploy.js +191 -0
  220. package/scripts/set-reanimated-version.js +37 -0
  221. package/scripts/update-version.js +119 -0
  222. package/scripts/validate-react-native-version.js +46 -0
  223. package/scripts/validate-worklets-build.js +17 -0
  224. package/scripts/validate-worklets-version.js +79 -0
  225. package/scripts/worklets-version.json +4 -0
  226. package/LICENSE +0 -21
  227. package/README.OpenSource +0 -11
  228. package/README.md +0 -10
  229. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +0 -68
  230. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/PropsRegistry.h +0 -68
  231. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +0 -147
  232. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/CollectionUtils.h +0 -14
  233. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.cpp +0 -5
  234. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeaturesConfig.h +0 -19
  235. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +0 -47
  236. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +0 -59
  237. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +0 -27
  238. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +0 -25
  239. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +0 -94
  240. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/EventHandlerRegistry.h +0 -49
  241. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +0 -8
  242. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +0 -39
  243. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.cpp +0 -326
  244. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/SharedItems/Shareables.h +0 -345
  245. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.cpp +0 -52
  246. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/AsyncQueue.h +0 -35
  247. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/Defs.h +0 -10
  248. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.cpp +0 -342
  249. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSISerializer.h +0 -47
  250. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.cpp +0 -16
  251. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSLogger.h +0 -20
  252. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.cpp +0 -20
  253. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/JSScheduler.h +0 -29
  254. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/PlatformLogger.h +0 -16
  255. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.cpp +0 -26
  256. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedJSIUtils.h +0 -199
  257. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ReanimatedVersion.cpp +0 -95
  258. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/SingleInstanceChecker.h +0 -72
  259. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/ThreadSafeQueue.h +0 -49
  260. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.cpp +0 -20
  261. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/UIScheduler.h +0 -22
  262. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +0 -29
  263. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/Tools/WorkletEventHandler.h +0 -41
  264. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +0 -16
  265. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +0 -19
  266. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.cpp +0 -112
  267. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedHermesRuntime.h +0 -127
  268. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.cpp +0 -53
  269. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/ReanimatedRuntime.h +0 -22
  270. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +0 -191
  271. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +0 -173
  272. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +0 -90
  273. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +0 -36
  274. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +0 -189
  275. package/harmony/reanimated/src/main/cpp/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +0 -22
  276. package/harmony/reanimated/src/main/cpp/ReanimatedLogger.cpp +0 -33
  277. package/harmony/reanimated/src/main/cpp/WorkletsModule.cpp +0 -61
  278. package/harmony/reanimated/src/main/cpp/WorkletsModule.h +0 -22
  279. package/harmony/reanimated/src/main/cpp/patches/AnimatedSensor/AnimatedSensorModule.cpp +0 -89
  280. package/harmony/reanimated/src/main/cpp/patches/Fabric/ShadowTreeCloner.cpp +0 -95
  281. package/harmony/reanimated/src/main/cpp/patches/NativeModules/ReanimatedModuleProxy.cpp +0 -964
  282. package/harmony/reanimated/src/main/ets/WorkletsModule.ts +0 -15
@@ -0,0 +1,544 @@
1
+ #include <react/renderer/components/scrollview/ScrollViewState.h>
2
+ #include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h>
3
+ #include <reanimated/Tools/ReanimatedSystraceSection.h>
4
+ #ifndef ANDROID
5
+ #if __has_include(<react/renderer/components/rnscreens/Props.h>)
6
+ #define HAS_SCREENS_PROPS
7
+ #include <react/renderer/components/rnscreens/Props.h>
8
+ #endif
9
+ #endif // !ANDROID
10
+
11
+ #include <folly/dynamic.h>
12
+
13
+ #include <ranges>
14
+
15
+ namespace reanimated {
16
+
17
+ // MARK: Shared Element Transitions
18
+
19
+ std::shared_ptr<LightNode> LayoutAnimationsProxy_Experimental::findTopScreen(
20
+ const std::shared_ptr<LightNode> &node) const {
21
+ std::shared_ptr<LightNode> result = nullptr;
22
+ // TODO: We could get rid of the RNScreens c++ dependency if we create a custom native component that would be a boundary for Shared Element Transitions.
23
+ // This way we could allow for transitions without screens, and across components on the same screen.
24
+ if (isRNSScreen(node)) {
25
+ bool isActive = false;
26
+ #ifdef ANDROID
27
+ // TODO (future): this looks like a RNScreens bug - sometimes there is no active
28
+ // screen at a deeper level, when going back (uncomment the following when fixed)
29
+ // float f = node->current.props->rawProps.getDefault("activityState",
30
+ // 0).asDouble(); isActive = f == 2.0f;
31
+ isActive = true;
32
+ #elif defined(HAS_SCREENS_PROPS)
33
+ isActive = std::static_pointer_cast<const RNSScreenProps>(node->current.props)->activityState == 2.0f;
34
+ #endif
35
+ if (isActive) {
36
+ result = node;
37
+ }
38
+ }
39
+ for (auto it = node->children.rbegin(); it != node->children.rend(); ++it) {
40
+ const auto& child = *it;
41
+ auto top = findTopScreen(child);
42
+ if (top) {
43
+ return top;
44
+ }
45
+ }
46
+ return result;
47
+ }
48
+
49
+ void LayoutAnimationsProxy_Experimental::findSharedElementsOnScreen(
50
+ const std::shared_ptr<LightNode> &node,
51
+ BeforeOrAfter index,
52
+ const PropsParserContext &propsParserContext) const {
53
+ if (sharedTransitionManager_->tagToName_.contains(node->current.tag)) {
54
+ ShadowView copy = node->current;
55
+ std::vector<react::Point> absolutePositions;
56
+ absolutePositions = getAbsolutePositionsForRootPathView(node);
57
+ copy.layoutMetrics.frame.origin = absolutePositions[0];
58
+
59
+ auto sharedTag = sharedTransitionManager_->tagToName_[node->current.tag];
60
+ auto &transition = transitionMap_[sharedTag];
61
+ auto &[snapshot, parentTag, transform] = transition;
62
+ auto newTransform = parseParentTransforms(node, absolutePositions);
63
+ const auto &parent = node->parent.lock();
64
+ react_native_assert(parent && "Parent node is nullptr");
65
+ transform[index] = std::move(newTransform);
66
+ snapshot[index] = copy;
67
+ parentTag[index] = parent->current.tag;
68
+
69
+ if (parentTag[BEFORE] && parentTag[AFTER]) {
70
+ transitions_.emplace_back(sharedTag, transition);
71
+ } else if (parentTag[AFTER]) {
72
+ // TODO (future): this is adding unnecessary views to the list
73
+ tagsToRestore_.push_back(snapshot[AFTER].tag);
74
+ }
75
+ }
76
+ for (auto &child : node->children) {
77
+ findSharedElementsOnScreen(child, index, propsParserContext);
78
+ }
79
+ }
80
+
81
+ void LayoutAnimationsProxy_Experimental::handleProgressTransition(
82
+ ShadowViewMutationList &filteredMutations,
83
+ const ShadowViewMutationList &mutations,
84
+ const PropsParserContext &propsParserContext,
85
+ SurfaceId surfaceId) const {
86
+ if (!transitionUpdated_) {
87
+ return;
88
+ }
89
+ transitionUpdated_ = false;
90
+
91
+ if (!mutations.empty() || !transitionState_) {
92
+ return;
93
+ }
94
+
95
+ if (transitionState_ == START) {
96
+ auto root = lightNodes_[surfaceId];
97
+ auto beforeTopScreen = topScreen[surfaceId];
98
+ auto afterTopScreen = lightNodes_[transitionTag_];
99
+ if (beforeTopScreen && afterTopScreen && beforeTopScreen != afterTopScreen) {
100
+ findSharedElementsOnScreen(beforeTopScreen, BEFORE, propsParserContext);
101
+ findSharedElementsOnScreen(afterTopScreen, AFTER, propsParserContext);
102
+ hideTransitioningViews(BEFORE, filteredMutations, propsParserContext);
103
+ hideTransitioningViews(AFTER, filteredMutations, propsParserContext);
104
+
105
+ for (auto &[sharedTag, transition] : transitions_) {
106
+ auto &[before, after] = transition.snapshot;
107
+ const auto &transform = transition.transform;
108
+ overrideTransform(before, transform[BEFORE], propsParserContext);
109
+ overrideTransform(after, transform[AFTER], propsParserContext);
110
+ auto containerTag = getOrCreateContainer(before, sharedTag, filteredMutations, surfaceId);
111
+ transferConfigToContainer(containerTag, before.tag);
112
+
113
+ restoreMap_[containerTag][BEFORE] = before.tag;
114
+ restoreMap_[containerTag][AFTER] = after.tag;
115
+ before.tag = containerTag;
116
+ after.tag = containerTag;
117
+ activeTransitions_.insert(containerTag);
118
+
119
+ startProgressTransition(containerTag, before, after, surfaceId);
120
+ }
121
+ }
122
+ } else if (transitionState_ == ACTIVE) {
123
+ for (auto tag : activeTransitions_) {
124
+ auto layoutAnimation = layoutAnimations_[tag];
125
+ auto &updateMap = surfaceManager.getUpdateMap(layoutAnimation.finalView.surfaceId);
126
+ auto before = layoutAnimation.startView.layoutMetrics.frame;
127
+ auto after = layoutAnimation.finalView.layoutMetrics.frame;
128
+ auto x = before.origin.x + transitionProgress_ * (after.origin.x - before.origin.x);
129
+ auto y = before.origin.y + transitionProgress_ * (after.origin.y - before.origin.y);
130
+ auto width = before.size.width + transitionProgress_ * (after.size.width - before.size.width);
131
+ auto height = before.size.height + transitionProgress_ * (after.size.height - before.size.height);
132
+
133
+ auto beforeProps = std::static_pointer_cast<const BaseViewProps>(layoutAnimation.startView.props);
134
+ auto afterProps = std::static_pointer_cast<const BaseViewProps>(layoutAnimation.finalView.props);
135
+ auto beforeRadius = beforeProps->borderRadii.all.value_or(ValueUnit(0, UnitType::Point)).value;
136
+ auto afterRadius = afterProps->borderRadii.all.value_or(ValueUnit(0, UnitType::Point)).value;
137
+
138
+ // TODO (future): Support more props in progress transitions.
139
+ auto borderRadiusDynamic =
140
+ folly::dynamic::object("borderRadius", beforeRadius + transitionProgress_ * (afterRadius - beforeRadius));
141
+
142
+ #ifdef RN_SERIALIZABLE_STATE
143
+ // TODO (future): Support borderRadius on Android.
144
+ const Props::Shared newProps = nullptr;
145
+ #else
146
+ auto rawProps = RawProps(std::move(borderRadiusDynamic));
147
+
148
+ auto newProps = getComponentDescriptorForShadowView(layoutAnimation.finalView)
149
+ .cloneProps(propsParserContext, layoutAnimation.finalView.props, std::move(rawProps));
150
+ #endif
151
+
152
+ updateMap.insert_or_assign(tag, UpdateValues{newProps, {x, y, width, height}});
153
+ }
154
+ }
155
+
156
+ if (transitionState_ == START) {
157
+ transitionState_ = ACTIVE;
158
+ } else if (transitionState_ == END || transitionState_ == CANCELLED) {
159
+ for (auto tag : activeTransitions_) {
160
+ sharedContainersToRemove_.push_back(tag);
161
+ tagsToRestore_.push_back(restoreMap_[tag][AFTER]);
162
+ if (transitionState_ == CANCELLED) {
163
+ tagsToRestore_.push_back(restoreMap_[tag][BEFORE]);
164
+ }
165
+ }
166
+ if (transitionState_ == END) {
167
+ topScreen[surfaceId] = lightNodes_[transitionTag_];
168
+ synchronized_ = false;
169
+ }
170
+ sharedTransitionManager_->containerTags_.clear();
171
+ activeTransitions_.clear();
172
+ transitionState_ = NONE;
173
+ }
174
+ }
175
+
176
+ void LayoutAnimationsProxy_Experimental::overrideTransform(
177
+ ShadowView &shadowView,
178
+ const std::optional<Transform> &transform,
179
+ const PropsParserContext &propsParserContext) const {
180
+ ReanimatedSystraceSection s("overrideTransfrom");
181
+ if (!transform) {
182
+ return;
183
+ }
184
+ #ifdef ANDROID
185
+ auto array = folly::dynamic::array(folly::dynamic::object("matrix", transform->operator folly::dynamic()));
186
+ const folly::dynamic newTransformDynamic = folly::dynamic::object("transform", array);
187
+ auto newRawProps = folly::dynamic::merge(shadowView.props->rawProps, newTransformDynamic);
188
+ auto newProps = getComponentDescriptorForShadowView(shadowView)
189
+ .cloneProps(propsParserContext, shadowView.props, RawProps(newRawProps));
190
+ auto viewProps = std::const_pointer_cast<ViewProps>(std::static_pointer_cast<const ViewProps>(newProps));
191
+ #else
192
+ auto newProps = getComponentDescriptorForShadowView(shadowView).cloneProps(propsParserContext, shadowView.props, {});
193
+ auto viewProps = std::const_pointer_cast<ViewProps>(std::static_pointer_cast<const ViewProps>(newProps));
194
+ viewProps->transform = *transform;
195
+ #endif
196
+ shadowView.props = newProps;
197
+ }
198
+
199
+ void LayoutAnimationsProxy_Experimental::transferConfigToContainer(Tag containerTag, Tag beforeTag) const {
200
+ layoutAnimationsManager_->transferSharedConfig(beforeTag, containerTag);
201
+ }
202
+
203
+ Tag LayoutAnimationsProxy_Experimental::getOrCreateContainer(
204
+ const ShadowView &before,
205
+ const SharedTag &sharedTag,
206
+ ShadowViewMutationList &filteredMutations,
207
+ SurfaceId surfaceId) const {
208
+ auto containerTag = sharedTransitionManager_->containerTags_[sharedTag];
209
+ auto shouldCreateContainer = (containerTag == -1 || !layoutAnimations_.contains(containerTag));
210
+
211
+ if (shouldCreateContainer) {
212
+ containerTag = containerTag_;
213
+ containerTag_ += 2;
214
+ auto &root = lightNodes_[surfaceId];
215
+ ShadowView container = before;
216
+ sharedTransitionManager_->tagToName_[containerTag] = sharedTag;
217
+
218
+ container.tag = containerTag;
219
+ auto node = std::make_shared<LightNode>();
220
+ node->current = std::move(container);
221
+ root->children.push_back(node);
222
+ containersToInsert_.push_back(node);
223
+ lightNodes_[containerTag] = std::move(node);
224
+
225
+ sharedTransitionManager_->containerTags_[sharedTag] = containerTag;
226
+ }
227
+ return containerTag;
228
+ }
229
+
230
+ void LayoutAnimationsProxy_Experimental::handleSharedTransitionsStart(
231
+ const std::shared_ptr<LightNode> &afterTopScreen,
232
+ const std::shared_ptr<LightNode> &beforeTopScreen,
233
+ ShadowViewMutationList &filteredMutations,
234
+ const ShadowViewMutationList &mutations,
235
+ const PropsParserContext &propsParserContext,
236
+ SurfaceId surfaceId) const {
237
+ ReanimatedSystraceSection s1("LayoutAnimationsProxy_Experimental::handleSharedTransitionsStart");
238
+
239
+ if (!beforeTopScreen || !afterTopScreen) {
240
+ return;
241
+ }
242
+
243
+ if (beforeTopScreen != afterTopScreen) {
244
+ for (auto &[sharedTag, transition] : transitions_) {
245
+ auto &[before, after] = transition.snapshot;
246
+ const auto &transform = transition.transform;
247
+ overrideTransform(before, transform[BEFORE], propsParserContext);
248
+ overrideTransform(after, transform[AFTER], propsParserContext);
249
+ auto containerTag = getOrCreateContainer(before, sharedTag, filteredMutations, surfaceId);
250
+
251
+ transferConfigToContainer(containerTag, before.tag);
252
+ restoreMap_[containerTag][1] = after.tag;
253
+ before.tag = containerTag;
254
+ after.tag = containerTag;
255
+
256
+ startSharedTransition(containerTag, before, after, surfaceId);
257
+ }
258
+ } else if (!mutations.empty()) {
259
+ for (auto &[sharedTag, transition] : transitions_) {
260
+ auto &[_, after] = transition.snapshot;
261
+
262
+ auto containerTag = sharedTransitionManager_->containerTags_[sharedTag];
263
+ if (!layoutAnimations_.contains(containerTag)) {
264
+ continue;
265
+ }
266
+ after.tag = containerTag;
267
+ const auto &la = layoutAnimations_[containerTag];
268
+ if (la.finalView.layoutMetrics != after.layoutMetrics) {
269
+ overrideTransform(after, transition.transform[AFTER], propsParserContext);
270
+ startSharedTransition(containerTag, la.currentView, after, surfaceId);
271
+ }
272
+ }
273
+ }
274
+ }
275
+
276
+ void LayoutAnimationsProxy_Experimental::hideTransitioningViews(
277
+ BeforeOrAfter index,
278
+ ShadowViewMutationList &filteredMutations,
279
+ const PropsParserContext &propsParserContext) const {
280
+ for (auto &[sharedTag, transition] : transitions_) {
281
+ const auto &shadowView = transition.snapshot[index];
282
+ const auto &parentTag = transition.parentTag[index];
283
+ auto m = ShadowViewMutation::UpdateMutation(
284
+ shadowView, cloneViewWithoutOpacity(shadowView, propsParserContext), parentTag);
285
+ filteredMutations.push_back(m);
286
+ }
287
+ }
288
+
289
+ std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onTransitionProgress(
290
+ int tag,
291
+ double progress,
292
+ bool isClosing,
293
+ bool isGoingForward) {
294
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
295
+ transitionUpdated_ = true;
296
+ bool isAndroid;
297
+ #ifdef ANDROID
298
+ isAndroid = true;
299
+ #else
300
+ isAndroid = false;
301
+ #endif
302
+ // TODO (future): this new approach causes all back transitions to be progress
303
+ // transitions (maybe that's ok?)
304
+ if (!isClosing && !isGoingForward && !isAndroid) {
305
+ transitionProgress_ = progress;
306
+ if (transitionState_ == NONE && progress < 1) {
307
+ transitionState_ = START;
308
+ transitionTag_ = tag;
309
+ } else if (transitionState_ == ACTIVE && progress == 1) {
310
+ transitionState_ = END;
311
+ }
312
+ const auto &node = lightNodes_[tag];
313
+ react_native_assert(node && "LightNode is nullptr");
314
+
315
+ transitioningSurfaceId_ = node->current.surfaceId;
316
+ return transitioningSurfaceId_;
317
+ }
318
+ return {};
319
+ }
320
+
321
+ std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onGestureCancel() {
322
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
323
+ if (transitionState_) {
324
+ transitionState_ = CANCELLED;
325
+ transitionUpdated_ = true;
326
+ react_native_assert(transitioningSurfaceId_ != -1 && "Cancelling non-observed transition");
327
+
328
+ const auto surfaceId = transitioningSurfaceId_;
329
+ transitioningSurfaceId_ = -1;
330
+ return surfaceId;
331
+ }
332
+ return {};
333
+ }
334
+
335
+ void LayoutAnimationsProxy_Experimental::startSurface(const SurfaceId surfaceId) {
336
+ const auto node = std::make_shared<LightNode>();
337
+ node->current.componentName = "RootView";
338
+ node->current.tag = surfaceId;
339
+ node->current.props = std::make_shared<BaseViewProps>();
340
+ lightNodes_[surfaceId] = node;
341
+ }
342
+
343
+ void LayoutAnimationsProxy_Experimental::insertContainers(
344
+ ShadowViewMutationList &filteredMutations,
345
+ int &rootChildCount,
346
+ SurfaceId surfaceId) const {
347
+ ShadowViewMutationList currentMutations;
348
+ std::swap(currentMutations, filteredMutations);
349
+ filteredMutations.reserve(containersToInsert_.size() * 2);
350
+ auto root = lightNodes_[surfaceId];
351
+ for (auto &node : containersToInsert_) {
352
+ filteredMutations.push_back(ShadowViewMutation::CreateMutation(node->current));
353
+ filteredMutations.push_back(ShadowViewMutation::InsertMutation(surfaceId, node->current, rootChildCount++));
354
+ }
355
+ filteredMutations.insert(filteredMutations.end(), currentMutations.begin(), currentMutations.end());
356
+ containersToInsert_.clear();
357
+ }
358
+
359
+ void LayoutAnimationsProxy_Experimental::cleanupSharedTransitions(
360
+ ShadowViewMutationList &filteredMutations,
361
+ const PropsParserContext &propsParserContext,
362
+ SurfaceId surfaceId) const {
363
+ ReanimatedSystraceSection s1("cleanupSharedTransitions");
364
+ for (auto &tag : tagsToRestore_) {
365
+ ReanimatedSystraceSection s("Restore tag");
366
+ auto &node = lightNodes_[tag];
367
+ if (node) {
368
+ auto view = node->current;
369
+ const auto &parent = node->parent.lock();
370
+ react_native_assert(parent && "Parent node is nullptr");
371
+ auto parentTag = parent->current.tag;
372
+ auto m = ShadowViewMutation::UpdateMutation(
373
+ cloneViewWithoutOpacity(view, propsParserContext), cloneViewWithOpacity(view, propsParserContext), parentTag);
374
+ filteredMutations.push_back(m);
375
+ }
376
+ }
377
+ tagsToRestore_.clear();
378
+
379
+ ReanimatedSystraceSection s2("remove shared containers");
380
+ for (auto &tag : sharedContainersToRemove_) {
381
+ auto root = lightNodes_[surfaceId];
382
+ for (int i = 0; i < root->children.size(); i++) {
383
+ auto &child = root->children[i];
384
+ if (child->current.tag == tag) {
385
+ filteredMutations.push_back(ShadowViewMutation::RemoveMutation(surfaceId, child->current, i));
386
+ filteredMutations.push_back(ShadowViewMutation::DeleteMutation(child->current));
387
+ root->children.erase(root->children.begin() + i);
388
+ }
389
+ }
390
+ }
391
+ sharedContainersToRemove_.clear();
392
+ }
393
+
394
+ // MARK: Position Calculation
395
+
396
+ std::vector<react::Point> LayoutAnimationsProxy_Experimental::getAbsolutePositionsForRootPathView(
397
+ const std::shared_ptr<LightNode> &node) const {
398
+ std::vector<react::Point> viewsAbsolutePositions;
399
+ auto currentNode = node;
400
+ while (currentNode) {
401
+ react::Point viewPosition;
402
+ const auto &componentName = currentNode->current.componentName;
403
+ react_native_assert(componentName && "Component name is nullptr");
404
+ if (!strcmp(componentName, "ScrollView")) {
405
+ auto state = std::static_pointer_cast<const ConcreteState<ScrollViewState>>(currentNode->current.state);
406
+ auto data = state->getData();
407
+ viewPosition -= data.contentOffset;
408
+ }
409
+ if (!strcmp(componentName, "RNSScreen") && currentNode->children.size() >= 2) {
410
+ const auto &parent = currentNode->parent.lock();
411
+ react_native_assert(parent && "Parent node is nullptr");
412
+
413
+ const float headerHeight =
414
+ parent->current.layoutMetrics.frame.size.height - currentNode->current.layoutMetrics.frame.size.height;
415
+ viewPosition.y += headerHeight;
416
+ }
417
+ viewPosition += currentNode->current.layoutMetrics.frame.origin;
418
+ viewsAbsolutePositions.emplace_back(viewPosition);
419
+ currentNode = currentNode->parent.lock();
420
+ }
421
+ for (int i = static_cast<int>(viewsAbsolutePositions.size()) - 2; i >= 0; --i) {
422
+ viewsAbsolutePositions[i] += viewsAbsolutePositions[i + 1];
423
+ }
424
+ return viewsAbsolutePositions;
425
+ }
426
+
427
+ std::optional<Transform> LayoutAnimationsProxy_Experimental::parseParentTransforms(
428
+ const std::shared_ptr<LightNode> &node,
429
+ const std::vector<react::Point> &absolutePositions) const {
430
+ std::vector<std::pair<Transform, TransformOrigin>> transforms;
431
+ auto currentNode = node;
432
+ while (currentNode) {
433
+ const auto &props = static_cast<const ViewProps &>(*currentNode->current.props);
434
+ auto origin = props.transformOrigin;
435
+ const auto &viewSize = currentNode->current.layoutMetrics.frame.size;
436
+ if (origin.xy[0].unit == facebook::react::UnitType::Percent) {
437
+ origin.xy[0] = {static_cast<float>(viewSize.width * origin.xy[0].value / 100), UnitType::Point};
438
+ } else if (origin.xy[0].unit == facebook::react::UnitType::Undefined) {
439
+ origin.xy[0] = {static_cast<float>(viewSize.width * 0.5), UnitType::Point};
440
+ }
441
+ if (origin.xy[1].unit == facebook::react::UnitType::Percent) {
442
+ origin.xy[1] = {static_cast<float>(viewSize.height * origin.xy[1].value / 100), UnitType::Point};
443
+ } else if (origin.xy[1].unit == facebook::react::UnitType::Undefined) {
444
+ origin.xy[1] = {static_cast<float>(viewSize.height * 0.5), UnitType::Point};
445
+ }
446
+ transforms.emplace_back(props.transform, origin);
447
+ currentNode = currentNode->parent.lock();
448
+ }
449
+
450
+ const auto &targetViewPosition = absolutePositions[0];
451
+ Transform combinedMatrix;
452
+ bool parentHasTransform = false;
453
+ for (int i = static_cast<int>(transforms.size()) - 1; i >= 0; --i) {
454
+ auto &[transform, transformOrigin] = transforms[i];
455
+ if (transform.operations.empty()) {
456
+ continue;
457
+ } else if (i > 0) {
458
+ parentHasTransform = true;
459
+ }
460
+ if (i == 0 && !parentHasTransform) {
461
+ // If only target view has transform, let's skip it, to matrix decomposition in JS
462
+ break;
463
+ }
464
+ transformOrigin.xy[0].value -= targetViewPosition.x - absolutePositions[i].x;
465
+ transformOrigin.xy[1].value -= targetViewPosition.y - absolutePositions[i].y;
466
+ combinedMatrix = combinedMatrix * resolveTransform(node->current.layoutMetrics, transform, transformOrigin);
467
+ combinedMatrix.operations.clear();
468
+ }
469
+ if (parentHasTransform) {
470
+ react::TransformOperation transformOp {
471
+ react::TransformOperationType::Arbitrary,
472
+ {},
473
+ {},
474
+ {}
475
+ };
476
+
477
+ return Transform::FromTransformOperation(
478
+ transformOp, {}, combinedMatrix);
479
+ }
480
+
481
+ return {};
482
+ }
483
+
484
+ // The methods resolveTransform and getTranslateForTransformOrigin are sourced
485
+ // from:
486
+ // https://github.com/facebook/react-native/blob/v0.80.0/packages/react-native/ReactCommon/react/renderer/components/view/BaseViewProps.cpp#L548
487
+ // We need a copy of these methods to modify the `resolveTransform` method
488
+ // to accept the transform origin as a parameter instead of as a class field.
489
+ react::Transform LayoutAnimationsProxy_Experimental::resolveTransform(
490
+ const LayoutMetrics &layoutMetrics,
491
+ const Transform &transform,
492
+ const TransformOrigin &transformOrigin) const {
493
+ const auto &frameSize = layoutMetrics.frame.size;
494
+ auto transformMatrix = Transform{};
495
+ if (frameSize.width == 0 && frameSize.height == 0) {
496
+ return transformMatrix;
497
+ }
498
+
499
+ if (transform.operations.size() == 1 &&
500
+ transform.operations[0].type == facebook::react::TransformOperationType::Arbitrary) {
501
+ transformMatrix = transform;
502
+ } else {
503
+ for (const auto &operation : transform.operations) {
504
+ transformMatrix =
505
+ transformMatrix * Transform::FromTransformOperation(operation, layoutMetrics.frame.size, transform);
506
+ }
507
+ }
508
+
509
+ if (transformOrigin.isSet()) {
510
+ std::array<float, 3> translateOffsets =
511
+ getTranslateForTransformOrigin(frameSize.width, frameSize.height, transformOrigin);
512
+ transformMatrix = Transform::Translate(translateOffsets[0], translateOffsets[1], translateOffsets[2]) *
513
+ transformMatrix * Transform::Translate(-translateOffsets[0], -translateOffsets[1], -translateOffsets[2]);
514
+ }
515
+
516
+ return transformMatrix;
517
+ }
518
+
519
+ std::array<float, 3> LayoutAnimationsProxy_Experimental::getTranslateForTransformOrigin(
520
+ float viewWidth,
521
+ float viewHeight,
522
+ const TransformOrigin &transformOrigin) const {
523
+ const float viewCenterX = viewWidth / 2;
524
+ const float viewCenterY = viewHeight / 2;
525
+
526
+ std::array<float, 3> origin = {viewCenterX, viewCenterY, transformOrigin.z};
527
+
528
+ for (int i = 0; i < static_cast<int>(transformOrigin.xy.size()); ++i) {
529
+ const auto &currentOrigin = transformOrigin.xy[i];
530
+ if (currentOrigin.unit == UnitType::Point) {
531
+ origin[i] = currentOrigin.value;
532
+ } else if (currentOrigin.unit == UnitType::Percent) {
533
+ origin[i] = ((i == 0) ? viewWidth : viewHeight) * currentOrigin.value / 100.0f;
534
+ }
535
+ }
536
+
537
+ const float newTranslateX = -viewCenterX + origin[0];
538
+ const float newTranslateY = -viewCenterY + origin[1];
539
+ const float newTranslateZ = origin[2];
540
+
541
+ return {newTranslateX, newTranslateY, newTranslateZ};
542
+ }
543
+
544
+ } // namespace reanimated
@@ -0,0 +1,119 @@
1
+ #include <jsi/jsi.h>
2
+ #include <reanimated/NativeModules/PropValueProcessor.h>
3
+
4
+ #include <iomanip>
5
+ #include <memory>
6
+ #include <sstream>
7
+ #include <stdexcept>
8
+ #include <string>
9
+ #include <unordered_set>
10
+
11
+ namespace reanimated {
12
+ const std::unordered_set<std::string> PropValueProcessor::layoutProps = {"width", "height", "top", "left"};
13
+ const std::unordered_set<std::string> PropValueProcessor::styleProps = {
14
+ "opacity",
15
+ "zIndex",
16
+ "backgroundColor",
17
+ "boxShadow"};
18
+
19
+ std::string PropValueProcessor::processPropValue(
20
+ const std::string &propName,
21
+ const std::shared_ptr<const ShadowNode> &shadowNode,
22
+ jsi::Runtime &rt) {
23
+ if (isLayoutProp(propName)) {
24
+ auto layoutableShadowNode = dynamic_cast<const LayoutableShadowNode *>(shadowNode.get());
25
+ if (!layoutableShadowNode) {
26
+ throw std::runtime_error(
27
+ "Cannot cast shadow node to "
28
+ "LayoutableShadowNode for layout property: " +
29
+ propName);
30
+ }
31
+ return processLayoutProp(propName, layoutableShadowNode);
32
+ } else if (isStyleProp(propName)) {
33
+ auto props = shadowNode->getProps();
34
+ auto viewProps = std::static_pointer_cast<const ViewProps>(props);
35
+ return processStyleProp(propName, viewProps, rt);
36
+ }
37
+
38
+ throw std::runtime_error(
39
+ std::string("Getting property `" + propName + "` with function `getViewProp` is not supported"));
40
+ }
41
+
42
+ std::string PropValueProcessor::processLayoutProp(
43
+ const std::string &propName,
44
+ const LayoutableShadowNode *layoutableShadowNode) {
45
+ const auto &frame = layoutableShadowNode->layoutMetrics_.frame;
46
+
47
+ if (propName == "width") {
48
+ return std::to_string(frame.size.width);
49
+ } else if (propName == "height") {
50
+ return std::to_string(frame.size.height);
51
+ } else if (propName == "top") {
52
+ return std::to_string(frame.origin.y);
53
+ } else if (propName == "left") {
54
+ return std::to_string(frame.origin.x);
55
+ }
56
+
57
+ throw std::runtime_error("Unsupported layout property: " + propName);
58
+ }
59
+
60
+ std::string PropValueProcessor::processStyleProp(
61
+ const std::string &propName,
62
+ const std::shared_ptr<const ViewProps> &viewProps,
63
+ jsi::Runtime &rt) {
64
+ if (propName == "opacity") {
65
+ return std::to_string(viewProps->opacity);
66
+ } else if (propName == "zIndex") {
67
+ if (viewProps->zIndex.has_value()) {
68
+ return std::to_string(*viewProps->zIndex);
69
+ }
70
+ return "0"; // Default value when zIndex is not set
71
+ } else if (propName == "backgroundColor") {
72
+ return intColorToHex(*viewProps->backgroundColor);
73
+ } else if (propName == "boxShadow") {
74
+ jsi::Array result = jsi::Array(rt, viewProps->boxShadow.size());
75
+ for (size_t i = 0; i < viewProps->boxShadow.size(); i++) {
76
+ result.setValueAtIndex(rt, i, boxShadowPreprocessing(viewProps->boxShadow[i], rt));
77
+ }
78
+ return rt.global()
79
+ .getPropertyAsObject(rt, "JSON")
80
+ .getPropertyAsFunction(rt, "stringify")
81
+ .call(rt, result)
82
+ .asString(rt)
83
+ .utf8(rt);
84
+ }
85
+
86
+ throw std::runtime_error("Unsupported style property: " + propName);
87
+ }
88
+
89
+ jsi::Object PropValueProcessor::boxShadowPreprocessing(const BoxShadow &boxShadow, jsi::Runtime &rt) {
90
+ jsi::Object result(rt);
91
+ result.setProperty(rt, "offsetX", boxShadow.offsetX);
92
+ result.setProperty(rt, "offsetY", boxShadow.offsetY);
93
+ result.setProperty(rt, "blurRadius", boxShadow.blurRadius);
94
+ result.setProperty(rt, "spreadDistance", boxShadow.spreadDistance);
95
+ result.setProperty(rt, "color", intColorToHex(*boxShadow.color));
96
+ result.setProperty(rt, "inset", boxShadow.inset ? true : false);
97
+ return result;
98
+ }
99
+
100
+ std::string PropValueProcessor::intColorToHex(const int val) {
101
+ std::stringstream invertedHexColorStream;
102
+ // By default transparency is first, color second
103
+ invertedHexColorStream << std::setfill('0') << std::setw(8) << std::hex << val;
104
+
105
+ auto invertedHexColor = invertedHexColorStream.str();
106
+ auto hexColor = "#" + invertedHexColor.substr(2, 6) + invertedHexColor.substr(0, 2);
107
+
108
+ return hexColor;
109
+ }
110
+
111
+ bool PropValueProcessor::isLayoutProp(const std::string &propName) {
112
+ return layoutProps.contains(propName);
113
+ }
114
+
115
+ bool PropValueProcessor::isStyleProp(const std::string &propName) {
116
+ return styleProps.contains(propName);
117
+ }
118
+
119
+ } // namespace reanimated