-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
types.ts
89 lines (75 loc) · 1.89 KB
/
types.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
import type {
FrameworkConfig,
VanillaFrameworkConfig,
} from "@grida/builder-config";
import { LICENSE_CE } from "./license";
import type { TPlugin } from "@code-plugin/core";
export type FigmaNodeInput =
| string
| { url: string; version: string }
| { filekey: string; node: string; version: string };
type DebugOptions = {
/**
* if true, the response will be a vanilla html without other data.
* @default false
*/
raw?: boolean;
};
export type CodeRequest = DebugOptions & {
figma: FigmaNodeInput;
framework: Partial<FrameworkConfig>;
plugins?: TPlugin[];
};
export type CodeResponse = FigmaToVanillaResponse;
export type ApiEngineInfo = {
name: "code.grida.co/api/v1";
version: "2023.1.1";
license: "AGPL-3.0";
};
export type D2CSourceMap = {};
export type FigmaOriginalFileData = {
name: string;
lastModified: string;
thumbnailUrl: string;
version: string;
};
export type FigmaInputPong = {
file?: FigmaOriginalFileData;
filekey: string;
/**
* the id of entry node. usually it is the root node.
*/
entry: string;
/**
* the full node tree, including only essential information. like size, position, etc.
*/
node?: object;
json?: object;
};
export interface BaseFigmaInputResponse {
figma: FigmaInputPong;
}
export interface BaseResponse {
framework: FrameworkConfig;
engine: ApiEngineInfo;
version: 0; // for now, there is no versioning
license: typeof LICENSE_CE;
warnings: string[];
}
export interface BaseWebFrameworkResponse extends BaseResponse {
src?: string | null;
srcdoc?: string | null;
srcmap?: D2CSourceMap | null;
files: {
[key: string]: string;
};
thumbnail?: string;
}
export interface VanillaCodeResponse extends BaseWebFrameworkResponse {
framework: VanillaFrameworkConfig;
}
export interface FigmaToVanillaResponse
extends VanillaCodeResponse,
BaseFigmaInputResponse {
figma: FigmaInputPong;
}