react-native-reanimated 2.4.1 → 2.5.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/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +72 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +30 -1
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +64 -39
- package/Common/cpp/Tools/RuntimeDecorator.cpp +2 -0
- package/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h +41 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +14 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +14 -0
- package/Common/cpp/headers/SharedItems/MutableValue.h +4 -1
- package/Common/cpp/headers/SharedItems/ShareableValue.h +3 -0
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +3 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +11 -0
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +2 -0
- package/README.md +2 -2
- package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/CMakeLists.txt +198 -0
- package/android/README.md +15 -0
- package/android/build.gradle +686 -73
- package/android/empty.cpp +1 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +25 -0
- package/android/gradlew +234 -0
- package/android/gradlew.bat +89 -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/android/react-native-reanimated-68-hermes.aar +0 -0
- package/android/react-native-reanimated-68-jsc.aar +0 -0
- package/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java +412 -0
- package/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- 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/backup/.gitkeep +0 -0
- package/android/settings.gradle +1 -0
- package/android/spotless.gradle +9 -0
- package/android/src/{AndroidManifest.xml → main/AndroidManifest.xml} +0 -0
- package/android/src/main/cpp/AndroidErrorHandler.cpp +42 -0
- package/android/src/main/cpp/AndroidLogger.cpp +27 -0
- package/android/src/main/cpp/AndroidScheduler.cpp +59 -0
- package/android/src/main/cpp/JNIHelper.cpp +59 -0
- package/android/src/main/cpp/LayoutAnimations.cpp +103 -0
- package/android/src/main/cpp/NativeProxy.cpp +327 -0
- package/android/src/main/cpp/OnLoad.cpp +17 -0
- package/android/src/main/cpp/TurboModule.cpp +44 -0
- package/android/src/main/cpp/headers/AndroidErrorHandler.h +30 -0
- package/android/src/main/cpp/headers/AndroidLogger.h +16 -0
- package/android/src/main/cpp/headers/AndroidScheduler.h +41 -0
- package/android/src/main/cpp/headers/JNIHelper.h +30 -0
- package/android/src/main/cpp/headers/LayoutAnimations.h +42 -0
- package/android/src/main/cpp/headers/NativeProxy.h +170 -0
- package/android/src/main/cpp/headers/TurboModule.h +70 -0
- package/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java +15 -0
- package/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java +5 -0
- package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +8 -0
- package/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java +43 -0
- package/android/src/main/java/com/swmansion/reanimated/MapUtils.java +26 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +117 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +285 -0
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +682 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java +29 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java +251 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +96 -0
- package/android/src/main/java/com/swmansion/reanimated/Scheduler.java +51 -0
- package/android/src/main/java/com/swmansion/reanimated/UpdateContext.java +11 -0
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +32 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +517 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +56 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +11 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +410 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +292 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +121 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +12 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java +29 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java +87 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java +24 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java +49 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java +38 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java +73 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java +36 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java +33 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java +83 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java +5 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java +20 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/Node.java +139 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java +37 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +377 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java +71 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java +153 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java +32 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java +84 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java +84 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java +25 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java +86 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java +161 -0
- package/ios/LayoutReanimation/REAAnimationsManager.m +14 -4
- package/ios/REAModule.m +8 -9
- package/ios/REANodesManager.h +4 -1
- package/ios/REANodesManager.m +75 -3
- package/ios/native/NativeProxy.mm +76 -4
- package/ios/sensor/ReanimatedSensor.h +21 -0
- package/ios/sensor/ReanimatedSensor.m +169 -0
- package/ios/sensor/ReanimatedSensorContainer.h +13 -0
- package/ios/sensor/ReanimatedSensorContainer.m +41 -0
- package/ios/sensor/ReanimatedSensorType.h +7 -0
- package/lib/ConfigHelper.js +2 -2
- package/lib/createAnimatedComponent.js +3 -4
- package/lib/reanimated1/core/AnimatedFunction.js +1 -1
- package/lib/reanimated1/derived/interpolate.js +2 -4
- package/lib/reanimated2/Colors.js +2 -1
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +25 -12
- package/lib/reanimated2/NativeReanimated/index.js +0 -4
- package/lib/reanimated2/ViewDescriptorsSet.js +2 -2
- package/lib/reanimated2/animation/styleAnimation.js +2 -1
- package/lib/reanimated2/core.js +30 -24
- package/lib/reanimated2/globals.d.ts +6 -0
- package/lib/reanimated2/hook/index.js +1 -0
- package/lib/reanimated2/hook/useAnimatedSensor.js +66 -0
- package/lib/reanimated2/interpolation.js +1 -1
- package/lib/reanimated2/jestUtils.js +9 -4
- package/lib/reanimated2/js-reanimated/JSReanimated.js +23 -2
- package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +8 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +2 -1
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +32 -42
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +20 -38
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +32 -44
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -10
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +20 -36
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -20
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +8 -12
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +32 -48
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +22 -18
- package/lib/reanimated2/mock.js +3 -2
- package/mock.js +4 -4
- package/package.json +42 -36
- package/plugin.js +2 -0
- package/react-native-reanimated.d.ts +41 -12
- package/src/ConfigHelper.ts +4 -4
- package/src/createAnimatedComponent.tsx +3 -3
- package/src/reanimated1/core/AnimatedFunction.js +1 -1
- package/src/reanimated1/derived/interpolate.js +2 -4
- package/src/reanimated2/Colors.ts +2 -1
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +42 -15
- package/src/reanimated2/NativeReanimated/index.ts +0 -6
- package/src/reanimated2/ViewDescriptorsSet.ts +2 -3
- package/src/reanimated2/animation/index.ts +1 -0
- package/src/reanimated2/animation/styleAnimation.ts +10 -7
- package/src/reanimated2/animation/timing.ts +3 -1
- package/src/reanimated2/animation/util.ts +10 -11
- package/src/reanimated2/commonTypes.ts +20 -0
- package/src/reanimated2/component/FlatList.tsx +2 -1
- package/src/reanimated2/core.ts +34 -26
- package/src/reanimated2/globals.d.ts +6 -0
- package/src/reanimated2/hook/index.ts +1 -0
- package/src/reanimated2/hook/useAnimatedSensor.ts +91 -0
- package/src/reanimated2/hook/utils.ts +2 -1
- package/src/reanimated2/interpolation.ts +2 -6
- package/src/reanimated2/jestUtils.ts +9 -4
- package/src/reanimated2/js-reanimated/JSReanimated.ts +25 -2
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +13 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -3
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +51 -21
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +40 -10
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +48 -12
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -2
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +32 -8
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -10
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +64 -16
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +26 -19
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +2 -1
- package/src/reanimated2/mock.ts +3 -2
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedProxyPackage.java +0 -15
- 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
|
@@ -128,15 +128,13 @@ export default function interpolate(value, config) {
|
|
|
128
128
|
const right = extrapolateRight || extrapolate;
|
|
129
129
|
let output = interpolateInternal(value, inputRange, outputRange);
|
|
130
130
|
|
|
131
|
-
if (left === Extrapolate.
|
|
132
|
-
} else if (left === Extrapolate.CLAMP) {
|
|
131
|
+
if (left === Extrapolate.CLAMP) {
|
|
133
132
|
output = cond(lessThan(value, inputRange[0]), outputRange[0], output);
|
|
134
133
|
} else if (left === Extrapolate.IDENTITY) {
|
|
135
134
|
output = cond(lessThan(value, inputRange[0]), value, output);
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
if (right === Extrapolate.
|
|
139
|
-
} else if (right === Extrapolate.CLAMP) {
|
|
137
|
+
if (right === Extrapolate.CLAMP) {
|
|
140
138
|
output = cond(
|
|
141
139
|
greaterThan(value, inputRange[inputRange.length - 1]),
|
|
142
140
|
outputRange[outputRange.length - 1],
|
|
@@ -31,7 +31,8 @@ function getMatchers() {
|
|
|
31
31
|
cachedMatchers.hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
|
|
32
32
|
cachedMatchers.hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
|
|
33
33
|
cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
34
|
-
cachedMatchers.hex4 =
|
|
34
|
+
cachedMatchers.hex4 =
|
|
35
|
+
/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
35
36
|
cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
|
|
36
37
|
cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
|
|
37
38
|
}
|
|
@@ -1,37 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
2
|
export class NativeReanimated {
|
|
3
3
|
constructor(native = true) {
|
|
4
|
+
if (global.__reanimatedModuleProxy === undefined) {
|
|
5
|
+
const { ReanimatedModule } = NativeModules;
|
|
6
|
+
ReanimatedModule === null || ReanimatedModule === void 0 ? void 0 : ReanimatedModule.installTurboModule();
|
|
7
|
+
}
|
|
8
|
+
this.InnerNativeModule = global.__reanimatedModuleProxy;
|
|
4
9
|
this.native = native;
|
|
5
|
-
this.useOnlyV1 = InnerNativeModule === null;
|
|
6
10
|
}
|
|
7
11
|
installCoreFunctions(valueSetter) {
|
|
8
|
-
return InnerNativeModule.installCoreFunctions(valueSetter);
|
|
12
|
+
return this.InnerNativeModule.installCoreFunctions(valueSetter);
|
|
9
13
|
}
|
|
10
14
|
makeShareable(value) {
|
|
11
|
-
return InnerNativeModule.makeShareable(value);
|
|
15
|
+
return this.InnerNativeModule.makeShareable(value);
|
|
12
16
|
}
|
|
13
17
|
makeMutable(value) {
|
|
14
|
-
return InnerNativeModule.makeMutable(value);
|
|
18
|
+
return this.InnerNativeModule.makeMutable(value);
|
|
15
19
|
}
|
|
16
20
|
makeRemote(object = {}) {
|
|
17
|
-
return InnerNativeModule.makeRemote(object);
|
|
21
|
+
return this.InnerNativeModule.makeRemote(object);
|
|
22
|
+
}
|
|
23
|
+
registerSensor(sensorType, interval, sensorData) {
|
|
24
|
+
return this.InnerNativeModule.registerSensor(sensorType, interval, sensorData);
|
|
25
|
+
}
|
|
26
|
+
unregisterSensor(sensorId) {
|
|
27
|
+
return this.InnerNativeModule.unregisterSensor(sensorId);
|
|
18
28
|
}
|
|
19
29
|
startMapper(mapper, inputs = [], outputs = [], updater, viewDescriptors) {
|
|
20
|
-
return InnerNativeModule.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
|
|
30
|
+
return this.InnerNativeModule.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
|
|
21
31
|
}
|
|
22
32
|
stopMapper(mapperId) {
|
|
23
|
-
return InnerNativeModule.stopMapper(mapperId);
|
|
33
|
+
return this.InnerNativeModule.stopMapper(mapperId);
|
|
24
34
|
}
|
|
25
35
|
registerEventHandler(eventHash, eventHandler) {
|
|
26
|
-
return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
|
|
36
|
+
return this.InnerNativeModule.registerEventHandler(eventHash, eventHandler);
|
|
27
37
|
}
|
|
28
38
|
unregisterEventHandler(id) {
|
|
29
|
-
return InnerNativeModule.unregisterEventHandler(id);
|
|
39
|
+
return this.InnerNativeModule.unregisterEventHandler(id);
|
|
30
40
|
}
|
|
31
41
|
getViewProp(viewTag, propName, callback) {
|
|
32
|
-
return InnerNativeModule.getViewProp(viewTag, propName, callback);
|
|
42
|
+
return this.InnerNativeModule.getViewProp(viewTag, propName, callback);
|
|
33
43
|
}
|
|
34
44
|
enableLayoutAnimations(flag) {
|
|
35
|
-
InnerNativeModule.enableLayoutAnimations(flag);
|
|
45
|
+
this.InnerNativeModule.enableLayoutAnimations(flag);
|
|
46
|
+
}
|
|
47
|
+
configureProps(uiProps, nativeProps) {
|
|
48
|
+
this.InnerNativeModule.configureProps(uiProps, nativeProps);
|
|
36
49
|
}
|
|
37
50
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import reanimatedJS from '../js-reanimated';
|
|
2
2
|
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
3
|
import { NativeReanimated } from './NativeReanimated';
|
|
5
4
|
let exportedModule;
|
|
6
5
|
if (shouldBeUseWeb()) {
|
|
@@ -8,8 +7,5 @@ if (shouldBeUseWeb()) {
|
|
|
8
7
|
}
|
|
9
8
|
else {
|
|
10
9
|
exportedModule = new NativeReanimated();
|
|
11
|
-
if (exportedModule.useOnlyV1 && Platform.OS === 'android') {
|
|
12
|
-
console.warn(`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`);
|
|
13
|
-
}
|
|
14
10
|
}
|
|
15
11
|
export default exportedModule;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
2
|
import { makeMutable } from './core';
|
|
3
|
-
import {
|
|
4
|
-
const scheduleUpdates =
|
|
3
|
+
import { shouldBeUseWeb } from './PlatformChecker';
|
|
4
|
+
const scheduleUpdates = shouldBeUseWeb() ? requestAnimationFrame : setImmediate;
|
|
5
5
|
export function makeViewDescriptorsSet() {
|
|
6
6
|
const ref = useRef(null);
|
|
7
7
|
if (ref.current === null) {
|
package/lib/reanimated2/core.js
CHANGED
|
@@ -24,7 +24,7 @@ export const checkPluginState = (throwError = true) => {
|
|
|
24
24
|
return true;
|
|
25
25
|
};
|
|
26
26
|
export const isConfigured = (throwError = false) => {
|
|
27
|
-
return checkPluginState(throwError)
|
|
27
|
+
return checkPluginState(throwError);
|
|
28
28
|
};
|
|
29
29
|
export const isConfiguredCheck = () => {
|
|
30
30
|
if (!isConfigured(true)) {
|
|
@@ -259,29 +259,27 @@ export function runOnJS(fun) {
|
|
|
259
259
|
return fun.__callAsync;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
global.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
})();
|
|
284
|
-
}
|
|
262
|
+
NativeReanimatedModule.installCoreFunctions(NativeReanimatedModule.native
|
|
263
|
+
? workletValueSetter
|
|
264
|
+
: workletValueSetterJS);
|
|
265
|
+
if (!isWeb() && isConfigured()) {
|
|
266
|
+
const capturableConsole = console;
|
|
267
|
+
runOnUI(() => {
|
|
268
|
+
'worklet';
|
|
269
|
+
const console = {
|
|
270
|
+
debug: runOnJS(capturableConsole.debug),
|
|
271
|
+
log: runOnJS(capturableConsole.log),
|
|
272
|
+
warn: runOnJS(capturableConsole.warn),
|
|
273
|
+
error: runOnJS(capturableConsole.error),
|
|
274
|
+
info: runOnJS(capturableConsole.info),
|
|
275
|
+
};
|
|
276
|
+
_setGlobalConsole(console);
|
|
277
|
+
if (global.performance == null) {
|
|
278
|
+
global.performance = {
|
|
279
|
+
now: global._chronoNow,
|
|
280
|
+
}; // due to conflict with lib.dom.d.ts -> Performance
|
|
281
|
+
}
|
|
282
|
+
})();
|
|
285
283
|
}
|
|
286
284
|
let featuresConfig = {
|
|
287
285
|
enableLayoutAnimations: false,
|
|
@@ -301,3 +299,11 @@ export function enableLayoutAnimations(flag, isCallByUser = true) {
|
|
|
301
299
|
NativeReanimatedModule.enableLayoutAnimations(flag);
|
|
302
300
|
}
|
|
303
301
|
}
|
|
302
|
+
export function configureProps(uiProps, nativeProps) {
|
|
303
|
+
if (!nativeShouldBeMock()) {
|
|
304
|
+
NativeReanimatedModule.configureProps(uiProps, nativeProps);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
export function jestResetJsReanimatedModule() {
|
|
308
|
+
NativeReanimatedModule.jestResetModule();
|
|
309
|
+
}
|
|
@@ -27,6 +27,9 @@ declare global {
|
|
|
27
27
|
animated: boolean
|
|
28
28
|
) => void;
|
|
29
29
|
const _chronoNow: () => number;
|
|
30
|
+
const ReanimatedDataMock: {
|
|
31
|
+
now: () => number;
|
|
32
|
+
};
|
|
30
33
|
namespace NodeJS {
|
|
31
34
|
interface Global {
|
|
32
35
|
__reanimatedWorkletInit: (worklet: WorkletFunction) => void;
|
|
@@ -50,6 +53,9 @@ declare global {
|
|
|
50
53
|
yogaValues: unknown
|
|
51
54
|
): void;
|
|
52
55
|
};
|
|
56
|
+
ReanimatedDataMock: {
|
|
57
|
+
now: () => number;
|
|
58
|
+
};
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -6,3 +6,4 @@ export { useAnimatedReaction, } from './useAnimatedReaction';
|
|
|
6
6
|
export { useAnimatedRef } from './useAnimatedRef';
|
|
7
7
|
export { useAnimatedScrollHandler, } from './useAnimatedScrollHandler';
|
|
8
8
|
export { useDerivedValue } from './useDerivedValue';
|
|
9
|
+
export { useAnimatedSensor, SensorType } from './useAnimatedSensor';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { makeMutable } from '../core';
|
|
3
|
+
import NativeReanimated from '../NativeReanimated';
|
|
4
|
+
export var SensorType;
|
|
5
|
+
(function (SensorType) {
|
|
6
|
+
SensorType[SensorType["ACCELEROMETER"] = 1] = "ACCELEROMETER";
|
|
7
|
+
SensorType[SensorType["GYROSCOPE"] = 2] = "GYROSCOPE";
|
|
8
|
+
SensorType[SensorType["GRAVITY"] = 3] = "GRAVITY";
|
|
9
|
+
SensorType[SensorType["MAGNETIC_FIELD"] = 4] = "MAGNETIC_FIELD";
|
|
10
|
+
SensorType[SensorType["ROTATION"] = 5] = "ROTATION";
|
|
11
|
+
})(SensorType || (SensorType = {}));
|
|
12
|
+
export function useAnimatedSensor(sensorType, userConfig) {
|
|
13
|
+
const ref = useRef({
|
|
14
|
+
sensor: null,
|
|
15
|
+
unregister: () => {
|
|
16
|
+
// NOOP
|
|
17
|
+
},
|
|
18
|
+
isAvailable: false,
|
|
19
|
+
config: {
|
|
20
|
+
interval: 0,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
if (ref.current.sensor === null) {
|
|
24
|
+
ref.current.config = Object.assign({ interval: 10 }, userConfig);
|
|
25
|
+
let sensorData;
|
|
26
|
+
if (sensorType === SensorType.ROTATION) {
|
|
27
|
+
sensorData = {
|
|
28
|
+
qw: 0,
|
|
29
|
+
qx: 0,
|
|
30
|
+
qy: 0,
|
|
31
|
+
qz: 0,
|
|
32
|
+
yaw: 0,
|
|
33
|
+
pitch: 0,
|
|
34
|
+
roll: 0,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
sensorData = {
|
|
39
|
+
x: 0,
|
|
40
|
+
y: 0,
|
|
41
|
+
z: 0,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
ref.current.sensor = makeMutable(sensorData);
|
|
45
|
+
}
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
ref.current.config = Object.assign({ interval: 10 }, userConfig);
|
|
48
|
+
const id = NativeReanimated.registerSensor(sensorType, ref.current.config.interval, ref.current.sensor);
|
|
49
|
+
if (id !== -1) {
|
|
50
|
+
// if sensor is available
|
|
51
|
+
ref.current.unregister = () => NativeReanimated.unregisterSensor(id);
|
|
52
|
+
ref.current.isAvailable = true;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// if sensor is unavailable
|
|
56
|
+
ref.current.unregister = () => {
|
|
57
|
+
// NOOP
|
|
58
|
+
};
|
|
59
|
+
ref.current.isAvailable = false;
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
ref.current.unregister();
|
|
63
|
+
};
|
|
64
|
+
}, [sensorType, userConfig]);
|
|
65
|
+
return ref.current;
|
|
66
|
+
}
|
|
@@ -66,7 +66,7 @@ function validateType(type) {
|
|
|
66
66
|
}
|
|
67
67
|
function internalInterpolate(x, narrowedInput, extrapolationConfig) {
|
|
68
68
|
'worklet';
|
|
69
|
-
const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput
|
|
69
|
+
const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } = narrowedInput;
|
|
70
70
|
if (rightEdgeInput - leftEdgeInput === 0)
|
|
71
71
|
return leftEdgeOutput;
|
|
72
72
|
const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
|
|
3
|
+
import { jestResetJsReanimatedModule } from './core';
|
|
4
4
|
let config = {
|
|
5
5
|
fps: 60,
|
|
6
6
|
};
|
|
@@ -105,22 +105,26 @@ const compareStyle = (received, expectedStyle, config) => {
|
|
|
105
105
|
};
|
|
106
106
|
let frameTime = 1000 / config.fps;
|
|
107
107
|
let requestAnimationFrameCopy;
|
|
108
|
+
let currentTimestamp = 0;
|
|
108
109
|
const requestAnimationFrame = (callback) => {
|
|
109
110
|
setTimeout(callback, frameTime);
|
|
110
111
|
};
|
|
111
112
|
const beforeTest = () => {
|
|
113
|
+
jestResetJsReanimatedModule();
|
|
112
114
|
requestAnimationFrameCopy = global.requestAnimationFrame;
|
|
113
115
|
global.requestAnimationFrame = requestAnimationFrame;
|
|
114
|
-
|
|
116
|
+
global.ReanimatedDataMock = {
|
|
117
|
+
now: () => currentTimestamp,
|
|
118
|
+
};
|
|
119
|
+
currentTimestamp = 0;
|
|
115
120
|
jest.useFakeTimers();
|
|
116
121
|
};
|
|
117
122
|
const afterTest = () => {
|
|
118
|
-
MockDate.reset();
|
|
119
123
|
jest.useRealTimers();
|
|
120
124
|
global.requestAnimationFrame = requestAnimationFrameCopy;
|
|
121
125
|
};
|
|
122
126
|
const tickTravel = () => {
|
|
123
|
-
|
|
127
|
+
currentTimestamp += frameTime;
|
|
124
128
|
jest.advanceTimersByTime(frameTime);
|
|
125
129
|
};
|
|
126
130
|
export const withReanimatedTimer = (animatonTest) => {
|
|
@@ -142,6 +146,7 @@ export const advanceAnimationByFrame = (count) => {
|
|
|
142
146
|
};
|
|
143
147
|
export const setUpTests = (userConfig = {}) => {
|
|
144
148
|
const expect = require('expect');
|
|
149
|
+
require('setimmediate');
|
|
145
150
|
frameTime = Math.round(1000 / config.fps);
|
|
146
151
|
config = Object.assign(Object.assign({}, config), userConfig);
|
|
147
152
|
expect.extend({
|
|
@@ -2,6 +2,7 @@ import MapperRegistry from './MapperRegistry';
|
|
|
2
2
|
import Mapper from './Mapper';
|
|
3
3
|
import MutableValue from './MutableValue';
|
|
4
4
|
import { NativeReanimated } from '../NativeReanimated/NativeReanimated';
|
|
5
|
+
import { isJest } from '../PlatformChecker';
|
|
5
6
|
export default class JSReanimated extends NativeReanimated {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(false);
|
|
@@ -9,8 +10,8 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
9
10
|
this._renderRequested = false;
|
|
10
11
|
this._mapperRegistry = new MapperRegistry(this);
|
|
11
12
|
this._frames = [];
|
|
12
|
-
if (
|
|
13
|
-
this.timeProvider = { now: () =>
|
|
13
|
+
if (isJest()) {
|
|
14
|
+
this.timeProvider = { now: () => global.ReanimatedDataMock.now() };
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
16
17
|
this.timeProvider = { now: () => window.performance.now() };
|
|
@@ -75,4 +76,24 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
75
76
|
enableLayoutAnimations() {
|
|
76
77
|
console.warn('[Reanimated] enableLayoutAnimations is not available for WEB yet');
|
|
77
78
|
}
|
|
79
|
+
registerSensor() {
|
|
80
|
+
console.warn('[Reanimated] useAnimatedSensor is not available on web yet.');
|
|
81
|
+
return -1;
|
|
82
|
+
}
|
|
83
|
+
unregisterSensor() {
|
|
84
|
+
// noop
|
|
85
|
+
}
|
|
86
|
+
jestResetModule() {
|
|
87
|
+
if (isJest()) {
|
|
88
|
+
/**
|
|
89
|
+
* If someone used timers to stop animation before the end,
|
|
90
|
+
* then _renderRequested was set as true
|
|
91
|
+
* and any new update from another test wasn't applied.
|
|
92
|
+
*/
|
|
93
|
+
this._renderRequested = false;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
throw Error('This method can be only use in Jest testing.');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
78
99
|
}
|
|
@@ -73,6 +73,14 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
73
73
|
this.restSpeedThresholdV = restSpeedThreshold;
|
|
74
74
|
return this;
|
|
75
75
|
}
|
|
76
|
+
static withInitialValues(values) {
|
|
77
|
+
const instance = this.createInstance();
|
|
78
|
+
return instance.withInitialValues(values);
|
|
79
|
+
}
|
|
80
|
+
withInitialValues(values) {
|
|
81
|
+
this.initialValues = values;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
76
84
|
getAnimationAndConfig() {
|
|
77
85
|
const duration = this.durationV;
|
|
78
86
|
const easing = this.easingV;
|
|
@@ -109,7 +109,8 @@ export class Keyframe {
|
|
|
109
109
|
if (styleProp === 'transform') {
|
|
110
110
|
(_a = initialValues[styleProp]) === null || _a === void 0 ? void 0 : _a.forEach((transformStyle, index) => {
|
|
111
111
|
Object.keys(transformStyle).forEach((transformProp) => {
|
|
112
|
-
parsedKeyframes[index.toString() + '_transform:' + transformProp] =
|
|
112
|
+
parsedKeyframes[index.toString() + '_transform:' + transformProp] =
|
|
113
|
+
[];
|
|
113
114
|
});
|
|
114
115
|
});
|
|
115
116
|
}
|