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
|
@@ -7,7 +7,6 @@ export const Extrapolate = {
|
|
|
7
7
|
CLAMP: 'clamp',
|
|
8
8
|
IDENTITY: 'identity'
|
|
9
9
|
};
|
|
10
|
-
|
|
11
10
|
const interpolateColorsHSV = (value, inputRange, colors, options) => {
|
|
12
11
|
'worklet';
|
|
13
12
|
|
|
@@ -15,7 +14,6 @@ const interpolateColorsHSV = (value, inputRange, colors, options) => {
|
|
|
15
14
|
const {
|
|
16
15
|
useCorrectedHSVInterpolation = true
|
|
17
16
|
} = options;
|
|
18
|
-
|
|
19
17
|
if (useCorrectedHSVInterpolation) {
|
|
20
18
|
// if the difference between hues in a range is > 180 deg
|
|
21
19
|
// then move the hue at the right end of the range +/- 360 deg
|
|
@@ -24,10 +22,8 @@ const interpolateColorsHSV = (value, inputRange, colors, options) => {
|
|
|
24
22
|
const correctedInputRange = [inputRange[0]];
|
|
25
23
|
const originalH = colors.h;
|
|
26
24
|
const correctedH = [originalH[0]];
|
|
27
|
-
|
|
28
25
|
for (let i = 1; i < originalH.length; ++i) {
|
|
29
26
|
const d = originalH[i] - originalH[i - 1];
|
|
30
|
-
|
|
31
27
|
if (originalH[i] > originalH[i - 1] && d > 0.5) {
|
|
32
28
|
correctedInputRange.push(inputRange[i]);
|
|
33
29
|
correctedInputRange.push(inputRange[i] + 0.00001);
|
|
@@ -43,30 +39,25 @@ const interpolateColorsHSV = (value, inputRange, colors, options) => {
|
|
|
43
39
|
correctedH.push(originalH[i]);
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
|
-
|
|
47
42
|
h = (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) + 1) % 1;
|
|
48
43
|
} else {
|
|
49
44
|
h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);
|
|
53
47
|
const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);
|
|
54
48
|
const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
|
|
55
49
|
return hsvToColor(h, s, v, a);
|
|
56
50
|
};
|
|
57
|
-
|
|
58
51
|
const toLinearSpace = (x, gamma) => {
|
|
59
52
|
'worklet';
|
|
60
53
|
|
|
61
54
|
return x.map(v => Math.pow(v / 255, gamma));
|
|
62
55
|
};
|
|
63
|
-
|
|
64
56
|
const toGammaSpace = (x, gamma) => {
|
|
65
57
|
'worklet';
|
|
66
58
|
|
|
67
59
|
return Math.round(Math.pow(x, 1 / gamma) * 255);
|
|
68
60
|
};
|
|
69
|
-
|
|
70
61
|
const interpolateColorsRGB = (value, inputRange, colors, options) => {
|
|
71
62
|
'worklet';
|
|
72
63
|
|
|
@@ -78,25 +69,20 @@ const interpolateColorsRGB = (value, inputRange, colors, options) => {
|
|
|
78
69
|
g: outputG,
|
|
79
70
|
b: outputB
|
|
80
71
|
} = colors;
|
|
81
|
-
|
|
82
72
|
if (gamma !== 1) {
|
|
83
73
|
outputR = toLinearSpace(outputR, gamma);
|
|
84
74
|
outputG = toLinearSpace(outputG, gamma);
|
|
85
75
|
outputB = toLinearSpace(outputB, gamma);
|
|
86
76
|
}
|
|
87
|
-
|
|
88
77
|
const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);
|
|
89
78
|
const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);
|
|
90
79
|
const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);
|
|
91
80
|
const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
|
|
92
|
-
|
|
93
81
|
if (gamma === 1) {
|
|
94
82
|
return rgbaColor(r, g, b, a);
|
|
95
83
|
}
|
|
96
|
-
|
|
97
84
|
return rgbaColor(toGammaSpace(r, gamma), toGammaSpace(g, gamma), toGammaSpace(b, gamma), a);
|
|
98
85
|
};
|
|
99
|
-
|
|
100
86
|
const getInterpolateRGB = colors => {
|
|
101
87
|
'worklet';
|
|
102
88
|
|
|
@@ -104,11 +90,10 @@ const getInterpolateRGB = colors => {
|
|
|
104
90
|
const g = [];
|
|
105
91
|
const b = [];
|
|
106
92
|
const a = [];
|
|
107
|
-
|
|
108
93
|
for (let i = 0; i < colors.length; ++i) {
|
|
109
94
|
const color = colors[i];
|
|
110
|
-
const processedColor = processColor(color);
|
|
111
|
-
|
|
95
|
+
const processedColor = processColor(color);
|
|
96
|
+
// explicit check in case if processedColor is 0
|
|
112
97
|
if (processedColor !== null && processedColor !== undefined) {
|
|
113
98
|
r.push(red(processedColor));
|
|
114
99
|
g.push(green(processedColor));
|
|
@@ -116,7 +101,6 @@ const getInterpolateRGB = colors => {
|
|
|
116
101
|
a.push(opacity(processedColor));
|
|
117
102
|
}
|
|
118
103
|
}
|
|
119
|
-
|
|
120
104
|
return {
|
|
121
105
|
r,
|
|
122
106
|
g,
|
|
@@ -124,7 +108,6 @@ const getInterpolateRGB = colors => {
|
|
|
124
108
|
a
|
|
125
109
|
};
|
|
126
110
|
};
|
|
127
|
-
|
|
128
111
|
const getInterpolateHSV = colors => {
|
|
129
112
|
'worklet';
|
|
130
113
|
|
|
@@ -132,11 +115,9 @@ const getInterpolateHSV = colors => {
|
|
|
132
115
|
const s = [];
|
|
133
116
|
const v = [];
|
|
134
117
|
const a = [];
|
|
135
|
-
|
|
136
118
|
for (let i = 0; i < colors.length; ++i) {
|
|
137
119
|
const color = colors[i];
|
|
138
120
|
const processedColor = processColor(color);
|
|
139
|
-
|
|
140
121
|
if (typeof processedColor === 'number') {
|
|
141
122
|
const processedHSVColor = RGBtoHSV(red(processedColor), green(processedColor), blue(processedColor));
|
|
142
123
|
h.push(processedHSVColor.h);
|
|
@@ -145,7 +126,6 @@ const getInterpolateHSV = colors => {
|
|
|
145
126
|
a.push(opacity(processedColor));
|
|
146
127
|
}
|
|
147
128
|
}
|
|
148
|
-
|
|
149
129
|
return {
|
|
150
130
|
h,
|
|
151
131
|
s,
|
|
@@ -153,28 +133,23 @@ const getInterpolateHSV = colors => {
|
|
|
153
133
|
a
|
|
154
134
|
};
|
|
155
135
|
};
|
|
156
|
-
|
|
157
136
|
export const interpolateColor = function (value, inputRange, outputRange) {
|
|
158
137
|
'worklet';
|
|
159
138
|
|
|
160
139
|
let colorSpace = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'RGB';
|
|
161
140
|
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
162
|
-
|
|
163
141
|
if (colorSpace === 'HSV') {
|
|
164
142
|
return interpolateColorsHSV(value, inputRange, getInterpolateHSV(outputRange), options);
|
|
165
143
|
} else if (colorSpace === 'RGB') {
|
|
166
144
|
return interpolateColorsRGB(value, inputRange, getInterpolateRGB(outputRange), options);
|
|
167
145
|
}
|
|
168
|
-
|
|
169
146
|
throw new Error(`Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`);
|
|
170
147
|
};
|
|
171
|
-
export let ColorSpace
|
|
172
|
-
|
|
173
|
-
(function (ColorSpace) {
|
|
148
|
+
export let ColorSpace = /*#__PURE__*/function (ColorSpace) {
|
|
174
149
|
ColorSpace[ColorSpace["RGB"] = 0] = "RGB";
|
|
175
150
|
ColorSpace[ColorSpace["HSV"] = 1] = "HSV";
|
|
176
|
-
|
|
177
|
-
|
|
151
|
+
return ColorSpace;
|
|
152
|
+
}({});
|
|
178
153
|
export function useInterpolateConfig(inputRange, outputRange) {
|
|
179
154
|
let colorSpace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ColorSpace.RGB;
|
|
180
155
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
@@ -190,23 +165,19 @@ export const interpolateSharableColor = (value, interpolateConfig) => {
|
|
|
190
165
|
'worklet';
|
|
191
166
|
|
|
192
167
|
let colors = interpolateConfig.value.cache.value;
|
|
193
|
-
|
|
194
168
|
if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {
|
|
195
169
|
if (!colors) {
|
|
196
170
|
colors = getInterpolateRGB(interpolateConfig.value.outputRange);
|
|
197
171
|
interpolateConfig.value.cache.value = colors;
|
|
198
172
|
}
|
|
199
|
-
|
|
200
173
|
return interpolateColorsRGB(value, interpolateConfig.value.inputRange, colors, interpolateConfig.value.options);
|
|
201
174
|
} else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {
|
|
202
175
|
if (!colors) {
|
|
203
176
|
colors = getInterpolateHSV(interpolateConfig.value.outputRange);
|
|
204
177
|
interpolateConfig.value.cache.value = colors;
|
|
205
178
|
}
|
|
206
|
-
|
|
207
179
|
return interpolateColorsHSV(value, interpolateConfig.value.inputRange, colors, interpolateConfig.value.options);
|
|
208
180
|
}
|
|
209
|
-
|
|
210
181
|
throw new Error(`Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`);
|
|
211
182
|
};
|
|
212
183
|
//# sourceMappingURL=interpolateColor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","interpolate","useSharedValue","Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","Error","ColorSpace","useInterpolateConfig","RGB","cache","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\ninterface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\ninterface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport const interpolateColor = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number => {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB,\n interpolateConfig.value.options\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV,\n interpolateConfig.value.options\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":"AAAA,SACEA,UADF,EAEEC,QAFF,EAGEC,SAHF,EAIEC,YAJF,EAKEC,GALF,EAMEC,KANF,EAOEC,IAPF,EAQEC,OARF,QASO,UATP;AAUA,SAASC,WAAT,QAA4B,QAA5B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA,SAASC,cAAT,QAA+B,uBAA/B;AAEA,OAAO,MAAMC,WAAW,GAAG;EACzBC,MAAM,EAAE,QADiB;EAEzBC,KAAK,EAAE,OAFkB;EAGzBC,QAAQ,EAAE;AAHe,CAApB;;AAWP,MAAMC,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,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A9B,GAAsCE,MAAtC;IACD;;IACD,OAAOH,oBAAoB,CACzBC,KADyB,EAEzB8C,iBAAiB,CAAC9C,KAAlB,CAAwBC,UAFC,EAGzBC,MAHyB,EAIzB4C,iBAAiB,CAAC9C,KAAlB,CAAwBG,OAJC,CAA3B;EAMD;;EACD,MAAM,IAAIqC,KAAJ,CACH,iCAAgCM,iBAAiB,CAAC9C,KAAlB,CAAwBuC,UAAW,wCADhE,CAAN;AAGD,CAhCM"}
|
|
1
|
+
{"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","interpolate","useSharedValue","Extrapolate","EXTEND","CLAMP","IDENTITY","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","arguments","Error","ColorSpace","useInterpolateConfig","RGB","cache","interpolateSharableColor","interpolateConfig","HSV"],"sources":["interpolateColor.ts"],"sourcesContent":["import {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { interpolate } from './interpolation';\nimport { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\nexport const Extrapolate = {\n EXTEND: 'extend',\n CLAMP: 'clamp',\n IDENTITY: 'identity',\n};\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\ninterface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\ninterface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport const interpolateColor = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number => {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n\nexport const interpolateSharableColor = (\n value: number,\n interpolateConfig: SharedValue<InterpolateConfig>\n): string | number => {\n 'worklet';\n let colors = interpolateConfig.value.cache.value;\n if (interpolateConfig.value.colorSpace === ColorSpace.RGB) {\n if (!colors) {\n colors = getInterpolateRGB(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsRGB(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateRGB,\n interpolateConfig.value.options\n );\n } else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {\n if (!colors) {\n colors = getInterpolateHSV(interpolateConfig.value.outputRange);\n interpolateConfig.value.cache.value = colors;\n }\n return interpolateColorsHSV(\n value,\n interpolateConfig.value.inputRange,\n colors as InterpolateHSV,\n interpolateConfig.value.options\n );\n }\n throw new Error(\n `Invalid color space provided: ${interpolateConfig.value.colorSpace}. Supported values are: ['RGB', 'HSV']`\n );\n};\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,OAAO,QACF,UAAU;AACjB,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,WAA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MAC/DS,iBAAiB,CAAC/C,KAAK,CAAC6C,KAAK,CAAC7C,KAAK,GAAGE,MAAM;IAC9C;IACA,OAAOsB,oBAAoB,CACzBxB,KAAK,EACL+C,iBAAiB,CAAC/C,KAAK,CAACC,UAAU,EAClCC,MAAM,EACN6C,iBAAiB,CAAC/C,KAAK,CAACG,OAAO,CAChC;EACH,CAAC,MAAM,IAAI4C,iBAAiB,CAAC/C,KAAK,CAACuC,UAAU,KAAKG,UAAU,CAACM,GAAG,EAAE;IAChE,IAAI,CAAC9C,MAAM,EAAE;MACXA,MAAM,GAAGiC,iBAAiB,CAACY,iBAAiB,CAAC/C,KAAK,CAACsC,WAAW,CAAC;MAC/DS,iBAAiB,CAAC/C,KAAK,CAAC6C,KAAK,CAAC7C,KAAK,GAAGE,MAAM;IAC9C;IACA,OAAOH,oBAAoB,CACzBC,KAAK,EACL+C,iBAAiB,CAAC/C,KAAK,CAACC,UAAU,EAClCC,MAAM,EACN6C,iBAAiB,CAAC/C,KAAK,CAACG,OAAO,CAChC;EACH;EACA,MAAM,IAAIsC,KAAK,CACZ,iCAAgCM,iBAAiB,CAAC/C,KAAK,CAACuC,UAAW,wCAAuC,CAC5G;AACH,CAAC"}
|
|
@@ -1,63 +1,55 @@
|
|
|
1
|
-
export let Extrapolation
|
|
2
|
-
|
|
3
|
-
(function (Extrapolation) {
|
|
1
|
+
export let Extrapolation = /*#__PURE__*/function (Extrapolation) {
|
|
4
2
|
Extrapolation["IDENTITY"] = "identity";
|
|
5
3
|
Extrapolation["CLAMP"] = "clamp";
|
|
6
4
|
Extrapolation["EXTEND"] = "extend";
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
return Extrapolation;
|
|
6
|
+
}({});
|
|
9
7
|
function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
|
|
10
8
|
'worklet';
|
|
11
9
|
|
|
12
10
|
switch (type) {
|
|
13
11
|
case Extrapolation.IDENTITY:
|
|
14
12
|
return x;
|
|
15
|
-
|
|
16
13
|
case Extrapolation.CLAMP:
|
|
17
14
|
if (coef * val < coef * leftEdgeOutput) {
|
|
18
15
|
return leftEdgeOutput;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
return rightEdgeOutput;
|
|
22
|
-
|
|
23
18
|
case Extrapolation.EXTEND:
|
|
24
19
|
default:
|
|
25
20
|
return val;
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
function isExtrapolate(value) {
|
|
30
24
|
'worklet';
|
|
31
25
|
|
|
32
26
|
return value === Extrapolation.EXTEND || value === Extrapolation.CLAMP || value === Extrapolation.IDENTITY;
|
|
33
|
-
}
|
|
34
|
-
// if type is correct, converts it to ExtrapolationConfig
|
|
35
|
-
|
|
27
|
+
}
|
|
36
28
|
|
|
29
|
+
// validates extrapolations type
|
|
30
|
+
// if type is correct, converts it to ExtrapolationConfig
|
|
37
31
|
function validateType(type) {
|
|
38
|
-
'worklet';
|
|
32
|
+
'worklet';
|
|
39
33
|
|
|
34
|
+
// initialize extrapolationConfig with default extrapolation
|
|
40
35
|
const extrapolationConfig = {
|
|
41
36
|
extrapolateLeft: Extrapolation.EXTEND,
|
|
42
37
|
extrapolateRight: Extrapolation.EXTEND
|
|
43
38
|
};
|
|
44
|
-
|
|
45
39
|
if (!type) {
|
|
46
40
|
return extrapolationConfig;
|
|
47
41
|
}
|
|
48
|
-
|
|
49
42
|
if (typeof type === 'string') {
|
|
50
43
|
if (!isExtrapolate(type)) {
|
|
51
44
|
throw new Error(`Reanimated: not supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
|
|
52
45
|
interpolate(value, [inputRange], [outputRange], "clamp")`);
|
|
53
46
|
}
|
|
54
|
-
|
|
55
47
|
extrapolationConfig.extrapolateLeft = type;
|
|
56
48
|
extrapolationConfig.extrapolateRight = type;
|
|
57
49
|
return extrapolationConfig;
|
|
58
|
-
}
|
|
59
|
-
|
|
50
|
+
}
|
|
60
51
|
|
|
52
|
+
// otherwise type is extrapolation config object
|
|
61
53
|
if (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft) || type.extrapolateRight && !isExtrapolate(type.extrapolateRight)) {
|
|
62
54
|
throw new Error(`Reanimated: not supported value for "interpolate" \nSupported values: ["extend", "clamp", "identity", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\n Valid example:
|
|
63
55
|
interpolate(value, [inputRange], [outputRange], {
|
|
@@ -65,11 +57,9 @@ function validateType(type) {
|
|
|
65
57
|
extrapolateRight: Extrapolation.IDENTITY
|
|
66
58
|
}})`);
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
Object.assign(extrapolationConfig, type);
|
|
70
61
|
return extrapolationConfig;
|
|
71
62
|
}
|
|
72
|
-
|
|
73
63
|
function internalInterpolate(x, narrowedInput, extrapolationConfig) {
|
|
74
64
|
'worklet';
|
|
75
65
|
|
|
@@ -83,25 +73,22 @@ function internalInterpolate(x, narrowedInput, extrapolationConfig) {
|
|
|
83
73
|
const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);
|
|
84
74
|
const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);
|
|
85
75
|
const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;
|
|
86
|
-
|
|
87
76
|
if (coef * val < coef * leftEdgeOutput) {
|
|
88
77
|
return getVal(extrapolationConfig.extrapolateLeft, coef, val, leftEdgeOutput, rightEdgeOutput, x);
|
|
89
78
|
} else if (coef * val > coef * rightEdgeOutput) {
|
|
90
79
|
return getVal(extrapolationConfig.extrapolateRight, coef, val, leftEdgeOutput, rightEdgeOutput, x);
|
|
91
80
|
}
|
|
92
|
-
|
|
93
81
|
return val;
|
|
94
|
-
}
|
|
95
|
-
// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)
|
|
96
|
-
|
|
82
|
+
}
|
|
97
83
|
|
|
84
|
+
// TODO: support default values in worklets:
|
|
85
|
+
// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)
|
|
98
86
|
export function interpolate(x, input, output, type) {
|
|
99
87
|
'worklet';
|
|
100
88
|
|
|
101
89
|
if (input.length < 2 || output.length < 2) {
|
|
102
90
|
throw Error('Interpolation input and output should contain at least two values.');
|
|
103
91
|
}
|
|
104
|
-
|
|
105
92
|
const extrapolationConfig = validateType(type);
|
|
106
93
|
const length = input.length;
|
|
107
94
|
const narrowedInput = {
|
|
@@ -110,7 +97,6 @@ export function interpolate(x, input, output, type) {
|
|
|
110
97
|
leftEdgeOutput: output[0],
|
|
111
98
|
rightEdgeOutput: output[1]
|
|
112
99
|
};
|
|
113
|
-
|
|
114
100
|
if (length > 2) {
|
|
115
101
|
if (x > input[length - 1]) {
|
|
116
102
|
narrowedInput.leftEdgeInput = input[length - 2];
|
|
@@ -129,7 +115,6 @@ export function interpolate(x, input, output, type) {
|
|
|
129
115
|
}
|
|
130
116
|
}
|
|
131
117
|
}
|
|
132
|
-
|
|
133
118
|
return internalInterpolate(x, narrowedInput, extrapolationConfig);
|
|
134
119
|
}
|
|
135
120
|
//# sourceMappingURL=interpolation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Extrapolation","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolation.ts"],"sourcesContent":["export enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string;\n extrapolateRight?: Extrapolation | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation;\n extrapolateRight: Extrapolation;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n 'worklet';\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x;\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolation.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'worklet';\n\n return (\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'worklet';\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `Reanimated: not supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `Reanimated: not supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n 'worklet';\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// TODO: support default values in worklets:\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n 'worklet';\n if (input.length < 2 || output.length < 2) {\n throw Error(\n 'Interpolation input and output should contain at least two values.'\n );\n }\n\n const extrapolationConfig = validateType(type);\n const length = input.length;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":"AAAA,WAAYA,
|
|
1
|
+
{"version":3,"names":["Extrapolation","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i"],"sources":["interpolation.ts"],"sourcesContent":["export enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string;\n extrapolateRight?: Extrapolation | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation;\n extrapolateRight: Extrapolation;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | string\n | undefined;\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n 'worklet';\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x;\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolation.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'worklet';\n\n return (\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'worklet';\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `Reanimated: not supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `Reanimated: not supported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n 'worklet';\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// TODO: support default values in worklets:\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n 'worklet';\n if (input.length < 2 || output.length < 2) {\n throw Error(\n 'Interpolation input and output should contain at least two values.'\n );\n }\n\n const extrapolationConfig = validateType(type);\n const length = input.length;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n"],"mappings":"AAAA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AA6BzB,SAASC,MAAMA,CACbC,IAAmB,EACnBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS,EACD;EACR,SAAS;;EAET,QAAQL,IAAI;IACV,K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
|
2
2
|
// @ts-nocheck
|
|
3
|
+
|
|
3
4
|
let config = {
|
|
4
5
|
fps: 60
|
|
5
6
|
};
|
|
6
|
-
|
|
7
7
|
const isAnimatedStyle = style => {
|
|
8
8
|
return !!style.animatedStyle;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
10
|
const getAnimatedStyleFromObject = style => {
|
|
12
11
|
return style.animatedStyle.current.value;
|
|
13
12
|
};
|
|
14
|
-
|
|
15
13
|
const getCurrentStyle = received => {
|
|
16
14
|
const styleObject = received.props.style;
|
|
17
15
|
let currentStyle = {};
|
|
18
|
-
|
|
19
16
|
if (Array.isArray(styleObject)) {
|
|
20
17
|
received.props.style.forEach(style => {
|
|
21
18
|
if (isAnimatedStyle(style)) {
|
|
22
|
-
currentStyle = {
|
|
19
|
+
currentStyle = {
|
|
20
|
+
...currentStyle,
|
|
23
21
|
...getAnimatedStyleFromObject(style)
|
|
24
22
|
};
|
|
25
23
|
} else {
|
|
26
|
-
currentStyle = {
|
|
24
|
+
currentStyle = {
|
|
25
|
+
...currentStyle,
|
|
27
26
|
...style
|
|
28
27
|
};
|
|
29
28
|
}
|
|
@@ -32,19 +31,17 @@ const getCurrentStyle = received => {
|
|
|
32
31
|
if (isAnimatedStyle(styleObject)) {
|
|
33
32
|
currentStyle = getAnimatedStyleFromObject(styleObject);
|
|
34
33
|
} else {
|
|
35
|
-
currentStyle = {
|
|
34
|
+
currentStyle = {
|
|
35
|
+
...styleObject,
|
|
36
36
|
...received.props.animatedStyle.value
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
40
|
return currentStyle;
|
|
42
41
|
};
|
|
43
|
-
|
|
44
42
|
const checkEqual = (currentStyle, expectStyle) => {
|
|
45
43
|
if (Array.isArray(expectStyle)) {
|
|
46
44
|
if (expectStyle.length !== currentStyle.length) return false;
|
|
47
|
-
|
|
48
45
|
for (let i = 0; i < currentStyle.length; i++) {
|
|
49
46
|
if (!checkEqual(currentStyle[i], expectStyle[i])) {
|
|
50
47
|
return false;
|
|
@@ -59,14 +56,11 @@ const checkEqual = (currentStyle, expectStyle) => {
|
|
|
59
56
|
} else {
|
|
60
57
|
return currentStyle === expectStyle;
|
|
61
58
|
}
|
|
62
|
-
|
|
63
59
|
return true;
|
|
64
60
|
};
|
|
65
|
-
|
|
66
61
|
const findStyleDiff = (current, expect, requireAllMatch) => {
|
|
67
62
|
const diffs = [];
|
|
68
63
|
let isEqual = true;
|
|
69
|
-
|
|
70
64
|
for (const property in expect) {
|
|
71
65
|
if (!checkEqual(current[property], expect[property])) {
|
|
72
66
|
isEqual = false;
|
|
@@ -77,10 +71,8 @@ const findStyleDiff = (current, expect, requireAllMatch) => {
|
|
|
77
71
|
});
|
|
78
72
|
}
|
|
79
73
|
}
|
|
80
|
-
|
|
81
74
|
if (requireAllMatch && Object.keys(current).length !== Object.keys(expect).length) {
|
|
82
75
|
isEqual = false;
|
|
83
|
-
|
|
84
76
|
for (const property in current) {
|
|
85
77
|
if (expect[property] === undefined) {
|
|
86
78
|
diffs.push({
|
|
@@ -91,13 +83,11 @@ const findStyleDiff = (current, expect, requireAllMatch) => {
|
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
85
|
}
|
|
94
|
-
|
|
95
86
|
return {
|
|
96
87
|
isEqual,
|
|
97
88
|
diffs
|
|
98
89
|
};
|
|
99
90
|
};
|
|
100
|
-
|
|
101
91
|
const compareStyle = (received, expectedStyle, config) => {
|
|
102
92
|
if (!received.props.style) {
|
|
103
93
|
return {
|
|
@@ -105,7 +95,6 @@ const compareStyle = (received, expectedStyle, config) => {
|
|
|
105
95
|
pass: false
|
|
106
96
|
};
|
|
107
97
|
}
|
|
108
|
-
|
|
109
98
|
const {
|
|
110
99
|
exact
|
|
111
100
|
} = config;
|
|
@@ -114,14 +103,12 @@ const compareStyle = (received, expectedStyle, config) => {
|
|
|
114
103
|
isEqual,
|
|
115
104
|
diffs
|
|
116
105
|
} = findStyleDiff(currentStyle, expectedStyle, exact);
|
|
117
|
-
|
|
118
106
|
if (isEqual) {
|
|
119
107
|
return {
|
|
120
108
|
message: () => 'ok',
|
|
121
109
|
pass: true
|
|
122
110
|
};
|
|
123
111
|
}
|
|
124
|
-
|
|
125
112
|
const currentStyleStr = JSON.stringify(currentStyle);
|
|
126
113
|
const expectedStyleStr = JSON.stringify(expectedStyle);
|
|
127
114
|
const differences = diffs.map(diff => `- '${diff.property}' should be ${JSON.stringify(diff.expect)}, but is ${JSON.stringify(diff.current)}`).join('\n');
|
|
@@ -130,18 +117,14 @@ const compareStyle = (received, expectedStyle, config) => {
|
|
|
130
117
|
pass: false
|
|
131
118
|
};
|
|
132
119
|
};
|
|
133
|
-
|
|
134
120
|
let frameTime = 1000 / config.fps;
|
|
135
|
-
|
|
136
121
|
const beforeTest = () => {
|
|
137
122
|
jest.useFakeTimers();
|
|
138
123
|
};
|
|
139
|
-
|
|
140
124
|
const afterTest = () => {
|
|
141
125
|
jest.runOnlyPendingTimers();
|
|
142
126
|
jest.useRealTimers();
|
|
143
127
|
};
|
|
144
|
-
|
|
145
128
|
export const withReanimatedTimer = animationTest => {
|
|
146
129
|
console.warn('This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing');
|
|
147
130
|
beforeTest();
|
|
@@ -162,30 +145,24 @@ export const advanceAnimationByFrame = count => {
|
|
|
162
145
|
export const setUpTests = function () {
|
|
163
146
|
let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
164
147
|
let expect = global.expect;
|
|
165
|
-
|
|
166
148
|
if (expect === undefined) {
|
|
167
149
|
const expectModule = require('expect');
|
|
168
|
-
|
|
169
|
-
|
|
150
|
+
expect = expectModule;
|
|
151
|
+
// Starting from Jest 28, "expect" package uses named exports instead of default export.
|
|
170
152
|
// So, requiring "expect" package doesn't give direct access to "expect" function anymore.
|
|
171
153
|
// It gives access to the module object instead.
|
|
172
154
|
// We use this info to detect if the project uses Jest 28 or higher.
|
|
173
|
-
|
|
174
155
|
if (typeof expect === 'object') {
|
|
175
156
|
const jestGlobals = require('@jest/globals');
|
|
176
|
-
|
|
177
157
|
expect = jestGlobals.expect;
|
|
178
158
|
}
|
|
179
|
-
|
|
180
159
|
if (expect === undefined || expect.extend === undefined) {
|
|
181
160
|
expect = expectModule.default;
|
|
182
161
|
}
|
|
183
162
|
}
|
|
184
|
-
|
|
185
|
-
require('setimmediate');
|
|
186
|
-
|
|
187
163
|
frameTime = Math.round(1000 / config.fps);
|
|
188
|
-
config = {
|
|
164
|
+
config = {
|
|
165
|
+
...config,
|
|
189
166
|
...userConfig
|
|
190
167
|
};
|
|
191
168
|
expect.extend({
|
|
@@ -193,7 +170,6 @@ export const setUpTests = function () {
|
|
|
193
170
|
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
194
171
|
return compareStyle(received, expectedStyle, config);
|
|
195
172
|
}
|
|
196
|
-
|
|
197
173
|
});
|
|
198
174
|
};
|
|
199
175
|
export const getAnimatedStyle = received => {
|