react-native-reanimated 2.3.0-alpha.3 → 2.3.0-beta.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/LayoutAnimations/LayoutAnimationsProxy.cpp +15 -8
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +176 -154
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +49 -33
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +14 -7
- package/Common/cpp/Registries/MapperRegistry.cpp +24 -20
- package/Common/cpp/Registries/WorkletsCache.cpp +19 -9
- package/Common/cpp/SharedItems/FrozenObject.cpp +17 -8
- package/Common/cpp/SharedItems/MutableValue.cpp +38 -25
- package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +11 -7
- package/Common/cpp/SharedItems/RemoteObject.cpp +9 -5
- package/Common/cpp/SharedItems/ShareableValue.cpp +211 -160
- package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +25 -6
- package/Common/cpp/Tools/Mapper.cpp +30 -30
- package/Common/cpp/Tools/RuntimeDecorator.cpp +124 -86
- package/Common/cpp/Tools/Scheduler.cpp +6 -5
- package/Common/cpp/Tools/WorkletEventHandler.cpp +4 -2
- package/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h +12 -11
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +50 -31
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +34 -16
- package/Common/cpp/headers/Registries/EventHandlerRegistry.h +15 -8
- package/Common/cpp/headers/Registries/MapperRegistry.h +5 -4
- package/Common/cpp/headers/Registries/WorkletsCache.h +9 -7
- package/Common/cpp/headers/SharedItems/FrozenObject.h +19 -11
- package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +8 -4
- package/Common/cpp/headers/SharedItems/MutableValue.h +23 -12
- package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +12 -7
- package/Common/cpp/headers/SharedItems/RemoteObject.h +19 -8
- package/Common/cpp/headers/SharedItems/RuntimeManager.h +26 -25
- package/Common/cpp/headers/SharedItems/ShareableValue.h +32 -27
- package/Common/cpp/headers/SharedItems/SharedParent.h +10 -7
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +95 -72
- package/Common/cpp/headers/SpecTools/ErrorHandler.h +18 -19
- package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
- package/Common/cpp/headers/Tools/JSIStoreValueUser.h +13 -16
- package/Common/cpp/headers/Tools/Mapper.h +19 -16
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +17 -7
- package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +7 -11
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +36 -27
- package/Common/cpp/headers/Tools/Scheduler.h +30 -35
- package/Common/cpp/headers/Tools/WorkletEventHandler.h +11 -8
- package/Common/cpp/hidden_headers/Logger.h +14 -14
- package/Common/cpp/hidden_headers/LoggerInterface.h +8 -9
- package/Common/cpp/hidden_headers/SpeedChecker.h +7 -8
- package/README.md +1 -1
- package/RNReanimated.podspec +24 -6
- package/android/build.gradle +38 -29
- 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/LayoutReanimation/REAAnimationsManager.h +10 -8
- package/ios/LayoutReanimation/REAAnimationsManager.m +91 -87
- package/ios/LayoutReanimation/REASnapshot.h +2 -2
- package/ios/LayoutReanimation/REASnapshot.m +8 -7
- package/ios/LayoutReanimation/REAUIManager.h +4 -4
- package/ios/LayoutReanimation/REAUIManager.mm +116 -70
- package/ios/Nodes/REAAlwaysNode.m +14 -15
- package/ios/Nodes/REABezierNode.m +8 -7
- package/ios/Nodes/REABlockNode.m +1 -1
- package/ios/Nodes/REACallFuncNode.h +0 -1
- package/ios/Nodes/REACallFuncNode.m +10 -8
- package/ios/Nodes/REAClockNodes.m +22 -20
- package/ios/Nodes/REAConcatNode.h +0 -1
- package/ios/Nodes/REAConcatNode.m +2 -2
- package/ios/Nodes/REACondNode.m +7 -5
- package/ios/Nodes/READebugNode.m +5 -4
- package/ios/Nodes/REAEventNode.m +1 -1
- package/ios/Nodes/REAFunctionNode.h +0 -1
- package/ios/Nodes/REAFunctionNode.m +2 -2
- package/ios/Nodes/REAJSCallNode.m +4 -5
- package/ios/Nodes/REANode.h +3 -4
- package/ios/Nodes/REANode.m +9 -11
- package/ios/Nodes/REAOperatorNode.m +68 -67
- package/ios/Nodes/REAParamNode.h +1 -3
- package/ios/Nodes/REAParamNode.m +15 -17
- package/ios/Nodes/REAPropsNode.h +1 -3
- package/ios/Nodes/REAPropsNode.m +19 -22
- package/ios/Nodes/REASetNode.h +0 -1
- package/ios/Nodes/REASetNode.m +7 -5
- package/ios/Nodes/REAStyleNode.h +0 -1
- package/ios/Nodes/REAStyleNode.m +2 -4
- package/ios/Nodes/REATransformNode.h +0 -1
- package/ios/Nodes/REATransformNode.m +3 -5
- package/ios/Nodes/REAValueNode.m +5 -7
- package/ios/REAEventDispatcher.m +4 -4
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +29 -38
- package/ios/REANodesManager.h +11 -19
- package/ios/REANodesManager.m +106 -130
- package/ios/REAUtils.h +5 -3
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/Transitioning/RCTConvert+REATransition.m +45 -29
- package/ios/Transitioning/REAAllTransitions.h +2 -2
- package/ios/Transitioning/REAAllTransitions.m +14 -25
- package/ios/Transitioning/REATransition.h +8 -7
- package/ios/Transitioning/REATransition.m +19 -16
- package/ios/Transitioning/REATransitionAnimation.h +1 -1
- package/ios/Transitioning/REATransitionAnimation.m +2 -3
- package/ios/Transitioning/REATransitionManager.m +3 -3
- package/ios/native/NativeMethods.h +20 -5
- package/ios/native/NativeMethods.mm +14 -6
- package/ios/native/NativeProxy.h +4 -2
- package/ios/native/NativeProxy.mm +84 -63
- package/ios/native/REAIOSErrorHandler.h +13 -10
- package/ios/native/REAIOSErrorHandler.mm +19 -15
- package/ios/native/REAIOSLogger.h +8 -8
- package/ios/native/REAIOSLogger.mm +10 -6
- package/ios/native/REAIOSScheduler.h +5 -5
- package/ios/native/REAIOSScheduler.mm +17 -10
- package/ios/native/REAInitializer.h +5 -7
- package/ios/native/REAInitializer.mm +43 -31
- package/ios/native/UIResponder+Reanimated.mm +2 -2
- package/lib/Animated.js +9 -1
- package/lib/ConfigHelper.js +121 -138
- package/lib/ReanimatedEventEmitter.js +0 -1
- package/lib/ReanimatedModule.js +0 -1
- package/lib/ReanimatedModule.macos.js +0 -1
- package/lib/ReanimatedModule.native.js +5 -6
- package/lib/ReanimatedModule.windows.js +0 -1
- package/lib/ReanimatedModuleCompat.js +64 -35
- package/lib/createAnimatedComponent.js +468 -487
- package/lib/index.js +9 -1
- package/lib/reanimated2/NativeMethods.js +7 -12
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +37 -0
- package/lib/reanimated2/NativeReanimated/index.js +15 -0
- package/lib/reanimated2/PropAdapters.js +0 -1
- package/lib/reanimated2/UpdateProps.js +6 -7
- package/lib/reanimated2/ViewDescriptorsSet.js +4 -4
- package/lib/reanimated2/WorkletEventHandler.js +15 -13
- package/lib/reanimated2/animation/delay.js +8 -2
- package/lib/reanimated2/animation/spring.js +2 -0
- package/lib/reanimated2/animation/styleAnimation.js +7 -3
- package/lib/reanimated2/animation/util.js +25 -2
- package/lib/reanimated2/core.js +41 -17
- package/lib/reanimated2/globals.d.ts +21 -1
- package/lib/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/reanimated2/hook/useAnimatedStyle.js +3 -3
- package/lib/reanimated2/index.js +1 -0
- package/lib/reanimated2/interpolation.js +95 -87
- package/lib/reanimated2/js-reanimated/JSReanimated.js +13 -10
- package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
- package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
- package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
- package/lib/reanimated2/js-reanimated/index.js +10 -8
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +33 -2
- package/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +27 -124
- package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +125 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/index.js +1 -2
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +115 -45
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +7 -2
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +21 -21
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +25 -25
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +19 -17
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +5 -5
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +9 -9
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +17 -17
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +19 -19
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +9 -9
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +33 -33
- package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +78 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +128 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +37 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +41 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +34 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +46 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/index.js +6 -0
- package/lib/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/reanimated2/mock.js +3 -1
- package/lib/reanimated2/utils.js +9 -0
- package/lib/setAndForwardRef.js +14 -48
- 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/mock.js +1 -1
- package/package.json +28 -17
- package/plugin.js +220 -39
- package/react-native-reanimated.d.ts +542 -547
- package/src/Animated.js +9 -1
- package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
- package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
- package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
- package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
- package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
- package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
- package/src/ReanimatedModuleCompat.ts +51 -0
- package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +285 -126
- package/src/reanimated2/NativeMethods.ts +34 -13
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +72 -0
- package/src/reanimated2/NativeReanimated/index.ts +18 -0
- package/src/reanimated2/PropAdapters.ts +0 -1
- package/src/reanimated2/UpdateProps.ts +31 -15
- package/src/reanimated2/ViewDescriptorsSet.ts +15 -12
- package/src/reanimated2/WorkletEventHandler.ts +41 -23
- package/src/reanimated2/animation/commonTypes.ts +4 -4
- package/src/reanimated2/animation/decay.ts +2 -2
- package/src/reanimated2/animation/delay.ts +11 -5
- package/src/reanimated2/animation/index.ts +7 -7
- package/src/reanimated2/animation/repeat.ts +4 -4
- package/src/reanimated2/animation/sequence.ts +2 -2
- package/src/reanimated2/animation/spring.ts +6 -5
- package/src/reanimated2/animation/styleAnimation.ts +27 -15
- package/src/reanimated2/animation/timing.ts +5 -5
- package/src/reanimated2/animation/util.ts +47 -8
- package/src/reanimated2/commonTypes.ts +3 -0
- package/src/reanimated2/core.ts +80 -34
- package/src/reanimated2/globals.d.ts +21 -1
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -1
- package/src/reanimated2/hook/useAnimatedRef.ts +13 -15
- package/src/reanimated2/hook/useAnimatedScrollHandler.ts +3 -3
- package/src/reanimated2/hook/useAnimatedStyle.ts +7 -7
- package/src/reanimated2/hook/utils.ts +4 -3
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/interpolation.ts +170 -103
- package/src/reanimated2/js-reanimated/JSReanimated.ts +37 -23
- package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
- package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
- package/src/reanimated2/js-reanimated/index.ts +31 -14
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +75 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +29 -159
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +169 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -2
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -9
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -5
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +162 -82
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +7 -2
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +32 -32
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +38 -38
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +34 -32
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -8
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +14 -14
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +26 -26
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +28 -28
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +14 -14
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +50 -50
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +104 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +213 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +60 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +58 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +41 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +78 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/index.ts +6 -0
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/mock.ts +3 -1
- package/src/reanimated2/utils.ts +21 -0
- package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
- package/android/react-native-reanimated-62-hermes.aar +0 -0
- package/android/react-native-reanimated-62-jsc.aar +0 -0
- package/lib/reanimated2/NativeReanimated.js +0 -48
- package/lib/reanimated2/layoutReanimation/animationBuilder/BaseBounceAnimationBuilder.js +0 -55
- package/lib/reanimated2/layoutReanimation/animationBuilder/LayoutAnimationBuilder.js +0 -165
- package/src/ReanimatedModuleCompat.js +0 -37
- package/src/reanimated2/NativeReanimated.ts +0 -70
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.tsx +0 -41
- package/src/reanimated2/layoutReanimation/animationBuilder/BaseBounceAnimationBuilder.ts +0 -82
- package/src/reanimated2/layoutReanimation/animationBuilder/LayoutAnimationBuilder.ts +0 -217
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import JSReanimated from './JSReanimated';
|
|
2
|
+
import Mapper from './Mapper';
|
|
3
|
+
|
|
4
|
+
export default class MapperRegistry<T> {
|
|
5
|
+
sortedMappers: Mapper<T>[] = [];
|
|
6
|
+
mappers: Map<number, Mapper<T>> = new Map();
|
|
7
|
+
_module: JSReanimated;
|
|
6
8
|
|
|
7
9
|
updatedSinceLastExecute = false;
|
|
8
10
|
|
|
9
|
-
constructor(module) {
|
|
11
|
+
constructor(module: JSReanimated) {
|
|
10
12
|
this._module = module;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
startMapper(mapper) {
|
|
15
|
+
startMapper(mapper: Mapper<T>): number {
|
|
14
16
|
this.mappers.set(mapper.id, mapper);
|
|
15
17
|
this.updatedSinceLastExecute = true;
|
|
16
18
|
return mapper.id;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
stopMapper(id) {
|
|
21
|
+
stopMapper(id: number): void {
|
|
20
22
|
this.mappers.delete(id);
|
|
21
23
|
this.updatedSinceLastExecute = true;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
execute() {
|
|
26
|
+
execute(): void {
|
|
25
27
|
if (this.updatedSinceLastExecute) {
|
|
26
28
|
this.updateOrder();
|
|
27
29
|
this.updatedSinceLastExecute = false;
|
|
@@ -35,10 +37,10 @@ export default class MapperRegistry {
|
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
updateOrder() {
|
|
40
|
+
updateOrder(): void {
|
|
39
41
|
const nodes = [...this.mappers.values()].map((mapper) => new Node(mapper));
|
|
40
42
|
|
|
41
|
-
const mappersById = {};
|
|
43
|
+
const mappersById: Record<number, Mapper<T>> = {};
|
|
42
44
|
this.mappers.forEach((mapper) => {
|
|
43
45
|
mappersById[mapper.id] = mapper;
|
|
44
46
|
});
|
|
@@ -75,9 +77,9 @@ export default class MapperRegistry {
|
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
const post = {};
|
|
80
|
+
const post: Record<number, number> = {};
|
|
79
81
|
let postCounter = 1;
|
|
80
|
-
const dfs = (node) => {
|
|
82
|
+
const dfs = (node: Node<T>) => {
|
|
81
83
|
const index = nodes.indexOf(node);
|
|
82
84
|
if (index === -1) {
|
|
83
85
|
// this node has already been handled
|
|
@@ -99,7 +101,8 @@ export default class MapperRegistry {
|
|
|
99
101
|
while (nodes.length) dfs(nodes[0]);
|
|
100
102
|
|
|
101
103
|
const postArray = Object.keys(post).map((key) => {
|
|
102
|
-
|
|
104
|
+
const num = parseInt(key);
|
|
105
|
+
return [num, post[num]];
|
|
103
106
|
});
|
|
104
107
|
postArray.sort((a, b) => {
|
|
105
108
|
return b[1] - a[1];
|
|
@@ -114,16 +117,16 @@ export default class MapperRegistry {
|
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
119
|
|
|
117
|
-
get needRunOnRender() {
|
|
120
|
+
get needRunOnRender(): boolean {
|
|
118
121
|
return this.updatedSinceLastExecute;
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
|
|
122
|
-
class Node {
|
|
123
|
-
mapper
|
|
124
|
-
children
|
|
125
|
+
class Node<T> {
|
|
126
|
+
mapper: Mapper<T>;
|
|
127
|
+
children: Node<T>[];
|
|
125
128
|
|
|
126
|
-
constructor(mapper
|
|
129
|
+
constructor(mapper: Mapper<T>, children = []) {
|
|
127
130
|
this.mapper = mapper;
|
|
128
131
|
this.children = children;
|
|
129
132
|
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
export default class MutableValue {
|
|
1
|
+
export default class MutableValue<T> {
|
|
4
2
|
static MUTABLE_ID = 1;
|
|
5
|
-
|
|
3
|
+
_id: number;
|
|
4
|
+
_value: T;
|
|
5
|
+
_setter: (value: T) => void;
|
|
6
6
|
_animation = null;
|
|
7
|
-
_listeners = [];
|
|
7
|
+
_listeners: (() => void)[] = [];
|
|
8
8
|
|
|
9
|
-
constructor(value, setter) {
|
|
9
|
+
constructor(value: T, setter: (value: T) => void) {
|
|
10
10
|
this._id = MutableValue.MUTABLE_ID++;
|
|
11
11
|
this._value = value;
|
|
12
12
|
this._setter = setter;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
get value() {
|
|
15
|
+
get value(): T {
|
|
16
16
|
return this._value;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
set value(nextValue) {
|
|
19
|
+
set value(nextValue: T) {
|
|
20
20
|
this._setter(nextValue);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// this changes the value finally and is supposed to be called from this._setter
|
|
24
|
-
_setValue(newValue) {
|
|
24
|
+
_setValue(newValue: T): void {
|
|
25
25
|
this._value = newValue;
|
|
26
26
|
this._triggerListener();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
addListener(listener) {
|
|
29
|
+
addListener(listener: () => void): void {
|
|
30
30
|
this._listeners.push(listener);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
_triggerListener() {
|
|
33
|
+
_triggerListener(): void {
|
|
34
34
|
for (let i = 0, len = this._listeners.length; i < len; ++i) {
|
|
35
35
|
this._listeners[i]();
|
|
36
36
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
-
// @ts-nocheck
|
|
3
1
|
import JSReanimated from './JSReanimated';
|
|
4
2
|
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
3
|
+
import { AnimatedStyle, StyleProps } from '../commonTypes';
|
|
5
4
|
|
|
6
5
|
const reanimatedJS = new JSReanimated();
|
|
7
6
|
|
|
7
|
+
interface JSReanimatedComponent {
|
|
8
|
+
previousStyle: StyleProps;
|
|
9
|
+
setNativeProps: (style: StyleProps) => void;
|
|
10
|
+
props: Record<string, string | number>;
|
|
11
|
+
_touchableNode: {
|
|
12
|
+
setAttribute: (key: string, props: unknown) => void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
if (shouldBeUseWeb()) {
|
|
9
17
|
global._frameTimestamp = null;
|
|
10
18
|
global._setGlobalConsole = (_val) => {
|
|
@@ -28,12 +36,21 @@ if (shouldBeUseWeb()) {
|
|
|
28
36
|
"[Reanimated] You can't use 'scrollTo' method with Chrome Debugger or with web version"
|
|
29
37
|
);
|
|
30
38
|
};
|
|
39
|
+
global._setGestureState = () => {
|
|
40
|
+
console.warn(
|
|
41
|
+
"[Reanimated] You can't use 'setGestureState' method with Chrome Debugger or with web version"
|
|
42
|
+
);
|
|
43
|
+
};
|
|
31
44
|
}
|
|
32
45
|
|
|
33
|
-
export const _updatePropsJS = (
|
|
34
|
-
|
|
46
|
+
export const _updatePropsJS = (
|
|
47
|
+
updates: StyleProps | AnimatedStyle,
|
|
48
|
+
viewRef: { _component?: JSReanimatedComponent }
|
|
49
|
+
): void => {
|
|
50
|
+
if (viewRef._component) {
|
|
51
|
+
const component = viewRef._component;
|
|
35
52
|
const [rawStyles] = Object.keys(updates).reduce(
|
|
36
|
-
(acc, key) => {
|
|
53
|
+
(acc: [StyleProps, AnimatedStyle], key) => {
|
|
37
54
|
const value = updates[key];
|
|
38
55
|
const index = typeof value === 'function' ? 1 : 0;
|
|
39
56
|
acc[index][key] = value;
|
|
@@ -42,18 +59,15 @@ export const _updatePropsJS = (updates, viewRef) => {
|
|
|
42
59
|
[{}, {}]
|
|
43
60
|
);
|
|
44
61
|
|
|
45
|
-
if (typeof
|
|
46
|
-
setNativeProps(
|
|
47
|
-
} else if (Object.keys(
|
|
48
|
-
Object.keys(
|
|
62
|
+
if (typeof component.setNativeProps === 'function') {
|
|
63
|
+
setNativeProps(component, rawStyles);
|
|
64
|
+
} else if (Object.keys(component.props).length > 0) {
|
|
65
|
+
Object.keys(component.props).forEach((key) => {
|
|
49
66
|
if (!rawStyles[key]) {
|
|
50
67
|
return;
|
|
51
68
|
}
|
|
52
69
|
const dashedKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
|
|
53
|
-
|
|
54
|
-
dashedKey,
|
|
55
|
-
rawStyles[key]
|
|
56
|
-
);
|
|
70
|
+
component._touchableNode.setAttribute(dashedKey, rawStyles[key]);
|
|
57
71
|
});
|
|
58
72
|
} else {
|
|
59
73
|
console.warn('It is not possible to manipulate component');
|
|
@@ -61,7 +75,10 @@ export const _updatePropsJS = (updates, viewRef) => {
|
|
|
61
75
|
}
|
|
62
76
|
};
|
|
63
77
|
|
|
64
|
-
const setNativeProps = (
|
|
78
|
+
const setNativeProps = (
|
|
79
|
+
component: JSReanimatedComponent,
|
|
80
|
+
style: StyleProps
|
|
81
|
+
): void => {
|
|
65
82
|
const previousStyle = component.previousStyle ? component.previousStyle : {};
|
|
66
83
|
const currentStyle = { ...previousStyle, ...style };
|
|
67
84
|
component.previousStyle = currentStyle;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* global _stopObservingProgress, _startObservingProgress */
|
|
2
|
+
import { runOnUI } from '../core';
|
|
3
|
+
import { withStyleAnimation } from '../animation/styleAnimation';
|
|
4
|
+
import { ColorProperties } from '../UpdateProps';
|
|
5
|
+
import { processColor } from '../Colors';
|
|
6
|
+
|
|
7
|
+
runOnUI(() => {
|
|
8
|
+
'worklet';
|
|
9
|
+
|
|
10
|
+
const configs: Record<string, any> = {};
|
|
11
|
+
const enteringAnimationForTag: Record<string, any> = {};
|
|
12
|
+
|
|
13
|
+
global.LayoutAnimationRepository = {
|
|
14
|
+
configs,
|
|
15
|
+
registerConfig(tag, config) {
|
|
16
|
+
configs[tag] = config;
|
|
17
|
+
enteringAnimationForTag[tag] = null;
|
|
18
|
+
},
|
|
19
|
+
removeConfig(tag) {
|
|
20
|
+
delete configs[tag];
|
|
21
|
+
delete enteringAnimationForTag[tag];
|
|
22
|
+
},
|
|
23
|
+
startAnimationForTag(tag, type, yogaValues) {
|
|
24
|
+
if (configs[tag] == null) {
|
|
25
|
+
return; // :(
|
|
26
|
+
}
|
|
27
|
+
const style = configs[tag][type](yogaValues);
|
|
28
|
+
let currentAnimation = style.animations;
|
|
29
|
+
if (type === 'entering') {
|
|
30
|
+
enteringAnimationForTag[tag] = style;
|
|
31
|
+
} else if (type === 'layout' && enteringAnimationForTag[tag] !== null) {
|
|
32
|
+
const entryAniamtion = enteringAnimationForTag[tag].animations;
|
|
33
|
+
const layoutAnimation = style.animations;
|
|
34
|
+
currentAnimation = {};
|
|
35
|
+
for (const key in entryAniamtion) {
|
|
36
|
+
currentAnimation[key] = entryAniamtion[key];
|
|
37
|
+
}
|
|
38
|
+
for (const key in layoutAnimation) {
|
|
39
|
+
currentAnimation[key] = layoutAnimation[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const sv: { value: boolean; _value: boolean } = configs[tag].sv;
|
|
44
|
+
_stopObservingProgress(tag, false);
|
|
45
|
+
_startObservingProgress(tag, sv);
|
|
46
|
+
|
|
47
|
+
const backupColor: Record<string, string> = {};
|
|
48
|
+
for (const key in style.initialValues) {
|
|
49
|
+
if (ColorProperties.includes(key)) {
|
|
50
|
+
const value = style.initialValues[key];
|
|
51
|
+
backupColor[key] = value;
|
|
52
|
+
style.initialValues[key] = processColor(value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
sv.value = Object.assign({}, sv._value, style.initialValues);
|
|
57
|
+
_stopObservingProgress(tag, false);
|
|
58
|
+
const animation = withStyleAnimation(currentAnimation);
|
|
59
|
+
|
|
60
|
+
animation.callback = (finished?: boolean) => {
|
|
61
|
+
if (finished) {
|
|
62
|
+
_stopObservingProgress(tag, finished);
|
|
63
|
+
}
|
|
64
|
+
style.callback && style.callback(finished);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
if (backupColor) {
|
|
68
|
+
configs[tag].sv._value = { ...configs[tag].sv.value, ...backupColor };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
configs[tag].sv.value = animation;
|
|
72
|
+
_startObservingProgress(tag, sv);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
})();
|
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import { withDelay
|
|
1
|
+
import { withDelay } from '../../animation';
|
|
2
2
|
import {
|
|
3
3
|
EntryExitAnimationFunction,
|
|
4
4
|
AnimationFunction,
|
|
5
|
-
|
|
6
|
-
EntryExitAnimationBuild,
|
|
7
|
-
LayoutAnimationAndConfig,
|
|
5
|
+
LayoutAnimationFunction,
|
|
8
6
|
} from './commonTypes';
|
|
9
|
-
|
|
7
|
+
|
|
10
8
|
export class BaseAnimationBuilder {
|
|
11
9
|
durationV?: number;
|
|
12
|
-
easingV?: EasingFn;
|
|
13
10
|
delayV?: number;
|
|
14
|
-
|
|
15
|
-
type?: AnimationFunction;
|
|
16
|
-
dampingV?: number;
|
|
17
|
-
massV?: number;
|
|
18
|
-
stiffnessV?: number;
|
|
19
|
-
overshootClampingV?: number;
|
|
20
|
-
restDisplacementThresholdV?: number;
|
|
21
|
-
restSpeedThresholdV?: number;
|
|
11
|
+
randomizeDelay = false;
|
|
22
12
|
callbackV?: (finished: boolean) => void;
|
|
23
13
|
|
|
24
14
|
static createInstance: () => BaseAnimationBuilder;
|
|
25
|
-
build
|
|
15
|
+
build = (): EntryExitAnimationFunction | LayoutAnimationFunction => {
|
|
26
16
|
throw Error('Unimplemented method in child class.');
|
|
27
17
|
};
|
|
28
18
|
|
|
@@ -36,16 +26,6 @@ export class BaseAnimationBuilder {
|
|
|
36
26
|
return this;
|
|
37
27
|
}
|
|
38
28
|
|
|
39
|
-
static easing(easingFunction: EasingFn): BaseAnimationBuilder {
|
|
40
|
-
const instance = this.createInstance();
|
|
41
|
-
return instance.easing(easingFunction);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
easing(easingFunction: EasingFn): BaseAnimationBuilder {
|
|
45
|
-
this.easingV = easingFunction;
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
29
|
static delay(delayMs: number): BaseAnimationBuilder {
|
|
50
30
|
const instance = this.createInstance();
|
|
51
31
|
return instance.delay(delayMs);
|
|
@@ -56,110 +36,47 @@ export class BaseAnimationBuilder {
|
|
|
56
36
|
return this;
|
|
57
37
|
}
|
|
58
38
|
|
|
59
|
-
static
|
|
60
|
-
|
|
61
|
-
return instance.rotate(degree);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
rotate(degree: string): BaseAnimationBuilder {
|
|
65
|
-
this.rotateV = degree;
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static springify(): BaseAnimationBuilder {
|
|
70
|
-
const instance = this.createInstance();
|
|
71
|
-
return instance.springify();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
springify(): BaseAnimationBuilder {
|
|
75
|
-
this.type = withSpring as AnimationFunction;
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static damping(damping: number): BaseAnimationBuilder {
|
|
80
|
-
const instance = this.createInstance();
|
|
81
|
-
return instance.damping(damping);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
damping(damping: number): BaseAnimationBuilder {
|
|
85
|
-
this.dampingV = damping;
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
static mass(mass: number): BaseAnimationBuilder {
|
|
90
|
-
const instance = this.createInstance();
|
|
91
|
-
return instance.mass(mass);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
mass(mass: number): BaseAnimationBuilder {
|
|
95
|
-
this.massV = mass;
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static stiffness(stiffness: number): BaseAnimationBuilder {
|
|
100
|
-
const instance = this.createInstance();
|
|
101
|
-
return instance.stiffness(stiffness);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
stiffness(stiffness: number): BaseAnimationBuilder {
|
|
105
|
-
this.stiffnessV = stiffness;
|
|
106
|
-
return this;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
static overshootClamping(overshootClamping: number): BaseAnimationBuilder {
|
|
110
|
-
const instance = this.createInstance();
|
|
111
|
-
return instance.overshootClamping(overshootClamping);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
overshootClamping(overshootClamping: number): BaseAnimationBuilder {
|
|
115
|
-
this.overshootClampingV = overshootClamping;
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
static restDisplacementThreshold(
|
|
120
|
-
restDisplacementThreshold: number
|
|
39
|
+
static withCallback(
|
|
40
|
+
callback: (finished: boolean) => void
|
|
121
41
|
): BaseAnimationBuilder {
|
|
122
42
|
const instance = this.createInstance();
|
|
123
|
-
return instance.
|
|
43
|
+
return instance.withCallback(callback);
|
|
124
44
|
}
|
|
125
45
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
): BaseAnimationBuilder {
|
|
129
|
-
this.restDisplacementThresholdV = restDisplacementThreshold;
|
|
46
|
+
withCallback(callback: (finsihed: boolean) => void): BaseAnimationBuilder {
|
|
47
|
+
this.callbackV = callback;
|
|
130
48
|
return this;
|
|
131
49
|
}
|
|
132
50
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return
|
|
51
|
+
// 300ms is the default animation duration. If any animation has different default has to override this method.
|
|
52
|
+
static getDuration(): number {
|
|
53
|
+
return 300;
|
|
136
54
|
}
|
|
137
55
|
|
|
138
|
-
|
|
139
|
-
this.
|
|
140
|
-
return this;
|
|
56
|
+
getDuration(): number {
|
|
57
|
+
return this.durationV ?? 300;
|
|
141
58
|
}
|
|
142
59
|
|
|
143
|
-
static
|
|
144
|
-
callback: (finished: boolean) => void
|
|
145
|
-
): BaseAnimationBuilder {
|
|
60
|
+
static randomDelay(): BaseAnimationBuilder {
|
|
146
61
|
const instance = this.createInstance();
|
|
147
|
-
return instance.
|
|
62
|
+
return instance.randomDelay();
|
|
148
63
|
}
|
|
149
64
|
|
|
150
|
-
|
|
151
|
-
this.
|
|
65
|
+
randomDelay(): BaseAnimationBuilder {
|
|
66
|
+
this.randomizeDelay = true;
|
|
152
67
|
return this;
|
|
153
68
|
}
|
|
154
69
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return
|
|
70
|
+
// when randomizeDelay is set to true, randomize delay between 0 and provided value (or 1000ms if delay is not provided)
|
|
71
|
+
getDelay(): number {
|
|
72
|
+
return this.randomizeDelay
|
|
73
|
+
? Math.random() * (this.delayV ?? 1000)
|
|
74
|
+
: this.delayV ?? 0;
|
|
158
75
|
}
|
|
159
76
|
|
|
160
77
|
getDelayFunction(): AnimationFunction {
|
|
161
|
-
const
|
|
162
|
-
return
|
|
78
|
+
const isDelayProvided = this.randomizeDelay || this.delayV;
|
|
79
|
+
return isDelayProvided
|
|
163
80
|
? withDelay
|
|
164
81
|
: (_, animation) => {
|
|
165
82
|
'worklet';
|
|
@@ -167,55 +84,8 @@ export class BaseAnimationBuilder {
|
|
|
167
84
|
};
|
|
168
85
|
}
|
|
169
86
|
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const rotate = this.rotateV;
|
|
174
|
-
const type = this.type ? this.type : (withTiming as AnimationFunction);
|
|
175
|
-
const damping = this.dampingV;
|
|
176
|
-
const mass = this.massV;
|
|
177
|
-
const stiffness = this.stiffnessV;
|
|
178
|
-
const overshootClamping = this.overshootClampingV;
|
|
179
|
-
const restDisplacementThreshold = this.restDisplacementThresholdV;
|
|
180
|
-
const restSpeedThreshold = this.restSpeedThresholdV;
|
|
181
|
-
|
|
182
|
-
const animation = type;
|
|
183
|
-
|
|
184
|
-
const config: BaseBuilderAnimationConfig = {};
|
|
185
|
-
|
|
186
|
-
if (type === withTiming) {
|
|
187
|
-
if (easing) {
|
|
188
|
-
config.easing = easing;
|
|
189
|
-
}
|
|
190
|
-
if (duration) {
|
|
191
|
-
config.duration = duration;
|
|
192
|
-
}
|
|
193
|
-
if (rotate) {
|
|
194
|
-
config.rotate = rotate;
|
|
195
|
-
}
|
|
196
|
-
} else {
|
|
197
|
-
if (damping) {
|
|
198
|
-
config.damping = damping;
|
|
199
|
-
}
|
|
200
|
-
if (mass) {
|
|
201
|
-
config.mass = mass;
|
|
202
|
-
}
|
|
203
|
-
if (stiffness) {
|
|
204
|
-
config.stiffness = stiffness;
|
|
205
|
-
}
|
|
206
|
-
if (overshootClamping) {
|
|
207
|
-
config.overshootClamping = overshootClamping;
|
|
208
|
-
}
|
|
209
|
-
if (restDisplacementThreshold) {
|
|
210
|
-
config.restDisplacementThreshold = restDisplacementThreshold;
|
|
211
|
-
}
|
|
212
|
-
if (restSpeedThreshold) {
|
|
213
|
-
config.restSpeedThreshold = restSpeedThreshold;
|
|
214
|
-
}
|
|
215
|
-
if (rotate) {
|
|
216
|
-
config.rotate = rotate;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return [animation, config];
|
|
87
|
+
static build(): EntryExitAnimationFunction | LayoutAnimationFunction {
|
|
88
|
+
const instance = this.createInstance();
|
|
89
|
+
return instance.build();
|
|
220
90
|
}
|
|
221
91
|
}
|