@react-native-ohos/react-native-reanimated 4.0.0-rc.1 → 4.0.2-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/compatibility.json +161 -161
- package/harmony/reanimated/BuildProfile.ets +16 -16
- package/harmony/reanimated/build-profile.json5 +18 -18
- package/harmony/reanimated/hvigorfile.ts +4 -4
- package/harmony/reanimated/index.ets +4 -4
- package/harmony/reanimated/oh-package-lock.json5 +39 -0
- package/harmony/reanimated/oh-package.json5 +12 -12
- package/harmony/reanimated/src/main/cpp/CMakeLists.txt +65 -62
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +390 -390
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +30 -30
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.cpp +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.h +23 -23
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.cpp +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.h +21 -21
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.cpp +166 -166
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.cpp +368 -368
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.cpp +594 -594
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.cpp +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.cpp +156 -156
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.h +76 -76
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +94 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.cpp +48 -48
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +135 -135
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.h +61 -61
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +100 -100
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +45 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.cpp +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +122 -122
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.h +38 -38
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +82 -82
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +63 -63
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +118 -118
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +174 -174
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +111 -111
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.cpp +196 -196
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.h +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.cpp +134 -134
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +44 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +174 -174
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +17 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +13 -13
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +127 -127
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +145 -145
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.cpp +69 -69
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.cpp +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.h +15 -15
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.cpp +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.h +15 -15
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.cpp +13 -13
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.h +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +157 -157
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +189 -189
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +76 -76
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/configs.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +136 -136
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +40 -40
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.cpp +38 -38
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.h +24 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.cpp +58 -58
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.h +24 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/blur.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/brightness.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/contrast.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/dropShadow.h +17 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/grayscale.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/hueRotate.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/invert.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/opacity.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/saturate.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/sepia.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.h +32 -32
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +99 -99
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +37 -37
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +308 -308
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +100 -100
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.cpp +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +94 -94
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.cpp +18 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +103 -103
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +42 -42
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +224 -224
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.h +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +218 -218
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +89 -89
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.cpp +149 -149
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +208 -208
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.h +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.cpp +42 -42
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.cpp +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.cpp +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.cpp +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +70 -70
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.h +40 -40
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +146 -146
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +155 -155
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +170 -170
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/KeyframeProgressProvider.h +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +193 -193
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +77 -77
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +340 -340
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +80 -80
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +167 -167
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +61 -61
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.cpp +80 -80
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +93 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +111 -110
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +75 -75
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.cpp +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.h +10 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.cpp +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.h +23 -23
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +149 -149
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +32 -32
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +113 -113
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +37 -37
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +104 -104
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -72
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +160 -160
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +161 -161
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +65 -65
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +11 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +137 -137
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +82 -82
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +79 -79
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +864 -864
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +214 -214
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +897 -897
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +220 -220
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +146 -146
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.cpp +456 -456
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.h +102 -102
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +544 -544
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.cpp +119 -119
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +1380 -1376
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +230 -228
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +183 -183
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +93 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +54 -54
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +58 -58
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.cpp +18 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.h +44 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +114 -114
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +18 -18
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +233 -230
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +30 -30
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +44 -44
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +16 -16
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +265 -265
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +36 -36
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +35 -35
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +19 -19
- package/harmony/reanimated/src/main/cpp/TransformParser.h +93 -93
- package/harmony/reanimated/src/main/ets/AnimationManager.ts +60 -60
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +51 -51
- package/harmony/reanimated/src/main/ets/ReanimatedPackage.ts +25 -25
- package/harmony/reanimated/src/main/module.json5 +12 -12
- package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
- package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/reanimated/ts.ts +6 -6
- package/harmony/reanimated.har +0 -0
- package/package.json +70 -68
- package/scripts/deploy.js +191 -191
- package/scripts/set-reanimated-version.js +37 -37
- package/scripts/update-version.js +119 -119
- package/scripts/validate-react-native-version.js +46 -46
- package/scripts/validate-worklets-build.js +17 -17
- package/scripts/validate-worklets-version.js +84 -79
- package/scripts/worklets-version.json +4 -4
- package/src/index.ts +9 -9
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.cpp
CHANGED
|
@@ -1,456 +1,456 @@
|
|
|
1
|
-
#include <react/renderer/components/view/ViewProps.h>
|
|
2
|
-
#include <react/renderer/core/graphicsConversions.h>
|
|
3
|
-
#include <react/renderer/graphics/Transform.h>
|
|
4
|
-
#include <reanimated/LayoutAnimations/PropsDiffer.h>
|
|
5
|
-
|
|
6
|
-
#include <string>
|
|
7
|
-
#include <vector>
|
|
8
|
-
|
|
9
|
-
using namespace facebook;
|
|
10
|
-
|
|
11
|
-
namespace reanimated {
|
|
12
|
-
|
|
13
|
-
jsi::Object PropsDiffer::computeDiff(jsi::Runtime &runtime) {
|
|
14
|
-
diffFrame(runtime);
|
|
15
|
-
diffOpacity(runtime);
|
|
16
|
-
diffBackgroundColor(runtime);
|
|
17
|
-
diffTransform(runtime);
|
|
18
|
-
diffTransformOrigin(runtime);
|
|
19
|
-
diffShadow(runtime);
|
|
20
|
-
diffBorder(runtime);
|
|
21
|
-
|
|
22
|
-
jsi::Object diff(runtime);
|
|
23
|
-
diff.setProperty(runtime, "source", sourceValues_);
|
|
24
|
-
diff.setProperty(runtime, "target", targetValues_);
|
|
25
|
-
return diff;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
void PropsDiffer::diffFrame(jsi::Runtime &rt) {
|
|
29
|
-
const auto &sourceFrame = sourceView_.layoutMetrics.frame;
|
|
30
|
-
const auto &targetFrame = targetView_.layoutMetrics.frame;
|
|
31
|
-
const auto &sourceOrigin = sourceFrame.origin;
|
|
32
|
-
const auto &targetOrigin = targetFrame.origin;
|
|
33
|
-
if (sourceOrigin.x != targetOrigin.x) {
|
|
34
|
-
sourceValues_.setProperty(rt, "originX", sourceOrigin.x);
|
|
35
|
-
targetValues_.setProperty(rt, "originX", targetOrigin.x);
|
|
36
|
-
sourceValues_.setProperty(rt, "globalOriginX", sourceOrigin.x);
|
|
37
|
-
targetValues_.setProperty(rt, "globalOriginX", targetOrigin.x);
|
|
38
|
-
}
|
|
39
|
-
if (sourceOrigin.y != targetOrigin.y) {
|
|
40
|
-
sourceValues_.setProperty(rt, "originY", sourceOrigin.y);
|
|
41
|
-
targetValues_.setProperty(rt, "originY", targetOrigin.y);
|
|
42
|
-
sourceValues_.setProperty(rt, "globalOriginY", sourceOrigin.y);
|
|
43
|
-
targetValues_.setProperty(rt, "globalOriginY", targetOrigin.y);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const auto &sourceSize = sourceFrame.size;
|
|
47
|
-
const auto &targetSize = targetFrame.size;
|
|
48
|
-
if (sourceSize.width != targetSize.width) {
|
|
49
|
-
sourceValues_.setProperty(rt, "width", sourceSize.width);
|
|
50
|
-
targetValues_.setProperty(rt, "width", targetSize.width);
|
|
51
|
-
}
|
|
52
|
-
if (sourceSize.height != targetSize.height) {
|
|
53
|
-
sourceValues_.setProperty(rt, "height", sourceSize.height);
|
|
54
|
-
targetValues_.setProperty(rt, "height", targetSize.height);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
void PropsDiffer::diffOpacity(jsi::Runtime &rt) {
|
|
59
|
-
if (sourceViewProps_.opacity != targetViewProps_.opacity) {
|
|
60
|
-
sourceValues_.setProperty(rt, "opacity", sourceViewProps_.opacity);
|
|
61
|
-
targetValues_.setProperty(rt, "opacity", targetViewProps_.opacity);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
void PropsDiffer::diffBackgroundColor(jsi::Runtime &rt) {
|
|
66
|
-
if (sourceViewProps_.backgroundColor != targetViewProps_.backgroundColor) {
|
|
67
|
-
sourceValues_.setProperty(rt, "backgroundColor", react::toString(sourceViewProps_.backgroundColor));
|
|
68
|
-
targetValues_.setProperty(rt, "backgroundColor", react::toString(targetViewProps_.backgroundColor));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
void PropsDiffer::diffTransform(jsi::Runtime &rt) {
|
|
73
|
-
const auto &sourceJsiOperations = getTransformOperationsFromProps(rt, sourceViewProps_);
|
|
74
|
-
const auto &targetJsiOperations = getTransformOperationsFromProps(rt, targetViewProps_);
|
|
75
|
-
|
|
76
|
-
if (sourceJsiOperations.size() == 1 && targetJsiOperations.size() == 1 &&
|
|
77
|
-
sourceJsiOperations[0].currentValue.hasProperty(rt, "matrix") &&
|
|
78
|
-
targetJsiOperations[0].currentValue.hasProperty(rt, "matrix")) {
|
|
79
|
-
jsi::Array sourceTransforms(rt, 1), targetTransforms(rt, 1);
|
|
80
|
-
sourceTransforms.setValueAtIndex(rt, 0, sourceJsiOperations[0].currentValue);
|
|
81
|
-
targetTransforms.setValueAtIndex(rt, 0, targetJsiOperations[0].currentValue);
|
|
82
|
-
sourceValues_.setProperty(rt, "transform", sourceTransforms);
|
|
83
|
-
targetValues_.setProperty(rt, "transform", targetTransforms);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
jsi::Array sourceTransforms(rt, sourceJsiOperations.size() + targetJsiOperations.size());
|
|
88
|
-
jsi::Array targetTransforms(rt, sourceJsiOperations.size() + targetJsiOperations.size());
|
|
89
|
-
for (size_t i = 0; i < sourceJsiOperations.size(); i++) {
|
|
90
|
-
sourceTransforms.setValueAtIndex(rt, i, sourceJsiOperations[i].currentValue);
|
|
91
|
-
targetTransforms.setValueAtIndex(rt, i, sourceJsiOperations[i].defaultValue);
|
|
92
|
-
}
|
|
93
|
-
for (size_t i = 0; i < targetJsiOperations.size(); i++) {
|
|
94
|
-
size_t index = i + sourceJsiOperations.size();
|
|
95
|
-
sourceTransforms.setValueAtIndex(rt, index, targetJsiOperations[i].defaultValue);
|
|
96
|
-
targetTransforms.setValueAtIndex(rt, index, targetJsiOperations[i].currentValue);
|
|
97
|
-
}
|
|
98
|
-
sourceValues_.setProperty(rt, "transform", sourceTransforms);
|
|
99
|
-
targetValues_.setProperty(rt, "transform", targetTransforms);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
std::vector<TransformOperationWithDefault> PropsDiffer::getTransformOperationsFromProps(
|
|
103
|
-
jsi::Runtime &rt,
|
|
104
|
-
const ViewProps &props) {
|
|
105
|
-
std::vector<TransformOperationWithDefault> jsiOperations;
|
|
106
|
-
const auto &operations = props.transform.operations;
|
|
107
|
-
|
|
108
|
-
if (operations.size() == 1 && operations[0].type == react::TransformOperationType::Arbitrary) {
|
|
109
|
-
jsi::Array currentMatrix(rt, 16), defaultMatrix(rt, 16);
|
|
110
|
-
for (int i = 0; i < 16; i++) {
|
|
111
|
-
currentMatrix.setValueAtIndex(rt, i, props.transform.matrix[i]);
|
|
112
|
-
defaultMatrix.setValueAtIndex(rt, i, i % 5 == 0 ? 1 : 0);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
jsi::Object currentValue(rt), defaultValue(rt);
|
|
116
|
-
currentValue.setProperty(rt, "matrix", currentMatrix);
|
|
117
|
-
defaultValue.setProperty(rt, "matrix", defaultMatrix);
|
|
118
|
-
jsiOperations.emplace_back(currentValue, defaultValue);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
for (const auto &operation : operations) {
|
|
122
|
-
switch (operation.type) {
|
|
123
|
-
case react::TransformOperationType::Perspective: {
|
|
124
|
-
maybeAddOperationToDiff(rt, "perspective", operation.x.value, 1, jsiOperations);
|
|
125
|
-
} break;
|
|
126
|
-
|
|
127
|
-
case react::TransformOperationType::Scale: {
|
|
128
|
-
maybeAddOperationToDiff(rt, "scaleX", operation.x.value, 1, jsiOperations);
|
|
129
|
-
maybeAddOperationToDiff(rt, "scaleY", operation.y.value, 1, jsiOperations);
|
|
130
|
-
maybeAddOperationToDiff(rt, "scaleZ", operation.z.value, 1, jsiOperations);
|
|
131
|
-
} break;
|
|
132
|
-
|
|
133
|
-
case react::TransformOperationType::Translate: {
|
|
134
|
-
maybeAddOperationToDiff(rt, "translateX", operation.x.value, 0, jsiOperations);
|
|
135
|
-
maybeAddOperationToDiff(rt, "translateY", operation.y.value, 0, jsiOperations);
|
|
136
|
-
maybeAddOperationToDiff(rt, "translateZ", operation.z.value, 0, jsiOperations);
|
|
137
|
-
} break;
|
|
138
|
-
|
|
139
|
-
case react::TransformOperationType::Rotate: {
|
|
140
|
-
maybeAddOperationToDiff(rt, "rotateX", operation.x.value, 0, jsiOperations);
|
|
141
|
-
maybeAddOperationToDiff(rt, "rotateY", operation.y.value, 0, jsiOperations);
|
|
142
|
-
maybeAddOperationToDiff(rt, "rotateZ", operation.z.value, 0, jsiOperations);
|
|
143
|
-
} break;
|
|
144
|
-
|
|
145
|
-
case react::TransformOperationType::Skew: {
|
|
146
|
-
maybeAddOperationToDiff(rt, "skewX", operation.x.value, 0, jsiOperations);
|
|
147
|
-
maybeAddOperationToDiff(rt, "skewY", operation.y.value, 0, jsiOperations);
|
|
148
|
-
maybeAddOperationToDiff(rt, "skewZ", operation.z.value, 0, jsiOperations);
|
|
149
|
-
} break;
|
|
150
|
-
|
|
151
|
-
default: {
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return jsiOperations;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
void PropsDiffer::maybeAddOperationToDiff(
|
|
159
|
-
jsi::Runtime &rt,
|
|
160
|
-
const char *name,
|
|
161
|
-
float value,
|
|
162
|
-
float defaultValue,
|
|
163
|
-
std::vector<TransformOperationWithDefault> &jsiOperations) {
|
|
164
|
-
if (value == defaultValue) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
jsi::Object jsiValue(rt);
|
|
168
|
-
jsiValue.setProperty(rt, name, value);
|
|
169
|
-
jsi::Object jsiDefaultDefault(rt);
|
|
170
|
-
jsiDefaultDefault.setProperty(rt, name, defaultValue);
|
|
171
|
-
jsiOperations.emplace_back(jsiValue, jsiDefaultDefault);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
void PropsDiffer::diffTransformOrigin(jsi::Runtime &rt) {
|
|
175
|
-
const auto &sourceTransformOrigin = sourceViewProps_.transformOrigin;
|
|
176
|
-
const auto &targetTransformOrigin = targetViewProps_.transformOrigin;
|
|
177
|
-
|
|
178
|
-
if (sourceTransformOrigin.xy[0] == targetTransformOrigin.xy[0] &&
|
|
179
|
-
sourceTransformOrigin.xy[1] == targetTransformOrigin.xy[1] &&
|
|
180
|
-
sourceTransformOrigin.z == targetTransformOrigin.z) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
addTransformOriginToDiff(rt, sourceTransformOrigin, sourceValues_, sourceView_);
|
|
185
|
-
addTransformOriginToDiff(rt, targetTransformOrigin, targetValues_, targetView_);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
void PropsDiffer::addTransformOriginToDiff(
|
|
189
|
-
jsi::Runtime &rt,
|
|
190
|
-
const TransformOrigin &transformOrigin,
|
|
191
|
-
jsi::Object &jsiValues,
|
|
192
|
-
const ShadowView &view) {
|
|
193
|
-
jsi::Array transformOriginJsi(rt, 3);
|
|
194
|
-
|
|
195
|
-
if (transformOrigin.xy[0].unit == UnitType::Percent) {
|
|
196
|
-
const float origin = view.layoutMetrics.frame.size.width * transformOrigin.xy[0].value / 100;
|
|
197
|
-
transformOriginJsi.setValueAtIndex(rt, 0, origin);
|
|
198
|
-
} else {
|
|
199
|
-
transformOriginJsi.setValueAtIndex(rt, 0, transformOrigin.xy[0].value);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (transformOrigin.xy[1].unit == UnitType::Percent) {
|
|
203
|
-
const float origin = view.layoutMetrics.frame.size.height * transformOrigin.xy[1].value / 100;
|
|
204
|
-
transformOriginJsi.setValueAtIndex(rt, 1, origin);
|
|
205
|
-
} else {
|
|
206
|
-
transformOriginJsi.setValueAtIndex(rt, 1, transformOrigin.xy[1].value);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
transformOriginJsi.setValueAtIndex(rt, 2, transformOrigin.z);
|
|
210
|
-
|
|
211
|
-
jsiValues.setProperty(rt, "transformOrigin", transformOriginJsi);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
void PropsDiffer::diffShadow(jsi::Runtime &rt) {
|
|
215
|
-
const auto &sourceBoxShadows = getBoxShadowsFromProps(rt, sourceViewProps_);
|
|
216
|
-
const auto &targetBoxShadows = getBoxShadowsFromProps(rt, targetViewProps_);
|
|
217
|
-
|
|
218
|
-
if (sourceBoxShadows.size() == targetBoxShadows.size()) {
|
|
219
|
-
const size_t size = sourceBoxShadows.size();
|
|
220
|
-
jsi::Array sourceBoxShadowArray(rt, size), targetBoxShadowArray(rt, size);
|
|
221
|
-
for (int i = 0; i < size; i++) {
|
|
222
|
-
sourceBoxShadowArray.setValueAtIndex(rt, i, sourceBoxShadows[i].currentValue);
|
|
223
|
-
targetBoxShadowArray.setValueAtIndex(rt, i, targetBoxShadows[i].currentValue);
|
|
224
|
-
}
|
|
225
|
-
sourceValues_.setProperty(rt, "boxShadow", sourceBoxShadowArray);
|
|
226
|
-
targetValues_.setProperty(rt, "boxShadow", targetBoxShadowArray);
|
|
227
|
-
} else {
|
|
228
|
-
const size_t size = sourceBoxShadows.size() + targetBoxShadows.size();
|
|
229
|
-
jsi::Array sourceBoxShadowArray(rt, size), targetBoxShadowArray(rt, size);
|
|
230
|
-
for (size_t i = 0; i < sourceBoxShadows.size(); i++) {
|
|
231
|
-
sourceBoxShadowArray.setValueAtIndex(rt, i, sourceBoxShadows[i].currentValue);
|
|
232
|
-
targetBoxShadowArray.setValueAtIndex(rt, i, sourceBoxShadows[i].defaultValue);
|
|
233
|
-
}
|
|
234
|
-
for (size_t i = 0; i < targetBoxShadows.size(); i++) {
|
|
235
|
-
size_t index = i + sourceBoxShadows.size();
|
|
236
|
-
sourceBoxShadowArray.setValueAtIndex(rt, index, targetBoxShadows[i].defaultValue);
|
|
237
|
-
targetBoxShadowArray.setValueAtIndex(rt, index, targetBoxShadows[i].currentValue);
|
|
238
|
-
}
|
|
239
|
-
sourceValues_.setProperty(rt, "boxShadow", sourceBoxShadowArray);
|
|
240
|
-
targetValues_.setProperty(rt, "boxShadow", targetBoxShadowArray);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (sourceViewProps_.shadowColor != targetViewProps_.shadowColor) {
|
|
244
|
-
sourceValues_.setProperty(rt, "shadowColor", toString(sourceViewProps_.shadowColor));
|
|
245
|
-
targetValues_.setProperty(rt, "shadowColor", toString(targetViewProps_.shadowColor));
|
|
246
|
-
}
|
|
247
|
-
if (sourceViewProps_.shadowOffset != targetViewProps_.shadowOffset) {
|
|
248
|
-
jsi::Object sourceShadowOffset(rt), targetShadowOffset(rt);
|
|
249
|
-
sourceShadowOffset.setProperty(rt, "width", sourceViewProps_.shadowOffset.width);
|
|
250
|
-
sourceShadowOffset.setProperty(rt, "height", sourceViewProps_.shadowOffset.height);
|
|
251
|
-
targetShadowOffset.setProperty(rt, "width", targetViewProps_.shadowOffset.width);
|
|
252
|
-
targetShadowOffset.setProperty(rt, "height", targetViewProps_.shadowOffset.height);
|
|
253
|
-
sourceValues_.setProperty(rt, "shadowOffset", sourceShadowOffset);
|
|
254
|
-
targetValues_.setProperty(rt, "shadowOffset", targetShadowOffset);
|
|
255
|
-
}
|
|
256
|
-
if (sourceViewProps_.shadowOpacity != targetViewProps_.shadowOpacity) {
|
|
257
|
-
sourceValues_.setProperty(rt, "shadowOpacity", sourceViewProps_.shadowOpacity);
|
|
258
|
-
targetValues_.setProperty(rt, "shadowOpacity", targetViewProps_.shadowOpacity);
|
|
259
|
-
}
|
|
260
|
-
if (sourceViewProps_.shadowRadius != targetViewProps_.shadowRadius) {
|
|
261
|
-
sourceValues_.setProperty(rt, "shadowRadius", sourceViewProps_.shadowRadius);
|
|
262
|
-
targetValues_.setProperty(rt, "shadowRadius", targetViewProps_.shadowRadius);
|
|
263
|
-
}
|
|
264
|
-
#ifdef ANDROID
|
|
265
|
-
if (sourceViewProps_.elevation != targetViewProps_.elevation) {
|
|
266
|
-
sourceValues_.setProperty(rt, "elevation", sourceViewProps_.elevation);
|
|
267
|
-
targetValues_.setProperty(rt, "elevation", targetViewProps_.elevation);
|
|
268
|
-
}
|
|
269
|
-
#endif
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
std::vector<BoxShadowWithDefault> PropsDiffer::getBoxShadowsFromProps(jsi::Runtime &rt, const ViewProps &props) {
|
|
273
|
-
const auto &boxShadows = props.boxShadow;
|
|
274
|
-
std::vector<BoxShadowWithDefault> boxShadowsWithDefault;
|
|
275
|
-
for (const auto &boxShadow : boxShadows) {
|
|
276
|
-
jsi::Object currentBoxShadow(rt), defaultBoxShadow(rt);
|
|
277
|
-
|
|
278
|
-
currentBoxShadow.setProperty(rt, "offsetX", boxShadow.offsetX);
|
|
279
|
-
currentBoxShadow.setProperty(rt, "offsetY", boxShadow.offsetY);
|
|
280
|
-
currentBoxShadow.setProperty(rt, "blurRadius", boxShadow.blurRadius);
|
|
281
|
-
currentBoxShadow.setProperty(rt, "spreadDistance", boxShadow.spreadDistance);
|
|
282
|
-
currentBoxShadow.setProperty(rt, "color", toString(boxShadow.color));
|
|
283
|
-
|
|
284
|
-
defaultBoxShadow.setProperty(rt, "offsetX", 0);
|
|
285
|
-
defaultBoxShadow.setProperty(rt, "offsetY", 0);
|
|
286
|
-
defaultBoxShadow.setProperty(rt, "blurRadius", 0);
|
|
287
|
-
defaultBoxShadow.setProperty(rt, "spreadDistance", 0);
|
|
288
|
-
defaultBoxShadow.setProperty(rt, "color", toString(SharedColor()));
|
|
289
|
-
|
|
290
|
-
boxShadowsWithDefault.emplace_back(currentBoxShadow, defaultBoxShadow);
|
|
291
|
-
}
|
|
292
|
-
return boxShadowsWithDefault;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
void PropsDiffer::diffBorder(jsi::Runtime &rt) {
|
|
296
|
-
const auto &sourceBorderRadii = sourceViewProps_.borderRadii;
|
|
297
|
-
const auto &targetBorderRadii = targetViewProps_.borderRadii;
|
|
298
|
-
diffBorderRadius(sourceBorderRadii.all, targetBorderRadii.all, "borderRadius", rt);
|
|
299
|
-
diffBorderRadius(sourceBorderRadii.topLeft, targetBorderRadii.topLeft, "borderTopLeftRadius", rt);
|
|
300
|
-
diffBorderRadius(sourceBorderRadii.topRight, targetBorderRadii.topRight, "borderTopRightRadius", rt);
|
|
301
|
-
diffBorderRadius(sourceBorderRadii.bottomLeft, targetBorderRadii.bottomLeft, "borderBottomLeftRadius", rt);
|
|
302
|
-
diffBorderRadius(sourceBorderRadii.bottomRight, targetBorderRadii.bottomRight, "borderBottomRightRadius", rt);
|
|
303
|
-
diffBorderRadius(sourceBorderRadii.topStart, targetBorderRadii.topStart, "borderTopStartRadius", rt);
|
|
304
|
-
diffBorderRadius(sourceBorderRadii.topEnd, targetBorderRadii.topEnd, "borderTopEndRadius", rt);
|
|
305
|
-
diffBorderRadius(sourceBorderRadii.bottomStart, targetBorderRadii.bottomStart, "borderBottomStartRadius", rt);
|
|
306
|
-
diffBorderRadius(sourceBorderRadii.bottomEnd, targetBorderRadii.bottomEnd, "borderBottomEndRadius", rt);
|
|
307
|
-
diffBorderRadius(sourceBorderRadii.endEnd, targetBorderRadii.endEnd, "borderEndEndRadius", rt);
|
|
308
|
-
diffBorderRadius(sourceBorderRadii.endStart, targetBorderRadii.endStart, "borderEndStartRadius", rt);
|
|
309
|
-
diffBorderRadius(sourceBorderRadii.startEnd, targetBorderRadii.startEnd, "borderStartEndRadius", rt);
|
|
310
|
-
diffBorderRadius(sourceBorderRadii.startStart, targetBorderRadii.startStart, "borderStartStartRadius", rt);
|
|
311
|
-
|
|
312
|
-
const auto &sourceBorderWidths = sourceViewProps_.getBorderWidths();
|
|
313
|
-
const auto &targetBorderWidths = targetViewProps_.getBorderWidths();
|
|
314
|
-
const auto defaultSourceWidth = sourceBorderWidths.all.value_or(0);
|
|
315
|
-
const auto defaultTargetWidth = targetBorderWidths.all.value_or(0);
|
|
316
|
-
diffBorderWidth(
|
|
317
|
-
sourceBorderWidths.all, targetBorderWidths.all, "borderWidth", rt, defaultSourceWidth, defaultTargetWidth);
|
|
318
|
-
diffBorderWidth(
|
|
319
|
-
sourceBorderWidths.left, targetBorderWidths.left, "borderLeftWidth", rt, defaultSourceWidth, defaultTargetWidth);
|
|
320
|
-
diffBorderWidth(
|
|
321
|
-
sourceBorderWidths.right,
|
|
322
|
-
targetBorderWidths.right,
|
|
323
|
-
"borderRightWidth",
|
|
324
|
-
rt,
|
|
325
|
-
defaultSourceWidth,
|
|
326
|
-
defaultTargetWidth);
|
|
327
|
-
diffBorderWidth(
|
|
328
|
-
sourceBorderWidths.top, targetBorderWidths.top, "borderTopWidth", rt, defaultSourceWidth, defaultTargetWidth);
|
|
329
|
-
diffBorderWidth(
|
|
330
|
-
sourceBorderWidths.bottom,
|
|
331
|
-
targetBorderWidths.bottom,
|
|
332
|
-
"borderBottomWidth",
|
|
333
|
-
rt,
|
|
334
|
-
defaultSourceWidth,
|
|
335
|
-
defaultTargetWidth);
|
|
336
|
-
|
|
337
|
-
const auto &sourceBorderColors = sourceViewProps_.borderColors;
|
|
338
|
-
const auto &targetBorderColors = targetViewProps_.borderColors;
|
|
339
|
-
diffBorderColors(sourceBorderColors.all, targetBorderColors.all, "borderColor", rt);
|
|
340
|
-
diffBorderColors(sourceBorderColors.left, targetBorderColors.left, "borderLeftColor", rt);
|
|
341
|
-
diffBorderColors(sourceBorderColors.right, targetBorderColors.right, "borderRightColor", rt);
|
|
342
|
-
diffBorderColors(sourceBorderColors.top, targetBorderColors.top, "borderTopColor", rt);
|
|
343
|
-
diffBorderColors(sourceBorderColors.bottom, targetBorderColors.bottom, "borderBottomColor", rt);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
void PropsDiffer::diffBorderRadius(
|
|
347
|
-
const std::optional<react::ValueUnit> &sourceValue,
|
|
348
|
-
const std::optional<react::ValueUnit> &targetValue,
|
|
349
|
-
const char *name,
|
|
350
|
-
jsi::Runtime &rt) {
|
|
351
|
-
ValueUnit defaultValue;
|
|
352
|
-
const auto &source = sourceValue.value_or(defaultValue).value;
|
|
353
|
-
const auto &target = targetValue.value_or(defaultValue).value;
|
|
354
|
-
if (source == target) {
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
// In React Native, we can't set asymmetric border radii for the edges of a
|
|
358
|
-
// corner using pixels. This limitation means we can't properly animate
|
|
359
|
-
// between units in percentages and pixels.
|
|
360
|
-
if (targetValue.value_or(defaultValue).unit == UnitType::Percent) {
|
|
361
|
-
if (sourceValue.has_value()) {
|
|
362
|
-
sourceValues_.setProperty(rt, name, std::to_string(source) + "%");
|
|
363
|
-
} else {
|
|
364
|
-
const auto &defaultRadius = sourceViewProps_.borderRadii.all.value_or(defaultValue).value;
|
|
365
|
-
sourceValues_.setProperty(rt, name, std::to_string(defaultRadius) + "%");
|
|
366
|
-
}
|
|
367
|
-
if (targetValue.has_value()) {
|
|
368
|
-
targetValues_.setProperty(rt, name, std::to_string(target) + "%");
|
|
369
|
-
} else {
|
|
370
|
-
const auto &defaultRadius = targetViewProps_.borderRadii.all.value_or(defaultValue).value;
|
|
371
|
-
targetValues_.setProperty(rt, name, std::to_string(defaultRadius) + "%");
|
|
372
|
-
}
|
|
373
|
-
} else {
|
|
374
|
-
if (sourceValue.has_value()) {
|
|
375
|
-
sourceValues_.setProperty(rt, name, source);
|
|
376
|
-
} else {
|
|
377
|
-
const auto &defaultRadius = sourceViewProps_.borderRadii.all.value_or(defaultValue).value;
|
|
378
|
-
sourceValues_.setProperty(rt, name, defaultRadius);
|
|
379
|
-
}
|
|
380
|
-
if (targetValue.has_value()) {
|
|
381
|
-
targetValues_.setProperty(rt, name, target);
|
|
382
|
-
} else {
|
|
383
|
-
const auto &defaultRadius = targetViewProps_.borderRadii.all.value_or(defaultValue).value;
|
|
384
|
-
targetValues_.setProperty(rt, name, defaultRadius);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
void PropsDiffer::diffBorderWidth(
|
|
390
|
-
const std::optional<react::Float> &sourceValue,
|
|
391
|
-
const std::optional<react::Float> &targetValue,
|
|
392
|
-
const char *name,
|
|
393
|
-
jsi::Runtime &rt,
|
|
394
|
-
float defaultSourceWidth,
|
|
395
|
-
float defaultTargetWidth) {
|
|
396
|
-
const auto source = sourceValue.value_or(0);
|
|
397
|
-
const auto target = targetValue.value_or(0);
|
|
398
|
-
if (source != target) {
|
|
399
|
-
if (sourceValue.has_value()) {
|
|
400
|
-
sourceValues_.setProperty(rt, name, source);
|
|
401
|
-
} else {
|
|
402
|
-
sourceValues_.setProperty(rt, name, defaultSourceWidth);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
if (targetValue.has_value()) {
|
|
406
|
-
targetValues_.setProperty(rt, name, target);
|
|
407
|
-
} else {
|
|
408
|
-
targetValues_.setProperty(rt, name, defaultTargetWidth);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
void PropsDiffer::diffBorderColors(
|
|
414
|
-
const std::optional<react::SharedColor> &sourceValue,
|
|
415
|
-
const std::optional<react::SharedColor> &targetValue,
|
|
416
|
-
const char *name,
|
|
417
|
-
jsi::Runtime &rt) {
|
|
418
|
-
SharedColor defaultValue;
|
|
419
|
-
const auto &source = sourceValue.value_or(defaultValue);
|
|
420
|
-
const auto &target = targetValue.value_or(defaultValue);
|
|
421
|
-
if (source != target) {
|
|
422
|
-
if (sourceValue.has_value()) {
|
|
423
|
-
sourceValues_.setProperty(rt, name, toString(source));
|
|
424
|
-
} else {
|
|
425
|
-
auto const &maybeDefaultColor = sourceViewProps_.borderColors.all.value_or(defaultValue);
|
|
426
|
-
sourceValues_.setProperty(rt, name, toString(maybeDefaultColor));
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
if (targetValue.has_value()) {
|
|
430
|
-
targetValues_.setProperty(rt, name, toString(target));
|
|
431
|
-
} else {
|
|
432
|
-
auto const &maybeDefaultColor = targetViewProps_.borderColors.all.value_or(defaultValue);
|
|
433
|
-
targetValues_.setProperty(rt, name, toString(maybeDefaultColor));
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// Copied from
|
|
439
|
-
// https://github.com/facebook/react-native/blob/v0.80.0-rc.5/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h#L47
|
|
440
|
-
// I needed to manually apply a patch for unnecessary alpha channel
|
|
441
|
-
// normalization.
|
|
442
|
-
inline std::string PropsDiffer::toString(const SharedColor &value) {
|
|
443
|
-
ColorComponents components = colorComponentsFromColor(value);
|
|
444
|
-
std::array<char, 255> buffer{};
|
|
445
|
-
std::snprintf(
|
|
446
|
-
buffer.data(),
|
|
447
|
-
buffer.size(),
|
|
448
|
-
"rgba(%.0f, %.0f, %.0f, %f)",
|
|
449
|
-
components.red * 255.f,
|
|
450
|
-
components.green * 255.f,
|
|
451
|
-
components.blue * 255.f,
|
|
452
|
-
components.alpha);
|
|
453
|
-
return buffer.data();
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
} // namespace reanimated
|
|
1
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
2
|
+
#include <react/renderer/core/graphicsConversions.h>
|
|
3
|
+
#include <react/renderer/graphics/Transform.h>
|
|
4
|
+
#include <reanimated/LayoutAnimations/PropsDiffer.h>
|
|
5
|
+
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
namespace reanimated {
|
|
12
|
+
|
|
13
|
+
jsi::Object PropsDiffer::computeDiff(jsi::Runtime &runtime) {
|
|
14
|
+
diffFrame(runtime);
|
|
15
|
+
diffOpacity(runtime);
|
|
16
|
+
diffBackgroundColor(runtime);
|
|
17
|
+
diffTransform(runtime);
|
|
18
|
+
diffTransformOrigin(runtime);
|
|
19
|
+
diffShadow(runtime);
|
|
20
|
+
diffBorder(runtime);
|
|
21
|
+
|
|
22
|
+
jsi::Object diff(runtime);
|
|
23
|
+
diff.setProperty(runtime, "source", sourceValues_);
|
|
24
|
+
diff.setProperty(runtime, "target", targetValues_);
|
|
25
|
+
return diff;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void PropsDiffer::diffFrame(jsi::Runtime &rt) {
|
|
29
|
+
const auto &sourceFrame = sourceView_.layoutMetrics.frame;
|
|
30
|
+
const auto &targetFrame = targetView_.layoutMetrics.frame;
|
|
31
|
+
const auto &sourceOrigin = sourceFrame.origin;
|
|
32
|
+
const auto &targetOrigin = targetFrame.origin;
|
|
33
|
+
if (sourceOrigin.x != targetOrigin.x) {
|
|
34
|
+
sourceValues_.setProperty(rt, "originX", sourceOrigin.x);
|
|
35
|
+
targetValues_.setProperty(rt, "originX", targetOrigin.x);
|
|
36
|
+
sourceValues_.setProperty(rt, "globalOriginX", sourceOrigin.x);
|
|
37
|
+
targetValues_.setProperty(rt, "globalOriginX", targetOrigin.x);
|
|
38
|
+
}
|
|
39
|
+
if (sourceOrigin.y != targetOrigin.y) {
|
|
40
|
+
sourceValues_.setProperty(rt, "originY", sourceOrigin.y);
|
|
41
|
+
targetValues_.setProperty(rt, "originY", targetOrigin.y);
|
|
42
|
+
sourceValues_.setProperty(rt, "globalOriginY", sourceOrigin.y);
|
|
43
|
+
targetValues_.setProperty(rt, "globalOriginY", targetOrigin.y);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const auto &sourceSize = sourceFrame.size;
|
|
47
|
+
const auto &targetSize = targetFrame.size;
|
|
48
|
+
if (sourceSize.width != targetSize.width) {
|
|
49
|
+
sourceValues_.setProperty(rt, "width", sourceSize.width);
|
|
50
|
+
targetValues_.setProperty(rt, "width", targetSize.width);
|
|
51
|
+
}
|
|
52
|
+
if (sourceSize.height != targetSize.height) {
|
|
53
|
+
sourceValues_.setProperty(rt, "height", sourceSize.height);
|
|
54
|
+
targetValues_.setProperty(rt, "height", targetSize.height);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void PropsDiffer::diffOpacity(jsi::Runtime &rt) {
|
|
59
|
+
if (sourceViewProps_.opacity != targetViewProps_.opacity) {
|
|
60
|
+
sourceValues_.setProperty(rt, "opacity", sourceViewProps_.opacity);
|
|
61
|
+
targetValues_.setProperty(rt, "opacity", targetViewProps_.opacity);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void PropsDiffer::diffBackgroundColor(jsi::Runtime &rt) {
|
|
66
|
+
if (sourceViewProps_.backgroundColor != targetViewProps_.backgroundColor) {
|
|
67
|
+
sourceValues_.setProperty(rt, "backgroundColor", react::toString(sourceViewProps_.backgroundColor));
|
|
68
|
+
targetValues_.setProperty(rt, "backgroundColor", react::toString(targetViewProps_.backgroundColor));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void PropsDiffer::diffTransform(jsi::Runtime &rt) {
|
|
73
|
+
const auto &sourceJsiOperations = getTransformOperationsFromProps(rt, sourceViewProps_);
|
|
74
|
+
const auto &targetJsiOperations = getTransformOperationsFromProps(rt, targetViewProps_);
|
|
75
|
+
|
|
76
|
+
if (sourceJsiOperations.size() == 1 && targetJsiOperations.size() == 1 &&
|
|
77
|
+
sourceJsiOperations[0].currentValue.hasProperty(rt, "matrix") &&
|
|
78
|
+
targetJsiOperations[0].currentValue.hasProperty(rt, "matrix")) {
|
|
79
|
+
jsi::Array sourceTransforms(rt, 1), targetTransforms(rt, 1);
|
|
80
|
+
sourceTransforms.setValueAtIndex(rt, 0, sourceJsiOperations[0].currentValue);
|
|
81
|
+
targetTransforms.setValueAtIndex(rt, 0, targetJsiOperations[0].currentValue);
|
|
82
|
+
sourceValues_.setProperty(rt, "transform", sourceTransforms);
|
|
83
|
+
targetValues_.setProperty(rt, "transform", targetTransforms);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
jsi::Array sourceTransforms(rt, sourceJsiOperations.size() + targetJsiOperations.size());
|
|
88
|
+
jsi::Array targetTransforms(rt, sourceJsiOperations.size() + targetJsiOperations.size());
|
|
89
|
+
for (size_t i = 0; i < sourceJsiOperations.size(); i++) {
|
|
90
|
+
sourceTransforms.setValueAtIndex(rt, i, sourceJsiOperations[i].currentValue);
|
|
91
|
+
targetTransforms.setValueAtIndex(rt, i, sourceJsiOperations[i].defaultValue);
|
|
92
|
+
}
|
|
93
|
+
for (size_t i = 0; i < targetJsiOperations.size(); i++) {
|
|
94
|
+
size_t index = i + sourceJsiOperations.size();
|
|
95
|
+
sourceTransforms.setValueAtIndex(rt, index, targetJsiOperations[i].defaultValue);
|
|
96
|
+
targetTransforms.setValueAtIndex(rt, index, targetJsiOperations[i].currentValue);
|
|
97
|
+
}
|
|
98
|
+
sourceValues_.setProperty(rt, "transform", sourceTransforms);
|
|
99
|
+
targetValues_.setProperty(rt, "transform", targetTransforms);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
std::vector<TransformOperationWithDefault> PropsDiffer::getTransformOperationsFromProps(
|
|
103
|
+
jsi::Runtime &rt,
|
|
104
|
+
const ViewProps &props) {
|
|
105
|
+
std::vector<TransformOperationWithDefault> jsiOperations;
|
|
106
|
+
const auto &operations = props.transform.operations;
|
|
107
|
+
|
|
108
|
+
if (operations.size() == 1 && operations[0].type == react::TransformOperationType::Arbitrary) {
|
|
109
|
+
jsi::Array currentMatrix(rt, 16), defaultMatrix(rt, 16);
|
|
110
|
+
for (int i = 0; i < 16; i++) {
|
|
111
|
+
currentMatrix.setValueAtIndex(rt, i, props.transform.matrix[i]);
|
|
112
|
+
defaultMatrix.setValueAtIndex(rt, i, i % 5 == 0 ? 1 : 0);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
jsi::Object currentValue(rt), defaultValue(rt);
|
|
116
|
+
currentValue.setProperty(rt, "matrix", currentMatrix);
|
|
117
|
+
defaultValue.setProperty(rt, "matrix", defaultMatrix);
|
|
118
|
+
jsiOperations.emplace_back(currentValue, defaultValue);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
for (const auto &operation : operations) {
|
|
122
|
+
switch (operation.type) {
|
|
123
|
+
case react::TransformOperationType::Perspective: {
|
|
124
|
+
maybeAddOperationToDiff(rt, "perspective", operation.x.value, 1, jsiOperations);
|
|
125
|
+
} break;
|
|
126
|
+
|
|
127
|
+
case react::TransformOperationType::Scale: {
|
|
128
|
+
maybeAddOperationToDiff(rt, "scaleX", operation.x.value, 1, jsiOperations);
|
|
129
|
+
maybeAddOperationToDiff(rt, "scaleY", operation.y.value, 1, jsiOperations);
|
|
130
|
+
maybeAddOperationToDiff(rt, "scaleZ", operation.z.value, 1, jsiOperations);
|
|
131
|
+
} break;
|
|
132
|
+
|
|
133
|
+
case react::TransformOperationType::Translate: {
|
|
134
|
+
maybeAddOperationToDiff(rt, "translateX", operation.x.value, 0, jsiOperations);
|
|
135
|
+
maybeAddOperationToDiff(rt, "translateY", operation.y.value, 0, jsiOperations);
|
|
136
|
+
maybeAddOperationToDiff(rt, "translateZ", operation.z.value, 0, jsiOperations);
|
|
137
|
+
} break;
|
|
138
|
+
|
|
139
|
+
case react::TransformOperationType::Rotate: {
|
|
140
|
+
maybeAddOperationToDiff(rt, "rotateX", operation.x.value, 0, jsiOperations);
|
|
141
|
+
maybeAddOperationToDiff(rt, "rotateY", operation.y.value, 0, jsiOperations);
|
|
142
|
+
maybeAddOperationToDiff(rt, "rotateZ", operation.z.value, 0, jsiOperations);
|
|
143
|
+
} break;
|
|
144
|
+
|
|
145
|
+
case react::TransformOperationType::Skew: {
|
|
146
|
+
maybeAddOperationToDiff(rt, "skewX", operation.x.value, 0, jsiOperations);
|
|
147
|
+
maybeAddOperationToDiff(rt, "skewY", operation.y.value, 0, jsiOperations);
|
|
148
|
+
maybeAddOperationToDiff(rt, "skewZ", operation.z.value, 0, jsiOperations);
|
|
149
|
+
} break;
|
|
150
|
+
|
|
151
|
+
default: {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return jsiOperations;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
void PropsDiffer::maybeAddOperationToDiff(
|
|
159
|
+
jsi::Runtime &rt,
|
|
160
|
+
const char *name,
|
|
161
|
+
float value,
|
|
162
|
+
float defaultValue,
|
|
163
|
+
std::vector<TransformOperationWithDefault> &jsiOperations) {
|
|
164
|
+
if (value == defaultValue) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
jsi::Object jsiValue(rt);
|
|
168
|
+
jsiValue.setProperty(rt, name, value);
|
|
169
|
+
jsi::Object jsiDefaultDefault(rt);
|
|
170
|
+
jsiDefaultDefault.setProperty(rt, name, defaultValue);
|
|
171
|
+
jsiOperations.emplace_back(jsiValue, jsiDefaultDefault);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
void PropsDiffer::diffTransformOrigin(jsi::Runtime &rt) {
|
|
175
|
+
const auto &sourceTransformOrigin = sourceViewProps_.transformOrigin;
|
|
176
|
+
const auto &targetTransformOrigin = targetViewProps_.transformOrigin;
|
|
177
|
+
|
|
178
|
+
if (sourceTransformOrigin.xy[0] == targetTransformOrigin.xy[0] &&
|
|
179
|
+
sourceTransformOrigin.xy[1] == targetTransformOrigin.xy[1] &&
|
|
180
|
+
sourceTransformOrigin.z == targetTransformOrigin.z) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
addTransformOriginToDiff(rt, sourceTransformOrigin, sourceValues_, sourceView_);
|
|
185
|
+
addTransformOriginToDiff(rt, targetTransformOrigin, targetValues_, targetView_);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
void PropsDiffer::addTransformOriginToDiff(
|
|
189
|
+
jsi::Runtime &rt,
|
|
190
|
+
const TransformOrigin &transformOrigin,
|
|
191
|
+
jsi::Object &jsiValues,
|
|
192
|
+
const ShadowView &view) {
|
|
193
|
+
jsi::Array transformOriginJsi(rt, 3);
|
|
194
|
+
|
|
195
|
+
if (transformOrigin.xy[0].unit == UnitType::Percent) {
|
|
196
|
+
const float origin = view.layoutMetrics.frame.size.width * transformOrigin.xy[0].value / 100;
|
|
197
|
+
transformOriginJsi.setValueAtIndex(rt, 0, origin);
|
|
198
|
+
} else {
|
|
199
|
+
transformOriginJsi.setValueAtIndex(rt, 0, transformOrigin.xy[0].value);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (transformOrigin.xy[1].unit == UnitType::Percent) {
|
|
203
|
+
const float origin = view.layoutMetrics.frame.size.height * transformOrigin.xy[1].value / 100;
|
|
204
|
+
transformOriginJsi.setValueAtIndex(rt, 1, origin);
|
|
205
|
+
} else {
|
|
206
|
+
transformOriginJsi.setValueAtIndex(rt, 1, transformOrigin.xy[1].value);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
transformOriginJsi.setValueAtIndex(rt, 2, transformOrigin.z);
|
|
210
|
+
|
|
211
|
+
jsiValues.setProperty(rt, "transformOrigin", transformOriginJsi);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void PropsDiffer::diffShadow(jsi::Runtime &rt) {
|
|
215
|
+
const auto &sourceBoxShadows = getBoxShadowsFromProps(rt, sourceViewProps_);
|
|
216
|
+
const auto &targetBoxShadows = getBoxShadowsFromProps(rt, targetViewProps_);
|
|
217
|
+
|
|
218
|
+
if (sourceBoxShadows.size() == targetBoxShadows.size()) {
|
|
219
|
+
const size_t size = sourceBoxShadows.size();
|
|
220
|
+
jsi::Array sourceBoxShadowArray(rt, size), targetBoxShadowArray(rt, size);
|
|
221
|
+
for (int i = 0; i < size; i++) {
|
|
222
|
+
sourceBoxShadowArray.setValueAtIndex(rt, i, sourceBoxShadows[i].currentValue);
|
|
223
|
+
targetBoxShadowArray.setValueAtIndex(rt, i, targetBoxShadows[i].currentValue);
|
|
224
|
+
}
|
|
225
|
+
sourceValues_.setProperty(rt, "boxShadow", sourceBoxShadowArray);
|
|
226
|
+
targetValues_.setProperty(rt, "boxShadow", targetBoxShadowArray);
|
|
227
|
+
} else {
|
|
228
|
+
const size_t size = sourceBoxShadows.size() + targetBoxShadows.size();
|
|
229
|
+
jsi::Array sourceBoxShadowArray(rt, size), targetBoxShadowArray(rt, size);
|
|
230
|
+
for (size_t i = 0; i < sourceBoxShadows.size(); i++) {
|
|
231
|
+
sourceBoxShadowArray.setValueAtIndex(rt, i, sourceBoxShadows[i].currentValue);
|
|
232
|
+
targetBoxShadowArray.setValueAtIndex(rt, i, sourceBoxShadows[i].defaultValue);
|
|
233
|
+
}
|
|
234
|
+
for (size_t i = 0; i < targetBoxShadows.size(); i++) {
|
|
235
|
+
size_t index = i + sourceBoxShadows.size();
|
|
236
|
+
sourceBoxShadowArray.setValueAtIndex(rt, index, targetBoxShadows[i].defaultValue);
|
|
237
|
+
targetBoxShadowArray.setValueAtIndex(rt, index, targetBoxShadows[i].currentValue);
|
|
238
|
+
}
|
|
239
|
+
sourceValues_.setProperty(rt, "boxShadow", sourceBoxShadowArray);
|
|
240
|
+
targetValues_.setProperty(rt, "boxShadow", targetBoxShadowArray);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (sourceViewProps_.shadowColor != targetViewProps_.shadowColor) {
|
|
244
|
+
sourceValues_.setProperty(rt, "shadowColor", toString(sourceViewProps_.shadowColor));
|
|
245
|
+
targetValues_.setProperty(rt, "shadowColor", toString(targetViewProps_.shadowColor));
|
|
246
|
+
}
|
|
247
|
+
if (sourceViewProps_.shadowOffset != targetViewProps_.shadowOffset) {
|
|
248
|
+
jsi::Object sourceShadowOffset(rt), targetShadowOffset(rt);
|
|
249
|
+
sourceShadowOffset.setProperty(rt, "width", sourceViewProps_.shadowOffset.width);
|
|
250
|
+
sourceShadowOffset.setProperty(rt, "height", sourceViewProps_.shadowOffset.height);
|
|
251
|
+
targetShadowOffset.setProperty(rt, "width", targetViewProps_.shadowOffset.width);
|
|
252
|
+
targetShadowOffset.setProperty(rt, "height", targetViewProps_.shadowOffset.height);
|
|
253
|
+
sourceValues_.setProperty(rt, "shadowOffset", sourceShadowOffset);
|
|
254
|
+
targetValues_.setProperty(rt, "shadowOffset", targetShadowOffset);
|
|
255
|
+
}
|
|
256
|
+
if (sourceViewProps_.shadowOpacity != targetViewProps_.shadowOpacity) {
|
|
257
|
+
sourceValues_.setProperty(rt, "shadowOpacity", sourceViewProps_.shadowOpacity);
|
|
258
|
+
targetValues_.setProperty(rt, "shadowOpacity", targetViewProps_.shadowOpacity);
|
|
259
|
+
}
|
|
260
|
+
if (sourceViewProps_.shadowRadius != targetViewProps_.shadowRadius) {
|
|
261
|
+
sourceValues_.setProperty(rt, "shadowRadius", sourceViewProps_.shadowRadius);
|
|
262
|
+
targetValues_.setProperty(rt, "shadowRadius", targetViewProps_.shadowRadius);
|
|
263
|
+
}
|
|
264
|
+
#ifdef ANDROID
|
|
265
|
+
if (sourceViewProps_.elevation != targetViewProps_.elevation) {
|
|
266
|
+
sourceValues_.setProperty(rt, "elevation", sourceViewProps_.elevation);
|
|
267
|
+
targetValues_.setProperty(rt, "elevation", targetViewProps_.elevation);
|
|
268
|
+
}
|
|
269
|
+
#endif
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
std::vector<BoxShadowWithDefault> PropsDiffer::getBoxShadowsFromProps(jsi::Runtime &rt, const ViewProps &props) {
|
|
273
|
+
const auto &boxShadows = props.boxShadow;
|
|
274
|
+
std::vector<BoxShadowWithDefault> boxShadowsWithDefault;
|
|
275
|
+
for (const auto &boxShadow : boxShadows) {
|
|
276
|
+
jsi::Object currentBoxShadow(rt), defaultBoxShadow(rt);
|
|
277
|
+
|
|
278
|
+
currentBoxShadow.setProperty(rt, "offsetX", boxShadow.offsetX);
|
|
279
|
+
currentBoxShadow.setProperty(rt, "offsetY", boxShadow.offsetY);
|
|
280
|
+
currentBoxShadow.setProperty(rt, "blurRadius", boxShadow.blurRadius);
|
|
281
|
+
currentBoxShadow.setProperty(rt, "spreadDistance", boxShadow.spreadDistance);
|
|
282
|
+
currentBoxShadow.setProperty(rt, "color", toString(boxShadow.color));
|
|
283
|
+
|
|
284
|
+
defaultBoxShadow.setProperty(rt, "offsetX", 0);
|
|
285
|
+
defaultBoxShadow.setProperty(rt, "offsetY", 0);
|
|
286
|
+
defaultBoxShadow.setProperty(rt, "blurRadius", 0);
|
|
287
|
+
defaultBoxShadow.setProperty(rt, "spreadDistance", 0);
|
|
288
|
+
defaultBoxShadow.setProperty(rt, "color", toString(SharedColor()));
|
|
289
|
+
|
|
290
|
+
boxShadowsWithDefault.emplace_back(currentBoxShadow, defaultBoxShadow);
|
|
291
|
+
}
|
|
292
|
+
return boxShadowsWithDefault;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
void PropsDiffer::diffBorder(jsi::Runtime &rt) {
|
|
296
|
+
const auto &sourceBorderRadii = sourceViewProps_.borderRadii;
|
|
297
|
+
const auto &targetBorderRadii = targetViewProps_.borderRadii;
|
|
298
|
+
diffBorderRadius(sourceBorderRadii.all, targetBorderRadii.all, "borderRadius", rt);
|
|
299
|
+
diffBorderRadius(sourceBorderRadii.topLeft, targetBorderRadii.topLeft, "borderTopLeftRadius", rt);
|
|
300
|
+
diffBorderRadius(sourceBorderRadii.topRight, targetBorderRadii.topRight, "borderTopRightRadius", rt);
|
|
301
|
+
diffBorderRadius(sourceBorderRadii.bottomLeft, targetBorderRadii.bottomLeft, "borderBottomLeftRadius", rt);
|
|
302
|
+
diffBorderRadius(sourceBorderRadii.bottomRight, targetBorderRadii.bottomRight, "borderBottomRightRadius", rt);
|
|
303
|
+
diffBorderRadius(sourceBorderRadii.topStart, targetBorderRadii.topStart, "borderTopStartRadius", rt);
|
|
304
|
+
diffBorderRadius(sourceBorderRadii.topEnd, targetBorderRadii.topEnd, "borderTopEndRadius", rt);
|
|
305
|
+
diffBorderRadius(sourceBorderRadii.bottomStart, targetBorderRadii.bottomStart, "borderBottomStartRadius", rt);
|
|
306
|
+
diffBorderRadius(sourceBorderRadii.bottomEnd, targetBorderRadii.bottomEnd, "borderBottomEndRadius", rt);
|
|
307
|
+
diffBorderRadius(sourceBorderRadii.endEnd, targetBorderRadii.endEnd, "borderEndEndRadius", rt);
|
|
308
|
+
diffBorderRadius(sourceBorderRadii.endStart, targetBorderRadii.endStart, "borderEndStartRadius", rt);
|
|
309
|
+
diffBorderRadius(sourceBorderRadii.startEnd, targetBorderRadii.startEnd, "borderStartEndRadius", rt);
|
|
310
|
+
diffBorderRadius(sourceBorderRadii.startStart, targetBorderRadii.startStart, "borderStartStartRadius", rt);
|
|
311
|
+
|
|
312
|
+
const auto &sourceBorderWidths = sourceViewProps_.getBorderWidths();
|
|
313
|
+
const auto &targetBorderWidths = targetViewProps_.getBorderWidths();
|
|
314
|
+
const auto defaultSourceWidth = sourceBorderWidths.all.value_or(0);
|
|
315
|
+
const auto defaultTargetWidth = targetBorderWidths.all.value_or(0);
|
|
316
|
+
diffBorderWidth(
|
|
317
|
+
sourceBorderWidths.all, targetBorderWidths.all, "borderWidth", rt, defaultSourceWidth, defaultTargetWidth);
|
|
318
|
+
diffBorderWidth(
|
|
319
|
+
sourceBorderWidths.left, targetBorderWidths.left, "borderLeftWidth", rt, defaultSourceWidth, defaultTargetWidth);
|
|
320
|
+
diffBorderWidth(
|
|
321
|
+
sourceBorderWidths.right,
|
|
322
|
+
targetBorderWidths.right,
|
|
323
|
+
"borderRightWidth",
|
|
324
|
+
rt,
|
|
325
|
+
defaultSourceWidth,
|
|
326
|
+
defaultTargetWidth);
|
|
327
|
+
diffBorderWidth(
|
|
328
|
+
sourceBorderWidths.top, targetBorderWidths.top, "borderTopWidth", rt, defaultSourceWidth, defaultTargetWidth);
|
|
329
|
+
diffBorderWidth(
|
|
330
|
+
sourceBorderWidths.bottom,
|
|
331
|
+
targetBorderWidths.bottom,
|
|
332
|
+
"borderBottomWidth",
|
|
333
|
+
rt,
|
|
334
|
+
defaultSourceWidth,
|
|
335
|
+
defaultTargetWidth);
|
|
336
|
+
|
|
337
|
+
const auto &sourceBorderColors = sourceViewProps_.borderColors;
|
|
338
|
+
const auto &targetBorderColors = targetViewProps_.borderColors;
|
|
339
|
+
diffBorderColors(sourceBorderColors.all, targetBorderColors.all, "borderColor", rt);
|
|
340
|
+
diffBorderColors(sourceBorderColors.left, targetBorderColors.left, "borderLeftColor", rt);
|
|
341
|
+
diffBorderColors(sourceBorderColors.right, targetBorderColors.right, "borderRightColor", rt);
|
|
342
|
+
diffBorderColors(sourceBorderColors.top, targetBorderColors.top, "borderTopColor", rt);
|
|
343
|
+
diffBorderColors(sourceBorderColors.bottom, targetBorderColors.bottom, "borderBottomColor", rt);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
void PropsDiffer::diffBorderRadius(
|
|
347
|
+
const std::optional<react::ValueUnit> &sourceValue,
|
|
348
|
+
const std::optional<react::ValueUnit> &targetValue,
|
|
349
|
+
const char *name,
|
|
350
|
+
jsi::Runtime &rt) {
|
|
351
|
+
ValueUnit defaultValue;
|
|
352
|
+
const auto &source = sourceValue.value_or(defaultValue).value;
|
|
353
|
+
const auto &target = targetValue.value_or(defaultValue).value;
|
|
354
|
+
if (source == target) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
// In React Native, we can't set asymmetric border radii for the edges of a
|
|
358
|
+
// corner using pixels. This limitation means we can't properly animate
|
|
359
|
+
// between units in percentages and pixels.
|
|
360
|
+
if (targetValue.value_or(defaultValue).unit == UnitType::Percent) {
|
|
361
|
+
if (sourceValue.has_value()) {
|
|
362
|
+
sourceValues_.setProperty(rt, name, std::to_string(source) + "%");
|
|
363
|
+
} else {
|
|
364
|
+
const auto &defaultRadius = sourceViewProps_.borderRadii.all.value_or(defaultValue).value;
|
|
365
|
+
sourceValues_.setProperty(rt, name, std::to_string(defaultRadius) + "%");
|
|
366
|
+
}
|
|
367
|
+
if (targetValue.has_value()) {
|
|
368
|
+
targetValues_.setProperty(rt, name, std::to_string(target) + "%");
|
|
369
|
+
} else {
|
|
370
|
+
const auto &defaultRadius = targetViewProps_.borderRadii.all.value_or(defaultValue).value;
|
|
371
|
+
targetValues_.setProperty(rt, name, std::to_string(defaultRadius) + "%");
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
if (sourceValue.has_value()) {
|
|
375
|
+
sourceValues_.setProperty(rt, name, source);
|
|
376
|
+
} else {
|
|
377
|
+
const auto &defaultRadius = sourceViewProps_.borderRadii.all.value_or(defaultValue).value;
|
|
378
|
+
sourceValues_.setProperty(rt, name, defaultRadius);
|
|
379
|
+
}
|
|
380
|
+
if (targetValue.has_value()) {
|
|
381
|
+
targetValues_.setProperty(rt, name, target);
|
|
382
|
+
} else {
|
|
383
|
+
const auto &defaultRadius = targetViewProps_.borderRadii.all.value_or(defaultValue).value;
|
|
384
|
+
targetValues_.setProperty(rt, name, defaultRadius);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
void PropsDiffer::diffBorderWidth(
|
|
390
|
+
const std::optional<react::Float> &sourceValue,
|
|
391
|
+
const std::optional<react::Float> &targetValue,
|
|
392
|
+
const char *name,
|
|
393
|
+
jsi::Runtime &rt,
|
|
394
|
+
float defaultSourceWidth,
|
|
395
|
+
float defaultTargetWidth) {
|
|
396
|
+
const auto source = sourceValue.value_or(0);
|
|
397
|
+
const auto target = targetValue.value_or(0);
|
|
398
|
+
if (source != target) {
|
|
399
|
+
if (sourceValue.has_value()) {
|
|
400
|
+
sourceValues_.setProperty(rt, name, source);
|
|
401
|
+
} else {
|
|
402
|
+
sourceValues_.setProperty(rt, name, defaultSourceWidth);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (targetValue.has_value()) {
|
|
406
|
+
targetValues_.setProperty(rt, name, target);
|
|
407
|
+
} else {
|
|
408
|
+
targetValues_.setProperty(rt, name, defaultTargetWidth);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
void PropsDiffer::diffBorderColors(
|
|
414
|
+
const std::optional<react::SharedColor> &sourceValue,
|
|
415
|
+
const std::optional<react::SharedColor> &targetValue,
|
|
416
|
+
const char *name,
|
|
417
|
+
jsi::Runtime &rt) {
|
|
418
|
+
SharedColor defaultValue;
|
|
419
|
+
const auto &source = sourceValue.value_or(defaultValue);
|
|
420
|
+
const auto &target = targetValue.value_or(defaultValue);
|
|
421
|
+
if (source != target) {
|
|
422
|
+
if (sourceValue.has_value()) {
|
|
423
|
+
sourceValues_.setProperty(rt, name, toString(source));
|
|
424
|
+
} else {
|
|
425
|
+
auto const &maybeDefaultColor = sourceViewProps_.borderColors.all.value_or(defaultValue);
|
|
426
|
+
sourceValues_.setProperty(rt, name, toString(maybeDefaultColor));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (targetValue.has_value()) {
|
|
430
|
+
targetValues_.setProperty(rt, name, toString(target));
|
|
431
|
+
} else {
|
|
432
|
+
auto const &maybeDefaultColor = targetViewProps_.borderColors.all.value_or(defaultValue);
|
|
433
|
+
targetValues_.setProperty(rt, name, toString(maybeDefaultColor));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Copied from
|
|
439
|
+
// https://github.com/facebook/react-native/blob/v0.80.0-rc.5/packages/react-native/ReactCommon/react/renderer/core/graphicsConversions.h#L47
|
|
440
|
+
// I needed to manually apply a patch for unnecessary alpha channel
|
|
441
|
+
// normalization.
|
|
442
|
+
inline std::string PropsDiffer::toString(const SharedColor &value) {
|
|
443
|
+
ColorComponents components = colorComponentsFromColor(value);
|
|
444
|
+
std::array<char, 255> buffer{};
|
|
445
|
+
std::snprintf(
|
|
446
|
+
buffer.data(),
|
|
447
|
+
buffer.size(),
|
|
448
|
+
"rgba(%.0f, %.0f, %.0f, %f)",
|
|
449
|
+
components.red * 255.f,
|
|
450
|
+
components.green * 255.f,
|
|
451
|
+
components.blue * 255.f,
|
|
452
|
+
components.alpha);
|
|
453
|
+
return buffer.data();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
} // namespace reanimated
|