-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathsvgo.d.ts
189 lines (176 loc) · 5.01 KB
/
svgo.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import type {
StringifyOptions,
DataUri,
Plugin,
XastChild,
XastNode,
} from './types.js';
import type {
BuiltinsWithOptionalParams,
BuiltinsWithRequiredParams,
PluginsParams,
} from '../plugins/plugins-types.js';
export type CustomPlugin<T = any> = {
name: string;
fn: Plugin<T>;
params?: T;
};
export type PluginConfig =
| keyof BuiltinsWithOptionalParams
| {
[Name in keyof BuiltinsWithOptionalParams]: {
name: Name;
params?: BuiltinsWithOptionalParams[Name];
};
}[keyof BuiltinsWithOptionalParams]
| {
[Name in keyof BuiltinsWithRequiredParams]: {
name: Name;
params: BuiltinsWithRequiredParams[Name];
};
}[keyof BuiltinsWithRequiredParams]
| CustomPlugin;
type BuiltinPlugin<Name, Params> = {
/** Name of the plugin, also known as the plugin ID. */
name: Name;
description?: string;
fn: Plugin<Params>;
};
export type BuiltinPluginOrPreset<Name, Params> = BuiltinPlugin<
Name,
Params
> & {
/** If the plugin is itself a preset that invokes other plugins. */
isPreset: true | undefined;
/**
* If the plugin is a preset that invokes other plugins, this returns an
* array of the plugins in the preset in the order that they are invoked.
*/
plugins?: Readonly<BuiltinPlugin<string, Object>[]>;
};
/**
* Plugins that are bundled with SVGO. This includes plugin presets, and plugins
* that are not enabled by default.
*/
export declare const builtinPlugins: Array<
{
[Name in keyof PluginsParams]: BuiltinPluginOrPreset<
Name,
PluginsParams[Name]
>;
}[keyof PluginsParams]
>;
export type Config = {
/** Can be used by plugins, for example prefixids */
path?: string;
/** Pass over SVGs multiple times to ensure all optimizations are applied. */
multipass?: boolean;
/** Precision of floating point numbers. Will be passed to each plugin that supports this param. */
floatPrecision?: number;
/**
* Plugins configuration
* ['preset-default'] is default
* Can also specify any builtin plugin
* ['sortAttrs', { name: 'prefixIds', params: { prefix: 'my-prefix' } }]
* Or custom
* [{ name: 'myPlugin', fn: () => ({}) }]
*/
plugins?: PluginConfig[];
/** Options for rendering optimized SVG from AST. */
js2svg?: StringifyOptions;
/** Output as Data URI string. */
datauri?: DataUri;
};
export type Output = {
data: string;
};
export declare const _collections: {
elemsGroups: Readonly<Record<string, Set<string>>>;
/**
* Elements where adding or removing whitespace may effect rendering, metadata,
* or semantic meaning.
*
* @see https://developer.mozilla.org/docs/Web/HTML/Element/pre
*/
textElems: Readonly<Set<string>>;
pathElems: Readonly<Set<string>>;
/**
* @see https://www.w3.org/TR/SVG11/intro.html#Definitions
*/
attrsGroups: Readonly<Record<string, Set<string>>>;
attrsGroupsDefaults: Readonly<Record<string, Record<string, string>>>;
/**
* @see https://www.w3.org/TR/SVG11/intro.html#Definitions
*/
attrsGroupsDeprecated: Readonly<
Record<string, { safe?: Set<string>; unsafe?: Set<string> }>
>;
/**
* @see https://www.w3.org/TR/SVG11/eltindex.html
*/
elems: Readonly<
Record<
string,
{
attrsGroups: Set<string>;
attrs?: Set<string>;
defaults?: Record<string, string>;
deprecated?: {
safe?: Set<string>;
unsafe?: Set<string>;
};
contentGroups?: Set<string>;
content?: Set<string>;
}
>
>;
/**
* @see https://wiki.inkscape.org/wiki/index.php/Inkscape-specific_XML_attributes
*/
editorNamespaces: Readonly<Set<string>>;
/**
* @see https://www.w3.org/TR/SVG11/linking.html#processingIRI
*/
referencesProps: Readonly<Set<string>>;
/**
* @see https://www.w3.org/TR/SVG11/propidx.html
*/
inheritableAttrs: Readonly<Set<string>>;
presentationNonInheritableGroupAttrs: Readonly<Set<string>>;
/**
* @see https://www.w3.org/TR/SVG11/single-page.html#types-ColorKeywords
*/
colorsNames: Readonly<Record<string, string>>;
colorsShortNames: Readonly<Record<string, string>>;
/**
* @see https://www.w3.org/TR/SVG11/single-page.html#types-DataTypeColor
*/
colorsProps: Readonly<Set<string>>;
/**
* @see https://developer.mozilla.org/docs/Web/CSS/Pseudo-classes
*/
pseudoClasses: Readonly<Record<string, Set<string>>>;
};
export type * from './types.d.ts';
/** Installed version of SVGO. */
export declare const VERSION: string;
/** The core of SVGO */
export declare function optimize(input: string, config?: Config): Output;
/**
* @param node Element to query the children of.
* @param selector CSS selector string.
* @returns First match, or null if there was no match.
*/
export declare function querySelector(
node: XastNode,
selector: string,
): XastChild | null;
/**
* @param node Element to query the children of.
* @param selector CSS selector string.
* @returns All matching elements.
*/
export declare function querySelectorAll(
node: XastNode,
selector: string,
): XastChild[];