chalk 5.1.2 → 5.2.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chalk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Terminal string styling done right",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/chalk",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"log-update": "^5.0.0",
|
|
59
59
|
"matcha": "^0.7.0",
|
|
60
60
|
"tsd": "^0.19.0",
|
|
61
|
-
"xo": "^0.
|
|
61
|
+
"xo": "^0.53.0",
|
|
62
62
|
"yoctodelay": "^2.0.0"
|
|
63
63
|
},
|
|
64
64
|
"xo": {
|
package/readme.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://codecov.io/gh/chalk/chalk)
|
|
13
13
|
[](https://www.npmjs.com/package/chalk?activeTab=dependents)
|
|
14
14
|
[](https://www.npmjs.com/package/chalk)
|
|
15
|
-
[](https://repl.it/github/chalk/chalk)
|
|
16
16
|
|
|
17
17
|

|
|
18
18
|
|
|
@@ -40,18 +40,6 @@
|
|
|
40
40
|
</a>
|
|
41
41
|
<br>
|
|
42
42
|
<br>
|
|
43
|
-
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
|
|
44
|
-
<div>
|
|
45
|
-
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
|
|
46
|
-
</div>
|
|
47
|
-
<b>All your environment variables, in one place</b>
|
|
48
|
-
<div>
|
|
49
|
-
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
|
|
50
|
-
<br>
|
|
51
|
-
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
|
|
52
|
-
</div>
|
|
53
|
-
</a>
|
|
54
|
-
<br>
|
|
55
43
|
<a href="https://strapi.io/?ref=sindresorhus">
|
|
56
44
|
<div>
|
|
57
45
|
<img src="https://sindresorhus.com/assets/thanks/strapi-logo-white-bg.png" width="220" alt="Strapi">
|
|
@@ -281,7 +269,7 @@ console.log(foregroundColorNames.includes('pink'));
|
|
|
281
269
|
|
|
282
270
|
## 256 and Truecolor color support
|
|
283
271
|
|
|
284
|
-
Chalk supports 256 colors and [Truecolor](https://
|
|
272
|
+
Chalk supports 256 colors and [Truecolor](https://github.com/termstandard/colors) (16 million colors) on supported terminal apps.
|
|
285
273
|
|
|
286
274
|
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
|
287
275
|
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const level = (() => {
|
|
4
|
+
if (navigator.userAgentData) {
|
|
5
|
+
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
|
6
|
+
if (brand && brand.version > 93) {
|
|
7
|
+
return 3;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return 0;
|
|
16
|
+
})();
|
|
17
|
+
|
|
18
|
+
const colorSupport = level !== 0 && {
|
|
19
|
+
level,
|
|
9
20
|
hasBasic: true,
|
|
10
|
-
has256:
|
|
11
|
-
has16m:
|
|
12
|
-
}
|
|
21
|
+
has256: level >= 2,
|
|
22
|
+
has16m: level >= 3,
|
|
23
|
+
};
|
|
13
24
|
|
|
14
25
|
const supportsColor = {
|
|
15
26
|
stdout: colorSupport,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {WriteStream} from 'node:tty';
|
|
1
|
+
import type {WriteStream} from 'node:tty';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type Options = {
|
|
4
4
|
/**
|
|
5
5
|
Whether `process.argv` should be sniffed for `--color` and `--no-color` flags.
|
|
6
6
|
|
|
7
7
|
@default true
|
|
8
8
|
*/
|
|
9
9
|
readonly sniffFlags?: boolean;
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
Levels:
|
|
@@ -21,7 +21,7 @@ export type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
|
21
21
|
/**
|
|
22
22
|
Detect whether the terminal supports color.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export type ColorSupport = {
|
|
25
25
|
/**
|
|
26
26
|
The color level.
|
|
27
27
|
*/
|
|
@@ -41,11 +41,11 @@ export interface ColorSupport {
|
|
|
41
41
|
Whether Truecolor 16 million colors are supported.
|
|
42
42
|
*/
|
|
43
43
|
has16m: boolean;
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
45
|
|
|
46
46
|
export type ColorInfo = ColorSupport | false;
|
|
47
47
|
|
|
48
|
-
export function createSupportsColor(stream
|
|
48
|
+
export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo;
|
|
49
49
|
|
|
50
50
|
declare const supportsColor: {
|
|
51
51
|
stdout: ColorInfo;
|
|
@@ -3,7 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import tty from 'node:tty';
|
|
4
4
|
|
|
5
5
|
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
6
|
-
function hasFlag(flag, argv = process.argv) {
|
|
6
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
|
7
7
|
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
8
8
|
const position = argv.indexOf(prefix + flag);
|
|
9
9
|
const terminatorPosition = argv.indexOf('--');
|
|
@@ -80,6 +80,12 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// Check for Azure DevOps pipelines.
|
|
84
|
+
// Has to be above the `!streamIsTTY` check.
|
|
85
|
+
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
84
90
|
return 0;
|
|
85
91
|
}
|
|
@@ -105,7 +111,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
if ('CI' in env) {
|
|
108
|
-
if (
|
|
114
|
+
if ('GITHUB_ACTIONS' in env) {
|
|
115
|
+
return 3;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
109
119
|
return 1;
|
|
110
120
|
}
|
|
111
121
|
|
|
@@ -116,12 +126,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
116
126
|
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
117
127
|
}
|
|
118
128
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return 1;
|
|
129
|
+
if (env.COLORTERM === 'truecolor') {
|
|
130
|
+
return 3;
|
|
122
131
|
}
|
|
123
132
|
|
|
124
|
-
if (env.
|
|
133
|
+
if (env.TERM === 'xterm-kitty') {
|
|
125
134
|
return 3;
|
|
126
135
|
}
|
|
127
136
|
|
|
@@ -129,10 +138,13 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
129
138
|
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
130
139
|
|
|
131
140
|
switch (env.TERM_PROGRAM) {
|
|
132
|
-
case 'iTerm.app':
|
|
141
|
+
case 'iTerm.app': {
|
|
133
142
|
return version >= 3 ? 3 : 2;
|
|
134
|
-
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
case 'Apple_Terminal': {
|
|
135
146
|
return 2;
|
|
147
|
+
}
|
|
136
148
|
// No default
|
|
137
149
|
}
|
|
138
150
|
}
|