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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
#include <thread>
|
|
5
5
|
#include "EventHandlerRegistry.h"
|
|
6
|
+
#include "FeaturesConfig.h"
|
|
6
7
|
#include "FrozenObject.h"
|
|
7
8
|
#include "JSIStoreValueUser.h"
|
|
8
9
|
#include "Mapper.h"
|
|
@@ -84,6 +85,7 @@ NativeReanimatedModule::NativeReanimatedModule(
|
|
|
84
85
|
platformDepMethodsHolder.scrollToFunction,
|
|
85
86
|
platformDepMethodsHolder.measuringFunction,
|
|
86
87
|
platformDepMethodsHolder.getCurrentTime,
|
|
88
|
+
platformDepMethodsHolder.setGestureStateFunction,
|
|
87
89
|
layoutAnimationsProxy);
|
|
88
90
|
onRenderCallback = [this](double timestampMs) {
|
|
89
91
|
this->renderRequested = false;
|
|
@@ -164,7 +166,7 @@ jsi::Value NativeReanimatedModule::startMapper(
|
|
|
164
166
|
maybeRequestRender();
|
|
165
167
|
});
|
|
166
168
|
|
|
167
|
-
return jsi::Value((
|
|
169
|
+
return jsi::Value(static_cast<double>(newMapperId));
|
|
168
170
|
}
|
|
169
171
|
|
|
170
172
|
void NativeReanimatedModule::stopMapper(
|
|
@@ -196,7 +198,7 @@ jsi::Value NativeReanimatedModule::registerEventHandler(
|
|
|
196
198
|
eventHandlerRegistry->registerEventHandler(handler);
|
|
197
199
|
});
|
|
198
200
|
|
|
199
|
-
return jsi::Value((
|
|
201
|
+
return jsi::Value(static_cast<double>(newRegistrationId));
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
void NativeReanimatedModule::unregisterEventHandler(
|
|
@@ -212,7 +214,7 @@ jsi::Value NativeReanimatedModule::getViewProp(
|
|
|
212
214
|
const jsi::Value &viewTag,
|
|
213
215
|
const jsi::Value &propName,
|
|
214
216
|
const jsi::Value &callback) {
|
|
215
|
-
const int viewTagInt = (
|
|
217
|
+
const int viewTagInt = static_cast<int>(viewTag.asNumber());
|
|
216
218
|
std::string propNameStr = propName.asString(rt).utf8(rt);
|
|
217
219
|
jsi::Function fun = callback.getObject(rt).asFunction(rt);
|
|
218
220
|
std::shared_ptr<jsi::Function> funPtr =
|
|
@@ -234,6 +236,13 @@ jsi::Value NativeReanimatedModule::getViewProp(
|
|
|
234
236
|
return jsi::Value::undefined();
|
|
235
237
|
}
|
|
236
238
|
|
|
239
|
+
jsi::Value NativeReanimatedModule::enableLayoutAnimations(
|
|
240
|
+
jsi::Runtime &rt,
|
|
241
|
+
const jsi::Value &config) {
|
|
242
|
+
FeaturesConfig::setLayoutAnimationEnabled(config.getBool());
|
|
243
|
+
return jsi::Value::undefined();
|
|
244
|
+
}
|
|
245
|
+
|
|
237
246
|
void NativeReanimatedModule::onEvent(
|
|
238
247
|
std::string eventName,
|
|
239
248
|
std::string eventAsString) {
|
|
@@ -99,6 +99,17 @@ static jsi::Value __hostFunction_NativeReanimatedModuleSpec_getViewProp(
|
|
|
99
99
|
return jsi::Value::undefined();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
static jsi::Value
|
|
103
|
+
__hostFunction_NativeReanimatedModuleSpec_enableLayoutAnimations(
|
|
104
|
+
jsi::Runtime &rt,
|
|
105
|
+
TurboModule &turboModule,
|
|
106
|
+
const jsi::Value *args,
|
|
107
|
+
size_t count) {
|
|
108
|
+
static_cast<NativeReanimatedModuleSpec *>(&turboModule)
|
|
109
|
+
->enableLayoutAnimations(rt, std::move(args[0]));
|
|
110
|
+
return jsi::Value::undefined();
|
|
111
|
+
}
|
|
112
|
+
|
|
102
113
|
NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
|
|
103
114
|
std::shared_ptr<CallInvoker> jsInvoker)
|
|
104
115
|
: TurboModule("NativeReanimated", jsInvoker) {
|
|
@@ -124,6 +135,8 @@ NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
|
|
|
124
135
|
|
|
125
136
|
methodMap_["getViewProp"] =
|
|
126
137
|
MethodMetadata{3, __hostFunction_NativeReanimatedModuleSpec_getViewProp};
|
|
138
|
+
methodMap_["enableLayoutAnimations"] = MethodMetadata{
|
|
139
|
+
2, __hostFunction_NativeReanimatedModuleSpec_enableLayoutAnimations};
|
|
127
140
|
}
|
|
128
141
|
|
|
129
142
|
} // namespace reanimated
|
|
@@ -50,7 +50,7 @@ void EventHandlerRegistry::processEvent(
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
auto eventObject = jsi::Value::createFromJsonUtf8(
|
|
53
|
-
rt,
|
|
53
|
+
rt, reinterpret_cast<uint8_t *>(&eventJSON[0]), eventJSON.size());
|
|
54
54
|
|
|
55
55
|
eventObject.asObject(rt).setProperty(
|
|
56
56
|
rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
|
|
@@ -62,7 +62,7 @@ void EventHandlerRegistry::processEvent(
|
|
|
62
62
|
bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(std::string eventName) {
|
|
63
63
|
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
64
64
|
auto it = eventMappings.find(eventName);
|
|
65
|
-
return (it != eventMappings.end())
|
|
65
|
+
return (it != eventMappings.end()) && (!(it->second).empty());
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
} // namespace reanimated
|
|
@@ -39,7 +39,7 @@ void MapperRegistry::updateOrder() { // Topological sorting
|
|
|
39
39
|
std::shared_ptr<Mapper> mapper;
|
|
40
40
|
std::shared_ptr<MutableValue> mutableValue;
|
|
41
41
|
|
|
42
|
-
NodeID(std::shared_ptr<Mapper> mapper) {
|
|
42
|
+
explicit NodeID(std::shared_ptr<Mapper> mapper) {
|
|
43
43
|
if (mapper == nullptr) {
|
|
44
44
|
throw std::runtime_error(
|
|
45
45
|
"Graph couldn't be sorted (Mapper cannot be nullptr)");
|
|
@@ -47,7 +47,7 @@ void MapperRegistry::updateOrder() { // Topological sorting
|
|
|
47
47
|
this->mapper = mapper;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
NodeID(std::shared_ptr<MutableValue> mutableValue) {
|
|
50
|
+
explicit NodeID(std::shared_ptr<MutableValue> mutableValue) {
|
|
51
51
|
if (mutableValue == nullptr) {
|
|
52
52
|
throw std::runtime_error(
|
|
53
53
|
"Graph couldn't be sorted (Mutable cannot be nullptr)");
|
|
@@ -97,7 +97,7 @@ void MapperRegistry::updateOrder() { // Topological sorting
|
|
|
97
97
|
for (auto sharedValue : mapper->inputs) {
|
|
98
98
|
auto sharedValueID = NodeID(sharedValue);
|
|
99
99
|
mappersThatUseSharedValue[sharedValue].push_back(mapper);
|
|
100
|
-
if (deg.count(
|
|
100
|
+
if (deg.count(sharedValueID) == 0) {
|
|
101
101
|
deg[sharedValueID] = 0;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -114,7 +114,7 @@ void MapperRegistry::updateOrder() { // Topological sorting
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
while (nodes.size() > 0
|
|
117
|
+
while (nodes.size() > 0 && nodes.begin()->first == 0) {
|
|
118
118
|
auto entry = *nodes.begin();
|
|
119
119
|
nodes.erase(entry);
|
|
120
120
|
|
|
@@ -123,7 +123,7 @@ void MapperRegistry::updateOrder() { // Topological sorting
|
|
|
123
123
|
|
|
124
124
|
if (id.isMutable()) {
|
|
125
125
|
for (auto id : mappersThatUseSharedValue[id.mutableValue]) {
|
|
126
|
-
toUpdate.push_back(id);
|
|
126
|
+
toUpdate.push_back(NodeID(id));
|
|
127
127
|
}
|
|
128
128
|
} else {
|
|
129
129
|
for (auto sharedValue : id.mapper->outputs) {
|
|
@@ -27,9 +27,7 @@ jsi::Object FrozenObject::shallowClone(jsi::Runtime &rt) {
|
|
|
27
27
|
for (auto propName : namesOrder) {
|
|
28
28
|
auto value = map[propName];
|
|
29
29
|
object.setProperty(
|
|
30
|
-
rt,
|
|
31
|
-
jsi::String::createFromUtf8(rt, propName),
|
|
32
|
-
value->getValue(rt));
|
|
30
|
+
rt, jsi::String::createFromUtf8(rt, propName), value->getValue(rt));
|
|
33
31
|
}
|
|
34
32
|
return object;
|
|
35
33
|
}
|
|
@@ -13,16 +13,15 @@ const char *HIDDEN_HOST_OBJECT_PROP = "__reanimatedHostObjectRef";
|
|
|
13
13
|
const char *ALREADY_CONVERTED = "__alreadyConverted";
|
|
14
14
|
const char *CALL_ASYNC = "__callAsync";
|
|
15
15
|
const char *PRIMAL_FUNCTION = "__primalFunction";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
b) If you want to execute this method on the JS thread, wrap it using runOnJS )";
|
|
16
|
+
const char *CALLBACK_ERROR_SUFFIX =
|
|
17
|
+
"\n\nPossible solutions are:\n"
|
|
18
|
+
"a) If you want to synchronously execute this method, mark it as a Worklet\n"
|
|
19
|
+
"b) If you want to execute this method on the JS thread, wrap it using runOnJS";
|
|
21
20
|
|
|
22
21
|
void addHiddenProperty(
|
|
23
22
|
jsi::Runtime &rt,
|
|
24
23
|
jsi::Value &&value,
|
|
25
|
-
jsi::Object &obj,
|
|
24
|
+
const jsi::Object &obj,
|
|
26
25
|
const char *name) {
|
|
27
26
|
jsi::Object globalObject = rt.global().getPropertyAsObject(rt, "Object");
|
|
28
27
|
jsi::Function defineProperty =
|
|
@@ -34,7 +33,7 @@ void addHiddenProperty(
|
|
|
34
33
|
defineProperty.call(rt, obj, internalPropName, paramForDefineProperty);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
void freeze(jsi::Runtime &rt, jsi::Object &obj) {
|
|
36
|
+
void freeze(jsi::Runtime &rt, const jsi::Object &obj) {
|
|
38
37
|
jsi::Object globalObject = rt.global().getPropertyAsObject(rt, "Object");
|
|
39
38
|
jsi::Function freeze = globalObject.getPropertyAsFunction(rt, "freeze");
|
|
40
39
|
freeze.call(rt, obj);
|
|
@@ -344,7 +343,7 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) {
|
|
|
344
343
|
hostFunction->getPureFunction().get()->call(
|
|
345
344
|
*hostRuntime,
|
|
346
345
|
static_cast<const jsi::Value *>(args),
|
|
347
|
-
(
|
|
346
|
+
static_cast<size_t>(params.size()));
|
|
348
347
|
|
|
349
348
|
delete[] args;
|
|
350
349
|
// ToDo use returned value to return promise
|
|
@@ -455,8 +454,7 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) {
|
|
|
455
454
|
returnedValue = funPtr->call(
|
|
456
455
|
rt,
|
|
457
456
|
static_cast<const jsi::Value *>(args),
|
|
458
|
-
(
|
|
459
|
-
|
|
457
|
+
static_cast<size_t>(params.size()));
|
|
460
458
|
} catch (std::exception &e) {
|
|
461
459
|
std::string str = e.what();
|
|
462
460
|
runtimeManager->errorHandler->setError(str);
|
|
@@ -21,7 +21,7 @@ std::weak_ptr<jsi::Value> StoreUser::getWeakRef(jsi::Runtime &rt) {
|
|
|
21
21
|
|
|
22
22
|
StoreUser::StoreUser(
|
|
23
23
|
std::shared_ptr<Scheduler> s,
|
|
24
|
-
RuntimeManager &runtimeManager)
|
|
24
|
+
const RuntimeManager &runtimeManager)
|
|
25
25
|
: scheduler(s) {
|
|
26
26
|
storeUserData = runtimeManager.storeUserData;
|
|
27
27
|
identifier = storeUserData->ctr++;
|
|
@@ -32,7 +32,7 @@ StoreUser::~StoreUser() {
|
|
|
32
32
|
std::shared_ptr<Scheduler> strongScheduler = scheduler.lock();
|
|
33
33
|
if (strongScheduler != nullptr) {
|
|
34
34
|
std::shared_ptr<StaticStoreUser> sud = storeUserData;
|
|
35
|
-
|
|
35
|
+
#ifdef ONANDROID
|
|
36
36
|
jni::ThreadScope::WithClassLoader([&] {
|
|
37
37
|
strongScheduler->scheduleOnUI([id, sud]() {
|
|
38
38
|
const std::lock_guard<std::recursive_mutex> lock(sud->storeMutex);
|
|
@@ -41,14 +41,14 @@ StoreUser::~StoreUser() {
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
#else
|
|
45
45
|
strongScheduler->scheduleOnUI([id, sud]() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
const std::lock_guard<std::recursive_mutex> lock(sud->storeMutex);
|
|
47
|
+
if (sud->store.count(id) > 0) {
|
|
48
|
+
sud->store.erase(id);
|
|
49
|
+
}
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
#endif
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -36,7 +36,7 @@ void Mapper::execute(jsi::Runtime &rt) {
|
|
|
36
36
|
jsViewDescriptorArray.getValueAtIndex(rt, i).getObject(rt);
|
|
37
37
|
(*updateProps)(
|
|
38
38
|
rt,
|
|
39
|
-
(
|
|
39
|
+
static_cast<int>(jsViewDescriptor.getProperty(rt, "tag").asNumber()),
|
|
40
40
|
jsViewDescriptor.getProperty(rt, "name"),
|
|
41
41
|
newStyle);
|
|
42
42
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "RuntimeDecorator.h"
|
|
2
|
+
#include <chrono>
|
|
2
3
|
#include <memory>
|
|
3
4
|
#include <unordered_map>
|
|
4
5
|
#include "LayoutAnimationsProxy.h"
|
|
@@ -8,11 +9,15 @@
|
|
|
8
9
|
namespace reanimated {
|
|
9
10
|
|
|
10
11
|
std::unordered_map<RuntimePointer, RuntimeType>
|
|
11
|
-
RuntimeDecorator::runtimeRegistry
|
|
12
|
+
&RuntimeDecorator::runtimeRegistry() {
|
|
13
|
+
static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
|
|
14
|
+
return runtimeRegistry;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
void RuntimeDecorator::registerRuntime(
|
|
13
18
|
jsi::Runtime *runtime,
|
|
14
19
|
RuntimeType runtimeType) {
|
|
15
|
-
runtimeRegistry.insert({runtime, runtimeType});
|
|
20
|
+
runtimeRegistry().insert({runtime, runtimeType});
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
void RuntimeDecorator::decorateRuntime(
|
|
@@ -79,6 +84,22 @@ void RuntimeDecorator::decorateRuntime(
|
|
|
79
84
|
jsi::PropNameID::forAscii(rt, "_setGlobalConsole"),
|
|
80
85
|
1,
|
|
81
86
|
setGlobalConsole));
|
|
87
|
+
|
|
88
|
+
rt.global().setProperty(
|
|
89
|
+
rt,
|
|
90
|
+
"_chronoNow",
|
|
91
|
+
jsi::Function::createFromHostFunction(
|
|
92
|
+
rt,
|
|
93
|
+
jsi::PropNameID::forAscii(rt, "_chronoNow"),
|
|
94
|
+
0,
|
|
95
|
+
[](jsi::Runtime &rt,
|
|
96
|
+
const jsi::Value &thisValue,
|
|
97
|
+
const jsi::Value *args,
|
|
98
|
+
size_t count) -> jsi::Value {
|
|
99
|
+
double now = std::chrono::system_clock::now().time_since_epoch() /
|
|
100
|
+
std::chrono::milliseconds(1);
|
|
101
|
+
return jsi::Value(now);
|
|
102
|
+
}));
|
|
82
103
|
}
|
|
83
104
|
|
|
84
105
|
void RuntimeDecorator::decorateUIRuntime(
|
|
@@ -88,6 +109,7 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
88
109
|
const ScrollToFunction scrollTo,
|
|
89
110
|
const MeasuringFunction measure,
|
|
90
111
|
const TimeProviderFunction getCurrentTime,
|
|
112
|
+
const SetGestureStateFunction setGestureState,
|
|
91
113
|
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy) {
|
|
92
114
|
RuntimeDecorator::decorateRuntime(rt, "UI");
|
|
93
115
|
rt.global().setProperty(rt, "_UI", jsi::Value(true));
|
|
@@ -128,7 +150,7 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
128
150
|
const jsi::Value &thisValue,
|
|
129
151
|
const jsi::Value *args,
|
|
130
152
|
const size_t count) -> jsi::Value {
|
|
131
|
-
int viewTag = (
|
|
153
|
+
int viewTag = static_cast<int>(args[0].asNumber());
|
|
132
154
|
double x = args[1].asNumber();
|
|
133
155
|
double y = args[2].asNumber();
|
|
134
156
|
bool animated = args[3].getBool();
|
|
@@ -144,7 +166,7 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
144
166
|
const jsi::Value &thisValue,
|
|
145
167
|
const jsi::Value *args,
|
|
146
168
|
const size_t count) -> jsi::Value {
|
|
147
|
-
int viewTag = (
|
|
169
|
+
int viewTag = static_cast<int>(args[0].asNumber());
|
|
148
170
|
auto result = measure(viewTag);
|
|
149
171
|
jsi::Object resultObject(rt);
|
|
150
172
|
for (auto &i : result) {
|
|
@@ -207,6 +229,20 @@ void RuntimeDecorator::decorateUIRuntime(
|
|
|
207
229
|
jsi::Value _stopObservingProgress = jsi::Function::createFromHostFunction(
|
|
208
230
|
rt, jsi::PropNameID::forAscii(rt, "_stopObservingProgress"), 0, clb8);
|
|
209
231
|
rt.global().setProperty(rt, "_stopObservingProgress", _stopObservingProgress);
|
|
232
|
+
|
|
233
|
+
auto clb9 = [setGestureState](
|
|
234
|
+
jsi::Runtime &rt,
|
|
235
|
+
const jsi::Value &thisValue,
|
|
236
|
+
const jsi::Value *args,
|
|
237
|
+
size_t count) -> jsi::Value {
|
|
238
|
+
int handlerTag = static_cast<int>(args[0].asNumber());
|
|
239
|
+
int newState = static_cast<int>(args[1].asNumber());
|
|
240
|
+
setGestureState(handlerTag, newState);
|
|
241
|
+
return jsi::Value::undefined();
|
|
242
|
+
};
|
|
243
|
+
jsi::Value setGestureStateFunction = jsi::Function::createFromHostFunction(
|
|
244
|
+
rt, jsi::PropNameID::forAscii(rt, "_setGestureState"), 2, clb9);
|
|
245
|
+
rt.global().setProperty(rt, "_setGestureState", setGestureStateFunction);
|
|
210
246
|
}
|
|
211
247
|
|
|
212
248
|
} // namespace reanimated
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
#include <unistd.h>
|
|
4
4
|
#include <memory>
|
|
5
|
+
#include <string>
|
|
5
6
|
#include <vector>
|
|
7
|
+
|
|
6
8
|
#include "ErrorHandler.h"
|
|
7
9
|
#include "LayoutAnimationsProxy.h"
|
|
8
10
|
#include "NativeReanimatedModuleSpec.h"
|
|
@@ -66,6 +68,9 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
|
|
|
66
68
|
const jsi::Value &propName,
|
|
67
69
|
const jsi::Value &callback) override;
|
|
68
70
|
|
|
71
|
+
jsi::Value enableLayoutAnimations(jsi::Runtime &rt, const jsi::Value &config)
|
|
72
|
+
override;
|
|
73
|
+
|
|
69
74
|
void onRender(double timestampMs);
|
|
70
75
|
void onEvent(std::string eventName, std::string eventAsString);
|
|
71
76
|
bool isAnyHandlerWaitingForEvent(std::string eventName);
|
|
@@ -19,7 +19,7 @@ namespace reanimated {
|
|
|
19
19
|
|
|
20
20
|
class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
|
|
21
21
|
protected:
|
|
22
|
-
NativeReanimatedModuleSpec(std::shared_ptr<CallInvoker> jsInvoker);
|
|
22
|
+
explicit NativeReanimatedModuleSpec(std::shared_ptr<CallInvoker> jsInvoker);
|
|
23
23
|
|
|
24
24
|
public:
|
|
25
25
|
virtual void installCoreFunctions(
|
|
@@ -58,6 +58,11 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
|
|
|
58
58
|
const jsi::Value &viewTag,
|
|
59
59
|
const jsi::Value &propName,
|
|
60
60
|
const jsi::Value &callback) = 0;
|
|
61
|
+
|
|
62
|
+
// other
|
|
63
|
+
virtual jsi::Value enableLayoutAnimations(
|
|
64
|
+
jsi::Runtime &rt,
|
|
65
|
+
const jsi::Value &config) = 0;
|
|
61
66
|
};
|
|
62
67
|
|
|
63
68
|
} // namespace reanimated
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <utility>
|
|
4
6
|
#include "SharedParent.h"
|
|
5
7
|
|
|
6
8
|
using namespace facebook;
|
|
@@ -13,7 +15,7 @@ class MutableValueSetterProxy : public jsi::HostObject {
|
|
|
13
15
|
std::shared_ptr<MutableValue> mutableValue;
|
|
14
16
|
|
|
15
17
|
public:
|
|
16
|
-
MutableValueSetterProxy(std::shared_ptr<MutableValue> mutableValue)
|
|
18
|
+
explicit MutableValueSetterProxy(std::shared_ptr<MutableValue> mutableValue)
|
|
17
19
|
: mutableValue(std::move(mutableValue)) {}
|
|
18
20
|
void
|
|
19
21
|
set(jsi::Runtime &rt, const jsi::PropNameID &name, const jsi::Value &value);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
3
6
|
#include "FrozenObject.h"
|
|
4
7
|
#include "JSIStoreValueUser.h"
|
|
5
8
|
#include "SharedParent.h"
|
|
@@ -17,7 +20,7 @@ class RemoteObject : public jsi::HostObject, public StoreUser {
|
|
|
17
20
|
void maybeInitializeOnWorkletRuntime(jsi::Runtime &rt);
|
|
18
21
|
RemoteObject(
|
|
19
22
|
jsi::Runtime &rt,
|
|
20
|
-
jsi::Object &object,
|
|
23
|
+
const jsi::Object &object,
|
|
21
24
|
RuntimeManager *runtimeManager,
|
|
22
25
|
std::shared_ptr<Scheduler> s)
|
|
23
26
|
: StoreUser(s, *runtimeManager),
|
|
@@ -8,15 +8,15 @@ enum class ValueType {
|
|
|
8
8
|
BoolType,
|
|
9
9
|
NumberType,
|
|
10
10
|
StringType,
|
|
11
|
-
RemoteObjectType,
|
|
12
|
-
|
|
13
|
-
MutableValueType,
|
|
14
|
-
|
|
15
|
-
HostFunctionType,
|
|
16
|
-
|
|
17
|
-
WorkletFunctionType,
|
|
18
|
-
FrozenObjectType,
|
|
19
|
-
FrozenArrayType,
|
|
11
|
+
RemoteObjectType, // object that can be instantiated on host side and modified
|
|
12
|
+
// on the remote (worklet) side
|
|
13
|
+
MutableValueType, // object with 'value' property that can be updated and read
|
|
14
|
+
// from any thread
|
|
15
|
+
HostFunctionType, // function that will be executed asynchronously on the host
|
|
16
|
+
// runtime
|
|
17
|
+
WorkletFunctionType, // function that gets run on the UI thread
|
|
18
|
+
FrozenObjectType, // frozen object, can only be set and never modified
|
|
19
|
+
FrozenArrayType, // frozen array, can only be set and never modified
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
class ShareableValue;
|