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":[],"sources":["globals.d.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"names":[],"sources":["globals.d.ts"],"sourcesContent":["/* eslint-disable no-var */\nimport type {\n AnimatedStyle,\n StyleProps,\n MeasuredDimensions,\n MapperRegistry,\n ShareableRef,\n ShareableSyncDataHolderRef,\n ShadowNodeWrapper,\n} from './commonTypes';\nimport type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';\nimport type { NativeReanimated } from './NativeReanimated/NativeReanimated';\nimport type {\n LayoutAnimationFunction,\n LayoutAnimationType,\n LayoutAnimationsValues,\n} from './layoutReanimation/animationBuilder';\n\ndeclare global {\n var _WORKLET: boolean | undefined;\n var _IS_FABRIC: boolean | undefined;\n var _REANIMATED_VERSION_CPP: string | undefined;\n var _REANIMATED_VERSION_BABEL_PLUGIN: string | undefined;\n var __reanimatedModuleProxy: NativeReanimated | undefined;\n var evalWithSourceMap:\n | ((\n js: string,\n sourceURL: string,\n sourceMap: string\n // eslint-ignore-next-line @typescript-eslint/no-explicit-any\n ) => any)\n | undefined;\n // eslint-ignore-next-line @typescript-eslint/no-explicit-any\n var evalWithSourceUrl: ((js: string, sourceURL: string) => any) | undefined;\n var _log: (s: string) => void;\n var _notifyAboutProgress: (\n tag: number,\n value: number,\n isSharedTransition: boolean\n ) => void;\n var _notifyAboutEnd: (\n tag: number,\n finished: boolean,\n removeView: boolean\n ) => void;\n var _setGestureState: (handlerTag: number, newState: number) => void;\n // eslint-ignore-next-line @typescript-eslint/no-explicit-any\n var _makeShareableClone: (value: any) => any;\n var _updateDataSynchronously: (\n dataHolder: ShareableSyncDataHolderRef,\n data: ShareableRef\n ) => void;\n var _scheduleOnJS: (fun: ShareableRef, args?: ShareableRef) => void;\n var _updatePropsPaper:\n | ((tag: number, name: string, updates: StyleProps | AnimatedStyle) => void)\n | undefined;\n var _updatePropsFabric:\n | ((\n shadowNodeWrapper: ShadowNodeWrapper,\n props: StyleProps | AnimatedStyle\n ) => void)\n | undefined;\n var _removeShadowNodeFromRegistry: ((viewTag: number) => void) | undefined;\n var _measure: (viewTag: number | ShadowNodeWrapper) => MeasuredDimensions;\n var _scrollTo: (\n viewTag: number,\n x: number,\n y: number,\n animated: boolean\n ) => void;\n var _dispatchCommand:\n | ((\n nodeRef: ShadowNodeWrapper,\n commandName: string,\n args: Array<unknown>\n ) => void)\n | undefined;\n var performance: { now: () => number };\n var __ErrorUtils: {\n reportFatalError: (error: Error) => void;\n };\n var _frameCallbackRegistry: FrameCallbackRegistryUI;\n var requestAnimationFrame: (callback: (time: number) => void) => number;\n var console: Console;\n var __frameTimestamp: number | undefined;\n var __flushAnimationFrame: (timestamp: number) => void;\n // eslint-ignore-next-line @typescript-eslint/no-explicit-any\n var __workletsCache: Map<string, any>;\n // eslint-ignore-next-line @typescript-eslint/no-explicit-any\n var __handleCache: WeakMap<object, any>;\n var __callMicrotasks: () => void;\n var __mapperRegistry: MapperRegistry;\n var _maybeFlushUIUpdatesQueue: () => void;\n var LayoutAnimationsManager: {\n start(\n tag: number,\n type: LayoutAnimationType,\n yogaValues: LayoutAnimationsValues,\n config: LayoutAnimationFunction\n );\n };\n}\n"],"mappings":""}
|
|
@@ -17,18 +17,13 @@ Object.defineProperty(exports, "useHandler", {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
exports.useWorkletCallback = useWorkletCallback;
|
|
20
|
-
|
|
21
20
|
var _react = require("react");
|
|
22
|
-
|
|
23
21
|
var _useAnimatedStyle = require("./useAnimatedStyle");
|
|
24
|
-
|
|
25
22
|
var _utils = require("./utils");
|
|
26
|
-
|
|
27
23
|
// TODO: we should make sure that when useAP is used we are not assigning styles
|
|
28
24
|
// when you need styles to animated you should always use useAS
|
|
29
25
|
const useAnimatedProps = _useAnimatedStyle.useAnimatedStyle;
|
|
30
26
|
exports.useAnimatedProps = useAnimatedProps;
|
|
31
|
-
|
|
32
27
|
function useWorkletCallback(fun, deps) {
|
|
33
28
|
return (0, _react.useCallback)(fun, deps ?? []);
|
|
34
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedProps","useAnimatedStyle","useWorkletCallback","fun","deps","useCallback"],"sources":["Hooks.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { DependencyList } from './commonTypes';\nimport { useAnimatedStyle } from './useAnimatedStyle';\n\n// TODO: we should make sure that when useAP is used we are not assigning styles\n// when you need styles to animated you should always use useAS\nexport const useAnimatedProps = useAnimatedStyle;\n\nexport function useWorkletCallback<A extends unknown[], R>(\n fun: (...args: A) => R,\n deps?: DependencyList\n): (...args: Parameters<typeof fun>) => R {\n return useCallback(fun, deps ?? []);\n}\n\nexport { useEvent, useHandler } from './utils';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_react","require","_useAnimatedStyle","_utils","useAnimatedProps","useAnimatedStyle","exports","useWorkletCallback","fun","deps","useCallback"],"sources":["Hooks.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { DependencyList } from './commonTypes';\nimport { useAnimatedStyle } from './useAnimatedStyle';\n\n// TODO: we should make sure that when useAP is used we are not assigning styles\n// when you need styles to animated you should always use useAS\nexport const useAnimatedProps = useAnimatedStyle;\n\nexport function useWorkletCallback<A extends unknown[], R>(\n fun: (...args: A) => R,\n deps?: DependencyList\n): (...args: Parameters<typeof fun>) => R {\n return useCallback(fun, deps ?? []);\n}\n\nexport { useEvent, useHandler } from './utils';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAaA,IAAAE,MAAA,GAAAF,OAAA;AAXA;AACA;AACO,MAAMG,gBAAgB,GAAGC,kCAAgB;AAACC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA;AAE1C,SAASG,kBAAkBA,CAChCC,GAAsB,EACtBC,IAAqB,EACmB;EACxC,OAAO,IAAAC,kBAAW,EAACF,GAAG,EAAEC,IAAI,IAAI,EAAE,CAAC;AACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { Context, ShadowNodeWrapper } from '../commonTypes';\n\nexport type DependencyList = Array<unknown> | undefined;\n\nexport interface ContextWithDependencies<TContext extends Context> {\n context: TContext;\n savedDependencies: DependencyList;\n}\n\nexport interface Descriptor {\n tag: number;\n name: string;\n shadowNodeWrapper: ShadowNodeWrapper;\n}\n\nexport interface RefObjectFunction<T> {\n current: T | null;\n (component?: T): number;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["import { Context, ShadowNodeWrapper } from '../commonTypes';\n\nexport type DependencyList = Array<unknown> | undefined;\n\nexport interface ContextWithDependencies<TContext extends Context> {\n context: TContext;\n savedDependencies: DependencyList;\n}\n\nexport interface Descriptor {\n tag: number;\n name: string;\n shadowNodeWrapper: ShadowNodeWrapper;\n}\n\nexport interface RefObjectFunction<T> {\n current: T | null;\n (component?: T): number | ShadowNodeWrapper;\n}\n"],"mappings":""}
|
|
@@ -93,28 +93,16 @@ Object.defineProperty(exports, "useWorkletCallback", {
|
|
|
93
93
|
return _Hooks.useWorkletCallback;
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
-
|
|
97
96
|
var _Hooks = require("./Hooks");
|
|
98
|
-
|
|
99
97
|
var _useSharedValue = require("./useSharedValue");
|
|
100
|
-
|
|
101
98
|
var _useAnimatedStyle = require("./useAnimatedStyle");
|
|
102
|
-
|
|
103
99
|
var _useAnimatedGestureHandler = require("./useAnimatedGestureHandler");
|
|
104
|
-
|
|
105
100
|
var _useAnimatedReaction = require("./useAnimatedReaction");
|
|
106
|
-
|
|
107
101
|
var _useAnimatedRef = require("./useAnimatedRef");
|
|
108
|
-
|
|
109
102
|
var _useAnimatedScrollHandler = require("./useAnimatedScrollHandler");
|
|
110
|
-
|
|
111
103
|
var _useDerivedValue = require("./useDerivedValue");
|
|
112
|
-
|
|
113
104
|
var _useAnimatedSensor = require("./useAnimatedSensor");
|
|
114
|
-
|
|
115
105
|
var _useFrameCallback = require("./useFrameCallback");
|
|
116
|
-
|
|
117
106
|
var _useAnimatedKeyboard = require("./useAnimatedKeyboard");
|
|
118
|
-
|
|
119
107
|
var _useScrollViewOffset = require("./useScrollViewOffset");
|
|
120
108
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type { DependencyList } from './commonTypes';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n} from './Hooks';\nexport { useSharedValue } from './useSharedValue';\nexport { useAnimatedStyle } from './useAnimatedStyle';\nexport type { AnimatedStyleResult } from './useAnimatedStyle';\nexport { useAnimatedGestureHandler } from './useAnimatedGestureHandler';\nexport type {\n GestureHandlerEvent,\n GestureHandlers,\n} from './useAnimatedGestureHandler';\nexport { useAnimatedReaction } from './useAnimatedReaction';\nexport type { AnimatedReactionWorkletFunction } from './useAnimatedReaction';\nexport { useAnimatedRef } from './useAnimatedRef';\nexport { useAnimatedScrollHandler } from './useAnimatedScrollHandler';\nexport type { ScrollHandler, ScrollHandlers } from './useAnimatedScrollHandler';\nexport { useDerivedValue } from './useDerivedValue';\nexport type { DerivedValue } from './useDerivedValue';\nexport { useAnimatedSensor } from './useAnimatedSensor';\nexport { useFrameCallback } from './useFrameCallback';\nexport type { FrameCallback } from './useFrameCallback';\nexport { useAnimatedKeyboard } from './useAnimatedKeyboard';\nexport { useScrollViewOffset } from './useScrollViewOffset';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_Hooks","require","_useSharedValue","_useAnimatedStyle","_useAnimatedGestureHandler","_useAnimatedReaction","_useAnimatedRef","_useAnimatedScrollHandler","_useDerivedValue","_useAnimatedSensor","_useFrameCallback","_useAnimatedKeyboard","_useScrollViewOffset"],"sources":["index.ts"],"sourcesContent":["export type { DependencyList } from './commonTypes';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n} from './Hooks';\nexport { useSharedValue } from './useSharedValue';\nexport { useAnimatedStyle } from './useAnimatedStyle';\nexport type { AnimatedStyleResult } from './useAnimatedStyle';\nexport { useAnimatedGestureHandler } from './useAnimatedGestureHandler';\nexport type {\n GestureHandlerEvent,\n GestureHandlers,\n} from './useAnimatedGestureHandler';\nexport { useAnimatedReaction } from './useAnimatedReaction';\nexport type { AnimatedReactionWorkletFunction } from './useAnimatedReaction';\nexport { useAnimatedRef } from './useAnimatedRef';\nexport { useAnimatedScrollHandler } from './useAnimatedScrollHandler';\nexport type { ScrollHandler, ScrollHandlers } from './useAnimatedScrollHandler';\nexport { useDerivedValue } from './useDerivedValue';\nexport type { DerivedValue } from './useDerivedValue';\nexport { useAnimatedSensor } from './useAnimatedSensor';\nexport { useFrameCallback } from './useFrameCallback';\nexport type { FrameCallback } from './useFrameCallback';\nexport { useAnimatedKeyboard } from './useAnimatedKeyboard';\nexport { useScrollViewOffset } from './useScrollViewOffset';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,0BAAA,GAAAH,OAAA;AAKA,IAAAI,oBAAA,GAAAJ,OAAA;AAEA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,yBAAA,GAAAN,OAAA;AAEA,IAAAO,gBAAA,GAAAP,OAAA;AAEA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AAEA,IAAAU,oBAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAX,OAAA"}
|
|
@@ -5,62 +5,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.EventType = void 0;
|
|
7
7
|
exports.useAnimatedGestureHandler = useAnimatedGestureHandler;
|
|
8
|
-
|
|
9
8
|
var _Hooks = require("./Hooks");
|
|
10
|
-
|
|
11
|
-
let EventType;
|
|
12
|
-
exports.EventType = EventType;
|
|
13
|
-
|
|
14
|
-
(function (EventType) {
|
|
9
|
+
let EventType = /*#__PURE__*/function (EventType) {
|
|
15
10
|
EventType[EventType["UNDETERMINED"] = 0] = "UNDETERMINED";
|
|
16
11
|
EventType[EventType["FAILED"] = 1] = "FAILED";
|
|
17
12
|
EventType[EventType["BEGAN"] = 2] = "BEGAN";
|
|
18
13
|
EventType[EventType["CANCELLED"] = 3] = "CANCELLED";
|
|
19
14
|
EventType[EventType["ACTIVE"] = 4] = "ACTIVE";
|
|
20
15
|
EventType[EventType["END"] = 5] = "END";
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
return EventType;
|
|
17
|
+
}({});
|
|
18
|
+
exports.EventType = EventType;
|
|
23
19
|
function useAnimatedGestureHandler(handlers, dependencies) {
|
|
24
20
|
const {
|
|
25
21
|
context,
|
|
26
22
|
doDependenciesDiffer,
|
|
27
23
|
useWeb
|
|
28
24
|
} = (0, _Hooks.useHandler)(handlers, dependencies);
|
|
29
|
-
|
|
30
25
|
const handler = e => {
|
|
31
26
|
'worklet';
|
|
32
27
|
|
|
33
28
|
const event = useWeb ? e.nativeEvent : e;
|
|
34
|
-
|
|
35
29
|
if (event.state === EventType.BEGAN && handlers.onStart) {
|
|
36
30
|
handlers.onStart(event, context);
|
|
37
31
|
}
|
|
38
|
-
|
|
39
32
|
if (event.state === EventType.ACTIVE && handlers.onActive) {
|
|
40
33
|
handlers.onActive(event, context);
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
if (event.oldState === EventType.ACTIVE && event.state === EventType.END && handlers.onEnd) {
|
|
44
36
|
handlers.onEnd(event, context);
|
|
45
37
|
}
|
|
46
|
-
|
|
47
38
|
if (event.oldState === EventType.BEGAN && event.state === EventType.FAILED && handlers.onFail) {
|
|
48
39
|
handlers.onFail(event, context);
|
|
49
40
|
}
|
|
50
|
-
|
|
51
41
|
if (event.oldState === EventType.ACTIVE && event.state === EventType.CANCELLED && handlers.onCancel) {
|
|
52
42
|
handlers.onCancel(event, context);
|
|
53
43
|
}
|
|
54
|
-
|
|
55
44
|
if ((event.oldState === EventType.BEGAN || event.oldState === EventType.ACTIVE) && event.state !== EventType.BEGAN && event.state !== EventType.ACTIVE && handlers.onFinish) {
|
|
56
45
|
handlers.onFinish(event, context, event.state === EventType.CANCELLED || event.state === EventType.FAILED);
|
|
57
46
|
}
|
|
58
47
|
};
|
|
59
|
-
|
|
60
48
|
if (useWeb) {
|
|
61
49
|
return handler;
|
|
62
50
|
}
|
|
63
|
-
|
|
64
51
|
return (0, _Hooks.useEvent)(handler, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], doDependenciesDiffer);
|
|
65
52
|
}
|
|
66
53
|
//# sourceMappingURL=useAnimatedGestureHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EventType","useAnimatedGestureHandler","handlers","dependencies","context","doDependenciesDiffer","useWeb","useHandler","handler","e","event","nativeEvent","state","BEGAN","onStart","ACTIVE","onActive","oldState","END","onEnd","FAILED","onFail","CANCELLED","onCancel","onFinish","useEvent"],"sources":["useAnimatedGestureHandler.ts"],"sourcesContent":["import { MutableRefObject } from 'react';\nimport { Context, WorkletFunction } from '../commonTypes';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport { DependencyList } from './commonTypes';\nimport { useEvent, useHandler } from './Hooks';\n\ninterface Handler<T, TContext extends Context> extends WorkletFunction {\n (event: T, context: TContext, isCanceledOrFailed?: boolean): void;\n}\n\nexport interface GestureHandlers<T, TContext extends Context> {\n [key: string]: Handler<T, TContext> | undefined;\n onStart?: Handler<T, TContext>;\n onActive?: Handler<T, TContext>;\n onEnd?: Handler<T, TContext>;\n onFail?: Handler<T, TContext>;\n onCancel?: Handler<T, TContext>;\n onFinish?: Handler<T, TContext>;\n}\n\nexport enum EventType {\n UNDETERMINED = 0,\n FAILED,\n BEGAN,\n CANCELLED,\n ACTIVE,\n END,\n}\n\nexport interface GestureHandlerStateChangeNativeEvent {\n handlerTag: number;\n numberOfPointers: number;\n state: EventType;\n oldState: EventType;\n}\n\nexport interface GestureHandlerEvent<T>\n extends GestureHandlerStateChangeNativeEvent {\n nativeEvent: T;\n}\n\nexport function useAnimatedGestureHandler<\n T extends GestureHandlerEvent<T>,\n TContext extends Context\n>(\n handlers: GestureHandlers<T, TContext>,\n dependencies?: DependencyList\n): MutableRefObject<WorkletEventHandler<T> | null> | ((e: T) => void) {\n const { context, doDependenciesDiffer, useWeb } = useHandler<T, TContext>(\n handlers,\n dependencies\n );\n\n const handler = (e: T) => {\n 'worklet';\n const event = useWeb ? e.nativeEvent : e;\n\n if (event.state === EventType.BEGAN && handlers.onStart) {\n handlers.onStart(event, context);\n }\n if (event.state === EventType.ACTIVE && handlers.onActive) {\n handlers.onActive(event, context);\n }\n if (\n event.oldState === EventType.ACTIVE &&\n event.state === EventType.END &&\n handlers.onEnd\n ) {\n handlers.onEnd(event, context);\n }\n if (\n event.oldState === EventType.BEGAN &&\n event.state === EventType.FAILED &&\n handlers.onFail\n ) {\n handlers.onFail(event, context);\n }\n if (\n event.oldState === EventType.ACTIVE &&\n event.state === EventType.CANCELLED &&\n handlers.onCancel\n ) {\n handlers.onCancel(event, context);\n }\n if (\n (event.oldState === EventType.BEGAN ||\n event.oldState === EventType.ACTIVE) &&\n event.state !== EventType.BEGAN &&\n event.state !== EventType.ACTIVE &&\n handlers.onFinish\n ) {\n handlers.onFinish(\n event,\n context,\n event.state === EventType.CANCELLED || event.state === EventType.FAILED\n );\n }\n };\n\n if (useWeb) {\n return handler;\n }\n\n return useEvent<T>(\n handler,\n ['onGestureHandlerStateChange', 'onGestureHandlerEvent'],\n doDependenciesDiffer\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_Hooks","require","EventType","exports","useAnimatedGestureHandler","handlers","dependencies","context","doDependenciesDiffer","useWeb","useHandler","handler","e","event","nativeEvent","state","BEGAN","onStart","ACTIVE","onActive","oldState","END","onEnd","FAILED","onFail","CANCELLED","onCancel","onFinish","useEvent"],"sources":["useAnimatedGestureHandler.ts"],"sourcesContent":["import { MutableRefObject } from 'react';\nimport { Context, WorkletFunction } from '../commonTypes';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport { DependencyList } from './commonTypes';\nimport { useEvent, useHandler } from './Hooks';\n\ninterface Handler<T, TContext extends Context> extends WorkletFunction {\n (event: T, context: TContext, isCanceledOrFailed?: boolean): void;\n}\n\nexport interface GestureHandlers<T, TContext extends Context> {\n [key: string]: Handler<T, TContext> | undefined;\n onStart?: Handler<T, TContext>;\n onActive?: Handler<T, TContext>;\n onEnd?: Handler<T, TContext>;\n onFail?: Handler<T, TContext>;\n onCancel?: Handler<T, TContext>;\n onFinish?: Handler<T, TContext>;\n}\n\nexport enum EventType {\n UNDETERMINED = 0,\n FAILED,\n BEGAN,\n CANCELLED,\n ACTIVE,\n END,\n}\n\nexport interface GestureHandlerStateChangeNativeEvent {\n handlerTag: number;\n numberOfPointers: number;\n state: EventType;\n oldState: EventType;\n}\n\nexport interface GestureHandlerEvent<T>\n extends GestureHandlerStateChangeNativeEvent {\n nativeEvent: T;\n}\n\nexport function useAnimatedGestureHandler<\n T extends GestureHandlerEvent<T>,\n TContext extends Context\n>(\n handlers: GestureHandlers<T, TContext>,\n dependencies?: DependencyList\n): MutableRefObject<WorkletEventHandler<T> | null> | ((e: T) => void) {\n const { context, doDependenciesDiffer, useWeb } = useHandler<T, TContext>(\n handlers,\n dependencies\n );\n\n const handler = (e: T) => {\n 'worklet';\n const event = useWeb ? e.nativeEvent : e;\n\n if (event.state === EventType.BEGAN && handlers.onStart) {\n handlers.onStart(event, context);\n }\n if (event.state === EventType.ACTIVE && handlers.onActive) {\n handlers.onActive(event, context);\n }\n if (\n event.oldState === EventType.ACTIVE &&\n event.state === EventType.END &&\n handlers.onEnd\n ) {\n handlers.onEnd(event, context);\n }\n if (\n event.oldState === EventType.BEGAN &&\n event.state === EventType.FAILED &&\n handlers.onFail\n ) {\n handlers.onFail(event, context);\n }\n if (\n event.oldState === EventType.ACTIVE &&\n event.state === EventType.CANCELLED &&\n handlers.onCancel\n ) {\n handlers.onCancel(event, context);\n }\n if (\n (event.oldState === EventType.BEGAN ||\n event.oldState === EventType.ACTIVE) &&\n event.state !== EventType.BEGAN &&\n event.state !== EventType.ACTIVE &&\n handlers.onFinish\n ) {\n handlers.onFinish(\n event,\n context,\n event.state === EventType.CANCELLED || event.state === EventType.FAILED\n );\n }\n };\n\n if (useWeb) {\n return handler;\n }\n\n return useEvent<T>(\n handler,\n ['onGestureHandlerStateChange', 'onGestureHandlerEvent'],\n doDependenciesDiffer\n );\n}\n"],"mappings":";;;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAA+C,IAgBnCC,SAAS,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA;AAAAC,OAAA,CAAAD,SAAA,GAAAA,SAAA;AAqBd,SAASE,yBAAyBA,CAIvCC,QAAsC,EACtCC,YAA6B,EACuC;EACpE,MAAM;IAAEC,OAAO;IAAEC,oBAAoB;IAAEC;EAAO,CAAC,GAAG,IAAAC,iBAAU,EAC1DL,QAAQ,EACRC,YAAY,CACb;EAED,MAAMK,OAAO,GAAIC,CAAI,IAAK;IACxB,SAAS;;IACT,MAAMC,KAAK,GAAGJ,MAAM,GAAGG,CAAC,CAACE,WAAW,GAAGF,CAAC;IAExC,IAAIC,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACc,KAAK,IAAIX,QAAQ,CAACY,OAAO,EAAE;MACvDZ,QAAQ,CAACY,OAAO,CAACJ,KAAK,EAAEN,OAAO,CAAC;IAClC;IACA,IAAIM,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACgB,MAAM,IAAIb,QAAQ,CAACc,QAAQ,EAAE;MACzDd,QAAQ,CAACc,QAAQ,CAACN,KAAK,EAAEN,OAAO,CAAC;IACnC;IACA,IACEM,KAAK,CAACO,QAAQ,KAAKlB,SAAS,CAACgB,MAAM,IACnCL,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACmB,GAAG,IAC7BhB,QAAQ,CAACiB,KAAK,EACd;MACAjB,QAAQ,CAACiB,KAAK,CAACT,KAAK,EAAEN,OAAO,CAAC;IAChC;IACA,IACEM,KAAK,CAACO,QAAQ,KAAKlB,SAAS,CAACc,KAAK,IAClCH,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACqB,MAAM,IAChClB,QAAQ,CAACmB,MAAM,EACf;MACAnB,QAAQ,CAACmB,MAAM,CAACX,KAAK,EAAEN,OAAO,CAAC;IACjC;IACA,IACEM,KAAK,CAACO,QAAQ,KAAKlB,SAAS,CAACgB,MAAM,IACnCL,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACuB,SAAS,IACnCpB,QAAQ,CAACqB,QAAQ,EACjB;MACArB,QAAQ,CAACqB,QAAQ,CAACb,KAAK,EAAEN,OAAO,CAAC;IACnC;IACA,IACE,CAACM,KAAK,CAACO,QAAQ,KAAKlB,SAAS,CAACc,KAAK,IACjCH,KAAK,CAACO,QAAQ,KAAKlB,SAAS,CAACgB,MAAM,KACrCL,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACc,KAAK,IAC/BH,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACgB,MAAM,IAChCb,QAAQ,CAACsB,QAAQ,EACjB;MACAtB,QAAQ,CAACsB,QAAQ,CACfd,KAAK,EACLN,OAAO,EACPM,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACuB,SAAS,IAAIZ,KAAK,CAACE,KAAK,KAAKb,SAAS,CAACqB,MAAM,CACxE;IACH;EACF,CAAC;EAED,IAAId,MAAM,EAAE;IACV,OAAOE,OAAO;EAChB;EAEA,OAAO,IAAAiB,eAAQ,EACbjB,OAAO,EACP,CAAC,6BAA6B,EAAE,uBAAuB,CAAC,EACxDH,oBAAoB,CACrB;AACH"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimatedKeyboard = useAnimatedKeyboard;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _core = require("../core");
|
|
11
|
-
|
|
12
9
|
var _commonTypes = require("../commonTypes");
|
|
13
|
-
|
|
14
10
|
function useAnimatedKeyboard() {
|
|
15
11
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
16
12
|
isStatusBarTranslucentAndroid: false
|
|
@@ -18,7 +14,6 @@ function useAnimatedKeyboard() {
|
|
|
18
14
|
const ref = (0, _react.useRef)(null);
|
|
19
15
|
const listenerId = (0, _react.useRef)(-1);
|
|
20
16
|
const isSubscribed = (0, _react.useRef)(false);
|
|
21
|
-
|
|
22
17
|
if (ref.current === null) {
|
|
23
18
|
const keyboardEventData = {
|
|
24
19
|
state: (0, _core.makeMutable)(_commonTypes.KeyboardState.UNKNOWN),
|
|
@@ -33,11 +28,10 @@ function useAnimatedKeyboard() {
|
|
|
33
28
|
ref.current = keyboardEventData;
|
|
34
29
|
isSubscribed.current = true;
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
(0, _react.useEffect)(() => {
|
|
38
32
|
if (isSubscribed.current === false && ref.current !== null) {
|
|
39
|
-
const keyboardEventData = ref.current;
|
|
40
|
-
|
|
33
|
+
const keyboardEventData = ref.current;
|
|
34
|
+
// subscribe again after Fast Refresh
|
|
41
35
|
listenerId.current = (0, _core.subscribeForKeyboardEvents)((state, height) => {
|
|
42
36
|
'worklet';
|
|
43
37
|
|
|
@@ -46,7 +40,6 @@ function useAnimatedKeyboard() {
|
|
|
46
40
|
}, options);
|
|
47
41
|
isSubscribed.current = true;
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
return () => {
|
|
51
44
|
(0, _core.unsubscribeFromKeyboardEvents)(listenerId.current);
|
|
52
45
|
isSubscribed.current = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedKeyboard","options","isStatusBarTranslucentAndroid","ref","useRef","listenerId","isSubscribed","current","keyboardEventData","state","makeMutable","KeyboardState","UNKNOWN","height","subscribeForKeyboardEvents","value","useEffect","unsubscribeFromKeyboardEvents"],"sources":["useAnimatedKeyboard.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n makeMutable,\n subscribeForKeyboardEvents,\n unsubscribeFromKeyboardEvents,\n} from '../core';\nimport {\n AnimatedKeyboardInfo,\n AnimatedKeyboardOptions,\n KeyboardState,\n} from '../commonTypes';\n\nexport function useAnimatedKeyboard(\n options: AnimatedKeyboardOptions = { isStatusBarTranslucentAndroid: false }\n): AnimatedKeyboardInfo {\n const ref = useRef<AnimatedKeyboardInfo | null>(null);\n const listenerId = useRef<number>(-1);\n const isSubscribed = useRef<boolean>(false);\n\n if (ref.current === null) {\n const keyboardEventData: AnimatedKeyboardInfo = {\n state: makeMutable<KeyboardState>(KeyboardState.UNKNOWN),\n height: makeMutable(0),\n };\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n }, options);\n ref.current = keyboardEventData;\n isSubscribed.current = true;\n }\n useEffect(() => {\n if (isSubscribed.current === false && ref.current !== null) {\n const keyboardEventData = ref.current;\n // subscribe again after Fast Refresh\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n }, options);\n isSubscribed.current = true;\n }\n return () => {\n unsubscribeFromKeyboardEvents(listenerId.current);\n isSubscribed.current = false;\n };\n }, []);\n return ref.current;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_react","require","_core","_commonTypes","useAnimatedKeyboard","options","arguments","length","undefined","isStatusBarTranslucentAndroid","ref","useRef","listenerId","isSubscribed","current","keyboardEventData","state","makeMutable","KeyboardState","UNKNOWN","height","subscribeForKeyboardEvents","value","useEffect","unsubscribeFromKeyboardEvents"],"sources":["useAnimatedKeyboard.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport {\n makeMutable,\n subscribeForKeyboardEvents,\n unsubscribeFromKeyboardEvents,\n} from '../core';\nimport {\n AnimatedKeyboardInfo,\n AnimatedKeyboardOptions,\n KeyboardState,\n} from '../commonTypes';\n\nexport function useAnimatedKeyboard(\n options: AnimatedKeyboardOptions = { isStatusBarTranslucentAndroid: false }\n): AnimatedKeyboardInfo {\n const ref = useRef<AnimatedKeyboardInfo | null>(null);\n const listenerId = useRef<number>(-1);\n const isSubscribed = useRef<boolean>(false);\n\n if (ref.current === null) {\n const keyboardEventData: AnimatedKeyboardInfo = {\n state: makeMutable<KeyboardState>(KeyboardState.UNKNOWN),\n height: makeMutable(0),\n };\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n }, options);\n ref.current = keyboardEventData;\n isSubscribed.current = true;\n }\n useEffect(() => {\n if (isSubscribed.current === false && ref.current !== null) {\n const keyboardEventData = ref.current;\n // subscribe again after Fast Refresh\n listenerId.current = subscribeForKeyboardEvents((state, height) => {\n 'worklet';\n keyboardEventData.state.value = state;\n keyboardEventData.height.value = height;\n }, options);\n isSubscribed.current = true;\n }\n return () => {\n unsubscribeFromKeyboardEvents(listenerId.current);\n isSubscribed.current = false;\n };\n }, []);\n return ref.current;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,YAAA,GAAAF,OAAA;AAMO,SAASG,mBAAmBA,CAAA,EAEX;EAAA,IADtBC,OAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IAAEG,6BAA6B,EAAE;EAAM,CAAC;EAE3E,MAAMC,GAAG,GAAG,IAAAC,aAAM,EAA8B,IAAI,CAAC;EACrD,MAAMC,UAAU,GAAG,IAAAD,aAAM,EAAS,CAAC,CAAC,CAAC;EACrC,MAAME,YAAY,GAAG,IAAAF,aAAM,EAAU,KAAK,CAAC;EAE3C,IAAID,GAAG,CAACI,OAAO,KAAK,IAAI,EAAE;IACxB,MAAMC,iBAAuC,GAAG;MAC9CC,KAAK,EAAE,IAAAC,iBAAW,EAAgBC,0BAAa,CAACC,OAAO,CAAC;MACxDC,MAAM,EAAE,IAAAH,iBAAW,EAAC,CAAC;IACvB,CAAC;IACDL,UAAU,CAACE,OAAO,GAAG,IAAAO,gCAA0B,EAAC,CAACL,KAAK,EAAEI,MAAM,KAAK;MACjE,SAAS;;MACTL,iBAAiB,CAACC,KAAK,CAACM,KAAK,GAAGN,KAAK;MACrCD,iBAAiB,CAACK,MAAM,CAACE,KAAK,GAAGF,MAAM;IACzC,CAAC,EAAEf,OAAO,CAAC;IACXK,GAAG,CAACI,OAAO,GAAGC,iBAAiB;IAC/BF,YAAY,CAACC,OAAO,GAAG,IAAI;EAC7B;EACA,IAAAS,gBAAS,EAAC,MAAM;IACd,IAAIV,YAAY,CAACC,OAAO,KAAK,KAAK,IAAIJ,GAAG,CAACI,OAAO,KAAK,IAAI,EAAE;MAC1D,MAAMC,iBAAiB,GAAGL,GAAG,CAACI,OAAO;MACrC;MACAF,UAAU,CAACE,OAAO,GAAG,IAAAO,gCAA0B,EAAC,CAACL,KAAK,EAAEI,MAAM,KAAK;QACjE,SAAS;;QACTL,iBAAiB,CAACC,KAAK,CAACM,KAAK,GAAGN,KAAK;QACrCD,iBAAiB,CAACK,MAAM,CAACE,KAAK,GAAGF,MAAM;MACzC,CAAC,EAAEf,OAAO,CAAC;MACXQ,YAAY,CAACC,OAAO,GAAG,IAAI;IAC7B;IACA,OAAO,MAAM;MACX,IAAAU,mCAA6B,EAACZ,UAAU,CAACE,OAAO,CAAC;MACjDD,YAAY,CAACC,OAAO,GAAG,KAAK;IAC9B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EACN,OAAOJ,GAAG,CAACI,OAAO;AACpB"}
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimatedReaction = useAnimatedReaction;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _core = require("../core");
|
|
11
|
-
|
|
12
9
|
var _useSharedValue = require("./useSharedValue");
|
|
13
|
-
|
|
14
10
|
var _PlatformChecker = require("../PlatformChecker");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* @param prepare - worklet used for data preparation for the second parameter
|
|
18
13
|
* @param react - worklet which takes data prepared by the one in the first parameter and performs certain actions
|
|
@@ -22,22 +17,18 @@ var _PlatformChecker = require("../PlatformChecker");
|
|
|
22
17
|
function useAnimatedReaction(prepare, react, dependencies) {
|
|
23
18
|
const previous = (0, _useSharedValue.useSharedValue)(null);
|
|
24
19
|
let inputs = Object.values(prepare._closure ?? {});
|
|
25
|
-
|
|
26
20
|
if ((0, _PlatformChecker.shouldBeUseWeb)()) {
|
|
27
21
|
var _dependencies;
|
|
28
|
-
|
|
29
22
|
if (!inputs.length && (_dependencies = dependencies) !== null && _dependencies !== void 0 && _dependencies.length) {
|
|
30
23
|
// let web work without a Babel/SWC plugin
|
|
31
24
|
inputs = dependencies;
|
|
32
25
|
}
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
if (dependencies === undefined) {
|
|
36
|
-
dependencies = [Object.values(prepare._closure ?? {}), Object.values(react._closure ?? {}), prepare.__workletHash, react.__workletHash];
|
|
28
|
+
dependencies = [...Object.values(prepare._closure ?? {}), ...Object.values(react._closure ?? {}), prepare.__workletHash, react.__workletHash];
|
|
37
29
|
} else {
|
|
38
30
|
dependencies.push(prepare.__workletHash, react.__workletHash);
|
|
39
31
|
}
|
|
40
|
-
|
|
41
32
|
(0, _react.useEffect)(() => {
|
|
42
33
|
const fun = () => {
|
|
43
34
|
'worklet';
|
|
@@ -46,7 +37,6 @@ function useAnimatedReaction(prepare, react, dependencies) {
|
|
|
46
37
|
react(input, previous.value);
|
|
47
38
|
previous.value = input;
|
|
48
39
|
};
|
|
49
|
-
|
|
50
40
|
const mapperId = (0, _core.startMapper)(fun, inputs, []);
|
|
51
41
|
return () => {
|
|
52
42
|
(0, _core.stopMapper)(mapperId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedReaction","prepare","react","dependencies","previous","useSharedValue","inputs","Object","values","_closure","shouldBeUseWeb","length","undefined","__workletHash","push","useEffect","fun","input","value","mapperId","startMapper","stopMapper"],"sources":["useAnimatedReaction.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { BasicWorkletFunction, WorkletFunction } from '../commonTypes';\nimport { startMapper, stopMapper } from '../core';\nimport { DependencyList } from './commonTypes';\nimport { useSharedValue } from './useSharedValue';\nimport { shouldBeUseWeb } from '../PlatformChecker';\n\nexport interface AnimatedReactionWorkletFunction<T> extends WorkletFunction {\n (prepared: T, previous: T | null): void;\n}\n/**\n * @param prepare - worklet used for data preparation for the second parameter\n * @param react - worklet which takes data prepared by the one in the first parameter and performs certain actions\n * the first worklet defines the inputs, in other words on which shared values change will it be called.\n * the second one can modify any shared values but those which are mentioned in the first worklet. Beware of that, because this may result in endless loop and high cpu usage.\n */\nexport function useAnimatedReaction<T>(\n prepare: BasicWorkletFunction<T>,\n react: AnimatedReactionWorkletFunction<T>,\n dependencies: DependencyList\n): void {\n const previous = useSharedValue<T | null>(null);\n\n let inputs = Object.values(prepare._closure ?? {});\n\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 if (dependencies === undefined) {\n dependencies = [\n Object.values(prepare._closure ?? {}),\n Object.values(react._closure ?? {}),\n prepare.__workletHash,\n react.__workletHash,\n ];\n } else {\n dependencies.push(prepare.__workletHash, react.__workletHash);\n }\n\n useEffect(() => {\n const fun = () => {\n 'worklet';\n const input = prepare();\n react(input, previous.value);\n previous.value = input;\n };\n const mapperId = startMapper(fun, inputs, []);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_react","require","_core","_useSharedValue","_PlatformChecker","useAnimatedReaction","prepare","react","dependencies","previous","useSharedValue","inputs","Object","values","_closure","shouldBeUseWeb","_dependencies","length","undefined","__workletHash","push","useEffect","fun","input","value","mapperId","startMapper","stopMapper"],"sources":["useAnimatedReaction.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { BasicWorkletFunction, WorkletFunction } from '../commonTypes';\nimport { startMapper, stopMapper } from '../core';\nimport { DependencyList } from './commonTypes';\nimport { useSharedValue } from './useSharedValue';\nimport { shouldBeUseWeb } from '../PlatformChecker';\n\nexport interface AnimatedReactionWorkletFunction<T> extends WorkletFunction {\n (prepared: T, previous: T | null): void;\n}\n/**\n * @param prepare - worklet used for data preparation for the second parameter\n * @param react - worklet which takes data prepared by the one in the first parameter and performs certain actions\n * the first worklet defines the inputs, in other words on which shared values change will it be called.\n * the second one can modify any shared values but those which are mentioned in the first worklet. Beware of that, because this may result in endless loop and high cpu usage.\n */\nexport function useAnimatedReaction<T>(\n prepare: BasicWorkletFunction<T>,\n react: AnimatedReactionWorkletFunction<T>,\n dependencies: DependencyList\n): void {\n const previous = useSharedValue<T | null>(null);\n\n let inputs = Object.values(prepare._closure ?? {});\n\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 if (dependencies === undefined) {\n dependencies = [\n ...Object.values(prepare._closure ?? {}),\n ...Object.values(react._closure ?? {}),\n prepare.__workletHash,\n react.__workletHash,\n ];\n } else {\n dependencies.push(prepare.__workletHash, react.__workletHash);\n }\n\n useEffect(() => {\n const fun = () => {\n 'worklet';\n const input = prepare();\n react(input, previous.value);\n previous.value = input;\n };\n const mapperId = startMapper(fun, inputs, []);\n return () => {\n stopMapper(mapperId);\n };\n }, dependencies);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,mBAAmBA,CACjCC,OAAgC,EAChCC,KAAyC,EACzCC,YAA4B,EACtB;EACN,MAAMC,QAAQ,GAAG,IAAAC,8BAAc,EAAW,IAAI,CAAC;EAE/C,IAAIC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAACP,OAAO,CAACQ,QAAQ,IAAI,CAAC,CAAC,CAAC;EAElD,IAAI,IAAAC,+BAAc,GAAE,EAAE;IAAA,IAAAC,aAAA;IACpB,IAAI,CAACL,MAAM,CAACM,MAAM,KAAAD,aAAA,GAAIR,YAAY,cAAAQ,aAAA,eAAZA,aAAA,CAAcC,MAAM,EAAE;MAC1C;MACAN,MAAM,GAAGH,YAAY;IACvB;EACF;EAEA,IAAIA,YAAY,KAAKU,SAAS,EAAE;IAC9BV,YAAY,GAAG,CACb,GAAGI,MAAM,CAACC,MAAM,CAACP,OAAO,CAACQ,QAAQ,IAAI,CAAC,CAAC,CAAC,EACxC,GAAGF,MAAM,CAACC,MAAM,CAACN,KAAK,CAACO,QAAQ,IAAI,CAAC,CAAC,CAAC,EACtCR,OAAO,CAACa,aAAa,EACrBZ,KAAK,CAACY,aAAa,CACpB;EACH,CAAC,MAAM;IACLX,YAAY,CAACY,IAAI,CAACd,OAAO,CAACa,aAAa,EAAEZ,KAAK,CAACY,aAAa,CAAC;EAC/D;EAEA,IAAAE,gBAAS,EAAC,MAAM;IACd,MAAMC,GAAG,GAAGA,CAAA,KAAM;MAChB,SAAS;;MACT,MAAMC,KAAK,GAAGjB,OAAO,EAAE;MACvBC,KAAK,CAACgB,KAAK,EAAEd,QAAQ,CAACe,KAAK,CAAC;MAC5Bf,QAAQ,CAACe,KAAK,GAAGD,KAAK;IACxB,CAAC;IACD,MAAME,QAAQ,GAAG,IAAAC,iBAAW,EAACJ,GAAG,EAAEX,MAAM,EAAE,EAAE,CAAC;IAC7C,OAAO,MAAM;MACX,IAAAgB,gBAAU,EAACF,QAAQ,CAAC;IACtB,CAAC;EACH,CAAC,EAAEjB,YAAY,CAAC;AAClB"}
|
|
@@ -4,27 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimatedRef = useAnimatedRef;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _useSharedValue = require("./useSharedValue");
|
|
11
|
-
|
|
12
9
|
var _NativeMethods = require("../NativeMethods");
|
|
13
|
-
|
|
14
10
|
var _fabricUtils = require("../fabricUtils");
|
|
15
|
-
|
|
16
11
|
var _shareables = require("../shareables");
|
|
17
|
-
|
|
18
12
|
function getShareableShadowNodeFromComponent(component) {
|
|
19
13
|
return (0, _fabricUtils.getShadowNodeWrapperFromHostInstance)(component);
|
|
20
14
|
}
|
|
21
|
-
|
|
22
15
|
const getTagValueFunction = global._IS_FABRIC ? getShareableShadowNodeFromComponent : _NativeMethods.getTag;
|
|
23
|
-
|
|
24
16
|
function useAnimatedRef() {
|
|
25
17
|
const tag = (0, _useSharedValue.useSharedValue)(-1);
|
|
26
18
|
const ref = (0, _react.useRef)();
|
|
27
|
-
|
|
28
19
|
if (!ref.current) {
|
|
29
20
|
const fun = component => {
|
|
30
21
|
// enters when ref is set by attaching to a component
|
|
@@ -32,10 +23,8 @@ function useAnimatedRef() {
|
|
|
32
23
|
tag.value = getTagValueFunction(component);
|
|
33
24
|
fun.current = component;
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
return tag.value;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
fun.current = null;
|
|
40
29
|
const remoteRef = (0, _shareables.makeShareableCloneRecursive)({
|
|
41
30
|
__init: () => {
|
|
@@ -47,7 +36,6 @@ function useAnimatedRef() {
|
|
|
47
36
|
(0, _shareables.registerShareableMapping)(fun, remoteRef);
|
|
48
37
|
ref.current = fun;
|
|
49
38
|
}
|
|
50
|
-
|
|
51
39
|
return ref.current;
|
|
52
40
|
}
|
|
53
41
|
//# sourceMappingURL=useAnimatedRef.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getShareableShadowNodeFromComponent","component","getShadowNodeWrapperFromHostInstance","getTagValueFunction","global","_IS_FABRIC","getTag","useAnimatedRef","tag","useSharedValue","ref","useRef","current","fun","value","remoteRef","makeShareableCloneRecursive","__init","registerShareableMapping"],"sources":["useAnimatedRef.ts"],"sourcesContent":["import { Component, useRef } from 'react';\nimport { useSharedValue } from './useSharedValue';\nimport { RefObjectFunction } from './commonTypes';\nimport { ShadowNodeWrapper } from '../commonTypes';\nimport { getTag } from '../NativeMethods';\nimport { getShadowNodeWrapperFromHostInstance } from '../fabricUtils';\nimport {\n makeShareableCloneRecursive,\n registerShareableMapping,\n} from '../shareables';\n\nfunction getShareableShadowNodeFromComponent(\n component: Component\n): ShadowNodeWrapper {\n return getShadowNodeWrapperFromHostInstance(component);\n}\n\nconst getTagValueFunction = global._IS_FABRIC\n ? getShareableShadowNodeFromComponent\n : getTag;\n\nexport function useAnimatedRef<T extends Component>(): RefObjectFunction<T> {\n const tag = useSharedValue<number | ShadowNodeWrapper | null>(-1);\n const ref = useRef<RefObjectFunction<T>>();\n\n if (!ref.current) {\n const fun: RefObjectFunction<T> = <RefObjectFunction<T>>((component) => {\n // enters when ref is set by attaching to a component\n if (component) {\n tag.value = getTagValueFunction(component);\n fun.current = component;\n }\n return tag.value;\n });\n\n fun.current = null;\n\n const remoteRef = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return () => tag.value;\n },\n });\n registerShareableMapping(fun, remoteRef);\n\n ref.current = fun;\n }\n\n return ref.current;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_react","require","_useSharedValue","_NativeMethods","_fabricUtils","_shareables","getShareableShadowNodeFromComponent","component","getShadowNodeWrapperFromHostInstance","getTagValueFunction","global","_IS_FABRIC","getTag","useAnimatedRef","tag","useSharedValue","ref","useRef","current","fun","value","remoteRef","makeShareableCloneRecursive","__init","registerShareableMapping"],"sources":["useAnimatedRef.ts"],"sourcesContent":["import { Component, useRef } from 'react';\nimport { useSharedValue } from './useSharedValue';\nimport { RefObjectFunction } from './commonTypes';\nimport { ShadowNodeWrapper } from '../commonTypes';\nimport { getTag } from '../NativeMethods';\nimport { getShadowNodeWrapperFromHostInstance } from '../fabricUtils';\nimport {\n makeShareableCloneRecursive,\n registerShareableMapping,\n} from '../shareables';\n\nfunction getShareableShadowNodeFromComponent(\n component: Component\n): ShadowNodeWrapper {\n return getShadowNodeWrapperFromHostInstance(component);\n}\n\nconst getTagValueFunction = global._IS_FABRIC\n ? getShareableShadowNodeFromComponent\n : getTag;\n\nexport function useAnimatedRef<T extends Component>(): RefObjectFunction<T> {\n const tag = useSharedValue<number | ShadowNodeWrapper | null>(-1);\n const ref = useRef<RefObjectFunction<T>>();\n\n if (!ref.current) {\n const fun: RefObjectFunction<T> = <RefObjectFunction<T>>((component) => {\n // enters when ref is set by attaching to a component\n if (component) {\n tag.value = getTagValueFunction(component);\n fun.current = component;\n }\n return tag.value;\n });\n\n fun.current = null;\n\n const remoteRef = makeShareableCloneRecursive({\n __init: () => {\n 'worklet';\n return () => tag.value;\n },\n });\n registerShareableMapping(fun, remoteRef);\n\n ref.current = fun;\n }\n\n return ref.current;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,SAASK,mCAAmCA,CAC1CC,SAAoB,EACD;EACnB,OAAO,IAAAC,iDAAoC,EAACD,SAAS,CAAC;AACxD;AAEA,MAAME,mBAAmB,GAAGC,MAAM,CAACC,UAAU,GACzCL,mCAAmC,GACnCM,qBAAM;AAEH,SAASC,cAAcA,CAAA,EAA8C;EAC1E,MAAMC,GAAG,GAAG,IAAAC,8BAAc,EAAoC,CAAC,CAAC,CAAC;EACjE,MAAMC,GAAG,GAAG,IAAAC,aAAM,GAAwB;EAE1C,IAAI,CAACD,GAAG,CAACE,OAAO,EAAE;IAChB,MAAMC,GAAyB,GAA2BZ,SAAS,IAAK;MACtE;MACA,IAAIA,SAAS,EAAE;QACbO,GAAG,CAACM,KAAK,GAAGX,mBAAmB,CAACF,SAAS,CAAC;QAC1CY,GAAG,CAACD,OAAO,GAAGX,SAAS;MACzB;MACA,OAAOO,GAAG,CAACM,KAAK;IAClB,CAAE;IAEFD,GAAG,CAACD,OAAO,GAAG,IAAI;IAElB,MAAMG,SAAS,GAAG,IAAAC,uCAA2B,EAAC;MAC5CC,MAAM,EAAEA,CAAA,KAAM;QACZ,SAAS;;QACT,OAAO,MAAMT,GAAG,CAACM,KAAK;MACxB;IACF,CAAC,CAAC;IACF,IAAAI,oCAAwB,EAACL,GAAG,EAAEE,SAAS,CAAC;IAExCL,GAAG,CAACE,OAAO,GAAGC,GAAG;EACnB;EAEA,OAAOH,GAAG,CAACE,OAAO;AACpB"}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimatedScrollHandler = useAnimatedScrollHandler;
|
|
7
|
-
|
|
8
7
|
var _Hooks = require("./Hooks");
|
|
9
|
-
|
|
10
8
|
function useAnimatedScrollHandler(handlers, dependencies) {
|
|
11
9
|
// case when handlers is a function
|
|
12
10
|
const scrollHandlers = typeof handlers === 'function' ? {
|
|
@@ -15,26 +13,22 @@ function useAnimatedScrollHandler(handlers, dependencies) {
|
|
|
15
13
|
const {
|
|
16
14
|
context,
|
|
17
15
|
doDependenciesDiffer
|
|
18
|
-
} = (0, _Hooks.useHandler)(scrollHandlers, dependencies);
|
|
16
|
+
} = (0, _Hooks.useHandler)(scrollHandlers, dependencies);
|
|
19
17
|
|
|
18
|
+
// build event subscription array
|
|
20
19
|
const subscribeForEvents = ['onScroll'];
|
|
21
|
-
|
|
22
20
|
if (scrollHandlers.onBeginDrag !== undefined) {
|
|
23
21
|
subscribeForEvents.push('onScrollBeginDrag');
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
if (scrollHandlers.onEndDrag !== undefined) {
|
|
27
24
|
subscribeForEvents.push('onScrollEndDrag');
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
if (scrollHandlers.onMomentumBegin !== undefined) {
|
|
31
27
|
subscribeForEvents.push('onMomentumScrollBegin');
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
if (scrollHandlers.onMomentumEnd !== undefined) {
|
|
35
30
|
subscribeForEvents.push('onMomentumScrollEnd');
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
return (0, _Hooks.useEvent)(event => {
|
|
39
33
|
'worklet';
|
|
40
34
|
|
|
@@ -45,7 +39,6 @@ function useAnimatedScrollHandler(handlers, dependencies) {
|
|
|
45
39
|
onMomentumBegin,
|
|
46
40
|
onMomentumEnd
|
|
47
41
|
} = scrollHandlers;
|
|
48
|
-
|
|
49
42
|
if (onScroll && event.eventName.endsWith('onScroll')) {
|
|
50
43
|
onScroll(event, context);
|
|
51
44
|
} else if (onBeginDrag && event.eventName.endsWith('onScrollBeginDrag')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useAnimatedScrollHandler","handlers","dependencies","scrollHandlers","onScroll","context","doDependenciesDiffer","useHandler","subscribeForEvents","onBeginDrag","undefined","push","onEndDrag","onMomentumBegin","onMomentumEnd","useEvent","event","eventName","endsWith"],"sources":["useAnimatedScrollHandler.ts"],"sourcesContent":["import { RefObject } from 'react';\nimport { NativeScrollEvent } from 'react-native';\nimport { Context, NativeEvent, WorkletFunction } from '../commonTypes';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport { DependencyList } from './commonTypes';\nimport { useEvent, useHandler } from './Hooks';\n\nexport interface ScrollHandler<TContext extends Context>\n extends WorkletFunction {\n (event: NativeScrollEvent, context?: TContext): void;\n}\n\nexport interface ScrollEvent\n extends NativeScrollEvent,\n NativeEvent<ScrollEvent> {\n eventName: string;\n}\nexport interface ScrollHandlers<TContext extends Context> {\n [key: string]: ScrollHandler<TContext> | undefined;\n onScroll?: ScrollHandler<TContext>;\n onBeginDrag?: ScrollHandler<TContext>;\n onEndDrag?: ScrollHandler<TContext>;\n onMomentumBegin?: ScrollHandler<TContext>;\n onMomentumEnd?: ScrollHandler<TContext>;\n}\n\nexport function useAnimatedScrollHandler<TContext extends Context>(\n handlers: ScrollHandlers<TContext> | ScrollHandler<TContext>,\n dependencies?: DependencyList\n): RefObject<WorkletEventHandler<ScrollEvent>> {\n // case when handlers is a function\n const scrollHandlers: ScrollHandlers<TContext> =\n typeof handlers === 'function' ? { onScroll: handlers } : handlers;\n const { context, doDependenciesDiffer } = useHandler<ScrollEvent, TContext>(\n scrollHandlers,\n dependencies\n );\n\n // build event subscription array\n const subscribeForEvents = ['onScroll'];\n if (scrollHandlers.onBeginDrag !== undefined) {\n subscribeForEvents.push('onScrollBeginDrag');\n }\n if (scrollHandlers.onEndDrag !== undefined) {\n subscribeForEvents.push('onScrollEndDrag');\n }\n if (scrollHandlers.onMomentumBegin !== undefined) {\n subscribeForEvents.push('onMomentumScrollBegin');\n }\n if (scrollHandlers.onMomentumEnd !== undefined) {\n subscribeForEvents.push('onMomentumScrollEnd');\n }\n\n return useEvent<ScrollEvent>(\n (event: ScrollEvent) => {\n 'worklet';\n const {\n onScroll,\n onBeginDrag,\n onEndDrag,\n onMomentumBegin,\n onMomentumEnd,\n } = scrollHandlers;\n if (onScroll && event.eventName.endsWith('onScroll')) {\n onScroll(event, context);\n } else if (onBeginDrag && event.eventName.endsWith('onScrollBeginDrag')) {\n onBeginDrag(event, context);\n } else if (onEndDrag && event.eventName.endsWith('onScrollEndDrag')) {\n onEndDrag(event, context);\n } else if (\n onMomentumBegin &&\n event.eventName.endsWith('onMomentumScrollBegin')\n ) {\n onMomentumBegin(event, context);\n } else if (\n onMomentumEnd &&\n event.eventName.endsWith('onMomentumScrollEnd')\n ) {\n onMomentumEnd(event, context);\n }\n },\n subscribeForEvents,\n doDependenciesDiffer\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_Hooks","require","useAnimatedScrollHandler","handlers","dependencies","scrollHandlers","onScroll","context","doDependenciesDiffer","useHandler","subscribeForEvents","onBeginDrag","undefined","push","onEndDrag","onMomentumBegin","onMomentumEnd","useEvent","event","eventName","endsWith"],"sources":["useAnimatedScrollHandler.ts"],"sourcesContent":["import { RefObject } from 'react';\nimport { NativeScrollEvent } from 'react-native';\nimport { Context, NativeEvent, WorkletFunction } from '../commonTypes';\nimport WorkletEventHandler from '../WorkletEventHandler';\nimport { DependencyList } from './commonTypes';\nimport { useEvent, useHandler } from './Hooks';\n\nexport interface ScrollHandler<TContext extends Context>\n extends WorkletFunction {\n (event: NativeScrollEvent, context?: TContext): void;\n}\n\nexport interface ScrollEvent\n extends NativeScrollEvent,\n NativeEvent<ScrollEvent> {\n eventName: string;\n}\nexport interface ScrollHandlers<TContext extends Context> {\n [key: string]: ScrollHandler<TContext> | undefined;\n onScroll?: ScrollHandler<TContext>;\n onBeginDrag?: ScrollHandler<TContext>;\n onEndDrag?: ScrollHandler<TContext>;\n onMomentumBegin?: ScrollHandler<TContext>;\n onMomentumEnd?: ScrollHandler<TContext>;\n}\n\nexport function useAnimatedScrollHandler<TContext extends Context>(\n handlers: ScrollHandlers<TContext> | ScrollHandler<TContext>,\n dependencies?: DependencyList\n): RefObject<WorkletEventHandler<ScrollEvent>> {\n // case when handlers is a function\n const scrollHandlers: ScrollHandlers<TContext> =\n typeof handlers === 'function' ? { onScroll: handlers } : handlers;\n const { context, doDependenciesDiffer } = useHandler<ScrollEvent, TContext>(\n scrollHandlers,\n dependencies\n );\n\n // build event subscription array\n const subscribeForEvents = ['onScroll'];\n if (scrollHandlers.onBeginDrag !== undefined) {\n subscribeForEvents.push('onScrollBeginDrag');\n }\n if (scrollHandlers.onEndDrag !== undefined) {\n subscribeForEvents.push('onScrollEndDrag');\n }\n if (scrollHandlers.onMomentumBegin !== undefined) {\n subscribeForEvents.push('onMomentumScrollBegin');\n }\n if (scrollHandlers.onMomentumEnd !== undefined) {\n subscribeForEvents.push('onMomentumScrollEnd');\n }\n\n return useEvent<ScrollEvent>(\n (event: ScrollEvent) => {\n 'worklet';\n const {\n onScroll,\n onBeginDrag,\n onEndDrag,\n onMomentumBegin,\n onMomentumEnd,\n } = scrollHandlers;\n if (onScroll && event.eventName.endsWith('onScroll')) {\n onScroll(event, context);\n } else if (onBeginDrag && event.eventName.endsWith('onScrollBeginDrag')) {\n onBeginDrag(event, context);\n } else if (onEndDrag && event.eventName.endsWith('onScrollEndDrag')) {\n onEndDrag(event, context);\n } else if (\n onMomentumBegin &&\n event.eventName.endsWith('onMomentumScrollBegin')\n ) {\n onMomentumBegin(event, context);\n } else if (\n onMomentumEnd &&\n event.eventName.endsWith('onMomentumScrollEnd')\n ) {\n onMomentumEnd(event, context);\n }\n },\n subscribeForEvents,\n doDependenciesDiffer\n );\n}\n"],"mappings":";;;;;;AAKA,IAAAA,MAAA,GAAAC,OAAA;AAqBO,SAASC,wBAAwBA,CACtCC,QAA4D,EAC5DC,YAA6B,EACgB;EAC7C;EACA,MAAMC,cAAwC,GAC5C,OAAOF,QAAQ,KAAK,UAAU,GAAG;IAAEG,QAAQ,EAAEH;EAAS,CAAC,GAAGA,QAAQ;EACpE,MAAM;IAAEI,OAAO;IAAEC;EAAqB,CAAC,GAAG,IAAAC,iBAAU,EAClDJ,cAAc,EACdD,YAAY,CACb;;EAED;EACA,MAAMM,kBAAkB,GAAG,CAAC,UAAU,CAAC;EACvC,IAAIL,cAAc,CAACM,WAAW,KAAKC,SAAS,EAAE;IAC5CF,kBAAkB,CAACG,IAAI,CAAC,mBAAmB,CAAC;EAC9C;EACA,IAAIR,cAAc,CAACS,SAAS,KAAKF,SAAS,EAAE;IAC1CF,kBAAkB,CAACG,IAAI,CAAC,iBAAiB,CAAC;EAC5C;EACA,IAAIR,cAAc,CAACU,eAAe,KAAKH,SAAS,EAAE;IAChDF,kBAAkB,CAACG,IAAI,CAAC,uBAAuB,CAAC;EAClD;EACA,IAAIR,cAAc,CAACW,aAAa,KAAKJ,SAAS,EAAE;IAC9CF,kBAAkB,CAACG,IAAI,CAAC,qBAAqB,CAAC;EAChD;EAEA,OAAO,IAAAI,eAAQ,EACZC,KAAkB,IAAK;IACtB,SAAS;;IACT,MAAM;MACJZ,QAAQ;MACRK,WAAW;MACXG,SAAS;MACTC,eAAe;MACfC;IACF,CAAC,GAAGX,cAAc;IAClB,IAAIC,QAAQ,IAAIY,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,UAAU,CAAC,EAAE;MACpDd,QAAQ,CAACY,KAAK,EAAEX,OAAO,CAAC;IAC1B,CAAC,MAAM,IAAII,WAAW,IAAIO,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;MACvET,WAAW,CAACO,KAAK,EAAEX,OAAO,CAAC;IAC7B,CAAC,MAAM,IAAIO,SAAS,IAAII,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,iBAAiB,CAAC,EAAE;MACnEN,SAAS,CAACI,KAAK,EAAEX,OAAO,CAAC;IAC3B,CAAC,MAAM,IACLQ,eAAe,IACfG,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,uBAAuB,CAAC,EACjD;MACAL,eAAe,CAACG,KAAK,EAAEX,OAAO,CAAC;IACjC,CAAC,MAAM,IACLS,aAAa,IACbE,KAAK,CAACC,SAAS,CAACC,QAAQ,CAAC,qBAAqB,CAAC,EAC/C;MACAJ,aAAa,CAACE,KAAK,EAAEX,OAAO,CAAC;IAC/B;EACF,CAAC,EACDG,kBAAkB,EAClBF,oBAAoB,CACrB;AACH"}
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAnimatedSensor = useAnimatedSensor;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _core = require("../core");
|
|
11
|
-
|
|
12
9
|
var _commonTypes = require("../commonTypes");
|
|
13
|
-
|
|
14
10
|
var _threads = require("../threads");
|
|
15
|
-
|
|
16
11
|
function initSensorData(sensorType) {
|
|
17
12
|
if (sensorType === _commonTypes.SensorType.ROTATION) {
|
|
18
13
|
return (0, _core.makeMutable)({
|
|
@@ -33,10 +28,10 @@ function initSensorData(sensorType) {
|
|
|
33
28
|
interfaceOrientation: 0
|
|
34
29
|
});
|
|
35
30
|
}
|
|
36
|
-
}
|
|
37
|
-
// https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L237
|
|
38
|
-
|
|
31
|
+
}
|
|
39
32
|
|
|
33
|
+
// euler angles are in order ZXY, z = yaw, x = pitch, y = roll
|
|
34
|
+
// https://github.com/mrdoob/three.js/blob/dev/src/math/Quaternion.js#L237
|
|
40
35
|
function eulerToQuaternion(pitch, roll, yaw) {
|
|
41
36
|
'worklet';
|
|
42
37
|
|
|
@@ -48,7 +43,6 @@ function eulerToQuaternion(pitch, roll, yaw) {
|
|
|
48
43
|
const s3 = Math.sin(yaw / 2);
|
|
49
44
|
return [s1 * c2 * c3 - c1 * s2 * s3, c1 * s2 * c3 + s1 * c2 * s3, c1 * c2 * s3 + s1 * s2 * c3, c1 * c2 * c3 - s1 * s2 * s3];
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
function adjustRotationToInterfaceOrientation(data) {
|
|
53
47
|
'worklet';
|
|
54
48
|
|
|
@@ -58,7 +52,6 @@ function adjustRotationToInterfaceOrientation(data) {
|
|
|
58
52
|
roll,
|
|
59
53
|
yaw
|
|
60
54
|
} = data;
|
|
61
|
-
|
|
62
55
|
if (interfaceOrientation === 90) {
|
|
63
56
|
data.pitch = roll;
|
|
64
57
|
data.roll = -pitch;
|
|
@@ -72,7 +65,6 @@ function adjustRotationToInterfaceOrientation(data) {
|
|
|
72
65
|
data.roll *= -1;
|
|
73
66
|
data.yaw *= -1;
|
|
74
67
|
}
|
|
75
|
-
|
|
76
68
|
const q = eulerToQuaternion(data.pitch, data.roll, data.yaw);
|
|
77
69
|
data.qx = q[0];
|
|
78
70
|
data.qy = q[1];
|
|
@@ -80,7 +72,6 @@ function adjustRotationToInterfaceOrientation(data) {
|
|
|
80
72
|
data.qw = q[3];
|
|
81
73
|
return data;
|
|
82
74
|
}
|
|
83
|
-
|
|
84
75
|
function adjustVectorToInterfaceOrientation(data) {
|
|
85
76
|
'worklet';
|
|
86
77
|
|
|
@@ -89,7 +80,6 @@ function adjustVectorToInterfaceOrientation(data) {
|
|
|
89
80
|
x,
|
|
90
81
|
y
|
|
91
82
|
} = data;
|
|
92
|
-
|
|
93
83
|
if (interfaceOrientation === 90) {
|
|
94
84
|
data.x = -y;
|
|
95
85
|
data.y = x;
|
|
@@ -100,14 +90,13 @@ function adjustVectorToInterfaceOrientation(data) {
|
|
|
100
90
|
data.x *= -1;
|
|
101
91
|
data.y *= -1;
|
|
102
92
|
}
|
|
103
|
-
|
|
104
93
|
return data;
|
|
105
94
|
}
|
|
106
|
-
|
|
107
95
|
function useAnimatedSensor(sensorType, userConfig) {
|
|
108
96
|
const ref = (0, _react.useRef)({
|
|
109
97
|
sensor: initSensorData(sensorType),
|
|
110
|
-
unregister: () => {
|
|
98
|
+
unregister: () => {
|
|
99
|
+
// NOOP
|
|
111
100
|
},
|
|
112
101
|
isAvailable: false,
|
|
113
102
|
config: {
|
|
@@ -134,24 +123,20 @@ function useAnimatedSensor(sensorType, userConfig) {
|
|
|
134
123
|
data = adjustVectorToInterfaceOrientation(data);
|
|
135
124
|
}
|
|
136
125
|
}
|
|
137
|
-
|
|
138
126
|
sensorData.value = data;
|
|
139
|
-
(0, _threads.
|
|
127
|
+
(0, _threads.callMicrotasks)();
|
|
140
128
|
});
|
|
141
|
-
|
|
142
129
|
if (id !== -1) {
|
|
143
130
|
// if sensor is available
|
|
144
131
|
ref.current.unregister = () => (0, _core.unregisterSensor)(id);
|
|
145
|
-
|
|
146
132
|
ref.current.isAvailable = true;
|
|
147
133
|
} else {
|
|
148
134
|
// if sensor is unavailable
|
|
149
|
-
ref.current.unregister = () => {
|
|
135
|
+
ref.current.unregister = () => {
|
|
136
|
+
// NOOP
|
|
150
137
|
};
|
|
151
|
-
|
|
152
138
|
ref.current.isAvailable = false;
|
|
153
139
|
}
|
|
154
|
-
|
|
155
140
|
return () => {
|
|
156
141
|
ref.current.unregister();
|
|
157
142
|
};
|