react-native-reanimated 4.0.1 → 4.0.3
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/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +13 -8
- package/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +13 -11
- package/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +4 -3
- package/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +13 -14
- package/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +4 -2
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +2 -2
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +207 -23
- package/android/build.gradle +11 -15
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +93 -8
- package/lib/module/animation/spring/springUtils.js +3 -1
- package/lib/module/animation/spring/springUtils.js.map +1 -1
- package/lib/module/createAnimatedComponent/AnimatedComponent.js +0 -10
- package/lib/module/createAnimatedComponent/AnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js +0 -5
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js.map +1 -1
- package/lib/module/createAnimatedComponent/NativeEventsManager.js +1 -1
- package/lib/module/createAnimatedComponent/NativeEventsManager.js.map +1 -1
- package/lib/module/css/managers/CSSAnimationsManager.web.js +3 -1
- package/lib/module/css/managers/CSSAnimationsManager.web.js.map +1 -1
- package/lib/module/initializers.js +6 -1
- package/lib/module/initializers.js.map +1 -1
- package/lib/module/layoutReanimation/animationsManager.js +8 -5
- package/lib/module/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/layoutReanimation/web/animationParser.js.map +1 -1
- package/lib/module/layoutReanimation/web/config.js.map +1 -1
- package/lib/module/layoutReanimation/web/createAnimation.js +12 -0
- package/lib/module/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/platform-specific/jsVersion.js +1 -1
- package/lib/typescript/animation/spring/springUtils.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/AnimatedComponent.d.ts +0 -1
- package/lib/typescript/createAnimatedComponent/AnimatedComponent.d.ts.map +1 -1
- package/lib/typescript/createAnimatedComponent/JSPropsUpdater.d.ts +0 -1
- package/lib/typescript/createAnimatedComponent/JSPropsUpdater.d.ts.map +1 -1
- package/lib/typescript/css/managers/CSSAnimationsManager.web.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/animationsManager.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/animationParser.d.ts +3 -0
- package/lib/typescript/layoutReanimation/web/animationParser.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/config.d.ts +1 -1
- package/lib/typescript/layoutReanimation/web/config.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/createAnimation.d.ts.map +1 -1
- package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
- package/package.json +2 -2
- package/scripts/reanimated_utils.rb +1 -1
- package/src/animation/spring/springUtils.ts +3 -4
- package/src/createAnimatedComponent/AnimatedComponent.tsx +0 -16
- package/src/createAnimatedComponent/JSPropsUpdater.ts +0 -6
- package/src/createAnimatedComponent/NativeEventsManager.ts +1 -1
- package/src/css/managers/CSSAnimationsManager.web.ts +3 -1
- package/src/initializers.ts +5 -1
- package/src/layoutReanimation/animationsManager.ts +8 -5
- package/src/layoutReanimation/web/animationParser.ts +3 -0
- package/src/layoutReanimation/web/config.ts +4 -1
- package/src/layoutReanimation/web/createAnimation.ts +15 -0
- package/src/platform-specific/jsVersion.ts +1 -1
|
@@ -45,14 +45,19 @@ void ArrayPropertiesInterpolator::updateKeyframesFromStyleChange(
|
|
|
45
45
|
const folly::dynamic &oldStyleValue,
|
|
46
46
|
const folly::dynamic &newStyleValue,
|
|
47
47
|
const folly::dynamic &lastUpdateValue) {
|
|
48
|
-
const
|
|
49
|
-
const auto
|
|
50
|
-
|
|
51
|
-
const auto
|
|
52
|
-
|
|
48
|
+
const auto emptyArray = folly::dynamic::array();
|
|
49
|
+
const auto null = folly::dynamic();
|
|
50
|
+
|
|
51
|
+
const auto &oldStyleArray =
|
|
52
|
+
oldStyleValue.empty() ? emptyArray : oldStyleValue;
|
|
53
|
+
const auto &newStyleArray =
|
|
54
|
+
newStyleValue.empty() ? emptyArray : newStyleValue;
|
|
55
|
+
const auto &lastUpdateArray =
|
|
56
|
+
lastUpdateValue.empty() ? emptyArray : lastUpdateValue;
|
|
53
57
|
|
|
54
58
|
const size_t oldSize = oldStyleArray.size();
|
|
55
59
|
const size_t newSize = newStyleArray.size();
|
|
60
|
+
const size_t lastSize = lastUpdateArray.size();
|
|
56
61
|
const size_t valuesCount = std::max(oldSize, newSize);
|
|
57
62
|
|
|
58
63
|
resizeInterpolators(valuesCount);
|
|
@@ -61,9 +66,9 @@ void ArrayPropertiesInterpolator::updateKeyframesFromStyleChange(
|
|
|
61
66
|
// These index checks ensure that interpolation works between 2 arrays
|
|
62
67
|
// with different lengths
|
|
63
68
|
interpolators_[i]->updateKeyframesFromStyleChange(
|
|
64
|
-
i < oldSize ? oldStyleArray[i] :
|
|
65
|
-
i < newSize ? newStyleArray[i] :
|
|
66
|
-
i <
|
|
69
|
+
i < oldSize ? oldStyleArray[i] : null,
|
|
70
|
+
i < newSize ? newStyleArray[i] : null,
|
|
71
|
+
i < lastSize ? lastUpdateArray[i] : null);
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
|
|
@@ -37,14 +37,16 @@ void RecordPropertiesInterpolator::updateKeyframesFromStyleChange(
|
|
|
37
37
|
const folly::dynamic &newStyleValue,
|
|
38
38
|
const folly::dynamic &lastUpdateValue) {
|
|
39
39
|
// TODO - maybe add a possibility to remove interpolators that are no longer
|
|
40
|
-
// used
|
|
41
|
-
const folly::dynamic
|
|
42
|
-
const folly::dynamic
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
40
|
+
// used (for now, for simplicity, we only add new ones)
|
|
41
|
+
const folly::dynamic emptyObject = folly::dynamic::object();
|
|
42
|
+
const auto null = folly::dynamic();
|
|
43
|
+
|
|
44
|
+
const auto &oldStyleObject =
|
|
45
|
+
oldStyleValue.empty() ? emptyObject : oldStyleValue;
|
|
46
|
+
const auto &newStyleObject =
|
|
47
|
+
newStyleValue.empty() ? emptyObject : newStyleValue;
|
|
48
|
+
const auto &lastUpdateObject =
|
|
49
|
+
lastUpdateValue.empty() ? emptyObject : lastUpdateValue;
|
|
48
50
|
|
|
49
51
|
std::unordered_set<std::string> propertyNamesSet;
|
|
50
52
|
for (const auto &key : oldStyleObject.keys()) {
|
|
@@ -57,9 +59,9 @@ void RecordPropertiesInterpolator::updateKeyframesFromStyleChange(
|
|
|
57
59
|
for (const auto &propertyName : propertyNamesSet) {
|
|
58
60
|
maybeCreateInterpolator(propertyName);
|
|
59
61
|
interpolators_[propertyName]->updateKeyframesFromStyleChange(
|
|
60
|
-
oldStyleObject.getDefault(propertyName,
|
|
61
|
-
newStyleObject.getDefault(propertyName,
|
|
62
|
-
lastUpdateObject.getDefault(propertyName,
|
|
62
|
+
oldStyleObject.getDefault(propertyName, null),
|
|
63
|
+
newStyleObject.getDefault(propertyName, null),
|
|
64
|
+
lastUpdateObject.getDefault(propertyName, null));
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -87,9 +87,10 @@ void TransitionStyleInterpolator::updateInterpolatedProperties(
|
|
|
87
87
|
const auto &newValue = newPropsObj.getDefault(propertyName, empty);
|
|
88
88
|
// Pass lastValue only if the interpolator is updated (no new interpolator
|
|
89
89
|
// was created), otherwise pass an empty value
|
|
90
|
-
const auto &lastValue =
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const auto &lastValue =
|
|
91
|
+
(shouldCreateInterpolator || lastUpdateValue.empty())
|
|
92
|
+
? empty
|
|
93
|
+
: lastUpdateValue.getDefault(propertyName, empty);
|
|
93
94
|
|
|
94
95
|
it->second->updateKeyframesFromStyleChange(oldValue, newValue, lastValue);
|
|
95
96
|
}
|
|
@@ -57,25 +57,24 @@ void UpdatesRegistryManager::unmarkNodeAsRemovable(Tag viewTag) {
|
|
|
57
57
|
|
|
58
58
|
void UpdatesRegistryManager::handleNodeRemovals(
|
|
59
59
|
const RootShadowNode &rootShadowNode) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const auto &ancestors = family.getAncestors(rootShadowNode);
|
|
65
|
-
|
|
66
|
-
// Skip if the node hasn't been removed
|
|
67
|
-
if (!ancestors.empty()) {
|
|
68
|
-
++it;
|
|
60
|
+
RemovableShadowNodes remainingShadowNodes;
|
|
61
|
+
|
|
62
|
+
for (const auto &[tag, shadowNode] : removableShadowNodes_) {
|
|
63
|
+
if (!shadowNode) {
|
|
69
64
|
continue;
|
|
70
65
|
}
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
if (shadowNode->getFamily().getAncestors(rootShadowNode).empty()) {
|
|
68
|
+
for (auto ®istry : registries_) {
|
|
69
|
+
registry->remove(tag);
|
|
70
|
+
}
|
|
71
|
+
staticPropsRegistry_->remove(tag);
|
|
72
|
+
} else {
|
|
73
|
+
remainingShadowNodes.emplace(tag, shadowNode);
|
|
75
74
|
}
|
|
76
|
-
staticPropsRegistry_->remove(tag);
|
|
77
|
-
it = removableShadowNodes_.erase(it);
|
|
78
75
|
}
|
|
76
|
+
|
|
77
|
+
removableShadowNodes_ = std::move(remainingShadowNodes);
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
PropsMap UpdatesRegistryManager::collectProps() {
|
|
@@ -45,11 +45,13 @@ class UpdatesRegistryManager {
|
|
|
45
45
|
#endif
|
|
46
46
|
|
|
47
47
|
private:
|
|
48
|
+
using RemovableShadowNodes =
|
|
49
|
+
std::unordered_map<Tag, std::shared_ptr<const ShadowNode>>;
|
|
50
|
+
|
|
48
51
|
mutable std::mutex mutex_;
|
|
49
52
|
std::atomic<bool> isPaused_;
|
|
50
53
|
std::atomic<bool> shouldCommitAfterPause_;
|
|
51
|
-
|
|
52
|
-
removableShadowNodes_;
|
|
54
|
+
RemovableShadowNodes removableShadowNodes_;
|
|
53
55
|
std::vector<std::shared_ptr<UpdatesRegistry>> registries_;
|
|
54
56
|
const std::shared_ptr<StaticPropsRegistry> staticPropsRegistry_;
|
|
55
57
|
|
|
@@ -44,14 +44,14 @@ struct LayoutAnimationsProxy
|
|
|
44
44
|
mutable std::unordered_map<Tag, int> leastRemoved;
|
|
45
45
|
mutable std::vector<Tag> finishedAnimationTags_;
|
|
46
46
|
std::shared_ptr<LayoutAnimationsManager> layoutAnimationsManager_;
|
|
47
|
-
|
|
47
|
+
std::shared_ptr<const ContextContainer> contextContainer_;
|
|
48
48
|
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
|
|
49
49
|
jsi::Runtime &uiRuntime_;
|
|
50
50
|
const std::shared_ptr<UIScheduler> uiScheduler_;
|
|
51
51
|
LayoutAnimationsProxy(
|
|
52
52
|
std::shared_ptr<LayoutAnimationsManager> layoutAnimationsManager,
|
|
53
53
|
SharedComponentDescriptorRegistry componentDescriptorRegistry,
|
|
54
|
-
|
|
54
|
+
std::shared_ptr<const ContextContainer> contextContainer,
|
|
55
55
|
jsi::Runtime &uiRuntime,
|
|
56
56
|
const std::shared_ptr<UIScheduler> uiScheduler)
|
|
57
57
|
: layoutAnimationsManager_(layoutAnimationsManager),
|
|
@@ -408,6 +408,7 @@ void ReanimatedModuleProxy::setViewStyle(
|
|
|
408
408
|
void ReanimatedModuleProxy::markNodeAsRemovable(
|
|
409
409
|
jsi::Runtime &rt,
|
|
410
410
|
const jsi::Value &shadowNodeWrapper) {
|
|
411
|
+
auto lock = updatesRegistryManager_->lock();
|
|
411
412
|
auto shadowNode = shadowNodeFromValue(rt, shadowNodeWrapper);
|
|
412
413
|
updatesRegistryManager_->markNodeAsRemovable(shadowNode);
|
|
413
414
|
}
|
|
@@ -415,6 +416,7 @@ void ReanimatedModuleProxy::markNodeAsRemovable(
|
|
|
415
416
|
void ReanimatedModuleProxy::unmarkNodeAsRemovable(
|
|
416
417
|
jsi::Runtime &rt,
|
|
417
418
|
const jsi::Value &viewTag) {
|
|
419
|
+
auto lock = updatesRegistryManager_->lock();
|
|
418
420
|
updatesRegistryManager_->unmarkNodeAsRemovable(viewTag.asNumber());
|
|
419
421
|
}
|
|
420
422
|
|
|
@@ -674,12 +676,35 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
674
676
|
if constexpr (StaticFeatureFlags::getFlag(
|
|
675
677
|
"ANDROID_SYNCHRONOUSLY_UPDATE_UI_PROPS")) {
|
|
676
678
|
static const std::unordered_set<std::string> synchronousProps = {
|
|
677
|
-
"transform",
|
|
678
679
|
"opacity",
|
|
679
|
-
"
|
|
680
|
+
"elevation",
|
|
681
|
+
"zIndex",
|
|
682
|
+
// "shadowOpacity", // not supported on Android
|
|
683
|
+
// "shadowRadius", // not supported on Android
|
|
680
684
|
"backgroundColor",
|
|
681
|
-
"borderColor",
|
|
682
685
|
// "color", // TODO: fix animating color of Animated.Text
|
|
686
|
+
"tintColor",
|
|
687
|
+
"borderRadius",
|
|
688
|
+
"borderTopLeftRadius",
|
|
689
|
+
"borderTopRightRadius",
|
|
690
|
+
"borderTopStartRadius",
|
|
691
|
+
"borderTopEndRadius",
|
|
692
|
+
"borderBottomLeftRadius",
|
|
693
|
+
"borderBottomRightRadius",
|
|
694
|
+
"borderBottomStartRadius",
|
|
695
|
+
"borderBottomEndRadius",
|
|
696
|
+
"borderStartStartRadius",
|
|
697
|
+
"borderStartEndRadius",
|
|
698
|
+
"borderEndStartRadius",
|
|
699
|
+
"borderEndEndRadius",
|
|
700
|
+
"borderColor",
|
|
701
|
+
"borderTopColor",
|
|
702
|
+
"borderBottomColor",
|
|
703
|
+
"borderLeftColor",
|
|
704
|
+
"borderRightColor",
|
|
705
|
+
"borderStartColor",
|
|
706
|
+
"borderEndColor",
|
|
707
|
+
"transform",
|
|
683
708
|
};
|
|
684
709
|
|
|
685
710
|
// NOTE: Keep in sync with NativeProxy.java
|
|
@@ -687,11 +712,38 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
687
712
|
static constexpr auto CMD_START_OF_TRANSFORM = 2;
|
|
688
713
|
static constexpr auto CMD_END_OF_TRANSFORM = 3;
|
|
689
714
|
static constexpr auto CMD_END_OF_VIEW = 4;
|
|
715
|
+
|
|
690
716
|
static constexpr auto CMD_OPACITY = 10;
|
|
691
|
-
static constexpr auto
|
|
692
|
-
static constexpr auto
|
|
693
|
-
static constexpr auto
|
|
694
|
-
static constexpr auto
|
|
717
|
+
static constexpr auto CMD_ELEVATION = 11;
|
|
718
|
+
static constexpr auto CMD_Z_INDEX = 12;
|
|
719
|
+
static constexpr auto CMD_SHADOW_OPACITY = 13;
|
|
720
|
+
static constexpr auto CMD_SHADOW_RADIUS = 14;
|
|
721
|
+
static constexpr auto CMD_BACKGROUND_COLOR = 15;
|
|
722
|
+
static constexpr auto CMD_COLOR = 16;
|
|
723
|
+
static constexpr auto CMD_TINT_COLOR = 17;
|
|
724
|
+
|
|
725
|
+
static constexpr auto CMD_BORDER_RADIUS = 20;
|
|
726
|
+
static constexpr auto CMD_BORDER_TOP_LEFT_RADIUS = 21;
|
|
727
|
+
static constexpr auto CMD_BORDER_TOP_RIGHT_RADIUS = 22;
|
|
728
|
+
static constexpr auto CMD_BORDER_TOP_START_RADIUS = 23;
|
|
729
|
+
static constexpr auto CMD_BORDER_TOP_END_RADIUS = 24;
|
|
730
|
+
static constexpr auto CMD_BORDER_BOTTOM_LEFT_RADIUS = 25;
|
|
731
|
+
static constexpr auto CMD_BORDER_BOTTOM_RIGHT_RADIUS = 26;
|
|
732
|
+
static constexpr auto CMD_BORDER_BOTTOM_START_RADIUS = 27;
|
|
733
|
+
static constexpr auto CMD_BORDER_BOTTOM_END_RADIUS = 28;
|
|
734
|
+
static constexpr auto CMD_BORDER_START_START_RADIUS = 29;
|
|
735
|
+
static constexpr auto CMD_BORDER_START_END_RADIUS = 30;
|
|
736
|
+
static constexpr auto CMD_BORDER_END_START_RADIUS = 31;
|
|
737
|
+
static constexpr auto CMD_BORDER_END_END_RADIUS = 32;
|
|
738
|
+
|
|
739
|
+
static constexpr auto CMD_BORDER_COLOR = 40;
|
|
740
|
+
static constexpr auto CMD_BORDER_TOP_COLOR = 41;
|
|
741
|
+
static constexpr auto CMD_BORDER_BOTTOM_COLOR = 42;
|
|
742
|
+
static constexpr auto CMD_BORDER_LEFT_COLOR = 43;
|
|
743
|
+
static constexpr auto CMD_BORDER_RIGHT_COLOR = 44;
|
|
744
|
+
static constexpr auto CMD_BORDER_START_COLOR = 45;
|
|
745
|
+
static constexpr auto CMD_BORDER_END_COLOR = 46;
|
|
746
|
+
|
|
695
747
|
static constexpr auto CMD_TRANSFORM_TRANSLATE_X = 100;
|
|
696
748
|
static constexpr auto CMD_TRANSFORM_TRANSLATE_Y = 101;
|
|
697
749
|
static constexpr auto CMD_TRANSFORM_SCALE = 102;
|
|
@@ -705,6 +757,7 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
705
757
|
static constexpr auto CMD_TRANSFORM_SKEW_Y = 110;
|
|
706
758
|
static constexpr auto CMD_TRANSFORM_MATRIX = 111;
|
|
707
759
|
static constexpr auto CMD_TRANSFORM_PERSPECTIVE = 112;
|
|
760
|
+
|
|
708
761
|
static constexpr auto CMD_UNIT_DEG = 200;
|
|
709
762
|
static constexpr auto CMD_UNIT_RAD = 201;
|
|
710
763
|
static constexpr auto CMD_UNIT_PX = 202;
|
|
@@ -713,47 +766,135 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
713
766
|
const auto propNameToCommand = [](const std::string &name) {
|
|
714
767
|
if (name == "opacity")
|
|
715
768
|
return CMD_OPACITY;
|
|
716
|
-
|
|
717
|
-
|
|
769
|
+
|
|
770
|
+
if (name == "elevation")
|
|
771
|
+
return CMD_ELEVATION;
|
|
772
|
+
|
|
773
|
+
if (name == "zIndex")
|
|
774
|
+
return CMD_Z_INDEX;
|
|
775
|
+
|
|
776
|
+
if (name == "shadowOpacity")
|
|
777
|
+
return CMD_SHADOW_OPACITY;
|
|
778
|
+
|
|
779
|
+
if (name == "shadowRadius")
|
|
780
|
+
return CMD_SHADOW_RADIUS;
|
|
781
|
+
|
|
718
782
|
if (name == "backgroundColor")
|
|
719
783
|
return CMD_BACKGROUND_COLOR;
|
|
720
|
-
|
|
721
|
-
return CMD_BORDER_COLOR;
|
|
784
|
+
|
|
722
785
|
if (name == "color")
|
|
723
786
|
return CMD_COLOR;
|
|
787
|
+
|
|
788
|
+
if (name == "tintColor")
|
|
789
|
+
return CMD_TINT_COLOR;
|
|
790
|
+
|
|
791
|
+
if (name == "borderRadius")
|
|
792
|
+
return CMD_BORDER_RADIUS;
|
|
793
|
+
|
|
794
|
+
if (name == "borderTopLeftRadius")
|
|
795
|
+
return CMD_BORDER_TOP_LEFT_RADIUS;
|
|
796
|
+
|
|
797
|
+
if (name == "borderTopRightRadius")
|
|
798
|
+
return CMD_BORDER_TOP_RIGHT_RADIUS;
|
|
799
|
+
|
|
800
|
+
if (name == "borderTopStartRadius")
|
|
801
|
+
return CMD_BORDER_TOP_START_RADIUS;
|
|
802
|
+
|
|
803
|
+
if (name == "borderTopEndRadius")
|
|
804
|
+
return CMD_BORDER_TOP_END_RADIUS;
|
|
805
|
+
|
|
806
|
+
if (name == "borderBottomLeftRadius")
|
|
807
|
+
return CMD_BORDER_BOTTOM_LEFT_RADIUS;
|
|
808
|
+
|
|
809
|
+
if (name == "borderBottomRightRadius")
|
|
810
|
+
return CMD_BORDER_BOTTOM_RIGHT_RADIUS;
|
|
811
|
+
|
|
812
|
+
if (name == "borderBottomStartRadius")
|
|
813
|
+
return CMD_BORDER_BOTTOM_START_RADIUS;
|
|
814
|
+
|
|
815
|
+
if (name == "borderBottomEndRadius")
|
|
816
|
+
return CMD_BORDER_BOTTOM_END_RADIUS;
|
|
817
|
+
|
|
818
|
+
if (name == "borderStartStartRadius")
|
|
819
|
+
return CMD_BORDER_START_START_RADIUS;
|
|
820
|
+
|
|
821
|
+
if (name == "borderStartEndRadius")
|
|
822
|
+
return CMD_BORDER_START_END_RADIUS;
|
|
823
|
+
|
|
824
|
+
if (name == "borderEndStartRadius")
|
|
825
|
+
return CMD_BORDER_END_START_RADIUS;
|
|
826
|
+
|
|
827
|
+
if (name == "borderEndEndRadius")
|
|
828
|
+
return CMD_BORDER_END_END_RADIUS;
|
|
829
|
+
|
|
830
|
+
if (name == "borderColor")
|
|
831
|
+
return CMD_BORDER_COLOR;
|
|
832
|
+
|
|
833
|
+
if (name == "borderTopColor")
|
|
834
|
+
return CMD_BORDER_TOP_COLOR;
|
|
835
|
+
|
|
836
|
+
if (name == "borderBottomColor")
|
|
837
|
+
return CMD_BORDER_BOTTOM_COLOR;
|
|
838
|
+
|
|
839
|
+
if (name == "borderLeftColor")
|
|
840
|
+
return CMD_BORDER_LEFT_COLOR;
|
|
841
|
+
|
|
842
|
+
if (name == "borderRightColor")
|
|
843
|
+
return CMD_BORDER_RIGHT_COLOR;
|
|
844
|
+
|
|
845
|
+
if (name == "borderStartColor")
|
|
846
|
+
return CMD_BORDER_START_COLOR;
|
|
847
|
+
|
|
848
|
+
if (name == "borderEndColor")
|
|
849
|
+
return CMD_BORDER_END_COLOR;
|
|
850
|
+
|
|
724
851
|
if (name == "transform")
|
|
725
852
|
return CMD_START_OF_TRANSFORM; // TODO: use CMD_TRANSFORM?
|
|
726
|
-
|
|
853
|
+
|
|
854
|
+
throw std::runtime_error("[Reanimated] Unsupported style: " + name);
|
|
727
855
|
};
|
|
728
856
|
|
|
729
857
|
const auto transformNameToCommand = [](const std::string &name) {
|
|
730
858
|
if (name == "translateX")
|
|
731
859
|
return CMD_TRANSFORM_TRANSLATE_X;
|
|
860
|
+
|
|
732
861
|
if (name == "translateY")
|
|
733
862
|
return CMD_TRANSFORM_TRANSLATE_Y;
|
|
863
|
+
|
|
734
864
|
if (name == "scale")
|
|
735
865
|
return CMD_TRANSFORM_SCALE;
|
|
866
|
+
|
|
736
867
|
if (name == "scaleX")
|
|
737
868
|
return CMD_TRANSFORM_SCALE_X;
|
|
869
|
+
|
|
738
870
|
if (name == "scaleY")
|
|
739
871
|
return CMD_TRANSFORM_SCALE_Y;
|
|
872
|
+
|
|
740
873
|
if (name == "rotate")
|
|
741
874
|
return CMD_TRANSFORM_ROTATE;
|
|
875
|
+
|
|
742
876
|
if (name == "rotateX")
|
|
743
877
|
return CMD_TRANSFORM_ROTATE_X;
|
|
878
|
+
|
|
744
879
|
if (name == "rotateY")
|
|
745
880
|
return CMD_TRANSFORM_ROTATE_Y;
|
|
881
|
+
|
|
746
882
|
if (name == "rotateZ")
|
|
747
883
|
return CMD_TRANSFORM_ROTATE_Z;
|
|
884
|
+
|
|
748
885
|
if (name == "skewX")
|
|
749
886
|
return CMD_TRANSFORM_SKEW_X;
|
|
887
|
+
|
|
750
888
|
if (name == "skewY")
|
|
751
889
|
return CMD_TRANSFORM_SKEW_Y;
|
|
890
|
+
|
|
752
891
|
if (name == "matrix")
|
|
753
892
|
return CMD_TRANSFORM_MATRIX;
|
|
893
|
+
|
|
754
894
|
if (name == "perspective")
|
|
755
895
|
return CMD_TRANSFORM_PERSPECTIVE;
|
|
756
|
-
|
|
896
|
+
|
|
897
|
+
throw std::runtime_error("[Reanimated] Unsupported transform: " + name);
|
|
757
898
|
};
|
|
758
899
|
|
|
759
900
|
UpdatesBatch synchronousUpdatesBatch, shadowTreeUpdatesBatch;
|
|
@@ -787,29 +928,71 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
787
928
|
const auto command = propNameToCommand(key.getString());
|
|
788
929
|
switch (command) {
|
|
789
930
|
case CMD_OPACITY:
|
|
790
|
-
case
|
|
931
|
+
case CMD_ELEVATION:
|
|
932
|
+
case CMD_Z_INDEX:
|
|
933
|
+
case CMD_SHADOW_OPACITY:
|
|
934
|
+
case CMD_SHADOW_RADIUS:
|
|
791
935
|
intBuffer.push_back(command);
|
|
792
936
|
doubleBuffer.push_back(value.asDouble());
|
|
793
937
|
break;
|
|
794
938
|
|
|
795
939
|
case CMD_BACKGROUND_COLOR:
|
|
796
|
-
case CMD_BORDER_COLOR:
|
|
797
940
|
case CMD_COLOR:
|
|
941
|
+
case CMD_TINT_COLOR:
|
|
942
|
+
case CMD_BORDER_COLOR:
|
|
943
|
+
case CMD_BORDER_TOP_COLOR:
|
|
944
|
+
case CMD_BORDER_BOTTOM_COLOR:
|
|
945
|
+
case CMD_BORDER_LEFT_COLOR:
|
|
946
|
+
case CMD_BORDER_RIGHT_COLOR:
|
|
947
|
+
case CMD_BORDER_START_COLOR:
|
|
948
|
+
case CMD_BORDER_END_COLOR:
|
|
798
949
|
intBuffer.push_back(command);
|
|
799
950
|
intBuffer.push_back(value.asInt());
|
|
800
951
|
break;
|
|
801
952
|
|
|
953
|
+
case CMD_BORDER_RADIUS:
|
|
954
|
+
case CMD_BORDER_TOP_LEFT_RADIUS:
|
|
955
|
+
case CMD_BORDER_TOP_RIGHT_RADIUS:
|
|
956
|
+
case CMD_BORDER_TOP_START_RADIUS:
|
|
957
|
+
case CMD_BORDER_TOP_END_RADIUS:
|
|
958
|
+
case CMD_BORDER_BOTTOM_LEFT_RADIUS:
|
|
959
|
+
case CMD_BORDER_BOTTOM_RIGHT_RADIUS:
|
|
960
|
+
case CMD_BORDER_BOTTOM_START_RADIUS:
|
|
961
|
+
case CMD_BORDER_BOTTOM_END_RADIUS:
|
|
962
|
+
case CMD_BORDER_START_START_RADIUS:
|
|
963
|
+
case CMD_BORDER_START_END_RADIUS:
|
|
964
|
+
case CMD_BORDER_END_START_RADIUS:
|
|
965
|
+
case CMD_BORDER_END_END_RADIUS:
|
|
966
|
+
intBuffer.push_back(command);
|
|
967
|
+
if (value.isDouble()) {
|
|
968
|
+
intBuffer.push_back(CMD_UNIT_PX);
|
|
969
|
+
doubleBuffer.push_back(value.getDouble());
|
|
970
|
+
} else if (value.isString()) {
|
|
971
|
+
const auto &valueStr = value.getString();
|
|
972
|
+
if (!valueStr.ends_with("%")) {
|
|
973
|
+
throw std::runtime_error(
|
|
974
|
+
"[Reanimated] Border radius string must be a percentage");
|
|
975
|
+
}
|
|
976
|
+
intBuffer.push_back(CMD_UNIT_PERCENT);
|
|
977
|
+
doubleBuffer.push_back(std::stof(valueStr.substr(0, -1)));
|
|
978
|
+
} else {
|
|
979
|
+
throw std::runtime_error(
|
|
980
|
+
"[Reanimated] Border radius value must be either a number or a string");
|
|
981
|
+
}
|
|
982
|
+
break;
|
|
983
|
+
|
|
802
984
|
case CMD_START_OF_TRANSFORM:
|
|
803
985
|
intBuffer.push_back(command);
|
|
804
986
|
react_native_assert(
|
|
805
|
-
value.isArray() &&
|
|
987
|
+
value.isArray() &&
|
|
988
|
+
"[Reanimated] Transform value must be an array");
|
|
806
989
|
for (const auto &item : value) {
|
|
807
990
|
react_native_assert(
|
|
808
991
|
item.isObject() &&
|
|
809
|
-
"Transform array item must be an object");
|
|
992
|
+
"[Reanimated] Transform array item must be an object");
|
|
810
993
|
react_native_assert(
|
|
811
994
|
item.size() == 1 &&
|
|
812
|
-
"Transform array item must have exactly one key-value pair");
|
|
995
|
+
"[Reanimated] Transform array item must have exactly one key-value pair");
|
|
813
996
|
const auto transformCommand =
|
|
814
997
|
transformNameToCommand(item.keys().begin()->getString());
|
|
815
998
|
const auto &transformValue = *item.values().begin();
|
|
@@ -828,20 +1011,20 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
828
1011
|
intBuffer.push_back(transformCommand);
|
|
829
1012
|
if (transformValue.isDouble()) {
|
|
830
1013
|
intBuffer.push_back(CMD_UNIT_PX);
|
|
831
|
-
doubleBuffer.push_back(transformValue.
|
|
1014
|
+
doubleBuffer.push_back(transformValue.getDouble());
|
|
832
1015
|
} else if (transformValue.isString()) {
|
|
833
1016
|
const auto &transformValueStr =
|
|
834
1017
|
transformValue.getString();
|
|
835
1018
|
if (!transformValueStr.ends_with("%")) {
|
|
836
1019
|
throw std::runtime_error(
|
|
837
|
-
"String translate must be a percentage");
|
|
1020
|
+
"[Reanimated] String translate must be a percentage");
|
|
838
1021
|
}
|
|
839
1022
|
intBuffer.push_back(CMD_UNIT_PERCENT);
|
|
840
1023
|
doubleBuffer.push_back(
|
|
841
1024
|
std::stof(transformValueStr.substr(0, -1)));
|
|
842
1025
|
} else {
|
|
843
1026
|
throw std::runtime_error(
|
|
844
|
-
"Translate value must be a number or a string");
|
|
1027
|
+
"[Reanimated] Translate value must be either a number or a string");
|
|
845
1028
|
}
|
|
846
1029
|
break;
|
|
847
1030
|
}
|
|
@@ -861,7 +1044,8 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
861
1044
|
intBuffer.push_back(CMD_UNIT_RAD);
|
|
862
1045
|
} else {
|
|
863
1046
|
throw std::runtime_error(
|
|
864
|
-
"Unsupported rotation unit: " +
|
|
1047
|
+
"[Reanimated] Unsupported rotation unit: " +
|
|
1048
|
+
transformValueStr);
|
|
865
1049
|
}
|
|
866
1050
|
doubleBuffer.push_back(
|
|
867
1051
|
std::stof(transformValueStr.substr(0, -3)));
|
|
@@ -872,7 +1056,7 @@ void ReanimatedModuleProxy::performOperations() {
|
|
|
872
1056
|
intBuffer.push_back(transformCommand);
|
|
873
1057
|
react_native_assert(
|
|
874
1058
|
transformValue.isArray() &&
|
|
875
|
-
"Matrix must be an array");
|
|
1059
|
+
"[Reanimated] Matrix must be an array");
|
|
876
1060
|
int size = transformValue.size();
|
|
877
1061
|
intBuffer.push_back(size);
|
|
878
1062
|
for (int i = 0; i < size; i++) {
|
package/android/build.gradle
CHANGED
|
@@ -85,18 +85,6 @@ def toPlatformFileString(String path) {
|
|
|
85
85
|
return path
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
def validateWorkletsVersion() {
|
|
89
|
-
def result = providers.exec {
|
|
90
|
-
workingDir(projectDir.path)
|
|
91
|
-
commandLine("node", "./../scripts/validate-worklets-build.js")
|
|
92
|
-
ignoreExitValue = true
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (result.getResult().get().exitValue != 0) {
|
|
96
|
-
throw new GradleException(result.getStandardError().getAsText().get().trim())
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
88
|
def getReanimatedStaticFeatureFlags() {
|
|
101
89
|
def featureFlags = new HashMap<String, String>()
|
|
102
90
|
|
|
@@ -123,6 +111,7 @@ if (isNewArchitectureEnabled()) {
|
|
|
123
111
|
apply plugin: "com.facebook.react"
|
|
124
112
|
}
|
|
125
113
|
|
|
114
|
+
def packageDir = project.projectDir.parentFile
|
|
126
115
|
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
127
116
|
def reactNativeWorkletsRootDir = resolveReactNativeWorkletsDirectory()
|
|
128
117
|
def REACT_NATIVE_MINOR_VERSION = getReactNativeMinorVersion()
|
|
@@ -270,7 +259,6 @@ android {
|
|
|
270
259
|
if (!IS_REANIMATED_EXAMPLE_APP) {
|
|
271
260
|
return
|
|
272
261
|
}
|
|
273
|
-
def packageDir = new File("${project.projectDir}/..")
|
|
274
262
|
|
|
275
263
|
def generated = new File("${compileTask.abi.getCxxBuildFolder()}/compile_commands.json")
|
|
276
264
|
def output = new File("${packageDir}/compile_commands.json")
|
|
@@ -284,7 +272,7 @@ android {
|
|
|
284
272
|
|
|
285
273
|
task assertMinimalReactNativeVersionTask {
|
|
286
274
|
// If you change the minimal React Native version remember to update Compatibility Table in docs
|
|
287
|
-
def minimalReactNativeVersion =
|
|
275
|
+
def minimalReactNativeVersion = 78
|
|
288
276
|
onlyIf { REACT_NATIVE_MINOR_VERSION < minimalReactNativeVersion }
|
|
289
277
|
doFirst {
|
|
290
278
|
throw new GradleException("[Reanimated] Unsupported React Native version. Please use React Native 0.$minimalReactNativeVersion or newer.")
|
|
@@ -302,9 +290,17 @@ task assertNewArchitectureEnabledTask {
|
|
|
302
290
|
|
|
303
291
|
preBuild.dependsOn(assertNewArchitectureEnabledTask)
|
|
304
292
|
|
|
293
|
+
def validateWorkletsBuildResult = providers.exec {
|
|
294
|
+
workingDir(projectDir.path)
|
|
295
|
+
commandLine("node", "./../scripts/validate-worklets-build.js")
|
|
296
|
+
ignoreExitValue = true
|
|
297
|
+
}
|
|
298
|
+
|
|
305
299
|
task assertWorkletsVersionTask {
|
|
306
300
|
doFirst {
|
|
307
|
-
|
|
301
|
+
if (validateWorkletsBuildResult.getResult().get().exitValue != 0) {
|
|
302
|
+
throw new GradleException(validateWorkletsBuildResult.getStandardError().getAsText().get().trim())
|
|
303
|
+
}
|
|
308
304
|
}
|
|
309
305
|
}
|
|
310
306
|
|