@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
@@ -9,25 +9,15 @@ namespace reanimated::css {
9
9
  using namespace facebook;
10
10
  using namespace react;
11
11
 
12
- using PropsObserver = std::function<void(const folly::dynamic &oldProps, const folly::dynamic &newProps)>;
13
-
14
12
  class StaticPropsRegistry {
15
13
  public:
16
14
  void set(jsi::Runtime &rt, Tag viewTag, const jsi::Value &props);
17
15
  folly::dynamic get(Tag viewTag) const;
18
- bool has(Tag viewTag) const;
19
16
  void remove(Tag viewTag);
20
17
  bool isEmpty() const;
21
18
 
22
- bool hasObservers(Tag viewTag) const;
23
- void setObserver(Tag viewTag, PropsObserver observer);
24
- void removeObserver(Tag viewTag);
25
-
26
19
  private:
27
20
  std::unordered_map<Tag, folly::dynamic> registry_;
28
- std::unordered_map<Tag, PropsObserver> observers_;
29
-
30
- void notifyObservers(Tag viewTag, const folly::dynamic &oldProps, const folly::dynamic &newProps);
31
21
  };
32
22
 
33
23
  } // namespace reanimated::css
@@ -0,0 +1,47 @@
1
+ #include <reanimated/CSS/svg/values/CSSLengthArray.h>
2
+
3
+ #include <algorithm>
4
+ #include <cmath>
5
+ #include <utility>
6
+ #include <vector>
7
+
8
+ namespace reanimated::css {
9
+
10
+ CSSLengthArray CSSLengthArray::interpolate(
11
+ double progress,
12
+ const CSSLengthArray &to,
13
+ const ResolvableValueInterpolationContext &context) const {
14
+ // Treat an empty list as a single zero.
15
+ static const std::vector<CSSLength> fallback{CSSLength(0.0)};
16
+ const auto &fromLengths = values.empty() ? fallback : values;
17
+ const auto &toLengths = to.values.empty() ? fallback : to.values;
18
+
19
+ size_t fromSize = fromLengths.size();
20
+ size_t toSize = toLengths.size();
21
+ size_t longerSize = std::max(fromSize, toSize);
22
+
23
+ std::vector<CSSLength> result;
24
+ result.reserve(longerSize);
25
+
26
+ for (size_t i = 0; i < longerSize; ++i) {
27
+ double ratio = (longerSize > 1) ? static_cast<double>(i) / (longerSize - 1.0) : 0.0;
28
+
29
+ auto fromIdx = static_cast<size_t>(std::round(ratio * (fromSize - 1)));
30
+ auto toIdx = static_cast<size_t>(std::round(ratio * (toSize - 1)));
31
+
32
+ result.emplace_back(fromLengths[fromIdx].interpolate(progress, toLengths[toIdx], context));
33
+ }
34
+
35
+ return CSSLengthArray(std::move(result));
36
+ }
37
+
38
+ #ifndef NDEBUG
39
+
40
+ std::ostream &operator<<(std::ostream &os, const CSSLengthArray &value) {
41
+ os << "CSSLengthArray(" << value.toString() << ")";
42
+ return os;
43
+ }
44
+
45
+ #endif // NDEBUG
46
+
47
+ } // namespace reanimated::css
@@ -0,0 +1,24 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/svg/values/CSSLengthVector.h>
4
+
5
+ #include <vector>
6
+
7
+ namespace reanimated::css {
8
+
9
+ struct CSSLengthArray : public CSSLengthVector<CSSLengthArray> {
10
+ // Defaults to a single zero; an empty list is also treated as zero.
11
+ CSSLengthArray() : CSSLengthVector(std::vector<CSSLength>{CSSLength(0.0)}) {}
12
+ using CSSLengthVector::CSSLengthVector;
13
+
14
+ CSSLengthArray interpolate(
15
+ double progress,
16
+ const CSSLengthArray &to,
17
+ const ResolvableValueInterpolationContext &context) const override;
18
+
19
+ #ifndef NDEBUG
20
+ friend std::ostream &operator<<(std::ostream &os, const CSSLengthArray &value);
21
+ #endif // NDEBUG
22
+ };
23
+
24
+ } // namespace reanimated::css
@@ -0,0 +1,87 @@
1
+ #include <reanimated/CSS/svg/values/CSSLengthArray.h>
2
+ #include <reanimated/CSS/svg/values/CSSLengthVector.h>
3
+ #include <reanimated/CSS/svg/values/SVGStrokeDashArray.h>
4
+
5
+ #include <algorithm>
6
+ #include <sstream>
7
+ #include <string>
8
+ #include <utility>
9
+ #include <vector>
10
+
11
+ namespace reanimated::css {
12
+
13
+ template <typename Derived>
14
+ CSSLengthVector<Derived>::CSSLengthVector(std::vector<CSSLength> values) : values(std::move(values)) {}
15
+
16
+ template <typename Derived>
17
+ CSSLengthVector<Derived>::CSSLengthVector(jsi::Runtime &rt, const jsi::Value &jsiValue) {
18
+ const auto array = jsiValue.asObject(rt).asArray(rt);
19
+ const auto size = array.size(rt);
20
+ values.reserve(size);
21
+ for (size_t i = 0; i < size; ++i) {
22
+ values.emplace_back(rt, array.getValueAtIndex(rt, i));
23
+ }
24
+ }
25
+
26
+ template <typename Derived>
27
+ CSSLengthVector<Derived>::CSSLengthVector(const folly::dynamic &value) {
28
+ values.reserve(value.size());
29
+ for (const auto &item : value) {
30
+ values.emplace_back(item);
31
+ }
32
+ }
33
+
34
+ template <typename Derived>
35
+ bool CSSLengthVector<Derived>::canConstruct(jsi::Runtime &rt, const jsi::Value &jsiValue) {
36
+ if (!jsiValue.isObject() || !jsiValue.asObject(rt).isArray(rt)) {
37
+ return false;
38
+ }
39
+ const auto array = jsiValue.asObject(rt).asArray(rt);
40
+ const auto size = array.size(rt);
41
+ for (size_t i = 0; i < size; ++i) {
42
+ if (!CSSLength::canConstruct(rt, array.getValueAtIndex(rt, i))) {
43
+ return false;
44
+ }
45
+ }
46
+ return true;
47
+ }
48
+
49
+ template <typename Derived>
50
+ bool CSSLengthVector<Derived>::canConstruct(const folly::dynamic &value) {
51
+ return value.isArray() &&
52
+ std::all_of(value.begin(), value.end(), [](const auto &item) { return CSSLength::canConstruct(item); });
53
+ }
54
+
55
+ template <typename Derived>
56
+ folly::dynamic CSSLengthVector<Derived>::toDynamic() const {
57
+ folly::dynamic array = folly::dynamic::array;
58
+ array.reserve(values.size());
59
+ for (const auto &length : values) {
60
+ array.push_back(length.toDynamic());
61
+ }
62
+ return array;
63
+ }
64
+
65
+ template <typename Derived>
66
+ std::string CSSLengthVector<Derived>::toString() const {
67
+ std::stringstream ss;
68
+ ss << '[';
69
+ for (size_t i = 0; i < values.size(); ++i) {
70
+ if (i > 0) {
71
+ ss << ", ";
72
+ }
73
+ ss << values[i].toString();
74
+ }
75
+ ss << ']';
76
+ return ss.str();
77
+ }
78
+
79
+ template <typename Derived>
80
+ bool CSSLengthVector<Derived>::operator==(const CSSLengthVector &other) const {
81
+ return values == other.values;
82
+ }
83
+
84
+ template struct CSSLengthVector<CSSLengthArray>;
85
+ template struct CSSLengthVector<SVGStrokeDashArray>;
86
+
87
+ } // namespace reanimated::css
@@ -0,0 +1,28 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/common/values/CSSLength.h>
4
+
5
+ #include <string>
6
+ #include <vector>
7
+
8
+ namespace reanimated::css {
9
+
10
+ template <typename Derived>
11
+ struct CSSLengthVector : public CSSResolvableValue<Derived> {
12
+ std::vector<CSSLength> values;
13
+
14
+ CSSLengthVector() = default;
15
+ explicit CSSLengthVector(std::vector<CSSLength> values);
16
+ explicit CSSLengthVector(jsi::Runtime &rt, const jsi::Value &jsiValue);
17
+ explicit CSSLengthVector(const folly::dynamic &value);
18
+
19
+ static bool canConstruct(jsi::Runtime &rt, const jsi::Value &jsiValue);
20
+ static bool canConstruct(const folly::dynamic &value);
21
+
22
+ folly::dynamic toDynamic() const override;
23
+ std::string toString() const override;
24
+
25
+ bool operator==(const CSSLengthVector &other) const;
26
+ };
27
+
28
+ } // namespace reanimated::css
@@ -0,0 +1,326 @@
1
+ #include <reanimated/CSS/svg/values/SVGPath.h>
2
+
3
+ #include <reanimated/CSS/common/transforms/vectors.h>
4
+
5
+ #include <algorithm>
6
+ #include <cstddef>
7
+ #include <functional>
8
+ #include <optional>
9
+ #include <regex>
10
+ #include <string>
11
+
12
+ namespace reanimated::css {
13
+
14
+ using Point = Vector2D;
15
+ using Cubic = std::array<Vector2D, 4>;
16
+ using SubPath = SVGPath::SubPath;
17
+
18
+ SVGPath::SVGPath() : subPaths() {}
19
+
20
+ SVGPath::SVGPath(std::vector<SubPath> &&subPaths) : subPaths(std::move(subPaths)) {}
21
+
22
+ SVGPath::SVGPath(jsi::Runtime &rt, const jsi::Value &jsiValue) : SVGPath(jsiValue.getString(rt).utf8(rt)) {}
23
+
24
+ SVGPath::SVGPath(const folly::dynamic &value) : SVGPath(value.getString()) {}
25
+
26
+ bool SVGPath::isNormalizedSVGPathString(const std::string &s) {
27
+ static constexpr auto WS = R"(\s*)";
28
+ static constexpr auto NUM = R"(-?\d*\.?\d+(?:e[+-]?\d+)?)";
29
+
30
+ static const std::string M_CMD = std::string("M") + WS + "(?:" + NUM + WS + "){2}";
31
+ static const std::string C_CMD = std::string("C") + WS + "(?:" + NUM + WS + "){6}";
32
+ static const std::string Z_CMD = std::string("Z") + WS;
33
+
34
+ static const std::regex pathRegex(
35
+ std::string(WS) + "(?:(?:" + M_CMD + ")|(?:" + C_CMD + ")|(?:" + Z_CMD + "))*", std::regex_constants::optimize);
36
+
37
+ return std::regex_match(s, pathRegex);
38
+ }
39
+
40
+ bool SVGPath::canConstruct(jsi::Runtime &rt, const jsi::Value &jsiValue) {
41
+ if (!jsiValue.isString()) {
42
+ return false;
43
+ }
44
+ return isNormalizedSVGPathString(jsiValue.getString(rt).utf8(rt));
45
+ }
46
+
47
+ bool SVGPath::canConstruct(const folly::dynamic &value) {
48
+ if (!value.isString()) {
49
+ return false;
50
+ }
51
+ return isNormalizedSVGPathString(value.getString());
52
+ }
53
+
54
+ folly::dynamic SVGPath::toDynamic() const {
55
+ return toString();
56
+ }
57
+
58
+ std::string SVGPath::toString() const {
59
+ std::ostringstream oss;
60
+ oss << std::defaultfloat;
61
+ for (size_t i = 0; i < subPaths.size(); ++i) {
62
+ const auto &segment = subPaths[i];
63
+
64
+ if (i > 0) {
65
+ oss << " ";
66
+ }
67
+
68
+ oss << "M" << segment.M[0] << " " << segment.M[1];
69
+
70
+ for (const auto &point : segment.C) {
71
+ oss << " C";
72
+ for (int j = 1; j < 4; ++j) {
73
+ // In SVGPath C command start point is implicit
74
+ oss << " " << point[j][0] << " " << point[j][1];
75
+ }
76
+ }
77
+
78
+ if (segment.Z) {
79
+ oss << " Z";
80
+ }
81
+ }
82
+ return oss.str();
83
+ }
84
+
85
+ SVGPath SVGPath::interpolate(const double progress, const SVGPath &to) const {
86
+ const auto &longerPath = (subPaths.size() >= to.subPaths.size()) ? subPaths : to.subPaths;
87
+ const auto &shorterPath = (subPaths.size() < to.subPaths.size()) ? subPaths : to.subPaths;
88
+
89
+ size_t longerSize = longerPath.size();
90
+ size_t shorterSize = shorterPath.size();
91
+
92
+ if (shorterSize == 0) {
93
+ return to;
94
+ }
95
+
96
+ std::vector<std::reference_wrapper<const SubPath>> fromRef;
97
+ std::vector<std::reference_wrapper<const SubPath>> toRef;
98
+
99
+ fromRef.reserve(longerSize);
100
+ toRef.reserve(longerSize);
101
+
102
+ size_t baseGroupSize = longerSize / shorterSize;
103
+ size_t remainder = longerSize % shorterSize;
104
+
105
+ size_t longerPathIndex = 0;
106
+
107
+ for (size_t i = 0; i < shorterSize; ++i) {
108
+ size_t currentGroupSize = baseGroupSize + (i < remainder ? 1 : 0);
109
+
110
+ for (size_t j = 0; j < currentGroupSize; ++j) {
111
+ if (subPaths.size() <= to.subPaths.size()) {
112
+ fromRef.push_back(std::cref(subPaths[i]));
113
+ toRef.push_back(std::cref(to.subPaths[longerPathIndex]));
114
+ } else {
115
+ fromRef.push_back(std::cref(subPaths[longerPathIndex]));
116
+ toRef.push_back(std::cref(to.subPaths[i]));
117
+ }
118
+ longerPathIndex++;
119
+ }
120
+ }
121
+
122
+ std::vector<SubPath> interpolatedSubPaths;
123
+ interpolatedSubPaths.reserve(longerSize);
124
+
125
+ for (size_t i = 0; i < longerSize; ++i) {
126
+ interpolatedSubPaths.push_back(interpolateSubPaths(fromRef[i], toRef[i], progress));
127
+ }
128
+
129
+ return SVGPath(std::move(interpolatedSubPaths));
130
+ }
131
+
132
+ bool SVGPath::operator==(const SVGPath &other) const {
133
+ return toString() == other.toString();
134
+ }
135
+
136
+ #ifndef NDEBUG
137
+
138
+ std::ostream &operator<<(std::ostream &os, const SVGPath &value) {
139
+ os << "SVGPath(" << value.toString() << ")";
140
+ return os;
141
+ }
142
+
143
+ #endif // NDEBUG
144
+
145
+ std::vector<SubPath> SVGPath::parseSVGPath(const std::string &value) const {
146
+ std::vector<SubPath> result;
147
+ std::stringstream ss(value);
148
+ Point currPos{}, startPos{};
149
+
150
+ // Format of input: (M num num |C num num num num num num |Z)*
151
+ std::optional<SubPath> buffer;
152
+
153
+ auto pushBufferToResult = [&]() {
154
+ if (buffer && !buffer->C.empty()) {
155
+ result.push_back(std::move(buffer.value()));
156
+ }
157
+ buffer = std::nullopt;
158
+ };
159
+
160
+ while (ss >> std::ws && !ss.eof()) {
161
+ char cmd;
162
+ ss >> cmd;
163
+
164
+ switch (cmd) {
165
+ case 'M':
166
+ double x, y;
167
+ if (!(ss >> x >> y)) {
168
+ throw std::invalid_argument("[Reanimated] Invalid coordinates for 'M' command in path: \"" + value + "\"");
169
+ }
170
+ pushBufferToResult();
171
+ startPos = currPos = Point(x, y);
172
+ buffer = SubPath(startPos);
173
+ break;
174
+ case 'C': {
175
+ if (buffer && buffer->Z) {
176
+ pushBufferToResult();
177
+ }
178
+ if (!buffer) {
179
+ buffer = SubPath(currPos);
180
+ }
181
+
182
+ Point p0(currPos), p1, p2, p3;
183
+ if (!(ss >> p1[0] >> p1[1] >> p2[0] >> p2[1] >> p3[0] >> p3[1])) {
184
+ throw std::invalid_argument("[Reanimated] Invalid coordinates for 'C' command in path: \"" + value + "\"");
185
+ }
186
+ buffer->C.push_back({p0, p1, p2, p3});
187
+ currPos = p3;
188
+ break;
189
+ }
190
+ case 'Z':
191
+ if (buffer) {
192
+ buffer->Z = true;
193
+ currPos = startPos;
194
+ break;
195
+ }
196
+ // Fallthrough
197
+ default:
198
+ std::invalid_argument("[Reanimated] Invalid SVGPath string format (provided path: \"" + value + "\")");
199
+ }
200
+ }
201
+
202
+ pushBufferToResult();
203
+
204
+ return result;
205
+ }
206
+
207
+ std::vector<Cubic> SVGPath::splitCubic(Cubic cubic, int count) const {
208
+ std::vector<Cubic> result;
209
+ for (int i = 0; i < count; i++) {
210
+ double t = 1.0 / (count - i);
211
+ auto [st, nd] = singleSplitCubic(cubic, t);
212
+ result.push_back(st);
213
+ cubic = nd;
214
+ }
215
+ return result;
216
+ }
217
+
218
+ SubPath SVGPath::interpolateSubPaths(const SubPath &from, const SubPath &to, double t) const {
219
+ Point newM = from.M.interpolate(t, to.M);
220
+ SubPath result(newM);
221
+
222
+ // Closepath is structural, so a pair can't smoothly open<->close: render the
223
+ // segment closed if either endpoint is closed (matches the web normalizer).
224
+ result.Z = from.Z || to.Z;
225
+
226
+ size_t longerSize = std::max(from.C.size(), to.C.size());
227
+ size_t shorterSize = std::min(from.C.size(), to.C.size());
228
+
229
+ if (shorterSize == 0) {
230
+ return result;
231
+ }
232
+
233
+ size_t baseGroupSize = longerSize / shorterSize;
234
+ size_t remainder = longerSize % shorterSize;
235
+
236
+ std::vector<Cubic> prolongatedShorter;
237
+ prolongatedShorter.reserve(longerSize);
238
+
239
+ for (size_t i = 0; i < shorterSize; ++i) {
240
+ size_t currentGroupSize = baseGroupSize + (i < remainder ? 1 : 0);
241
+ const auto count = static_cast<int>(currentGroupSize);
242
+ std::vector<Cubic> x = from.C.size() <= to.C.size() ? splitCubic(from.C[i], count) : splitCubic(to.C[i], count);
243
+ prolongatedShorter.insert(prolongatedShorter.end(), x.begin(), x.end());
244
+ }
245
+
246
+ auto &fromRef = from.C.size() <= to.C.size() ? prolongatedShorter : from.C;
247
+ auto &toRef = from.C.size() <= to.C.size() ? to.C : prolongatedShorter;
248
+
249
+ for (size_t i = 0; i < longerSize; ++i) {
250
+ const auto &c1 = fromRef[i];
251
+ const auto &c2 = toRef[i];
252
+
253
+ Cubic newCubic;
254
+
255
+ for (size_t j = 0; j < 4; ++j) {
256
+ newCubic[j] = c1[j].interpolate(t, c2[j]);
257
+ }
258
+
259
+ // ensure continuity
260
+ newCubic[0] = i == 0 ? result.M : result.C.back()[3];
261
+
262
+ // Ensure tangent differs from 0
263
+ {
264
+ // TODO: This implementation of path interpolation has a problem - if we interpolate
265
+ // a control point (e.g. of C) in a way that during its movement it collides with another point
266
+ // of the same element (so another control point or beginning/end) we efectively get rid of
267
+ // one of the points for this element for this frame, which breaks the math. I currently deal with it by
268
+ // 'nudging' the point a bit when I detect a collision, which is imperfect and can cause an unplesant 'jump'
269
+ // in the animation (visible in example 'Smooth Cubic Bézier curve'). We might want to rethink this in the future.
270
+ constexpr double NUDGE_EPS = 5e-1;
271
+ newCubic[1] = applyDirectionalNudge(newCubic[1], newCubic[0], newCubic[2], newCubic[3], NUDGE_EPS);
272
+ newCubic[2] = applyDirectionalNudge(newCubic[2], newCubic[3], newCubic[1], newCubic[0], NUDGE_EPS);
273
+ }
274
+
275
+ result.C.push_back(newCubic);
276
+ }
277
+
278
+ return result;
279
+ }
280
+
281
+ Point SVGPath::lineAt(Point p0, Point p1, double t) const {
282
+ return Point(p0[0] + t * (p1[0] - p0[0]), p0[1] + t * (p1[1] - p0[1]));
283
+ }
284
+
285
+ Point SVGPath::applyDirectionalNudge(
286
+ Point target,
287
+ const Point &anchor,
288
+ const Point &guide,
289
+ const Point &altGuide,
290
+ double epsilon) const {
291
+ double dx0 = target[0] - anchor[0];
292
+ double dy0 = target[1] - anchor[1];
293
+
294
+ if (dx0 * dx0 + dy0 * dy0 < epsilon * epsilon) {
295
+ Point v = Point(guide[0] - anchor[0], guide[1] - anchor[1]);
296
+ double vLen = v.length();
297
+
298
+ if (vLen < epsilon) {
299
+ v = Point(altGuide[0] - anchor[0], altGuide[1] - anchor[1]);
300
+ vLen = v.length();
301
+ }
302
+
303
+ if (vLen < epsilon) {
304
+ target[0] += epsilon;
305
+ return target;
306
+ }
307
+
308
+ v.normalize();
309
+ return Point(target[0] + v[0] * epsilon, target[1] + v[1] * epsilon);
310
+ }
311
+
312
+ return target;
313
+ }
314
+
315
+ std::pair<Cubic, Cubic> SVGPath::singleSplitCubic(const Cubic &p, double t) const {
316
+ Point p01 = lineAt(p[0], p[1], t);
317
+ Point p12 = lineAt(p[1], p[2], t);
318
+ Point p23 = lineAt(p[2], p[3], t);
319
+ Point c0 = lineAt(p01, p12, t);
320
+ Point c1 = lineAt(p12, p23, t);
321
+ Point q = lineAt(c0, c1, t);
322
+
323
+ return {{p[0], p01, c0, q}, {q, c1, p23, p[3]}};
324
+ }
325
+
326
+ } // namespace reanimated::css
@@ -0,0 +1,65 @@
1
+ #pragma once
2
+
3
+ #include <reanimated/CSS/common/transforms/vectors.h>
4
+ #include <reanimated/CSS/common/values/CSSValue.h>
5
+
6
+ #include <concepts>
7
+ #include <string>
8
+ #include <utility>
9
+ #include <vector>
10
+
11
+ namespace reanimated::css {
12
+
13
+ struct SVGPath : public CSSSimpleValue<SVGPath> {
14
+ using Point = Vector2D;
15
+ using Cubic = std::array<Vector2D, 4>;
16
+ struct SubPath {
17
+ Point M;
18
+ std::vector<Cubic> C;
19
+ bool Z;
20
+ explicit SubPath(Point M) : M{M}, Z{false} {}
21
+ };
22
+
23
+ std::vector<SubPath> subPaths;
24
+
25
+ SVGPath();
26
+ template <typename T>
27
+ requires std::constructible_from<std::string, T>
28
+ explicit SVGPath(T &&value) : subPaths(parseSVGPath(std::forward<T>(value))) {}
29
+ explicit SVGPath(std::vector<SubPath> &&subPaths);
30
+ explicit SVGPath(jsi::Runtime &rt, const jsi::Value &jsiValue);
31
+ explicit SVGPath(const folly::dynamic &value);
32
+
33
+ static bool isNormalizedSVGPathString(const std::string &s);
34
+ static bool canConstruct(jsi::Runtime &rt, const jsi::Value &jsiValue);
35
+ static bool canConstruct(const folly::dynamic &value);
36
+
37
+ folly::dynamic toDynamic() const override;
38
+ std::string toString() const override;
39
+ SVGPath interpolate(double progress, const SVGPath &to) const override;
40
+
41
+ bool operator==(const SVGPath &other) const;
42
+
43
+ #ifndef NDEBUG
44
+ friend std::ostream &operator<<(std::ostream &os, const SVGPath &dimension);
45
+ #endif // NDEBUG
46
+
47
+ protected:
48
+ std::vector<SubPath> parseSVGPath(const std::string &value) const;
49
+ std::vector<Cubic> splitCubic(Cubic cubic, int count) const;
50
+ SubPath interpolateSubPaths(const SubPath &from, const SubPath &to, double t) const;
51
+
52
+ private:
53
+ Point lineAt(Point p0, Point p1, double t) const;
54
+
55
+ Point applyDirectionalNudge(
56
+ Point target,
57
+ const Point &anchor,
58
+ const Point &guide,
59
+ const Point &altGuide,
60
+ double epsilon = 5e-1) const;
61
+
62
+ std::pair<Cubic, Cubic> singleSplitCubic(const Cubic &cubic, double t) const;
63
+ };
64
+
65
+ } // namespace reanimated::css