UNPKG

9.32 kBTypeScriptView Raw
1// Type definitions for svgo 1.3
2// Project: https://github.com/svg/svgo
3// Definitions by: Bradley Ayers <https://github.com/bradleyayers>
4// Gilad Gray <https://github.com/giladgray>
5// Aankhen <https://github.com/Aankhen>
6// Jan Karres <https://github.com/jankarres>
7// Gavin Gregory <https://github.com/gavingregory>
8// Piotr Błażejewicz <https://github.com/peterblazejewicz>
9// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10// TypeScript Version: 2.2
11
12interface PluginCleanupAttrs {
13 cleanupAttrs: boolean | object;
14}
15
16interface PluginInlineStyles {
17 inlineStyles: boolean | object;
18}
19
20interface PluginRemoveDoctype {
21 removeDoctype: boolean | object;
22}
23
24interface PluginRemoveXMLProcInst {
25 removeXMLProcInst: boolean | object;
26}
27
28interface PluginRemoveComments {
29 removeComments: boolean | object;
30}
31
32interface PluginRemoveMetadata {
33 removeMetadata: boolean | object;
34}
35
36interface PluginRemoveTitle {
37 removeTitle: boolean | object;
38}
39
40interface PluginRemoveDesc {
41 removeDesc: boolean | object;
42}
43
44interface PluginRemoveUselessDefs {
45 removeUselessDefs: boolean | object;
46}
47
48interface PluginRemoveXMLNS {
49 removeXMLNS: boolean | object;
50}
51
52interface PluginRemoveEditorsNSData {
53 removeEditorsNSData: boolean | object;
54}
55
56interface PluginRemoveEmptyAttrs {
57 removeEmptyAttrs: boolean | object;
58}
59
60interface PluginRemoveHiddenElems {
61 removeHiddenElems: boolean | object;
62}
63
64interface PluginRemoveEmptyText {
65 removeEmptyText: boolean | object;
66}
67
68interface PluginRemoveEmptyContainers {
69 removeEmptyContainers: boolean | object;
70}
71
72interface PluginRemoveViewBox {
73 removeViewBox: boolean | object;
74}
75
76interface PluginCleanupEnableBackground {
77 cleanupEnableBackground: boolean | object;
78}
79
80interface PluginMinifyStyles {
81 minifyStyles: boolean | object;
82}
83
84interface PluginConvertStyleToAttrs {
85 convertStyleToAttrs: boolean | object;
86}
87
88interface PluginConvertColors {
89 convertColors: boolean | object;
90}
91
92interface PluginConvertEllipseToCircle {
93 /** convert ellipse with equal radius measures to circle */
94 convertEllipseToCircle: boolean | object;
95}
96
97interface PluginConvertPathData {
98 convertPathData: boolean | object;
99}
100
101interface PluginConvertTransform {
102 convertTransform: boolean | object;
103}
104
105interface PluginRemoveUnknownsAndDefaults {
106 removeUnknownsAndDefaults: boolean | object;
107}
108
109interface PluginRemoveNonInheritableGroupAttrs {
110 removeNonInheritableGroupAttrs: boolean | object;
111}
112
113interface PluginRemoveUselessStrokeAndFill {
114 removeUselessStrokeAndFill: boolean | object;
115}
116
117interface PluginRemoveUnusedNS {
118 removeUnusedNS: boolean | object;
119}
120
121interface PluginPrefixIds {
122 /** prefix IDs and classes with the SVG filename or an arbitrary string */
123 prefixIds: boolean | object;
124}
125
126interface PluginCleanupIDs {
127 cleanupIDs: boolean | object;
128}
129
130interface PluginCleanupNumericValues {
131 cleanupNumericValues: boolean | object;
132}
133
134interface PluginCleanupListOfValues {
135 cleanupListOfValues: boolean | object;
136}
137
138interface PluginMoveElemsAttrsToGroup {
139 moveElemsAttrsToGroup: boolean | object;
140}
141
142interface PluginMoveGroupAttrsToElems {
143 moveGroupAttrsToElems: boolean | object;
144}
145
146interface PluginCollapseGroups {
147 collapseGroups: boolean | object;
148}
149
150interface PluginRemoveRasterImages {
151 removeRasterImages: boolean | object;
152}
153
154interface PluginMergePaths {
155 mergePaths: boolean | object;
156}
157
158interface PluginConvertShapeToPath {
159 convertShapeToPath: boolean | object;
160}
161
162interface PluginSortAttrs {
163 sortAttrs: boolean | object;
164}
165
166interface PluginSortDefsChildren {
167 /** sort children of <defs> in order to improve compression */
168 sortDefsChildren: boolean | object;
169}
170
171interface PluginRemoveDimensions {
172 removeDimensions: boolean | object;
173}
174
175interface PluginRemoveAttrs {
176 removeAttrs: boolean | object;
177}
178
179interface PluginRemoveAttributesBySelector {
180 removeAttributesBySelector: boolean | object;
181}
182
183interface PluginRemoveElementsByAttr {
184 removeElementsByAttr: boolean | object;
185}
186
187interface PluginAddClassesToSVGElement {
188 addClassesToSVGElement: boolean | object;
189}
190
191interface PluginAddAttributesToSVGElement {
192 addAttributesToSVGElement: boolean | object;
193}
194
195interface PluginRemoveOffCanvasPaths {
196 removeOffCanvasPaths: boolean | object;
197}
198
199interface PluginRemoveStyleElement {
200 removeStyleElement: boolean | object;
201}
202
203interface PluginRemoveScriptElement {
204 removeScriptElement: boolean | object;
205}
206
207interface PluginReusePaths {
208 reusePaths: boolean | object;
209}
210
211interface SvgInfo {
212 path?: string;
213}
214
215interface OptimizedSvg {
216 data: string;
217 info: {
218 width: string;
219 height: string;
220 };
221 path?: string;
222}
223
224declare class SVGO {
225 static Config(config?: SVGO.Options): SVGO.Options;
226 constructor(config?: SVGO.Options);
227 optimize(svgString: string, info?: SvgInfo): Promise<OptimizedSvg>;
228}
229
230declare namespace SVGO {
231 type PluginConfig =
232 | PluginCleanupAttrs
233 | PluginInlineStyles
234 | PluginRemoveDoctype
235 | PluginRemoveXMLProcInst
236 | PluginRemoveComments
237 | PluginRemoveMetadata
238 | PluginRemoveTitle
239 | PluginRemoveDesc
240 | PluginRemoveUselessDefs
241 | PluginRemoveXMLNS
242 | PluginRemoveEditorsNSData
243 | PluginRemoveEmptyAttrs
244 | PluginRemoveHiddenElems
245 | PluginRemoveEmptyText
246 | PluginRemoveEmptyContainers
247 | PluginRemoveViewBox
248 | PluginCleanupEnableBackground
249 | PluginMinifyStyles
250 | PluginConvertStyleToAttrs
251 | PluginConvertColors
252 | PluginConvertEllipseToCircle
253 | PluginConvertPathData
254 | PluginConvertTransform
255 | PluginRemoveUnknownsAndDefaults
256 | PluginRemoveNonInheritableGroupAttrs
257 | PluginRemoveUselessStrokeAndFill
258 | PluginRemoveUnusedNS
259 | PluginPrefixIds
260 | PluginCleanupIDs
261 | PluginCleanupNumericValues
262 | PluginCleanupListOfValues
263 | PluginMoveElemsAttrsToGroup
264 | PluginMoveGroupAttrsToElems
265 | PluginCollapseGroups
266 | PluginRemoveRasterImages
267 | PluginMergePaths
268 | PluginConvertShapeToPath
269 | PluginSortAttrs
270 | PluginSortDefsChildren
271 | PluginRemoveDimensions
272 | PluginRemoveAttrs
273 | PluginRemoveAttributesBySelector
274 | PluginRemoveElementsByAttr
275 | PluginAddClassesToSVGElement
276 | PluginAddAttributesToSVGElement
277 | PluginRemoveOffCanvasPaths
278 | PluginRemoveStyleElement
279 | PluginRemoveScriptElement
280 | PluginReusePaths;
281
282 interface Js2SvgOptions {
283 /** @default '<!DOCTYPE' */
284 doctypeStart?: string;
285 /** @default '>' */
286 doctypeEnd?: string;
287 /** @default '<?' */
288 procInstStart?: string;
289 /** @default '?>' */
290 procInstEnd?: string;
291 /** @default '<' */
292 tagOpenStart?: string;
293 /** @default '>' */
294 tagOpenEnd?: string;
295 /** @default '</' */
296 tagCloseStart?: string;
297 /** @default '>' */
298 tagCloseEnd?: string;
299 /** @default '<' */
300 tagShortStart?: string;
301 /** @default '/>' */
302 tagShortEnd?: string;
303 /** @default '="' */
304 attrStart?: string;
305 /** @default '"' */
306 attrEnd?: string;
307 /** @default '<!--' */
308 commentStart?: string;
309 /** @default '-->' */
310 commentEnd?: string;
311 /** @default '<![CDATA[' */
312 cdataStart?: string;
313 /** @default ']]>' */
314 cdataEnd?: string;
315 /** @default '' */
316 textStart?: string;
317 /** @default '' */
318 textEnd?: string;
319 /** @default 4 */
320 indent?: number;
321 /** @default /[&'"<>]/g */
322 regEntities?: RegExp;
323 /** @default /[&"<>]/g */
324 regValEntities?: RegExp;
325 /** @default encodeEntity */
326 encodeEntity?: (char?: string) => string;
327 /** @default false */
328 pretty?: boolean;
329 /** @default true */
330 useShortTags?: boolean;
331 }
332
333 interface Svg2JsOptions {
334 /** @default true */
335 strict?: boolean;
336 /** @default false */
337 trim?: boolean;
338 /** @default true */
339 normalize?: boolean;
340 /** @default true */
341 lowercase?: boolean;
342 /** @default true */
343 xmlns?: boolean;
344 /** @default true */
345 position?: boolean;
346 }
347
348 interface Options {
349 /** Output as Data URI string. */
350 datauri?: 'base64' | 'enc' | 'unenc';
351
352 /** Precision of floating point numbers. Will be passed to each plugin that suppors this param. */
353 floatPrecision?: number;
354
355 /** Use full set of plugins. */
356 full?: boolean;
357
358 /** Options for rendering optimized SVG from AST. */
359 js2svg?: Js2SvgOptions;
360
361 /**
362 * Individual plugin configurations.
363 * For specific options, see plugin source in https://github.com/svg/svgo/tree/master/plugins.
364 */
365 plugins?: PluginConfig[];
366
367 /** Options for parsing original SVG into AST. */
368 svg2js?: Svg2JsOptions;
369 }
370}
371
372export = SVGO;