|
3 | 3 | // Definitions by: Qubo <https://github.com/tkqubo>
|
4 | 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped
|
5 | 5 |
|
| 6 | +/// <reference path="../node/node.d.ts" /> |
6 | 7 | /// <reference path="../vinyl/vinyl.d.ts" />
|
| 8 | +/// <reference path="../winston/winston.d.ts" /> |
7 | 9 |
|
| 10 | +import {LoggerInstance} from "winston"; |
8 | 11 | declare module "svg-sprite" {
|
9 | 12 | import File = require('vinyl');
|
10 | 13 |
|
11 | 14 | namespace sprite {
|
12 |
| - interface SVGSpriterConstructor { |
13 |
| - new(config: any): SVGSpriter; |
| 15 | + interface SVGSpriterConstructor extends NodeJS.EventEmitter { |
| 16 | + new(config: Config): SVGSpriter; |
14 | 17 | }
|
15 | 18 |
|
16 | 19 | interface SVGSpriter {
|
17 | 20 | add(file: string|File, name: string, svg: string): SVGSpriter;
|
18 |
| - compile(config: any, callback: CompileCallback): SVGSpriter; |
| 21 | + compile(config: Config, callback: CompileCallback): SVGSpriter; |
19 | 22 | compile(callback: CompileCallback): void;
|
20 | 23 | getShapes(dest: string, callback: GetShapesCallback): void;
|
21 | 24 | }
|
22 | 25 |
|
| 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 | + |
23 | 163 | interface CompileCallback {
|
24 |
| - (error: any, result: any, data: any): any; |
| 164 | + (error: Error, result: any, data: any): any; |
25 | 165 | }
|
26 | 166 |
|
27 | 167 | interface GetShapesCallback {
|
28 |
| - (error: any, result: File[]): any; |
| 168 | + (error: Error, result: File[]): any; |
29 | 169 | }
|
30 | 170 | }
|
31 | 171 |
|
|
0 commit comments