@visulima/is-ansi-color-supported 1.1.0 → 2.0.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 +25 -0
- package/README.md +7 -5
- package/dist/is-color-supported.browser.cjs +3 -2
- package/dist/is-color-supported.browser.cjs.map +1 -1
- package/dist/is-color-supported.browser.d.cts +3 -2
- package/dist/is-color-supported.browser.d.ts +3 -2
- package/dist/is-color-supported.browser.js +2 -2
- package/dist/is-color-supported.browser.js.map +1 -1
- package/dist/is-color-supported.server.cjs +3 -2
- package/dist/is-color-supported.server.cjs.map +1 -1
- package/dist/is-color-supported.server.d.cts +3 -2
- package/dist/is-color-supported.server.d.ts +3 -2
- package/dist/is-color-supported.server.js +2 -2
- package/dist/is-color-supported.server.js.map +1 -1
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## @visulima/is-ansi-color-supported [2.0.0](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@1.2.0...@visulima/is-ansi-color-supported@2.0.0) (2024-02-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### ⚠ BREAKING CHANGES
|
|
5
|
+
|
|
6
|
+
* export changed to isStderrColorSupported,isStdoutColorSupported; isColorSupported is now isStdoutColorSupported
|
|
7
|
+
|
|
8
|
+
Signed-off-by: prisis <d.bannert@anolilab.de>
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* added support for stderr, migrated deno api to v2 ([2e8ac8f](https://github.com/visulima/visulima/commit/2e8ac8f0251719aa54a2bf3466618d47988dd248))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* fixed tests ([12c7b71](https://github.com/visulima/visulima/commit/12c7b716f716f9190d462c1b8665989b57602160))
|
|
18
|
+
|
|
19
|
+
## @visulima/is-ansi-color-supported [1.2.0](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@1.1.0...@visulima/is-ansi-color-supported@1.2.0) (2024-02-20)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* add detection of additional terminals, thanks [@dse](https://github.com/dse), [colors.js:issue [#42](https://github.com/visulima/visulima/issues/42)](https://github.com/DABH/colors.js/issues/42) ([d2f034d](https://github.com/visulima/visulima/commit/d2f034de2ea41bce4c09fe7a40d8e9aa8ad4401c))
|
|
25
|
+
|
|
1
26
|
## @visulima/is-ansi-color-supported [1.1.0](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@1.0.0...@visulima/is-ansi-color-supported@1.1.0) (2024-01-31)
|
|
2
27
|
|
|
3
28
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h3>Visulima is-ansi-color-supported</h3>
|
|
3
3
|
<p>
|
|
4
|
-
Detect whether a terminal, browser or edge supports ansi colors.
|
|
4
|
+
Detect whether a terminal (stdout/stderr), browser or edge supports (next.js) ansi colors.
|
|
5
5
|
</p>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
@@ -42,7 +42,7 @@ pnpm add @visulima/is-ansi-color-supported
|
|
|
42
42
|
## Usage
|
|
43
43
|
|
|
44
44
|
```typescript
|
|
45
|
-
import {
|
|
45
|
+
import { isStdoutColorSupported, isStderrColorSupported } from "@visulima/is-ansi-color-supported";
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Levels:
|
|
@@ -51,7 +51,9 @@ import { isColorSupported } from "@visulima/is-ansi-color-supported";
|
|
|
51
51
|
* - `2` - ANSI 256 colors support.
|
|
52
52
|
* - `3` - Truecolor 16 million colors support.
|
|
53
53
|
*/
|
|
54
|
-
console.log(
|
|
54
|
+
console.log(isStdoutColorSupported()); // 3
|
|
55
|
+
|
|
56
|
+
console.log(isStderrColorSupported()); // 3
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
## Environment variables
|
|
@@ -74,9 +76,9 @@ For example, an executable script _colors.js_:
|
|
|
74
76
|
|
|
75
77
|
```js
|
|
76
78
|
#!/usr/bin/env node
|
|
77
|
-
import {
|
|
79
|
+
import { isStdoutColorSupported } from "@visulima/is-ansi-color-supported";
|
|
78
80
|
|
|
79
|
-
console.log(
|
|
81
|
+
console.log(isStdoutColorSupported());
|
|
80
82
|
```
|
|
81
83
|
|
|
82
84
|
Execute the script in a terminal:
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var r=()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData&&navigator.userAgentData.brands.find(({b:o})=>o==="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})(),n=r,p=r;
|
|
4
4
|
|
|
5
|
-
exports.
|
|
5
|
+
exports.isStderrColorSupported = p;
|
|
6
|
+
exports.isStdoutColorSupported = n;
|
|
6
7
|
//# sourceMappingURL=out.js.map
|
|
7
8
|
//# sourceMappingURL=is-color-supported.browser.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-color-supported.browser.ts"],"names":["isColorSupported","b"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/is-color-supported.browser.ts"],"names":["isColorSupported","b","isStdoutColorSupported","isStderrColorSupported"],"mappings":"AAMA,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,MACD,QAAQ,IAAI,cAAmB,IAAI,SAAS,MAAM,EAElD,EAGf,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 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 3;\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (/\\b(Chrome|Chromium)\\//.test(navigator.userAgent)) {\n return 1;\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 ? 1 : 0;\n }\n\n return 0;\n })();\n\nexport const isStdoutColorSupported = isColorSupported;\n\nexport const isStderrColorSupported = isColorSupported;\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { ColorSupportLevel } from \"./types\";\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { C as ColorSupportLevel } from './types-tBMJqxWx.cjs';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
3
|
+
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
4
|
+
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
4
5
|
|
|
5
|
-
export { ColorSupportLevel,
|
|
6
|
+
export { ColorSupportLevel, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { C as ColorSupportLevel } from './types-tBMJqxWx.js';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
3
|
+
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
4
|
+
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
4
5
|
|
|
5
|
-
export { ColorSupportLevel,
|
|
6
|
+
export { ColorSupportLevel, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
1
|
+
var r=()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData&&navigator.userAgentData.brands.find(({b:o})=>o==="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})(),p=r,s=r;
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { s as isStderrColorSupported, p as isStdoutColorSupported };
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=is-color-supported.browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-color-supported.browser.ts"],"names":["isColorSupported","b"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/is-color-supported.browser.ts"],"names":["isColorSupported","b","isStdoutColorSupported","isStderrColorSupported"],"mappings":"AAMA,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,MACD,QAAQ,IAAI,cAAmB,IAAI,SAAS,MAAM,EAElD,EAGf,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 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 3;\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (/\\b(Chrome|Chromium)\\//.test(navigator.userAgent)) {\n return 1;\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 ? 1 : 0;\n }\n\n return 0;\n })();\n\nexport const isStdoutColorSupported = isColorSupported;\n\nexport const isStderrColorSupported = isColorSupported;\n\n// eslint-disable-next-line import/no-unused-modules\nexport type { ColorSupportLevel } from \"./types\";\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var O=s=>{let t=globalThis,l=t.Deno!=null,o=t.process??t.Deno??{},f=o.argv??o.args??[],c=e=>{let T=f.indexOf("--"),C=f.findIndex(d=>e.test(d));return C!==-1&&(T===-1||C<T)},r={};try{r=l?o.env.toObject():o.env??{};}catch{}let a="FORCE_COLOR",E=a in r,n=r[a]?String(r[a]):void 0,R=Object.prototype.toString.call(n).slice(8,-1)==="String",i=0;if(n==="true"?i=1:n==="false"?i=0:R&&n.length===0?i=1:R&&n.length>0&&(i=Math.min(Number.parseInt(n,10),3)),"NO_COLOR"in r||E&&i===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 p=i||0;if("TF_BUILD"in r&&"AGENT_NAME"in r)return 1;if(r.TERM==="dumb")return p;if((l?t.Deno.build.os:o.platform)==="win32")try{let e=(l?t.Deno.osRelease():o.os.release()).split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[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(e=>e in r)||r.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in r)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor"||r.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in r){let e=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return e>=3?3:2;if(r.TERM_PROGRAM==="Apple_Terminal")return 2}if(/-256(color)?$/i.test(r.TERM))return 2;let u=!1;return l?s==="out"?u=t.Deno.stdout.isTerminal():s==="err"&&(u=t.Deno.stderr.isTerminal()):u=o["std"+s]&&"isTTY"in o["std"+s],u&&/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:p},_=()=>O("out"),L=()=>O("err");
|
|
4
4
|
|
|
5
|
-
exports.
|
|
5
|
+
exports.isStderrColorSupported = L;
|
|
6
|
+
exports.isStdoutColorSupported = _;
|
|
6
7
|
//# sourceMappingURL=out.js.map
|
|
7
8
|
//# sourceMappingURL=is-color-supported.server.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-color-supported.server.ts"],"names":["isColorSupported","mockThis","_this","isDeno","proc","argv","oneOfFlags","regex","terminatorPosition","position","flag","environment","FORCE_COLOR","hasForceColor","forceColorValue","forceColorValueIsString","forceColor","minColorLevel","osRelease","sign","version"],"mappings":"AAUO,IAAMA,EAAoBC,GAAsC,CAEnE,IAAMC,EAAQD,GAAY,WAEpBE,EAASD,EAAM,MAAQ,KAEvBE,EAA4BF,EAAM,SAAWA,EAAM,MAAQ,CAAC,EAE5DG,EAAkBD,EAAK,MAAWA,EAAK,MAAW,CAAC,EAQnDE,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,IAAO,SAAS,EAAIA,EAAK,KAAU,CAAC,CACpE,MAAQ,CAER,CAEA,IAAMQ,EAAc,cACdC,EAAgBD,KAAeD,EAE/BG,EAAkBH,EAAYC,CAAW,EAAI,OAAOD,EAAYC,CAAW,CAAC,EAAI,OAChFG,EAA0B,OAAO,UAAU,SAAS,KAAKD,CAAe,EAAE,MAAM,EAAG,EAAE,IAAM,SAE7FE,EAAgC,EAgBpC,GAdIF,IAAoB,OACpBE,EAAa,EACNF,IAAoB,QAC3BE,EAAa,EACND,GAA4BD,EAA2B,SAAW,EACzEE,EAAa,EACND,GAA4BD,EAA2B,OAAS,IACvEE,EAAa,KAAK,IAAI,OAAO,SAASF,EAA2B,EAAE,EAAG,CAAC,GAKvE,aAAcH,GAAgBE,GAAiBG,IAAe,GAAMV,EAAW,sDAAsD,EAGrI,MAAO,GAIX,GAAIA,EAAW,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aO,EAAY,IAAO,GAIvG,cAAeA,EACR,EAGJM,CACX","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 {Object?} mockThis The mock object of globalThis, used by unit test only.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity,@typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nexport const isColorSupported = (mockThis?: any): ColorSupportLevel => {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const _this = mockThis ?? globalThis;\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-unsafe-member-access,@typescript-eslint/no-explicit-any\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n const isTTY = isDeno ? _this.Deno.isatty(1) : proc[\"stdout\"] && \"isTTY\" in proc[\"stdout\"];\n\n if (isTTY && /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|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\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":"AAUA,IAAMA,EAA2BC,GAA8C,CAE3E,IAAMC,EAAQ,WAERC,EAASD,EAAM,MAAQ,KAEvBE,EAA4BF,EAAM,SAAWA,EAAM,MAAQ,CAAC,EAE5DG,EAAkBD,EAAK,MAAWA,EAAK,MAAW,CAAC,EAQnDE,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,IAAO,SAAS,EAAIA,EAAK,KAAU,CAAC,CACpE,MAAQ,CAER,CAEA,IAAMQ,EAAc,cACdC,EAAgBD,KAAeD,EAE/BG,EAAkBH,EAAYC,CAAW,EAAI,OAAOD,EAAYC,CAAW,CAAC,EAAI,OAChFG,EAA0B,OAAO,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,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,5 +1,6 @@
|
|
|
1
1
|
import { C as ColorSupportLevel } from './types-tBMJqxWx.cjs';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
3
|
+
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
4
|
+
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
4
5
|
|
|
5
|
-
export { ColorSupportLevel,
|
|
6
|
+
export { ColorSupportLevel, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { C as ColorSupportLevel } from './types-tBMJqxWx.js';
|
|
2
2
|
|
|
3
|
-
declare const
|
|
3
|
+
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
4
|
+
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
4
5
|
|
|
5
|
-
export { ColorSupportLevel,
|
|
6
|
+
export { ColorSupportLevel, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O=s=>{let t=globalThis,l=t.Deno!=null,o=t.process??t.Deno??{},f=o.argv??o.args??[],c=e=>{let T=f.indexOf("--"),C=f.findIndex(d=>e.test(d));return C!==-1&&(T===-1||C<T)},r={};try{r=l?o.env.toObject():o.env??{};}catch{}let a="FORCE_COLOR",E=a in r,n=r[a]?String(r[a]):void 0,R=Object.prototype.toString.call(n).slice(8,-1)==="String",i=0;if(n==="true"?i=1:n==="false"?i=0:R&&n.length===0?i=1:R&&n.length>0&&(i=Math.min(Number.parseInt(n,10),3)),"NO_COLOR"in r||E&&i===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 p=i||0;if("TF_BUILD"in r&&"AGENT_NAME"in r)return 1;if(r.TERM==="dumb")return p;if((l?t.Deno.build.os:o.platform)==="win32")try{let e=(l?t.Deno.osRelease():o.os.release()).split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[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(e=>e in r)||r.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in r)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor"||r.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in r){let e=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return e>=3?3:2;if(r.TERM_PROGRAM==="Apple_Terminal")return 2}if(/-256(color)?$/i.test(r.TERM))return 2;let u=!1;return l?s==="out"?u=t.Deno.stdout.isTerminal():s==="err"&&(u=t.Deno.stderr.isTerminal()):u=o["std"+s]&&"isTTY"in o["std"+s],u&&/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:p},L=()=>O("out"),M=()=>O("err");
|
|
2
2
|
|
|
3
|
-
export { M as
|
|
3
|
+
export { M as isStderrColorSupported, L as isStdoutColorSupported };
|
|
4
4
|
//# sourceMappingURL=out.js.map
|
|
5
5
|
//# sourceMappingURL=is-color-supported.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/is-color-supported.server.ts"],"names":["isColorSupported","mockThis","_this","isDeno","proc","argv","oneOfFlags","regex","terminatorPosition","position","flag","environment","FORCE_COLOR","hasForceColor","forceColorValue","forceColorValueIsString","forceColor","minColorLevel","osRelease","sign","version"],"m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E,EAAK,YAAiB,QACtD,GAAI,CAMA,IAAMc,GAAaf,EAASD,EAAM,KAAK,UAAU,EAAIE,EAAK,GAAM,QAAQ,GAAG,MAAM,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,MAAI,iBAAiB,KAAaA,EAAY,IAAO,EAC1C,GAIGR,EAASD,EAAM,KAAK,OAAO,CAAC,EAAIE,EAAK,QAAa,UAAWA,EAAK,SAEnE,8DAA8D,KAAaO,EAAY,IAAO,GAIvG,cAAeA,EACR,EAGJM,CACX","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 {Object?} mockThis The mock object of globalThis, used by unit test only.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity,@typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\nexport const isColorSupported = (mockThis?: any): ColorSupportLevel => {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const _this = mockThis ?? globalThis;\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-unsafe-member-access,@typescript-eslint/no-explicit-any\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access\n const isTTY = isDeno ? _this.Deno.isatty(1) : proc[\"stdout\"] && \"isTTY\" in proc[\"stdout\"];\n\n if (isTTY && /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|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\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":"AAUA,IAAMA,EAA2BC,GAA8C,CAE3E,IAAMC,EAAQ,WAERC,EAASD,EAAM,MAAQ,KAEvBE,EAA4BF,EAAM,SAAWA,EAAM,MAAQ,CAAC,EAE5DG,EAAkBD,EAAK,MAAWA,EAAK,MAAW,CAAC,EAQnDE,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,IAAO,SAAS,EAAIA,EAAK,KAAU,CAAC,CACpE,MAAQ,CAER,CAEA,IAAMQ,EAAc,cACdC,EAAgBD,KAAeD,EAE/BG,EAAkBH,EAAYC,CAAW,EAAI,OAAOD,EAAYC,CAAW,CAAC,EAAI,OAChFG,EAA0B,OAAO,UAAU,SAAS,KAAKD,CAAe,EAAE,MAAM,EAAG,EAAE,IAAM,SAE7FE,EAAgC,EAgBpC,GAdIF,IAAoB,OACpBE,EAAa,EACNF,IAAoB,QAC3BE,EAAa,EACND,GAA4BD,EAA2B,SAAW,EACzEE,EAAa,EACND,GAA4BD,EAA2B,OAAS,IACvEE,EAAa,KAAK,IAAI,OAAO,SAASF,EAA2B,EAAE,EAAG,CAAC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D,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/is-ansi-color-supported",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Detect whether a terminal or browser supports ansi colors.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -100,28 +100,28 @@
|
|
|
100
100
|
"@anolilab/prettier-config": "^5.0.14",
|
|
101
101
|
"@anolilab/semantic-release-preset": "^8.0.3",
|
|
102
102
|
"@babel/core": "^7.23.9",
|
|
103
|
-
"@rushstack/eslint-plugin-security": "^0.8.
|
|
104
|
-
"@secretlint/secretlint-rule-preset-recommend": "^8.1.
|
|
103
|
+
"@rushstack/eslint-plugin-security": "^0.8.1",
|
|
104
|
+
"@secretlint/secretlint-rule-preset-recommend": "^8.1.2",
|
|
105
105
|
"@types/micromatch": "^4.0.6",
|
|
106
|
-
"@types/node": "18.18.
|
|
107
|
-
"@vitest/coverage-v8": "^1.
|
|
108
|
-
"@vitest/ui": "^1.
|
|
106
|
+
"@types/node": "18.18.14",
|
|
107
|
+
"@vitest/coverage-v8": "^1.3.1",
|
|
108
|
+
"@vitest/ui": "^1.3.1",
|
|
109
109
|
"cross-env": "^7.0.3",
|
|
110
|
-
"eslint": "^8.
|
|
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.3.
|
|
115
|
+
"eslint-plugin-vitest": "^0.3.22",
|
|
116
116
|
"eslint-plugin-vitest-globals": "^1.4.0",
|
|
117
|
-
"prettier": "^3.2.
|
|
117
|
+
"prettier": "^3.2.5",
|
|
118
118
|
"rimraf": "^5.0.5",
|
|
119
|
-
"secretlint": "8.1.
|
|
120
|
-
"semantic-release": "^23.0.
|
|
121
|
-
"sort-package-json": "^2.
|
|
122
|
-
"tsup": "^8.0.
|
|
119
|
+
"secretlint": "8.1.2",
|
|
120
|
+
"semantic-release": "^23.0.2",
|
|
121
|
+
"sort-package-json": "^2.8.0",
|
|
122
|
+
"tsup": "^8.0.2",
|
|
123
123
|
"typescript": "^5.3.3",
|
|
124
|
-
"vitest": "^1.
|
|
124
|
+
"vitest": "^1.3.1"
|
|
125
125
|
},
|
|
126
126
|
"engines": {
|
|
127
127
|
"node": ">=18.* <=21.*"
|