@visulima/is-ansi-color-supported 2.3.5 → 3.0.0-alpha.10
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/CHANGELOG.md +113 -0
- package/LICENSE.md +1 -1
- package/README.md +32 -14
- package/dist/is-color-supported.browser.cjs +2 -1
- package/dist/is-color-supported.browser.mjs +2 -1
- package/dist/is-color-supported.edge-light.cjs +3 -2
- package/dist/is-color-supported.edge-light.mjs +3 -2
- package/dist/is-color-supported.server.cjs +23 -16
- package/dist/is-color-supported.server.mjs +23 -16
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,116 @@
|
|
|
1
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.10](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.9...@visulima/is-ansi-color-supported@3.0.0-alpha.10) (2026-04-22)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* Remove JSR configuration generation script and generated jsr.json files ([#616](https://github.com/visulima/visulima/issues/616)) ([533744b](https://github.com/visulima/visulima/commit/533744b103b74896941db5b727173e617a27a63b))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* bump engines.node to ^22.14.0 || >=24.10.0 ([c3d0931](https://github.com/visulima/visulima/commit/c3d0931d1504e4f21ebf50ea680cfa7ce4ba15ce))
|
|
10
|
+
* fixed jsr.json ([5d85e51](https://github.com/visulima/visulima/commit/5d85e5179de38e284ec433b14d77c71a1619c8d6))
|
|
11
|
+
|
|
12
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.8...@visulima/is-ansi-color-supported@3.0.0-alpha.9) (2026-04-15)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **is-ansi-color-supported:** add node types for process global ([ac91525](https://github.com/visulima/visulima/commit/ac915251cb0390ca930c2ffef42cf20be98231b8))
|
|
17
|
+
* **terminal:** resolve eslint and formatting issues ([8f30389](https://github.com/visulima/visulima/commit/8f30389deb9ff81e7afce0aa064ef11fcb179f23))
|
|
18
|
+
|
|
19
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.7...@visulima/is-ansi-color-supported@3.0.0-alpha.8) (2026-04-08)
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **is-ansi-color-supported:** resolve eslint errors ([0dc2a10](https://github.com/visulima/visulima/commit/0dc2a10efb727473fa108979c6171098a3cefacb))
|
|
24
|
+
* resolve failing tests across multiple packages ([2b4b6f0](https://github.com/visulima/visulima/commit/2b4b6f04169b60fdc4cf77b293015436a272c0fb))
|
|
25
|
+
|
|
26
|
+
### Miscellaneous Chores
|
|
27
|
+
|
|
28
|
+
* **is-ansi-color-supported:** add tsconfig.eslint.json for type-aware linting ([81cc05a](https://github.com/visulima/visulima/commit/81cc05abf7ef84398d8b90816f9802580ca3a639))
|
|
29
|
+
* **is-ansi-color-supported:** apply prettier formatting ([9efa94d](https://github.com/visulima/visulima/commit/9efa94d0a4f392857665ffc010e41f86a92d3dc0))
|
|
30
|
+
* **is-ansi-color-supported:** migrate .prettierrc.cjs to prettier.config.js ([b25b9c9](https://github.com/visulima/visulima/commit/b25b9c9c4858f6c562b4952eb6d0862b56de98b6))
|
|
31
|
+
* **terminal:** remove empty dependency objects from package.json ([562c704](https://github.com/visulima/visulima/commit/562c704e5d90aa2d13eae942ebbdcfeb787c2b46))
|
|
32
|
+
|
|
33
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.7](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.6...@visulima/is-ansi-color-supported@3.0.0-alpha.7) (2026-03-26)
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
* **web:** auto-generate packages page from workspace metadata ([623e520](https://github.com/visulima/visulima/commit/623e5207693a7fe720f5f2f179593a3654c880e3))
|
|
38
|
+
|
|
39
|
+
### Miscellaneous Chores
|
|
40
|
+
|
|
41
|
+
* update homepage URLs to visulima.com/packages/ format ([be42968](https://github.com/visulima/visulima/commit/be42968129df85fb074224435e33135ff44cab91))
|
|
42
|
+
|
|
43
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.6](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.5...@visulima/is-ansi-color-supported@3.0.0-alpha.6) (2026-03-26)
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
* **web:** improve build setup with incremental stats caching and prod install ([fe33e75](https://github.com/visulima/visulima/commit/fe33e75827586779b4b3a0c6d57b39f889ee6207))
|
|
48
|
+
|
|
49
|
+
### Miscellaneous Chores
|
|
50
|
+
|
|
51
|
+
* **is-ansi-color-supported:** migrate deps to pnpm catalogs ([426b1cc](https://github.com/visulima/visulima/commit/426b1cc246a502c29180d2340ef2f1edc4e345dd))
|
|
52
|
+
* **is-ansi-color-supported:** update dependencies ([9e61102](https://github.com/visulima/visulima/commit/9e61102fda7078094f88f9ccadd2965ad7816231))
|
|
53
|
+
* visulima website ([#591](https://github.com/visulima/visulima/issues/591)) ([59ab2e2](https://github.com/visulima/visulima/commit/59ab2e2befb03e51cd2088956f83d9b87de6d033))
|
|
54
|
+
|
|
55
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.5](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.4...@visulima/is-ansi-color-supported@3.0.0-alpha.5) (2026-03-06)
|
|
56
|
+
|
|
57
|
+
### Bug Fixes
|
|
58
|
+
|
|
59
|
+
* **is-ansi-color-supported:** update packem to 2.0.0-alpha.54 ([1ca2c4c](https://github.com/visulima/visulima/commit/1ca2c4c8b8f316a6e77aad1f8569ec4b9dae51b0))
|
|
60
|
+
|
|
61
|
+
### Documentation
|
|
62
|
+
|
|
63
|
+
* **boxen,command-line-args,tabular,is-ansi-color-supported,disposable-email-domains:** add comprehensive Fumadocs documentation ([95e0578](https://github.com/visulima/visulima/commit/95e057833978dfeeb9f2768269e36862572539db))
|
|
64
|
+
|
|
65
|
+
### Miscellaneous Chores
|
|
66
|
+
|
|
67
|
+
* **is-ansi-color-supported:** update dependencies ([624b623](https://github.com/visulima/visulima/commit/624b623b5aec3d7b159a2779553e5dd8667e9ff9))
|
|
68
|
+
* **is-ansi-color-supported:** update dependencies ([92c254e](https://github.com/visulima/visulima/commit/92c254e8773e1b5b8daaa50e206a1330f4de2c90))
|
|
69
|
+
* **terminal:** update dependencies ([a5bb91a](https://github.com/visulima/visulima/commit/a5bb91a66f2be2ade485d586156a54c347a23cc9))
|
|
70
|
+
* update lock file maintenance ([d83e716](https://github.com/visulima/visulima/commit/d83e71697b75d24704185b66bb521a934d2db02d))
|
|
71
|
+
* year update ([47f4105](https://github.com/visulima/visulima/commit/47f410596ce7190cfea36a073db32e0cec50bbcd))
|
|
72
|
+
|
|
73
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.4](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.3...@visulima/is-ansi-color-supported@3.0.0-alpha.4) (2025-12-27)
|
|
74
|
+
|
|
75
|
+
### Bug Fixes
|
|
76
|
+
|
|
77
|
+
* **is-ansi-color-supported:** update package files ([83a7a52](https://github.com/visulima/visulima/commit/83a7a52760135c66ea5275df5b5de05841f094bb))
|
|
78
|
+
|
|
79
|
+
### Miscellaneous Chores
|
|
80
|
+
|
|
81
|
+
* fixed project.json names and schema path ([964722f](https://github.com/visulima/visulima/commit/964722f691db205c7edb9aa6db29e849a647500b))
|
|
82
|
+
|
|
83
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.3](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.2...@visulima/is-ansi-color-supported@3.0.0-alpha.3) (2025-12-11)
|
|
84
|
+
|
|
85
|
+
### Bug Fixes
|
|
86
|
+
|
|
87
|
+
* update package OG images across multiple packages ([f08e4dd](https://github.com/visulima/visulima/commit/f08e4dd2b105ccb29c8412020a9c2be36d6c1e9e))
|
|
88
|
+
|
|
89
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.2](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.1...@visulima/is-ansi-color-supported@3.0.0-alpha.2) (2025-12-06)
|
|
90
|
+
|
|
91
|
+
### Bug Fixes
|
|
92
|
+
|
|
93
|
+
* add new package image, fixed readme rendering on npm, fixed building of packages ([b790ba2](https://github.com/visulima/visulima/commit/b790ba253ea07fef83528fd822a678facf021b5f))
|
|
94
|
+
|
|
95
|
+
### Miscellaneous Chores
|
|
96
|
+
|
|
97
|
+
* update @anolilab/semantic-release-pnpm and @anolilab/semantic-release-preset to versions 3.2.2 and 12.1.2 across multiple package.json files for improved compatibility ([3921626](https://github.com/visulima/visulima/commit/3921626141fe5da398749bf0ba675f1596f18afb))
|
|
98
|
+
|
|
99
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.1](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.3.5...@visulima/is-ansi-color-supported@3.0.0-alpha.1) (2025-12-04)
|
|
100
|
+
|
|
101
|
+
### ⚠ BREAKING CHANGES
|
|
102
|
+
|
|
103
|
+
* change min node version to 22.13
|
|
104
|
+
|
|
105
|
+
### Bug Fixes
|
|
106
|
+
|
|
107
|
+
* update Node.js engine version requirement to >=22.13 in multiple package.json files for improved compatibility ([b828e9a](https://github.com/visulima/visulima/commit/b828e9aeaebfc798eecddccd90e6ec7560c6d36a))
|
|
108
|
+
|
|
109
|
+
### Miscellaneous Chores
|
|
110
|
+
|
|
111
|
+
* moved all packages into groups ([0615e9d](https://github.com/visulima/visulima/commit/0615e9d14a8a886e11da529ce150cf31ca973c10))
|
|
112
|
+
* update dependencies across multiple packages to improve compatibility and performance, including upgrading `@anolilab/semantic-release-pnpm` and `@anolilab/semantic-release-preset` to versions 3.2.0 and 12.1.0 respectively, and updating `react`, `react-dom`, and `next` versions to 19.2.1 and 16.0.7 in various package.json files ([aee8fcd](https://github.com/visulima/visulima/commit/aee8fcd796ae9b8d055903260e7150996ea9f53d))
|
|
113
|
+
|
|
1
114
|
## @visulima/is-ansi-color-supported [2.3.5](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.3.4...@visulima/is-ansi-color-supported@2.3.5) (2025-11-13)
|
|
2
115
|
|
|
3
116
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<!-- START_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
2
|
+
|
|
3
|
+
<a href="https://www.anolilab.com/open-source" align="center">
|
|
4
|
+
|
|
5
|
+
<img src="__assets__/package-og.svg" alt="is-ansi-color-supported" />
|
|
6
|
+
|
|
7
|
+
</a>
|
|
8
|
+
|
|
9
|
+
<h3 align="center">Detect whether a terminal or browser supports ansi colors.</h3>
|
|
10
|
+
|
|
11
|
+
<!-- END_PACKAGE_OG_IMAGE_PLACEHOLDER -->
|
|
7
12
|
|
|
8
13
|
<br />
|
|
9
14
|
|
|
10
15
|
<div align="center">
|
|
11
16
|
|
|
12
|
-
[![typescript-image]
|
|
17
|
+
[![typescript-image][typescript-badge]][typescript-url]
|
|
18
|
+
[![mit licence][license-badge]][license]
|
|
19
|
+
[![npm downloads][npm-downloads-badge]][npm-downloads]
|
|
20
|
+
[![Chat][chat-badge]][chat]
|
|
21
|
+
[![PRs Welcome][prs-welcome-badge]][prs-welcome]
|
|
13
22
|
|
|
14
23
|
</div>
|
|
15
24
|
|
|
@@ -164,14 +173,23 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
164
173
|
- [Daniel Bannert](https://github.com/prisis)
|
|
165
174
|
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
166
175
|
|
|
176
|
+
## Made with ❤️ at Anolilab
|
|
177
|
+
|
|
178
|
+
This is an open source project and will always remain free to use. If you think it's cool, please star it 🌟. [Anolilab](https://www.anolilab.com/open-source) is a Development and AI Studio. Contact us at [hello@anolilab.com](mailto:hello@anolilab.com) if you need any help with these technologies or just want to say hi!
|
|
179
|
+
|
|
167
180
|
## License
|
|
168
181
|
|
|
169
|
-
The visulima is-ansi-color-supported is open-sourced software licensed under the [MIT][license
|
|
182
|
+
The visulima is-ansi-color-supported is open-sourced software licensed under the [MIT][license]
|
|
170
183
|
|
|
171
|
-
|
|
184
|
+
<!-- badges -->
|
|
172
185
|
|
|
173
|
-
[
|
|
174
|
-
[license
|
|
175
|
-
[
|
|
176
|
-
[npm-
|
|
177
|
-
[
|
|
186
|
+
[license-badge]: https://img.shields.io/npm/l/@visulima/is-ansi-color-supported?style=for-the-badge
|
|
187
|
+
[license]: https://github.com/visulima/visulima/blob/main/LICENSE
|
|
188
|
+
[npm-downloads-badge]: https://img.shields.io/npm/dm/@visulima/is-ansi-color-supported?style=for-the-badge
|
|
189
|
+
[npm-downloads]: https://www.npmjs.com/package/@visulima/is-ansi-color-supported
|
|
190
|
+
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
|
|
191
|
+
[prs-welcome]: https://github.com/visulima/visulima/blob/main/.github/CONTRIBUTING.md
|
|
192
|
+
[chat-badge]: https://img.shields.io/discord/932323359193186354.svg?style=for-the-badge
|
|
193
|
+
[chat]: https://discord.gg/TtFJY8xkFK
|
|
194
|
+
[typescript-badge]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
195
|
+
[typescript-url]: https://www.typescriptlang.org/
|
|
@@ -4,6 +4,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
4
4
|
|
|
5
5
|
const SPACE_MONO = require('./packem_shared/SPACE_MONO-Cwv43lY6.cjs');
|
|
6
6
|
|
|
7
|
+
const CHROME_CHROMIUM_RE = /\b(Chrome|Chromium)\//;
|
|
7
8
|
const isColorSupported = () => (() => {
|
|
8
9
|
if (typeof navigator !== "undefined") {
|
|
9
10
|
if (navigator.userAgentData) {
|
|
@@ -12,7 +13,7 @@ const isColorSupported = () => (() => {
|
|
|
12
13
|
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
if (
|
|
16
|
+
if (CHROME_CHROMIUM_RE.test(navigator.userAgent)) {
|
|
16
17
|
return SPACE_MONO.SPACE_16_COLORS;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SPACE_TRUE_COLORS, SPACE_16_COLORS, SPACE_MONO } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
2
2
|
export { SPACE_256_COLORS } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
3
3
|
|
|
4
|
+
const CHROME_CHROMIUM_RE = /\b(Chrome|Chromium)\//;
|
|
4
5
|
const isColorSupported = () => (() => {
|
|
5
6
|
if (typeof navigator !== "undefined") {
|
|
6
7
|
if (navigator.userAgentData) {
|
|
@@ -9,7 +10,7 @@ const isColorSupported = () => (() => {
|
|
|
9
10
|
return SPACE_TRUE_COLORS;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
if (
|
|
13
|
+
if (CHROME_CHROMIUM_RE.test(navigator.userAgent)) {
|
|
13
14
|
return SPACE_16_COLORS;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
4
4
|
|
|
5
5
|
const SPACE_MONO = require('./packem_shared/SPACE_MONO-Cwv43lY6.cjs');
|
|
6
6
|
|
|
7
|
+
const CHROME_CHROMIUM_RE = /\b(Chrome|Chromium)\//;
|
|
7
8
|
const isColorSupported$1 = () => (() => {
|
|
8
9
|
if (typeof navigator !== "undefined") {
|
|
9
10
|
if (navigator.userAgentData) {
|
|
@@ -12,7 +13,7 @@ const isColorSupported$1 = () => (() => {
|
|
|
12
13
|
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
if (
|
|
16
|
+
if (CHROME_CHROMIUM_RE.test(navigator.userAgent)) {
|
|
16
17
|
return SPACE_MONO.SPACE_16_COLORS;
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -21,7 +22,7 @@ const isColorSupported$1 = () => (() => {
|
|
|
21
22
|
const isStdoutColorSupported$1 = isColorSupported$1;
|
|
22
23
|
|
|
23
24
|
const isColorSupported = () => (() => {
|
|
24
|
-
if (process.env.NEXT_RUNTIME
|
|
25
|
+
if (process.env.NEXT_RUNTIME?.includes("edge")) {
|
|
25
26
|
return SPACE_MONO.SPACE_16_COLORS;
|
|
26
27
|
}
|
|
27
28
|
return isStdoutColorSupported$1();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SPACE_TRUE_COLORS, SPACE_16_COLORS, SPACE_MONO } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
2
2
|
export { SPACE_256_COLORS } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
3
3
|
|
|
4
|
+
const CHROME_CHROMIUM_RE = /\b(Chrome|Chromium)\//;
|
|
4
5
|
const isColorSupported$1 = () => (() => {
|
|
5
6
|
if (typeof navigator !== "undefined") {
|
|
6
7
|
if (navigator.userAgentData) {
|
|
@@ -9,7 +10,7 @@ const isColorSupported$1 = () => (() => {
|
|
|
9
10
|
return SPACE_TRUE_COLORS;
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
|
-
if (
|
|
13
|
+
if (CHROME_CHROMIUM_RE.test(navigator.userAgent)) {
|
|
13
14
|
return SPACE_16_COLORS;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -18,7 +19,7 @@ const isColorSupported$1 = () => (() => {
|
|
|
18
19
|
const isStdoutColorSupported$1 = isColorSupported$1;
|
|
19
20
|
|
|
20
21
|
const isColorSupported = () => (() => {
|
|
21
|
-
if (process.env.NEXT_RUNTIME
|
|
22
|
+
if (process.env.NEXT_RUNTIME?.includes("edge")) {
|
|
22
23
|
return SPACE_16_COLORS;
|
|
23
24
|
}
|
|
24
25
|
return isStdoutColorSupported$1();
|
|
@@ -4,6 +4,14 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
4
4
|
|
|
5
5
|
const SPACE_MONO = require('./packem_shared/SPACE_MONO-Cwv43lY6.cjs');
|
|
6
6
|
|
|
7
|
+
const NO_COLOR_FLAGS_RE = /^-{1,2}(no-color|no-colors|color=false|color=never)$/;
|
|
8
|
+
const COLOR_256_FLAGS_RE = /^-{1,2}(color=256)$/;
|
|
9
|
+
const COLOR_TRUECOLOR_FLAGS_RE = /^-{1,2}(color=16m|color=full|color=truecolor)$/;
|
|
10
|
+
const COLOR_ENABLED_FLAGS_RE = /^-{1,2}(color|colors|color=true|color=always)$/;
|
|
11
|
+
const DUMB_TERM_RE = /-mono|dumb/i;
|
|
12
|
+
const TEAMCITY_RE = /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/;
|
|
13
|
+
const TERM_256_RE = /-256(color)?$/i;
|
|
14
|
+
const TERM_COLOR_RE = /^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i;
|
|
7
15
|
const isColorSupportedFactory = (stdName) => {
|
|
8
16
|
const _this = globalThis;
|
|
9
17
|
const isDeno = _this.Deno != void 0;
|
|
@@ -21,8 +29,9 @@ const isColorSupportedFactory = (stdName) => {
|
|
|
21
29
|
}
|
|
22
30
|
const FORCE_COLOR = "FORCE_COLOR";
|
|
23
31
|
const hasForceColor = FORCE_COLOR in environment;
|
|
24
|
-
const forceColorValue = environment[FORCE_COLOR]
|
|
32
|
+
const forceColorValue = environment[FORCE_COLOR] ?? void 0;
|
|
25
33
|
const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === "String";
|
|
34
|
+
const forceColorValueIsNumber = typeof forceColorValue === "number";
|
|
26
35
|
let forceColor;
|
|
27
36
|
if (forceColorValue === "true") {
|
|
28
37
|
forceColor = SPACE_MONO.SPACE_16_COLORS;
|
|
@@ -32,29 +41,31 @@ const isColorSupportedFactory = (stdName) => {
|
|
|
32
41
|
forceColor = SPACE_MONO.SPACE_16_COLORS;
|
|
33
42
|
} else if (forceColorValueIsString && forceColorValue.length > 0) {
|
|
34
43
|
forceColor = Math.min(Number.parseInt(forceColorValue, 10), 3);
|
|
44
|
+
} else if (forceColorValueIsNumber) {
|
|
45
|
+
forceColor = Math.min(forceColorValue, 3);
|
|
35
46
|
}
|
|
36
47
|
if (forceColorValue !== "true" && forceColorValue !== "false" && forceColor !== void 0 && forceColor < 4) {
|
|
37
48
|
return forceColor;
|
|
38
49
|
}
|
|
39
|
-
const isForceDisabled = "NO_COLOR" in environment || hasForceColor && forceColor === 0 || oneOfFlags(
|
|
50
|
+
const isForceDisabled = "NO_COLOR" in environment || hasForceColor && forceColor === 0 || oneOfFlags(NO_COLOR_FLAGS_RE);
|
|
40
51
|
if (isForceDisabled) {
|
|
41
52
|
return SPACE_MONO.SPACE_MONO;
|
|
42
53
|
}
|
|
43
|
-
if (oneOfFlags(
|
|
54
|
+
if (oneOfFlags(COLOR_256_FLAGS_RE)) {
|
|
44
55
|
return SPACE_MONO.SPACE_256_COLORS;
|
|
45
56
|
}
|
|
46
|
-
if (oneOfFlags(
|
|
57
|
+
if (oneOfFlags(COLOR_TRUECOLOR_FLAGS_RE)) {
|
|
47
58
|
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
48
59
|
}
|
|
49
|
-
const isForceEnabled = oneOfFlags(
|
|
60
|
+
const isForceEnabled = oneOfFlags(COLOR_ENABLED_FLAGS_RE);
|
|
50
61
|
if (isForceEnabled) {
|
|
51
62
|
return SPACE_MONO.SPACE_16_COLORS;
|
|
52
63
|
}
|
|
53
|
-
const minColorLevel = forceColor
|
|
64
|
+
const minColorLevel = forceColor ?? SPACE_MONO.SPACE_MONO;
|
|
54
65
|
if ("TF_BUILD" in environment && "AGENT_NAME" in environment) {
|
|
55
66
|
return SPACE_MONO.SPACE_16_COLORS;
|
|
56
67
|
}
|
|
57
|
-
const isDumbTerminal = environment.TERM &&
|
|
68
|
+
const isDumbTerminal = environment.TERM && DUMB_TERM_RE.test(environment.TERM);
|
|
58
69
|
if (isDumbTerminal) {
|
|
59
70
|
return minColorLevel;
|
|
60
71
|
}
|
|
@@ -81,7 +92,7 @@ const isColorSupportedFactory = (stdName) => {
|
|
|
81
92
|
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
82
93
|
}
|
|
83
94
|
if ("TEAMCITY_VERSION" in environment) {
|
|
84
|
-
return
|
|
95
|
+
return TEAMCITY_RE.test(environment.TEAMCITY_VERSION) ? SPACE_MONO.SPACE_16_COLORS : SPACE_MONO.SPACE_MONO;
|
|
85
96
|
}
|
|
86
97
|
if (environment.COLORTERM === "truecolor") {
|
|
87
98
|
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
@@ -104,22 +115,18 @@ const isColorSupportedFactory = (stdName) => {
|
|
|
104
115
|
return SPACE_MONO.SPACE_256_COLORS;
|
|
105
116
|
}
|
|
106
117
|
}
|
|
107
|
-
if (
|
|
118
|
+
if (TERM_256_RE.test(environment.TERM)) {
|
|
108
119
|
return SPACE_MONO.SPACE_256_COLORS;
|
|
109
120
|
}
|
|
110
|
-
let isTTY
|
|
121
|
+
let isTTY;
|
|
111
122
|
if (isDeno) {
|
|
112
|
-
|
|
113
|
-
isTTY = _this.Deno.stdout.isTerminal();
|
|
114
|
-
} else if (stdName === "err") {
|
|
115
|
-
isTTY = _this.Deno.stderr.isTerminal();
|
|
116
|
-
}
|
|
123
|
+
isTTY = stdName === "out" ? _this.Deno.stdout.isTerminal() : _this.Deno.stderr.isTerminal();
|
|
117
124
|
} else if ("PM2_HOME" in environment && "pm_id" in environment) {
|
|
118
125
|
isTTY = true;
|
|
119
126
|
} else {
|
|
120
127
|
isTTY = proc[`std${stdName}`] && "isTTY" in proc[`std${stdName}`];
|
|
121
128
|
}
|
|
122
|
-
if (isTTY &&
|
|
129
|
+
if (isTTY && TERM_COLOR_RE.test(environment.TERM)) {
|
|
123
130
|
return SPACE_MONO.SPACE_16_COLORS;
|
|
124
131
|
}
|
|
125
132
|
if ("COLORTERM" in environment) {
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { SPACE_MONO, SPACE_256_COLORS, SPACE_TRUE_COLORS, SPACE_16_COLORS } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
2
2
|
|
|
3
|
+
const NO_COLOR_FLAGS_RE = /^-{1,2}(no-color|no-colors|color=false|color=never)$/;
|
|
4
|
+
const COLOR_256_FLAGS_RE = /^-{1,2}(color=256)$/;
|
|
5
|
+
const COLOR_TRUECOLOR_FLAGS_RE = /^-{1,2}(color=16m|color=full|color=truecolor)$/;
|
|
6
|
+
const COLOR_ENABLED_FLAGS_RE = /^-{1,2}(color|colors|color=true|color=always)$/;
|
|
7
|
+
const DUMB_TERM_RE = /-mono|dumb/i;
|
|
8
|
+
const TEAMCITY_RE = /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/;
|
|
9
|
+
const TERM_256_RE = /-256(color)?$/i;
|
|
10
|
+
const TERM_COLOR_RE = /^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i;
|
|
3
11
|
const isColorSupportedFactory = (stdName) => {
|
|
4
12
|
const _this = globalThis;
|
|
5
13
|
const isDeno = _this.Deno != void 0;
|
|
@@ -17,8 +25,9 @@ const isColorSupportedFactory = (stdName) => {
|
|
|
17
25
|
}
|
|
18
26
|
const FORCE_COLOR = "FORCE_COLOR";
|
|
19
27
|
const hasForceColor = FORCE_COLOR in environment;
|
|
20
|
-
const forceColorValue = environment[FORCE_COLOR]
|
|
28
|
+
const forceColorValue = environment[FORCE_COLOR] ?? void 0;
|
|
21
29
|
const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === "String";
|
|
30
|
+
const forceColorValueIsNumber = typeof forceColorValue === "number";
|
|
22
31
|
let forceColor;
|
|
23
32
|
if (forceColorValue === "true") {
|
|
24
33
|
forceColor = SPACE_16_COLORS;
|
|
@@ -28,29 +37,31 @@ const isColorSupportedFactory = (stdName) => {
|
|
|
28
37
|
forceColor = SPACE_16_COLORS;
|
|
29
38
|
} else if (forceColorValueIsString && forceColorValue.length > 0) {
|
|
30
39
|
forceColor = Math.min(Number.parseInt(forceColorValue, 10), 3);
|
|
40
|
+
} else if (forceColorValueIsNumber) {
|
|
41
|
+
forceColor = Math.min(forceColorValue, 3);
|
|
31
42
|
}
|
|
32
43
|
if (forceColorValue !== "true" && forceColorValue !== "false" && forceColor !== void 0 && forceColor < 4) {
|
|
33
44
|
return forceColor;
|
|
34
45
|
}
|
|
35
|
-
const isForceDisabled = "NO_COLOR" in environment || hasForceColor && forceColor === 0 || oneOfFlags(
|
|
46
|
+
const isForceDisabled = "NO_COLOR" in environment || hasForceColor && forceColor === 0 || oneOfFlags(NO_COLOR_FLAGS_RE);
|
|
36
47
|
if (isForceDisabled) {
|
|
37
48
|
return SPACE_MONO;
|
|
38
49
|
}
|
|
39
|
-
if (oneOfFlags(
|
|
50
|
+
if (oneOfFlags(COLOR_256_FLAGS_RE)) {
|
|
40
51
|
return SPACE_256_COLORS;
|
|
41
52
|
}
|
|
42
|
-
if (oneOfFlags(
|
|
53
|
+
if (oneOfFlags(COLOR_TRUECOLOR_FLAGS_RE)) {
|
|
43
54
|
return SPACE_TRUE_COLORS;
|
|
44
55
|
}
|
|
45
|
-
const isForceEnabled = oneOfFlags(
|
|
56
|
+
const isForceEnabled = oneOfFlags(COLOR_ENABLED_FLAGS_RE);
|
|
46
57
|
if (isForceEnabled) {
|
|
47
58
|
return SPACE_16_COLORS;
|
|
48
59
|
}
|
|
49
|
-
const minColorLevel = forceColor
|
|
60
|
+
const minColorLevel = forceColor ?? SPACE_MONO;
|
|
50
61
|
if ("TF_BUILD" in environment && "AGENT_NAME" in environment) {
|
|
51
62
|
return SPACE_16_COLORS;
|
|
52
63
|
}
|
|
53
|
-
const isDumbTerminal = environment.TERM &&
|
|
64
|
+
const isDumbTerminal = environment.TERM && DUMB_TERM_RE.test(environment.TERM);
|
|
54
65
|
if (isDumbTerminal) {
|
|
55
66
|
return minColorLevel;
|
|
56
67
|
}
|
|
@@ -77,7 +88,7 @@ const isColorSupportedFactory = (stdName) => {
|
|
|
77
88
|
return SPACE_TRUE_COLORS;
|
|
78
89
|
}
|
|
79
90
|
if ("TEAMCITY_VERSION" in environment) {
|
|
80
|
-
return
|
|
91
|
+
return TEAMCITY_RE.test(environment.TEAMCITY_VERSION) ? SPACE_16_COLORS : SPACE_MONO;
|
|
81
92
|
}
|
|
82
93
|
if (environment.COLORTERM === "truecolor") {
|
|
83
94
|
return SPACE_TRUE_COLORS;
|
|
@@ -100,22 +111,18 @@ const isColorSupportedFactory = (stdName) => {
|
|
|
100
111
|
return SPACE_256_COLORS;
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
|
-
if (
|
|
114
|
+
if (TERM_256_RE.test(environment.TERM)) {
|
|
104
115
|
return SPACE_256_COLORS;
|
|
105
116
|
}
|
|
106
|
-
let isTTY
|
|
117
|
+
let isTTY;
|
|
107
118
|
if (isDeno) {
|
|
108
|
-
|
|
109
|
-
isTTY = _this.Deno.stdout.isTerminal();
|
|
110
|
-
} else if (stdName === "err") {
|
|
111
|
-
isTTY = _this.Deno.stderr.isTerminal();
|
|
112
|
-
}
|
|
119
|
+
isTTY = stdName === "out" ? _this.Deno.stdout.isTerminal() : _this.Deno.stderr.isTerminal();
|
|
113
120
|
} else if ("PM2_HOME" in environment && "pm_id" in environment) {
|
|
114
121
|
isTTY = true;
|
|
115
122
|
} else {
|
|
116
123
|
isTTY = proc[`std${stdName}`] && "isTTY" in proc[`std${stdName}`];
|
|
117
124
|
}
|
|
118
|
-
if (isTTY &&
|
|
125
|
+
if (isTTY && TERM_COLOR_RE.test(environment.TERM)) {
|
|
119
126
|
return SPACE_16_COLORS;
|
|
120
127
|
}
|
|
121
128
|
if ("COLORTERM" in environment) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/is-ansi-color-supported",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.10",
|
|
4
4
|
"description": "Detect whether a terminal or browser supports ansi colors.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"shell",
|
|
33
33
|
"command-line"
|
|
34
34
|
],
|
|
35
|
-
"homepage": "https://
|
|
35
|
+
"homepage": "https://visulima.com/packages/is-ansi-color-supported/",
|
|
36
36
|
"bugs": {
|
|
37
37
|
"url": "https://github.com/visulima/visulima/issues"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
41
|
"url": "git+https://github.com/visulima/visulima.git",
|
|
42
|
-
"directory": "packages/is-ansi-color-supported"
|
|
42
|
+
"directory": "packages/terminal/is-ansi-color-supported"
|
|
43
43
|
},
|
|
44
44
|
"funding": [
|
|
45
45
|
{
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"LICENSE.md"
|
|
126
126
|
],
|
|
127
127
|
"engines": {
|
|
128
|
-
"node": "
|
|
128
|
+
"node": "^22.14.0 || >=24.10.0"
|
|
129
129
|
},
|
|
130
130
|
"os": [
|
|
131
131
|
"darwin",
|