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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/CHANGELOG.md +1070 -0
  2. package/LICENSE +21 -0
  3. package/README.md +842 -0
  4. package/compatibility.json +20 -26
  5. package/harmony/reanimated/BuildProfile.ets +1 -1
  6. package/harmony/reanimated/index.ets +4 -2
  7. package/harmony/reanimated/oh-package-lock.json5 +1 -1
  8. package/harmony/reanimated/oh-package.json5 +1 -1
  9. package/harmony/reanimated/src/main/cpp/CMakeLists.txt +23 -6
  10. package/harmony/reanimated/src/main/cpp/Common/NativeView/CMakeLists.txt +56 -0
  11. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/ComponentDescriptors.h +19 -0
  12. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryComponentDescriptor.h +30 -0
  13. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.cpp +15 -0
  14. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.h +41 -0
  15. package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryState.h +30 -0
  16. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +8 -9
  17. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +3 -6
  18. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +203 -150
  19. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +1 -6
  20. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +2 -7
  21. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +0 -1
  22. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +2 -18
  23. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +11 -11
  24. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +2 -6
  25. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +4 -1
  26. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +5 -0
  27. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +8 -0
  28. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +27 -46
  29. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +20 -20
  30. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +2 -2
  31. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +3 -3
  32. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +10 -2
  33. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +5 -3
  34. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +20 -17
  35. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +5 -8
  36. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +33 -66
  37. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +29 -22
  38. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +14 -2
  39. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +8 -2
  40. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +50 -91
  41. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +43 -18
  42. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.cpp +63 -0
  43. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.h +37 -0
  44. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.cpp +100 -0
  45. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.h +49 -0
  46. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimation.h +13 -0
  47. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimationFactory.h +32 -0
  48. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.cpp +156 -0
  49. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.h +71 -0
  50. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.cpp +141 -0
  51. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.h +104 -0
  52. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.cpp +97 -0
  53. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.h +69 -0
  54. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.cpp +89 -0
  55. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.h +36 -0
  56. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +12 -0
  57. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +11 -2
  58. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +2 -3
  59. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +3 -5
  60. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +3 -3
  61. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +1 -1
  62. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +38 -37
  63. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +3 -6
  64. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +54 -32
  65. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +5 -7
  66. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +46 -46
  67. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +8 -7
  68. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +4 -57
  69. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.cpp +23 -0
  70. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +10 -8
  71. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.cpp +77 -0
  72. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.h +38 -0
  73. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +47 -68
  74. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +21 -9
  75. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +4 -1
  76. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +35 -78
  77. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +44 -13
  78. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +13 -11
  79. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +4 -0
  80. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +7 -3
  81. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +20 -27
  82. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +12 -9
  83. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +63 -36
  84. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +6 -8
  85. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +55 -46
  86. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +8 -5
  87. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +1 -2
  88. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +3 -2
  89. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +76 -71
  90. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +17 -14
  91. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +145 -273
  92. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +43 -44
  93. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +19 -19
  94. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +16 -12
  95. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +95 -114
  96. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +38 -25
  97. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +9 -34
  98. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +0 -10
  99. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.cpp +47 -0
  100. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.h +24 -0
  101. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.cpp +87 -0
  102. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.h +28 -0
  103. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.cpp +326 -0
  104. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.h +65 -0
  105. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.cpp +164 -0
  106. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.h +51 -0
  107. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +14 -66
  108. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +7 -18
  109. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.cpp +284 -0
  110. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.h +31 -0
  111. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +13 -132
  112. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +3 -21
  113. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/reversingShortening.h +43 -0
  114. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Compat/WorkletsApi.h +13 -0
  115. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.cpp +33 -0
  116. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.h +39 -0
  117. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.cpp +95 -0
  118. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.h +40 -0
  119. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +20 -23
  120. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +2 -6
  121. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +26 -18
  122. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +4 -8
  123. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +16 -28
  124. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +3 -4
  125. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -24
  126. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +17 -7
  127. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.cpp +152 -0
  128. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.h +86 -0
  129. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/PropsLayoutFilter.h +98 -0
  130. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +162 -28
  131. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +69 -11
  132. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +41 -17
  133. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +14 -3
  134. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/propNameFromString.h +130 -0
  135. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +1 -0
  136. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +5 -7
  137. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +7 -4
  138. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +52 -9
  139. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +174 -62
  140. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +12 -11
  141. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +251 -128
  142. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +23 -19
  143. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +34 -6
  144. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +71 -64
  145. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +938 -700
  146. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +123 -76
  147. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.cpp +313 -0
  148. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.h +18 -0
  149. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoSelector.h +41 -0
  150. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.cpp +113 -0
  151. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.h +73 -0
  152. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +4 -4
  153. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +23 -48
  154. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +13 -14
  155. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +20 -3
  156. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReaJSIUtils.h +227 -0
  157. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +51 -14
  158. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +2 -5
  159. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/SingleInstanceChecker.h +76 -0
  160. package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.cpp +353 -0
  161. package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.h +95 -0
  162. package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.cpp +140 -0
  163. package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.h +52 -0
  164. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.cpp +45 -0
  165. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.h +33 -0
  166. package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryJSIBinder.h +20 -0
  167. package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +98 -18
  168. package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +4 -2
  169. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +1 -1
  170. package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +1 -1
  171. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +24 -1
  172. package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +7 -2
  173. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +88 -57
  174. package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +4 -2
  175. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +1 -1
  176. package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +1 -1
  177. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +9 -7
  178. package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +6 -5
  179. package/harmony/reanimated/src/main/cpp/TransformParser.h +1 -1
  180. package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/EventEmitters.h +19 -0
  181. package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/Props.h +31 -0
  182. package/harmony/reanimated/src/main/ets/KeyboardState.ts +11 -0
  183. package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +106 -17
  184. package/harmony/reanimated/src/main/ets/{ReanimatedPackage.ts → ReanimatedPackage.ets} +4 -3
  185. package/harmony/reanimated.har +0 -0
  186. package/package.json +52 -24
  187. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +0 -145
  188. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +0 -47
  189. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +0 -93
  190. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +0 -36
  191. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +0 -75
  192. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +0 -45
  193. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +0 -183
  194. package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +0 -93
  195. package/harmony/reanimated/src/main/ets/AnimationManager.ts +0 -61
  196. /package/harmony/reanimated/{ts.ts → ts.ets} +0 -0
@@ -1,5 +1,11 @@
1
1
  #include <reanimated/Fabric/updates/UpdatesRegistry.h>
2
2
 
3
+ #include <reanimated/Fabric/updates/PropsLayoutFilter.h>
4
+ #include <reanimated/Fabric/updates/UpdatesRegistryManager.h>
5
+
6
+ #include <react/debug/react_native_assert.h>
7
+
8
+ #include <jsi/jsi.h>
3
9
  #include <memory>
4
10
  #include <string>
5
11
  #include <unordered_set>
@@ -8,17 +14,13 @@
8
14
 
9
15
  namespace reanimated {
10
16
 
11
- std::lock_guard<std::mutex> UpdatesRegistry::lock() const {
12
- return std::lock_guard<std::mutex>{mutex_};
13
- }
14
-
15
17
  bool UpdatesRegistry::isEmpty() const {
18
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
16
19
  return updatesRegistry_.empty();
17
20
  }
18
21
 
19
22
  folly::dynamic UpdatesRegistry::get(const Tag tag) const {
20
- std::lock_guard<std::mutex> lock{mutex_};
21
-
23
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
22
24
  auto it = updatesRegistry_.find(tag);
23
25
  if (it == updatesRegistry_.cend()) {
24
26
  return nullptr;
@@ -26,51 +28,182 @@ folly::dynamic UpdatesRegistry::get(const Tag tag) const {
26
28
  return it->second.second;
27
29
  }
28
30
 
31
+ void UpdatesRegistry::remove(const Tag tag) {
32
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
33
+ removeTag(tag);
34
+ }
35
+
29
36
  void UpdatesRegistry::flushUpdates(UpdatesBatch &updatesBatch) {
37
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
38
+ flush(updatesBatch);
39
+ }
40
+
41
+ void UpdatesRegistry::flush(UpdatesBatch &updatesBatch) {
30
42
  auto copiedUpdatesBatch = std::move(updatesBatch_);
31
43
  updatesBatch_.clear();
32
44
 
33
45
  // Store all updates in the registry for later use in the commit hook
34
46
  flushUpdatesToRegistry(copiedUpdatesBatch);
35
47
  // Flush the updates to the updatesBatch used to apply current changes
36
- for (auto &[shadowNode, props] : copiedUpdatesBatch) {
37
- updatesBatch.emplace_back(shadowNode, std::move(props));
48
+ for (auto &[shadowNodeFamily, props] : copiedUpdatesBatch) {
49
+ updatesBatch.emplace_back(shadowNodeFamily, std::move(props));
38
50
  }
39
51
  }
40
52
 
53
+ #if REACT_NATIVE_VERSION_MINOR >= 85
54
+ void UpdatesRegistry::flushUpdates(UpdatesBatchAnimatedProps &updatesBatch) {
55
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
56
+ flush(updatesBatch);
57
+ }
58
+
59
+ void UpdatesRegistry::flush(UpdatesBatchAnimatedProps &updatesBatch) {
60
+ auto copiedUpdatesBatch = std::move(updatesBatchAnimatedProps_);
61
+ updatesBatchAnimatedProps_.clear();
62
+
63
+ for (auto &entry : copiedUpdatesBatch) {
64
+ updatesBatch.push_back(std::move(entry));
65
+ }
66
+ }
67
+
68
+ void UpdatesRegistry::flushNonLayoutUpdates(jsi::Runtime &rt, AnimationMutations &mutations) {
69
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
70
+
71
+ UpdatesBatchAnimatedProps remaining;
72
+
73
+ for (auto &[shadowNodeFamily, animatedProp, _hasLayout] : updatesBatchAnimatedProps_) {
74
+ // Split typed props by layout vs non-layout.
75
+ std::vector<std::unique_ptr<AnimatedPropBase>> nonLayoutTypedProps;
76
+ std::vector<std::unique_ptr<AnimatedPropBase>> layoutTypedProps;
77
+ for (auto &prop : animatedProp.props) {
78
+ if (isLayoutProp(prop->propName)) {
79
+ layoutTypedProps.push_back(std::move(prop));
80
+ } else {
81
+ nonLayoutTypedProps.push_back(std::move(prop));
82
+ }
83
+ }
84
+
85
+ // Split rawProps by layout vs non-layout.
86
+ std::unique_ptr<RawProps> nonLayoutRawProps;
87
+ std::unique_ptr<RawProps> layoutRawProps;
88
+ if (animatedProp.rawProps) {
89
+ auto propsDyn = animatedProp.rawProps->toDynamic();
90
+ folly::dynamic nonLayoutDyn = folly::dynamic::object();
91
+ folly::dynamic layoutDyn = folly::dynamic::object();
92
+ for (const auto &key : propsDyn.keys()) {
93
+ const auto keyStr = key.asString();
94
+ const auto propName = propNameFromString(keyStr);
95
+ if (propName.has_value() && isLayoutProp(propName.value())) {
96
+ layoutDyn[keyStr] = propsDyn[key];
97
+ } else {
98
+ nonLayoutDyn[keyStr] = propsDyn[key];
99
+ }
100
+ }
101
+ if (!nonLayoutDyn.empty()) {
102
+ nonLayoutRawProps = std::make_unique<RawProps>(rt, jsi::valueFromDynamic(rt, nonLayoutDyn));
103
+ }
104
+ if (!layoutDyn.empty()) {
105
+ layoutRawProps = std::make_unique<RawProps>(rt, jsi::valueFromDynamic(rt, layoutDyn));
106
+ }
107
+ }
108
+
109
+ // Non-layout part → apply now.
110
+ if (!nonLayoutTypedProps.empty() || nonLayoutRawProps) {
111
+ AnimatedProps nonLayoutProps{std::move(nonLayoutTypedProps), std::move(nonLayoutRawProps)};
112
+ mutations.batch.push_back(
113
+ AnimationMutation{shadowNodeFamily->getTag(), shadowNodeFamily, std::move(nonLayoutProps), false});
114
+ }
115
+
116
+ // Layout part → defer to next full flush.
117
+ if (!layoutTypedProps.empty() || layoutRawProps) {
118
+ AnimatedProps layoutProps{std::move(layoutTypedProps), std::move(layoutRawProps)};
119
+ remaining.push_back(AnimatedPropsEntry{shadowNodeFamily, std::move(layoutProps), true});
120
+ }
121
+ }
122
+
123
+ updatesBatchAnimatedProps_ = std::move(remaining);
124
+ }
125
+
126
+ bool UpdatesRegistry::hasPendingAnimatedPropsUpdates() const {
127
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
128
+ return !updatesBatchAnimatedProps_.empty();
129
+ }
130
+
131
+ void UpdatesRegistry::addAnimatedPropsToBatch(
132
+ const ShadowNodeFamily::Shared &shadowNodeFamily,
133
+ AnimatedProps animatedProps,
134
+ bool hasLayoutUpdates) {
135
+ if (!hasLayoutUpdates) {
136
+ for (const auto &prop : animatedProps.props) {
137
+ if (isLayoutProp(prop->propName)) {
138
+ hasLayoutUpdates = true;
139
+ break;
140
+ }
141
+ }
142
+ }
143
+ updatesBatchAnimatedProps_.push_back(
144
+ AnimatedPropsEntry{shadowNodeFamily, std::move(animatedProps), hasLayoutUpdates});
145
+ }
146
+
147
+ void UpdatesRegistry::addRawPropsToAnimatedPropsBatch(
148
+ const ShadowNodeFamily::Shared &shadowNodeFamily,
149
+ folly::dynamic props) {
150
+ const bool hasLayoutUpdates = hasLayoutProps(props);
151
+ animatedPropsBuilder_.storeDynamic(props);
152
+ addAnimatedPropsToBatch(shadowNodeFamily, animatedPropsBuilder_.get(), hasLayoutUpdates);
153
+ }
154
+
155
+ void UpdatesRegistry::addJSIPropsToAnimatedPropsBatch(
156
+ const ShadowNodeFamily::Shared &shadowNodeFamily,
157
+ jsi::Runtime &rt,
158
+ jsi::Value &props) {
159
+ const bool hasLayoutUpdates = hasLayoutProps(rt, props);
160
+ animatedPropsBuilder_.storeJSI(rt, props);
161
+ addAnimatedPropsToBatch(shadowNodeFamily, animatedPropsBuilder_.get(), hasLayoutUpdates);
162
+ }
163
+ #endif
164
+
165
+ UpdatesBatch UpdatesRegistry::getPendingUpdates() {
166
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
167
+ flushUpdatesToRegistry(updatesBatch_);
168
+
169
+ UpdatesBatch updatesBatch;
170
+ for (const auto &[tag, pair] : updatesRegistry_) {
171
+ const auto &[shadowNodeFamily, props] = pair;
172
+ updatesBatch.emplace_back(shadowNodeFamily, props);
173
+ }
174
+ return updatesBatch;
175
+ }
176
+
41
177
  void UpdatesRegistry::collectProps(PropsMap &propsMap) {
42
- std::lock_guard<std::mutex> lock{mutex_};
178
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
43
179
 
44
180
  auto copiedRegistry = updatesRegistry_;
45
181
  for (const auto &[tag, pair] : copiedRegistry) {
46
- const auto &[shadowNode, props] = pair;
47
- auto &family = shadowNode->getFamily();
48
- auto it = propsMap.find(&family);
182
+ const auto &[shadowNodeFamily, props] = pair;
183
+ const auto it = propsMap.find(shadowNodeFamily);
49
184
 
50
185
  if (it == propsMap.cend()) {
51
186
  auto propsVector = std::vector<RawProps>{};
52
187
  propsVector.emplace_back(RawProps(props));
53
- propsMap.emplace(&family, propsVector);
188
+ propsMap.emplace(shadowNodeFamily, propsVector);
54
189
  } else {
55
190
  it->second.push_back(RawProps(props));
56
191
  }
57
192
  }
58
193
  }
59
194
 
60
- void UpdatesRegistry::addUpdatesToBatch(
61
- const std::shared_ptr<const ShadowNode> &shadowNode,
62
- const folly::dynamic &props) {
63
- updatesBatch_.emplace_back(shadowNode, props);
195
+ void UpdatesRegistry::addUpdatesToBatch(const ShadowNodeFamily::Shared &shadowNodeFamily, const folly::dynamic &props) {
196
+ updatesBatch_.emplace_back(shadowNodeFamily, props);
64
197
  }
65
198
 
66
199
  void UpdatesRegistry::setInUpdatesRegistry(
67
- const std::shared_ptr<const ShadowNode> &shadowNode,
200
+ const ShadowNodeFamily::Shared &shadowNodeFamily,
68
201
  const folly::dynamic &props) {
69
- const auto tag = shadowNode->getTag();
202
+ const auto tag = shadowNodeFamily->getTag();
70
203
  #ifdef ANDROID
71
204
  updatePropsToRevert(tag, &props);
72
205
  #endif
73
- updatesRegistry_[tag] = std::make_pair(shadowNode, props);
206
+ updatesRegistry_[tag] = std::make_pair(shadowNodeFamily, props);
74
207
  }
75
208
 
76
209
  folly::dynamic UpdatesRegistry::getUpdatesFromRegistry(const Tag tag) const {
@@ -89,12 +222,12 @@ void UpdatesRegistry::removeFromUpdatesRegistry(const Tag tag) {
89
222
  }
90
223
 
91
224
  void UpdatesRegistry::flushUpdatesToRegistry(const UpdatesBatch &updatesBatch) {
92
- for (auto &[shadowNode, props] : updatesBatch) {
93
- const auto tag = shadowNode->getTag();
225
+ for (auto &[shadowNodeFamily, props] : updatesBatch) {
226
+ const auto tag = shadowNodeFamily->getTag();
94
227
  auto it = updatesRegistry_.find(tag);
95
228
 
96
229
  if (it == updatesRegistry_.cend()) {
97
- updatesRegistry_[tag] = std::make_pair(shadowNode, props);
230
+ updatesRegistry_[tag] = std::make_pair(shadowNodeFamily, props);
98
231
  } else {
99
232
  it->second.second.update(props);
100
233
  }
@@ -104,17 +237,18 @@ void UpdatesRegistry::flushUpdatesToRegistry(const UpdatesBatch &updatesBatch) {
104
237
  #ifdef ANDROID
105
238
 
106
239
  bool UpdatesRegistry::hasPropsToRevert() const {
240
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
107
241
  return !propsToRevertMap_.empty();
108
242
  }
109
243
 
110
244
  void UpdatesRegistry::collectPropsToRevert(PropsToRevertMap &propsToRevertMap) {
111
- std::lock_guard<std::mutex> lock{mutex_};
245
+ react_native_assert(UpdatesRegistryManager::isLockedByCurrentThread());
112
246
 
113
247
  for (const auto &[tag, pair] : propsToRevertMap_) {
114
- const auto &[shadowNode, props] = pair;
248
+ const auto &[shadowNodeFamily, props] = pair;
115
249
  const auto it = propsToRevertMap.find(tag);
116
250
  if (it == propsToRevertMap.end()) {
117
- propsToRevertMap[tag] = {shadowNode, props};
251
+ propsToRevertMap[tag] = {shadowNodeFamily, props};
118
252
  } else {
119
253
  it->second.props.insert(props.begin(), props.end());
120
254
  }
@@ -129,10 +263,10 @@ void UpdatesRegistry::updatePropsToRevert(const Tag tag, const folly::dynamic *n
129
263
  return;
130
264
  }
131
265
 
132
- const auto &shadowNode = it->second.first;
266
+ const auto &shadowNodeFamily = it->second.first;
133
267
  const auto &registryProps = it->second.second;
134
268
  if (propsToRevertMap_.find(tag) == propsToRevertMap_.end()) {
135
- propsToRevertMap_[tag] = {shadowNode, std::unordered_set<std::string>()};
269
+ propsToRevertMap_[tag] = {shadowNodeFamily, std::unordered_set<std::string>()};
136
270
  }
137
271
 
138
272
  if (newProps == nullptr) {
@@ -1,10 +1,16 @@
1
1
  #pragma once
2
2
 
3
+ #include <cxxreact/ReactNativeVersion.h>
4
+ #include <jsi/jsi.h>
5
+ #include <react/renderer/core/ShadowNode.h>
3
6
  #include <reanimated/Fabric/ShadowTreeCloner.h>
4
7
 
5
- #include <react/renderer/core/ShadowNode.h>
8
+ #if REACT_NATIVE_VERSION_MINOR >= 85
9
+ #include <react/renderer/animationbackend/AnimatedProps.h>
10
+ #include <react/renderer/animationbackend/AnimatedPropsBuilder.h>
11
+ #include <react/renderer/animationbackend/AnimationBackend.h>
12
+ #endif
6
13
 
7
- #include <jsi/jsi.h>
8
14
  #include <memory>
9
15
  #include <string>
10
16
  #include <unordered_map>
@@ -17,48 +23,100 @@ namespace reanimated {
17
23
  using namespace facebook;
18
24
  using namespace react;
19
25
 
20
- using UpdatesBatch = std::vector<std::pair<std::shared_ptr<const ShadowNode>, folly::dynamic>>;
21
- using RegistryMap = std::unordered_map<Tag, std::pair<std::shared_ptr<const ShadowNode>, folly::dynamic>>;
26
+ using UpdatesBatch = std::vector<std::pair<ShadowNodeFamily::Shared, folly::dynamic>>;
27
+
28
+ #if REACT_NATIVE_VERSION_MINOR >= 85
29
+ struct AnimatedPropsEntry {
30
+ const ShadowNodeFamily::Shared shadowNodeFamily;
31
+ AnimatedProps animatedProps;
32
+ const bool hasLayoutUpdates;
33
+ };
34
+ using UpdatesBatchAnimatedProps = std::vector<AnimatedPropsEntry>;
35
+ #endif
36
+
37
+ using RegistryMap = std::unordered_map<Tag, std::pair<ShadowNodeFamily::Shared, folly::dynamic>>;
22
38
 
23
39
  #ifdef ANDROID
24
40
  struct PropsToRevert {
25
- std::shared_ptr<const ShadowNode> shadowNode;
41
+ ShadowNodeFamily::Shared shadowNodeFamily;
26
42
  std::unordered_set<std::string> props;
27
43
  };
28
44
 
29
45
  using PropsToRevertMap = std::unordered_map<Tag, PropsToRevert>;
30
46
  #endif
31
47
 
48
+ // All public methods require `UpdatesRegistryManager::lock()` to be held.
32
49
  class UpdatesRegistry {
33
50
  public:
34
51
  virtual ~UpdatesRegistry() {}
35
52
 
36
- std::lock_guard<std::mutex> lock() const;
37
-
38
53
  virtual bool isEmpty() const;
39
54
  folly::dynamic get(Tag tag) const;
40
- virtual void remove(Tag tag) = 0;
55
+ void remove(Tag tag);
41
56
 
42
57
  #ifdef ANDROID
43
58
  bool hasPropsToRevert() const;
44
59
  void collectPropsToRevert(PropsToRevertMap &propsToRevertMap);
45
60
  #endif
46
61
 
62
+ // Drains pending style updates as folly::dynamic.
47
63
  void flushUpdates(UpdatesBatch &updatesBatch);
64
+
65
+ #if REACT_NATIVE_VERSION_MINOR >= 85
66
+ // Drains pending typed animated props.
67
+ void flushUpdates(UpdatesBatchAnimatedProps &updatesBatch);
68
+
69
+ // Get only non-layout updates (for android event handling) in the animation backend path.
70
+ void flushNonLayoutUpdates(jsi::Runtime &rt, facebook::react::AnimationMutations &mutations);
71
+ bool hasPendingAnimatedPropsUpdates() const;
72
+ void addAnimatedPropsToBatch(
73
+ const ShadowNodeFamily::Shared &shadowNodeFamily,
74
+ AnimatedProps animatedProps,
75
+ bool hasLayoutUpdates = false);
76
+ void addRawPropsToAnimatedPropsBatch(const ShadowNodeFamily::Shared &shadowNodeFamily, folly::dynamic props);
77
+ void addJSIPropsToAnimatedPropsBatch(
78
+ const ShadowNodeFamily::Shared &shadowNodeFamily,
79
+ jsi::Runtime &rt,
80
+ jsi::Value &props);
81
+ #endif
82
+
48
83
  void collectProps(PropsMap &propsMap);
84
+ UpdatesBatch getPendingUpdates();
49
85
 
50
86
  protected:
51
- mutable std::mutex mutex_;
52
87
  RegistryMap updatesRegistry_;
53
88
 
54
- void addUpdatesToBatch(const std::shared_ptr<const ShadowNode> &shadowNode, const folly::dynamic &props);
89
+ /// Assumes the caller already locked the registry.
90
+ void flush(UpdatesBatch &updatesBatch);
91
+
92
+ #if REACT_NATIVE_VERSION_MINOR >= 85
93
+ // Assumes the caller already locked the registry.
94
+ void flush(UpdatesBatchAnimatedProps &updatesBatch);
95
+ #endif
96
+
97
+ /// Assumes the caller already locked the registry.
98
+ virtual void removeTag(Tag tag) = 0;
99
+
100
+ /// Assumes the caller already locked the registry.
101
+ void addUpdatesToBatch(const ShadowNodeFamily::Shared &shadowNodeFamily, const folly::dynamic &props);
102
+
103
+ /// Assumes the caller already locked the registry.
55
104
  folly::dynamic getUpdatesFromRegistry(const Tag tag) const;
56
- void setInUpdatesRegistry(const std::shared_ptr<const ShadowNode> &shadowNode, const folly::dynamic &props);
105
+
106
+ /// Assumes the caller already locked the registry.
107
+ void setInUpdatesRegistry(const ShadowNodeFamily::Shared &shadowNodeFamily, const folly::dynamic &props);
108
+
109
+ /// Assumes the caller already locked the registry.
57
110
  void removeFromUpdatesRegistry(Tag tag);
58
111
 
59
112
  private:
60
113
  UpdatesBatch updatesBatch_;
61
114
 
115
+ #if REACT_NATIVE_VERSION_MINOR >= 85
116
+ UpdatesBatchAnimatedProps updatesBatchAnimatedProps_;
117
+ AnimatedPropsBuilder animatedPropsBuilder_;
118
+ #endif
119
+
62
120
  void flushUpdatesToRegistry(const UpdatesBatch &updatesBatch);
63
121
 
64
122
  #ifdef ANDROID
@@ -1,17 +1,35 @@
1
1
  #include <reanimated/Fabric/updates/UpdatesRegistryManager.h>
2
2
  #include <reanimated/Tools/FeatureFlags.h>
3
3
 
4
+ #include <react/debug/react_native_assert.h>
5
+
4
6
  #include <memory>
5
7
  #include <utility>
6
8
  #include <vector>
7
9
 
8
10
  namespace reanimated {
9
11
 
12
+ namespace {
13
+ thread_local bool tCurrentThreadHoldsLock = false;
14
+ } // namespace
15
+
16
+ UpdatesRegistryManager::ScopedLock::ScopedLock(std::mutex &mutex) : guard_(mutex) {
17
+ tCurrentThreadHoldsLock = true;
18
+ }
19
+
20
+ UpdatesRegistryManager::ScopedLock::~ScopedLock() {
21
+ tCurrentThreadHoldsLock = false;
22
+ }
23
+
10
24
  UpdatesRegistryManager::UpdatesRegistryManager(const std::shared_ptr<StaticPropsRegistry> &staticPropsRegistry)
11
25
  : staticPropsRegistry_(staticPropsRegistry) {}
12
26
 
13
- std::lock_guard<std::mutex> UpdatesRegistryManager::lock() const {
14
- return std::lock_guard<std::mutex>{mutex_};
27
+ UpdatesRegistryManager::ScopedLock UpdatesRegistryManager::lock() const {
28
+ return ScopedLock{mutex_};
29
+ }
30
+
31
+ bool UpdatesRegistryManager::isLockedByCurrentThread() {
32
+ return tCurrentThreadHoldsLock;
15
33
  }
16
34
 
17
35
  void UpdatesRegistryManager::addRegistry(const std::shared_ptr<UpdatesRegistry> &registry) {
@@ -48,28 +66,31 @@ bool UpdatesRegistryManager::shouldCommitAfterPause() {
48
66
  }
49
67
 
50
68
  void UpdatesRegistryManager::markNodeAsRemovable(const std::shared_ptr<const ShadowNode> &shadowNode) {
51
- removableShadowNodes_[shadowNode->getTag()] = shadowNode;
69
+ react_native_assert(isLockedByCurrentThread());
70
+ removableShadowNodes_[shadowNode->getTag()] = shadowNode->getFamilyShared();
52
71
  }
53
72
 
54
73
  void UpdatesRegistryManager::unmarkNodeAsRemovable(Tag viewTag) {
74
+ react_native_assert(isLockedByCurrentThread());
55
75
  removableShadowNodes_.erase(viewTag);
56
76
  }
57
77
 
58
78
  void UpdatesRegistryManager::handleNodeRemovals(const RootShadowNode &rootShadowNode) {
79
+ react_native_assert(isLockedByCurrentThread());
59
80
  RemovableShadowNodes remainingShadowNodes;
60
81
 
61
- for (const auto &[tag, shadowNode] : removableShadowNodes_) {
62
- if (!shadowNode) {
82
+ for (const auto &[tag, shadowNodeFamily] : removableShadowNodes_) {
83
+ if (!shadowNodeFamily) {
63
84
  continue;
64
85
  }
65
86
 
66
- if (shadowNode->getFamily().getAncestors(rootShadowNode).empty()) {
87
+ if (shadowNodeFamily->getAncestors(rootShadowNode).empty()) {
67
88
  for (auto &registry : registries_) {
68
89
  registry->remove(tag);
69
90
  }
70
91
  staticPropsRegistry_->remove(tag);
71
92
  } else {
72
- remainingShadowNodes.emplace(tag, shadowNode);
93
+ remainingShadowNodes.emplace(tag, shadowNodeFamily);
73
94
  }
74
95
  }
75
96
 
@@ -77,6 +98,7 @@ void UpdatesRegistryManager::handleNodeRemovals(const RootShadowNode &rootShadow
77
98
  }
78
99
 
79
100
  PropsMap UpdatesRegistryManager::collectProps() {
101
+ react_native_assert(isLockedByCurrentThread());
80
102
  PropsMap propsMap;
81
103
  for (auto &registry : registries_) {
82
104
  registry->collectProps(propsMap);
@@ -87,6 +109,7 @@ PropsMap UpdatesRegistryManager::collectProps() {
87
109
  #ifdef ANDROID
88
110
 
89
111
  bool UpdatesRegistryManager::hasPropsToRevert() {
112
+ react_native_assert(isLockedByCurrentThread());
90
113
  for (auto &registry : registries_) {
91
114
  if (registry->hasPropsToRevert()) {
92
115
  return true;
@@ -97,27 +120,27 @@ bool UpdatesRegistryManager::hasPropsToRevert() {
97
120
 
98
121
  void UpdatesRegistryManager::addToPropsMap(
99
122
  PropsMap &propsMap,
100
- const std::shared_ptr<const ShadowNode> &shadowNode,
123
+ const ShadowNodeFamily::Shared &shadowNodeFamily,
101
124
  const folly::dynamic &props) {
102
- auto &family = shadowNode->getFamily();
103
- auto it = propsMap.find(&family);
125
+ auto it = propsMap.find(shadowNodeFamily);
104
126
 
105
127
  if (it == propsMap.cend()) {
106
128
  auto propsVector = std::vector<RawProps>{};
107
129
  propsVector.emplace_back(props);
108
- propsMap.emplace(&family, propsVector);
130
+ propsMap.emplace(shadowNodeFamily, propsVector);
109
131
  } else {
110
132
  it->second.emplace_back(props);
111
133
  }
112
134
  }
113
135
 
114
136
  void UpdatesRegistryManager::collectPropsToRevertBySurface(std::unordered_map<SurfaceId, PropsMap> &propsMapBySurface) {
137
+ react_native_assert(isLockedByCurrentThread());
115
138
  for (const auto &registry : registries_) {
116
139
  registry->collectPropsToRevert(propsToRevertMap_);
117
140
  }
118
141
 
119
142
  for (const auto &[tag, pair] : propsToRevertMap_) {
120
- const auto &[shadowNode, props] = pair;
143
+ const auto &[shadowNodeFamily, props] = pair;
121
144
  const auto &staticStyle = staticPropsRegistry_->get(tag);
122
145
  folly::dynamic filteredStyle = folly::dynamic::object;
123
146
 
@@ -127,8 +150,8 @@ void UpdatesRegistryManager::collectPropsToRevertBySurface(std::unordered_map<Su
127
150
  continue;
128
151
  }
129
152
 
130
- const auto &componentName = shadowNode->getComponentName();
131
- const auto &interpolators = getComponentInterpolators(componentName);
153
+ const auto &nativeComponentName = shadowNodeFamily->getComponentName();
154
+ const auto &interpolators = getComponentInterpolators(nativeComponentName);
132
155
  const auto &it = interpolators.find(propName);
133
156
 
134
157
  if (it != interpolators.end()) {
@@ -139,16 +162,17 @@ void UpdatesRegistryManager::collectPropsToRevertBySurface(std::unordered_map<Su
139
162
  filteredStyle[propName] = nullptr;
140
163
  }
141
164
 
142
- const auto &surfaceId = shadowNode->getSurfaceId();
165
+ const auto &surfaceId = shadowNodeFamily->getSurfaceId();
143
166
  auto &propsMap = propsMapBySurface[surfaceId];
144
167
 
145
- addToPropsMap(propsMap, shadowNode, filteredStyle);
168
+ addToPropsMap(propsMap, shadowNodeFamily, filteredStyle);
146
169
  }
147
170
  }
148
171
 
149
172
  void UpdatesRegistryManager::clearPropsToRevert(const SurfaceId surfaceId) {
173
+ react_native_assert(isLockedByCurrentThread());
150
174
  for (auto it = propsToRevertMap_.begin(); it != propsToRevertMap_.end();) {
151
- if (it->second.shadowNode->getSurfaceId() == surfaceId) {
175
+ if (it->second.shadowNodeFamily->getSurfaceId() == surfaceId) {
152
176
  it = propsToRevertMap_.erase(it);
153
177
  } else {
154
178
  ++it;
@@ -6,6 +6,7 @@
6
6
  #include <reanimated/Fabric/ShadowTreeCloner.h>
7
7
  #include <reanimated/Fabric/updates/UpdatesRegistry.h>
8
8
 
9
+ #include <atomic>
9
10
  #include <memory>
10
11
  #include <unordered_map>
11
12
  #include <utility>
@@ -17,9 +18,19 @@ using namespace css;
17
18
 
18
19
  class UpdatesRegistryManager {
19
20
  public:
21
+ class [[nodiscard]] ScopedLock {
22
+ public:
23
+ explicit ScopedLock(std::mutex &mutex);
24
+ ~ScopedLock();
25
+
26
+ private:
27
+ std::lock_guard<std::mutex> guard_;
28
+ };
29
+
20
30
  explicit UpdatesRegistryManager(const std::shared_ptr<StaticPropsRegistry> &staticPropsRegistry);
21
31
 
22
- std::lock_guard<std::mutex> lock() const;
32
+ ScopedLock lock() const;
33
+ static bool isLockedByCurrentThread();
23
34
 
24
35
  // TODO - ensure that other sublibraries can easily hook into this registry
25
36
  // manager (e.g. add priority to registries)
@@ -45,7 +56,7 @@ class UpdatesRegistryManager {
45
56
  #endif
46
57
 
47
58
  private:
48
- using RemovableShadowNodes = std::unordered_map<Tag, std::shared_ptr<const ShadowNode>>;
59
+ using RemovableShadowNodes = std::unordered_map<Tag, ShadowNodeFamily::Shared>;
49
60
 
50
61
  mutable std::mutex mutex_;
51
62
  std::atomic<bool> isPaused_;
@@ -58,7 +69,7 @@ class UpdatesRegistryManager {
58
69
  PropsToRevertMap propsToRevertMap_;
59
70
 
60
71
  static void
61
- addToPropsMap(PropsMap &propsMap, const std::shared_ptr<const ShadowNode> &shadowNode, const folly::dynamic &props);
72
+ addToPropsMap(PropsMap &propsMap, const ShadowNodeFamily::Shared &shadowNodeFamily, const folly::dynamic &props);
62
73
  #endif
63
74
  };
64
75