react-native-reanimated 2.3.0-beta.2 → 2.3.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/Common/cpp/NativeModules/NativeReanimatedModule.cpp +12 -3
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +2 -2
- package/Common/cpp/Registries/MapperRegistry.cpp +5 -5
- package/Common/cpp/SharedItems/FrozenObject.cpp +1 -3
- package/Common/cpp/SharedItems/ShareableValue.cpp +8 -10
- package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +8 -8
- package/Common/cpp/Tools/Mapper.cpp +1 -1
- package/Common/cpp/Tools/RuntimeDecorator.cpp +40 -4
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -1
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +5 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +6 -1
- package/Common/cpp/headers/Registries/EventHandlerRegistry.h +1 -0
- package/Common/cpp/headers/Registries/MapperRegistry.h +1 -0
- package/Common/cpp/headers/SharedItems/FrozenObject.h +4 -0
- package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +2 -0
- package/Common/cpp/headers/SharedItems/MutableValue.h +2 -0
- package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +3 -1
- package/Common/cpp/headers/SharedItems/RemoteObject.h +4 -1
- package/Common/cpp/headers/SharedItems/ShareableValue.h +2 -0
- package/Common/cpp/headers/SharedItems/SharedParent.h +9 -9
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +32 -28
- package/Common/cpp/headers/SpecTools/ErrorHandler.h +1 -0
- package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
- package/Common/cpp/headers/Tools/JSIStoreValueUser.h +2 -5
- package/Common/cpp/headers/Tools/Mapper.h +2 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
- package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +1 -5
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +10 -7
- package/Common/cpp/headers/Tools/Scheduler.h +2 -0
- package/Common/cpp/headers/Tools/WorkletEventHandler.h +2 -1
- package/Common/cpp/hidden_headers/Logger.h +2 -2
- package/Common/cpp/hidden_headers/LoggerInterface.h +1 -1
- package/README.md +1 -1
- package/RNReanimated.podspec +21 -3
- package/android/build.gradle +33 -13
- package/android/expo/linking.gradle +46 -0
- package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
- package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/expo-module.config.json +3 -0
- package/ios/LayoutReanimation/REAAnimationsManager.m +65 -19
- package/ios/LayoutReanimation/REAUIManager.mm +101 -61
- package/ios/Nodes/REAPropsNode.m +1 -1
- package/ios/REAEventDispatcher.m +1 -1
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +0 -3
- package/ios/REANodesManager.m +1 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/native/NativeMethods.h +5 -0
- package/ios/native/NativeMethods.mm +14 -6
- package/ios/native/NativeProxy.h +1 -0
- package/ios/native/NativeProxy.mm +84 -63
- package/ios/native/REAIOSErrorHandler.mm +19 -15
- package/ios/native/REAIOSLogger.mm +10 -6
- package/ios/native/REAIOSScheduler.mm +17 -10
- package/ios/native/REAInitializer.mm +39 -37
- package/ios/native/UIResponder+Reanimated.mm +2 -2
- package/lib/Animated.js +11 -5
- package/lib/ConfigHelper.js +121 -138
- package/lib/ReanimatedEventEmitter.js +0 -1
- package/lib/ReanimatedModule.js +0 -1
- package/lib/ReanimatedModule.macos.js +0 -1
- package/lib/ReanimatedModule.native.js +5 -6
- package/lib/ReanimatedModule.windows.js +0 -1
- package/lib/ReanimatedModuleCompat.js +64 -35
- package/lib/createAnimatedComponent.js +469 -499
- package/lib/index.js +11 -5
- package/lib/reanimated1/core/Core.test.js +1 -1
- package/lib/reanimated2/NativeMethods.js +7 -0
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +3 -0
- package/lib/reanimated2/PropAdapters.js +0 -1
- package/lib/reanimated2/UpdateProps.js +1 -1
- package/lib/reanimated2/ViewDescriptorsSet.js +4 -2
- package/lib/reanimated2/animation/spring.js +2 -0
- package/lib/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/reanimated2/animation/util.js +23 -0
- package/lib/reanimated2/component/FlatList.js +30 -0
- package/lib/reanimated2/component/WrappedComponents.js +9 -0
- package/lib/reanimated2/component/index.js +4 -0
- package/lib/reanimated2/core.js +34 -6
- package/lib/reanimated2/globals.d.ts +8 -0
- package/lib/reanimated2/js-reanimated/JSReanimated.js +4 -0
- package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
- package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
- package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
- package/lib/reanimated2/js-reanimated/index.js +10 -8
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +14 -5
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +14 -14
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +16 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +4 -4
- package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
- package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
- package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
- package/lib/reanimated2/mock.js +3 -1
- package/lib/setAndForwardRef.js +14 -48
- package/mock.js +1 -1
- package/package.json +27 -23
- package/plugin.js +111 -110
- package/react-native-reanimated.d.ts +56 -27
- package/src/Animated.js +11 -5
- package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
- package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
- package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
- package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
- package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
- package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
- package/src/ReanimatedModuleCompat.ts +51 -0
- package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +278 -124
- package/src/reanimated1/core/Core.test.js +1 -1
- package/src/reanimated2/NativeMethods.ts +13 -1
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -11
- package/src/reanimated2/PropAdapters.ts +0 -1
- package/src/reanimated2/UpdateProps.ts +1 -1
- package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
- package/src/reanimated2/animation/commonTypes.ts +4 -4
- package/src/reanimated2/animation/decay.ts +2 -2
- package/src/reanimated2/animation/delay.ts +3 -3
- package/src/reanimated2/animation/index.ts +7 -7
- package/src/reanimated2/animation/repeat.ts +4 -4
- package/src/reanimated2/animation/sequence.ts +2 -2
- package/src/reanimated2/animation/spring.ts +6 -5
- package/src/reanimated2/animation/styleAnimation.ts +24 -12
- package/src/reanimated2/animation/timing.ts +5 -5
- package/src/reanimated2/animation/util.ts +45 -6
- package/src/reanimated2/component/FlatList.tsx +44 -0
- package/src/reanimated2/component/WrappedComponents.ts +11 -0
- package/src/reanimated2/component/index.ts +9 -0
- package/src/reanimated2/core.ts +62 -17
- package/src/reanimated2/globals.d.ts +8 -0
- package/src/reanimated2/hook/useAnimatedStyle.ts +2 -2
- package/src/reanimated2/js-reanimated/JSReanimated.ts +15 -26
- package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
- package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
- package/src/reanimated2/js-reanimated/index.ts +31 -14
- package/src/reanimated2/layoutReanimation/{LayoutAnimationRepository.tsx → LayoutAnimationRepository.ts} +18 -5
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +9 -9
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
- package/src/reanimated2/mock.ts +3 -1
- package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
- package/src/ReanimatedModuleCompat.js +0 -37
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
|
+
#include <memory>
|
|
4
5
|
#include <string>
|
|
6
|
+
#include <vector>
|
|
5
7
|
#include "HostFunctionHandler.h"
|
|
6
8
|
#include "JSIStoreValueUser.h"
|
|
7
9
|
#include "SharedParent.h"
|
|
@@ -13,8 +15,8 @@ class HostFunctionWrapper;
|
|
|
13
15
|
|
|
14
16
|
class ValueWrapper {
|
|
15
17
|
public:
|
|
16
|
-
ValueWrapper(){}
|
|
17
|
-
ValueWrapper(ValueType _type) : type(_type){}
|
|
18
|
+
ValueWrapper() {}
|
|
19
|
+
explicit ValueWrapper(ValueType _type) : type(_type) {}
|
|
18
20
|
ValueType getType() const {
|
|
19
21
|
return type;
|
|
20
22
|
}
|
|
@@ -47,105 +49,107 @@ class ValueWrapper {
|
|
|
47
49
|
|
|
48
50
|
class BooleanValueWrapper : public ValueWrapper {
|
|
49
51
|
public:
|
|
50
|
-
BooleanValueWrapper(const bool _value)
|
|
51
|
-
: ValueWrapper(ValueType::BoolType), value(_value){}
|
|
52
|
+
explicit BooleanValueWrapper(const bool _value)
|
|
53
|
+
: ValueWrapper(ValueType::BoolType), value(_value) {}
|
|
52
54
|
bool value;
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
class NumberValueWrapper : public ValueWrapper {
|
|
56
58
|
public:
|
|
57
|
-
NumberValueWrapper(const double _value)
|
|
58
|
-
: ValueWrapper(ValueType::NumberType), value(_value){}
|
|
59
|
+
explicit NumberValueWrapper(const double _value)
|
|
60
|
+
: ValueWrapper(ValueType::NumberType), value(_value) {}
|
|
59
61
|
double value;
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
class StringValueWrapper : public ValueWrapper {
|
|
63
65
|
public:
|
|
64
|
-
StringValueWrapper(const std::string &_value)
|
|
65
|
-
: ValueWrapper(ValueType::StringType), value(_value){}
|
|
66
|
+
explicit StringValueWrapper(const std::string &_value)
|
|
67
|
+
: ValueWrapper(ValueType::StringType), value(_value) {}
|
|
66
68
|
std::string value;
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
class HostFunctionWrapper : public ValueWrapper {
|
|
70
72
|
public:
|
|
71
|
-
HostFunctionWrapper(
|
|
72
|
-
|
|
73
|
+
explicit HostFunctionWrapper(
|
|
74
|
+
const std::shared_ptr<HostFunctionHandler> &_value)
|
|
75
|
+
: ValueWrapper(ValueType::HostFunctionType), value(_value) {}
|
|
73
76
|
std::shared_ptr<HostFunctionHandler> value;
|
|
74
77
|
};
|
|
75
78
|
|
|
76
79
|
class FrozenObjectWrapper : public ValueWrapper {
|
|
77
80
|
public:
|
|
78
|
-
FrozenObjectWrapper(const std::shared_ptr<FrozenObject> &_value)
|
|
79
|
-
: ValueWrapper(ValueType::FrozenObjectType), value(_value){}
|
|
81
|
+
explicit FrozenObjectWrapper(const std::shared_ptr<FrozenObject> &_value)
|
|
82
|
+
: ValueWrapper(ValueType::FrozenObjectType), value(_value) {}
|
|
80
83
|
std::shared_ptr<FrozenObject> value;
|
|
81
84
|
};
|
|
82
85
|
|
|
83
86
|
class RemoteObjectWrapper : public ValueWrapper {
|
|
84
87
|
public:
|
|
85
|
-
RemoteObjectWrapper(const std::shared_ptr<RemoteObject> &_value)
|
|
86
|
-
: ValueWrapper(ValueType::RemoteObjectType), value(_value){}
|
|
88
|
+
explicit RemoteObjectWrapper(const std::shared_ptr<RemoteObject> &_value)
|
|
89
|
+
: ValueWrapper(ValueType::RemoteObjectType), value(_value) {}
|
|
87
90
|
std::shared_ptr<RemoteObject> value;
|
|
88
91
|
};
|
|
89
92
|
|
|
90
93
|
class FrozenArrayWrapper : public ValueWrapper {
|
|
91
94
|
public:
|
|
92
|
-
FrozenArrayWrapper() : ValueWrapper(ValueType::FrozenArrayType){}
|
|
93
|
-
FrozenArrayWrapper(
|
|
94
|
-
|
|
95
|
+
FrozenArrayWrapper() : ValueWrapper(ValueType::FrozenArrayType) {}
|
|
96
|
+
explicit FrozenArrayWrapper(
|
|
97
|
+
const std::vector<std::shared_ptr<ShareableValue>> &_value)
|
|
98
|
+
: ValueWrapper(ValueType::FrozenArrayType), value(_value) {}
|
|
95
99
|
std::vector<std::shared_ptr<ShareableValue>> value;
|
|
96
100
|
};
|
|
97
101
|
|
|
98
102
|
class MutableValueWrapper : public ValueWrapper {
|
|
99
103
|
public:
|
|
100
|
-
MutableValueWrapper(const std::shared_ptr<MutableValue> &_value)
|
|
101
|
-
: ValueWrapper(ValueType::MutableValueType), value(_value){}
|
|
104
|
+
explicit MutableValueWrapper(const std::shared_ptr<MutableValue> &_value)
|
|
105
|
+
: ValueWrapper(ValueType::MutableValueType), value(_value) {}
|
|
102
106
|
std::shared_ptr<MutableValue> value;
|
|
103
107
|
};
|
|
104
108
|
|
|
105
109
|
inline bool ValueWrapper::asBoolean(
|
|
106
110
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
107
111
|
return static_cast<BooleanValueWrapper *>(valueContainer.get())->value;
|
|
108
|
-
}
|
|
112
|
+
}
|
|
109
113
|
|
|
110
114
|
inline double ValueWrapper::asNumber(
|
|
111
115
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
112
116
|
return static_cast<NumberValueWrapper *>(valueContainer.get())->value;
|
|
113
|
-
}
|
|
117
|
+
}
|
|
114
118
|
|
|
115
119
|
inline const std::string &ValueWrapper::asString(
|
|
116
120
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
117
121
|
return static_cast<StringValueWrapper *>(valueContainer.get())->value;
|
|
118
|
-
}
|
|
122
|
+
}
|
|
119
123
|
|
|
120
124
|
inline const std::shared_ptr<HostFunctionHandler> &ValueWrapper::asHostFunction(
|
|
121
125
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
122
126
|
return static_cast<HostFunctionWrapper *>(valueContainer.get())->value;
|
|
123
|
-
}
|
|
127
|
+
}
|
|
124
128
|
|
|
125
129
|
inline const std::shared_ptr<FrozenObject> &ValueWrapper::asFrozenObject(
|
|
126
130
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
127
131
|
return static_cast<FrozenObjectWrapper *>(valueContainer.get())->value;
|
|
128
|
-
}
|
|
132
|
+
}
|
|
129
133
|
|
|
130
134
|
inline const std::shared_ptr<RemoteObject> &ValueWrapper::asRemoteObject(
|
|
131
135
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
132
136
|
return static_cast<RemoteObjectWrapper *>(valueContainer.get())->value;
|
|
133
|
-
}
|
|
137
|
+
}
|
|
134
138
|
|
|
135
139
|
inline std::vector<std::shared_ptr<ShareableValue>>
|
|
136
140
|
&ValueWrapper::asFrozenArray(
|
|
137
141
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
138
142
|
return static_cast<FrozenArrayWrapper *>(valueContainer.get())->value;
|
|
139
|
-
}
|
|
143
|
+
}
|
|
140
144
|
|
|
141
145
|
inline const std::shared_ptr<MutableValue> &ValueWrapper::asMutableValue(
|
|
142
146
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
143
147
|
return static_cast<MutableValueWrapper *>(valueContainer.get())->value;
|
|
144
|
-
}
|
|
148
|
+
}
|
|
145
149
|
|
|
146
150
|
inline const HostFunctionWrapper *ValueWrapper::asHostFunctionWrapper(
|
|
147
151
|
const std::unique_ptr<ValueWrapper> &valueContainer) {
|
|
148
152
|
return static_cast<HostFunctionWrapper *>(valueContainer.get());
|
|
149
|
-
}
|
|
153
|
+
}
|
|
150
154
|
|
|
151
155
|
} // namespace reanimated
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <string>
|
|
3
|
+
|
|
4
|
+
namespace reanimated {
|
|
5
|
+
|
|
6
|
+
class FeaturesConfig {
|
|
7
|
+
public:
|
|
8
|
+
static inline bool isLayoutAnimationEnabled() {
|
|
9
|
+
return _isLayoutAnimationEnabled;
|
|
10
|
+
}
|
|
11
|
+
static inline void setLayoutAnimationEnabled(bool isLayoutAnimationEnabled) {
|
|
12
|
+
_isLayoutAnimationEnabled = isLayoutAnimationEnabled;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private:
|
|
16
|
+
static bool _isLayoutAnimationEnabled;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
} // namespace reanimated
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
#
|
|
2
|
-
#define JSIStoreValueUser_h
|
|
1
|
+
#pragma once
|
|
3
2
|
|
|
4
3
|
#include <jsi/jsi.h>
|
|
5
4
|
#include <stdio.h>
|
|
@@ -27,7 +26,7 @@ class StoreUser {
|
|
|
27
26
|
std::shared_ptr<StaticStoreUser> storeUserData;
|
|
28
27
|
|
|
29
28
|
public:
|
|
30
|
-
StoreUser(std::shared_ptr<Scheduler> s, RuntimeManager &runtimeManager);
|
|
29
|
+
StoreUser(std::shared_ptr<Scheduler> s, const RuntimeManager &runtimeManager);
|
|
31
30
|
|
|
32
31
|
std::weak_ptr<jsi::Value> getWeakRef(jsi::Runtime &rt);
|
|
33
32
|
void removeRefs();
|
|
@@ -36,5 +35,3 @@ class StoreUser {
|
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
} // namespace reanimated
|
|
39
|
-
|
|
40
|
-
#endif /* JSIStoreValueUser_h */
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
4
|
#include <stdio.h>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <utility>
|
|
7
|
+
#include <vector>
|
|
5
8
|
|
|
6
9
|
using namespace facebook;
|
|
7
10
|
|
|
@@ -18,6 +21,7 @@ using ScrollToFunction = std::function<void(int, double, double, bool)>;
|
|
|
18
21
|
using MeasuringFunction =
|
|
19
22
|
std::function<std::vector<std::pair<std::string, double>>(int)>;
|
|
20
23
|
using TimeProviderFunction = std::function<double(void)>;
|
|
24
|
+
using SetGestureStateFunction = std::function<void(int, int)>;
|
|
21
25
|
|
|
22
26
|
struct PlatformDepMethodsHolder {
|
|
23
27
|
RequestRender requestRender;
|
|
@@ -25,6 +29,7 @@ struct PlatformDepMethodsHolder {
|
|
|
25
29
|
ScrollToFunction scrollToFunction;
|
|
26
30
|
MeasuringFunction measuringFunction;
|
|
27
31
|
TimeProviderFunction getCurrentTime;
|
|
32
|
+
SetGestureStateFunction setGestureStateFunction;
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
} // namespace reanimated
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
#ifndef REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H
|
|
3
|
-
#define REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H
|
|
1
|
+
#pragma once
|
|
4
2
|
|
|
5
3
|
#if defined(ONANDROID)
|
|
6
4
|
#include "Logger.h"
|
|
@@ -11,5 +9,3 @@
|
|
|
11
9
|
#include "Common/cpp/hidden_headers/LoggerInterface.h"
|
|
12
10
|
#include "Common/cpp/hidden_headers/SpeedChecker.h"
|
|
13
11
|
#endif
|
|
14
|
-
|
|
15
|
-
#endif // REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
4
|
#include <stdio.h>
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
5
7
|
#include <unordered_map>
|
|
6
8
|
#include "LayoutAnimationsProxy.h"
|
|
7
9
|
#include "PlatformDepMethodsHolder.h"
|
|
@@ -34,6 +36,7 @@ class RuntimeDecorator {
|
|
|
34
36
|
const ScrollToFunction scrollTo,
|
|
35
37
|
const MeasuringFunction measure,
|
|
36
38
|
const TimeProviderFunction getCurrentTime,
|
|
39
|
+
const SetGestureStateFunction setGestureState,
|
|
37
40
|
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy);
|
|
38
41
|
|
|
39
42
|
/**
|
|
@@ -56,27 +59,27 @@ class RuntimeDecorator {
|
|
|
56
59
|
static void registerRuntime(jsi::Runtime *runtime, RuntimeType runtimeType);
|
|
57
60
|
|
|
58
61
|
private:
|
|
59
|
-
static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
|
|
62
|
+
static std::unordered_map<RuntimePointer, RuntimeType> &runtimeRegistry();
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
inline bool RuntimeDecorator::isUIRuntime(jsi::Runtime &rt) {
|
|
63
|
-
auto iterator = runtimeRegistry.find(&rt);
|
|
64
|
-
if (iterator == runtimeRegistry.end())
|
|
66
|
+
auto iterator = runtimeRegistry().find(&rt);
|
|
67
|
+
if (iterator == runtimeRegistry().end())
|
|
65
68
|
return false;
|
|
66
69
|
return iterator->second == RuntimeType::UI;
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
inline bool RuntimeDecorator::isWorkletRuntime(jsi::Runtime &rt) {
|
|
70
|
-
auto iterator = runtimeRegistry.find(&rt);
|
|
71
|
-
if (iterator == runtimeRegistry.end())
|
|
73
|
+
auto iterator = runtimeRegistry().find(&rt);
|
|
74
|
+
if (iterator == runtimeRegistry().end())
|
|
72
75
|
return false;
|
|
73
76
|
auto type = iterator->second;
|
|
74
77
|
return type == RuntimeType::UI || type == RuntimeType::Worklet;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
inline bool RuntimeDecorator::isReactRuntime(jsi::Runtime &rt) {
|
|
78
|
-
auto iterator = runtimeRegistry.find(&rt);
|
|
79
|
-
if (iterator == runtimeRegistry.end())
|
|
81
|
+
auto iterator = runtimeRegistry().find(&rt);
|
|
82
|
+
if (iterator == runtimeRegistry().end())
|
|
80
83
|
return true;
|
|
81
84
|
return false;
|
|
82
85
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
4
|
#include <string>
|
|
5
|
+
#include <utility>
|
|
5
6
|
|
|
6
7
|
using namespace facebook;
|
|
7
8
|
|
|
@@ -23,7 +24,7 @@ class WorkletEventHandler {
|
|
|
23
24
|
std::string eventName,
|
|
24
25
|
jsi::Function &&handler)
|
|
25
26
|
: id(id), eventName(eventName), handler(std::move(handler)) {}
|
|
26
|
-
void process(jsi::Runtime &rt, jsi::Value &eventValue);
|
|
27
|
+
void process(jsi::Runtime &rt, const jsi::Value &eventValue);
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
} // namespace reanimated
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Check out our dedicated documentation page for info about this library, API refe
|
|
|
19
19
|
|
|
20
20
|
## Examples
|
|
21
21
|
|
|
22
|
-
The source code for the example (showcase) app is under the [`Example/`](https://github.com/software-mansion/react-native-reanimated/blob/
|
|
22
|
+
The source code for the example (showcase) app is under the [`Example/`](https://github.com/software-mansion/react-native-reanimated/blob/main/Example/) directory.
|
|
23
23
|
If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Check Example/ directory README for installation instructions.
|
|
24
24
|
|
|
25
25
|
## License
|
package/RNReanimated.podspec
CHANGED
|
@@ -5,9 +5,28 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
|
5
5
|
reactVersion = '0.0.0'
|
|
6
6
|
|
|
7
7
|
begin
|
|
8
|
-
|
|
8
|
+
# standard app
|
|
9
|
+
# /appName/node_modules/react-native-reanimated/RNReanimated.podspec
|
|
10
|
+
# /appName/node_modules/react-native/package.json
|
|
11
|
+
reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json")))["version"]
|
|
9
12
|
rescue
|
|
10
|
-
|
|
13
|
+
begin
|
|
14
|
+
# monorepo
|
|
15
|
+
# /monorepo/packages/appName/node_modules/react-native-reanimated/RNReanimated.podspec
|
|
16
|
+
# /monorepo/node_modules/react-native/package.json
|
|
17
|
+
reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "..", "node_modules", "react-native", "package.json")))["version"]
|
|
18
|
+
rescue
|
|
19
|
+
begin
|
|
20
|
+
# Example app in reanimated repo
|
|
21
|
+
# /react-native-reanimated/RNReanimated.podspec
|
|
22
|
+
# /react-native-reanimated/node_modules/react-native/package.json
|
|
23
|
+
reactVersion = JSON.parse(File.read(File.join(__dir__, "node_modules", "react-native", "package.json")))["version"]
|
|
24
|
+
rescue
|
|
25
|
+
# should never happen
|
|
26
|
+
reactVersion = '0.66.0'
|
|
27
|
+
puts "[RNReanimated] Unable to recognized your `react-native` version! Default `react-native` version: " + reactVersion
|
|
28
|
+
end
|
|
29
|
+
end
|
|
11
30
|
end
|
|
12
31
|
|
|
13
32
|
rnVersion = reactVersion.split('.')[1]
|
|
@@ -74,7 +93,6 @@ Pod::Spec.new do |s|
|
|
|
74
93
|
s.dependency 'React-RCTBlob'
|
|
75
94
|
s.dependency 'React-RCTSettings'
|
|
76
95
|
s.dependency 'React-RCTText'
|
|
77
|
-
s.dependency 'React-RCTVibration'
|
|
78
96
|
s.dependency 'React-RCTImage'
|
|
79
97
|
s.dependency 'React-Core/RCTWebSocket'
|
|
80
98
|
s.dependency 'React-cxxreact'
|
package/android/build.gradle
CHANGED
|
@@ -31,20 +31,14 @@ abstract class replaceSoTask extends DefaultTask {
|
|
|
31
31
|
def getCurrentFlavor() {
|
|
32
32
|
Gradle gradle = getGradle()
|
|
33
33
|
String taskRequestName = gradle.getStartParameter().getTaskRequests().toString()
|
|
34
|
-
Pattern pattern
|
|
35
|
-
|
|
36
|
-
if(taskRequestName.contains("assemble")) {
|
|
37
|
-
pattern = Pattern.compile("assemble(\\w+)(Release|Debug)")
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
pattern = Pattern.compile("generate(\\w+)(Release|Debug)")
|
|
41
|
-
}
|
|
34
|
+
Pattern pattern = Pattern.compile("(assemble|bundle|install|generate)(\\w*)(Release|Debug)")
|
|
42
35
|
Matcher matcher = pattern.matcher(taskRequestName)
|
|
43
36
|
|
|
44
37
|
if(matcher.find()) {
|
|
45
|
-
return matcher.group(
|
|
38
|
+
return matcher.group(2)
|
|
46
39
|
}
|
|
47
|
-
|
|
40
|
+
|
|
41
|
+
return "NOT-FOUND"
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
def replaceSoTaskDebug
|
|
@@ -64,8 +58,9 @@ rootProject.getSubprojects().forEach({project ->
|
|
|
64
58
|
|
|
65
59
|
if(project.getProperties().get("android") && Integer.parseInt(minor) < 65) {
|
|
66
60
|
def projectProperties = project.getProperties()
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
final NOTFOUND = "NOT-FOUND"
|
|
62
|
+
if(!NOTFOUND.equals(getCurrentFlavor()) && (!projectProperties.get("reanimated")
|
|
63
|
+
|| (projectProperties.get("reanimated") && projectProperties.get("reanimated").get("enablePackagingOptions")))
|
|
69
64
|
) {
|
|
70
65
|
def flavorString = getCurrentFlavor()
|
|
71
66
|
replaceSoTask.appName = project.getProperties().path
|
|
@@ -88,4 +83,29 @@ rootProject.getSubprojects().forEach({project ->
|
|
|
88
83
|
}
|
|
89
84
|
})
|
|
90
85
|
|
|
91
|
-
|
|
86
|
+
def minorCopy = Integer.parseInt(minor)
|
|
87
|
+
def aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
|
|
88
|
+
|
|
89
|
+
while (!aar.exists()) {
|
|
90
|
+
minorCopy -= 1
|
|
91
|
+
aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
|
|
92
|
+
if (minorCopy < 63) {
|
|
93
|
+
throw new GradleException('No aar for react-native-reanimated found.')
|
|
94
|
+
}
|
|
95
|
+
if (aar.exists()) {
|
|
96
|
+
println "\n\n\n"
|
|
97
|
+
println "****************************************************************************************"
|
|
98
|
+
println "\n\n\n"
|
|
99
|
+
println "WARNING reanimated - no version-specific reanimated AAR for react-native version " . minor . " found."
|
|
100
|
+
println "Falling back to AAR for react-native version " . minorCopy
|
|
101
|
+
println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
|
|
102
|
+
println "Please post a pull request to implement support for react-native version " . minor . " to the reanimated repo."
|
|
103
|
+
println "Thanks!"
|
|
104
|
+
println "\n\n\n"
|
|
105
|
+
println "****************************************************************************************"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
artifacts.add("default", aar)
|
|
110
|
+
|
|
111
|
+
apply from: './expo/linking.gradle'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
def isExpoLinked = false
|
|
2
|
+
rootProject.getSubprojects().forEach({ project ->
|
|
3
|
+
if (project.plugins.hasPlugin("com.android.application")) {
|
|
4
|
+
if (project.configurations.implementation.getDependencies().find { dep -> dep.name == "expo" }) {
|
|
5
|
+
isExpoLinked = true
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
def safeExtGet(prop, fallback) {
|
|
11
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (isExpoLinked) {
|
|
15
|
+
apply plugin: 'com.android.library'
|
|
16
|
+
|
|
17
|
+
android {
|
|
18
|
+
// Disable aar bundling to fix the error when running `gradle assembleRelease` over `gradle :app:assembleRelease`
|
|
19
|
+
// which will throw `Direct local .aar file dependencies are not supported when building an AAR.`
|
|
20
|
+
tasks.whenTaskAdded { task ->
|
|
21
|
+
if (['bundleDebugAar', 'bundleReleaseAar'].contains(task.name)) {
|
|
22
|
+
task.enabled = false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 30)
|
|
27
|
+
|
|
28
|
+
sourceSets {
|
|
29
|
+
main.manifest.srcFile 'src/AndroidManifest.xml'
|
|
30
|
+
main.java.srcDirs = [ 'expo/src/main/java' ]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
libraryVariants.all {
|
|
34
|
+
generateBuildConfigProvider?.get()?.enabled = false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
dependencies {
|
|
39
|
+
implementation 'com.facebook.react:react-native:+'
|
|
40
|
+
implementation project(':expo-modules-core')
|
|
41
|
+
|
|
42
|
+
project.configurations.default.artifacts.each { artifact ->
|
|
43
|
+
api files(artifact.file)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.swmansion.reanimated;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
|
|
6
|
+
public class EXReanimatedAdapter {
|
|
7
|
+
public static void registerJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext) {
|
|
8
|
+
NodesManager nodesManager =
|
|
9
|
+
reactApplicationContext.getNativeModule(ReanimatedModule.class).getNodesManager();
|
|
10
|
+
nodesManager.initWithContext(reactApplicationContext);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package expo.modules.adapters.reanimated;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.swmansion.reanimated.EXReanimatedAdapter;
|
|
8
|
+
|
|
9
|
+
import java.util.Collections;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
|
|
12
|
+
import expo.modules.core.interfaces.Package;
|
|
13
|
+
import expo.modules.core.interfaces.ReactNativeHostHandler;
|
|
14
|
+
|
|
15
|
+
public class EXReanimatedPackage implements Package {
|
|
16
|
+
@Override
|
|
17
|
+
public List<? extends ReactNativeHostHandler> createReactNativeHostHandlers(Context context) {
|
|
18
|
+
final ReactNativeHostHandler handler = new ReactNativeHostHandler() {
|
|
19
|
+
@Override
|
|
20
|
+
public void onRegisterJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext, boolean useDeveloperSupport) {
|
|
21
|
+
EXReanimatedAdapter.registerJSIModules(reactApplicationContext, jsContext);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return Collections.singletonList(handler);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|