1 | import type { ViewStyle, TextStyle, TransformsStyle, ImageStyle } from 'react-native';
|
2 | export type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
3 | export interface StyleProps extends ViewStyle, TextStyle {
|
4 | originX?: number;
|
5 | originY?: number;
|
6 | [key: string]: any;
|
7 | }
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export interface SharedValue<Value = unknown> {
|
19 | value: Value;
|
20 | get(): Value;
|
21 | set(value: Value | ((value: Value) => Value)): void;
|
22 | addListener: (listenerID: number, listener: (value: Value) => void) => void;
|
23 | removeListener: (listenerID: number) => void;
|
24 | modify: (modifier?: <T extends Value>(value: T) => T, forceUpdate?: boolean) => void;
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | type SharedValueDisableContravariance<Value = unknown> = Omit<SharedValue<Value>, 'set'>;
|
33 | export interface Mutable<Value = unknown> extends SharedValue<Value> {
|
34 | _isReanimatedSharedValue: true;
|
35 | _animation?: AnimationObject<Value> | null;
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | _value: Value;
|
44 | }
|
45 | export type ShareableRef<T = unknown> = {
|
46 | __hostObjectShareableJSRef: T;
|
47 | };
|
48 | export type FlatShareableRef<T> = T extends ShareableRef<infer U> ? ShareableRef<U> : ShareableRef<T>;
|
49 | export type MapperRawInputs = unknown[];
|
50 | export type MapperOutputs = SharedValue[];
|
51 | export type MapperRegistry = {
|
52 | start: (mapperID: number, worklet: () => void, inputs: MapperRawInputs, outputs?: MapperOutputs) => void;
|
53 | stop: (mapperID: number) => void;
|
54 | };
|
55 | export type WorkletStackDetails = [
|
56 | error: Error,
|
57 | lineOffset: number,
|
58 | columnOffset: number
|
59 | ];
|
60 | type WorkletClosure = Record<string, unknown>;
|
61 | interface WorkletInitDataCommon {
|
62 | code: string;
|
63 | }
|
64 | type WorkletInitDataRelease = WorkletInitDataCommon;
|
65 | interface WorkletInitDataDev extends WorkletInitDataCommon {
|
66 | location: string;
|
67 | sourceMap: string;
|
68 | version: string;
|
69 | }
|
70 | interface WorkletBaseCommon {
|
71 | __closure: WorkletClosure;
|
72 | __workletHash: number;
|
73 | }
|
74 | interface WorkletBaseRelease extends WorkletBaseCommon {
|
75 | __initData: WorkletInitDataRelease;
|
76 | }
|
77 | interface WorkletBaseDev extends WorkletBaseCommon {
|
78 | __initData: WorkletInitDataDev;
|
79 |
|
80 | __stackDetails?: WorkletStackDetails;
|
81 | }
|
82 | export type WorkletFunction<Args extends unknown[] = unknown[], ReturnValue = unknown> = ((...args: Args) => ReturnValue) & (WorkletBaseRelease | WorkletBaseDev);
|
83 | /**
|
84 | * This function allows you to determine if a given function is a worklet. It
|
85 | * only works with Reanimated Babel plugin enabled. Unless you are doing
|
86 | * something with internals of Reanimated you shouldn't need to use this
|
87 | * function.
|
88 | *
|
89 | * ### Note
|
90 | *
|
91 | * Do not call it before the worklet is declared, as it will always return false
|
92 | * then. E.g.:
|
93 | *
|
94 | * ```ts
|
95 | * isWorkletFunction(myWorklet); // Will always return false.
|
96 | *
|
97 | * function myWorklet() {
|
98 | * 'worklet';
|
99 | * }
|
100 | * ```
|
101 | *
|
102 | * ### Maintainer note
|
103 | *
|
104 | * This function works well on the JS thread performance-wise, since the JIT can
|
105 | * inline it. However, on other threads it will not get optimized and we will
|
106 | * get a function call overhead. We want to change it in the future, but it's
|
107 | * not feasible at the moment.
|
108 | */
|
109 | export declare function isWorkletFunction<Args extends unknown[] = unknown[], ReturnValue = unknown, BuildType extends WorkletBaseDev | WorkletBaseRelease = WorkletBaseDev>(value: unknown): value is WorkletFunction<Args, ReturnValue> & BuildType;
|
110 | export type AnimatedPropsAdapterFunction = (props: Record<string, unknown>) => void;
|
111 | export type AnimatedPropsAdapterWorklet = WorkletFunction<[
|
112 | props: Record<string, unknown>
|
113 | ], void>;
|
114 | export interface NestedObject<T> {
|
115 | [key: string]: NestedObjectValues<T>;
|
116 | }
|
117 | export type NestedObjectValues<T> = T | Array<NestedObjectValues<T>> | NestedObject<T>;
|
118 | type Animatable = number | string | Array<number>;
|
119 | export type AnimatableValueObject = {
|
120 | [key: string]: Animatable;
|
121 | };
|
122 | export type AnimatableValue = Animatable | AnimatableValueObject;
|
123 | export interface AnimationObject<T = AnimatableValue> {
|
124 | [key: string]: any;
|
125 | callback?: AnimationCallback;
|
126 | current?: T;
|
127 | toValue?: AnimationObject<T>['current'];
|
128 | startValue?: AnimationObject<T>['current'];
|
129 | finished?: boolean;
|
130 | strippedCurrent?: number;
|
131 | cancelled?: boolean;
|
132 | reduceMotion?: boolean;
|
133 | __prefix?: string;
|
134 | __suffix?: string;
|
135 | onFrame: (animation: any, timestamp: Timestamp) => boolean;
|
136 | onStart: (nextAnimation: any, current: any, timestamp: Timestamp, previousAnimation: any) => void;
|
137 | }
|
138 | export interface Animation<T extends AnimationObject> extends AnimationObject {
|
139 | onFrame: (animation: T, timestamp: Timestamp) => boolean;
|
140 | onStart: (nextAnimation: T, current: AnimatableValue, timestamp: Timestamp, previousAnimation: Animation<any> | null | T) => void;
|
141 | }
|
142 | export declare enum SensorType {
|
143 | ACCELEROMETER = 1,
|
144 | GYROSCOPE = 2,
|
145 | GRAVITY = 3,
|
146 | MAGNETIC_FIELD = 4,
|
147 | ROTATION = 5
|
148 | }
|
149 | export declare enum IOSReferenceFrame {
|
150 | XArbitraryZVertical = 0,
|
151 | XArbitraryCorrectedZVertical = 1,
|
152 | XMagneticNorthZVertical = 2,
|
153 | XTrueNorthZVertical = 3,
|
154 | Auto = 4
|
155 | }
|
156 | export type SensorConfig = {
|
157 | interval: number | 'auto';
|
158 | adjustToInterfaceOrientation: boolean;
|
159 | iosReferenceFrame: IOSReferenceFrame;
|
160 | };
|
161 | export type AnimatedSensor<T extends Value3D | ValueRotation> = {
|
162 | sensor: SharedValue<T>;
|
163 | unregister: () => void;
|
164 | isAvailable: boolean;
|
165 | config: SensorConfig;
|
166 | };
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 | export type AnimationCallback = (finished?: boolean, current?: AnimatableValue) => void;
|
173 | export type Timestamp = number;
|
174 | export type Value3D = {
|
175 | x: number;
|
176 | y: number;
|
177 | z: number;
|
178 | interfaceOrientation: InterfaceOrientation;
|
179 | };
|
180 | export type ValueRotation = {
|
181 | qw: number;
|
182 | qx: number;
|
183 | qy: number;
|
184 | qz: number;
|
185 | yaw: number;
|
186 | pitch: number;
|
187 | roll: number;
|
188 | interfaceOrientation: InterfaceOrientation;
|
189 | };
|
190 | export declare enum InterfaceOrientation {
|
191 | ROTATION_0 = 0,
|
192 | ROTATION_90 = 90,
|
193 | ROTATION_180 = 180,
|
194 | ROTATION_270 = 270
|
195 | }
|
196 | export type ShadowNodeWrapper = {
|
197 | __hostObjectShadowNodeWrapper: never;
|
198 | };
|
199 | export declare enum KeyboardState {
|
200 | UNKNOWN = 0,
|
201 | OPENING = 1,
|
202 | OPEN = 2,
|
203 | CLOSING = 3,
|
204 | CLOSED = 4
|
205 | }
|
206 | export type AnimatedKeyboardInfo = {
|
207 | height: SharedValue<number>;
|
208 | state: SharedValue<KeyboardState>;
|
209 | };
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 | export interface MeasuredDimensions {
|
222 | x: number;
|
223 | y: number;
|
224 | width: number;
|
225 | height: number;
|
226 | pageX: number;
|
227 | pageY: number;
|
228 | }
|
229 | export interface AnimatedKeyboardOptions {
|
230 | isStatusBarTranslucentAndroid?: boolean;
|
231 | isNavigationBarTranslucentAndroid?: boolean;
|
232 | }
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | export declare enum ReduceMotion {
|
241 | System = "system",
|
242 | Always = "always",
|
243 | Never = "never"
|
244 | }
|
245 | export type EasingFunction = (t: number) => number;
|
246 | export type TransformArrayItem = Extract<TransformsStyle['transform'], Array<unknown>>[number];
|
247 | type MaybeSharedValue<Value> = Value | (Value extends AnimatableValue ? SharedValueDisableContravariance<Value> : never);
|
248 | type MaybeSharedValueRecursive<Value> = Value extends (infer Item)[] ? SharedValueDisableContravariance<Item[]> | (MaybeSharedValueRecursive<Item> | Item)[] : Value extends object ? SharedValueDisableContravariance<Value> | {
|
249 | [Key in keyof Value]: MaybeSharedValueRecursive<Value[Key]> | Value[Key];
|
250 | } : MaybeSharedValue<Value>;
|
251 | type DefaultStyle = ViewStyle & ImageStyle & TextStyle;
|
252 | export type AnimatedStyle<Style = DefaultStyle> = Style | MaybeSharedValueRecursive<Style>;
|
253 | export type AnimatedTransform = MaybeSharedValueRecursive<TransformsStyle['transform']>;
|
254 |
|
255 | export type AnimateStyle<Style = DefaultStyle> = AnimatedStyle<Style>;
|
256 |
|
257 | export type StylesOrDefault<T> = 'style' extends keyof T ? MaybeSharedValueRecursive<T['style']> : Record<string, unknown>;
|
258 | export {};
|
259 |
|
\ | No newline at end of file |