-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathmodel.ts
More file actions
41 lines (35 loc) · 1.13 KB
/
Copy pathmodel.ts
File metadata and controls
41 lines (35 loc) · 1.13 KB
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
import type { APP_MESSAGE_TYPE, HOST_MESSAGE_TYPE } from './constant';
export interface ContentBbox {
x: number;
y: number;
width: number;
height: number;
}
export interface LoadFilePayload {
data: unknown;
fileName: string;
}
export interface ThemePayload {
background: string;
backgroundSecondary: string;
foreground: string;
}
export type HostMessage =
| {
type: typeof HOST_MESSAGE_TYPE.LOAD;
payload: { content: string; fileName: string };
}
| { type: typeof HOST_MESSAGE_TYPE.SAVED }
| { type: typeof HOST_MESSAGE_TYPE.LOAD_FILE; payload: LoadFilePayload }
| { type: typeof HOST_MESSAGE_TYPE.THEME; payload: ThemePayload };
export type AppMessage =
| { type: typeof APP_MESSAGE_TYPE.READY }
| { type: typeof APP_MESSAGE_TYPE.WEBVIEW_READY }
| { type: typeof APP_MESSAGE_TYPE.SAVE; payload: { content: string } }
| {
type: typeof APP_MESSAGE_TYPE.RENDER_COMPLETE;
payload?: ContentBbox;
}
| { type: typeof APP_MESSAGE_TYPE.NEW_FILE };
export type PayloadOf<U extends { type: string }, T extends U['type']> =
Extract<U, { type: T }> extends { payload: infer P } ? P : undefined;