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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/CHANGELOG.md +1070 -0
  2. package/LICENSE +21 -0
  3. package/README.md +842 -0
  4. package/compatibility.json +20 -26
  5. package/harmony/reanimated/BuildProfile.ets +1 -1
  6. package/harmony/reanimated/index.ets +4 -2
  7. package/harmony/reanimated/oh-package-lock.json5 +1 -1
  8. package/harmony/reanimated/oh-package.json5 +1 -1
  9. package/harmony/reanimated/src/main/cpp/CMakeLists.txt +23 -9
  10. package/harmony/reanimated/src/main/cpp/Common/NativeView/CMakeLists.txt +56 -0
  11. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/ComponentDescriptors.h +19 -0
  12. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryComponentDescriptor.h +30 -0
  13. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.cpp +15 -0
  14. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.h +41 -0
  15. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryState.h +30 -0
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +8 -9
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +3 -6
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +203 -150
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +1 -6
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +2 -7
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +0 -1
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +2 -18
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +11 -11
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +2 -6
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +4 -1
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +5 -0
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +8 -0
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +27 -46
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +20 -20
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +2 -2
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +3 -3
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +10 -2
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +5 -3
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +20 -17
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +5 -8
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +33 -66
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +29 -22
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +14 -2
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +8 -2
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +50 -91
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +43 -18
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.cpp +63 -0
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.h +37 -0
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.cpp +100 -0
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.h +49 -0
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimation.h +13 -0
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimationFactory.h +32 -0
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.cpp +156 -0
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.h +71 -0
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.cpp +141 -0
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.h +104 -0
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.cpp +97 -0
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.h +69 -0
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.cpp +89 -0
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.h +36 -0
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +12 -0
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +11 -2
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +2 -3
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +3 -5
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +3 -3
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +1 -1
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +38 -37
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +3 -6
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +54 -32
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +5 -7
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +46 -46
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +8 -7
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +4 -57
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.cpp +23 -0
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +10 -8
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.cpp +77 -0
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.h +38 -0
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +47 -68
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +21 -9
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +4 -1
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +35 -78
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +44 -13
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +13 -11
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +4 -0
  80. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +7 -3
  81. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +20 -27
  82. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +12 -9
  83. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +63 -36
  84. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +6 -8
  85. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +55 -46
  86. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +8 -5
  87. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +1 -2
  88. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +3 -2
  89. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +76 -71
  90. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +17 -14
  91. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +145 -273
  92. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +43 -44
  93. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +19 -19
  94. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +16 -12
  95. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +95 -114
  96. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +38 -25
  97. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +9 -34
  98. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +0 -10
  99. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.cpp +47 -0
  100. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.h +24 -0
  101. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.cpp +87 -0
  102. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.h +28 -0
  103. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.cpp +326 -0
  104. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.h +65 -0
  105. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.cpp +164 -0
  106. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.h +51 -0
  107. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +14 -66
  108. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +7 -18
  109. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.cpp +284 -0
  110. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.h +31 -0
  111. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +13 -132
  112. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +3 -21
  113. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/reversingShortening.h +43 -0
  114. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Compat/WorkletsApi.h +13 -0
  115. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.cpp +33 -0
  116. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.h +39 -0
  117. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.cpp +95 -0
  118. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.h +40 -0
  119. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +20 -23
  120. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +2 -6
  121. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +26 -18
  122. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +4 -8
  123. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +16 -28
  124. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +3 -4
  125. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -24
  126. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +17 -7
  127. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.cpp +152 -0
  128. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.h +86 -0
  129. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/PropsLayoutFilter.h +98 -0
  130. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +162 -28
  131. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +69 -11
  132. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +41 -17
  133. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +14 -3
  134. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/propNameFromString.h +130 -0
  135. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +1 -0
  136. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +5 -7
  137. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +7 -4
  138. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +52 -9
  139. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +174 -62
  140. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +12 -11
  141. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +251 -128
  142. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +23 -19
  143. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +34 -6
  144. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +71 -64
  145. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +938 -700
  146. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +123 -76
  147. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.cpp +313 -0
  148. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.h +18 -0
  149. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoSelector.h +41 -0
  150. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.cpp +113 -0
  151. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.h +73 -0
  152. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +4 -4
  153. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +23 -48
  154. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +13 -14
  155. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +20 -3
  156. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReaJSIUtils.h +227 -0
  157. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +51 -14
  158. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +2 -5
  159. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/SingleInstanceChecker.h +76 -0
  160. package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.cpp +353 -0
  161. package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.h +95 -0
  162. package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.cpp +140 -0
  163. package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.h +52 -0
  164. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.cpp +45 -0
  165. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.h +33 -0
  166. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryJSIBinder.h +20 -0
  167. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +112 -19
  168. package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +4 -2
  169. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +1 -1
  170. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +1 -1
  171. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +24 -1
  172. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +7 -2
  173. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +88 -57
  174. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +4 -2
  175. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +1 -1
  176. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +1 -1
  177. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +9 -7
  178. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +6 -5
  179. package/harmony/reanimated/src/main/cpp/TransformParser.h +1 -1
  180. package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/EventEmitters.h +19 -0
  181. package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/Props.h +31 -0
  182. package/harmony/reanimated/src/main/ets/KeyboardState.ts +11 -0
  183. package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +119 -19
  184. package/harmony/reanimated/src/main/ets/{ReanimatedPackage.ts → ReanimatedPackage.ets} +4 -3
  185. package/harmony/reanimated.har +0 -0
  186. package/package.json +52 -24
  187. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +0 -145
  188. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +0 -47
  189. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +0 -93
  190. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +0 -36
  191. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +0 -75
  192. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +0 -45
  193. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +0 -183
  194. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +0 -93
  195. package/harmony/reanimated/src/main/ets/AnimationManager.ts +0 -61
  196. /package/harmony/reanimated/{ts.ts → ts.ets} +0 -0
@@ -1,7 +1,6 @@
1
1
  #include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h>
2
- #include <reanimated/NativeModules/ReanimatedModuleProxy.h>
3
2
 
4
- #include <react/renderer/animations/utils.h>
3
+ #include <react/debug/react_native_assert.h>
5
4
  #include <react/renderer/mounting/ShadowViewMutation.h>
6
5
 
7
6
  #include <memory>
@@ -39,17 +38,25 @@ std::optional<MountingTransaction> LayoutAnimationsProxy_Legacy::pullTransaction
39
38
  std::vector<std::shared_ptr<MutationNode>> roots;
40
39
  std::unordered_map<Tag, Tag> movedViews;
41
40
 
41
+ reconcileContradictedRemovals(mutations, filteredMutations, surfaceId);
42
+
42
43
  addOngoingAnimations(surfaceId, filteredMutations);
43
44
 
44
45
  #ifdef ANDROID
45
46
  restoreOpacityInCaseOfFlakyEnteringAnimation(surfaceId);
46
47
  #endif // ANDROID
47
- for (const auto tag : finishedAnimationTags_) {
48
- auto &updateMap = surfaceManager.getUpdateMap(surfaceId);
49
- layoutAnimations_.erase(tag);
48
+ auto &updateMap = surfaceManager.getUpdateMap(surfaceId);
49
+ for (const auto tag : maybeSettledAnimationTags_) {
50
+ const auto layoutAnimationIt = layoutAnimations_.find(tag);
51
+ if (layoutAnimationIt == layoutAnimations_.end() || !layoutAnimationIt->second.isSettled()) {
52
+ continue;
53
+ }
54
+ layoutAnimations_.erase(layoutAnimationIt);
50
55
  updateMap.erase(tag);
51
56
  }
52
- finishedAnimationTags_.clear();
57
+ maybeSettledAnimationTags_.clear();
58
+ // Past this point no animation can be settled - we hold the mutex for the whole
59
+ // transaction, so no end callback can run until we return.
53
60
 
54
61
  parseRemoveMutations(movedViews, mutations, roots);
55
62
 
@@ -64,6 +71,40 @@ std::optional<MountingTransaction> LayoutAnimationsProxy_Legacy::pullTransaction
64
71
  return MountingTransaction{surfaceId, transactionNumber, std::move(filteredMutations), telemetry};
65
72
  }
66
73
 
74
+ // If React re-creates or re-inserts a tag whose exiting removal we are still
75
+ // withholding, it has contradicted that withheld Remove/Delete. Flush it now
76
+ // instead of letting it fire later against a stale hierarchy (which would
77
+ // unmount the wrong, still-live view and crash the mounting layer).
78
+ //
79
+ // This must run before addOngoingAnimations (which would otherwise emit an
80
+ // Update for a tag we are about to Delete this frame) and before
81
+ // parseRemoveMutations, so the rest of the pipeline sees clean bookkeeping.
82
+ void LayoutAnimationsProxy_Legacy::reconcileContradictedRemovals(
83
+ ShadowViewMutationList &mutations,
84
+ ShadowViewMutationList &filteredMutations,
85
+ SurfaceId surfaceId) const {
86
+ auto &[deadNodes] = surfaceContext_[surfaceId];
87
+ for (auto &mutation : mutations) {
88
+ if (mutation.type != ShadowViewMutation::Type::Create && mutation.type != ShadowViewMutation::Type::Insert) {
89
+ continue;
90
+ }
91
+ auto tag = mutation.newChildShadowView.tag;
92
+ auto it = nodeForTag_.find(tag);
93
+ // Only a MutationNode represents a withheld removal; a plain Node is just a
94
+ // live parent of some removed child and must be left untouched.
95
+ if (it == nodeForTag_.end() || !it->second->isMutationNode()) {
96
+ continue;
97
+ }
98
+ auto node = std::static_pointer_cast<MutationNode>(it->second);
99
+ // Flush the withheld Remove/Delete for this tag (and its withheld subtree)
100
+ // right now, mirroring the deadNodes cleanup in handleRemovals. This removes
101
+ // the stale view before React's Create/Insert re-registers the same tag.
102
+ endAnimationsRecursively(node, filteredMutations);
103
+ maybeDropAncestors(node->unflattenedParent, node, filteredMutations);
104
+ deadNodes.erase(node);
105
+ }
106
+ }
107
+
67
108
  std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::progressLayoutAnimation(int tag, const jsi::Object &newStyle) {
68
109
  #ifdef LAYOUT_ANIMATIONS_LOGS
69
110
  LOG(INFO) << "progress layout animation for tag " << tag << std::endl;
@@ -111,11 +152,10 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::endLayoutAnimation(int ta
111
152
  // one after the other, so we need to keep count of how many
112
153
  // were actually triggered, so that we don't cleanup necessary
113
154
  // structures too early
114
- if (layoutAnimation.count > 1) {
115
- layoutAnimation.count--;
155
+ if (--layoutAnimation.count > 0) {
116
156
  return {};
117
157
  }
118
- finishedAnimationTags_.push_back(tag);
158
+ maybeSettledAnimationTags_.insert(tag);
119
159
  auto surfaceId = layoutAnimation.finalView.surfaceId;
120
160
 
121
161
  if (!shouldRemove || !nodeForTag_.contains(tag)) {
@@ -123,8 +163,12 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::endLayoutAnimation(int ta
123
163
  }
124
164
 
125
165
  auto node = nodeForTag_[tag];
166
+ if (!node->isMutationNode()) {
167
+ react_native_assert(false && "exiting tag must map to a MutationNode");
168
+ return {};
169
+ }
126
170
  auto mutationNode = std::static_pointer_cast<MutationNode>(node);
127
- mutationNode->state = DEAD;
171
+ mutationNode->state = ExitingState_Legacy::DEAD;
128
172
  auto &[deadNodes] = surfaceContext_[surfaceId];
129
173
  deadNodes.insert(mutationNode);
130
174
 
@@ -172,7 +216,7 @@ void LayoutAnimationsProxy_Legacy::parseRemoveMutations(
172
216
  }
173
217
  }
174
218
  if (!deletedViews.contains(mutation.oldChildShadowView.tag)) {
175
- mutationNode->state = MOVED;
219
+ mutationNode->state = ExitingState_Legacy::MOVED;
176
220
  movedViews.insert_or_assign(mutation.oldChildShadowView.tag, -1);
177
221
  }
178
222
  nodeForTag_[tag] = mutationNode;
@@ -245,11 +289,11 @@ void LayoutAnimationsProxy_Legacy::handleRemovals(
245
289
  if (!startAnimationsRecursively(node, true, shouldAnimate, false, filteredMutations)) {
246
290
  filteredMutations.push_back(node->mutation);
247
291
  node->unflattenedParent->removeChildFromUnflattenedTree(node); //???
248
- if (node->state != MOVED) {
292
+ if (node->state != ExitingState_Legacy::MOVED) {
249
293
  maybeCancelAnimation(node->tag);
250
294
  filteredMutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
251
295
  nodeForTag_.erase(node->tag);
252
- node->state = DELETED;
296
+ node->state = ExitingState_Legacy::DELETED;
253
297
  #ifdef LAYOUT_ANIMATIONS_LOGS
254
298
  LOG(INFO) << "delete " << node->tag << std::endl;
255
299
  #endif
@@ -258,7 +302,7 @@ void LayoutAnimationsProxy_Legacy::handleRemovals(
258
302
  }
259
303
 
260
304
  for (const auto &node : deadNodes) {
261
- if (node->state != DELETED) {
305
+ if (node->state != ExitingState_Legacy::DELETED) {
262
306
  endAnimationsRecursively(node, filteredMutations);
263
307
  maybeDropAncestors(node->unflattenedParent, node, filteredMutations);
264
308
  }
@@ -408,7 +452,13 @@ void LayoutAnimationsProxy_Legacy::addOngoingAnimations(SurfaceId surfaceId, Sha
408
452
 
409
453
  auto layoutAnimationIt = layoutAnimations_.find(tag);
410
454
 
411
- if (layoutAnimationIt == layoutAnimations_.end()) {
455
+ if (layoutAnimationIt == layoutAnimations_.end() ||
456
+ // A settled animation is normally cleaned up without applying further
457
+ // updates. The exception is a flaky entering animation whose opacity was
458
+ // never restored (the view wasn't mounted in time) - we still need to
459
+ // apply that pending opacity, otherwise the view stays invisible. Only
460
+ // entering animations carry an opacity value.
461
+ (layoutAnimationIt->second.isSettled() && !layoutAnimationIt->second.opacity.has_value())) {
412
462
  continue;
413
463
  }
414
464
 
@@ -429,12 +479,12 @@ void LayoutAnimationsProxy_Legacy::endAnimationsRecursively(
429
479
  const std::shared_ptr<MutationNode> &node,
430
480
  ShadowViewMutationList &mutations) const {
431
481
  maybeCancelAnimation(node->tag);
432
- node->state = DELETED;
482
+ node->state = ExitingState_Legacy::DELETED;
433
483
  // iterate from the end, so that children
434
484
  // with higher indices appear first in the mutations list
435
485
  for (auto it = node->unflattenedChildren.rbegin(); it != node->unflattenedChildren.rend(); it++) {
436
486
  auto &subNode = *it;
437
- if (subNode->state != DELETED) {
487
+ if (subNode->state != ExitingState_Legacy::DELETED) {
438
488
  endAnimationsRecursively(subNode, mutations);
439
489
  }
440
490
  }
@@ -457,11 +507,11 @@ void LayoutAnimationsProxy_Legacy::maybeDropAncestors(
457
507
 
458
508
  auto node = std::static_pointer_cast<MutationNode>(parent);
459
509
 
460
- if (node->children.size() == 0 && node->state != ANIMATING) {
510
+ if (node->children.size() == 0 && node->state != ExitingState_Legacy::ANIMATING) {
461
511
  nodeForTag_.erase(node->tag);
462
512
  cleanupMutations.push_back(node->mutation);
463
513
  maybeCancelAnimation(node->tag);
464
- node->state = DELETED;
514
+ node->state = ExitingState_Legacy::DELETED;
465
515
  #ifdef LAYOUT_ANIMATIONS_LOGS
466
516
  LOG(INFO) << "delete " << node->tag << std::endl;
467
517
  #endif
@@ -492,7 +542,7 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
492
542
  bool hasAnimatedChildren = false;
493
543
 
494
544
  shouldRemoveSubviewsWithoutAnimations =
495
- shouldRemoveSubviewsWithoutAnimations && (!hasExitAnimation || node->state == MOVED);
545
+ shouldRemoveSubviewsWithoutAnimations && (!hasExitAnimation || node->state == ExitingState_Legacy::MOVED);
496
546
  std::vector<std::shared_ptr<MutationNode>> toBeRemoved;
497
547
 
498
548
  // iterate from the end, so that children
@@ -503,8 +553,8 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
503
553
  LOG(INFO) << "child " << subNode->tag << " "
504
554
  << " " << shouldAnimate << " " << shouldRemoveSubviewsWithoutAnimations << std::endl;
505
555
  #endif
506
- if (subNode->state != UNDEFINED && subNode->state != MOVED) {
507
- if (shouldAnimate && subNode->state != DEAD) {
556
+ if (subNode->state != ExitingState_Legacy::UNDEFINED && subNode->state != ExitingState_Legacy::MOVED) {
557
+ if (shouldAnimate && subNode->state != ExitingState_Legacy::DEAD) {
508
558
  hasAnimatedChildren = true;
509
559
  } else {
510
560
  endAnimationsRecursively(subNode, mutations);
@@ -516,21 +566,21 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
516
566
  LOG(INFO) << "child " << subNode->tag << " start animations returned true " << std::endl;
517
567
  #endif
518
568
  hasAnimatedChildren = true;
519
- } else if (subNode->state == MOVED) {
569
+ } else if (subNode->state == ExitingState_Legacy::MOVED) {
520
570
  mutations.push_back(subNode->mutation);
521
571
  toBeRemoved.push_back(subNode);
522
572
  } else if (shouldRemoveSubviewsWithoutAnimations) {
523
573
  maybeCancelAnimation(subNode->tag);
524
574
  mutations.push_back(subNode->mutation);
525
575
  toBeRemoved.push_back(subNode);
526
- subNode->state = DELETED;
576
+ subNode->state = ExitingState_Legacy::DELETED;
527
577
  nodeForTag_.erase(subNode->tag);
528
578
  #ifdef LAYOUT_ANIMATIONS_LOGS
529
579
  LOG(INFO) << "delete " << subNode->tag << std::endl;
530
580
  #endif
531
581
  mutations.push_back(ShadowViewMutation::DeleteMutation(subNode->mutation.oldChildShadowView));
532
582
  } else {
533
- subNode->state = WAITING;
583
+ subNode->state = ExitingState_Legacy::WAITING;
534
584
  }
535
585
  }
536
586
 
@@ -538,7 +588,7 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
538
588
  node->removeChildFromUnflattenedTree(subNode);
539
589
  }
540
590
 
541
- if (node->state == MOVED) {
591
+ if (node->state == ExitingState_Legacy::MOVED) {
542
592
  auto replacement = std::make_shared<Node>(*node);
543
593
  for (const auto &subNode : node->children) {
544
594
  subNode->parent = replacement;
@@ -553,7 +603,7 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
553
603
  bool wantAnimateExit = hasExitAnimation || hasAnimatedChildren;
554
604
 
555
605
  if (hasExitAnimation) {
556
- node->state = ANIMATING;
606
+ node->state = ExitingState_Legacy::ANIMATING;
557
607
  startExitingAnimation(node->tag, node->mutation);
558
608
  } else {
559
609
  layoutAnimationsManager_->clearLayoutAnimationConfig(node->tag);
@@ -635,38 +685,60 @@ void LayoutAnimationsProxy_Legacy::startEnteringAnimation(const int tag, ShadowV
635
685
 
636
686
  auto &viewProps = static_cast<const ViewProps &>(*mutation.newChildShadowView.props);
637
687
  auto opacity = viewProps.opacity;
688
+ #ifdef ANDROID
689
+ const auto handle = pendingStarts_[tag].handle;
690
+ pendingStarts_[tag].count++;
691
+ #endif
638
692
 
639
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), finalView, current, mutation, opacity, tag]() {
640
- auto strongThis = weakThis.lock();
641
- if (!strongThis) {
642
- return;
643
- }
693
+ scheduleOnUI(
694
+ uiScheduler_,
695
+ [weakThis = weak_from_this(),
696
+ finalView,
697
+ current,
698
+ mutation,
699
+ opacity,
700
+ tag
701
+ #ifdef ANDROID
702
+ ,
703
+ handle
704
+ #endif
705
+ ]() {
706
+ auto strongThis = weakThis.lock();
707
+ if (!strongThis) {
708
+ return;
709
+ }
644
710
 
645
- Rect window{};
646
- {
647
- auto &mutex = strongThis->mutex;
648
- auto lock = std::unique_lock<std::recursive_mutex>(mutex);
649
- strongThis->layoutAnimations_.insert_or_assign(
650
- tag,
651
- LayoutAnimation{
652
- .finalView = finalView, .currentView = current, .parentTag = mutation.parentTag, .opacity = opacity});
653
- window = strongThis->surfaceManager.getWindow(mutation.newChildShadowView.surfaceId);
654
- }
711
+ Rect window{};
712
+ {
713
+ auto &mutex = strongThis->mutex;
714
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
715
+ #ifdef ANDROID
716
+ if (consumeIsCancelled(strongThis->pendingStarts_, tag, handle)) {
717
+ // the view was removed before this start could run
718
+ return;
719
+ }
720
+ #endif
721
+ strongThis->layoutAnimations_.insert_or_assign(
722
+ tag,
723
+ LayoutAnimation{
724
+ .finalView = finalView, .currentView = current, .parentTag = mutation.parentTag, .opacity = opacity});
725
+ window = strongThis->surfaceManager.getWindow(mutation.newChildShadowView.surfaceId);
726
+ }
655
727
 
656
- Snapshot values(mutation.newChildShadowView, window);
657
- auto &uiRuntime = strongThis->uiRuntime_;
658
- jsi::Object yogaValues(uiRuntime);
659
- yogaValues.setProperty(uiRuntime, "targetOriginX", values.x);
660
- yogaValues.setProperty(uiRuntime, "targetGlobalOriginX", values.x);
661
- yogaValues.setProperty(uiRuntime, "targetOriginY", values.y);
662
- yogaValues.setProperty(uiRuntime, "targetGlobalOriginY", values.y);
663
- yogaValues.setProperty(uiRuntime, "targetWidth", values.width);
664
- yogaValues.setProperty(uiRuntime, "targetHeight", values.height);
665
- yogaValues.setProperty(uiRuntime, "windowWidth", values.windowWidth);
666
- yogaValues.setProperty(uiRuntime, "windowHeight", values.windowHeight);
667
- strongThis->layoutAnimationsManager_->startLayoutAnimation(
668
- uiRuntime, tag, LayoutAnimationType::ENTERING, yogaValues);
669
- });
728
+ Snapshot values(mutation.newChildShadowView, window);
729
+ auto &uiRuntime = strongThis->uiRuntime_;
730
+ jsi::Object yogaValues(uiRuntime);
731
+ yogaValues.setProperty(uiRuntime, "targetOriginX", values.x);
732
+ yogaValues.setProperty(uiRuntime, "targetGlobalOriginX", values.x);
733
+ yogaValues.setProperty(uiRuntime, "targetOriginY", values.y);
734
+ yogaValues.setProperty(uiRuntime, "targetGlobalOriginY", values.y);
735
+ yogaValues.setProperty(uiRuntime, "targetWidth", values.width);
736
+ yogaValues.setProperty(uiRuntime, "targetHeight", values.height);
737
+ yogaValues.setProperty(uiRuntime, "windowWidth", values.windowWidth);
738
+ yogaValues.setProperty(uiRuntime, "windowHeight", values.windowHeight);
739
+ strongThis->layoutAnimationsManager_->startLayoutAnimation(
740
+ uiRuntime, tag, LayoutAnimationType::ENTERING, yogaValues);
741
+ });
670
742
  }
671
743
 
672
744
  void LayoutAnimationsProxy_Legacy::startExitingAnimation(const int tag, ShadowViewMutation &mutation) const {
@@ -674,38 +746,62 @@ void LayoutAnimationsProxy_Legacy::startExitingAnimation(const int tag, ShadowVi
674
746
  LOG(INFO) << "start exiting animation for tag " << tag << std::endl;
675
747
  #endif
676
748
  auto surfaceId = mutation.oldChildShadowView.surfaceId;
749
+ #ifdef ANDROID
750
+ const auto handle = pendingStarts_[tag].handle;
751
+ pendingStarts_[tag].count++;
752
+ #endif
677
753
 
678
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag, mutation, surfaceId]() {
679
- auto strongThis = weakThis.lock();
680
- if (!strongThis) {
681
- return;
682
- }
683
-
684
- auto oldView = mutation.oldChildShadowView;
685
- Rect window{};
686
- {
687
- auto &mutex = strongThis->mutex;
688
- auto lock = std::unique_lock<std::recursive_mutex>(mutex);
689
- strongThis->createLayoutAnimation(mutation, oldView, surfaceId, tag);
690
- window = strongThis->surfaceManager.getWindow(surfaceId);
691
- }
754
+ scheduleOnUI(
755
+ uiScheduler_,
756
+ [weakThis = weak_from_this(),
757
+ tag,
758
+ mutation,
759
+ surfaceId
760
+ #ifdef ANDROID
761
+ ,
762
+ handle
763
+ #endif
764
+ ]() {
765
+ auto strongThis = weakThis.lock();
766
+ if (!strongThis) {
767
+ return;
768
+ }
692
769
 
693
- Snapshot values(oldView, window);
770
+ auto oldView = mutation.oldChildShadowView;
771
+ Rect window{};
772
+ {
773
+ auto &mutex = strongThis->mutex;
774
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
775
+ #ifdef ANDROID
776
+ if (consumeIsCancelled(strongThis->pendingStarts_, tag, handle)) {
777
+ // the view was removed (e.g. its subtree was force-ended by a screen
778
+ // pop) before this start could run — its Remove+Delete are already on
779
+ // their way to the mounting layer, so starting the animation now
780
+ // would emit updates for a view that's about to be deleted
781
+ strongThis->layoutAnimationsManager_->clearLayoutAnimationConfig(tag);
782
+ return;
783
+ }
784
+ #endif
785
+ strongThis->createLayoutAnimation(mutation, oldView, surfaceId, tag);
786
+ window = strongThis->surfaceManager.getWindow(surfaceId);
787
+ }
694
788
 
695
- auto &uiRuntime = strongThis->uiRuntime_;
696
- jsi::Object yogaValues(uiRuntime);
697
- yogaValues.setProperty(uiRuntime, "currentOriginX", values.x);
698
- yogaValues.setProperty(uiRuntime, "currentGlobalOriginX", values.x);
699
- yogaValues.setProperty(uiRuntime, "currentOriginY", values.y);
700
- yogaValues.setProperty(uiRuntime, "currentGlobalOriginY", values.y);
701
- yogaValues.setProperty(uiRuntime, "currentWidth", values.width);
702
- yogaValues.setProperty(uiRuntime, "currentHeight", values.height);
703
- yogaValues.setProperty(uiRuntime, "windowWidth", values.windowWidth);
704
- yogaValues.setProperty(uiRuntime, "windowHeight", values.windowHeight);
705
- strongThis->layoutAnimationsManager_->startLayoutAnimation(
706
- uiRuntime, tag, LayoutAnimationType::EXITING, yogaValues);
707
- strongThis->layoutAnimationsManager_->clearLayoutAnimationConfig(tag);
708
- });
789
+ Snapshot values(oldView, window);
790
+
791
+ auto &uiRuntime = strongThis->uiRuntime_;
792
+ jsi::Object yogaValues(uiRuntime);
793
+ yogaValues.setProperty(uiRuntime, "currentOriginX", values.x);
794
+ yogaValues.setProperty(uiRuntime, "currentGlobalOriginX", values.x);
795
+ yogaValues.setProperty(uiRuntime, "currentOriginY", values.y);
796
+ yogaValues.setProperty(uiRuntime, "currentGlobalOriginY", values.y);
797
+ yogaValues.setProperty(uiRuntime, "currentWidth", values.width);
798
+ yogaValues.setProperty(uiRuntime, "currentHeight", values.height);
799
+ yogaValues.setProperty(uiRuntime, "windowWidth", values.windowWidth);
800
+ yogaValues.setProperty(uiRuntime, "windowHeight", values.windowHeight);
801
+ strongThis->layoutAnimationsManager_->startLayoutAnimation(
802
+ uiRuntime, tag, LayoutAnimationType::EXITING, yogaValues);
803
+ strongThis->layoutAnimationsManager_->clearLayoutAnimationConfig(tag);
804
+ });
709
805
  }
710
806
 
711
807
  void LayoutAnimationsProxy_Legacy::startLayoutAnimation(const int tag, const ShadowViewMutation &mutation) const {
@@ -713,43 +809,64 @@ void LayoutAnimationsProxy_Legacy::startLayoutAnimation(const int tag, const Sha
713
809
  LOG(INFO) << "start layout animation for tag " << tag << std::endl;
714
810
  #endif
715
811
  auto surfaceId = mutation.oldChildShadowView.surfaceId;
812
+ #ifdef ANDROID
813
+ const auto handle = pendingStarts_[tag].handle;
814
+ pendingStarts_[tag].count++;
815
+ #endif
716
816
 
717
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), mutation, surfaceId, tag]() {
718
- auto strongThis = weakThis.lock();
719
- if (!strongThis) {
720
- return;
721
- }
722
-
723
- auto oldView = mutation.oldChildShadowView;
724
- Rect window{};
725
- {
726
- auto &mutex = strongThis->mutex;
727
- auto lock = std::unique_lock<std::recursive_mutex>(mutex);
728
- strongThis->createLayoutAnimation(mutation, oldView, surfaceId, tag);
729
- window = strongThis->surfaceManager.getWindow(surfaceId);
730
- }
817
+ scheduleOnUI(
818
+ uiScheduler_,
819
+ [weakThis = weak_from_this(),
820
+ mutation,
821
+ surfaceId,
822
+ tag
823
+ #ifdef ANDROID
824
+ ,
825
+ handle
826
+ #endif
827
+ ]() {
828
+ auto strongThis = weakThis.lock();
829
+ if (!strongThis) {
830
+ return;
831
+ }
731
832
 
732
- Snapshot currentValues(oldView, window);
733
- Snapshot targetValues(mutation.newChildShadowView, window);
833
+ auto oldView = mutation.oldChildShadowView;
834
+ Rect window{};
835
+ {
836
+ auto &mutex = strongThis->mutex;
837
+ auto lock = std::unique_lock<std::recursive_mutex>(mutex);
838
+ #ifdef ANDROID
839
+ if (consumeIsCancelled(strongThis->pendingStarts_, tag, handle)) {
840
+ // the view was removed before this start could run
841
+ return;
842
+ }
843
+ #endif
844
+ strongThis->createLayoutAnimation(mutation, oldView, surfaceId, tag);
845
+ window = strongThis->surfaceManager.getWindow(surfaceId);
846
+ }
734
847
 
735
- auto &uiRuntime = strongThis->uiRuntime_;
736
- jsi::Object yogaValues(uiRuntime);
737
- yogaValues.setProperty(uiRuntime, "currentOriginX", currentValues.x);
738
- yogaValues.setProperty(uiRuntime, "currentGlobalOriginX", currentValues.x);
739
- yogaValues.setProperty(uiRuntime, "currentOriginY", currentValues.y);
740
- yogaValues.setProperty(uiRuntime, "currentGlobalOriginY", currentValues.y);
741
- yogaValues.setProperty(uiRuntime, "currentWidth", currentValues.width);
742
- yogaValues.setProperty(uiRuntime, "currentHeight", currentValues.height);
743
- yogaValues.setProperty(uiRuntime, "targetOriginX", targetValues.x);
744
- yogaValues.setProperty(uiRuntime, "targetGlobalOriginX", targetValues.x);
745
- yogaValues.setProperty(uiRuntime, "targetOriginY", targetValues.y);
746
- yogaValues.setProperty(uiRuntime, "targetGlobalOriginY", targetValues.y);
747
- yogaValues.setProperty(uiRuntime, "targetWidth", targetValues.width);
748
- yogaValues.setProperty(uiRuntime, "targetHeight", targetValues.height);
749
- yogaValues.setProperty(uiRuntime, "windowWidth", targetValues.windowWidth);
750
- yogaValues.setProperty(uiRuntime, "windowHeight", targetValues.windowHeight);
751
- strongThis->layoutAnimationsManager_->startLayoutAnimation(uiRuntime, tag, LayoutAnimationType::LAYOUT, yogaValues);
752
- });
848
+ Snapshot currentValues(oldView, window);
849
+ Snapshot targetValues(mutation.newChildShadowView, window);
850
+
851
+ auto &uiRuntime = strongThis->uiRuntime_;
852
+ jsi::Object yogaValues(uiRuntime);
853
+ yogaValues.setProperty(uiRuntime, "currentOriginX", currentValues.x);
854
+ yogaValues.setProperty(uiRuntime, "currentGlobalOriginX", currentValues.x);
855
+ yogaValues.setProperty(uiRuntime, "currentOriginY", currentValues.y);
856
+ yogaValues.setProperty(uiRuntime, "currentGlobalOriginY", currentValues.y);
857
+ yogaValues.setProperty(uiRuntime, "currentWidth", currentValues.width);
858
+ yogaValues.setProperty(uiRuntime, "currentHeight", currentValues.height);
859
+ yogaValues.setProperty(uiRuntime, "targetOriginX", targetValues.x);
860
+ yogaValues.setProperty(uiRuntime, "targetGlobalOriginX", targetValues.x);
861
+ yogaValues.setProperty(uiRuntime, "targetOriginY", targetValues.y);
862
+ yogaValues.setProperty(uiRuntime, "targetGlobalOriginY", targetValues.y);
863
+ yogaValues.setProperty(uiRuntime, "targetWidth", targetValues.width);
864
+ yogaValues.setProperty(uiRuntime, "targetHeight", targetValues.height);
865
+ yogaValues.setProperty(uiRuntime, "windowWidth", targetValues.windowWidth);
866
+ yogaValues.setProperty(uiRuntime, "windowHeight", targetValues.windowHeight);
867
+ strongThis->layoutAnimationsManager_->startLayoutAnimation(
868
+ uiRuntime, tag, LayoutAnimationType::LAYOUT, yogaValues);
869
+ });
753
870
  }
754
871
 
755
872
  void LayoutAnimationsProxy_Legacy::updateOngoingAnimationTarget(const int tag, const ShadowViewMutation &mutation)
@@ -759,11 +876,18 @@ void LayoutAnimationsProxy_Legacy::updateOngoingAnimationTarget(const int tag, c
759
876
  }
760
877
 
761
878
  void LayoutAnimationsProxy_Legacy::maybeCancelAnimation(const int tag) const {
762
- if (!layoutAnimations_.contains(tag)) {
879
+ #ifdef ANDROID
880
+ // invalidate animation starts that are scheduled but haven't run yet
881
+ if (const auto it = pendingStarts_.find(tag); it != pendingStarts_.end()) {
882
+ it->second.handle++;
883
+ }
884
+ #endif
885
+ const auto layoutAnimationIt = layoutAnimations_.find(tag);
886
+ if (layoutAnimationIt == layoutAnimations_.end()) {
763
887
  return;
764
888
  }
765
- layoutAnimations_.erase(tag);
766
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag]() {
889
+ layoutAnimations_.erase(layoutAnimationIt);
890
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag]() {
767
891
  auto strongThis = weakThis.lock();
768
892
  if (!strongThis) {
769
893
  return;
@@ -824,15 +948,14 @@ void LayoutAnimationsProxy_Legacy::maybeUpdateWindowDimensions(
824
948
  }
825
949
  }
826
950
 
827
- void Node::applyMutationToIndices(ShadowViewMutation mutation) {
951
+ void Node::applyMutationToIndices(const ShadowViewMutation &mutation) {
828
952
  const auto parentTag = mutation.parentTag;
829
953
  if (tag != parentTag) {
830
954
  return;
831
955
  }
832
956
 
833
957
  int delta = mutation.type == ShadowViewMutation::Insert ? 1 : -1;
834
- for (auto it = children.rbegin(); it != children.rend(); ++it) {
835
- const auto& child = *it;
958
+ for (const auto &child : std::views::reverse(children)) {
836
959
  if (child->mutation.index < mutation.index) {
837
960
  return;
838
961
  }
@@ -841,8 +964,8 @@ void Node::applyMutationToIndices(ShadowViewMutation mutation) {
841
964
  }
842
965
 
843
966
  // Should only be called on unflattened parents
844
- void Node::removeChildFromUnflattenedTree(std::shared_ptr<MutationNode> child) {
845
- for (int i = unflattenedChildren.size() - 1; i >= 0; i--) {
967
+ void Node::removeChildFromUnflattenedTree(const std::shared_ptr<MutationNode> &child) {
968
+ for (size_t i = unflattenedChildren.size(); i-- > 0;) {
846
969
  if (unflattenedChildren[i]->tag == child->tag) {
847
970
  unflattenedChildren.erase(unflattenedChildren.begin() + i);
848
971
  break;
@@ -850,7 +973,7 @@ void Node::removeChildFromUnflattenedTree(std::shared_ptr<MutationNode> child) {
850
973
  }
851
974
 
852
975
  auto &flattenedChildren = child->parent->children;
853
- for (int i = flattenedChildren.size() - 1; i >= 0; i--) {
976
+ for (size_t i = flattenedChildren.size(); i-- > 0;) {
854
977
  if (flattenedChildren[i]->tag == child->tag) {
855
978
  flattenedChildren.erase(flattenedChildren.begin() + i);
856
979
  return;