2019-12-25 15:31:12 +05:30
/ * *
* This is a copy - paste from chalk lib , to fix typescript erros
* when isolatedModules is enabled
* /
declare module 'chalk' {
2020-05-24 04:38:24 +05:30
const enum LevelEnum {
/ * *
2019-12-25 15:31:12 +05:30
All colors disabled .
* /
2020-05-24 04:38:24 +05:30
None = 0 ,
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Basic 16 colors support .
* /
2020-05-24 04:38:24 +05:30
Basic = 1 ,
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
ANSI 256 colors support .
* /
2020-05-24 04:38:24 +05:30
Ansi256 = 2 ,
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Truecolor 16 million colors support .
* /
2020-05-24 04:38:24 +05:30
TrueColor = 3 ,
}
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Basic foreground colors .
[ More colors here . ] ( https : //github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
* /
2020-05-24 04:38:24 +05:30
type ForegroundColor =
| 'black'
| 'red'
| 'green'
| 'yellow'
| 'blue'
| 'magenta'
| 'cyan'
| 'white'
| 'gray'
| 'grey'
| 'blackBright'
| 'redBright'
| 'greenBright'
| 'yellowBright'
| 'blueBright'
| 'magentaBright'
| 'cyanBright'
| 'whiteBright' ;
/ * *
2019-12-25 15:31:12 +05:30
Basic background colors .
[ More colors here . ] ( https : //github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
* /
2020-05-24 04:38:24 +05:30
type BackgroundColor =
| 'bgBlack'
| 'bgRed'
| 'bgGreen'
| 'bgYellow'
| 'bgBlue'
| 'bgMagenta'
| 'bgCyan'
| 'bgWhite'
| 'bgGray'
| 'bgGrey'
| 'bgBlackBright'
| 'bgRedBright'
| 'bgGreenBright'
| 'bgYellowBright'
| 'bgBlueBright'
| 'bgMagentaBright'
| 'bgCyanBright'
| 'bgWhiteBright' ;
/ * *
2019-12-25 15:31:12 +05:30
Basic colors .
[ More colors here . ] ( https : //github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
* /
2020-05-24 04:38:24 +05:30
type Color = ForegroundColor | BackgroundColor ;
type Modifiers =
| 'reset'
| 'bold'
| 'dim'
| 'italic'
| 'underline'
| 'inverse'
| 'hidden'
| 'strikethrough'
| 'visible' ;
namespace chalk {
type Level = LevelEnum ;
interface Options {
/ * *
2019-12-25 15:31:12 +05:30
Specify the color support for Chalk .
By default , color support is automatically detected based on the environment .
* /
2020-05-24 04:38:24 +05:30
level? : Level ;
}
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
interface Instance {
/ * *
2019-12-25 15:31:12 +05:30
Return a new Chalk instance .
* /
2020-05-24 04:38:24 +05:30
new ( options? : Options ) : Chalk ;
}
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Detect whether the terminal supports color .
* /
2020-05-24 04:38:24 +05:30
interface ColorSupport {
/ * *
2019-12-25 15:31:12 +05:30
The color level used by Chalk .
* /
2020-05-24 04:38:24 +05:30
level : Level ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Return whether Chalk supports basic 16 colors .
* /
2020-05-24 04:38:24 +05:30
hasBasic : boolean ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Return whether Chalk supports ANSI 256 colors .
* /
2020-05-24 04:38:24 +05:30
has256 : boolean ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Return whether Chalk supports Truecolor 16 million colors .
* /
2020-05-24 04:38:24 +05:30
has16m : boolean ;
}
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
interface ChalkFunction {
/ * *
2019-12-25 15:31:12 +05:30
Use a template string .
@remarks Template literals are unsupported for nested calls ( see [ issue # 341 ] ( https : //github.com/chalk/chalk/issues/341))
@example
` ` `
import chalk = require ( 'chalk' ) ;
log ( chalk `
CPU : { red $ { cpu . totalPercent } % }
RAM : { green $ { ram . used / ram . total * 100 } % }
DISK : { rgb ( 255 , 131 , 0 ) $ { disk . used / disk . total * 100 } % }
` );
` ` `
* /
2020-05-24 04:38:24 +05:30
( text : TemplateStringsArray , . . . placeholders : unknown [ ] ) : string ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
( . . . text : unknown [ ] ) : string ;
}
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
interface Chalk extends ChalkFunction {
/ * *
2019-12-25 15:31:12 +05:30
Return a new Chalk instance .
* /
2020-05-24 04:38:24 +05:30
Instance : Instance ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
The color support for Chalk .
By default , color support is automatically detected based on the environment .
* /
2020-05-24 04:38:24 +05:30
level : Level ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use HEX value to set text color .
@param color - Hexadecimal value representing the desired color .
@example
` ` `
import chalk = require ( 'chalk' ) ;
chalk . hex ( '#DEADED' ) ;
` ` `
* /
2020-05-24 04:38:24 +05:30
hex ( color : string ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use keyword color value to set text color .
@param color - Keyword value representing the desired color .
@example
` ` `
import chalk = require ( 'chalk' ) ;
chalk . keyword ( 'orange' ) ;
` ` `
* /
2020-05-24 04:38:24 +05:30
keyword ( color : string ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use RGB values to set text color .
* /
2020-05-24 04:38:24 +05:30
rgb ( red : number , green : number , blue : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use HSL values to set text color .
* /
2020-05-24 04:38:24 +05:30
hsl ( hue : number , saturation : number , lightness : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use HSV values to set text color .
* /
2020-05-24 04:38:24 +05:30
hsv ( hue : number , saturation : number , value : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use HWB values to set text color .
* /
2020-05-24 04:38:24 +05:30
hwb ( hue : number , whiteness : number , blackness : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
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.
30 <= code && code < 38 || 90 <= code && code < 98
For example , 31 for red , 91 for redBright .
* /
2020-05-24 04:38:24 +05:30
ansi ( code : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use a [ 8 - bit unsigned number ] ( https : //en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
* /
2020-05-24 04:38:24 +05:30
ansi256 ( index : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use HEX value to set background color .
@param color - Hexadecimal value representing the desired color .
@example
` ` `
import chalk = require ( 'chalk' ) ;
chalk . bgHex ( '#DEADED' ) ;
` ` `
* /
2020-05-24 04:38:24 +05:30
bgHex ( color : string ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use keyword color value to set background color .
@param color - Keyword value representing the desired color .
@example
` ` `
import chalk = require ( 'chalk' ) ;
chalk . bgKeyword ( 'orange' ) ;
` ` `
* /
2020-05-24 04:38:24 +05:30
bgKeyword ( color : string ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use RGB values to set background color .
* /
2020-05-24 04:38:24 +05:30
bgRgb ( red : number , green : number , blue : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use HSL values to set background color .
* /
2020-05-24 04:38:24 +05:30
bgHsl ( hue : number , saturation : number , lightness : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use HSV values to set background color .
* /
2020-05-24 04:38:24 +05:30
bgHsv ( hue : number , saturation : number , value : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use HWB values to set background color .
* /
2020-05-24 04:38:24 +05:30
bgHwb ( hue : number , whiteness : number , blackness : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
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.
30 <= code && code < 38 || 90 <= code && code < 98
For example , 31 for red , 91 for redBright .
Use the foreground code , not the background code ( for example , not 41 , nor 101 ) .
* /
2020-05-24 04:38:24 +05:30
bgAnsi ( code : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Use a [ 8 - bit unsigned number ] ( https : //en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
* /
2020-05-24 04:38:24 +05:30
bgAnsi256 ( index : number ) : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Resets the current color chain .
* /
2020-05-24 04:38:24 +05:30
readonly reset : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Make text bold .
* /
2020-05-24 04:38:24 +05:30
readonly bold : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Emitting only a small amount of light .
* /
2020-05-24 04:38:24 +05:30
readonly dim : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Make text italic . ( Not widely supported )
* /
2020-05-24 04:38:24 +05:30
readonly italic : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Make text underline . ( Not widely supported )
* /
2020-05-24 04:38:24 +05:30
readonly underline : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Inverse background and foreground colors .
* /
2020-05-24 04:38:24 +05:30
readonly inverse : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Prints the text , but makes it invisible .
* /
2020-05-24 04:38:24 +05:30
readonly hidden : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Puts a horizontal line through the center of the text . ( Not widely supported )
* /
2020-05-24 04:38:24 +05:30
readonly strikethrough : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Modifier : Prints the text only when Chalk has a color support level > 0 .
Can be useful for things that are purely cosmetic .
* /
2020-05-24 04:38:24 +05:30
readonly visible : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
readonly black : Chalk ;
readonly red : Chalk ;
readonly green : Chalk ;
readonly yellow : Chalk ;
readonly blue : Chalk ;
readonly magenta : Chalk ;
readonly cyan : Chalk ;
readonly white : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ *
2019-12-25 15:31:12 +05:30
Alias for ` blackBright ` .
* /
2020-05-24 04:38:24 +05:30
readonly gray : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ *
2019-12-25 15:31:12 +05:30
Alias for ` blackBright ` .
* /
2020-05-24 04:38:24 +05:30
readonly grey : Chalk ;
readonly blackBright : Chalk ;
readonly redBright : Chalk ;
readonly greenBright : Chalk ;
readonly yellowBright : Chalk ;
readonly blueBright : Chalk ;
readonly magentaBright : Chalk ;
readonly cyanBright : Chalk ;
readonly whiteBright : Chalk ;
readonly bgBlack : Chalk ;
readonly bgRed : Chalk ;
readonly bgGreen : Chalk ;
readonly bgYellow : Chalk ;
readonly bgBlue : Chalk ;
readonly bgMagenta : Chalk ;
readonly bgCyan : Chalk ;
readonly bgWhite : Chalk ;
/ *
2019-12-25 15:31:12 +05:30
Alias for ` bgBlackBright ` .
* /
2020-05-24 04:38:24 +05:30
readonly bgGray : Chalk ;
2019-12-25 15:31:12 +05:30
2020-05-24 04:38:24 +05:30
/ *
2019-12-25 15:31:12 +05:30
Alias for ` bgBlackBright ` .
* /
2020-05-24 04:38:24 +05:30
readonly bgGrey : Chalk ;
readonly bgBlackBright : Chalk ;
readonly bgRedBright : Chalk ;
readonly bgGreenBright : Chalk ;
readonly bgYellowBright : Chalk ;
readonly bgBlueBright : Chalk ;
readonly bgMagentaBright : Chalk ;
readonly bgCyanBright : Chalk ;
readonly bgWhiteBright : Chalk ;
}
2019-12-25 15:31:12 +05:30
}
2020-05-24 04:38:24 +05:30
/ * *
2019-12-25 15:31:12 +05:30
Main Chalk object that allows to chain styles together .
Call the last one as a method with a string argument .
Order doesn ' t matter , and later styles take precedent in case of a conflict .
This simply means that ` chalk.red.yellow.green ` is equivalent to ` chalk.green ` .
* /
2020-05-24 04:38:24 +05:30
const chalk : chalk.Chalk &
chalk . ChalkFunction & {
supportsColor : chalk.ColorSupport | false ;
Level : LevelEnum ;
Color : Color ;
ForegroundColor : ForegroundColor ;
BackgroundColor : BackgroundColor ;
Modifiers : Modifiers ;
stderr : chalk.Chalk & { supportsColor : chalk.ColorSupport | false } ;
} ;
export = chalk ;
2019-12-25 15:31:12 +05:30
}