-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.d.ts
147 lines (133 loc) · 3.43 KB
/
index.d.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
/**
* An object containing global template definitions.
* "components" is a map binding component keys to codegen result arrays.
* "types" is a map binding NodeTypes to codegen result arrays.
*/
type CodeSnippetGlobalTemplates = {
components?: CodegenResultTemplatesByComponentKey;
types?: { [K in NodeType | "DEFAULT"]?: CodegenResult[] };
};
/**
* An object of params to fill a snippet template where k is like "property.variant"
*/
type CodeSnippetParams = { [k: string]: string };
/**
* An object of template specific params, only generated when template calls for it.
*/
type CodeSnippetParamsTemplateParams = {
code: string;
children?: CodeSnippetParamsMap[];
svg?: string;
};
/**
* A map of raw and normalized code snippet params objects. Keys are implicitly the same, values are formatted differently.
*/
type CodeSnippetParamsMap = {
paramsRaw: CodeSnippetParams;
params: CodeSnippetParams;
template: {
[templateId: string]: CodeSnippetParamsTemplateParams;
};
};
/**
* An transient object that can hold values by any component property type
*/
type ComponentPropValues = {
[K in ComponentPropertyType]?: string | boolean;
};
/**
* A map of ComponentPropValuesMaps where the key is a property name.
* Used to see if properties with the same name exist but with different types.
*/
type ComponentPropValuesMap = {
[k: string]: ComponentPropValues;
};
/**
* All filters for string transformation
* https://github.com/figma/code-snippet-editor-plugin#filters
*/
type SnippetStringFilter =
| "hyphen"
| "camel"
| "constant"
| "pascal"
| "raw"
| "snake";
interface NodeSnippetTemplateData {
/**
* CodegenResult containing hydrated snippets
*/
codegenResultArray: CodegenResult[];
/**
* CodegenResult of raw templates to be returned supplementally in "details mode"
* https://github.com/figma/code-snippet-editor-plugin#details-mode
*/
codegenResultRawTemplatesArray: CodegenResult[];
}
/**
* JSON format of codegen result where key is the component key and value is an array of CodegenResult templates
*/
type CodegenResultTemplatesByComponentKey = {
[componentKey: string]: CodegenResult[];
};
/**
* Object of components and component sets by key
*/
type ComponentsByComponentKey = {
[componentKey: string]: ComponentNode | ComponentSetNode;
};
/**
* Events coming in from the editor.html ui
*/
type EventFromEditor =
| {
type: "EDITOR_INITIALIZE";
}
| EventFromEditorSave;
type EventFromEditorSave = {
type: "EDITOR_SAVE";
data: CodegenResult[];
};
/**
* Events sending to the editor.html ui
*/
type EventToEditor = {
type: "EDITOR_SELECTION";
nodeId: string | null;
nodeType: SceneNode["type"] | null;
nodePluginData: CodegenResult[] | null;
};
/**
* Events coming in from the templates.html ui
*/
type EventFromTemplates = EventFromTemplatesData;
type EventFromTemplatesData = {
type: "TEMPLATES_DATA";
data: CodeSnippetGlobalTemplates;
};
/**
* Events sending to the tempaltes.html ui
*/
type EventToTemplates = {
type: "TEMPLATES_INITIALIZE";
templates: CodeSnippetGlobalTemplates | "{}";
};
/**
* Events coming in from the bulk.html ui
*/
type EventFromBulk =
| {
type: "BULK_INITIALIZE" | "BULK_EXPORT";
}
| EventFromBulkImport;
type EventFromBulkImport = {
type: "BULK_IMPORT";
data: CodegenResultTemplatesByComponentKey;
};
/**
* Events sending to the bulk.html ui
*/
type EventToBulk = {
type: "BULK_EXPORT";
code: string;
};