react-native-reanimated 3.0.2 → 3.1.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/Fabric/FabricUtils.h +1 -1
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -27
- package/Common/cpp/SharedItems/Shareables.h +22 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +2 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +4 -1
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
- package/Common/cpp/Tools/SingleInstanceChecker.h +14 -2
- package/RNReanimated.podspec +5 -2
- package/android/CMakeLists.txt +4 -0
- package/android/build.gradle +18 -10
- package/android/src/main/cpp/NativeProxy.cpp +316 -337
- package/android/src/main/cpp/NativeProxy.h +53 -11
- package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +7 -12
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +11 -8
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +21 -14
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +0 -3
- package/ios/Fabric/REAInitializerRCTFabricSurface.mm +1 -0
- package/ios/REANodesManager.h +1 -0
- package/ios/REANodesManager.mm +30 -4
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +51 -130
- package/ios/native/NativeMethods.mm +1 -1
- package/ios/native/NativeProxy.mm +4 -1
- package/ios/native/REAIOSErrorHandler.mm +1 -1
- package/ios/native/REAIOSLogger.mm +1 -1
- package/ios/native/REAIOSScheduler.mm +1 -1
- package/ios/native/REAInitializer.mm +1 -1
- package/ios/native/REAMessageThread.mm +2 -2
- package/lib/commonjs/Animated.js +0 -8
- package/lib/commonjs/Animated.js.map +1 -1
- package/lib/commonjs/ConfigHelper.js +8 -19
- package/lib/commonjs/ConfigHelper.js.map +1 -1
- package/lib/commonjs/createAnimatedComponent.js +20 -158
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/index.js +0 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +0 -7
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/reanimated2/Bezier.js +14 -34
- package/lib/commonjs/reanimated2/Bezier.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +60 -132
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/Easing.js +81 -34
- package/lib/commonjs/reanimated2/Easing.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeMethods.js +8 -20
- package/lib/commonjs/reanimated2/NativeMethods.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +5 -31
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/index.js +0 -7
- package/lib/commonjs/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/PlatformChecker.js +0 -6
- package/lib/commonjs/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/commonjs/reanimated2/PropAdapters.js +10 -12
- package/lib/commonjs/reanimated2/PropAdapters.js.map +1 -1
- package/lib/commonjs/reanimated2/UpdateProps.js +3 -12
- package/lib/commonjs/reanimated2/UpdateProps.js.map +1 -1
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +0 -10
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -22
- package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/decay.js +7 -18
- package/lib/commonjs/reanimated2/animation/decay.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/delay.js +0 -11
- package/lib/commonjs/reanimated2/animation/delay.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/index.js +0 -8
- package/lib/commonjs/reanimated2/animation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/repeat.js +6 -22
- package/lib/commonjs/reanimated2/animation/repeat.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/sequence.js +3 -20
- package/lib/commonjs/reanimated2/animation/sequence.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/spring.js +11 -23
- package/lib/commonjs/reanimated2/animation/spring.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +3 -35
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/timing.js +0 -11
- package/lib/commonjs/reanimated2/animation/timing.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +11 -41
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +16 -23
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/component/FlatList.js +0 -16
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/component/Image.js +0 -4
- package/lib/commonjs/reanimated2/component/Image.js.map +1 -1
- package/lib/commonjs/reanimated2/component/ScrollView.js +0 -4
- package/lib/commonjs/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/commonjs/reanimated2/component/Text.js +0 -4
- package/lib/commonjs/reanimated2/component/Text.js.map +1 -1
- package/lib/commonjs/reanimated2/component/View.js +0 -4
- package/lib/commonjs/reanimated2/component/View.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +6 -48
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +3 -14
- package/lib/commonjs/reanimated2/errors.js.map +1 -1
- package/lib/commonjs/reanimated2/fabricUtils.js +3 -5
- package/lib/commonjs/reanimated2/fabricUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/fabricUtils.web.js +1 -3
- package/lib/commonjs/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -12
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -17
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/Hooks.js +0 -5
- package/lib/commonjs/reanimated2/hook/Hooks.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -12
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js +4 -17
- package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +2 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +1 -11
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +0 -12
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js +2 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +8 -23
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +13 -71
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +4 -13
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useFrameCallback.js +0 -5
- package/lib/commonjs/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +0 -7
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useSharedValue.js +2 -7
- package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +8 -39
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +0 -26
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +21 -43
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +6 -43
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolation.js +14 -29
- package/lib/commonjs/reanimated2/interpolation.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +11 -44
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +15 -39
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +9 -28
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js +7 -37
- package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js +5 -18
- package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +2 -9
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +3 -14
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -26
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -49
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -43
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -5
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +0 -4
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +4 -23
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -74
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -53
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -63
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -26
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -13
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -43
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -43
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -83
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js +0 -20
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -22
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -29
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -9
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -11
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -8
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -12
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js +0 -12
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +0 -9
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -17
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/commonjs/reanimated2/mappers.js +26 -32
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +5 -15
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +2 -28
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js +0 -2
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js +31 -0
- package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +0 -2
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/jsVersion.js +14 -0
- package/lib/commonjs/reanimated2/platform-specific/jsVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +0 -1
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/shareables.js +92 -49
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +42 -46
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +0 -5
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +6 -21
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/commonjs/setAndForwardRef.js +3 -3
- package/lib/commonjs/setAndForwardRef.js.map +1 -1
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/ConfigHelper.js +9 -15
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +20 -139
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/reanimated2/Bezier.js +14 -33
- package/lib/module/reanimated2/Bezier.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +59 -109
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +37 -33
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/NativeMethods.js +8 -15
- package/lib/module/reanimated2/NativeMethods.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +5 -27
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.js +0 -2
- package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/PropAdapters.js +12 -10
- package/lib/module/reanimated2/PropAdapters.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js +3 -5
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js +0 -6
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +5 -18
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/decay.js +7 -15
- package/lib/module/reanimated2/animation/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/delay.js +0 -9
- package/lib/module/reanimated2/animation/delay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/repeat.js +6 -20
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +3 -18
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js +11 -21
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +7 -31
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +0 -8
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +10 -33
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +12 -19
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +0 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/Image.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/component/Text.js.map +1 -1
- package/lib/module/reanimated2/component/View.js.map +1 -1
- package/lib/module/reanimated2/core.js +6 -22
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +3 -13
- package/lib/module/reanimated2/errors.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +3 -3
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -8
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -15
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/Hooks.js +3 -2
- package/lib/module/reanimated2/hook/Hooks.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +3 -14
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +2 -5
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -7
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +0 -6
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +2 -7
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +9 -20
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +13 -59
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +4 -8
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +0 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js +2 -3
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +8 -21
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +23 -37
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +5 -34
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +13 -28
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +11 -35
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +15 -35
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +9 -23
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +7 -35
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/MutableValue.js +5 -16
- package/lib/module/reanimated2/js-reanimated/MutableValue.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +2 -6
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +3 -9
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -23
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -45
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -39
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +3 -3
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +4 -19
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -52
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -32
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -38
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -16
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -8
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -14
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -14
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -50
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -17
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -23
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -5
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -6
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -5
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -8
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -13
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +26 -25
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +5 -15
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +2 -19
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +24 -0
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +0 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +7 -0
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +96 -44
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +39 -33
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +0 -3
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +6 -19
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/setAndForwardRef.js +3 -2
- package/lib/module/setAndForwardRef.js.map +1 -1
- package/package.json +46 -40
- package/plugin/.eslintrc.js +7 -0
- package/plugin/README.md +241 -0
- package/plugin/build/plugin.js +714 -0
- package/plugin/build/plugin.js.map +7 -0
- package/plugin/index.js +1 -807
- package/plugin/package.json +23 -0
- package/plugin/src/buildWorkletString.ts +213 -0
- package/plugin/src/commonObjects.ts +60 -0
- package/plugin/src/injectVersion.ts +37 -0
- package/plugin/src/makeWorklet.ts +375 -0
- package/plugin/src/plugin.ts +49 -0
- package/plugin/src/processForCalleesWorklets.ts +106 -0
- package/plugin/src/processIfGestureHandlerEventCallbackFunctionNode.ts +156 -0
- package/plugin/src/processIfWorkletFunction.ts +55 -0
- package/plugin/src/processIfWorkletNode.ts +44 -0
- package/plugin/src/processInlineStylesWarning.ts +129 -0
- package/plugin/src/processWorkletObjectMethod.ts +31 -0
- package/plugin/src/types.ts +15 -0
- package/plugin/src/utils.ts +6 -0
- package/plugin/tsconfig.json +15 -0
- package/plugin/yarn.lock +2193 -0
- package/react-native-reanimated.d.ts +1 -0
- package/scripts/reanimated_utils.rb +2 -2
- package/src/createAnimatedComponent.tsx +2 -3
- package/src/reanimated2/Easing.ts +19 -0
- package/src/reanimated2/NativeMethods.ts +9 -4
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +2 -2
- package/src/reanimated2/UpdateProps.ts +2 -2
- package/src/reanimated2/animation/decay.ts +7 -1
- package/src/reanimated2/animation/styleAnimation.ts +5 -1
- package/src/reanimated2/core.ts +4 -4
- package/src/reanimated2/errors.ts +1 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +12 -4
- package/src/reanimated2/globals.d.ts +71 -112
- package/src/reanimated2/hook/commonTypes.ts +1 -1
- package/src/reanimated2/hook/useAnimatedReaction.ts +2 -2
- package/src/reanimated2/hook/useAnimatedSensor.ts +2 -2
- package/src/reanimated2/initializers.ts +11 -8
- package/src/reanimated2/jestUtils.ts +0 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +5 -1
- package/src/reanimated2/js-reanimated/index.ts +1 -1
- package/src/reanimated2/mappers.ts +26 -4
- package/src/reanimated2/mock.ts +1 -0
- package/src/reanimated2/platform-specific/checkCppVersion.ts +29 -0
- package/src/reanimated2/platform-specific/jsVersion.ts +6 -0
- package/src/reanimated2/shareables.ts +107 -8
- package/src/reanimated2/threads.ts +36 -17
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +0 -42
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +0 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +0 -35
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +0 -1
- package/src/reanimated2/platform-specific/checkVersion.ts +0 -39
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineAnimation } from './util';
|
|
2
2
|
import { withTiming } from './timing';
|
|
3
3
|
import { ColorProperties } from '../UpdateProps';
|
|
4
|
-
import { processColor } from '../Colors';
|
|
5
|
-
// if path cannot be resolved returns undefined
|
|
4
|
+
import { processColor } from '../Colors';
|
|
6
5
|
|
|
6
|
+
// resolves path to value for nested objects
|
|
7
|
+
// if path cannot be resolved returns undefined
|
|
7
8
|
export function resolvePath(obj, path) {
|
|
8
9
|
'worklet';
|
|
9
10
|
|
|
@@ -11,24 +12,23 @@ export function resolvePath(obj, path) {
|
|
|
11
12
|
return keys.reduce((acc, current) => {
|
|
12
13
|
if (Array.isArray(acc) && typeof current === 'number') {
|
|
13
14
|
return acc[current];
|
|
14
|
-
} else if (typeof acc === 'object' && current in acc) {
|
|
15
|
+
} else if (acc !== null && typeof acc === 'object' && current in acc) {
|
|
15
16
|
return acc[current];
|
|
16
17
|
}
|
|
17
|
-
|
|
18
18
|
return undefined;
|
|
19
19
|
}, obj);
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// set value at given path
|
|
21
23
|
|
|
22
24
|
export function setPath(obj, path, value) {
|
|
23
25
|
'worklet';
|
|
24
26
|
|
|
25
27
|
const keys = Array.isArray(path) ? path : [path];
|
|
26
28
|
let currObj = obj;
|
|
27
|
-
|
|
28
29
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
29
30
|
// creates entry if there isn't one
|
|
30
31
|
currObj = currObj;
|
|
31
|
-
|
|
32
32
|
if (!(keys[i] in currObj)) {
|
|
33
33
|
// if next key is a number create an array
|
|
34
34
|
if (typeof keys[i + 1] === 'number') {
|
|
@@ -37,10 +37,8 @@ export function setPath(obj, path, value) {
|
|
|
37
37
|
currObj[keys[i]] = {};
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
40
|
currObj = currObj[keys[i]];
|
|
42
41
|
}
|
|
43
|
-
|
|
44
42
|
currObj[keys[keys.length - 1]] = value;
|
|
45
43
|
}
|
|
46
44
|
export function withStyleAnimation(styleAnimations) {
|
|
@@ -55,10 +53,8 @@ export function withStyleAnimation(styleAnimations) {
|
|
|
55
53
|
value: animation.styleAnimations,
|
|
56
54
|
path: []
|
|
57
55
|
}];
|
|
58
|
-
|
|
59
56
|
while (entriesToCheck.length > 0) {
|
|
60
57
|
const currentEntry = entriesToCheck.pop();
|
|
61
|
-
|
|
62
58
|
if (Array.isArray(currentEntry.value)) {
|
|
63
59
|
for (let index = 0; index < currentEntry.value.length; index++) {
|
|
64
60
|
entriesToCheck.push({
|
|
@@ -76,43 +72,33 @@ export function withStyleAnimation(styleAnimations) {
|
|
|
76
72
|
}
|
|
77
73
|
} else {
|
|
78
74
|
const currentStyleAnimation = currentEntry.value;
|
|
79
|
-
|
|
80
75
|
if (currentStyleAnimation.finished) {
|
|
81
76
|
continue;
|
|
82
77
|
}
|
|
83
|
-
|
|
84
78
|
const finished = currentStyleAnimation.onFrame(currentStyleAnimation, now);
|
|
85
|
-
|
|
86
79
|
if (finished) {
|
|
87
80
|
currentStyleAnimation.finished = true;
|
|
88
|
-
|
|
89
81
|
if (currentStyleAnimation.callback) {
|
|
90
82
|
currentStyleAnimation.callback(true);
|
|
91
83
|
}
|
|
92
84
|
} else {
|
|
93
85
|
stillGoing = true;
|
|
94
86
|
}
|
|
95
|
-
|
|
96
87
|
if (ColorProperties.includes(currentEntry.path[0])) {
|
|
97
88
|
currentStyleAnimation.current = processColor(currentStyleAnimation.current);
|
|
98
89
|
}
|
|
99
|
-
|
|
100
90
|
setPath(animation.current, currentEntry.path, currentStyleAnimation.current);
|
|
101
91
|
}
|
|
102
92
|
}
|
|
103
|
-
|
|
104
93
|
return !stillGoing;
|
|
105
94
|
};
|
|
106
|
-
|
|
107
95
|
const onStart = (animation, value, now, previousAnimation) => {
|
|
108
96
|
const entriesToCheck = [{
|
|
109
97
|
value: styleAnimations,
|
|
110
98
|
path: []
|
|
111
99
|
}];
|
|
112
|
-
|
|
113
100
|
while (entriesToCheck.length > 0) {
|
|
114
101
|
const currentEntry = entriesToCheck.pop();
|
|
115
|
-
|
|
116
102
|
if (Array.isArray(currentEntry.value)) {
|
|
117
103
|
for (let index = 0; index < currentEntry.value.length; index++) {
|
|
118
104
|
entriesToCheck.push({
|
|
@@ -130,18 +116,14 @@ export function withStyleAnimation(styleAnimations) {
|
|
|
130
116
|
} else {
|
|
131
117
|
const prevAnimation = resolvePath(previousAnimation === null || previousAnimation === void 0 ? void 0 : previousAnimation.styleAnimations, currentEntry.path);
|
|
132
118
|
let prevVal = resolvePath(value, currentEntry.path);
|
|
133
|
-
|
|
134
119
|
if (prevAnimation && !prevVal) {
|
|
135
120
|
prevVal = prevAnimation.current;
|
|
136
121
|
}
|
|
137
|
-
|
|
138
122
|
if (prevVal === undefined) {
|
|
139
123
|
console.warn(`Initial values for animation are missing for property ${currentEntry.path.join('.')}`);
|
|
140
124
|
}
|
|
141
|
-
|
|
142
125
|
setPath(animation.current, currentEntry.path, prevVal);
|
|
143
126
|
let currentAnimation;
|
|
144
|
-
|
|
145
127
|
if (typeof currentEntry.value !== 'object' || !currentEntry.value.onStart) {
|
|
146
128
|
currentAnimation = withTiming(currentEntry.value, {
|
|
147
129
|
duration: 0
|
|
@@ -150,19 +132,15 @@ export function withStyleAnimation(styleAnimations) {
|
|
|
150
132
|
} else {
|
|
151
133
|
currentAnimation = currentEntry.value;
|
|
152
134
|
}
|
|
153
|
-
|
|
154
135
|
currentAnimation.onStart(currentAnimation, prevVal, now, prevAnimation);
|
|
155
136
|
}
|
|
156
137
|
}
|
|
157
138
|
};
|
|
158
|
-
|
|
159
139
|
const callback = finished => {
|
|
160
140
|
if (!finished) {
|
|
161
141
|
const animationsToCheck = [styleAnimations];
|
|
162
|
-
|
|
163
142
|
while (animationsToCheck.length > 0) {
|
|
164
143
|
const currentAnimation = animationsToCheck.pop();
|
|
165
|
-
|
|
166
144
|
if (Array.isArray(currentAnimation)) {
|
|
167
145
|
for (const element of currentAnimation) {
|
|
168
146
|
animationsToCheck.push(element);
|
|
@@ -173,7 +151,6 @@ export function withStyleAnimation(styleAnimations) {
|
|
|
173
151
|
}
|
|
174
152
|
} else {
|
|
175
153
|
const currentStyleAnimation = currentAnimation;
|
|
176
|
-
|
|
177
154
|
if (!currentStyleAnimation.finished && currentStyleAnimation.callback) {
|
|
178
155
|
currentStyleAnimation.callback(false);
|
|
179
156
|
}
|
|
@@ -181,7 +158,6 @@ export function withStyleAnimation(styleAnimations) {
|
|
|
181
158
|
}
|
|
182
159
|
}
|
|
183
160
|
};
|
|
184
|
-
|
|
185
161
|
return {
|
|
186
162
|
isHigherOrder: true,
|
|
187
163
|
onFrame,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defineAnimation","withTiming","ColorProperties","processColor","resolvePath","obj","path","keys","Array","isArray","reduce","acc","current","undefined","setPath","value","currObj","i","length","withStyleAnimation","styleAnimations","onFrame","animation","now","stillGoing","entriesToCheck","currentEntry","pop","index","push","concat","key","Object","currentStyleAnimation","finished","callback","includes","onStart","previousAnimation","prevAnimation","prevVal","console","warn","join","currentAnimation","duration","animationsToCheck","element","values","isHigherOrder"],"sources":["styleAnimation.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport {\n Timestamp,\n AnimatableValue,\n AnimationObject,\n Animation,\n AnimatedStyle,\n NestedObject,\n NestedObjectValues,\n} from '../commonTypes';\nimport { StyleLayoutAnimation } from './commonTypes';\nimport { withTiming } from './timing';\nimport { ColorProperties } from '../UpdateProps';\nimport { processColor } from '../Colors';\n\n// resolves path to value for nested objects\n// if path cannot be resolved returns undefined\nexport function resolvePath<T>(\n obj: NestedObject<T>,\n path: AnimatableValue[] | AnimatableValue\n): NestedObjectValues<T> | undefined {\n 'worklet';\n const keys: AnimatableValue[] = Array.isArray(path) ? path : [path];\n return keys.reduce<NestedObjectValues<T> | undefined>((acc, current) => {\n if (Array.isArray(acc) && typeof current === 'number') {\n return acc[current];\n } else if (typeof acc === 'object' && (current as number | string) in acc) {\n return (acc as { [key: string]: NestedObjectValues<T> })[\n current as number | string\n ];\n }\n return undefined;\n }, obj);\n}\n\n// set value at given path\ntype Path = Array<string | number> | string | number;\nexport function setPath<T>(\n obj: NestedObject<T>,\n path: Path,\n value: NestedObjectValues<T>\n): void {\n 'worklet';\n const keys: Path = Array.isArray(path) ? path : [path];\n let currObj: NestedObjectValues<T> = obj;\n for (let i = 0; i < keys.length - 1; i++) {\n // creates entry if there isn't one\n currObj = currObj as { [key: string]: NestedObjectValues<T> };\n if (!(keys[i] in currObj)) {\n // if next key is a number create an array\n if (typeof keys[i + 1] === 'number') {\n currObj[keys[i]] = [];\n } else {\n currObj[keys[i]] = {};\n }\n }\n currObj = currObj[keys[i]];\n }\n\n (currObj as { [key: string]: NestedObjectValues<T> })[keys[keys.length - 1]] =\n value;\n}\n\ninterface NestedObjectEntry<T> {\n value: NestedObjectValues<T>;\n path: (string | number)[];\n}\n\nexport function withStyleAnimation(\n styleAnimations: AnimatedStyle\n): StyleLayoutAnimation {\n 'worklet';\n return defineAnimation<StyleLayoutAnimation>({}, () => {\n 'worklet';\n\n const onFrame = (\n animation: StyleLayoutAnimation,\n now: Timestamp\n ): boolean => {\n let stillGoing = false;\n const entriesToCheck: NestedObjectEntry<AnimationObject>[] = [\n { value: animation.styleAnimations, path: [] },\n ];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<AnimationObject> =\n entriesToCheck.pop() as NestedObjectEntry<AnimationObject>;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onFrame === undefined\n ) {\n // nested object\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentEntry.value as AnimationObject;\n if (currentStyleAnimation.finished) {\n continue;\n }\n const finished = currentStyleAnimation.onFrame(\n currentStyleAnimation,\n now\n );\n if (finished) {\n currentStyleAnimation.finished = true;\n if (currentStyleAnimation.callback) {\n currentStyleAnimation.callback(true);\n }\n } else {\n stillGoing = true;\n }\n\n if (ColorProperties.includes(currentEntry.path[0] as string)) {\n currentStyleAnimation.current = processColor(\n currentStyleAnimation.current\n ) as number;\n }\n\n setPath(\n animation.current,\n currentEntry.path,\n currentStyleAnimation.current\n );\n }\n }\n return !stillGoing;\n };\n\n const onStart = (\n animation: StyleLayoutAnimation,\n value: AnimatedStyle,\n now: Timestamp,\n previousAnimation: StyleLayoutAnimation\n ): void => {\n const entriesToCheck: NestedObjectEntry<\n AnimationObject | AnimatableValue\n >[] = [{ value: styleAnimations, path: [] }];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<\n AnimationObject | AnimatableValue\n > = entriesToCheck.pop() as NestedObjectEntry<\n AnimationObject | AnimatableValue\n >;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onStart === undefined\n ) {\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const prevAnimation = resolvePath(\n previousAnimation?.styleAnimations,\n currentEntry.path\n );\n let prevVal = resolvePath(value, currentEntry.path);\n if (prevAnimation && !prevVal) {\n prevVal = prevAnimation.current;\n }\n if (prevVal === undefined) {\n console.warn(\n `Initial values for animation are missing for property ${currentEntry.path.join(\n '.'\n )}`\n );\n }\n setPath(animation.current, currentEntry.path, prevVal);\n let currentAnimation: AnimationObject;\n if (\n typeof currentEntry.value !== 'object' ||\n !currentEntry.value.onStart\n ) {\n currentAnimation = withTiming(\n currentEntry.value as AnimatableValue,\n { duration: 0 }\n );\n setPath(\n animation.styleAnimations,\n currentEntry.path,\n currentAnimation\n );\n } else {\n currentAnimation = currentEntry.value as Animation<AnimationObject>;\n }\n currentAnimation.onStart(\n currentAnimation,\n prevVal,\n now,\n prevAnimation\n );\n }\n }\n };\n\n const callback = (finished: boolean): void => {\n if (!finished) {\n const animationsToCheck: NestedObjectValues<AnimationObject>[] = [\n styleAnimations,\n ];\n while (animationsToCheck.length > 0) {\n const currentAnimation: NestedObjectValues<AnimationObject> =\n animationsToCheck.pop() as NestedObjectValues<AnimationObject>;\n if (Array.isArray(currentAnimation)) {\n for (const element of currentAnimation) {\n animationsToCheck.push(element);\n }\n } else if (\n typeof currentAnimation === 'object' &&\n currentAnimation.onStart === undefined\n ) {\n for (const value of Object.values(currentAnimation)) {\n animationsToCheck.push(value);\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentAnimation as AnimationObject;\n if (\n !currentStyleAnimation.finished &&\n currentStyleAnimation.callback\n ) {\n currentStyleAnimation.callback(false);\n }\n }\n }\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame,\n onStart,\n current: {},\n styleAnimations,\n callback,\n } as StyleLayoutAnimation;\n });\n}\n"],"mappings":"AAAA,SAASA,eAAT,QAAgC,QAAhC;AAWA,SAASC,UAAT,QAA2B,UAA3B;AACA,SAASC,eAAT,QAAgC,gBAAhC;AACA,SAASC,YAAT,QAA6B,WAA7B,C,CAEA;AACA;;AACA,OAAO,SAASC,WAAT,CACLC,GADK,EAELC,IAFK,EAG8B;EACnC;;EACA,MAAMC,IAAuB,GAAGC,KAAK,CAACC,OAAN,CAAcH,IAAd,IAAsBA,IAAtB,GAA6B,CAACA,IAAD,CAA7D;EACA,OAAOC,IAAI,CAACG,MAAL,CAA+C,CAACC,GAAD,EAAMC,OAAN,KAAkB;IACtE,IAAIJ,KAAK,CAACC,OAAN,CAAcE,GAAd,KAAsB,OAAOC,OAAP,KAAmB,QAA7C,EAAuD;MACrD,OAAOD,GAAG,CAACC,OAAD,CAAV;IACD,CAFD,MAEO,IAAI,OAAOD,GAAP,KAAe,QAAf,IAA4BC,OAAD,IAAgCD,GAA/D,EAAoE;MACzE,OAAQA,GAAD,CACLC,OADK,CAAP;IAGD;;IACD,OAAOC,SAAP;EACD,CATM,EASJR,GATI,CAAP;AAUD,C,CAED;;AAEA,OAAO,SAASS,OAAT,CACLT,GADK,EAELC,IAFK,EAGLS,KAHK,EAIC;EACN;;EACA,MAAMR,IAAU,GAAGC,KAAK,CAACC,OAAN,CAAcH,IAAd,IAAsBA,IAAtB,GAA6B,CAACA,IAAD,CAAhD;EACA,IAAIU,OAA8B,GAAGX,GAArC;;EACA,KAAK,IAAIY,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGV,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,EAAqC;YACnC,KAAK,MAAMG,OAAX,IAAsBH,gBAAtB,EAAwC;cACtCE,iBAAiB,CAACjB,IAAlB,CAAuBkB,OAAvB;YACD;UACF,CAJD,MAIO,IACL,OAAOH,gBAAP,KAA4B,QAA5B,IACAA,gBAAgB,CAACP,OAAjB,KAA6BxB,SAFxB,EAGL;YACA,KAAK,MAAME,KAAX,IAAoBiB,MAAM,CAACgB,MAAP,CAAcJ,gBAAd,CAApB,EAAqD;cACnDE,iBAAiB,CAACjB,IAAlB,CAAuBd,KAAvB;YACD;UACF,CAPM,MAOA;YACL,MAAMkB,qBAAsC,GAC1CW,gBADF;;YAEA,IACE,CAACX,qBAAqB,CAACC,QAAvB,IACAD,qBAAqB,CAACE,QAFxB,EAGE;cACAF,qBAAqB,CAACE,QAAtB,CAA+B,KAA/B;YACD;UACF;QACF;MACF;IACF,CA/BD;;IAiCA,OAAO;MACLc,aAAa,EAAE,IADV;MAEL5B,OAFK;MAGLgB,OAHK;MAILzB,OAAO,EAAE,EAJJ;MAKLQ,eALK;MAMLe;IANK,CAAP;EAQD,CAxLqB,CAAtB;AAyLD"}
|
|
1
|
+
{"version":3,"names":["defineAnimation","withTiming","ColorProperties","processColor","resolvePath","obj","path","keys","Array","isArray","reduce","acc","current","undefined","setPath","value","currObj","i","length","withStyleAnimation","styleAnimations","onFrame","animation","now","stillGoing","entriesToCheck","currentEntry","pop","index","push","concat","key","Object","currentStyleAnimation","finished","callback","includes","onStart","previousAnimation","prevAnimation","prevVal","console","warn","join","currentAnimation","duration","animationsToCheck","element","values","isHigherOrder"],"sources":["styleAnimation.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport {\n Timestamp,\n AnimatableValue,\n AnimationObject,\n Animation,\n AnimatedStyle,\n NestedObject,\n NestedObjectValues,\n} from '../commonTypes';\nimport { StyleLayoutAnimation } from './commonTypes';\nimport { withTiming } from './timing';\nimport { ColorProperties } from '../UpdateProps';\nimport { processColor } from '../Colors';\n\n// resolves path to value for nested objects\n// if path cannot be resolved returns undefined\nexport function resolvePath<T>(\n obj: NestedObject<T>,\n path: AnimatableValue[] | AnimatableValue\n): NestedObjectValues<T> | undefined {\n 'worklet';\n const keys: AnimatableValue[] = Array.isArray(path) ? path : [path];\n return keys.reduce<NestedObjectValues<T> | undefined>((acc, current) => {\n if (Array.isArray(acc) && typeof current === 'number') {\n return acc[current];\n } else if (\n acc !== null &&\n typeof acc === 'object' &&\n (current as number | string) in acc\n ) {\n return (acc as { [key: string]: NestedObjectValues<T> })[\n current as number | string\n ];\n }\n return undefined;\n }, obj);\n}\n\n// set value at given path\ntype Path = Array<string | number> | string | number;\nexport function setPath<T>(\n obj: NestedObject<T>,\n path: Path,\n value: NestedObjectValues<T>\n): void {\n 'worklet';\n const keys: Path = Array.isArray(path) ? path : [path];\n let currObj: NestedObjectValues<T> = obj;\n for (let i = 0; i < keys.length - 1; i++) {\n // creates entry if there isn't one\n currObj = currObj as { [key: string]: NestedObjectValues<T> };\n if (!(keys[i] in currObj)) {\n // if next key is a number create an array\n if (typeof keys[i + 1] === 'number') {\n currObj[keys[i]] = [];\n } else {\n currObj[keys[i]] = {};\n }\n }\n currObj = currObj[keys[i]];\n }\n\n (currObj as { [key: string]: NestedObjectValues<T> })[keys[keys.length - 1]] =\n value;\n}\n\ninterface NestedObjectEntry<T> {\n value: NestedObjectValues<T>;\n path: (string | number)[];\n}\n\nexport function withStyleAnimation(\n styleAnimations: AnimatedStyle\n): StyleLayoutAnimation {\n 'worklet';\n return defineAnimation<StyleLayoutAnimation>({}, () => {\n 'worklet';\n\n const onFrame = (\n animation: StyleLayoutAnimation,\n now: Timestamp\n ): boolean => {\n let stillGoing = false;\n const entriesToCheck: NestedObjectEntry<AnimationObject>[] = [\n { value: animation.styleAnimations, path: [] },\n ];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<AnimationObject> =\n entriesToCheck.pop() as NestedObjectEntry<AnimationObject>;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onFrame === undefined\n ) {\n // nested object\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentEntry.value as AnimationObject;\n if (currentStyleAnimation.finished) {\n continue;\n }\n const finished = currentStyleAnimation.onFrame(\n currentStyleAnimation,\n now\n );\n if (finished) {\n currentStyleAnimation.finished = true;\n if (currentStyleAnimation.callback) {\n currentStyleAnimation.callback(true);\n }\n } else {\n stillGoing = true;\n }\n\n if (ColorProperties.includes(currentEntry.path[0] as string)) {\n currentStyleAnimation.current = processColor(\n currentStyleAnimation.current\n ) as number;\n }\n\n setPath(\n animation.current,\n currentEntry.path,\n currentStyleAnimation.current\n );\n }\n }\n return !stillGoing;\n };\n\n const onStart = (\n animation: StyleLayoutAnimation,\n value: AnimatedStyle,\n now: Timestamp,\n previousAnimation: StyleLayoutAnimation\n ): void => {\n const entriesToCheck: NestedObjectEntry<\n AnimationObject | AnimatableValue\n >[] = [{ value: styleAnimations, path: [] }];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<\n AnimationObject | AnimatableValue\n > = entriesToCheck.pop() as NestedObjectEntry<\n AnimationObject | AnimatableValue\n >;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onStart === undefined\n ) {\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const prevAnimation = resolvePath(\n previousAnimation?.styleAnimations,\n currentEntry.path\n );\n let prevVal = resolvePath(value, currentEntry.path);\n if (prevAnimation && !prevVal) {\n prevVal = prevAnimation.current;\n }\n if (prevVal === undefined) {\n console.warn(\n `Initial values for animation are missing for property ${currentEntry.path.join(\n '.'\n )}`\n );\n }\n setPath(animation.current, currentEntry.path, prevVal);\n let currentAnimation: AnimationObject;\n if (\n typeof currentEntry.value !== 'object' ||\n !currentEntry.value.onStart\n ) {\n currentAnimation = withTiming(\n currentEntry.value as AnimatableValue,\n { duration: 0 }\n );\n setPath(\n animation.styleAnimations,\n currentEntry.path,\n currentAnimation\n );\n } else {\n currentAnimation = currentEntry.value as Animation<AnimationObject>;\n }\n currentAnimation.onStart(\n currentAnimation,\n prevVal,\n now,\n prevAnimation\n );\n }\n }\n };\n\n const callback = (finished: boolean): void => {\n if (!finished) {\n const animationsToCheck: NestedObjectValues<AnimationObject>[] = [\n styleAnimations,\n ];\n while (animationsToCheck.length > 0) {\n const currentAnimation: NestedObjectValues<AnimationObject> =\n animationsToCheck.pop() as NestedObjectValues<AnimationObject>;\n if (Array.isArray(currentAnimation)) {\n for (const element of currentAnimation) {\n animationsToCheck.push(element);\n }\n } else if (\n typeof currentAnimation === 'object' &&\n currentAnimation.onStart === undefined\n ) {\n for (const value of Object.values(currentAnimation)) {\n animationsToCheck.push(value);\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentAnimation as AnimationObject;\n if (\n !currentStyleAnimation.finished &&\n currentStyleAnimation.callback\n ) {\n currentStyleAnimation.callback(false);\n }\n }\n }\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame,\n onStart,\n current: {},\n styleAnimations,\n callback,\n } as StyleLayoutAnimation;\n });\n}\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,QAAQ;AAWxC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,YAAY,QAAQ,WAAW;;AAExC;AACA;AACA,OAAO,SAASC,WAAWA,CACzBC,GAAoB,EACpBC,IAAyC,EACN;EACnC,SAAS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,OAAO;MACLc,aAAa,EAAE,IAAI;MACnB5B,OAAO;MACPgB,OAAO;MACPzB,OAAO,EAAE,CAAC,CAAC;MACXQ,eAAe;MACfe;IACF,CAAC;EACH,CAAC,CAAC;AACJ"}
|
|
@@ -10,11 +10,9 @@ export function withTiming(toValue, userConfig, callback) {
|
|
|
10
10
|
duration: 300,
|
|
11
11
|
easing: Easing.inOut(Easing.quad)
|
|
12
12
|
};
|
|
13
|
-
|
|
14
13
|
if (userConfig) {
|
|
15
14
|
Object.keys(userConfig).forEach(key => config[key] = userConfig[key]);
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
function timing(animation, now) {
|
|
19
17
|
const {
|
|
20
18
|
toValue,
|
|
@@ -22,19 +20,16 @@ export function withTiming(toValue, userConfig, callback) {
|
|
|
22
20
|
startValue
|
|
23
21
|
} = animation;
|
|
24
22
|
const runtime = now - startTime;
|
|
25
|
-
|
|
26
23
|
if (runtime >= config.duration) {
|
|
27
24
|
// reset startTime to avoid reusing finished animation config in `start` method
|
|
28
25
|
animation.startTime = 0;
|
|
29
26
|
animation.current = toValue;
|
|
30
27
|
return true;
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
const progress = animation.easing(runtime / config.duration);
|
|
34
30
|
animation.current = startValue + (toValue - startValue) * progress;
|
|
35
31
|
return false;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
function onStart(animation, value, now, previousAnimation) {
|
|
39
34
|
if (previousAnimation && previousAnimation.type === 'timing' && previousAnimation.toValue === toValue && previousAnimation.startTime) {
|
|
40
35
|
// to maintain continuity of timing animations we check if we are starting
|
|
@@ -46,16 +41,13 @@ export function withTiming(toValue, userConfig, callback) {
|
|
|
46
41
|
animation.startTime = now;
|
|
47
42
|
animation.startValue = value;
|
|
48
43
|
}
|
|
49
|
-
|
|
50
44
|
animation.current = value;
|
|
51
|
-
|
|
52
45
|
if (typeof config.easing === 'object') {
|
|
53
46
|
animation.easing = config.easing.factory();
|
|
54
47
|
} else {
|
|
55
48
|
animation.easing = config.easing;
|
|
56
49
|
}
|
|
57
50
|
}
|
|
58
|
-
|
|
59
51
|
return {
|
|
60
52
|
type: 'timing',
|
|
61
53
|
onFrame: timing,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Easing","defineAnimation","withTiming","toValue","userConfig","callback","config","duration","easing","inOut","quad","Object","keys","forEach","key","timing","animation","now","startTime","startValue","runtime","current","progress","onStart","value","previousAnimation","type","factory","onFrame"],"sources":["timing.ts"],"sourcesContent":["import { Easing, EasingFn, EasingFactoryFn } from '../Easing';\nimport { defineAnimation } from './util';\nimport {\n Animation,\n AnimationCallback,\n Timestamp,\n AnimatableValue,\n} from '../commonTypes';\n\ninterface TimingConfig {\n duration?: number;\n easing?: EasingFn | EasingFactoryFn;\n}\n\nexport interface TimingAnimation extends Animation<TimingAnimation> {\n type: string;\n easing: EasingFn;\n startValue: AnimatableValue;\n startTime: Timestamp;\n progress: number;\n toValue: AnimatableValue;\n current: AnimatableValue;\n}\n\nexport interface InnerTimingAnimation\n extends Omit<TimingAnimation, 'toValue' | 'current'> {\n toValue: number;\n current: number;\n}\n\nexport function withTiming(\n toValue: AnimatableValue,\n userConfig?: TimingConfig,\n callback?: AnimationCallback\n): Animation<TimingAnimation> {\n 'worklet';\n\n return defineAnimation<TimingAnimation>(toValue, () => {\n 'worklet';\n const config: Required<TimingConfig> = {\n duration: 300,\n easing: Easing.inOut(Easing.quad),\n };\n if (userConfig) {\n Object.keys(userConfig).forEach(\n (key) =>\n ((config as any)[key] = userConfig[key as keyof typeof userConfig])\n );\n }\n\n function timing(animation: InnerTimingAnimation, now: Timestamp): boolean {\n const { toValue, startTime, startValue } = animation;\n const runtime = now - startTime;\n\n if (runtime >= config.duration) {\n // reset startTime to avoid reusing finished animation config in `start` method\n animation.startTime = 0;\n animation.current = toValue;\n return true;\n }\n const progress = animation.easing(runtime / config.duration);\n animation.current =\n (startValue as number) + (toValue - (startValue as number)) * progress;\n return false;\n }\n\n function onStart(\n animation: TimingAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: Animation<TimingAnimation>\n ): void {\n if (\n previousAnimation &&\n (previousAnimation as TimingAnimation).type === 'timing' &&\n (previousAnimation as TimingAnimation).toValue === toValue &&\n (previousAnimation as TimingAnimation).startTime\n ) {\n // to maintain continuity of timing animations we check if we are starting\n // new timing over the old one with the same parameters. If so, we want\n // to copy animation timeline properties\n animation.startTime = (previousAnimation as TimingAnimation).startTime;\n animation.startValue = (\n previousAnimation as TimingAnimation\n ).startValue;\n } else {\n animation.startTime = now;\n animation.startValue = value;\n }\n animation.current = value;\n if (typeof config.easing === 'object') {\n animation.easing = config.easing.factory();\n } else {\n animation.easing = config.easing;\n }\n }\n\n return {\n type: 'timing',\n onFrame: timing,\n onStart: onStart as (animation: TimingAnimation, now: number) => boolean,\n progress: 0,\n toValue,\n startValue: 0,\n startTime: 0,\n easing: () => 0,\n current: toValue,\n callback,\n } as TimingAnimation;\n });\n}\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"names":["Easing","defineAnimation","withTiming","toValue","userConfig","callback","config","duration","easing","inOut","quad","Object","keys","forEach","key","timing","animation","now","startTime","startValue","runtime","current","progress","onStart","value","previousAnimation","type","factory","onFrame"],"sources":["timing.ts"],"sourcesContent":["import { Easing, EasingFn, EasingFactoryFn } from '../Easing';\nimport { defineAnimation } from './util';\nimport {\n Animation,\n AnimationCallback,\n Timestamp,\n AnimatableValue,\n} from '../commonTypes';\n\ninterface TimingConfig {\n duration?: number;\n easing?: EasingFn | EasingFactoryFn;\n}\n\nexport interface TimingAnimation extends Animation<TimingAnimation> {\n type: string;\n easing: EasingFn;\n startValue: AnimatableValue;\n startTime: Timestamp;\n progress: number;\n toValue: AnimatableValue;\n current: AnimatableValue;\n}\n\nexport interface InnerTimingAnimation\n extends Omit<TimingAnimation, 'toValue' | 'current'> {\n toValue: number;\n current: number;\n}\n\nexport function withTiming(\n toValue: AnimatableValue,\n userConfig?: TimingConfig,\n callback?: AnimationCallback\n): Animation<TimingAnimation> {\n 'worklet';\n\n return defineAnimation<TimingAnimation>(toValue, () => {\n 'worklet';\n const config: Required<TimingConfig> = {\n duration: 300,\n easing: Easing.inOut(Easing.quad),\n };\n if (userConfig) {\n Object.keys(userConfig).forEach(\n (key) =>\n ((config as any)[key] = userConfig[key as keyof typeof userConfig])\n );\n }\n\n function timing(animation: InnerTimingAnimation, now: Timestamp): boolean {\n const { toValue, startTime, startValue } = animation;\n const runtime = now - startTime;\n\n if (runtime >= config.duration) {\n // reset startTime to avoid reusing finished animation config in `start` method\n animation.startTime = 0;\n animation.current = toValue;\n return true;\n }\n const progress = animation.easing(runtime / config.duration);\n animation.current =\n (startValue as number) + (toValue - (startValue as number)) * progress;\n return false;\n }\n\n function onStart(\n animation: TimingAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: Animation<TimingAnimation>\n ): void {\n if (\n previousAnimation &&\n (previousAnimation as TimingAnimation).type === 'timing' &&\n (previousAnimation as TimingAnimation).toValue === toValue &&\n (previousAnimation as TimingAnimation).startTime\n ) {\n // to maintain continuity of timing animations we check if we are starting\n // new timing over the old one with the same parameters. If so, we want\n // to copy animation timeline properties\n animation.startTime = (previousAnimation as TimingAnimation).startTime;\n animation.startValue = (\n previousAnimation as TimingAnimation\n ).startValue;\n } else {\n animation.startTime = now;\n animation.startValue = value;\n }\n animation.current = value;\n if (typeof config.easing === 'object') {\n animation.easing = config.easing.factory();\n } else {\n animation.easing = config.easing;\n }\n }\n\n return {\n type: 'timing',\n onFrame: timing,\n onStart: onStart as (animation: TimingAnimation, now: number) => boolean,\n progress: 0,\n toValue,\n startValue: 0,\n startTime: 0,\n easing: () => 0,\n current: toValue,\n callback,\n } as TimingAnimation;\n });\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAmC,WAAW;AAC7D,SAASC,eAAe,QAAQ,QAAQ;AA6BxC,OAAO,SAASC,UAAUA,CACxBC,OAAwB,EACxBC,UAAyB,EACzBC,QAA4B,EACA;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BN,UAAU;MACd,CAAC,MAAM;QACLH,SAAS,CAACE,SAAS,GAAGD,GAAG;QACzBD,SAAS,CAACG,UAAU,GAAGK,KAAK;MAC9B;MACAR,SAAS,CAACK,OAAO,GAAGG,KAAK;MACzB,IAAI,OAAOlB,MAAM,CAACE,MAAM,KAAK,QAAQ,EAAE;QACrCQ,SAAS,CAACR,MAAM,GAAGF,MAAM,CAACE,MAAM,CAACmB,OAAO,EAAE;MAC5C,CAAC,MAAM;QACLX,SAAS,CAACR,MAAM,GAAGF,MAAM,CAACE,MAAM;MAClC;IACF;IAEA,OAAO;MACLkB,IAAI,EAAE,QAAQ;MACdE,OAAO,EAAEb,MAAM;MACfQ,OAAO,EAAEA,OAA+D;MACxED,QAAQ,EAAE,CAAC;MACXnB,OAAO;MACPgB,UAAU,EAAE,CAAC;MACbD,SAAS,EAAE,CAAC;MACZV,MAAM,EAAEA,CAAA,KAAM,CAAC;MACfa,OAAO,EAAElB,OAAO;MAChBE;IACF,CAAC;EACH,CAAC,CAAC;AACJ"}
|
|
@@ -8,20 +8,17 @@ export function initialUpdaterRun(updater) {
|
|
|
8
8
|
IN_STYLE_UPDATER = false;
|
|
9
9
|
return result;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
function recognizePrefixSuffix(value) {
|
|
13
12
|
'worklet';
|
|
14
13
|
|
|
15
14
|
if (typeof value === 'string') {
|
|
16
15
|
const match = value.match(/([A-Za-z]*)(-?\d*\.?\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/);
|
|
17
|
-
|
|
18
16
|
if (!match) {
|
|
19
17
|
throw Error("Couldn't parse animation value. Check if there isn't any typo.");
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
const prefix = match[1];
|
|
23
|
-
const suffix = match[4];
|
|
24
|
-
|
|
20
|
+
const suffix = match[4];
|
|
21
|
+
// number with scientific notation
|
|
25
22
|
const number = match[2] + (match[3] ?? '');
|
|
26
23
|
return {
|
|
27
24
|
prefix,
|
|
@@ -34,19 +31,16 @@ function recognizePrefixSuffix(value) {
|
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
function decorateAnimation(animation) {
|
|
39
35
|
'worklet';
|
|
40
36
|
|
|
41
37
|
if (animation.isHigherOrder) {
|
|
42
38
|
return;
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
const baseOnStart = animation.onStart;
|
|
46
41
|
const baseOnFrame = animation.onFrame;
|
|
47
42
|
const animationCopy = Object.assign({}, animation);
|
|
48
43
|
delete animationCopy.callback;
|
|
49
|
-
|
|
50
44
|
const prefNumberSuffOnStart = (animation, value, timestamp, previousAnimation) => {
|
|
51
45
|
// recognize prefix, suffix, and updates stripped value on animation start
|
|
52
46
|
const {
|
|
@@ -63,7 +57,6 @@ function decorateAnimation(animation) {
|
|
|
63
57
|
animation.current = strippedValue;
|
|
64
58
|
animation.startValue = strippedValue;
|
|
65
59
|
animation.toValue = strippedToValue;
|
|
66
|
-
|
|
67
60
|
if (previousAnimation && previousAnimation !== animation) {
|
|
68
61
|
const {
|
|
69
62
|
prefix: paPrefix,
|
|
@@ -74,15 +67,12 @@ function decorateAnimation(animation) {
|
|
|
74
67
|
previousAnimation.__prefix = paPrefix;
|
|
75
68
|
previousAnimation.__suffix = paSuffix;
|
|
76
69
|
}
|
|
77
|
-
|
|
78
70
|
baseOnStart(animation, strippedValue, timestamp, previousAnimation);
|
|
79
71
|
animation.current = (animation.__prefix ?? '') + animation.current + (animation.__suffix ?? '');
|
|
80
|
-
|
|
81
72
|
if (previousAnimation && previousAnimation !== animation) {
|
|
82
73
|
previousAnimation.current = (previousAnimation.__prefix ?? '') + previousAnimation.current + (previousAnimation.__suffix ?? '');
|
|
83
74
|
}
|
|
84
75
|
};
|
|
85
|
-
|
|
86
76
|
const prefNumberSuffOnFrame = (animation, timestamp) => {
|
|
87
77
|
animation.current = animation.strippedCurrent;
|
|
88
78
|
const res = baseOnFrame(animation, timestamp);
|
|
@@ -90,24 +80,19 @@ function decorateAnimation(animation) {
|
|
|
90
80
|
animation.current = (animation.__prefix ?? '') + animation.current + (animation.__suffix ?? '');
|
|
91
81
|
return res;
|
|
92
82
|
};
|
|
93
|
-
|
|
94
83
|
const tab = ['R', 'G', 'B', 'A'];
|
|
95
|
-
|
|
96
84
|
const colorOnStart = (animation, value, timestamp, previousAnimation) => {
|
|
97
85
|
let RGBAValue;
|
|
98
86
|
let RGBACurrent;
|
|
99
87
|
let RGBAToValue;
|
|
100
88
|
const res = [];
|
|
101
|
-
|
|
102
89
|
if (isColor(value)) {
|
|
103
90
|
RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
|
|
104
91
|
RGBAValue = toLinearSpace(convertToRGBA(value));
|
|
105
|
-
|
|
106
92
|
if (animation.toValue) {
|
|
107
93
|
RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));
|
|
108
94
|
}
|
|
109
95
|
}
|
|
110
|
-
|
|
111
96
|
tab.forEach((i, index) => {
|
|
112
97
|
animation[i] = Object.assign({}, animationCopy);
|
|
113
98
|
animation[i].current = RGBACurrent[index];
|
|
@@ -117,21 +102,19 @@ function decorateAnimation(animation) {
|
|
|
117
102
|
});
|
|
118
103
|
animation.current = rgbaArrayToRGBAColor(toGammaSpace(res));
|
|
119
104
|
};
|
|
120
|
-
|
|
121
105
|
const colorOnFrame = (animation, timestamp) => {
|
|
122
106
|
const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
|
|
123
107
|
const res = [];
|
|
124
108
|
let finished = true;
|
|
125
109
|
tab.forEach((i, index) => {
|
|
126
|
-
animation[i].current = RGBACurrent[index];
|
|
127
|
-
|
|
110
|
+
animation[i].current = RGBACurrent[index];
|
|
111
|
+
// @ts-ignore: disable-next-line
|
|
128
112
|
finished &= animation[i].onFrame(animation[i], timestamp);
|
|
129
113
|
res.push(animation[i].current);
|
|
130
114
|
});
|
|
131
115
|
animation.current = rgbaArrayToRGBAColor(toGammaSpace(res));
|
|
132
116
|
return finished;
|
|
133
117
|
};
|
|
134
|
-
|
|
135
118
|
const arrayOnStart = (animation, value, timestamp, previousAnimation) => {
|
|
136
119
|
value.forEach((v, i) => {
|
|
137
120
|
animation[i] = Object.assign({}, animationCopy);
|
|
@@ -141,7 +124,6 @@ function decorateAnimation(animation) {
|
|
|
141
124
|
});
|
|
142
125
|
animation.current = value;
|
|
143
126
|
};
|
|
144
|
-
|
|
145
127
|
const arrayOnFrame = (animation, timestamp) => {
|
|
146
128
|
let finished = true;
|
|
147
129
|
animation.current.forEach((v, i) => {
|
|
@@ -151,7 +133,6 @@ function decorateAnimation(animation) {
|
|
|
151
133
|
});
|
|
152
134
|
return finished;
|
|
153
135
|
};
|
|
154
|
-
|
|
155
136
|
animation.onStart = (animation, value, timestamp, previousAnimation) => {
|
|
156
137
|
if (isColor(value)) {
|
|
157
138
|
colorOnStart(animation, value, timestamp, previousAnimation);
|
|
@@ -166,11 +147,9 @@ function decorateAnimation(animation) {
|
|
|
166
147
|
animation.onFrame = prefNumberSuffOnFrame;
|
|
167
148
|
return;
|
|
168
149
|
}
|
|
169
|
-
|
|
170
150
|
baseOnStart(animation, value, timestamp, previousAnimation);
|
|
171
151
|
};
|
|
172
152
|
}
|
|
173
|
-
|
|
174
153
|
const IS_NATIVE = NativeReanimatedModule.native;
|
|
175
154
|
export function defineAnimation(starting, factory) {
|
|
176
155
|
'worklet';
|
|
@@ -178,7 +157,6 @@ export function defineAnimation(starting, factory) {
|
|
|
178
157
|
if (IN_STYLE_UPDATER) {
|
|
179
158
|
return starting;
|
|
180
159
|
}
|
|
181
|
-
|
|
182
160
|
const create = () => {
|
|
183
161
|
'worklet';
|
|
184
162
|
|
|
@@ -186,20 +164,20 @@ export function defineAnimation(starting, factory) {
|
|
|
186
164
|
decorateAnimation(animation);
|
|
187
165
|
return animation;
|
|
188
166
|
};
|
|
189
|
-
|
|
190
167
|
if (_WORKLET || !IS_NATIVE) {
|
|
191
168
|
return create();
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
169
|
+
}
|
|
170
|
+
// @ts-ignore: eslint-disable-line
|
|
195
171
|
return create;
|
|
196
172
|
}
|
|
197
173
|
export function cancelAnimation(sharedValue) {
|
|
198
|
-
'worklet';
|
|
174
|
+
'worklet';
|
|
199
175
|
|
|
176
|
+
// setting the current value cancels the animation if one is currently running
|
|
200
177
|
sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign
|
|
201
|
-
}
|
|
178
|
+
}
|
|
202
179
|
|
|
180
|
+
// TODO it should work only if there was no animation before.
|
|
203
181
|
export function withStartValue(startValue, animation) {
|
|
204
182
|
'worklet';
|
|
205
183
|
|
|
@@ -209,7 +187,6 @@ export function withStartValue(startValue, animation) {
|
|
|
209
187
|
if (!_WORKLET && typeof animation === 'function') {
|
|
210
188
|
animation = animation();
|
|
211
189
|
}
|
|
212
|
-
|
|
213
190
|
animation.current = startValue;
|
|
214
191
|
return animation;
|
|
215
192
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isColor","convertToRGBA","rgbaArrayToRGBAColor","toGammaSpace","toLinearSpace","NativeReanimatedModule","IN_STYLE_UPDATER","initialUpdaterRun","updater","result","recognizePrefixSuffix","value","match","Error","prefix","suffix","number","strippedValue","parseFloat","decorateAnimation","animation","isHigherOrder","baseOnStart","onStart","baseOnFrame","onFrame","animationCopy","Object","assign","callback","prefNumberSuffOnStart","timestamp","previousAnimation","__prefix","__suffix","strippedCurrent","strippedToValue","toValue","current","startValue","paPrefix","paSuffix","paStrippedValue","prefNumberSuffOnFrame","res","tab","colorOnStart","RGBAValue","RGBACurrent","RGBAToValue","forEach","i","index","undefined","push","colorOnFrame","finished","arrayOnStart","v","arrayOnFrame","Array","isArray","IS_NATIVE","native","defineAnimation","starting","factory","create","_WORKLET","cancelAnimation","sharedValue","withStartValue"],"sources":["util.ts"],"sourcesContent":["import {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\n/* global _WORKLET */\nimport {\n ParsedColorArray,\n isColor,\n convertToRGBA,\n rgbaArrayToRGBAColor,\n toGammaSpace,\n toLinearSpace,\n} from '../Colors';\n\nimport {\n AnimatedStyle,\n SharedValue,\n AnimatableValue,\n Animation,\n AnimationObject,\n Timestamp,\n} from '../commonTypes';\nimport NativeReanimatedModule from '../NativeReanimated';\n\nlet IN_STYLE_UPDATER = false;\n\nexport type UserUpdater = () => AnimatedStyle;\n\nexport function initialUpdaterRun<T>(updater: () => T): T {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\n\ninterface RecognizedPrefixSuffix {\n prefix?: string;\n suffix?: string;\n strippedValue: number;\n}\n\nfunction recognizePrefixSuffix(value: string | number): RecognizedPrefixSuffix {\n 'worklet';\n if (typeof value === 'string') {\n const match = value.match(\n /([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/\n );\n if (!match) {\n throw Error(\n \"Couldn't parse animation value. Check if there isn't any typo.\"\n );\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + (match[3] ?? '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n } else {\n return { strippedValue: value };\n }\n}\n\nfunction decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(\n animation: T\n): void {\n 'worklet';\n if ((animation as HigherOrderAnimation).isHigherOrder) {\n return;\n }\n\n const baseOnStart = (animation as Animation<AnimationObject>).onStart;\n const baseOnFrame = (animation as Animation<AnimationObject>).onFrame;\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n\n const prefNumberSuffOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: number,\n previousAnimation: Animation<AnimationObject>\n ) => {\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(\n animation.toValue as string | number\n );\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n const {\n prefix: paPrefix,\n suffix: paSuffix,\n strippedValue: paStrippedValue,\n } = recognizePrefixSuffix(previousAnimation.current as string | number);\n previousAnimation.current = paStrippedValue;\n previousAnimation.__prefix = paPrefix;\n previousAnimation.__suffix = paSuffix;\n }\n\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n (previousAnimation.__prefix ?? '') +\n previousAnimation.current +\n (previousAnimation.__suffix ?? '');\n }\n };\n const prefNumberSuffOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: number\n ) => {\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n return res;\n };\n\n const tab = ['R', 'G', 'B', 'A'];\n const colorOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n let RGBAValue: ParsedColorArray;\n let RGBACurrent: ParsedColorArray;\n let RGBAToValue: ParsedColorArray;\n const res: Array<number> = [];\n if (isColor(value)) {\n RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n RGBAValue = toLinearSpace(convertToRGBA(value));\n if (animation.toValue) {\n RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = RGBACurrent[index];\n animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;\n animation[i].onStart(\n animation[i],\n RGBAValue[index],\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n };\n\n const colorOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n const res: Array<number> = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = RGBACurrent[index];\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n return finished;\n };\n\n const arrayOnStart = (\n animation: Animation<AnimationObject>,\n value: Array<number>,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = (animation.toValue as Array<number>)[i];\n animation[i].onStart(\n animation[i],\n v,\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n });\n\n animation.current = value;\n };\n\n const arrayOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n (animation.current as Array<number>).forEach((v, i) => {\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n (animation.current as Array<number>)[i] = animation[i].current;\n });\n\n return finished;\n };\n\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n } else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n } else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\n\ntype AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation> =\n T extends StyleLayoutAnimation\n ? Record<string, unknown>\n : T extends DelayAnimation\n ? NextAnimation<DelayAnimation>\n : T extends RepeatAnimation\n ? NextAnimation<RepeatAnimation>\n : T extends SequenceAnimation\n ? NextAnimation<SequenceAnimation>\n : AnimatableValue | T;\n\nconst IS_NATIVE = NativeReanimatedModule.native;\n\nexport function defineAnimation<\n T extends AnimationObject | StyleLayoutAnimation\n>(starting: AnimationToDecoration<T>, factory: () => T): T {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting as T;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation<T>(animation);\n return animation;\n };\n\n if (_WORKLET || !IS_NATIVE) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\n\nexport function cancelAnimation<T>(sharedValue: SharedValue<T>): void {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n\n// TODO it should work only if there was no animation before.\nexport function withStartValue(\n startValue: AnimatableValue,\n animation: NextAnimation<AnimationObject>\n): Animation<AnimationObject> {\n 'worklet';\n return defineAnimation(startValue, () => {\n 'worklet';\n if (!_WORKLET && typeof animation === 'function') {\n animation = animation();\n }\n (animation as Animation<AnimationObject>).current = startValue;\n return animation as Animation<AnimationObject>;\n });\n}\n"],"mappings":"AAQA;AACA,SAEEA,OAFF,EAGEC,aAHF,EAIEC,oBAJF,EAKEC,YALF,EAMEC,aANF,QAOO,WAPP;AAiBA,OAAOC,sBAAP,MAAmC,qBAAnC;AAEA,IAAIC,gBAAgB,GAAG,KAAvB;AAIA,OAAO,SAASC,iBAAT,CAA8BC,OAA9B,EAAmD;EACxDF,gBAAgB,GAAG,IAAnB;EACA,MAAMG,MAAM,GAAGD,OAAO,EAAtB;EACAF,gBAAgB,GAAG,KAAnB;EACA,OAAOG,MAAP;AACD;;AAQD,SAASC,qBAAT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CAAtB;AAQD"}
|
|
1
|
+
{"version":3,"names":["isColor","convertToRGBA","rgbaArrayToRGBAColor","toGammaSpace","toLinearSpace","NativeReanimatedModule","IN_STYLE_UPDATER","initialUpdaterRun","updater","result","recognizePrefixSuffix","value","match","Error","prefix","suffix","number","strippedValue","parseFloat","decorateAnimation","animation","isHigherOrder","baseOnStart","onStart","baseOnFrame","onFrame","animationCopy","Object","assign","callback","prefNumberSuffOnStart","timestamp","previousAnimation","__prefix","__suffix","strippedCurrent","strippedToValue","toValue","current","startValue","paPrefix","paSuffix","paStrippedValue","prefNumberSuffOnFrame","res","tab","colorOnStart","RGBAValue","RGBACurrent","RGBAToValue","forEach","i","index","undefined","push","colorOnFrame","finished","arrayOnStart","v","arrayOnFrame","Array","isArray","IS_NATIVE","native","defineAnimation","starting","factory","create","_WORKLET","cancelAnimation","sharedValue","withStartValue"],"sources":["util.ts"],"sourcesContent":["import {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\n/* global _WORKLET */\nimport {\n ParsedColorArray,\n isColor,\n convertToRGBA,\n rgbaArrayToRGBAColor,\n toGammaSpace,\n toLinearSpace,\n} from '../Colors';\n\nimport {\n AnimatedStyle,\n SharedValue,\n AnimatableValue,\n Animation,\n AnimationObject,\n Timestamp,\n} from '../commonTypes';\nimport NativeReanimatedModule from '../NativeReanimated';\n\nlet IN_STYLE_UPDATER = false;\n\nexport type UserUpdater = () => AnimatedStyle;\n\nexport function initialUpdaterRun<T>(updater: () => T): T {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\n\ninterface RecognizedPrefixSuffix {\n prefix?: string;\n suffix?: string;\n strippedValue: number;\n}\n\nfunction recognizePrefixSuffix(value: string | number): RecognizedPrefixSuffix {\n 'worklet';\n if (typeof value === 'string') {\n const match = value.match(\n /([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/\n );\n if (!match) {\n throw Error(\n \"Couldn't parse animation value. Check if there isn't any typo.\"\n );\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + (match[3] ?? '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n } else {\n return { strippedValue: value };\n }\n}\n\nfunction decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(\n animation: T\n): void {\n 'worklet';\n if ((animation as HigherOrderAnimation).isHigherOrder) {\n return;\n }\n\n const baseOnStart = (animation as Animation<AnimationObject>).onStart;\n const baseOnFrame = (animation as Animation<AnimationObject>).onFrame;\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n\n const prefNumberSuffOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: number,\n previousAnimation: Animation<AnimationObject>\n ) => {\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(\n animation.toValue as string | number\n );\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n const {\n prefix: paPrefix,\n suffix: paSuffix,\n strippedValue: paStrippedValue,\n } = recognizePrefixSuffix(previousAnimation.current as string | number);\n previousAnimation.current = paStrippedValue;\n previousAnimation.__prefix = paPrefix;\n previousAnimation.__suffix = paSuffix;\n }\n\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n (previousAnimation.__prefix ?? '') +\n previousAnimation.current +\n (previousAnimation.__suffix ?? '');\n }\n };\n const prefNumberSuffOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: number\n ) => {\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n return res;\n };\n\n const tab = ['R', 'G', 'B', 'A'];\n const colorOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n let RGBAValue: ParsedColorArray;\n let RGBACurrent: ParsedColorArray;\n let RGBAToValue: ParsedColorArray;\n const res: Array<number> = [];\n if (isColor(value)) {\n RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n RGBAValue = toLinearSpace(convertToRGBA(value));\n if (animation.toValue) {\n RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = RGBACurrent[index];\n animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;\n animation[i].onStart(\n animation[i],\n RGBAValue[index],\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n };\n\n const colorOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n const res: Array<number> = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = RGBACurrent[index];\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n return finished;\n };\n\n const arrayOnStart = (\n animation: Animation<AnimationObject>,\n value: Array<number>,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = (animation.toValue as Array<number>)[i];\n animation[i].onStart(\n animation[i],\n v,\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n });\n\n animation.current = value;\n };\n\n const arrayOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n (animation.current as Array<number>).forEach((v, i) => {\n // @ts-ignore: disable-next-line\n finished &= animation[i].onFrame(animation[i], timestamp);\n (animation.current as Array<number>)[i] = animation[i].current;\n });\n\n return finished;\n };\n\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n } else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n } else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\n\ntype AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation> =\n T extends StyleLayoutAnimation\n ? Record<string, unknown>\n : T extends DelayAnimation\n ? NextAnimation<DelayAnimation>\n : T extends RepeatAnimation\n ? NextAnimation<RepeatAnimation>\n : T extends SequenceAnimation\n ? NextAnimation<SequenceAnimation>\n : AnimatableValue | T;\n\nconst IS_NATIVE = NativeReanimatedModule.native;\n\nexport function defineAnimation<\n T extends AnimationObject | StyleLayoutAnimation\n>(starting: AnimationToDecoration<T>, factory: () => T): T {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting as T;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation<T>(animation);\n return animation;\n };\n\n if (_WORKLET || !IS_NATIVE) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\n\nexport function cancelAnimation<T>(sharedValue: SharedValue<T>): void {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n\n// TODO it should work only if there was no animation before.\nexport function withStartValue(\n startValue: AnimatableValue,\n animation: NextAnimation<AnimationObject>\n): Animation<AnimationObject> {\n 'worklet';\n return defineAnimation(startValue, () => {\n 'worklet';\n if (!_WORKLET && typeof animation === 'function') {\n animation = animation();\n }\n (animation as Animation<AnimationObject>).current = startValue;\n return animation as Animation<AnimationObject>;\n });\n}\n"],"mappings":"AAQA;AACA,SAEEA,OAAO,EACPC,aAAa,EACbC,oBAAoB,EACpBC,YAAY,EACZC,aAAa,QACR,WAAW;AAUlB,OAAOC,sBAAsB,MAAM,qBAAqB;AAExD,IAAIC,gBAAgB,GAAG,KAAK;AAI5B,OAAO,SAASC,iBAAiBA,CAAIC,OAAgB,EAAK;EACxDF,gBAAgB,GAAG,IAAI;EACvB,MAAMG,MAAM,GAAGD,OAAO,EAAE;EACxBF,gBAAgB,GAAG,KAAK;EACxB,OAAOG,MAAM;AACf;AAQA,SAASC,qBAAqBA,CAACC,KAAsB,EAA0B;EAC7E,SAAS;;EACT,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,MAAMC,KAAK,GAAGD,KAAK,CAACC,KAAK,CACvB,wDAAwD,CACzD;IACD,IAAI,CAACA,KAAK,EAAE;MACV,MAAMC,KAAK,CACT,gEAAgE,CACjE;IACH;IACA,MAAMC,MAAM,GAAGF,KAAK,CAAC,CAAC,CAAC;IACvB,MAAMG,MAAM,GAAGH,KAAK,CAAC,CAAC,CAAC;IACvB;IACA,MAAMI,MAAM,GAAGJ,KAAK,CAAC,CAAC,CAAC,IAAIA,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,OAAO;MAAEE,MAAM;MAAEC,MAAM;MAAEE,aAAa,EAAEC,UAAU,CAACF,MAAM;IAAE,CAAC;EAC9D,CAAC,MAAM;IACL,OAAO;MAAEC,aAAa,EAAEN;IAAM,CAAC;EACjC;A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EAAE;IAC3B/C,iBAAiB,CAAIC,SAAS,CAAC;IAC/B,OAAOA,SAAS;EAClB,CAAC;EAED,IAAIgD,QAAQ,IAAI,CAACN,SAAS,EAAE;IAC1B,OAAOK,MAAM,EAAE;EACjB;EACA;EACA,OAAOA,MAAM;AACf;AAEA,OAAO,SAASE,eAAeA,CAAIC,WAA2B,EAAQ;EACpE,SAAS;;EACT;EACAA,WAAW,CAAC3D,KAAK,GAAG2D,WAAW,CAAC3D,KAAK,CAAC,CAAC;AACzC;;AAEA;AACA,OAAO,SAAS4D,cAAcA,CAC5BhC,UAA2B,EAC3BnB,SAAyC,EACb;EAC5B,SAAS;;EACT,OAAO4C,eAAe,CAACzB,UAAU,EAAE,MAAM;IACvC,SAAS;;IACT,IAAI,CAAC6B,QAAQ,IAAI,OAAOhD,SAAS,KAAK,UAAU,EAAE;MAChDA,SAAS,GAAGA,SAAS,EAAE;IACzB;IACCA,SAAS,CAAgCkB,OAAO,GAAGC,UAAU;IAC9D,OAAOnB,SAAS;EAClB,CAAC,CAAC;AACJ"}
|
|
@@ -5,42 +5,35 @@
|
|
|
5
5
|
// check other methods that may use them. However, this field is not actually defined
|
|
6
6
|
// nor should be used for anything else as assigning any data to those objects will
|
|
7
7
|
// throw an error.
|
|
8
|
-
export let SensorType
|
|
9
|
-
|
|
10
|
-
(function (SensorType) {
|
|
8
|
+
export let SensorType = /*#__PURE__*/function (SensorType) {
|
|
11
9
|
SensorType[SensorType["ACCELEROMETER"] = 1] = "ACCELEROMETER";
|
|
12
10
|
SensorType[SensorType["GYROSCOPE"] = 2] = "GYROSCOPE";
|
|
13
11
|
SensorType[SensorType["GRAVITY"] = 3] = "GRAVITY";
|
|
14
12
|
SensorType[SensorType["MAGNETIC_FIELD"] = 4] = "MAGNETIC_FIELD";
|
|
15
13
|
SensorType[SensorType["ROTATION"] = 5] = "ROTATION";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export let IOSReferenceFrame
|
|
19
|
-
|
|
20
|
-
(function (IOSReferenceFrame) {
|
|
14
|
+
return SensorType;
|
|
15
|
+
}({});
|
|
16
|
+
export let IOSReferenceFrame = /*#__PURE__*/function (IOSReferenceFrame) {
|
|
21
17
|
IOSReferenceFrame[IOSReferenceFrame["XArbitraryZVertical"] = 0] = "XArbitraryZVertical";
|
|
22
18
|
IOSReferenceFrame[IOSReferenceFrame["XArbitraryCorrectedZVertical"] = 1] = "XArbitraryCorrectedZVertical";
|
|
23
19
|
IOSReferenceFrame[IOSReferenceFrame["XMagneticNorthZVertical"] = 2] = "XMagneticNorthZVertical";
|
|
24
20
|
IOSReferenceFrame[IOSReferenceFrame["XTrueNorthZVertical"] = 3] = "XTrueNorthZVertical";
|
|
25
21
|
IOSReferenceFrame[IOSReferenceFrame["Auto"] = 4] = "Auto";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export let InterfaceOrientation
|
|
29
|
-
|
|
30
|
-
(function (InterfaceOrientation) {
|
|
22
|
+
return IOSReferenceFrame;
|
|
23
|
+
}({});
|
|
24
|
+
export let InterfaceOrientation = /*#__PURE__*/function (InterfaceOrientation) {
|
|
31
25
|
InterfaceOrientation[InterfaceOrientation["ROTATION_0"] = 0] = "ROTATION_0";
|
|
32
26
|
InterfaceOrientation[InterfaceOrientation["ROTATION_90"] = 90] = "ROTATION_90";
|
|
33
27
|
InterfaceOrientation[InterfaceOrientation["ROTATION_180"] = 180] = "ROTATION_180";
|
|
34
28
|
InterfaceOrientation[InterfaceOrientation["ROTATION_270"] = 270] = "ROTATION_270";
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export let KeyboardState
|
|
38
|
-
|
|
39
|
-
(function (KeyboardState) {
|
|
29
|
+
return InterfaceOrientation;
|
|
30
|
+
}({});
|
|
31
|
+
export let KeyboardState = /*#__PURE__*/function (KeyboardState) {
|
|
40
32
|
KeyboardState[KeyboardState["UNKNOWN"] = 0] = "UNKNOWN";
|
|
41
33
|
KeyboardState[KeyboardState["OPENING"] = 1] = "OPENING";
|
|
42
34
|
KeyboardState[KeyboardState["OPEN"] = 2] = "OPEN";
|
|
43
35
|
KeyboardState[KeyboardState["CLOSING"] = 3] = "CLOSING";
|
|
44
36
|
KeyboardState[KeyboardState["CLOSED"] = 4] = "CLOSED";
|
|
45
|
-
|
|
37
|
+
return KeyboardState;
|
|
38
|
+
}({});
|
|
46
39
|
//# sourceMappingURL=commonTypes.js.map
|