react-native-reanimated 2.2.0 → 2.2.4
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/Tools/JSIStoreValueUser.cpp +28 -15
- package/Common/cpp/headers/Tools/JSIStoreValueUser.h +8 -3
- package/RNReanimated.podspec +6 -6
- package/android/build.gradle +87 -4
- 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/ios/native/NativeProxy.mm +6 -2
- package/ios/native/REAInitializer.h +32 -0
- package/ios/native/REAInitializer.mm +54 -0
- package/ios/native/UIResponder+Reanimated.mm +8 -48
- package/lib/reanimated1/core/Core.test.js +30 -0
- package/lib/reanimated2/core.js +1 -1
- package/lib/reanimated2/js-reanimated/index.web.js +7 -1
- package/lib/reanimated2/platform-specific/RNRenderer.web.js +2 -0
- package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
- package/package.json +4 -3
- package/src/reanimated1/core/Core.test.js +30 -0
- package/src/reanimated2/core.ts +1 -1
- package/src/reanimated2/js-reanimated/index.web.ts +8 -1
- package/src/reanimated2/platform-specific/RNRenderer.web.ts +2 -0
- package/android/.DS_Store +0 -0
- package/android/react-native-reanimated-62-hermes.aar +0 -0
- package/android/react-native-reanimated-62-jsc.aar +0 -0
|
@@ -1,43 +1,56 @@
|
|
|
1
|
+
#ifdef ONANDROID
|
|
2
|
+
#include <AndroidScheduler.h>
|
|
3
|
+
#endif
|
|
1
4
|
#include "JSIStoreValueUser.h"
|
|
2
5
|
|
|
3
6
|
namespace reanimated {
|
|
4
7
|
|
|
5
|
-
std::
|
|
6
|
-
std::recursive_mutex StoreUser::storeMutex;
|
|
7
|
-
std::unordered_map<int, std::vector<std::shared_ptr<jsi::Value>>> StoreUser::store;
|
|
8
|
+
std::shared_ptr<StaticStoreUser> StoreUser::staticStoreUserData = std::make_shared<StaticStoreUser>();
|
|
8
9
|
|
|
9
10
|
std::weak_ptr<jsi::Value> StoreUser::getWeakRef(jsi::Runtime &rt) {
|
|
10
|
-
const std::lock_guard<std::recursive_mutex> lock(storeMutex);
|
|
11
|
-
if (
|
|
12
|
-
|
|
11
|
+
const std::lock_guard<std::recursive_mutex> lock(storeUserData->storeMutex);
|
|
12
|
+
if (storeUserData->store.count(identifier) == 0) {
|
|
13
|
+
storeUserData->store[identifier] = std::vector<std::shared_ptr<jsi::Value>>();
|
|
13
14
|
}
|
|
14
15
|
std::shared_ptr<jsi::Value> sv = std::make_shared<jsi::Value>(rt, jsi::Value::undefined());
|
|
15
|
-
|
|
16
|
+
storeUserData->store[identifier].push_back(sv);
|
|
16
17
|
|
|
17
18
|
return sv;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
StoreUser::StoreUser(std::shared_ptr<Scheduler> s): scheduler(s) {
|
|
21
|
-
|
|
22
|
+
storeUserData = StoreUser::staticStoreUserData;
|
|
23
|
+
identifier = storeUserData->ctr++;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
StoreUser::~StoreUser() {
|
|
25
27
|
int id = identifier;
|
|
26
28
|
std::shared_ptr<Scheduler> strongScheduler = scheduler.lock();
|
|
27
29
|
if (strongScheduler != nullptr) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
std::shared_ptr<StaticStoreUser> sud = storeUserData;
|
|
31
|
+
#ifdef ONANDROID
|
|
32
|
+
jni::ThreadScope::WithClassLoader([&] {
|
|
33
|
+
strongScheduler->scheduleOnUI([id, sud]() {
|
|
34
|
+
const std::lock_guard<std::recursive_mutex> lock(sud->storeMutex);
|
|
35
|
+
if (sud->store.count(id) > 0) {
|
|
36
|
+
sud->store.erase(id);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
#else
|
|
41
|
+
strongScheduler->scheduleOnUI([id, sud]() {
|
|
42
|
+
const std::lock_guard<std::recursive_mutex> lock(sud->storeMutex);
|
|
43
|
+
if (sud->store.count(id) > 0) {
|
|
44
|
+
sud->store.erase(id);
|
|
32
45
|
}
|
|
33
46
|
});
|
|
47
|
+
#endif
|
|
34
48
|
}
|
|
35
49
|
}
|
|
36
50
|
|
|
37
|
-
|
|
38
51
|
void StoreUser::clearStore() {
|
|
39
|
-
const std::lock_guard<std::recursive_mutex> lock(storeMutex);
|
|
40
|
-
StoreUser::store.clear();
|
|
52
|
+
const std::lock_guard<std::recursive_mutex> lock(StoreUser::staticStoreUserData->storeMutex);
|
|
53
|
+
StoreUser::staticStoreUserData->store.clear();
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
}
|
|
@@ -13,11 +13,16 @@ using namespace facebook;
|
|
|
13
13
|
|
|
14
14
|
namespace reanimated {
|
|
15
15
|
|
|
16
|
+
struct StaticStoreUser {
|
|
17
|
+
std::atomic<int> ctr;
|
|
18
|
+
std::unordered_map<int, std::vector<std::shared_ptr<jsi::Value>>> store;
|
|
19
|
+
std::recursive_mutex storeMutex;
|
|
20
|
+
};
|
|
21
|
+
|
|
16
22
|
class StoreUser {
|
|
17
23
|
int identifier = 0;
|
|
18
|
-
static std::
|
|
19
|
-
|
|
20
|
-
static std::recursive_mutex storeMutex;
|
|
24
|
+
static std::shared_ptr<StaticStoreUser> staticStoreUserData;
|
|
25
|
+
std::shared_ptr<StaticStoreUser> storeUserData;
|
|
21
26
|
std::weak_ptr<Scheduler> scheduler;
|
|
22
27
|
|
|
23
28
|
public:
|
package/RNReanimated.podspec
CHANGED
|
@@ -5,9 +5,10 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
|
5
5
|
reactVersion = '0.0.0'
|
|
6
6
|
|
|
7
7
|
begin
|
|
8
|
-
reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "react-native", "package.json")))["version"]
|
|
8
|
+
reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json")))["version"]
|
|
9
9
|
rescue
|
|
10
|
-
|
|
10
|
+
# Example app
|
|
11
|
+
reactVersion = JSON.parse(File.read(File.join(__dir__, "node_modules", "react-native", "package.json")))["version"]
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
rnVersion = reactVersion.split('.')[1]
|
|
@@ -20,7 +21,7 @@ end
|
|
|
20
21
|
|
|
21
22
|
folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DRNVERSION=' + rnVersion
|
|
22
23
|
folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
|
|
23
|
-
folly_version = '
|
|
24
|
+
folly_version = '2021.04.26.00'
|
|
24
25
|
boost_compiler_flags = '-Wno-documentation'
|
|
25
26
|
|
|
26
27
|
Pod::Spec.new do |s|
|
|
@@ -49,12 +50,12 @@ Pod::Spec.new do |s|
|
|
|
49
50
|
|
|
50
51
|
s.pod_target_xcconfig = {
|
|
51
52
|
"USE_HEADERMAP" => "YES",
|
|
52
|
-
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
|
|
53
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
|
|
53
54
|
}
|
|
54
55
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
55
56
|
s.xcconfig = {
|
|
56
57
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++14",
|
|
57
|
-
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\"",
|
|
58
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\"",
|
|
58
59
|
"OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags }
|
|
59
60
|
|
|
60
61
|
s.requires_arc = true
|
|
@@ -95,4 +96,3 @@ Pod::Spec.new do |s|
|
|
|
95
96
|
s.dependency "#{folly_prefix}Folly"
|
|
96
97
|
|
|
97
98
|
end
|
|
98
|
-
|
package/android/build.gradle
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import groovy.json.JsonSlurper
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
import java.util.regex.Matcher
|
|
3
|
+
import java.util.regex.Pattern
|
|
2
4
|
configurations.maybeCreate("default")
|
|
3
5
|
|
|
4
6
|
def inputFile = new File(projectDir, '../../react-native/package.json')
|
|
@@ -7,8 +9,89 @@ def reactNativeVersion = json.version as String
|
|
|
7
9
|
def (major, minor, patch) = reactNativeVersion.tokenize('.')
|
|
8
10
|
|
|
9
11
|
def engine = "jsc"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
abstract class replaceSoTask extends DefaultTask {
|
|
14
|
+
public static String appName = ":app"
|
|
15
|
+
public static String buildDir = "../../../android/app/build"
|
|
16
|
+
|
|
17
|
+
@TaskAction
|
|
18
|
+
def run() {
|
|
19
|
+
for(def abiVersion in ["x86", "x86_64", "armeabi-v7a", "arm64-v8a"]) {
|
|
20
|
+
ant.sequential {
|
|
21
|
+
copy(
|
|
22
|
+
tofile: "${buildDir}/intermediates/merged_native_libs/debug/out/lib/${abiVersion}/libfbjni.so",
|
|
23
|
+
file: "../libSo/fbjni/jni/${abiVersion}/libfbjni.so",
|
|
24
|
+
overwrite: true
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def getCurrentFlavor() {
|
|
32
|
+
Gradle gradle = getGradle()
|
|
33
|
+
String taskRequestName = gradle.getStartParameter().getTaskRequests().toString()
|
|
34
|
+
Pattern pattern = Pattern.compile("(assemble|bundle|install|generate)(\\w*)(Release|Debug)")
|
|
35
|
+
Matcher matcher = pattern.matcher(taskRequestName)
|
|
36
|
+
|
|
37
|
+
if(matcher.find()) {
|
|
38
|
+
return matcher.group(2)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return "NOT-FOUND"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
def replaceSoTaskDebug
|
|
45
|
+
def replaceSoTaskRelease
|
|
46
|
+
if(Integer.parseInt(minor) < 65) {
|
|
47
|
+
tasks.register("replaceSoTaskDebug", replaceSoTask)
|
|
48
|
+
tasks.register("replaceSoTaskRelease", replaceSoTask)
|
|
49
|
+
replaceSoTaskDebug = project.getTasks().getByPath(":react-native-reanimated:replaceSoTaskDebug")
|
|
50
|
+
replaceSoTaskRelease = project.getTasks().getByPath(":react-native-reanimated:replaceSoTaskRelease")
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
rootProject.getSubprojects().forEach({project ->
|
|
54
|
+
if (project.plugins.hasPlugin("com.android.application")) {
|
|
55
|
+
if(project.ext.react.enableHermes) {
|
|
56
|
+
engine = "hermes"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if(project.getProperties().get("android") && Integer.parseInt(minor) < 65) {
|
|
60
|
+
def projectProperties = project.getProperties()
|
|
61
|
+
final NOTFOUND = "NOT-FOUND"
|
|
62
|
+
if(!NOTFOUND.equals(getCurrentFlavor()) && (!projectProperties.get("reanimated")
|
|
63
|
+
|| (projectProperties.get("reanimated") && projectProperties.get("reanimated").get("enablePackagingOptions")))
|
|
64
|
+
) {
|
|
65
|
+
def flavorString = getCurrentFlavor()
|
|
66
|
+
replaceSoTask.appName = project.getProperties().path
|
|
67
|
+
replaceSoTask.buildDir = project.getProperties().buildDir
|
|
68
|
+
def appName = project.getProperties().path
|
|
69
|
+
|
|
70
|
+
replaceSoTaskDebug.dependsOn(
|
|
71
|
+
project.getTasks().getByPath("${appName}:merge${flavorString}DebugNativeLibs"),
|
|
72
|
+
project.getTasks().getByPath("${appName}:strip${flavorString}DebugDebugSymbols")
|
|
73
|
+
)
|
|
74
|
+
project.getTasks().getByPath("${appName}:package${flavorString}Debug").dependsOn(replaceSoTaskDebug)
|
|
75
|
+
|
|
76
|
+
replaceSoTaskRelease.dependsOn(
|
|
77
|
+
project.getTasks().getByPath("${appName}:merge${flavorString}ReleaseNativeLibs"),
|
|
78
|
+
project.getTasks().getByPath("${appName}:strip${flavorString}ReleaseDebugSymbols")
|
|
79
|
+
)
|
|
80
|
+
project.getTasks().getByPath("${appName}:package${flavorString}Release").dependsOn(replaceSoTaskRelease)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
|
|
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
|
+
}
|
|
12
95
|
}
|
|
13
96
|
|
|
14
|
-
artifacts.add("default",
|
|
97
|
+
artifacts.add("default", aar)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
#import <React/RCTFollyConvert.h>
|
|
9
9
|
#import <React/RCTUIManager.h>
|
|
10
10
|
|
|
11
|
-
#if __has_include(<
|
|
11
|
+
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
|
12
|
+
#import <reacthermes/HermesExecutorFactory.h>
|
|
13
|
+
#elif __has_include(<hermes/hermes.h>)
|
|
12
14
|
#import <hermes/hermes.h>
|
|
13
15
|
#else
|
|
14
16
|
#import <jsi/JSCRuntime.h>
|
|
@@ -111,7 +113,9 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(std::shared_ptr<C
|
|
|
111
113
|
};
|
|
112
114
|
|
|
113
115
|
|
|
114
|
-
#if __has_include(<
|
|
116
|
+
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
|
117
|
+
std::unique_ptr<jsi::Runtime> animatedRuntime = facebook::hermes::makeHermesRuntime();
|
|
118
|
+
#elif __has_include(<hermes/hermes.h>)
|
|
115
119
|
std::unique_ptr<jsi::Runtime> animatedRuntime = facebook::hermes::makeHermesRuntime();
|
|
116
120
|
#else
|
|
117
121
|
std::unique_ptr<jsi::Runtime> animatedRuntime = facebook::jsc::makeJSCRuntime();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <React/RCTCxxBridgeDelegate.h>
|
|
3
|
+
#import <RNReanimated/NativeProxy.h>
|
|
4
|
+
#import <RNReanimated/REAModule.h>
|
|
5
|
+
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
6
|
+
#import <React/RCTBridge+Private.h>
|
|
7
|
+
#import <React/RCTCxxBridgeDelegate.h>
|
|
8
|
+
#import <RNReanimated/REAEventDispatcher.h>
|
|
9
|
+
#import <jsireact/JSIExecutor.h>
|
|
10
|
+
|
|
11
|
+
#if RNVERSION >= 64
|
|
12
|
+
#import <React/RCTJSIExecutorRuntimeInstaller.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
#if RNVERSION < 63
|
|
16
|
+
#import <ReactCommon/BridgeJSCallInvoker.h>
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
20
|
+
|
|
21
|
+
namespace reanimated {
|
|
22
|
+
|
|
23
|
+
using namespace facebook;
|
|
24
|
+
using namespace react;
|
|
25
|
+
|
|
26
|
+
JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
|
|
27
|
+
RCTBridge* bridge,
|
|
28
|
+
JSIExecutor::RuntimeInstaller runtimeInstallerToWrap
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#import "REAInitializer.h"
|
|
2
|
+
|
|
3
|
+
@interface RCTEventDispatcher(Reanimated)
|
|
4
|
+
|
|
5
|
+
- (void)setBridge:(RCTBridge*)bridge;
|
|
6
|
+
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
namespace reanimated {
|
|
10
|
+
|
|
11
|
+
using namespace facebook;
|
|
12
|
+
using namespace react;
|
|
13
|
+
|
|
14
|
+
JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
|
|
15
|
+
RCTBridge* bridge,
|
|
16
|
+
JSIExecutor::RuntimeInstaller runtimeInstallerToWrap)
|
|
17
|
+
{
|
|
18
|
+
[bridge moduleForClass:[RCTEventDispatcher class]];
|
|
19
|
+
RCTEventDispatcher *eventDispatcher = [REAEventDispatcher new];
|
|
20
|
+
#if RNVERSION >= 66
|
|
21
|
+
RCTCallableJSModules *callableJSModules = [RCTCallableJSModules new];
|
|
22
|
+
[bridge setValue:callableJSModules forKey:@"_callableJSModules"];
|
|
23
|
+
[callableJSModules setBridge:bridge];
|
|
24
|
+
[eventDispatcher setValue:callableJSModules forKey:@"_callableJSModules"];
|
|
25
|
+
[eventDispatcher setValue:bridge forKey:@"_bridge"];
|
|
26
|
+
[eventDispatcher initialize];
|
|
27
|
+
#else
|
|
28
|
+
[eventDispatcher setBridge:bridge];
|
|
29
|
+
#endif
|
|
30
|
+
[bridge updateModuleWithInstance:eventDispatcher];
|
|
31
|
+
_bridge_reanimated = bridge;
|
|
32
|
+
const auto runtimeInstaller = [bridge, runtimeInstallerToWrap](facebook::jsi::Runtime &runtime) {
|
|
33
|
+
if (!bridge) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
#if RNVERSION >= 63
|
|
37
|
+
auto reanimatedModule = reanimated::createReanimatedModule(bridge.jsCallInvoker);
|
|
38
|
+
#else
|
|
39
|
+
auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
|
|
40
|
+
auto reanimatedModule = reanimated::createReanimatedModule(callInvoker);
|
|
41
|
+
#endif
|
|
42
|
+
runtime.global().setProperty(runtime,
|
|
43
|
+
jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
|
|
44
|
+
jsi::Object::createFromHostObject(runtime, reanimatedModule));
|
|
45
|
+
|
|
46
|
+
if (runtimeInstallerToWrap) {
|
|
47
|
+
runtimeInstallerToWrap(runtime);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return runtimeInstaller;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
#import "UIResponder+Reanimated.h"
|
|
2
|
-
#import
|
|
3
|
-
#import <RNReanimated/NativeProxy.h>
|
|
4
|
-
#import <RNReanimated/REAModule.h>
|
|
5
|
-
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
6
|
-
#import <React/RCTBridge+Private.h>
|
|
7
|
-
#import <React/RCTCxxBridgeDelegate.h>
|
|
8
|
-
#import <RNReanimated/REAEventDispatcher.h>
|
|
2
|
+
#import "REAInitializer.h"
|
|
9
3
|
|
|
10
|
-
#if
|
|
11
|
-
#import <
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#if RNVERSION < 63
|
|
15
|
-
#import <ReactCommon/BridgeJSCallInvoker.h>
|
|
16
|
-
#endif
|
|
17
|
-
|
|
18
|
-
#if __has_include(<React/HermesExecutorFactory.h>)
|
|
4
|
+
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
|
5
|
+
#import <reacthermes/HermesExecutorFactory.h>
|
|
6
|
+
typedef HermesExecutorFactory ExecutorFactory;
|
|
7
|
+
#elif __has_include(<React/HermesExecutorFactory.h>)
|
|
19
8
|
#import <React/HermesExecutorFactory.h>
|
|
20
9
|
typedef HermesExecutorFactory ExecutorFactory;
|
|
21
10
|
#else
|
|
@@ -25,45 +14,16 @@ typedef JSCExecutorFactory ExecutorFactory;
|
|
|
25
14
|
|
|
26
15
|
#ifndef DONT_AUTOINSTALL_REANIMATED
|
|
27
16
|
|
|
28
|
-
@interface RCTEventDispatcher(Reanimated)
|
|
29
|
-
|
|
30
|
-
- (void)setBridge:(RCTBridge*)bridge;
|
|
31
|
-
|
|
32
|
-
@end
|
|
33
|
-
|
|
34
17
|
@implementation UIResponder (Reanimated)
|
|
35
18
|
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
|
36
19
|
{
|
|
37
|
-
|
|
38
|
-
RCTEventDispatcher *eventDispatcher = [REAEventDispatcher new];
|
|
39
|
-
[eventDispatcher setBridge:bridge];
|
|
40
|
-
[bridge updateModuleWithInstance:eventDispatcher];
|
|
41
|
-
_bridge_reanimated = bridge;
|
|
42
|
-
__weak __typeof(self) weakSelf = self;
|
|
43
|
-
|
|
44
|
-
const auto executor = [weakSelf, bridge](facebook::jsi::Runtime &runtime) {
|
|
45
|
-
if (!bridge) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
__typeof(self) strongSelf = weakSelf;
|
|
49
|
-
if (strongSelf) {
|
|
50
|
-
#if RNVERSION >= 63
|
|
51
|
-
auto reanimatedModule = reanimated::createReanimatedModule(bridge.jsCallInvoker);
|
|
52
|
-
#else
|
|
53
|
-
auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
|
|
54
|
-
auto reanimatedModule = reanimated::createReanimatedModule(callInvoker);
|
|
55
|
-
#endif
|
|
56
|
-
runtime.global().setProperty(runtime,
|
|
57
|
-
jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
|
|
58
|
-
jsi::Object::createFromHostObject(runtime, reanimatedModule));
|
|
59
|
-
}
|
|
60
|
-
};
|
|
20
|
+
const auto installer = reanimated::REAJSIExecutorRuntimeInstaller(bridge, NULL);
|
|
61
21
|
|
|
62
22
|
#if RNVERSION >= 64
|
|
63
23
|
// installs globals such as console, nativePerformanceNow, etc.
|
|
64
|
-
return std::make_unique<ExecutorFactory>(RCTJSIExecutorRuntimeInstaller(
|
|
24
|
+
return std::make_unique<ExecutorFactory>(RCTJSIExecutorRuntimeInstaller(installer));
|
|
65
25
|
#else
|
|
66
|
-
return std::make_unique<ExecutorFactory>(
|
|
26
|
+
return std::make_unique<ExecutorFactory>(installer);
|
|
67
27
|
#endif
|
|
68
28
|
}
|
|
69
29
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Animated from '../../Animated';
|
|
3
|
+
|
|
4
|
+
import renderer from 'react-test-renderer';
|
|
5
|
+
|
|
6
|
+
jest.mock('../../ReanimatedEventEmitter');
|
|
7
|
+
jest.mock('../../ReanimatedModule');
|
|
8
|
+
jest.mock('../../reanimated2/NativeReanimated');
|
|
9
|
+
|
|
10
|
+
describe('Core Animated components', () => {
|
|
11
|
+
xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
|
|
12
|
+
console.error = jest.fn();
|
|
13
|
+
|
|
14
|
+
expect(() =>
|
|
15
|
+
renderer.create(<Animated.Code exec="not a node" />)
|
|
16
|
+
).toThrowError(
|
|
17
|
+
"<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node."
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
xit('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {
|
|
22
|
+
console.error = jest.fn();
|
|
23
|
+
|
|
24
|
+
expect(() =>
|
|
25
|
+
renderer.create(<Animated.Code>not a node</Animated.Code>)
|
|
26
|
+
).toThrowError(
|
|
27
|
+
"<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node."
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
});
|
package/lib/reanimated2/core.js
CHANGED
|
@@ -30,7 +30,7 @@ export const isConfigured = (throwError = false) => {
|
|
|
30
30
|
};
|
|
31
31
|
export const isConfiguredCheck = () => {
|
|
32
32
|
if (!isConfigured(true)) {
|
|
33
|
-
throw new Error('If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation');
|
|
33
|
+
throw new Error('If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation');
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
function _toArrayReanimated(object) {
|
|
@@ -11,9 +11,15 @@ export const _updatePropsJS = (_viewTag, _viewName, updates, viewRef) => {
|
|
|
11
11
|
acc[index][key] = value;
|
|
12
12
|
return acc;
|
|
13
13
|
}, [{}, {}]);
|
|
14
|
-
viewRef.
|
|
14
|
+
setNativeProps(viewRef._component, rawStyles);
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
+
const setNativeProps = (component, style) => {
|
|
18
|
+
const previousStyle = component.previousStyle ? component.previousStyle : {};
|
|
19
|
+
const currentStyle = Object.assign(Object.assign({}, previousStyle), style);
|
|
20
|
+
component.previousStyle = currentStyle;
|
|
21
|
+
component.setNativeProps({ style: currentStyle });
|
|
22
|
+
};
|
|
17
23
|
global._setGlobalConsole = (_val) => {
|
|
18
24
|
// noop
|
|
19
25
|
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-reanimated",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "More powerful alternative to Animated library for React Native.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "node node_modules/react-native/local-cli/cli.js start",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"Common/",
|
|
25
25
|
"src/",
|
|
26
26
|
"lib/",
|
|
27
|
+
"libSo/",
|
|
27
28
|
"android/src/main/AndroidManifest.xml",
|
|
28
29
|
"android/src/main/java/",
|
|
29
30
|
"android/build.gradle",
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
"@types/babel__generator": "^7.6.2",
|
|
81
82
|
"@types/babel__traverse": "^7.0.15",
|
|
82
83
|
"@types/jest": "^26.0.15",
|
|
83
|
-
"@types/react-native": "^0.
|
|
84
|
+
"@types/react-native": "^0.66.1",
|
|
84
85
|
"@typescript-eslint/eslint-plugin": "^4.15.1",
|
|
85
86
|
"@typescript-eslint/parser": "^4.15.1",
|
|
86
87
|
"babel-eslint": "^10.0.3",
|
|
@@ -99,7 +100,7 @@
|
|
|
99
100
|
"lint-staged": "^10.2.11",
|
|
100
101
|
"prettier": "^2.2.1",
|
|
101
102
|
"react": "17.0.1",
|
|
102
|
-
"react-native": "0.
|
|
103
|
+
"react-native": "0.67.0-rc.2",
|
|
103
104
|
"react-native-gesture-handler": "^1.6.1",
|
|
104
105
|
"react-test-renderer": "17.0.1",
|
|
105
106
|
"release-it": "^13.1.1",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Animated from '../../Animated';
|
|
3
|
+
|
|
4
|
+
import renderer from 'react-test-renderer';
|
|
5
|
+
|
|
6
|
+
jest.mock('../../ReanimatedEventEmitter');
|
|
7
|
+
jest.mock('../../ReanimatedModule');
|
|
8
|
+
jest.mock('../../reanimated2/NativeReanimated');
|
|
9
|
+
|
|
10
|
+
describe('Core Animated components', () => {
|
|
11
|
+
xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
|
|
12
|
+
console.error = jest.fn();
|
|
13
|
+
|
|
14
|
+
expect(() =>
|
|
15
|
+
renderer.create(<Animated.Code exec="not a node" />)
|
|
16
|
+
).toThrowError(
|
|
17
|
+
"<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node."
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
xit('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {
|
|
22
|
+
console.error = jest.fn();
|
|
23
|
+
|
|
24
|
+
expect(() =>
|
|
25
|
+
renderer.create(<Animated.Code>not a node</Animated.Code>)
|
|
26
|
+
).toThrowError(
|
|
27
|
+
"<Animated.Code /> expects the 'exec' prop or children to be an animated node or a function returning an animated node."
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
});
|
package/src/reanimated2/core.ts
CHANGED
|
@@ -39,7 +39,7 @@ export const isConfigured = (throwError = false) => {
|
|
|
39
39
|
export const isConfiguredCheck = () => {
|
|
40
40
|
if (!isConfigured(true)) {
|
|
41
41
|
throw new Error(
|
|
42
|
-
'If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation'
|
|
42
|
+
'If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation'
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
@@ -18,10 +18,17 @@ export const _updatePropsJS = (_viewTag, _viewName, updates, viewRef) => {
|
|
|
18
18
|
[{}, {}]
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
viewRef.
|
|
21
|
+
setNativeProps(viewRef._component, rawStyles);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
const setNativeProps = (component, style) => {
|
|
26
|
+
const previousStyle = component.previousStyle ? component.previousStyle : {};
|
|
27
|
+
const currentStyle = { ...previousStyle, ...style };
|
|
28
|
+
component.previousStyle = currentStyle;
|
|
29
|
+
component.setNativeProps({ style: currentStyle });
|
|
30
|
+
};
|
|
31
|
+
|
|
25
32
|
global._setGlobalConsole = (_val) => {
|
|
26
33
|
// noop
|
|
27
34
|
};
|
package/android/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|