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,5 +1,6 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
3
4
|
import { Easing } from '../../Easing';
|
|
4
5
|
import { withDelay, withSequence, withTiming } from '../../animation';
|
|
5
6
|
export class Keyframe {
|
|
@@ -9,13 +10,9 @@ export class Keyframe {
|
|
|
9
10
|
*/
|
|
10
11
|
constructor(definitions) {
|
|
11
12
|
_defineProperty(this, "durationV", void 0);
|
|
12
|
-
|
|
13
13
|
_defineProperty(this, "delayV", void 0);
|
|
14
|
-
|
|
15
14
|
_defineProperty(this, "callbackV", void 0);
|
|
16
|
-
|
|
17
15
|
_defineProperty(this, "definitions", void 0);
|
|
18
|
-
|
|
19
16
|
_defineProperty(this, "build", () => {
|
|
20
17
|
const delay = this.delayV;
|
|
21
18
|
const delayFunction = this.getDelayFunction();
|
|
@@ -28,14 +25,14 @@ export class Keyframe {
|
|
|
28
25
|
'worklet';
|
|
29
26
|
|
|
30
27
|
const animations = {};
|
|
28
|
+
|
|
31
29
|
/*
|
|
32
30
|
For each style property, an animations sequence is created that corresponds with its key points.
|
|
33
31
|
Transform style properties require special handling because of their nested structure.
|
|
34
32
|
*/
|
|
35
|
-
|
|
36
33
|
const addAnimation = key => {
|
|
37
|
-
const keyframePoints = keyframes[key];
|
|
38
|
-
|
|
34
|
+
const keyframePoints = keyframes[key];
|
|
35
|
+
// in case if property was only passed as initial value
|
|
39
36
|
if (keyframePoints.length === 0) return;
|
|
40
37
|
const animation = delayFunction(delay, keyframePoints.length === 1 ? withTiming(keyframePoints[0].value, {
|
|
41
38
|
duration: keyframePoints[0].duration,
|
|
@@ -44,14 +41,11 @@ export class Keyframe {
|
|
|
44
41
|
duration: keyframePoint.duration,
|
|
45
42
|
easing: keyframePoint.easing ? keyframePoint.easing : Easing.linear
|
|
46
43
|
}))));
|
|
47
|
-
|
|
48
44
|
if (key.includes('transform')) {
|
|
49
45
|
var _animations$transform;
|
|
50
|
-
|
|
51
46
|
if (!('transform' in animations)) {
|
|
52
47
|
animations.transform = [];
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
(_animations$transform = animations.transform) === null || _animations$transform === void 0 ? void 0 : _animations$transform.push({
|
|
56
50
|
[key.split(':')[1]]: animation
|
|
57
51
|
});
|
|
@@ -59,7 +53,6 @@ export class Keyframe {
|
|
|
59
53
|
animations[key] = animation;
|
|
60
54
|
}
|
|
61
55
|
};
|
|
62
|
-
|
|
63
56
|
Object.keys(initialValues).forEach(key => {
|
|
64
57
|
if (key.includes('transform')) {
|
|
65
58
|
initialValues[key].forEach((transformProp, index) => {
|
|
@@ -78,10 +71,8 @@ export class Keyframe {
|
|
|
78
71
|
};
|
|
79
72
|
};
|
|
80
73
|
});
|
|
81
|
-
|
|
82
74
|
this.definitions = definitions;
|
|
83
75
|
}
|
|
84
|
-
|
|
85
76
|
parseDefinitions() {
|
|
86
77
|
/*
|
|
87
78
|
Each style property contain an array with all their key points:
|
|
@@ -91,21 +82,17 @@ export class Keyframe {
|
|
|
91
82
|
/*
|
|
92
83
|
Parsing keyframes 'from' and 'to'.
|
|
93
84
|
*/
|
|
94
|
-
|
|
95
85
|
if (this.definitions.from) {
|
|
96
86
|
if (this.definitions['0']) {
|
|
97
87
|
throw Error("You cannot provide both keyframe 0 and 'from' as they both specified initial values");
|
|
98
88
|
}
|
|
99
|
-
|
|
100
89
|
this.definitions['0'] = this.definitions.from;
|
|
101
90
|
delete this.definitions.from;
|
|
102
91
|
}
|
|
103
|
-
|
|
104
92
|
if (this.definitions.to) {
|
|
105
93
|
if (this.definitions['100']) {
|
|
106
94
|
throw Error("You cannot provide both keyframe 100 and 'to' as they both specified values at the end of the animation.");
|
|
107
95
|
}
|
|
108
|
-
|
|
109
96
|
this.definitions['100'] = this.definitions.to;
|
|
110
97
|
delete this.definitions.to;
|
|
111
98
|
}
|
|
@@ -113,21 +100,16 @@ export class Keyframe {
|
|
|
113
100
|
One of the assumptions is that keyframe 0 is required to properly set initial values.
|
|
114
101
|
Every other keyframe should contain properties from the set provided as initial values.
|
|
115
102
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
103
|
if (!this.definitions['0']) {
|
|
119
104
|
throw Error("Please provide 0, or 'from' keyframe with initial state of your object.");
|
|
120
105
|
}
|
|
121
|
-
|
|
122
106
|
const initialValues = this.definitions['0'];
|
|
123
107
|
/*
|
|
124
108
|
Initialize parsedKeyframes for properties provided in initial keyframe
|
|
125
109
|
*/
|
|
126
|
-
|
|
127
110
|
Object.keys(initialValues).forEach(styleProp => {
|
|
128
111
|
if (styleProp === 'transform') {
|
|
129
112
|
var _initialValues$styleP;
|
|
130
|
-
|
|
131
113
|
(_initialValues$styleP = initialValues[styleProp]) === null || _initialValues$styleP === void 0 ? void 0 : _initialValues$styleP.forEach((transformStyle, index) => {
|
|
132
114
|
Object.keys(transformStyle).forEach(transformProp => {
|
|
133
115
|
parsedKeyframes[index.toString() + '_transform:' + transformProp] = [];
|
|
@@ -139,17 +121,15 @@ export class Keyframe {
|
|
|
139
121
|
});
|
|
140
122
|
const duration = this.durationV ? this.durationV : 500;
|
|
141
123
|
const animationKeyPoints = Array.from(Object.keys(this.definitions));
|
|
142
|
-
|
|
143
124
|
const getAnimationDuration = (key, currentKeyPoint) => {
|
|
144
125
|
const maxDuration = currentKeyPoint / 100 * duration;
|
|
145
126
|
const currentDuration = parsedKeyframes[key].reduce((acc, value) => acc + value.duration, 0);
|
|
146
127
|
return maxDuration - currentDuration;
|
|
147
128
|
};
|
|
129
|
+
|
|
148
130
|
/*
|
|
149
131
|
Other keyframes can't contain properties that were not specified in initial keyframe.
|
|
150
132
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
133
|
const addKeyPoint = _ref => {
|
|
154
134
|
let {
|
|
155
135
|
key,
|
|
@@ -157,38 +137,31 @@ export class Keyframe {
|
|
|
157
137
|
currentKeyPoint,
|
|
158
138
|
easing
|
|
159
139
|
} = _ref;
|
|
160
|
-
|
|
161
140
|
if (!(key in parsedKeyframes)) {
|
|
162
141
|
throw Error("Keyframe can contain only that set of properties that were provide with initial values (keyframe 0 or 'from')");
|
|
163
142
|
}
|
|
164
|
-
|
|
165
143
|
parsedKeyframes[key].push({
|
|
166
144
|
duration: getAnimationDuration(key, currentKeyPoint),
|
|
167
145
|
value: value,
|
|
168
146
|
easing: easing
|
|
169
147
|
});
|
|
170
148
|
};
|
|
171
|
-
|
|
172
149
|
animationKeyPoints.filter(value => parseInt(value) !== 0).sort((a, b) => parseInt(a) - parseInt(b)).forEach(keyPoint => {
|
|
173
150
|
if (parseInt(keyPoint) < 0 || parseInt(keyPoint) > 100) {
|
|
174
151
|
throw Error('Keyframe should be in between range 0 - 100.');
|
|
175
152
|
}
|
|
176
|
-
|
|
177
153
|
const keyframe = this.definitions[keyPoint];
|
|
178
154
|
const easing = keyframe.easing;
|
|
179
155
|
delete keyframe.easing;
|
|
180
|
-
|
|
181
156
|
const addKeyPointWith = (key, value) => addKeyPoint({
|
|
182
157
|
key,
|
|
183
158
|
value,
|
|
184
159
|
currentKeyPoint: parseInt(keyPoint),
|
|
185
160
|
easing
|
|
186
161
|
});
|
|
187
|
-
|
|
188
162
|
Object.keys(keyframe).forEach(key => {
|
|
189
163
|
if (key === 'transform') {
|
|
190
164
|
var _keyframe$key;
|
|
191
|
-
|
|
192
165
|
(_keyframe$key = keyframe[key]) === null || _keyframe$key === void 0 ? void 0 : _keyframe$key.forEach((transformStyle, index) => {
|
|
193
166
|
Object.keys(transformStyle).forEach(transformProp => {
|
|
194
167
|
addKeyPointWith(index.toString() + '_transform:' + transformProp, transformStyle[transformProp]);
|
|
@@ -204,22 +177,18 @@ export class Keyframe {
|
|
|
204
177
|
keyframes: parsedKeyframes
|
|
205
178
|
};
|
|
206
179
|
}
|
|
207
|
-
|
|
208
180
|
duration(durationMs) {
|
|
209
181
|
this.durationV = durationMs;
|
|
210
182
|
return this;
|
|
211
183
|
}
|
|
212
|
-
|
|
213
184
|
delay(delayMs) {
|
|
214
185
|
this.delayV = delayMs;
|
|
215
186
|
return this;
|
|
216
187
|
}
|
|
217
|
-
|
|
218
188
|
withCallback(callback) {
|
|
219
189
|
this.callbackV = callback;
|
|
220
190
|
return this;
|
|
221
191
|
}
|
|
222
|
-
|
|
223
192
|
getDelayFunction() {
|
|
224
193
|
const delay = this.delayV;
|
|
225
194
|
return delay ? withDelay : (_, animation) => {
|
|
@@ -228,6 +197,5 @@ export class Keyframe {
|
|
|
228
197
|
return animation;
|
|
229
198
|
};
|
|
230
199
|
}
|
|
231
|
-
|
|
232
200
|
}
|
|
233
201
|
//# sourceMappingURL=Keyframe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Easing","withDelay","withSequence","withTiming","Keyframe","constructor","definitions","delay","delayV","delayFunction","getDelayFunction","keyframes","initialValues","parseDefinitions","callback","callbackV","_targetValues","animations","addAnimation","key","keyframePoints","length","animation","value","duration","easing","linear","apply","map","keyframePoint","includes","transform","push","split","Object","keys","forEach","transformProp","index","transformPropKey","toString","parsedKeyframes","from","Error","to","styleProp","transformStyle","durationV","animationKeyPoints","Array","getAnimationDuration","currentKeyPoint","maxDuration","currentDuration","reduce","acc","addKeyPoint","filter","parseInt","sort","a","b","keyPoint","keyframe","addKeyPointWith","durationMs","delayMs","withCallback","_"],"sources":["Keyframe.ts"],"sourcesContent":["import { Easing, EasingFn } from '../../Easing';\nimport { withDelay, withSequence, withTiming } from '../../animation';\nimport {\n AnimationFunction,\n EntryExitAnimationFunction,\n IEntryExitAnimationBuilder,\n KeyframeProps,\n} from './commonTypes';\nimport { TransformProperty, StyleProps } from '../../commonTypes';\nexport interface KeyframePoint {\n duration: number;\n value: number | string;\n easing?: EasingFn;\n}\nexport interface ParsedKeyframesDefinition {\n initialValues: StyleProps;\n keyframes: Record<string, KeyframePoint[]>;\n}\nexport class Keyframe implements IEntryExitAnimationBuilder {\n durationV?: number;\n delayV?: number;\n callbackV?: (finished: boolean) => void;\n definitions: Record<string, KeyframeProps>;\n\n /*\n Keyframe definition should be passed in the constructor as the map\n which keys are between range 0 - 100 (%) and correspond to the point in the animation progress.\n */\n constructor(definitions: Record<string, KeyframeProps>) {\n this.definitions = definitions;\n }\n\n private parseDefinitions(): ParsedKeyframesDefinition {\n /* \n Each style property contain an array with all their key points: \n value, duration of transition to that value, and optional easing function (defaults to Linear)\n */\n const parsedKeyframes: Record<string, KeyframePoint[]> = {};\n /*\n Parsing keyframes 'from' and 'to'.\n */\n if (this.definitions.from) {\n if (this.definitions['0']) {\n throw Error(\n \"You cannot provide both keyframe 0 and 'from' as they both specified initial values\"\n );\n }\n this.definitions['0'] = this.definitions.from;\n delete this.definitions.from;\n }\n if (this.definitions.to) {\n if (this.definitions['100']) {\n throw Error(\n \"You cannot provide both keyframe 100 and 'to' as they both specified values at the end of the animation.\"\n );\n }\n this.definitions['100'] = this.definitions.to;\n delete this.definitions.to;\n }\n /* \n One of the assumptions is that keyframe 0 is required to properly set initial values.\n Every other keyframe should contain properties from the set provided as initial values.\n */\n if (!this.definitions['0']) {\n throw Error(\n \"Please provide 0, or 'from' keyframe with initial state of your object.\"\n );\n }\n const initialValues: StyleProps = this.definitions['0'] as StyleProps;\n /*\n Initialize parsedKeyframes for properties provided in initial keyframe\n */\n Object.keys(initialValues).forEach((styleProp: string) => {\n if (styleProp === 'transform') {\n initialValues[styleProp]?.forEach((transformStyle, index) => {\n Object.keys(transformStyle).forEach((transformProp: string) => {\n parsedKeyframes[index.toString() + '_transform:' + transformProp] =\n [];\n });\n });\n } else {\n parsedKeyframes[styleProp] = [];\n }\n });\n\n const duration: number = this.durationV ? this.durationV : 500;\n const animationKeyPoints: Array<string> = Array.from(\n Object.keys(this.definitions)\n );\n\n const getAnimationDuration = (\n key: string,\n currentKeyPoint: number\n ): number => {\n const maxDuration = (currentKeyPoint / 100) * duration;\n const currentDuration = parsedKeyframes[key].reduce(\n (acc: number, value: KeyframePoint) => acc + value.duration,\n 0\n );\n return maxDuration - currentDuration;\n };\n\n /* \n Other keyframes can't contain properties that were not specified in initial keyframe.\n */\n const addKeyPoint = ({\n key,\n value,\n currentKeyPoint,\n easing,\n }: {\n key: string;\n value: string | number;\n currentKeyPoint: number;\n easing?: EasingFn;\n }): void => {\n if (!(key in parsedKeyframes)) {\n throw Error(\n \"Keyframe can contain only that set of properties that were provide with initial values (keyframe 0 or 'from')\"\n );\n }\n parsedKeyframes[key].push({\n duration: getAnimationDuration(key, currentKeyPoint),\n value: value,\n easing: easing,\n });\n };\n animationKeyPoints\n .filter((value: string) => parseInt(value) !== 0)\n .sort((a: string, b: string) => parseInt(a) - parseInt(b))\n .forEach((keyPoint: string) => {\n if (parseInt(keyPoint) < 0 || parseInt(keyPoint) > 100) {\n throw Error('Keyframe should be in between range 0 - 100.');\n }\n const keyframe: KeyframeProps = this.definitions[keyPoint];\n const easing = keyframe.easing;\n delete keyframe.easing;\n const addKeyPointWith = (key: string, value: string | number) =>\n addKeyPoint({\n key,\n value,\n currentKeyPoint: parseInt(keyPoint),\n easing,\n });\n Object.keys(keyframe).forEach((key: string) => {\n if (key === 'transform') {\n keyframe[key]?.forEach(\n (transformStyle: { [key: string]: any }, index) => {\n Object.keys(transformStyle).forEach((transformProp: string) => {\n addKeyPointWith(\n index.toString() + '_transform:' + transformProp,\n transformStyle[transformProp]\n );\n });\n }\n );\n } else {\n addKeyPointWith(key, keyframe[key]);\n }\n });\n });\n return { initialValues: initialValues, keyframes: parsedKeyframes };\n }\n\n duration(durationMs: number): Keyframe {\n this.durationV = durationMs;\n return this;\n }\n\n delay(delayMs: number): Keyframe {\n this.delayV = delayMs;\n return this;\n }\n\n withCallback(callback: (finsihed: boolean) => void): Keyframe {\n this.callbackV = callback;\n return this;\n }\n\n private getDelayFunction(): AnimationFunction {\n const delay = this.delayV;\n return delay\n ? withDelay\n : (_, animation) => {\n 'worklet';\n return animation;\n };\n }\n\n build = (): EntryExitAnimationFunction => {\n const delay = this.delayV;\n const delayFunction = this.getDelayFunction();\n const { keyframes, initialValues } = this.parseDefinitions();\n const callback = this.callbackV;\n\n return (_targetValues) => {\n 'worklet';\n const animations: StyleProps = {};\n\n /* \n For each style property, an animations sequence is created that corresponds with its key points.\n Transform style properties require special handling because of their nested structure.\n */\n const addAnimation = (key: string) => {\n const keyframePoints = keyframes[key];\n // in case if property was only passed as initial value\n if (keyframePoints.length === 0) return;\n const animation = delayFunction(\n delay,\n keyframePoints.length === 1\n ? withTiming(keyframePoints[0].value, {\n duration: keyframePoints[0].duration,\n easing: keyframePoints[0].easing\n ? keyframePoints[0].easing\n : Easing.linear,\n })\n : withSequence.apply(\n this,\n keyframePoints.map((keyframePoint: KeyframePoint) =>\n withTiming(keyframePoint.value, {\n duration: keyframePoint.duration,\n easing: keyframePoint.easing\n ? keyframePoint.easing\n : Easing.linear,\n })\n )\n )\n );\n if (key.includes('transform')) {\n if (!('transform' in animations)) {\n animations.transform = [];\n }\n animations.transform?.push(<TransformProperty>{\n [key.split(':')[1]]: animation,\n });\n } else {\n animations[key] = animation;\n }\n };\n Object.keys(initialValues).forEach((key: string) => {\n if (key.includes('transform')) {\n initialValues[key].forEach(\n (transformProp: Record<string, number | string>, index: number) => {\n Object.keys(transformProp).forEach((transformPropKey: string) => {\n addAnimation(\n index.toString() + '_transform:' + transformPropKey\n );\n });\n }\n );\n } else {\n addAnimation(key);\n }\n });\n return {\n animations: animations,\n initialValues: initialValues,\n callback: callback,\n };\n };\n };\n}\n"],"mappings":";;AAAA,SAASA,MAAT,QAAiC,cAAjC;AACA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,UAAlC,QAAoD,iBAApD;AAiBA,OAAO,MAAMC,QAAN,CAAqD;EAM1D;AACF;AACA;AACA;EACEC,WAAW,CAACC,WAAD,EAA6C;IAAA;;IAAA;;IAAA;;IAAA;;IAAA,+BAiKhD,MAAkC;MACxC,MAAMC,KAAK,GAAG,KAAKC,MAAnB;MACA,MAAMC,aAAa,GAAG,KAAKC,gBAAL,EAAtB;MACA,MAAM;QAAEC,SAAF;QAAaC;MAAb,IAA+B,KAAKC,gBAAL,EAArC;MACA,MAAMC,QAAQ,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U,CAAD,CADb;;MAOAS,MAAM,CAACC,IAAP,CAAY4B,QAAZ,EAAsB3B,OAAtB,CAA+BjB,GAAD,IAAiB;QAC7C,IAAIA,GAAG,KAAK,WAAZ,EAAyB;UAAA;;UACvB,iBAAA4C,QAAQ,CAAC5C,GAAD,CAAR,gEAAeiB,OAAf,CACE,CAACU,cAAD,EAAyCR,KAAzC,KAAmD;YACjDJ,MAAM,CAACC,IAAP,CAAYW,cAAZ,EAA4BV,OAA5B,CAAqCC,aAAD,IAA2B;cAC7D2B,eAAe,CACb1B,KAAK,CAACE,QAAN,KAAmB,aAAnB,GAAmCH,aADtB,EAEbS,cAAc,CAACT,aAAD,CAFD,CAAf;YAID,CALD;UAMD,CARH;QAUD,CAXD,MAWO;UACL2B,eAAe,CAAC7C,GAAD,EAAM4C,QAAQ,CAAC5C,GAAD,CAAd,CAAf;QACD;MACF,CAfD;IAgBD,CAjCH;IAkCA,OAAO;MAAEP,aAAa,EAAEA,aAAjB;MAAgCD,SAAS,EAAE8B;IAA3C,CAAP;EACD;;EAEDjB,QAAQ,CAACyC,UAAD,EAA+B;IACrC,KAAKlB,SAAL,GAAiBkB,UAAjB;IACA,OAAO,IAAP;EACD;;EAED1D,KAAK,CAAC2D,OAAD,EAA4B;IAC/B,KAAK1D,MAAL,GAAc0D,OAAd;IACA,OAAO,IAAP;EACD;;EAEDC,YAAY,CAACrD,QAAD,EAAkD;IAC5D,KAAKC,SAAL,GAAiBD,QAAjB;IACA,OAAO,IAAP;EACD;;EAEOJ,gBAAgB,GAAsB;IAC5C,MAAMH,KAAK,GAAG,KAAKC,MAAnB;IACA,OAAOD,KAAK,GACRN,SADQ,GAER,CAACmE,CAAD,EAAI9C,SAAJ,KAAkB;MAChB;;MACA,OAAOA,SAAP;IACD,CALL;EAMD;;AAzKyD"}
|
|
1
|
+
{"version":3,"names":["Easing","withDelay","withSequence","withTiming","Keyframe","constructor","definitions","_defineProperty","delay","delayV","delayFunction","getDelayFunction","keyframes","initialValues","parseDefinitions","callback","callbackV","_targetValues","animations","addAnimation","key","keyframePoints","length","animation","value","duration","easing","linear","apply","map","keyframePoint","includes","_animations$transform","transform","push","split","Object","keys","forEach","transformProp","index","transformPropKey","toString","parsedKeyframes","from","Error","to","styleProp","_initialValues$styleP","transformStyle","durationV","animationKeyPoints","Array","getAnimationDuration","currentKeyPoint","maxDuration","currentDuration","reduce","acc","addKeyPoint","_ref","filter","parseInt","sort","a","b","keyPoint","keyframe","addKeyPointWith","_keyframe$key","durationMs","delayMs","withCallback","_"],"sources":["Keyframe.ts"],"sourcesContent":["import { Easing, EasingFn } from '../../Easing';\nimport { withDelay, withSequence, withTiming } from '../../animation';\nimport {\n AnimationFunction,\n EntryExitAnimationFunction,\n IEntryExitAnimationBuilder,\n KeyframeProps,\n} from './commonTypes';\nimport { TransformProperty, StyleProps } from '../../commonTypes';\nexport interface KeyframePoint {\n duration: number;\n value: number | string;\n easing?: EasingFn;\n}\nexport interface ParsedKeyframesDefinition {\n initialValues: StyleProps;\n keyframes: Record<string, KeyframePoint[]>;\n}\nexport class Keyframe implements IEntryExitAnimationBuilder {\n durationV?: number;\n delayV?: number;\n callbackV?: (finished: boolean) => void;\n definitions: Record<string, KeyframeProps>;\n\n /*\n Keyframe definition should be passed in the constructor as the map\n which keys are between range 0 - 100 (%) and correspond to the point in the animation progress.\n */\n constructor(definitions: Record<string, KeyframeProps>) {\n this.definitions = definitions;\n }\n\n private parseDefinitions(): ParsedKeyframesDefinition {\n /* \n Each style property contain an array with all their key points: \n value, duration of transition to that value, and optional easing function (defaults to Linear)\n */\n const parsedKeyframes: Record<string, KeyframePoint[]> = {};\n /*\n Parsing keyframes 'from' and 'to'.\n */\n if (this.definitions.from) {\n if (this.definitions['0']) {\n throw Error(\n \"You cannot provide both keyframe 0 and 'from' as they both specified initial values\"\n );\n }\n this.definitions['0'] = this.definitions.from;\n delete this.definitions.from;\n }\n if (this.definitions.to) {\n if (this.definitions['100']) {\n throw Error(\n \"You cannot provide both keyframe 100 and 'to' as they both specified values at the end of the animation.\"\n );\n }\n this.definitions['100'] = this.definitions.to;\n delete this.definitions.to;\n }\n /* \n One of the assumptions is that keyframe 0 is required to properly set initial values.\n Every other keyframe should contain properties from the set provided as initial values.\n */\n if (!this.definitions['0']) {\n throw Error(\n \"Please provide 0, or 'from' keyframe with initial state of your object.\"\n );\n }\n const initialValues: StyleProps = this.definitions['0'] as StyleProps;\n /*\n Initialize parsedKeyframes for properties provided in initial keyframe\n */\n Object.keys(initialValues).forEach((styleProp: string) => {\n if (styleProp === 'transform') {\n initialValues[styleProp]?.forEach((transformStyle, index) => {\n Object.keys(transformStyle).forEach((transformProp: string) => {\n parsedKeyframes[index.toString() + '_transform:' + transformProp] =\n [];\n });\n });\n } else {\n parsedKeyframes[styleProp] = [];\n }\n });\n\n const duration: number = this.durationV ? this.durationV : 500;\n const animationKeyPoints: Array<string> = Array.from(\n Object.keys(this.definitions)\n );\n\n const getAnimationDuration = (\n key: string,\n currentKeyPoint: number\n ): number => {\n const maxDuration = (currentKeyPoint / 100) * duration;\n const currentDuration = parsedKeyframes[key].reduce(\n (acc: number, value: KeyframePoint) => acc + value.duration,\n 0\n );\n return maxDuration - currentDuration;\n };\n\n /* \n Other keyframes can't contain properties that were not specified in initial keyframe.\n */\n const addKeyPoint = ({\n key,\n value,\n currentKeyPoint,\n easing,\n }: {\n key: string;\n value: string | number;\n currentKeyPoint: number;\n easing?: EasingFn;\n }): void => {\n if (!(key in parsedKeyframes)) {\n throw Error(\n \"Keyframe can contain only that set of properties that were provide with initial values (keyframe 0 or 'from')\"\n );\n }\n parsedKeyframes[key].push({\n duration: getAnimationDuration(key, currentKeyPoint),\n value: value,\n easing: easing,\n });\n };\n animationKeyPoints\n .filter((value: string) => parseInt(value) !== 0)\n .sort((a: string, b: string) => parseInt(a) - parseInt(b))\n .forEach((keyPoint: string) => {\n if (parseInt(keyPoint) < 0 || parseInt(keyPoint) > 100) {\n throw Error('Keyframe should be in between range 0 - 100.');\n }\n const keyframe: KeyframeProps = this.definitions[keyPoint];\n const easing = keyframe.easing;\n delete keyframe.easing;\n const addKeyPointWith = (key: string, value: string | number) =>\n addKeyPoint({\n key,\n value,\n currentKeyPoint: parseInt(keyPoint),\n easing,\n });\n Object.keys(keyframe).forEach((key: string) => {\n if (key === 'transform') {\n keyframe[key]?.forEach(\n (transformStyle: { [key: string]: any }, index) => {\n Object.keys(transformStyle).forEach((transformProp: string) => {\n addKeyPointWith(\n index.toString() + '_transform:' + transformProp,\n transformStyle[transformProp]\n );\n });\n }\n );\n } else {\n addKeyPointWith(key, keyframe[key]);\n }\n });\n });\n return { initialValues: initialValues, keyframes: parsedKeyframes };\n }\n\n duration(durationMs: number): Keyframe {\n this.durationV = durationMs;\n return this;\n }\n\n delay(delayMs: number): Keyframe {\n this.delayV = delayMs;\n return this;\n }\n\n withCallback(callback: (finsihed: boolean) => void): Keyframe {\n this.callbackV = callback;\n return this;\n }\n\n private getDelayFunction(): AnimationFunction {\n const delay = this.delayV;\n return delay\n ? withDelay\n : (_, animation) => {\n 'worklet';\n return animation;\n };\n }\n\n build = (): EntryExitAnimationFunction => {\n const delay = this.delayV;\n const delayFunction = this.getDelayFunction();\n const { keyframes, initialValues } = this.parseDefinitions();\n const callback = this.callbackV;\n\n return (_targetValues) => {\n 'worklet';\n const animations: StyleProps = {};\n\n /* \n For each style property, an animations sequence is created that corresponds with its key points.\n Transform style properties require special handling because of their nested structure.\n */\n const addAnimation = (key: string) => {\n const keyframePoints = keyframes[key];\n // in case if property was only passed as initial value\n if (keyframePoints.length === 0) return;\n const animation = delayFunction(\n delay,\n keyframePoints.length === 1\n ? withTiming(keyframePoints[0].value, {\n duration: keyframePoints[0].duration,\n easing: keyframePoints[0].easing\n ? keyframePoints[0].easing\n : Easing.linear,\n })\n : withSequence.apply(\n this,\n keyframePoints.map((keyframePoint: KeyframePoint) =>\n withTiming(keyframePoint.value, {\n duration: keyframePoint.duration,\n easing: keyframePoint.easing\n ? keyframePoint.easing\n : Easing.linear,\n })\n )\n )\n );\n if (key.includes('transform')) {\n if (!('transform' in animations)) {\n animations.transform = [];\n }\n animations.transform?.push(<TransformProperty>{\n [key.split(':')[1]]: animation,\n });\n } else {\n animations[key] = animation;\n }\n };\n Object.keys(initialValues).forEach((key: string) => {\n if (key.includes('transform')) {\n initialValues[key].forEach(\n (transformProp: Record<string, number | string>, index: number) => {\n Object.keys(transformProp).forEach((transformPropKey: string) => {\n addAnimation(\n index.toString() + '_transform:' + transformPropKey\n );\n });\n }\n );\n } else {\n addAnimation(key);\n }\n });\n return {\n animations: animations,\n initialValues: initialValues,\n callback: callback,\n };\n };\n };\n}\n"],"mappings":";;;AAAA,SAASA,MAAM,QAAkB,cAAc;AAC/C,SAASC,SAAS,EAAEC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAiBrE,OAAO,MAAMC,QAAQ,CAAuC;EAM1D;AACF;AACA;AACA;EACEC,WAAWA,CAACC,WAA0C,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,gBAiKhD,MAAkC;MACxC,MAAMC,KAAK,GAAG,IAAI,CAACC,MAAM;MACzB,MAAMC,aAAa,GAAG,IAAI,CAACC,gBAAgB,EAAE;MAC7C,MAAM;QAAEC,SAAS;QAAEC;MAAc,CAAC,GAAG,IAAI,CAACC,gBAAgB,EAAE;MAC5D,MAAMC,QAAQ,GAAG,IAAI,CAACC,SAAS;MAE/B,OAAQC,aAAa,IAAK;QACxB,SAAS;;QACT,MAAMC,UAAsB,GAAG,CAAC,CAAC;;QAEjC;AACN;AACA;AACA;QACM,MAAMC,YAAY,GAAIC,GAAW,IAAK;UACpC,MAAMC,cAAc,GAAGT,SAAS,CAACQ,GAAG,CAAC;UACrC;UACA,IAAIC,cAAc,CAACC,MAAM,KAAK,CAAC,EAAE;UACjC,MAAMC,SAAS,GAAGb,aAAa,CAC7BF,KAAK,EACLa,cAAc,CAACC,MAAM,KAAK,CAAC,GACvBnB,UAAU,C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G,CAAC,cAAAiD,aAAA,uBAAbA,aAAA,CAAe/B,OAAO,CACpB,CAACW,cAAsC,EAAET,KAAK,KAAK;YACjDJ,MAAM,CAACC,IAAI,CAACY,cAAc,CAAC,CAACX,OAAO,CAAEC,aAAqB,IAAK;cAC7D6B,eAAe,CACb5B,KAAK,CAACE,QAAQ,EAAE,GAAG,aAAa,GAAGH,aAAa,EAChDU,cAAc,CAACV,aAAa,CAAC,CAC9B;YACH,CAAC,CAAC;UACJ,CAAC,CACF;QACH,CAAC,MAAM;UACL6B,eAAe,CAAChD,GAAG,EAAE+C,QAAQ,CAAC/C,GAAG,CAAC,CAAC;QACrC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IACJ,OAAO;MAAEP,aAAa,EAAEA,aAAa;MAAED,SAAS,EAAE+B;IAAgB,CAAC;EACrE;EAEAlB,QAAQA,CAAC6C,UAAkB,EAAY;IACrC,IAAI,CAACpB,SAAS,GAAGoB,UAAU;IAC3B,OAAO,IAAI;EACb;EAEA9D,KAAKA,CAAC+D,OAAe,EAAY;IAC/B,IAAI,CAAC9D,MAAM,GAAG8D,OAAO;IACrB,OAAO,IAAI;EACb;EAEAC,YAAYA,CAACzD,QAAqC,EAAY;IAC5D,IAAI,CAACC,SAAS,GAAGD,QAAQ;IACzB,OAAO,IAAI;EACb;EAEQJ,gBAAgBA,CAAA,EAAsB;IAC5C,MAAMH,KAAK,GAAG,IAAI,CAACC,MAAM;IACzB,OAAOD,KAAK,GACRP,SAAS,GACT,CAACwE,CAAC,EAAElD,SAAS,KAAK;MAChB,SAAS;;MACT,OAAOA,SAAS;IAClB,CAAC;EACP;AA0EF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// this is just a temporary mock
|
|
2
|
-
export let LayoutAnimationType;
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
export let LayoutAnimationType = /*#__PURE__*/function (LayoutAnimationType) {
|
|
5
4
|
LayoutAnimationType[LayoutAnimationType["ENTERING"] = 1] = "ENTERING";
|
|
6
5
|
LayoutAnimationType[LayoutAnimationType["EXITING"] = 2] = "EXITING";
|
|
7
6
|
LayoutAnimationType[LayoutAnimationType["LAYOUT"] = 3] = "LAYOUT";
|
|
8
7
|
LayoutAnimationType[LayoutAnimationType["SHARED_ELEMENT_TRANSITION"] = 4] = "SHARED_ELEMENT_TRANSITION";
|
|
9
|
-
|
|
8
|
+
return LayoutAnimationType;
|
|
9
|
+
}({});
|
|
10
10
|
//# sourceMappingURL=commonTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LayoutAnimationType"],"sources":["commonTypes.ts"],"sourcesContent":["import { EasingFn } from '../../Easing';\nimport { StyleProps } from '../../commonTypes';\n\nexport interface KeyframeProps extends StyleProps {\n easing?: EasingFn;\n [key: string]: any;\n}\n\nexport type LayoutAnimation = {\n initialValues: StyleProps;\n animations: StyleProps;\n callback?: (finished: boolean) => void;\n};\n\nexport type AnimationFunction = (a?: any, b?: any, c?: any) => any; // this is just a temporary mock\n\nexport interface EntryAnimationsValues {\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport interface ExitAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport type EntryExitAnimationFunction = (\n targetValues: EntryAnimationsValues | ExitAnimationsValues\n) => LayoutAnimation;\n\nexport type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;\n\nexport interface LayoutAnimationsValues {\n [key: string]: number;\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport enum LayoutAnimationType {\n ENTERING = 1,\n EXITING = 2,\n LAYOUT = 3,\n SHARED_ELEMENT_TRANSITION = 4,\n}\n\nexport type LayoutAnimationFunction = (\n targetValues: LayoutAnimationsValues\n) => LayoutAnimation;\n\nexport type LayoutAnimationStartFunction = (\n tag: number,\n type: LayoutAnimationType,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n) => void;\n\nexport interface ILayoutAnimationBuilder {\n build: () => LayoutAnimationFunction;\n}\n\nexport interface BaseLayoutAnimationConfig {\n duration?: number;\n easing?: EasingFn;\n type?: AnimationFunction;\n damping?: number;\n mass?: number;\n stiffness?: number;\n overshootClamping?: number;\n restDisplacementThreshold?: number;\n restSpeedThreshold?: number;\n}\n\nexport interface BaseBuilderAnimationConfig extends BaseLayoutAnimationConfig {\n rotate?: number | string;\n}\n\nexport type LayoutAnimationAndConfig = [\n AnimationFunction,\n BaseBuilderAnimationConfig\n];\n\nexport interface IEntryExitAnimationBuilder {\n build: () => EntryExitAnimationFunction;\n}\n\nexport interface IEntryAnimationBuilder {\n build: () => AnimationConfigFunction<EntryAnimationsValues>;\n}\n\nexport interface IExitAnimationBuilder {\n build: () => AnimationConfigFunction<ExitAnimationsValues>;\n}\n"],"mappings":"AAcoE
|
|
1
|
+
{"version":3,"names":["LayoutAnimationType"],"sources":["commonTypes.ts"],"sourcesContent":["import { EasingFn } from '../../Easing';\nimport { StyleProps } from '../../commonTypes';\n\nexport interface KeyframeProps extends StyleProps {\n easing?: EasingFn;\n [key: string]: any;\n}\n\nexport type LayoutAnimation = {\n initialValues: StyleProps;\n animations: StyleProps;\n callback?: (finished: boolean) => void;\n};\n\nexport type AnimationFunction = (a?: any, b?: any, c?: any) => any; // this is just a temporary mock\n\nexport interface EntryAnimationsValues {\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport interface ExitAnimationsValues {\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport type EntryExitAnimationFunction = (\n targetValues: EntryAnimationsValues | ExitAnimationsValues\n) => LayoutAnimation;\n\nexport type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;\n\nexport interface LayoutAnimationsValues {\n [key: string]: number;\n currentOriginX: number;\n currentOriginY: number;\n currentWidth: number;\n currentHeight: number;\n currentGlobalOriginX: number;\n currentGlobalOriginY: number;\n targetOriginX: number;\n targetOriginY: number;\n targetWidth: number;\n targetHeight: number;\n targetGlobalOriginX: number;\n targetGlobalOriginY: number;\n windowWidth: number;\n windowHeight: number;\n}\n\nexport enum LayoutAnimationType {\n ENTERING = 1,\n EXITING = 2,\n LAYOUT = 3,\n SHARED_ELEMENT_TRANSITION = 4,\n}\n\nexport type LayoutAnimationFunction = (\n targetValues: LayoutAnimationsValues\n) => LayoutAnimation;\n\nexport type LayoutAnimationStartFunction = (\n tag: number,\n type: LayoutAnimationType,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n) => void;\n\nexport interface ILayoutAnimationBuilder {\n build: () => LayoutAnimationFunction;\n}\n\nexport interface BaseLayoutAnimationConfig {\n duration?: number;\n easing?: EasingFn;\n type?: AnimationFunction;\n damping?: number;\n mass?: number;\n stiffness?: number;\n overshootClamping?: number;\n restDisplacementThreshold?: number;\n restSpeedThreshold?: number;\n}\n\nexport interface BaseBuilderAnimationConfig extends BaseLayoutAnimationConfig {\n rotate?: number | string;\n}\n\nexport type LayoutAnimationAndConfig = [\n AnimationFunction,\n BaseBuilderAnimationConfig\n];\n\nexport interface IEntryExitAnimationBuilder {\n build: () => EntryExitAnimationFunction;\n}\n\nexport interface IEntryAnimationBuilder {\n build: () => AnimationConfigFunction<EntryAnimationsValues>;\n}\n\nexport interface IExitAnimationBuilder {\n build: () => AnimationConfigFunction<ExitAnimationsValues>;\n}\n"],"mappings":"AAcoE;;AAgDpE,WAAYA,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAnBA,mBAAmB,CAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BaseAnimationBuilder","ComplexAnimationBuilder","Keyframe","LayoutAnimationType"],"sources":["index.ts"],"sourcesContent":["export { BaseAnimationBuilder } from './BaseAnimationBuilder';\nexport { ComplexAnimationBuilder } from './ComplexAnimationBuilder';\nexport { Keyframe } from './Keyframe';\nexport { LayoutAnimationType } from './commonTypes';\nexport type {\n LayoutAnimation,\n AnimationFunction,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n AnimationConfigFunction,\n IEntryAnimationBuilder,\n IExitAnimationBuilder,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n LayoutAnimationStartFunction,\n ILayoutAnimationBuilder,\n BaseLayoutAnimationConfig,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n IEntryExitAnimationBuilder,\n} from './commonTypes';\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"names":["BaseAnimationBuilder","ComplexAnimationBuilder","Keyframe","LayoutAnimationType"],"sources":["index.ts"],"sourcesContent":["export { BaseAnimationBuilder } from './BaseAnimationBuilder';\nexport { ComplexAnimationBuilder } from './ComplexAnimationBuilder';\nexport { Keyframe } from './Keyframe';\nexport { LayoutAnimationType } from './commonTypes';\nexport type {\n LayoutAnimation,\n AnimationFunction,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n AnimationConfigFunction,\n IEntryAnimationBuilder,\n IExitAnimationBuilder,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n LayoutAnimationStartFunction,\n ILayoutAnimationBuilder,\n BaseLayoutAnimationConfig,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n IEntryExitAnimationBuilder,\n} from './commonTypes';\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,mBAAmB,QAAQ,eAAe"}
|
|
@@ -3,7 +3,6 @@ import { makeUIMutable } from '../mutables';
|
|
|
3
3
|
import { LayoutAnimationType } from './animationBuilder';
|
|
4
4
|
import { runOnUIImmediately } from '../threads';
|
|
5
5
|
const TAG_OFFSET = 1e9;
|
|
6
|
-
|
|
7
6
|
function startObservingProgress(tag, sharedValue, animationType) {
|
|
8
7
|
'worklet';
|
|
9
8
|
|
|
@@ -12,15 +11,12 @@ function startObservingProgress(tag, sharedValue, animationType) {
|
|
|
12
11
|
_notifyAboutProgress(tag, sharedValue.value, isSharedTransition);
|
|
13
12
|
});
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
function stopObservingProgress(tag, sharedValue, cancelled, removeView) {
|
|
17
15
|
'worklet';
|
|
18
16
|
|
|
19
17
|
sharedValue.removeListener(tag + TAG_OFFSET);
|
|
20
|
-
|
|
21
18
|
_notifyAboutEnd(tag, cancelled, removeView);
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
function createLayoutAnimationManager() {
|
|
25
21
|
'worklet';
|
|
26
22
|
|
|
@@ -30,34 +26,30 @@ function createLayoutAnimationManager() {
|
|
|
30
26
|
start(tag, type, yogaValues, config) {
|
|
31
27
|
const style = config(yogaValues);
|
|
32
28
|
let currentAnimation = style.animations;
|
|
33
|
-
|
|
34
29
|
if (type === LayoutAnimationType.ENTERING) {
|
|
35
30
|
enteringAnimationForTag.set(tag, currentAnimation);
|
|
36
31
|
} else if (type === LayoutAnimationType.LAYOUT) {
|
|
37
32
|
// When layout animation is requested, but entering is still running, we merge
|
|
38
33
|
// new layout animation targets into the ongoing animation
|
|
39
34
|
const enteringAnimation = enteringAnimationForTag.get(tag);
|
|
40
|
-
|
|
41
35
|
if (enteringAnimation) {
|
|
42
|
-
currentAnimation = {
|
|
36
|
+
currentAnimation = {
|
|
37
|
+
...enteringAnimation,
|
|
43
38
|
...style.animations
|
|
44
39
|
};
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
|
-
|
|
48
42
|
let value = mutableValuesForTag.get(tag);
|
|
49
|
-
|
|
50
43
|
if (value === undefined) {
|
|
51
44
|
value = makeUIMutable(style.initialValues);
|
|
52
45
|
mutableValuesForTag.set(tag, value);
|
|
53
46
|
} else {
|
|
54
47
|
stopObservingProgress(tag, value, false, false);
|
|
55
48
|
value._value = style.initialValues;
|
|
56
|
-
}
|
|
57
|
-
|
|
49
|
+
}
|
|
58
50
|
|
|
51
|
+
// @ts-ignore The line below started failing because I added types to the method – don't have time to fix it right now
|
|
59
52
|
const animation = withStyleAnimation(currentAnimation);
|
|
60
|
-
|
|
61
53
|
animation.callback = finished => {
|
|
62
54
|
if (finished) {
|
|
63
55
|
enteringAnimationForTag.delete(tag);
|
|
@@ -65,27 +57,20 @@ function createLayoutAnimationManager() {
|
|
|
65
57
|
const shouldRemoveView = type === LayoutAnimationType.EXITING;
|
|
66
58
|
stopObservingProgress(tag, value, finished, shouldRemoveView);
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
style.callback && style.callback(finished === undefined ? false : finished);
|
|
70
61
|
};
|
|
71
|
-
|
|
72
62
|
startObservingProgress(tag, value, type);
|
|
73
63
|
value.value = animation;
|
|
74
64
|
},
|
|
75
|
-
|
|
76
65
|
stop(tag) {
|
|
77
66
|
const value = mutableValuesForTag.get(tag);
|
|
78
|
-
|
|
79
67
|
if (!value) {
|
|
80
68
|
return;
|
|
81
69
|
}
|
|
82
|
-
|
|
83
70
|
stopObservingProgress(tag, value, true, true);
|
|
84
71
|
}
|
|
85
|
-
|
|
86
72
|
};
|
|
87
73
|
}
|
|
88
|
-
|
|
89
74
|
runOnUIImmediately(() => {
|
|
90
75
|
'worklet';
|
|
91
76
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withStyleAnimation","makeUIMutable","LayoutAnimationType","runOnUIImmediately","TAG_OFFSET","startObservingProgress","tag","sharedValue","animationType","isSharedTransition","SHARED_ELEMENT_TRANSITION","addListener","_notifyAboutProgress","value","stopObservingProgress","cancelled","removeView","removeListener","_notifyAboutEnd","createLayoutAnimationManager","enteringAnimationForTag","Map","mutableValuesForTag","start","type","yogaValues","config","style","currentAnimation","animations","ENTERING","set","LAYOUT","enteringAnimation","get","undefined","initialValues","_value","animation","callback","finished","delete","shouldRemoveView","EXITING","stop","global","LayoutAnimationsManager"],"sources":["animationsManager.ts"],"sourcesContent":["import { withStyleAnimation } from '../animation/styleAnimation';\nimport { SharedValue } from '../commonTypes';\nimport { makeUIMutable } from '../mutables';\nimport {\n LayoutAnimationFunction,\n LayoutAnimationType,\n LayoutAnimationsValues,\n} from './animationBuilder';\nimport { runOnUIImmediately } from '../threads';\n\nconst TAG_OFFSET = 1e9;\n\nfunction startObservingProgress(\n tag: number,\n sharedValue: SharedValue<number>,\n animationType: LayoutAnimationType\n): void {\n 'worklet';\n const isSharedTransition =\n animationType === LayoutAnimationType.SHARED_ELEMENT_TRANSITION;\n sharedValue.addListener(tag + TAG_OFFSET, () => {\n _notifyAboutProgress(tag, sharedValue.value, isSharedTransition);\n });\n}\n\nfunction stopObservingProgress(\n tag: number,\n sharedValue: SharedValue<number>,\n cancelled: boolean,\n removeView: boolean\n): void {\n 'worklet';\n sharedValue.removeListener(tag + TAG_OFFSET);\n _notifyAboutEnd(tag, cancelled, removeView);\n}\n\nfunction createLayoutAnimationManager() {\n 'worklet';\n const enteringAnimationForTag = new Map();\n const mutableValuesForTag = new Map();\n\n return {\n start(\n tag: number,\n type: LayoutAnimationType,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n ) {\n const style = config(yogaValues);\n let currentAnimation = style.animations;\n\n if (type === LayoutAnimationType.ENTERING) {\n enteringAnimationForTag.set(tag, currentAnimation);\n } else if (type === LayoutAnimationType.LAYOUT) {\n // When layout animation is requested, but entering is still running, we merge\n // new layout animation targets into the ongoing animation\n const enteringAnimation = enteringAnimationForTag.get(tag);\n if (enteringAnimation) {\n currentAnimation = { ...enteringAnimation, ...style.animations };\n }\n }\n\n let value = mutableValuesForTag.get(tag);\n if (value === undefined) {\n value = makeUIMutable(style.initialValues);\n mutableValuesForTag.set(tag, value);\n } else {\n stopObservingProgress(tag, value, false, false);\n value._value = style.initialValues;\n }\n\n // @ts-ignore The line below started failing because I added types to the method – don't have time to fix it right now\n const animation = withStyleAnimation(currentAnimation);\n\n animation.callback = (finished?: boolean) => {\n if (finished) {\n enteringAnimationForTag.delete(tag);\n mutableValuesForTag.delete(tag);\n const shouldRemoveView = type === LayoutAnimationType.EXITING;\n stopObservingProgress(tag, value, finished, shouldRemoveView);\n }\n style.callback &&\n style.callback(finished === undefined ? false : finished);\n };\n\n startObservingProgress(tag, value, type);\n value.value = animation;\n },\n stop(tag: number) {\n const value = mutableValuesForTag.get(tag);\n if (!value) {\n return;\n }\n stopObservingProgress(tag, value, true, true);\n },\n };\n}\n\nrunOnUIImmediately(() => {\n 'worklet';\n global.LayoutAnimationsManager = createLayoutAnimationManager();\n})();\n"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"names":["withStyleAnimation","makeUIMutable","LayoutAnimationType","runOnUIImmediately","TAG_OFFSET","startObservingProgress","tag","sharedValue","animationType","isSharedTransition","SHARED_ELEMENT_TRANSITION","addListener","_notifyAboutProgress","value","stopObservingProgress","cancelled","removeView","removeListener","_notifyAboutEnd","createLayoutAnimationManager","enteringAnimationForTag","Map","mutableValuesForTag","start","type","yogaValues","config","style","currentAnimation","animations","ENTERING","set","LAYOUT","enteringAnimation","get","undefined","initialValues","_value","animation","callback","finished","delete","shouldRemoveView","EXITING","stop","global","LayoutAnimationsManager"],"sources":["animationsManager.ts"],"sourcesContent":["import { withStyleAnimation } from '../animation/styleAnimation';\nimport { SharedValue } from '../commonTypes';\nimport { makeUIMutable } from '../mutables';\nimport {\n LayoutAnimationFunction,\n LayoutAnimationType,\n LayoutAnimationsValues,\n} from './animationBuilder';\nimport { runOnUIImmediately } from '../threads';\n\nconst TAG_OFFSET = 1e9;\n\nfunction startObservingProgress(\n tag: number,\n sharedValue: SharedValue<number>,\n animationType: LayoutAnimationType\n): void {\n 'worklet';\n const isSharedTransition =\n animationType === LayoutAnimationType.SHARED_ELEMENT_TRANSITION;\n sharedValue.addListener(tag + TAG_OFFSET, () => {\n _notifyAboutProgress(tag, sharedValue.value, isSharedTransition);\n });\n}\n\nfunction stopObservingProgress(\n tag: number,\n sharedValue: SharedValue<number>,\n cancelled: boolean,\n removeView: boolean\n): void {\n 'worklet';\n sharedValue.removeListener(tag + TAG_OFFSET);\n _notifyAboutEnd(tag, cancelled, removeView);\n}\n\nfunction createLayoutAnimationManager() {\n 'worklet';\n const enteringAnimationForTag = new Map();\n const mutableValuesForTag = new Map();\n\n return {\n start(\n tag: number,\n type: LayoutAnimationType,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n ) {\n const style = config(yogaValues);\n let currentAnimation = style.animations;\n\n if (type === LayoutAnimationType.ENTERING) {\n enteringAnimationForTag.set(tag, currentAnimation);\n } else if (type === LayoutAnimationType.LAYOUT) {\n // When layout animation is requested, but entering is still running, we merge\n // new layout animation targets into the ongoing animation\n const enteringAnimation = enteringAnimationForTag.get(tag);\n if (enteringAnimation) {\n currentAnimation = { ...enteringAnimation, ...style.animations };\n }\n }\n\n let value = mutableValuesForTag.get(tag);\n if (value === undefined) {\n value = makeUIMutable(style.initialValues);\n mutableValuesForTag.set(tag, value);\n } else {\n stopObservingProgress(tag, value, false, false);\n value._value = style.initialValues;\n }\n\n // @ts-ignore The line below started failing because I added types to the method – don't have time to fix it right now\n const animation = withStyleAnimation(currentAnimation);\n\n animation.callback = (finished?: boolean) => {\n if (finished) {\n enteringAnimationForTag.delete(tag);\n mutableValuesForTag.delete(tag);\n const shouldRemoveView = type === LayoutAnimationType.EXITING;\n stopObservingProgress(tag, value, finished, shouldRemoveView);\n }\n style.callback &&\n style.callback(finished === undefined ? false : finished);\n };\n\n startObservingProgress(tag, value, type);\n value.value = animation;\n },\n stop(tag: number) {\n const value = mutableValuesForTag.get(tag);\n if (!value) {\n return;\n }\n stopObservingProgress(tag, value, true, true);\n },\n };\n}\n\nrunOnUIImmediately(() => {\n 'worklet';\n global.LayoutAnimationsManager = createLayoutAnimationManager();\n})();\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,6BAA6B;AAEhE,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAEEC,mBAAmB,QAEd,oBAAoB;AAC3B,SAASC,kBAAkB,QAAQ,YAAY;AAE/C,MAAMC,UAAU,GAAG,GAAG;AAEtB,SAASC,sBAAsBA,CAC7BC,GAAW,EACXC,WAAgC,EAChCC,aAAkC,EAC5B;EACN,SAAS;;EACT,MAAMC,kBAAkB,GACtBD,aAAa,KAAKN,mBAAmB,CAACQ,yBAAyB;EACjEH,WAAW,CAACI,WAAW,CAACL,GAAG,GAAGF,UAAU,EAAE,MAAM;IAC9CQ,oBAAoB,CAACN,GAAG,EAAEC,WAAW,CAACM,KAAK,EAAEJ,kBAAkB,CAAC;EAClE,CAAC,CAAC;AACJ;AAEA,SAASK,qBAAqBA,CAC5BR,GAAW,EACXC,WAAgC,EAChCQ,SAAkB,EAClBC,UAAmB,EACb;EACN,SAAS;;EACTT,WAAW,CAACU,cAAc,CAACX,GAAG,GAAGF,UAAU,CAAC;EAC5Cc,eAAe,CAACZ,GAAG,EAAES,SAAS,EAAEC,UAAU,CAAC;AAC7C;AAEA,SAASG,4BAA4BA,CAAA,EAAG;EACtC,SAAS;;EACT,MAAMC,uBAAuB,GAAG,IAAIC,GAAG,EAAE;EACzC,MAAMC,mBAAmB,GAAG,IAAID,GAAG,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