|
@@ -0,0 +1,257 @@
|
|
1
|
+/// <reference types="react" />
|
|
2
|
+export interface TLPage<T extends TLShape> {
|
|
3
|
+ id: string;
|
|
4
|
+ name?: string;
|
|
5
|
+ childIndex?: number;
|
|
6
|
+ shapes: Record<string, T>;
|
|
7
|
+ bindings: Record<string, TLBinding>;
|
|
8
|
+ backgroundColor?: string;
|
|
9
|
+}
|
|
10
|
+export interface TLPageState {
|
|
11
|
+ id: string;
|
|
12
|
+ brush?: TLBounds;
|
|
13
|
+ pointedId?: string;
|
|
14
|
+ hoveredId?: string;
|
|
15
|
+ editingId?: string;
|
|
16
|
+ bindingId?: string;
|
|
17
|
+ boundsRotation?: number;
|
|
18
|
+ currentParentId?: string;
|
|
19
|
+ selectedIds: string[];
|
|
20
|
+ camera: {
|
|
21
|
+ point: number[];
|
|
22
|
+ zoom: number;
|
|
23
|
+ };
|
|
24
|
+}
|
|
25
|
+export interface TLHandle {
|
|
26
|
+ id: string;
|
|
27
|
+ index: number;
|
|
28
|
+ point: number[];
|
|
29
|
+ canBind?: boolean;
|
|
30
|
+ bindingId?: string;
|
|
31
|
+}
|
|
32
|
+export interface TLShape {
|
|
33
|
+ id: string;
|
|
34
|
+ type: string;
|
|
35
|
+ parentId: string;
|
|
36
|
+ childIndex: number;
|
|
37
|
+ name: string;
|
|
38
|
+ point: number[];
|
|
39
|
+ rotation?: number;
|
|
40
|
+ children?: string[];
|
|
41
|
+ handles?: Record<string, TLHandle>;
|
|
42
|
+ isLocked?: boolean;
|
|
43
|
+ isHidden?: boolean;
|
|
44
|
+ isEditing?: boolean;
|
|
45
|
+ isGenerated?: boolean;
|
|
46
|
+ isAspectRatioLocked?: boolean;
|
|
47
|
+}
|
|
48
|
+export declare type TLShapeUtils<T extends TLShape> = Record<string, TLShapeUtil<T>>;
|
|
49
|
+export interface TLRenderInfo<T extends SVGElement | HTMLElement = any> {
|
|
50
|
+ isEditing: boolean;
|
|
51
|
+ isBinding: boolean;
|
|
52
|
+ isDarkMode: boolean;
|
|
53
|
+ isCurrentParent: boolean;
|
|
54
|
+ ref?: React.RefObject<T>;
|
|
55
|
+ onTextChange?: TLCallbacks['onTextChange'];
|
|
56
|
+ onTextBlur?: TLCallbacks['onTextBlur'];
|
|
57
|
+ onTextFocus?: TLCallbacks['onTextFocus'];
|
|
58
|
+ onTextKeyDown?: TLCallbacks['onTextKeyDown'];
|
|
59
|
+ onTextKeyUp?: TLCallbacks['onTextKeyUp'];
|
|
60
|
+}
|
|
61
|
+export interface TLTool {
|
|
62
|
+ id: string;
|
|
63
|
+ name: string;
|
|
64
|
+}
|
|
65
|
+export interface TLBinding {
|
|
66
|
+ id: string;
|
|
67
|
+ type: string;
|
|
68
|
+ toId: string;
|
|
69
|
+ fromId: string;
|
|
70
|
+}
|
|
71
|
+export interface TLSettings {
|
|
72
|
+ isDebugMode: boolean;
|
|
73
|
+ isDarkMode: boolean;
|
|
74
|
+ isPenMode: boolean;
|
|
75
|
+}
|
|
76
|
+export interface TLTheme {
|
|
77
|
+ brushFill?: string;
|
|
78
|
+ brushStroke?: string;
|
|
79
|
+ selectFill?: string;
|
|
80
|
+ selectStroke?: string;
|
|
81
|
+ background?: string;
|
|
82
|
+ foreground?: string;
|
|
83
|
+}
|
|
84
|
+export declare type TLWheelEventHandler = (info: TLPointerInfo<string>, e: React.WheelEvent<Element> | WheelEvent) => void;
|
|
85
|
+export declare type TLPinchEventHandler = (info: TLPointerInfo<string>, e: React.WheelEvent<Element> | WheelEvent | React.TouchEvent<Element> | TouchEvent) => void;
|
|
86
|
+export declare type TLPointerEventHandler = (info: TLPointerInfo<string>, e: React.PointerEvent) => void;
|
|
87
|
+export declare type TLCanvasEventHandler = (info: TLPointerInfo<'canvas'>, e: React.PointerEvent) => void;
|
|
88
|
+export declare type TLBoundsEventHandler = (info: TLPointerInfo<'bounds'>, e: React.PointerEvent) => void;
|
|
89
|
+export declare type TLBoundsHandleEventHandler = (info: TLPointerInfo<TLBoundsCorner | TLBoundsEdge | 'rotate'>, e: React.PointerEvent) => void;
|
|
90
|
+export interface TLCallbacks {
|
|
91
|
+ onChange: (ids: string[]) => void;
|
|
92
|
+ onPinchStart: TLPinchEventHandler;
|
|
93
|
+ onPinchEnd: TLPinchEventHandler;
|
|
94
|
+ onPinch: TLPinchEventHandler;
|
|
95
|
+ onPan: TLWheelEventHandler;
|
|
96
|
+ onZoom: TLWheelEventHandler;
|
|
97
|
+ onPointerMove: TLPointerEventHandler;
|
|
98
|
+ onPointerUp: TLPointerEventHandler;
|
|
99
|
+ onPointerDown: TLPointerEventHandler;
|
|
100
|
+ onPointCanvas: TLCanvasEventHandler;
|
|
101
|
+ onDoubleClickCanvas: TLCanvasEventHandler;
|
|
102
|
+ onRightPointCanvas: TLCanvasEventHandler;
|
|
103
|
+ onDragCanvas: TLCanvasEventHandler;
|
|
104
|
+ onReleaseCanvas: TLCanvasEventHandler;
|
|
105
|
+ onPointShape: TLPointerEventHandler;
|
|
106
|
+ onDoubleClickShape: TLPointerEventHandler;
|
|
107
|
+ onRightPointShape: TLPointerEventHandler;
|
|
108
|
+ onDragShape: TLPointerEventHandler;
|
|
109
|
+ onHoverShape: TLPointerEventHandler;
|
|
110
|
+ onUnhoverShape: TLPointerEventHandler;
|
|
111
|
+ onReleaseShape: TLPointerEventHandler;
|
|
112
|
+ onPointBounds: TLBoundsEventHandler;
|
|
113
|
+ onDoubleClickBounds: TLBoundsEventHandler;
|
|
114
|
+ onRightPointBounds: TLBoundsEventHandler;
|
|
115
|
+ onDragBounds: TLBoundsEventHandler;
|
|
116
|
+ onHoverBounds: TLBoundsEventHandler;
|
|
117
|
+ onUnhoverBounds: TLBoundsEventHandler;
|
|
118
|
+ onReleaseBounds: TLBoundsEventHandler;
|
|
119
|
+ onPointBoundsHandle: TLBoundsHandleEventHandler;
|
|
120
|
+ onDoubleClickBoundsHandle: TLBoundsHandleEventHandler;
|
|
121
|
+ onRightPointBoundsHandle: TLBoundsHandleEventHandler;
|
|
122
|
+ onDragBoundsHandle: TLBoundsHandleEventHandler;
|
|
123
|
+ onHoverBoundsHandle: TLBoundsHandleEventHandler;
|
|
124
|
+ onUnhoverBoundsHandle: TLBoundsHandleEventHandler;
|
|
125
|
+ onReleaseBoundsHandle: TLBoundsHandleEventHandler;
|
|
126
|
+ onPointHandle: TLPointerEventHandler;
|
|
127
|
+ onDoubleClickHandle: TLPointerEventHandler;
|
|
128
|
+ onRightPointHandle: TLPointerEventHandler;
|
|
129
|
+ onDragHandle: TLPointerEventHandler;
|
|
130
|
+ onHoverHandle: TLPointerEventHandler;
|
|
131
|
+ onUnhoverHandle: TLPointerEventHandler;
|
|
132
|
+ onReleaseHandle: TLPointerEventHandler;
|
|
133
|
+ onTextChange: (id: string, text: string) => void;
|
|
134
|
+ onTextBlur: (id: string) => void;
|
|
135
|
+ onTextFocus: (id: string) => void;
|
|
136
|
+ onTextKeyDown: (id: string, key: string) => void;
|
|
137
|
+ onTextKeyUp: (id: string, key: string) => void;
|
|
138
|
+ onBlurEditingShape: () => void;
|
|
139
|
+ onError: (error: Error) => void;
|
|
140
|
+}
|
|
141
|
+export interface TLBounds {
|
|
142
|
+ minX: number;
|
|
143
|
+ minY: number;
|
|
144
|
+ maxX: number;
|
|
145
|
+ maxY: number;
|
|
146
|
+ width: number;
|
|
147
|
+ height: number;
|
|
148
|
+ rotation?: number;
|
|
149
|
+}
|
|
150
|
+export declare type TLIntersection = {
|
|
151
|
+ didIntersect: boolean;
|
|
152
|
+ message: string;
|
|
153
|
+ points: number[][];
|
|
154
|
+};
|
|
155
|
+export declare enum TLBoundsEdge {
|
|
156
|
+ Top = "top_edge",
|
|
157
|
+ Right = "right_edge",
|
|
158
|
+ Bottom = "bottom_edge",
|
|
159
|
+ Left = "left_edge"
|
|
160
|
+}
|
|
161
|
+export declare enum TLBoundsCorner {
|
|
162
|
+ TopLeft = "top_left_corner",
|
|
163
|
+ TopRight = "top_right_corner",
|
|
164
|
+ BottomRight = "bottom_right_corner",
|
|
165
|
+ BottomLeft = "bottom_left_corner"
|
|
166
|
+}
|
|
167
|
+export interface TLPointerInfo<T extends string = string> {
|
|
168
|
+ target: T;
|
|
169
|
+ pointerId: number;
|
|
170
|
+ origin: number[];
|
|
171
|
+ point: number[];
|
|
172
|
+ delta: number[];
|
|
173
|
+ pressure: number;
|
|
174
|
+ shiftKey: boolean;
|
|
175
|
+ ctrlKey: boolean;
|
|
176
|
+ metaKey: boolean;
|
|
177
|
+ altKey: boolean;
|
|
178
|
+}
|
|
179
|
+export interface TLKeyboardInfo {
|
|
180
|
+ origin: number[];
|
|
181
|
+ point: number[];
|
|
182
|
+ key: string;
|
|
183
|
+ keys: string[];
|
|
184
|
+ shiftKey: boolean;
|
|
185
|
+ ctrlKey: boolean;
|
|
186
|
+ metaKey: boolean;
|
|
187
|
+ altKey: boolean;
|
|
188
|
+}
|
|
189
|
+export interface TLTransformInfo<T extends TLShape> {
|
|
190
|
+ type: TLBoundsEdge | TLBoundsCorner;
|
|
191
|
+ initialShape: T;
|
|
192
|
+ scaleX: number;
|
|
193
|
+ scaleY: number;
|
|
194
|
+ transformOrigin: number[];
|
|
195
|
+}
|
|
196
|
+export interface TLBezierCurveSegment {
|
|
197
|
+ start: number[];
|
|
198
|
+ tangentStart: number[];
|
|
199
|
+ normalStart: number[];
|
|
200
|
+ pressureStart: number;
|
|
201
|
+ end: number[];
|
|
202
|
+ tangentEnd: number[];
|
|
203
|
+ normalEnd: number[];
|
|
204
|
+ pressureEnd: number;
|
|
205
|
+}
|
|
206
|
+export declare abstract class TLShapeUtil<T extends TLShape> {
|
|
207
|
+ boundsCache: WeakMap<TLShape, TLBounds>;
|
|
208
|
+ isEditableText: boolean;
|
|
209
|
+ isAspectRatioLocked: boolean;
|
|
210
|
+ canEdit: boolean;
|
|
211
|
+ canBind: boolean;
|
|
212
|
+ abstract type: T['type'];
|
|
213
|
+ abstract defaultProps: T;
|
|
214
|
+ abstract render(shape: T, info: TLRenderInfo): JSX.Element;
|
|
215
|
+ abstract renderIndicator(shape: T): JSX.Element | null;
|
|
216
|
+ abstract getBounds(shape: T): TLBounds;
|
|
217
|
+ abstract getRotatedBounds(shape: T): TLBounds;
|
|
218
|
+ abstract hitTest(shape: T, point: number[]): boolean;
|
|
219
|
+ abstract hitTestBounds(shape: T, bounds: TLBounds): boolean;
|
|
220
|
+ abstract transform(shape: T, bounds: TLBounds, info: TLTransformInfo<T>): Partial<T>;
|
|
221
|
+ transformSingle(shape: T, bounds: TLBounds, info: TLTransformInfo<T>): Partial<T>;
|
|
222
|
+ shouldRender(_prev: T, _next: T): boolean;
|
|
223
|
+ shouldDelete(_shape: T): boolean;
|
|
224
|
+ getCenter(shape: T): number[];
|
|
225
|
+ getBindingPoint(shape: T, point: number[], origin: number[], direction: number[], padding: number, anywhere: boolean): {
|
|
226
|
+ point: number[];
|
|
227
|
+ distance: number;
|
|
228
|
+ } | undefined;
|
|
229
|
+ create(props: Partial<T>): T;
|
|
230
|
+ mutate(shape: T, props: Partial<T>): T;
|
|
231
|
+ updateChildren<K extends TLShape>(_shape: T, _children: K[]): Partial<K>[] | void;
|
|
232
|
+ onChildrenChange(_shape: T, _children: TLShape[]): Partial<T> | void;
|
|
233
|
+ onBindingChange(_shape: T, _binding: TLBinding, _target: TLShape, _targetBounds: TLBounds, _center: number[]): Partial<T> | void;
|
|
234
|
+ onHandleChange(_shape: T, _handle: Partial<T['handles']>, _info: Partial<TLPointerInfo>): Partial<T> | void;
|
|
235
|
+ onRightPointHandle(_shape: T, _handle: Partial<T['handles']>, _info: Partial<TLPointerInfo>): Partial<T> | void;
|
|
236
|
+ onDoubleClickHandle(_shape: T, _handle: Partial<T['handles']>, _info: Partial<TLPointerInfo>): Partial<T> | void;
|
|
237
|
+ onSessionComplete(_shape: T): Partial<T> | void;
|
|
238
|
+ onBoundsReset(_shape: T): Partial<T> | void;
|
|
239
|
+ onStyleChange(_shape: T): Partial<T> | void;
|
|
240
|
+}
|
|
241
|
+export interface IShapeTreeNode {
|
|
242
|
+ shape: TLShape;
|
|
243
|
+ children?: IShapeTreeNode[];
|
|
244
|
+ isEditing: boolean;
|
|
245
|
+ isBinding: boolean;
|
|
246
|
+ isDarkMode: boolean;
|
|
247
|
+ isCurrentParent: boolean;
|
|
248
|
+}
|
|
249
|
+export declare type MappedByType<T extends {
|
|
250
|
+ type: string;
|
|
251
|
+}> = {
|
|
252
|
+ [P in T['type']]: T extends any ? (P extends T['type'] ? T : never) : never;
|
|
253
|
+};
|
|
254
|
+export declare type RequiredKeys<T> = {
|
|
255
|
+ [K in keyof T]-?: Record<string, unknown> extends Pick<T, K> ? never : K;
|
|
256
|
+}[keyof T];
|
|
257
|
+export {};
|