supports-color 9.3.1 → 10.0.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/browser.js +7 -2
- package/index.d.ts +4 -4
- package/index.js +22 -10
- package/package.json +13 -10
- package/readme.md +2 -16
package/browser.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
|
+
/* eslint-disable n/no-unsupported-features/node-builtins */
|
|
2
3
|
|
|
3
4
|
const level = (() => {
|
|
4
|
-
if (navigator
|
|
5
|
+
if (!('navigator' in globalThis)) {
|
|
6
|
+
return 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (globalThis.navigator.userAgentData) {
|
|
5
10
|
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
|
6
11
|
if (brand?.version > 93) {
|
|
7
12
|
return 3;
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
15
|
|
|
11
|
-
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
16
|
+
if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
|
|
12
17
|
return 1;
|
|
13
18
|
}
|
|
14
19
|
|
package/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
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,7 +41,7 @@ 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
|
|
package/index.js
CHANGED
|
@@ -31,17 +31,29 @@ if (
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function envForceColor() {
|
|
34
|
-
if ('FORCE_COLOR' in env) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
34
|
+
if (!('FORCE_COLOR' in env)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
if (env.FORCE_COLOR === 'true') {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (env.FORCE_COLOR === 'false') {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
if (env.FORCE_COLOR.length === 0) {
|
|
47
|
+
return 1;
|
|
44
48
|
}
|
|
49
|
+
|
|
50
|
+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
51
|
+
|
|
52
|
+
if (![0, 1, 2, 3].includes(level)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return level;
|
|
45
57
|
}
|
|
46
58
|
|
|
47
59
|
function translateLevel(level) {
|
|
@@ -112,11 +124,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
112
124
|
}
|
|
113
125
|
|
|
114
126
|
if ('CI' in env) {
|
|
115
|
-
if ('GITHUB_ACTIONS' in env) {
|
|
127
|
+
if (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {
|
|
116
128
|
return 3;
|
|
117
129
|
}
|
|
118
130
|
|
|
119
|
-
if (['TRAVIS', '
|
|
131
|
+
if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
120
132
|
return 1;
|
|
121
133
|
}
|
|
122
134
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supports-color",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Detect whether a terminal supports color",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/supports-color",
|
|
@@ -12,15 +12,16 @@
|
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"exports": {
|
|
15
|
+
"types": "./index.d.ts",
|
|
15
16
|
"node": "./index.js",
|
|
16
17
|
"default": "./browser.js"
|
|
17
18
|
},
|
|
19
|
+
"sideEffects": false,
|
|
18
20
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
21
|
+
"node": ">=18"
|
|
20
22
|
},
|
|
21
23
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"test": "xo && tsd"
|
|
24
|
+
"test": "xo && ava && tsd"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
26
27
|
"index.js",
|
|
@@ -51,11 +52,13 @@
|
|
|
51
52
|
"16m"
|
|
52
53
|
],
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@types/node": "^
|
|
55
|
-
"ava": "^
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
"@types/node": "^22.10.2",
|
|
56
|
+
"ava": "^6.2.0",
|
|
57
|
+
"tsd": "^0.31.2",
|
|
58
|
+
"xo": "^0.60.0"
|
|
59
|
+
},
|
|
60
|
+
"ava": {
|
|
61
|
+
"serial": true,
|
|
62
|
+
"workerThreads": false
|
|
60
63
|
}
|
|
61
64
|
}
|
package/readme.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
|
|
7
|
+
```sh
|
|
8
|
+
npm install supports-color
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -73,17 +73,3 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
|
|
|
73
73
|
|
|
74
74
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
75
75
|
- [Josh Junon](https://github.com/qix-)
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
<div align="center">
|
|
80
|
-
<b>
|
|
81
|
-
<a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
|
82
|
-
</b>
|
|
83
|
-
<br>
|
|
84
|
-
<sub>
|
|
85
|
-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
86
|
-
</sub>
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
---
|