diff --git a/native/flow-typed/npm/react-native-reanimated_v2.x.x.js b/native/flow-typed/npm/react-native-reanimated_v2.x.x.js index 67a2671c5..7bab56666 100644 --- a/native/flow-typed/npm/react-native-reanimated_v2.x.x.js +++ b/native/flow-typed/npm/react-native-reanimated_v2.x.x.js @@ -1,719 +1,724 @@ // flow-typed signature: 3742390ed7eeeb6c96844c62149ea639 // flow-typed version: <>/react-native-reanimated_v2.2.0/flow_v0.137.0 /** * This is an autogenerated libdef stub for: * * 'react-native-reanimated' * * Fill this stub out by replacing all the `any` types. * * Once filled out, we encourage you to share your work with the * community by sending a pull request to: * https://github.com/flowtype/flow-typed */ declare module 'react-native-reanimated' { // This was taken from the flow typed library definitions of bottom-tabs_v6 declare type StyleObj = | null | void | number | false | '' | $ReadOnlyArray | { [name: string]: any, ... }; declare type ViewStyleProp = StyleObj; declare type TextStyleProp = StyleObj; declare type StyleProps = $ReadOnly<{| ...ViewStyleProp, ...TextStyleProp, +originX?: number, +originY?: number, +[key: string]: any, |}>; declare class NodeImpl { } declare class ValueImpl extends NodeImpl { constructor(val: number): this; setValue(num: number): void; } declare class ClockImpl extends NodeImpl { } declare class ViewImpl extends React$Component<{ +entering?: | ReanimatedAnimationBuilder - | EntryExitAnimationFunction + | EntryAnimationFunction | Keyframe, +exiting?: | ReanimatedAnimationBuilder - | EntryExitAnimationFunction + | ExitAnimationFunction | Keyframe, ... }> { } declare class TextImpl extends React$Component<{ +entering?: | ReanimatedAnimationBuilder - | EntryExitAnimationFunction + | EntryAnimationFunction | Keyframe, +exiting?: | ReanimatedAnimationBuilder - | EntryExitAnimationFunction + | ExitAnimationFunction | Keyframe, ... }> { } declare class ImageImpl extends React$Component<{ +entering?: | ReanimatedAnimationBuilder - | EntryExitAnimationFunction + | EntryAnimationFunction | Keyframe, +exiting?: | ReanimatedAnimationBuilder - | EntryExitAnimationFunction + | ExitAnimationFunction | Keyframe, ... }> { } declare class CodeImpl extends React$Component<{ +exec: NodeImpl, ... }> { } declare type NodeOrNum = NodeImpl | number; declare export type NodeParam = NodeOrNum | $ReadOnlyArray; declare type NodeOrArrayOfNodes = NodeImpl | $ReadOnlyArray; declare export type Block = ( nodes: $ReadOnlyArray, ) => NodeImpl; declare export type Set = (node: ValueImpl, val: NodeParam) => NodeImpl; declare type ToNumber = (val: mixed) => number; declare export type Call = >( nodes: N, callback: (vals: $TupleMap) => mixed, ) => NodeImpl; declare export type Cond = ( cond: NodeParam, branch1: ?NodeParam, branch2?: ?NodeParam, ) => NodeImpl; declare export type Not = NodeImpl => NodeImpl; declare export type And = (...$ReadOnlyArray) => NodeImpl; declare export type Or = (...$ReadOnlyArray) => NodeImpl; declare export type Eq = (NodeParam, NodeParam) => NodeImpl; declare export type Neq = (NodeParam, NodeParam) => NodeImpl; declare export type LessThan = (NodeParam, NodeParam) => NodeImpl; declare export type GreaterThan = (NodeParam, NodeParam) => NodeImpl; declare export type LessOrEq = (NodeParam, NodeParam) => NodeImpl; declare export type GreaterOrEq = (NodeParam, NodeParam) => NodeImpl; declare export type Add = (...$ReadOnlyArray) => NodeImpl; declare export type Sub = (...$ReadOnlyArray) => NodeImpl; declare export type Multiply = (...$ReadOnlyArray) => NodeImpl; declare export type Divide = (...$ReadOnlyArray) => NodeImpl; declare export type Pow = (...$ReadOnlyArray) => NodeImpl; declare export type Max = (NodeParam, NodeParam) => NodeImpl; declare export type Min = (NodeParam, NodeParam) => NodeImpl; declare export type Abs = (NodeParam) => NodeImpl; declare export type Ceil = (NodeParam) => NodeImpl; declare export type Floor = (NodeParam) => NodeImpl; declare export type Round = (NodeParam) => NodeImpl; declare export type StartClock = ClockImpl => NodeImpl; declare export type StopClock = ClockImpl => NodeImpl; declare export type ClockRunning = ClockImpl => NodeImpl; declare export type Debug = (string, NodeParam) => NodeImpl; declare type AnimationCallback = ( finished?: boolean, current?: AnimatableValue ) => mixed; declare type Animatable = number | string | Array; declare type AnimatableValueObject = { +[key: string]: Animatable }; declare export type AnimatableValue = Animatable | AnimatableValueObject; declare type ExtrapolateType = { ... }; declare type ExtrapolateModule = { +CLAMP: ExtrapolateType, ... }; declare export type InterpolationConfig = { +inputRange: $ReadOnlyArray, +outputRange: $ReadOnlyArray, +extrapolate?: ?ExtrapolateType, ... }; declare export type InterpolateNode = ( node: NodeParam, interpolationConfig: InterpolationConfig, ) => NodeImpl; declare export type InterpolateColorsConfig = { +inputRange: $ReadOnlyArray, +outputColorRange: $ReadOnlyArray, }; declare export type InterpolateColors = ( animationValue: NodeParam, interpolationConfig: InterpolateColorsConfig ) => NodeImpl; declare export type Interpolate = ( input: number, inputRange: $ReadOnlyArray, outputRange: $ReadOnlyArray, extrapolate?: ?ExtrapolateType, ) => number; declare export type InterpolateColorConfig = $Shape<{ +gamma: number, +useCorrectedHSVInterpolation: boolean, }>; declare export type InterpolateColor = ( input: number, inputRange: $ReadOnlyArray, outputRange: $ReadOnlyArray, colorSpace?: 'RGB' | 'HSV', interpolateColorConfig?: InterpolateColorConfig, ) => T; declare type EasingType = { ... }; declare type EasingNodeModule = { +ease: EasingType, +quad: EasingType, +in: EasingType => EasingType, +out: EasingType => EasingType, +inOut: EasingType => EasingType, ... }; declare export var EasingNode: EasingNodeModule; declare type EasingFn = (t: number) => number; declare type EasingFnFactory = { +factory: () => EasingFn }; declare type EasingModule = { +ease: EasingFn, +quad: EasingFn, +in: EasingFn => EasingFn, +out: EasingFn => EasingFn, +inOut: EasingFn => EasingFn, ... }; declare export var Easing: EasingModule; declare export type TimingState = { +finished: ValueImpl, +position: ValueImpl, +frameTime: ValueImpl, +time: ValueImpl, ... }; declare export type TimingConfig = { +duration: number, +toValue: NodeOrNum, +easing?: ?EasingType, ... }; declare type Animator = { +start: () => void, ... }; declare type Timing = {| ( value: ValueImpl, config: TimingConfig, ): Animator, ( clock: ClockImpl, state: TimingState, config: TimingConfig, ): NodeImpl, |}; declare export type SpringConfig = { +overshootClamping: boolean, +damping: number, +mass: number, +toValue: NodeOrNum, ... }; declare type SpringUtilsModule = { +makeDefaultConfig: () => SpringConfig, +makeConfigFromBouncinessAndSpeed: ($ReadOnly<{ ...SpringConfig, +bounciness: ?number, +speed: ?number, ... }>) => SpringConfig, ... }; declare export type SpringState = { +finished: ValueImpl, +position: ValueImpl, +velocity: ValueImpl, +time: ValueImpl, ... }; declare type Spring = {| ( value: ValueImpl, config: SpringConfig, ): Animator, ( clock: ClockImpl, state: SpringState, config: SpringConfig, ): NodeImpl, |}; declare export type DecayConfig = { +deceleration: number, ... }; declare export type DecayState = { +finished: ValueImpl, +position: ValueImpl, +velocity: ValueImpl, +time: ValueImpl, ... }; declare type Decay = {| ( value: ValueImpl, config: DecayConfig, ): Animator, ( clock: ClockImpl, state: DecayState, config: DecayConfig, ): NodeImpl, |}; declare type LayoutAnimation = {| +initialValues: StyleProps, +animations: StyleProps, +callback?: (finished: boolean) => void, |}; declare type AnimationFunction = (a?: any, b?: any, c?: any) => any; - declare type EntryAnimationsValues = {| + declare export type EntryAnimationsValues = {| +targetOriginX: number, +targetOriginY: number, +targetWidth: number, +targetHeight: number, +targetGlobalOriginX: number, +targetGlobalOriginY: number, |}; - declare type ExitAnimationsValues = {| + declare export type ExitAnimationsValues = {| +currentOriginX: number, +currentOriginY: number, +currentWidth: number, +currentHeight: number, +currentGlobalOriginX: number, +currentGlobalOriginY: number, |}; - declare export type EntryExitAnimationFunction = ( - targetValues: EntryAnimationsValues | ExitAnimationsValues, + + declare export type EntryAnimationFunction = ( + targetValues: EntryAnimationsValues, + ) => LayoutAnimation; + + declare export type ExitAnimationFunction = ( + targetValues: ExitAnimationsValues, ) => LayoutAnimation; declare type AnimationConfigFunction = ( targetValues: T, ) => LayoutAnimation; declare type LayoutAnimationsValues = {| +currentOriginX: number, +currentOriginY: number, +currentWidth: number, +currentHeight: number, +currentGlobalOriginX: number, +currentGlobalOriginY: number, +targetOriginX: number, +targetOriginY: number, +targetWidth: number, +targetHeight: number, +targetGlobalOriginX: number, +argetGlobalOriginY: number, +windowWidth: number, +windowHeight: number, |}; declare type LayoutAnimationFunction = ( targetValues: LayoutAnimationsValues, ) => LayoutAnimation; declare type BaseLayoutAnimationConfig = {| +duration?: number, +easing?: EasingFn, +type?: AnimationFunction, +damping?: number, +mass?: number, +stiffness?: number, +overshootClamping?: number, +restDisplacementThreshold?: number, +restSpeedThreshold?: number, |}; declare type BaseBuilderAnimationConfig = $ReadOnly<{| ...BaseLayoutAnimationConfig, +rotate?: number | string, |}>; declare type LayoutAnimationAndConfig = [ AnimationFunction, BaseBuilderAnimationConfig, ]; declare export class BaseAnimationBuilder { static duration(durationMs: number): BaseAnimationBuilder; duration(durationMs: number): BaseAnimationBuilder; static delay(delayMs: number): BaseAnimationBuilder; delay(delayMs: number): BaseAnimationBuilder; static withCallback( callback: (finished: boolean) => void, ): BaseAnimationBuilder; withCallback(callback: (finished: boolean) => void): BaseAnimationBuilder; static getDuration(): number; getDuration(): number; static randomDelay(): BaseAnimationBuilder; randomDelay(): BaseAnimationBuilder; getDelay(): number; getDelayFunction(): AnimationFunction; - static build(): EntryExitAnimationFunction | LayoutAnimationFunction; + static build(): EntryAnimationFunction | ExitAnimationFunction | LayoutAnimationFunction; } declare export type ReanimatedAnimationBuilder = | Class | BaseAnimationBuilder; declare export class ComplexAnimationBuilder extends BaseAnimationBuilder { static easing(easingFunction: EasingFn): ComplexAnimationBuilder; easing(easingFunction: EasingFn): ComplexAnimationBuilder; static rotate(degree: string): ComplexAnimationBuilder; rotate(degree: string): ComplexAnimationBuilder; static springify(): ComplexAnimationBuilder; springify(): ComplexAnimationBuilder; static damping(damping: number): ComplexAnimationBuilder; damping(damping: number): ComplexAnimationBuilder; static mass(mass: number): ComplexAnimationBuilder; mass(mass: number): ComplexAnimationBuilder; static stiffness(stiffness: number): ComplexAnimationBuilder; stiffness(stiffness: number): ComplexAnimationBuilder; static overshootClamping( overshootClamping: number, ): ComplexAnimationBuilder; overshootClamping(overshootClamping: number): ComplexAnimationBuilder; static restDisplacementThreshold( restDisplacementThreshold: number, ): ComplexAnimationBuilder; restDisplacementThreshold( restDisplacementThreshold: number, ): ComplexAnimationBuilder; static restSpeedThreshold( restSpeedThreshold: number, ): ComplexAnimationBuilder; restSpeedThreshold(restSpeedThreshold: number): ComplexAnimationBuilder; static withInitialValues(values: StyleProps): BaseAnimationBuilder; withInitialValues(values: StyleProps): BaseAnimationBuilder; getAnimationAndConfig(): LayoutAnimationAndConfig; } declare export class SlideInDown extends ComplexAnimationBuilder { static createInstance(): SlideInDown; build(): AnimationConfigFunction; } declare export class SlideOutDown extends ComplexAnimationBuilder { static createInstance(): SlideOutDown; build(): AnimationConfigFunction; } declare export class FadeInDown extends ComplexAnimationBuilder { static createInstance(): FadeInDown; build(): AnimationConfigFunction; } declare export class FadeOutDown extends ComplexAnimationBuilder { static createInstance(): FadeOutDown; build(): AnimationConfigFunction; } declare export class FadeIn extends ComplexAnimationBuilder { static createInstance(): FadeIn; build(): AnimationConfigFunction; } declare export class FadeOut extends ComplexAnimationBuilder { static createInstance(): FadeOut; build(): AnimationConfigFunction; } declare type $SyntheticEvent = { +nativeEvent: $ReadOnly<$Exact>, ... }; declare type GestureStateUndetermined = 0; declare type GestureStateFailed = 1; declare type GestureStateBegan = 2; declare type GestureStateCancelled = 3; declare type GestureStateActive = 4; declare type GestureStateEnd = 5; declare type GestureState = | GestureStateUndetermined | GestureStateFailed | GestureStateBegan | GestureStateCancelled | GestureStateActive | GestureStateEnd; declare export type $Event = { handlerTag: number, numberOfPointers: number, state: GestureState, oldState: GestureState, ...$Exact, ... }; declare export type EventResult = $Event> = $SyntheticEvent => void; declare type ToValue = (val: mixed) => ValueImpl; declare type Event = = $Event>( defs: $ReadOnlyArray<{ +nativeEvent: $Shape<$ObjMap>, ... }>, ) => EventResult; declare type UseValue = (initialVal: number) => ValueImpl; declare type AnimatedGestureHandlerEventCallback> = ( event: $Shape, context: {| [name: string]: mixed |}, ) => mixed; declare type UseAnimatedGestureHandler = = $Event>( callbacks: $Shape<{| +onStart: AnimatedGestureHandlerEventCallback, +onActive: AnimatedGestureHandlerEventCallback, +onEnd: AnimatedGestureHandlerEventCallback, +onFail: AnimatedGestureHandlerEventCallback, +onCancel: AnimatedGestureHandlerEventCallback, +onFinish: AnimatedGestureHandlerEventCallback, |}>, dependencies?: $ReadOnlyArray, ) => $SyntheticEvent => mixed; declare export type SharedValue = { value: T, ... }; declare type UseSharedValue = (val: T) => SharedValue; declare type UseDerivedValue = ( updater: () => T, dependencies?: $ReadOnlyArray, ) => SharedValue; declare type UseAnimatedStyle = ( styleSelector: () => T, dependencies?: $ReadOnlyArray, ) => T; declare export type WithSpringConfig = $Shape<{| +stiffness: number, +damping: number, +mass: number, +overshootClamping: boolean, +restDisplacementThreshold: number, +restSpeedThreshold: number, +velocity: number, |}>; // Doesn't actually return a number, but sharedValue.value has a differently // typed getter vs. setter, and Flow doesn't support that declare type WithSpring = ( toValue: number | string, springConfig?: WithSpringConfig, ) => number; declare type WithTimingConfig = $Shape<{ +duration: number, +easing: EasingFn | EasingFnFactory, }>; declare type WithTiming = ( toValue: T, timingConfig?: WithTimingConfig, callback?: AnimationCallback, ) => T; declare type RunOnJS = (func: F) => F; declare type CancelAnimation = (animation: number) => void; declare type AnimatedKeyboardInfo = {| +height: SharedValue, +state: SharedValue<0 | 1 | 2 | 3 | 4>, |}; declare type UseAnimatedKeyboard = (config?: {| +isStatusBarTranslucentAndroid?: boolean, |}) => AnimatedKeyboardInfo; declare type UseAnimatedReaction = ( () => T, (currentValue: T, previousValue: T) => mixed, ) => void; declare export var Node: typeof NodeImpl; declare export var Value: typeof ValueImpl; declare export var Clock: typeof ClockImpl; declare export var View: typeof ViewImpl; declare export var Text: typeof TextImpl; declare export var Image: typeof ImageImpl; declare export var Code: typeof CodeImpl; declare export var block: Block; declare export var set: Set; declare export var call: Call; declare export var cond: Cond; declare export var not: Not; declare export var and: And; declare export var or: Or; declare export var eq: Eq; declare export var neq: Neq; declare export var lessThan: LessThan; declare export var greaterThan: GreaterThan; declare export var lessOrEq: LessOrEq; declare export var greaterOrEq: GreaterOrEq; declare export var add: Add; declare export var sub: Sub; declare export var multiply: Multiply; declare export var divide: Divide; declare export var pow: Pow; declare export var max: Max; declare export var min: Min; declare export var abs: Abs; declare export var ceil: Ceil; declare export var floor: Floor; declare export var round: Round; declare export var startClock: StartClock; declare export var stopClock: StopClock; declare export var clockRunning: ClockRunning; declare export var debug: Debug; declare export var interpolateNode: InterpolateNode; declare export var interpolateColors: InterpolateColors; declare export var interpolate: Interpolate; declare export var interpolateColor: InterpolateColor; declare export var Extrapolate: ExtrapolateModule; declare export var timing: Timing; declare export var SpringUtils: SpringUtilsModule; declare export var spring: Spring; declare export var decay: Decay; declare export var event: Event; declare export var useValue: UseValue; declare export var useAnimatedGestureHandler: UseAnimatedGestureHandler; declare export var useSharedValue: UseSharedValue; declare export var useDerivedValue: UseDerivedValue; declare export var useAnimatedStyle: UseAnimatedStyle; declare export var withSpring: WithSpring; declare export var withTiming: WithTiming; declare export var runOnJS: RunOnJS; declare export var cancelAnimation: CancelAnimation; declare export var useAnimatedKeyboard: UseAnimatedKeyboard; declare export var useAnimatedReaction: UseAnimatedReaction; declare export default { +Node: typeof NodeImpl, +Value: typeof ValueImpl, +Clock: typeof ClockImpl, +View: typeof ViewImpl, +Text: typeof TextImpl, +Image: typeof ImageImpl, +Code: typeof CodeImpl, +block: Block, +set: Set, +call: Call, +cond: Cond, +not: Not, +and: And, +or: Or, +eq: Eq, +neq: Neq, +lessThan: LessThan, +greaterThan: GreaterThan, +lessOrEq: LessOrEq, +greaterOrEq: GreaterOrEq, +add: Add, +sub: Sub, +multiply: Multiply, +divide: Divide, +pow: Pow, +max: Max, +min: Min, +abs: Abs, +ceil: Ceil, +floor: Floor, +round: Round, +startClock: StartClock, +stopClock: StopClock, +clockRunning: ClockRunning, +debug: Debug, +interpolateNode: InterpolateNode, +interpolateColors: InterpolateColors, +interpolate: Interpolate, +interpolateColor: InterpolateColor, +Extrapolate: ExtrapolateModule, +timing: Timing, +spring: Spring, +decay: Decay, +SpringUtils: SpringUtilsModule, +event: Event, +useValue: UseValue, +useAnimatedGestureHandler: UseAnimatedGestureHandler, +useSharedValue: UseSharedValue, +useDerivedValue: UseDerivedValue, +useAnimatedStyle: UseAnimatedStyle, +withSpring: WithSpring, +withTiming: WithTiming, +runOnJS: RunOnJS, +cancelAnimation: CancelAnimation, ... }; } diff --git a/native/types/styles.js b/native/types/styles.js index ae067c2a6..bb3fd73ec 100644 --- a/native/types/styles.js +++ b/native/types/styles.js @@ -1,76 +1,74 @@ // @flow import * as React from 'react'; import { View, Text, Image } from 'react-native'; import Animated, { type ReanimatedAnimationBuilder, - type EntryExitAnimationFunction, + type EntryAnimationFunction, + type ExitAnimationFunction, type SharedValue, } from 'react-native-reanimated'; import type { ViewStyleObj } from './react-native.js'; type ViewProps = React.ElementConfig; export type ViewStyle = $PropertyType; type TextProps = React.ElementConfig; export type TextStyle = $PropertyType; type ImageProps = React.ElementConfig; export type ImageStyle = $PropertyType; type Value = ?number | Animated.Node | SharedValue; export type ReanimatedTransform = { +scale?: Value, +translateX?: Value, +translateY?: Value, ... }; export type WritableAnimatedStyleObj = { ...ViewStyleObj, opacity?: Value, height?: Value, width?: Value, marginTop?: Value, marginRight?: Value, marginLeft?: Value, backgroundColor?: ?string | Animated.Node | SharedValue, bottom?: Value, transform?: $ReadOnlyArray, ... }; export type AnimatedStyleObj = $ReadOnly; export type AnimatedViewStyle = | AnimatedStyleObj | $ReadOnlyArray; const AnimatedView: React.ComponentType<{ ...$Diff, +style: AnimatedViewStyle, - +entering?: - | ReanimatedAnimationBuilder - | EntryExitAnimationFunction - | Keyframe, - +exiting?: ReanimatedAnimationBuilder | EntryExitAnimationFunction | Keyframe, + +entering?: ReanimatedAnimationBuilder | EntryAnimationFunction | Keyframe, + +exiting?: ReanimatedAnimationBuilder | ExitAnimationFunction | Keyframe, }> = Animated.View; export type AnimatedTextStyle = | AnimatedStyleObj | $ReadOnlyArray; const AnimatedText: React.ComponentType<{ ...$Diff, +style: AnimatedTextStyle, }> = Animated.Text; export type AnimatedImageStyle = | AnimatedStyleObj | $ReadOnlyArray; const AnimatedImage: React.ComponentType<{ ...$Diff, +style: AnimatedImageStyle, }> = Animated.Image; export { AnimatedView, AnimatedText, AnimatedImage };