react-native-reanimated 4.0.0 → 4.0.2
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/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/RNReanimated.podspec +0 -6
- package/android/CMakeLists.txt +20 -4
- package/android/build.gradle +44 -15
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +93 -8
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +0 -8
- package/lib/module/animation/spring/springUtils.js +3 -1
- package/lib/module/animation/spring/springUtils.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js +0 -5
- package/lib/module/createAnimatedComponent/JSPropsUpdater.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/jestUtils.js +0 -3
- package/lib/module/jestUtils.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/module/specs/index.js +1 -3
- package/lib/module/specs/index.js.map +1 -1
- package/lib/typescript/animation/spring/springUtils.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/jestUtils.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/lib/typescript/platformFunctions/findNodeHandle.web.d.ts +1 -1
- package/lib/typescript/specs/index.d.ts +1 -4
- package/lib/typescript/specs/index.d.ts.map +1 -1
- package/package.json +3 -8
- package/scripts/reanimated_utils.rb +1 -1
- package/src/animation/spring/springUtils.ts +3 -4
- package/src/createAnimatedComponent/JSPropsUpdater.ts +0 -6
- package/src/css/managers/CSSAnimationsManager.web.ts +3 -1
- package/src/initializers.ts +5 -1
- package/src/jestUtils.ts +0 -9
- 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
- package/src/specs/index.ts +1 -6
- package/Common/NativeView/CMakeLists.txt +0 -52
- package/Common/NativeView/react/renderer/components/rnreanimated/ComponentDescriptors.h +0 -17
- package/Common/NativeView/react/renderer/components/rnreanimated/ReanimatedShadowNode.cpp +0 -11
- package/Common/NativeView/react/renderer/components/rnreanimated/ReanimatedShadowNode.h +0 -26
- package/Common/NativeView/react/renderer/components/rnreanimated/ReanimatedViewState.h +0 -23
- package/android/src/main/java/com/swmansion/reanimated/view/ReanimatedView.java +0 -13
- package/android/src/main/java/com/swmansion/reanimated/view/ReanimatedViewManager.java +0 -19
- package/apple/reanimated/apple/view/ReanimatedView.h +0 -11
- package/apple/reanimated/apple/view/ReanimatedView.mm +0 -30
- package/lib/module/specs/ReanimatedNativeComponent.js +0 -7
- package/lib/module/specs/ReanimatedNativeComponent.js.map +0 -1
- package/lib/module/specs/ReanimatedViewProvider.js +0 -5
- package/lib/module/specs/ReanimatedViewProvider.js.map +0 -1
- package/lib/module/specs/ReanimatedViewProvider.native.js +0 -5
- package/lib/module/specs/ReanimatedViewProvider.native.js.map +0 -1
- package/lib/typescript/specs/ReanimatedNativeComponent.d.ts +0 -7
- package/lib/typescript/specs/ReanimatedNativeComponent.d.ts.map +0 -1
- package/lib/typescript/specs/ReanimatedViewProvider.d.ts +0 -4
- package/lib/typescript/specs/ReanimatedViewProvider.d.ts.map +0 -1
- package/lib/typescript/specs/ReanimatedViewProvider.native.d.ts +0 -3
- package/lib/typescript/specs/ReanimatedViewProvider.native.d.ts.map +0 -1
- package/src/specs/ReanimatedNativeComponent.ts +0 -9
- package/src/specs/ReanimatedViewProvider.native.ts +0 -4
- package/src/specs/ReanimatedViewProvider.ts +0 -6
|
@@ -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/RNReanimated.podspec
CHANGED
|
@@ -46,12 +46,6 @@ Pod::Spec.new do |s|
|
|
|
46
46
|
sss.header_dir = "reanimated"
|
|
47
47
|
sss.header_mappings_dir = "apple/reanimated"
|
|
48
48
|
end
|
|
49
|
-
|
|
50
|
-
ss.subspec "view" do |sss|
|
|
51
|
-
sss.source_files = "Common/NativeView/**/*.{mm,h,cpp}"
|
|
52
|
-
sss.header_dir = ""
|
|
53
|
-
sss.header_mappings_dir = "Common/NativeView"
|
|
54
|
-
end
|
|
55
49
|
end
|
|
56
50
|
|
|
57
51
|
s.pod_target_xcconfig = {
|
package/android/CMakeLists.txt
CHANGED
|
@@ -49,7 +49,6 @@ file(GLOB_RECURSE REANIMATED_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS
|
|
|
49
49
|
|
|
50
50
|
find_package(fbjni REQUIRED CONFIG)
|
|
51
51
|
find_package(ReactAndroid REQUIRED CONFIG)
|
|
52
|
-
find_package(react-native-worklets REQUIRED CONFIG)
|
|
53
52
|
|
|
54
53
|
add_library(reanimated SHARED ${REANIMATED_COMMON_CPP_SOURCES}
|
|
55
54
|
${REANIMATED_ANDROID_CPP_SOURCES})
|
|
@@ -65,13 +64,30 @@ target_include_directories(
|
|
|
65
64
|
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
|
|
66
65
|
"${REACT_NATIVE_DIR}/ReactCommon/jsiexecutor"
|
|
67
66
|
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
|
|
68
|
-
|
|
67
|
+
"${REACT_NATIVE_WORKLETS_DIR}/Common/cpp"
|
|
68
|
+
"${REACT_NATIVE_WORKLETS_DIR}/android/src/main/cpp")
|
|
69
69
|
|
|
70
70
|
set_target_properties(reanimated PROPERTIES LINKER_LANGUAGE CXX)
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
|
73
|
+
set(BUILD_TYPE "debug")
|
|
74
|
+
else()
|
|
75
|
+
set(BUILD_TYPE "release")
|
|
76
|
+
endif()
|
|
77
|
+
|
|
78
|
+
add_library(worklets SHARED IMPORTED)
|
|
79
|
+
|
|
80
|
+
set_target_properties(
|
|
81
|
+
worklets
|
|
82
|
+
PROPERTIES
|
|
83
|
+
IMPORTED_LOCATION
|
|
84
|
+
"${REACT_NATIVE_WORKLETS_DIR}/android/build/intermediates/cmake/${BUILD_TYPE}/obj/${ANDROID_ABI}/libworklets.so"
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
set_target_properties(reanimated PROPERTIES LINKER_LANGUAGE CXX)
|
|
73
88
|
|
|
74
|
-
target_link_libraries(reanimated
|
|
89
|
+
target_link_libraries(reanimated log ReactAndroid::jsi fbjni::fbjni android
|
|
90
|
+
worklets)
|
|
75
91
|
|
|
76
92
|
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
77
93
|
target_link_libraries(reanimated ReactAndroid::reactnative)
|
package/android/build.gradle
CHANGED
|
@@ -42,6 +42,28 @@ def resolveReactNativeDirectory() {
|
|
|
42
42
|
)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
def resolveReactNativeWorkletsDirectory() {
|
|
46
|
+
def reactNativeWorkletsLocation = safeAppExtGet("REACT_NATIVE_WORKLETS_NODE_MODULES_DIR", null)
|
|
47
|
+
if (reactNativeWorkletsLocation != null) {
|
|
48
|
+
return file(reactNativeWorkletsLocation)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Fallback to node resolver for custom directory structures like monorepos.
|
|
52
|
+
def reactNativeWorkletsPackage = file(
|
|
53
|
+
providers.exec {
|
|
54
|
+
workingDir(rootDir)
|
|
55
|
+
commandLine("node", "--print", "require.resolve('react-native-worklets/package.json')")
|
|
56
|
+
}.standardOutput.asText.get().trim()
|
|
57
|
+
)
|
|
58
|
+
if (reactNativeWorkletsPackage.exists()) {
|
|
59
|
+
return reactNativeWorkletsPackage.parentFile
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
throw new GradleException(
|
|
63
|
+
"[Reanimated] Unable to resolve react-native-worklets location in node_modules. You should set project extension property (in `app/build.gradle`) named `REACT_NATIVE_WORKLETS_NODE_MODULES_DIR` with the path to react-native-worklets in node_modules."
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
45
67
|
def getReactNativeMinorVersion() {
|
|
46
68
|
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
47
69
|
def reactProperties = new Properties()
|
|
@@ -63,18 +85,6 @@ def toPlatformFileString(String path) {
|
|
|
63
85
|
return path
|
|
64
86
|
}
|
|
65
87
|
|
|
66
|
-
def validateWorkletsVersion() {
|
|
67
|
-
def result = providers.exec {
|
|
68
|
-
workingDir(projectDir.path)
|
|
69
|
-
commandLine("node", "./../scripts/validate-worklets-build.js")
|
|
70
|
-
ignoreExitValue = true
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (result.getResult().get().exitValue != 0) {
|
|
74
|
-
throw new GradleException(result.getStandardError().getAsText().get().trim())
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
88
|
def getReanimatedStaticFeatureFlags() {
|
|
79
89
|
def featureFlags = new HashMap<String, String>()
|
|
80
90
|
|
|
@@ -101,7 +111,9 @@ if (isNewArchitectureEnabled()) {
|
|
|
101
111
|
apply plugin: "com.facebook.react"
|
|
102
112
|
}
|
|
103
113
|
|
|
114
|
+
def packageDir = project.projectDir.parentFile
|
|
104
115
|
def reactNativeRootDir = resolveReactNativeDirectory()
|
|
116
|
+
def reactNativeWorkletsRootDir = resolveReactNativeWorkletsDirectory()
|
|
105
117
|
def REACT_NATIVE_MINOR_VERSION = getReactNativeMinorVersion()
|
|
106
118
|
def REANIMATED_VERSION = getReanimatedVersion()
|
|
107
119
|
def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()
|
|
@@ -181,6 +193,7 @@ android {
|
|
|
181
193
|
"-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
|
|
182
194
|
"-DANDROID_TOOLCHAIN=clang",
|
|
183
195
|
"-DREACT_NATIVE_DIR=${toPlatformFileString(reactNativeRootDir.path)}",
|
|
196
|
+
"-DREACT_NATIVE_WORKLETS_DIR=${toPlatformFileString(reactNativeWorkletsRootDir.path)}",
|
|
184
197
|
"-DIS_REANIMATED_EXAMPLE_APP=${IS_REANIMATED_EXAMPLE_APP}",
|
|
185
198
|
"-DREANIMATED_PROFILING=${REANIMATED_PROFILING}",
|
|
186
199
|
"-DREANIMATED_VERSION=${REANIMATED_VERSION}",
|
|
@@ -246,7 +259,6 @@ android {
|
|
|
246
259
|
if (!IS_REANIMATED_EXAMPLE_APP) {
|
|
247
260
|
return
|
|
248
261
|
}
|
|
249
|
-
def packageDir = new File("${project.projectDir}/..")
|
|
250
262
|
|
|
251
263
|
def generated = new File("${compileTask.abi.getCxxBuildFolder()}/compile_commands.json")
|
|
252
264
|
def output = new File("${packageDir}/compile_commands.json")
|
|
@@ -260,7 +272,7 @@ android {
|
|
|
260
272
|
|
|
261
273
|
task assertMinimalReactNativeVersionTask {
|
|
262
274
|
// If you change the minimal React Native version remember to update Compatibility Table in docs
|
|
263
|
-
def minimalReactNativeVersion =
|
|
275
|
+
def minimalReactNativeVersion = 78
|
|
264
276
|
onlyIf { REACT_NATIVE_MINOR_VERSION < minimalReactNativeVersion }
|
|
265
277
|
doFirst {
|
|
266
278
|
throw new GradleException("[Reanimated] Unsupported React Native version. Please use React Native 0.$minimalReactNativeVersion or newer.")
|
|
@@ -278,9 +290,17 @@ task assertNewArchitectureEnabledTask {
|
|
|
278
290
|
|
|
279
291
|
preBuild.dependsOn(assertNewArchitectureEnabledTask)
|
|
280
292
|
|
|
293
|
+
def validateWorkletsBuildResult = providers.exec {
|
|
294
|
+
workingDir(projectDir.path)
|
|
295
|
+
commandLine("node", "./../scripts/validate-worklets-build.js")
|
|
296
|
+
ignoreExitValue = true
|
|
297
|
+
}
|
|
298
|
+
|
|
281
299
|
task assertWorkletsVersionTask {
|
|
282
300
|
doFirst {
|
|
283
|
-
|
|
301
|
+
if (validateWorkletsBuildResult.getResult().get().exitValue != 0) {
|
|
302
|
+
throw new GradleException(validateWorkletsBuildResult.getStandardError().getAsText().get().trim())
|
|
303
|
+
}
|
|
284
304
|
}
|
|
285
305
|
}
|
|
286
306
|
|
|
@@ -324,3 +344,12 @@ dependencies {
|
|
|
324
344
|
}
|
|
325
345
|
|
|
326
346
|
preBuild.dependsOn(prepareReanimatedHeadersForPrefabs)
|
|
347
|
+
|
|
348
|
+
if (project != rootProject) {
|
|
349
|
+
evaluationDependsOn(":react-native-worklets")
|
|
350
|
+
|
|
351
|
+
afterEvaluate {
|
|
352
|
+
tasks.getByName("externalNativeBuildDebug").dependsOn(findProject(":react-native-worklets").tasks.getByName("externalNativeBuildDebug"))
|
|
353
|
+
tasks.getByName("externalNativeBuildRelease").dependsOn(findProject(":react-native-worklets").tasks.getByName("externalNativeBuildRelease"))
|
|
354
|
+
}
|
|
355
|
+
}
|