react-native-reanimated 2.11.0 → 2.12.0
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/RNReanimated.podspec +7 -4
- package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
- package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build.gradle +63 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +1 -1
- package/android/{rnVersionPatch/62 → src/reactNativeVersionPatch/UIImplementation/64/com/swmansion/reanimated}/layoutReanimation/ReanimatedUIImplementation.java +0 -0
- package/android/src/{main/java → reactNativeVersionPatch/UIImplementation/latest}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +0 -0
- package/android/src/reactNativeVersionPatch/messageQueueThread/67/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +12 -0
- package/android/src/reactNativeVersionPatch/messageQueueThread/latest/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +12 -0
- package/android/{rnVersionPatch/62 → src/reactNativeVersionPatch/nativeHierarchyManager/62/com/swmansion/reanimated}/layoutReanimation/ReanimatedNativeHierarchyManager.java +0 -0
- package/android/src/{main/java → reactNativeVersionPatch/nativeHierarchyManager/latest}/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +0 -0
- package/ios/REAModule.mm +19 -2
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +1 -1
- package/lib/createAnimatedComponent.js +3 -4
- package/lib/reanimated2/NativeMethods.js +78 -43
- package/lib/reanimated2/globals.d.ts +39 -13
- package/lib/reanimated2/hook/useScrollViewOffset.js +2 -1
- package/lib/types/reanimated2/NativeMethods.d.ts +2 -2
- package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryUI.d.ts +14 -0
- package/package.json +5 -4
- package/scripts/reanimated_utils.rb +14 -2
- package/src/createAnimatedComponent.tsx +2 -3
- package/src/reanimated2/NativeMethods.ts +98 -54
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +1 -1
- package/src/reanimated2/globals.d.ts +39 -13
- package/src/reanimated2/hook/useScrollViewOffset.ts +4 -3
- package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +0 -68
- package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +0 -68
- package/android/rnVersionPatch/65/.gitkeep +0 -0
- package/android/rnVersionPatch/66/.gitkeep +0 -0
- package/android/rnVersionPatch/67/.gitkeep +0 -0
- package/android/rnVersionPatch/68/.gitkeep +0 -0
- package/android/rnVersionPatch/69/.gitkeep +0 -0
- package/android/rnVersionPatch/70/.gitkeep +0 -0
- package/android/rnVersionPatch/backup/.gitkeep +0 -0
package/RNReanimated.podspec
CHANGED
|
@@ -4,6 +4,7 @@ require_relative './scripts/reanimated_utils'
|
|
|
4
4
|
reanimated_package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
5
5
|
config = find_config()
|
|
6
6
|
assert_no_multiple_instances(config)
|
|
7
|
+
assert_no_reanimated2_with_new_architecture(reanimated_package_json)
|
|
7
8
|
|
|
8
9
|
folly_prefix = config[:react_native_minor_version] >= 64 ? 'RCT-' : ''
|
|
9
10
|
folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=' + config[:react_native_minor_version].to_s
|
|
@@ -34,14 +35,16 @@ Pod::Spec.new do |s|
|
|
|
34
35
|
"Common/cpp/hidden_headers/**"
|
|
35
36
|
]
|
|
36
37
|
|
|
37
|
-
s.pod_target_xcconfig
|
|
38
|
+
s.pod_target_xcconfig = {
|
|
38
39
|
"USE_HEADERMAP" => "YES",
|
|
39
|
-
"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\" "
|
|
40
|
+
"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\" ",
|
|
41
|
+
"FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
|
|
40
42
|
}
|
|
41
43
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
42
44
|
s.xcconfig = {
|
|
43
|
-
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"
|
|
44
|
-
|
|
45
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"$(PODS_ROOT)/#{config[:react_native_common_dir]}\"",
|
|
46
|
+
"OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags
|
|
47
|
+
}
|
|
45
48
|
|
|
46
49
|
s.requires_arc = true
|
|
47
50
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#Thu Oct
|
|
1
|
+
#Thu Oct 27 10:05:12 UTC 2022
|
|
2
2
|
gradle.version=7.5.1
|
|
Binary file
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import com.android.Version
|
|
2
2
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
3
|
-
|
|
3
|
+
import groovy.json.JsonSlurper
|
|
4
4
|
import java.nio.file.Paths
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -43,12 +43,10 @@ def safeExtGet(prop, fallback) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
def safeAppExtGet(prop, fallback) {
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
appProject = project(":app")
|
|
49
|
-
} catch(Exception e) {
|
|
46
|
+
if (findProject(':app') == null) {
|
|
50
47
|
return fallback
|
|
51
48
|
}
|
|
49
|
+
def appProject = project(':app')
|
|
52
50
|
appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
|
|
53
51
|
}
|
|
54
52
|
|
|
@@ -150,7 +148,7 @@ def findReanimatedInstancesForPath(String path) {
|
|
|
150
148
|
}.files
|
|
151
149
|
}
|
|
152
150
|
|
|
153
|
-
def
|
|
151
|
+
def checkNoMultipleInstances() {
|
|
154
152
|
// Assert there are no multiple installations of Reanimated
|
|
155
153
|
Set<File> files
|
|
156
154
|
if (projectDir.path.contains(rootDir.parent)) {
|
|
@@ -167,9 +165,9 @@ def assertNoMultipleInstances() {
|
|
|
167
165
|
String parsedLocation = files.stream().map({
|
|
168
166
|
File file -> "- " + file.toString().replace("/package.json", "")
|
|
169
167
|
}).collect().join("\n")
|
|
170
|
-
String exceptionMessage = "\
|
|
171
|
-
"instance of react-native-reanimated can be installed in a
|
|
172
|
-
"resolve the conflict manually. Check out the documentation: " +
|
|
168
|
+
String exceptionMessage = "\n[react-native-reanimated] Multiple versions of Reanimated " +
|
|
169
|
+
"were detected. Only one instance of react-native-reanimated can be installed in a " +
|
|
170
|
+
"project. You need to resolve the conflict manually. Check out the documentation: " +
|
|
173
171
|
"https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/" +
|
|
174
172
|
"troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict " +
|
|
175
173
|
"between: \n" + parsedLocation + "\n";
|
|
@@ -177,6 +175,14 @@ def assertNoMultipleInstances() {
|
|
|
177
175
|
}
|
|
178
176
|
}
|
|
179
177
|
|
|
178
|
+
def getReanimatedVersion() {
|
|
179
|
+
def inputFile = file(projectDir.path + '/../package.json')
|
|
180
|
+
def json = new JsonSlurper().parseText(inputFile.text)
|
|
181
|
+
String reanimatedVersion = json.version
|
|
182
|
+
def (major, minor, patch) = reanimatedVersion.tokenize('.')
|
|
183
|
+
return major.toInteger()
|
|
184
|
+
}
|
|
185
|
+
|
|
180
186
|
boolean CLIENT_SIDE_BUILD = resolveClientSideBuild()
|
|
181
187
|
if (CLIENT_SIDE_BUILD) {
|
|
182
188
|
configurations.maybeCreate("default")
|
|
@@ -195,6 +201,7 @@ def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
|
|
|
195
201
|
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
|
|
196
202
|
def FBJNI_VERSION = "0.3.0"
|
|
197
203
|
def REANIMATED_PACKAGE_BUILD = System.getenv("REANIMATED_PACKAGE_BUILD")
|
|
204
|
+
def REANIMATED_MAJOR_VERSION = getReanimatedVersion()
|
|
198
205
|
|
|
199
206
|
// We download various C++ open-source dependencies into downloads.
|
|
200
207
|
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
|
|
@@ -525,27 +532,57 @@ android {
|
|
|
525
532
|
sourceSets.main {
|
|
526
533
|
java {
|
|
527
534
|
if (isNewArchitectureEnabled()) {
|
|
528
|
-
srcDirs +=
|
|
529
|
-
|
|
530
|
-
|
|
535
|
+
srcDirs += "src/fabric/java"
|
|
536
|
+
} else {
|
|
537
|
+
srcDirs += "src/paper/java"
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// messageQueueThread
|
|
541
|
+
if (REANIMATED_MAJOR_VERSION > 2) {
|
|
542
|
+
if (REACT_NATIVE_MINOR_VERSION <= 67) {
|
|
543
|
+
srcDirs += "src/reactNativeVersionPatch/messageQueueThread/67"
|
|
544
|
+
} else {
|
|
545
|
+
srcDirs += "src/reactNativeVersionPatch/messageQueueThread/latest"
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// UIImplementation
|
|
550
|
+
if (REACT_NATIVE_MINOR_VERSION <= 64) {
|
|
551
|
+
srcDirs += "src/reactNativeVersionPatch/UIImplementation/64"
|
|
552
|
+
} else {
|
|
553
|
+
srcDirs += "src/reactNativeVersionPatch/UIImplementation/latest"
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// nativeHierarchyManager
|
|
557
|
+
if (REACT_NATIVE_MINOR_VERSION <= 62) {
|
|
558
|
+
srcDirs += "src/reactNativeVersionPatch/nativeHierarchyManager/62"
|
|
531
559
|
} else {
|
|
532
|
-
srcDirs +=
|
|
533
|
-
"src/paper/java",
|
|
534
|
-
]
|
|
560
|
+
srcDirs += "src/reactNativeVersionPatch/nativeHierarchyManager/latest"
|
|
535
561
|
}
|
|
536
562
|
}
|
|
537
563
|
}
|
|
538
564
|
}
|
|
539
565
|
|
|
540
|
-
def
|
|
566
|
+
def assertNoMultipleInstances = task assertNoMultipleInstancesTask {
|
|
541
567
|
onlyIf { shouldAssertNoMultipleInstances() && CLIENT_SIDE_BUILD }
|
|
542
568
|
doFirst {
|
|
543
|
-
|
|
569
|
+
checkNoMultipleInstances()
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
def assertNoReanimated2WithNewArchitecture = task assertNoReanimated2WithNewArchitectureTask {
|
|
574
|
+
onlyIf { isNewArchitectureEnabled() && REANIMATED_MAJOR_VERSION == 2 }
|
|
575
|
+
doFirst {
|
|
576
|
+
throw new Exception(
|
|
577
|
+
"\n[react-native-reanimated] Reanimated 2.x does not support Fabric. " +
|
|
578
|
+
"Please upgrade to 3.x to use Reanimated with the New Architecture. " +
|
|
579
|
+
"For details, see https://blog.swmansion.com/announcing-reanimated-3-16167428c5f7"
|
|
580
|
+
)
|
|
544
581
|
}
|
|
545
582
|
}
|
|
546
583
|
|
|
547
584
|
tasks.preBuild {
|
|
548
|
-
dependsOn
|
|
585
|
+
dependsOn assertNoMultipleInstances, assertNoReanimated2WithNewArchitecture
|
|
549
586
|
}
|
|
550
587
|
|
|
551
588
|
task cleanCmakeCache() {
|
|
@@ -560,21 +597,7 @@ task printVersions {
|
|
|
560
597
|
println "Gradle: ${project.gradle.gradleVersion}"
|
|
561
598
|
}
|
|
562
599
|
|
|
563
|
-
task
|
|
564
|
-
println("building Reanimated2")
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
task applyJavaPatches(type: Copy) {
|
|
568
|
-
def patchDirectory = file("${projectDir}/rnVersionPatch/${REACT_NATIVE_MINOR_VERSION}")
|
|
569
|
-
if (patchDirectory.exists()) {
|
|
570
|
-
from ("${patchDirectory}") {
|
|
571
|
-
include "**/*.java"
|
|
572
|
-
}
|
|
573
|
-
into ("${projectDir}/src/main/java/com/swmansion/reanimated")
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
task createNativeDepsDirectories(dependsOn: applyJavaPatches) {
|
|
600
|
+
task createNativeDepsDirectories() {
|
|
578
601
|
downloadsDir.mkdirs()
|
|
579
602
|
thirdPartyNdkDir.mkdirs()
|
|
580
603
|
}
|
|
@@ -967,8 +990,13 @@ task prepareThirdPartyNdkHeaders(dependsOn:[
|
|
|
967
990
|
) {}
|
|
968
991
|
|
|
969
992
|
def nativeBuildDependsOn(dependsOnTask) {
|
|
970
|
-
def buildTasks = tasks.findAll({ task ->
|
|
971
|
-
!task.name.contains("Clean")
|
|
993
|
+
def buildTasks = tasks.findAll({ task -> (
|
|
994
|
+
!task.name.contains("Clean")
|
|
995
|
+
&& (task.name.contains("externalNative")
|
|
996
|
+
|| task.name.contains("CMake")
|
|
997
|
+
|| task.name.contains("generateJsonModel")
|
|
998
|
+
)
|
|
999
|
+
) })
|
|
972
1000
|
buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
|
|
973
1001
|
}
|
|
974
1002
|
|
package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java
CHANGED
|
@@ -20,7 +20,7 @@ class ReaUiImplementationProvider extends UIImplementationProvider {
|
|
|
20
20
|
ViewManagerRegistry viewManagerRegistry,
|
|
21
21
|
EventDispatcher eventDispatcher,
|
|
22
22
|
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
23
|
-
return new ReanimatedUIImplementation(
|
|
23
|
+
return new com.facebook.react.uimanager.ReanimatedUIImplementation(
|
|
24
24
|
reactContext,
|
|
25
25
|
viewManagerRegistry,
|
|
26
26
|
eventDispatcher,
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.swmansion.reanimated;
|
|
2
|
+
|
|
3
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
4
|
+
import com.swmansion.reanimated.ReanimatedMessageQueueThreadBase;
|
|
5
|
+
|
|
6
|
+
@DoNotStrip
|
|
7
|
+
public class ReanimatedMessageQueueThread extends ReanimatedMessageQueueThreadBase {
|
|
8
|
+
@Override
|
|
9
|
+
public void runOnQueue(Runnable runnable) {
|
|
10
|
+
messageQueueThread.runOnQueue(runnable);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.swmansion.reanimated;
|
|
2
|
+
|
|
3
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
4
|
+
import com.swmansion.reanimated.ReanimatedMessageQueueThreadBase;
|
|
5
|
+
|
|
6
|
+
@DoNotStrip
|
|
7
|
+
public class ReanimatedMessageQueueThread extends ReanimatedMessageQueueThreadBase {
|
|
8
|
+
@Override
|
|
9
|
+
public boolean runOnQueue(Runnable runnable) {
|
|
10
|
+
return messageQueueThread.runOnQueue(runnable);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
File without changes
|
|
File without changes
|
package/ios/REAModule.mm
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
#import <RNReanimated/REAModule.h>
|
|
3
3
|
#import <RNReanimated/REANodesManager.h>
|
|
4
4
|
#import <RNReanimated/REATransitionManager.h>
|
|
5
|
-
|
|
6
|
-
#import "SingleInstanceChecker.h"
|
|
5
|
+
#import <RNReanimated/SingleInstanceChecker.h>
|
|
7
6
|
|
|
8
7
|
using namespace reanimated;
|
|
9
8
|
|
|
@@ -15,14 +14,17 @@ typedef void (^AnimatedOperation)(REANodesManager *nodesManager);
|
|
|
15
14
|
#ifdef DEBUG
|
|
16
15
|
SingleInstanceChecker<REAModule> singleInstanceChecker_;
|
|
17
16
|
#endif
|
|
17
|
+
bool hasListeners;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
RCT_EXPORT_MODULE(ReanimatedModule);
|
|
21
21
|
|
|
22
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
22
23
|
+ (BOOL)requiresMainQueueSetup
|
|
23
24
|
{
|
|
24
25
|
return YES;
|
|
25
26
|
}
|
|
27
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
26
28
|
|
|
27
29
|
- (void)invalidate
|
|
28
30
|
{
|
|
@@ -193,4 +195,19 @@ RCT_EXPORT_METHOD(triggerRender)
|
|
|
193
195
|
[_nodesManager dispatchEvent:event];
|
|
194
196
|
}
|
|
195
197
|
|
|
198
|
+
- (void)startObserving {
|
|
199
|
+
hasListeners = YES;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
- (void)stopObserving {
|
|
203
|
+
hasListeners = NO;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
- (void)sendEventWithName:(NSString *)eventName body:(id)body
|
|
207
|
+
{
|
|
208
|
+
if (hasListeners) {
|
|
209
|
+
[super sendEventWithName:eventName body:body];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
196
213
|
@end
|
|
@@ -119,11 +119,10 @@ export default function createAnimatedComponent(Component, options) {
|
|
|
119
119
|
setLocalRef: (ref) => {
|
|
120
120
|
// TODO update config
|
|
121
121
|
const tag = findNodeHandle(ref);
|
|
122
|
-
if ((
|
|
122
|
+
if (!shouldBeUseWeb() &&
|
|
123
|
+
(this.props.layout || this.props.entering || this.props.exiting) &&
|
|
123
124
|
tag != null) {
|
|
124
|
-
|
|
125
|
-
enableLayoutAnimations(true, false);
|
|
126
|
-
}
|
|
125
|
+
enableLayoutAnimations(true, false);
|
|
127
126
|
let layout = this.props.layout ? this.props.layout : DefaultLayout;
|
|
128
127
|
let entering = this.props.entering
|
|
129
128
|
? this.props.entering
|
|
@@ -1,53 +1,88 @@
|
|
|
1
1
|
import { findNodeHandle } from 'react-native';
|
|
2
|
-
import { shouldBeUseWeb } from './PlatformChecker';
|
|
2
|
+
import { isChromeDebugger, isWeb, shouldBeUseWeb } from './PlatformChecker';
|
|
3
3
|
export function getTag(view) {
|
|
4
4
|
return findNodeHandle(view);
|
|
5
5
|
}
|
|
6
6
|
const isNative = !shouldBeUseWeb();
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
console.warn(
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
const measured = _measure(viewTag);
|
|
28
|
-
if (measured === null) {
|
|
29
|
-
console.warn(`[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \`LayoutMetrics\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`);
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
else if (measured.x === -1234567) {
|
|
33
|
-
console.warn(`[Reanimated] The view with tag ${viewTag} returned an invalid measurement response`);
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
else if (isNaN(measured.x)) {
|
|
37
|
-
console.warn(`[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \`collapsable={false}\` on this component.`);
|
|
7
|
+
export let measure;
|
|
8
|
+
if (isWeb()) {
|
|
9
|
+
measure = (animatedRef) => {
|
|
10
|
+
const element = animatedRef(); // TODO: fix typing of animated refs on web
|
|
11
|
+
const viewportOffset = element.getBoundingClientRect();
|
|
12
|
+
return {
|
|
13
|
+
width: element.offsetWidth,
|
|
14
|
+
height: element.offsetHeight,
|
|
15
|
+
x: element.offsetLeft,
|
|
16
|
+
y: element.offsetTop,
|
|
17
|
+
pageX: viewportOffset.left,
|
|
18
|
+
pageY: viewportOffset.top,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
else if (isChromeDebugger()) {
|
|
23
|
+
measure = (_animatedRef) => {
|
|
24
|
+
console.warn('[Reanimated] measure() cannot be used with Chrome Debugger.');
|
|
38
25
|
return null;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
return measured;
|
|
42
|
-
}
|
|
26
|
+
};
|
|
43
27
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
else {
|
|
29
|
+
measure = (animatedRef) => {
|
|
30
|
+
'worklet';
|
|
31
|
+
if (!_WORKLET) {
|
|
32
|
+
console.warn('[Reanimated] measure() was called from the main JS context. Measure is ' +
|
|
33
|
+
'only available in the UI runtime. This may also happen if measure() ' +
|
|
34
|
+
'was called by a worklet in the useAnimatedStyle hook, because useAnimatedStyle ' +
|
|
35
|
+
'calls the given worklet on the JS runtime during render. If you want to ' +
|
|
36
|
+
'prevent this warning then wrap the call with `if (_WORKLET)`. Then it will ' +
|
|
37
|
+
'only be called on the UI runtime after the render has been completed.');
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const viewTag = animatedRef();
|
|
41
|
+
if (viewTag === -1) {
|
|
42
|
+
console.warn(`[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const measured = _measure(viewTag);
|
|
46
|
+
if (measured === null) {
|
|
47
|
+
console.warn(`[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \`LayoutMetrics\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
else if (measured.x === -1234567) {
|
|
51
|
+
console.warn(`[Reanimated] The view with tag ${viewTag} returned an invalid measurement response.`);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
else if (isNaN(measured.x)) {
|
|
55
|
+
console.warn(`[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \`collapsable={false}\` on this component.`);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return measured;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export let scrollTo;
|
|
64
|
+
if (isWeb()) {
|
|
65
|
+
scrollTo = (animatedRef, x, y, animated) => {
|
|
66
|
+
'worklet';
|
|
67
|
+
const element = animatedRef();
|
|
68
|
+
// @ts-ignore same call as in react-native-web
|
|
69
|
+
element.scrollTo({ x, y, animated });
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
else if (isNative) {
|
|
73
|
+
scrollTo = (animatedRef, x, y, animated) => {
|
|
74
|
+
'worklet';
|
|
75
|
+
if (!_WORKLET) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const viewTag = animatedRef();
|
|
79
|
+
_scrollTo(viewTag, x, y, animated);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
scrollTo = (_animatedRef, _x, _y) => {
|
|
84
|
+
// no-op
|
|
85
|
+
};
|
|
51
86
|
}
|
|
52
87
|
export function setGestureState(handlerTag, newState) {
|
|
53
88
|
'worklet';
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AnimatedStyle,
|
|
3
|
+
StyleProps,
|
|
4
|
+
MeasuredDimensions,
|
|
5
|
+
} from './commonTypes';
|
|
6
|
+
import type { ReanimatedConsole } from './core';
|
|
7
|
+
import type { NativeReanimated } from './NativeReanimated/NativeReanimated';
|
|
8
|
+
import type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';
|
|
9
|
+
|
|
6
10
|
declare global {
|
|
7
11
|
const _WORKLET: boolean;
|
|
8
|
-
const _frameTimestamp: number;
|
|
12
|
+
const _frameTimestamp: number | null;
|
|
9
13
|
const _eventTimestamp: number;
|
|
14
|
+
const __reanimatedModuleProxy: NativeReanimated;
|
|
10
15
|
const _setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
16
|
+
const _log: (s: string) => void;
|
|
11
17
|
const _getCurrentTime: () => number;
|
|
12
18
|
const _stopObservingProgress: (tag: number, flag: boolean) => void;
|
|
13
19
|
const _startObservingProgress: (
|
|
@@ -20,7 +26,7 @@ declare global {
|
|
|
20
26
|
name: string,
|
|
21
27
|
updates: StyleProps | AnimatedStyle
|
|
22
28
|
) => void;
|
|
23
|
-
const _measure: (viewTag: number) => MeasuredDimensions
|
|
29
|
+
const _measure: (viewTag: number) => MeasuredDimensions;
|
|
24
30
|
const _scrollTo: (
|
|
25
31
|
viewTag: number,
|
|
26
32
|
x: number,
|
|
@@ -28,20 +34,40 @@ declare global {
|
|
|
28
34
|
animated: boolean
|
|
29
35
|
) => void;
|
|
30
36
|
const _chronoNow: () => number;
|
|
37
|
+
const performance: { now: () => number };
|
|
38
|
+
const LayoutAnimationRepository: {
|
|
39
|
+
configs: Record<string, unknown>;
|
|
40
|
+
registerConfig(tag: number, config: Record<string, unknown>): void;
|
|
41
|
+
removeConfig(tag: number): void;
|
|
42
|
+
startAnimationForTag(tag: number, type: string, yogaValues: unknown): void;
|
|
43
|
+
};
|
|
31
44
|
const ReanimatedDataMock: {
|
|
32
45
|
now: () => number;
|
|
33
46
|
};
|
|
34
47
|
const _frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
35
48
|
namespace NodeJS {
|
|
36
49
|
interface Global {
|
|
37
|
-
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
38
|
-
_log: (s: string) => void;
|
|
39
|
-
_setGestureState: () => void;
|
|
40
50
|
_WORKLET: boolean;
|
|
41
|
-
|
|
51
|
+
_IS_FABRIC: boolean;
|
|
42
52
|
_frameTimestamp: number | null;
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
_eventTimestamp: number;
|
|
54
|
+
__reanimatedModuleProxy: NativeReanimated;
|
|
55
|
+
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
56
|
+
_log: (s: string) => void;
|
|
57
|
+
_getCurrentTime: () => number;
|
|
58
|
+
_stopObservingProgress: (tag: number, flag: boolean) => void;
|
|
59
|
+
_startObservingProgress: (
|
|
60
|
+
tag: number,
|
|
61
|
+
flag: { value: boolean; _value: boolean }
|
|
62
|
+
) => void;
|
|
63
|
+
_setGestureState: (handlerTag: number, newState: number) => void;
|
|
64
|
+
_measure: (viewTag: number) => MeasuredDimensions;
|
|
65
|
+
_scrollTo: (
|
|
66
|
+
viewTag: number,
|
|
67
|
+
x: number,
|
|
68
|
+
y: number,
|
|
69
|
+
animated: boolean
|
|
70
|
+
) => void;
|
|
45
71
|
_chronoNow: () => number;
|
|
46
72
|
performance: { now: () => number };
|
|
47
73
|
LayoutAnimationRepository: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { findNodeHandle } from 'react-native';
|
|
3
|
-
import { useEvent
|
|
3
|
+
import { useEvent } from './utils';
|
|
4
|
+
import { useSharedValue } from './useSharedValue';
|
|
4
5
|
const subscribeForEvents = [
|
|
5
6
|
'onScroll',
|
|
6
7
|
'onScrollBeginDrag',
|
|
@@ -2,6 +2,6 @@ import { Component } from 'react';
|
|
|
2
2
|
import { MeasuredDimensions } from './commonTypes';
|
|
3
3
|
import { RefObjectFunction } from './hook/commonTypes';
|
|
4
4
|
export declare function getTag(view: null | number | React.Component<any, any> | React.ComponentClass<any>): null | number;
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
5
|
+
export declare let measure: (animatedRef: RefObjectFunction<Component>) => MeasuredDimensions | null;
|
|
6
|
+
export declare let scrollTo: (animatedRef: RefObjectFunction<Component>, x: number, y: number, animated: boolean) => void;
|
|
7
7
|
export declare function setGestureState(handlerTag: number, newState: number): void;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
declare type CallbackDetails = {
|
|
2
|
+
callback: (frameInfo: FrameInfo) => void;
|
|
3
|
+
startTime: number | null;
|
|
4
|
+
};
|
|
1
5
|
export declare type FrameInfo = {
|
|
2
6
|
timestamp: number;
|
|
3
7
|
timeSincePreviousFrame: number | null;
|
|
4
8
|
timeSinceFirstFrame: number;
|
|
5
9
|
};
|
|
10
|
+
export interface FrameCallbackRegistryUI {
|
|
11
|
+
frameCallbackRegistry: Map<number, CallbackDetails>;
|
|
12
|
+
activeFrameCallbacks: Set<number>;
|
|
13
|
+
previousFrameTimestamp: number | null;
|
|
14
|
+
runCallbacks: () => void;
|
|
15
|
+
registerFrameCallback: (callback: (frameInfo: FrameInfo) => void, callbackId: number) => void;
|
|
16
|
+
unregisterFrameCallback: (callbackId: number) => void;
|
|
17
|
+
manageStateFrameCallback: (callbackId: number, state: boolean) => void;
|
|
18
|
+
}
|
|
6
19
|
export declare const prepareUIRegistry: () => void;
|
|
20
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-reanimated",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "More powerful alternative to Animated library for React Native.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
|
|
7
7
|
"test:unit": "jest",
|
|
8
|
-
"lint": "yarn lint:js && yarn lint:cpp && yarn lint:java",
|
|
8
|
+
"lint": "yarn lint:js && yarn lint:cpp && yarn lint:java && yarn lint:ios && yarn lint:docs",
|
|
9
9
|
"lint:js": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check src/",
|
|
10
10
|
"lint:java": "./android/gradlew -p android spotlessCheck -q",
|
|
11
11
|
"lint:cpp": "./scripts/cpplint.sh",
|
|
12
|
+
"lint:ios": "./scripts/validate-ios.sh",
|
|
12
13
|
"format": "yarn format:js && yarn format:java && yarn format:ios && yarn format:android && yarn format:common",
|
|
13
14
|
"format:js": "prettier --write --list-different './src/'",
|
|
14
15
|
"format:java": "node ./scripts/format-java.js",
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"type:generate:remove.tsx": "find ./lib -type f -name \"*.tsx\" -and -not -name \"*.d.ts\" -delete",
|
|
27
28
|
"type:generate:remove.js:from-src": "find ./src/reanimated2 -type f -name \"*.js\" -delete",
|
|
28
29
|
"prepare": "husky install",
|
|
29
|
-
"circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular
|
|
30
|
+
"circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular src lib",
|
|
30
31
|
"setup": "yarn && cd Example && yarn && cd ios && pod install --verbose && cd ../..",
|
|
31
32
|
"clean": "rm -rf node_modules && cd Example && rm -rf node_modules && cd ios && pod deintegrate && cd ../..",
|
|
32
33
|
"reset": "yarn clean && yarn setup",
|
|
@@ -122,7 +123,7 @@
|
|
|
122
123
|
"madge": "^5.0.1",
|
|
123
124
|
"prettier": "^2.5.1",
|
|
124
125
|
"react": "17.0.2",
|
|
125
|
-
"react-native": "0.70.
|
|
126
|
+
"react-native": "0.70.3",
|
|
126
127
|
"react-native-builder-bob": "^0.18.3",
|
|
127
128
|
"react-native-codegen": "^0.0.7",
|
|
128
129
|
"react-native-gesture-handler": "^1.6.1",
|
|
@@ -36,7 +36,11 @@ def find_config()
|
|
|
36
36
|
result[:react_native_minor_version] = react_native_json['version'].split('.')[1].to_i
|
|
37
37
|
result[:react_native_node_modules_dir] = File.expand_path(react_native_node_modules_dir)
|
|
38
38
|
result[:reanimated_node_modules_dir] = File.expand_path(File.join(__dir__, '..', '..'))
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
pods_root = Pod::Config.instance.project_pods_root
|
|
41
|
+
react_native_common_dir_absolute = File.join(react_native_node_modules_dir, 'react-native', 'ReactCommon')
|
|
42
|
+
react_native_common_dir_relative = Pathname.new(react_native_common_dir_absolute).relative_path_from(pods_root).to_s
|
|
43
|
+
result[:react_native_common_dir] = react_native_common_dir_relative
|
|
40
44
|
|
|
41
45
|
return result
|
|
42
46
|
end
|
|
@@ -60,6 +64,14 @@ def assert_no_multiple_instances(react_native_info)
|
|
|
60
64
|
location['/package.json'] = ''
|
|
61
65
|
parsed_location += "- " + location + "\n"
|
|
62
66
|
end
|
|
63
|
-
raise "[
|
|
67
|
+
raise "[react-native-reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsed_location
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def assert_no_reanimated2_with_new_architecture(reanimated_package_json)
|
|
72
|
+
reanimated_major_version = reanimated_package_json['version'].split('.')[0].to_i
|
|
73
|
+
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
74
|
+
if fabric_enabled && reanimated_major_version == 2
|
|
75
|
+
raise "[react-native-reanimated] Reanimated 2.x does not support Fabric. Please upgrade to 3.x to use Reanimated with the New Architecture. For details, see https://blog.swmansion.com/announcing-reanimated-3-16167428c5f7"
|
|
64
76
|
end
|
|
65
77
|
end
|
|
@@ -534,12 +534,11 @@ export default function createAnimatedComponent(
|
|
|
534
534
|
// TODO update config
|
|
535
535
|
const tag = findNodeHandle(ref);
|
|
536
536
|
if (
|
|
537
|
+
!shouldBeUseWeb() &&
|
|
537
538
|
(this.props.layout || this.props.entering || this.props.exiting) &&
|
|
538
539
|
tag != null
|
|
539
540
|
) {
|
|
540
|
-
|
|
541
|
-
enableLayoutAnimations(true, false);
|
|
542
|
-
}
|
|
541
|
+
enableLayoutAnimations(true, false);
|
|
543
542
|
let layout = this.props.layout ? this.props.layout : DefaultLayout;
|
|
544
543
|
let entering = this.props.entering
|
|
545
544
|
? this.props.entering
|
|
@@ -3,7 +3,7 @@ import { Component } from 'react';
|
|
|
3
3
|
import { findNodeHandle } from 'react-native';
|
|
4
4
|
import { MeasuredDimensions } from './commonTypes';
|
|
5
5
|
import { RefObjectFunction } from './hook/commonTypes';
|
|
6
|
-
import { shouldBeUseWeb } from './PlatformChecker';
|
|
6
|
+
import { isChromeDebugger, isWeb, shouldBeUseWeb } from './PlatformChecker';
|
|
7
7
|
|
|
8
8
|
export function getTag(
|
|
9
9
|
view: null | number | React.Component<any, any> | React.ComponentClass<any>
|
|
@@ -13,70 +13,114 @@ export function getTag(
|
|
|
13
13
|
|
|
14
14
|
const isNative = !shouldBeUseWeb();
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export let measure: (
|
|
17
17
|
animatedRef: RefObjectFunction<Component>
|
|
18
|
-
)
|
|
19
|
-
'worklet';
|
|
20
|
-
if (!isNative) {
|
|
21
|
-
console.warn(
|
|
22
|
-
'[Reanimated] measure() cannot be used on web or Chrome Debugger'
|
|
23
|
-
);
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
18
|
+
) => MeasuredDimensions | null;
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
if (isWeb()) {
|
|
21
|
+
measure = (animatedRef: RefObjectFunction<Component>) => {
|
|
22
|
+
const element = animatedRef() as unknown as HTMLElement; // TODO: fix typing of animated refs on web
|
|
23
|
+
const viewportOffset = element.getBoundingClientRect();
|
|
24
|
+
return {
|
|
25
|
+
width: element.offsetWidth,
|
|
26
|
+
height: element.offsetHeight,
|
|
27
|
+
x: element.offsetLeft,
|
|
28
|
+
y: element.offsetTop,
|
|
29
|
+
pageX: viewportOffset.left,
|
|
30
|
+
pageY: viewportOffset.top,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
} else if (isChromeDebugger()) {
|
|
34
|
+
measure = (_animatedRef: RefObjectFunction<Component>) => {
|
|
35
|
+
console.warn('[Reanimated] measure() cannot be used with Chrome Debugger.');
|
|
36
36
|
return null;
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
|
+
} else {
|
|
39
|
+
measure = (animatedRef: RefObjectFunction<Component>) => {
|
|
40
|
+
'worklet';
|
|
41
|
+
if (!_WORKLET) {
|
|
42
|
+
console.warn(
|
|
43
|
+
'[Reanimated] measure() was called from the main JS context. Measure is ' +
|
|
44
|
+
'only available in the UI runtime. This may also happen if measure() ' +
|
|
45
|
+
'was called by a worklet in the useAnimatedStyle hook, because useAnimatedStyle ' +
|
|
46
|
+
'calls the given worklet on the JS runtime during render. If you want to ' +
|
|
47
|
+
'prevent this warning then wrap the call with `if (_WORKLET)`. Then it will ' +
|
|
48
|
+
'only be called on the UI runtime after the render has been completed.'
|
|
49
|
+
);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
38
52
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
const viewTag = animatedRef();
|
|
54
|
+
if (viewTag === -1) {
|
|
55
|
+
console.warn(
|
|
56
|
+
`[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`
|
|
57
|
+
);
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
const measured = _measure(viewTag);
|
|
62
|
+
if (measured === null) {
|
|
63
|
+
console.warn(
|
|
64
|
+
`[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \`LayoutMetrics\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`
|
|
65
|
+
);
|
|
66
|
+
return null;
|
|
67
|
+
} else if (measured.x === -1234567) {
|
|
68
|
+
console.warn(
|
|
69
|
+
`[Reanimated] The view with tag ${viewTag} returned an invalid measurement response.`
|
|
70
|
+
);
|
|
71
|
+
return null;
|
|
72
|
+
} else if (isNaN(measured.x)) {
|
|
73
|
+
console.warn(
|
|
74
|
+
`[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \`collapsable={false}\` on this component.`
|
|
75
|
+
);
|
|
76
|
+
return null;
|
|
77
|
+
} else {
|
|
78
|
+
return measured;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
66
81
|
}
|
|
67
82
|
|
|
68
|
-
export
|
|
83
|
+
export let scrollTo: (
|
|
69
84
|
animatedRef: RefObjectFunction<Component>,
|
|
70
85
|
x: number,
|
|
71
86
|
y: number,
|
|
72
87
|
animated: boolean
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
) => void;
|
|
89
|
+
|
|
90
|
+
if (isWeb()) {
|
|
91
|
+
scrollTo = (
|
|
92
|
+
animatedRef: RefObjectFunction<Component>,
|
|
93
|
+
x: number,
|
|
94
|
+
y: number,
|
|
95
|
+
animated: boolean
|
|
96
|
+
) => {
|
|
97
|
+
'worklet';
|
|
98
|
+
const element = animatedRef() as unknown as HTMLElement;
|
|
99
|
+
// @ts-ignore same call as in react-native-web
|
|
100
|
+
element.scrollTo({ x, y, animated });
|
|
101
|
+
};
|
|
102
|
+
} else if (isNative) {
|
|
103
|
+
scrollTo = (
|
|
104
|
+
animatedRef: RefObjectFunction<Component>,
|
|
105
|
+
x: number,
|
|
106
|
+
y: number,
|
|
107
|
+
animated: boolean
|
|
108
|
+
) => {
|
|
109
|
+
'worklet';
|
|
110
|
+
if (!_WORKLET) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const viewTag = animatedRef();
|
|
114
|
+
_scrollTo(viewTag, x, y, animated);
|
|
115
|
+
};
|
|
116
|
+
} else {
|
|
117
|
+
scrollTo = (
|
|
118
|
+
_animatedRef: RefObjectFunction<Component>,
|
|
119
|
+
_x: number,
|
|
120
|
+
_y: number
|
|
121
|
+
) => {
|
|
122
|
+
// no-op
|
|
123
|
+
};
|
|
80
124
|
}
|
|
81
125
|
|
|
82
126
|
export function setGestureState(handlerTag: number, newState: number): void {
|
|
@@ -11,7 +11,7 @@ export type FrameInfo = {
|
|
|
11
11
|
timeSinceFirstFrame: number;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
interface FrameCallbackRegistryUI {
|
|
14
|
+
export interface FrameCallbackRegistryUI {
|
|
15
15
|
frameCallbackRegistry: Map<number, CallbackDetails>;
|
|
16
16
|
activeFrameCallbacks: Set<number>;
|
|
17
17
|
previousFrameTimestamp: number | null;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type {
|
|
2
|
+
AnimatedStyle,
|
|
3
|
+
StyleProps,
|
|
4
|
+
MeasuredDimensions,
|
|
5
|
+
} from './commonTypes';
|
|
6
|
+
import type { ReanimatedConsole } from './core';
|
|
7
|
+
import type { NativeReanimated } from './NativeReanimated/NativeReanimated';
|
|
8
|
+
import type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';
|
|
9
|
+
|
|
6
10
|
declare global {
|
|
7
11
|
const _WORKLET: boolean;
|
|
8
|
-
const _frameTimestamp: number;
|
|
12
|
+
const _frameTimestamp: number | null;
|
|
9
13
|
const _eventTimestamp: number;
|
|
14
|
+
const __reanimatedModuleProxy: NativeReanimated;
|
|
10
15
|
const _setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
16
|
+
const _log: (s: string) => void;
|
|
11
17
|
const _getCurrentTime: () => number;
|
|
12
18
|
const _stopObservingProgress: (tag: number, flag: boolean) => void;
|
|
13
19
|
const _startObservingProgress: (
|
|
@@ -20,7 +26,7 @@ declare global {
|
|
|
20
26
|
name: string,
|
|
21
27
|
updates: StyleProps | AnimatedStyle
|
|
22
28
|
) => void;
|
|
23
|
-
const _measure: (viewTag: number) => MeasuredDimensions
|
|
29
|
+
const _measure: (viewTag: number) => MeasuredDimensions;
|
|
24
30
|
const _scrollTo: (
|
|
25
31
|
viewTag: number,
|
|
26
32
|
x: number,
|
|
@@ -28,20 +34,40 @@ declare global {
|
|
|
28
34
|
animated: boolean
|
|
29
35
|
) => void;
|
|
30
36
|
const _chronoNow: () => number;
|
|
37
|
+
const performance: { now: () => number };
|
|
38
|
+
const LayoutAnimationRepository: {
|
|
39
|
+
configs: Record<string, unknown>;
|
|
40
|
+
registerConfig(tag: number, config: Record<string, unknown>): void;
|
|
41
|
+
removeConfig(tag: number): void;
|
|
42
|
+
startAnimationForTag(tag: number, type: string, yogaValues: unknown): void;
|
|
43
|
+
};
|
|
31
44
|
const ReanimatedDataMock: {
|
|
32
45
|
now: () => number;
|
|
33
46
|
};
|
|
34
47
|
const _frameCallbackRegistry: FrameCallbackRegistryUI;
|
|
35
48
|
namespace NodeJS {
|
|
36
49
|
interface Global {
|
|
37
|
-
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
38
|
-
_log: (s: string) => void;
|
|
39
|
-
_setGestureState: () => void;
|
|
40
50
|
_WORKLET: boolean;
|
|
41
|
-
|
|
51
|
+
_IS_FABRIC: boolean;
|
|
42
52
|
_frameTimestamp: number | null;
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
_eventTimestamp: number;
|
|
54
|
+
__reanimatedModuleProxy: NativeReanimated;
|
|
55
|
+
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
56
|
+
_log: (s: string) => void;
|
|
57
|
+
_getCurrentTime: () => number;
|
|
58
|
+
_stopObservingProgress: (tag: number, flag: boolean) => void;
|
|
59
|
+
_startObservingProgress: (
|
|
60
|
+
tag: number,
|
|
61
|
+
flag: { value: boolean; _value: boolean }
|
|
62
|
+
) => void;
|
|
63
|
+
_setGestureState: (handlerTag: number, newState: number) => void;
|
|
64
|
+
_measure: (viewTag: number) => MeasuredDimensions;
|
|
65
|
+
_scrollTo: (
|
|
66
|
+
viewTag: number,
|
|
67
|
+
x: number,
|
|
68
|
+
y: number,
|
|
69
|
+
animated: boolean
|
|
70
|
+
) => void;
|
|
45
71
|
_chronoNow: () => number;
|
|
46
72
|
performance: { now: () => number };
|
|
47
73
|
LayoutAnimationRepository: {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { RefObject, useEffect, useRef } from 'react';
|
|
2
2
|
|
|
3
|
-
import { findNodeHandle } from 'react-native';
|
|
4
3
|
import type Animated from 'react-native-reanimated';
|
|
5
|
-
import { useEvent, useSharedValue } from '.';
|
|
6
|
-
import { SharedValue } from '../commonTypes';
|
|
7
4
|
import { ScrollEvent } from './useAnimatedScrollHandler';
|
|
5
|
+
import { SharedValue } from '../commonTypes';
|
|
6
|
+
import { findNodeHandle } from 'react-native';
|
|
7
|
+
import { useEvent } from './utils';
|
|
8
|
+
import { useSharedValue } from './useSharedValue';
|
|
8
9
|
|
|
9
10
|
const subscribeForEvents = [
|
|
10
11
|
'onScroll',
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
package com.facebook.react.uimanager;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.Nullable;
|
|
4
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
6
|
-
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
7
|
-
import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager;
|
|
8
|
-
import java.util.List;
|
|
9
|
-
|
|
10
|
-
public class ReanimatedUIImplementation extends UIImplementation {
|
|
11
|
-
public ReanimatedUIImplementation(
|
|
12
|
-
ReactApplicationContext reactContext,
|
|
13
|
-
UIManagerModule.ViewManagerResolver viewManagerResolver,
|
|
14
|
-
EventDispatcher eventDispatcher,
|
|
15
|
-
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
16
|
-
this(
|
|
17
|
-
reactContext,
|
|
18
|
-
new ViewManagerRegistry(viewManagerResolver),
|
|
19
|
-
eventDispatcher,
|
|
20
|
-
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public ReanimatedUIImplementation(
|
|
24
|
-
ReactApplicationContext reactContext,
|
|
25
|
-
List<ViewManager> viewManagerList,
|
|
26
|
-
EventDispatcher eventDispatcher,
|
|
27
|
-
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
28
|
-
this(
|
|
29
|
-
reactContext,
|
|
30
|
-
new ViewManagerRegistry(viewManagerList),
|
|
31
|
-
eventDispatcher,
|
|
32
|
-
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public ReanimatedUIImplementation(
|
|
36
|
-
ReactApplicationContext reactContext,
|
|
37
|
-
ViewManagerRegistry viewManagerRegistry,
|
|
38
|
-
EventDispatcher eventDispatcher,
|
|
39
|
-
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
40
|
-
super(
|
|
41
|
-
reactContext,
|
|
42
|
-
viewManagerRegistry,
|
|
43
|
-
new UIViewOperationQueue(
|
|
44
|
-
reactContext,
|
|
45
|
-
new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext),
|
|
46
|
-
minTimeLeftInFrameForNonBatchedOperationMs),
|
|
47
|
-
eventDispatcher);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Invoked when there is a mutation in a node tree.
|
|
52
|
-
*
|
|
53
|
-
* @param tag react tag of the node we want to manage
|
|
54
|
-
* @param indicesToRemove ordered (asc) list of indicies at which view should be removed
|
|
55
|
-
* @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent
|
|
56
|
-
* a view which should be added at the specified index
|
|
57
|
-
* @param tagsToDelete list of tags corresponding to views that should be removed
|
|
58
|
-
*/
|
|
59
|
-
public void manageChildren(
|
|
60
|
-
int viewTag,
|
|
61
|
-
@Nullable ReadableArray moveFrom,
|
|
62
|
-
@Nullable ReadableArray moveTo,
|
|
63
|
-
@Nullable ReadableArray addChildTags,
|
|
64
|
-
@Nullable ReadableArray addAtIndices,
|
|
65
|
-
@Nullable ReadableArray removeFrom) {
|
|
66
|
-
super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
package com.facebook.react.uimanager;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.Nullable;
|
|
4
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
6
|
-
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
7
|
-
import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager;
|
|
8
|
-
import java.util.List;
|
|
9
|
-
|
|
10
|
-
public class ReanimatedUIImplementation extends UIImplementation {
|
|
11
|
-
public ReanimatedUIImplementation(
|
|
12
|
-
ReactApplicationContext reactContext,
|
|
13
|
-
UIManagerModule.ViewManagerResolver viewManagerResolver,
|
|
14
|
-
EventDispatcher eventDispatcher,
|
|
15
|
-
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
16
|
-
this(
|
|
17
|
-
reactContext,
|
|
18
|
-
new ViewManagerRegistry(viewManagerResolver),
|
|
19
|
-
eventDispatcher,
|
|
20
|
-
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public ReanimatedUIImplementation(
|
|
24
|
-
ReactApplicationContext reactContext,
|
|
25
|
-
List<ViewManager> viewManagerList,
|
|
26
|
-
EventDispatcher eventDispatcher,
|
|
27
|
-
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
28
|
-
this(
|
|
29
|
-
reactContext,
|
|
30
|
-
new ViewManagerRegistry(viewManagerList),
|
|
31
|
-
eventDispatcher,
|
|
32
|
-
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public ReanimatedUIImplementation(
|
|
36
|
-
ReactApplicationContext reactContext,
|
|
37
|
-
ViewManagerRegistry viewManagerRegistry,
|
|
38
|
-
EventDispatcher eventDispatcher,
|
|
39
|
-
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
40
|
-
super(
|
|
41
|
-
reactContext,
|
|
42
|
-
viewManagerRegistry,
|
|
43
|
-
new UIViewOperationQueue(
|
|
44
|
-
reactContext,
|
|
45
|
-
new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext),
|
|
46
|
-
minTimeLeftInFrameForNonBatchedOperationMs),
|
|
47
|
-
eventDispatcher);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Invoked when there is a mutation in a node tree.
|
|
52
|
-
*
|
|
53
|
-
* @param tag react tag of the node we want to manage
|
|
54
|
-
* @param indicesToRemove ordered (asc) list of indicies at which view should be removed
|
|
55
|
-
* @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent
|
|
56
|
-
* a view which should be added at the specified index
|
|
57
|
-
* @param tagsToDelete list of tags corresponding to views that should be removed
|
|
58
|
-
*/
|
|
59
|
-
public void manageChildren(
|
|
60
|
-
int viewTag,
|
|
61
|
-
@Nullable ReadableArray moveFrom,
|
|
62
|
-
@Nullable ReadableArray moveTo,
|
|
63
|
-
@Nullable ReadableArray addChildTags,
|
|
64
|
-
@Nullable ReadableArray addAtIndices,
|
|
65
|
-
@Nullable ReadableArray removeFrom) {
|
|
66
|
-
super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|