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