@visulima/is-ansi-color-supported 2.3.2 → 2.3.3
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 +10 -0
- package/dist/is-color-supported.browser.cjs +29 -1
- package/dist/is-color-supported.browser.mjs +21 -1
- package/dist/is-color-supported.edge-light.cjs +37 -1
- package/dist/is-color-supported.edge-light.mjs +29 -1
- package/dist/is-color-supported.server.cjs +138 -1
- package/dist/is-color-supported.server.mjs +129 -1
- package/dist/packem_shared/SPACE_MONO-Cwv43lY6.cjs +13 -0
- package/dist/packem_shared/SPACE_MONO-VdlYcTli.mjs +6 -0
- package/package.json +1 -1
- package/dist/packem_shared/SPACE_MONO-BEQbKWNs.mjs +0 -1
- package/dist/packem_shared/SPACE_MONO-CIFY-d7-.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## @visulima/is-ansi-color-supported [2.3.3](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.3.2...@visulima/is-ansi-color-supported@2.3.3) (2025-11-07)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* update TypeScript configurations and improve linting across multiple packages ([6f25ec7](https://github.com/visulima/visulima/commit/6f25ec7841da7246f8f9166efc5292a7089d37ee))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* update npm and pnpm configurations for monorepo optimization ([#564](https://github.com/visulima/visulima/issues/564)) ([5512b42](https://github.com/visulima/visulima/commit/5512b42f672c216b6a3c9e39035199a4ebd9a4b8))
|
|
10
|
+
|
|
1
11
|
## @visulima/is-ansi-color-supported [2.3.2](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.3.1...@visulima/is-ansi-color-supported@2.3.2) (2025-11-05)
|
|
2
12
|
|
|
3
13
|
### Bug Fixes
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const SPACE_MONO = require('./packem_shared/SPACE_MONO-Cwv43lY6.cjs');
|
|
6
|
+
|
|
7
|
+
const isColorSupported = () => (() => {
|
|
8
|
+
if (typeof navigator !== "undefined") {
|
|
9
|
+
if (navigator.userAgentData) {
|
|
10
|
+
const brand = navigator.userAgentData.brands.find(({ b }) => b === "Chromium");
|
|
11
|
+
if (brand?.version > 93) {
|
|
12
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
16
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return SPACE_MONO.SPACE_MONO;
|
|
20
|
+
})();
|
|
21
|
+
const isStdoutColorSupported = isColorSupported;
|
|
22
|
+
const isStderrColorSupported = isColorSupported;
|
|
23
|
+
|
|
24
|
+
exports.SPACE_16_COLORS = SPACE_MONO.SPACE_16_COLORS;
|
|
25
|
+
exports.SPACE_256_COLORS = SPACE_MONO.SPACE_256_COLORS;
|
|
26
|
+
exports.SPACE_MONO = SPACE_MONO.SPACE_MONO;
|
|
27
|
+
exports.SPACE_TRUE_COLORS = SPACE_MONO.SPACE_TRUE_COLORS;
|
|
28
|
+
exports.isStderrColorSupported = isStderrColorSupported;
|
|
29
|
+
exports.isStdoutColorSupported = isStdoutColorSupported;
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { SPACE_TRUE_COLORS, SPACE_16_COLORS, SPACE_MONO } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
2
|
+
export { SPACE_256_COLORS } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
3
|
+
|
|
4
|
+
const isColorSupported = () => (() => {
|
|
5
|
+
if (typeof navigator !== "undefined") {
|
|
6
|
+
if (navigator.userAgentData) {
|
|
7
|
+
const brand = navigator.userAgentData.brands.find(({ b }) => b === "Chromium");
|
|
8
|
+
if (brand?.version > 93) {
|
|
9
|
+
return SPACE_TRUE_COLORS;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
13
|
+
return SPACE_16_COLORS;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return SPACE_MONO;
|
|
17
|
+
})();
|
|
18
|
+
const isStdoutColorSupported = isColorSupported;
|
|
19
|
+
const isStderrColorSupported = isColorSupported;
|
|
20
|
+
|
|
21
|
+
export { SPACE_16_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const SPACE_MONO = require('./packem_shared/SPACE_MONO-Cwv43lY6.cjs');
|
|
6
|
+
|
|
7
|
+
const isColorSupported$1 = () => (() => {
|
|
8
|
+
if (typeof navigator !== "undefined") {
|
|
9
|
+
if (navigator.userAgentData) {
|
|
10
|
+
const brand = navigator.userAgentData.brands.find(({ b }) => b === "Chromium");
|
|
11
|
+
if (brand?.version > 93) {
|
|
12
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
16
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return SPACE_MONO.SPACE_MONO;
|
|
20
|
+
})();
|
|
21
|
+
const isStdoutColorSupported$1 = isColorSupported$1;
|
|
22
|
+
|
|
23
|
+
const isColorSupported = () => (() => {
|
|
24
|
+
if (process.env.NEXT_RUNTIME !== void 0 && process.env.NEXT_RUNTIME.includes("edge")) {
|
|
25
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
26
|
+
}
|
|
27
|
+
return isStdoutColorSupported$1();
|
|
28
|
+
})();
|
|
29
|
+
const isStdoutColorSupported = isColorSupported;
|
|
30
|
+
const isStderrColorSupported = isColorSupported;
|
|
31
|
+
|
|
32
|
+
exports.SPACE_16_COLORS = SPACE_MONO.SPACE_16_COLORS;
|
|
33
|
+
exports.SPACE_256_COLORS = SPACE_MONO.SPACE_256_COLORS;
|
|
34
|
+
exports.SPACE_MONO = SPACE_MONO.SPACE_MONO;
|
|
35
|
+
exports.SPACE_TRUE_COLORS = SPACE_MONO.SPACE_TRUE_COLORS;
|
|
36
|
+
exports.isStderrColorSupported = isStderrColorSupported;
|
|
37
|
+
exports.isStdoutColorSupported = isStdoutColorSupported;
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import { SPACE_TRUE_COLORS, SPACE_16_COLORS, SPACE_MONO } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
2
|
+
export { SPACE_256_COLORS } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
3
|
+
|
|
4
|
+
const isColorSupported$1 = () => (() => {
|
|
5
|
+
if (typeof navigator !== "undefined") {
|
|
6
|
+
if (navigator.userAgentData) {
|
|
7
|
+
const brand = navigator.userAgentData.brands.find(({ b }) => b === "Chromium");
|
|
8
|
+
if (brand?.version > 93) {
|
|
9
|
+
return SPACE_TRUE_COLORS;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
13
|
+
return SPACE_16_COLORS;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return SPACE_MONO;
|
|
17
|
+
})();
|
|
18
|
+
const isStdoutColorSupported$1 = isColorSupported$1;
|
|
19
|
+
|
|
20
|
+
const isColorSupported = () => (() => {
|
|
21
|
+
if (process.env.NEXT_RUNTIME !== void 0 && process.env.NEXT_RUNTIME.includes("edge")) {
|
|
22
|
+
return SPACE_16_COLORS;
|
|
23
|
+
}
|
|
24
|
+
return isStdoutColorSupported$1();
|
|
25
|
+
})();
|
|
26
|
+
const isStdoutColorSupported = isColorSupported;
|
|
27
|
+
const isStderrColorSupported = isColorSupported;
|
|
28
|
+
|
|
29
|
+
export { SPACE_16_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1 +1,138 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const SPACE_MONO = require('./packem_shared/SPACE_MONO-Cwv43lY6.cjs');
|
|
6
|
+
|
|
7
|
+
const isColorSupportedFactory = (stdName) => {
|
|
8
|
+
const _this = globalThis;
|
|
9
|
+
const isDeno = _this.Deno != void 0;
|
|
10
|
+
const proc = _this.process ?? _this.Deno ?? {};
|
|
11
|
+
const argv = proc.argv ?? proc.args ?? [];
|
|
12
|
+
const oneOfFlags = (regex) => {
|
|
13
|
+
const terminatorPosition = argv.indexOf("--");
|
|
14
|
+
const position = argv.findIndex((flag) => regex.test(flag));
|
|
15
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
16
|
+
};
|
|
17
|
+
let environment = {};
|
|
18
|
+
try {
|
|
19
|
+
environment = isDeno ? proc.env.toObject() : proc.env ?? {};
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
const FORCE_COLOR = "FORCE_COLOR";
|
|
23
|
+
const hasForceColor = FORCE_COLOR in environment;
|
|
24
|
+
const forceColorValue = environment[FORCE_COLOR] ? String(environment[FORCE_COLOR]) : void 0;
|
|
25
|
+
const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === "String";
|
|
26
|
+
let forceColor;
|
|
27
|
+
if (forceColorValue === "true") {
|
|
28
|
+
forceColor = SPACE_MONO.SPACE_16_COLORS;
|
|
29
|
+
} else if (forceColorValue === "false") {
|
|
30
|
+
forceColor = SPACE_MONO.SPACE_MONO;
|
|
31
|
+
} else if (forceColorValueIsString && forceColorValue.length === 0) {
|
|
32
|
+
forceColor = SPACE_MONO.SPACE_16_COLORS;
|
|
33
|
+
} else if (forceColorValueIsString && forceColorValue.length > 0) {
|
|
34
|
+
forceColor = Math.min(Number.parseInt(forceColorValue, 10), 3);
|
|
35
|
+
}
|
|
36
|
+
if (forceColorValue !== "true" && forceColorValue !== "false" && forceColor !== void 0 && forceColor < 4) {
|
|
37
|
+
return forceColor;
|
|
38
|
+
}
|
|
39
|
+
const isForceDisabled = "NO_COLOR" in environment || hasForceColor && forceColor === 0 || oneOfFlags(/^-{1,2}(no-color|no-colors|color=false|color=never)$/);
|
|
40
|
+
if (isForceDisabled) {
|
|
41
|
+
return SPACE_MONO.SPACE_MONO;
|
|
42
|
+
}
|
|
43
|
+
if (oneOfFlags(/^-{1,2}(color=256)$/)) {
|
|
44
|
+
return SPACE_MONO.SPACE_256_COLORS;
|
|
45
|
+
}
|
|
46
|
+
if (oneOfFlags(/^-{1,2}(color=16m|color=full|color=truecolor)$/)) {
|
|
47
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
48
|
+
}
|
|
49
|
+
const isForceEnabled = oneOfFlags(/^-{1,2}(color|colors|color=true|color=always)$/);
|
|
50
|
+
if (isForceEnabled) {
|
|
51
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
52
|
+
}
|
|
53
|
+
const minColorLevel = forceColor || SPACE_MONO.SPACE_MONO;
|
|
54
|
+
if ("TF_BUILD" in environment && "AGENT_NAME" in environment) {
|
|
55
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
56
|
+
}
|
|
57
|
+
const isDumbTerminal = environment.TERM && /-mono|dumb/i.test(environment.TERM);
|
|
58
|
+
if (isDumbTerminal) {
|
|
59
|
+
return minColorLevel;
|
|
60
|
+
}
|
|
61
|
+
if ((isDeno ? _this.Deno.build.os : proc.platform) === "win32") {
|
|
62
|
+
try {
|
|
63
|
+
const osRelease = (isDeno ? _this.Deno.osRelease() : proc.os.release()).split(".");
|
|
64
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
65
|
+
return Number(osRelease[2]) >= 14931 ? SPACE_MONO.SPACE_TRUE_COLORS : SPACE_MONO.SPACE_256_COLORS;
|
|
66
|
+
}
|
|
67
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if ("CI" in environment) {
|
|
72
|
+
if (["GITEA_ACTIONS", "CIRCLECI", "GITHUB_WORKFLOW", "GITHUB_ACTIONS"].some((sign) => sign in environment)) {
|
|
73
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
74
|
+
}
|
|
75
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in environment) || environment.CI_NAME === "codeship") {
|
|
76
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
77
|
+
}
|
|
78
|
+
return minColorLevel;
|
|
79
|
+
}
|
|
80
|
+
if (environment.TERMINAL_EMULATOR?.includes("JediTerm")) {
|
|
81
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
82
|
+
}
|
|
83
|
+
if ("TEAMCITY_VERSION" in environment) {
|
|
84
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(environment.TEAMCITY_VERSION) ? SPACE_MONO.SPACE_16_COLORS : SPACE_MONO.SPACE_MONO;
|
|
85
|
+
}
|
|
86
|
+
if (environment.COLORTERM === "truecolor") {
|
|
87
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
88
|
+
}
|
|
89
|
+
if (environment.TERM === "xterm-kitty") {
|
|
90
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
91
|
+
}
|
|
92
|
+
if (environment.TERM === "xterm-ghostty") {
|
|
93
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
94
|
+
}
|
|
95
|
+
if (environment.TERM === "wezterm") {
|
|
96
|
+
return SPACE_MONO.SPACE_TRUE_COLORS;
|
|
97
|
+
}
|
|
98
|
+
if ("TERM_PROGRAM" in environment) {
|
|
99
|
+
const version = Number.parseInt((environment.TERM_PROGRAM_VERSION ?? "").split(".")[0], 10);
|
|
100
|
+
if (environment.TERM_PROGRAM === "iTerm.app") {
|
|
101
|
+
return version >= 3 ? SPACE_MONO.SPACE_TRUE_COLORS : SPACE_MONO.SPACE_256_COLORS;
|
|
102
|
+
}
|
|
103
|
+
if (environment.TERM_PROGRAM === "Apple_Terminal") {
|
|
104
|
+
return SPACE_MONO.SPACE_256_COLORS;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (/-256(color)?$/i.test(environment.TERM)) {
|
|
108
|
+
return SPACE_MONO.SPACE_256_COLORS;
|
|
109
|
+
}
|
|
110
|
+
let isTTY = false;
|
|
111
|
+
if (isDeno) {
|
|
112
|
+
if (stdName === "out") {
|
|
113
|
+
isTTY = _this.Deno.stdout.isTerminal();
|
|
114
|
+
} else if (stdName === "err") {
|
|
115
|
+
isTTY = _this.Deno.stderr.isTerminal();
|
|
116
|
+
}
|
|
117
|
+
} else if ("PM2_HOME" in environment && "pm_id" in environment) {
|
|
118
|
+
isTTY = true;
|
|
119
|
+
} else {
|
|
120
|
+
isTTY = proc[`std${stdName}`] && "isTTY" in proc[`std${stdName}`];
|
|
121
|
+
}
|
|
122
|
+
if (isTTY && /^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(environment.TERM)) {
|
|
123
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
124
|
+
}
|
|
125
|
+
if ("COLORTERM" in environment) {
|
|
126
|
+
return SPACE_MONO.SPACE_16_COLORS;
|
|
127
|
+
}
|
|
128
|
+
return minColorLevel;
|
|
129
|
+
};
|
|
130
|
+
const isStdoutColorSupported = () => isColorSupportedFactory("out");
|
|
131
|
+
const isStderrColorSupported = () => isColorSupportedFactory("err");
|
|
132
|
+
|
|
133
|
+
exports.SPACE_16_COLORS = SPACE_MONO.SPACE_16_COLORS;
|
|
134
|
+
exports.SPACE_256_COLORS = SPACE_MONO.SPACE_256_COLORS;
|
|
135
|
+
exports.SPACE_MONO = SPACE_MONO.SPACE_MONO;
|
|
136
|
+
exports.SPACE_TRUE_COLORS = SPACE_MONO.SPACE_TRUE_COLORS;
|
|
137
|
+
exports.isStderrColorSupported = isStderrColorSupported;
|
|
138
|
+
exports.isStdoutColorSupported = isStdoutColorSupported;
|
|
@@ -1 +1,129 @@
|
|
|
1
|
-
|
|
1
|
+
import { SPACE_MONO, SPACE_256_COLORS, SPACE_TRUE_COLORS, SPACE_16_COLORS } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
|
|
2
|
+
|
|
3
|
+
const isColorSupportedFactory = (stdName) => {
|
|
4
|
+
const _this = globalThis;
|
|
5
|
+
const isDeno = _this.Deno != void 0;
|
|
6
|
+
const proc = _this.process ?? _this.Deno ?? {};
|
|
7
|
+
const argv = proc.argv ?? proc.args ?? [];
|
|
8
|
+
const oneOfFlags = (regex) => {
|
|
9
|
+
const terminatorPosition = argv.indexOf("--");
|
|
10
|
+
const position = argv.findIndex((flag) => regex.test(flag));
|
|
11
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
12
|
+
};
|
|
13
|
+
let environment = {};
|
|
14
|
+
try {
|
|
15
|
+
environment = isDeno ? proc.env.toObject() : proc.env ?? {};
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
const FORCE_COLOR = "FORCE_COLOR";
|
|
19
|
+
const hasForceColor = FORCE_COLOR in environment;
|
|
20
|
+
const forceColorValue = environment[FORCE_COLOR] ? String(environment[FORCE_COLOR]) : void 0;
|
|
21
|
+
const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === "String";
|
|
22
|
+
let forceColor;
|
|
23
|
+
if (forceColorValue === "true") {
|
|
24
|
+
forceColor = SPACE_16_COLORS;
|
|
25
|
+
} else if (forceColorValue === "false") {
|
|
26
|
+
forceColor = SPACE_MONO;
|
|
27
|
+
} else if (forceColorValueIsString && forceColorValue.length === 0) {
|
|
28
|
+
forceColor = SPACE_16_COLORS;
|
|
29
|
+
} else if (forceColorValueIsString && forceColorValue.length > 0) {
|
|
30
|
+
forceColor = Math.min(Number.parseInt(forceColorValue, 10), 3);
|
|
31
|
+
}
|
|
32
|
+
if (forceColorValue !== "true" && forceColorValue !== "false" && forceColor !== void 0 && forceColor < 4) {
|
|
33
|
+
return forceColor;
|
|
34
|
+
}
|
|
35
|
+
const isForceDisabled = "NO_COLOR" in environment || hasForceColor && forceColor === 0 || oneOfFlags(/^-{1,2}(no-color|no-colors|color=false|color=never)$/);
|
|
36
|
+
if (isForceDisabled) {
|
|
37
|
+
return SPACE_MONO;
|
|
38
|
+
}
|
|
39
|
+
if (oneOfFlags(/^-{1,2}(color=256)$/)) {
|
|
40
|
+
return SPACE_256_COLORS;
|
|
41
|
+
}
|
|
42
|
+
if (oneOfFlags(/^-{1,2}(color=16m|color=full|color=truecolor)$/)) {
|
|
43
|
+
return SPACE_TRUE_COLORS;
|
|
44
|
+
}
|
|
45
|
+
const isForceEnabled = oneOfFlags(/^-{1,2}(color|colors|color=true|color=always)$/);
|
|
46
|
+
if (isForceEnabled) {
|
|
47
|
+
return SPACE_16_COLORS;
|
|
48
|
+
}
|
|
49
|
+
const minColorLevel = forceColor || SPACE_MONO;
|
|
50
|
+
if ("TF_BUILD" in environment && "AGENT_NAME" in environment) {
|
|
51
|
+
return SPACE_16_COLORS;
|
|
52
|
+
}
|
|
53
|
+
const isDumbTerminal = environment.TERM && /-mono|dumb/i.test(environment.TERM);
|
|
54
|
+
if (isDumbTerminal) {
|
|
55
|
+
return minColorLevel;
|
|
56
|
+
}
|
|
57
|
+
if ((isDeno ? _this.Deno.build.os : proc.platform) === "win32") {
|
|
58
|
+
try {
|
|
59
|
+
const osRelease = (isDeno ? _this.Deno.osRelease() : proc.os.release()).split(".");
|
|
60
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
61
|
+
return Number(osRelease[2]) >= 14931 ? SPACE_TRUE_COLORS : SPACE_256_COLORS;
|
|
62
|
+
}
|
|
63
|
+
return SPACE_16_COLORS;
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if ("CI" in environment) {
|
|
68
|
+
if (["GITEA_ACTIONS", "CIRCLECI", "GITHUB_WORKFLOW", "GITHUB_ACTIONS"].some((sign) => sign in environment)) {
|
|
69
|
+
return SPACE_TRUE_COLORS;
|
|
70
|
+
}
|
|
71
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in environment) || environment.CI_NAME === "codeship") {
|
|
72
|
+
return SPACE_16_COLORS;
|
|
73
|
+
}
|
|
74
|
+
return minColorLevel;
|
|
75
|
+
}
|
|
76
|
+
if (environment.TERMINAL_EMULATOR?.includes("JediTerm")) {
|
|
77
|
+
return SPACE_TRUE_COLORS;
|
|
78
|
+
}
|
|
79
|
+
if ("TEAMCITY_VERSION" in environment) {
|
|
80
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(environment.TEAMCITY_VERSION) ? SPACE_16_COLORS : SPACE_MONO;
|
|
81
|
+
}
|
|
82
|
+
if (environment.COLORTERM === "truecolor") {
|
|
83
|
+
return SPACE_TRUE_COLORS;
|
|
84
|
+
}
|
|
85
|
+
if (environment.TERM === "xterm-kitty") {
|
|
86
|
+
return SPACE_TRUE_COLORS;
|
|
87
|
+
}
|
|
88
|
+
if (environment.TERM === "xterm-ghostty") {
|
|
89
|
+
return SPACE_TRUE_COLORS;
|
|
90
|
+
}
|
|
91
|
+
if (environment.TERM === "wezterm") {
|
|
92
|
+
return SPACE_TRUE_COLORS;
|
|
93
|
+
}
|
|
94
|
+
if ("TERM_PROGRAM" in environment) {
|
|
95
|
+
const version = Number.parseInt((environment.TERM_PROGRAM_VERSION ?? "").split(".")[0], 10);
|
|
96
|
+
if (environment.TERM_PROGRAM === "iTerm.app") {
|
|
97
|
+
return version >= 3 ? SPACE_TRUE_COLORS : SPACE_256_COLORS;
|
|
98
|
+
}
|
|
99
|
+
if (environment.TERM_PROGRAM === "Apple_Terminal") {
|
|
100
|
+
return SPACE_256_COLORS;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (/-256(color)?$/i.test(environment.TERM)) {
|
|
104
|
+
return SPACE_256_COLORS;
|
|
105
|
+
}
|
|
106
|
+
let isTTY = false;
|
|
107
|
+
if (isDeno) {
|
|
108
|
+
if (stdName === "out") {
|
|
109
|
+
isTTY = _this.Deno.stdout.isTerminal();
|
|
110
|
+
} else if (stdName === "err") {
|
|
111
|
+
isTTY = _this.Deno.stderr.isTerminal();
|
|
112
|
+
}
|
|
113
|
+
} else if ("PM2_HOME" in environment && "pm_id" in environment) {
|
|
114
|
+
isTTY = true;
|
|
115
|
+
} else {
|
|
116
|
+
isTTY = proc[`std${stdName}`] && "isTTY" in proc[`std${stdName}`];
|
|
117
|
+
}
|
|
118
|
+
if (isTTY && /^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(environment.TERM)) {
|
|
119
|
+
return SPACE_16_COLORS;
|
|
120
|
+
}
|
|
121
|
+
if ("COLORTERM" in environment) {
|
|
122
|
+
return SPACE_16_COLORS;
|
|
123
|
+
}
|
|
124
|
+
return minColorLevel;
|
|
125
|
+
};
|
|
126
|
+
const isStdoutColorSupported = () => isColorSupportedFactory("out");
|
|
127
|
+
const isStderrColorSupported = () => isColorSupportedFactory("err");
|
|
128
|
+
|
|
129
|
+
export { SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const SPACE_MONO = 0;
|
|
6
|
+
const SPACE_16_COLORS = 1;
|
|
7
|
+
const SPACE_256_COLORS = 2;
|
|
8
|
+
const SPACE_TRUE_COLORS = 3;
|
|
9
|
+
|
|
10
|
+
exports.SPACE_16_COLORS = SPACE_16_COLORS;
|
|
11
|
+
exports.SPACE_256_COLORS = SPACE_256_COLORS;
|
|
12
|
+
exports.SPACE_MONO = SPACE_MONO;
|
|
13
|
+
exports.SPACE_TRUE_COLORS = SPACE_TRUE_COLORS;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const O=0,C=1,S=2,_=3;export{C as SPACE_16_COLORS,S as SPACE_256_COLORS,O as SPACE_MONO,_ as SPACE_TRUE_COLORS};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const O=0,S=1,_=2,C=3;exports.SPACE_16_COLORS=S;exports.SPACE_256_COLORS=_;exports.SPACE_MONO=O;exports.SPACE_TRUE_COLORS=C;
|