chalk 4.1.1 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/license +1 -1
- package/package.json +34 -24
- package/readme.md +49 -67
- package/source/index.d.ts +318 -0
- package/source/index.js +69 -86
- package/source/{util.js → utilities.js} +7 -13
- package/source/vendor/ansi-styles/index.d.ts +190 -0
- package/source/vendor/ansi-styles/index.js +219 -0
- package/source/vendor/supports-color/browser.d.ts +1 -0
- package/source/vendor/supports-color/browser.js +17 -0
- package/source/vendor/supports-color/index.d.ts +55 -0
- package/source/vendor/supports-color/index.js +169 -0
- package/index.d.ts +0 -415
- package/source/templates.js +0 -134
package/license
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chalk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Terminal string styling done right",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/chalk",
|
|
7
7
|
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
|
8
|
-
"
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./source/index.js",
|
|
10
|
+
"exports": "./source/index.js",
|
|
11
|
+
"imports": {
|
|
12
|
+
"#ansi-styles": "./source/vendor/ansi-styles/index.js",
|
|
13
|
+
"#supports-color": {
|
|
14
|
+
"node": "./source/vendor/supports-color/index.js",
|
|
15
|
+
"default": "./source/vendor/supports-color/browser.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"types": "./source/index.d.ts",
|
|
9
19
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
20
|
+
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
|
11
21
|
},
|
|
12
22
|
"scripts": {
|
|
13
|
-
"test": "xo &&
|
|
23
|
+
"test": "xo && c8 ava && tsd",
|
|
14
24
|
"bench": "matcha benchmark.js"
|
|
15
25
|
},
|
|
16
26
|
"files": [
|
|
17
27
|
"source",
|
|
18
|
-
"index.d.ts"
|
|
28
|
+
"!source/index.test-d.ts"
|
|
19
29
|
],
|
|
20
30
|
"keywords": [
|
|
21
31
|
"color",
|
|
@@ -25,7 +35,6 @@
|
|
|
25
35
|
"console",
|
|
26
36
|
"cli",
|
|
27
37
|
"string",
|
|
28
|
-
"str",
|
|
29
38
|
"ansi",
|
|
30
39
|
"style",
|
|
31
40
|
"styles",
|
|
@@ -40,29 +49,30 @@
|
|
|
40
49
|
"command-line",
|
|
41
50
|
"text"
|
|
42
51
|
],
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"ansi-styles": "^4.1.0",
|
|
45
|
-
"supports-color": "^7.1.0"
|
|
46
|
-
},
|
|
47
52
|
"devDependencies": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
53
|
+
"@types/node": "^16.11.10",
|
|
54
|
+
"ava": "^3.15.0",
|
|
55
|
+
"c8": "^7.10.0",
|
|
56
|
+
"color-convert": "^2.0.1",
|
|
57
|
+
"execa": "^6.0.0",
|
|
58
|
+
"log-update": "^5.0.0",
|
|
52
59
|
"matcha": "^0.7.0",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"xo": "^0.28.2"
|
|
60
|
+
"tsd": "^0.19.0",
|
|
61
|
+
"xo": "^0.47.0",
|
|
62
|
+
"yoctodelay": "^2.0.0"
|
|
57
63
|
},
|
|
58
64
|
"xo": {
|
|
59
65
|
"rules": {
|
|
60
|
-
"unicorn/prefer-string-slice": "off"
|
|
61
|
-
"unicorn/prefer-includes": "off",
|
|
62
|
-
"@typescript-eslint/member-ordering": "off",
|
|
63
|
-
"no-redeclare": "off",
|
|
64
|
-
"unicorn/string-content": "off",
|
|
65
|
-
"unicorn/better-regex": "off"
|
|
66
|
+
"unicorn/prefer-string-slice": "off"
|
|
66
67
|
}
|
|
68
|
+
},
|
|
69
|
+
"c8": {
|
|
70
|
+
"reporter": [
|
|
71
|
+
"text",
|
|
72
|
+
"lcov"
|
|
73
|
+
],
|
|
74
|
+
"exclude": [
|
|
75
|
+
"source/vendor"
|
|
76
|
+
]
|
|
67
77
|
}
|
|
68
78
|
}
|
package/readme.md
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
> Terminal string styling done right
|
|
11
11
|
|
|
12
|
-
[](https://codecov.io/gh/chalk/chalk)
|
|
13
|
+
[](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk)
|
|
14
|
+
[](https://repl.it/github/chalk/chalk)
|
|
15
|
+
[](https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15)
|
|
13
16
|
|
|
14
17
|
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
|
15
18
|
|
|
@@ -33,7 +36,7 @@
|
|
|
33
36
|
<br>
|
|
34
37
|
<br>
|
|
35
38
|
<a href="https://retool.com/?utm_campaign=sindresorhus">
|
|
36
|
-
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="
|
|
39
|
+
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230"/>
|
|
37
40
|
</a>
|
|
38
41
|
<br>
|
|
39
42
|
<br>
|
|
@@ -48,6 +51,16 @@
|
|
|
48
51
|
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
|
|
49
52
|
</div>
|
|
50
53
|
</a>
|
|
54
|
+
<br>
|
|
55
|
+
<a href="https://strapi.io/?ref=sindresorhus">
|
|
56
|
+
<div>
|
|
57
|
+
<img src="https://sindresorhus.com/assets/thanks/strapi-logo-white-bg.png" width="220" alt="Strapi">
|
|
58
|
+
</div>
|
|
59
|
+
<b>Strapi is the leading open-source headless CMS.</b>
|
|
60
|
+
<div>
|
|
61
|
+
<sup>It’s 100% JavaScript, fully customizable, and developer-first.</sup>
|
|
62
|
+
</div>
|
|
63
|
+
</a>
|
|
51
64
|
</p>
|
|
52
65
|
</div>
|
|
53
66
|
|
|
@@ -59,24 +72,27 @@
|
|
|
59
72
|
|
|
60
73
|
- Expressive API
|
|
61
74
|
- Highly performant
|
|
75
|
+
- No dependencies
|
|
62
76
|
- Ability to nest styles
|
|
63
77
|
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
|
64
78
|
- Auto-detects color support
|
|
65
79
|
- Doesn't extend `String.prototype`
|
|
66
80
|
- Clean and focused
|
|
67
81
|
- Actively maintained
|
|
68
|
-
- [Used by ~
|
|
82
|
+
- [Used by ~76,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 26, 2021
|
|
69
83
|
|
|
70
84
|
## Install
|
|
71
85
|
|
|
72
|
-
```
|
|
73
|
-
|
|
86
|
+
```sh
|
|
87
|
+
npm install chalk
|
|
74
88
|
```
|
|
75
89
|
|
|
90
|
+
**IMPORTANT:** Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now. [Read more.](https://github.com/chalk/chalk/releases/tag/v5.0.0)
|
|
91
|
+
|
|
76
92
|
## Usage
|
|
77
93
|
|
|
78
94
|
```js
|
|
79
|
-
|
|
95
|
+
import chalk from 'chalk';
|
|
80
96
|
|
|
81
97
|
console.log(chalk.blue('Hello world!'));
|
|
82
98
|
```
|
|
@@ -84,7 +100,8 @@ console.log(chalk.blue('Hello world!'));
|
|
|
84
100
|
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
|
85
101
|
|
|
86
102
|
```js
|
|
87
|
-
|
|
103
|
+
import chalk from 'chalk';
|
|
104
|
+
|
|
88
105
|
const log = console.log;
|
|
89
106
|
|
|
90
107
|
// Combine styled and normal strings
|
|
@@ -113,15 +130,7 @@ RAM: ${chalk.green('40%')}
|
|
|
113
130
|
DISK: ${chalk.yellow('70%')}
|
|
114
131
|
`);
|
|
115
132
|
|
|
116
|
-
// ES2015 tagged template literal
|
|
117
|
-
log(chalk`
|
|
118
|
-
CPU: {red ${cpu.totalPercent}%}
|
|
119
|
-
RAM: {green ${ram.used / ram.total * 100}%}
|
|
120
|
-
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
|
121
|
-
`);
|
|
122
|
-
|
|
123
133
|
// Use RGB colors in terminal emulators that support it.
|
|
124
|
-
log(chalk.keyword('orange')('Yay for orange colored text!'));
|
|
125
134
|
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
|
126
135
|
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
|
127
136
|
```
|
|
@@ -129,10 +138,10 @@ log(chalk.hex('#DEADED').bold('Bold gray!'));
|
|
|
129
138
|
Easily define your own themes:
|
|
130
139
|
|
|
131
140
|
```js
|
|
132
|
-
|
|
141
|
+
import chalk from 'chalk';
|
|
133
142
|
|
|
134
143
|
const error = chalk.bold.red;
|
|
135
|
-
const warning = chalk.
|
|
144
|
+
const warning = chalk.hex('#FFA500'); // Orange color
|
|
136
145
|
|
|
137
146
|
console.log(error('Error!'));
|
|
138
147
|
console.log(warning('Warning!'));
|
|
@@ -141,6 +150,8 @@ console.log(warning('Warning!'));
|
|
|
141
150
|
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
|
142
151
|
|
|
143
152
|
```js
|
|
153
|
+
import chalk from 'chalk';
|
|
154
|
+
|
|
144
155
|
const name = 'Sindre';
|
|
145
156
|
console.log(chalk.green('Hello %s'), name);
|
|
146
157
|
//=> 'Hello Sindre'
|
|
@@ -165,7 +176,9 @@ Color support is automatically detected, but you can override it by setting the
|
|
|
165
176
|
If you need to change this in a reusable module, create a new instance:
|
|
166
177
|
|
|
167
178
|
```js
|
|
168
|
-
|
|
179
|
+
import {Chalk} from 'chalk';
|
|
180
|
+
|
|
181
|
+
const customChalk = new Chalk({level: 0});
|
|
169
182
|
```
|
|
170
183
|
|
|
171
184
|
| Level | Description |
|
|
@@ -175,7 +188,7 @@ const ctx = new chalk.Instance({level: 0});
|
|
|
175
188
|
| `2` | 256 color support |
|
|
176
189
|
| `3` | Truecolor support (16 million colors) |
|
|
177
190
|
|
|
178
|
-
###
|
|
191
|
+
### supportsColor
|
|
179
192
|
|
|
180
193
|
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
|
181
194
|
|
|
@@ -183,23 +196,24 @@ Can be overridden by the user with the flags `--color` and `--no-color`. For sit
|
|
|
183
196
|
|
|
184
197
|
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
|
185
198
|
|
|
186
|
-
###
|
|
199
|
+
### chalkStderr and supportsColorStderr
|
|
187
200
|
|
|
188
|
-
`
|
|
201
|
+
`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.
|
|
189
202
|
|
|
190
203
|
## Styles
|
|
191
204
|
|
|
192
205
|
### Modifiers
|
|
193
206
|
|
|
194
|
-
- `reset` -
|
|
195
|
-
- `bold` - Make text bold.
|
|
196
|
-
- `dim` -
|
|
197
|
-
- `italic` - Make text italic. *(Not widely supported)*
|
|
198
|
-
- `underline` -
|
|
199
|
-
- `
|
|
200
|
-
- `
|
|
207
|
+
- `reset` - Reset the current style.
|
|
208
|
+
- `bold` - Make the text bold.
|
|
209
|
+
- `dim` - Make the text have lower opacity.
|
|
210
|
+
- `italic` - Make the text italic. *(Not widely supported)*
|
|
211
|
+
- `underline` - Put a horizontal line below the text. *(Not widely supported)*
|
|
212
|
+
- `overline` - Put a horizontal line above the text. *(Not widely supported)*
|
|
213
|
+
- `inverse`- Invert background and foreground colors.
|
|
214
|
+
- `hidden` - Print the text but make it invisible.
|
|
201
215
|
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
|
202
|
-
- `visible`-
|
|
216
|
+
- `visible`- Print the text only when Chalk has a color level above zero. Can be useful for things that are purely cosmetic.
|
|
203
217
|
|
|
204
218
|
### Colors
|
|
205
219
|
|
|
@@ -239,36 +253,6 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
|
|
239
253
|
- `bgCyanBright`
|
|
240
254
|
- `bgWhiteBright`
|
|
241
255
|
|
|
242
|
-
## Tagged template literal
|
|
243
|
-
|
|
244
|
-
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
|
245
|
-
|
|
246
|
-
```js
|
|
247
|
-
const chalk = require('chalk');
|
|
248
|
-
|
|
249
|
-
const miles = 18;
|
|
250
|
-
const calculateFeet = miles => miles * 5280;
|
|
251
|
-
|
|
252
|
-
console.log(chalk`
|
|
253
|
-
There are {bold 5280 feet} in a mile.
|
|
254
|
-
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
|
|
255
|
-
`);
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
|
259
|
-
|
|
260
|
-
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
|
|
261
|
-
|
|
262
|
-
```js
|
|
263
|
-
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
|
264
|
-
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
|
|
265
|
-
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
|
|
269
|
-
|
|
270
|
-
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
|
271
|
-
|
|
272
256
|
## 256 and Truecolor color support
|
|
273
257
|
|
|
274
258
|
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
|
@@ -278,26 +262,23 @@ Colors are downsampled from 16 million RGB values to an ANSI color format that i
|
|
|
278
262
|
Examples:
|
|
279
263
|
|
|
280
264
|
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
|
281
|
-
- `chalk.keyword('orange')('Some orange text')`
|
|
282
265
|
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
|
283
266
|
|
|
284
|
-
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `
|
|
267
|
+
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `hex` for foreground colors and `bgHex` for background colors).
|
|
285
268
|
|
|
286
269
|
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
|
287
|
-
- `chalk.bgKeyword('orange')('Some orange text')`
|
|
288
270
|
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
|
289
271
|
|
|
290
272
|
The following color models can be used:
|
|
291
273
|
|
|
292
274
|
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
|
293
275
|
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
|
294
|
-
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
|
295
|
-
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
|
296
|
-
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
|
297
|
-
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
|
298
|
-
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
|
299
276
|
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
|
300
277
|
|
|
278
|
+
## Browser support
|
|
279
|
+
|
|
280
|
+
Since Chrome 69, ANSI escape codes are natively supported in the developer console.
|
|
281
|
+
|
|
301
282
|
## Windows
|
|
302
283
|
|
|
303
284
|
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
|
@@ -314,6 +295,7 @@ The maintainers of chalk and thousands of other packages are working with Tideli
|
|
|
314
295
|
|
|
315
296
|
## Related
|
|
316
297
|
|
|
298
|
+
- [chalk-template](https://github.com/chalk/chalk-template) - [Tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) support for this module
|
|
317
299
|
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
|
318
300
|
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
|
319
301
|
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// TODO: Make it this when TS suports that.
|
|
2
|
+
// import {ColorInfo, ColorSupportLevel} from '#supports-color';
|
|
3
|
+
import {ColorInfo, ColorSupportLevel} from './vendor/supports-color/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Basic foreground colors.
|
|
7
|
+
|
|
8
|
+
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
|
9
|
+
*/
|
|
10
|
+
export type ForegroundColor =
|
|
11
|
+
| 'black'
|
|
12
|
+
| 'red'
|
|
13
|
+
| 'green'
|
|
14
|
+
| 'yellow'
|
|
15
|
+
| 'blue'
|
|
16
|
+
| 'magenta'
|
|
17
|
+
| 'cyan'
|
|
18
|
+
| 'white'
|
|
19
|
+
| 'gray'
|
|
20
|
+
| 'grey'
|
|
21
|
+
| 'blackBright'
|
|
22
|
+
| 'redBright'
|
|
23
|
+
| 'greenBright'
|
|
24
|
+
| 'yellowBright'
|
|
25
|
+
| 'blueBright'
|
|
26
|
+
| 'magentaBright'
|
|
27
|
+
| 'cyanBright'
|
|
28
|
+
| 'whiteBright';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
Basic background colors.
|
|
32
|
+
|
|
33
|
+
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
|
34
|
+
*/
|
|
35
|
+
export type BackgroundColor =
|
|
36
|
+
| 'bgBlack'
|
|
37
|
+
| 'bgRed'
|
|
38
|
+
| 'bgGreen'
|
|
39
|
+
| 'bgYellow'
|
|
40
|
+
| 'bgBlue'
|
|
41
|
+
| 'bgMagenta'
|
|
42
|
+
| 'bgCyan'
|
|
43
|
+
| 'bgWhite'
|
|
44
|
+
| 'bgGray'
|
|
45
|
+
| 'bgGrey'
|
|
46
|
+
| 'bgBlackBright'
|
|
47
|
+
| 'bgRedBright'
|
|
48
|
+
| 'bgGreenBright'
|
|
49
|
+
| 'bgYellowBright'
|
|
50
|
+
| 'bgBlueBright'
|
|
51
|
+
| 'bgMagentaBright'
|
|
52
|
+
| 'bgCyanBright'
|
|
53
|
+
| 'bgWhiteBright';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
Basic colors.
|
|
57
|
+
|
|
58
|
+
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
|
|
59
|
+
*/
|
|
60
|
+
export type Color = ForegroundColor | BackgroundColor;
|
|
61
|
+
|
|
62
|
+
export type Modifiers =
|
|
63
|
+
| 'reset'
|
|
64
|
+
| 'bold'
|
|
65
|
+
| 'dim'
|
|
66
|
+
| 'italic'
|
|
67
|
+
| 'underline'
|
|
68
|
+
| 'overline'
|
|
69
|
+
| 'inverse'
|
|
70
|
+
| 'hidden'
|
|
71
|
+
| 'strikethrough'
|
|
72
|
+
| 'visible';
|
|
73
|
+
|
|
74
|
+
export interface Options {
|
|
75
|
+
/**
|
|
76
|
+
Specify the color support for Chalk.
|
|
77
|
+
|
|
78
|
+
By default, color support is automatically detected based on the environment.
|
|
79
|
+
|
|
80
|
+
Levels:
|
|
81
|
+
- `0` - All colors disabled.
|
|
82
|
+
- `1` - Basic 16 colors support.
|
|
83
|
+
- `2` - ANSI 256 colors support.
|
|
84
|
+
- `3` - Truecolor 16 million colors support.
|
|
85
|
+
*/
|
|
86
|
+
readonly level?: ColorSupportLevel;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
Return a new Chalk instance.
|
|
91
|
+
*/
|
|
92
|
+
export const Chalk: new (options?: Options) => ChalkInstance; // eslint-disable-line @typescript-eslint/naming-convention
|
|
93
|
+
|
|
94
|
+
export interface ChalkInstance {
|
|
95
|
+
(...text: unknown[]): string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
The color support for Chalk.
|
|
99
|
+
|
|
100
|
+
By default, color support is automatically detected based on the environment.
|
|
101
|
+
|
|
102
|
+
Levels:
|
|
103
|
+
- `0` - All colors disabled.
|
|
104
|
+
- `1` - Basic 16 colors support.
|
|
105
|
+
- `2` - ANSI 256 colors support.
|
|
106
|
+
- `3` - Truecolor 16 million colors support.
|
|
107
|
+
*/
|
|
108
|
+
level: ColorSupportLevel;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
Use RGB values to set text color.
|
|
112
|
+
|
|
113
|
+
@example
|
|
114
|
+
```
|
|
115
|
+
import chalk from 'chalk';
|
|
116
|
+
|
|
117
|
+
chalk.rgb(222, 173, 237);
|
|
118
|
+
```
|
|
119
|
+
*/
|
|
120
|
+
rgb: (red: number, green: number, blue: number) => this;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
Use HEX value to set text color.
|
|
124
|
+
|
|
125
|
+
@param color - Hexadecimal value representing the desired color.
|
|
126
|
+
|
|
127
|
+
@example
|
|
128
|
+
```
|
|
129
|
+
import chalk from 'chalk';
|
|
130
|
+
|
|
131
|
+
chalk.hex('#DEADED');
|
|
132
|
+
```
|
|
133
|
+
*/
|
|
134
|
+
hex: (color: string) => this;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
|
138
|
+
|
|
139
|
+
@example
|
|
140
|
+
```
|
|
141
|
+
import chalk from 'chalk';
|
|
142
|
+
|
|
143
|
+
chalk.ansi256(201);
|
|
144
|
+
```
|
|
145
|
+
*/
|
|
146
|
+
ansi256: (index: number) => this;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
Use RGB values to set background color.
|
|
150
|
+
|
|
151
|
+
@example
|
|
152
|
+
```
|
|
153
|
+
import chalk from 'chalk';
|
|
154
|
+
|
|
155
|
+
chalk.bgRgb(222, 173, 237);
|
|
156
|
+
```
|
|
157
|
+
*/
|
|
158
|
+
bgRgb: (red: number, green: number, blue: number) => this;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
Use HEX value to set background color.
|
|
162
|
+
|
|
163
|
+
@param color - Hexadecimal value representing the desired color.
|
|
164
|
+
|
|
165
|
+
@example
|
|
166
|
+
```
|
|
167
|
+
import chalk from 'chalk';
|
|
168
|
+
|
|
169
|
+
chalk.bgHex('#DEADED');
|
|
170
|
+
```
|
|
171
|
+
*/
|
|
172
|
+
bgHex: (color: string) => this;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
|
176
|
+
|
|
177
|
+
@example
|
|
178
|
+
```
|
|
179
|
+
import chalk from 'chalk';
|
|
180
|
+
|
|
181
|
+
chalk.bgAnsi256(201);
|
|
182
|
+
```
|
|
183
|
+
*/
|
|
184
|
+
bgAnsi256: (index: number) => this;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
Modifier: Reset the current style.
|
|
188
|
+
*/
|
|
189
|
+
readonly reset: this;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
Modifier: Make the text bold.
|
|
193
|
+
*/
|
|
194
|
+
readonly bold: this;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
Modifier: Make the text have lower opacity.
|
|
198
|
+
*/
|
|
199
|
+
readonly dim: this;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
Modifier: Make the text italic. *(Not widely supported)*
|
|
203
|
+
*/
|
|
204
|
+
readonly italic: this;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
Modifier: Put a horizontal line below the text. *(Not widely supported)*
|
|
208
|
+
*/
|
|
209
|
+
readonly underline: this;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
Modifier: Put a horizontal line above the text. *(Not widely supported)*
|
|
213
|
+
*/
|
|
214
|
+
readonly overline: this;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
Modifier: Invert background and foreground colors.
|
|
218
|
+
*/
|
|
219
|
+
readonly inverse: this;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
Modifier: Print the text but make it invisible.
|
|
223
|
+
*/
|
|
224
|
+
readonly hidden: this;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
Modifier: Puts a horizontal line through the center of the text. *(Not widely supported)*
|
|
228
|
+
*/
|
|
229
|
+
readonly strikethrough: this;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
Modifier: Print the text only when Chalk has a color level above zero.
|
|
233
|
+
|
|
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
|
+
|
|
247
|
+
/*
|
|
248
|
+
Alias for `blackBright`.
|
|
249
|
+
*/
|
|
250
|
+
readonly gray: this;
|
|
251
|
+
|
|
252
|
+
/*
|
|
253
|
+
Alias for `blackBright`.
|
|
254
|
+
*/
|
|
255
|
+
readonly grey: this;
|
|
256
|
+
|
|
257
|
+
readonly blackBright: this;
|
|
258
|
+
readonly redBright: this;
|
|
259
|
+
readonly greenBright: this;
|
|
260
|
+
readonly yellowBright: this;
|
|
261
|
+
readonly blueBright: this;
|
|
262
|
+
readonly magentaBright: this;
|
|
263
|
+
readonly cyanBright: this;
|
|
264
|
+
readonly whiteBright: this;
|
|
265
|
+
|
|
266
|
+
readonly bgBlack: this;
|
|
267
|
+
readonly bgRed: this;
|
|
268
|
+
readonly bgGreen: this;
|
|
269
|
+
readonly bgYellow: this;
|
|
270
|
+
readonly bgBlue: this;
|
|
271
|
+
readonly bgMagenta: this;
|
|
272
|
+
readonly bgCyan: this;
|
|
273
|
+
readonly bgWhite: this;
|
|
274
|
+
|
|
275
|
+
/*
|
|
276
|
+
Alias for `bgBlackBright`.
|
|
277
|
+
*/
|
|
278
|
+
readonly bgGray: this;
|
|
279
|
+
|
|
280
|
+
/*
|
|
281
|
+
Alias for `bgBlackBright`.
|
|
282
|
+
*/
|
|
283
|
+
readonly bgGrey: this;
|
|
284
|
+
|
|
285
|
+
readonly bgBlackBright: this;
|
|
286
|
+
readonly bgRedBright: this;
|
|
287
|
+
readonly bgGreenBright: this;
|
|
288
|
+
readonly bgYellowBright: this;
|
|
289
|
+
readonly bgBlueBright: this;
|
|
290
|
+
readonly bgMagentaBright: this;
|
|
291
|
+
readonly bgCyanBright: this;
|
|
292
|
+
readonly bgWhiteBright: this;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
Main Chalk object that allows to chain styles together.
|
|
297
|
+
|
|
298
|
+
Call the last one as a method with a string argument.
|
|
299
|
+
|
|
300
|
+
Order doesn't matter, and later styles take precedent in case of a conflict.
|
|
301
|
+
|
|
302
|
+
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
|
303
|
+
*/
|
|
304
|
+
declare const chalk: ChalkInstance;
|
|
305
|
+
|
|
306
|
+
export const supportsColor: ColorInfo;
|
|
307
|
+
|
|
308
|
+
export const chalkStderr: typeof chalk;
|
|
309
|
+
export const supportsColorStderr: typeof supportsColor;
|
|
310
|
+
|
|
311
|
+
export {
|
|
312
|
+
ColorInfo,
|
|
313
|
+
ColorSupport,
|
|
314
|
+
ColorSupportLevel,
|
|
315
|
+
// } from '#supports-color';
|
|
316
|
+
} from './vendor/supports-color/index.js';
|
|
317
|
+
|
|
318
|
+
export default chalk;
|