|
1 | 1 | import type { StringifyOptions, DataUri, Plugin as PluginFn } from './types';
|
2 |
| - |
3 |
| -type PluginDef = { |
4 |
| - name: string; |
5 |
| - fn: PluginFn<unknown>; |
6 |
| -}; |
7 |
| - |
8 |
| -type Usage<T extends PluginDef> = { |
9 |
| - name: T['name']; |
10 |
| - params?: Parameters<T['fn']>[1]; |
11 |
| -}; |
12 |
| - |
13 |
| -type UsageReqParams<T extends PluginDef> = { |
14 |
| - name: T['name']; |
15 |
| - params: Parameters<T['fn']>[1]; |
16 |
| -}; |
| 2 | +import type { |
| 3 | + BuiltinsWithOptionalParams, |
| 4 | + BuiltinsWithRequiredParams, |
| 5 | +} from '../plugins/plugins-types'; |
17 | 6 |
|
18 | 7 | type CustomPlugin = {
|
19 | 8 | name: string;
|
20 | 9 | fn: PluginFn<void>;
|
21 | 10 | };
|
22 | 11 |
|
23 |
| -type DefaultPlugin = |
24 |
| - | Usage<typeof import('../plugins/cleanupAttrs.js')> |
25 |
| - | Usage<typeof import('../plugins/cleanupEnableBackground.js')> |
26 |
| - | Usage<typeof import('../plugins/cleanupIds.js')> |
27 |
| - | Usage<typeof import('../plugins/cleanupNumericValues.js')> |
28 |
| - | Usage<typeof import('../plugins/collapseGroups.js')> |
29 |
| - | Usage<typeof import('../plugins/convertColors.js')> |
30 |
| - | Usage<typeof import('../plugins/convertEllipseToCircle.js')> |
31 |
| - | Usage<typeof import('../plugins/convertPathData.js')> |
32 |
| - | Usage<typeof import('../plugins/convertShapeToPath.js')> |
33 |
| - | Usage<typeof import('../plugins/convertTransform.js')> |
34 |
| - | Usage<typeof import('../plugins/mergeStyles.js')> |
35 |
| - | Usage<typeof import('../plugins/inlineStyles.js')> |
36 |
| - | Usage<typeof import('../plugins/mergePaths.js')> |
37 |
| - | Usage<typeof import('../plugins/minifyStyles.js')> |
38 |
| - | Usage<typeof import('../plugins/moveElemsAttrsToGroup.js')> |
39 |
| - | Usage<typeof import('../plugins/moveGroupAttrsToElems.js')> |
40 |
| - | Usage<typeof import('../plugins/removeComments.js')> |
41 |
| - | Usage<typeof import('../plugins/removeDesc.js')> |
42 |
| - | Usage<typeof import('../plugins/removeDoctype.js')> |
43 |
| - | Usage<typeof import('../plugins/removeEditorsNSData.js')> |
44 |
| - | Usage<typeof import('../plugins/removeEmptyAttrs.js')> |
45 |
| - | Usage<typeof import('../plugins/removeEmptyContainers.js')> |
46 |
| - | Usage<typeof import('../plugins/removeEmptyText.js')> |
47 |
| - | Usage<typeof import('../plugins/removeHiddenElems.js')> |
48 |
| - | Usage<typeof import('../plugins/removeMetadata.js')> |
49 |
| - | Usage<typeof import('../plugins/removeNonInheritableGroupAttrs.js')> |
50 |
| - | Usage<typeof import('../plugins/removeTitle.js')> |
51 |
| - | Usage<typeof import('../plugins/removeUnknownsAndDefaults.js')> |
52 |
| - | Usage<typeof import('../plugins/removeUnusedNS.js')> |
53 |
| - | Usage<typeof import('../plugins/removeUselessDefs.js')> |
54 |
| - | Usage<typeof import('../plugins/removeUselessStrokeAndFill.js')> |
55 |
| - | Usage<typeof import('../plugins/removeViewBox.js')> |
56 |
| - | Usage<typeof import('../plugins/removeXMLProcInst.js')> |
57 |
| - | Usage<typeof import('../plugins/sortAttrs.js')> |
58 |
| - | Usage<typeof import('../plugins/sortDefsChildren.js')>; |
59 |
| - |
60 |
| -type Overrides<T = DefaultPlugin> = T extends DefaultPlugin |
61 |
| - ? { [key in T['name']]?: T['params'] | false } |
62 |
| - : never; |
63 |
| - |
64 |
| -type PresetDefault = { |
65 |
| - name: 'preset-default'; |
66 |
| - params?: { |
67 |
| - floatPrecision?: number; |
68 |
| - /** |
69 |
| - * All default plugins can be customized or disabled here |
70 |
| - * for example |
71 |
| - * { |
72 |
| - * sortAttrs: { xmlnsOrder: "alphabetical" }, |
73 |
| - * cleanupAttrs: false, |
74 |
| - * } |
75 |
| - */ |
76 |
| - overrides?: Overrides; |
77 |
| - }; |
78 |
| -}; |
79 |
| - |
80 |
| -type BuiltinPluginWithOptionalParams = |
81 |
| - | DefaultPlugin |
82 |
| - | PresetDefault |
83 |
| - | Usage<typeof import('../plugins/cleanupListOfValues.js')> |
84 |
| - | Usage<typeof import('../plugins/convertStyleToAttrs.js')> |
85 |
| - | Usage<typeof import('../plugins/prefixIds.js')> |
86 |
| - | Usage<typeof import('../plugins/removeDimensions.js')> |
87 |
| - | Usage<typeof import('../plugins/removeOffCanvasPaths.js')> |
88 |
| - | Usage<typeof import('../plugins/removeRasterImages.js')> |
89 |
| - | Usage<typeof import('../plugins/removeScriptElement.js')> |
90 |
| - | Usage<typeof import('../plugins/removeStyleElement.js')> |
91 |
| - | Usage<typeof import('../plugins/removeXMLNS.js')> |
92 |
| - | Usage<typeof import('../plugins/reusePaths.js')>; |
93 |
| - |
94 |
| -type BuiltinPluginWithRequiredParams = |
95 |
| - | UsageReqParams<typeof import('../plugins/addAttributesToSVGElement.js')> |
96 |
| - | UsageReqParams<typeof import('../plugins/addClassesToSVGElement.js')> |
97 |
| - | UsageReqParams<typeof import('../plugins/removeAttributesBySelector.js')> |
98 |
| - | UsageReqParams<typeof import('../plugins/removeAttrs.js')> |
99 |
| - | UsageReqParams<typeof import('../plugins/removeElementsByAttr.js')>; |
100 |
| - |
101 | 12 | type PluginConfig =
|
102 |
| - | BuiltinPluginWithOptionalParams['name'] |
103 |
| - | BuiltinPluginWithOptionalParams |
104 |
| - | BuiltinPluginWithRequiredParams |
| 13 | + | keyof BuiltinsWithOptionalParams |
| 14 | + | { |
| 15 | + [Name in keyof BuiltinsWithOptionalParams]: { |
| 16 | + name: Name; |
| 17 | + params?: BuiltinsWithOptionalParams[Name]; |
| 18 | + }; |
| 19 | + }[keyof BuiltinsWithOptionalParams] |
| 20 | + | { |
| 21 | + [Name in keyof BuiltinsWithRequiredParams]: { |
| 22 | + name: Name; |
| 23 | + params: BuiltinsWithRequiredParams[Name]; |
| 24 | + }; |
| 25 | + }[keyof BuiltinsWithRequiredParams] |
105 | 26 | | CustomPlugin;
|
106 | 27 |
|
107 | 28 | export type Config = {
|
|
0 commit comments