react-native-reanimated 3.9.0-rc.0 → 3.9.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/ShadowTreeCloner.cpp +2 -1
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +11 -4
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +5 -3
- package/apple/REAModule.mm +14 -29
- package/apple/REANodesManager.mm +7 -6
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/animationBuilder.js.map +1 -1
- package/lib/module/createAnimatedComponent/InlinePropManager.js +2 -2
- package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js +4 -4
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js.map +1 -1
- package/lib/module/createAnimatedComponent/PropsFilter.js +5 -5
- package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
- package/lib/module/createAnimatedComponent/commonTypes.js.map +1 -1
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +33 -33
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/getViewInfo.js +2 -2
- package/lib/module/createAnimatedComponent/getViewInfo.js.map +1 -1
- package/lib/module/createAnimatedComponent/index.js.map +1 -1
- package/lib/module/createAnimatedComponent/setAndForwardRef.js +4 -5
- package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
- package/lib/module/createAnimatedComponent/utils.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -2
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/mock.js +3 -8
- package/lib/module/mock.js.map +1 -1
- package/lib/module/propsAllowlists.js.map +1 -1
- package/lib/module/reanimated2/Bezier.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +4 -11
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +3 -7
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +3 -3
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.web.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js +1 -0
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/PropAdapters.js +1 -1
- package/lib/module/reanimated2/PropAdapters.js.map +1 -1
- package/lib/module/reanimated2/PropsRegistry.js.map +1 -1
- package/lib/module/reanimated2/Sensor.js +2 -2
- package/lib/module/reanimated2/Sensor.js.map +1 -1
- package/lib/module/reanimated2/SensorContainer.js +2 -2
- package/lib/module/reanimated2/SensorContainer.js.map +1 -1
- package/lib/module/reanimated2/UpdateLayoutAnimations.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +74 -31
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/clamp.js.map +1 -1
- package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/index.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/rigidDecay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/rubberBandDecay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
- 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 +1 -6
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +1 -5
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js +8 -10
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -4
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +1 -2
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +2 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +1 -0
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/Image.js +1 -0
- package/lib/module/reanimated2/component/Image.js.map +1 -1
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js +1 -0
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
- package/lib/module/reanimated2/component/PerformanceMonitor.js +3 -4
- package/lib/module/reanimated2/component/PerformanceMonitor.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.js +1 -0
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/component/Text.js +1 -0
- package/lib/module/reanimated2/component/Text.js.map +1 -1
- package/lib/module/reanimated2/component/View.js +1 -0
- package/lib/module/reanimated2/component/View.js.map +1 -1
- package/lib/module/reanimated2/core.js +2 -4
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +7 -8
- package/lib/module/reanimated2/errors.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +4 -4
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/index.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/helperTypes.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 +1 -0
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +3 -4
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -0
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +3 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +3 -6
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +3 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useEvent.js +4 -5
- package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js +1 -2
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useHandler.js +3 -1
- package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +14 -6
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
- 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 +1 -5
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +2 -6
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +1 -1
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/isSharedValue.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +3 -6
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.web.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +4 -5
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +2 -2
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/react-native-web.d.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +4 -2
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +8 -11
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +8 -9
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- 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 +1 -2
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +22 -22
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +22 -22
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +26 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -6
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +18 -18
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +18 -18
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +34 -34
- 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 +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +4 -4
- 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/ProgressTransitionManager.js +4 -6
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +4 -6
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Bounce.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Fade.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Flip.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Lightspeed.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Pinwheel.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Roll.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Rotate.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Slide.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Stretch.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Zoom.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animationParser.js +0 -2
- package/lib/module/reanimated2/layoutReanimation/web/animationParser.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js +1 -2
- package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js +3 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js +6 -7
- package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/config.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +2 -2
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/domUtils.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/web/domUtils.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Fading.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Linear.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Sequenced.web.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +2 -4
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mockedRequestAnimationFrame.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +2 -4
- 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.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js +2 -4
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +2 -2
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/index.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.web.js +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setGestureState.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setGestureState.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.web.js.map +1 -1
- package/lib/module/reanimated2/pluginUtils.js.map +1 -1
- package/lib/module/reanimated2/publicGlobals.js.map +1 -1
- package/lib/module/reanimated2/runtimes.js +11 -19
- package/lib/module/reanimated2/runtimes.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/animationManager.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/index.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/presets.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/styleUpdater.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/swipeSimulator.js +1 -1
- package/lib/module/reanimated2/screenTransition/swipeSimulator.js.map +1 -1
- package/lib/module/reanimated2/shareableMappingCache.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +2 -4
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +9 -34
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/reanimated2/valueUnpacker.js.map +1 -1
- package/lib/module/specs/NativeReanimatedModule.js.map +1 -1
- package/lib/typescript/reanimated2/WorkletEventHandler.d.ts +16 -9
- package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +1 -1
- package/lib/typescript/reanimated2/component/PerformanceMonitor.d.ts +2 -1
- package/lib/typescript/reanimated2/hook/commonTypes.d.ts +5 -0
- package/lib/typescript/reanimated2/hook/useEvent.d.ts +2 -3
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/package.json +18 -14
- package/plugin/build/plugin.js +7 -2
- package/src/createAnimatedComponent/PropsFilter.tsx +1 -1
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +29 -33
- package/src/reanimated2/WorkletEventHandler.ts +98 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -6
- package/src/reanimated2/hook/commonTypes.ts +9 -0
- package/src/reanimated2/hook/useEvent.ts +4 -4
- package/src/reanimated2/hook/useScrollViewOffset.ts +21 -5
- package/src/reanimated2/js-reanimated/JSReanimated.ts +6 -3
- package/src/reanimated2/layoutReanimation/web/animationsManager.ts +1 -1
- package/src/reanimated2/layoutReanimation/web/componentStyle.ts +3 -1
- package/src/reanimated2/layoutReanimation/web/componentUtils.ts +1 -1
- package/src/reanimated2/layoutReanimation/web/createAnimation.ts +2 -2
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/platformFunctions/getRelativeCoords.ts +2 -2
|
@@ -48,6 +48,7 @@ function useScrollViewOffsetNative(animatedRef, providedOffset) {
|
|
|
48
48
|
const internalOffset = useSharedValue(0);
|
|
49
49
|
const offset = useRef(providedOffset ?? internalOffset).current;
|
|
50
50
|
const scrollRef = useRef(null);
|
|
51
|
+
const scrollRefTag = useRef(null);
|
|
51
52
|
const eventHandler = useEvent(event => {
|
|
52
53
|
'worklet';
|
|
53
54
|
|
|
@@ -56,17 +57,24 @@ function useScrollViewOffsetNative(animatedRef, providedOffset) {
|
|
|
56
57
|
// Read https://github.com/software-mansion/react-native-reanimated/pull/5056
|
|
57
58
|
// for more information about this cast.
|
|
58
59
|
);
|
|
59
|
-
|
|
60
60
|
useEffect(() => {
|
|
61
61
|
// We need to make sure that listener for old animatedRef value is removed
|
|
62
|
-
if (scrollRef.current !== null) {
|
|
63
|
-
eventHandler.workletEventHandler.unregisterFromEvents();
|
|
62
|
+
if (scrollRef.current !== null && scrollRefTag.current !== null) {
|
|
63
|
+
eventHandler.workletEventHandler.unregisterFromEvents(scrollRefTag.current);
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
// Store the ref and viewTag for future cleanup
|
|
65
67
|
scrollRef.current = animatedRef.current;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
scrollRefTag.current = animatedRef.getTag();
|
|
69
|
+
if (scrollRefTag === null) {
|
|
70
|
+
console.warn('[Reanimated] ScrollViewOffset failed to resolve the view tag from animated ref. Did you forget to attach the ref to a component?');
|
|
71
|
+
} else {
|
|
72
|
+
eventHandler.workletEventHandler.registerForEvents(scrollRefTag.current);
|
|
73
|
+
}
|
|
68
74
|
return () => {
|
|
69
|
-
|
|
75
|
+
if (scrollRefTag.current !== null) {
|
|
76
|
+
eventHandler.workletEventHandler.unregisterFromEvents(scrollRefTag.current);
|
|
77
|
+
}
|
|
70
78
|
};
|
|
71
79
|
// React here has a problem with `animatedRef.current` since a Ref .current
|
|
72
80
|
// field shouldn't be used as a dependency. However, in this case we have
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useCallback","useEvent","useSharedValue","isWeb","IS_WEB","useScrollViewOffset","useScrollViewOffsetWeb","useScrollViewOffsetNative","animatedRef","providedOffset","internalOffset","offset","current","scrollRef","eventHandler","element","getWebScrollableElement","value","scrollLeft","scrollTop","removeEventListener","addEventListener","event","contentOffset","x","y","scrollNativeEventNames","workletEventHandler","unregisterFromEvents","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useCallback","useEvent","useSharedValue","isWeb","IS_WEB","useScrollViewOffset","useScrollViewOffsetWeb","useScrollViewOffsetNative","animatedRef","providedOffset","internalOffset","offset","current","scrollRef","eventHandler","element","getWebScrollableElement","value","scrollLeft","scrollTop","removeEventListener","addEventListener","scrollRefTag","event","contentOffset","x","y","scrollNativeEventNames","workletEventHandler","unregisterFromEvents","getTag","console","warn","registerForEvents","scrollComponent","getScrollableNode"],"sources":["useScrollViewOffset.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useRef, useCallback } from 'react';\nimport type { SharedValue } from '../commonTypes';\nimport type { EventHandlerInternal } from './useEvent';\nimport { useEvent } from './useEvent';\nimport { useSharedValue } from './useSharedValue';\nimport type { AnimatedScrollView } from '../component/ScrollView';\nimport type {\n AnimatedRef,\n RNNativeScrollEvent,\n ReanimatedScrollEvent,\n} from './commonTypes';\nimport { isWeb } from '../PlatformChecker';\n\nconst IS_WEB = isWeb();\n\n/**\n * Lets you synchronously get the current offset of a `ScrollView`.\n *\n * @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef) attached to an Animated.ScrollView component.\n * @returns A shared value which holds the current offset of the `ScrollView`.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/scroll/useScrollViewOffset\n */\nexport const useScrollViewOffset = IS_WEB\n ? useScrollViewOffsetWeb\n : useScrollViewOffsetNative;\n\nfunction useScrollViewOffsetWeb(\n animatedRef: AnimatedRef<AnimatedScrollView>,\n providedOffset?: SharedValue<number>\n): SharedValue<number> {\n const internalOffset = useSharedValue(0);\n const offset = useRef(providedOffset ?? internalOffset).current;\n const scrollRef = useRef<AnimatedScrollView | null>(null);\n\n const eventHandler = useCallback(() => {\n 'worklet';\n const element = getWebScrollableElement(animatedRef.current);\n // scrollLeft is the X axis scrolled offset, works properly also with RTL layout\n offset.value =\n element.scrollLeft === 0 ? element.scrollTop : element.scrollLeft;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [animatedRef, animatedRef.current]);\n\n useEffect(() => {\n // We need to make sure that listener for old animatedRef value is removed\n if (scrollRef.current !== null) {\n getWebScrollableElement(scrollRef.current).removeEventListener(\n 'scroll',\n eventHandler\n );\n }\n scrollRef.current = animatedRef.current;\n\n const element = getWebScrollableElement(animatedRef.current);\n element.addEventListener('scroll', eventHandler);\n return () => {\n element.removeEventListener('scroll', eventHandler);\n };\n // React here has a problem with `animatedRef.current` since a Ref .current\n // field shouldn't be used as a dependency. However, in this case we have\n // to do it this way.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [animatedRef, animatedRef.current, eventHandler]);\n\n return offset;\n}\n\nfunction useScrollViewOffsetNative(\n animatedRef: AnimatedRef<AnimatedScrollView>,\n providedOffset?: SharedValue<number>\n): SharedValue<number> {\n const internalOffset = useSharedValue(0);\n const offset = useRef(providedOffset ?? internalOffset).current;\n const scrollRef = useRef<AnimatedScrollView | null>(null);\n const scrollRefTag = useRef<number | null>(null);\n\n const eventHandler = useEvent<RNNativeScrollEvent>(\n (event: ReanimatedScrollEvent) => {\n 'worklet';\n offset.value =\n event.contentOffset.x === 0\n ? event.contentOffset.y\n : event.contentOffset.x;\n },\n scrollNativeEventNames\n // Read https://github.com/software-mansion/react-native-reanimated/pull/5056\n // for more information about this cast.\n ) as unknown as EventHandlerInternal<ReanimatedScrollEvent>;\n\n useEffect(() => {\n // We need to make sure that listener for old animatedRef value is removed\n if (scrollRef.current !== null && scrollRefTag.current !== null) {\n eventHandler.workletEventHandler.unregisterFromEvents(\n scrollRefTag.current\n );\n }\n\n // Store the ref and viewTag for future cleanup\n scrollRef.current = animatedRef.current;\n scrollRefTag.current = animatedRef.getTag();\n\n if (scrollRefTag === null) {\n console.warn(\n '[Reanimated] ScrollViewOffset failed to resolve the view tag from animated ref. Did you forget to attach the ref to a component?'\n );\n } else {\n eventHandler.workletEventHandler.registerForEvents(scrollRefTag.current);\n }\n\n return () => {\n if (scrollRefTag.current !== null) {\n eventHandler.workletEventHandler.unregisterFromEvents(\n scrollRefTag.current\n );\n }\n };\n // React here has a problem with `animatedRef.current` since a Ref .current\n // field shouldn't be used as a dependency. However, in this case we have\n // to do it this way.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [animatedRef, animatedRef.current, eventHandler]);\n\n return offset;\n}\n\nfunction getWebScrollableElement(\n scrollComponent: AnimatedScrollView | null\n): HTMLElement {\n return (\n (scrollComponent?.getScrollableNode() as unknown as HTMLElement) ??\n scrollComponent\n );\n}\n\nconst scrollNativeEventNames = [\n 'onScroll',\n 'onScrollBeginDrag',\n 'onScrollEndDrag',\n 'onMomentumScrollBegin',\n 'onMomentumScrollEnd',\n];\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,QAAQ,OAAO;AAGtD,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,cAAc,QAAQ,kBAAkB;AAOjD,SAASC,KAAK,QAAQ,oBAAoB;AAE1C,MAAMC,MAAM,GAAGD,KAAK,CAAC,CAAC;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,mBAAmB,GAAGD,MAAM,GACrCE,sBAAsB,GACtBC,yBAAyB;AAE7B,SAASD,sBAAsBA,CAC7BE,WAA4C,EAC5CC,cAAoC,EACf;EACrB,MAAMC,cAAc,GAAGR,cAAc,CAAC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CAAC,CAAC,KACrCD,eAAe;AAEnB;AAEA,MAAMP,sBAAsB,GAAG,CAC7B,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,CACtB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","cancelAnimation","makeMutable","useSharedValue","initialValue","mutable"],"sources":["useSharedValue.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useState } from 'react';\nimport { cancelAnimation } from '../animation';\nimport type { SharedValue } from '../commonTypes';\nimport { makeMutable } from '../core';\n\n/**\n * Lets you define [shared values](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#shared-value) in your components.\n *\n * @param initialValue - The value you want to be initially stored to a `.value` property.\n * @returns A shared value with a single `.value` property initially set to the `initialValue` - {@link SharedValue}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue\n */\nexport function useSharedValue<Value>(initialValue: Value): SharedValue<Value> {\n const [mutable] = useState(() => makeMutable(initialValue));\n useEffect(() => {\n return () => {\n cancelAnimation(mutable);\n };\n }, [mutable]);\n return mutable;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,eAAe,QAAQ,cAAc;AAE9C,SAASC,WAAW,QAAQ,SAAS;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAQC,YAAmB,EAAsB;EAC7E,MAAM,CAACC,OAAO,CAAC,GAAGL,QAAQ,CAAC,MAAME,WAAW,CAACE,YAAY,CAAC,CAAC;EAC3DL,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXE,eAAe,CAACI,OAAO,CAAC;IAC1B,CAAC;EACH,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EACb,OAAOA,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"names":["useEffect","useState","cancelAnimation","makeMutable","useSharedValue","initialValue","mutable"],"sources":["useSharedValue.ts"],"sourcesContent":["'use strict';\nimport { useEffect, useState } from 'react';\nimport { cancelAnimation } from '../animation';\nimport type { SharedValue } from '../commonTypes';\nimport { makeMutable } from '../core';\n\n/**\n * Lets you define [shared values](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#shared-value) in your components.\n *\n * @param initialValue - The value you want to be initially stored to a `.value` property.\n * @returns A shared value with a single `.value` property initially set to the `initialValue` - {@link SharedValue}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue\n */\nexport function useSharedValue<Value>(initialValue: Value): SharedValue<Value> {\n const [mutable] = useState(() => makeMutable(initialValue));\n useEffect(() => {\n return () => {\n cancelAnimation(mutable);\n };\n }, [mutable]);\n return mutable;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,eAAe,QAAQ,cAAc;AAE9C,SAASC,WAAW,QAAQ,SAAS;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAQC,YAAmB,EAAsB;EAC7E,MAAM,CAACC,OAAO,CAAC,GAAGL,QAAQ,CAAC,MAAME,WAAW,CAACE,YAAY,CAAC,CAAC;EAC3DL,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXE,eAAe,CAACI,OAAO,CAAC;IAC1B,CAAC;EACH,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EACb,OAAOA,OAAO;AAChB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useWorkletCallback","worklet","deps"],"sources":["useWorkletCallback.ts"],"sourcesContent":["'use strict';\nimport { useCallback } from 'react';\nimport type { DependencyList } from './commonTypes';\n\n/**\n * @deprecated don't use\n */\nexport function useWorkletCallback<Args extends unknown[], ReturnValue>(\n worklet: (...args: Args) => ReturnValue,\n deps?: DependencyList\n) {\n return useCallback(worklet, deps ?? []);\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,WAAW,QAAQ,OAAO;AAGnC;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCC,OAAuC,EACvCC,IAAqB,EACrB;EACA,OAAOH,WAAW,CAACE,OAAO,EAAEC,IAAI,IAAI,EAAE,CAAC;AACzC"}
|
|
1
|
+
{"version":3,"names":["useCallback","useWorkletCallback","worklet","deps"],"sources":["useWorkletCallback.ts"],"sourcesContent":["'use strict';\nimport { useCallback } from 'react';\nimport type { DependencyList } from './commonTypes';\n\n/**\n * @deprecated don't use\n */\nexport function useWorkletCallback<Args extends unknown[], ReturnValue>(\n worklet: (...args: Args) => ReturnValue,\n deps?: DependencyList\n) {\n return useCallback(worklet, deps ?? []);\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,WAAW,QAAQ,OAAO;AAGnC;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCC,OAAuC,EACvCC,IAAqB,EACrB;EACA,OAAOH,WAAW,CAACE,OAAO,EAAEC,IAAI,IAAI,EAAE,CAAC;AACzC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["buildWorkletsHash","worklets","Object","values","reduce","acc","worklet","__workletHash","toString","buildDependencies","dependencies","handlers","handlersList","filter","handler","undefined","map","workletHash","closure","__closure","push","areDependenciesEqual","nextDependencies","prevDependencies","is","x","y","Number","isNaN","objectIs","areHookInputsEqual","nextDeps","prevDeps","length","i","isAnimated","prop","Array","isArray","some","onFrame","shallowEqual","a","b","aKeys","keys","bKeys","validateAnimatedStyles","styles","Error"],"sources":["utils.ts"],"sourcesContent":["'use strict';\nimport type { WorkletFunction } from '../commonTypes';\nimport type { DependencyList } from './commonTypes';\n\n// Builds one big hash from multiple worklets' hashes.\nexport function buildWorkletsHash<Args extends unknown[], ReturnValue>(\n worklets:\n | Record<string, WorkletFunction<Args, ReturnValue>>\n | WorkletFunction<Args, ReturnValue>[]\n) {\n // For arrays `Object.values` returns the array itself.\n return Object.values(worklets).reduce(\n (acc, worklet: WorkletFunction<Args, ReturnValue>) =>\n acc + worklet.__workletHash.toString(),\n ''\n );\n}\n\n// Builds dependencies array for useEvent handlers.\nexport function buildDependencies(\n dependencies: DependencyList,\n handlers: Record<string, WorkletFunction | undefined>\n) {\n type Handler = (typeof handlers)[keyof typeof handlers];\n const handlersList = Object.values(handlers).filter(\n (handler) => handler !== undefined\n ) as NonNullable<Handler>[];\n if (!dependencies) {\n dependencies = handlersList.map((handler) => {\n return {\n workletHash: handler.__workletHash,\n closure: handler.__closure,\n };\n });\n } else {\n dependencies.push(buildWorkletsHash(handlersList));\n }\n\n return dependencies;\n}\n\n// This is supposed to work as useEffect comparison.\nexport function areDependenciesEqual(\n nextDependencies: DependencyList,\n prevDependencies: DependencyList\n) {\n function is(x: number, y: number) {\n return (\n (x === y && (x !== 0 || 1 / x === 1 / y)) ||\n (Number.isNaN(x) && Number.isNaN(y))\n );\n }\n const objectIs: (nextDeps: unknown, prevDeps: unknown) => boolean =\n typeof Object.is === 'function' ? Object.is : is;\n\n function areHookInputsEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n ) {\n if (!nextDeps || !prevDeps || prevDeps.length !== nextDeps.length) {\n return false;\n }\n for (let i = 0; i < prevDeps.length; ++i) {\n if (!objectIs(nextDeps[i], prevDeps[i])) {\n return false;\n }\n }\n return true;\n }\n\n return areHookInputsEqual(nextDependencies, prevDependencies);\n}\n\nexport function isAnimated(prop: unknown) {\n 'worklet';\n if (Array.isArray(prop)) {\n return prop.some(isAnimated);\n } else if (typeof prop === 'object' && prop !== null) {\n if ((prop as Record<string, unknown>).onFrame !== undefined) {\n return true;\n } else {\n return Object.values(prop).some(isAnimated);\n }\n }\n return false;\n}\n\n// This function works because `Object.keys`\n// return empty array of primitives and on arrays\n// it returns array of its indices.\nexport function shallowEqual<\n T extends Record<string | number | symbol, unknown>\n>(a: T, b: T) {\n 'worklet';\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (let i = 0; i < aKeys.length; i++) {\n if (a[aKeys[i]] !== b[aKeys[i]]) {\n return false;\n }\n }\n return true;\n}\n\nexport function validateAnimatedStyles(styles: unknown[] | object) {\n 'worklet';\n if (typeof styles !== 'object') {\n throw new Error(\n `[Reanimated] \\`useAnimatedStyle\\` has to return an object, found ${typeof styles} instead.`\n );\n } else if (Array.isArray(styles)) {\n throw new Error(\n '[Reanimated] `useAnimatedStyle` has to return an object and cannot return static styles combined with dynamic ones. Please do merging where a component receives props.'\n );\n }\n}\n"],"mappings":"AAAA,YAAY;;AAIZ;AACA,OAAO,SAASA,iBAAiBA,CAC/BC,QAEwC,EACxC;EACA;EACA,OAAOC,MAAM,CAACC,MAAM,CAACF,QAAQ,CAAC,CAACG,MAAM,CACnC,CAACC,GAAG,EAAEC,OAA2C,KAC/CD,GAAG,GAAGC,OAAO,CAACC,aAAa,CAACC,QAAQ,
|
|
1
|
+
{"version":3,"names":["buildWorkletsHash","worklets","Object","values","reduce","acc","worklet","__workletHash","toString","buildDependencies","dependencies","handlers","handlersList","filter","handler","undefined","map","workletHash","closure","__closure","push","areDependenciesEqual","nextDependencies","prevDependencies","is","x","y","Number","isNaN","objectIs","areHookInputsEqual","nextDeps","prevDeps","length","i","isAnimated","prop","Array","isArray","some","onFrame","shallowEqual","a","b","aKeys","keys","bKeys","validateAnimatedStyles","styles","Error"],"sources":["utils.ts"],"sourcesContent":["'use strict';\nimport type { WorkletFunction } from '../commonTypes';\nimport type { DependencyList } from './commonTypes';\n\n// Builds one big hash from multiple worklets' hashes.\nexport function buildWorkletsHash<Args extends unknown[], ReturnValue>(\n worklets:\n | Record<string, WorkletFunction<Args, ReturnValue>>\n | WorkletFunction<Args, ReturnValue>[]\n) {\n // For arrays `Object.values` returns the array itself.\n return Object.values(worklets).reduce(\n (acc, worklet: WorkletFunction<Args, ReturnValue>) =>\n acc + worklet.__workletHash.toString(),\n ''\n );\n}\n\n// Builds dependencies array for useEvent handlers.\nexport function buildDependencies(\n dependencies: DependencyList,\n handlers: Record<string, WorkletFunction | undefined>\n) {\n type Handler = (typeof handlers)[keyof typeof handlers];\n const handlersList = Object.values(handlers).filter(\n (handler) => handler !== undefined\n ) as NonNullable<Handler>[];\n if (!dependencies) {\n dependencies = handlersList.map((handler) => {\n return {\n workletHash: handler.__workletHash,\n closure: handler.__closure,\n };\n });\n } else {\n dependencies.push(buildWorkletsHash(handlersList));\n }\n\n return dependencies;\n}\n\n// This is supposed to work as useEffect comparison.\nexport function areDependenciesEqual(\n nextDependencies: DependencyList,\n prevDependencies: DependencyList\n) {\n function is(x: number, y: number) {\n return (\n (x === y && (x !== 0 || 1 / x === 1 / y)) ||\n (Number.isNaN(x) && Number.isNaN(y))\n );\n }\n const objectIs: (nextDeps: unknown, prevDeps: unknown) => boolean =\n typeof Object.is === 'function' ? Object.is : is;\n\n function areHookInputsEqual(\n nextDeps: DependencyList,\n prevDeps: DependencyList\n ) {\n if (!nextDeps || !prevDeps || prevDeps.length !== nextDeps.length) {\n return false;\n }\n for (let i = 0; i < prevDeps.length; ++i) {\n if (!objectIs(nextDeps[i], prevDeps[i])) {\n return false;\n }\n }\n return true;\n }\n\n return areHookInputsEqual(nextDependencies, prevDependencies);\n}\n\nexport function isAnimated(prop: unknown) {\n 'worklet';\n if (Array.isArray(prop)) {\n return prop.some(isAnimated);\n } else if (typeof prop === 'object' && prop !== null) {\n if ((prop as Record<string, unknown>).onFrame !== undefined) {\n return true;\n } else {\n return Object.values(prop).some(isAnimated);\n }\n }\n return false;\n}\n\n// This function works because `Object.keys`\n// return empty array of primitives and on arrays\n// it returns array of its indices.\nexport function shallowEqual<\n T extends Record<string | number | symbol, unknown>\n>(a: T, b: T) {\n 'worklet';\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (let i = 0; i < aKeys.length; i++) {\n if (a[aKeys[i]] !== b[aKeys[i]]) {\n return false;\n }\n }\n return true;\n}\n\nexport function validateAnimatedStyles(styles: unknown[] | object) {\n 'worklet';\n if (typeof styles !== 'object') {\n throw new Error(\n `[Reanimated] \\`useAnimatedStyle\\` has to return an object, found ${typeof styles} instead.`\n );\n } else if (Array.isArray(styles)) {\n throw new Error(\n '[Reanimated] `useAnimatedStyle` has to return an object and cannot return static styles combined with dynamic ones. Please do merging where a component receives props.'\n );\n }\n}\n"],"mappings":"AAAA,YAAY;;AAIZ;AACA,OAAO,SAASA,iBAAiBA,CAC/BC,QAEwC,EACxC;EACA;EACA,OAAOC,MAAM,CAACC,MAAM,CAACF,QAAQ,CAAC,CAACG,MAAM,CACnC,CAACC,GAAG,EAAEC,OAA2C,KAC/CD,GAAG,GAAGC,OAAO,CAACC,aAAa,CAACC,QAAQ,CAAC,CAAC,EACxC,EACF,CAAC;AACH;;AAEA;AACA,OAAO,SAASC,iBAAiBA,CAC/BC,YAA4B,EAC5BC,QAAqD,EACrD;EAEA,MAAMC,YAAY,GAAGV,MAAM,CAACC,MAAM,CAACQ,QAAQ,CAAC,CAACE,MAAM,CAChDC,OAAO,IAAKA,OAAO,KAAKC,SAC3B,CAA2B;EAC3B,IAAI,CAACL,YAAY,EAAE;IACjBA,YAAY,GAAGE,YAAY,CAACI,GAAG,CAAEF,OAAO,IAAK;MAC3C,OAAO;QACLG,WAAW,EAAEH,OAAO,CAACP,aAAa;QAClCW,OAAO,EAAEJ,OAAO,CAACK;MACnB,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,MAAM;IACLT,YAAY,CAACU,IAAI,CAACpB,iBAAiB,CAACY,YAAY,CAAC,CAAC;EACpD;EAEA,OAAOF,YAAY;AACrB;;AAEA;AACA,OAAO,SAASW,oBAAoBA,CAClCC,gBAAgC,EAChCC,gBAAgC,EAChC;EACA,SAASC,EAAEA,CAACC,CAAS,EAAEC,CAAS,EAAE;IAChC,OACGD,CAAC,KAAKC,CAAC,KAAKD,CAAC,KAAK,CAAC,IAAI,CAAC,GAAGA,CA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CAAI,EAAEC,CAAI,EAAE;EACZ,SAAS;;EACT,MAAMC,KAAK,GAAG1C,MAAM,CAAC2C,IAAI,CAACH,CAAC,CAAC;EAC5B,MAAMI,KAAK,GAAG5C,MAAM,CAAC2C,IAAI,CAACF,CAAC,CAAC;EAC5B,IAAIC,KAAK,CAACX,MAAM,KAAKa,KAAK,CAACb,MAAM,EAAE;IACjC,OAAO,KAAK;EACd;EACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGU,KAAK,CAACX,MAAM,EAAEC,CAAC,EAAE,EAAE;IACrC,IAAIQ,CAAC,CAACE,KAAK,CAACV,CAAC,CAAC,CAAC,KAAKS,CAAC,CAACC,KAAK,CAACV,CAAC,CAAC,CAAC,EAAE;MAC/B,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb;AAEA,OAAO,SAASa,sBAAsBA,CAACC,MAA0B,EAAE;EACjE,SAAS;;EACT,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,MAAM,IAAIC,KAAK,CACZ,oEAAmE,OAAOD,MAAO,WACpF,CAAC;EACH,CAAC,MAAM,IAAIX,KAAK,CAACC,OAAO,CAACU,MAAM,CAAC,EAAE;IAChC,MAAM,IAAIC,KAAK,CACb,yKACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["runOnJS","runOnUI","createWorkletRuntime","runOnRuntime","makeMutable","makeShareableCloneRecursive","isReanimated3","isConfigured","enableLayoutAnimations","getViewProp","executeOnUIRuntimeSync","useAnimatedProps","useEvent","useHandler","useWorkletCallback","useSharedValue","useReducedMotion","useAnimatedStyle","useAnimatedGestureHandler","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useDerivedValue","useAnimatedSensor","useFrameCallback","useAnimatedKeyboard","useScrollViewOffset","cancelAnimation","defineAnimation","withClamp","withDecay","withDelay","withRepeat","withSequence","withSpring","withTiming","Extrapolation","interpolate","clamp","Extrapolate","ColorSpace","interpolateColor","useInterpolateConfig","Easing","measure","dispatchCommand","scrollTo","setGestureState","setNativeProps","getRelativeCoords","isColor","processColor","convertToRGBA","createAnimatedPropAdapter","BaseAnimationBuilder","ComplexAnimationBuilder","Keyframe","FlipInXUp","FlipInYLeft","FlipInXDown","FlipInYRight","FlipInEasyX","FlipInEasyY","FlipOutXUp","FlipOutYLeft","FlipOutXDown","FlipOutYRight","FlipOutEasyX","FlipOutEasyY","StretchInX","StretchInY","StretchOutX","StretchOutY","FadeIn","FadeInRight","FadeInLeft","FadeInUp","FadeInDown","FadeOut","FadeOutRight","FadeOutLeft","FadeOutUp","FadeOutDown","SlideInRight","SlideInLeft","SlideOutRight","SlideOutLeft","SlideInUp","SlideInDown","SlideOutUp","SlideOutDown","ZoomIn","ZoomInRotate","ZoomInLeft","ZoomInRight","ZoomInUp","ZoomInDown","ZoomInEasyUp","ZoomInEasyDown","ZoomOut","ZoomOutRotate","ZoomOutLeft","ZoomOutRight","ZoomOutUp","ZoomOutDown","ZoomOutEasyUp","ZoomOutEasyDown","BounceIn","BounceInDown","BounceInUp","BounceInLeft","BounceInRight","BounceOut","BounceOutDown","BounceOutUp","BounceOutLeft","BounceOutRight","LightSpeedInRight","LightSpeedInLeft","LightSpeedOutRight","LightSpeedOutLeft","PinwheelIn","PinwheelOut","RotateInDownLeft","RotateInDownRight","RotateInUpLeft","RotateInUpRight","RotateOutDownLeft","RotateOutDownRight","RotateOutUpLeft","RotateOutUpRight","RollInLeft","RollInRight","RollOutLeft","RollOutRight","Layout","LinearTransition","FadingTransition","SequencedTransition","JumpingTransition","CurvedTransition","EntryExitTransition","combineTransition","SharedTransition","SharedTransitionType","isSharedValue","SensorType","IOSReferenceFrame","InterfaceOrientation","KeyboardState","ReduceMotion","isWorkletFunction","getUseOfValueInStyleWarning","withReanimatedTimer","advanceAnimationByTime","advanceAnimationByFrame","setUpTests","getAnimatedStyle","LayoutAnimationConfig","PerformanceMonitor","startMapper","stopMapper","startScreenTransition","finishScreenTransition","ScreenTransition"],"sources":["index.ts"],"sourcesContent":["'use strict';\n\nimport './publicGlobals';\n\nexport type { WorkletRuntime } from './core';\nexport {\n runOnJS,\n runOnUI,\n createWorkletRuntime,\n runOnRuntime,\n makeMutable,\n makeShareableCloneRecursive,\n isReanimated3,\n isConfigured,\n enableLayoutAnimations,\n getViewProp,\n executeOnUIRuntimeSync,\n} from './core';\nexport type {\n GestureHandlers,\n AnimatedRef,\n DerivedValue,\n ScrollHandler,\n ScrollHandlers,\n ScrollHandlerProcessed,\n FrameCallback,\n ScrollEvent,\n EventHandler,\n EventHandlerProcessed,\n UseHandlerContext,\n ReanimatedEvent,\n} from './hook';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n useSharedValue,\n useReducedMotion,\n useAnimatedStyle,\n useAnimatedGestureHandler,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useDerivedValue,\n useAnimatedSensor,\n useFrameCallback,\n useAnimatedKeyboard,\n useScrollViewOffset,\n} from './hook';\nexport type {\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n WithTimingConfig,\n TimingAnimation,\n WithSpringConfig,\n SpringAnimation,\n WithDecayConfig,\n DecayAnimation,\n} from './animation';\nexport {\n cancelAnimation,\n defineAnimation,\n withClamp,\n withDecay,\n withDelay,\n withRepeat,\n withSequence,\n withSpring,\n withTiming,\n} from './animation';\nexport type { ExtrapolationConfig, ExtrapolationType } from './interpolation';\nexport { Extrapolation, interpolate, clamp } from './interpolation';\nexport type {\n InterpolationOptions,\n InterpolateConfig,\n InterpolateRGB,\n InterpolateHSV,\n} from './interpolateColor';\nexport {\n /**\n * @deprecated Please use {@link Extrapolation} instead.\n */\n Extrapolate,\n ColorSpace,\n interpolateColor,\n useInterpolateConfig,\n} from './interpolateColor';\nexport type {\n EasingFunction,\n EasingFn,\n EasingFunctionFactory,\n EasingFactoryFn,\n} from './Easing';\nexport { Easing } from './Easing';\nexport type { ComponentCoords } from './platformFunctions';\nexport {\n measure,\n dispatchCommand,\n scrollTo,\n setGestureState,\n setNativeProps,\n getRelativeCoords,\n} from './platformFunctions';\nexport type { ParsedColorArray } from './Colors';\nexport { isColor, processColor, convertToRGBA } from './Colors';\nexport { createAnimatedPropAdapter } from './PropAdapters';\nexport type {\n LayoutAnimation,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n ILayoutAnimationBuilder,\n IEntryExitAnimationBuilder,\n} from './layoutReanimation';\nexport {\n BaseAnimationBuilder,\n ComplexAnimationBuilder,\n Keyframe,\n // Flip\n FlipInXUp,\n FlipInYLeft,\n FlipInXDown,\n FlipInYRight,\n FlipInEasyX,\n FlipInEasyY,\n FlipOutXUp,\n FlipOutYLeft,\n FlipOutXDown,\n FlipOutYRight,\n FlipOutEasyX,\n FlipOutEasyY,\n // Stretch\n StretchInX,\n StretchInY,\n StretchOutX,\n StretchOutY,\n // Fade\n FadeIn,\n FadeInRight,\n FadeInLeft,\n FadeInUp,\n FadeInDown,\n FadeOut,\n FadeOutRight,\n FadeOutLeft,\n FadeOutUp,\n FadeOutDown,\n // Slide\n SlideInRight,\n SlideInLeft,\n SlideOutRight,\n SlideOutLeft,\n SlideInUp,\n SlideInDown,\n SlideOutUp,\n SlideOutDown,\n // Zoom\n ZoomIn,\n ZoomInRotate,\n ZoomInLeft,\n ZoomInRight,\n ZoomInUp,\n ZoomInDown,\n ZoomInEasyUp,\n ZoomInEasyDown,\n ZoomOut,\n ZoomOutRotate,\n ZoomOutLeft,\n ZoomOutRight,\n ZoomOutUp,\n ZoomOutDown,\n ZoomOutEasyUp,\n ZoomOutEasyDown,\n // Bounce\n BounceIn,\n BounceInDown,\n BounceInUp,\n BounceInLeft,\n BounceInRight,\n BounceOut,\n BounceOutDown,\n BounceOutUp,\n BounceOutLeft,\n BounceOutRight,\n // Lightspeed\n LightSpeedInRight,\n LightSpeedInLeft,\n LightSpeedOutRight,\n LightSpeedOutLeft,\n // Pinwheel\n PinwheelIn,\n PinwheelOut,\n // Rotate\n RotateInDownLeft,\n RotateInDownRight,\n RotateInUpLeft,\n RotateInUpRight,\n RotateOutDownLeft,\n RotateOutDownRight,\n RotateOutUpLeft,\n RotateOutUpRight,\n // Roll\n RollInLeft,\n RollInRight,\n RollOutLeft,\n RollOutRight,\n // Transitions\n Layout,\n LinearTransition,\n FadingTransition,\n SequencedTransition,\n JumpingTransition,\n CurvedTransition,\n EntryExitTransition,\n combineTransition,\n // SET\n SharedTransition,\n SharedTransitionType,\n} from './layoutReanimation';\nexport { isSharedValue } from './isSharedValue';\nexport type {\n StyleProps,\n SharedValue,\n AnimatableValueObject,\n AnimatableValue,\n AnimationObject,\n SensorConfig,\n Animation,\n AnimatedSensor,\n AnimationCallback,\n Value3D,\n ValueRotation,\n AnimatedKeyboardInfo,\n AnimatedKeyboardOptions,\n MeasuredDimensions,\n} from './commonTypes';\nexport {\n SensorType,\n IOSReferenceFrame,\n InterfaceOrientation,\n KeyboardState,\n ReduceMotion,\n isWorkletFunction,\n} from './commonTypes';\nexport type { FrameInfo } from './frameCallback';\nexport { getUseOfValueInStyleWarning } from './pluginUtils';\nexport {\n withReanimatedTimer,\n advanceAnimationByTime,\n advanceAnimationByFrame,\n setUpTests,\n getAnimatedStyle,\n} from './jestUtils';\nexport { LayoutAnimationConfig } from './component/LayoutAnimationConfig';\nexport { PerformanceMonitor } from './component/PerformanceMonitor';\nexport type {\n Adaptable,\n AdaptTransforms,\n AnimateProps,\n AnimatedProps,\n AnimatedTransform,\n TransformStyleTypes,\n TransformArrayItem,\n AnimateStyle,\n AnimatedStyle,\n AnimatedStyleProp,\n StylesOrDefault,\n} from './helperTypes';\nexport type { AnimatedScrollViewProps } from './component/ScrollView';\nexport type { FlatListPropsWithLayout } from './component/FlatList';\nexport { startMapper, stopMapper } from './mappers';\nexport {\n startScreenTransition,\n finishScreenTransition,\n ScreenTransition,\n} from './screenTransition';\nexport type {\n AnimatedScreenTransition,\n GoBackGesture,\n ScreenTransitionConfig,\n} from './screenTransition';\n"],"mappings":"AAAA,YAAY;;AAEZ,OAAO,iBAAiB;AAGxB,SACEA,OAAO,EACPC,OAAO,EACPC,oBAAoB,EACpBC,YAAY,EACZC,WAAW,EACXC,2BAA2B,EAC3BC,aAAa,EACbC,YAAY,EACZC,sBAAsB,EACtBC,WAAW,EACXC,sBAAsB,QACjB,QAAQ;AAef,SACEC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,yBAAyB,EACzBC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,EACxBC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBC,mBAAmB,EACnBC,mBAAmB,QACd,QAAQ;AAaf,SACEC,eAAe,EACfC,eAAe,EACfC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,YAAY,EACZC,UAAU,EACVC,UAAU,QACL,aAAa;AAEpB,SAASC,aAAa,EAAEC,WAAW,EAAEC,KAAK,QAAQ,iBAAiB;AAOnE;AACE;AACF;AACA;AACEC,WAAW,EACXC,UAAU,EACVC,gBAAgB,EAChBC,oBAAoB,QACf,oBAAoB;AAO3B,SAASC,MAAM,QAAQ,UAAU;AAEjC,SACEC,OAAO,EACPC,eAAe,EACfC,QAAQ,EACRC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,qBAAqB;AAE5B,SAASC,OAAO,EAAEC,YAAY,EAAEC,aAAa,QAAQ,UAAU;AAC/D,SAASC,yBAAyB,QAAQ,gBAAgB;AAW1D,SACEC,oBAAoB,EACpBC,uBAAuB,EACvBC,QAAQ;AACR;AACAC,SAAS,EACTC,WAAW,EACXC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,WAAW,EACXC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,aAAa,EACbC,YAAY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AAe;AAC3D,SACEC,mBAAmB,EACnBC,sBAAsB,EACtBC,uBAAuB,EACvBC,UAAU,EACVC,gBAAgB,QACX,aAAa;AACpB,SAASC,qBAAqB,QAAQ,mCAAmC;AACzE,SAASC,kBAAkB,QAAQ,gCAAgC;AAgBnE,SAASC,WAAW,EAAEC,UAAU,QAAQ,WAAW;AACnD,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,gBAAgB,QACX,oBAAoB"}
|
|
1
|
+
{"version":3,"names":["runOnJS","runOnUI","createWorkletRuntime","runOnRuntime","makeMutable","makeShareableCloneRecursive","isReanimated3","isConfigured","enableLayoutAnimations","getViewProp","executeOnUIRuntimeSync","useAnimatedProps","useEvent","useHandler","useWorkletCallback","useSharedValue","useReducedMotion","useAnimatedStyle","useAnimatedGestureHandler","useAnimatedReaction","useAnimatedRef","useAnimatedScrollHandler","useDerivedValue","useAnimatedSensor","useFrameCallback","useAnimatedKeyboard","useScrollViewOffset","cancelAnimation","defineAnimation","withClamp","withDecay","withDelay","withRepeat","withSequence","withSpring","withTiming","Extrapolation","interpolate","clamp","Extrapolate","ColorSpace","interpolateColor","useInterpolateConfig","Easing","measure","dispatchCommand","scrollTo","setGestureState","setNativeProps","getRelativeCoords","isColor","processColor","convertToRGBA","createAnimatedPropAdapter","BaseAnimationBuilder","ComplexAnimationBuilder","Keyframe","FlipInXUp","FlipInYLeft","FlipInXDown","FlipInYRight","FlipInEasyX","FlipInEasyY","FlipOutXUp","FlipOutYLeft","FlipOutXDown","FlipOutYRight","FlipOutEasyX","FlipOutEasyY","StretchInX","StretchInY","StretchOutX","StretchOutY","FadeIn","FadeInRight","FadeInLeft","FadeInUp","FadeInDown","FadeOut","FadeOutRight","FadeOutLeft","FadeOutUp","FadeOutDown","SlideInRight","SlideInLeft","SlideOutRight","SlideOutLeft","SlideInUp","SlideInDown","SlideOutUp","SlideOutDown","ZoomIn","ZoomInRotate","ZoomInLeft","ZoomInRight","ZoomInUp","ZoomInDown","ZoomInEasyUp","ZoomInEasyDown","ZoomOut","ZoomOutRotate","ZoomOutLeft","ZoomOutRight","ZoomOutUp","ZoomOutDown","ZoomOutEasyUp","ZoomOutEasyDown","BounceIn","BounceInDown","BounceInUp","BounceInLeft","BounceInRight","BounceOut","BounceOutDown","BounceOutUp","BounceOutLeft","BounceOutRight","LightSpeedInRight","LightSpeedInLeft","LightSpeedOutRight","LightSpeedOutLeft","PinwheelIn","PinwheelOut","RotateInDownLeft","RotateInDownRight","RotateInUpLeft","RotateInUpRight","RotateOutDownLeft","RotateOutDownRight","RotateOutUpLeft","RotateOutUpRight","RollInLeft","RollInRight","RollOutLeft","RollOutRight","Layout","LinearTransition","FadingTransition","SequencedTransition","JumpingTransition","CurvedTransition","EntryExitTransition","combineTransition","SharedTransition","SharedTransitionType","isSharedValue","SensorType","IOSReferenceFrame","InterfaceOrientation","KeyboardState","ReduceMotion","isWorkletFunction","getUseOfValueInStyleWarning","withReanimatedTimer","advanceAnimationByTime","advanceAnimationByFrame","setUpTests","getAnimatedStyle","LayoutAnimationConfig","PerformanceMonitor","startMapper","stopMapper","startScreenTransition","finishScreenTransition","ScreenTransition"],"sources":["index.ts"],"sourcesContent":["'use strict';\n\nimport './publicGlobals';\n\nexport type { WorkletRuntime } from './core';\nexport {\n runOnJS,\n runOnUI,\n createWorkletRuntime,\n runOnRuntime,\n makeMutable,\n makeShareableCloneRecursive,\n isReanimated3,\n isConfigured,\n enableLayoutAnimations,\n getViewProp,\n executeOnUIRuntimeSync,\n} from './core';\nexport type {\n GestureHandlers,\n AnimatedRef,\n DerivedValue,\n ScrollHandler,\n ScrollHandlers,\n ScrollHandlerProcessed,\n FrameCallback,\n ScrollEvent,\n EventHandler,\n EventHandlerProcessed,\n UseHandlerContext,\n ReanimatedEvent,\n} from './hook';\nexport {\n useAnimatedProps,\n useEvent,\n useHandler,\n useWorkletCallback,\n useSharedValue,\n useReducedMotion,\n useAnimatedStyle,\n useAnimatedGestureHandler,\n useAnimatedReaction,\n useAnimatedRef,\n useAnimatedScrollHandler,\n useDerivedValue,\n useAnimatedSensor,\n useFrameCallback,\n useAnimatedKeyboard,\n useScrollViewOffset,\n} from './hook';\nexport type {\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n WithTimingConfig,\n TimingAnimation,\n WithSpringConfig,\n SpringAnimation,\n WithDecayConfig,\n DecayAnimation,\n} from './animation';\nexport {\n cancelAnimation,\n defineAnimation,\n withClamp,\n withDecay,\n withDelay,\n withRepeat,\n withSequence,\n withSpring,\n withTiming,\n} from './animation';\nexport type { ExtrapolationConfig, ExtrapolationType } from './interpolation';\nexport { Extrapolation, interpolate, clamp } from './interpolation';\nexport type {\n InterpolationOptions,\n InterpolateConfig,\n InterpolateRGB,\n InterpolateHSV,\n} from './interpolateColor';\nexport {\n /**\n * @deprecated Please use {@link Extrapolation} instead.\n */\n Extrapolate,\n ColorSpace,\n interpolateColor,\n useInterpolateConfig,\n} from './interpolateColor';\nexport type {\n EasingFunction,\n EasingFn,\n EasingFunctionFactory,\n EasingFactoryFn,\n} from './Easing';\nexport { Easing } from './Easing';\nexport type { ComponentCoords } from './platformFunctions';\nexport {\n measure,\n dispatchCommand,\n scrollTo,\n setGestureState,\n setNativeProps,\n getRelativeCoords,\n} from './platformFunctions';\nexport type { ParsedColorArray } from './Colors';\nexport { isColor, processColor, convertToRGBA } from './Colors';\nexport { createAnimatedPropAdapter } from './PropAdapters';\nexport type {\n LayoutAnimation,\n EntryAnimationsValues,\n ExitAnimationsValues,\n EntryExitAnimationFunction,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n ILayoutAnimationBuilder,\n IEntryExitAnimationBuilder,\n} from './layoutReanimation';\nexport {\n BaseAnimationBuilder,\n ComplexAnimationBuilder,\n Keyframe,\n // Flip\n FlipInXUp,\n FlipInYLeft,\n FlipInXDown,\n FlipInYRight,\n FlipInEasyX,\n FlipInEasyY,\n FlipOutXUp,\n FlipOutYLeft,\n FlipOutXDown,\n FlipOutYRight,\n FlipOutEasyX,\n FlipOutEasyY,\n // Stretch\n StretchInX,\n StretchInY,\n StretchOutX,\n StretchOutY,\n // Fade\n FadeIn,\n FadeInRight,\n FadeInLeft,\n FadeInUp,\n FadeInDown,\n FadeOut,\n FadeOutRight,\n FadeOutLeft,\n FadeOutUp,\n FadeOutDown,\n // Slide\n SlideInRight,\n SlideInLeft,\n SlideOutRight,\n SlideOutLeft,\n SlideInUp,\n SlideInDown,\n SlideOutUp,\n SlideOutDown,\n // Zoom\n ZoomIn,\n ZoomInRotate,\n ZoomInLeft,\n ZoomInRight,\n ZoomInUp,\n ZoomInDown,\n ZoomInEasyUp,\n ZoomInEasyDown,\n ZoomOut,\n ZoomOutRotate,\n ZoomOutLeft,\n ZoomOutRight,\n ZoomOutUp,\n ZoomOutDown,\n ZoomOutEasyUp,\n ZoomOutEasyDown,\n // Bounce\n BounceIn,\n BounceInDown,\n BounceInUp,\n BounceInLeft,\n BounceInRight,\n BounceOut,\n BounceOutDown,\n BounceOutUp,\n BounceOutLeft,\n BounceOutRight,\n // Lightspeed\n LightSpeedInRight,\n LightSpeedInLeft,\n LightSpeedOutRight,\n LightSpeedOutLeft,\n // Pinwheel\n PinwheelIn,\n PinwheelOut,\n // Rotate\n RotateInDownLeft,\n RotateInDownRight,\n RotateInUpLeft,\n RotateInUpRight,\n RotateOutDownLeft,\n RotateOutDownRight,\n RotateOutUpLeft,\n RotateOutUpRight,\n // Roll\n RollInLeft,\n RollInRight,\n RollOutLeft,\n RollOutRight,\n // Transitions\n Layout,\n LinearTransition,\n FadingTransition,\n SequencedTransition,\n JumpingTransition,\n CurvedTransition,\n EntryExitTransition,\n combineTransition,\n // SET\n SharedTransition,\n SharedTransitionType,\n} from './layoutReanimation';\nexport { isSharedValue } from './isSharedValue';\nexport type {\n StyleProps,\n SharedValue,\n AnimatableValueObject,\n AnimatableValue,\n AnimationObject,\n SensorConfig,\n Animation,\n AnimatedSensor,\n AnimationCallback,\n Value3D,\n ValueRotation,\n AnimatedKeyboardInfo,\n AnimatedKeyboardOptions,\n MeasuredDimensions,\n} from './commonTypes';\nexport {\n SensorType,\n IOSReferenceFrame,\n InterfaceOrientation,\n KeyboardState,\n ReduceMotion,\n isWorkletFunction,\n} from './commonTypes';\nexport type { FrameInfo } from './frameCallback';\nexport { getUseOfValueInStyleWarning } from './pluginUtils';\nexport {\n withReanimatedTimer,\n advanceAnimationByTime,\n advanceAnimationByFrame,\n setUpTests,\n getAnimatedStyle,\n} from './jestUtils';\nexport { LayoutAnimationConfig } from './component/LayoutAnimationConfig';\nexport { PerformanceMonitor } from './component/PerformanceMonitor';\nexport type {\n Adaptable,\n AdaptTransforms,\n AnimateProps,\n AnimatedProps,\n AnimatedTransform,\n TransformStyleTypes,\n TransformArrayItem,\n AnimateStyle,\n AnimatedStyle,\n AnimatedStyleProp,\n StylesOrDefault,\n} from './helperTypes';\nexport type { AnimatedScrollViewProps } from './component/ScrollView';\nexport type { FlatListPropsWithLayout } from './component/FlatList';\nexport { startMapper, stopMapper } from './mappers';\nexport {\n startScreenTransition,\n finishScreenTransition,\n ScreenTransition,\n} from './screenTransition';\nexport type {\n AnimatedScreenTransition,\n GoBackGesture,\n ScreenTransitionConfig,\n} from './screenTransition';\n"],"mappings":"AAAA,YAAY;;AAEZ,OAAO,iBAAiB;AAGxB,SACEA,OAAO,EACPC,OAAO,EACPC,oBAAoB,EACpBC,YAAY,EACZC,WAAW,EACXC,2BAA2B,EAC3BC,aAAa,EACbC,YAAY,EACZC,sBAAsB,EACtBC,WAAW,EACXC,sBAAsB,QACjB,QAAQ;AAef,SACEC,gBAAgB,EAChBC,QAAQ,EACRC,UAAU,EACVC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,yBAAyB,EACzBC,mBAAmB,EACnBC,cAAc,EACdC,wBAAwB,EACxBC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBC,mBAAmB,EACnBC,mBAAmB,QACd,QAAQ;AAaf,SACEC,eAA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a,EACbC,SAAS,EACTC,aAAa,EACbC,WAAW,EACXC,aAAa,EACbC,cAAc;AACd;AACAC,iBAAiB,EACjBC,gBAAgB,EAChBC,kBAAkB,EAClBC,iBAAiB;AACjB;AACAC,UAAU,EACVC,WAAW;AACX;AACAC,gBAAgB,EAChBC,iBAAiB,EACjBC,cAAc,EACdC,eAAe,EACfC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,EACfC,gBAAgB;AAChB;AACAC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXC,YAAY;AACZ;AACAC,MAAM,EACNC,gBAAgB,EAChBC,gBAAgB,EAChBC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,EAChBC,mBAAmB,EACnBC,iBAAiB;AACjB;AACAC,gBAAgB,EAChBC,oBAAoB,QACf,qBAAqB;AAC5B,SAASC,aAAa,QAAQ,iBAAiB;AAiB/C,SACEC,UAAU,EACVC,iBAAiB,EACjBC,oBAAoB,EACpBC,aAAa,EACbC,YAAY,EACZC,iBAAiB,QACZ,eAAe;AAEtB,SAASC,2BAA2B,QAAQ,eAAe;AAC3D,SACEC,mBAAmB,EACnBC,sBAAsB,EACtBC,uBAAuB,EACvBC,UAAU,EACVC,gBAAgB,QACX,aAAa;AACpB,SAASC,qBAAqB,QAAQ,mCAAmC;AACzE,SAASC,kBAAkB,QAAQ,gCAAgC;AAgBnE,SAASC,WAAW,EAAEC,UAAU,QAAQ,WAAW;AACnD,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,gBAAgB,QACX,oBAAoB","ignoreList":[]}
|
|
@@ -9,12 +9,9 @@ const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
|
|
9
9
|
const IS_CHROME_DEBUGGER = isChromeDebugger();
|
|
10
10
|
|
|
11
11
|
// callGuard is only used with debug builds
|
|
12
|
-
export function callGuardDEV(fn) {
|
|
12
|
+
export function callGuardDEV(fn, ...args) {
|
|
13
13
|
'worklet';
|
|
14
14
|
|
|
15
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
16
|
-
args[_key - 1] = arguments[_key];
|
|
17
|
-
}
|
|
18
15
|
try {
|
|
19
16
|
return fn(...args);
|
|
20
17
|
} catch (e) {
|
|
@@ -61,7 +58,6 @@ export function setupConsole() {
|
|
|
61
58
|
};
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
|
-
|
|
65
61
|
function setupRequestAnimationFrame() {
|
|
66
62
|
'worklet';
|
|
67
63
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["reportFatalErrorOnJS","isChromeDebugger","isJest","shouldBeUseWeb","runOnJS","setupMicrotasks","callMicrotasks","runOnUIImmediately","mockedRequestAnimationFrame","IS_JEST","SHOULD_BE_USE_WEB","IS_CHROME_DEBUGGER","callGuardDEV","fn","
|
|
1
|
+
{"version":3,"names":["reportFatalErrorOnJS","isChromeDebugger","isJest","shouldBeUseWeb","runOnJS","setupMicrotasks","callMicrotasks","runOnUIImmediately","mockedRequestAnimationFrame","IS_JEST","SHOULD_BE_USE_WEB","IS_CHROME_DEBUGGER","callGuardDEV","fn","args","e","global","__ErrorUtils","reportFatalError","setupCallGuard","__callGuardDEV","error","message","stack","capturableConsole","console","setupConsole","assert","debug","log","warn","info","setupRequestAnimationFrame","nativeRequestAnimationFrame","requestAnimationFrame","animationFrameCallbacks","lastNativeAnimationFrameTimestamp","__flushAnimationFrame","frameTimestamp","currentCallbacks","forEach","f","callback","push","length","timestamp","__frameTimestamp","undefined","initializeUIRuntime","globalThis"],"sources":["initializers.ts"],"sourcesContent":["'use strict';\nimport { reportFatalErrorOnJS } from './errors';\nimport { isChromeDebugger, isJest, shouldBeUseWeb } from './PlatformChecker';\nimport {\n runOnJS,\n setupMicrotasks,\n callMicrotasks,\n runOnUIImmediately,\n} from './threads';\nimport { mockedRequestAnimationFrame } from './mockedRequestAnimationFrame';\n\nconst IS_JEST = isJest();\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\nconst IS_CHROME_DEBUGGER = isChromeDebugger();\n\n// callGuard is only used with debug builds\nexport function callGuardDEV<Args extends unknown[], ReturnValue>(\n fn: (...args: Args) => ReturnValue,\n ...args: Args\n): ReturnValue | void {\n 'worklet';\n try {\n return fn(...args);\n } catch (e) {\n if (global.__ErrorUtils) {\n global.__ErrorUtils.reportFatalError(e as Error);\n } else {\n throw e;\n }\n }\n}\n\nexport function setupCallGuard() {\n 'worklet';\n global.__callGuardDEV = callGuardDEV;\n global.__ErrorUtils = {\n reportFatalError: (error: Error) => {\n runOnJS(reportFatalErrorOnJS)({\n message: error.message,\n stack: error.stack,\n });\n },\n };\n}\n\n// We really have to create a copy of console here. Function runOnJS we use on elements inside\n// this object makes it not configurable\nconst capturableConsole = { ...console };\n\nexport function setupConsole() {\n 'worklet';\n if (!IS_CHROME_DEBUGGER) {\n // @ts-ignore TypeScript doesn't like that there are missing methods in console object, but we don't provide all the methods for the UI runtime console version\n global.console = {\n /* eslint-disable @typescript-eslint/unbound-method */\n assert: runOnJS(capturableConsole.assert),\n debug: runOnJS(capturableConsole.debug),\n log: runOnJS(capturableConsole.log),\n warn: runOnJS(capturableConsole.warn),\n error: runOnJS(capturableConsole.error),\n info: runOnJS(capturableConsole.info),\n /* eslint-enable @typescript-eslint/unbound-method */\n };\n }\n}\n\nfunction setupRequestAnimationFrame() {\n 'worklet';\n\n // Jest mocks requestAnimationFrame API and it does not like if that mock gets overridden\n // so we avoid doing requestAnimationFrame batching in Jest environment.\n const nativeRequestAnimationFrame = global.requestAnimationFrame;\n\n let animationFrameCallbacks: Array<(timestamp: number) => void> = [];\n let lastNativeAnimationFrameTimestamp = -1;\n\n global.__flushAnimationFrame = (frameTimestamp: number) => {\n const currentCallbacks = animationFrameCallbacks;\n animationFrameCallbacks = [];\n currentCallbacks.forEach((f) => f(frameTimestamp));\n callMicrotasks();\n };\n\n global.requestAnimationFrame = (\n callback: (timestamp: number) => void\n ): number => {\n animationFrameCallbacks.push(callback);\n if (animationFrameCallbacks.length === 1) {\n // We schedule native requestAnimationFrame only when the first callback\n // is added and then use it to execute all the enqueued callbacks. Once\n // the callbacks are run, we clear the array.\n nativeRequestAnimationFrame((timestamp) => {\n if (lastNativeAnimationFrameTimestamp >= timestamp) {\n // Make sure we only execute the callbacks once for a given frame\n return;\n }\n lastNativeAnimationFrameTimestamp = timestamp;\n global.__frameTimestamp = timestamp;\n global.__flushAnimationFrame(timestamp);\n global.__frameTimestamp = undefined;\n });\n }\n // Reanimated currently does not support cancelling callbacks requested with\n // requestAnimationFrame. We return -1 as identifier which isn't in line\n // with the spec but it should give users better clue in case they actually\n // attempt to store the value returned from rAF and use it for cancelling.\n return -1;\n };\n}\n\nexport function initializeUIRuntime() {\n if (IS_JEST) {\n // requestAnimationFrame react-native jest's setup is incorrect as it polyfills\n // the method directly using setTimeout, therefore the callback doesn't get the\n // expected timestamp as the only argument: https://github.com/facebook/react-native/blob/main/packages/react-native/jest/setup.js#L28\n // We override this setup here to make sure that callbacks get the proper timestamps\n // when executed. For non-jest environments we define requestAnimationFrame in setupRequestAnimationFrame\n // @ts-ignore TypeScript uses Node definition for rAF, setTimeout, etc which returns a Timeout object rather than a number\n globalThis.requestAnimationFrame = mockedRequestAnimationFrame;\n }\n\n runOnUIImmediately(() => {\n 'worklet';\n setupCallGuard();\n setupConsole();\n if (!SHOULD_BE_USE_WEB) {\n setupMicrotasks();\n setupRequestAnimationFrame();\n }\n })();\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,oBAAoB,QAAQ,UAAU;AAC/C,SAASC,gBAAgB,EAAEC,MAAM,EAAEC,cAAc,QAAQ,mBAAmB;AAC5E,SACEC,OAAO,EACPC,eAAe,EACfC,cAAc,EACdC,kBAAkB,QACb,WAAW;AAClB,SAASC,2BAA2B,QAAQ,+BAA+B;AAE3E,MAAMC,OAAO,GAAGP,MAAM,CAAC,CAAC;AACxB,MAAMQ,iBAAiB,GAAGP,cAAc,CAAC,CAAC;AAC1C,MAAMQ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2B,0BAA0B,CAAC,CAAC;IAC9B;EACF,CAAC,CAAC,CAAC,CAAC;AACN","ignoreList":[]}
|
|
@@ -156,11 +156,9 @@ const getInterpolateHSV = colors => {
|
|
|
156
156
|
* @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolateColor
|
|
157
157
|
*/
|
|
158
158
|
|
|
159
|
-
export function interpolateColor(value, inputRange, outputRange) {
|
|
159
|
+
export function interpolateColor(value, inputRange, outputRange, colorSpace = 'RGB', options = {}) {
|
|
160
160
|
'worklet';
|
|
161
161
|
|
|
162
|
-
let colorSpace = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'RGB';
|
|
163
|
-
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
164
162
|
if (colorSpace === 'HSV') {
|
|
165
163
|
return interpolateColorsHSV(value, inputRange, getInterpolateHSV(outputRange), options);
|
|
166
164
|
} else if (colorSpace === 'RGB') {
|
|
@@ -173,9 +171,7 @@ export let ColorSpace = /*#__PURE__*/function (ColorSpace) {
|
|
|
173
171
|
ColorSpace[ColorSpace["HSV"] = 1] = "HSV";
|
|
174
172
|
return ColorSpace;
|
|
175
173
|
}({});
|
|
176
|
-
export function useInterpolateConfig(inputRange, outputRange) {
|
|
177
|
-
let colorSpace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ColorSpace.RGB;
|
|
178
|
-
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
174
|
+
export function useInterpolateConfig(inputRange, outputRange, colorSpace = ColorSpace.RGB, options = {}) {
|
|
179
175
|
return useSharedValue({
|
|
180
176
|
inputRange,
|
|
181
177
|
outputRange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","Extrapolation","interpolate","useSharedValue","Extrapolate","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","CLAMP","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","arguments","Error","ColorSpace","useInterpolateConfig","RGB","cache"],"sources":["interpolateColor.ts"],"sourcesContent":["'use strict';\nimport {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { Extrapolation, interpolate } from './interpolation';\nimport type { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\n/**\n * @deprecated Please use Extrapolation instead\n */\nexport const Extrapolate = Extrapolation;\n\n/**\n * Options for color interpolation.\n *\n * @param gamma - Gamma value used in gamma correction. Defaults to `2.2`.\n * @param useCorrectedHSVInterpolation - Whether to reduce the number of colors the interpolation has to go through. Defaults to `true`.\n */\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(\n value,\n correctedInputRange,\n correctedH,\n Extrapolation.CLAMP\n ) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolation.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolation.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolation.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolation.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolation.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolation.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolation.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolation.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\nexport interface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\nexport interface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\n/**\n * Lets you map a value from a range of numbers to a range of colors using linear interpolation.\n *\n * @param value - A number from the `input` range that is going to be mapped to the color in the `output` range.\n * @param inputRange - An array of numbers specifying the input range of the interpolation.\n * @param outputRange - An array of output colors values (eg. \"red\", \"#00FFCC\", \"rgba(255, 0, 0, 0.5)\").\n * @param colorSpace - The color space to use for interpolation. Defaults to 'RGB'.\n * @param options - Additional options for interpolation - {@link InterpolationOptions}.\n * @returns The color after interpolation from within the output range in rgba(r, g, b, a) format.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolateColor\n */\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): string;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): number;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `[Reanimated] Invalid color space provided: ${\n colorSpace as string\n }. Supported values are: ['RGB', 'HSV'].`\n );\n}\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,OAAO,QACF,UAAU;AACjB,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,aAAa,EAAEC,WAAW,QAAQ,iBAAiB;AAE5D,SAASC,cAAc,QAAQ,uBAAuB;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAGH,aAAa;;AAExC;AACA;AACA;AACA;AACA;AACA;;AAMA,MAAMI,oBAAoB,GAAGA,CAC3BC,KAAa,EACbC,UAA6B,EAC7BC,MAAsB,EACtBC,OAA6B,KAC1B;EACH,SAAS;;EACT,IAAIC,CAAC,GAAG,CAAC;EACT,MAAM;IAAEC,4BAA4B,GAAG;EAAK,CAAC,GAAGF,O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,CAC1C;AACH;AAEA,WAAYG,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAatB,OAAO,SAASC,oBAAoBA,CAClC3C,UAA6B,EAC7BsC,WAAyC,EAGT;EAAA,IAFhCC,UAAU,GAAAC,SAAA,CAAA/B,MAAA,QAAA+B,SAAA,QAAAN,SAAA,GAAAM,SAAA,MAAGE,UAAU,CAACE,GAAG;EAAA,IAC3B1C,OAA6B,GAAAsC,SAAA,CAAA/B,MAAA,QAAA+B,SAAA,QAAAN,SAAA,GAAAM,SAAA,MAAG,CAAC,CAAC;EAElC,OAAO5C,cAAc,CAAoB;IACvCI,UAAU;IACVsC,WAAW;IACXC,UAAU;IACVM,KAAK,EAAEpD,WAAW,CAAyC,IAAI,CAAC;IAChES;EACF,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","Extrapolation","interpolate","useSharedValue","Extrapolate","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","CLAMP","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","Error","ColorSpace","useInterpolateConfig","RGB","cache"],"sources":["interpolateColor.ts"],"sourcesContent":["'use strict';\nimport {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { Extrapolation, interpolate } from './interpolation';\nimport type { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\n/**\n * @deprecated Please use Extrapolation instead\n */\nexport const Extrapolate = Extrapolation;\n\n/**\n * Options for color interpolation.\n *\n * @param gamma - Gamma value used in gamma correction. Defaults to `2.2`.\n * @param useCorrectedHSVInterpolation - Whether to reduce the number of colors the interpolation has to go through. Defaults to `true`.\n */\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(\n value,\n correctedInputRange,\n correctedH,\n Extrapolation.CLAMP\n ) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolation.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolation.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolation.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolation.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolation.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolation.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolation.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolation.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\nexport interface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\nexport interface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\n/**\n * Lets you map a value from a range of numbers to a range of colors using linear interpolation.\n *\n * @param value - A number from the `input` range that is going to be mapped to the color in the `output` range.\n * @param inputRange - An array of numbers specifying the input range of the interpolation.\n * @param outputRange - An array of output colors values (eg. \"red\", \"#00FFCC\", \"rgba(255, 0, 0, 0.5)\").\n * @param colorSpace - The color space to use for interpolation. Defaults to 'RGB'.\n * @param options - Additional options for interpolation - {@link InterpolationOptions}.\n * @returns The color after interpolation from within the output range in rgba(r, g, b, a) format.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolateColor\n */\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): string;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): number;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `[Reanimated] Invalid color space provided: ${\n colorSpace as string\n }. Supported values are: ['RGB', 'HSV'].`\n );\n}\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,OAAO,QACF,UAAU;AACjB,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,aAAa,EAAEC,WAAW,QAAQ,iBAAiB;AAE5D,SAASC,cAAc,QAAQ,uBAAuB;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAGH,aAAa;;AAExC;AACA;AACA;AACA;AACA;AACA;;AAMA,MAAMI,oBAAoB,GAAGA,CAC3BC,KAAa,EACbC,UAA6B,EAC7BC,MAAsB,EACtBC,OAA6B,KAC1B;EACH,SAAS;;EACT,IAAIC,CAAC,GAAG,CAAC;EACT,MAAM;IAAEC,4BAA4B,GAAG;EAAK,CAAC,GAAGF,OAAO;EACvD,IAAIE,4BAA4B,EAAE;IAChC;IACA;IACA;IACA;IACA,MAAMC,mBAAmB,GAAG,CAACL,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAMM,SAAS,GAAGL,MAAM,CAACE,CAAC;IAC1B,MAAMI,UAAU,GAAG,CAACD,SAAS,CAAC,CAAC,CAAC,CAAC;IAEjC,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,SAAS,CAACG,MAAM,EAAE,EAAED,CAAC,EAAE;MACzC,MAAME,CAAC,GAAGJ,SAAS,CAACE,CAAC,CAAC,GAAGF,SAAS,CAACE,CAAC,GAAG,CAAC,CAAC;MACzC,IAAIF,SAAS,CAACE,CAAC,CAAC,GAAGF,SAAS,CAACE,CAAC,GAAG,CAAC,C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EC;EAAE,CAAC;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA,OAAO,SAASsB,gBAAgBA,CAC9BtC,KAAa,EACbC,UAA6B,EAC7BsC,WAAyC,EACzCC,UAAyB,GAAG,KAAK,EACjCrC,OAA6B,GAAG,CAAC,CAAC,EACjB;EACjB,SAAS;;EACT,IAAIqC,UAAU,KAAK,KAAK,EAAE;IACxB,OAAOzC,oBAAoB,CACzBC,KAAK,EACLC,UAAU,EACVmC,iBAAiB,CAACG,WAAW,CAAC,EAC9BpC,OACF,CAAC;EACH,CAAC,MAAM,IAAIqC,UAAU,KAAK,KAAK,EAAE;IAC/B,OAAOf,oBAAoB,CACzBzB,KAAK,EACLC,UAAU,EACV+B,iBAAiB,CAACO,WAAW,CAAC,EAC9BpC,OACF,CAAC;EACH;EACA,MAAM,IAAIsC,KAAK,CACZ,8CACCD,UACD,yCACH,CAAC;AACH;AAEA,WAAYE,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAatB,OAAO,SAASC,oBAAoBA,CAClC1C,UAA6B,EAC7BsC,WAAyC,EACzCC,UAAU,GAAGE,UAAU,CAACE,GAAG,EAC3BzC,OAA6B,GAAG,CAAC,CAAC,EACF;EAChC,OAAON,cAAc,CAAoB;IACvCI,UAAU;IACVsC,WAAW;IACXC,UAAU;IACVK,KAAK,EAAEnD,WAAW,CAAyC,IAAI,CAAC;IAChES;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -45,7 +45,7 @@ function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
|
|
|
45
45
|
function isExtrapolate(value) {
|
|
46
46
|
'worklet';
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */(
|
|
49
49
|
value === Extrapolation.EXTEND || value === Extrapolation.CLAMP || value === Extrapolation.IDENTITY
|
|
50
50
|
/* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */
|
|
51
51
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Extrapolation","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","inputRange","outputRange","length","i","clamp","min","max","Math"],"sources":["interpolation.ts"],"sourcesContent":["'use strict';\n\n/**\n * Extrapolation type.\n *\n * @param IDENTITY - Returns the provided value as is.\n * @param CLAMP - Clamps the value to the edge of the output range.\n * @param EXTEND - Predicts the values beyond the output range.\n */\nexport enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\n/**\n * Represents the possible values for extrapolation as a string.\n */\ntype ExtrapolationAsString = 'identity' | 'clamp' | 'extend';\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\n/**\n * Allows to specify extrapolation for left and right edge of the interpolation.\n */\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string;\n extrapolateRight?: Extrapolation | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation;\n extrapolateRight: Extrapolation;\n}\n\n/**\n * Configuration options for extrapolation.\n */\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | ExtrapolationAsString\n | undefined;\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n 'worklet';\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x;\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolation.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'worklet';\n\n return (\n /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n /* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'worklet';\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `[Reanimated] Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `[Reanimated] Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n 'worklet';\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n/**\n * Lets you map a value from one range to another using linear interpolation.\n *\n * @param value - A number from the `input` range that is going to be mapped to the `output` range.\n * @param inputRange - An array of numbers specifying the input range of the interpolation.\n * @param outputRange - An array of numbers specifying the output range of the interpolation.\n * @param extrapolate - determines what happens when the `value` goes beyond the `input` range. Defaults to `Extrapolation.EXTEND` - {@link ExtrapolationType}.\n * @returns A mapped value within the output range.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolate\n */\nexport function interpolate(\n x: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n type?: ExtrapolationType\n): number {\n 'worklet';\n if (inputRange.length < 2 || outputRange.length < 2) {\n throw new Error(\n '[Reanimated] Interpolation input and output ranges should contain at least two values.'\n );\n }\n\n const extrapolationConfig = validateType(type);\n const length = inputRange.length;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: inputRange[0],\n rightEdgeInput: inputRange[1],\n leftEdgeOutput: outputRange[0],\n rightEdgeOutput: outputRange[1],\n };\n if (length > 2) {\n if (x > inputRange[length - 1]) {\n narrowedInput.leftEdgeInput = inputRange[length - 2];\n narrowedInput.rightEdgeInput = inputRange[length - 1];\n narrowedInput.leftEdgeOutput = outputRange[length - 2];\n narrowedInput.rightEdgeOutput = outputRange[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= inputRange[i]) {\n narrowedInput.leftEdgeInput = inputRange[i - 1];\n narrowedInput.rightEdgeInput = inputRange[i];\n narrowedInput.leftEdgeOutput = outputRange[i - 1];\n narrowedInput.rightEdgeOutput = outputRange[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n\n/**\n * Lets you limit a value within a specified range.\n *\n * @param value - A number that will be returned as long as the provided value is in range between `min` and `max`.\n * @param min - A number which will be returned when provided `value` is lower than `min`.\n * @param max - A number which will be returned when provided `value` is higher than `max`.\n * @returns A number between min and max bounds.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/clamp/\n */\nexport function clamp(value: number, min: number, max: number) {\n 'worklet';\n return Math.min(Math.max(value, min), max);\n}\n"],"mappings":"AAAA,YAAY;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;;AAMzB;AACA;AACA;;AAUA;AACA;AACA;;AAWA;AACA;AACA;;AAOA,SAASC,MAAMA,CACbC,IAAmB,EACnBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS,EACD;EACR,SAAS;;EAET,QAAQL,IAAI;IACV,KAAKF,aAAa,CAACQ,QAAQ;MACzB,OAAOD,CAAC;IACV,KAAKP,aAAa,CAACS,KAAK;MACtB,IAAIN,IAAI,GAAGC,GAAG,GAAGD,IAAI,GAAGE,cAAc,EAAE;QACtC,OAAOA,cAAc;MACvB;MACA,OAAOC,eAAe;IACxB,KAAKN,aAAa,CAACU,MAAM;IACzB;MACE,OAAON,GAAG;EAAC;AAEjB;AAEA,SAASO,aAAaA,CAACC,KAAa,EAA0B;EAC5D,SAAS;;EAET,OACE;IACAA,KAA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M,GAAG,CAAC,EAAE;IACd,IAAIrB,CAAC,GAAGmB,UAAU,CAACE,MAAM,GAAG,CAAC,CAAC,EAAE;MAC9BP,aAAa,CAACC,aAAa,GAAGI,UAAU,CAACE,MAAM,GAAG,CAAC,CAAC;MACpDP,aAAa,CAACE,cAAc,GAAGG,UAAU,CAACE,MAAM,GAAG,CAAC,CAAC;MACrDP,aAAa,CAAChB,cAAc,GAAGsB,WAAW,CAACC,MAAM,GAAG,CAAC,CAAC;MACtDP,aAAa,CAACf,eAAe,GAAGqB,WAAW,CAACC,MAAM,GAAG,CAAC,CAAC;IACzD,CAAC,MAAM;MACL,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,EAAE,EAAEC,CAAC,EAAE;QAC/B,IAAItB,CAAC,IAAImB,UAAU,CAACG,CAAC,CAAC,EAAE;UACtBR,aAAa,CAACC,aAAa,GAAGI,UAAU,CAACG,CAAC,GAAG,CAAC,CAAC;UAC/CR,aAAa,CAACE,cAAc,GAAGG,UAAU,CAACG,CAAC,CAAC;UAC5CR,aAAa,CAAChB,cAAc,GAAGsB,WAAW,CAACE,CAAC,GAAG,CAAC,CAAC;UACjDR,aAAa,CAACf,eAAe,GAAGqB,WAAW,CAACE,CAAC,CAAC;UAC9C;QACF;MACF;IACF;EACF;EAEA,OAAOT,mBAAmB,CAACb,CAAC,EAAEc,aAAa,EAAEP,mBAAmB,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgB,KAAKA,CAAClB,KAAa,EAAEmB,GAAW,EAAEC,GAAW,EAAE;EAC7D,SAAS;;EACT,OAAOC,IAAI,CAACF,GAAG,CAACE,IAAI,CAACD,GAAG,CAACpB,KAAK,EAAEmB,GAAG,CAAC,EAAEC,GAAG,CAAC;AAC5C"}
|
|
1
|
+
{"version":3,"names":["Extrapolation","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","inputRange","outputRange","length","i","clamp","min","max","Math"],"sources":["interpolation.ts"],"sourcesContent":["'use strict';\n\n/**\n * Extrapolation type.\n *\n * @param IDENTITY - Returns the provided value as is.\n * @param CLAMP - Clamps the value to the edge of the output range.\n * @param EXTEND - Predicts the values beyond the output range.\n */\nexport enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\n/**\n * Represents the possible values for extrapolation as a string.\n */\ntype ExtrapolationAsString = 'identity' | 'clamp' | 'extend';\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\n/**\n * Allows to specify extrapolation for left and right edge of the interpolation.\n */\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string;\n extrapolateRight?: Extrapolation | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation;\n extrapolateRight: Extrapolation;\n}\n\n/**\n * Configuration options for extrapolation.\n */\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | ExtrapolationAsString\n | undefined;\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n 'worklet';\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x;\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolation.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'worklet';\n\n return (\n /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n /* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'worklet';\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `[Reanimated] Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `[Reanimated] Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n 'worklet';\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n/**\n * Lets you map a value from one range to another using linear interpolation.\n *\n * @param value - A number from the `input` range that is going to be mapped to the `output` range.\n * @param inputRange - An array of numbers specifying the input range of the interpolation.\n * @param outputRange - An array of numbers specifying the output range of the interpolation.\n * @param extrapolate - determines what happens when the `value` goes beyond the `input` range. Defaults to `Extrapolation.EXTEND` - {@link ExtrapolationType}.\n * @returns A mapped value within the output range.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolate\n */\nexport function interpolate(\n x: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n type?: ExtrapolationType\n): number {\n 'worklet';\n if (inputRange.length < 2 || outputRange.length < 2) {\n throw new Error(\n '[Reanimated] Interpolation input and output ranges should contain at least two values.'\n );\n }\n\n const extrapolationConfig = validateType(type);\n const length = inputRange.length;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: inputRange[0],\n rightEdgeInput: inputRange[1],\n leftEdgeOutput: outputRange[0],\n rightEdgeOutput: outputRange[1],\n };\n if (length > 2) {\n if (x > inputRange[length - 1]) {\n narrowedInput.leftEdgeInput = inputRange[length - 2];\n narrowedInput.rightEdgeInput = inputRange[length - 1];\n narrowedInput.leftEdgeOutput = outputRange[length - 2];\n narrowedInput.rightEdgeOutput = outputRange[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= inputRange[i]) {\n narrowedInput.leftEdgeInput = inputRange[i - 1];\n narrowedInput.rightEdgeInput = inputRange[i];\n narrowedInput.leftEdgeOutput = outputRange[i - 1];\n narrowedInput.rightEdgeOutput = outputRange[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n\n/**\n * Lets you limit a value within a specified range.\n *\n * @param value - A number that will be returned as long as the provided value is in range between `min` and `max`.\n * @param min - A number which will be returned when provided `value` is lower than `min`.\n * @param max - A number which will be returned when provided `value` is higher than `max`.\n * @returns A number between min and max bounds.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/clamp/\n */\nexport function clamp(value: number, min: number, max: number) {\n 'worklet';\n return Math.min(Math.max(value, min), max);\n}\n"],"mappings":"AAAA,YAAY;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;;AAMzB;AACA;AACA;;AAUA;AACA;AACA;;AAWA;AACA;AACA;;AAOA,SAASC,MAAMA,CACbC,IAAmB,EACnBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS,EACD;EACR,SAAS;;EAET,QAAQL,IAAI;IACV,KAAKF,aAAa,CAACQ,QAAQ;MACzB,OAAOD,CAAC;IACV,KAAKP,aAAa,CAACS,KAAK;MACtB,IAAIN,IAAI,GAAGC,GAAG,GAAGD,IAAI,GAAGE,cAAc,EAAE;QACtC,OAAOA,cAAc;MACvB;MACA,OAAOC,eAAe;IACxB,KAAKN,aAAa,CAACU,MAAM;IACzB;MACE,OAAON,GAAG;EACd;AACF;AAEA,SAASO,aAAaA,CAACC,KAAa,EAA0B;EAC5D,SAAS;;EAET,OACE;IACAA,KAAK,KAAKZ,aAAa,CAACU,MAAM,IAC9BE,KAAK,KAAKZ,aAAa,CAACS,KAAK,IAC7BG,KAAK,KAAKZ,aAAa,CAACQ;IACxB;EAAA;AAEJ;;AAEA;AACA;AACA,SAASK,YAAYA,CAACX,IAAuB,EAA+B;EAC1E,SAAS;;EACT;EACA,MAAMY,mBA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CAAC,CAAC;MACrDP,aAAa,CAAChB,cAAc,GAAGsB,WAAW,CAACC,MAAM,GAAG,CAAC,CAAC;MACtDP,aAAa,CAACf,eAAe,GAAGqB,WAAW,CAACC,MAAM,GAAG,CAAC,CAAC;IACzD,CAAC,MAAM;MACL,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,EAAE,EAAEC,CAAC,EAAE;QAC/B,IAAItB,CAAC,IAAImB,UAAU,CAACG,CAAC,CAAC,EAAE;UACtBR,aAAa,CAACC,aAAa,GAAGI,UAAU,CAACG,CAAC,GAAG,CAAC,CAAC;UAC/CR,aAAa,CAACE,cAAc,GAAGG,UAAU,CAACG,CAAC,CAAC;UAC5CR,aAAa,CAAChB,cAAc,GAAGsB,WAAW,CAACE,CAAC,GAAG,CAAC,CAAC;UACjDR,aAAa,CAACf,eAAe,GAAGqB,WAAW,CAACE,CAAC,CAAC;UAC9C;QACF;MACF;IACF;EACF;EAEA,OAAOT,mBAAmB,CAACb,CAAC,EAAEc,aAAa,EAAEP,mBAAmB,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgB,KAAKA,CAAClB,KAAa,EAAEmB,GAAW,EAAEC,GAAW,EAAE;EAC7D,SAAS;;EACT,OAAOC,IAAI,CAACF,GAAG,CAACE,IAAI,CAACD,GAAG,CAACpB,KAAK,EAAEmB,GAAG,CAAC,EAAEC,GAAG,CAAC;AAC5C","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isSharedValue","value","_isReanimatedSharedValue"],"sources":["isSharedValue.ts"],"sourcesContent":["'use strict';\nimport type { SharedValue } from './commonTypes';\n\nexport function isSharedValue<T = unknown>(\n value: unknown\n): value is SharedValue<T> {\n 'worklet';\n // We cannot use `in` operator here because `value` could be a HostObject and therefore we cast.\n return (value as Record<string, unknown>)?._isReanimatedSharedValue === true;\n}\n"],"mappings":"AAAA,YAAY;;AAGZ,OAAO,SAASA,aAAaA,CAC3BC,KAAc,EACW;EACzB,SAAS;;EACT;EACA,OAAO,CAACA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAA8BC,wBAAwB,MAAK,IAAI;AAC9E"}
|
|
1
|
+
{"version":3,"names":["isSharedValue","value","_isReanimatedSharedValue"],"sources":["isSharedValue.ts"],"sourcesContent":["'use strict';\nimport type { SharedValue } from './commonTypes';\n\nexport function isSharedValue<T = unknown>(\n value: unknown\n): value is SharedValue<T> {\n 'worklet';\n // We cannot use `in` operator here because `value` could be a HostObject and therefore we cast.\n return (value as Record<string, unknown>)?._isReanimatedSharedValue === true;\n}\n"],"mappings":"AAAA,YAAY;;AAGZ,OAAO,SAASA,aAAaA,CAC3BC,KAAc,EACW;EACzB,SAAS;;EACT;EACA,OAAO,CAACA,KAAK,aAALA,KAAK,uBAALA,KAAK,CAA8BC,wBAAwB,MAAK,IAAI;AAC9E","ignoreList":[]}
|
|
@@ -124,8 +124,7 @@ export const withReanimatedTimer = animationTest => {
|
|
|
124
124
|
animationTest();
|
|
125
125
|
afterTest();
|
|
126
126
|
};
|
|
127
|
-
export const advanceAnimationByTime =
|
|
128
|
-
let time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : frameTime;
|
|
127
|
+
export const advanceAnimationByTime = (time = frameTime) => {
|
|
129
128
|
console.warn('This method is deprecated, use jest.advanceTimersByTime directly');
|
|
130
129
|
jest.advanceTimersByTime(time);
|
|
131
130
|
jest.runOnlyPendingTimers();
|
|
@@ -138,8 +137,7 @@ export const advanceAnimationByFrame = count => {
|
|
|
138
137
|
const requireFunction = isJest() ? require : () => {
|
|
139
138
|
throw new Error('[Reanimated] `setUpTests` is available only in Jest environment.');
|
|
140
139
|
};
|
|
141
|
-
export const setUpTests =
|
|
142
|
-
let userFramerateConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
140
|
+
export const setUpTests = (userFramerateConfig = {}) => {
|
|
143
141
|
let expect = global.expect;
|
|
144
142
|
if (expect === undefined) {
|
|
145
143
|
const expectModule = requireFunction('expect');
|
|
@@ -162,8 +160,7 @@ export const setUpTests = function () {
|
|
|
162
160
|
};
|
|
163
161
|
frameTime = Math.round(1000 / framerateConfig.fps);
|
|
164
162
|
expect.extend({
|
|
165
|
-
toHaveAnimatedStyle(component, expectedStyle) {
|
|
166
|
-
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
163
|
+
toHaveAnimatedStyle(component, expectedStyle, config = {}) {
|
|
167
164
|
return compareStyle(component, expectedStyle, config);
|
|
168
165
|
}
|
|
169
166
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isJest","defaultFramerateConfig","fps","getCurrentStyle","component","styleObject","props","style","currentStyle","Array","isArray","forEach","_component$props$jest","jestAnimatedStyle","value","checkEqual","current","expected","length","i","property","findStyleDiff","shouldMatchAllProps","diffs","isEqual","push","expect","Object","keys","undefined","compareStyle","expectedStyle","config","message","pass","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","Math","round","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","advanceAnimationByTime","time","arguments","advanceTimersByTime","advanceAnimationByFrame","count","requireFunction","require","Error","setUpTests","userFramerateConfig","global","expectModule","jestGlobals","extend","default","framerateConfig","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n'use strict';\n\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport type {\n AnimatedComponentProps,\n IAnimatedComponentInternal,\n InitialComponentProps,\n} from '../createAnimatedComponent/commonTypes';\nimport { isJest } from './PlatformChecker';\nimport type { DefaultStyle } from './hook/commonTypes';\n\ndeclare global {\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>,\n config?: {\n shouldMatchAllProps?: boolean;\n }\n ): R;\n }\n }\n}\n\nconst defaultFramerateConfig = {\n fps: 60,\n};\n\nconst getCurrentStyle = (component: TestComponent): DefaultStyle => {\n const styleObject = component.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n styleObject.forEach((style) => {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n });\n } else {\n currentStyle = {\n ...styleObject,\n ...component.props.jestAnimatedStyle?.value,\n };\n }\n return currentStyle;\n};\n\nconst checkEqual = <Value>(current: Value, expected: Value) => {\n if (Array.isArray(expected)) {\n if (!Array.isArray(current) || expected.length !== current.length) {\n return false;\n }\n for (let i = 0; i < current.length; i++) {\n if (!checkEqual(current[i], expected[i])) {\n return false;\n }\n }\n } else if (typeof current === 'object' && current) {\n if (typeof expected !== 'object' || !expected) {\n return false;\n }\n for (const property in expected) {\n if (!checkEqual(current[property], expected[property])) {\n return false;\n }\n }\n } else {\n return current === expected;\n }\n return true;\n};\n\nconst findStyleDiff = (\n current: DefaultStyle,\n expected: DefaultStyle,\n shouldMatchAllProps?: boolean\n) => {\n const diffs = [];\n let isEqual = true;\n let property: keyof DefaultStyle;\n for (property in expected) {\n if (!checkEqual(current[property], expected[property])) {\n isEqual = false;\n diffs.push({\n property,\n current: current[property],\n expect: expected[property],\n });\n }\n }\n\n if (\n shouldMatchAllProps &&\n Object.keys(current).length !== Object.keys(expected).length\n ) {\n isEqual = false;\n // eslint-disable-next-line @typescript-eslint/no-shadow\n let property: keyof DefaultStyle;\n for (property in current) {\n if (expected[property] === undefined) {\n diffs.push({\n property,\n current: current[property],\n expect: expected[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (\n component: TestComponent,\n expectedStyle: DefaultStyle,\n config: ToHaveAnimatedStyleConfig\n) => {\n if (!component.props.style) {\n return { message: () => `Component doesn't have a style.`, pass: false };\n }\n const { shouldMatchAllProps } = config;\n const currentStyle = getCurrentStyle(component);\n const { isEqual, diffs } = findStyleDiff(\n currentStyle,\n expectedStyle,\n shouldMatchAllProps\n );\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = Math.round(1000 / defaultFramerateConfig.fps);\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest: () => void) => {\n console.warn(\n 'This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count: number) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nconst requireFunction = isJest()\n ? require\n : () => {\n throw new Error(\n '[Reanimated] `setUpTests` is available only in Jest environment.'\n );\n };\n\ntype ToHaveAnimatedStyleConfig = {\n shouldMatchAllProps?: boolean;\n};\n\nexport const setUpTests = (userFramerateConfig = {}) => {\n let expect: jest.Expect = (global as typeof global & { expect: jest.Expect })\n .expect;\n if (expect === undefined) {\n const expectModule = requireFunction('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = requireFunction('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n const framerateConfig = {\n ...defaultFramerateConfig,\n ...userFramerateConfig,\n };\n frameTime = Math.round(1000 / framerateConfig.fps);\n\n expect.extend({\n toHaveAnimatedStyle(\n component: React.Component<\n AnimatedComponentProps<InitialComponentProps>\n > &\n IAnimatedComponentInternal,\n expectedStyle: DefaultStyle,\n config: ToHaveAnimatedStyleConfig = {}\n ) {\n return compareStyle(component, expectedStyle, config);\n },\n });\n};\n\ntype TestComponent = React.Component<\n AnimatedComponentProps<InitialComponentProps> & {\n jestAnimatedStyle?: { value: DefaultStyle };\n }\n>;\n\nexport const getAnimatedStyle = (component: ReactTestInstance) => {\n return getCurrentStyle(\n // This type assertion is needed to get type checking in the following\n // functions since `ReactTestInstance` has its `props` defined as `any`.\n component as unknown as TestComponent\n );\n};\n"],"mappings":"AAAA;AACA,YAAY;;AAQZ,SAASA,MAAM,QAAQ,mBAAmB;AAgB1C,MAAMC,sBAAsB,GAAG;EAC7BC,GAAG,EAAE;AACP,CAAC;AAED,MAAMC,eAAe,GAAIC,SAAwB,IAAmB;EAClE,MAAMC,WAAW,GAAGD,SAAS,CAACE,KAAK,CAACC,KAAK;EACzC,IAAIC,YAAY,GAAG,CAAC,CAAC;EACrB,IAAIC,KAAK,CAACC,OAAO,CAACL,WAAW,CAAC,EAAE;IAC9BA,WAAW,CAACM,OAAO,CAAEJ,KAAK,IAAK;MAC7BC,YAAY,GAAG;QACb,GAAGA,YAAY;QACf,GAAGD;MACL,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,MAAM;IAAA,IAAAK,qBAAA;IACLJ,YAAY,GAAG;MACb,GAAGH,WAAW;MACd,KAAAO,qBAAA,GAAGR,SAAS,CAACE,KAAK,CAACO,iBAAiB,cAAAD,qBAAA,uBAAjCA,qBAAA,CAAmCE,KAAK;IAC7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AA2B,EAE3B;MAAA,IADAC,MAAiC,GAAA0B,SAAA,CAAAxC,MAAA,QAAAwC,SAAA,QAAA7B,SAAA,GAAA6B,SAAA,MAAG,CAAC,CAAC;MAEtC,OAAO5B,YAAY,CAAC1B,SAAS,EAAE2B,aAAa,EAAEC,MAAM,CAAC;IACvD;EACF,CAAC,CAAC;AACJ,CAAC;AAQD,OAAO,MAAM0C,gBAAgB,GAAItE,SAA4B,IAAK;EAChE,OAAOD,eAAe;EACpB;EACA;EACAC,SAAS,CACV;AACH,CAAC"}
|
|
1
|
+
{"version":3,"names":["isJest","defaultFramerateConfig","fps","getCurrentStyle","component","styleObject","props","style","currentStyle","Array","isArray","forEach","_component$props$jest","jestAnimatedStyle","value","checkEqual","current","expected","length","i","property","findStyleDiff","shouldMatchAllProps","diffs","isEqual","push","expect","Object","keys","undefined","compareStyle","expectedStyle","config","message","pass","currentStyleStr","JSON","stringify","expectedStyleStr","differences","map","diff","join","frameTime","Math","round","beforeTest","jest","useFakeTimers","afterTest","runOnlyPendingTimers","useRealTimers","withReanimatedTimer","animationTest","console","warn","advanceAnimationByTime","time","advanceTimersByTime","advanceAnimationByFrame","count","requireFunction","require","Error","setUpTests","userFramerateConfig","global","expectModule","jestGlobals","extend","default","framerateConfig","toHaveAnimatedStyle","getAnimatedStyle"],"sources":["jestUtils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n'use strict';\n\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport type {\n AnimatedComponentProps,\n IAnimatedComponentInternal,\n InitialComponentProps,\n} from '../createAnimatedComponent/commonTypes';\nimport { isJest } from './PlatformChecker';\nimport type { DefaultStyle } from './hook/commonTypes';\n\ndeclare global {\n namespace jest {\n interface Matchers<R> {\n toHaveAnimatedStyle(\n style: Record<string, unknown>[] | Record<string, unknown>,\n config?: {\n shouldMatchAllProps?: boolean;\n }\n ): R;\n }\n }\n}\n\nconst defaultFramerateConfig = {\n fps: 60,\n};\n\nconst getCurrentStyle = (component: TestComponent): DefaultStyle => {\n const styleObject = component.props.style;\n let currentStyle = {};\n if (Array.isArray(styleObject)) {\n styleObject.forEach((style) => {\n currentStyle = {\n ...currentStyle,\n ...style,\n };\n });\n } else {\n currentStyle = {\n ...styleObject,\n ...component.props.jestAnimatedStyle?.value,\n };\n }\n return currentStyle;\n};\n\nconst checkEqual = <Value>(current: Value, expected: Value) => {\n if (Array.isArray(expected)) {\n if (!Array.isArray(current) || expected.length !== current.length) {\n return false;\n }\n for (let i = 0; i < current.length; i++) {\n if (!checkEqual(current[i], expected[i])) {\n return false;\n }\n }\n } else if (typeof current === 'object' && current) {\n if (typeof expected !== 'object' || !expected) {\n return false;\n }\n for (const property in expected) {\n if (!checkEqual(current[property], expected[property])) {\n return false;\n }\n }\n } else {\n return current === expected;\n }\n return true;\n};\n\nconst findStyleDiff = (\n current: DefaultStyle,\n expected: DefaultStyle,\n shouldMatchAllProps?: boolean\n) => {\n const diffs = [];\n let isEqual = true;\n let property: keyof DefaultStyle;\n for (property in expected) {\n if (!checkEqual(current[property], expected[property])) {\n isEqual = false;\n diffs.push({\n property,\n current: current[property],\n expect: expected[property],\n });\n }\n }\n\n if (\n shouldMatchAllProps &&\n Object.keys(current).length !== Object.keys(expected).length\n ) {\n isEqual = false;\n // eslint-disable-next-line @typescript-eslint/no-shadow\n let property: keyof DefaultStyle;\n for (property in current) {\n if (expected[property] === undefined) {\n diffs.push({\n property,\n current: current[property],\n expect: expected[property],\n });\n }\n }\n }\n\n return { isEqual, diffs };\n};\n\nconst compareStyle = (\n component: TestComponent,\n expectedStyle: DefaultStyle,\n config: ToHaveAnimatedStyleConfig\n) => {\n if (!component.props.style) {\n return { message: () => `Component doesn't have a style.`, pass: false };\n }\n const { shouldMatchAllProps } = config;\n const currentStyle = getCurrentStyle(component);\n const { isEqual, diffs } = findStyleDiff(\n currentStyle,\n expectedStyle,\n shouldMatchAllProps\n );\n\n if (isEqual) {\n return { message: () => 'ok', pass: true };\n }\n\n const currentStyleStr = JSON.stringify(currentStyle);\n const expectedStyleStr = JSON.stringify(expectedStyle);\n const differences = diffs\n .map(\n (diff) =>\n `- '${diff.property}' should be ${JSON.stringify(\n diff.expect\n )}, but is ${JSON.stringify(diff.current)}`\n )\n .join('\\n');\n\n return {\n message: () =>\n `Expected: ${expectedStyleStr}\\nReceived: ${currentStyleStr}\\n\\nDifferences:\\n${differences}`,\n pass: false,\n };\n};\n\nlet frameTime = Math.round(1000 / defaultFramerateConfig.fps);\n\nconst beforeTest = () => {\n jest.useFakeTimers();\n};\n\nconst afterTest = () => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n};\n\nexport const withReanimatedTimer = (animationTest: () => void) => {\n console.warn(\n 'This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'\n );\n beforeTest();\n animationTest();\n afterTest();\n};\n\nexport const advanceAnimationByTime = (time = frameTime) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(time);\n jest.runOnlyPendingTimers();\n};\n\nexport const advanceAnimationByFrame = (count: number) => {\n console.warn(\n 'This method is deprecated, use jest.advanceTimersByTime directly'\n );\n jest.advanceTimersByTime(count * frameTime);\n jest.runOnlyPendingTimers();\n};\n\nconst requireFunction = isJest()\n ? require\n : () => {\n throw new Error(\n '[Reanimated] `setUpTests` is available only in Jest environment.'\n );\n };\n\ntype ToHaveAnimatedStyleConfig = {\n shouldMatchAllProps?: boolean;\n};\n\nexport const setUpTests = (userFramerateConfig = {}) => {\n let expect: jest.Expect = (global as typeof global & { expect: jest.Expect })\n .expect;\n if (expect === undefined) {\n const expectModule = requireFunction('expect');\n expect = expectModule;\n // Starting from Jest 28, \"expect\" package uses named exports instead of default export.\n // So, requiring \"expect\" package doesn't give direct access to \"expect\" function anymore.\n // It gives access to the module object instead.\n // We use this info to detect if the project uses Jest 28 or higher.\n if (typeof expect === 'object') {\n const jestGlobals = requireFunction('@jest/globals');\n expect = jestGlobals.expect;\n }\n if (expect === undefined || expect.extend === undefined) {\n expect = expectModule.default;\n }\n }\n\n const framerateConfig = {\n ...defaultFramerateConfig,\n ...userFramerateConfig,\n };\n frameTime = Math.round(1000 / framerateConfig.fps);\n\n expect.extend({\n toHaveAnimatedStyle(\n component: React.Component<\n AnimatedComponentProps<InitialComponentProps>\n > &\n IAnimatedComponentInternal,\n expectedStyle: DefaultStyle,\n config: ToHaveAnimatedStyleConfig = {}\n ) {\n return compareStyle(component, expectedStyle, config);\n },\n });\n};\n\ntype TestComponent = React.Component<\n AnimatedComponentProps<InitialComponentProps> & {\n jestAnimatedStyle?: { value: DefaultStyle };\n }\n>;\n\nexport const getAnimatedStyle = (component: ReactTestInstance) => {\n return getCurrentStyle(\n // This type assertion is needed to get type checking in the following\n // functions since `ReactTestInstance` has its `props` defined as `any`.\n component as unknown as TestComponent\n );\n};\n"],"mappings":"AAAA;AACA,YAAY;;AAQZ,SAASA,MAAM,QAAQ,mBAAmB;AAgB1C,MAAMC,sBAAsB,GAAG;EAC7BC,GAAG,EAAE;AACP,CAAC;AAED,MAAMC,eAAe,GAAIC,SAAwB,IAAmB;EAClE,MAAMC,WAAW,GAAGD,SAAS,CAACE,KAAK,CAACC,KAAK;EACzC,IAAIC,YAAY,GAAG,CAAC,CAAC;EACrB,IAAIC,KAAK,CAACC,OAAO,CAACL,WAAW,CAAC,EAAE;IAC9BA,WAAW,CAACM,OAAO,CAAEJ,KAAK,IAAK;MAC7BC,YAAY,GAAG;QACb,GAAGA,YAAY;QACf,GAAGD;MACL,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,MAAM;IAAA,IAAAK,qBAAA;IACLJ,YAAY,GAAG;MACb,GAAGH,WAAW;MACd,KAAAO,qBAAA,GAAGR,SAAS,CAACE,KAAK,CAACO,iBAAiB,cAAAD,qBAAA,uBAAjCA,qBAAA,CAAmCE,KAAK;IAC7C,CAAC;EACH;EACA,OAAON,YAAY;AACrB,CAAC;AAED,MAAMO,UAAU,GAAGA,CAA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AAe;EACpB;EACA;EACAC,SACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withReanimatedTimer","advanceAnimationByTime","advanceAnimationByFrame","setUpTests","getAnimatedStyle"],"sources":["jestUtils.web.ts"],"sourcesContent":["'use strict';\n/*\n * Stubbed for web, where we don't use this file;\n */\n\nexport function withReanimatedTimer() {\n // NOOP\n}\n\nexport function advanceAnimationByTime() {\n // NOOP\n}\n\nexport function advanceAnimationByFrame() {\n // NOOP\n}\n\nexport function setUpTests() {\n // NOOP\n}\n\nexport function getAnimatedStyle() {\n // NOOP\n}\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACA;AAEA,OAAO,SAASA,mBAAmBA,CAAA,EAAG;EACpC;AAAA;AAGF,OAAO,SAASC,sBAAsBA,CAAA,EAAG;EACvC;AAAA;AAGF,OAAO,SAASC,uBAAuBA,CAAA,EAAG;EACxC;AAAA;AAGF,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC3B;AAAA;AAGF,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EACjC;AAAA"}
|
|
1
|
+
{"version":3,"names":["withReanimatedTimer","advanceAnimationByTime","advanceAnimationByFrame","setUpTests","getAnimatedStyle"],"sources":["jestUtils.web.ts"],"sourcesContent":["'use strict';\n/*\n * Stubbed for web, where we don't use this file;\n */\n\nexport function withReanimatedTimer() {\n // NOOP\n}\n\nexport function advanceAnimationByTime() {\n // NOOP\n}\n\nexport function advanceAnimationByFrame() {\n // NOOP\n}\n\nexport function setUpTests() {\n // NOOP\n}\n\nexport function getAnimatedStyle() {\n // NOOP\n}\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACA;AAEA,OAAO,SAASA,mBAAmBA,CAAA,EAAG;EACpC;AAAA;AAGF,OAAO,SAASC,sBAAsBA,CAAA,EAAG;EACvC;AAAA;AAGF,OAAO,SAASC,uBAAuBA,CAAA,EAAG;EACxC;AAAA;AAGF,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC3B;AAAA;AAGF,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EACjC;AAAA","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
-
function _toPropertyKey(
|
|
5
|
-
function _toPrimitive(
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
6
|
import { isChromeDebugger, isJest, isWeb, isWindowAvailable } from '../PlatformChecker';
|
|
7
7
|
import { SensorType } from '../commonTypes';
|
|
8
8
|
import { mockedRequestAnimationFrame } from '../mockedRequestAnimationFrame';
|
|
@@ -96,11 +96,10 @@ export default class JSReanimated {
|
|
|
96
96
|
throw new Error('[Reanimated] scheduleOnRuntime is not available in JSReanimated.');
|
|
97
97
|
}
|
|
98
98
|
registerEventHandler(_eventHandler, _eventName, _emitterReactTag) {
|
|
99
|
-
|
|
100
|
-
return -1;
|
|
99
|
+
throw new Error('[Reanimated] registerEventHandler is not available in JSReanimated.');
|
|
101
100
|
}
|
|
102
101
|
unregisterEventHandler(_) {
|
|
103
|
-
|
|
102
|
+
throw new Error('[Reanimated] unregisterEventHandler is not available in JSReanimated.');
|
|
104
103
|
}
|
|
105
104
|
enableLayoutAnimations() {
|
|
106
105
|
if (isWeb()) {
|