@react-native-ohos/react-native-reanimated 4.0.2 → 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 -6
  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 +98 -18
  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 +106 -17
  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
@@ -2,12 +2,14 @@
2
2
 
3
3
  #include <reanimated/CSS/configs/CSSAnimationConfig.h>
4
4
  #include <reanimated/CSS/core/CSSAnimation.h>
5
- #include <reanimated/CSS/utils/DelayedItemsManager.h>
5
+ #include <reanimated/CSS/core/CSSAnimationsGroup.h>
6
+ #include <reanimated/CSS/core/CSSPlatformAnimationFactory.h>
7
+ #include <reanimated/CSS/registries/CSSKeyframesRegistry.h>
6
8
  #include <reanimated/CSS/utils/props.h>
9
+ #include <reanimated/Fabric/updates/OperationsLoop.h>
7
10
  #include <reanimated/Fabric/updates/UpdatesRegistry.h>
8
11
 
9
12
  #include <memory>
10
- #include <set>
11
13
  #include <string>
12
14
  #include <unordered_map>
13
15
  #include <unordered_set>
@@ -17,64 +19,61 @@
17
19
  namespace reanimated::css {
18
20
 
19
21
  using CSSAnimationsMap = std::unordered_map<size_t, std::shared_ptr<CSSAnimation>>;
20
- using CSSAnimationsVector = std::vector<std::shared_ptr<CSSAnimation>>;
21
22
 
22
- class CSSAnimationsRegistry : public UpdatesRegistry, std::enable_shared_from_this<CSSAnimationsRegistry> {
23
+ class CSSAnimationsRegistry : public UpdatesRegistry {
23
24
  public:
24
- using SettingsUpdates = std::vector<std::pair<size_t, PartialCSSAnimationSettings>>;
25
+ CSSAnimationsRegistry(
26
+ const std::shared_ptr<OperationsLoop> &loop,
27
+ const std::shared_ptr<CSSKeyframesRegistry> &keyframesRegistry,
28
+ const std::shared_ptr<CSSPlatformAnimationFactory> &platformAnimationFactory);
25
29
 
26
- bool isEmpty() const override;
27
- bool hasUpdates() const;
30
+ bool needsFlush() const;
28
31
 
29
32
  void apply(
30
- jsi::Runtime &rt,
31
33
  const std::shared_ptr<const ShadowNode> &shadowNode,
32
- const std::optional<std::vector<std::string>> &animationNames,
33
- const CSSAnimationsMap &newAnimations,
34
- const CSSAnimationSettingsUpdatesMap &settingsUpdates,
35
- double timestamp);
36
- void remove(Tag viewTag) override;
34
+ const std::string &compoundComponentName,
35
+ const CSSAnimationUpdates &updates);
37
36
 
38
- void update(double timestamp);
37
+ void flushUpdates(UpdatesBatch &updatesBatch);
38
+ #if REACT_NATIVE_VERSION_MINOR >= 85
39
+ void flushUpdates(UpdatesBatchAnimatedProps &updatesBatch);
40
+ #endif
39
41
 
40
42
  private:
41
- using AnimationToIndexMap = std::unordered_map<std::shared_ptr<CSSAnimation>, size_t>;
42
- using RunningAnimationIndicesMap = std::unordered_map<Tag, std::set<size_t>>;
43
- using AnimationsToRevertMap = std::unordered_map<Tag, std::unordered_set<size_t>>;
44
- struct RegistryEntry {
45
- const CSSAnimationsVector animationsVector;
46
- const AnimationToIndexMap animationToIndexMap;
43
+ class AnimationObserver : public CSSAnimation::Observer {
44
+ public:
45
+ explicit AnimationObserver(CSSAnimationsRegistry &owner);
46
+ void onAnimationUpdate(Tag viewTag) override;
47
+ void onAnimationNeedsRevert(Tag viewTag) override;
48
+
49
+ private:
50
+ CSSAnimationsRegistry &owner_;
47
51
  };
48
52
 
49
- using Registry = std::unordered_map<Tag, RegistryEntry>;
53
+ const std::shared_ptr<OperationsLoop> loop_;
54
+ const std::shared_ptr<CSSKeyframesRegistry> keyframesRegistry_;
55
+ const std::shared_ptr<CSSPlatformAnimationFactory> platformAnimationFactory_;
50
56
 
51
- Registry registry_;
57
+ AnimationObserver animationObserver_{*this};
52
58
 
53
- RunningAnimationIndicesMap runningAnimationIndicesMap_;
54
- AnimationsToRevertMap animationsToRevertMap_;
55
- DelayedItemsManager<std::shared_ptr<CSSAnimation>> delayedAnimationsManager_;
59
+ std::unordered_map<Tag, CSSAnimationsGroup> groups_;
60
+ // Tags reported by owned animations between flushes.
61
+ std::unordered_set<Tag> updatedTags_;
62
+ std::unordered_set<Tag> pendingRevertTags_;
56
63
 
57
- CSSAnimationsVector buildAnimationsVector(
58
- jsi::Runtime &rt,
64
+ void removeTag(Tag viewTag) override;
65
+ std::optional<CSSAnimationsGroup> maybeBuildNewGroup(
66
+ const std::shared_ptr<const ShadowNode> &shadowNode,
67
+ const std::string &compoundComponentName,
68
+ const std::optional<std::vector<std::string>> &updatedAnimationNames,
69
+ const CSSAnimationSettingsMap &newAnimationSettings);
70
+ std::shared_ptr<CSSAnimation> createAnimation(
59
71
  const std::shared_ptr<const ShadowNode> &shadowNode,
60
- const std::optional<std::vector<std::string>> &animationNames,
61
- const std::optional<CSSAnimationsMap> &newAnimations) const;
62
- AnimationToIndexMap buildAnimationToIndexMap(const CSSAnimationsVector &animationsVector) const;
63
- void updateAnimationSettings(
64
- const CSSAnimationsVector &animationsVector,
65
- const CSSAnimationSettingsUpdatesMap &settingsUpdates,
72
+ const std::string &name,
73
+ const std::string &compoundComponentName,
74
+ const CSSAnimationSettings &settings,
66
75
  double timestamp);
67
-
68
- void
69
- updateViewAnimations(Tag viewTag, const std::vector<size_t> &animationIndices, double timestamp, bool addToBatch);
70
- void
71
- scheduleOrActivateAnimation(size_t animationIndex, const std::shared_ptr<CSSAnimation> &animation, double timestamp);
72
- void removeViewAnimations(Tag viewTag);
73
- void applyViewAnimationsStyle(Tag viewTag, double timestamp);
74
- void activateDelayedAnimations(double timestamp);
75
- void handleAnimationsToRevert(double timestamp);
76
-
77
- static bool addStyleUpdates(folly::dynamic &target, const folly::dynamic &updates, bool shouldOverride);
76
+ void updateRegistryForRevertedAnimations();
78
77
  };
79
78
 
80
79
  } // namespace reanimated::css
@@ -1,42 +1,42 @@
1
1
  #include <reanimated/CSS/registries/CSSKeyframesRegistry.h>
2
+ #include <reanimated/Fabric/updates/UpdatesRegistryManager.h>
3
+
4
+ #include <react/debug/react_native_assert.h>
2
5
 
3
- #include <memory>
4
6
  #include <string>
5
7
  #include <utility>
6
8
 
7
9
  namespace reanimated::css {
8
10
 
9
- CSSKeyframesRegistry::CSSKeyframesRegistry(const std::shared_ptr<ViewStylesRepository> &viewStylesRepository)
10
- : viewStylesRepository_(viewStylesRepository) {}
11
-
12
- const CSSKeyframesConfig &CSSKeyframesRegistry::get(
11
+ std::optional<std::reference_wrapper<const CSSKeyframesConfig>> CSSKeyframesRegistry::get(
13
12
  const std::string &animationName,
14
- const std::string &componentName) {
15
- const auto &registryIt = registry_.find(animationName);
13
+ const std::string &compoundComponentName) {
14
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
15
+ const auto registryIt = registry_.find(animationName);
16
16
  if (registryIt == registry_.end()) {
17
- throw std::runtime_error("[Reanimated] No keyframes with name `" + animationName + "` were registered");
17
+ return std::nullopt;
18
18
  }
19
19
 
20
- const auto &keyframesByComponentName = registryIt->second;
21
- const auto &keyframesByComponentNameIt = keyframesByComponentName.find(componentName);
22
- if (keyframesByComponentNameIt == keyframesByComponentName.end()) {
23
- throw std::runtime_error(
24
- "[Reanimated] No keyframes with name `" + animationName + "` were registered for component `" + componentName +
25
- "`");
20
+ const auto &keyframesByComponent = registryIt->second;
21
+ const auto keyframesByComponentIt = keyframesByComponent.find(compoundComponentName);
22
+ if (keyframesByComponentIt == keyframesByComponent.end()) {
23
+ return std::nullopt;
26
24
  }
27
25
 
28
- return keyframesByComponentNameIt->second;
26
+ return std::cref(keyframesByComponentIt->second);
29
27
  }
30
28
 
31
29
  void CSSKeyframesRegistry::set(
32
30
  const std::string &animationName,
33
- const std::string &componentName,
31
+ const std::string &compoundComponentName,
34
32
  CSSKeyframesConfig &&config) {
35
- registry_[animationName][componentName] = std::move(config);
33
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
34
+ registry_[animationName][compoundComponentName] = std::move(config);
36
35
  }
37
36
 
38
- void CSSKeyframesRegistry::remove(const std::string &animationName, const std::string &componentName) {
39
- registry_[animationName].erase(componentName);
37
+ void CSSKeyframesRegistry::remove(const std::string &animationName, const std::string &compoundComponentName) {
38
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
39
+ registry_[animationName].erase(compoundComponentName);
40
40
  if (registry_[animationName].empty()) {
41
41
  registry_.erase(animationName);
42
42
  }
@@ -1,10 +1,9 @@
1
1
  #pragma once
2
2
 
3
3
  #include <reanimated/CSS/configs/CSSKeyframesConfig.h>
4
- #include <reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h>
5
- #include <reanimated/CSS/misc/ViewStylesRepository.h>
6
4
 
7
- #include <memory>
5
+ #include <functional>
6
+ #include <optional>
8
7
  #include <string>
9
8
  #include <unordered_map>
10
9
  #include <utility>
@@ -13,17 +12,22 @@ namespace reanimated::css {
13
12
 
14
13
  class CSSKeyframesRegistry {
15
14
  public:
16
- explicit CSSKeyframesRegistry(const std::shared_ptr<ViewStylesRepository> &viewStylesRepository);
17
-
18
- const CSSKeyframesConfig &get(const std::string &animationName, const std::string &componentName);
19
- void set(const std::string &animationName, const std::string &componentName, CSSKeyframesConfig &&config);
20
- void remove(const std::string &animationName, const std::string &componentName);
15
+ std::optional<std::reference_wrapper<const CSSKeyframesConfig>> get(
16
+ const std::string &animationName,
17
+ const std::string &compoundComponentName);
18
+ void set(const std::string &animationName, const std::string &compoundComponentName, CSSKeyframesConfig &&config);
19
+ void remove(const std::string &animationName, const std::string &compoundComponentName);
21
20
 
22
21
  private:
23
- using ConfigsByComponentName = std::unordered_map<std::string, CSSKeyframesConfig>;
24
-
25
- std::unordered_map<std::string, ConfigsByComponentName> registry_;
26
- const std::shared_ptr<ViewStylesRepository> viewStylesRepository_;
22
+ // Maps compound component name to CSSKeyframesConfig. The same keyframes object may be
23
+ // interpolated differently per component (different interpolators) even when the
24
+ // keyframes look identical. CSSKeyframesConfig holds a component-specific
25
+ // styleInterpolator, so configs must be stored separately per component.
26
+ // Compound component name combines native and JS component names (caller must build it).
27
+ using KeyframesByCompoundComponentName = std::unordered_map<std::string, CSSKeyframesConfig>;
28
+
29
+ // Top level: animation name. Inner level: compound component name -> config.
30
+ std::unordered_map<std::string, KeyframesByCompoundComponentName> registry_;
27
31
  };
28
32
 
29
33
  } // namespace reanimated::css
@@ -1,135 +1,101 @@
1
1
  #include <reanimated/CSS/registries/CSSTransitionsRegistry.h>
2
+ #include <reanimated/Fabric/updates/UpdatesRegistryManager.h>
3
+
4
+ #include <react/debug/react_native_assert.h>
2
5
 
3
6
  #include <memory>
4
7
  #include <utility>
8
+ #include <vector>
5
9
 
6
10
  namespace reanimated::css {
7
11
 
8
12
  CSSTransitionsRegistry::CSSTransitionsRegistry(
9
- const std::shared_ptr<StaticPropsRegistry> &staticPropsRegistry,
10
- const GetAnimationTimestampFunction &getCurrentTimestamp)
11
- : getCurrentTimestamp_(getCurrentTimestamp), staticPropsRegistry_(staticPropsRegistry) {}
12
-
13
- bool CSSTransitionsRegistry::isEmpty() const {
14
- // The registry is empty if has no registered animations and no updates
15
- // stored in the updates registry
16
- return UpdatesRegistry::isEmpty() && registry_.empty();
17
- }
18
-
19
- bool CSSTransitionsRegistry::hasUpdates() const {
20
- return !runningTransitionTags_.empty() || !delayedTransitionsManager_.empty();
13
+ const std::shared_ptr<ViewStylesRepository> &viewStylesRepository,
14
+ const std::shared_ptr<OperationsLoop> &loop,
15
+ const std::shared_ptr<CSSPlatformTransitionProxy> &platformTransitionProxy)
16
+ : viewStylesRepository_(viewStylesRepository), loop_(loop), platformTransitionProxy_(platformTransitionProxy) {}
17
+
18
+ bool CSSTransitionsRegistry::needsFlush() const {
19
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
20
+ return !updatedTags_.empty();
21
21
  }
22
22
 
23
- void CSSTransitionsRegistry::add(const std::shared_ptr<CSSTransition> &transition) {
24
- const auto &shadowNode = transition->getShadowNode();
25
- const auto viewTag = shadowNode->getTag();
26
-
27
- registry_.insert({viewTag, transition});
28
- PropsObserver observer = createPropsObserver(viewTag);
29
- staticPropsRegistry_->setObserver(viewTag, std::move(observer));
23
+ void CSSTransitionsRegistry::updateConfigOrRun(
24
+ jsi::Runtime &rt,
25
+ const std::shared_ptr<const ShadowNode> &shadowNode,
26
+ CSSTransitionConfig &&config) {
27
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
28
+ const auto &transition = getOrCreateTransition(shadowNode);
29
+ auto initialUpdate = transition->run(rt, std::move(config), getUpdatesFromRegistry(transition->getViewTag()));
30
+ recordInitialUpdate(transition, initialUpdate);
30
31
  }
31
32
 
32
- void CSSTransitionsRegistry::remove(const Tag viewTag) {
33
- removeFromUpdatesRegistry(viewTag);
34
- staticPropsRegistry_->removeObserver(viewTag);
35
- delayedTransitionsManager_.remove(viewTag);
36
- runningTransitionTags_.erase(viewTag);
37
- registry_.erase(viewTag);
38
- }
39
-
40
- void CSSTransitionsRegistry::updateSettings(const Tag viewTag, const PartialCSSTransitionConfig &config) {
41
- const auto &transition = registry_[viewTag];
42
- transition->updateSettings(config);
43
-
44
- // Replace style overrides with the new ones if transition properties were
45
- // updated (we want to keep overrides only for transitioned properties)
46
- if (config.properties.has_value()) {
47
- updateInUpdatesRegistry(transition, transition->getCurrentInterpolationStyle());
48
- }
33
+ void CSSTransitionsRegistry::run(
34
+ const std::shared_ptr<const ShadowNode> &shadowNode,
35
+ const PropertyValueDynamicDiffsMap &propertyDiffs) {
36
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
37
+ const auto &transition = getOrCreateTransition(shadowNode);
38
+ auto initialUpdate = transition->run(propertyDiffs, getUpdatesFromRegistry(transition->getViewTag()));
39
+ recordInitialUpdate(transition, initialUpdate);
49
40
  }
50
41
 
51
- void CSSTransitionsRegistry::update(const double timestamp) {
52
- // Activate all delayed transitions that should start now
53
- activateDelayedTransitions(timestamp);
54
-
55
- // Iterate over active transitions and update them
56
- for (auto it = runningTransitionTags_.begin(); it != runningTransitionTags_.end();) {
57
- const auto &viewTag = *it;
58
- const auto &transition = registry_[viewTag];
59
-
60
- const folly::dynamic &updates = transition->update(timestamp);
61
- if (!updates.empty()) {
62
- addUpdatesToBatch(transition->getShadowNode(), updates);
63
- }
64
-
65
- // We remove transition from running and schedule it when animation of one
66
- // of properties has finished and the other one is still delayed
67
- const auto &minDelay = transition->getMinDelay(timestamp);
68
- if (minDelay > 0) {
69
- delayedTransitionsManager_.add(timestamp + transition->getMinDelay(timestamp), viewTag);
42
+ void CSSTransitionsRegistry::flushUpdates(UpdatesBatch &updatesBatch) {
43
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
44
+ const auto tags = std::exchange(updatedTags_, {});
45
+ for (const auto viewTag : tags) {
46
+ const auto it = registry_.find(viewTag);
47
+ if (it == registry_.end()) {
48
+ continue;
70
49
  }
71
50
 
72
- if (transition->getState() != TransitionProgressState::Running) {
73
- it = runningTransitionTags_.erase(it);
74
- } else {
75
- ++it;
51
+ auto &transition = it->second;
52
+ const auto updates = transition->computeCurrentLoopStyle();
53
+ if (!updates.empty()) {
54
+ addUpdatesToBatch(transition->getShadowNodeFamily(), updates);
76
55
  }
77
56
  }
57
+
58
+ flush(updatesBatch);
78
59
  }
79
60
 
80
- void CSSTransitionsRegistry::activateDelayedTransitions(const double timestamp) {
81
- while (!delayedTransitionsManager_.empty() && delayedTransitionsManager_.top().timestamp <= timestamp) {
82
- const auto [_, viewTag] = delayedTransitionsManager_.pop();
61
+ #if REACT_NATIVE_VERSION_MINOR >= 85
62
+ void CSSTransitionsRegistry::flushUpdates(UpdatesBatchAnimatedProps &updatesBatch) {
63
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
64
+ const auto tags = std::exchange(updatedTags_, {});
65
+ for (const auto viewTag : tags) {
66
+ const auto it = registry_.find(viewTag);
67
+ if (it == registry_.end()) {
68
+ continue;
69
+ }
83
70
 
84
- // Add only these transitions which weren't removed in the meantime
85
- if (registry_.find(viewTag) != registry_.end()) {
86
- runningTransitionTags_.insert(viewTag);
71
+ auto &transition = it->second;
72
+ const auto updates = transition->computeCurrentLoopStyle();
73
+ if (!updates.empty()) {
74
+ addRawPropsToAnimatedPropsBatch(transition->getShadowNodeFamily(), updates);
75
+ // Legacy flushes merge each frame into the updates registry; animated-props flushes do not.
76
+ // Keep the registry current so the next transition reads a real "from" value, not the first frame only.
77
+ updateInUpdatesRegistry(transition, updates);
87
78
  }
88
79
  }
89
- }
90
80
 
91
- void CSSTransitionsRegistry::scheduleOrActivateTransition(const std::shared_ptr<CSSTransition> &transition) {
92
- const auto viewTag = transition->getViewTag();
93
- const auto currentTimestamp = getCurrentTimestamp_();
94
- const auto minDelay = transition->getMinDelay(currentTimestamp);
95
-
96
- // Remove transition from delayed (if it is already added to delayed
97
- // transitions)
98
- delayedTransitionsManager_.remove(viewTag);
99
-
100
- if (minDelay > 0) {
101
- delayedTransitionsManager_.add(currentTimestamp + minDelay, viewTag);
102
- } else {
103
- runningTransitionTags_.insert(viewTag);
104
- }
81
+ flush(updatesBatch);
105
82
  }
83
+ #endif
106
84
 
107
- PropsObserver CSSTransitionsRegistry::createPropsObserver(const Tag viewTag) {
108
- return [weakThis = weak_from_this(), viewTag](const folly::dynamic &oldProps, const folly::dynamic &newProps) {
109
- auto strongThis = weakThis.lock();
110
- if (!strongThis) {
111
- return;
112
- }
113
-
114
- const auto &transition = strongThis->registry_[viewTag];
115
- const auto allowedProperties = transition->getAllowedProperties(oldProps, newProps);
116
-
117
- const auto changedProps = getChangedProps(oldProps, newProps, allowedProperties);
85
+ CSSTransitionsRegistry::TransitionObserver::TransitionObserver(CSSTransitionsRegistry &owner) : owner_(owner) {}
118
86
 
119
- if (changedProps.changedPropertyNames.empty()) {
120
- return;
121
- }
122
-
123
- {
124
- std::lock_guard<std::mutex> lock{strongThis->mutex_};
87
+ void CSSTransitionsRegistry::TransitionObserver::onTransitionUpdate(const Tag viewTag) {
88
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
89
+ owner_.updatedTags_.insert(viewTag);
90
+ }
125
91
 
126
- const auto &shadowNode = transition->getShadowNode();
127
- const auto &lastUpdates = strongThis->getUpdatesFromRegistry(shadowNode->getTag());
128
- const auto &transitionStartStyle = transition->run(changedProps, lastUpdates, strongThis->getCurrentTimestamp_());
129
- strongThis->updateInUpdatesRegistry(transition, transitionStartStyle);
130
- strongThis->scheduleOrActivateTransition(transition);
131
- }
132
- };
92
+ void CSSTransitionsRegistry::removeTag(const Tag viewTag) {
93
+ const auto it = registry_.find(viewTag);
94
+ if (it != registry_.end()) {
95
+ it->second->cancel();
96
+ }
97
+ removeFromUpdatesRegistry(viewTag);
98
+ registry_.erase(viewTag);
133
99
  }
134
100
 
135
101
  void CSSTransitionsRegistry::updateInUpdatesRegistry(
@@ -141,17 +107,10 @@ void CSSTransitionsRegistry::updateInUpdatesRegistry(
141
107
 
142
108
  folly::dynamic filteredUpdates = folly::dynamic::object;
143
109
 
144
- if (!transitionProperties.has_value()) {
145
- // If transitionProperty is set to 'all' (optional has no value), we have
146
- // to keep the result of the previous transition updated with the new
147
- // transition starting values
148
- if (!lastUpdates.empty()) {
149
- filteredUpdates = lastUpdates;
150
- }
151
- } else if (!lastUpdates.empty()) {
110
+ if (!lastUpdates.empty()) {
152
111
  // Otherwise, we keep only allowed properties from the last updates
153
112
  // and update the object with the new transition starting values
154
- for (const auto &prop : transitionProperties.value()) {
113
+ for (const auto &prop : transitionProperties) {
155
114
  if (lastUpdates.count(prop)) {
156
115
  filteredUpdates[prop] = lastUpdates[prop];
157
116
  }
@@ -161,7 +120,29 @@ void CSSTransitionsRegistry::updateInUpdatesRegistry(
161
120
  // updated object contains only allowed properties so we don't need
162
121
  // to do additional filtering here
163
122
  filteredUpdates.update(updates);
164
- setInUpdatesRegistry(shadowNode, filteredUpdates);
123
+ setInUpdatesRegistry(shadowNode->getFamilyShared(), filteredUpdates);
124
+ }
125
+
126
+ const std::shared_ptr<CSSTransition> &CSSTransitionsRegistry::getOrCreateTransition(
127
+ const std::shared_ptr<const ShadowNode> &shadowNode) {
128
+ const auto viewTag = shadowNode->getTag();
129
+ if (!registry_.contains(viewTag)) {
130
+ registry_.emplace(
131
+ viewTag,
132
+ std::make_shared<CSSTransition>(
133
+ shadowNode, viewStylesRepository_, platformTransitionProxy_, loop_, transitionObserver_));
134
+ }
135
+ return registry_.at(viewTag);
136
+ }
137
+
138
+ void CSSTransitionsRegistry::recordInitialUpdate(
139
+ const std::shared_ptr<CSSTransition> &transition,
140
+ const folly::dynamic &initialUpdate) {
141
+ if (initialUpdate.empty()) {
142
+ return;
143
+ }
144
+ updateInUpdatesRegistry(transition, initialUpdate);
145
+ updatedTags_.insert(transition->getViewTag());
165
146
  }
166
147
 
167
148
  } // namespace reanimated::css
@@ -1,51 +1,64 @@
1
1
  #pragma once
2
2
 
3
- #include <reanimated/CSS/core/CSSTransition.h>
4
- #include <reanimated/CSS/registries/StaticPropsRegistry.h>
5
- #include <reanimated/CSS/utils/DelayedItemsManager.h>
6
- #include <reanimated/CSS/utils/props.h>
3
+ #include <reanimated/CSS/configs/CSSTransitionConfig.h>
4
+ #include <reanimated/CSS/core/transition/CSSTransition.h>
5
+ #include <reanimated/CSS/misc/ViewStylesRepository.h>
6
+ #include <reanimated/Fabric/updates/OperationsLoop.h>
7
7
  #include <reanimated/Fabric/updates/UpdatesRegistry.h>
8
- #include <reanimated/Tools/PlatformDepMethodsHolder.h>
9
8
 
10
9
  #include <memory>
11
- #include <set>
12
10
  #include <unordered_map>
13
11
  #include <unordered_set>
14
- #include <utility>
15
- #include <vector>
16
12
 
17
13
  namespace reanimated::css {
18
14
 
19
- class CSSTransitionsRegistry : public UpdatesRegistry, public std::enable_shared_from_this<CSSTransitionsRegistry> {
15
+ class CSSTransitionsRegistry : public UpdatesRegistry {
20
16
  public:
21
17
  CSSTransitionsRegistry(
22
- const std::shared_ptr<StaticPropsRegistry> &staticPropsRegistry,
23
- const GetAnimationTimestampFunction &getCurrentTimestamp);
18
+ const std::shared_ptr<ViewStylesRepository> &viewStylesRepository,
19
+ const std::shared_ptr<OperationsLoop> &loop,
20
+ const std::shared_ptr<CSSPlatformTransitionProxy> &platformTransitionProxy);
24
21
 
25
- bool isEmpty() const override;
26
- bool hasUpdates() const;
22
+ bool needsFlush() const;
27
23
 
28
- void add(const std::shared_ptr<CSSTransition> &transition);
29
- void updateSettings(Tag viewTag, const PartialCSSTransitionConfig &config);
30
- void remove(Tag viewTag) override;
24
+ // TODO: In the future we want to decouple config update and run
25
+ void updateConfigOrRun(
26
+ jsi::Runtime &rt,
27
+ const std::shared_ptr<const ShadowNode> &shadowNode,
28
+ CSSTransitionConfig &&config);
29
+ void run(const std::shared_ptr<const ShadowNode> &shadowNode, const PropertyValueDynamicDiffsMap &propertyDiffs);
31
30
 
32
- void update(double timestamp);
31
+ void flushUpdates(UpdatesBatch &updatesBatch);
32
+ #if REACT_NATIVE_VERSION_MINOR >= 85
33
+ void flushUpdates(UpdatesBatchAnimatedProps &updatesBatch);
34
+ #endif
33
35
 
34
36
  private:
35
37
  using Registry = std::unordered_map<Tag, std::shared_ptr<CSSTransition>>;
36
38
 
37
- const GetAnimationTimestampFunction &getCurrentTimestamp_;
38
- const std::shared_ptr<StaticPropsRegistry> staticPropsRegistry_;
39
+ class TransitionObserver : public CSSTransition::Observer {
40
+ public:
41
+ explicit TransitionObserver(CSSTransitionsRegistry &owner);
42
+ void onTransitionUpdate(Tag viewTag) override;
39
43
 
40
- Registry registry_;
44
+ private:
45
+ CSSTransitionsRegistry &owner_;
46
+ };
47
+
48
+ const std::shared_ptr<ViewStylesRepository> viewStylesRepository_;
49
+ const std::shared_ptr<OperationsLoop> loop_;
50
+ const std::shared_ptr<CSSPlatformTransitionProxy> platformTransitionProxy_;
41
51
 
42
- std::unordered_set<Tag> runningTransitionTags_;
43
- DelayedItemsManager<Tag> delayedTransitionsManager_;
52
+ TransitionObserver transitionObserver_{*this};
53
+
54
+ Registry registry_;
55
+ // Tags reported by owned transitions between flushes.
56
+ std::unordered_set<Tag> updatedTags_;
44
57
 
45
- void activateDelayedTransitions(double timestamp);
46
- void scheduleOrActivateTransition(const std::shared_ptr<CSSTransition> &transition);
47
- PropsObserver createPropsObserver(Tag viewTag);
58
+ void removeTag(Tag viewTag) override;
59
+ const std::shared_ptr<CSSTransition> &getOrCreateTransition(const std::shared_ptr<const ShadowNode> &shadowNode);
48
60
  void updateInUpdatesRegistry(const std::shared_ptr<CSSTransition> &transition, const folly::dynamic &updates);
61
+ void recordInitialUpdate(const std::shared_ptr<CSSTransition> &transition, const folly::dynamic &initialUpdate);
49
62
  };
50
63
 
51
64
  } // namespace reanimated::css
@@ -1,22 +1,21 @@
1
1
  #include <reanimated/CSS/registries/StaticPropsRegistry.h>
2
+ #include <reanimated/Fabric/updates/UpdatesRegistryManager.h>
2
3
 
3
- #include <utility>
4
+ #include <react/debug/react_native_assert.h>
4
5
 
5
6
  namespace reanimated::css {
6
7
 
7
8
  void StaticPropsRegistry::set(jsi::Runtime &rt, const Tag viewTag, const jsi::Value &props) {
9
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
8
10
  if (props.isNull() || props.isUndefined()) {
9
- remove(viewTag);
11
+ registry_.erase(viewTag);
10
12
  } else {
11
- const auto newProps = dynamicFromValue(rt, props);
12
- if (has(viewTag)) {
13
- notifyObservers(viewTag, get(viewTag), newProps);
14
- }
15
- registry_[viewTag] = newProps;
13
+ registry_[viewTag] = dynamicFromValue(rt, props);
16
14
  }
17
15
  }
18
16
 
19
17
  folly::dynamic StaticPropsRegistry::get(const Tag viewTag) const {
18
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
20
19
  auto it = registry_.find(viewTag);
21
20
  if (it == registry_.end()) {
22
21
  return nullptr;
@@ -24,38 +23,14 @@ folly::dynamic StaticPropsRegistry::get(const Tag viewTag) const {
24
23
  return it->second;
25
24
  }
26
25
 
27
- bool StaticPropsRegistry::has(const Tag viewTag) const {
28
- return registry_.find(viewTag) != registry_.end();
29
- }
30
-
31
26
  void StaticPropsRegistry::remove(const Tag viewTag) {
27
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
32
28
  registry_.erase(viewTag);
33
29
  }
34
30
 
35
31
  bool StaticPropsRegistry::isEmpty() const {
36
- return registry_.empty() && observers_.empty();
37
- }
38
-
39
- bool StaticPropsRegistry::hasObservers(const Tag viewTag) const {
40
- return observers_.find(viewTag) != observers_.end();
41
- }
42
-
43
- void StaticPropsRegistry::setObserver(const Tag viewTag, PropsObserver observer) {
44
- observers_[viewTag] = std::move(observer);
45
- }
46
-
47
- void StaticPropsRegistry::removeObserver(const Tag viewTag) {
48
- observers_.erase(viewTag);
49
- }
50
-
51
- void StaticPropsRegistry::notifyObservers(
52
- const Tag viewTag,
53
- const folly::dynamic &oldProps,
54
- const folly::dynamic &newProps) {
55
- auto observerIt = observers_.find(viewTag);
56
- if (observerIt != observers_.end()) {
57
- observerIt->second(oldProps, newProps);
58
- }
32
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
33
+ return registry_.empty();
59
34
  }
60
35
 
61
36
  } // namespace reanimated::css