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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["initSensorData","sensorType","SensorType","ROTATION","makeMutable","qw","qx","qy","qz","yaw","pitch","roll","interfaceOrientation","x","y","z","eulerToQuaternion","c1","Math","cos","s1","sin","c2","s2","c3","s3","adjustRotationToInterfaceOrientation","data","PI","q","adjustVectorToInterfaceOrientation","useAnimatedSensor","userConfig","ref","useRef","sensor","unregister","isAvailable","config","interval","adjustToInterfaceOrientation","iosReferenceFrame","IOSReferenceFrame","Auto","useEffect","current","sensorData","id","registerSensor","value","
|
|
1
|
+
{"version":3,"names":["_react","require","_core","_commonTypes","_threads","initSensorData","sensorType","SensorType","ROTATION","makeMutable","qw","qx","qy","qz","yaw","pitch","roll","interfaceOrientation","x","y","z","eulerToQuaternion","c1","Math","cos","s1","sin","c2","s2","c3","s3","adjustRotationToInterfaceOrientation","data","PI","q","adjustVectorToInterfaceOrientation","useAnimatedSensor","userConfig","ref","useRef","sensor","unregister","isAvailable","config","interval","adjustToInterfaceOrientation","iosReferenceFrame","IOSReferenceFrame","Auto","useEffect","current","sensorData","id","registerSensor","value","callMicrotasks","unregisterSensor"],"sources":["useAnimatedSensor.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { makeMutable, registerSensor, unregisterSensor } from '../core';\nimport {\n SensorType,\n SharedValue,\n Value3D,\n ValueRotation,\n IOSReferenceFrame,\n} from '../commonTypes';\nimport { callMicrotasks } from '../threads';\n\nexport type SensorConfig = {\n interval: number | 'auto';\n adjustToInterfaceOrientation: boolean;\n iosReferenceFrame: IOSReferenceFrame;\n};\n\nexport type AnimatedSensor = {\n sensor: SharedValue<Value3D | ValueRotation>;\n unregister: () => void;\n isAvailable: boolean;\n config: SensorConfig;\n};\n\nfunction initSensorData(\n sensorType: SensorType\n): SharedValue<Value3D | ValueRotation> {\n if (sensorType === SensorType.ROTATION) {\n return makeMutable<Value3D | ValueRotation>({\n qw: 0,\n qx: 0,\n qy: 0,\n qz: 0,\n yaw: 0,\n pitch: 0,\n roll: 0,\n interfaceOrientation: 0,\n });\n } else {\n return makeMutable<Value3D | ValueRotation>({\n x: 0,\n y: 0,\n z: 0,\n interfaceOrientation: 0,\n });\n }\n}\n\n// euler angles are in order ZXY, z = yaw, x = pitch, y = roll\n// https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L237\nfunction eulerToQuaternion(pitch: number, roll: number, yaw: number) {\n 'worklet';\n const c1 = Math.cos(pitch / 2);\n const s1 = Math.sin(pitch / 2);\n const c2 = Math.cos(roll / 2);\n const s2 = Math.sin(roll / 2);\n const c3 = Math.cos(yaw / 2);\n const s3 = Math.sin(yaw / 2);\n\n return [\n s1 * c2 * c3 - c1 * s2 * s3,\n c1 * s2 * c3 + s1 * c2 * s3,\n c1 * c2 * s3 + s1 * s2 * c3,\n c1 * c2 * c3 - s1 * s2 * s3,\n ];\n}\n\nfunction adjustRotationToInterfaceOrientation(data: ValueRotation) {\n 'worklet';\n const { interfaceOrientation, pitch, roll, yaw } = data;\n if (interfaceOrientation === 90) {\n data.pitch = roll;\n data.roll = -pitch;\n data.yaw = yaw - Math.PI / 2;\n } else if (interfaceOrientation === 270) {\n data.pitch = -roll;\n data.roll = pitch;\n data.yaw = yaw + Math.PI / 2;\n } else if (interfaceOrientation === 180) {\n data.pitch *= -1;\n data.roll *= -1;\n data.yaw *= -1;\n }\n\n const q = eulerToQuaternion(data.pitch, data.roll, data.yaw);\n data.qx = q[0];\n data.qy = q[1];\n data.qz = q[2];\n data.qw = q[3];\n return data;\n}\n\nfunction adjustVectorToInterfaceOrientation(data: Value3D) {\n 'worklet';\n const { interfaceOrientation, x, y } = data;\n if (interfaceOrientation === 90) {\n data.x = -y;\n data.y = x;\n } else if (interfaceOrientation === 270) {\n data.x = y;\n data.y = -x;\n } else if (interfaceOrientation === 180) {\n data.x *= -1;\n data.y *= -1;\n }\n return data;\n}\n\nexport function useAnimatedSensor(\n sensorType: SensorType,\n userConfig?: Partial<SensorConfig>\n): AnimatedSensor {\n const ref = useRef<AnimatedSensor>({\n sensor: initSensorData(sensorType),\n unregister: () => {\n // NOOP\n },\n isAvailable: false,\n config: {\n interval: 0,\n adjustToInterfaceOrientation: true,\n iosReferenceFrame: IOSReferenceFrame.Auto,\n },\n });\n\n useEffect(() => {\n ref.current.config = {\n interval: 'auto',\n adjustToInterfaceOrientation: true,\n iosReferenceFrame: IOSReferenceFrame.Auto,\n ...userConfig,\n };\n const sensorData = ref.current.sensor!;\n const id = registerSensor(\n sensorType,\n ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval,\n ref.current.config.iosReferenceFrame,\n (data) => {\n 'worklet';\n if (ref.current.config.adjustToInterfaceOrientation) {\n if (sensorType === SensorType.ROTATION) {\n data = adjustRotationToInterfaceOrientation(data as ValueRotation);\n } else {\n data = adjustVectorToInterfaceOrientation(data as Value3D);\n }\n }\n sensorData.value = data;\n callMicrotasks();\n }\n );\n\n if (id !== -1) {\n // if sensor is available\n ref.current.unregister = () => unregisterSensor(id);\n ref.current.isAvailable = true;\n } else {\n // if sensor is unavailable\n ref.current.unregister = () => {\n // NOOP\n };\n ref.current.isAvailable = false;\n }\n\n return () => {\n ref.current.unregister();\n };\n }, [sensorType, userConfig]);\n\n return ref.current;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAOA,IAAAG,QAAA,GAAAH,OAAA;AAeA,SAASI,cAAcA,CACrBC,UAAsB,EACgB;EACtC,IAAIA,UAAU,KAAKC,uBAAU,CAACC,QAAQ,EAAE;IACtC,OAAO,IAAAC,iBAAW,EAA0B;MAC1CC,EAAE,EAAE,CAAC;MACLC,EAAE,EAAE,CAAC;MACLC,EAAE,EAAE,CAAC;MACLC,EAAE,EAAE,CAAC;MACLC,GAAG,EAAE,CAAC;MACNC,KAAK,EAAE,CAAC;MACRC,IAAI,EAAE,CAAC;MACPC,oBAAoB,EAAE;IACxB,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,OAAO,IAAAR,iBAAW,EAA0B;MAC1CS,CAAC,EAAE,CAAC;MACJC,CAAC,EAAE,CAAC;MACJC,CAAC,EAAE,CAAC;MACJH,oBAAoB,EAAE;IACxB,CAAC,CAAC;EACJ;AACF;;AAEA;AACA;AACA,SAASI,iBAAiBA,CAACN,KAAa,EAAEC,IAAY,EAAEF,GAAW,EAAE;EACnE,SAAS;;EACT,MAAMQ,EAAE,GAAGC,IAAI,CAACC,GAAG,CAACT,KAAK,GAAG,CAAC,CAAC;EAC9B,MAAMU,EAAE,GAAGF,IAAI,CAACG,GAAG,CAACX,KAAK,GAAG,CAAC,CAAC;EAC9B,MAAMY,EAAE,GAAGJ,IAAI,CAACC,GAAG,CAACR,I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G,CAACY,OAAO,CAACT,UAAU,GAAG,MAAM;QAC7B;MAAA,CACD;MACDH,GAAG,CAACY,OAAO,CAACR,WAAW,GAAG,KAAK;IACjC;IAEA,OAAO,MAAM;MACXJ,GAAG,CAACY,OAAO,CAACT,UAAU,EAAE;IAC1B,CAAC;EACH,CAAC,EAAE,CAACnC,UAAU,EAAE+B,UAAU,CAAC,CAAC;EAE5B,OAAOC,GAAG,CAACY,OAAO;AACpB"}
|
|
@@ -4,44 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimatedStyle = useAnimatedStyle;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _core = require("../core");
|
|
11
|
-
|
|
12
9
|
var _UpdateProps = _interopRequireWildcard(require("../UpdateProps"));
|
|
13
|
-
|
|
14
10
|
var _animation = require("../animation");
|
|
15
|
-
|
|
16
11
|
var _NativeReanimated = _interopRequireDefault(require("../NativeReanimated"));
|
|
17
|
-
|
|
18
12
|
var _useSharedValue = require("./useSharedValue");
|
|
19
|
-
|
|
20
13
|
var _utils = require("./utils");
|
|
21
|
-
|
|
22
14
|
var _ViewDescriptorsSet = require("../ViewDescriptorsSet");
|
|
23
|
-
|
|
24
15
|
var _PlatformChecker = require("../PlatformChecker");
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
-
|
|
30
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
-
|
|
32
19
|
function prepareAnimation(frameTimestamp, animatedProp, lastAnimation, lastValue) {
|
|
33
20
|
'worklet';
|
|
34
21
|
|
|
35
22
|
if (Array.isArray(animatedProp)) {
|
|
36
23
|
animatedProp.forEach((prop, index) => {
|
|
37
24
|
prepareAnimation(frameTimestamp, prop, lastAnimation && lastAnimation[index], lastValue && lastValue[index]);
|
|
38
|
-
});
|
|
25
|
+
});
|
|
26
|
+
// return animatedProp;
|
|
39
27
|
}
|
|
40
28
|
|
|
41
29
|
if (typeof animatedProp === 'object' && animatedProp.onFrame) {
|
|
42
30
|
const animation = animatedProp;
|
|
43
31
|
let value = animation.current;
|
|
44
|
-
|
|
45
32
|
if (lastValue !== undefined) {
|
|
46
33
|
if (typeof lastValue === 'object') {
|
|
47
34
|
if (lastValue.value !== undefined) {
|
|
@@ -61,11 +48,9 @@ function prepareAnimation(frameTimestamp, animatedProp, lastAnimation, lastValue
|
|
|
61
48
|
value = lastValue;
|
|
62
49
|
}
|
|
63
50
|
}
|
|
64
|
-
|
|
65
51
|
animation.callStart = timestamp => {
|
|
66
52
|
animation.onStart(animation, value, timestamp, lastAnimation);
|
|
67
53
|
};
|
|
68
|
-
|
|
69
54
|
animation.callStart(frameTimestamp);
|
|
70
55
|
animation.callStart = null;
|
|
71
56
|
} else if (typeof animatedProp === 'object') {
|
|
@@ -73,14 +58,12 @@ function prepareAnimation(frameTimestamp, animatedProp, lastAnimation, lastValue
|
|
|
73
58
|
Object.keys(animatedProp).forEach(key => prepareAnimation(frameTimestamp, animatedProp[key], lastAnimation && lastAnimation[key], lastValue && lastValue[key]));
|
|
74
59
|
}
|
|
75
60
|
}
|
|
76
|
-
|
|
77
61
|
function runAnimations(animation, timestamp, key, result, animationsActive) {
|
|
78
62
|
'worklet';
|
|
79
63
|
|
|
80
64
|
if (!animationsActive.value) {
|
|
81
65
|
return true;
|
|
82
66
|
}
|
|
83
|
-
|
|
84
67
|
if (Array.isArray(animation)) {
|
|
85
68
|
result[key] = [];
|
|
86
69
|
let allFinished = true;
|
|
@@ -92,21 +75,16 @@ function runAnimations(animation, timestamp, key, result, animationsActive) {
|
|
|
92
75
|
return allFinished;
|
|
93
76
|
} else if (typeof animation === 'object' && animation.onFrame) {
|
|
94
77
|
let finished = true;
|
|
95
|
-
|
|
96
78
|
if (!animation.finished) {
|
|
97
79
|
if (animation.callStart) {
|
|
98
80
|
animation.callStart(timestamp);
|
|
99
81
|
animation.callStart = null;
|
|
100
82
|
}
|
|
101
|
-
|
|
102
83
|
finished = animation.onFrame(animation, timestamp);
|
|
103
84
|
animation.timestamp = timestamp;
|
|
104
|
-
|
|
105
85
|
if (finished) {
|
|
106
86
|
animation.finished = true;
|
|
107
|
-
animation.callback && animation.callback(true
|
|
108
|
-
/* finished */
|
|
109
|
-
);
|
|
87
|
+
animation.callback && animation.callback(true /* finished */);
|
|
110
88
|
}
|
|
111
89
|
}
|
|
112
90
|
|
|
@@ -126,7 +104,6 @@ function runAnimations(animation, timestamp, key, result, animationsActive) {
|
|
|
126
104
|
return true;
|
|
127
105
|
}
|
|
128
106
|
}
|
|
129
|
-
|
|
130
107
|
function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsActive) {
|
|
131
108
|
'worklet';
|
|
132
109
|
|
|
@@ -137,10 +114,8 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
137
114
|
let hasAnimations = false;
|
|
138
115
|
let frameTimestamp;
|
|
139
116
|
let hasNonAnimatedValues = false;
|
|
140
|
-
|
|
141
117
|
for (const key in newValues) {
|
|
142
118
|
const value = newValues[key];
|
|
143
|
-
|
|
144
119
|
if ((0, _utils.isAnimated)(value)) {
|
|
145
120
|
frameTimestamp = global.__frameTimestamp || performance.now();
|
|
146
121
|
prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);
|
|
@@ -152,7 +127,6 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
152
127
|
delete animations[key];
|
|
153
128
|
}
|
|
154
129
|
}
|
|
155
|
-
|
|
156
130
|
if (hasAnimations) {
|
|
157
131
|
const frame = timestamp => {
|
|
158
132
|
const {
|
|
@@ -160,18 +134,14 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
160
134
|
last,
|
|
161
135
|
isAnimationCancelled
|
|
162
136
|
} = state;
|
|
163
|
-
|
|
164
137
|
if (isAnimationCancelled) {
|
|
165
138
|
state.isAnimationRunning = false;
|
|
166
139
|
return;
|
|
167
140
|
}
|
|
168
|
-
|
|
169
141
|
const updates = {};
|
|
170
142
|
let allFinished = true;
|
|
171
|
-
|
|
172
143
|
for (const propName in animations) {
|
|
173
144
|
const finished = runAnimations(animations[propName], timestamp, propName, updates, animationsActive);
|
|
174
|
-
|
|
175
145
|
if (finished) {
|
|
176
146
|
last[propName] = updates[propName];
|
|
177
147
|
delete animations[propName];
|
|
@@ -179,61 +149,52 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
179
149
|
allFinished = false;
|
|
180
150
|
}
|
|
181
151
|
}
|
|
182
|
-
|
|
183
152
|
if (updates) {
|
|
184
153
|
(0, _UpdateProps.default)(viewDescriptors, updates, maybeViewRef);
|
|
185
154
|
}
|
|
186
|
-
|
|
187
155
|
if (!allFinished) {
|
|
188
156
|
requestAnimationFrame(frame);
|
|
189
157
|
} else {
|
|
190
158
|
state.isAnimationRunning = false;
|
|
191
159
|
}
|
|
192
160
|
};
|
|
193
|
-
|
|
194
161
|
state.animations = animations;
|
|
195
|
-
|
|
196
162
|
if (!state.isAnimationRunning) {
|
|
197
163
|
state.isAnimationCancelled = false;
|
|
198
164
|
state.isAnimationRunning = true;
|
|
199
165
|
frame(frameTimestamp);
|
|
200
166
|
}
|
|
201
|
-
|
|
202
167
|
if (hasNonAnimatedValues) {
|
|
203
168
|
(0, _UpdateProps.default)(viewDescriptors, nonAnimatedNewValues, maybeViewRef);
|
|
204
169
|
}
|
|
205
170
|
} else {
|
|
206
171
|
state.isAnimationCancelled = true;
|
|
207
172
|
state.animations = [];
|
|
208
|
-
|
|
209
173
|
if (!(0, _utils.shallowEqual)(oldValues, newValues)) {
|
|
210
174
|
(0, _UpdateProps.default)(viewDescriptors, newValues, maybeViewRef);
|
|
211
175
|
}
|
|
212
176
|
}
|
|
213
|
-
|
|
214
177
|
state.last = newValues;
|
|
215
178
|
}
|
|
216
|
-
|
|
217
179
|
function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsActive, animatedStyle) {
|
|
218
180
|
'worklet';
|
|
219
181
|
|
|
220
182
|
let adapters = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [];
|
|
221
183
|
const animations = state.animations ?? {};
|
|
222
184
|
const newValues = updater() ?? {};
|
|
223
|
-
const oldValues = state.last;
|
|
185
|
+
const oldValues = state.last;
|
|
224
186
|
|
|
187
|
+
// extract animated props
|
|
225
188
|
let hasAnimations = false;
|
|
226
189
|
let frameTimestamp;
|
|
227
190
|
Object.keys(animations).forEach(key => {
|
|
228
191
|
const value = newValues[key];
|
|
229
|
-
|
|
230
192
|
if (!(0, _utils.isAnimated)(value)) {
|
|
231
193
|
delete animations[key];
|
|
232
194
|
}
|
|
233
195
|
});
|
|
234
196
|
Object.keys(newValues).forEach(key => {
|
|
235
197
|
const value = newValues[key];
|
|
236
|
-
|
|
237
198
|
if ((0, _utils.isAnimated)(value)) {
|
|
238
199
|
frameTimestamp = global.__frameTimestamp || performance.now();
|
|
239
200
|
prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);
|
|
@@ -241,24 +202,20 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
241
202
|
hasAnimations = true;
|
|
242
203
|
}
|
|
243
204
|
});
|
|
244
|
-
|
|
245
205
|
function frame(timestamp) {
|
|
246
206
|
const {
|
|
247
207
|
animations,
|
|
248
208
|
last,
|
|
249
209
|
isAnimationCancelled
|
|
250
210
|
} = state;
|
|
251
|
-
|
|
252
211
|
if (isAnimationCancelled) {
|
|
253
212
|
state.isAnimationRunning = false;
|
|
254
213
|
return;
|
|
255
214
|
}
|
|
256
|
-
|
|
257
215
|
const updates = {};
|
|
258
216
|
let allFinished = true;
|
|
259
217
|
Object.keys(animations).forEach(propName => {
|
|
260
218
|
const finished = runAnimations(animations[propName], timestamp, propName, updates, animationsActive);
|
|
261
|
-
|
|
262
219
|
if (finished) {
|
|
263
220
|
last[propName] = updates[propName];
|
|
264
221
|
delete animations[propName];
|
|
@@ -266,21 +223,17 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
266
223
|
allFinished = false;
|
|
267
224
|
}
|
|
268
225
|
});
|
|
269
|
-
|
|
270
226
|
if (Object.keys(updates).length) {
|
|
271
227
|
(0, _UpdateProps.updatePropsJestWrapper)(viewDescriptors, updates, maybeViewRef, animatedStyle, adapters);
|
|
272
228
|
}
|
|
273
|
-
|
|
274
229
|
if (!allFinished) {
|
|
275
230
|
requestAnimationFrame(frame);
|
|
276
231
|
} else {
|
|
277
232
|
state.isAnimationRunning = false;
|
|
278
233
|
}
|
|
279
234
|
}
|
|
280
|
-
|
|
281
235
|
if (hasAnimations) {
|
|
282
236
|
state.animations = animations;
|
|
283
|
-
|
|
284
237
|
if (!state.isAnimationRunning) {
|
|
285
238
|
state.isAnimationCancelled = false;
|
|
286
239
|
state.isAnimationRunning = true;
|
|
@@ -289,17 +242,16 @@ function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animati
|
|
|
289
242
|
} else {
|
|
290
243
|
state.isAnimationCancelled = true;
|
|
291
244
|
state.animations = [];
|
|
292
|
-
}
|
|
293
|
-
|
|
245
|
+
}
|
|
294
246
|
|
|
247
|
+
// calculate diff
|
|
295
248
|
state.last = newValues;
|
|
296
|
-
|
|
297
249
|
if (!(0, _utils.shallowEqual)(oldValues, newValues)) {
|
|
298
250
|
(0, _UpdateProps.updatePropsJestWrapper)(viewDescriptors, newValues, maybeViewRef, animatedStyle, adapters);
|
|
299
251
|
}
|
|
300
|
-
}
|
|
301
|
-
|
|
252
|
+
}
|
|
302
253
|
|
|
254
|
+
// check for invalid usage of shared values in returned object
|
|
303
255
|
function checkSharedValueUsage(prop, currentKey) {
|
|
304
256
|
if (Array.isArray(prop)) {
|
|
305
257
|
// if it's an array (i.ex. transform) validate all its elements
|
|
@@ -316,40 +268,34 @@ function checkSharedValueUsage(prop, currentKey) {
|
|
|
316
268
|
throw new Error(`invalid value passed to \`${currentKey}\`, maybe you forgot to use \`.value\`?`);
|
|
317
269
|
}
|
|
318
270
|
}
|
|
319
|
-
|
|
320
271
|
function useAnimatedStyle(updater, dependencies, adapters) {
|
|
321
272
|
const viewsRef = (0, _ViewDescriptorsSet.makeViewsRefSet)();
|
|
322
273
|
const initRef = (0, _react.useRef)();
|
|
323
274
|
let inputs = Object.values(updater._closure ?? {});
|
|
324
|
-
|
|
325
275
|
if ((0, _PlatformChecker.shouldBeUseWeb)()) {
|
|
326
276
|
var _dependencies;
|
|
327
|
-
|
|
328
277
|
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
329
278
|
// let web work without a Babel/SWC plugin
|
|
330
279
|
inputs = dependencies;
|
|
331
280
|
}
|
|
332
|
-
|
|
333
281
|
if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {
|
|
334
282
|
throw new Error(`useAnimatedStyle was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.
|
|
335
283
|
|
|
336
284
|
For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/web-support#web-without-a-babel-plugin`);
|
|
337
285
|
}
|
|
338
286
|
}
|
|
339
|
-
|
|
340
287
|
const adaptersArray = adapters ? Array.isArray(adapters) ? adapters : [adapters] : [];
|
|
341
288
|
const adaptersHash = adapters ? (0, _utils.buildWorkletsHash)(adaptersArray) : null;
|
|
342
289
|
const animationsActive = (0, _useSharedValue.useSharedValue)(true);
|
|
343
|
-
const animatedStyle = (0, _react.useRef)({});
|
|
290
|
+
const animatedStyle = (0, _react.useRef)({});
|
|
344
291
|
|
|
292
|
+
// build dependencies
|
|
345
293
|
if (!dependencies) {
|
|
346
294
|
dependencies = [...inputs, updater.__workletHash];
|
|
347
295
|
} else {
|
|
348
296
|
dependencies.push(updater.__workletHash);
|
|
349
297
|
}
|
|
350
|
-
|
|
351
298
|
adaptersHash && dependencies.push(adaptersHash);
|
|
352
|
-
|
|
353
299
|
if (!initRef.current) {
|
|
354
300
|
const initialStyle = (0, _animation.initialUpdaterRun)(updater);
|
|
355
301
|
(0, _utils.validateAnimatedStyles)(initialStyle);
|
|
@@ -366,9 +312,9 @@ For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/
|
|
|
366
312
|
}),
|
|
367
313
|
viewDescriptors: (0, _ViewDescriptorsSet.makeViewDescriptorsSet)()
|
|
368
314
|
};
|
|
369
|
-
}
|
|
370
|
-
|
|
315
|
+
}
|
|
371
316
|
|
|
317
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
372
318
|
const {
|
|
373
319
|
initial,
|
|
374
320
|
remoteState,
|
|
@@ -380,7 +326,6 @@ For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/
|
|
|
380
326
|
(0, _react.useEffect)(() => {
|
|
381
327
|
let fun;
|
|
382
328
|
let updaterFn = updater;
|
|
383
|
-
|
|
384
329
|
if (adapters) {
|
|
385
330
|
updaterFn = () => {
|
|
386
331
|
'worklet';
|
|
@@ -392,7 +337,6 @@ For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/
|
|
|
392
337
|
return newValues;
|
|
393
338
|
};
|
|
394
339
|
}
|
|
395
|
-
|
|
396
340
|
if ((0, _PlatformChecker.isJest)()) {
|
|
397
341
|
fun = () => {
|
|
398
342
|
'worklet';
|
|
@@ -406,7 +350,6 @@ For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/
|
|
|
406
350
|
styleUpdater(sharableViewDescriptors, updaterFn, remoteState, maybeViewRef, animationsActive);
|
|
407
351
|
};
|
|
408
352
|
}
|
|
409
|
-
|
|
410
353
|
const mapperId = (0, _core.startMapper)(fun, inputs);
|
|
411
354
|
return () => {
|
|
412
355
|
(0, _core.stopMapper)(mapperId);
|
|
@@ -419,7 +362,6 @@ For more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/
|
|
|
419
362
|
};
|
|
420
363
|
}, []);
|
|
421
364
|
checkSharedValueUsage(initial.value);
|
|
422
|
-
|
|
423
365
|
if (process.env.JEST_WORKER_ID) {
|
|
424
366
|
return {
|
|
425
367
|
viewDescriptors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","Object","keys","key","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","isAnimated","global","__frameTimestamp","performance","now","frame","isAnimationCancelled","isAnimationRunning","updates","propName","updateProps","requestAnimationFrame","shallowEqual","jestStyleUpdater","animatedStyle","adapters","length","updatePropsJestWrapper","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","makeViewsRefSet","initRef","useRef","inputs","values","_closure","shouldBeUseWeb","__DEV__","__workletHash","adaptersArray","adaptersHash","buildWorkletsHash","useSharedValue","push","initialStyle","initialUpdaterRun","validateAnimatedStyles","initial","remoteState","makeRemote","makeViewDescriptorsSet","sharableViewDescriptors","NativeReanimatedModule","native","useEffect","fun","updaterFn","adapter","isJest","mapperId","startMapper","stopMapper","process","env","JEST_WORKER_ID"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["import { MutableRefObject, useEffect, useRef } from 'react';\n\nimport { startMapper, stopMapper, makeRemote } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport NativeReanimatedModule from '../NativeReanimated';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport { DependencyList, Descriptor } from './commonTypes';\nimport {\n makeViewDescriptorsSet,\n makeViewsRefSet,\n ViewDescriptorsSet,\n ViewRefSet,\n} from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport {\n AnimationObject,\n Timestamp,\n AdapterWorkletFunction,\n AnimatedStyle,\n BasicWorkletFunction,\n BasicWorkletFunctionOptional,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n} from '../commonTypes';\nexport interface AnimatedStyleResult {\n viewDescriptors: ViewDescriptorsSet;\n initial: AnimatedStyle;\n viewsRef: ViewRefSet<any>;\n animatedStyle?: MutableRefObject<AnimatedStyle>;\n}\n\ninterface AnimatedState {\n last: AnimatedStyle;\n animations: AnimatedStyle;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimationRef {\n initial: {\n value: AnimatedStyle;\n updater: () => AnimatedStyle;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle,\n lastAnimation: AnimatedStyle,\n lastValue: AnimatedStyle\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle>,\n adapters: AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (typeof prop === 'object' && prop.value === undefined) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\nexport function useAnimatedStyle<T extends AnimatedStyle>(\n updater: BasicWorkletFunction<T>,\n dependencies?: DependencyList,\n adapters?: AdapterWorkletFunction | AdapterWorkletFunction[]\n): AnimatedStyleResult {\n const viewsRef: ViewRefSet<any> = makeViewsRefSet();\n const initRef = useRef<AnimationRef>();\n let inputs = Object.values(updater._closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `useAnimatedStyle was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.\n\nFor more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/web-support#web-without-a-babel-plugin`\n );\n }\n }\n const adaptersArray: AdapterWorkletFunction[] = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const animationsActive = useSharedValue<boolean>(true);\n const animatedStyle: MutableRefObject<AnimatedStyle> = useRef<AnimatedStyle>(\n {}\n );\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!initRef.current) {\n const initialStyle: AnimatedStyle = initialUpdaterRun(updater);\n validateAnimatedStyles(initialStyle);\n initRef.current = {\n initial: {\n value: initialStyle,\n updater: updater,\n },\n remoteState: makeRemote<AnimatedState>({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { initial, remoteState, viewDescriptors } = initRef.current!;\n const sharableViewDescriptors = viewDescriptors.sharableViewDescriptors;\n const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;\n\n dependencies.push(sharableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater as BasicWorkletFunctionOptional<T>;\n if (adapters) {\n updaterFn = () => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n };\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n sharableViewDescriptors,\n updater,\n remoteState,\n maybeViewRef,\n animationsActive,\n animatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n sharableViewDescriptors,\n updaterFn,\n remoteState,\n maybeViewRef,\n animationsActive\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n animationsActive.value = true;\n return () => {\n animationsActive.value = false;\n };\n }, []);\n\n checkSharedValueUsage(initial.value);\n\n if (process.env.JEST_WORKER_ID) {\n return { viewDescriptors, initial: initial, viewsRef, animatedStyle };\n } else {\n return { viewDescriptors, initial: initial, viewsRef };\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;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AqClB,QAArC;MAA+CV;IAA/C,CAAP;EACD,CAFD,MAEO;IACL,OAAO;MAAEzB,eAAF;MAAmBqD,OAAO,EAAEA,OAA5B;MAAqClB;IAArC,CAAP;EACD;AACF"}
|
|
1
|
+
{"version":3,"names":["_react","require","_core","_UpdateProps","_interopRequireWildcard","_animation","_NativeReanimated","_interopRequireDefault","_useSharedValue","_utils","_ViewDescriptorsSet","_PlatformChecker","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","prepareAnimation","frameTimestamp","animatedProp","lastAnimation","lastValue","Array","isArray","forEach","prop","index","onFrame","animation","value","current","undefined","callStart","timestamp","onStart","keys","runAnimations","result","animationsActive","allFinished","entry","finished","callback","k","styleUpdater","viewDescriptors","updater","state","maybeViewRef","animations","newValues","oldValues","last","nonAnimatedNewValues","hasAnimations","hasNonAnimatedValues","isAnimated","global","__frameTimestamp","performance","now","frame","isAnimationCancelled","isAnimationRunning","updates","propName","updateProps","requestAnimationFrame","shallowEqual","jestStyleUpdater","animatedStyle","adapters","arguments","length","updatePropsJestWrapper","checkSharedValueUsage","currentKey","element","Error","useAnimatedStyle","dependencies","viewsRef","makeViewsRefSet","initRef","useRef","inputs","values","_closure","shouldBeUseWeb","_dependencies","__DEV__","__workletHash","adaptersArray","adaptersHash","buildWorkletsHash","useSharedValue","push","initialStyle","initialUpdaterRun","validateAnimatedStyles","initial","remoteState","makeRemote","makeViewDescriptorsSet","sharableViewDescriptors","NativeReanimatedModule","native","useEffect","fun","updaterFn","adapter","isJest","mapperId","startMapper","stopMapper","process","env","JEST_WORKER_ID"],"sources":["useAnimatedStyle.ts"],"sourcesContent":["import { MutableRefObject, useEffect, useRef } from 'react';\n\nimport { startMapper, stopMapper, makeRemote } from '../core';\nimport updateProps, { updatePropsJestWrapper } from '../UpdateProps';\nimport { initialUpdaterRun } from '../animation';\nimport NativeReanimatedModule from '../NativeReanimated';\nimport { useSharedValue } from './useSharedValue';\nimport {\n buildWorkletsHash,\n isAnimated,\n shallowEqual,\n validateAnimatedStyles,\n} from './utils';\nimport { DependencyList, Descriptor } from './commonTypes';\nimport {\n makeViewDescriptorsSet,\n makeViewsRefSet,\n ViewDescriptorsSet,\n ViewRefSet,\n} from '../ViewDescriptorsSet';\nimport { isJest, shouldBeUseWeb } from '../PlatformChecker';\nimport {\n AnimationObject,\n Timestamp,\n AdapterWorkletFunction,\n AnimatedStyle,\n BasicWorkletFunction,\n BasicWorkletFunctionOptional,\n NestedObjectValues,\n SharedValue,\n StyleProps,\n} from '../commonTypes';\nexport interface AnimatedStyleResult {\n viewDescriptors: ViewDescriptorsSet;\n initial: AnimatedStyle;\n viewsRef: ViewRefSet<any>;\n animatedStyle?: MutableRefObject<AnimatedStyle>;\n}\n\ninterface AnimatedState {\n last: AnimatedStyle;\n animations: AnimatedStyle;\n isAnimationRunning: boolean;\n isAnimationCancelled: boolean;\n}\n\ninterface AnimationRef {\n initial: {\n value: AnimatedStyle;\n updater: () => AnimatedStyle;\n };\n remoteState: AnimatedState;\n viewDescriptors: ViewDescriptorsSet;\n}\n\nfunction prepareAnimation(\n frameTimestamp: number,\n animatedProp: AnimatedStyle,\n lastAnimation: AnimatedStyle,\n lastValue: AnimatedStyle\n): void {\n 'worklet';\n if (Array.isArray(animatedProp)) {\n animatedProp.forEach((prop, index) => {\n prepareAnimation(\n frameTimestamp,\n prop,\n lastAnimation && lastAnimation[index],\n lastValue && lastValue[index]\n );\n });\n // return animatedProp;\n }\n if (typeof animatedProp === 'object' && animatedProp.onFrame) {\n const animation = animatedProp;\n\n let value = animation.current;\n if (lastValue !== undefined) {\n if (typeof lastValue === 'object') {\n if (lastValue.value !== undefined) {\n // previously it was a shared value\n value = lastValue.value;\n } else if (lastValue.onFrame !== undefined) {\n if (lastAnimation?.current !== undefined) {\n // it was an animation before, copy its state\n value = lastAnimation.current;\n } else if (lastValue?.current !== undefined) {\n // it was initialized\n value = lastValue.current;\n }\n }\n } else {\n // previously it was a plain value, just set it as starting point\n value = lastValue;\n }\n }\n\n animation.callStart = (timestamp: Timestamp) => {\n animation.onStart(animation, value, timestamp, lastAnimation);\n };\n animation.callStart(frameTimestamp);\n animation.callStart = null;\n } else if (typeof animatedProp === 'object') {\n // it is an object\n Object.keys(animatedProp).forEach((key) =>\n prepareAnimation(\n frameTimestamp,\n animatedProp[key],\n lastAnimation && lastAnimation[key],\n lastValue && lastValue[key]\n )\n );\n }\n}\n\nfunction runAnimations(\n animation: AnimatedStyle,\n timestamp: Timestamp,\n key: number | string,\n result: AnimatedStyle,\n animationsActive: SharedValue<boolean>\n): boolean {\n 'worklet';\n if (!animationsActive.value) {\n return true;\n }\n if (Array.isArray(animation)) {\n result[key] = [];\n let allFinished = true;\n animation.forEach((entry, index) => {\n if (\n !runAnimations(entry, timestamp, index, result[key], animationsActive)\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else if (typeof animation === 'object' && animation.onFrame) {\n let finished = true;\n if (!animation.finished) {\n if (animation.callStart) {\n animation.callStart(timestamp);\n animation.callStart = null;\n }\n finished = animation.onFrame(animation, timestamp);\n animation.timestamp = timestamp;\n if (finished) {\n animation.finished = true;\n animation.callback && animation.callback(true /* finished */);\n }\n }\n result[key] = animation.current;\n return finished;\n } else if (typeof animation === 'object') {\n result[key] = {};\n let allFinished = true;\n Object.keys(animation).forEach((k) => {\n if (\n !runAnimations(\n animation[k],\n timestamp,\n k,\n result[key],\n animationsActive\n )\n ) {\n allFinished = false;\n }\n });\n return allFinished;\n } else {\n result[key] = animation;\n return true;\n }\n}\n\nfunction styleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>\n): void {\n 'worklet';\n const animations = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n const nonAnimatedNewValues: StyleProps = {};\n\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n let hasNonAnimatedValues = false;\n for (const key in newValues) {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n } else {\n hasNonAnimatedValues = true;\n nonAnimatedNewValues[key] = value;\n delete animations[key];\n }\n }\n\n if (hasAnimations) {\n const frame = (timestamp: Timestamp) => {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n for (const propName in animations) {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n }\n\n if (updates) {\n updateProps(viewDescriptors, updates, maybeViewRef);\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n };\n\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n\n if (hasNonAnimatedValues) {\n updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n\n if (!shallowEqual(oldValues, newValues)) {\n updateProps(viewDescriptors, newValues, maybeViewRef);\n }\n }\n state.last = newValues;\n}\n\nfunction jestStyleUpdater(\n viewDescriptors: SharedValue<Descriptor[]>,\n updater: BasicWorkletFunction<AnimatedStyle>,\n state: AnimatedState,\n maybeViewRef: ViewRefSet<any> | undefined,\n animationsActive: SharedValue<boolean>,\n animatedStyle: MutableRefObject<AnimatedStyle>,\n adapters: AdapterWorkletFunction[] = []\n): void {\n 'worklet';\n const animations: AnimatedStyle = state.animations ?? {};\n const newValues = updater() ?? {};\n const oldValues = state.last;\n\n // extract animated props\n let hasAnimations = false;\n let frameTimestamp: number | undefined;\n Object.keys(animations).forEach((key) => {\n const value = newValues[key];\n if (!isAnimated(value)) {\n delete animations[key];\n }\n });\n Object.keys(newValues).forEach((key) => {\n const value = newValues[key];\n if (isAnimated(value)) {\n frameTimestamp = global.__frameTimestamp || performance.now();\n prepareAnimation(frameTimestamp, value, animations[key], oldValues[key]);\n animations[key] = value;\n hasAnimations = true;\n }\n });\n\n function frame(timestamp: Timestamp) {\n const { animations, last, isAnimationCancelled } = state;\n if (isAnimationCancelled) {\n state.isAnimationRunning = false;\n return;\n }\n\n const updates: AnimatedStyle = {};\n let allFinished = true;\n Object.keys(animations).forEach((propName) => {\n const finished = runAnimations(\n animations[propName],\n timestamp,\n propName,\n updates,\n animationsActive\n );\n if (finished) {\n last[propName] = updates[propName];\n delete animations[propName];\n } else {\n allFinished = false;\n }\n });\n\n if (Object.keys(updates).length) {\n updatePropsJestWrapper(\n viewDescriptors,\n updates,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n\n if (!allFinished) {\n requestAnimationFrame(frame);\n } else {\n state.isAnimationRunning = false;\n }\n }\n\n if (hasAnimations) {\n state.animations = animations;\n if (!state.isAnimationRunning) {\n state.isAnimationCancelled = false;\n state.isAnimationRunning = true;\n frame(frameTimestamp!);\n }\n } else {\n state.isAnimationCancelled = true;\n state.animations = [];\n }\n\n // calculate diff\n state.last = newValues;\n\n if (!shallowEqual(oldValues, newValues)) {\n updatePropsJestWrapper(\n viewDescriptors,\n newValues,\n maybeViewRef,\n animatedStyle,\n adapters\n );\n }\n}\n\n// check for invalid usage of shared values in returned object\nfunction checkSharedValueUsage(\n prop: NestedObjectValues<AnimationObject>,\n currentKey?: string\n): void {\n if (Array.isArray(prop)) {\n // if it's an array (i.ex. transform) validate all its elements\n for (const element of prop) {\n checkSharedValueUsage(element, currentKey);\n }\n } else if (typeof prop === 'object' && prop.value === undefined) {\n // if it's a nested object, run validation for all its props\n for (const key of Object.keys(prop)) {\n checkSharedValueUsage(prop[key], key);\n }\n } else if (\n currentKey !== undefined &&\n typeof prop === 'object' &&\n prop.value !== undefined\n ) {\n // if shared value is passed insted of its value, throw an error\n throw new Error(\n `invalid value passed to \\`${currentKey}\\`, maybe you forgot to use \\`.value\\`?`\n );\n }\n}\n\nexport function useAnimatedStyle<T extends AnimatedStyle>(\n updater: BasicWorkletFunction<T>,\n dependencies?: DependencyList,\n adapters?: AdapterWorkletFunction | AdapterWorkletFunction[]\n): AnimatedStyleResult {\n const viewsRef: ViewRefSet<any> = makeViewsRefSet();\n const initRef = useRef<AnimationRef>();\n let inputs = Object.values(updater._closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n if (__DEV__ && !inputs.length && !dependencies && !updater.__workletHash) {\n throw new Error(\n `useAnimatedStyle was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.\n\nFor more, see the docs: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/web-support#web-without-a-babel-plugin`\n );\n }\n }\n const adaptersArray: AdapterWorkletFunction[] = adapters\n ? Array.isArray(adapters)\n ? adapters\n : [adapters]\n : [];\n const adaptersHash = adapters ? buildWorkletsHash(adaptersArray) : null;\n const animationsActive = useSharedValue<boolean>(true);\n const animatedStyle: MutableRefObject<AnimatedStyle> = useRef<AnimatedStyle>(\n {}\n );\n\n // build dependencies\n if (!dependencies) {\n dependencies = [...inputs, updater.__workletHash];\n } else {\n dependencies.push(updater.__workletHash);\n }\n adaptersHash && dependencies.push(adaptersHash);\n\n if (!initRef.current) {\n const initialStyle: AnimatedStyle = initialUpdaterRun(updater);\n validateAnimatedStyles(initialStyle);\n initRef.current = {\n initial: {\n value: initialStyle,\n updater: updater,\n },\n remoteState: makeRemote<AnimatedState>({\n last: initialStyle,\n animations: {},\n isAnimationCancelled: false,\n isAnimationRunning: false,\n }),\n viewDescriptors: makeViewDescriptorsSet(),\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { initial, remoteState, viewDescriptors } = initRef.current!;\n const sharableViewDescriptors = viewDescriptors.sharableViewDescriptors;\n const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;\n\n dependencies.push(sharableViewDescriptors);\n\n useEffect(() => {\n let fun;\n let updaterFn = updater as BasicWorkletFunctionOptional<T>;\n if (adapters) {\n updaterFn = () => {\n 'worklet';\n const newValues = updater();\n adaptersArray.forEach((adapter) => {\n adapter(newValues);\n });\n return newValues;\n };\n }\n\n if (isJest()) {\n fun = () => {\n 'worklet';\n jestStyleUpdater(\n sharableViewDescriptors,\n updater,\n remoteState,\n maybeViewRef,\n animationsActive,\n animatedStyle,\n adaptersArray\n );\n };\n } else {\n fun = () => {\n 'worklet';\n styleUpdater(\n sharableViewDescriptors,\n updaterFn,\n remoteState,\n maybeViewRef,\n animationsActive\n );\n };\n }\n const mapperId = startMapper(fun, inputs);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n animationsActive.value = true;\n return () => {\n animationsActive.value = false;\n };\n }, []);\n\n checkSharedValueUsage(initial.value);\n\n if (process.env.JEST_WORKER_ID) {\n return { viewDescriptors, initial: initial, viewsRef, animatedStyle };\n } else {\n return { viewDescriptors, initial: initial, viewsRef };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAOA,IAAAS,mBAAA,GAAAT,OAAA;AAMA,IAAAU,gBAAA,GAAAV,OAAA;AAA4D,SAAAM,uBAAAK,GAAA,WA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sF,OAAO,CAACC,GAAG,CAACC,cAAc,EAAE;IAC9B,OAAO;MAAExE,eAAe;MAAEuD,OAAO,EAAEA,OAAO;MAAEnB,QAAQ;MAAEX;IAAc,CAAC;EACvE,CAAC,MAAM;IACL,OAAO;MAAEzB,eAAe;MAAEuD,OAAO,EAAEA,OAAO;MAAEnB;IAAS,CAAC;EACxD;AACF"}
|
|
@@ -4,40 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useDerivedValue = useDerivedValue;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _animation = require("../animation");
|
|
11
|
-
|
|
12
9
|
var _core = require("../core");
|
|
13
|
-
|
|
14
10
|
var _PlatformChecker = require("../PlatformChecker");
|
|
15
|
-
|
|
16
11
|
function useDerivedValue(processor, dependencies) {
|
|
17
12
|
const initRef = (0, _react.useRef)(null);
|
|
18
13
|
let inputs = Object.values(processor._closure ?? {});
|
|
19
|
-
|
|
20
14
|
if ((0, _PlatformChecker.shouldBeUseWeb)()) {
|
|
21
15
|
var _dependencies;
|
|
22
|
-
|
|
23
16
|
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
24
17
|
// let web work without a Babel/SWC plugin
|
|
25
18
|
inputs = dependencies;
|
|
26
19
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
20
|
+
}
|
|
29
21
|
|
|
22
|
+
// build dependencies
|
|
30
23
|
if (dependencies === undefined) {
|
|
31
24
|
dependencies = [...inputs, processor.__workletHash];
|
|
32
25
|
} else {
|
|
33
26
|
dependencies.push(processor.__workletHash);
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
if (initRef.current === null) {
|
|
37
29
|
initRef.current = (0, _core.makeMutable)((0, _animation.initialUpdaterRun)(processor));
|
|
38
|
-
}
|
|
39
|
-
|
|
30
|
+
}
|
|
40
31
|
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
41
33
|
const sharedValue = initRef.current;
|
|
42
34
|
(0, _react.useEffect)(() => {
|
|
43
35
|
const fun = () => {
|
|
@@ -45,7 +37,6 @@ function useDerivedValue(processor, dependencies) {
|
|
|
45
37
|
|
|
46
38
|
sharedValue.value = processor();
|
|
47
39
|
};
|
|
48
|
-
|
|
49
40
|
const mapperId = (0, _core.startMapper)(fun, inputs, [sharedValue]);
|
|
50
41
|
return () => {
|
|
51
42
|
(0, _core.stopMapper)(mapperId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDerivedValue","processor","dependencies","initRef","useRef","inputs","Object","values","_closure","shouldBeUseWeb","length","undefined","__workletHash","push","current","makeMutable","initialUpdaterRun","sharedValue","useEffect","fun","value","mapperId","startMapper","stopMapper"],"sources":["useDerivedValue.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { initialUpdaterRun } from '../animation';\nimport { BasicWorkletFunction, SharedValue } from '../commonTypes';\nimport { makeMutable, startMapper, stopMapper } from '../core';\nimport { DependencyList } from './commonTypes';\nimport { shouldBeUseWeb } from '../PlatformChecker';\n\nexport type DerivedValue<T> = Readonly<SharedValue<T>>;\n\nexport function useDerivedValue<T>(\n processor: BasicWorkletFunction<T>,\n dependencies: DependencyList\n): DerivedValue<T> {\n const initRef = useRef<SharedValue<T> | null>(null);\n let inputs = Object.values(processor._closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n }\n\n // build dependencies\n if (dependencies === undefined) {\n dependencies = [...inputs, processor.__workletHash];\n } else {\n dependencies.push(processor.__workletHash);\n }\n\n if (initRef.current === null) {\n initRef.current = makeMutable(initialUpdaterRun(processor));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sharedValue: SharedValue<T> = initRef.current!;\n\n useEffect(() => {\n const fun = () => {\n 'worklet';\n sharedValue.value = processor();\n };\n const mapperId = startMapper(fun, inputs, [sharedValue]);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n\n return sharedValue;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_react","require","_animation","_core","_PlatformChecker","useDerivedValue","processor","dependencies","initRef","useRef","inputs","Object","values","_closure","shouldBeUseWeb","_dependencies","length","undefined","__workletHash","push","current","makeMutable","initialUpdaterRun","sharedValue","useEffect","fun","value","mapperId","startMapper","stopMapper"],"sources":["useDerivedValue.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { initialUpdaterRun } from '../animation';\nimport { BasicWorkletFunction, SharedValue } from '../commonTypes';\nimport { makeMutable, startMapper, stopMapper } from '../core';\nimport { DependencyList } from './commonTypes';\nimport { shouldBeUseWeb } from '../PlatformChecker';\n\nexport type DerivedValue<T> = Readonly<SharedValue<T>>;\n\nexport function useDerivedValue<T>(\n processor: BasicWorkletFunction<T>,\n dependencies: DependencyList\n): DerivedValue<T> {\n const initRef = useRef<SharedValue<T> | null>(null);\n let inputs = Object.values(processor._closure ?? {});\n if (shouldBeUseWeb()) {\n if (!inputs.length && dependencies?.length) {\n // let web work without a Babel/SWC plugin\n inputs = dependencies;\n }\n }\n\n // build dependencies\n if (dependencies === undefined) {\n dependencies = [...inputs, processor.__workletHash];\n } else {\n dependencies.push(processor.__workletHash);\n }\n\n if (initRef.current === null) {\n initRef.current = makeMutable(initialUpdaterRun(processor));\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const sharedValue: SharedValue<T> = initRef.current!;\n\n useEffect(() => {\n const fun = () => {\n 'worklet';\n sharedValue.value = processor();\n };\n const mapperId = startMapper(fun, inputs, [sharedValue]);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n\n useEffect(() => {\n return () => {\n initRef.current = null;\n };\n }, []);\n\n return sharedValue;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MA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