@visulima/is-ansi-color-supported 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/chunk-ARYGRP3O.js +5 -0
- package/dist/chunk-ARYGRP3O.js.map +1 -0
- package/dist/chunk-VGFXSNOZ.cjs +10 -0
- package/dist/chunk-VGFXSNOZ.cjs.map +1 -0
- package/dist/color-spaces-LVm3eRLc.d.cts +8 -0
- package/dist/color-spaces-LVm3eRLc.d.ts +8 -0
- package/dist/is-color-supported.browser.cjs +21 -3
- package/dist/is-color-supported.browser.cjs.map +1 -1
- package/dist/is-color-supported.browser.d.cts +2 -1
- package/dist/is-color-supported.browser.d.ts +2 -1
- package/dist/is-color-supported.browser.js +4 -2
- package/dist/is-color-supported.browser.js.map +1 -1
- package/dist/is-color-supported.server.cjs +21 -3
- package/dist/is-color-supported.server.cjs.map +1 -1
- package/dist/is-color-supported.server.d.cts +2 -1
- package/dist/is-color-supported.server.d.ts +2 -1
- package/dist/is-color-supported.server.js +4 -2
- package/dist/is-color-supported.server.js.map +1 -1
- package/package.json +17 -12
- package/dist/types-tBMJqxWx.d.cts +0 -3
- package/dist/types-tBMJqxWx.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## @visulima/is-ansi-color-supported [2.1.0](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.0.2...@visulima/is-ansi-color-supported@2.1.0) (2024-04-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **is-ansi-color-supported:** added new const exports, added check f… ([#390](https://github.com/visulima/visulima/issues/390)) ([167f5b3](https://github.com/visulima/visulima/commit/167f5b3936a9fadcb30c748bf0533c89fed8c6ab))
|
|
7
|
+
|
|
8
|
+
## @visulima/is-ansi-color-supported [2.0.2](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.0.1...@visulima/is-ansi-color-supported@2.0.2) (2024-03-27)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* added missing os key to package.json ([4ad1268](https://github.com/visulima/visulima/commit/4ad1268ed12cbdcf60aeb46d4c052ed1696bc150))
|
|
14
|
+
|
|
1
15
|
## @visulima/is-ansi-color-supported [2.0.1](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@2.0.0...@visulima/is-ansi-color-supported@2.0.1) (2024-03-04)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/color-spaces.ts"],"names":["SPACE_MONO","SPACE_16_COLORS","SPACE_256_COLORS","SPACE_TRUE_COLORS"],"mappings":"AAAO,IAAMA,EAAa,EACbC,EAAkB,EAClBC,EAAmB,EACnBC,EAAoB","sourcesContent":["export const SPACE_MONO = 0;\nexport const SPACE_16_COLORS = 1;\nexport const SPACE_256_COLORS = 2;\nexport const SPACE_TRUE_COLORS = 3;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/color-spaces.ts"],"names":["SPACE_MONO","SPACE_16_COLORS","SPACE_256_COLORS","SPACE_TRUE_COLORS"],"mappings":"AAAO,IAAMA,EAAa,EACbC,EAAkB,EAClBC,EAAmB,EACnBC,EAAoB","sourcesContent":["export const SPACE_MONO = 0;\nexport const SPACE_16_COLORS = 1;\nexport const SPACE_256_COLORS = 2;\nexport const SPACE_TRUE_COLORS = 3;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export { type ColorSupportLevel as C, SPACE_16_COLORS as S, SPACE_256_COLORS as a, SPACE_MONO as b, SPACE_TRUE_COLORS as c };
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export { type ColorSupportLevel as C, SPACE_16_COLORS as S, SPACE_256_COLORS as a, SPACE_MONO as b, SPACE_TRUE_COLORS as c };
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVGFXSNOZ_cjs = require('./chunk-VGFXSNOZ.cjs');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var t=()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData&&navigator.userAgentData.brands.find(({b:p})=>p==="Chromium")?.version>93)return 3;if(/\b(Chrome|Chromium)\//.test(navigator.userAgent))return 1}return typeof process<"u"?(process.env.NEXT_RUNTIME??"").includes("edge")?1:0:0})(),S=t,C=t;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, 'SPACE_16_COLORS', {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkVGFXSNOZ_cjs.b; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, 'SPACE_256_COLORS', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkVGFXSNOZ_cjs.c; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, 'SPACE_MONO', {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkVGFXSNOZ_cjs.a; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, 'SPACE_TRUE_COLORS', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkVGFXSNOZ_cjs.d; }
|
|
22
|
+
});
|
|
23
|
+
exports.isStderrColorSupported = C;
|
|
24
|
+
exports.isStdoutColorSupported = S;
|
|
7
25
|
//# sourceMappingURL=out.js.map
|
|
8
26
|
//# sourceMappingURL=is-color-supported.browser.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-color-supported.browser.ts"],"names":["isColorSupported","b","isStdoutColorSupported","isStderrColorSupported"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/is-color-supported.browser.ts"],"names":["isColorSupported","b","isStdoutColorSupported","isStderrColorSupported"],"mappings":"8DAOA,IAAMA,EAAmB,KACpB,IAAM,CACH,GAAI,OAAO,UAAc,IAAa,CAElC,GAAI,UAAU,eAGI,UAAU,cAAc,OAAO,KAAK,CAAC,CAAE,EAAAC,CAAE,IAAqBA,IAAM,UAAU,GAGjF,QAAU,GACjB,MAAO,GAKf,GAAI,wBAAwB,KAAK,UAAU,SAAS,EAChD,MAAO,EAEf,CAIA,OAAI,OAAO,QAAY,KACD,QAAQ,IAAI,cAAgB,IAAI,SAAS,MAAM,EAE/C,EAAkB,EAGjC,CACX,GAAG,EAEMC,EAAyBF,EAEzBG,EAAyBH","sourcesContent":["// Some of this code is taken from https://github.com/chalk/supports-color/blob/main/index.js\n// MIT License\n// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nimport { SPACE_16_COLORS, SPACE_MONO,SPACE_TRUE_COLORS } from \"./color-spaces\";\nimport type { ColorSupportLevel } from \"./types\";\n\nconst isColorSupported = (): ColorSupportLevel =>\n (() => {\n if (typeof navigator !== \"undefined\") {\n // @ts-expect-error - `navigator` is not defined in Node.\n if (navigator.userAgentData) {\n // @ts-expect-error - `navigator` is not defined in Node.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n const brand = navigator.userAgentData.brands.find(({ b }: { b: string }) => b === \"Chromium\");\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (brand?.version > 93) {\n return SPACE_TRUE_COLORS;\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (/\\b(Chrome|Chromium)\\//.test(navigator.userAgent)) {\n return SPACE_16_COLORS;\n }\n }\n\n // when Next.JS runtime is `edge`, process.stdout is undefined, but colors output is supported\n // runtime values supported colors: `nodejs`, `edge`, `experimental-edge`\n if (typeof process !== \"undefined\") {\n const isNextJS = (process.env.NEXT_RUNTIME ?? \"\").includes(\"edge\");\n\n return isNextJS ? SPACE_16_COLORS : SPACE_MONO;\n }\n\n return SPACE_MONO;\n })();\n\nexport const isStdoutColorSupported = isColorSupported;\n\nexport const isStderrColorSupported = isColorSupported;\n// eslint-disable-next-line import/no-unused-modules\nexport { SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO,SPACE_TRUE_COLORS } from \"./color-spaces\";\n// eslint-disable-next-line import/no-unused-modules\nexport type { ColorSupportLevel } from \"./types\";\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as ColorSupportLevel } from './
|
|
1
|
+
import { C as ColorSupportLevel } from './color-spaces-LVm3eRLc.cjs';
|
|
2
|
+
export { S as SPACE_16_COLORS, a as SPACE_256_COLORS, b as SPACE_MONO, c as SPACE_TRUE_COLORS } from './color-spaces-LVm3eRLc.cjs';
|
|
2
3
|
|
|
3
4
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
4
5
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as ColorSupportLevel } from './
|
|
1
|
+
import { C as ColorSupportLevel } from './color-spaces-LVm3eRLc.js';
|
|
2
|
+
export { S as SPACE_16_COLORS, a as SPACE_256_COLORS, b as SPACE_MONO, c as SPACE_TRUE_COLORS } from './color-spaces-LVm3eRLc.js';
|
|
2
3
|
|
|
3
4
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
4
5
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export { b as SPACE_16_COLORS, c as SPACE_256_COLORS, a as SPACE_MONO, d as SPACE_TRUE_COLORS } from './chunk-ARYGRP3O.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var t=()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData&&navigator.userAgentData.brands.find(({b:p})=>p==="Chromium")?.version>93)return 3;if(/\b(Chrome|Chromium)\//.test(navigator.userAgent))return 1}return typeof process<"u"?(process.env.NEXT_RUNTIME??"").includes("edge")?1:0:0})(),C=t,u=t;
|
|
4
|
+
|
|
5
|
+
export { u as isStderrColorSupported, C as isStdoutColorSupported };
|
|
4
6
|
//# sourceMappingURL=out.js.map
|
|
5
7
|
//# sourceMappingURL=is-color-supported.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-color-supported.browser.ts"],"names":["isColorSupported","b","isStdoutColorSupported","isStderrColorSupported"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/is-color-supported.browser.ts"],"names":["isColorSupported","b","isStdoutColorSupported","isStderrColorSupported"],"mappings":"6DAOA,IAAMA,EAAmB,KACpB,IAAM,CACH,GAAI,OAAO,UAAc,IAAa,CAElC,GAAI,UAAU,eAGI,UAAU,cAAc,OAAO,KAAK,CAAC,CAAE,EAAAC,CAAE,IAAqBA,IAAM,UAAU,GAGjF,QAAU,GACjB,MAAO,GAKf,GAAI,wBAAwB,KAAK,UAAU,SAAS,EAChD,MAAO,EAEf,CAIA,OAAI,OAAO,QAAY,KACD,QAAQ,IAAI,cAAgB,IAAI,SAAS,MAAM,EAE/C,EAAkB,EAGjC,CACX,GAAG,EAEMC,EAAyBF,EAEzBG,EAAyBH","sourcesContent":["// Some of this code is taken from https://github.com/chalk/supports-color/blob/main/index.js\n// MIT License\n// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nimport { SPACE_16_COLORS, SPACE_MONO,SPACE_TRUE_COLORS } from \"./color-spaces\";\nimport type { ColorSupportLevel } from \"./types\";\n\nconst isColorSupported = (): ColorSupportLevel =>\n (() => {\n if (typeof navigator !== \"undefined\") {\n // @ts-expect-error - `navigator` is not defined in Node.\n if (navigator.userAgentData) {\n // @ts-expect-error - `navigator` is not defined in Node.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n const brand = navigator.userAgentData.brands.find(({ b }: { b: string }) => b === \"Chromium\");\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (brand?.version > 93) {\n return SPACE_TRUE_COLORS;\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (/\\b(Chrome|Chromium)\\//.test(navigator.userAgent)) {\n return SPACE_16_COLORS;\n }\n }\n\n // when Next.JS runtime is `edge`, process.stdout is undefined, but colors output is supported\n // runtime values supported colors: `nodejs`, `edge`, `experimental-edge`\n if (typeof process !== \"undefined\") {\n const isNextJS = (process.env.NEXT_RUNTIME ?? \"\").includes(\"edge\");\n\n return isNextJS ? SPACE_16_COLORS : SPACE_MONO;\n }\n\n return SPACE_MONO;\n })();\n\nexport const isStdoutColorSupported = isColorSupported;\n\nexport const isStderrColorSupported = isColorSupported;\n// eslint-disable-next-line import/no-unused-modules\nexport { SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO,SPACE_TRUE_COLORS } from \"./color-spaces\";\n// eslint-disable-next-line import/no-unused-modules\nexport type { ColorSupportLevel } from \"./types\";\n"]}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVGFXSNOZ_cjs = require('./chunk-VGFXSNOZ.cjs');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var m=R=>{let i=globalThis,a=i.Deno!=null,t=i.process??i.Deno??{},T=t.argv??t.args??[],C=o=>{let _=T.indexOf("--"),S=T.findIndex(A=>o.test(A));return S!==-1&&(_===-1||S<_)},r={};try{r=a?t.env.toObject():t.env??{};}catch{}let p="FORCE_COLOR",d=p in r,s=r[p]?String(r[p]):void 0,E=Object.prototype.toString.call(s).slice(8,-1)==="String",l=0;if(s==="true"?l=1:s==="false"?l=0:E&&s.length===0?l=1:E&&s.length>0&&(l=Math.min(Number.parseInt(s,10),3)),"NO_COLOR"in r||d&&l===0||C(/^-{1,2}(no-color|no-colors|color=false|color=never)$/))return 0;if(C(/^-{1,2}(color=256)$/))return 2;if(C(/^-{1,2}(color=16m|color=full|color=truecolor)$/))return 3;if(C(/^-{1,2}(color|colors|color=true|color=always)$/))return 1;let f=l||0;if("TF_BUILD"in r&&"AGENT_NAME"in r)return 1;if(r.TERM&&/-mono|dumb/i.test(r.TERM))return f;if((a?i.Deno.build.os:t.platform)==="win32")try{let o=(a?i.Deno.osRelease():t.os.release()).split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}catch{}if("CI"in r)return "GITHUB_ACTIONS"in r||"GITHUB_WORKFLOW"in r||"GITEA_ACTIONS"in r?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE","GITLAB_CI"].some(o=>o in r)||r.CI_NAME==="codeship"?1:f;if(r.TERMINAL_EMULATOR?.includes("JediTerm"))return 3;if("TEAMCITY_VERSION"in r)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if(r.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in r){let o=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return o>=3?3:2;if(r.TERM_PROGRAM==="Apple_Terminal")return 2}if(/-256(color)?$/i.test(r.TERM))return 2;let O=!1;return a?R==="out"?O=i.Deno.stdout.isTerminal():R==="err"&&(O=i.Deno.stderr.isTerminal()):O=t["std"+R]&&"isTTY"in t["std"+R],O&&/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(r.TERM)?1:"COLORTERM"in r?1:f},b=()=>m("out"),v=()=>m("err");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, 'SPACE_16_COLORS', {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkVGFXSNOZ_cjs.b; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, 'SPACE_256_COLORS', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkVGFXSNOZ_cjs.c; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, 'SPACE_MONO', {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkVGFXSNOZ_cjs.a; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, 'SPACE_TRUE_COLORS', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkVGFXSNOZ_cjs.d; }
|
|
22
|
+
});
|
|
23
|
+
exports.isStderrColorSupported = v;
|
|
24
|
+
exports.isStdoutColorSupported = b;
|
|
7
25
|
//# sourceMappingURL=out.js.map
|
|
8
26
|
//# sourceMappingURL=is-color-supported.server.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-color-supported.server.ts"],"names":["isColorSupportedFactory","stdName","_this","isDeno","proc","argv","oneOfFlags","regex","terminatorPosition","position","flag","environment","FORCE_COLOR","hasForceColor","forceColorValue","forceColorValueIsString","forceColor","minColorLevel","osRelease","sign","version","isTTY","isStdoutColorSupported","isStderrColorSupported"],"mappings":"AAUA,IAAMA,EAA2BC,GAA8C,CAE3E,IAAMC,EAAQ,WAERC,EAASD,EAAM,MAAQ,KAEvBE,EAA4BF,EAAM,SAAWA,EAAM,MAAQ,CAAC,EAE5DG,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C,CAAC,GAAK,IAAM,OAAOA,EAAU,CAAC,CAAC,GAAK,MAE/C,OAAOA,EAAU,CAAC,CAAC,GAAK,MAAS,EAAI,EAGzC,CACX,MAAQ,CAER,CAGJ,GAAI,OAAQP,EACR,MAAI,mBAAoBA,GAAe,oBAAqBA,GAAe,kBAAmBA,EACnF,EAIP,CAAC,SAAU,WAAY,WAAY,YAAa,YAAa,QAAS,WAAW,EAAE,KAAMQ,GAASA,KAAQR,CAAW,GACrHA,EAAY,UAAe,WAEpB,EAGJM,EAGX,GAAI,qBAAsBN,EAGtB,MAAO,gCAAgC,KAAKA,EAAY,gBAA6B,EAAI,EAAI,EAOjG,GAJIA,EAAY,YAAiB,aAI7BA,EAAY,OAAY,cACxB,MAAO,GAGX,GAAI,iBAAkBA,EAAa,CAE/B,IAAMS,EAAU,OAAO,UAAWT,EAAY,sBAAsC,IAAI,MAAM,GAAG,EAAE,CAAC,EAAa,EAAE,EAEnH,GAAIA,EAAY,eAAoB,YAChC,OAAOS,GAAW,EAAI,EAAI,EAG9B,GAAIT,EAAY,eAAoB,iBAChC,MAAO,EAEf,CAGA,GAAI,iBAAiB,KAAaA,EAAY,IAAO,EACjD,MAAO,GAGX,IAAIU,EAAQ,GAmBZ,OAjBIlB,EACIF,IAAY,MAEZoB,EAAQnB,EAAM,KAAK,OAAO,WAAW,EAE9BD,IAAY,QAEnBoB,EAAQnB,EAAM,KAAK,OAAO,WAAW,GAGzCmB,EAAQjB,EAAK,MAAQH,CAAO,GAAK,UAAWG,EAAK,MAAQH,CAAO,EAGhEoB,GAAS,0EAA0E,KAAaV,EAAY,IAAO,GAInH,cAAeA,EACR,EAGJM,CACX,EAEaK,EAAyB,IAAyBtB,EAAwB,KAAK,EAE/EuB,EAAyB,IAAyBvB,EAAwB,KAAK","sourcesContent":["// Some of this code is taken from https://github.com/chalk/supports-color/blob/main/index.js\n// MIT License\n// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nimport type { ColorSupportLevel } from \"./types\";\n\n/**\n * @param {string} stdName The standard name of the stream, either \"err\" or \"out\".\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst isColorSupportedFactory = (stdName: \"err\" | \"out\"): ColorSupportLevel => {\n // eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-explicit-any\n const _this = globalThis as any;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const isDeno = _this.Deno != null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access\n const proc: Record<string, any> = _this.process ?? _this.Deno ?? {};\n // Node -> `argv`, Deno -> `args`\n const argv: string[] = (proc[\"argv\"] ?? proc[\"args\"] ?? []) as string[];\n\n /**\n * Detect whether flags exist with `-` or `--` prefix in command-line arguments.\n *\n * @param {RegExp} regex The RegEx to match all possible flags.\n * @return {boolean}\n */\n const oneOfFlags = (regex: RegExp): boolean => {\n const terminatorPosition = argv.indexOf(\"--\");\n\n const position = argv.findIndex((flag) => regex.test(flag));\n\n return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n };\n\n let environment: Record<string, string | undefined> = {};\n\n try {\n // Deno requires the permission for the access to env, use the `--allow-env` flag: deno run --allow-env ./app.js\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n environment = isDeno ? proc[\"env\"].toObject() : proc[\"env\"] ?? {};\n } catch {\n // Deno: if interactive permission is not granted, do nothing, no colors\n }\n\n const FORCE_COLOR = \"FORCE_COLOR\";\n const hasForceColor = FORCE_COLOR in environment;\n // eslint-disable-next-line security/detect-object-injection\n const forceColorValue = environment[FORCE_COLOR] ? String(environment[FORCE_COLOR]) : undefined;\n const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === \"String\";\n\n let forceColor: ColorSupportLevel = 0;\n\n if (forceColorValue === \"true\") {\n forceColor = 1;\n } else if (forceColorValue === \"false\") {\n forceColor = 0;\n } else if (forceColorValueIsString && (forceColorValue as string).length === 0) {\n forceColor = 1;\n } else if (forceColorValueIsString && (forceColorValue as string).length > 0) {\n forceColor = Math.min(Number.parseInt(forceColorValue as string, 10), 3) as ColorSupportLevel;\n }\n\n const isForceDisabled =\n // eslint-disable-next-line regexp/no-unused-capturing-group\n \"NO_COLOR\" in environment || (hasForceColor && forceColor === 0) || oneOfFlags(/^-{1,2}(no-color|no-colors|color=false|color=never)$/);\n\n if (isForceDisabled) {\n return 0;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (oneOfFlags(/^-{1,2}(color=256)$/)) {\n return 2;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (oneOfFlags(/^-{1,2}(color=16m|color=full|color=truecolor)$/)) {\n return 3;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n const isForceEnabled = oneOfFlags(/^-{1,2}(color|colors|color=true|color=always)$/);\n\n if (isForceEnabled) {\n return 1;\n }\n\n const minColorLevel = forceColor || 0;\n\n // Check for Azure DevOps pipelines.\n // Has to be above the `stream isTTY` check.\n if (\"TF_BUILD\" in environment && \"AGENT_NAME\" in environment) {\n return 1;\n }\n\n const isDumbTerminal: boolean = environment[\"TERM\"] === \"dumb\";\n\n if (isDumbTerminal) {\n return minColorLevel;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if ((isDeno ? _this.Deno.build.os : proc[\"platform\"]) === \"win32\") {\n try {\n // Deno requires the permission for the access to the operating system, use the `--allow-sys` flag: deno run --allow-sys ./app.js\n\n // Windows 10 build 10586 is the first Windows release that supports 256 colors.\n // Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n const osRelease = (isDeno ? _this.Deno.osRelease() : proc[\"os\"].release()).split(\".\");\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return Number(osRelease[2]) >= 14_931 ? 3 : 2;\n }\n\n return 1;\n } catch {\n // Deno: if interactive permission is not granted, do nothing, no colors\n }\n }\n\n if (\"CI\" in environment) {\n if (\"GITHUB_ACTIONS\" in environment || \"GITHUB_WORKFLOW\" in environment || \"GITEA_ACTIONS\" in environment) {\n return 3;\n }\n\n if (\n [\"TRAVIS\", \"CIRCLECI\", \"APPVEYOR\", \"GITLAB_CI\", \"BUILDKITE\", \"DRONE\", \"GITLAB_CI\"].some((sign) => sign in environment) ||\n environment[\"CI_NAME\"] === \"codeship\"\n ) {\n return 1;\n }\n\n return minColorLevel;\n }\n\n if (\"TEAMCITY_VERSION\" in environment) {\n // https://www.jetbrains.com/help/teamcity/build-script-interaction-with-teamcity.html#BuildScriptInteractionwithTeamCity-ReportingMessages\n // eslint-disable-next-line regexp/no-unused-capturing-group\n return /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(environment[\"TEAMCITY_VERSION\"] as string) ? 1 : 0;\n }\n\n if (environment[\"COLORTERM\"] === \"truecolor\") {\n return 3;\n }\n\n if (environment[\"TERM\"] === \"xterm-kitty\") {\n return 3;\n }\n\n if (\"TERM_PROGRAM\" in environment) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const version = Number.parseInt(((environment[\"TERM_PROGRAM_VERSION\"] as string) ?? \"\").split(\".\")[0] as string, 10);\n\n if (environment[\"TERM_PROGRAM\"] === \"iTerm.app\") {\n return version >= 3 ? 3 : 2;\n }\n\n if (environment[\"TERM_PROGRAM\"] === \"Apple_Terminal\") {\n return 2;\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (/-256(color)?$/i.test(<string>environment[\"TERM\"])) {\n return 2;\n }\n\n let isTTY = false;\n\n if (isDeno) {\n if (stdName === \"out\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n isTTY = _this.Deno.stdout.isTerminal();\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n } else if (stdName === \"err\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n isTTY = _this.Deno.stderr.isTerminal();\n }\n } else {\n isTTY = proc[\"std\" + stdName] && \"isTTY\" in proc[\"std\" + stdName];\n }\n\n if (isTTY && /^screen|^tmux|^xterm|^vt[1-5]\\d\\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(<string>environment[\"TERM\"])) {\n return 1;\n }\n\n if (\"COLORTERM\" in environment) {\n return 1;\n }\n\n return minColorLevel;\n};\n\nexport const isStdoutColorSupported = (): ColorSupportLevel => isColorSupportedFactory(\"out\");\n\nexport const isStderrColorSupported = (): ColorSupportLevel => isColorSupportedFactory(\"err\");\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { ColorSupportLevel } from \"./types\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/is-color-supported.server.ts"],"names":["isColorSupportedFactory","stdName","_this","isDeno","proc","argv","oneOfFlags","regex","terminatorPosition","position","flag","environment","FORCE_COLOR","hasForceColor","forceColorValue","forceColorValueIsString","forceColor","minColorLevel","osRelease","sign","version","isTTY","isStdoutColorSupported","isStderrColorSupported"],"mappings":"8DAWA,IAAMA,EAA2BC,GAA8C,CAE3E,IAAMC,EAAQ,WAERC,EAASD,EAAM,MAAQ,KAEvBE,EAA4BF,EAAM,SAAWA,EAAM,MAAQ,CAAC,EAE5DG,EAAkBD,EAAK,MAAQA,EAAK,MAAQ,CAAC,EAQ7CE,EAAcC,GAA2B,CAC3C,IAAMC,EAAqBH,EAAK,QAAQ,IAAI,EAEtCI,EAAWJ,EAAK,UAAWK,GAASH,EAAM,KAAKG,CAAI,CAAC,EAE1D,OAAOD,IAAa,KAAOD,IAAuB,IAAMC,EAAWD,EACvE,EAEIG,EAAkD,CAAC,EAEvD,GAAI,CAGAA,EAAcR,EAASC,EAAK,IAAI,SAAS,EAAIA,EAAK,KAAO,CA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AAW,GACrHA,EAAY,UAAY,WAEjB,EAGJM,EAIX,GAAIN,EAAY,mBAAmB,SAAS,UAAU,EAClD,MAAO,GAGX,GAAI,qBAAsBA,EAGtB,MAAO,gCAAgC,KAAKA,EAAY,gBAA0B,EAAI,EAAkB,EAG5G,GAAIA,EAAY,YAAc,YAC1B,MAAO,GAIX,GAAIA,EAAY,OAAS,cACrB,MAAO,GAGX,GAAI,iBAAkBA,EAAa,CAE/B,IAAMS,EAAU,OAAO,UAAWT,EAAY,sBAAmC,IAAI,MAAM,GAAG,EAAE,CAAC,EAAa,EAAE,EAEhH,GAAIA,EAAY,eAAiB,YAC7B,OAAOS,GAAW,EAAI,EAAoB,EAG9C,GAAIT,EAAY,eAAiB,iBAC7B,MAAO,EAEf,CAGA,GAAI,iBAAiB,KAAaA,EAAY,IAAI,EAC9C,MAAO,GAGX,IAAIU,EAAQ,GAeZ,OAbIlB,EACIF,IAAY,MAEZoB,EAAQnB,EAAM,KAAK,OAAO,WAAW,EAE9BD,IAAY,QAEnBoB,EAAQnB,EAAM,KAAK,OAAO,WAAW,GAGzCmB,EAAQjB,EAAK,MAAQH,CAAO,GAAK,UAAWG,EAAK,MAAQH,CAAO,EAGhEoB,GAAS,0EAA0E,KAAaV,EAAY,IAAI,EACzG,EAGP,cAAeA,EACR,EAGJM,CACX,EAEaK,EAAyB,IAAyBtB,EAAwB,KAAK,EAE/EuB,EAAyB,IAAyBvB,EAAwB,KAAK","sourcesContent":["// Some of this code is taken from https://github.com/chalk/supports-color/blob/main/index.js\n// MIT License\n// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nimport { SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO,SPACE_TRUE_COLORS } from \"./color-spaces\";\nimport type { ColorSupportLevel } from \"./types\";\n\n/**\n * @param {string} stdName The standard name of the stream, either \"err\" or \"out\".\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst isColorSupportedFactory = (stdName: \"err\" | \"out\"): ColorSupportLevel => {\n // eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-explicit-any\n const _this = globalThis as any;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const isDeno = _this.Deno != null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access\n const proc: Record<string, any> = _this.process ?? _this.Deno ?? {};\n // Node -> `argv`, Deno -> `args`\n const argv: string[] = (proc.argv ?? proc.args ?? []) as string[];\n\n /**\n * Detect whether flags exist with `-` or `--` prefix in command-line arguments.\n *\n * @param {RegExp} regex The RegEx to match all possible flags.\n * @return {boolean}\n */\n const oneOfFlags = (regex: RegExp): boolean => {\n const terminatorPosition = argv.indexOf(\"--\");\n\n const position = argv.findIndex((flag) => regex.test(flag));\n\n return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n };\n\n let environment: Record<string, string | undefined> = {};\n\n try {\n // Deno requires the permission for the access to env, use the `--allow-env` flag: deno run --allow-env ./app.js\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n environment = isDeno ? proc.env.toObject() : proc.env ?? {};\n } catch {\n // Deno: if interactive permission is not granted, do nothing, no colors\n }\n\n const FORCE_COLOR = \"FORCE_COLOR\";\n const hasForceColor = FORCE_COLOR in environment;\n // eslint-disable-next-line security/detect-object-injection\n const forceColorValue = environment[FORCE_COLOR] ? String(environment[FORCE_COLOR]) : undefined;\n const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === \"String\";\n\n let forceColor: ColorSupportLevel = SPACE_MONO;\n\n if (forceColorValue === \"true\") {\n forceColor = SPACE_16_COLORS;\n } else if (forceColorValue === \"false\") {\n forceColor = SPACE_MONO;\n } else if (forceColorValueIsString && (forceColorValue as string).length === 0) {\n forceColor = SPACE_16_COLORS;\n } else if (forceColorValueIsString && (forceColorValue as string).length > 0) {\n forceColor = Math.min(Number.parseInt(forceColorValue as string, 10), 3) as ColorSupportLevel;\n }\n\n const isForceDisabled =\n // eslint-disable-next-line regexp/no-unused-capturing-group\n \"NO_COLOR\" in environment || (hasForceColor && forceColor === 0) || oneOfFlags(/^-{1,2}(no-color|no-colors|color=false|color=never)$/);\n\n if (isForceDisabled) {\n return SPACE_MONO;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (oneOfFlags(/^-{1,2}(color=256)$/)) {\n return SPACE_256_COLORS;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (oneOfFlags(/^-{1,2}(color=16m|color=full|color=truecolor)$/)) {\n return SPACE_TRUE_COLORS;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n const isForceEnabled = oneOfFlags(/^-{1,2}(color|colors|color=true|color=always)$/);\n\n if (isForceEnabled) {\n return SPACE_16_COLORS;\n }\n\n // note: the order of checks is important\n // many terminals that support truecolor have TERM as `xterm-256colors` but do not set COLORTERM to `truecolor`\n // therefore they can be detected by specific EVN variables\n\n const minColorLevel = forceColor || SPACE_MONO;\n\n // Check for Azure DevOps pipelines.\n // Has to be above the `stream isTTY` check.\n if (\"TF_BUILD\" in environment && \"AGENT_NAME\" in environment) {\n return SPACE_16_COLORS;\n }\n\n const isDumbTerminal: boolean = (environment.TERM && /-mono|dumb/i.test(environment.TERM)) as boolean;\n\n if (isDumbTerminal) {\n return minColorLevel;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if ((isDeno ? _this.Deno.build.os : proc.platform) === \"win32\") {\n try {\n // Deno requires the permission for the access to the operating system, use the `--allow-sys` flag: deno run --allow-sys ./app.js\n\n // Windows 10 build 10586 is the first Windows release that supports 256 colors.\n // Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n const osRelease = (isDeno ? _this.Deno.osRelease() : proc.os.release()).split(\".\");\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return Number(osRelease[2]) >= 14_931 ? SPACE_TRUE_COLORS : SPACE_256_COLORS;\n }\n\n return SPACE_16_COLORS;\n } catch {\n // Deno: if interactive permission is not granted, do nothing, no colors\n }\n }\n\n if (\"CI\" in environment) {\n if (\"GITHUB_ACTIONS\" in environment || \"GITHUB_WORKFLOW\" in environment || \"GITEA_ACTIONS\" in environment) {\n return SPACE_TRUE_COLORS;\n }\n\n if (\n [\"TRAVIS\", \"CIRCLECI\", \"APPVEYOR\", \"GITLAB_CI\", \"BUILDKITE\", \"DRONE\", \"GITLAB_CI\"].some((sign) => sign in environment) ||\n environment.CI_NAME === \"codeship\"\n ) {\n return SPACE_16_COLORS;\n }\n\n return minColorLevel;\n }\n\n // JetBrains IDEA: JetBrains-JediTerm\n if (environment.TERMINAL_EMULATOR?.includes(\"JediTerm\")) {\n return SPACE_TRUE_COLORS;\n }\n\n if (\"TEAMCITY_VERSION\" in environment) {\n // https://www.jetbrains.com/help/teamcity/build-script-interaction-with-teamcity.html#BuildScriptInteractionwithTeamCity-ReportingMessages\n // eslint-disable-next-line regexp/no-unused-capturing-group\n return /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(environment.TEAMCITY_VERSION as string) ? SPACE_16_COLORS : SPACE_MONO;\n }\n\n if (environment.COLORTERM === \"truecolor\") {\n return SPACE_TRUE_COLORS;\n }\n\n // kitty is GPU based terminal emulator\n if (environment.TERM === \"xterm-kitty\") {\n return SPACE_TRUE_COLORS;\n }\n\n if (\"TERM_PROGRAM\" in environment) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const version = Number.parseInt(((environment.TERM_PROGRAM_VERSION as string) ?? \"\").split(\".\")[0] as string, 10);\n\n if (environment.TERM_PROGRAM === \"iTerm.app\") {\n return version >= 3 ? SPACE_TRUE_COLORS : SPACE_256_COLORS;\n }\n\n if (environment.TERM_PROGRAM === \"Apple_Terminal\") {\n return SPACE_256_COLORS;\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (/-256(color)?$/i.test(<string>environment.TERM)) {\n return SPACE_256_COLORS;\n }\n\n let isTTY = false;\n\n if (isDeno) {\n if (stdName === \"out\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n isTTY = _this.Deno.stdout.isTerminal();\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n } else if (stdName === \"err\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n isTTY = _this.Deno.stderr.isTerminal();\n }\n } else {\n isTTY = proc[\"std\" + stdName] && \"isTTY\" in proc[\"std\" + stdName];\n }\n\n if (isTTY && /^screen|^tmux|^xterm|^vt[1-5]\\d\\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(<string>environment.TERM)) {\n return SPACE_16_COLORS;\n }\n\n if (\"COLORTERM\" in environment) {\n return SPACE_16_COLORS;\n }\n\n return minColorLevel;\n};\n\nexport const isStdoutColorSupported = (): ColorSupportLevel => isColorSupportedFactory(\"out\");\n\nexport const isStderrColorSupported = (): ColorSupportLevel => isColorSupportedFactory(\"err\");\n// eslint-disable-next-line import/no-unused-modules\nexport { SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO,SPACE_TRUE_COLORS } from \"./color-spaces\";\n// eslint-disable-next-line import/no-unused-modules\nexport type { ColorSupportLevel } from \"./types\";\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as ColorSupportLevel } from './
|
|
1
|
+
import { C as ColorSupportLevel } from './color-spaces-LVm3eRLc.cjs';
|
|
2
|
+
export { S as SPACE_16_COLORS, a as SPACE_256_COLORS, b as SPACE_MONO, c as SPACE_TRUE_COLORS } from './color-spaces-LVm3eRLc.cjs';
|
|
2
3
|
|
|
3
4
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
4
5
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as ColorSupportLevel } from './
|
|
1
|
+
import { C as ColorSupportLevel } from './color-spaces-LVm3eRLc.js';
|
|
2
|
+
export { S as SPACE_16_COLORS, a as SPACE_256_COLORS, b as SPACE_MONO, c as SPACE_TRUE_COLORS } from './color-spaces-LVm3eRLc.js';
|
|
2
3
|
|
|
3
4
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
4
5
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export { b as SPACE_16_COLORS, c as SPACE_256_COLORS, a as SPACE_MONO, d as SPACE_TRUE_COLORS } from './chunk-ARYGRP3O.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var m=R=>{let i=globalThis,a=i.Deno!=null,t=i.process??i.Deno??{},T=t.argv??t.args??[],C=o=>{let _=T.indexOf("--"),S=T.findIndex(A=>o.test(A));return S!==-1&&(_===-1||S<_)},r={};try{r=a?t.env.toObject():t.env??{};}catch{}let p="FORCE_COLOR",d=p in r,s=r[p]?String(r[p]):void 0,E=Object.prototype.toString.call(s).slice(8,-1)==="String",l=0;if(s==="true"?l=1:s==="false"?l=0:E&&s.length===0?l=1:E&&s.length>0&&(l=Math.min(Number.parseInt(s,10),3)),"NO_COLOR"in r||d&&l===0||C(/^-{1,2}(no-color|no-colors|color=false|color=never)$/))return 0;if(C(/^-{1,2}(color=256)$/))return 2;if(C(/^-{1,2}(color=16m|color=full|color=truecolor)$/))return 3;if(C(/^-{1,2}(color|colors|color=true|color=always)$/))return 1;let f=l||0;if("TF_BUILD"in r&&"AGENT_NAME"in r)return 1;if(r.TERM&&/-mono|dumb/i.test(r.TERM))return f;if((a?i.Deno.build.os:t.platform)==="win32")try{let o=(a?i.Deno.osRelease():t.os.release()).split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}catch{}if("CI"in r)return "GITHUB_ACTIONS"in r||"GITHUB_WORKFLOW"in r||"GITEA_ACTIONS"in r?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE","GITLAB_CI"].some(o=>o in r)||r.CI_NAME==="codeship"?1:f;if(r.TERMINAL_EMULATOR?.includes("JediTerm"))return 3;if("TEAMCITY_VERSION"in r)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if(r.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in r){let o=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return o>=3?3:2;if(r.TERM_PROGRAM==="Apple_Terminal")return 2}if(/-256(color)?$/i.test(r.TERM))return 2;let O=!1;return a?R==="out"?O=i.Deno.stdout.isTerminal():R==="err"&&(O=i.Deno.stderr.isTerminal()):O=t["std"+R]&&"isTTY"in t["std"+R],O&&/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(r.TERM)?1:"COLORTERM"in r?1:f},v=()=>m("out"),N=()=>m("err");
|
|
4
|
+
|
|
5
|
+
export { N as isStderrColorSupported, v as isStdoutColorSupported };
|
|
4
6
|
//# sourceMappingURL=out.js.map
|
|
5
7
|
//# sourceMappingURL=is-color-supported.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-color-supported.server.ts"],"names":["isColorSupportedFactory","stdName","_this","isDeno","proc","argv","oneOfFlags","regex","terminatorPosition","position","flag","environment","FORCE_COLOR","hasForceColor","forceColorValue","forceColorValueIsString","forceColor","minColorLevel","osRelease","sign","version","isTTY","isStdoutColorSupported","isStderrColorSupported"],"mappings":"AAUA,IAAMA,EAA2BC,GAA8C,CAE3E,IAAMC,EAAQ,WAERC,EAASD,EAAM,MAAQ,KAEvBE,EAA4BF,EAA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,GAAG,EAGpF,OAAI,OAAOc,EAAU,CAAC,CAAC,GAAK,IAAM,OAAOA,EAAU,CAAC,CAAC,GAAK,MAE/C,OAAOA,EAAU,CAAC,CAAC,GAAK,MAAS,EAAI,EAGzC,CACX,MAAQ,CAER,CAGJ,GAAI,OAAQP,EACR,MAAI,mBAAoBA,GAAe,oBAAqBA,GAAe,kBAAmBA,EACnF,EAIP,CAAC,SAAU,WAAY,WAAY,YAAa,YAAa,QAAS,WAAW,EAAE,KAAMQ,GAASA,KAAQR,CAAW,GACrHA,EAAY,UAAe,WAEpB,EAGJM,EAGX,GAAI,qBAAsBN,EAGtB,MAAO,gCAAgC,KAAKA,EAAY,gBAA6B,EAAI,EAAI,EAOjG,GAJIA,EAAY,YAAiB,aAI7BA,EAAY,OAAY,cACxB,MAAO,GAGX,GAAI,iBAAkBA,EAAa,CAE/B,IAAMS,EAAU,OAAO,UAAWT,EAAY,sBAAsC,IAAI,MAAM,GAAG,EAAE,CAAC,EAAa,EAAE,EAEnH,GAAIA,EAAY,eAAoB,YAChC,OAAOS,GAAW,EAAI,EAAI,EAG9B,GAAIT,EAAY,eAAoB,iBAChC,MAAO,EAEf,CAGA,GAAI,iBAAiB,KAAaA,EAAY,IAAO,EACjD,MAAO,GAGX,IAAIU,EAAQ,GAmBZ,OAjBIlB,EACIF,IAAY,MAEZoB,EAAQnB,EAAM,KAAK,OAAO,WAAW,EAE9BD,IAAY,QAEnBoB,EAAQnB,EAAM,KAAK,OAAO,WAAW,GAGzCmB,EAAQjB,EAAK,MAAQH,CAAO,GAAK,UAAWG,EAAK,MAAQH,CAAO,EAGhEoB,GAAS,0EAA0E,KAAaV,EAAY,IAAO,GAInH,cAAeA,EACR,EAGJM,CACX,EAEaK,EAAyB,IAAyBtB,EAAwB,KAAK,EAE/EuB,EAAyB,IAAyBvB,EAAwB,KAAK","sourcesContent":["// Some of this code is taken from https://github.com/chalk/supports-color/blob/main/index.js\n// MIT License\n// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nimport type { ColorSupportLevel } from \"./types\";\n\n/**\n * @param {string} stdName The standard name of the stream, either \"err\" or \"out\".\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst isColorSupportedFactory = (stdName: \"err\" | \"out\"): ColorSupportLevel => {\n // eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-explicit-any\n const _this = globalThis as any;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const isDeno = _this.Deno != null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access\n const proc: Record<string, any> = _this.process ?? _this.Deno ?? {};\n // Node -> `argv`, Deno -> `args`\n const argv: string[] = (proc[\"argv\"] ?? proc[\"args\"] ?? []) as string[];\n\n /**\n * Detect whether flags exist with `-` or `--` prefix in command-line arguments.\n *\n * @param {RegExp} regex The RegEx to match all possible flags.\n * @return {boolean}\n */\n const oneOfFlags = (regex: RegExp): boolean => {\n const terminatorPosition = argv.indexOf(\"--\");\n\n const position = argv.findIndex((flag) => regex.test(flag));\n\n return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n };\n\n let environment: Record<string, string | undefined> = {};\n\n try {\n // Deno requires the permission for the access to env, use the `--allow-env` flag: deno run --allow-env ./app.js\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n environment = isDeno ? proc[\"env\"].toObject() : proc[\"env\"] ?? {};\n } catch {\n // Deno: if interactive permission is not granted, do nothing, no colors\n }\n\n const FORCE_COLOR = \"FORCE_COLOR\";\n const hasForceColor = FORCE_COLOR in environment;\n // eslint-disable-next-line security/detect-object-injection\n const forceColorValue = environment[FORCE_COLOR] ? String(environment[FORCE_COLOR]) : undefined;\n const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === \"String\";\n\n let forceColor: ColorSupportLevel = 0;\n\n if (forceColorValue === \"true\") {\n forceColor = 1;\n } else if (forceColorValue === \"false\") {\n forceColor = 0;\n } else if (forceColorValueIsString && (forceColorValue as string).length === 0) {\n forceColor = 1;\n } else if (forceColorValueIsString && (forceColorValue as string).length > 0) {\n forceColor = Math.min(Number.parseInt(forceColorValue as string, 10), 3) as ColorSupportLevel;\n }\n\n const isForceDisabled =\n // eslint-disable-next-line regexp/no-unused-capturing-group\n \"NO_COLOR\" in environment || (hasForceColor && forceColor === 0) || oneOfFlags(/^-{1,2}(no-color|no-colors|color=false|color=never)$/);\n\n if (isForceDisabled) {\n return 0;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (oneOfFlags(/^-{1,2}(color=256)$/)) {\n return 2;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (oneOfFlags(/^-{1,2}(color=16m|color=full|color=truecolor)$/)) {\n return 3;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n const isForceEnabled = oneOfFlags(/^-{1,2}(color|colors|color=true|color=always)$/);\n\n if (isForceEnabled) {\n return 1;\n }\n\n const minColorLevel = forceColor || 0;\n\n // Check for Azure DevOps pipelines.\n // Has to be above the `stream isTTY` check.\n if (\"TF_BUILD\" in environment && \"AGENT_NAME\" in environment) {\n return 1;\n }\n\n const isDumbTerminal: boolean = environment[\"TERM\"] === \"dumb\";\n\n if (isDumbTerminal) {\n return minColorLevel;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if ((isDeno ? _this.Deno.build.os : proc[\"platform\"]) === \"win32\") {\n try {\n // Deno requires the permission for the access to the operating system, use the `--allow-sys` flag: deno run --allow-sys ./app.js\n\n // Windows 10 build 10586 is the first Windows release that supports 256 colors.\n // Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n const osRelease = (isDeno ? _this.Deno.osRelease() : proc[\"os\"].release()).split(\".\");\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return Number(osRelease[2]) >= 14_931 ? 3 : 2;\n }\n\n return 1;\n } catch {\n // Deno: if interactive permission is not granted, do nothing, no colors\n }\n }\n\n if (\"CI\" in environment) {\n if (\"GITHUB_ACTIONS\" in environment || \"GITHUB_WORKFLOW\" in environment || \"GITEA_ACTIONS\" in environment) {\n return 3;\n }\n\n if (\n [\"TRAVIS\", \"CIRCLECI\", \"APPVEYOR\", \"GITLAB_CI\", \"BUILDKITE\", \"DRONE\", \"GITLAB_CI\"].some((sign) => sign in environment) ||\n environment[\"CI_NAME\"] === \"codeship\"\n ) {\n return 1;\n }\n\n return minColorLevel;\n }\n\n if (\"TEAMCITY_VERSION\" in environment) {\n // https://www.jetbrains.com/help/teamcity/build-script-interaction-with-teamcity.html#BuildScriptInteractionwithTeamCity-ReportingMessages\n // eslint-disable-next-line regexp/no-unused-capturing-group\n return /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(environment[\"TEAMCITY_VERSION\"] as string) ? 1 : 0;\n }\n\n if (environment[\"COLORTERM\"] === \"truecolor\") {\n return 3;\n }\n\n if (environment[\"TERM\"] === \"xterm-kitty\") {\n return 3;\n }\n\n if (\"TERM_PROGRAM\" in environment) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const version = Number.parseInt(((environment[\"TERM_PROGRAM_VERSION\"] as string) ?? \"\").split(\".\")[0] as string, 10);\n\n if (environment[\"TERM_PROGRAM\"] === \"iTerm.app\") {\n return version >= 3 ? 3 : 2;\n }\n\n if (environment[\"TERM_PROGRAM\"] === \"Apple_Terminal\") {\n return 2;\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (/-256(color)?$/i.test(<string>environment[\"TERM\"])) {\n return 2;\n }\n\n let isTTY = false;\n\n if (isDeno) {\n if (stdName === \"out\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n isTTY = _this.Deno.stdout.isTerminal();\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n } else if (stdName === \"err\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n isTTY = _this.Deno.stderr.isTerminal();\n }\n } else {\n isTTY = proc[\"std\" + stdName] && \"isTTY\" in proc[\"std\" + stdName];\n }\n\n if (isTTY && /^screen|^tmux|^xterm|^vt[1-5]\\d\\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(<string>environment[\"TERM\"])) {\n return 1;\n }\n\n if (\"COLORTERM\" in environment) {\n return 1;\n }\n\n return minColorLevel;\n};\n\nexport const isStdoutColorSupported = (): ColorSupportLevel => isColorSupportedFactory(\"out\");\n\nexport const isStderrColorSupported = (): ColorSupportLevel => isColorSupportedFactory(\"err\");\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { ColorSupportLevel } from \"./types\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/is-color-supported.server.ts"],"names":["isColorSupportedFactory","stdName","_this","isDeno","proc","argv","oneOfFlags","regex","terminatorPosition","position","flag","environment","FORCE_COLOR","hasForceColor","forceColorValue","forceColorValueIsString","forceColor","minColorLevel","osRelease","sign","version","isTTY","isStdoutColorSupported","isStderrColorSupported"],"mappings":"6DAWA,IAAMA,EAA2BC,GAA8C,CAE3E,IAAMC,EAAQ,WAERC,EAASD,EAAM,MAAQ,KAEvBE,EAA4BF,EAAM,SAAWA,EAAM,MAAQ,CAAC,EAE5DG,EAAkBD,EAAK,MAAQA,EAAK,MAAQ,CAAC,EAQ7CE,EAAcC,GAA2B,CAC3C,IAAMC,EAAqBH,EAAK,QAAQ,IAAI,EAEtCI,EAAWJ,EAAK,UAAWK,GAASH,EAAM,KAAKG,CAAI,CAAC,EAE1D,OAAOD,IAAa,KAAOD,IAAuB,IAAMC,EAAWD,EACvE,EAEIG,EAAkD,CAAC,EAEvD,GAAI,CAGAA,EAAcR,EAASC,EA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S,WAAW,EAAE,KAAMQ,GAASA,KAAQR,CAAW,GACrHA,EAAY,UAAY,WAEjB,EAGJM,EAIX,GAAIN,EAAY,mBAAmB,SAAS,UAAU,EAClD,MAAO,GAGX,GAAI,qBAAsBA,EAGtB,MAAO,gCAAgC,KAAKA,EAAY,gBAA0B,EAAI,EAAkB,EAG5G,GAAIA,EAAY,YAAc,YAC1B,MAAO,GAIX,GAAIA,EAAY,OAAS,cACrB,MAAO,GAGX,GAAI,iBAAkBA,EAAa,CAE/B,IAAMS,EAAU,OAAO,UAAWT,EAAY,sBAAmC,IAAI,MAAM,GAAG,EAAE,CAAC,EAAa,EAAE,EAEhH,GAAIA,EAAY,eAAiB,YAC7B,OAAOS,GAAW,EAAI,EAAoB,EAG9C,GAAIT,EAAY,eAAiB,iBAC7B,MAAO,EAEf,CAGA,GAAI,iBAAiB,KAAaA,EAAY,IAAI,EAC9C,MAAO,GAGX,IAAIU,EAAQ,GAeZ,OAbIlB,EACIF,IAAY,MAEZoB,EAAQnB,EAAM,KAAK,OAAO,WAAW,EAE9BD,IAAY,QAEnBoB,EAAQnB,EAAM,KAAK,OAAO,WAAW,GAGzCmB,EAAQjB,EAAK,MAAQH,CAAO,GAAK,UAAWG,EAAK,MAAQH,CAAO,EAGhEoB,GAAS,0EAA0E,KAAaV,EAAY,IAAI,EACzG,EAGP,cAAeA,EACR,EAGJM,CACX,EAEaK,EAAyB,IAAyBtB,EAAwB,KAAK,EAE/EuB,EAAyB,IAAyBvB,EAAwB,KAAK","sourcesContent":["// Some of this code is taken from https://github.com/chalk/supports-color/blob/main/index.js\n// MIT License\n// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nimport { SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO,SPACE_TRUE_COLORS } from \"./color-spaces\";\nimport type { ColorSupportLevel } from \"./types\";\n\n/**\n * @param {string} stdName The standard name of the stream, either \"err\" or \"out\".\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nconst isColorSupportedFactory = (stdName: \"err\" | \"out\"): ColorSupportLevel => {\n // eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-explicit-any\n const _this = globalThis as any;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const isDeno = _this.Deno != null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access\n const proc: Record<string, any> = _this.process ?? _this.Deno ?? {};\n // Node -> `argv`, Deno -> `args`\n const argv: string[] = (proc.argv ?? proc.args ?? []) as string[];\n\n /**\n * Detect whether flags exist with `-` or `--` prefix in command-line arguments.\n *\n * @param {RegExp} regex The RegEx to match all possible flags.\n * @return {boolean}\n */\n const oneOfFlags = (regex: RegExp): boolean => {\n const terminatorPosition = argv.indexOf(\"--\");\n\n const position = argv.findIndex((flag) => regex.test(flag));\n\n return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);\n };\n\n let environment: Record<string, string | undefined> = {};\n\n try {\n // Deno requires the permission for the access to env, use the `--allow-env` flag: deno run --allow-env ./app.js\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n environment = isDeno ? proc.env.toObject() : proc.env ?? {};\n } catch {\n // Deno: if interactive permission is not granted, do nothing, no colors\n }\n\n const FORCE_COLOR = \"FORCE_COLOR\";\n const hasForceColor = FORCE_COLOR in environment;\n // eslint-disable-next-line security/detect-object-injection\n const forceColorValue = environment[FORCE_COLOR] ? String(environment[FORCE_COLOR]) : undefined;\n const forceColorValueIsString = Object.prototype.toString.call(forceColorValue).slice(8, -1) === \"String\";\n\n let forceColor: ColorSupportLevel = SPACE_MONO;\n\n if (forceColorValue === \"true\") {\n forceColor = SPACE_16_COLORS;\n } else if (forceColorValue === \"false\") {\n forceColor = SPACE_MONO;\n } else if (forceColorValueIsString && (forceColorValue as string).length === 0) {\n forceColor = SPACE_16_COLORS;\n } else if (forceColorValueIsString && (forceColorValue as string).length > 0) {\n forceColor = Math.min(Number.parseInt(forceColorValue as string, 10), 3) as ColorSupportLevel;\n }\n\n const isForceDisabled =\n // eslint-disable-next-line regexp/no-unused-capturing-group\n \"NO_COLOR\" in environment || (hasForceColor && forceColor === 0) || oneOfFlags(/^-{1,2}(no-color|no-colors|color=false|color=never)$/);\n\n if (isForceDisabled) {\n return SPACE_MONO;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (oneOfFlags(/^-{1,2}(color=256)$/)) {\n return SPACE_256_COLORS;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (oneOfFlags(/^-{1,2}(color=16m|color=full|color=truecolor)$/)) {\n return SPACE_TRUE_COLORS;\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n const isForceEnabled = oneOfFlags(/^-{1,2}(color|colors|color=true|color=always)$/);\n\n if (isForceEnabled) {\n return SPACE_16_COLORS;\n }\n\n // note: the order of checks is important\n // many terminals that support truecolor have TERM as `xterm-256colors` but do not set COLORTERM to `truecolor`\n // therefore they can be detected by specific EVN variables\n\n const minColorLevel = forceColor || SPACE_MONO;\n\n // Check for Azure DevOps pipelines.\n // Has to be above the `stream isTTY` check.\n if (\"TF_BUILD\" in environment && \"AGENT_NAME\" in environment) {\n return SPACE_16_COLORS;\n }\n\n const isDumbTerminal: boolean = (environment.TERM && /-mono|dumb/i.test(environment.TERM)) as boolean;\n\n if (isDumbTerminal) {\n return minColorLevel;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if ((isDeno ? _this.Deno.build.os : proc.platform) === \"win32\") {\n try {\n // Deno requires the permission for the access to the operating system, use the `--allow-sys` flag: deno run --allow-sys ./app.js\n\n // Windows 10 build 10586 is the first Windows release that supports 256 colors.\n // Windows 10 build 14931 is the first release that supports 16m/TrueColor.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n const osRelease = (isDeno ? _this.Deno.osRelease() : proc.os.release()).split(\".\");\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return Number(osRelease[2]) >= 14_931 ? SPACE_TRUE_COLORS : SPACE_256_COLORS;\n }\n\n return SPACE_16_COLORS;\n } catch {\n // Deno: if interactive permission is not granted, do nothing, no colors\n }\n }\n\n if (\"CI\" in environment) {\n if (\"GITHUB_ACTIONS\" in environment || \"GITHUB_WORKFLOW\" in environment || \"GITEA_ACTIONS\" in environment) {\n return SPACE_TRUE_COLORS;\n }\n\n if (\n [\"TRAVIS\", \"CIRCLECI\", \"APPVEYOR\", \"GITLAB_CI\", \"BUILDKITE\", \"DRONE\", \"GITLAB_CI\"].some((sign) => sign in environment) ||\n environment.CI_NAME === \"codeship\"\n ) {\n return SPACE_16_COLORS;\n }\n\n return minColorLevel;\n }\n\n // JetBrains IDEA: JetBrains-JediTerm\n if (environment.TERMINAL_EMULATOR?.includes(\"JediTerm\")) {\n return SPACE_TRUE_COLORS;\n }\n\n if (\"TEAMCITY_VERSION\" in environment) {\n // https://www.jetbrains.com/help/teamcity/build-script-interaction-with-teamcity.html#BuildScriptInteractionwithTeamCity-ReportingMessages\n // eslint-disable-next-line regexp/no-unused-capturing-group\n return /^(9\\.(0*[1-9]\\d*)\\.|\\d{2,}\\.)/.test(environment.TEAMCITY_VERSION as string) ? SPACE_16_COLORS : SPACE_MONO;\n }\n\n if (environment.COLORTERM === \"truecolor\") {\n return SPACE_TRUE_COLORS;\n }\n\n // kitty is GPU based terminal emulator\n if (environment.TERM === \"xterm-kitty\") {\n return SPACE_TRUE_COLORS;\n }\n\n if (\"TERM_PROGRAM\" in environment) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const version = Number.parseInt(((environment.TERM_PROGRAM_VERSION as string) ?? \"\").split(\".\")[0] as string, 10);\n\n if (environment.TERM_PROGRAM === \"iTerm.app\") {\n return version >= 3 ? SPACE_TRUE_COLORS : SPACE_256_COLORS;\n }\n\n if (environment.TERM_PROGRAM === \"Apple_Terminal\") {\n return SPACE_256_COLORS;\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (/-256(color)?$/i.test(<string>environment.TERM)) {\n return SPACE_256_COLORS;\n }\n\n let isTTY = false;\n\n if (isDeno) {\n if (stdName === \"out\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n isTTY = _this.Deno.stdout.isTerminal();\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n } else if (stdName === \"err\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n isTTY = _this.Deno.stderr.isTerminal();\n }\n } else {\n isTTY = proc[\"std\" + stdName] && \"isTTY\" in proc[\"std\" + stdName];\n }\n\n if (isTTY && /^screen|^tmux|^xterm|^vt[1-5]\\d\\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(<string>environment.TERM)) {\n return SPACE_16_COLORS;\n }\n\n if (\"COLORTERM\" in environment) {\n return SPACE_16_COLORS;\n }\n\n return minColorLevel;\n};\n\nexport const isStdoutColorSupported = (): ColorSupportLevel => isColorSupportedFactory(\"out\");\n\nexport const isStderrColorSupported = (): ColorSupportLevel => isColorSupportedFactory(\"err\");\n// eslint-disable-next-line import/no-unused-modules\nexport { SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO,SPACE_TRUE_COLORS } from \"./color-spaces\";\n// eslint-disable-next-line import/no-unused-modules\nexport type { ColorSupportLevel } from \"./types\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/is-ansi-color-supported",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Detect whether a terminal or browser supports ansi colors.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -99,33 +99,38 @@
|
|
|
99
99
|
"@anolilab/eslint-config": "^15.0.3",
|
|
100
100
|
"@anolilab/prettier-config": "^5.0.14",
|
|
101
101
|
"@anolilab/semantic-release-preset": "^8.0.3",
|
|
102
|
-
"@babel/core": "^7.24.
|
|
102
|
+
"@babel/core": "^7.24.4",
|
|
103
103
|
"@rushstack/eslint-plugin-security": "^0.8.1",
|
|
104
|
-
"@secretlint/secretlint-rule-preset-recommend": "^8.
|
|
104
|
+
"@secretlint/secretlint-rule-preset-recommend": "^8.2.3",
|
|
105
105
|
"@types/micromatch": "^4.0.6",
|
|
106
106
|
"@types/node": "18.18.14",
|
|
107
|
-
"@vitest/coverage-v8": "^1.
|
|
108
|
-
"@vitest/ui": "^1.
|
|
107
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
108
|
+
"@vitest/ui": "^1.4.0",
|
|
109
109
|
"cross-env": "^7.0.3",
|
|
110
110
|
"eslint": "^8.57.0",
|
|
111
111
|
"eslint-plugin-deprecation": "^2.0.0",
|
|
112
112
|
"eslint-plugin-etc": "^2.0.3",
|
|
113
113
|
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
114
114
|
"eslint-plugin-mdx": "^3.1.5",
|
|
115
|
-
"eslint-plugin-vitest": "^0.
|
|
116
|
-
"eslint-plugin-vitest-globals": "^1.
|
|
115
|
+
"eslint-plugin-vitest": "^0.4.1",
|
|
116
|
+
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
117
117
|
"prettier": "^3.2.5",
|
|
118
118
|
"rimraf": "^5.0.5",
|
|
119
|
-
"secretlint": "8.
|
|
120
|
-
"semantic-release": "^23.0.
|
|
121
|
-
"sort-package-json": "^2.
|
|
119
|
+
"secretlint": "8.2.3",
|
|
120
|
+
"semantic-release": "^23.0.7",
|
|
121
|
+
"sort-package-json": "^2.10.0",
|
|
122
122
|
"tsup": "^8.0.2",
|
|
123
|
-
"typescript": "^5.
|
|
124
|
-
"vitest": "^1.
|
|
123
|
+
"typescript": "^5.4.4",
|
|
124
|
+
"vitest": "^1.4.0"
|
|
125
125
|
},
|
|
126
126
|
"engines": {
|
|
127
127
|
"node": ">=18.* <=21.*"
|
|
128
128
|
},
|
|
129
|
+
"os": [
|
|
130
|
+
"darwin",
|
|
131
|
+
"linux",
|
|
132
|
+
"win32"
|
|
133
|
+
],
|
|
129
134
|
"publishConfig": {
|
|
130
135
|
"access": "public",
|
|
131
136
|
"provenance": true
|
package/dist/types-tBMJqxWx.d.ts
DELETED