react-native-reanimated 3.6.0 → 3.6.2
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/lib/module/createAnimatedComponent/createAnimatedComponent.js +12 -0
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/setAndForwardRef.js +2 -0
- package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +3 -3
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/decay.js +9 -0
- package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/utils.js +13 -0
- package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
- package/lib/module/reanimated2/animation/delay.js +9 -0
- package/lib/module/reanimated2/animation/delay.js.map +1 -1
- package/lib/module/reanimated2/animation/repeat.js +11 -0
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +10 -0
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js +9 -0
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js +16 -0
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +18 -0
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +7 -0
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +30 -7
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js +7 -0
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.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/useAnimatedKeyboard.js +8 -0
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedProps.js +9 -0
- package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +6 -4
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +7 -0
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +10 -2
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +10 -0
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +8 -0
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +14 -8
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useEvent.js +7 -6
- package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js +17 -0
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useHandler.js +8 -2
- package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useReducedMotion.js +9 -0
- package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +8 -0
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js +11 -3
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useWorkletCallback.js +3 -0
- package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +21 -0
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +51 -21
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +29 -2
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +67 -2
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +6 -3
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +80 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +79 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +96 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +31 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +15 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +31 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +63 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +64 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +32 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +128 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +8 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +9 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +8 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +10 -3
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +49 -3
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +0 -2
- 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 +9 -0
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +14 -4
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.js +7 -0
- package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.js +9 -0
- package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.js +8 -0
- package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
- package/lib/module/reanimated2/runtimes.js +8 -0
- package/lib/module/reanimated2/runtimes.js.map +1 -1
- package/lib/module/reanimated2/threads.js +16 -6
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/typescript/createAnimatedComponent/createAnimatedComponent.d.ts +12 -0
- package/lib/typescript/reanimated2/Easing.d.ts +3 -3
- package/lib/typescript/reanimated2/animation/decay/decay.d.ts +8 -0
- package/lib/typescript/reanimated2/animation/decay/utils.d.ts +12 -0
- package/lib/typescript/reanimated2/animation/delay.d.ts +9 -0
- package/lib/typescript/reanimated2/animation/repeat.d.ts +11 -0
- package/lib/typescript/reanimated2/animation/sequence.d.ts +8 -0
- package/lib/typescript/reanimated2/animation/spring.d.ts +9 -0
- package/lib/typescript/reanimated2/animation/springUtils.d.ts +15 -0
- package/lib/typescript/reanimated2/animation/timing.d.ts +17 -0
- package/lib/typescript/reanimated2/animation/util.d.ts +6 -0
- package/lib/typescript/reanimated2/commonTypes.d.ts +25 -7
- package/lib/typescript/reanimated2/component/FlatList.d.ts +6 -0
- package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +7 -0
- package/lib/typescript/reanimated2/component/ScrollView.d.ts +3 -2
- package/lib/typescript/reanimated2/helperTypes.d.ts +45 -3
- package/lib/typescript/reanimated2/hook/useAnimatedKeyboard.d.ts +7 -0
- package/lib/typescript/reanimated2/hook/useAnimatedProps.d.ts +9 -0
- package/lib/typescript/reanimated2/hook/useAnimatedReaction.d.ts +6 -4
- package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +6 -0
- package/lib/typescript/reanimated2/hook/useAnimatedScrollHandler.d.ts +10 -0
- package/lib/typescript/reanimated2/hook/useAnimatedSensor.d.ts +8 -0
- package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +8 -0
- package/lib/typescript/reanimated2/hook/useDerivedValue.d.ts +9 -1
- package/lib/typescript/reanimated2/hook/useEvent.d.ts +8 -5
- package/lib/typescript/reanimated2/hook/useFrameCallback.d.ts +14 -0
- package/lib/typescript/reanimated2/hook/useHandler.d.ts +8 -0
- package/lib/typescript/reanimated2/hook/useReducedMotion.d.ts +8 -0
- package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +7 -0
- package/lib/typescript/reanimated2/hook/useSharedValue.d.ts +8 -1
- package/lib/typescript/reanimated2/hook/useWorkletCallback.d.ts +3 -0
- package/lib/typescript/reanimated2/index.d.ts +1 -1
- package/lib/typescript/reanimated2/interpolateColor.d.ts +17 -0
- package/lib/typescript/reanimated2/interpolation.d.ts +30 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +25 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +56 -1
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +4 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +70 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +70 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +84 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +28 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +14 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +28 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +56 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +56 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +28 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +112 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +7 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +8 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +7 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +7 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +10 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +7 -0
- package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.d.ts +43 -1
- package/lib/typescript/reanimated2/layoutReanimation/web/createAnimation.d.ts +4 -4
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/reanimated2/platformFunctions/dispatchCommand.d.ts +8 -0
- package/lib/typescript/reanimated2/platformFunctions/getRelativeCoords.d.ts +11 -3
- package/lib/typescript/reanimated2/platformFunctions/measure.d.ts +7 -0
- package/lib/typescript/reanimated2/platformFunctions/scrollTo.d.ts +9 -0
- package/lib/typescript/reanimated2/platformFunctions/setNativeProps.d.ts +7 -0
- package/lib/typescript/reanimated2/runtimes.d.ts +8 -0
- package/lib/typescript/reanimated2/threads.d.ts +17 -2
- package/package.json +2 -1
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +18 -0
- package/src/createAnimatedComponent/setAndForwardRef.ts +2 -0
- package/src/reanimated2/Easing.ts +3 -3
- package/src/reanimated2/PlatformChecker.ts +1 -1
- package/src/reanimated2/animation/decay/decay.ts +8 -0
- package/src/reanimated2/animation/decay/utils.ts +12 -0
- package/src/reanimated2/animation/delay.ts +9 -0
- package/src/reanimated2/animation/repeat.ts +11 -0
- package/src/reanimated2/animation/sequence.ts +8 -0
- package/src/reanimated2/animation/spring.ts +9 -0
- package/src/reanimated2/animation/springUtils.ts +15 -0
- package/src/reanimated2/animation/timing.ts +17 -0
- package/src/reanimated2/animation/util.ts +6 -0
- package/src/reanimated2/commonTypes.ts +25 -7
- package/src/reanimated2/component/FlatList.tsx +6 -0
- package/src/reanimated2/component/LayoutAnimationConfig.tsx +7 -0
- package/src/reanimated2/component/ScrollView.tsx +3 -1
- package/src/reanimated2/globals.d.ts +1 -1
- package/src/reanimated2/helperTypes.ts +45 -3
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +7 -0
- package/src/reanimated2/hook/useAnimatedProps.ts +9 -0
- package/src/reanimated2/hook/useAnimatedReaction.ts +6 -4
- package/src/reanimated2/hook/useAnimatedRef.ts +6 -0
- package/src/reanimated2/hook/useAnimatedScrollHandler.ts +10 -0
- package/src/reanimated2/hook/useAnimatedSensor.ts +8 -0
- package/src/reanimated2/hook/useAnimatedStyle.ts +8 -0
- package/src/reanimated2/hook/useDerivedValue.ts +15 -7
- package/src/reanimated2/hook/useEvent.ts +9 -6
- package/src/reanimated2/hook/useFrameCallback.ts +14 -0
- package/src/reanimated2/hook/useHandler.ts +8 -0
- package/src/reanimated2/hook/useReducedMotion.ts +8 -0
- package/src/reanimated2/hook/useScrollViewOffset.ts +7 -0
- package/src/reanimated2/hook/useSharedValue.ts +12 -3
- package/src/reanimated2/hook/useWorkletCallback.ts +3 -0
- package/src/reanimated2/index.ts +1 -1
- package/src/reanimated2/interpolateColor.ts +17 -0
- package/src/reanimated2/interpolation.ts +48 -22
- package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +26 -3
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +57 -2
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +7 -6
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +4 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +71 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +70 -1
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +84 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +28 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +14 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +28 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +56 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +56 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +28 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +112 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +7 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +8 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +7 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +8 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +10 -3
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +7 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.ts +45 -3
- package/src/reanimated2/layoutReanimation/web/createAnimation.ts +4 -4
- package/src/reanimated2/platform-specific/checkCppVersion.ts +0 -4
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/platformFunctions/dispatchCommand.ts +8 -0
- package/src/reanimated2/platformFunctions/getRelativeCoords.ts +12 -4
- package/src/reanimated2/platformFunctions/measure.ts +7 -0
- package/src/reanimated2/platformFunctions/scrollTo.ts +9 -0
- package/src/reanimated2/platformFunctions/setNativeProps.ts +7 -0
- package/src/reanimated2/runtimes.ts +8 -0
- package/src/reanimated2/threads.ts +18 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isChromeDebugger","isFabric","isJest","shouldBeUseWeb","measure","measureFabric","animatedRef","_WORKLET","viewTag","console","warn","measured","_measureFabric","x","isNaN","measurePaper","_measurePaper","measureJest","measureChromeDebugger","measureDefault"],"sources":["measure.ts"],"sourcesContent":["'use strict';\nimport type { MeasuredDimensions, ShadowNodeWrapper } from '../commonTypes';\nimport {\n isChromeDebugger,\n isFabric,\n isJest,\n shouldBeUseWeb,\n} from '../PlatformChecker';\nimport type { AnimatedRef } from '../hook/commonTypes';\nimport type { Component } from 'react';\n\nexport let measure: <T extends Component>(\n animatedRef: AnimatedRef<T>\n) => MeasuredDimensions | null;\n\nfunction measureFabric<T extends Component>(animatedRef: AnimatedRef<T>) {\n 'worklet';\n if (!_WORKLET) {\n return null;\n }\n\n const viewTag = (animatedRef as any)();\n if (viewTag === -1) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`\n );\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const measured = _measureFabric!(viewTag as ShadowNodeWrapper);\n if (measured === null) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \\`LayoutMetrics\\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`\n );\n return null;\n } else if (measured.x === -1234567) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} returned an invalid measurement response. Please make sure the view is currently rendered.`\n );\n return null;\n } else if (isNaN(measured.x)) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \\`collapsable={false}\\` on this component.`\n );\n return null;\n } else {\n return measured;\n }\n}\n\nfunction measurePaper<T extends Component>(animatedRef: AnimatedRef<T>) {\n 'worklet';\n if (!_WORKLET) {\n return null;\n }\n\n const viewTag = (animatedRef as any)();\n if (viewTag === -1) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`\n );\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const measured = _measurePaper!(viewTag as number);\n if (measured === null) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \\`LayoutMetrics\\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`\n );\n return null;\n } else if (measured.x === -1234567) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} returned an invalid measurement response. Please make sure the view is currently rendered.`\n );\n return null;\n } else if (isNaN(measured.x)) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \\`collapsable={false}\\` on this component.`\n );\n return null;\n } else {\n return measured;\n }\n}\n\nfunction measureJest() {\n console.warn('[Reanimated] measure() cannot be used with Jest.');\n return null;\n}\n\nfunction measureChromeDebugger() {\n console.warn('[Reanimated] measure() cannot be used with Chrome Debugger.');\n return null;\n}\n\nfunction measureDefault() {\n console.warn(\n '[Reanimated] measure() is not supported on this configuration.'\n );\n return null;\n}\n\nif (!shouldBeUseWeb()) {\n if (isFabric()) {\n measure = measureFabric;\n } else {\n measure = measurePaper;\n }\n} else if (isJest()) {\n measure = measureJest;\n} else if (isChromeDebugger()) {\n measure = measureChromeDebugger;\n} else {\n measure = measureDefault;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,cAAc,QACT,oBAAoB;AAI3B,OAAO,IAAIC,OAEmB;AAE9B,SAASC,aAAaA,CAAsBC,WAA2B,EAAE;EACvE,SAAS;;EACT,IAAI,CAACC,QAAQ,EAAE;IACb,OAAO,IAAI;EACb;EAEA,MAAMC,OAAO,GAAIF,WAAW,EAAU;EACtC,IAAIE,OAAO,KAAK,CAAC,CAAC,EAAE;IAClBC,OAAO,CAACC,IAAI,CACT,kCAAiCF,OAAQ,4JAA2J,CACtM;IACD,OAAO,IAAI;EACb;;EAEA;EACA,MAAMG,QAAQ,GAAGC,cAAc,CAAEJ,OAAO,CAAsB;EAC9D,IAAIG,QAAQ,KAAK,IAAI,EAAE;IACrBF,OAAO,CAACC,IAAI,CACT,kCAAiCF,OAAQ,0MAAyM,CACpP;IACD,OAAO,IAAI;EACb,CAAC,MAAM,IAAIG,QAAQ,CAACE,CAAC,KAAK,CAAC,OAAO,EAAE;IAClCJ,OAAO,CAACC,IAAI,CACT,kCAAiCF,OAAQ,6FAA4F,CACvI;IACD,OAAO,IAAI;EACb,CAAC,MAAM,IAAIM,KAAK,CAACH,QAAQ,CAACE,CAAC,CAAC,EAAE;IAC5BJ,OAAO,CAACC,IAAI,CACT,kCAAiCF,OAAQ,6GAA4G,CACvJ;IACD,OAAO,IAAI;EACb,CAAC,MAAM;IACL,OAAOG,QAAQ;EACjB;AACF;AAEA,SAASI,YAAYA,CAAsBT,WAA2B,EAAE;EACtE,SAAS;;EACT,IAAI,CAACC,QAAQ,EAAE;IACb,OAAO,IAAI;EACb;EAEA,MAAMC,OAAO,GAAIF,WAAW,EAAU;EACtC,IAAIE,OAAO,KAAK,CAAC,CAAC,EAAE;IAClBC,OAAO,CAACC,IAAI,CACT,kCAAiCF,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romeDebugger","isFabric","isJest","shouldBeUseWeb","measure","measureFabric","animatedRef","_WORKLET","viewTag","console","warn","measured","_measureFabric","x","isNaN","measurePaper","_measurePaper","measureJest","measureChromeDebugger","measureDefault"],"sources":["measure.ts"],"sourcesContent":["'use strict';\nimport type { MeasuredDimensions, ShadowNodeWrapper } from '../commonTypes';\nimport {\n isChromeDebugger,\n isFabric,\n isJest,\n shouldBeUseWeb,\n} from '../PlatformChecker';\nimport type { AnimatedRef } from '../hook/commonTypes';\nimport type { Component } from 'react';\n\n/**\n * Lets you synchronously get the dimensions and position of a view on the screen.\n *\n * @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef#returns) connected to the component you'd want to get the measurements from.\n * @returns An object containing component measurements or null when the measurement couldn't be performed- {@link MeasuredDimensions}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/measure/\n */\nexport let measure: <T extends Component>(\n animatedRef: AnimatedRef<T>\n) => MeasuredDimensions | null;\n\nfunction measureFabric<T extends Component>(animatedRef: AnimatedRef<T>) {\n 'worklet';\n if (!_WORKLET) {\n return null;\n }\n\n const viewTag = (animatedRef as any)();\n if (viewTag === -1) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`\n );\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const measured = _measureFabric!(viewTag as ShadowNodeWrapper);\n if (measured === null) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \\`LayoutMetrics\\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`\n );\n return null;\n } else if (measured.x === -1234567) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} returned an invalid measurement response. Please make sure the view is currently rendered.`\n );\n return null;\n } else if (isNaN(measured.x)) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \\`collapsable={false}\\` on this component.`\n );\n return null;\n } else {\n return measured;\n }\n}\n\nfunction measurePaper<T extends Component>(animatedRef: AnimatedRef<T>) {\n 'worklet';\n if (!_WORKLET) {\n return null;\n }\n\n const viewTag = (animatedRef as any)();\n if (viewTag === -1) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} is not a valid argument for measure(). This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`\n );\n return null;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const measured = _measurePaper!(viewTag as number);\n if (measured === null) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} has some undefined, not-yet-computed or meaningless value of \\`LayoutMetrics\\` type. This may be because the view is not currently rendered, which may not be a bug (e.g. an off-screen FlatList item).`\n );\n return null;\n } else if (measured.x === -1234567) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} returned an invalid measurement response. Please make sure the view is currently rendered.`\n );\n return null;\n } else if (isNaN(measured.x)) {\n console.warn(\n `[Reanimated] The view with tag ${viewTag} gets view-flattened on Android. To disable view-flattening, set \\`collapsable={false}\\` on this component.`\n );\n return null;\n } else {\n return measured;\n }\n}\n\nfunction measureJest() {\n console.warn('[Reanimated] measure() cannot be used with Jest.');\n return null;\n}\n\nfunction measureChromeDebugger() {\n console.warn('[Reanimated] measure() cannot be used with Chrome Debugger.');\n return null;\n}\n\nfunction measureDefault() {\n console.warn(\n '[Reanimated] measure() is not supported on this configuration.'\n );\n return null;\n}\n\nif (!shouldBeUseWeb()) {\n if (isFabric()) {\n measure = measureFabric;\n } else {\n measure = measurePaper;\n }\n} else if (isJest()) {\n measure = measureJest;\n} else if (isChromeDebugger()) {\n measure = measureChromeDebugger;\n} else {\n measure = measureDefault;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,cAAc,QACT,oBAAoB;AAI3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,O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yM,CACpP;IACD,OAAO,IAAI;EACb,CAAC,MAAM,IAAIG,QAAQ,CAACE,CAAC,KAAK,CAAC,OAAO,EAAE;IAClCJ,OAAO,CAACC,IAAI,CACT,kCAAiCF,OAAQ,6FAA4F,CACvI;IACD,OAAO,IAAI;EACb,CAAC,MAAM,IAAIM,KAAK,CAACH,QAAQ,CAACE,CAAC,CAAC,EAAE;IAC5BJ,OAAO,CAACC,IAAI,CACT,kCAAiCF,OAAQ,6GAA4G,CACvJ;IACD,OAAO,IAAI;EACb,CAAC,MAAM;IACL,OAAOG,QAAQ;EACjB;AACF;AAEA,SAASM,WAAWA,CAAA,EAAG;EACrBR,OAAO,CAACC,IAAI,CAAC,kDAAkD,CAAC;EAChE,OAAO,IAAI;AACb;AAEA,SAASQ,qBAAqBA,CAAA,EAAG;EAC/BT,OAAO,CAACC,IAAI,CAAC,6DAA6D,CAAC;EAC3E,OAAO,IAAI;AACb;AAEA,SAASS,cAAcA,CAAA,EAAG;EACxBV,OAAO,CAACC,IAAI,CACV,gEAAgE,CACjE;EACD,OAAO,IAAI;AACb;AAEA,IAAI,CAACP,cAAc,EAAE,EAAE;EACrB,IAAIF,QAAQ,EAAE,EAAE;IACdG,OAAO,GAAGC,aAAa;EACzB,CAAC,MAAM;IACLD,OAAO,GAAGW,YAAY;EACxB;AACF,CAAC,MAAM,IAAIb,MAAM,EAAE,EAAE;EACnBE,OAAO,GAAGa,WAAW;AACvB,CAAC,MAAM,IAAIjB,gBAAgB,EAAE,EAAE;EAC7BI,OAAO,GAAGc,qBAAqB;AACjC,CAAC,MAAM;EACLd,OAAO,GAAGe,cAAc;AAC1B"}
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import { isChromeDebugger, isFabric, isJest, shouldBeUseWeb } from '../PlatformChecker';
|
|
4
4
|
import { dispatchCommand } from './dispatchCommand';
|
|
5
|
+
/**
|
|
6
|
+
* Lets you synchronously scroll to a given position of a `ScrollView`.
|
|
7
|
+
*
|
|
8
|
+
* @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef) attached to an `Animated.ScrollView` component.
|
|
9
|
+
* @param x - The x position you want to scroll to.
|
|
10
|
+
* @param y - The y position you want to scroll to.
|
|
11
|
+
* @param animated - Whether the scrolling should be smooth or instant.
|
|
12
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/scroll/scrollTo
|
|
13
|
+
*/
|
|
5
14
|
export let scrollTo;
|
|
6
15
|
function scrollToFabric(animatedRef, x, y, animated) {
|
|
7
16
|
'worklet';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isChromeDebugger","isFabric","isJest","shouldBeUseWeb","dispatchCommand","scrollTo","scrollToFabric","animatedRef","x","y","animated","scrollToPaper","_WORKLET","viewTag","_scrollToPaper","scrollToJest","console","warn","scrollToChromeDebugger","scrollToDefault"],"sources":["scrollTo.ts"],"sourcesContent":["'use strict';\nimport {\n isChromeDebugger,\n isFabric,\n isJest,\n shouldBeUseWeb,\n} from '../PlatformChecker';\nimport { dispatchCommand } from './dispatchCommand';\nimport type { AnimatedRef } from '../hook/commonTypes';\nimport type { Component } from 'react';\n\nexport let scrollTo: <T extends Component>(\n animatedRef: AnimatedRef<T>,\n x: number,\n y: number,\n animated: boolean\n) => void;\n\nfunction scrollToFabric<T extends Component>(\n animatedRef: AnimatedRef<T>,\n x: number,\n y: number,\n animated: boolean\n) {\n 'worklet';\n dispatchCommand(animatedRef as any, 'scrollTo', [x, y, animated]);\n}\n\nfunction scrollToPaper<T extends Component>(\n animatedRef: AnimatedRef<T>,\n x: number,\n y: number,\n animated: boolean\n) {\n 'worklet';\n if (!_WORKLET) {\n return;\n }\n\n // Calling animatedRef on Paper returns a number (nativeTag)\n const viewTag = (animatedRef as any)() as number;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n _scrollToPaper!(viewTag, x, y, animated);\n}\n\nfunction scrollToJest() {\n console.warn('[Reanimated] scrollTo() is not supported with Jest.');\n}\n\nfunction scrollToChromeDebugger() {\n console.warn(\n '[Reanimated] scrollTo() is not supported with Chrome Debugger.'\n );\n}\n\nfunction scrollToDefault() {\n console.warn(\n '[Reanimated] scrollTo() is not supported on this configuration.'\n );\n}\n\nif (!shouldBeUseWeb()) {\n if (isFabric()) {\n scrollTo = scrollToFabric;\n } else {\n scrollTo = scrollToPaper;\n }\n} else if (isJest()) {\n scrollTo = scrollToJest;\n} else if (isChromeDebugger()) {\n scrollTo = scrollToChromeDebugger;\n} else {\n scrollTo = scrollToDefault;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,cAAc,QACT,oBAAoB;AAC3B,SAASC,eAAe,QAAQ,mBAAmB;AAInD,OAAO,IAAIC,QAKF;AAET,SAASC,cAAcA,CACrBC,WAA2B,EAC3BC,CAAS,EACTC,CAAS,EACTC,QAAiB,EACjB;EACA,SAAS;;EACTN,eAAe,CAACG,WAAW,EAAS,UAAU,EAAE,CAACC,CAAC,EAAEC,CAAC,EAAEC,QAAQ,CAAC,CAAC;AACnE;AAEA,SAASC,aAAaA,CACpBJ,WAA2B,EAC3BC,CAAS,EACTC,CAAS,EACTC,QAAiB,EACjB;EACA,SAAS;;EACT,IAAI,CAACE,QAAQ,EAAE;IACb;EACF;;EAEA;EACA,MAAMC,OAAO,GAAIN,WAAW,EAAoB;EAChD;EACAO,cAAc,CAAED,OAAO,EAAEL,CAAC,EAAEC,CAAC,EAAEC,QAAQ,CAAC;AAC1C;AAEA,SAASK,YAAYA,CAAA,EAAG;EACtBC,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC;AACrE;AAEA,SAASC,sBAAsBA,CAAA,EAAG;EAChCF,OAAO,CAACC,IAAI,CACV,gEAAgE,CACjE;AACH;AAEA,SAASE,eAAeA,CAAA,EAAG;EACzBH,OAAO,CAACC,IAAI,CACV,iEAAiE,CAClE;AACH;AAEA,IAAI,CAACd,cAAc,EAAE,EAAE;EACrB,IAAIF,QAAQ,EAAE,EAAE;IACdI,QAAQ,GAAGC,cAAc;EAC3B,CAAC,MAAM;IACLD,QAAQ,GAAGM,aAAa;EAC1B;AACF,CAAC,MAAM,IAAIT,MAAM,EAAE,EAAE;EACnBG,QAAQ,GAAGU,YAAY;AACzB,CAAC,MAAM,IAAIf,gBAAgB,EAAE,EAAE;EAC7BK,QAAQ,GAAGa,sBAAsB;AACnC,CAAC,MAAM;EACLb,QAAQ,GAAGc,eAAe;AAC5B"}
|
|
1
|
+
{"version":3,"names":["isChromeDebugger","isFabric","isJest","shouldBeUseWeb","dispatchCommand","scrollTo","scrollToFabric","animatedRef","x","y","animated","scrollToPaper","_WORKLET","viewTag","_scrollToPaper","scrollToJest","console","warn","scrollToChromeDebugger","scrollToDefault"],"sources":["scrollTo.ts"],"sourcesContent":["'use strict';\nimport {\n isChromeDebugger,\n isFabric,\n isJest,\n shouldBeUseWeb,\n} from '../PlatformChecker';\nimport { dispatchCommand } from './dispatchCommand';\nimport type { AnimatedRef } from '../hook/commonTypes';\nimport type { Component } from 'react';\n\n/**\n * Lets you synchronously scroll to a given position 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 * @param x - The x position you want to scroll to.\n * @param y - The y position you want to scroll to.\n * @param animated - Whether the scrolling should be smooth or instant.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/scroll/scrollTo\n */\nexport let scrollTo: <T extends Component>(\n animatedRef: AnimatedRef<T>,\n x: number,\n y: number,\n animated: boolean\n) => void;\n\nfunction scrollToFabric<T extends Component>(\n animatedRef: AnimatedRef<T>,\n x: number,\n y: number,\n animated: boolean\n) {\n 'worklet';\n dispatchCommand(animatedRef as any, 'scrollTo', [x, y, animated]);\n}\n\nfunction scrollToPaper<T extends Component>(\n animatedRef: AnimatedRef<T>,\n x: number,\n y: number,\n animated: boolean\n) {\n 'worklet';\n if (!_WORKLET) {\n return;\n }\n\n // Calling animatedRef on Paper returns a number (nativeTag)\n const viewTag = (animatedRef as any)() as number;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n _scrollToPaper!(viewTag, x, y, animated);\n}\n\nfunction scrollToJest() {\n console.warn('[Reanimated] scrollTo() is not supported with Jest.');\n}\n\nfunction scrollToChromeDebugger() {\n console.warn(\n '[Reanimated] scrollTo() is not supported with Chrome Debugger.'\n );\n}\n\nfunction scrollToDefault() {\n console.warn(\n '[Reanimated] scrollTo() is not supported on this configuration.'\n );\n}\n\nif (!shouldBeUseWeb()) {\n if (isFabric()) {\n scrollTo = scrollToFabric;\n } else {\n scrollTo = scrollToPaper;\n }\n} else if (isJest()) {\n scrollTo = scrollToJest;\n} else if (isChromeDebugger()) {\n scrollTo = scrollToChromeDebugger;\n} else {\n scrollTo = scrollToDefault;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,cAAc,QACT,oBAAoB;AAC3B,SAASC,eAAe,QAAQ,mBAAmB;AAInD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAIC,QAKF;AAET,SAASC,cAAcA,CACrBC,WAA2B,EAC3BC,CAAS,EACTC,CAAS,EACTC,QAAiB,EACjB;EACA,SAAS;;EACTN,eAAe,CAACG,WAAW,EAAS,UAAU,EAAE,CAACC,CAAC,EAAEC,CAAC,EAAEC,QAAQ,CAAC,CAAC;AACnE;AAEA,SAASC,aAAaA,CACpBJ,WAA2B,EAC3BC,CAAS,EACTC,CAAS,EACTC,QAAiB,EACjB;EACA,SAAS;;EACT,IAAI,CAACE,QAAQ,EAAE;IACb;EACF;;EAEA;EACA,MAAMC,OAAO,GAAIN,WAAW,EAAoB;EAChD;EACAO,cAAc,CAAED,OAAO,EAAEL,CAAC,EAAEC,CAAC,EAAEC,QAAQ,CAAC;AAC1C;AAEA,SAASK,YAAYA,CAAA,EAAG;EACtBC,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC;AACrE;AAEA,SAASC,sBAAsBA,CAAA,EAAG;EAChCF,OAAO,CAACC,IAAI,CACV,gEAAgE,CACjE;AACH;AAEA,SAASE,eAAeA,CAAA,EAAG;EACzBH,OAAO,CAACC,IAAI,CACV,iEAAiE,CAClE;AACH;AAEA,IAAI,CAACd,cAAc,EAAE,EAAE;EACrB,IAAIF,QAAQ,EAAE,EAAE;IACdI,QAAQ,GAAGC,cAAc;EAC3B,CAAC,MAAM;IACLD,QAAQ,GAAGM,aAAa;EAC1B;AACF,CAAC,MAAM,IAAIT,MAAM,EAAE,EAAE;EACnBG,QAAQ,GAAGU,YAAY;AACzB,CAAC,MAAM,IAAIf,gBAAgB,EAAE,EAAE;EAC7BK,QAAQ,GAAGa,sBAAsB;AACnC,CAAC,MAAM;EACLb,QAAQ,GAAGc,eAAe;AAC5B"}
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { isChromeDebugger, isFabric, isJest, shouldBeUseWeb } from '../PlatformChecker';
|
|
4
4
|
import { processColorsInProps } from '../Colors';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Lets you imperatively update component properties. You should always reach for [useAnimatedStyle](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedStyle) and [useAnimatedProps](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedProps) first when animating styles or properties.
|
|
8
|
+
*
|
|
9
|
+
* @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef#returns) connected to the component you'd want to update.
|
|
10
|
+
* @param updates - An object with properties you want to update.
|
|
11
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/setNativeProps
|
|
12
|
+
*/
|
|
5
13
|
export let setNativeProps;
|
|
6
14
|
function setNativePropsFabric(animatedRef, updates) {
|
|
7
15
|
'worklet';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isChromeDebugger","isFabric","isJest","shouldBeUseWeb","processColorsInProps","setNativeProps","setNativePropsFabric","animatedRef","updates","_WORKLET","console","warn","shadowNodeWrapper","_updatePropsFabric","setNativePropsPaper","tag","name","viewName","value","_updatePropsPaper","setNativePropsJest","setNativePropsChromeDebugger","setNativePropsDefault"],"sources":["setNativeProps.ts"],"sourcesContent":["'use strict';\nimport type { ShadowNodeWrapper, StyleProps } from '../commonTypes';\nimport {\n isChromeDebugger,\n isFabric,\n isJest,\n shouldBeUseWeb,\n} from '../PlatformChecker';\nimport type { AnimatedRef } from '../hook/commonTypes';\nimport type { Component } from 'react';\nimport { processColorsInProps } from '../Colors';\n\nexport let setNativeProps: <T extends Component>(\n animatedRef: AnimatedRef<T>,\n updates: StyleProps\n) => void;\n\nfunction setNativePropsFabric<T extends Component>(\n animatedRef: AnimatedRef<T>,\n updates: StyleProps\n) {\n 'worklet';\n if (!_WORKLET) {\n console.warn(\n '[Reanimated] setNativeProps() can only be used on the UI runtime.'\n );\n return;\n }\n const shadowNodeWrapper = (animatedRef as any)() as ShadowNodeWrapper;\n processColorsInProps(updates);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n _updatePropsFabric!([{ shadowNodeWrapper, updates }]);\n}\n\nfunction setNativePropsPaper<T extends Component>(\n animatedRef: AnimatedRef<T>,\n updates: StyleProps\n) {\n 'worklet';\n if (!_WORKLET) {\n console.warn(\n '[Reanimated] setNativeProps() can only be used on the UI runtime.'\n );\n return;\n }\n const tag = (animatedRef as any)() as number;\n const name = (animatedRef as any).viewName.value;\n processColorsInProps(updates);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n _updatePropsPaper!([{ tag, name, updates }]);\n}\n\nfunction setNativePropsJest() {\n console.warn('[Reanimated] setNativeProps() is not supported with Jest.');\n}\n\nfunction setNativePropsChromeDebugger() {\n console.warn(\n '[Reanimated] setNativeProps() is not supported with Chrome Debugger.'\n );\n}\n\nfunction setNativePropsDefault() {\n console.warn(\n '[Reanimated] setNativeProps() is not supported on this configuration.'\n );\n}\n\nif (!shouldBeUseWeb()) {\n if (isFabric()) {\n setNativeProps = setNativePropsFabric;\n } else {\n setNativeProps = setNativePropsPaper;\n }\n} else if (isJest()) {\n setNativeProps = setNativePropsJest;\n} else if (isChromeDebugger()) {\n setNativeProps = setNativePropsChromeDebugger;\n} else {\n setNativeProps = setNativePropsDefault;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,cAAc,QACT,oBAAoB;AAG3B,SAASC,oBAAoB,QAAQ,WAAW;
|
|
1
|
+
{"version":3,"names":["isChromeDebugger","isFabric","isJest","shouldBeUseWeb","processColorsInProps","setNativeProps","setNativePropsFabric","animatedRef","updates","_WORKLET","console","warn","shadowNodeWrapper","_updatePropsFabric","setNativePropsPaper","tag","name","viewName","value","_updatePropsPaper","setNativePropsJest","setNativePropsChromeDebugger","setNativePropsDefault"],"sources":["setNativeProps.ts"],"sourcesContent":["'use strict';\nimport type { ShadowNodeWrapper, StyleProps } from '../commonTypes';\nimport {\n isChromeDebugger,\n isFabric,\n isJest,\n shouldBeUseWeb,\n} from '../PlatformChecker';\nimport type { AnimatedRef } from '../hook/commonTypes';\nimport type { Component } from 'react';\nimport { processColorsInProps } from '../Colors';\n\n/**\n * Lets you imperatively update component properties. You should always reach for [useAnimatedStyle](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedStyle) and [useAnimatedProps](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedProps) first when animating styles or properties.\n *\n * @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef#returns) connected to the component you'd want to update.\n * @param updates - An object with properties you want to update.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/setNativeProps\n */\nexport let setNativeProps: <T extends Component>(\n animatedRef: AnimatedRef<T>,\n updates: StyleProps\n) => void;\n\nfunction setNativePropsFabric<T extends Component>(\n animatedRef: AnimatedRef<T>,\n updates: StyleProps\n) {\n 'worklet';\n if (!_WORKLET) {\n console.warn(\n '[Reanimated] setNativeProps() can only be used on the UI runtime.'\n );\n return;\n }\n const shadowNodeWrapper = (animatedRef as any)() as ShadowNodeWrapper;\n processColorsInProps(updates);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n _updatePropsFabric!([{ shadowNodeWrapper, updates }]);\n}\n\nfunction setNativePropsPaper<T extends Component>(\n animatedRef: AnimatedRef<T>,\n updates: StyleProps\n) {\n 'worklet';\n if (!_WORKLET) {\n console.warn(\n '[Reanimated] setNativeProps() can only be used on the UI runtime.'\n );\n return;\n }\n const tag = (animatedRef as any)() as number;\n const name = (animatedRef as any).viewName.value;\n processColorsInProps(updates);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n _updatePropsPaper!([{ tag, name, updates }]);\n}\n\nfunction setNativePropsJest() {\n console.warn('[Reanimated] setNativeProps() is not supported with Jest.');\n}\n\nfunction setNativePropsChromeDebugger() {\n console.warn(\n '[Reanimated] setNativeProps() is not supported with Chrome Debugger.'\n );\n}\n\nfunction setNativePropsDefault() {\n console.warn(\n '[Reanimated] setNativeProps() is not supported on this configuration.'\n );\n}\n\nif (!shouldBeUseWeb()) {\n if (isFabric()) {\n setNativeProps = setNativePropsFabric;\n } else {\n setNativeProps = setNativePropsPaper;\n }\n} else if (isJest()) {\n setNativeProps = setNativePropsJest;\n} else if (isChromeDebugger()) {\n setNativeProps = setNativePropsChromeDebugger;\n} else {\n setNativeProps = setNativePropsDefault;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SACEA,gBAAgB,EAChBC,QAAQ,EACRC,MAAM,EACNC,cAAc,QACT,oBAAoB;AAG3B,SAASC,oBAAoB,QAAQ,WAAW;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAIC,cAGF;AAET,SAASC,oBAAoBA,CAC3BC,WAA2B,EAC3BC,OAAmB,EACnB;EACA,SAAS;;EACT,IAAI,CAACC,QAAQ,EAAE;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 @@ import NativeReanimatedModule from './NativeReanimated';
|
|
|
5
5
|
import { shouldBeUseWeb } from './PlatformChecker';
|
|
6
6
|
import { makeShareableCloneOnUIRecursive, makeShareableCloneRecursive } from './shareables';
|
|
7
7
|
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
|
8
|
+
/**
|
|
9
|
+
* Lets you create a new JS runtime which can be used to run worklets possibly on different threads than JS or UI thread.
|
|
10
|
+
*
|
|
11
|
+
* @param name - A name used to identify the runtime which will appear in devices list in Chrome DevTools.
|
|
12
|
+
* @param initializer - An optional worklet that will be run synchronously on the same thread immediately after the runtime is created.
|
|
13
|
+
* @returns WorkletRuntime which is a jsi::HostObject\<reanimated::WorkletRuntime\> - {@link WorkletRuntime}
|
|
14
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/threading/createWorkletRuntime
|
|
15
|
+
*/
|
|
8
16
|
export function createWorkletRuntime(name, initializer) {
|
|
9
17
|
return NativeReanimatedModule.createWorkletRuntime(name, makeShareableCloneRecursive(() => {
|
|
10
18
|
'worklet';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["setupCallGuard","setupConsole","NativeReanimatedModule","shouldBeUseWeb","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","SHOULD_BE_USE_WEB","createWorkletRuntime","name","initializer","runOnRuntime","workletRuntime","worklet","__DEV__","__workletHash","undefined","Error","_WORKLET","_len","arguments","length","args","Array","_key","_scheduleOnRuntime","_len2","_key2","scheduleOnRuntime"],"sources":["runtimes.ts"],"sourcesContent":["'use strict';\nimport type { __ComplexWorkletFunction, WorkletFunction } from './commonTypes';\nimport { setupCallGuard, setupConsole } from './initializers';\nimport NativeReanimatedModule from './NativeReanimated';\nimport { shouldBeUseWeb } from './PlatformChecker';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n} from './shareables';\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\nexport type WorkletRuntime = {\n __hostObjectWorkletRuntime: never;\n readonly name: string;\n};\n\nexport function createWorkletRuntime(\n name: string,\n initializer?: __ComplexWorkletFunction<[], void>\n) {\n return NativeReanimatedModule.createWorkletRuntime(\n name,\n makeShareableCloneRecursive(() => {\n 'worklet';\n setupCallGuard();\n setupConsole();\n initializer?.();\n })\n );\n}\n\n// @ts-expect-error Check `runOnUI` overload.\nexport function runOnRuntime<Args extends unknown[], ReturnValue>(\n workletRuntime: WorkletRuntime,\n worklet: (...args: Args) => ReturnValue\n): WorkletFunction<Args, ReturnValue>;\n/**\n * Schedule a worklet to execute on the background queue.\n */\nexport function runOnRuntime<Args extends unknown[], ReturnValue>(\n workletRuntime: WorkletRuntime,\n worklet: WorkletFunction<Args, ReturnValue>\n): (...args: Args) => void {\n 'worklet';\n if (__DEV__ && !SHOULD_BE_USE_WEB && worklet.__workletHash === undefined) {\n throw new Error(\n '[Reanimated] The function passed to `runOnRuntime` is not a worklet.' +\n (_WORKLET\n ? ' Please make sure that `processNestedWorklets` option in Reanimated Babel plugin is enabled.'\n : '')\n );\n }\n if (_WORKLET) {\n return (...args) =>\n _scheduleOnRuntime(\n workletRuntime,\n makeShareableCloneOnUIRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n }\n return (...args) =>\n NativeReanimatedModule.scheduleOnRuntime(\n workletRuntime,\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,cAAc,EAAEC,YAAY,QAAQ,gBAAgB;AAC7D,OAAOC,sBAAsB,MAAM,oBAAoB;AACvD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SACEC,+BAA+B,EAC/BC,2BAA2B,QACtB,cAAc;AAErB,MAAMC,iBAAiB,GAAGH,cAAc,EAAE;AAO1C,OAAO,SAASI,oBAAoBA,CAClCC,IAAY,EACZC,WAAgD,EAChD;EACA,OAAOP,sBAAsB,CAACK,oBAAoB,CAChDC,IAAI,EACJH,2BAA2B,CAAC,MAAM;IAChC,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Recursive","makeShareableCloneRecursive","SHOULD_BE_USE_WEB","createWorkletRuntime","name","initializer","runOnRuntime","workletRuntime","worklet","__DEV__","__workletHash","undefined","Error","_WORKLET","_len","arguments","length","args","Array","_key","_scheduleOnRuntime","_len2","_key2","scheduleOnRuntime"],"sources":["runtimes.ts"],"sourcesContent":["'use strict';\nimport type { __ComplexWorkletFunction, WorkletFunction } from './commonTypes';\nimport { setupCallGuard, setupConsole } from './initializers';\nimport NativeReanimatedModule from './NativeReanimated';\nimport { shouldBeUseWeb } from './PlatformChecker';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n} from './shareables';\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\nexport type WorkletRuntime = {\n __hostObjectWorkletRuntime: never;\n readonly name: string;\n};\n\n/**\n * Lets you create a new JS runtime which can be used to run worklets possibly on different threads than JS or UI thread.\n *\n * @param name - A name used to identify the runtime which will appear in devices list in Chrome DevTools.\n * @param initializer - An optional worklet that will be run synchronously on the same thread immediately after the runtime is created.\n * @returns WorkletRuntime which is a jsi::HostObject\\<reanimated::WorkletRuntime\\> - {@link WorkletRuntime}\n * @see https://docs.swmansion.com/react-native-reanimated/docs/threading/createWorkletRuntime\n */\nexport function createWorkletRuntime(\n name: string,\n initializer?: __ComplexWorkletFunction<[], void>\n) {\n return NativeReanimatedModule.createWorkletRuntime(\n name,\n makeShareableCloneRecursive(() => {\n 'worklet';\n setupCallGuard();\n setupConsole();\n initializer?.();\n })\n );\n}\n\n// @ts-expect-error Check `runOnUI` overload.\nexport function runOnRuntime<Args extends unknown[], ReturnValue>(\n workletRuntime: WorkletRuntime,\n worklet: (...args: Args) => ReturnValue\n): WorkletFunction<Args, ReturnValue>;\n/**\n * Schedule a worklet to execute on the background queue.\n */\nexport function runOnRuntime<Args extends unknown[], ReturnValue>(\n workletRuntime: WorkletRuntime,\n worklet: WorkletFunction<Args, ReturnValue>\n): (...args: Args) => void {\n 'worklet';\n if (__DEV__ && !SHOULD_BE_USE_WEB && worklet.__workletHash === undefined) {\n throw new Error(\n '[Reanimated] The function passed to `runOnRuntime` is not a worklet.' +\n (_WORKLET\n ? ' Please make sure that `processNestedWorklets` option in Reanimated Babel plugin is enabled.'\n : '')\n );\n }\n if (_WORKLET) {\n return (...args) =>\n _scheduleOnRuntime(\n workletRuntime,\n makeShareableCloneOnUIRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n }\n return (...args) =>\n NativeReanimatedModule.scheduleOnRuntime(\n workletRuntime,\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,cAAc,EAAEC,YAAY,QAAQ,gBAAgB;AAC7D,OAAOC,sBAAsB,MAAM,oBAAoB;AACvD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SACEC,+BAA+B,EAC/BC,2BAA2B,QACtB,cAAc;AAErB,MAAMC,iBAAiB,GAAGH,cAAc,EAAE;AAO1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,oBAAoBA,CAClCC,IAAY,EACZC,WAAgD,EAChD;EACA,OAAOP,sBAAsB,CAACK,oBAAoB,CAChDC,IAAI,EACJH,2BAA2B,CAAC,MAAM;IAChC,SAAS;;IACTL,cAAc,EAAE;IAChBC,YAAY,EAAE;IACdQ,WAAW,aAAXA,WAAW,uBAAXA,WAAW,EAAI;EACjB,CAAC,CAAC,CACH;AACH;;AAEA;;AAKA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAC1BC,cAA8B,EAC9BC,OAA2C,EAClB;EACzB,SAAS;;EACT,IAAIC,OAAO,IAAI,CAACP,iBAAiB,IAAIM,OAAO,CAACE,aAAa,KAAKC,SAAS,EAAE;IACxE,MAAM,IAAIC,KAAK,CACb,sEAAsE,IACnEC,QAAQ,GACL,8FAA8F,GAC9F,EAAE,CAAC,CACV;EACH;EACA,IAAIA,QAAQ,EAAE;IACZ,OAAO;MAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAIC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;QAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;MAAA;MAAA,OACbC,kBAAkB,CAChBb,cAAc,EACdP,+BAA+B,CAAC,MAAM;QACpC,SAAS;;QACTQ,OAAO,CAAC,GAAGS,IAAI,CAAC;MAClB,CAAC,CAAC,CACH;IAAA;EACL;EACA,OAAO;IAAA,SAAAI,KAAA,GAAAN,SAAA,CAAAC,MAAA,EAAIC,IAAI,OAAAC,KAAA,CAAAG,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;MAAJL,IAAI,CAAAK,KAAA,IAAAP,SAAA,CAAAO,KAAA;IAAA;IAAA,OACbxB,sBAAsB,CAACyB,iBAAiB,CACtChB,cAAc,EACdN,2BAA2B,CAAC,MAAM;MAChC,SAAS;;MACTO,OAAO,CAAC,GAAGS,IAAI,CAAC;IAClB,CAAC,CAAC,CACH;EAAA;AACL"}
|
|
@@ -44,13 +44,19 @@ export const callMicrotasks = SHOULD_BE_USE_WEB ? () => {
|
|
|
44
44
|
// on web flushing is a noop as immediates are handled by the browser
|
|
45
45
|
} : callMicrotasksOnUIThread;
|
|
46
46
|
|
|
47
|
-
// @ts-expect-error This overload is correct since it's what user sees in his code
|
|
48
|
-
// before it's transformed by Reanimated Babel plugin.
|
|
49
47
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* Lets you asynchronously run [workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize) functions on the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).
|
|
49
|
+
*
|
|
50
|
+
* This method does not schedule the work immediately but instead waits for other worklets
|
|
51
|
+
* to be scheduled within the same JS loop. It uses queueMicrotask to schedule all the worklets
|
|
52
52
|
* at once making sure they will run within the same frame boundaries on the UI thread.
|
|
53
|
+
*
|
|
54
|
+
* @param fun - A reference to a function you want to execute on the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI) from the [JavaScript thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).
|
|
55
|
+
* @returns A function that accepts arguments for the function passed as the first argument.
|
|
56
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI
|
|
53
57
|
*/
|
|
58
|
+
// @ts-expect-error This overload is correct since it's what user sees in his code
|
|
59
|
+
// before it's transformed by Reanimated Babel plugin.
|
|
54
60
|
export function runOnUI(worklet) {
|
|
55
61
|
'worklet';
|
|
56
62
|
|
|
@@ -144,8 +150,12 @@ function runWorkletOnJS(worklet) {
|
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
153
|
+
* Lets you asynchronously run non-[workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize) functions that couldn't otherwise run on the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#ui-thread).
|
|
154
|
+
* This applies to most external libraries as they don't have their functions marked with "worklet"; directive.
|
|
155
|
+
*
|
|
156
|
+
* @param fun - A reference to a function you want to execute on the JavaScript thread from the UI thread.
|
|
157
|
+
* @returns A function that accepts arguments for the function passed as the first argument.
|
|
158
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnJS
|
|
149
159
|
*/
|
|
150
160
|
export function runOnJS(fun) {
|
|
151
161
|
'worklet';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeReanimatedModule","isJest","shouldBeUseWeb","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","IS_JEST","SHOULD_BE_USE_WEB","_runOnUIQueue","setupMicrotasks","microtasksQueue","isExecutingMicrotasksQueue","global","queueMicrotask","callback","push","__callMicrotasks","index","length","_maybeFlushUIUpdatesQueue","callMicrotasksOnUIThread","callMicrotasks","runOnUI","worklet","__DEV__","_WORKLET","Error","__workletHash","undefined","_len","arguments","args","Array","_key","scheduleOnUI","queue","forEach","_ref","runOnUIImmediately","_len2","_key2","runWorkletOnJS","_len3","_key3","runOnJS","fun","_len4","_key4","_len5","_key5","__remoteFunction","_len6","_key6","_scheduleOnJS"],"sources":["threads.ts"],"sourcesContent":["'use strict';\nimport NativeReanimatedModule from './NativeReanimated';\nimport { isJest, shouldBeUseWeb } from './PlatformChecker';\nimport type { WorkletFunction } from './commonTypes';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n} from './shareables';\n\nconst IS_JEST = isJest();\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\n/**\n * An array of [worklet, args] pairs.\n * */\nlet _runOnUIQueue: Array<[WorkletFunction<unknown[], unknown>, unknown[]]> = [];\n\nexport function setupMicrotasks() {\n 'worklet';\n\n let microtasksQueue: Array<() => void> = [];\n let isExecutingMicrotasksQueue = false;\n global.queueMicrotask = (callback: () => void) => {\n microtasksQueue.push(callback);\n };\n\n global.__callMicrotasks = () => {\n if (isExecutingMicrotasksQueue) {\n return;\n }\n try {\n isExecutingMicrotasksQueue = true;\n for (let index = 0; index < microtasksQueue.length; index += 1) {\n // we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to queueMicrotask calls\n microtasksQueue[index]();\n }\n microtasksQueue = [];\n global._maybeFlushUIUpdatesQueue();\n } finally {\n isExecutingMicrotasksQueue = false;\n }\n };\n}\n\nfunction callMicrotasksOnUIThread() {\n 'worklet';\n global.__callMicrotasks();\n}\n\nexport const callMicrotasks = SHOULD_BE_USE_WEB\n ? () => {\n // on web flushing is a noop as immediates are handled by the browser\n }\n : callMicrotasksOnUIThread;\n\n// @ts-expect-error This overload is correct since it's what user sees in his code\n// before it's transformed by Reanimated Babel plugin.\nexport function runOnUI<Args extends unknown[], ReturnValue>(\n worklet: (...args: Args) => ReturnValue\n): (...args: Args) => void;\n/**\n * Schedule a worklet to execute on the UI runtime. This method does not schedule the work immediately but instead\n * waits for other worklets to be scheduled within the same JS loop. It uses queueMicrotask to schedule all the worklets\n * at once making sure they will run within the same frame boundaries on the UI thread.\n */\nexport function runOnUI<Args extends unknown[], ReturnValue>(\n worklet: WorkletFunction<Args, ReturnValue>\n): (...args: Args) => void {\n 'worklet';\n if (__DEV__ && !SHOULD_BE_USE_WEB && _WORKLET) {\n throw new Error(\n '[Reanimated] `runOnUI` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.'\n );\n }\n if (__DEV__ && !SHOULD_BE_USE_WEB && worklet.__workletHash === undefined) {\n throw new Error('[Reanimated] `runOnUI` can only be used on worklets.');\n }\n return (...args) => {\n if (IS_JEST) {\n // Mocking time in Jest is tricky as both requestAnimationFrame and queueMicrotask\n // callbacks run on the same queue and can be interleaved. There is no way\n // to flush particular queue in Jest and the only control over mocked timers\n // is by using jest.advanceTimersByTime() method which advances all types\n // of timers including immediate and animation callbacks. Ideally we'd like\n // to have some way here to schedule work along with React updates, but\n // that's not possible, and hence in Jest environment instead of using scheduling\n // mechanism we just schedule the work ommiting the queue. This is ok for the\n // uses that we currently have but may not be ok for future tests that we write.\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n return;\n }\n if (__DEV__) {\n // in DEV mode we call shareable conversion here because in case the object\n // can't be converted, we will get a meaningful stack-trace as opposed to the\n // situation when conversion is only done via microtask queue. This does not\n // make the app particularily less efficient as converted objects are cached\n // and for a given worklet the conversion only happens once.\n makeShareableCloneRecursive(worklet);\n makeShareableCloneRecursive(args);\n }\n //\n _runOnUIQueue.push([worklet as WorkletFunction<unknown[], unknown>, args]);\n if (_runOnUIQueue.length === 1) {\n queueMicrotask(() => {\n const queue = _runOnUIQueue;\n _runOnUIQueue = [];\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n queue.forEach(([worklet, args]) => {\n worklet(...args);\n });\n callMicrotasks();\n })\n );\n });\n }\n };\n}\n\n// @ts-expect-error Check `runOnUI` overload above.\nexport function runOnUIImmediately<Args extends unknown[], ReturnValue>(\n worklet: (...args: Args) => ReturnValue\n): WorkletFunction<Args, ReturnValue>;\n/**\n * Schedule a worklet to execute on the UI runtime skipping batching mechanism.\n */\nexport function runOnUIImmediately<Args extends unknown[], ReturnValue>(\n worklet: WorkletFunction<Args, ReturnValue>\n): (...args: Args) => void {\n 'worklet';\n if (__DEV__ && !SHOULD_BE_USE_WEB && _WORKLET) {\n throw new Error(\n '[Reanimated] `runOnUIImmediately` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.'\n );\n }\n if (__DEV__ && !SHOULD_BE_USE_WEB && worklet.__workletHash === undefined) {\n throw new Error(\n '[Reanimated] `runOnUIImmediately` can only be used on worklets.'\n );\n }\n return (...args) => {\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n };\n}\n\ntype ReleaseRemoteFunction<Args extends unknown[], ReturnValue> = {\n (...args: Args): ReturnValue;\n};\n\ntype DevRemoteFunction<Args extends unknown[], ReturnValue> = {\n __remoteFunction: (...args: Args) => ReturnValue;\n};\n\ntype RemoteFunction<Args extends unknown[], ReturnValue> =\n | ReleaseRemoteFunction<Args, ReturnValue>\n | DevRemoteFunction<Args, ReturnValue>;\n\nfunction runWorkletOnJS<Args extends unknown[], ReturnValue>(\n worklet: WorkletFunction<Args, ReturnValue>,\n ...args: Args\n): void {\n // remote function that calls a worklet synchronously on the JS runtime\n worklet(...args);\n}\n\n/**\n * Returns a function that can be called to be executed asynchronously on both\n * UI and JS threads.\n */\nexport function runOnJS<Args extends unknown[], ReturnValue>(\n fun:\n | ((...args: Args) => ReturnValue)\n | RemoteFunction<Args, ReturnValue>\n | WorkletFunction<Args, ReturnValue>\n): (...args: Args) => void {\n 'worklet';\n type FunWorklet = Extract<typeof fun, WorkletFunction<Args, ReturnValue>>;\n type FunDevRemote = Extract<typeof fun, DevRemoteFunction<Args, ReturnValue>>;\n if (SHOULD_BE_USE_WEB || !_WORKLET) {\n // if we are already on the JS thread, we just schedule the worklet on the JS queue\n return (...args) =>\n queueMicrotask(\n args.length\n ? () => (fun as (...args: Args) => ReturnValue)(...args)\n : (fun as () => ReturnValue)\n );\n }\n if ((fun as FunWorklet).__workletHash) {\n // If `fun` is a worklet, we schedule a call of a remote function `runWorkletOnJS`\n // and pass the worklet as a first argument followed by original arguments.\n\n return (...args) =>\n runOnJS(runWorkletOnJS<Args, ReturnValue>)(\n fun as WorkletFunction<Args, ReturnValue>,\n ...args\n );\n }\n if ((fun as FunDevRemote).__remoteFunction) {\n // In development mode the function provided as `fun` throws an error message\n // such that when someone accidentally calls it directly on the UI runtime, they\n // see that they should use `runOnJS` instead. To facilitate that we put the\n // reference to the original remote function in the `__functionInDEV` property.\n fun = (fun as FunDevRemote).__remoteFunction;\n }\n return (...args) => {\n _scheduleOnJS(\n fun as\n | ((...args: Args) => ReturnValue)\n | WorkletFunction<Args, ReturnValue>,\n args.length > 0\n ? // TODO TYPESCRIPT this cast is terrible but will be fixed\n (makeShareableCloneOnUIRecursive(args) as unknown as unknown[])\n : undefined\n );\n };\n}\n"],"mappings":"AAAA,YAAY;;AACZ,OAAOA,sBAAsB,MAAM,oBAAoB;AACvD,SAASC,MAAM,EAAEC,cAAc,QAAQ,mBAAmB;AAE1D,SACEC,+BAA+B,EAC/BC,2BAA2B,QACtB,cAAc;AAErB,MAAMC,OAAO,GAAGJ,MAAM,EAAE;AACxB,MAAMK,iBAAiB,GAAGJ,cAAc,EAAE;;AAE1C;AACA;AACA;AACA,IAAIK,aAAsE,GAAG,EAAE;AAE/E,OAAO,SAASC,eAAeA,CAAA,EAAG;EAChC,SAAS;;EAET,IAAIC,eAAkC,GAAG,EAAE;EAC3C,IAAIC,0BAA0B,GAAG,KAAK;EACtCC,MAAM,CAAC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CAAAgB,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;QAAJlB,IAAI,CAAAkB,KAAA,IAAAnB,SAAA,CAAAmB,KAAA;MAAA;MAAA,OACbL,OAAO,CAACH,cAAc,CAAoB,CACxCI,GAAG,EACH,GAAGd,IAAI,CACR;IAAA;EACL;EACA,IAAKc,GAAG,CAAkBK,gBAAgB,EAAE;IAC1C;IACA;IACA;IACA;IACAL,GAAG,GAAIA,GAAG,CAAkBK,gBAAgB;EAC9C;EACA,OAAO,YAAa;IAAA,SAAAC,KAAA,GAAArB,SAAA,CAAAZ,MAAA,EAATa,IAAI,OAAAC,KAAA,CAAAmB,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;MAAJrB,IAAI,CAAAqB,KAAA,IAAAtB,SAAA,CAAAsB,KAAA;IAAA;IACbC,aAAa,CACXR,GAAG,EAGHd,IAAI,CAACb,MAAM,GAAG,CAAC;IACX;IACCd,+BAA+B,CAAC2B,IAAI,CAAC,GACtCH,SAAS,CACd;EACH,CAAC;AACH"}
|
|
1
|
+
{"version":3,"names":["NativeReanimatedModule","isJest","shouldBeUseWeb","makeShareableCloneOnUIRecursive","makeShareableCloneRecursive","IS_JEST","SHOULD_BE_USE_WEB","_runOnUIQueue","setupMicrotasks","microtasksQueue","isExecutingMicrotasksQueue","global","queueMicrotask","callback","push","__callMicrotasks","index","length","_maybeFlushUIUpdatesQueue","callMicrotasksOnUIThread","callMicrotasks","runOnUI","worklet","__DEV__","_WORKLET","Error","__workletHash","undefined","_len","arguments","args","Array","_key","scheduleOnUI","queue","forEach","_ref","runOnUIImmediately","_len2","_key2","runWorkletOnJS","_len3","_key3","runOnJS","fun","_len4","_key4","_len5","_key5","__remoteFunction","_len6","_key6","_scheduleOnJS"],"sources":["threads.ts"],"sourcesContent":["'use strict';\nimport NativeReanimatedModule from './NativeReanimated';\nimport { isJest, shouldBeUseWeb } from './PlatformChecker';\nimport type { WorkletFunction } from './commonTypes';\nimport {\n makeShareableCloneOnUIRecursive,\n makeShareableCloneRecursive,\n} from './shareables';\n\nconst IS_JEST = isJest();\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\n/**\n * An array of [worklet, args] pairs.\n * */\nlet _runOnUIQueue: Array<[WorkletFunction<unknown[], unknown>, unknown[]]> = [];\n\nexport function setupMicrotasks() {\n 'worklet';\n\n let microtasksQueue: Array<() => void> = [];\n let isExecutingMicrotasksQueue = false;\n global.queueMicrotask = (callback: () => void) => {\n microtasksQueue.push(callback);\n };\n\n global.__callMicrotasks = () => {\n if (isExecutingMicrotasksQueue) {\n return;\n }\n try {\n isExecutingMicrotasksQueue = true;\n for (let index = 0; index < microtasksQueue.length; index += 1) {\n // we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to queueMicrotask calls\n microtasksQueue[index]();\n }\n microtasksQueue = [];\n global._maybeFlushUIUpdatesQueue();\n } finally {\n isExecutingMicrotasksQueue = false;\n }\n };\n}\n\nfunction callMicrotasksOnUIThread() {\n 'worklet';\n global.__callMicrotasks();\n}\n\nexport const callMicrotasks = SHOULD_BE_USE_WEB\n ? () => {\n // on web flushing is a noop as immediates are handled by the browser\n }\n : callMicrotasksOnUIThread;\n\n/**\n * Lets you asynchronously run [workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize) functions on the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).\n *\n * This method does not schedule the work immediately but instead waits for other worklets\n * to be scheduled within the same JS loop. It uses queueMicrotask to schedule all the worklets\n * at once making sure they will run within the same frame boundaries on the UI thread.\n *\n * @param fun - A reference to a function you want to execute on the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI) from the [JavaScript thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).\n * @returns A function that accepts arguments for the function passed as the first argument.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI\n */\n// @ts-expect-error This overload is correct since it's what user sees in his code\n// before it's transformed by Reanimated Babel plugin.\nexport function runOnUI<Args extends unknown[], ReturnValue>(\n worklet: (...args: Args) => ReturnValue\n): (...args: Args) => void;\n\nexport function runOnUI<Args extends unknown[], ReturnValue>(\n worklet: WorkletFunction<Args, ReturnValue>\n): (...args: Args) => void {\n 'worklet';\n if (__DEV__ && !SHOULD_BE_USE_WEB && _WORKLET) {\n throw new Error(\n '[Reanimated] `runOnUI` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.'\n );\n }\n if (__DEV__ && !SHOULD_BE_USE_WEB && worklet.__workletHash === undefined) {\n throw new Error('[Reanimated] `runOnUI` can only be used on worklets.');\n }\n return (...args) => {\n if (IS_JEST) {\n // Mocking time in Jest is tricky as both requestAnimationFrame and queueMicrotask\n // callbacks run on the same queue and can be interleaved. There is no way\n // to flush particular queue in Jest and the only control over mocked timers\n // is by using jest.advanceTimersByTime() method which advances all types\n // of timers including immediate and animation callbacks. Ideally we'd like\n // to have some way here to schedule work along with React updates, but\n // that's not possible, and hence in Jest environment instead of using scheduling\n // mechanism we just schedule the work ommiting the queue. This is ok for the\n // uses that we currently have but may not be ok for future tests that we write.\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n return;\n }\n if (__DEV__) {\n // in DEV mode we call shareable conversion here because in case the object\n // can't be converted, we will get a meaningful stack-trace as opposed to the\n // situation when conversion is only done via microtask queue. This does not\n // make the app particularily less efficient as converted objects are cached\n // and for a given worklet the conversion only happens once.\n makeShareableCloneRecursive(worklet);\n makeShareableCloneRecursive(args);\n }\n //\n _runOnUIQueue.push([worklet as WorkletFunction<unknown[], unknown>, args]);\n if (_runOnUIQueue.length === 1) {\n queueMicrotask(() => {\n const queue = _runOnUIQueue;\n _runOnUIQueue = [];\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n queue.forEach(([worklet, args]) => {\n worklet(...args);\n });\n callMicrotasks();\n })\n );\n });\n }\n };\n}\n\n// @ts-expect-error Check `runOnUI` overload above.\nexport function runOnUIImmediately<Args extends unknown[], ReturnValue>(\n worklet: (...args: Args) => ReturnValue\n): WorkletFunction<Args, ReturnValue>;\n/**\n * Schedule a worklet to execute on the UI runtime skipping batching mechanism.\n */\nexport function runOnUIImmediately<Args extends unknown[], ReturnValue>(\n worklet: WorkletFunction<Args, ReturnValue>\n): (...args: Args) => void {\n 'worklet';\n if (__DEV__ && !SHOULD_BE_USE_WEB && _WORKLET) {\n throw new Error(\n '[Reanimated] `runOnUIImmediately` cannot be called on the UI runtime. Please call the function synchronously or use `queueMicrotask` or `requestAnimationFrame` instead.'\n );\n }\n if (__DEV__ && !SHOULD_BE_USE_WEB && worklet.__workletHash === undefined) {\n throw new Error(\n '[Reanimated] `runOnUIImmediately` can only be used on worklets.'\n );\n }\n return (...args) => {\n NativeReanimatedModule.scheduleOnUI(\n makeShareableCloneRecursive(() => {\n 'worklet';\n worklet(...args);\n })\n );\n };\n}\n\ntype ReleaseRemoteFunction<Args extends unknown[], ReturnValue> = {\n (...args: Args): ReturnValue;\n};\n\ntype DevRemoteFunction<Args extends unknown[], ReturnValue> = {\n __remoteFunction: (...args: Args) => ReturnValue;\n};\n\ntype RemoteFunction<Args extends unknown[], ReturnValue> =\n | ReleaseRemoteFunction<Args, ReturnValue>\n | DevRemoteFunction<Args, ReturnValue>;\n\nfunction runWorkletOnJS<Args extends unknown[], ReturnValue>(\n worklet: WorkletFunction<Args, ReturnValue>,\n ...args: Args\n): void {\n // remote function that calls a worklet synchronously on the JS runtime\n worklet(...args);\n}\n\n/**\n * Lets you asynchronously run non-[workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize) functions that couldn't otherwise run on the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#ui-thread).\n * This applies to most external libraries as they don't have their functions marked with \"worklet\"; directive.\n *\n * @param fun - A reference to a function you want to execute on the JavaScript thread from the UI thread.\n * @returns A function that accepts arguments for the function passed as the first argument.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnJS\n */\nexport function runOnJS<Args extends unknown[], ReturnValue>(\n fun:\n | ((...args: Args) => ReturnValue)\n | RemoteFunction<Args, ReturnValue>\n | WorkletFunction<Args, ReturnValue>\n): (...args: Args) => void {\n 'worklet';\n type FunWorklet = Extract<typeof fun, WorkletFunction<Args, ReturnValue>>;\n type FunDevRemote = Extract<typeof fun, DevRemoteFunction<Args, ReturnValue>>;\n if (SHOULD_BE_USE_WEB || !_WORKLET) {\n // if we are already on the JS thread, we just schedule the worklet on the JS queue\n return (...args) =>\n queueMicrotask(\n args.length\n ? () => (fun as (...args: Args) => ReturnValue)(...args)\n : (fun as () => ReturnValue)\n );\n }\n if ((fun as FunWorklet).__workletHash) {\n // If `fun` is a worklet, we schedule a call of a remote function `runWorkletOnJS`\n // and pass the worklet as a first argument followed by original arguments.\n\n return (...args) =>\n runOnJS(runWorkletOnJS<Args, ReturnValue>)(\n fun as WorkletFunction<Args, ReturnValue>,\n ...args\n );\n }\n if ((fun as FunDevRemote).__remoteFunction) {\n // In development mode the function provided as `fun` throws an error message\n // such that when someone accidentally calls it directly on the UI runtime, they\n // see that they should use `runOnJS` instead. To facilitate that we put the\n // reference to the original remote function in the `__functionInDEV` property.\n fun = (fun as FunDevRemote).__remoteFunction;\n }\n return (...args) => {\n _scheduleOnJS(\n fun as\n | ((...args: Args) => ReturnValue)\n | WorkletFunction<Args, ReturnValue>,\n args.length > 0\n ? // TODO TYPESCRIPT this cast is terrible but will be fixed\n (makeShareableCloneOnUIRecursive(args) as unknown as unknown[])\n : undefined\n );\n };\n}\n"],"mappings":"AAAA,YAAY;;AACZ,OAAOA,sBAAsB,MAAM,oBAAoB;AACvD,SAASC,MAAM,EAAEC,cAAc,QAAQ,mBAAmB;AAE1D,SACEC,+BAA+B,EAC/BC,2BAA2B,QACtB,cAAc;AAErB,MAA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B,KAAA,IAAAjB,SAAA,CAAAiB,KAAA;MAAA;MAAA,OACblC,cAAc,CACZkB,IAAI,CAACb,MAAM,GACP,MAAO2B,GAAG,CAAoC,GAAGd,IAAI,CAAC,GACrDc,GAAyB,CAC/B;IAAA;EACL;EACA,IAAKA,GAAG,CAAgBlB,aAAa,EAAE;IACrC;IACA;;IAEA,OAAO;MAAA,SAAAqB,KAAA,GAAAlB,SAAA,CAAAZ,MAAA,EAAIa,IAAI,OAAAC,KAAA,CAAAgB,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;QAAJlB,IAAI,CAAAkB,KAAA,IAAAnB,SAAA,CAAAmB,KAAA;MAAA;MAAA,OACbL,OAAO,CAACH,cAAc,CAAoB,CACxCI,GAAG,EACH,GAAGd,IAAI,CACR;IAAA;EACL;EACA,IAAKc,GAAG,CAAkBK,gBAAgB,EAAE;IAC1C;IACA;IACA;IACA;IACAL,GAAG,GAAIA,GAAG,CAAkBK,gBAAgB;EAC9C;EACA,OAAO,YAAa;IAAA,SAAAC,KAAA,GAAArB,SAAA,CAAAZ,MAAA,EAATa,IAAI,OAAAC,KAAA,CAAAmB,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;MAAJrB,IAAI,CAAAqB,KAAA,IAAAtB,SAAA,CAAAsB,KAAA;IAAA;IACbC,aAAa,CACXR,GAAG,EAGHd,IAAI,CAACb,MAAM,GAAG,CAAC;IACX;IACCd,+BAA+B,CAAC2B,IAAI,CAAC,GACtCH,SAAS,CACd;EACH,CAAC;AACH"}
|
|
@@ -2,9 +2,21 @@ import type { ComponentClass, FunctionComponent } from 'react';
|
|
|
2
2
|
import '../reanimated2/layoutReanimation/animationsManager';
|
|
3
3
|
import type { AnimateProps } from '../reanimated2';
|
|
4
4
|
import type { AnimatedComponentRef } from './commonTypes';
|
|
5
|
+
import type { FlatList, FlatListProps } from 'react-native';
|
|
5
6
|
type Options<P> = {
|
|
6
7
|
setNativeProps: (ref: AnimatedComponentRef, props: P) => void;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Lets you create an Animated version of any React Native component.
|
|
11
|
+
*
|
|
12
|
+
* @param component - The component you want to make animatable.
|
|
13
|
+
* @returns A component that Reanimated is capable of animating.
|
|
14
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/core/createAnimatedComponent
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Please use `Animated.FlatList` component instead of calling `Animated.createAnimatedComponent(FlatList)` manually.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createAnimatedComponent(component: typeof FlatList<unknown>, options?: Options<any>): ComponentClass<AnimateProps<FlatListProps<unknown>>>;
|
|
8
20
|
export declare function createAnimatedComponent<P extends object>(component: FunctionComponent<P>, options?: Options<P>): FunctionComponent<AnimateProps<P>>;
|
|
9
21
|
export declare function createAnimatedComponent<P extends object>(component: ComponentClass<P>, options?: Options<P>): ComponentClass<AnimateProps<P>>;
|
|
10
22
|
export {};
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
*/
|
|
46
46
|
export type EasingFunction = (t: number) => number;
|
|
47
47
|
/**
|
|
48
|
-
* @deprecated Please use
|
|
48
|
+
* @deprecated Please use {@link EasingFunction} type instead.
|
|
49
49
|
*/
|
|
50
50
|
export type EasingFn = EasingFunction;
|
|
51
51
|
export type EasingFunctionFactory = {
|
|
52
52
|
factory: () => EasingFunction;
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
|
-
* @deprecated Please use
|
|
55
|
+
* @deprecated Please use {@link EasingFunctionFactory} type instead.
|
|
56
56
|
*/
|
|
57
57
|
export type EasingFactoryFn = EasingFunctionFactory;
|
|
58
58
|
/**
|
|
@@ -113,7 +113,7 @@ declare function exp(t: number): number;
|
|
|
113
113
|
* forth.
|
|
114
114
|
*
|
|
115
115
|
* Default bounciness is 1, which overshoots a little bit once. 0 bounciness
|
|
116
|
-
* doesn't overshoot at all, and bounciness of N
|
|
116
|
+
* doesn't overshoot at all, and bounciness of N \> 1 will overshoot about N
|
|
117
117
|
* times.
|
|
118
118
|
*
|
|
119
119
|
* http://easings.net/#easeInElastic
|
|
@@ -2,5 +2,13 @@ import type { AnimationCallback } from '../../commonTypes';
|
|
|
2
2
|
import type { DecayConfig } from './utils';
|
|
3
3
|
export type WithDecayConfig = DecayConfig;
|
|
4
4
|
type withDecayType = (userConfig: DecayConfig, callback?: AnimationCallback) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Lets you create animations that mimic objects in motion with friction.
|
|
7
|
+
*
|
|
8
|
+
* @param config - The decay animation configuration - {@link DecayConfig}.
|
|
9
|
+
* @param callback - A function called upon animation completion - {@link AnimationCallback}.
|
|
10
|
+
* @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.
|
|
11
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay
|
|
12
|
+
*/
|
|
5
13
|
export declare const withDecay: withDecayType;
|
|
6
14
|
export {};
|
|
@@ -12,6 +12,18 @@ export interface InnerDecayAnimation extends Omit<DecayAnimation, 'current'>, An
|
|
|
12
12
|
current: number;
|
|
13
13
|
springActive?: boolean;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* The decay animation configuration.
|
|
17
|
+
*
|
|
18
|
+
* @param velocity - Initial velocity of the animation. Defaults to 0.
|
|
19
|
+
* @param deceleration - The rate at which the velocity decreases over time. Defaults to 0.998.
|
|
20
|
+
* @param clamp - Array of two numbers which restricts animation's range. Defaults to [].
|
|
21
|
+
* @param velocityFactor - Velocity multiplier. Defaults to 1.
|
|
22
|
+
* @param rubberBandEffect - Makes the animation bounce over the limit specified in `clamp`. Defaults to `false`.
|
|
23
|
+
* @param rubberBandFactor - Strength of the rubber band effect. Defaults to 0.6.
|
|
24
|
+
* @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
|
|
25
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay#config
|
|
26
|
+
*/
|
|
15
27
|
export type DecayConfig = {
|
|
16
28
|
deceleration?: number;
|
|
17
29
|
velocityFactor?: number;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { AnimatableValue, ReduceMotion } from '../commonTypes';
|
|
2
2
|
type withDelayType = <T extends AnimatableValue>(delayMs: number, delayedAnimation: T, reduceMotion?: ReduceMotion) => T;
|
|
3
|
+
/**
|
|
4
|
+
* An animation modifier that lets you start an animation with a delay.
|
|
5
|
+
*
|
|
6
|
+
* @param delayMs - Duration (in milliseconds) before the animation starts.
|
|
7
|
+
* @param nextAnimation - The animation to delay.
|
|
8
|
+
* @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
|
|
9
|
+
* @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.
|
|
10
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDelay
|
|
11
|
+
*/
|
|
3
12
|
export declare const withDelay: withDelayType;
|
|
4
13
|
export {};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { AnimationCallback, AnimatableValue, ReduceMotion } from '../commonTypes';
|
|
2
2
|
type withRepeatType = <T extends AnimatableValue>(animation: T, numberOfReps?: number, reverse?: boolean, callback?: AnimationCallback, reduceMotion?: ReduceMotion) => T;
|
|
3
|
+
/**
|
|
4
|
+
* Lets you repeat an animation given number of times or run it indefinitely.
|
|
5
|
+
*
|
|
6
|
+
* @param animation - An animation object you want to repeat.
|
|
7
|
+
* @param numberOfReps - The number of times the animation is going to be repeated. Defaults to 2.
|
|
8
|
+
* @param reverse - Whether the animation should run in reverse every other repetition. Defaults to false.
|
|
9
|
+
* @param callback - A function called on animation complete.
|
|
10
|
+
* @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
|
|
11
|
+
* @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.
|
|
12
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withRepeat
|
|
13
|
+
*/
|
|
3
14
|
export declare const withRepeat: withRepeatType;
|
|
4
15
|
export {};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { AnimatableValue, ReduceMotion } from '../commonTypes';
|
|
2
|
+
/**
|
|
3
|
+
* Lets you run animations in a sequence.
|
|
4
|
+
*
|
|
5
|
+
* @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
|
|
6
|
+
* @param animations - Any number of animation objects to be run in a sequence.
|
|
7
|
+
* @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation/
|
|
8
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSequence
|
|
9
|
+
*/
|
|
2
10
|
export declare function withSequence<T extends AnimatableValue>(_reduceMotion: ReduceMotion, ...animations: T[]): T;
|
|
3
11
|
export declare function withSequence<T extends AnimatableValue>(...animations: T[]): T;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { AnimationCallback, AnimatableValue } from '../commonTypes';
|
|
2
2
|
import type { SpringConfig } from './springUtils';
|
|
3
3
|
type withSpringType = <T extends AnimatableValue>(toValue: T, userConfig?: SpringConfig, callback?: AnimationCallback) => T;
|
|
4
|
+
/**
|
|
5
|
+
* Lets you create spring-based animations.
|
|
6
|
+
*
|
|
7
|
+
* @param toValue - the value at which the animation will come to rest - {@link AnimatableValue}
|
|
8
|
+
* @param config - the spring animation configuration - {@link SpringConfig}
|
|
9
|
+
* @param callback - a function called on animation complete - {@link AnimationCallback}
|
|
10
|
+
* @returns an [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation
|
|
11
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring
|
|
12
|
+
*/
|
|
4
13
|
export declare const withSpring: withSpringType;
|
|
5
14
|
export {};
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { Animation, AnimatableValue, Timestamp, ReduceMotion } from '../commonTypes';
|
|
2
|
+
/**
|
|
3
|
+
* Spring animation configuration.
|
|
4
|
+
*
|
|
5
|
+
* @param mass - The weight of the spring. Reducing this value makes the animation faster. Defaults to 1.
|
|
6
|
+
* @param damping - How quickly a spring slows down. Higher damping means the spring will come to rest faster. Defaults to 10.
|
|
7
|
+
* @param duration - Length of the animation (in milliseconds). Defaults to 2000.
|
|
8
|
+
* @param dampingRatio - How damped the spring is. Value 1 means the spring is critically damped, and value \>1 means the spring is overdamped. Defaults to 0.5.
|
|
9
|
+
* @param stiffness - How bouncy the spring is. Defaults to 100.
|
|
10
|
+
* @param velocity - Initial velocity applied to the spring equation. Defaults to 0.
|
|
11
|
+
* @param overshootClamping - Whether a spring can bounce over the `toValue`. Defaults to false.
|
|
12
|
+
* @param restDisplacementThreshold - The displacement below which the spring will snap to toValue without further oscillations. Defaults to 0.01.
|
|
13
|
+
* @param restSpeedThreshold - The speed in pixels per second from which the spring will snap to toValue without further oscillations. Defaults to 2.
|
|
14
|
+
* @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
|
|
15
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring/#config-
|
|
16
|
+
*/
|
|
2
17
|
export type SpringConfig = {
|
|
3
18
|
stiffness?: number;
|
|
4
19
|
overshootClamping?: boolean;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { EasingFunction, EasingFunctionFactory } from '../Easing';
|
|
2
2
|
import type { Animation, AnimationCallback, Timestamp, AnimatableValue, ReduceMotion } from '../commonTypes';
|
|
3
|
+
/**
|
|
4
|
+
* The timing animation configuration.
|
|
5
|
+
*
|
|
6
|
+
* @param duration - Length of the animation (in milliseconds). Defaults to 300.
|
|
7
|
+
* @param easing - An easing function which defines the animation curve. Defaults to `Easing.inOut(Easing.quad)`.
|
|
8
|
+
* @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
|
|
9
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming#config-
|
|
10
|
+
*/
|
|
3
11
|
interface TimingConfig {
|
|
4
12
|
duration?: number;
|
|
5
13
|
reduceMotion?: ReduceMotion;
|
|
@@ -16,5 +24,14 @@ export interface TimingAnimation extends Animation<TimingAnimation> {
|
|
|
16
24
|
current: AnimatableValue;
|
|
17
25
|
}
|
|
18
26
|
type withTimingType = <T extends AnimatableValue>(toValue: T, userConfig?: TimingConfig, callback?: AnimationCallback) => T;
|
|
27
|
+
/**
|
|
28
|
+
* Lets you create an animation based on duration and easing.
|
|
29
|
+
*
|
|
30
|
+
* @param toValue - The value on which the animation will come at rest - {@link AnimatableValue}.
|
|
31
|
+
* @param config - The timing animation configuration - {@link TimingConfig}.
|
|
32
|
+
* @param callback - A function called on animation complete - {@link AnimationCallback}.
|
|
33
|
+
* @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.
|
|
34
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming
|
|
35
|
+
*/
|
|
19
36
|
export declare const withTiming: withTimingType;
|
|
20
37
|
export {};
|
|
@@ -21,5 +21,11 @@ export declare function getReduceMotionForAnimation(config?: ReduceMotion): bool
|
|
|
21
21
|
type AnimationToDecoration<T extends AnimationObject | StyleLayoutAnimation, U extends AnimationObject | StyleLayoutAnimation> = T extends StyleLayoutAnimation ? Record<string, unknown> : U | (() => U) | AnimatableValue;
|
|
22
22
|
export declare function defineAnimation<T extends AnimationObject | StyleLayoutAnimation, // type that's supposed to be returned
|
|
23
23
|
U extends AnimationObject | StyleLayoutAnimation = T>(starting: AnimationToDecoration<T, U>, factory: () => T): T;
|
|
24
|
+
/**
|
|
25
|
+
* Lets you cancel a running animation paired to a shared value.
|
|
26
|
+
*
|
|
27
|
+
* @param sharedValue - The shared value of a running animation that you want to cancel.
|
|
28
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/core/cancelAnimation
|
|
29
|
+
*/
|
|
24
30
|
export declare function cancelAnimation<T>(sharedValue: SharedValue<T>): void;
|
|
25
31
|
export {};
|
|
@@ -5,6 +5,11 @@ export interface StyleProps extends ViewStyle, TextStyle {
|
|
|
5
5
|
originY?: number;
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* A value that can be used both on the [JavaScript thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#javascript-thread) and the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#ui-thread).
|
|
10
|
+
*
|
|
11
|
+
* Shared values are defined using [useSharedValue](https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue) hook. You access and modify shared values by their `.value` property.
|
|
12
|
+
*/
|
|
8
13
|
export interface SharedValue<Value> {
|
|
9
14
|
value: Value;
|
|
10
15
|
addListener: (listenerID: number, listener: (value: any) => void) => void;
|
|
@@ -97,6 +102,9 @@ export type AnimatedSensor<T extends Value3D | ValueRotation> = {
|
|
|
97
102
|
isAvailable: boolean;
|
|
98
103
|
config: SensorConfig;
|
|
99
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* A function called upon animation completion. If the animation is cancelled, the callback will receive `false` as the argument; otherwise, it will receive `true`.
|
|
107
|
+
*/
|
|
100
108
|
export type AnimationCallback = (finished?: boolean, current?: AnimatableValue) => void;
|
|
101
109
|
export type Timestamp = number;
|
|
102
110
|
export type Value3D = {
|
|
@@ -135,6 +143,15 @@ export type AnimatedKeyboardInfo = {
|
|
|
135
143
|
height: SharedValue<number>;
|
|
136
144
|
state: SharedValue<KeyboardState>;
|
|
137
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* @param x - A number representing X coordinate relative to the parent component.
|
|
148
|
+
* @param y - A number representing Y coordinate relative to the parent component.
|
|
149
|
+
* @param width - A number representing the width of the component.
|
|
150
|
+
* @param height - A number representing the height of the component.
|
|
151
|
+
* @param pageX - A number representing X coordinate relative to the screen.
|
|
152
|
+
* @param pageY - A number representing Y coordinate relative to the screen.
|
|
153
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/measure#returns
|
|
154
|
+
*/
|
|
138
155
|
export interface MeasuredDimensions {
|
|
139
156
|
x: number;
|
|
140
157
|
y: number;
|
|
@@ -147,9 +164,10 @@ export interface AnimatedKeyboardOptions {
|
|
|
147
164
|
isStatusBarTranslucentAndroid?: boolean;
|
|
148
165
|
}
|
|
149
166
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
167
|
+
* @param System - If the `Reduce motion` accessibility setting is enabled on the device, disable the animation. Otherwise, enable the animation.
|
|
168
|
+
* @param Always - Disable the animation.
|
|
169
|
+
* @param Never - Enable the animation.
|
|
170
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/guides/accessibility
|
|
153
171
|
*/
|
|
154
172
|
export declare enum ReduceMotion {
|
|
155
173
|
System = "system",
|
|
@@ -157,27 +175,27 @@ export declare enum ReduceMotion {
|
|
|
157
175
|
Never = "never"
|
|
158
176
|
}
|
|
159
177
|
/**
|
|
160
|
-
* @deprecated
|
|
178
|
+
* @deprecated don't use
|
|
161
179
|
*/
|
|
162
180
|
export interface __WorkletFunction {
|
|
163
181
|
__closure?: Record<string, unknown>;
|
|
164
182
|
__workletHash?: number;
|
|
165
183
|
}
|
|
166
184
|
/**
|
|
167
|
-
* @deprecated
|
|
185
|
+
* @deprecated don't use
|
|
168
186
|
*/
|
|
169
187
|
export interface __BasicWorkletFunction<T> extends __WorkletFunction {
|
|
170
188
|
(): T;
|
|
171
189
|
}
|
|
172
190
|
/**
|
|
173
|
-
* @deprecated
|
|
191
|
+
* @deprecated don't use
|
|
174
192
|
*/
|
|
175
193
|
export interface __ComplexWorkletFunction<A extends any[], R> extends __WorkletFunction {
|
|
176
194
|
(...args: A): R;
|
|
177
195
|
__remoteFunction?: (...args: A) => R;
|
|
178
196
|
}
|
|
179
197
|
/**
|
|
180
|
-
* @deprecated
|
|
198
|
+
* @deprecated don't use
|
|
181
199
|
*/
|
|
182
200
|
export interface __AdapterWorkletFunction extends __WorkletFunction {
|
|
183
201
|
(value: NestedObject<string | number | AnimationObject>): void;
|
|
@@ -5,7 +5,13 @@ import type { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuil
|
|
|
5
5
|
import type { AnimatedProps } from '../helperTypes';
|
|
6
6
|
declare const AnimatedFlatList: React.ComponentClass<import("../helperTypes").AnimateProps<FlatListProps<unknown>>, any>;
|
|
7
7
|
interface ReanimatedFlatListPropsWithLayout<T> extends AnimatedProps<FlatListProps<T>> {
|
|
8
|
+
/**
|
|
9
|
+
* Lets you pass layout animation directly to the FlatList item.
|
|
10
|
+
*/
|
|
8
11
|
itemLayoutAnimation?: ILayoutAnimationBuilder;
|
|
12
|
+
/**
|
|
13
|
+
* Lets you skip entering and exiting animations of FlatList items when on FlatList mount or unmount.
|
|
14
|
+
*/
|
|
9
15
|
skipEnteringExitingAnimations?: boolean;
|
|
10
16
|
}
|
|
11
17
|
export type FlatListPropsWithLayout<T> = ReanimatedFlatListPropsWithLayout<T>;
|
|
@@ -6,6 +6,13 @@ interface LayoutAnimationConfigProps {
|
|
|
6
6
|
skipExiting?: boolean;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* A component that lets you skip entering and exiting animations.
|
|
11
|
+
*
|
|
12
|
+
* @param skipEntering - A boolean indicating whether children's entering animations should be skipped when `LayoutAnimationConfig` is mounted.
|
|
13
|
+
* @param skipExiting - A boolean indicating whether children's exiting animations should be skipped when LayoutAnimationConfig is unmounted.
|
|
14
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/layout-animation-config/
|
|
15
|
+
*/
|
|
9
16
|
export declare class LayoutAnimationConfig extends Component<LayoutAnimationConfigProps> {
|
|
10
17
|
getMaybeWrappedChildren(): string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | JSX.Element[] | null | undefined;
|
|
11
18
|
setShouldAnimateExiting(): void;
|
|
@@ -2,13 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import type { ScrollViewProps } from 'react-native';
|
|
3
3
|
import { ScrollView } from 'react-native';
|
|
4
4
|
import type { SharedValue } from '../commonTypes';
|
|
5
|
-
|
|
5
|
+
import type { AnimatedProps } from '../helperTypes';
|
|
6
|
+
export interface AnimatedScrollViewProps extends AnimatedProps<ScrollViewProps> {
|
|
6
7
|
scrollViewOffset?: SharedValue<number>;
|
|
7
8
|
}
|
|
8
9
|
interface AnimatedScrollViewComplement extends ScrollView {
|
|
9
10
|
getNode(): ScrollView;
|
|
10
11
|
}
|
|
11
|
-
declare const AnimatedScrollViewComponent: React.ComponentClass<import("
|
|
12
|
+
declare const AnimatedScrollViewComponent: React.ComponentClass<import("../helperTypes").AnimateProps<ScrollViewProps>, any>;
|
|
12
13
|
export declare const AnimatedScrollView: React.ForwardRefExoticComponent<AnimatedScrollViewProps & React.RefAttributes<AnimatedScrollView>>;
|
|
13
14
|
export type AnimatedScrollView = AnimatedScrollViewComplement & typeof AnimatedScrollViewComponent;
|
|
14
15
|
export {};
|