UNPKG

3.14 kBTypeScriptView Raw
1import type { Component, MutableRefObject } from 'react';
2import type { AnimatedPropsAdapterFunction, ShadowNodeWrapper, SharedValue, WorkletFunction, AnimatedStyle } from '../commonTypes';
3import type { ImageStyle, NativeSyntheticEvent, TextStyle, ViewStyle, NativeScrollEvent } from 'react-native';
4import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
5import type { ReanimatedHTMLElement } from '../js-reanimated';
6export type DependencyList = Array<unknown> | undefined;
7export interface Descriptor {
8 tag: number | ReanimatedHTMLElement;
9 name: string;
10 shadowNodeWrapper: ShadowNodeWrapper;
11}
12export interface AnimatedRef<T extends Component> {
13 (component?: T): number | ShadowNodeWrapper | HTMLElement;
14 current: T | null;
15 getTag: () => number;
16}
17export type AnimatedRefOnJS = AnimatedRef<Component>;
18/** `AnimatedRef` is mapped to this type on the UI thread via a shareable handle. */
19export type AnimatedRefOnUI = {
20 (): number | ShadowNodeWrapper | null;
21 /**
22 * @remarks
23 * `viewName` is required only on iOS with Paper and it's value is null on
24 * other platforms.
25 */
26 viewName: SharedValue<string | null>;
27};
28type ReanimatedPayload = {
29 eventName: string;
30};
31/**
32 * This utility type is to convert type of events that would normally be sent by
33 * React Native (they have `nativeEvent` field) to the type that is sent by
34 * Reanimated.
35 */
36export type ReanimatedEvent<Event extends object> = ReanimatedPayload & (Event extends {
37 nativeEvent: infer NativeEvent extends object;
38} ? NativeEvent : Event);
39export type EventPayload<Event extends object> = Event extends {
40 nativeEvent: infer NativeEvent extends object;
41} ? NativeEvent : Omit<Event, 'eventName'>;
42export type NativeEventWrapper<Event extends object> = {
43 nativeEvent: Event;
44};
45export type DefaultStyle = ViewStyle | ImageStyle | TextStyle;
46export type RNNativeScrollEvent = NativeSyntheticEvent<NativeScrollEvent>;
47export type ReanimatedScrollEvent = ReanimatedEvent<RNNativeScrollEvent>;
48export interface IWorkletEventHandler<Event extends object> {
49 updateEventHandler: (newWorklet: (event: ReanimatedEvent<Event>) => void, newEvents: string[]) => void;
50 registerForEvents: (viewTag: number, fallbackEventName?: string) => void;
51 unregisterFromEvents: (viewTag: number) => void;
52}
53export interface AnimatedStyleHandle<Style extends DefaultStyle = DefaultStyle> {
54 viewDescriptors: ViewDescriptorsSet;
55 initial: {
56 value: AnimatedStyle<Style>;
57 updater: () => AnimatedStyle<Style>;
58 };
59}
60export interface JestAnimatedStyleHandle<Style extends DefaultStyle = DefaultStyle> extends AnimatedStyleHandle<Style> {
61 jestAnimatedStyle: MutableRefObject<AnimatedStyle<Style>>;
62}
63export type UseAnimatedStyleInternal<Style extends DefaultStyle> = (updater: WorkletFunction<[], Style> | (() => Style), dependencies?: DependencyList | null, adapters?: AnimatedPropsAdapterFunction | AnimatedPropsAdapterFunction[] | null, isAnimatedProps?: boolean) => AnimatedStyleHandle<Style> | JestAnimatedStyleHandle<Style>;
64export {};
65//# sourceMappingURL=commonTypes.d.ts.map
\No newline at end of file