@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.
- package/CHANGELOG.md +1070 -0
- package/LICENSE +21 -0
- package/README.md +842 -0
- package/compatibility.json +20 -26
- package/harmony/reanimated/BuildProfile.ets +1 -1
- package/harmony/reanimated/index.ets +4 -2
- package/harmony/reanimated/oh-package-lock.json5 +1 -1
- package/harmony/reanimated/oh-package.json5 +1 -1
- package/harmony/reanimated/src/main/cpp/CMakeLists.txt +23 -6
- package/harmony/reanimated/src/main/cpp/Common/NativeView/CMakeLists.txt +56 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/ComponentDescriptors.h +19 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryComponentDescriptor.h +30 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.cpp +15 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.h +41 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryState.h +30 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +8 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +3 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +203 -150
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +1 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +2 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +0 -1
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +2 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +11 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +2 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +4 -1
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +5 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +8 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +27 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +2 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +3 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +10 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +5 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +20 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +5 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +33 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +29 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +14 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +8 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +50 -91
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +43 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.cpp +63 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.h +37 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.cpp +100 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.h +49 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimation.h +13 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimationFactory.h +32 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.cpp +156 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.h +71 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.cpp +141 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.h +104 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.cpp +97 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.h +69 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.cpp +89 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.h +36 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +12 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +11 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +2 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +3 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +3 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +1 -1
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +38 -37
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +3 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +54 -32
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +5 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +8 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +4 -57
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.cpp +23 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +10 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.cpp +77 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.h +38 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +47 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +21 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +4 -1
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +35 -78
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +44 -13
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +13 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +4 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +7 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +20 -27
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +12 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +63 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +6 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +55 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +8 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +1 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +3 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +76 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +17 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +145 -273
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +43 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +16 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +95 -114
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +38 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +9 -34
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +0 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.cpp +47 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.h +24 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.cpp +87 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.h +28 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.cpp +326 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.h +65 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.cpp +164 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.h +51 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +14 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +7 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.cpp +284 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.h +31 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +13 -132
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +3 -21
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/reversingShortening.h +43 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Compat/WorkletsApi.h +13 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.cpp +33 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.h +39 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.cpp +95 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.h +40 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +20 -23
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +2 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +26 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +4 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +16 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +3 -4
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +17 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.cpp +152 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.h +86 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/PropsLayoutFilter.h +98 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +162 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +69 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +41 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +14 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/propNameFromString.h +130 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +1 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +5 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +7 -4
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +52 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +174 -62
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +12 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +251 -128
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +23 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +34 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +71 -64
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +938 -700
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +123 -76
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.cpp +313 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.h +18 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoSelector.h +41 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.cpp +113 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.h +73 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +4 -4
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +23 -48
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +13 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +20 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReaJSIUtils.h +227 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +51 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +2 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/SingleInstanceChecker.h +76 -0
- package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.cpp +353 -0
- package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.h +95 -0
- package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.cpp +140 -0
- package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.h +52 -0
- package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.cpp +45 -0
- package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.h +33 -0
- package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryJSIBinder.h +20 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +98 -18
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +4 -2
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +1 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +1 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +24 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +7 -2
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +88 -57
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +4 -2
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +1 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +1 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +9 -7
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +6 -5
- package/harmony/reanimated/src/main/cpp/TransformParser.h +1 -1
- package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/EventEmitters.h +19 -0
- package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/Props.h +31 -0
- package/harmony/reanimated/src/main/ets/KeyboardState.ts +11 -0
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +106 -17
- package/harmony/reanimated/src/main/ets/{ReanimatedPackage.ts → ReanimatedPackage.ets} +4 -3
- package/harmony/reanimated.har +0 -0
- package/package.json +52 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +0 -145
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +0 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +0 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +0 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +0 -75
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +0 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +0 -183
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +0 -93
- package/harmony/reanimated/src/main/ets/AnimationManager.ts +0 -61
- /package/harmony/reanimated/{ts.ts → ts.ets} +0 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#include <reanimated/CSS/svg/values/SVGBrush.h>
|
|
2
|
+
#include <reanimated/CSS/svg/values/SVGStops.h>
|
|
3
|
+
|
|
4
|
+
#include <algorithm>
|
|
5
|
+
#include <cstddef>
|
|
6
|
+
#include <functional>
|
|
7
|
+
#include <optional>
|
|
8
|
+
#include <regex>
|
|
9
|
+
#include <string>
|
|
10
|
+
|
|
11
|
+
namespace reanimated::css {
|
|
12
|
+
|
|
13
|
+
SVGStops::SVGStops(jsi::Runtime &rt, const jsi::Value &jsiValue) {
|
|
14
|
+
jsi::Array array = jsiValue.asObject(rt).asArray(rt);
|
|
15
|
+
size_t length = array.size(rt);
|
|
16
|
+
|
|
17
|
+
stops.reserve(length / 2);
|
|
18
|
+
|
|
19
|
+
for (size_t i = 0; i < length; i += 2) {
|
|
20
|
+
double offset = array.getValueAtIndex(rt, i).asNumber();
|
|
21
|
+
auto colorVal = array.getValueAtIndex(rt, i + 1);
|
|
22
|
+
|
|
23
|
+
stops.emplace_back(offset, SVGBrush(rt, colorVal));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
SVGStops::SVGStops(const folly::dynamic &value) {
|
|
28
|
+
stops.reserve(value.size() / 2);
|
|
29
|
+
|
|
30
|
+
for (size_t i = 0; i < value.size(); i += 2) {
|
|
31
|
+
double offset = value[i].asDouble();
|
|
32
|
+
stops.emplace_back(offset, SVGBrush(value[i + 1]));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
bool SVGStops::canConstruct(jsi::Runtime &rt, const jsi::Value &jsiValue) {
|
|
37
|
+
if (!jsiValue.isObject()) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
auto obj = jsiValue.asObject(rt);
|
|
42
|
+
if (!obj.isArray(rt)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
auto array = obj.asArray(rt);
|
|
47
|
+
size_t length = array.size(rt);
|
|
48
|
+
|
|
49
|
+
if (length == 0) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// [offset, brush, offset, brush, ...]
|
|
54
|
+
if (length % 2 != 0) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
auto firstOffset = array.getValueAtIndex(rt, 0);
|
|
59
|
+
auto firstBrush = array.getValueAtIndex(rt, 1);
|
|
60
|
+
|
|
61
|
+
return firstOffset.isNumber() && SVGBrush::canConstruct(rt, firstBrush);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
bool SVGStops::canConstruct(const folly::dynamic &value) {
|
|
65
|
+
if (!value.isArray()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (value.empty()) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// [offset, brush, offset, brush, ...]
|
|
74
|
+
if (value.size() % 2 != 0) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const auto &firstOffset = value[0];
|
|
79
|
+
const auto &firstBrush = value[1];
|
|
80
|
+
|
|
81
|
+
return firstOffset.isNumber() && SVGBrush::canConstruct(firstBrush);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
folly::dynamic SVGStops::toDynamic() const {
|
|
85
|
+
folly::dynamic array = folly::dynamic::array;
|
|
86
|
+
|
|
87
|
+
for (const auto &stop : stops) {
|
|
88
|
+
array.push_back(stop.offset);
|
|
89
|
+
array.push_back(stop.color.toDynamic());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return array;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
std::string SVGStops::toString() const {
|
|
96
|
+
if (stops.empty()) {
|
|
97
|
+
return "none";
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
std::stringstream ss;
|
|
101
|
+
ss << "stops(";
|
|
102
|
+
for (size_t i = 0; i < stops.size(); ++i) {
|
|
103
|
+
ss << stops[i].color.toString() << " " << (stops[i].offset * 100) << "%";
|
|
104
|
+
if (i < stops.size() - 1) {
|
|
105
|
+
ss << ", ";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
ss << ")";
|
|
109
|
+
return ss.str();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
SVGStops SVGStops::interpolate(double progress, const SVGStops &to) const {
|
|
113
|
+
const auto &fromStops = stops;
|
|
114
|
+
const auto &toStops = to.stops;
|
|
115
|
+
|
|
116
|
+
if (fromStops.empty() || toStops.empty()) {
|
|
117
|
+
return progress < 0.5 ? *this : to;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
size_t fromSize = fromStops.size();
|
|
121
|
+
size_t toSize = toStops.size();
|
|
122
|
+
size_t longerSize = std::max(toSize, fromSize);
|
|
123
|
+
|
|
124
|
+
std::vector<GradientStop> interpolatedStops;
|
|
125
|
+
interpolatedStops.reserve(longerSize);
|
|
126
|
+
|
|
127
|
+
for (size_t i = 0; i < longerSize; ++i) {
|
|
128
|
+
double ratio = (longerSize > 1) ? static_cast<double>(i) / (static_cast<double>(longerSize) - 1.0) : 0.0;
|
|
129
|
+
|
|
130
|
+
auto fromIdx = static_cast<size_t>(std::round(ratio * (fromSize - 1)));
|
|
131
|
+
auto toIdx = static_cast<size_t>(std::round(ratio * (toSize - 1)));
|
|
132
|
+
|
|
133
|
+
const auto &sFrom = fromStops[fromIdx];
|
|
134
|
+
const auto &sTo = toStops[toIdx];
|
|
135
|
+
|
|
136
|
+
double mixedOffset = sFrom.offset + (sTo.offset - sFrom.offset) * progress;
|
|
137
|
+
|
|
138
|
+
SVGBrush mixedBrush = sFrom.color.interpolate(progress, sTo.color);
|
|
139
|
+
|
|
140
|
+
interpolatedStops.emplace_back(mixedOffset, std::move(mixedBrush));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return SVGStops(std::move(interpolatedStops));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
bool SVGStops::operator==(const SVGStops &other) const {
|
|
147
|
+
return toString() == other.toString();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#ifndef NDEBUG
|
|
151
|
+
std::ostream &operator<<(std::ostream &os, const SVGStops &value) {
|
|
152
|
+
os << "SVGStops{ count: " << value.stops.size() << ", data: [";
|
|
153
|
+
for (size_t i = 0; i < value.stops.size(); ++i) {
|
|
154
|
+
os << "{ offset: " << value.stops[i].offset << ", brush: " << value.stops[i].color.toString() << " }";
|
|
155
|
+
if (i < value.stops.size() - 1) {
|
|
156
|
+
os << ", ";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
os << "] }";
|
|
160
|
+
return os;
|
|
161
|
+
}
|
|
162
|
+
#endif
|
|
163
|
+
|
|
164
|
+
} // namespace reanimated::css
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <reanimated/CSS/common/values/CSSValue.h>
|
|
4
|
+
#include <reanimated/CSS/svg/values/SVGBrush.h>
|
|
5
|
+
|
|
6
|
+
#include <concepts>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <utility>
|
|
9
|
+
#include <vector>
|
|
10
|
+
|
|
11
|
+
namespace reanimated::css {
|
|
12
|
+
|
|
13
|
+
struct SVGStops : public CSSSimpleValue<SVGStops> {
|
|
14
|
+
struct GradientStop {
|
|
15
|
+
// OHOS patch: clang 15's std::is_constructible doesn't account for
|
|
16
|
+
// parenthesized aggregate initialization (P0960), so
|
|
17
|
+
// std::construct_at — used by vector::emplace_back — rejects
|
|
18
|
+
// GradientStop(double, SVGBrush) ("no matching constructor"). An explicit
|
|
19
|
+
// constructor bypasses the trait gap; brace initialization keeps working.
|
|
20
|
+
// Upstream relies on P0960 with clang 17+ (NDK).
|
|
21
|
+
GradientStop(double offset_, SVGBrush color_) : offset(offset_), color(std::move(color_)) {}
|
|
22
|
+
|
|
23
|
+
double offset;
|
|
24
|
+
SVGBrush color;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
SVGStops() = default;
|
|
28
|
+
template <typename T>
|
|
29
|
+
requires(!std::same_as<std::decay_t<T>, SVGStops>) && std::constructible_from<std::vector<GradientStop>, T>
|
|
30
|
+
explicit SVGStops(T &&value) : stops{std::forward<T>(value)} {}
|
|
31
|
+
explicit SVGStops(jsi::Runtime &rt, const jsi::Value &jsiValue);
|
|
32
|
+
explicit SVGStops(const folly::dynamic &value);
|
|
33
|
+
|
|
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
|
+
SVGStops interpolate(double progress, const SVGStops &to) const override;
|
|
40
|
+
|
|
41
|
+
bool operator==(const SVGStops &other) const;
|
|
42
|
+
|
|
43
|
+
#ifndef NDEBUG
|
|
44
|
+
friend std::ostream &operator<<(std::ostream &os, const SVGStops &dimension);
|
|
45
|
+
#endif // NDEBUG
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
std::vector<GradientStop> stops;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} // namespace reanimated::css
|
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp
CHANGED
|
@@ -1,72 +1,15 @@
|
|
|
1
1
|
#include <reanimated/CSS/svg/values/SVGStrokeDashArray.h>
|
|
2
2
|
|
|
3
|
-
#include <
|
|
4
|
-
#include <string>
|
|
3
|
+
#include <numeric>
|
|
5
4
|
#include <vector>
|
|
6
5
|
|
|
7
6
|
namespace reanimated::css {
|
|
8
7
|
|
|
9
|
-
SVGStrokeDashArray::
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const auto &array = jsiValue.asObject(rt).asArray(rt);
|
|
15
|
-
const auto arraySize = array.size(rt);
|
|
16
|
-
values.reserve(arraySize);
|
|
17
|
-
for (size_t i = 0; i < arraySize; ++i) {
|
|
18
|
-
values.emplace_back(rt, array.getValueAtIndex(rt, i));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
SVGStrokeDashArray::SVGStrokeDashArray(const folly::dynamic &value) {
|
|
23
|
-
for (const auto &value : value) {
|
|
24
|
-
values.emplace_back(value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
bool SVGStrokeDashArray::canConstruct(jsi::Runtime &rt, const jsi::Value &jsiValue) {
|
|
29
|
-
if (!jsiValue.isObject() || !jsiValue.asObject(rt).isArray(rt)) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const auto &array = jsiValue.asObject(rt).asArray(rt);
|
|
33
|
-
for (size_t i = 0; i < array.size(rt); ++i) {
|
|
34
|
-
if (!SVGLength::canConstruct(rt, array.getValueAtIndex(rt, i))) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
bool SVGStrokeDashArray::canConstruct(const folly::dynamic &value) {
|
|
42
|
-
return value.isArray() &&
|
|
43
|
-
std::all_of(value.begin(), value.end(), [](const auto &value) { return SVGLength::canConstruct(value); });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
folly::dynamic SVGStrokeDashArray::toDynamic() const {
|
|
47
|
-
folly::dynamic array = folly::dynamic::array;
|
|
48
|
-
array.reserve(values.size());
|
|
49
|
-
for (const auto &value : values) {
|
|
50
|
-
array.push_back(value.toDynamic());
|
|
51
|
-
}
|
|
52
|
-
return array;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
std::string SVGStrokeDashArray::toString() const {
|
|
56
|
-
std::stringstream ss;
|
|
57
|
-
ss << "{";
|
|
58
|
-
for (const auto &value : values) {
|
|
59
|
-
ss << value.toString();
|
|
60
|
-
if (&value != &values.back()) {
|
|
61
|
-
ss << ", ";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
ss << "}";
|
|
65
|
-
return ss.str();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
SVGStrokeDashArray SVGStrokeDashArray::interpolate(double progress, const SVGStrokeDashArray &to) const {
|
|
69
|
-
std::vector<SVGLength> result;
|
|
8
|
+
SVGStrokeDashArray SVGStrokeDashArray::interpolate(
|
|
9
|
+
double progress,
|
|
10
|
+
const SVGStrokeDashArray &to,
|
|
11
|
+
const ResolvableValueInterpolationContext &context) const {
|
|
12
|
+
std::vector<CSSLength> result;
|
|
70
13
|
auto fromValues = values;
|
|
71
14
|
auto toValues = to.values;
|
|
72
15
|
|
|
@@ -89,14 +32,19 @@ SVGStrokeDashArray SVGStrokeDashArray::interpolate(double progress, const SVGStr
|
|
|
89
32
|
result.reserve(resultSize);
|
|
90
33
|
|
|
91
34
|
for (size_t i = 0; i < resultSize; i++) {
|
|
92
|
-
result.emplace_back(fromValues[i % fromSize].interpolate(progress, toValues[i % toSize]));
|
|
35
|
+
result.emplace_back(fromValues[i % fromSize].interpolate(progress, toValues[i % toSize], context));
|
|
93
36
|
}
|
|
94
37
|
|
|
95
38
|
return SVGStrokeDashArray(result);
|
|
96
39
|
}
|
|
97
40
|
|
|
98
|
-
|
|
99
|
-
|
|
41
|
+
folly::dynamic SVGStrokeDashArray::toDynamic() const {
|
|
42
|
+
// Empty means "no dashing" - emit null instead of [], which react-native-svg
|
|
43
|
+
// would feed to Android's DashPathEffect that requires at least 2 intervals.
|
|
44
|
+
if (values.empty()) {
|
|
45
|
+
return nullptr;
|
|
46
|
+
}
|
|
47
|
+
return CSSLengthVector::toDynamic();
|
|
100
48
|
}
|
|
101
49
|
|
|
102
50
|
#ifndef NDEBUG
|
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <reanimated/CSS/svg/values/
|
|
4
|
-
|
|
5
|
-
#include <numeric>
|
|
6
|
-
#include <string>
|
|
7
|
-
#include <vector>
|
|
3
|
+
#include <reanimated/CSS/svg/values/CSSLengthVector.h>
|
|
8
4
|
|
|
9
5
|
namespace reanimated::css {
|
|
10
6
|
|
|
11
|
-
struct SVGStrokeDashArray : public
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
SVGStrokeDashArray();
|
|
15
|
-
explicit SVGStrokeDashArray(const std::vector<SVGLength> &values);
|
|
16
|
-
explicit SVGStrokeDashArray(jsi::Runtime &rt, const jsi::Value &jsiValue);
|
|
17
|
-
explicit SVGStrokeDashArray(const folly::dynamic &value);
|
|
7
|
+
struct SVGStrokeDashArray : public CSSLengthVector<SVGStrokeDashArray> {
|
|
8
|
+
using CSSLengthVector::CSSLengthVector;
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
SVGStrokeDashArray interpolate(
|
|
11
|
+
double progress,
|
|
12
|
+
const SVGStrokeDashArray &to,
|
|
13
|
+
const ResolvableValueInterpolationContext &context) const override;
|
|
21
14
|
|
|
22
15
|
folly::dynamic toDynamic() const override;
|
|
23
|
-
std::string toString() const override;
|
|
24
|
-
SVGStrokeDashArray interpolate(double progress, const SVGStrokeDashArray &to) const override;
|
|
25
|
-
|
|
26
|
-
bool operator==(const SVGStrokeDashArray &other) const;
|
|
27
16
|
|
|
28
17
|
#ifndef NDEBUG
|
|
29
18
|
friend std::ostream &operator<<(std::ostream &os, const SVGStrokeDashArray &strokeDashArray);
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
#include <reanimated/CSS/utils/platform.h>
|
|
2
|
+
|
|
3
|
+
#if __APPLE__
|
|
4
|
+
|
|
5
|
+
#include <reanimated/CSS/utils/props.h>
|
|
6
|
+
#include <reanimated/Tools/FeatureFlags.h>
|
|
7
|
+
|
|
8
|
+
#include <array>
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <unordered_map>
|
|
11
|
+
|
|
12
|
+
namespace reanimated::css {
|
|
13
|
+
|
|
14
|
+
using namespace facebook;
|
|
15
|
+
|
|
16
|
+
namespace {
|
|
17
|
+
|
|
18
|
+
enum class CSSValueKind : std::uint8_t { Scalar, Color, Size };
|
|
19
|
+
|
|
20
|
+
struct CSSPropertyTraits {
|
|
21
|
+
CSSValueKind kind;
|
|
22
|
+
// CSS-spec default applied when an endpoint is null.
|
|
23
|
+
PlatformValue defaultValue;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// The natively animatable properties: each one's value kind and CSS default
|
|
27
|
+
// (mirrors InterpolatorRegistry.cpp). Grows as more properties are routed.
|
|
28
|
+
const CSSPropertyTraits *traitsFor(const std::string &propertyName) {
|
|
29
|
+
constexpr std::array<double, 4> kTransparentColor = {0, 0, 0, 0};
|
|
30
|
+
constexpr std::array<double, 4> kBlackColor = {0, 0, 0, 1};
|
|
31
|
+
static const std::unordered_map<std::string, CSSPropertyTraits> kProperties = {
|
|
32
|
+
{"opacity", {CSSValueKind::Scalar, 1.0}},
|
|
33
|
+
{"backgroundColor", {CSSValueKind::Color, kTransparentColor}},
|
|
34
|
+
{"borderColor", {CSSValueKind::Color, kBlackColor}},
|
|
35
|
+
{"borderRadius", {CSSValueKind::Scalar, 0.0}},
|
|
36
|
+
{"borderWidth", {CSSValueKind::Scalar, 0.0}},
|
|
37
|
+
{"shadowColor", {CSSValueKind::Color, kBlackColor}},
|
|
38
|
+
{"shadowOpacity", {CSSValueKind::Scalar, 1.0}},
|
|
39
|
+
{"shadowRadius", {CSSValueKind::Scalar, 0.0}},
|
|
40
|
+
{"shadowOffset", {CSSValueKind::Size, std::array<double, 2>{0.0, 0.0}}},
|
|
41
|
+
};
|
|
42
|
+
const auto it = kProperties.find(propertyName);
|
|
43
|
+
return it != kProperties.end() ? &it->second : nullptr;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// RN's processColor encodes named colors and rgba() strings as a packed ARGB
|
|
47
|
+
// number; PlatformColor-like objects are not expressible.
|
|
48
|
+
PlatformValue parseColorNumber(const double number) {
|
|
49
|
+
const auto channels = extractColorChannels(static_cast<int64_t>(number));
|
|
50
|
+
return std::array<double, 4>{
|
|
51
|
+
channels[0] / 255.0,
|
|
52
|
+
channels[1] / 255.0,
|
|
53
|
+
channels[2] / 255.0,
|
|
54
|
+
channels[3] / 255.0,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
} // namespace
|
|
59
|
+
|
|
60
|
+
bool canRouteCSSProperty(const std::string &propertyName, const EasingConfig &easing) {
|
|
61
|
+
if constexpr (!StaticFeatureFlags::getFlag("IOS_CSS_CORE_ANIMATION")) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (traitsFor(propertyName) == nullptr) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// TODO: border props route unconditionally, but snap when RN rasterizes the
|
|
68
|
+
// border (view fails useCoreAnimationBorderRendering); they should route only
|
|
69
|
+
// when the platform can render them correctly (follow-up PR).
|
|
70
|
+
// CAMediaTimingFunction can express only linear and cubic-bezier curves;
|
|
71
|
+
// steps / linear-stops easings have to interpolate per-frame on the loop.
|
|
72
|
+
return std::holds_alternative<LinearEasing>(easing) || std::holds_alternative<CubicBezierEasing>(easing);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
std::optional<PlatformValue>
|
|
76
|
+
parsePlatformValue(jsi::Runtime &rt, const std::string &propertyName, const jsi::Value &value) {
|
|
77
|
+
const auto *traits = traitsFor(propertyName);
|
|
78
|
+
if (traits == nullptr) {
|
|
79
|
+
return std::nullopt;
|
|
80
|
+
}
|
|
81
|
+
if (value.isNull() || value.isUndefined()) {
|
|
82
|
+
return traits->defaultValue;
|
|
83
|
+
}
|
|
84
|
+
switch (traits->kind) {
|
|
85
|
+
case CSSValueKind::Scalar:
|
|
86
|
+
return value.isNumber() ? std::optional<PlatformValue>(value.asNumber()) : std::nullopt;
|
|
87
|
+
case CSSValueKind::Color:
|
|
88
|
+
return value.isNumber() ? std::optional<PlatformValue>(parseColorNumber(value.asNumber())) : std::nullopt;
|
|
89
|
+
case CSSValueKind::Size: {
|
|
90
|
+
if (!value.isObject()) {
|
|
91
|
+
return std::nullopt;
|
|
92
|
+
}
|
|
93
|
+
const auto object = value.asObject(rt);
|
|
94
|
+
const auto width = object.getProperty(rt, "width");
|
|
95
|
+
const auto height = object.getProperty(rt, "height");
|
|
96
|
+
return std::array<double, 2>{
|
|
97
|
+
width.isNumber() ? width.asNumber() : 0.0,
|
|
98
|
+
height.isNumber() ? height.asNumber() : 0.0,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return std::nullopt;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
std::optional<PlatformValue> parsePlatformValue(const std::string &propertyName, const folly::dynamic &value) {
|
|
106
|
+
const auto *traits = traitsFor(propertyName);
|
|
107
|
+
if (traits == nullptr) {
|
|
108
|
+
return std::nullopt;
|
|
109
|
+
}
|
|
110
|
+
if (value.isNull()) {
|
|
111
|
+
return traits->defaultValue;
|
|
112
|
+
}
|
|
113
|
+
switch (traits->kind) {
|
|
114
|
+
case CSSValueKind::Scalar:
|
|
115
|
+
return value.isNumber() ? std::optional<PlatformValue>(value.asDouble()) : std::nullopt;
|
|
116
|
+
case CSSValueKind::Color:
|
|
117
|
+
return value.isNumber() ? std::optional<PlatformValue>(parseColorNumber(value.asDouble())) : std::nullopt;
|
|
118
|
+
case CSSValueKind::Size: {
|
|
119
|
+
if (!value.isObject()) {
|
|
120
|
+
return std::nullopt;
|
|
121
|
+
}
|
|
122
|
+
const auto *width = value.get_ptr("width");
|
|
123
|
+
const auto *height = value.get_ptr("height");
|
|
124
|
+
return std::array<double, 2>{
|
|
125
|
+
width != nullptr && width->isNumber() ? width->asDouble() : 0.0,
|
|
126
|
+
height != nullptr && height->isNumber() ? height->asDouble() : 0.0,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return std::nullopt;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
} // namespace reanimated::css
|
|
134
|
+
|
|
135
|
+
#elif defined(__OHOS__) // __OHOS__
|
|
136
|
+
|
|
137
|
+
#include <reanimated/CSS/utils/props.h>
|
|
138
|
+
#include <reanimated/Tools/FeatureFlags.h>
|
|
139
|
+
|
|
140
|
+
#include <array>
|
|
141
|
+
#include <cstdint>
|
|
142
|
+
#include <unordered_map>
|
|
143
|
+
|
|
144
|
+
namespace reanimated::css {
|
|
145
|
+
|
|
146
|
+
using namespace facebook;
|
|
147
|
+
|
|
148
|
+
namespace {
|
|
149
|
+
|
|
150
|
+
enum class CSSValueKind : std::uint8_t { Scalar, Color, Size };
|
|
151
|
+
|
|
152
|
+
struct CSSPropertyTraits {
|
|
153
|
+
CSSValueKind kind;
|
|
154
|
+
// CSS-spec default applied when an endpoint is null.
|
|
155
|
+
PlatformValue defaultValue;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// The natively animatable properties: each one's value kind and CSS default
|
|
159
|
+
// (mirrors InterpolatorRegistry.cpp). Grows as more properties are routed.
|
|
160
|
+
//
|
|
161
|
+
// Compared to the Apple table, the shadow* family is absent: ArkUI's
|
|
162
|
+
// NODE_SHADOW takes only predefined style enums (no arbitrary
|
|
163
|
+
// offset/radius/color), so shadows keep interpolating on the loop.
|
|
164
|
+
const CSSPropertyTraits *traitsFor(const std::string &propertyName) {
|
|
165
|
+
constexpr std::array<double, 4> kTransparentColor = {0, 0, 0, 0};
|
|
166
|
+
constexpr std::array<double, 4> kBlackColor = {0, 0, 0, 1};
|
|
167
|
+
static const std::unordered_map<std::string, CSSPropertyTraits> kProperties = {
|
|
168
|
+
{"opacity", {CSSValueKind::Scalar, 1.0}},
|
|
169
|
+
{"backgroundColor", {CSSValueKind::Color, kTransparentColor}},
|
|
170
|
+
{"borderColor", {CSSValueKind::Color, kBlackColor}},
|
|
171
|
+
{"borderRadius", {CSSValueKind::Scalar, 0.0}},
|
|
172
|
+
{"borderWidth", {CSSValueKind::Scalar, 0.0}},
|
|
173
|
+
};
|
|
174
|
+
const auto it = kProperties.find(propertyName);
|
|
175
|
+
return it != kProperties.end() ? &it->second : nullptr;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// RN's processColor encodes named colors and rgba() strings as a packed ARGB
|
|
179
|
+
// number; PlatformColor-like objects are not expressible.
|
|
180
|
+
PlatformValue parseColorNumber(const double number) {
|
|
181
|
+
const auto channels = extractColorChannels(static_cast<int64_t>(number));
|
|
182
|
+
return std::array<double, 4>{
|
|
183
|
+
channels[0] / 255.0,
|
|
184
|
+
channels[1] / 255.0,
|
|
185
|
+
channels[2] / 255.0,
|
|
186
|
+
channels[3] / 255.0,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
} // namespace
|
|
191
|
+
|
|
192
|
+
bool canRouteCSSProperty(const std::string &propertyName, const EasingConfig &easing) {
|
|
193
|
+
if constexpr (!StaticFeatureFlags::getFlag("IOS_CSS_CORE_ANIMATION")) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
if (traitsFor(propertyName) == nullptr) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
// ArkUI curves express linear and cubic-bezier; steps / linear-stops
|
|
200
|
+
// easings have to interpolate per-frame on the loop.
|
|
201
|
+
return std::holds_alternative<LinearEasing>(easing) || std::holds_alternative<CubicBezierEasing>(easing);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
std::optional<PlatformValue>
|
|
205
|
+
parsePlatformValue(jsi::Runtime &rt, const std::string &propertyName, const jsi::Value &value) {
|
|
206
|
+
const auto *traits = traitsFor(propertyName);
|
|
207
|
+
if (traits == nullptr) {
|
|
208
|
+
return std::nullopt;
|
|
209
|
+
}
|
|
210
|
+
if (value.isNull() || value.isUndefined()) {
|
|
211
|
+
return traits->defaultValue;
|
|
212
|
+
}
|
|
213
|
+
switch (traits->kind) {
|
|
214
|
+
case CSSValueKind::Scalar:
|
|
215
|
+
return value.isNumber() ? std::optional<PlatformValue>(value.asNumber()) : std::nullopt;
|
|
216
|
+
case CSSValueKind::Color:
|
|
217
|
+
return value.isNumber() ? std::optional<PlatformValue>(parseColorNumber(value.asNumber())) : std::nullopt;
|
|
218
|
+
case CSSValueKind::Size: {
|
|
219
|
+
if (!value.isObject()) {
|
|
220
|
+
return std::nullopt;
|
|
221
|
+
}
|
|
222
|
+
const auto object = value.asObject(rt);
|
|
223
|
+
const auto width = object.getProperty(rt, "width");
|
|
224
|
+
const auto height = object.getProperty(rt, "height");
|
|
225
|
+
return std::array<double, 2>{
|
|
226
|
+
width.isNumber() ? width.asNumber() : 0.0,
|
|
227
|
+
height.isNumber() ? height.asNumber() : 0.0,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return std::nullopt;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
std::optional<PlatformValue> parsePlatformValue(const std::string &propertyName, const folly::dynamic &value) {
|
|
235
|
+
const auto *traits = traitsFor(propertyName);
|
|
236
|
+
if (traits == nullptr) {
|
|
237
|
+
return std::nullopt;
|
|
238
|
+
}
|
|
239
|
+
if (value.isNull()) {
|
|
240
|
+
return traits->defaultValue;
|
|
241
|
+
}
|
|
242
|
+
switch (traits->kind) {
|
|
243
|
+
case CSSValueKind::Scalar:
|
|
244
|
+
return value.isNumber() ? std::optional<PlatformValue>(value.asDouble()) : std::nullopt;
|
|
245
|
+
case CSSValueKind::Color:
|
|
246
|
+
return value.isNumber() ? std::optional<PlatformValue>(parseColorNumber(value.asDouble())) : std::nullopt;
|
|
247
|
+
case CSSValueKind::Size: {
|
|
248
|
+
if (!value.isObject()) {
|
|
249
|
+
return std::nullopt;
|
|
250
|
+
}
|
|
251
|
+
const auto *width = value.get_ptr("width");
|
|
252
|
+
const auto *height = value.get_ptr("height");
|
|
253
|
+
return std::array<double, 2>{
|
|
254
|
+
width != nullptr && width->isNumber() ? width->asDouble() : 0.0,
|
|
255
|
+
height != nullptr && height->isNumber() ? height->asDouble() : 0.0,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return std::nullopt;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
} // namespace reanimated::css
|
|
263
|
+
|
|
264
|
+
#else // !__APPLE__ && !__OHOS__
|
|
265
|
+
|
|
266
|
+
namespace reanimated::css {
|
|
267
|
+
|
|
268
|
+
// No native routing backend on this platform yet; every property runs on the loop.
|
|
269
|
+
bool canRouteCSSProperty(const std::string &, const EasingConfig &) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
std::optional<PlatformValue>
|
|
274
|
+
parsePlatformValue(facebook::jsi::Runtime &, const std::string &, const facebook::jsi::Value &) {
|
|
275
|
+
return std::nullopt;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
std::optional<PlatformValue> parsePlatformValue(const std::string &, const folly::dynamic &) {
|
|
279
|
+
return std::nullopt;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
} // namespace reanimated::css
|
|
283
|
+
|
|
284
|
+
#endif // __APPLE__
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <reanimated/CSS/easing/EasingConfigs.h>
|
|
4
|
+
|
|
5
|
+
#include <folly/dynamic.h>
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
|
|
8
|
+
#include <array>
|
|
9
|
+
#include <optional>
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <variant>
|
|
12
|
+
|
|
13
|
+
namespace reanimated::css {
|
|
14
|
+
|
|
15
|
+
/// The value kinds the platform can animate natively: scalars, sizes, and RGBA
|
|
16
|
+
/// colors (normalized to [0, 1]).
|
|
17
|
+
using PlatformValue = std::variant<double, std::array<double, 2>, std::array<double, 4>>;
|
|
18
|
+
|
|
19
|
+
/// Whether the property can animate natively for the given easing. Routing is
|
|
20
|
+
/// platform specific: platforms without a native backend (e.g. Android) never
|
|
21
|
+
/// route, so every property runs on the C++ loop.
|
|
22
|
+
bool canRouteCSSProperty(const std::string &propertyName, const EasingConfig &easing);
|
|
23
|
+
|
|
24
|
+
/// Parses a transition endpoint into a platform value. Null/undefined falls back
|
|
25
|
+
/// to the property's CSS default; nullopt means it can't be animated natively and
|
|
26
|
+
/// runs on the loop. Two overloads: jsi::Value (config) and folly::dynamic (toggle).
|
|
27
|
+
std::optional<PlatformValue>
|
|
28
|
+
parsePlatformValue(facebook::jsi::Runtime &rt, const std::string &propertyName, const facebook::jsi::Value &value);
|
|
29
|
+
std::optional<PlatformValue> parsePlatformValue(const std::string &propertyName, const folly::dynamic &value);
|
|
30
|
+
|
|
31
|
+
} // namespace reanimated::css
|