import type { ViewStyle, TextStyle, TransformsStyle, ImageStyle } from 'react-native'; export type RequiredKeys = T & Required>; export interface StyleProps extends ViewStyle, TextStyle { originX?: number; originY?: number; [key: string]: any; } /** * 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). * * 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. */ export interface SharedValue { value: Value; get(): Value; set(value: Value | ((value: Value) => Value)): void; addListener: (listenerID: number, listener: (value: Value) => void) => void; removeListener: (listenerID: number) => void; modify: (modifier?: (value: T) => T, forceUpdate?: boolean) => void; } /** * Due to pattern of `MaybeSharedValue` type present in `AnimatedProps` * (`AnimatedStyle`), contravariance breaks types for animated styles etc. * Instead of refactoring the code with small chances of success, we just * disable contravariance for `SharedValue` in this problematic case. */ type SharedValueDisableContravariance = Omit, 'set'>; export interface Mutable extends SharedValue { _isReanimatedSharedValue: true; _animation?: AnimationObject | null; /** * `_value` prop should only be accessed by the `valueSetter` implementation * which may make the decision about updating the mutable value depending on * the provided new value. All other places should only attempt to modify the * mutable by assigning to `value` prop directly or by calling the `set` * method. */ _value: Value; } export type ShareableRef = { __hostObjectShareableJSRef: T; }; export type FlatShareableRef = T extends ShareableRef ? ShareableRef : ShareableRef; export type MapperRawInputs = unknown[]; export type MapperOutputs = SharedValue[]; export type MapperRegistry = { start: (mapperID: number, worklet: () => void, inputs: MapperRawInputs, outputs?: MapperOutputs) => void; stop: (mapperID: number) => void; }; export type WorkletStackDetails = [ error: Error, lineOffset: number, columnOffset: number ]; type WorkletClosure = Record; interface WorkletInitDataCommon { code: string; } type WorkletInitDataRelease = WorkletInitDataCommon; interface WorkletInitDataDev extends WorkletInitDataCommon { location: string; sourceMap: string; version: string; } interface WorkletBaseCommon { __closure: WorkletClosure; __workletHash: number; } interface WorkletBaseRelease extends WorkletBaseCommon { __initData: WorkletInitDataRelease; } interface WorkletBaseDev extends WorkletBaseCommon { __initData: WorkletInitDataDev; /** `__stackDetails` is removed after parsing. */ __stackDetails?: WorkletStackDetails; } export type WorkletFunction = ((...args: Args) => ReturnValue) & (WorkletBaseRelease | WorkletBaseDev); /** * This function allows you to determine if a given function is a worklet. It * only works with Reanimated Babel plugin enabled. Unless you are doing * something with internals of Reanimated you shouldn't need to use this * function. * * ### Note * * Do not call it before the worklet is declared, as it will always return false * then. E.g.: * * ```ts * isWorkletFunction(myWorklet); // Will always return false. * * function myWorklet() { * 'worklet'; * } * ``` * * ### Maintainer note * * This function works well on the JS thread performance-wise, since the JIT can * inline it. However, on other threads it will not get optimized and we will * get a function call overhead. We want to change it in the future, but it's * not feasible at the moment. */ export declare function isWorkletFunction(value: unknown): value is WorkletFunction & BuildType; export type AnimatedPropsAdapterFunction = (props: Record) => void; export type AnimatedPropsAdapterWorklet = WorkletFunction<[ props: Record ], void>; export interface NestedObject { [key: string]: NestedObjectValues; } export type NestedObjectValues = T | Array> | NestedObject; type Animatable = number | string | Array; export type AnimatableValueObject = { [key: string]: Animatable; }; export type AnimatableValue = Animatable | AnimatableValueObject; export interface AnimationObject { [key: string]: any; callback?: AnimationCallback; current?: T; toValue?: AnimationObject['current']; startValue?: AnimationObject['current']; finished?: boolean; strippedCurrent?: number; cancelled?: boolean; reduceMotion?: boolean; __prefix?: string; __suffix?: string; onFrame: (animation: any, timestamp: Timestamp) => boolean; onStart: (nextAnimation: any, current: any, timestamp: Timestamp, previousAnimation: any) => void; } export interface Animation extends AnimationObject { onFrame: (animation: T, timestamp: Timestamp) => boolean; onStart: (nextAnimation: T, current: AnimatableValue, timestamp: Timestamp, previousAnimation: Animation | null | T) => void; } export declare enum SensorType { ACCELEROMETER = 1, GYROSCOPE = 2, GRAVITY = 3, MAGNETIC_FIELD = 4, ROTATION = 5 } export declare enum IOSReferenceFrame { XArbitraryZVertical = 0, XArbitraryCorrectedZVertical = 1, XMagneticNorthZVertical = 2, XTrueNorthZVertical = 3, Auto = 4 } export type SensorConfig = { interval: number | 'auto'; adjustToInterfaceOrientation: boolean; iosReferenceFrame: IOSReferenceFrame; }; export type AnimatedSensor = { sensor: SharedValue; unregister: () => void; isAvailable: boolean; config: SensorConfig; }; /** * A function called upon animation completion. If the animation is cancelled, * the callback will receive `false` as the argument; otherwise, it will receive * `true`. */ export type AnimationCallback = (finished?: boolean, current?: AnimatableValue) => void; export type Timestamp = number; export type Value3D = { x: number; y: number; z: number; interfaceOrientation: InterfaceOrientation; }; export type ValueRotation = { qw: number; qx: number; qy: number; qz: number; yaw: number; pitch: number; roll: number; interfaceOrientation: InterfaceOrientation; }; export declare enum InterfaceOrientation { ROTATION_0 = 0, ROTATION_90 = 90, ROTATION_180 = 180, ROTATION_270 = 270 } export type ShadowNodeWrapper = { __hostObjectShadowNodeWrapper: never; }; export declare enum KeyboardState { UNKNOWN = 0, OPENING = 1, OPEN = 2, CLOSING = 3, CLOSED = 4 } export type AnimatedKeyboardInfo = { height: SharedValue; state: SharedValue; }; /** * @param x - A number representing X coordinate relative to the parent * component. * @param y - A number representing Y coordinate relative to the parent * component. * @param width - A number representing the width of the component. * @param height - A number representing the height of the component. * @param pageX - A number representing X coordinate relative to the screen. * @param pageY - A number representing Y coordinate relative to the screen. * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/measure#returns */ export interface MeasuredDimensions { x: number; y: number; width: number; height: number; pageX: number; pageY: number; } export interface AnimatedKeyboardOptions { isStatusBarTranslucentAndroid?: boolean; isNavigationBarTranslucentAndroid?: boolean; } /** * @param System - If the `Reduce motion` accessibility setting is enabled on * the device, disable the animation. Otherwise, enable the animation. * @param Always - Disable the animation. * @param Never - Enable the animation. * @see https://docs.swmansion.com/react-native-reanimated/docs/guides/accessibility */ export declare enum ReduceMotion { System = "system", Always = "always", Never = "never" } export type EasingFunction = (t: number) => number; export type TransformArrayItem = Extract>[number]; type MaybeSharedValue = Value | (Value extends AnimatableValue ? SharedValueDisableContravariance : never); type MaybeSharedValueRecursive = Value extends (infer Item)[] ? SharedValueDisableContravariance | (MaybeSharedValueRecursive | Item)[] : Value extends object ? SharedValueDisableContravariance | { [Key in keyof Value]: MaybeSharedValueRecursive | Value[Key]; } : MaybeSharedValue; type DefaultStyle = ViewStyle & ImageStyle & TextStyle; export type AnimatedStyle