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,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
#import "REAIOSScheduler.h"
|
|
3
|
-
#import "REAIOSErrorHandler.h"
|
|
4
|
-
#import "REAModule.h"
|
|
5
|
-
#import "REANodesManager.h"
|
|
6
|
-
#import "NativeMethods.h"
|
|
7
|
-
#import <folly/json.h>
|
|
1
|
+
|
|
8
2
|
#import <React/RCTFollyConvert.h>
|
|
9
3
|
#import <React/RCTUIManager.h>
|
|
4
|
+
#import <folly/json.h>
|
|
5
|
+
|
|
10
6
|
#import "LayoutAnimationsProxy.h"
|
|
7
|
+
#import "NativeMethods.h"
|
|
8
|
+
#import "NativeProxy.h"
|
|
11
9
|
#import "REAAnimationsManager.h"
|
|
10
|
+
#import "REAIOSErrorHandler.h"
|
|
11
|
+
#import "REAIOSScheduler.h"
|
|
12
|
+
#import "REAModule.h"
|
|
13
|
+
#import "REANodesManager.h"
|
|
12
14
|
#import "REAUIManager.h"
|
|
15
|
+
#import "RNGestureHandlerStateManager.h"
|
|
13
16
|
|
|
14
17
|
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
|
15
18
|
#import <reacthermes/HermesExecutorFactory.h>
|
|
@@ -24,7 +27,6 @@ namespace reanimated {
|
|
|
24
27
|
using namespace facebook;
|
|
25
28
|
using namespace react;
|
|
26
29
|
|
|
27
|
-
|
|
28
30
|
// COPIED FROM RCTTurboModule.mm
|
|
29
31
|
static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value);
|
|
30
32
|
|
|
@@ -49,15 +51,13 @@ static NSDictionary *convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const
|
|
|
49
51
|
return [result copy];
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
static NSArray *
|
|
53
|
-
convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value)
|
|
54
|
+
static NSArray *convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value)
|
|
54
55
|
{
|
|
55
56
|
size_t size = value.size(runtime);
|
|
56
57
|
NSMutableArray *result = [NSMutableArray new];
|
|
57
58
|
for (size_t i = 0; i < size; i++) {
|
|
58
59
|
// Insert kCFNull when it's `undefined` value to preserve the indices.
|
|
59
|
-
[result
|
|
60
|
-
addObject:convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i)) ?: (id)kCFNull];
|
|
60
|
+
[result addObject:convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i)) ?: (id)kCFNull];
|
|
61
61
|
}
|
|
62
62
|
return [result copy];
|
|
63
63
|
}
|
|
@@ -87,18 +87,23 @@ static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &v
|
|
|
87
87
|
throw std::runtime_error("Unsupported jsi::jsi::Value kind");
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
91
|
-
|
|
90
|
+
std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
91
|
+
RCTBridge *bridge,
|
|
92
|
+
std::shared_ptr<CallInvoker> jsInvoker)
|
|
93
|
+
{
|
|
92
94
|
REAModule *reanimatedModule = [bridge moduleForClass:[REAModule class]];
|
|
93
95
|
|
|
94
|
-
auto propUpdater = [reanimatedModule](
|
|
95
|
-
|
|
96
|
+
auto propUpdater = [reanimatedModule](
|
|
97
|
+
jsi::Runtime &rt, int viewTag, const jsi::Value &viewName, const jsi::Object &props) -> void {
|
|
98
|
+
NSString *nsViewName = [NSString stringWithCString:viewName.asString(rt).utf8(rt).c_str()
|
|
99
|
+
encoding:[NSString defaultCStringEncoding]];
|
|
96
100
|
|
|
97
101
|
NSDictionary *propsDict = convertJSIObjectToNSDictionary(rt, props);
|
|
98
|
-
[reanimatedModule.nodesManager updateProps:propsDict
|
|
102
|
+
[reanimatedModule.nodesManager updateProps:propsDict
|
|
103
|
+
ofViewWithTag:[NSNumber numberWithInt:viewTag]
|
|
104
|
+
withName:nsViewName];
|
|
99
105
|
};
|
|
100
106
|
|
|
101
|
-
|
|
102
107
|
RCTUIManager *uiManager = reanimatedModule.nodesManager.uiManager;
|
|
103
108
|
auto measuringFunction = [uiManager](int viewTag) -> std::vector<std::pair<std::string, double>> {
|
|
104
109
|
return measure(viewTag, uiManager);
|
|
@@ -108,11 +113,18 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
|
|
|
108
113
|
scrollTo(viewTag, uiManager, x, y, animated);
|
|
109
114
|
};
|
|
110
115
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
id<RNGestureHandlerStateManager> gestureHandlerStateManager = [bridge moduleForName:@"RNGestureHandlerModule"];
|
|
117
|
+
auto setGestureStateFunction = [gestureHandlerStateManager](int handlerTag, int newState) {
|
|
118
|
+
setGestureState(gestureHandlerStateManager, handlerTag, newState);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
auto propObtainer = [reanimatedModule](
|
|
122
|
+
jsi::Runtime &rt, const int viewTag, const jsi::String &propName) -> jsi::Value {
|
|
123
|
+
NSString *propNameConverted = [NSString stringWithFormat:@"%s", propName.utf8(rt).c_str()];
|
|
124
|
+
std::string resultStr = std::string([[reanimatedModule.nodesManager obtainProp:[NSNumber numberWithInt:viewTag]
|
|
125
|
+
propName:propNameConverted] UTF8String]);
|
|
126
|
+
jsi::Value val = jsi::String::createFromUtf8(rt, resultStr);
|
|
127
|
+
return val;
|
|
116
128
|
};
|
|
117
129
|
|
|
118
130
|
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
|
@@ -128,13 +140,13 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
|
|
|
128
140
|
std::shared_ptr<NativeReanimatedModule> module;
|
|
129
141
|
|
|
130
142
|
__block std::weak_ptr<Scheduler> weakScheduler = scheduler;
|
|
131
|
-
((REAUIManager*)uiManager).flushUiOperations = ^void() {
|
|
143
|
+
((REAUIManager *)uiManager).flushUiOperations = ^void() {
|
|
132
144
|
std::shared_ptr<Scheduler> scheduler = weakScheduler.lock();
|
|
133
145
|
if (scheduler != nullptr) {
|
|
134
146
|
scheduler->triggerUI();
|
|
135
147
|
}
|
|
136
148
|
};
|
|
137
|
-
|
|
149
|
+
|
|
138
150
|
auto requestRender = [reanimatedModule, &module](std::function<void(double)> onRender, jsi::Runtime &rt) {
|
|
139
151
|
[reanimatedModule.nodesManager postOnAnimation:^(CADisplayLink *displayLink) {
|
|
140
152
|
double frameTimestamp = displayLink.targetTimestamp * 1000;
|
|
@@ -146,80 +158,89 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
|
|
|
146
158
|
}];
|
|
147
159
|
};
|
|
148
160
|
|
|
149
|
-
auto getCurrentTime = []() {
|
|
150
|
-
|
|
151
|
-
};
|
|
152
|
-
|
|
161
|
+
auto getCurrentTime = []() { return CACurrentMediaTime() * 1000; };
|
|
162
|
+
|
|
153
163
|
// Layout Animations start
|
|
154
|
-
REAUIManager*
|
|
155
|
-
RCTUIManager*
|
|
164
|
+
REAUIManager *reaUiManagerNoCast = [bridge moduleForClass:[REAUIManager class]];
|
|
165
|
+
RCTUIManager *reaUiManager = reaUiManagerNoCast;
|
|
156
166
|
REAAnimationsManager *animationsManager = [[REAAnimationsManager alloc] initWithUIManager:reaUiManager];
|
|
157
167
|
[reaUiManagerNoCast setUp:animationsManager];
|
|
158
|
-
|
|
168
|
+
|
|
159
169
|
auto notifyAboutProgress = [=](int tag, jsi::Object newStyle) {
|
|
160
170
|
if (animationsManager) {
|
|
161
171
|
NSDictionary *propsDict = convertJSIObjectToNSDictionary(*animatedRuntime, newStyle);
|
|
162
|
-
[animationsManager notifyAboutProgress:propsDict tag:[NSNumber numberWithInt:
|
|
172
|
+
[animationsManager notifyAboutProgress:propsDict tag:[NSNumber numberWithInt:tag]];
|
|
163
173
|
}
|
|
164
174
|
};
|
|
165
|
-
|
|
175
|
+
|
|
166
176
|
auto notifyAboutEnd = [=](int tag, bool isCancelled) {
|
|
167
177
|
if (animationsManager) {
|
|
168
|
-
[animationsManager notifyAboutEnd:[NSNumber numberWithInt:
|
|
178
|
+
[animationsManager notifyAboutEnd:[NSNumber numberWithInt:tag] cancelled:isCancelled];
|
|
169
179
|
}
|
|
170
180
|
};
|
|
171
|
-
|
|
172
|
-
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy =
|
|
181
|
+
|
|
182
|
+
std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy =
|
|
183
|
+
std::make_shared<LayoutAnimationsProxy>(notifyAboutProgress, notifyAboutEnd);
|
|
173
184
|
std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
|
|
174
|
-
[animationsManager setAnimationStartingBlock:^(
|
|
185
|
+
[animationsManager setAnimationStartingBlock:^(
|
|
186
|
+
NSNumber *_Nonnull tag, NSString *type, NSDictionary *_Nonnull values, NSNumber *depth) {
|
|
175
187
|
std::shared_ptr<jsi::Runtime> rt = wrt.lock();
|
|
176
188
|
if (wrt.expired()) {
|
|
177
189
|
return;
|
|
178
190
|
}
|
|
179
191
|
jsi::Object yogaValues(*rt);
|
|
180
192
|
for (NSString *key in values.allKeys) {
|
|
181
|
-
NSNumber*
|
|
193
|
+
NSNumber *value = values[key];
|
|
182
194
|
yogaValues.setProperty(*rt, [key UTF8String], [value doubleValue]);
|
|
183
195
|
}
|
|
184
|
-
|
|
185
|
-
jsi::Value layoutAnimationRepositoryAsValue =
|
|
196
|
+
|
|
197
|
+
jsi::Value layoutAnimationRepositoryAsValue =
|
|
198
|
+
rt->global().getPropertyAsObject(*rt, "global").getProperty(*rt, "LayoutAnimationRepository");
|
|
186
199
|
if (!layoutAnimationRepositoryAsValue.isUndefined()) {
|
|
187
|
-
jsi::Function startAnimationForTag =
|
|
188
|
-
|
|
200
|
+
jsi::Function startAnimationForTag =
|
|
201
|
+
layoutAnimationRepositoryAsValue.getObject(*rt).getPropertyAsFunction(*rt, "startAnimationForTag");
|
|
202
|
+
startAnimationForTag.call(
|
|
203
|
+
*rt,
|
|
204
|
+
jsi::Value([tag intValue]),
|
|
205
|
+
jsi::String::createFromAscii(*rt, std::string([type UTF8String])),
|
|
206
|
+
yogaValues,
|
|
207
|
+
jsi::Value([depth intValue]));
|
|
189
208
|
}
|
|
190
209
|
}];
|
|
191
210
|
|
|
192
|
-
|
|
193
|
-
[animationsManager setRemovingConfigBlock:^(NSNumber* _Nonnull tag) {
|
|
211
|
+
[animationsManager setRemovingConfigBlock:^(NSNumber *_Nonnull tag) {
|
|
194
212
|
std::shared_ptr<jsi::Runtime> rt = wrt.lock();
|
|
195
213
|
if (wrt.expired()) {
|
|
196
214
|
return;
|
|
197
215
|
}
|
|
198
|
-
jsi::Value layoutAnimationRepositoryAsValue =
|
|
216
|
+
jsi::Value layoutAnimationRepositoryAsValue =
|
|
217
|
+
rt->global().getPropertyAsObject(*rt, "global").getProperty(*rt, "LayoutAnimationRepository");
|
|
199
218
|
if (!layoutAnimationRepositoryAsValue.isUndefined()) {
|
|
200
|
-
jsi::Function removeConfig =
|
|
219
|
+
jsi::Function removeConfig =
|
|
220
|
+
layoutAnimationRepositoryAsValue.getObject(*rt).getPropertyAsFunction(*rt, "removeConfig");
|
|
201
221
|
removeConfig.call(*rt, jsi::Value([tag intValue]));
|
|
202
222
|
}
|
|
203
223
|
}];
|
|
204
|
-
|
|
224
|
+
|
|
205
225
|
// Layout Animations end
|
|
206
|
-
|
|
226
|
+
|
|
207
227
|
PlatformDepMethodsHolder platformDepMethodsHolder = {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
228
|
+
requestRender,
|
|
229
|
+
propUpdater,
|
|
230
|
+
scrollToFunction,
|
|
231
|
+
measuringFunction,
|
|
232
|
+
getCurrentTime,
|
|
233
|
+
setGestureStateFunction,
|
|
213
234
|
};
|
|
214
235
|
|
|
215
|
-
module = std::make_shared<NativeReanimatedModule>(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
236
|
+
module = std::make_shared<NativeReanimatedModule>(
|
|
237
|
+
jsInvoker,
|
|
238
|
+
scheduler,
|
|
239
|
+
animatedRuntime,
|
|
240
|
+
errorHandler,
|
|
241
|
+
propObtainer,
|
|
242
|
+
layoutAnimationsProxy,
|
|
243
|
+
platformDepMethodsHolder);
|
|
223
244
|
|
|
224
245
|
scheduler->setRuntimeManager(module);
|
|
225
246
|
|
|
@@ -227,7 +248,7 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
|
|
|
227
248
|
std::string eventNameString([eventName UTF8String]);
|
|
228
249
|
std::string eventAsString = folly::toJson(convertIdToFollyDynamic([event arguments][2]));
|
|
229
250
|
|
|
230
|
-
eventAsString = "{ NativeMap:"
|
|
251
|
+
eventAsString = "{ NativeMap:" + eventAsString + "}";
|
|
231
252
|
jsi::Object global = module->runtime->global();
|
|
232
253
|
jsi::String eventTimestampName = jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
|
|
233
254
|
global.setProperty(*module->runtime, eventTimestampName, CACurrentMediaTime() * 1000);
|
|
@@ -2,31 +2,35 @@
|
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
3
|
#import <React/RCTLog.h>
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
namespace reanimated {
|
|
7
6
|
|
|
8
|
-
REAIOSErrorHandler::REAIOSErrorHandler(std::shared_ptr<Scheduler> scheduler)
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
REAIOSErrorHandler::REAIOSErrorHandler(std::shared_ptr<Scheduler> scheduler)
|
|
8
|
+
{
|
|
9
|
+
this->scheduler = scheduler;
|
|
10
|
+
error = std::make_shared<ErrorWrapper>();
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
void REAIOSErrorHandler::raiseSpec()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
void REAIOSErrorHandler::raiseSpec()
|
|
14
|
+
{
|
|
15
|
+
if (error->handled) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
RCTLogError(@(error->message.c_str()));
|
|
19
|
+
this->error->handled = true;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
std::shared_ptr<Scheduler> REAIOSErrorHandler::getScheduler()
|
|
22
|
-
|
|
22
|
+
std::shared_ptr<Scheduler> REAIOSErrorHandler::getScheduler()
|
|
23
|
+
{
|
|
24
|
+
return this->scheduler;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
std::shared_ptr<ErrorWrapper> REAIOSErrorHandler::getError()
|
|
26
|
-
|
|
27
|
+
std::shared_ptr<ErrorWrapper> REAIOSErrorHandler::getError()
|
|
28
|
+
{
|
|
29
|
+
return this->error;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
void REAIOSErrorHandler::setError(std::string message)
|
|
32
|
+
void REAIOSErrorHandler::setError(std::string message)
|
|
33
|
+
{
|
|
30
34
|
if (error->handled) {
|
|
31
35
|
error->message = message;
|
|
32
36
|
error->handled = false;
|
|
@@ -5,20 +5,24 @@ namespace reanimated {
|
|
|
5
5
|
|
|
6
6
|
std::unique_ptr<LoggerInterface> Logger::instance = std::make_unique<REAIOSLogger>();
|
|
7
7
|
|
|
8
|
-
void REAIOSLogger::log(const char*
|
|
8
|
+
void REAIOSLogger::log(const char *str)
|
|
9
|
+
{
|
|
9
10
|
NSLog(@"%@", [NSString stringWithCString:str encoding:[NSString defaultCStringEncoding]]);
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
void REAIOSLogger::log(double d)
|
|
13
|
+
void REAIOSLogger::log(double d)
|
|
14
|
+
{
|
|
13
15
|
NSLog(@"%lf", d);
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
void REAIOSLogger::log(int i)
|
|
17
|
-
|
|
18
|
+
void REAIOSLogger::log(int i)
|
|
19
|
+
{
|
|
20
|
+
NSLog(@"%i", i);
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
void REAIOSLogger::log(bool b)
|
|
21
|
-
|
|
23
|
+
void REAIOSLogger::log(bool b)
|
|
24
|
+
{
|
|
25
|
+
const char *str = (b) ? "true" : "false";
|
|
22
26
|
NSLog(@"%@", [NSString stringWithCString:str encoding:[NSString defaultCStringEncoding]]);
|
|
23
27
|
}
|
|
24
28
|
|
|
@@ -6,36 +6,43 @@ namespace reanimated {
|
|
|
6
6
|
using namespace facebook;
|
|
7
7
|
using namespace react;
|
|
8
8
|
|
|
9
|
-
REAIOSScheduler::REAIOSScheduler(std::shared_ptr<CallInvoker> jsInvoker)
|
|
9
|
+
REAIOSScheduler::REAIOSScheduler(std::shared_ptr<CallInvoker> jsInvoker)
|
|
10
|
+
{
|
|
10
11
|
this->jsCallInvoker_ = jsInvoker;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
void REAIOSScheduler::scheduleOnUI(std::function<void()> job)
|
|
14
|
+
void REAIOSScheduler::scheduleOnUI(std::function<void()> job)
|
|
15
|
+
{
|
|
14
16
|
if (runtimeManager.lock() == nullptr) {
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
if([NSThread isMainThread]) {
|
|
19
|
-
if (runtimeManager.lock())
|
|
20
|
+
if ([NSThread isMainThread]) {
|
|
21
|
+
if (runtimeManager.lock()) {
|
|
22
|
+
job();
|
|
23
|
+
}
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
Scheduler::scheduleOnUI(job);
|
|
24
|
-
if([NSThread isMainThread]) {
|
|
25
|
-
if (runtimeManager.lock())
|
|
28
|
+
if ([NSThread isMainThread]) {
|
|
29
|
+
if (runtimeManager.lock()) {
|
|
30
|
+
triggerUI();
|
|
31
|
+
}
|
|
26
32
|
return;
|
|
27
33
|
}
|
|
28
|
-
|
|
34
|
+
|
|
29
35
|
if (!this->scheduledOnUI) {
|
|
30
36
|
__block std::weak_ptr<RuntimeManager> blockRuntimeManager = runtimeManager;
|
|
31
37
|
|
|
32
38
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
33
|
-
if (blockRuntimeManager.lock())
|
|
39
|
+
if (blockRuntimeManager.lock()) {
|
|
40
|
+
triggerUI();
|
|
41
|
+
}
|
|
34
42
|
});
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
REAIOSScheduler::~REAIOSScheduler(){
|
|
39
|
-
}
|
|
46
|
+
REAIOSScheduler::~REAIOSScheduler() {}
|
|
40
47
|
|
|
41
48
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#import "REAInitializer.h"
|
|
2
2
|
#import "REAUIManager.h"
|
|
3
3
|
|
|
4
|
-
@interface RCTEventDispatcher(Reanimated)
|
|
4
|
+
@interface RCTEventDispatcher (Reanimated)
|
|
5
5
|
|
|
6
|
-
- (void)setBridge:(RCTBridge*)bridge;
|
|
6
|
+
- (void)setBridge:(RCTBridge *)bridge;
|
|
7
7
|
|
|
8
8
|
@end
|
|
9
9
|
|
|
@@ -13,51 +13,53 @@ using namespace facebook;
|
|
|
13
13
|
using namespace react;
|
|
14
14
|
|
|
15
15
|
JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
|
|
16
|
-
RCTBridge*
|
|
16
|
+
RCTBridge *bridge,
|
|
17
17
|
JSIExecutor::RuntimeInstaller runtimeInstallerToWrap)
|
|
18
18
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
[bridge moduleForClass:[RCTUIManager class]];
|
|
20
|
+
REAUIManager *reaUiManager = [REAUIManager new];
|
|
21
|
+
[reaUiManager setBridge:bridge];
|
|
22
|
+
RCTUIManager *uiManager = reaUiManager;
|
|
23
|
+
[bridge updateModuleWithInstance:uiManager];
|
|
24
|
+
|
|
25
|
+
[bridge moduleForClass:[RCTEventDispatcher class]];
|
|
26
|
+
RCTEventDispatcher *eventDispatcher = [REAEventDispatcher new];
|
|
27
27
|
#if RNVERSION >= 66
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
RCTCallableJSModules *callableJSModules = [RCTCallableJSModules new];
|
|
29
|
+
[bridge setValue:callableJSModules forKey:@"_callableJSModules"];
|
|
30
|
+
[callableJSModules setBridge:bridge];
|
|
31
|
+
[eventDispatcher setValue:callableJSModules forKey:@"_callableJSModules"];
|
|
32
|
+
[eventDispatcher setValue:bridge forKey:@"_bridge"];
|
|
33
|
+
[eventDispatcher initialize];
|
|
34
34
|
#else
|
|
35
|
-
|
|
35
|
+
[eventDispatcher setBridge:bridge];
|
|
36
36
|
#endif
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
37
|
+
[bridge updateModuleWithInstance:eventDispatcher];
|
|
38
|
+
const auto runtimeInstaller = [bridge, runtimeInstallerToWrap](facebook::jsi::Runtime &runtime) {
|
|
39
|
+
if (!bridge) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
43
42
|
#if RNVERSION >= 63
|
|
44
|
-
auto reanimatedModule = reanimated::createReanimatedModule(bridge.jsCallInvoker);
|
|
43
|
+
auto reanimatedModule = reanimated::createReanimatedModule(bridge, bridge.jsCallInvoker);
|
|
45
44
|
#else
|
|
46
45
|
auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
|
|
47
|
-
auto reanimatedModule = reanimated::createReanimatedModule(callInvoker);
|
|
46
|
+
auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker);
|
|
48
47
|
#endif
|
|
49
|
-
runtime.global().setProperty(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (runtimeInstallerToWrap) {
|
|
54
|
-
runtimeInstallerToWrap(runtime);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
return runtimeInstaller;
|
|
58
|
-
}
|
|
48
|
+
runtime.global().setProperty(
|
|
49
|
+
runtime,
|
|
50
|
+
"_WORKLET_RUNTIME",
|
|
51
|
+
static_cast<double>(reinterpret_cast<std::uintptr_t>(reanimatedModule->runtime.get())));
|
|
59
52
|
|
|
53
|
+
runtime.global().setProperty(
|
|
54
|
+
runtime,
|
|
55
|
+
jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
|
|
56
|
+
jsi::Object::createFromHostObject(runtime, reanimatedModule));
|
|
60
57
|
|
|
58
|
+
if (runtimeInstallerToWrap) {
|
|
59
|
+
runtimeInstallerToWrap(runtime);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
return runtimeInstaller;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
}
|
package/lib/Animated.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogBox } from 'react-native';
|
|
2
2
|
import createAnimatedComponent from './createAnimatedComponent';
|
|
3
3
|
import {
|
|
4
4
|
addWhitelistedNativeProps,
|
|
5
5
|
addWhitelistedUIProps,
|
|
6
6
|
} from './ConfigHelper';
|
|
7
7
|
import * as reanimated1 from './reanimated1';
|
|
8
|
+
import ReanimatedComponents from './reanimated2/component';
|
|
8
9
|
|
|
9
10
|
const Animated = {
|
|
10
11
|
// components
|
|
11
|
-
|
|
12
|
-
Text: createAnimatedComponent(Text),
|
|
13
|
-
Image: createAnimatedComponent(Image),
|
|
14
|
-
ScrollView: createAnimatedComponent(ScrollView),
|
|
12
|
+
...ReanimatedComponents,
|
|
15
13
|
createAnimatedComponent,
|
|
16
14
|
// configuration
|
|
17
15
|
addWhitelistedNativeProps,
|
|
@@ -23,3 +21,11 @@ const Animated = {
|
|
|
23
21
|
export * from './reanimated2';
|
|
24
22
|
export * from './reanimated1';
|
|
25
23
|
export default Animated;
|
|
24
|
+
|
|
25
|
+
// I think we can ignore this message as long as Gesture Handler doesn't
|
|
26
|
+
// try to load the Reanimated module. I figured it should be here instead of
|
|
27
|
+
// RNGH because this prevents the message from being displayed for all
|
|
28
|
+
// versions of RNGH.
|
|
29
|
+
LogBox.ignoreLogs([
|
|
30
|
+
'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
|
|
31
|
+
]);
|