-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
commonTypes.ts
171 lines (146 loc) · 3.47 KB
/
commonTypes.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import {
PerpectiveTransform,
RotateTransform,
RotateXTransform,
RotateYTransform,
RotateZTransform,
ScaleTransform,
ScaleXTransform,
ScaleYTransform,
TranslateXTransform,
TranslateYTransform,
SkewXTransform,
SkewYTransform,
MatrixTransform,
ViewStyle,
TextStyle,
} from 'react-native';
import { Context } from './hook/commonTypes';
export type TransformProperty =
| PerpectiveTransform
| RotateTransform
| RotateXTransform
| RotateYTransform
| RotateZTransform
| ScaleTransform
| ScaleXTransform
| ScaleYTransform
| TranslateXTransform
| TranslateYTransform
| SkewXTransform
| SkewYTransform
| MatrixTransform;
export interface StyleProps extends ViewStyle, TextStyle {
originX?: number;
originY?: number;
[key: string]: any;
}
export interface AnimatedStyle
extends Record<string, Animation<AnimationObject>> {
[key: string]: any;
transform?: Array<Record<string, Animation<AnimationObject>>>;
}
export interface SharedValue<T> {
value: T;
}
export interface WorkletFunction {
_closure?: Context;
__workletHash?: number;
__optimalization?: number;
}
export interface BasicWorkletFunction<T> extends WorkletFunction {
(): T;
}
export interface BasicWorkletFunctionOptional<T> extends WorkletFunction {
(): Partial<T>;
}
export interface NativeEvent<T> {
nativeEvent: T;
}
export interface ComplexWorkletFunction<A extends any[], R>
extends WorkletFunction {
(...args: A): R;
}
export interface NestedObject<T> {
[key: string]: NestedObjectValues<T>;
}
export type NestedObjectValues<T> =
| T
| Array<NestedObjectValues<T>>
| NestedObject<T>;
export interface AdapterWorkletFunction extends WorkletFunction {
(value: NestedObject<string | number | AnimationObject>): void;
}
export type AnimatableValue = number | string | Array<number>;
export interface AnimationObject {
[key: string]: any;
callback: AnimationCallback;
current?: AnimatableValue;
toValue?: AnimationObject['current'];
startValue?: AnimationObject['current'];
finished?: boolean;
strippedCurrent?: number;
cancelled?: boolean;
__prefix?: string;
__suffix?: string;
onFrame: (animation: any, timestamp: Timestamp) => boolean;
onStart: (
nextAnimation: any,
current: any,
timestamp: Timestamp,
previousAnimation: any
) => void;
}
export interface Animation<T extends AnimationObject> extends AnimationObject {
onFrame: (animation: T, timestamp: Timestamp) => boolean;
onStart: (
nextAnimation: T,
current: T extends NumericAnimation ? number : AnimatableValue,
timestamp: Timestamp,
previousAnimation: T
) => void;
}
export interface NumericAnimation {
current?: number;
}
export type AnimationCallback = (
finished?: boolean,
current?: AnimatableValue
) => void;
export type Timestamp = number;
export type Value3D = {
x: number;
y: number;
z: number;
};
export type SensorValue3D = SharedValue<Value3D>;
export type ValueRotation = {
qw: number;
qx: number;
qy: number;
qz: number;
yaw: number;
pitch: number;
roll: number;
};
export type SensorValueRotation = SharedValue<ValueRotation>;
export type ShadowNodeWrapper = object;
export enum KeyboardState {
UNKNOWN = 0,
OPENING = 1,
OPEN = 2,
CLOSING = 3,
CLOSED = 4,
}
export type AnimatedKeyboardInfo = {
height: SharedValue<number>;
state: SharedValue<KeyboardState>;
};
export interface MeasuredDimensions {
x: number;
y: number;
width: number;
height: number;
pageX: number;
pageY: number;
}