|
1 |
| -export const enum Level { |
| 1 | +declare const enum LevelEnum { |
2 | 2 | /**
|
3 |
| - * All colors disabled. |
4 |
| - */ |
| 3 | + All colors disabled. |
| 4 | + */ |
5 | 5 | None = 0,
|
6 | 6 |
|
7 | 7 | /**
|
8 |
| - * Basic 16 colors support. |
9 |
| - */ |
| 8 | + Basic 16 colors support. |
| 9 | + */ |
10 | 10 | Basic = 1,
|
11 | 11 |
|
12 | 12 | /**
|
13 |
| - * ANSI 256 colors support. |
14 |
| - */ |
| 13 | + ANSI 256 colors support. |
| 14 | + */ |
15 | 15 | Ansi256 = 2,
|
16 | 16 |
|
17 | 17 | /**
|
18 |
| - * Truecolor 16 million colors support. |
19 |
| - */ |
| 18 | + Truecolor 16 million colors support. |
| 19 | + */ |
20 | 20 | TrueColor = 3
|
21 | 21 | }
|
22 | 22 |
|
23 |
| -export interface Options { |
| 23 | +declare namespace chalk { |
| 24 | + type Level = LevelEnum; |
| 25 | + |
| 26 | + interface Options { |
| 27 | + /** |
| 28 | + Enable or disable Chalk. |
| 29 | +
|
| 30 | + @default true |
| 31 | + */ |
| 32 | + enabled?: boolean; |
| 33 | + |
| 34 | + /** |
| 35 | + Specify the color support for Chalk. |
| 36 | + By default, color support is automatically detected based on the environment. |
| 37 | + */ |
| 38 | + level?: Level; |
| 39 | + } |
| 40 | + |
| 41 | + interface Instance { |
| 42 | + /** |
| 43 | + Return a new Chalk instance. |
| 44 | + */ |
| 45 | + new (options?: Options): Chalk; |
| 46 | + } |
| 47 | + |
24 | 48 | /**
|
25 |
| - * Enable or disable Chalk. |
26 |
| - * |
27 |
| - * @default true |
28 |
| - */ |
29 |
| - enabled?: boolean; |
| 49 | + Detect whether the terminal supports color. |
| 50 | + */ |
| 51 | + interface ColorSupport { |
| 52 | + /** |
| 53 | + The color level used by Chalk. |
| 54 | + */ |
| 55 | + level: Level; |
| 56 | + |
| 57 | + /** |
| 58 | + Return whether Chalk supports basic 16 colors. |
| 59 | + */ |
| 60 | + hasBasic: boolean; |
| 61 | + |
| 62 | + /** |
| 63 | + Return whether Chalk supports ANSI 256 colors. |
| 64 | + */ |
| 65 | + has256: boolean; |
30 | 66 |
|
31 |
| - /** |
32 |
| - * Specify the color support for Chalk. |
33 |
| - * By default, color support is automatically detected based on the environment. |
34 |
| - */ |
35 |
| - level?: Level; |
36 |
| -} |
37 |
| - |
38 |
| -export interface Instance { |
39 |
| - /** |
40 |
| - * Return a new Chalk instance. |
41 |
| - */ |
42 |
| - new (options?: Options): Chalk; |
43 |
| -} |
44 |
| - |
45 |
| -/** |
46 |
| - * Detect whether the terminal supports color. |
47 |
| - */ |
48 |
| -export interface ColorSupport { |
49 |
| - /** |
50 |
| - * The color level used by Chalk. |
51 |
| - */ |
52 |
| - level: Level; |
53 |
| - |
54 |
| - /** |
55 |
| - * Return whether Chalk supports basic 16 colors. |
56 |
| - */ |
57 |
| - hasBasic: boolean; |
58 |
| - |
59 |
| - /** |
60 |
| - * Return whether Chalk supports ANSI 256 colors. |
61 |
| - */ |
62 |
| - has256: boolean; |
63 |
| - |
64 |
| - /** |
65 |
| - * Return whether Chalk supports Truecolor 16 million colors. |
66 |
| - */ |
67 |
| - has16m: boolean; |
68 |
| -} |
69 |
| - |
70 |
| -export interface Chalk { |
71 |
| - (...text: unknown[]): string; |
72 |
| - |
73 |
| - (text: TemplateStringsArray, ...placeholders: unknown[]): string; |
74 |
| - |
75 |
| - /** |
76 |
| - * Return a new Chalk instance. |
77 |
| - */ |
78 |
| - Instance: Instance; |
79 |
| - |
80 |
| - /** |
81 |
| - * Enable or disable Chalk. |
82 |
| - * |
83 |
| - * @default true |
84 |
| - */ |
85 |
| - enabled: boolean; |
86 |
| - |
87 |
| - /** |
88 |
| - * The color support for Chalk. |
89 |
| - * By default, color support is automatically detected based on the environment. |
90 |
| - */ |
91 |
| - level: Level; |
92 |
| - |
93 |
| - /** |
94 |
| - * Use HEX value to set text color. |
95 |
| - * |
96 |
| - * @param color - Hexadecimal value representing the desired color. |
97 |
| - * |
98 |
| - * @example |
99 |
| - * |
100 |
| - * import chalk from 'chalk'; |
101 |
| - * |
102 |
| - * chalk.hex('#DEADED'); |
103 |
| - */ |
104 |
| - hex(color: string): this; |
105 |
| - |
106 |
| - /** |
107 |
| - * Use keyword color value to set text color. |
108 |
| - * |
109 |
| - * @param color - Keyword value representing the desired color. |
110 |
| - * |
111 |
| - * @example |
112 |
| - * |
113 |
| - * import chalk from 'chalk'; |
114 |
| - * |
115 |
| - * chalk.keyword('orange'); |
116 |
| - */ |
117 |
| - keyword(color: string): this; |
118 |
| - |
119 |
| - /** |
120 |
| - * Use RGB values to set text color. |
121 |
| - */ |
122 |
| - rgb(red: number, green: number, blue: number): this; |
123 |
| - |
124 |
| - /** |
125 |
| - * Use HSL values to set text color. |
126 |
| - */ |
127 |
| - hsl(hue: number, saturation: number, lightness: number): this; |
128 |
| - |
129 |
| - /** |
130 |
| - * Use HSV values to set text color. |
131 |
| - */ |
132 |
| - hsv(hue: number, saturation: number, value: number): this; |
133 |
| - |
134 |
| - /** |
135 |
| - * Use HWB values to set text color. |
136 |
| - */ |
137 |
| - hwb(hue: number, whiteness: number, blackness: number): this; |
138 |
| - |
139 |
| - /** |
140 |
| - * Use HEX value to set background color. |
141 |
| - * |
142 |
| - * @param color - Hexadecimal value representing the desired color. |
143 |
| - * |
144 |
| - * @example |
145 |
| - * |
146 |
| - * import chalk from 'chalk'; |
147 |
| - * |
148 |
| - * chalk.bgHex('#DEADED'); |
149 |
| - */ |
150 |
| - bgHex(color: string): this; |
151 |
| - |
152 |
| - /** |
153 |
| - * Use keyword color value to set background color. |
154 |
| - * |
155 |
| - * @param color - Keyword value representing the desired color. |
156 |
| - * |
157 |
| - * @example |
158 |
| - * |
159 |
| - * import chalk from 'chalk'; |
160 |
| - * |
161 |
| - * chalk.bgKeyword('orange'); |
162 |
| - */ |
163 |
| - bgKeyword(color: string): this; |
164 |
| - |
165 |
| - /** |
166 |
| - * Use RGB values to set background color. |
167 |
| - */ |
168 |
| - bgRgb(red: number, green: number, blue: number): this; |
169 |
| - |
170 |
| - /** |
171 |
| - * Use HSL values to set background color. |
172 |
| - */ |
173 |
| - bgHsl(hue: number, saturation: number, lightness: number): this; |
174 |
| - |
175 |
| - /** |
176 |
| - * Use HSV values to set background color. |
177 |
| - */ |
178 |
| - bgHsv(hue: number, saturation: number, value: number): this; |
179 |
| - |
180 |
| - /** |
181 |
| - * Use HWB values to set background color. |
182 |
| - */ |
183 |
| - bgHwb(hue: number, whiteness: number, blackness: number): this; |
184 |
| - |
185 |
| - /** |
186 |
| - * Modifier: Resets the current color chain. |
187 |
| - */ |
188 |
| - readonly reset: this; |
189 |
| - |
190 |
| - /** |
191 |
| - * Modifier: Make text bold. |
192 |
| - */ |
193 |
| - readonly bold: this; |
194 |
| - |
195 |
| - /** |
196 |
| - * Modifier: Emitting only a small amount of light. |
197 |
| - */ |
198 |
| - readonly dim: this; |
199 |
| - |
200 |
| - /** |
201 |
| - * Modifier: Make text italic. (Not widely supported) |
202 |
| - */ |
203 |
| - readonly italic: this; |
204 |
| - |
205 |
| - /** |
206 |
| - * Modifier: Make text underline. (Not widely supported) |
207 |
| - */ |
208 |
| - readonly underline: this; |
209 |
| - |
210 |
| - /** |
211 |
| - * Modifier: Inverse background and foreground colors. |
212 |
| - */ |
213 |
| - readonly inverse: this; |
214 |
| - |
215 |
| - /** |
216 |
| - * Modifier: Prints the text, but makes it invisible. |
217 |
| - */ |
218 |
| - readonly hidden: this; |
219 |
| - |
220 |
| - /** |
221 |
| - * Modifier: Puts a horizontal line through the center of the text. (Not widely supported) |
222 |
| - */ |
223 |
| - readonly strikethrough: this; |
| 67 | + /** |
| 68 | + Return whether Chalk supports Truecolor 16 million colors. |
| 69 | + */ |
| 70 | + has16m: boolean; |
| 71 | + } |
224 | 72 |
|
225 |
| - /** |
226 |
| - * Modifier: Prints the text only when Chalk is enabled. |
227 |
| - * Can be useful for things that are purely cosmetic. |
228 |
| - */ |
229 |
| - readonly visible: this; |
230 |
| - |
231 |
| - readonly black: this; |
232 |
| - readonly red: this; |
233 |
| - readonly green: this; |
234 |
| - readonly yellow: this; |
235 |
| - readonly blue: this; |
236 |
| - readonly magenta: this; |
237 |
| - readonly cyan: this; |
238 |
| - readonly white: this; |
239 |
| - readonly gray: this; |
240 |
| - readonly grey: this; |
241 |
| - readonly blackBright: this; |
242 |
| - readonly redBright: this; |
243 |
| - readonly greenBright: this; |
244 |
| - readonly yellowBright: this; |
245 |
| - readonly blueBright: this; |
246 |
| - readonly magentaBright: this; |
247 |
| - readonly cyanBright: this; |
248 |
| - readonly whiteBright: this; |
249 |
| - |
250 |
| - readonly bgBlack: this; |
251 |
| - readonly bgRed: this; |
252 |
| - readonly bgGreen: this; |
253 |
| - readonly bgYellow: this; |
254 |
| - readonly bgBlue: this; |
255 |
| - readonly bgMagenta: this; |
256 |
| - readonly bgCyan: this; |
257 |
| - readonly bgWhite: this; |
258 |
| - readonly bgBlackBright: this; |
259 |
| - readonly bgRedBright: this; |
260 |
| - readonly bgGreenBright: this; |
261 |
| - readonly bgYellowBright: this; |
262 |
| - readonly bgBlueBright: this; |
263 |
| - readonly bgMagentaBright: this; |
264 |
| - readonly bgCyanBright: this; |
265 |
| - readonly bgWhiteBright: this; |
| 73 | + interface Chalk { |
| 74 | + (...text: unknown[]): string; |
| 75 | + |
| 76 | + (text: TemplateStringsArray, ...placeholders: unknown[]): string; |
| 77 | + |
| 78 | + /** |
| 79 | + Return a new Chalk instance. |
| 80 | + */ |
| 81 | + Instance: Instance; |
| 82 | + |
| 83 | + /** |
| 84 | + Enable or disable Chalk. |
| 85 | +
|
| 86 | + @default true |
| 87 | + */ |
| 88 | + enabled: boolean; |
| 89 | + |
| 90 | + /** |
| 91 | + The color support for Chalk. |
| 92 | + By default, color support is automatically detected based on the environment. |
| 93 | + */ |
| 94 | + level: Level; |
| 95 | + |
| 96 | + /** |
| 97 | + Use HEX value to set text color. |
| 98 | +
|
| 99 | + @param color - Hexadecimal value representing the desired color. |
| 100 | +
|
| 101 | + @example |
| 102 | + ``` |
| 103 | + import chalk = require('chalk'); |
| 104 | +
|
| 105 | + chalk.hex('#DEADED'); |
| 106 | + ``` |
| 107 | + */ |
| 108 | + hex(color: string): this; |
| 109 | + |
| 110 | + /** |
| 111 | + Use keyword color value to set text color. |
| 112 | +
|
| 113 | + @param color - Keyword value representing the desired color. |
| 114 | +
|
| 115 | + @example |
| 116 | + ``` |
| 117 | + import chalk = require('chalk'); |
| 118 | +
|
| 119 | + chalk.keyword('orange'); |
| 120 | + ``` |
| 121 | + */ |
| 122 | + keyword(color: string): this; |
| 123 | + |
| 124 | + /** |
| 125 | + Use RGB values to set text color. |
| 126 | + */ |
| 127 | + rgb(red: number, green: number, blue: number): this; |
| 128 | + |
| 129 | + /** |
| 130 | + Use HSL values to set text color. |
| 131 | + */ |
| 132 | + hsl(hue: number, saturation: number, lightness: number): this; |
| 133 | + |
| 134 | + /** |
| 135 | + Use HSV values to set text color. |
| 136 | + */ |
| 137 | + hsv(hue: number, saturation: number, value: number): this; |
| 138 | + |
| 139 | + /** |
| 140 | + Use HWB values to set text color. |
| 141 | + */ |
| 142 | + hwb(hue: number, whiteness: number, blackness: number): this; |
| 143 | + |
| 144 | + /** |
| 145 | + Use HEX value to set background color. |
| 146 | +
|
| 147 | + @param color - Hexadecimal value representing the desired color. |
| 148 | +
|
| 149 | + @example |
| 150 | + ``` |
| 151 | + import chalk = require('chalk'); |
| 152 | +
|
| 153 | + chalk.bgHex('#DEADED'); |
| 154 | + ``` |
| 155 | + */ |
| 156 | + bgHex(color: string): this; |
| 157 | + |
| 158 | + /** |
| 159 | + Use keyword color value to set background color. |
| 160 | +
|
| 161 | + @param color - Keyword value representing the desired color. |
| 162 | +
|
| 163 | + @example |
| 164 | + ``` |
| 165 | + import chalk = require('chalk'); |
| 166 | +
|
| 167 | + chalk.bgKeyword('orange'); |
| 168 | + ``` |
| 169 | + */ |
| 170 | + bgKeyword(color: string): this; |
| 171 | + |
| 172 | + /** |
| 173 | + Use RGB values to set background color. |
| 174 | + */ |
| 175 | + bgRgb(red: number, green: number, blue: number): this; |
| 176 | + |
| 177 | + /** |
| 178 | + Use HSL values to set background color. |
| 179 | + */ |
| 180 | + bgHsl(hue: number, saturation: number, lightness: number): this; |
| 181 | + |
| 182 | + /** |
| 183 | + Use HSV values to set background color. |
| 184 | + */ |
| 185 | + bgHsv(hue: number, saturation: number, value: number): this; |
| 186 | + |
| 187 | + /** |
| 188 | + Use HWB values to set background color. |
| 189 | + */ |
| 190 | + bgHwb(hue: number, whiteness: number, blackness: number): this; |
| 191 | + |
| 192 | + /** |
| 193 | + Modifier: Resets the current color chain. |
| 194 | + */ |
| 195 | + readonly reset: this; |
| 196 | + |
| 197 | + /** |
| 198 | + Modifier: Make text bold. |
| 199 | + */ |
| 200 | + readonly bold: this; |
| 201 | + |
| 202 | + /** |
| 203 | + Modifier: Emitting only a small amount of light. |
| 204 | + */ |
| 205 | + readonly dim: this; |
| 206 | + |
| 207 | + /** |
| 208 | + Modifier: Make text italic. (Not widely supported) |
| 209 | + */ |
| 210 | + readonly italic: this; |
| 211 | + |
| 212 | + /** |
| 213 | + Modifier: Make text underline. (Not widely supported) |
| 214 | + */ |
| 215 | + readonly underline: this; |
| 216 | + |
| 217 | + /** |
| 218 | + Modifier: Inverse background and foreground colors. |
| 219 | + */ |
| 220 | + readonly inverse: this; |
| 221 | + |
| 222 | + /** |
| 223 | + Modifier: Prints the text, but makes it invisible. |
| 224 | + */ |
| 225 | + readonly hidden: this; |
| 226 | + |
| 227 | + /** |
| 228 | + Modifier: Puts a horizontal line through the center of the text. (Not widely supported) |
| 229 | + */ |
| 230 | + readonly strikethrough: this; |
| 231 | + |
| 232 | + /** |
| 233 | + Modifier: Prints the text only when Chalk is enabled. |
| 234 | + Can be useful for things that are purely cosmetic. |
| 235 | + */ |
| 236 | + readonly visible: this; |
| 237 | + |
| 238 | + readonly black: this; |
| 239 | + readonly red: this; |
| 240 | + readonly green: this; |
| 241 | + readonly yellow: this; |
| 242 | + readonly blue: this; |
| 243 | + readonly magenta: this; |
| 244 | + readonly cyan: this; |
| 245 | + readonly white: this; |
| 246 | + readonly gray: this; |
| 247 | + readonly grey: this; |
| 248 | + readonly blackBright: this; |
| 249 | + readonly redBright: this; |
| 250 | + readonly greenBright: this; |
| 251 | + readonly yellowBright: this; |
| 252 | + readonly blueBright: this; |
| 253 | + readonly magentaBright: this; |
| 254 | + readonly cyanBright: this; |
| 255 | + readonly whiteBright: this; |
| 256 | + |
| 257 | + readonly bgBlack: this; |
| 258 | + readonly bgRed: this; |
| 259 | + readonly bgGreen: this; |
| 260 | + readonly bgYellow: this; |
| 261 | + readonly bgBlue: this; |
| 262 | + readonly bgMagenta: this; |
| 263 | + readonly bgCyan: this; |
| 264 | + readonly bgWhite: this; |
| 265 | + readonly bgBlackBright: this; |
| 266 | + readonly bgRedBright: this; |
| 267 | + readonly bgGreenBright: this; |
| 268 | + readonly bgYellowBright: this; |
| 269 | + readonly bgBlueBright: this; |
| 270 | + readonly bgMagentaBright: this; |
| 271 | + readonly bgCyanBright: this; |
| 272 | + readonly bgWhiteBright: this; |
| 273 | + } |
266 | 274 | }
|
267 | 275 |
|
268 | 276 | /**
|
269 |
| - * Main Chalk object that allows to chain styles together. |
270 |
| - * Call the last one as a method with a string argument. |
271 |
| - * Order doesn't matter, and later styles take precedent in case of a conflict. |
272 |
| - * This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`. |
273 |
| - */ |
274 |
| -declare const chalk: Chalk & {supportsColor: ColorSupport}; |
275 |
| - |
276 |
| -export default chalk; |
| 277 | +Main Chalk object that allows to chain styles together. |
| 278 | +Call the last one as a method with a string argument. |
| 279 | +Order doesn't matter, and later styles take precedent in case of a conflict. |
| 280 | +This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`. |
| 281 | +*/ |
| 282 | +declare const chalk: chalk.Chalk & { |
| 283 | + supportsColor: chalk.ColorSupport; |
| 284 | + Level: typeof LevelEnum; |
| 285 | +}; |
| 286 | + |
| 287 | +export = chalk; |
0 commit comments