-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathfigma.d.ts
More file actions
171 lines (152 loc) · 4.41 KB
/
figma.d.ts
File metadata and controls
171 lines (152 loc) · 4.41 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
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
// Figma Plugin API Type Definitions
// This provides type coverage for the plugin to compile without errors
declare global {
const figma: {
showUI: (html: string, options?: { width?: number; height?: number }) => void;
notify: (message: string, options?: { timeout?: number; error?: boolean }) => void;
currentPage: {
selection: SceneNode[];
findAll: (callback: (node: SceneNode) => boolean) => SceneNode[];
};
ui: {
onmessage: ((callback: (message: any) => void) => void) | ((message: any) => void);
postMessage: (message: any) => void;
};
on: (event: string, callback: () => void) => void;
clientStorage: {
getAsync: (key: string) => Promise<any>;
setAsync: (key: string, value: any) => Promise<void>;
deleteAsync: (key: string) => Promise<void>;
};
viewport: {
scrollAndZoomIntoView: (nodes: SceneNode[]) => void;
};
createComponent: () => ComponentNode;
createFrame: () => FrameNode;
createText: () => TextNode;
group: (nodes: SceneNode[], parent: BaseNode) => GroupNode;
loadFontAsync: (fontName: { family: string; style: string }) => Promise<void>;
getStyleById: (id: string) => { name: string } | null;
variables: {
getVariableById: (id: string) => { name: string } | null;
};
editorType?: string;
mode?: string;
};
const __html__: string;
// Color types
interface RGB {
r: number;
g: number;
b: number;
}
interface RGBA {
r: number;
g: number;
b: number;
a: number;
}
// Paint types
interface Paint {
type: string;
visible?: boolean;
opacity?: number;
color?: RGB;
}
interface SolidPaint extends Paint {
type: 'SOLID';
color: RGB;
}
// Effect types
interface Effect {
type: string;
visible: boolean;
radius?: number;
offset?: { x: number; y: number };
}
interface DropShadowEffect extends Effect {
type: 'DROP_SHADOW';
color: RGBA;
offset: { x: number; y: number };
radius: number;
blendMode: string;
}
// Base node types
interface BaseNode {
id: string;
parent: BaseNode | null;
appendChild(child: SceneNode): void;
remove(): void;
clone(): SceneNode;
setPluginData(key: string, value: string): void;
getPluginData(key: string): string;
}
interface SceneNode extends BaseNode {
name: string;
type: string;
visible: boolean;
locked: boolean;
x?: number;
y?: number;
width?: number;
height?: number;
fills?: Paint[];
strokes?: Paint[];
strokeWeight?: number;
strokeAlign?: 'INSIDE' | 'OUTSIDE' | 'CENTER';
dashPattern?: number[];
effects?: Effect[];
opacity?: number;
cornerRadius?: number;
children?: SceneNode[];
parent: BaseNode | null;
resize(width: number, height: number): void;
}
interface ContainerNode extends SceneNode {
children: SceneNode[];
appendChild(child: SceneNode): void;
}
// Base interface for frame-like nodes (Frame, Component, Instance, etc.)
interface BaseFrameNode extends ContainerNode {
layoutMode: 'NONE' | 'HORIZONTAL' | 'VERTICAL';
layoutAlign: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH';
itemSpacing: number;
paddingTop: number;
paddingRight: number;
paddingBottom: number;
paddingLeft: number;
constraints?: { horizontal: string; vertical: string };
}
interface FrameNode extends BaseFrameNode {
type: 'FRAME';
}
interface GroupNode extends ContainerNode {
type: 'GROUP';
}
interface TextNode extends SceneNode {
type: 'TEXT';
characters: string;
fontSize: number | symbol;
fontName: { family: string; style: string } | symbol;
textAlignHorizontal: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED';
textAlignVertical: 'TOP' | 'CENTER' | 'BOTTOM';
lineHeight: { value: number; unit: 'PIXELS' | 'PERCENT' | 'AUTO' } | symbol;
letterSpacing: { value: number; unit: 'PIXELS' | 'PERCENT' } | symbol;
}
interface ComponentNode extends BaseFrameNode {
type: 'COMPONENT';
description: string;
documentationLinks: { uri: string }[];
createInstance(): InstanceNode;
}
interface ComponentSetNode extends BaseFrameNode {
type: 'COMPONENT_SET';
description: string;
variantGroupProperties: { [property: string]: { values: string[] } };
}
interface InstanceNode extends BaseFrameNode {
type: 'INSTANCE';
mainComponent: ComponentNode | null;
}
}
export {};