Skip to content

Commit 4411f03

Browse files
committed
Improve typings
1 parent f2d81ad commit 4411f03

File tree

1 file changed

+179
-1
lines changed

1 file changed

+179
-1
lines changed

typings.d.ts

+179-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,179 @@
1-
export declare function sprites(): any;
1+
import { Plugin, AnyNode, Comment } from 'postcss';
2+
3+
interface Spritesheet {
4+
path: string,
5+
image: string,
6+
groups: string[],
7+
extension: string,
8+
coordinates: { width: number, height: number, x: number, y: number },
9+
properties: { width: number, height: number }
10+
}
11+
12+
interface Image {
13+
/**
14+
* An absolute path to the stylesheet.
15+
*/
16+
styleFilePath: string,
17+
18+
/**
19+
* An absolute path to the image.
20+
*/
21+
path: string,
22+
23+
/**
24+
* The url found in your stylesheet including the query params.
25+
*/
26+
originalUrl: string,
27+
28+
/**
29+
* A normalized version of the original url.
30+
*/
31+
url: string,
32+
33+
/**
34+
* The retina ratio of your image.
35+
*/
36+
ratio: number,
37+
38+
/**
39+
* Indicates whenever your image is retina.
40+
*/
41+
retina: boolean,
42+
43+
/**
44+
* The groups associated with the image.
45+
*/
46+
groups: string[],
47+
48+
/**
49+
* The string used as reference in your stylesheet.
50+
*/
51+
token: string,
52+
53+
/**
54+
* The position & dimensions of image in generated spritesheet.
55+
*/
56+
coords: { width: number, height: number, x: number, y: number },
57+
58+
/**
59+
* A relative path to the generated spritesheet.
60+
*/
61+
spritePath: string,
62+
63+
/**
64+
* A CSS url to the generated spritesheet.
65+
*/
66+
spriteUrl: string,
67+
68+
/**
69+
* The total width of the spritesheet.
70+
*/
71+
spriteWidth: number,
72+
73+
/**
74+
* The total height of the spritesheet.
75+
*/
76+
spriteHeight: number
77+
}
78+
79+
interface Hooks {
80+
/**
81+
* Hook that allows to rewrite the data of produced spritesheet.
82+
*/
83+
onSaveSpritesheet?: (options: Options, spritesheet: Spritesheet) => string|object|Promise<string|object>,
84+
85+
/**
86+
* Hook that allows to rewrite the CSS output for an image.
87+
*/
88+
onUpdateRule?: (rule: AnyNode, token: Comment, image: Image) => void
89+
}
90+
91+
interface Spritesmith {
92+
93+
/**
94+
* The [engine](https://github.com/Ensighten/spritesmith#engines).
95+
*/
96+
engine?: string,
97+
98+
/**
99+
* The [algorithm](https://github.com/Ensighten/spritesmith#algorithms).
100+
*/
101+
algorithm?: 'top-down' | 'left-right' | 'diagonal' | 'alt-diagonal' | 'binary-tree',
102+
103+
/**
104+
* The space between images in spritesheet.
105+
*/
106+
padding?: number,
107+
108+
/**
109+
* The configuration of the [engine](https://github.com/Ensighten/spritesmith#engines).
110+
*/
111+
engineOpts?: object,
112+
113+
/**
114+
* The export options of the [engine](https://github.com/Ensighten/spritesmith#engines).
115+
*/
116+
exportOpts?: object,
117+
}
118+
119+
interface Options {
120+
/**
121+
* Relative path to the folder that will keep your output stylesheet(s). If it's null the path of CSS file will be used.
122+
*/
123+
stylesheetPath?: string,
124+
125+
/**
126+
* Relative path to the folder that will keep your output spritesheet(s).
127+
*/
128+
spritePath: string,
129+
130+
/**
131+
* Your base path that will be used for images with absolute CSS urls.
132+
*/
133+
basePath?: string,
134+
135+
/**
136+
* Indicates whether the url should be relative against current CSS context or original CSS stylesheet file.
137+
*/
138+
relativeTo?: string,
139+
140+
/**
141+
* Defines filter functions that will manipulate the list of images founded in your stylesheet(s).
142+
*/
143+
filterBy?: (image: Image) => Promise<void>,
144+
145+
/**
146+
* Defines group functions that will manipulate the list of images founded in your stylesheet(s).
147+
*/
148+
groupBy?: (image: Image) => Promise<string>,
149+
150+
/**
151+
* Defines whether or not to search for retina mark in the filename.
152+
*/
153+
retina?: boolean,
154+
155+
/**
156+
* Process hooks.
157+
*/
158+
hooks?: Hooks,
159+
160+
/**
161+
* A [spritesmith](https://github.com/Ensighten/spritesmith) configuration.
162+
*/
163+
spritesmith?: Spritesmith,
164+
165+
/**
166+
* A [svg-sprite](https://github.com/jkphl/svg-sprite#configuration-basics) configuration.
167+
*/
168+
svgsprite?: object,
169+
170+
/**
171+
* Prints the plugin output to the console.
172+
*/
173+
verbose?: boolean
174+
175+
}
176+
177+
declare function sprites(options: Options): Plugin;
178+
179+
export = sprites;

0 commit comments

Comments
 (0)