Skip to content

Commit f2be56f

Browse files
committed
Add svg-spriter's Config and Shape interface
1 parent bcccc00 commit f2be56f

File tree

1 file changed

+145
-5
lines changed

1 file changed

+145
-5
lines changed

svg-sprite/svg-sprite.d.ts

Lines changed: 145 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,169 @@
33
// Definitions by: Qubo <https://github.com/tkqubo>
44
// Definitions: https://github.com/borisyankov/DefinitelyTyped
55

6+
/// <reference path="../node/node.d.ts" />
67
/// <reference path="../vinyl/vinyl.d.ts" />
8+
/// <reference path="../winston/winston.d.ts" />
79

10+
import {LoggerInstance} from "winston";
811
declare module "svg-sprite" {
912
import File = require('vinyl');
1013

1114
namespace sprite {
12-
interface SVGSpriterConstructor {
13-
new(config: any): SVGSpriter;
15+
interface SVGSpriterConstructor extends NodeJS.EventEmitter {
16+
new(config: Config): SVGSpriter;
1417
}
1518

1619
interface SVGSpriter {
1720
add(file: string|File, name: string, svg: string): SVGSpriter;
18-
compile(config: any, callback: CompileCallback): SVGSpriter;
21+
compile(config: Config, callback: CompileCallback): SVGSpriter;
1922
compile(callback: CompileCallback): void;
2023
getShapes(dest: string, callback: GetShapesCallback): void;
2124
}
2225

26+
interface Config {
27+
/**
28+
* Main output directory
29+
* @default '.'
30+
*/
31+
dest?: string;
32+
/**
33+
* Logging verbosity or custom logger
34+
*/
35+
log?: string|LoggerInstance;
36+
/**
37+
* SVG shape configuration
38+
*/
39+
shape?: Shape;
40+
/**
41+
* Sprite SVG options
42+
*/
43+
svg?: Svg;
44+
/**
45+
* Custom templating variables
46+
*/
47+
variables?: any;
48+
/**
49+
* Output mode configurations
50+
*/
51+
mode?: Mode;
52+
}
53+
54+
/**
55+
* All settings affecting the SVG shapes of the sprite
56+
*/
57+
interface Shape {
58+
/**
59+
* SVG shape ID related options
60+
*/
61+
id: {
62+
/**
63+
* Separator for directory name traversal
64+
*/
65+
separator: string;
66+
/**
67+
* SVG shape ID generator callback
68+
*/
69+
generator: string|((string) => string);
70+
/**
71+
* File name separator for shape states (e.g. ':hover')
72+
*/
73+
pseudo: string;
74+
/**
75+
* Whitespace replacement for shape IDs
76+
*/
77+
whitespace: string;
78+
};
79+
/**
80+
* Dimension related options
81+
*/
82+
dimension: {
83+
/**
84+
* Max. shape width
85+
*/
86+
maxWidth: number;
87+
/**
88+
* Max. shape height
89+
*/
90+
maxHeight: number;
91+
/**
92+
* Floating point precision
93+
*/
94+
precision: number;
95+
/**
96+
* Width and height attributes on embedded shapes
97+
*/
98+
attributes: boolean;
99+
};
100+
/**
101+
* Spacing related options
102+
*/
103+
spacing: {
104+
/**
105+
* Padding around all shapes
106+
*/
107+
padding: number|number[];
108+
/**
109+
* Padding strategy (similar to CSS `box-sizing`)
110+
*/
111+
box: string;
112+
};
113+
/**
114+
* List of transformations / optimizations
115+
*/
116+
transform: (string|CustomConfigurationTransform|CustomCallbackTransform)[];
117+
/**
118+
* Path to YAML file with meta / accessibility data
119+
*/
120+
meta: string;
121+
/**
122+
* Path to YAML file with extended alignment data
123+
*/
124+
align: string;
125+
/**
126+
* Output directory for optimized intermediate SVG shapes
127+
*/
128+
dest: string;
129+
}
130+
131+
/**
132+
* Pre-defined shape transformation with custom configuration
133+
*/
134+
interface CustomConfigurationTransform {
135+
[transformationName: string]: {
136+
plugins: { [transformationName: string]: boolean }[];
137+
}
138+
}
139+
140+
/**
141+
* Custom callback transformation
142+
*/
143+
interface CustomCallbackTransform {
144+
[transformationName: string]: {
145+
/**
146+
* Custom callback transformation
147+
* @param shape SVG shape object
148+
* @param sprite SVG spriter
149+
* @param callback Callback
150+
*/
151+
(shape: any, sprite: SVGSpriter, callback: Function): any;
152+
}
153+
}
154+
155+
interface Svg {
156+
157+
}
158+
159+
interface Mode {
160+
161+
}
162+
23163
interface CompileCallback {
24-
(error: any, result: any, data: any): any;
164+
(error: Error, result: any, data: any): any;
25165
}
26166

27167
interface GetShapesCallback {
28-
(error: any, result: File[]): any;
168+
(error: Error, result: File[]): any;
29169
}
30170
}
31171

0 commit comments

Comments
 (0)