1 | declare const enum LevelEnum {
|
2 | /**
|
3 | All colors disabled.
|
4 | */
|
5 | None = 0,
|
6 |
|
7 | /**
|
8 | Basic 16 colors support.
|
9 | */
|
10 | Basic = 1,
|
11 |
|
12 | /**
|
13 | ANSI 256 colors support.
|
14 | */
|
15 | Ansi256 = 2,
|
16 |
|
17 | /**
|
18 | Truecolor 16 million colors support.
|
19 | */
|
20 | TrueColor = 3
|
21 | }
|
22 |
|
23 | /**
|
24 | Basic foreground colors.
|
25 |
|
26 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
27 | */
|
28 | declare type ForegroundColor =
|
29 | | 'black'
|
30 | | 'red'
|
31 | | 'green'
|
32 | | 'yellow'
|
33 | | 'blue'
|
34 | | 'magenta'
|
35 | | 'cyan'
|
36 | | 'white'
|
37 | | 'gray'
|
38 | | 'grey'
|
39 | | 'blackBright'
|
40 | | 'redBright'
|
41 | | 'greenBright'
|
42 | | 'yellowBright'
|
43 | | 'blueBright'
|
44 | | 'magentaBright'
|
45 | | 'cyanBright'
|
46 | | 'whiteBright';
|
47 |
|
48 | /**
|
49 | Basic background colors.
|
50 |
|
51 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
52 | */
|
53 | declare type BackgroundColor =
|
54 | | 'bgBlack'
|
55 | | 'bgRed'
|
56 | | 'bgGreen'
|
57 | | 'bgYellow'
|
58 | | 'bgBlue'
|
59 | | 'bgMagenta'
|
60 | | 'bgCyan'
|
61 | | 'bgWhite'
|
62 | | 'bgGray'
|
63 | | 'bgGrey'
|
64 | | 'bgBlackBright'
|
65 | | 'bgRedBright'
|
66 | | 'bgGreenBright'
|
67 | | 'bgYellowBright'
|
68 | | 'bgBlueBright'
|
69 | | 'bgMagentaBright'
|
70 | | 'bgCyanBright'
|
71 | | 'bgWhiteBright';
|
72 |
|
73 | /**
|
74 | Basic colors.
|
75 |
|
76 | [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
77 | */
|
78 | declare type Color = ForegroundColor | BackgroundColor;
|
79 |
|
80 | declare type Modifiers =
|
81 | | 'reset'
|
82 | | 'bold'
|
83 | | 'dim'
|
84 | | 'italic'
|
85 | | 'underline'
|
86 | | 'inverse'
|
87 | | 'hidden'
|
88 | | 'strikethrough'
|
89 | | 'visible';
|
90 |
|
91 | declare namespace chalk {
|
92 | type Level = LevelEnum;
|
93 |
|
94 | interface Options {
|
95 | /**
|
96 | Specify the color support for Chalk.
|
97 | By default, color support is automatically detected based on the environment.
|
98 | */
|
99 | level?: Level;
|
100 | }
|
101 |
|
102 | interface Instance {
|
103 | /**
|
104 | Return a new Chalk instance.
|
105 | */
|
106 | new (options?: Options): Chalk;
|
107 | }
|
108 |
|
109 | /**
|
110 | Detect whether the terminal supports color.
|
111 | */
|
112 | interface ColorSupport {
|
113 | /**
|
114 | The color level used by Chalk.
|
115 | */
|
116 | level: Level;
|
117 |
|
118 | /**
|
119 | Return whether Chalk supports basic 16 colors.
|
120 | */
|
121 | hasBasic: boolean;
|
122 |
|
123 | /**
|
124 | Return whether Chalk supports ANSI 256 colors.
|
125 | */
|
126 | has256: boolean;
|
127 |
|
128 | /**
|
129 | Return whether Chalk supports Truecolor 16 million colors.
|
130 | */
|
131 | has16m: boolean;
|
132 | }
|
133 |
|
134 | interface ChalkFunction {
|
135 | /**
|
136 | Use a template string.
|
137 |
|
138 | @remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
|
139 |
|
140 | @example
|
141 | ```
|
142 | import chalk = require('chalk');
|
143 |
|
144 | log(chalk`
|
145 | CPU: {red ${cpu.totalPercent}%}
|
146 | RAM: {green ${ram.used / ram.total * 100}%}
|
147 | DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
148 | `);
|
149 | ```
|
150 | */
|
151 | (text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
152 |
|
153 | (...text: unknown[]): string;
|
154 | }
|
155 |
|
156 | interface Chalk extends ChalkFunction {
|
157 | /**
|
158 | Return a new Chalk instance.
|
159 | */
|
160 | Instance: Instance;
|
161 |
|
162 | /**
|
163 | The color support for Chalk.
|
164 | By default, color support is automatically detected based on the environment.
|
165 | */
|
166 | level: Level;
|
167 |
|
168 | /**
|
169 | Use HEX value to set text color.
|
170 |
|
171 | @param color - Hexadecimal value representing the desired color.
|
172 |
|
173 | @example
|
174 | ```
|
175 | import chalk = require('chalk');
|
176 |
|
177 | chalk.hex('#DEADED');
|
178 | ```
|
179 | */
|
180 | hex(color: string): Chalk;
|
181 |
|
182 | /**
|
183 | Use keyword color value to set text color.
|
184 |
|
185 | @param color - Keyword value representing the desired color.
|
186 |
|
187 | @example
|
188 | ```
|
189 | import chalk = require('chalk');
|
190 |
|
191 | chalk.keyword('orange');
|
192 | ```
|
193 | */
|
194 | keyword(color: string): Chalk;
|
195 |
|
196 | /**
|
197 | Use RGB values to set text color.
|
198 | */
|
199 | rgb(red: number, green: number, blue: number): Chalk;
|
200 |
|
201 | /**
|
202 | Use HSL values to set text color.
|
203 | */
|
204 | hsl(hue: number, saturation: number, lightness: number): Chalk;
|
205 |
|
206 | /**
|
207 | Use HSV values to set text color.
|
208 | */
|
209 | hsv(hue: number, saturation: number, value: number): Chalk;
|
210 |
|
211 | /**
|
212 | Use HWB values to set text color.
|
213 | */
|
214 | hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
215 |
|
216 | /**
|
217 | Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
218 |
|
219 | 30 <= code && code < 38 || 90 <= code && code < 98
|
220 | For example, 31 for red, 91 for redBright.
|
221 | */
|
222 | ansi(code: number): Chalk;
|
223 |
|
224 | /**
|
225 | Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
226 | */
|
227 | ansi256(index: number): Chalk;
|
228 |
|
229 | /**
|
230 | Use HEX value to set background color.
|
231 |
|
232 | @param color - Hexadecimal value representing the desired color.
|
233 |
|
234 | @example
|
235 | ```
|
236 | import chalk = require('chalk');
|
237 |
|
238 | chalk.bgHex('#DEADED');
|
239 | ```
|
240 | */
|
241 | bgHex(color: string): Chalk;
|
242 |
|
243 | /**
|
244 | Use keyword color value to set background color.
|
245 |
|
246 | @param color - Keyword value representing the desired color.
|
247 |
|
248 | @example
|
249 | ```
|
250 | import chalk = require('chalk');
|
251 |
|
252 | chalk.bgKeyword('orange');
|
253 | ```
|
254 | */
|
255 | bgKeyword(color: string): Chalk;
|
256 |
|
257 | /**
|
258 | Use RGB values to set background color.
|
259 | */
|
260 | bgRgb(red: number, green: number, blue: number): Chalk;
|
261 |
|
262 | /**
|
263 | Use HSL values to set background color.
|
264 | */
|
265 | bgHsl(hue: number, saturation: number, lightness: number): Chalk;
|
266 |
|
267 | /**
|
268 | Use HSV values to set background color.
|
269 | */
|
270 | bgHsv(hue: number, saturation: number, value: number): Chalk;
|
271 |
|
272 | /**
|
273 | Use HWB values to set background color.
|
274 | */
|
275 | bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
276 |
|
277 | /**
|
278 | Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
279 |
|
280 | 30 <= code && code < 38 || 90 <= code && code < 98
|
281 | For example, 31 for red, 91 for redBright.
|
282 | Use the foreground code, not the background code (for example, not 41, nor 101).
|
283 | */
|
284 | bgAnsi(code: number): Chalk;
|
285 |
|
286 | /**
|
287 | Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
288 | */
|
289 | bgAnsi256(index: number): Chalk;
|
290 |
|
291 | /**
|
292 | Modifier: Resets the current color chain.
|
293 | */
|
294 | readonly reset: Chalk;
|
295 |
|
296 | /**
|
297 | Modifier: Make text bold.
|
298 | */
|
299 | readonly bold: Chalk;
|
300 |
|
301 | /**
|
302 | Modifier: Emitting only a small amount of light.
|
303 | */
|
304 | readonly dim: Chalk;
|
305 |
|
306 | /**
|
307 | Modifier: Make text italic. (Not widely supported)
|
308 | */
|
309 | readonly italic: Chalk;
|
310 |
|
311 | /**
|
312 | Modifier: Make text underline. (Not widely supported)
|
313 | */
|
314 | readonly underline: Chalk;
|
315 |
|
316 | /**
|
317 | Modifier: Inverse background and foreground colors.
|
318 | */
|
319 | readonly inverse: Chalk;
|
320 |
|
321 | /**
|
322 | Modifier: Prints the text, but makes it invisible.
|
323 | */
|
324 | readonly hidden: Chalk;
|
325 |
|
326 | /**
|
327 | Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
|
328 | */
|
329 | readonly strikethrough: Chalk;
|
330 |
|
331 | /**
|
332 | Modifier: Prints the text only when Chalk has a color support level > 0.
|
333 | Can be useful for things that are purely cosmetic.
|
334 | */
|
335 | readonly visible: Chalk;
|
336 |
|
337 | readonly black: Chalk;
|
338 | readonly red: Chalk;
|
339 | readonly green: Chalk;
|
340 | readonly yellow: Chalk;
|
341 | readonly blue: Chalk;
|
342 | readonly magenta: Chalk;
|
343 | readonly cyan: Chalk;
|
344 | readonly white: Chalk;
|
345 |
|
346 | /*
|
347 | Alias for `blackBright`.
|
348 | */
|
349 | readonly gray: Chalk;
|
350 |
|
351 | /*
|
352 | Alias for `blackBright`.
|
353 | */
|
354 | readonly grey: Chalk;
|
355 |
|
356 | readonly blackBright: Chalk;
|
357 | readonly redBright: Chalk;
|
358 | readonly greenBright: Chalk;
|
359 | readonly yellowBright: Chalk;
|
360 | readonly blueBright: Chalk;
|
361 | readonly magentaBright: Chalk;
|
362 | readonly cyanBright: Chalk;
|
363 | readonly whiteBright: Chalk;
|
364 |
|
365 | readonly bgBlack: Chalk;
|
366 | readonly bgRed: Chalk;
|
367 | readonly bgGreen: Chalk;
|
368 | readonly bgYellow: Chalk;
|
369 | readonly bgBlue: Chalk;
|
370 | readonly bgMagenta: Chalk;
|
371 | readonly bgCyan: Chalk;
|
372 | readonly bgWhite: Chalk;
|
373 |
|
374 | /*
|
375 | Alias for `bgBlackBright`.
|
376 | */
|
377 | readonly bgGray: Chalk;
|
378 |
|
379 | /*
|
380 | Alias for `bgBlackBright`.
|
381 | */
|
382 | readonly bgGrey: Chalk;
|
383 |
|
384 | readonly bgBlackBright: Chalk;
|
385 | readonly bgRedBright: Chalk;
|
386 | readonly bgGreenBright: Chalk;
|
387 | readonly bgYellowBright: Chalk;
|
388 | readonly bgBlueBright: Chalk;
|
389 | readonly bgMagentaBright: Chalk;
|
390 | readonly bgCyanBright: Chalk;
|
391 | readonly bgWhiteBright: Chalk;
|
392 | }
|
393 | }
|
394 |
|
395 | /**
|
396 | Main Chalk object that allows to chain styles together.
|
397 | Call the last one as a method with a string argument.
|
398 | Order doesn't matter, and later styles take precedent in case of a conflict.
|
399 | This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
400 | */
|
401 | declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
402 | supportsColor: chalk.ColorSupport | false;
|
403 | Level: typeof LevelEnum;
|
404 | Color: Color;
|
405 | ForegroundColor: ForegroundColor;
|
406 | BackgroundColor: BackgroundColor;
|
407 | Modifiers: Modifiers;
|
408 | stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
|
409 | };
|
410 |
|
411 | export = chalk;
|