@visulima/is-ansi-color-supported 2.2.8 → 2.2.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 CHANGED
@@ -1,3 +1,32 @@
1
+ ## @visulima/is-ansi-color-supported [2.2.10](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.2.9...@visulima/is-ansi-color-supported@2.2.10) (2025-01-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ * updated @visulima/packem, and all other dev dependencies ([7797a1c](https://github.com/visulima/visulima/commit/7797a1c3e6f1fc532895247bd88285a8a9883c40))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * updated dev dependencies ([9de2eab](https://github.com/visulima/visulima/commit/9de2eab91e95c8b9289d12f863a5167218770650))
10
+
11
+ ## @visulima/is-ansi-color-supported [2.2.9](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.2.8...@visulima/is-ansi-color-supported@2.2.9) (2024-12-12)
12
+
13
+ ### Bug Fixes
14
+
15
+ * added missing placeholder variables into LICENSE.md file ([cef32c6](https://github.com/visulima/visulima/commit/cef32c6eb19dc3215a835e848ef12223a8fa05e0))
16
+ * allow node v23 ([8ca929a](https://github.com/visulima/visulima/commit/8ca929af311ce8036cbbfde68b6db05381b860a5))
17
+ * allowed node 23, updated dev dependencies ([f99d34e](https://github.com/visulima/visulima/commit/f99d34e01f6b13be8586a1b5d37dc8b8df0a5817))
18
+ * create a new edge-light export to remove the process check in browser export and updated packem to v1.9.2 ([c3b73c6](https://github.com/visulima/visulima/commit/c3b73c6ed25654e2b855f6bf23cf6508dc08d057))
19
+ * updated packem to v1.8.2 ([23f869b](https://github.com/visulima/visulima/commit/23f869b4120856cc97e2bffa6d508e2ae30420ea))
20
+
21
+ ### Styles
22
+
23
+ * cs fixes ([46d31e0](https://github.com/visulima/visulima/commit/46d31e082e1865262bf380859c14fabd28ff456d))
24
+ * **is-ansi-color-supported:** fixed order of exports ([2e89785](https://github.com/visulima/visulima/commit/2e89785846f812f50c239161aed9428df4320215))
25
+
26
+ ### Miscellaneous Chores
27
+
28
+ * updated dev dependencies ([a916944](https://github.com/visulima/visulima/commit/a916944b888bb34c34b0c54328b38d29e4399857))
29
+
1
30
  ## @visulima/is-ansi-color-supported [2.2.8](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.2.7...@visulima/is-ansi-color-supported@2.2.8) (2024-10-05)
2
31
 
3
32
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -19,3 +19,9 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
+
23
+ <!-- DEPENDENCIES -->
24
+ <!-- /DEPENDENCIES -->
25
+
26
+ <!-- TYPE_DEPENDENCIES -->
27
+ <!-- /TYPE_DEPENDENCIES -->
package/README.md CHANGED
@@ -60,10 +60,10 @@ console.log(isStderrColorSupported()); // 3
60
60
 
61
61
  Ansis automatically detects the supported color space:
62
62
 
63
- - TrueColor
64
- - ANSI 256 colors
65
- - ANSI 16 colors
66
- - black & white (no color)
63
+ - TrueColor
64
+ - ANSI 256 colors
65
+ - ANSI 16 colors
66
+ - black & white (no color)
67
67
 
68
68
  There is no standard way to detect which color space is supported.
69
69
  The most common way to detect color support is to check the `TERM` and `COLORTERM` environment variables.
@@ -93,8 +93,8 @@ Combine that with the knowledge about which operating system the program is runn
93
93
 
94
94
  See also:
95
95
 
96
- - [Truecolor Support in Output Devices](https://github.com/termstandard/colors#truecolor-support-in-output-devices).
97
- - [So you want to render colors in your terminal](https://marvinh.dev/blog/terminal-colors/).
96
+ - [Truecolor Support in Output Devices](https://github.com/termstandard/colors#truecolor-support-in-output-devices).
97
+ - [So you want to render colors in your terminal](https://marvinh.dev/blog/terminal-colors/).
98
98
 
99
99
  ## Environment variables
100
100
 
@@ -145,8 +145,8 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
145
145
 
146
146
  ## Related
147
147
 
148
- - [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
149
- - [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
148
+ - [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
149
+ - [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
150
150
 
151
151
  ## Supported Node.js Versions
152
152
 
@@ -161,8 +161,8 @@ If you would like to help take a look at the [list of issues](https://github.com
161
161
 
162
162
  ## Credits
163
163
 
164
- - [Daniel Bannert](https://github.com/prisis)
165
- - [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
164
+ - [Daniel Bannert](https://github.com/prisis)
165
+ - [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
166
166
 
167
167
  ## License
168
168
 
@@ -1 +1,23 @@
1
- var i=Object.defineProperty;var o=(r,e)=>i(r,"name",{value:e,configurable:!0});import{SPACE_TRUE_COLORS as a,SPACE_16_COLORS as t,SPACE_MONO as u}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";import{SPACE_256_COLORS as v}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";var s=Object.defineProperty,p=o((r,e)=>s(r,"name",{value:e,configurable:!0}),"e");const n=p(()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData&&navigator.userAgentData.brands.find(({b:r})=>r==="Chromium")?.version>93)return a;if(/\b(Chrome|Chromium)\//.test(navigator.userAgent))return t}return(process.env.NEXT_RUNTIME??"").includes("edge")?t:u})(),"isColorSupported"),d=n,f=n;export{t as SPACE_16_COLORS,v as SPACE_256_COLORS,u as SPACE_MONO,a as SPACE_TRUE_COLORS,f as isStderrColorSupported,d as isStdoutColorSupported};
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
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ const isColorSupported = /* @__PURE__ */ __name(() => (() => {
7
+ if (typeof navigator !== "undefined") {
8
+ if (navigator.userAgentData) {
9
+ const brand = navigator.userAgentData.brands.find(({ b }) => b === "Chromium");
10
+ if (brand?.version > 93) {
11
+ return SPACE_TRUE_COLORS;
12
+ }
13
+ }
14
+ if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
15
+ return SPACE_16_COLORS;
16
+ }
17
+ }
18
+ return SPACE_MONO;
19
+ })(), "isColorSupported");
20
+ const isStdoutColorSupported = isColorSupported;
21
+ const isStderrColorSupported = isColorSupported;
22
+
23
+ export { SPACE_16_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
@@ -0,0 +1,11 @@
1
+ type ColorSupportLevel = 0 | 1 | 2 | 3;
2
+
3
+ declare const SPACE_MONO = 0;
4
+ declare const SPACE_16_COLORS = 1;
5
+ declare const SPACE_256_COLORS = 2;
6
+ declare const SPACE_TRUE_COLORS = 3;
7
+
8
+ declare const isStdoutColorSupported: () => ColorSupportLevel;
9
+ declare const isStderrColorSupported: () => ColorSupportLevel;
10
+
11
+ export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
@@ -0,0 +1,11 @@
1
+ type ColorSupportLevel = 0 | 1 | 2 | 3;
2
+
3
+ declare const SPACE_MONO = 0;
4
+ declare const SPACE_16_COLORS = 1;
5
+ declare const SPACE_256_COLORS = 2;
6
+ declare const SPACE_TRUE_COLORS = 3;
7
+
8
+ declare const isStdoutColorSupported: () => ColorSupportLevel;
9
+ declare const isStderrColorSupported: () => ColorSupportLevel;
10
+
11
+ export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
@@ -0,0 +1,33 @@
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
+ var __defProp$1 = Object.defineProperty;
5
+ var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
6
+ const isColorSupported$1 = /* @__PURE__ */ __name$1(() => (() => {
7
+ if (typeof navigator !== "undefined") {
8
+ if (navigator.userAgentData) {
9
+ const brand = navigator.userAgentData.brands.find(({ b }) => b === "Chromium");
10
+ if (brand?.version > 93) {
11
+ return SPACE_TRUE_COLORS;
12
+ }
13
+ }
14
+ if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
15
+ return SPACE_16_COLORS;
16
+ }
17
+ }
18
+ return SPACE_MONO;
19
+ })(), "isColorSupported");
20
+ const isStdoutColorSupported$1 = isColorSupported$1;
21
+
22
+ var __defProp = Object.defineProperty;
23
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
24
+ const isColorSupported = /* @__PURE__ */ __name(() => (() => {
25
+ if (process?.env?.NEXT_RUNTIME !== undefined && process?.env.NEXT_RUNTIME.includes("edge")) {
26
+ return SPACE_16_COLORS;
27
+ }
28
+ return isStdoutColorSupported$1();
29
+ })(), "isColorSupported");
30
+ const isStdoutColorSupported = isColorSupported;
31
+ const isStderrColorSupported = isColorSupported;
32
+
33
+ export { SPACE_16_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
@@ -1 +1,137 @@
1
- "use strict";var a=Object.defineProperty;var P=(S,t)=>a(S,"name",{value:t,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./packem_shared/SPACE_MONO-D73nMay-.cjs");var p=Object.defineProperty,R=P((S,t)=>p(S,"name",{value:t,configurable:!0}),"f");const L=R(S=>{const t=globalThis,i=t.Deno!=null,C=t.process??t.Deno??{},A=C.argv??C.args??[],E=R(O=>{const T=A.indexOf("--"),c=A.findIndex(M=>O.test(M));return c!==-1&&(T===-1||c<T)},"oneOfFlags");let r={};try{r=i?C.env.toObject():C.env??{}}catch{}const l="FORCE_COLOR",d=l in r,_=r[l]?String(r[l]):void 0,u=Object.prototype.toString.call(_).slice(8,-1)==="String";let o;if(_==="true"?o=e.SPACE_16_COLORS:_==="false"?o=e.SPACE_MONO:u&&_.length===0?o=e.SPACE_16_COLORS:u&&_.length>0&&(o=Math.min(Number.parseInt(_,10),3)),_!=="true"&&_!=="false"&&o!==void 0&&o<4)return o;if("NO_COLOR"in r||d&&o===0||E(/^-{1,2}(no-color|no-colors|color=false|color=never)$/))return e.SPACE_MONO;if(E(/^-{1,2}(color=256)$/))return e.SPACE_256_COLORS;if(E(/^-{1,2}(color=16m|color=full|color=truecolor)$/))return e.SPACE_TRUE_COLORS;if(E(/^-{1,2}(color|colors|color=true|color=always)$/))return e.SPACE_16_COLORS;const s=o||e.SPACE_MONO;if("TF_BUILD"in r&&"AGENT_NAME"in r)return e.SPACE_16_COLORS;if(r.TERM&&/-mono|dumb/i.test(r.TERM))return s;if((i?t.Deno.build.os:C.platform)==="win32")try{const O=(i?t.Deno.osRelease():C.os.release()).split(".");return Number(O[0])>=10&&Number(O[2])>=10586?Number(O[2])>=14931?e.SPACE_TRUE_COLORS:e.SPACE_256_COLORS:e.SPACE_16_COLORS}catch{}if("CI"in r)return"GITHUB_ACTIONS"in r||"GITHUB_WORKFLOW"in r||"GITEA_ACTIONS"in r?e.SPACE_TRUE_COLORS:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE","GITLAB_CI"].some(O=>O in r)||r.CI_NAME==="codeship"?e.SPACE_16_COLORS:s;if(r.TERMINAL_EMULATOR?.includes("JediTerm"))return e.SPACE_TRUE_COLORS;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?e.SPACE_16_COLORS:e.SPACE_MONO;if(r.COLORTERM==="truecolor"||r.TERM==="xterm-kitty")return e.SPACE_TRUE_COLORS;if("TERM_PROGRAM"in r){const O=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return O>=3?e.SPACE_TRUE_COLORS:e.SPACE_256_COLORS;if(r.TERM_PROGRAM==="Apple_Terminal")return e.SPACE_256_COLORS}if(/-256(color)?$/i.test(r.TERM))return e.SPACE_256_COLORS;let n=!1;return i?S==="out"?n=t.Deno.stdout.isTerminal():S==="err"&&(n=t.Deno.stderr.isTerminal()):"PM2_HOME"in r&&"pm_id"in r?n=!0:n=C["std"+S]&&"isTTY"in C["std"+S],n&&/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?e.SPACE_16_COLORS:s},"isColorSupportedFactory"),f=R(()=>L("out"),"isStdoutColorSupported"),I=R(()=>L("err"),"isStderrColorSupported");exports.SPACE_16_COLORS=e.SPACE_16_COLORS;exports.SPACE_256_COLORS=e.SPACE_256_COLORS;exports.SPACE_MONO=e.SPACE_MONO;exports.SPACE_TRUE_COLORS=e.SPACE_TRUE_COLORS;exports.isStderrColorSupported=I;exports.isStdoutColorSupported=f;
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
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const isColorSupportedFactory = /* @__PURE__ */ __name((stdName) => {
10
+ const _this = globalThis;
11
+ const isDeno = _this.Deno != null;
12
+ const proc = _this.process ?? _this.Deno ?? {};
13
+ const argv = proc.argv ?? proc.args ?? [];
14
+ const oneOfFlags = /* @__PURE__ */ __name((regex) => {
15
+ const terminatorPosition = argv.indexOf("--");
16
+ const position = argv.findIndex((flag) => regex.test(flag));
17
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
18
+ }, "oneOfFlags");
19
+ let environment = {};
20
+ try {
21
+ environment = isDeno ? proc.env.toObject() : proc.env ?? {};
22
+ } catch {
23
+ }
24
+ const FORCE_COLOR = "FORCE_COLOR";
25
+ const hasForceColor = FORCE_COLOR in environment;
26
+ const forceColorValue = environment[FORCE_COLOR] ? String(environment[FORCE_COLOR]) : undefined;
27
+ const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === "String";
28
+ let forceColor;
29
+ if (forceColorValue === "true") {
30
+ forceColor = SPACE_MONO.SPACE_16_COLORS;
31
+ } else if (forceColorValue === "false") {
32
+ forceColor = SPACE_MONO.SPACE_MONO;
33
+ } else if (forceColorValueIsString && forceColorValue.length === 0) {
34
+ forceColor = SPACE_MONO.SPACE_16_COLORS;
35
+ } else if (forceColorValueIsString && forceColorValue.length > 0) {
36
+ forceColor = Math.min(Number.parseInt(forceColorValue, 10), 3);
37
+ }
38
+ if (forceColorValue !== "true" && forceColorValue !== "false" && forceColor !== undefined && forceColor < 4) {
39
+ return forceColor;
40
+ }
41
+ const isForceDisabled = (
42
+ // eslint-disable-next-line regexp/no-unused-capturing-group
43
+ "NO_COLOR" in environment || hasForceColor && forceColor === 0 || oneOfFlags(/^-{1,2}(no-color|no-colors|color=false|color=never)$/)
44
+ );
45
+ if (isForceDisabled) {
46
+ return SPACE_MONO.SPACE_MONO;
47
+ }
48
+ if (oneOfFlags(/^-{1,2}(color=256)$/)) {
49
+ return SPACE_MONO.SPACE_256_COLORS;
50
+ }
51
+ if (oneOfFlags(/^-{1,2}(color=16m|color=full|color=truecolor)$/)) {
52
+ return SPACE_MONO.SPACE_TRUE_COLORS;
53
+ }
54
+ const isForceEnabled = oneOfFlags(/^-{1,2}(color|colors|color=true|color=always)$/);
55
+ if (isForceEnabled) {
56
+ return SPACE_MONO.SPACE_16_COLORS;
57
+ }
58
+ const minColorLevel = forceColor || SPACE_MONO.SPACE_MONO;
59
+ if ("TF_BUILD" in environment && "AGENT_NAME" in environment) {
60
+ return SPACE_MONO.SPACE_16_COLORS;
61
+ }
62
+ const isDumbTerminal = environment.TERM && /-mono|dumb/i.test(environment.TERM);
63
+ if (isDumbTerminal) {
64
+ return minColorLevel;
65
+ }
66
+ if ((isDeno ? _this.Deno.build.os : proc.platform) === "win32") {
67
+ try {
68
+ const osRelease = (isDeno ? _this.Deno.osRelease() : proc.os.release()).split(".");
69
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
70
+ return Number(osRelease[2]) >= 14931 ? SPACE_MONO.SPACE_TRUE_COLORS : SPACE_MONO.SPACE_256_COLORS;
71
+ }
72
+ return SPACE_MONO.SPACE_16_COLORS;
73
+ } catch {
74
+ }
75
+ }
76
+ if ("CI" in environment) {
77
+ if ("GITHUB_ACTIONS" in environment || "GITHUB_WORKFLOW" in environment || "GITEA_ACTIONS" in environment) {
78
+ return SPACE_MONO.SPACE_TRUE_COLORS;
79
+ }
80
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE", "GITLAB_CI"].some((sign) => sign in environment) || environment.CI_NAME === "codeship") {
81
+ return SPACE_MONO.SPACE_16_COLORS;
82
+ }
83
+ return minColorLevel;
84
+ }
85
+ if (environment.TERMINAL_EMULATOR?.includes("JediTerm")) {
86
+ return SPACE_MONO.SPACE_TRUE_COLORS;
87
+ }
88
+ if ("TEAMCITY_VERSION" in environment) {
89
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(environment.TEAMCITY_VERSION) ? SPACE_MONO.SPACE_16_COLORS : SPACE_MONO.SPACE_MONO;
90
+ }
91
+ if (environment.COLORTERM === "truecolor") {
92
+ return SPACE_MONO.SPACE_TRUE_COLORS;
93
+ }
94
+ if (environment.TERM === "xterm-kitty") {
95
+ return SPACE_MONO.SPACE_TRUE_COLORS;
96
+ }
97
+ if ("TERM_PROGRAM" in environment) {
98
+ const version = Number.parseInt((environment.TERM_PROGRAM_VERSION ?? "").split(".")[0], 10);
99
+ if (environment.TERM_PROGRAM === "iTerm.app") {
100
+ return version >= 3 ? SPACE_MONO.SPACE_TRUE_COLORS : SPACE_MONO.SPACE_256_COLORS;
101
+ }
102
+ if (environment.TERM_PROGRAM === "Apple_Terminal") {
103
+ return SPACE_MONO.SPACE_256_COLORS;
104
+ }
105
+ }
106
+ if (/-256(color)?$/i.test(environment.TERM)) {
107
+ return SPACE_MONO.SPACE_256_COLORS;
108
+ }
109
+ let isTTY = false;
110
+ if (isDeno) {
111
+ if (stdName === "out") {
112
+ isTTY = _this.Deno.stdout.isTerminal();
113
+ } else if (stdName === "err") {
114
+ isTTY = _this.Deno.stderr.isTerminal();
115
+ }
116
+ } else if ("PM2_HOME" in environment && "pm_id" in environment) {
117
+ isTTY = true;
118
+ } else {
119
+ isTTY = proc["std" + stdName] && "isTTY" in proc["std" + stdName];
120
+ }
121
+ if (isTTY && /^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(environment.TERM)) {
122
+ return SPACE_MONO.SPACE_16_COLORS;
123
+ }
124
+ if ("COLORTERM" in environment) {
125
+ return SPACE_MONO.SPACE_16_COLORS;
126
+ }
127
+ return minColorLevel;
128
+ }, "isColorSupportedFactory");
129
+ const isStdoutColorSupported = /* @__PURE__ */ __name(() => isColorSupportedFactory("out"), "isStdoutColorSupported");
130
+ const isStderrColorSupported = /* @__PURE__ */ __name(() => isColorSupportedFactory("err"), "isStderrColorSupported");
131
+
132
+ exports.SPACE_16_COLORS = SPACE_MONO.SPACE_16_COLORS;
133
+ exports.SPACE_256_COLORS = SPACE_MONO.SPACE_256_COLORS;
134
+ exports.SPACE_MONO = SPACE_MONO.SPACE_MONO;
135
+ exports.SPACE_TRUE_COLORS = SPACE_MONO.SPACE_TRUE_COLORS;
136
+ exports.isStderrColorSupported = isStderrColorSupported;
137
+ exports.isStdoutColorSupported = isStdoutColorSupported;
@@ -1 +1,128 @@
1
- var N=Object.defineProperty;var S=(i,e)=>N(i,"name",{value:e,configurable:!0});import{SPACE_16_COLORS as n,SPACE_MONO as E,SPACE_256_COLORS as R,SPACE_TRUE_COLORS as u}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";var L=Object.defineProperty,d=S((i,e)=>L(i,"name",{value:e,configurable:!0}),"f");const m=d(i=>{const e=globalThis,O=e.Deno!=null,l=e.process??e.Deno??{},C=l.argv??l.args??[],T=d(o=>{const p=C.indexOf("--"),I=C.findIndex(A=>o.test(A));return I!==-1&&(p===-1||I<p)},"oneOfFlags");let r={};try{r=O?l.env.toObject():l.env??{}}catch{}const a="FORCE_COLOR",M=a in r,s=r[a]?String(r[a]):void 0,_=Object.prototype.toString.call(s).slice(8,-1)==="String";let t;if(s==="true"?t=n:s==="false"?t=E:_&&s.length===0?t=n:_&&s.length>0&&(t=Math.min(Number.parseInt(s,10),3)),s!=="true"&&s!=="false"&&t!==void 0&&t<4)return t;if("NO_COLOR"in r||M&&t===0||T(/^-{1,2}(no-color|no-colors|color=false|color=never)$/))return E;if(T(/^-{1,2}(color=256)$/))return R;if(T(/^-{1,2}(color=16m|color=full|color=truecolor)$/))return u;if(T(/^-{1,2}(color|colors|color=true|color=always)$/))return n;const f=t||E;if("TF_BUILD"in r&&"AGENT_NAME"in r)return n;if(r.TERM&&/-mono|dumb/i.test(r.TERM))return f;if((O?e.Deno.build.os:l.platform)==="win32")try{const o=(O?e.Deno.osRelease():l.os.release()).split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?u:R:n}catch{}if("CI"in r)return"GITHUB_ACTIONS"in r||"GITHUB_WORKFLOW"in r||"GITEA_ACTIONS"in r?u:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE","GITLAB_CI"].some(o=>o in r)||r.CI_NAME==="codeship"?n:f;if(r.TERMINAL_EMULATOR?.includes("JediTerm"))return u;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?n:E;if(r.COLORTERM==="truecolor")return u;if(r.TERM==="xterm-kitty")return u;if("TERM_PROGRAM"in r){const o=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return o>=3?u:R;if(r.TERM_PROGRAM==="Apple_Terminal")return R}if(/-256(color)?$/i.test(r.TERM))return R;let c=!1;return O?i==="out"?c=e.Deno.stdout.isTerminal():i==="err"&&(c=e.Deno.stderr.isTerminal()):"PM2_HOME"in r&&"pm_id"in r?c=!0:c=l["std"+i]&&"isTTY"in l["std"+i],c&&/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(r.TERM)?n:"COLORTERM"in r?n:f},"isColorSupportedFactory"),g=d(()=>m("out"),"isStdoutColorSupported"),v=d(()=>m("err"),"isStderrColorSupported");export{n as SPACE_16_COLORS,R as SPACE_256_COLORS,E as SPACE_MONO,u as SPACE_TRUE_COLORS,v as isStderrColorSupported,g as isStdoutColorSupported};
1
+ import { SPACE_MONO, SPACE_256_COLORS, SPACE_TRUE_COLORS, SPACE_16_COLORS } from './packem_shared/SPACE_MONO-VdlYcTli.mjs';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const isColorSupportedFactory = /* @__PURE__ */ __name((stdName) => {
6
+ const _this = globalThis;
7
+ const isDeno = _this.Deno != null;
8
+ const proc = _this.process ?? _this.Deno ?? {};
9
+ const argv = proc.argv ?? proc.args ?? [];
10
+ const oneOfFlags = /* @__PURE__ */ __name((regex) => {
11
+ const terminatorPosition = argv.indexOf("--");
12
+ const position = argv.findIndex((flag) => regex.test(flag));
13
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
14
+ }, "oneOfFlags");
15
+ let environment = {};
16
+ try {
17
+ environment = isDeno ? proc.env.toObject() : proc.env ?? {};
18
+ } catch {
19
+ }
20
+ const FORCE_COLOR = "FORCE_COLOR";
21
+ const hasForceColor = FORCE_COLOR in environment;
22
+ const forceColorValue = environment[FORCE_COLOR] ? String(environment[FORCE_COLOR]) : undefined;
23
+ const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === "String";
24
+ let forceColor;
25
+ if (forceColorValue === "true") {
26
+ forceColor = SPACE_16_COLORS;
27
+ } else if (forceColorValue === "false") {
28
+ forceColor = SPACE_MONO;
29
+ } else if (forceColorValueIsString && forceColorValue.length === 0) {
30
+ forceColor = SPACE_16_COLORS;
31
+ } else if (forceColorValueIsString && forceColorValue.length > 0) {
32
+ forceColor = Math.min(Number.parseInt(forceColorValue, 10), 3);
33
+ }
34
+ if (forceColorValue !== "true" && forceColorValue !== "false" && forceColor !== undefined && forceColor < 4) {
35
+ return forceColor;
36
+ }
37
+ const isForceDisabled = (
38
+ // eslint-disable-next-line regexp/no-unused-capturing-group
39
+ "NO_COLOR" in environment || hasForceColor && forceColor === 0 || oneOfFlags(/^-{1,2}(no-color|no-colors|color=false|color=never)$/)
40
+ );
41
+ if (isForceDisabled) {
42
+ return SPACE_MONO;
43
+ }
44
+ if (oneOfFlags(/^-{1,2}(color=256)$/)) {
45
+ return SPACE_256_COLORS;
46
+ }
47
+ if (oneOfFlags(/^-{1,2}(color=16m|color=full|color=truecolor)$/)) {
48
+ return SPACE_TRUE_COLORS;
49
+ }
50
+ const isForceEnabled = oneOfFlags(/^-{1,2}(color|colors|color=true|color=always)$/);
51
+ if (isForceEnabled) {
52
+ return SPACE_16_COLORS;
53
+ }
54
+ const minColorLevel = forceColor || SPACE_MONO;
55
+ if ("TF_BUILD" in environment && "AGENT_NAME" in environment) {
56
+ return SPACE_16_COLORS;
57
+ }
58
+ const isDumbTerminal = environment.TERM && /-mono|dumb/i.test(environment.TERM);
59
+ if (isDumbTerminal) {
60
+ return minColorLevel;
61
+ }
62
+ if ((isDeno ? _this.Deno.build.os : proc.platform) === "win32") {
63
+ try {
64
+ const osRelease = (isDeno ? _this.Deno.osRelease() : proc.os.release()).split(".");
65
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
66
+ return Number(osRelease[2]) >= 14931 ? SPACE_TRUE_COLORS : SPACE_256_COLORS;
67
+ }
68
+ return SPACE_16_COLORS;
69
+ } catch {
70
+ }
71
+ }
72
+ if ("CI" in environment) {
73
+ if ("GITHUB_ACTIONS" in environment || "GITHUB_WORKFLOW" in environment || "GITEA_ACTIONS" in environment) {
74
+ return SPACE_TRUE_COLORS;
75
+ }
76
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE", "GITLAB_CI"].some((sign) => sign in environment) || environment.CI_NAME === "codeship") {
77
+ return SPACE_16_COLORS;
78
+ }
79
+ return minColorLevel;
80
+ }
81
+ if (environment.TERMINAL_EMULATOR?.includes("JediTerm")) {
82
+ return SPACE_TRUE_COLORS;
83
+ }
84
+ if ("TEAMCITY_VERSION" in environment) {
85
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(environment.TEAMCITY_VERSION) ? SPACE_16_COLORS : SPACE_MONO;
86
+ }
87
+ if (environment.COLORTERM === "truecolor") {
88
+ return SPACE_TRUE_COLORS;
89
+ }
90
+ if (environment.TERM === "xterm-kitty") {
91
+ return SPACE_TRUE_COLORS;
92
+ }
93
+ if ("TERM_PROGRAM" in environment) {
94
+ const version = Number.parseInt((environment.TERM_PROGRAM_VERSION ?? "").split(".")[0], 10);
95
+ if (environment.TERM_PROGRAM === "iTerm.app") {
96
+ return version >= 3 ? SPACE_TRUE_COLORS : SPACE_256_COLORS;
97
+ }
98
+ if (environment.TERM_PROGRAM === "Apple_Terminal") {
99
+ return SPACE_256_COLORS;
100
+ }
101
+ }
102
+ if (/-256(color)?$/i.test(environment.TERM)) {
103
+ return SPACE_256_COLORS;
104
+ }
105
+ let isTTY = false;
106
+ if (isDeno) {
107
+ if (stdName === "out") {
108
+ isTTY = _this.Deno.stdout.isTerminal();
109
+ } else if (stdName === "err") {
110
+ isTTY = _this.Deno.stderr.isTerminal();
111
+ }
112
+ } else if ("PM2_HOME" in environment && "pm_id" in environment) {
113
+ isTTY = true;
114
+ } else {
115
+ isTTY = proc["std" + stdName] && "isTTY" in proc["std" + stdName];
116
+ }
117
+ if (isTTY && /^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(environment.TERM)) {
118
+ return SPACE_16_COLORS;
119
+ }
120
+ if ("COLORTERM" in environment) {
121
+ return SPACE_16_COLORS;
122
+ }
123
+ return minColorLevel;
124
+ }, "isColorSupportedFactory");
125
+ const isStdoutColorSupported = /* @__PURE__ */ __name(() => isColorSupportedFactory("out"), "isStdoutColorSupported");
126
+ const isStderrColorSupported = /* @__PURE__ */ __name(() => isColorSupportedFactory("err"), "isStderrColorSupported");
127
+
128
+ 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;
@@ -0,0 +1,6 @@
1
+ const SPACE_MONO = 0;
2
+ const SPACE_16_COLORS = 1;
3
+ const SPACE_256_COLORS = 2;
4
+ const SPACE_TRUE_COLORS = 3;
5
+
6
+ export { SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/is-ansi-color-supported",
3
- "version": "2.2.8",
3
+ "version": "2.2.10",
4
4
  "description": "Detect whether a terminal or browser supports ansi colors.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -60,7 +60,14 @@
60
60
  "type": "module",
61
61
  "exports": {
62
62
  ".": {
63
- "browser": "./dist/is-color-supported.browser.mjs",
63
+ "edge-light": {
64
+ "types": "./dist/is-color-supported.edge-light.d.mts",
65
+ "default": "./dist/is-color-supported.edge-light.mjs"
66
+ },
67
+ "browser": {
68
+ "types": "./dist/is-color-supported.browser.d.mts",
69
+ "default": "./dist/is-color-supported.browser.mjs"
70
+ },
64
71
  "require": {
65
72
  "types": "./dist/is-color-supported.server.d.cts",
66
73
  "default": "./dist/is-color-supported.server.cjs"
@@ -92,19 +99,19 @@
92
99
  "devDependencies": {
93
100
  "@anolilab/eslint-config": "^15.0.3",
94
101
  "@anolilab/prettier-config": "^5.0.14",
95
- "@anolilab/semantic-release-pnpm": "^1.1.3",
96
- "@anolilab/semantic-release-preset": "^9.0.0",
97
- "@arethetypeswrong/cli": "^0.16.4",
98
- "@babel/core": "^7.25.7",
102
+ "@anolilab/semantic-release-pnpm": "^1.1.6",
103
+ "@anolilab/semantic-release-preset": "^9.0.3",
104
+ "@arethetypeswrong/cli": "^0.17.2",
105
+ "@babel/core": "^7.26.0",
99
106
  "@rushstack/eslint-plugin-security": "^0.8.3",
100
- "@secretlint/secretlint-rule-preset-recommend": "^8.3.0",
107
+ "@secretlint/secretlint-rule-preset-recommend": "^9.0.0",
101
108
  "@types/node": "18.19.15",
102
- "@visulima/packem": "1.0.7",
103
- "@vitest/coverage-v8": "^2.1.2",
104
- "@vitest/ui": "^2.1.2",
109
+ "@visulima/packem": "1.10.7",
110
+ "@vitest/coverage-v8": "^2.1.8",
111
+ "@vitest/ui": "^2.1.8",
105
112
  "conventional-changelog-conventionalcommits": "8.0.0",
106
113
  "cross-env": "^7.0.3",
107
- "esbuild": "0.24.0",
114
+ "esbuild": "0.24.2",
108
115
  "eslint": "8.57.0",
109
116
  "eslint-plugin-deprecation": "^3.0.0",
110
117
  "eslint-plugin-etc": "^2.0.3",
@@ -112,15 +119,15 @@
112
119
  "eslint-plugin-mdx": "^3.1.5",
113
120
  "eslint-plugin-vitest": "^0.4.1",
114
121
  "eslint-plugin-vitest-globals": "^1.5.0",
115
- "prettier": "^3.3.3",
116
- "rimraf": "5.0.9",
117
- "secretlint": "8.2.4",
118
- "semantic-release": "24.0.0",
119
- "typescript": "5.4.5",
120
- "vitest": "^2.1.2"
122
+ "prettier": "^3.4.2",
123
+ "rimraf": "6.0.1",
124
+ "secretlint": "9.0.0",
125
+ "semantic-release": "24.2.1",
126
+ "typescript": "5.7.3",
127
+ "vitest": "^2.1.8"
121
128
  },
122
129
  "engines": {
123
- "node": ">=18.* <=22.*"
130
+ "node": ">=18.* <=23.*"
124
131
  },
125
132
  "os": [
126
133
  "darwin",
@@ -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.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=0,S=1,C=2,_=3;exports.SPACE_16_COLORS=S;exports.SPACE_256_COLORS=C;exports.SPACE_MONO=O;exports.SPACE_TRUE_COLORS=_;