@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
@@ -0,0 +1,100 @@
1
+ #include <reanimated/CSS/core/CSSLoopAnimation.h>
2
+
3
+ #include <memory>
4
+
5
+ namespace reanimated::css {
6
+
7
+ CSSLoopAnimation::CSSLoopAnimation(
8
+ const Tag viewTag,
9
+ const std::shared_ptr<AnimationStyleInterpolator> &interpolator,
10
+ const std::shared_ptr<CSSAnimationSettings> &settings,
11
+ const std::shared_ptr<KeyframeEasingConfigs> &keyframeEasingConfigs,
12
+ CSSAnimation::Observer &observer,
13
+ const double timestamp)
14
+ : viewTag_(viewTag),
15
+ settings_(settings),
16
+ interpolator_(interpolator),
17
+ progressProvider_(std::make_shared<AnimationProgressProvider>(
18
+ timestamp,
19
+ settings->duration,
20
+ settings->delay,
21
+ settings->iterationCount,
22
+ settings->direction,
23
+ getEasingFunctionFromConfig(settings->easingConfig),
24
+ keyframeEasingConfigs)),
25
+ observer_(observer) {
26
+ if (settings->playState == AnimationPlayState::Paused) {
27
+ progressProvider_->pause(timestamp);
28
+ }
29
+ }
30
+
31
+ folly::dynamic CSSLoopAnimation::getCurrentInterpolationStyle(
32
+ const std::shared_ptr<const ShadowNode> &shadowNode) const {
33
+ return interpolator_->interpolate(shadowNode, progressProvider_, FALLBACK_INTERPOLATION_THRESHOLD);
34
+ }
35
+
36
+ bool CSSLoopAnimation::update(const double timestamp, OperationsLoop & /*loop*/) {
37
+ progressProvider_->update(timestamp);
38
+ observer_.onAnimationUpdate(viewTag_);
39
+
40
+ if (progressProvider_->getState() == AnimationProgressState::Finished && !settings_->hasForwardsFillMode()) {
41
+ observer_.onAnimationNeedsRevert(viewTag_);
42
+ }
43
+
44
+ return progressProvider_->getState() == AnimationProgressState::Running;
45
+ }
46
+
47
+ void CSSLoopAnimation::schedule(OperationsLoop &loop) {
48
+ if (progressProvider_->getState() != AnimationProgressState::Paused) {
49
+ const auto timestamp = loop.resolveTimestamp();
50
+ loop.schedule(shared_from_this(), progressProvider_->getStartTimestamp(timestamp));
51
+ }
52
+ }
53
+
54
+ void CSSLoopAnimation::unschedule(OperationsLoop &loop) {
55
+ loop.remove(shared_from_this());
56
+ }
57
+
58
+ void CSSLoopAnimation::setAnimatedProperties(const std::unordered_set<std::string> &loopDrivenProperties) {
59
+ interpolator_->setActiveProperties(loopDrivenProperties);
60
+ }
61
+
62
+ void CSSLoopAnimation::updateSettings(const PartialCSSAnimationSettings &updatedSettings, const double timestamp) {
63
+ progressProvider_->resetProgress();
64
+
65
+ if (updatedSettings.duration.has_value()) {
66
+ settings_->duration = updatedSettings.duration.value();
67
+ progressProvider_->setDuration(updatedSettings.duration.value());
68
+ }
69
+ if (updatedSettings.easingConfig.has_value()) {
70
+ settings_->easingConfig = updatedSettings.easingConfig.value();
71
+ progressProvider_->setEasingFunction(getEasingFunctionFromConfig(updatedSettings.easingConfig.value()));
72
+ }
73
+ if (updatedSettings.delay.has_value()) {
74
+ settings_->delay = updatedSettings.delay.value();
75
+ progressProvider_->setDelay(updatedSettings.delay.value());
76
+ }
77
+ if (updatedSettings.iterationCount.has_value()) {
78
+ settings_->iterationCount = updatedSettings.iterationCount.value();
79
+ progressProvider_->setIterationCount(updatedSettings.iterationCount.value());
80
+ }
81
+ if (updatedSettings.direction.has_value()) {
82
+ settings_->direction = updatedSettings.direction.value();
83
+ progressProvider_->setDirection(updatedSettings.direction.value());
84
+ }
85
+ if (updatedSettings.fillMode.has_value()) {
86
+ settings_->fillMode = updatedSettings.fillMode.value();
87
+ }
88
+ if (updatedSettings.playState.has_value()) {
89
+ settings_->playState = updatedSettings.playState.value();
90
+ if (updatedSettings.playState.value() == AnimationPlayState::Paused) {
91
+ progressProvider_->pause(timestamp);
92
+ } else {
93
+ progressProvider_->play(timestamp);
94
+ }
95
+ }
96
+
97
+ progressProvider_->update(timestamp);
98
+ }
99
+
100
+ } // namespace reanimated::css
@@ -0,0 +1,49 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/configs/CSSAnimationConfig.h>
4
+ #include <reanimated/CSS/core/CSSAnimation.h>
5
+ #include <reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h>
6
+ #include <reanimated/CSS/progress/AnimationProgressProvider.h>
7
+ #include <reanimated/Fabric/updates/OperationsLoop.h>
8
+
9
+ #include <memory>
10
+ #include <string>
11
+ #include <unordered_set>
12
+
13
+ namespace reanimated::css {
14
+
15
+ class CSSLoopAnimation : public OperationsLoop::LoopOperation, public std::enable_shared_from_this<CSSLoopAnimation> {
16
+ public:
17
+ CSSLoopAnimation(
18
+ Tag viewTag,
19
+ const std::shared_ptr<AnimationStyleInterpolator> &interpolator,
20
+ const std::shared_ptr<CSSAnimationSettings> &settings,
21
+ const std::shared_ptr<KeyframeEasingConfigs> &keyframeEasingConfigs,
22
+ CSSAnimation::Observer &observer,
23
+ double timestamp);
24
+
25
+ AnimationProgressState getState() const {
26
+ return progressProvider_->getState();
27
+ }
28
+
29
+ folly::dynamic getCurrentInterpolationStyle(const std::shared_ptr<const ShadowNode> &shadowNode) const;
30
+
31
+ bool update(double timestamp, OperationsLoop &loop) override;
32
+
33
+ void schedule(OperationsLoop &loop);
34
+ void unschedule(OperationsLoop &loop);
35
+
36
+ void setAnimatedProperties(const std::unordered_set<std::string> &loopDrivenProperties);
37
+ void updateSettings(const PartialCSSAnimationSettings &updatedSettings, double timestamp);
38
+
39
+ private:
40
+ static constexpr double FALLBACK_INTERPOLATION_THRESHOLD = 0.5;
41
+
42
+ const Tag viewTag_;
43
+ const std::shared_ptr<CSSAnimationSettings> settings_;
44
+ const std::shared_ptr<AnimationStyleInterpolator> interpolator_;
45
+ const std::shared_ptr<AnimationProgressProvider> progressProvider_;
46
+ CSSAnimation::Observer &observer_;
47
+ };
48
+
49
+ } // namespace reanimated::css
@@ -0,0 +1,13 @@
1
+ #pragma once
2
+
3
+ namespace reanimated::css {
4
+
5
+ class CSSPlatformAnimation {
6
+ public:
7
+ virtual ~CSSPlatformAnimation() = default;
8
+
9
+ virtual void schedule(double startTimestamp) = 0;
10
+ virtual void unschedule() = 0;
11
+ };
12
+
13
+ } // namespace reanimated::css
@@ -0,0 +1,32 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/configs/CSSAnimationConfig.h>
4
+ #include <reanimated/CSS/configs/CSSKeyframesConfig.h>
5
+ #include <reanimated/CSS/core/CSSPlatformAnimation.h>
6
+
7
+ #include <react/renderer/core/ReactPrimitives.h>
8
+
9
+ #include <memory>
10
+ #include <string>
11
+ #include <unordered_set>
12
+
13
+ namespace reanimated::css {
14
+
15
+ struct PlatformRoutingResult {
16
+ std::shared_ptr<CSSPlatformAnimation> animation;
17
+ std::unordered_set<std::string> remainingProperties;
18
+ };
19
+
20
+ class CSSPlatformAnimationFactory {
21
+ public:
22
+ virtual ~CSSPlatformAnimationFactory() = default;
23
+
24
+ virtual PlatformRoutingResult resolve(
25
+ Tag viewTag,
26
+ const std::string &animationName,
27
+ const std::unordered_set<std::string> &allProperties,
28
+ const CSSKeyframesConfig &keyframesConfig,
29
+ const std::shared_ptr<CSSAnimationSettings> &settings) = 0;
30
+ };
31
+
32
+ } // namespace reanimated::css
@@ -0,0 +1,156 @@
1
+ #include <reanimated/CSS/core/transition/CSSLoopTransition.h>
2
+
3
+ #include <jsi/JSIDynamic.h>
4
+
5
+ #include <memory>
6
+ #include <string>
7
+ #include <utility>
8
+ #include <vector>
9
+
10
+ namespace reanimated::css {
11
+
12
+ CSSLoopTransition::CSSLoopTransition(
13
+ const Tag viewTag,
14
+ const std::string &componentName,
15
+ const std::shared_ptr<ViewStylesRepository> &viewStylesRepository,
16
+ OnUpdateCallback onUpdate)
17
+ : viewTag_(viewTag),
18
+ componentName_(componentName),
19
+ onUpdate_(std::move(onUpdate)),
20
+ styleInterpolator_(TransitionStyleInterpolator(componentName_, viewStylesRepository)),
21
+ progressProvider_(TransitionProgressProvider()) {}
22
+
23
+ double CSSLoopTransition::getMinDelay(double timestamp) const {
24
+ return progressProvider_.getMinDelay(timestamp);
25
+ }
26
+
27
+ bool CSSLoopTransition::update(const double timestamp, OperationsLoop &loop) {
28
+ progressProvider_.update(timestamp);
29
+ onUpdate_(viewTag_);
30
+
31
+ if (progressProvider_.getState() == TransitionProgressState::Pending) {
32
+ loop.schedule(shared_from_this(), timestamp + progressProvider_.getMinDelay(timestamp));
33
+ }
34
+
35
+ return progressProvider_.getState() == TransitionProgressState::Running;
36
+ }
37
+
38
+ folly::dynamic CSSLoopTransition::run(
39
+ jsi::Runtime &rt,
40
+ const std::shared_ptr<const ShadowNode> &shadowNode,
41
+ const PropertyValueDiffsMap &propertiesDiffs,
42
+ const folly::dynamic &lastUpdateValue,
43
+ const double timestamp) {
44
+ // Update interpolators and progress providers for changed properties
45
+ handleChangedProperties(
46
+ rt, propertiesDiffs, lastUpdateValue.empty() ? folly::dynamic::object() : lastUpdateValue, timestamp);
47
+ // Advance progress and return the first transition frame
48
+ progressProvider_.update(timestamp);
49
+ return computeCurrentStyle(shadowNode);
50
+ }
51
+
52
+ folly::dynamic CSSLoopTransition::run(
53
+ const std::shared_ptr<const ShadowNode> &shadowNode,
54
+ const PropertyValueDynamicDiffsMap &propertiesDiffs,
55
+ const folly::dynamic &lastUpdateValue,
56
+ const double timestamp) {
57
+ handleChangedProperties(
58
+ propertiesDiffs, lastUpdateValue.empty() ? folly::dynamic::object() : lastUpdateValue, timestamp);
59
+ progressProvider_.update(timestamp);
60
+ return computeCurrentStyle(shadowNode);
61
+ }
62
+
63
+ void CSSLoopTransition::updateSettings(
64
+ const PropertiesSettingsMap &changedPropertiesSettings,
65
+ const std::vector<std::string> &removedProperties) {
66
+
67
+ // Remove interpolators and progress providers for no longer transitioned props
68
+ removeProperties(removedProperties);
69
+
70
+ // Update the settings saved in progress provider
71
+ progressProvider_.setPropertySettings(changedPropertiesSettings);
72
+ }
73
+
74
+ folly::dynamic CSSLoopTransition::computeCurrentStyle(const std::shared_ptr<const ShadowNode> &shadowNode) {
75
+ auto result = styleInterpolator_.interpolate(shadowNode, progressProvider_);
76
+ // Remove interpolators for which interpolation has finished
77
+ // (we won't need them anymore in the current transition)
78
+ styleInterpolator_.discardFinishedInterpolators(progressProvider_);
79
+ // And remove finished progress providers after they were used to calculate
80
+ // the last frame of the transition
81
+ progressProvider_.discardFinishedProgressProviders();
82
+ return result;
83
+ }
84
+
85
+ void CSSLoopTransition::handleChangedProperties(
86
+ jsi::Runtime &rt,
87
+ const PropertyValueDiffsMap &propertiesDiffs,
88
+ const folly::dynamic &lastUpdateValue,
89
+ const double timestamp) {
90
+ const auto null = folly::dynamic();
91
+
92
+ for (const auto &[propertyName, propertyDiff] : propertiesDiffs) {
93
+ const auto allowDiscrete = progressProvider_.getPropertySettings(propertyName).allowDiscrete;
94
+
95
+ if (!allowDiscrete && isDiscreteProperty(propertyName, componentName_)) {
96
+ removeProperty(propertyName);
97
+ continue;
98
+ }
99
+
100
+ // Update the transition style interpolator
101
+ bool isReversed;
102
+ if (lastUpdateValue.count(propertyName)) {
103
+ // TODO - get rid of lastValue dynamic in the future
104
+ isReversed = styleInterpolator_.createOrUpdateInterpolator(
105
+ rt, propertyName, jsi::valueFromDynamic(rt, lastUpdateValue.at(propertyName)), propertyDiff.second);
106
+ } else {
107
+ isReversed =
108
+ styleInterpolator_.createOrUpdateInterpolator(rt, propertyName, propertyDiff.first, propertyDiff.second);
109
+ }
110
+
111
+ // We still pass allowDiscrete to use correct threshold for interpolation between incompatible values
112
+ // (e.g. when someone passes a keyword and a numeric value - in this case we interpolate them as discrete values)
113
+ styleInterpolator_.setAllowDiscrete(propertyName, allowDiscrete);
114
+
115
+ // Update the transition progress provider
116
+ progressProvider_.runProgressProvider(propertyName, isReversed, timestamp);
117
+ }
118
+ }
119
+
120
+ void CSSLoopTransition::handleChangedProperties(
121
+ const PropertyValueDynamicDiffsMap &propertiesDiffs,
122
+ const folly::dynamic &lastUpdateValue,
123
+ const double timestamp) {
124
+ for (const auto &[propertyName, propertyDiff] : propertiesDiffs) {
125
+ const auto allowDiscrete = progressProvider_.getPropertySettings(propertyName).allowDiscrete;
126
+
127
+ if (!allowDiscrete && isDiscreteProperty(propertyName, componentName_)) {
128
+ removeProperty(propertyName);
129
+ continue;
130
+ }
131
+
132
+ bool isReversed;
133
+ if (lastUpdateValue.count(propertyName)) {
134
+ isReversed = styleInterpolator_.createOrUpdateInterpolator(
135
+ propertyName, lastUpdateValue.at(propertyName), propertyDiff.second);
136
+ } else {
137
+ isReversed = styleInterpolator_.createOrUpdateInterpolator(propertyName, propertyDiff.first, propertyDiff.second);
138
+ }
139
+
140
+ styleInterpolator_.setAllowDiscrete(propertyName, allowDiscrete);
141
+
142
+ progressProvider_.runProgressProvider(propertyName, isReversed, timestamp);
143
+ }
144
+ }
145
+
146
+ void CSSLoopTransition::removeProperties(const std::vector<std::string> &propertyNames) {
147
+ styleInterpolator_.removeProperties(propertyNames);
148
+ progressProvider_.removeProperties(propertyNames);
149
+ }
150
+
151
+ void CSSLoopTransition::removeProperty(const std::string &propertyName) {
152
+ styleInterpolator_.removeProperty(propertyName);
153
+ progressProvider_.removeProperty(propertyName);
154
+ }
155
+
156
+ } // namespace reanimated::css
@@ -0,0 +1,71 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/configs/CSSTransitionConfig.h>
4
+ #include <reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h>
5
+ #include <reanimated/CSS/progress/TransitionProgressProvider.h>
6
+ #include <reanimated/Fabric/updates/OperationsLoop.h>
7
+
8
+ #include <folly/dynamic.h>
9
+ #include <jsi/jsi.h>
10
+ #include <functional>
11
+ #include <memory>
12
+ #include <string>
13
+ #include <vector>
14
+
15
+ namespace reanimated::css {
16
+
17
+ class CSSLoopTransition : public OperationsLoop::LoopOperation, public std::enable_shared_from_this<CSSLoopTransition> {
18
+ public:
19
+ using OnUpdateCallback = std::function<void(Tag)>;
20
+
21
+ CSSLoopTransition(
22
+ Tag viewTag,
23
+ const std::string &componentName,
24
+ const std::shared_ptr<ViewStylesRepository> &viewStylesRepository,
25
+ OnUpdateCallback onUpdate);
26
+
27
+ double getMinDelay(double timestamp) const;
28
+
29
+ bool update(double timestamp, OperationsLoop &loop) override;
30
+
31
+ folly::dynamic run(
32
+ jsi::Runtime &rt,
33
+ const std::shared_ptr<const ShadowNode> &shadowNode,
34
+ const PropertyValueDiffsMap &propertiesDiffs,
35
+ const folly::dynamic &lastUpdateValue,
36
+ double timestamp);
37
+ /** TODO: unify folly::dynamic and jsi::value versions */
38
+ folly::dynamic run(
39
+ const std::shared_ptr<const ShadowNode> &shadowNode,
40
+ const PropertyValueDynamicDiffsMap &propertiesDiffs,
41
+ const folly::dynamic &lastUpdateValue,
42
+ double timestamp);
43
+ void updateSettings(
44
+ const PropertiesSettingsMap &changedPropertiesSettings,
45
+ const std::vector<std::string> &removedProperties);
46
+
47
+ folly::dynamic computeCurrentStyle(const std::shared_ptr<const ShadowNode> &shadowNode);
48
+
49
+ private:
50
+ const Tag viewTag_;
51
+ const std::string componentName_;
52
+ OnUpdateCallback onUpdate_;
53
+
54
+ TransitionStyleInterpolator styleInterpolator_;
55
+ TransitionProgressProvider progressProvider_;
56
+
57
+ void handleChangedProperties(
58
+ jsi::Runtime &rt,
59
+ const PropertyValueDiffsMap &propertiesDiffs,
60
+ const folly::dynamic &lastUpdateValue,
61
+ double timestamp);
62
+ /** TODO: unify folly::dynamic and jsi::value versions */
63
+ void handleChangedProperties(
64
+ const PropertyValueDynamicDiffsMap &propertiesDiffs,
65
+ const folly::dynamic &lastUpdateValue,
66
+ double timestamp);
67
+ void removeProperties(const std::vector<std::string> &propertyNames);
68
+ void removeProperty(const std::string &propertyName);
69
+ };
70
+
71
+ } // namespace reanimated::css
@@ -0,0 +1,141 @@
1
+ #include <reanimated/CSS/core/transition/CSSPlatformTransitionProxy.h>
2
+
3
+ #include <react/debug/react_native_assert.h>
4
+
5
+ #include <utility>
6
+
7
+ namespace reanimated::css {
8
+
9
+ CSSPlatformTransitionProxy::CSSPlatformTransitionProxy(
10
+ CSSCanRoutePropertyFunction canRoute,
11
+ CSSApplyTransitionJSIFunction applyJSI,
12
+ CSSApplyTransitionDynamicFunction applyDynamic,
13
+ CSSRemoveTransitionFunction removeTransition)
14
+ : canRoute_(std::move(canRoute)),
15
+ applyJSI_(std::move(applyJSI)),
16
+ applyDynamic_(std::move(applyDynamic)),
17
+ removeTransition_(std::move(removeTransition)) {}
18
+
19
+ bool CSSPlatformTransitionProxy::canRoute(const std::string &propertyName, const EasingConfig &easing) const {
20
+ return canRoute_ && canRoute_(propertyName, easing);
21
+ }
22
+
23
+ bool CSSPlatformTransitionProxy::apply(
24
+ jsi::Runtime &rt,
25
+ const Tag viewTag,
26
+ const std::string &propertyName,
27
+ const jsi::Value &fromValue,
28
+ const jsi::Value &toValue,
29
+ const CSSTransitionPropertySettings &settings,
30
+ const double timestamp) const {
31
+ return applyJSI_ && applyJSI_(rt, viewTag, propertyName, fromValue, toValue, settings, timestamp);
32
+ }
33
+
34
+ bool CSSPlatformTransitionProxy::apply(
35
+ const Tag viewTag,
36
+ const std::string &propertyName,
37
+ const folly::dynamic &fromValue,
38
+ const folly::dynamic &toValue,
39
+ const double timestamp) const {
40
+ return applyDynamic_ && applyDynamic_(viewTag, propertyName, fromValue, toValue, timestamp);
41
+ }
42
+
43
+ void CSSPlatformTransitionProxy::remove(const Tag viewTag, const std::string &propertyName) const {
44
+ if (removeTransition_) {
45
+ removeTransition_(viewTag, propertyName);
46
+ }
47
+ }
48
+
49
+ CSSTransitionConfig CSSPlatformTransitionProxy::processConfig(
50
+ jsi::Runtime &rt,
51
+ const Tag viewTag,
52
+ const CSSTransitionConfig &config,
53
+ CSSTransitionRouting &routing,
54
+ const double timestamp) const {
55
+ CSSTransitionConfig loopConfig;
56
+ #ifndef NDEBUG
57
+ size_t matchedValues = 0;
58
+ #endif // NDEBUG
59
+
60
+ for (const auto &[propertyName, settings] : config.changedPropertiesSettings) {
61
+ const auto valueIt = config.changedProperties.find(propertyName);
62
+ const bool hasValue = valueIt != config.changedProperties.end();
63
+ #ifndef NDEBUG
64
+ if (hasValue) {
65
+ ++matchedValues;
66
+ }
67
+ #endif // NDEBUG
68
+
69
+ bool routable = canRoute(propertyName, settings.easingConfig);
70
+ if (routable && hasValue) {
71
+ routable = apply(rt, viewTag, propertyName, valueIt->second.first, valueIt->second.second, settings, timestamp);
72
+ } else if (routable) {
73
+ // Settings-only: stay on the platform only if already animating there.
74
+ routable = routing.platform.contains(propertyName);
75
+ }
76
+
77
+ if (routable) {
78
+ // loop -> platform migration cancels on the loop side.
79
+ if (routing.loop.erase(propertyName) > 0) {
80
+ loopConfig.removedProperties.push_back(propertyName);
81
+ }
82
+ routing.platform.insert(propertyName);
83
+ } else {
84
+ // platform -> loop migration cancels on the platform side.
85
+ if (routing.platform.erase(propertyName) > 0) {
86
+ remove(viewTag, propertyName);
87
+ }
88
+ routing.loop.insert(propertyName);
89
+ if (hasValue) {
90
+ loopConfig.changedProperties.emplace(
91
+ propertyName,
92
+ std::make_pair(jsi::Value(rt, valueIt->second.first), jsi::Value(rt, valueIt->second.second)));
93
+ }
94
+ loopConfig.changedPropertiesSettings.emplace(propertyName, settings);
95
+ }
96
+ }
97
+
98
+ // The parser pairs every value diff with settings, so all must have matched one.
99
+ react_native_assert(
100
+ matchedValues == config.changedProperties.size() && "[Reanimated] CSS transition value diff without settings");
101
+
102
+ for (const auto &propertyName : config.removedProperties) {
103
+ if (routing.platform.erase(propertyName) > 0) {
104
+ remove(viewTag, propertyName);
105
+ } else if (routing.loop.erase(propertyName) > 0) {
106
+ loopConfig.removedProperties.push_back(propertyName);
107
+ }
108
+ }
109
+
110
+ return loopConfig;
111
+ }
112
+
113
+ PropertyValueDynamicDiffsMap CSSPlatformTransitionProxy::processDynamicDiffs(
114
+ const Tag viewTag,
115
+ const PropertyValueDynamicDiffsMap &propertyDiffs,
116
+ CSSTransitionRouting &routing,
117
+ const double timestamp) const {
118
+ PropertyValueDynamicDiffsMap loopDiffs;
119
+ for (const auto &[propertyName, propertyDiff] : propertyDiffs) {
120
+ // A platform-routed property keeps animating natively while the platform can
121
+ // still express the toggled value; otherwise it migrates to the loop.
122
+ if (routing.platform.contains(propertyName)) {
123
+ if (apply(viewTag, propertyName, propertyDiff.first, propertyDiff.second, timestamp)) {
124
+ continue;
125
+ }
126
+ routing.platform.erase(propertyName);
127
+ remove(viewTag, propertyName);
128
+ routing.loop.insert(propertyName);
129
+ }
130
+ loopDiffs.emplace(propertyName, propertyDiff);
131
+ }
132
+ return loopDiffs;
133
+ }
134
+
135
+ void CSSPlatformTransitionProxy::cancelAll(const Tag viewTag, const TransitionProperties &properties) const {
136
+ for (const auto &propertyName : properties) {
137
+ remove(viewTag, propertyName);
138
+ }
139
+ }
140
+
141
+ } // namespace reanimated::css
@@ -0,0 +1,104 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/common/definitions.h>
4
+ #include <reanimated/CSS/configs/CSSTransitionConfig.h>
5
+ #include <reanimated/CSS/easing/EasingConfigs.h>
6
+
7
+ #include <folly/dynamic.h>
8
+ #include <jsi/jsi.h>
9
+ #include <react/renderer/core/ReactPrimitives.h>
10
+
11
+ #include <functional>
12
+ #include <string>
13
+
14
+ namespace reanimated::css {
15
+
16
+ using namespace facebook;
17
+ using namespace react;
18
+
19
+ /// Whether the platform can animate the property natively for the given easing.
20
+ using CSSCanRoutePropertyFunction = std::function<bool(const std::string &propertyName, const EasingConfig &easing)>;
21
+ /// Animates a routed property natively; a false (no-op) return means the platform
22
+ /// can't express the value, so it falls back to the loop. The jsi overload is the
23
+ /// config path (carries a runtime + settings); the folly overload, the toggle path.
24
+ using CSSApplyTransitionJSIFunction = std::function<bool(
25
+ jsi::Runtime &rt,
26
+ Tag viewTag,
27
+ const std::string &propertyName,
28
+ const jsi::Value &fromValue,
29
+ const jsi::Value &toValue,
30
+ const CSSTransitionPropertySettings &settings,
31
+ double timestamp)>;
32
+ using CSSApplyTransitionDynamicFunction = std::function<bool(
33
+ Tag viewTag,
34
+ const std::string &propertyName,
35
+ const folly::dynamic &fromValue,
36
+ const folly::dynamic &toValue,
37
+ double timestamp)>;
38
+ /// Cancels the property's native transition and drops its platform-side state.
39
+ using CSSRemoveTransitionFunction = std::function<void(Tag viewTag, const std::string &propertyName)>;
40
+
41
+ /// A view's transition partition: which properties animate on the platform vs the
42
+ /// C++ loop. Owned per-view by CSSTransition; updated by the proxy on migrations.
43
+ struct CSSTransitionRouting {
44
+ TransitionProperties platform;
45
+ TransitionProperties loop;
46
+ };
47
+
48
+ /// Stateless, shared routing engine: per property it routes a view's CSS transition
49
+ /// to the platform (animated natively via the hooks above) or the C++ loop, never
50
+ /// seeing the value - it forwards the raw JS source to the platform. Per-view routing
51
+ /// state is passed in; an absent hook keeps that property on the loop.
52
+ class CSSPlatformTransitionProxy {
53
+ public:
54
+ CSSPlatformTransitionProxy(
55
+ CSSCanRoutePropertyFunction canRoute,
56
+ CSSApplyTransitionJSIFunction applyJSI,
57
+ CSSApplyTransitionDynamicFunction applyDynamic,
58
+ CSSRemoveTransitionFunction removeTransition);
59
+
60
+ /// Routes the config between platform and loop, updating `routing` and returning
61
+ /// the loop-routed remainder to run.
62
+ CSSTransitionConfig processConfig(
63
+ jsi::Runtime &rt,
64
+ Tag viewTag,
65
+ const CSSTransitionConfig &config,
66
+ CSSTransitionRouting &routing,
67
+ double timestamp) const;
68
+
69
+ /// Re-routes pseudo-selector toggle diffs: a property the platform can no longer
70
+ /// express migrates to the loop. Updates `routing`, returns the loop diffs.
71
+ PropertyValueDynamicDiffsMap processDynamicDiffs(
72
+ Tag viewTag,
73
+ const PropertyValueDynamicDiffsMap &propertyDiffs,
74
+ CSSTransitionRouting &routing,
75
+ double timestamp) const;
76
+
77
+ /// Cancels the native transition of every given property (teardown).
78
+ void cancelAll(Tag viewTag, const TransitionProperties &properties) const;
79
+
80
+ private:
81
+ bool canRoute(const std::string &propertyName, const EasingConfig &easing) const;
82
+ bool apply(
83
+ jsi::Runtime &rt,
84
+ Tag viewTag,
85
+ const std::string &propertyName,
86
+ const jsi::Value &fromValue,
87
+ const jsi::Value &toValue,
88
+ const CSSTransitionPropertySettings &settings,
89
+ double timestamp) const;
90
+ bool apply(
91
+ Tag viewTag,
92
+ const std::string &propertyName,
93
+ const folly::dynamic &fromValue,
94
+ const folly::dynamic &toValue,
95
+ double timestamp) const;
96
+ void remove(Tag viewTag, const std::string &propertyName) const;
97
+
98
+ CSSCanRoutePropertyFunction canRoute_;
99
+ CSSApplyTransitionJSIFunction applyJSI_;
100
+ CSSApplyTransitionDynamicFunction applyDynamic_;
101
+ CSSRemoveTransitionFunction removeTransition_;
102
+ };
103
+
104
+ } // namespace reanimated::css