@visulima/is-ansi-color-supported 2.2.9 → 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,13 @@
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
+
1
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)
2
12
 
3
13
  ### Bug Fixes
@@ -1 +1,23 @@
1
- var a=Object.defineProperty;var o=(r,t)=>a(r,"name",{value:t,configurable:!0});import{SPACE_TRUE_COLORS as n,SPACE_16_COLORS as i,SPACE_MONO as u}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";import{SPACE_256_COLORS as g}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";var C=Object.defineProperty,p=o((r,t)=>C(r,"name",{value:t,configurable:!0}),"t");const e=p(()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData&&navigator.userAgentData.brands.find(({b:r})=>r==="Chromium")?.version>93)return n;if(/\b(Chrome|Chromium)\//.test(navigator.userAgent))return i}return u})(),"isColorSupported"),f=e,m=e;export{i as SPACE_16_COLORS,g as SPACE_256_COLORS,u as SPACE_MONO,n as SPACE_TRUE_COLORS,m as isStderrColorSupported,f 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 };
@@ -1 +1,33 @@
1
- var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{SPACE_TRUE_COLORS as i,SPACE_16_COLORS as t,SPACE_MONO as u}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";import{SPACE_256_COLORS as E}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";var s=Object.defineProperty,p=o((r,e)=>s(r,"name",{value:e,configurable:!0}),"t$1");const d=p(()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData&&navigator.userAgentData.brands.find(({b:r})=>r==="Chromium")?.version>93)return i;if(/\b(Chrome|Chromium)\//.test(navigator.userAgent))return t}return u})(),"isColorSupported"),C=d;var S=Object.defineProperty,v=o((r,e)=>S(r,"name",{value:e,configurable:!0}),"o");const n=v(()=>process?.env?.NEXT_RUNTIME!==void 0&&process?.env.NEXT_RUNTIME.includes("edge")?t:C(),"isColorSupported"),g=n,l=n;export{t as SPACE_16_COLORS,E as SPACE_256_COLORS,u as SPACE_MONO,i as SPACE_TRUE_COLORS,l as isStderrColorSupported,g 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$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_MONO as E,SPACE_256_COLORS as R,SPACE_TRUE_COLORS as u,SPACE_16_COLORS as n}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.9",
3
+ "version": "2.2.10",
4
4
  "description": "Detect whether a terminal or browser supports ansi colors.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -99,19 +99,19 @@
99
99
  "devDependencies": {
100
100
  "@anolilab/eslint-config": "^15.0.3",
101
101
  "@anolilab/prettier-config": "^5.0.14",
102
- "@anolilab/semantic-release-pnpm": "^1.1.5",
103
- "@anolilab/semantic-release-preset": "^9.0.2",
104
- "@arethetypeswrong/cli": "^0.17.1",
102
+ "@anolilab/semantic-release-pnpm": "^1.1.6",
103
+ "@anolilab/semantic-release-preset": "^9.0.3",
104
+ "@arethetypeswrong/cli": "^0.17.2",
105
105
  "@babel/core": "^7.26.0",
106
106
  "@rushstack/eslint-plugin-security": "^0.8.3",
107
107
  "@secretlint/secretlint-rule-preset-recommend": "^9.0.0",
108
108
  "@types/node": "18.19.15",
109
- "@visulima/packem": "1.9.2",
109
+ "@visulima/packem": "1.10.7",
110
110
  "@vitest/coverage-v8": "^2.1.8",
111
111
  "@vitest/ui": "^2.1.8",
112
112
  "conventional-changelog-conventionalcommits": "8.0.0",
113
113
  "cross-env": "^7.0.3",
114
- "esbuild": "0.24.0",
114
+ "esbuild": "0.24.2",
115
115
  "eslint": "8.57.0",
116
116
  "eslint-plugin-deprecation": "^3.0.0",
117
117
  "eslint-plugin-etc": "^2.0.3",
@@ -120,10 +120,10 @@
120
120
  "eslint-plugin-vitest": "^0.4.1",
121
121
  "eslint-plugin-vitest-globals": "^1.5.0",
122
122
  "prettier": "^3.4.2",
123
- "rimraf": "5.0.9",
124
- "secretlint": "8.2.4",
125
- "semantic-release": "24.0.0",
126
- "typescript": "5.4.5",
123
+ "rimraf": "6.0.1",
124
+ "secretlint": "9.0.0",
125
+ "semantic-release": "24.2.1",
126
+ "typescript": "5.7.3",
127
127
  "vitest": "^2.1.8"
128
128
  },
129
129
  "engines": {
@@ -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=_;