import type { ComponentRef, ElementType, RefObject } from 'react'; import type { HostInstance, ImageStyle, NativeScrollEvent, NativeSyntheticEvent, TextStyle, ViewStyle } from 'react-native'; import type { WorkletFunction } from 'react-native-worklets'; import type { Maybe } from '../common'; import type { AnimatedPropsAdapterFunction, AnimatedStyle, InstanceOrElement, InternalHostInstance, ShadowNodeWrapper, StyleUpdaterContainer } from '../commonTypes'; import type { AnimatedComponentType } from '../createAnimatedComponent'; import type { ReanimatedHTMLElement } from '../ReanimatedModule/js-reanimated'; import type { ViewDescriptorsSet } from '../ViewDescriptorsSet'; export type DependencyList = Array | undefined; export interface Descriptor { tag: number | ReanimatedHTMLElement; shadowNodeWrapper: ShadowNodeWrapper; } export type MaybeObserverCleanup = (() => void) | undefined; export type AnimatedRefObserver = (tag: number | null) => MaybeObserverCleanup; export type ExtractElementRef = TRef extends ElementType ? ComponentRef extends never ? TRef : ComponentRef : TRef; type AnimatedRefCurrent = ExtractElementRef ? Instance : TRef>; export type AnimatedRef = { (ref?: AnimatedRefCurrent | null): ShadowNodeWrapper | HTMLElement; current: AnimatedRefCurrent | null; observe: (observer: AnimatedRefObserver) => void; getTag?: () => Maybe; }; export type AnimatedRefOnJS = AnimatedRef; /** * `AnimatedRef` is mapped to this type on the UI thread via a serializable * handle. */ export type AnimatedRefOnUI = { (): number | ShadowNodeWrapper | null; }; type ReanimatedPayload = { eventName: string; }; /** * This utility type is to convert type of events that would normally be sent by * React Native (they have `nativeEvent` field) to the type that is sent by * Reanimated. */ export type ReanimatedEvent = ReanimatedPayload & (Event extends { nativeEvent: infer NativeEvent extends object; } ? NativeEvent : Event); export type EventPayload = Event extends { nativeEvent: infer NativeEvent extends object; } ? NativeEvent : Omit; export type DefaultStyle = ViewStyle | ImageStyle | TextStyle; export type RNNativeScrollEvent = NativeSyntheticEvent; export type ReanimatedScrollEvent = ReanimatedEvent; export interface IWorkletEventHandler { updateEventHandler: (newWorklet: (event: ReanimatedEvent) => void, newEvents: string[]) => void; registerForEvents: (viewTag: number, fallbackEventName?: string) => void; unregisterFromEvents: (viewTag: number) => void; } export interface AnimatedStyleHandle