@react-native-ohos/react-native-reanimated 4.0.2-beta.1 → 4.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/CHANGELOG.md +1070 -0
  2. package/LICENSE +21 -0
  3. package/README.md +842 -0
  4. package/compatibility.json +20 -26
  5. package/harmony/reanimated/BuildProfile.ets +1 -1
  6. package/harmony/reanimated/index.ets +4 -2
  7. package/harmony/reanimated/oh-package-lock.json5 +1 -1
  8. package/harmony/reanimated/oh-package.json5 +1 -1
  9. package/harmony/reanimated/src/main/cpp/CMakeLists.txt +23 -9
  10. package/harmony/reanimated/src/main/cpp/Common/NativeView/CMakeLists.txt +56 -0
  11. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/ComponentDescriptors.h +19 -0
  12. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryComponentDescriptor.h +30 -0
  13. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.cpp +15 -0
  14. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.h +41 -0
  15. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryState.h +30 -0
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +8 -9
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +3 -6
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +203 -150
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +1 -6
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +2 -7
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +0 -1
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +2 -18
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +11 -11
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +2 -6
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +4 -1
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +5 -0
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +8 -0
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +27 -46
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +20 -20
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +2 -2
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +3 -3
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +10 -2
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +5 -3
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +20 -17
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +5 -8
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +33 -66
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +29 -22
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +14 -2
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +8 -2
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +50 -91
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +43 -18
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.cpp +63 -0
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.h +37 -0
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.cpp +100 -0
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.h +49 -0
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimation.h +13 -0
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimationFactory.h +32 -0
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.cpp +156 -0
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.h +71 -0
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.cpp +141 -0
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.h +104 -0
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.cpp +97 -0
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.h +69 -0
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.cpp +89 -0
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.h +36 -0
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +12 -0
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +11 -2
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +2 -3
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +3 -5
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +3 -3
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +1 -1
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +38 -37
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +3 -6
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +54 -32
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +5 -7
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +46 -46
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +8 -7
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +4 -57
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.cpp +23 -0
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +10 -8
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.cpp +77 -0
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.h +38 -0
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +47 -68
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +21 -9
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +4 -1
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +35 -78
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +44 -13
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +13 -11
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +4 -0
  80. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +7 -3
  81. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +20 -27
  82. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +12 -9
  83. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +63 -36
  84. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +6 -8
  85. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +55 -46
  86. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +8 -5
  87. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +1 -2
  88. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +3 -2
  89. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +76 -71
  90. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +17 -14
  91. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +145 -273
  92. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +43 -44
  93. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +19 -19
  94. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +16 -12
  95. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +95 -114
  96. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +38 -25
  97. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +9 -34
  98. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +0 -10
  99. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.cpp +47 -0
  100. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.h +24 -0
  101. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.cpp +87 -0
  102. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.h +28 -0
  103. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.cpp +326 -0
  104. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.h +65 -0
  105. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.cpp +164 -0
  106. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.h +51 -0
  107. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +14 -66
  108. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +7 -18
  109. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.cpp +284 -0
  110. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.h +31 -0
  111. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +13 -132
  112. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +3 -21
  113. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/reversingShortening.h +43 -0
  114. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Compat/WorkletsApi.h +13 -0
  115. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.cpp +33 -0
  116. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.h +39 -0
  117. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.cpp +95 -0
  118. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.h +40 -0
  119. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +20 -23
  120. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +2 -6
  121. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +26 -18
  122. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +4 -8
  123. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +16 -28
  124. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +3 -4
  125. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -24
  126. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +17 -7
  127. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.cpp +152 -0
  128. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.h +86 -0
  129. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/PropsLayoutFilter.h +98 -0
  130. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +162 -28
  131. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +69 -11
  132. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +41 -17
  133. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +14 -3
  134. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/propNameFromString.h +130 -0
  135. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +1 -0
  136. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +5 -7
  137. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +7 -4
  138. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +52 -9
  139. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +174 -62
  140. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +12 -11
  141. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +251 -128
  142. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +23 -19
  143. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +34 -6
  144. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +71 -64
  145. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +938 -700
  146. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +123 -76
  147. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.cpp +313 -0
  148. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.h +18 -0
  149. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoSelector.h +41 -0
  150. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.cpp +113 -0
  151. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.h +73 -0
  152. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +4 -4
  153. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +23 -48
  154. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +13 -14
  155. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +20 -3
  156. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReaJSIUtils.h +227 -0
  157. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +51 -14
  158. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +2 -5
  159. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/SingleInstanceChecker.h +76 -0
  160. package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.cpp +353 -0
  161. package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.h +95 -0
  162. package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.cpp +140 -0
  163. package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.h +52 -0
  164. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.cpp +45 -0
  165. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.h +33 -0
  166. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryJSIBinder.h +20 -0
  167. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +112 -19
  168. package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +4 -2
  169. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +1 -1
  170. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +1 -1
  171. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +24 -1
  172. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +7 -2
  173. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +88 -57
  174. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +4 -2
  175. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +1 -1
  176. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +1 -1
  177. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +9 -7
  178. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +6 -5
  179. package/harmony/reanimated/src/main/cpp/TransformParser.h +1 -1
  180. package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/EventEmitters.h +19 -0
  181. package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/Props.h +31 -0
  182. package/harmony/reanimated/src/main/ets/KeyboardState.ts +11 -0
  183. package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +119 -19
  184. package/harmony/reanimated/src/main/ets/{ReanimatedPackage.ts → ReanimatedPackage.ets} +4 -3
  185. package/harmony/reanimated.har +0 -0
  186. package/package.json +52 -24
  187. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +0 -145
  188. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +0 -47
  189. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +0 -93
  190. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +0 -36
  191. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +0 -75
  192. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +0 -45
  193. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +0 -183
  194. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +0 -93
  195. package/harmony/reanimated/src/main/ets/AnimationManager.ts +0 -61
  196. /package/harmony/reanimated/{ts.ts → ts.ets} +0 -0
@@ -1,12 +1,12 @@
1
+ #include <reanimated/CSS/InterpolatorRegistry.h>
1
2
  #include <reanimated/CSS/utils/props.h>
2
3
 
3
4
  #include <string>
4
- #include <utility>
5
5
 
6
6
  namespace reanimated::css {
7
7
 
8
- bool isDiscreteProperty(const std::string &propName, const std::string &componentName) {
9
- const auto &interpolators = getComponentInterpolators(componentName);
8
+ bool isDiscreteProperty(const std::string &propName, const std::string &nativeComponentName) {
9
+ const auto &interpolators = getComponentInterpolators(nativeComponentName);
10
10
  const auto it = interpolators.find(propName);
11
11
  if (it == interpolators.end()) {
12
12
  return false;
@@ -14,136 +14,17 @@ bool isDiscreteProperty(const std::string &propName, const std::string &componen
14
14
  return it->second->isDiscreteProperty();
15
15
  }
16
16
 
17
- bool areArraysDifferentRecursive(const folly::dynamic &oldArray, const folly::dynamic &newArray) {
18
- if (oldArray.size() != newArray.size()) {
19
- return true;
20
- }
21
-
22
- for (size_t i = 0; i < oldArray.size(); i++) {
23
- const auto [oldChangedProp, newChangedProp] = getChangedPropsRecursive(oldArray[i], newArray[i]);
24
-
25
- if (!oldChangedProp.isNull() || !newChangedProp.isNull()) {
26
- return true;
27
- }
28
- }
29
-
30
- return false;
31
- }
32
-
33
- std::pair<folly::dynamic, folly::dynamic> getChangedPropsRecursive(
34
- const folly::dynamic &oldProp,
35
- const folly::dynamic &newProp) {
36
- if (!oldProp.isObject() || !newProp.isObject()) {
37
- // Primitive values comparison
38
- if (oldProp != newProp) {
39
- return {oldProp, newProp};
40
- }
41
- return {folly::dynamic(), folly::dynamic()};
42
- }
43
-
44
- if (oldProp.isArray() && newProp.isArray()) {
45
- // Arrays comparison
46
- if (areArraysDifferentRecursive(oldProp, newProp)) {
47
- return {oldProp, newProp};
48
- }
49
- return {folly::dynamic(), folly::dynamic()};
50
- }
51
-
52
- folly::dynamic oldResult = folly::dynamic::object;
53
- folly::dynamic newResult = folly::dynamic::object;
54
- bool oldHasChanges = false;
55
- bool newHasChanges = false;
56
-
57
- // Check for removed properties
58
- for (const auto &item : oldProp.items()) {
59
- const auto &propName = item.first.asString();
60
- if (!newProp.count(propName)) {
61
- const auto &oldValue = item.second;
62
- oldResult[propName] = oldValue;
63
- oldHasChanges = true;
64
- }
65
- }
66
-
67
- // Check for new and changed properties
68
- for (const auto &item : newProp.items()) {
69
- const auto &propName = item.first.asString();
70
- const auto &newValue = item.second;
71
-
72
- if (oldProp.count(propName)) {
73
- const auto &oldValue = oldProp[propName];
74
- auto [oldChangedProp, newChangedProp] = getChangedPropsRecursive(oldValue, newValue);
75
-
76
- if (!oldChangedProp.isNull() && !newChangedProp.isNull()) {
77
- oldResult[propName] = std::move(oldChangedProp);
78
- newResult[propName] = std::move(newChangedProp);
79
- oldHasChanges = true;
80
- newHasChanges = true;
81
- }
82
- } else {
83
- newResult[propName] = newValue;
84
- newHasChanges = true;
85
- }
86
- }
87
-
17
+ ColorChannels extractColorChannels(int64_t numberValue) {
18
+ // Colors above 2^31 arrive as signed negatives (JS applies `| 0`); cast
19
+ // through int32_t to preserve the bit pattern.
20
+ const uint32_t color =
21
+ numberValue < 0 ? static_cast<uint32_t>(static_cast<int32_t>(numberValue)) : static_cast<uint32_t>(numberValue);
88
22
  return {
89
- oldHasChanges ? std::move(oldResult) : folly::dynamic(), newHasChanges ? std::move(newResult) : folly::dynamic()};
90
- }
91
-
92
- std::pair<folly::dynamic, folly::dynamic>
93
- getChangedValueForProp(const folly::dynamic &oldObject, const folly::dynamic &newObject, const std::string &propName) {
94
- const bool oldHasProperty = oldObject.count(propName);
95
- const bool newHasProperty = newObject.count(propName);
96
-
97
- if (oldHasProperty && newHasProperty) {
98
- const auto &oldVal = oldObject[propName];
99
- const auto &newVal = newObject[propName];
100
-
101
- if (oldVal.isObject() && newVal.isObject()) {
102
- return getChangedPropsRecursive(oldVal, newVal);
103
- } else if (oldVal != newVal) {
104
- return {oldVal, newVal};
105
- }
106
-
107
- return {folly::dynamic(), folly::dynamic()};
108
- }
109
-
110
- if (oldHasProperty) {
111
- const auto &oldVal = oldObject[propName];
112
- return {oldVal, folly::dynamic()};
113
- } else if (newHasProperty) {
114
- const auto &newVal = newObject[propName];
115
- return {folly::dynamic(), newVal};
116
- }
117
-
118
- return {folly::dynamic(), folly::dynamic()};
119
- }
120
-
121
- ChangedProps getChangedProps(
122
- const folly::dynamic &oldProps,
123
- const folly::dynamic &newProps,
124
- const PropertyNames &allowedProperties) {
125
- folly::dynamic oldResult = folly::dynamic::object;
126
- folly::dynamic newResult = folly::dynamic::object;
127
- PropertyNames changedPropertyNames;
128
-
129
- for (const auto &propName : allowedProperties) {
130
- auto [oldChangedProp, newChangedProp] = getChangedValueForProp(oldProps, newProps, propName);
131
-
132
- const auto hasOldChangedProp = !oldChangedProp.isNull();
133
- const auto hasNewChangedProp = !newChangedProp.isNull();
134
-
135
- if (hasOldChangedProp) {
136
- oldResult[propName] = std::move(oldChangedProp);
137
- }
138
- if (hasNewChangedProp) {
139
- newResult[propName] = std::move(newChangedProp);
140
- }
141
- if (hasOldChangedProp || hasNewChangedProp) {
142
- changedPropertyNames.push_back(propName);
143
- }
144
- }
145
-
146
- return {std::move(oldResult), std::move(newResult), std::move(changedPropertyNames)};
23
+ static_cast<uint8_t>((color >> 16) & 0xFF),
24
+ static_cast<uint8_t>((color >> 8) & 0xFF),
25
+ static_cast<uint8_t>(color & 0xFF),
26
+ static_cast<uint8_t>((color >> 24) & 0xFF),
27
+ };
147
28
  }
148
29
 
149
30
  } // namespace reanimated::css
@@ -1,32 +1,14 @@
1
1
  #pragma once
2
2
 
3
- #include <reanimated/CSS/InterpolatorRegistry.h>
4
3
  #include <reanimated/CSS/common/definitions.h>
5
4
 
6
- #include <memory>
7
5
  #include <string>
8
- #include <unordered_map>
9
- #include <unordered_set>
10
- #include <utility>
11
6
 
12
7
  namespace reanimated::css {
13
8
 
14
- struct ChangedProps {
15
- const folly::dynamic oldProps;
16
- const folly::dynamic newProps;
17
- const PropertyNames changedPropertyNames;
18
- };
9
+ bool isDiscreteProperty(const std::string &propName, const std::string &nativeComponentName);
19
10
 
20
- bool isDiscreteProperty(const std::string &propName, const std::string &componentName);
21
-
22
- // We need to specify it here because there are 2 methods referencing
23
- // each other in the recursion and areArraysDifferentRecursive must be
24
- // aware that getChangedPropsRecursive exists
25
- std::pair<folly::dynamic, folly::dynamic> getChangedPropsRecursive(
26
- const folly::dynamic &oldProp,
27
- const folly::dynamic &newProp);
28
-
29
- ChangedProps
30
- getChangedProps(const folly::dynamic &oldProps, const folly::dynamic &newProps, const PropertyNames &allowedProperties);
11
+ /// Decodes RN's processColor output (packed ARGB int, possibly signed) into RGBA channels.
12
+ ColorChannels extractColorChannels(int64_t numberValue);
31
13
 
32
14
  } // namespace reanimated::css
@@ -0,0 +1,43 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/easing/EasingConfigs.h>
4
+
5
+ #include <algorithm>
6
+ #include <utility>
7
+
8
+ namespace reanimated::css {
9
+
10
+ // Snapshot of a transition's reversing-shortening state. Stores the easing as
11
+ // a config (variant), not a resolved EasingFunction - the function is only
12
+ // rebuilt inside reverseShorten when an actual reversal happens, so a
13
+ // transition that never gets reversed never pays for the resolution.
14
+ struct ReversingState {
15
+ double factor;
16
+ double startTimestamp;
17
+ double duration;
18
+ double delay;
19
+ EasingConfig easing;
20
+ };
21
+
22
+ inline ReversingState makeReversingState(double timestamp, double duration, double delay, EasingConfig easing) {
23
+ return {1.0, timestamp + delay, duration, delay, std::move(easing)};
24
+ }
25
+
26
+ // When a transition reverses an in-flight one, the new transition's duration
27
+ // (and negative delay) shorten by an accumulating factor based on how far the
28
+ // running transition had progressed.
29
+ // See https://drafts.csswg.org/css-transitions/#reversing
30
+ inline ReversingState
31
+ reverseShorten(const ReversingState &previous, double timestamp, double duration, double delay, EasingConfig easing) {
32
+ const double elapsed = std::clamp(timestamp - previous.startTimestamp, 0.0, previous.duration);
33
+ const double linearProgress = previous.duration > 0 ? elapsed / previous.duration : 1.0;
34
+ const double easedProgress = getEasingFunctionFromConfig(previous.easing)(linearProgress);
35
+ const double factor = easedProgress * previous.factor + (1 - previous.factor);
36
+ duration *= factor;
37
+ if (delay < 0) {
38
+ delay *= factor;
39
+ }
40
+ return {factor, timestamp + delay, duration, delay, std::move(easing)};
41
+ }
42
+
43
+ } // namespace reanimated::css
@@ -0,0 +1,13 @@
1
+ #pragma once
2
+
3
+ #include <worklets/Compat/StableApi.h>
4
+ #include <string>
5
+
6
+ #define EXPECTED_WORKLETS_STABLE_API_VERSION "0.9.0"
7
+
8
+ static_assert(
9
+ std::string(WORKLETS_STABLE_API_VERSION) == EXPECTED_WORKLETS_STABLE_API_VERSION,
10
+ "Incompatible worklets stable API version. Expected " EXPECTED_WORKLETS_STABLE_API_VERSION
11
+ ", but got " WORKLETS_STABLE_API_VERSION ".");
12
+
13
+ #undef EXPECTED_WORKLETS_STABLE_API_VERSION
@@ -0,0 +1,33 @@
1
+ #include <reanimated/Events/UIEventHandler.h>
2
+
3
+ #include <memory>
4
+ #include <string>
5
+
6
+ using namespace worklets;
7
+
8
+ namespace reanimated {
9
+
10
+ void UIEventHandler::process(
11
+ const std::shared_ptr<WorkletRuntime> &uiRuntime,
12
+ const double eventTimestamp,
13
+ const jsi::Value &eventValue) const {
14
+ runSyncOnRuntime(uiRuntime, handlerFunction_, jsi::Value(eventTimestamp), eventValue);
15
+ }
16
+
17
+ uint64_t UIEventHandler::getHandlerId() const {
18
+ return handlerId_;
19
+ }
20
+
21
+ const std::string &UIEventHandler::getEventName() const {
22
+ return eventName_;
23
+ }
24
+
25
+ uint64_t UIEventHandler::getEmitterReactTag() const {
26
+ return emitterReactTag_;
27
+ }
28
+
29
+ bool UIEventHandler::shouldIgnoreEmitterReactTag() const {
30
+ return emitterReactTag_ == -1;
31
+ }
32
+
33
+ } // namespace reanimated
@@ -0,0 +1,39 @@
1
+ #pragma once
2
+
3
+ #include <jsi/jsi.h>
4
+ #include <reanimated/Compat/WorkletsApi.h>
5
+
6
+ #include <memory>
7
+ #include <string>
8
+
9
+ using namespace facebook;
10
+
11
+ namespace reanimated {
12
+
13
+ class UIEventHandler {
14
+ const uint64_t handlerId_;
15
+ const uint64_t emitterReactTag_;
16
+ const std::string eventName_;
17
+ const std::shared_ptr<worklets::Serializable> handlerFunction_;
18
+
19
+ public:
20
+ UIEventHandler(
21
+ const uint64_t handlerId,
22
+ const std::string &eventName,
23
+ const uint64_t emitterReactTag,
24
+ const std::shared_ptr<worklets::Serializable> &handlerFunction)
25
+ : handlerId_(handlerId),
26
+ emitterReactTag_(emitterReactTag),
27
+ eventName_(eventName),
28
+ handlerFunction_(handlerFunction) {}
29
+ void process(
30
+ const std::shared_ptr<worklets::WorkletRuntime> &uiRuntime,
31
+ double eventTimestamp,
32
+ const jsi::Value &eventValue) const;
33
+ uint64_t getHandlerId() const;
34
+ const std::string &getEventName() const;
35
+ uint64_t getEmitterReactTag() const;
36
+ bool shouldIgnoreEmitterReactTag() const;
37
+ };
38
+
39
+ } // namespace reanimated
@@ -0,0 +1,95 @@
1
+ #include <reanimated/Events/UIEventHandler.h>
2
+ #include <reanimated/Events/UIEventHandlerRegistry.h>
3
+
4
+ #include <memory>
5
+ #include <string>
6
+ #include <utility>
7
+ #include <vector>
8
+
9
+ using namespace worklets;
10
+
11
+ namespace reanimated {
12
+
13
+ void UIEventHandlerRegistry::registerEventHandler(const std::shared_ptr<UIEventHandler> &eventHandler) {
14
+ const std::lock_guard<std::mutex> lock(instanceMutex);
15
+ const auto &eventName = eventHandler->getEventName();
16
+ auto handlerId = eventHandler->getHandlerId();
17
+
18
+ if (eventHandler->shouldIgnoreEmitterReactTag()) {
19
+ eventMappingsWithoutTag[eventName][handlerId] = eventHandler;
20
+ } else {
21
+ const auto emitterReactTag = eventHandler->getEmitterReactTag();
22
+ const auto eventHash = std::make_pair(emitterReactTag, eventName);
23
+ eventMappingsWithTag[eventHash][handlerId] = eventHandler;
24
+ }
25
+ eventHandlers[handlerId] = eventHandler;
26
+ }
27
+
28
+ void UIEventHandlerRegistry::unregisterEventHandler(const uint64_t id) {
29
+ const std::lock_guard<std::mutex> lock(instanceMutex);
30
+ auto handlerIt = eventHandlers.find(id);
31
+ if (handlerIt != eventHandlers.end()) {
32
+ const auto &eventHandler = handlerIt->second;
33
+ const auto &eventName = eventHandler->getEventName();
34
+
35
+ if (eventHandler->shouldIgnoreEmitterReactTag()) {
36
+ const auto eventMappingIt = eventMappingsWithoutTag.find(eventName);
37
+ auto &handlersMap = eventMappingIt->second;
38
+ handlersMap.erase(id);
39
+ if (handlersMap.empty()) {
40
+ eventMappingsWithoutTag.erase(eventMappingIt);
41
+ }
42
+ } else {
43
+ const auto emitterReactTag = eventHandler->getEmitterReactTag();
44
+ const auto eventHash = std::make_pair(emitterReactTag, eventName);
45
+ const auto eventMappingIt = eventMappingsWithTag.find(eventHash);
46
+ auto &handlersMap = eventMappingIt->second;
47
+ handlersMap.erase(id);
48
+ if (handlersMap.empty()) {
49
+ eventMappingsWithTag.erase(eventMappingIt);
50
+ }
51
+ }
52
+ eventHandlers.erase(handlerIt);
53
+ }
54
+ }
55
+
56
+ void UIEventHandlerRegistry::processEvent(
57
+ const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
58
+ const double eventTimestamp,
59
+ const std::string &eventName,
60
+ const int emitterReactTag,
61
+ const jsi::Value &eventPayload) {
62
+ std::vector<std::shared_ptr<UIEventHandler>> handlersForEvent;
63
+ {
64
+ const std::lock_guard<std::mutex> lock(instanceMutex);
65
+ auto handlersIt = eventMappingsWithoutTag.find(eventName);
66
+ if (handlersIt != eventMappingsWithoutTag.end()) {
67
+ for (const auto &handler : handlersIt->second) {
68
+ handlersForEvent.push_back(handler.second);
69
+ }
70
+ }
71
+ const auto eventHash = std::make_pair(emitterReactTag, eventName);
72
+ auto handlersWithTagIt = eventMappingsWithTag.find(eventHash);
73
+ if (handlersWithTagIt != eventMappingsWithTag.end()) {
74
+ for (const auto &handler : handlersWithTagIt->second) {
75
+ handlersForEvent.push_back(handler.second);
76
+ }
77
+ }
78
+ }
79
+
80
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiWorkletRuntime);
81
+ eventPayload.asObject(uiRuntime).setProperty(
82
+ uiRuntime, "eventName", jsi::String::createFromUtf8(uiRuntime, eventName));
83
+ for (const auto &handler : handlersForEvent) {
84
+ handler->process(uiWorkletRuntime, eventTimestamp, eventPayload);
85
+ }
86
+ }
87
+
88
+ bool UIEventHandlerRegistry::isAnyHandlerWaitingForEvent(const std::string &eventName, const int emitterReactTag) {
89
+ const std::lock_guard<std::mutex> lock(instanceMutex);
90
+ const auto eventHash = std::make_pair(emitterReactTag, eventName);
91
+ auto it = eventMappingsWithTag.find(eventHash);
92
+ return it != eventMappingsWithTag.end() && !it->second.empty();
93
+ }
94
+
95
+ } // namespace reanimated
@@ -0,0 +1,40 @@
1
+ #pragma once
2
+
3
+ #include <jsi/jsi.h>
4
+ #include <reanimated/Compat/WorkletsApi.h>
5
+
6
+ #include <map>
7
+ #include <memory>
8
+ #include <mutex>
9
+ #include <string>
10
+ #include <unordered_map>
11
+ #include <utility>
12
+
13
+ using namespace facebook;
14
+
15
+ namespace reanimated {
16
+
17
+ class UIEventHandler;
18
+
19
+ class UIEventHandlerRegistry {
20
+ std::map<std::pair<int, std::string>, std::unordered_map<uint64_t, std::shared_ptr<UIEventHandler>>>
21
+ eventMappingsWithTag;
22
+ std::map<std::string, std::unordered_map<uint64_t, std::shared_ptr<UIEventHandler>>> eventMappingsWithoutTag;
23
+ std::map<uint64_t, std::shared_ptr<UIEventHandler>> eventHandlers;
24
+ std::mutex instanceMutex;
25
+
26
+ public:
27
+ void registerEventHandler(const std::shared_ptr<UIEventHandler> &eventHandler);
28
+ void unregisterEventHandler(const uint64_t id);
29
+
30
+ void processEvent(
31
+ const std::shared_ptr<worklets::WorkletRuntime> &uiRuntime,
32
+ const double eventTimestamp,
33
+ const std::string &eventName,
34
+ const int emitterReactTag,
35
+ const jsi::Value &eventPayload);
36
+
37
+ bool isAnyHandlerWaitingForEvent(const std::string &eventName, const int emitterReactTag);
38
+ };
39
+
40
+ } // namespace reanimated
@@ -4,8 +4,6 @@
4
4
  #include <reanimated/Tools/FeatureFlags.h>
5
5
  #include <reanimated/Tools/ReanimatedSystraceSection.h>
6
6
 
7
- #include <react/renderer/core/ComponentDescriptor.h>
8
-
9
7
  #include <memory>
10
8
  #include <unordered_map>
11
9
  #include <vector>
@@ -33,19 +31,20 @@ void ReanimatedCommitHook::maybeInitializeLayoutAnimations(SurfaceId surfaceId)
33
31
  if (surfaceId > currentMaxSurfaceId_) {
34
32
  // when a new surfaceId is observed we call setMountingOverrideDelegate
35
33
  // for all yet unseen surfaces
36
- uiManager_->getShadowTreeRegistry().enumerate([strongThis = shared_from_this()](
37
- const ShadowTree &shadowTree, bool &stop) {
38
- // Executed synchronously.
39
- if (shadowTree.getSurfaceId() <= strongThis->currentMaxSurfaceId_) {
40
- // the set function actually adds our delegate to a list, so we
41
- // shouldn't invoke it twice for the same surface
42
- return;
43
- }
44
- // TODO: We should consider registering a new instance of proxy for each surface.
45
- // The current approach will encounter problems on platforms where it is more common to have multiple surfaces.
46
- strongThis->layoutAnimationsProxy_->startSurface(shadowTree.getSurfaceId());
47
- shadowTree.getMountingCoordinator()->setMountingOverrideDelegate(strongThis->layoutAnimationsProxy_);
48
- });
34
+ uiManager_->getShadowTreeRegistry().enumerate(
35
+ [strongThis = shared_from_this()](const ShadowTree &shadowTree, bool &stop) {
36
+ // Executed synchronously.
37
+ if (shadowTree.getSurfaceId() <= strongThis->currentMaxSurfaceId_) {
38
+ // the set function actually adds our delegate to a list, so we
39
+ // shouldn't invoke it twice for the same surface
40
+ return;
41
+ }
42
+ // TODO: We should consider registering a new instance of proxy for each surface.
43
+ // The current approach will encounter problems on platforms where it is more common to have multiple
44
+ // surfaces.
45
+ strongThis->layoutAnimationsProxy_->startSurface(shadowTree.getSurfaceId());
46
+ shadowTree.getMountingCoordinator()->setMountingOverrideDelegate(strongThis->layoutAnimationsProxy_);
47
+ });
49
48
  currentMaxSurfaceId_ = surfaceId;
50
49
  }
51
50
  }
@@ -53,16 +52,16 @@ void ReanimatedCommitHook::maybeInitializeLayoutAnimations(SurfaceId surfaceId)
53
52
  RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
54
53
  ShadowTree const &,
55
54
  RootShadowNode::Shared const &,
56
- RootShadowNode::Unshared const &newRootShadowNode
57
- #if REACT_NATIVE_MINOR_VERSION >= 80
58
- ,
59
- const ShadowTreeCommitOptions &commitOptions
60
- #endif
61
- ) noexcept {
55
+ RootShadowNode::Unshared const &newRootShadowNode,
56
+ const ShadowTreeCommitOptions &commitOptions) noexcept {
62
57
  ReanimatedSystraceSection s("ReanimatedCommitHook::shadowTreeWillCommit");
63
58
 
64
59
  maybeInitializeLayoutAnimations(newRootShadowNode->getSurfaceId());
65
60
 
61
+ if constexpr (StaticFeatureFlags::getFlag("USE_ANIMATION_BACKEND")) {
62
+ return newRootShadowNode;
63
+ }
64
+
66
65
  auto reaShadowNode = std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(newRootShadowNode);
67
66
 
68
67
  if (reaShadowNode->hasReanimatedCommitTrait()) {
@@ -73,7 +72,6 @@ RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
73
72
  return newRootShadowNode;
74
73
  }
75
74
 
76
- #if REACT_NATIVE_MINOR_VERSION >= 80
77
75
  if constexpr (StaticFeatureFlags::getFlag("USE_COMMIT_HOOK_ONLY_FOR_REACT_COMMITS")) {
78
76
  // State updates are based on the currently committed ShadowTree,
79
77
  // which means that all animation changes are already included.
@@ -82,7 +80,6 @@ RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
82
80
  return newRootShadowNode;
83
81
  }
84
82
  }
85
- #endif
86
83
 
87
84
  // ShadowTree not commited by Reanimated, apply updates from the updates
88
85
  // registry manager
@@ -29,12 +29,8 @@ class ReanimatedCommitHook : public UIManagerCommitHook, public std::enable_shar
29
29
  RootShadowNode::Unshared shadowTreeWillCommit(
30
30
  ShadowTree const &shadowTree,
31
31
  RootShadowNode::Shared const &oldRootShadowNode,
32
- RootShadowNode::Unshared const &newRootShadowNode
33
- #if REACT_NATIVE_MINOR_VERSION >= 80
34
- ,
35
- const ShadowTreeCommitOptions &commitOptions
36
- #endif
37
- ) noexcept override;
32
+ RootShadowNode::Unshared const &newRootShadowNode,
33
+ const ShadowTreeCommitOptions &commitOptions) noexcept override;
38
34
 
39
35
  private:
40
36
  std::shared_ptr<UIManager> uiManager_;
@@ -9,8 +9,12 @@ namespace reanimated {
9
9
  ReanimatedMountHook::ReanimatedMountHook(
10
10
  const std::shared_ptr<UIManager> &uiManager,
11
11
  const std::shared_ptr<UpdatesRegistryManager> &updatesRegistryManager,
12
+ const std::shared_ptr<css::ViewStylesRepository> &viewStylesRepository,
12
13
  const std::function<void()> &requestFlush)
13
- : uiManager_(uiManager), updatesRegistryManager_(updatesRegistryManager), requestFlush_(requestFlush) {
14
+ : uiManager_(uiManager),
15
+ updatesRegistryManager_(updatesRegistryManager),
16
+ viewStylesRepository_(viewStylesRepository),
17
+ requestFlush_(requestFlush) {
14
18
  uiManager_->registerMountHook(*this);
15
19
  }
16
20
 
@@ -20,35 +24,39 @@ ReanimatedMountHook::~ReanimatedMountHook() noexcept {
20
24
 
21
25
  void ReanimatedMountHook::shadowTreeDidMount(
22
26
  const RootShadowNode::Shared &rootShadowNode,
23
- #if REACT_NATIVE_MINOR_VERSION >= 81
24
- HighResTimeStamp
25
- #else
26
- double
27
- #endif // REACT_NATIVE_MINOR_VERSION >= 81
28
- ) noexcept {
27
+ HighResTimeStamp mountTime) noexcept {
29
28
  ReanimatedSystraceSection s("ReanimatedMountHook::shadowTreeDidMount");
30
29
 
31
30
  auto reaShadowNode = std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
32
31
  std::const_pointer_cast<RootShadowNode>(rootShadowNode));
33
32
 
34
- if (reaShadowNode->hasReanimatedMountTrait()) {
35
- // We mark reanimated commits with ReanimatedMountTrait. We don't want other
36
- // shadow nodes to use this trait, but since this rootShadowNode is Shared,
37
- // we don't have that guarantee. That's why we also unset this trait in the
38
- // commit hook. We remove it here mainly for the sake of cleanliness.
33
+ // We mark reanimated commits with ReanimatedMountTrait. We don't want other
34
+ // shadow nodes to use this trait, but since this rootShadowNode is Shared,
35
+ // we don't have that guarantee. That's why we also unset this trait in the
36
+ // commit hook. We remove it here mainly for the sake of cleanliness.
37
+ const bool isReanimatedMount = reaShadowNode->hasReanimatedMountTrait();
38
+ if (isReanimatedMount) {
39
39
  reaShadowNode->unsetReanimatedMountTrait();
40
- return;
41
40
  }
42
41
 
43
42
  {
44
43
  auto lock = updatesRegistryManager_->lock();
44
+ // Record the mounted tree for relative-length resolution.
45
+ viewStylesRepository_->setLastMountedRoot(rootShadowNode);
46
+
47
+ // Always drain removable nodes, even on Reanimated's own commits. While CSS
48
+ // animations run every mount carries the mount trait, so returning early here
49
+ // would skip removals for the whole animation and leak unmounted nodes if the
50
+ // tree is torn down mid-animation.
45
51
  updatesRegistryManager_->handleNodeRemovals(*rootShadowNode);
46
52
 
47
- // When commit from React Native has finished, we reset the skip commit flag
48
- // in order to allow Reanimated to commit its tree
49
- updatesRegistryManager_->unpauseReanimatedCommits();
50
- if (updatesRegistryManager_->shouldCommitAfterPause()) {
51
- requestFlush_();
53
+ if (!isReanimatedMount) {
54
+ // When a commit from React Native has finished, we reset the skip commit
55
+ // flag in order to allow Reanimated to commit its tree.
56
+ updatesRegistryManager_->unpauseReanimatedCommits();
57
+ if (updatesRegistryManager_->shouldCommitAfterPause()) {
58
+ requestFlush_();
59
+ }
52
60
  }
53
61
  }
54
62
  }
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
 
3
+ #include <reanimated/CSS/misc/ViewStylesRepository.h>
3
4
  #include <reanimated/Fabric/ShadowTreeCloner.h>
4
5
  #include <reanimated/Fabric/updates/UpdatesRegistryManager.h>
5
6
 
@@ -16,21 +17,16 @@ class ReanimatedMountHook : public UIManagerMountHook {
16
17
  ReanimatedMountHook(
17
18
  const std::shared_ptr<UIManager> &uiManager,
18
19
  const std::shared_ptr<UpdatesRegistryManager> &updatesRegistryManager,
20
+ const std::shared_ptr<css::ViewStylesRepository> &viewStylesRepository,
19
21
  const std::function<void()> &requestFlush);
20
22
  ~ReanimatedMountHook() noexcept override;
21
23
 
22
- void shadowTreeDidMount(
23
- RootShadowNode::Shared const &rootShadowNode,
24
- #if REACT_NATIVE_MINOR_VERSION >= 81
25
- HighResTimeStamp mountTime
26
- #else
27
- double mountTime
28
- #endif // REACT_NATIVE_MINOR_VERSION >= 81
29
- ) noexcept override;
24
+ void shadowTreeDidMount(RootShadowNode::Shared const &rootShadowNode, HighResTimeStamp mountTime) noexcept override;
30
25
 
31
26
  private:
32
27
  const std::shared_ptr<UIManager> uiManager_;
33
28
  const std::shared_ptr<UpdatesRegistryManager> updatesRegistryManager_;
29
+ const std::shared_ptr<css::ViewStylesRepository> viewStylesRepository_;
34
30
  const std::function<void()> requestFlush_;
35
31
  };
36
32