@visulima/is-ansi-color-supported 3.0.0-alpha.11 → 3.0.0-alpha.13
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 +22 -0
- package/README.md +34 -3
- package/dist/is-color-supported.browser.cjs +1 -1
- package/dist/is-color-supported.browser.d.cts +30 -1
- package/dist/is-color-supported.browser.d.mts +30 -1
- package/dist/is-color-supported.browser.d.ts +30 -1
- package/dist/is-color-supported.browser.mjs +1 -1
- package/dist/is-color-supported.edge-light.cjs +1 -1
- package/dist/is-color-supported.edge-light.d.cts +30 -1
- package/dist/is-color-supported.edge-light.d.mts +30 -1
- package/dist/is-color-supported.edge-light.d.ts +30 -1
- package/dist/is-color-supported.edge-light.mjs +1 -1
- package/dist/is-color-supported.server.cjs +1 -1
- package/dist/is-color-supported.server.d.cts +52 -1
- package/dist/is-color-supported.server.d.mts +52 -1
- package/dist/is-color-supported.server.d.ts +52 -1
- package/dist/is-color-supported.server.mjs +1 -1
- package/package.json +11 -16
- /package/dist/packem_shared/{SPACE_MONO-BEQbKWNs.mjs → SPACE_16_COLORS-BEQbKWNs.mjs} +0 -0
- /package/dist/packem_shared/{SPACE_MONO-CIFY-d7-.cjs → SPACE_16_COLORS-CIFY-d7-.cjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.13](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.12...@visulima/is-ansi-color-supported@3.0.0-alpha.13) (2026-06-13)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **is-ansi-color-supported:** correct release method property type ([a7b940c](https://github.com/visulima/visulima/commit/a7b940c78590c65ea141d5be671383695e85c44e))
|
|
6
|
+
* **is-ansi-color-supported:** lazily resolve os.release to avoid bundler getBuiltinModule shim crash ([8c551ad](https://github.com/visulima/visulima/commit/8c551ada86b1164b143faf144602bb5602e6a784))
|
|
7
|
+
* **is-ansi-color-supported:** repair windows detection and add createIsColorSupported ([b6a4706](https://github.com/visulima/visulima/commit/b6a470628045a895ecafdca004de7f374e9ee07b))
|
|
8
|
+
|
|
9
|
+
### Build System
|
|
10
|
+
|
|
11
|
+
* regenerate bundled-license manifests and types ordering ([af26588](https://github.com/visulima/visulima/commit/af26588d75aaa937fd4862800560bd4070a4878c))
|
|
12
|
+
|
|
13
|
+
## @visulima/is-ansi-color-supported [3.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.11...@visulima/is-ansi-color-supported@3.0.0-alpha.12) (2026-06-04)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **is-ansi-color-supported:** 2 bug fixes ([0e1fd0c](https://github.com/visulima/visulima/commit/0e1fd0cba80160781b8136d44506afd7f3219dd8))
|
|
18
|
+
|
|
19
|
+
### Tests
|
|
20
|
+
|
|
21
|
+
* **is-ansi-color-supported:** cover edge-light runtime, browser userAgentData, and server ci/term paths ([8633292](https://github.com/visulima/visulima/commit/863329255aaa41530e741808b197bebd8f63b70d))
|
|
22
|
+
|
|
1
23
|
## @visulima/is-ansi-color-supported [3.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/is-ansi-color-supported@3.0.0-alpha.10...@visulima/is-ansi-color-supported@3.0.0-alpha.11) (2026-05-27)
|
|
2
24
|
|
|
3
25
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -65,9 +65,29 @@ console.log(isStdoutColorSupported()); // 3
|
|
|
65
65
|
console.log(isStderrColorSupported()); // 3
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
### Custom detection (`createIsColorSupported`)
|
|
69
|
+
|
|
70
|
+
For library authors who need more control, `createIsColorSupported` lets you pick the
|
|
71
|
+
stream, disable CLI flag sniffing, or force the TTY state:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { createIsColorSupported } from "@visulima/is-ansi-color-supported";
|
|
75
|
+
|
|
76
|
+
// Detect stdout color support without inspecting `process.argv`
|
|
77
|
+
// (useful when your CLI defines its own `--color` semantics):
|
|
78
|
+
const level = createIsColorSupported("stdout", { sniffFlags: false });
|
|
79
|
+
|
|
80
|
+
// Probe stderr while forcing the TTY state (e.g. when writing to a log file):
|
|
81
|
+
const stderrLevel = createIsColorSupported("stderr", { isTTY: false });
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> The `browser` and `edge-light` builds also export `createIsColorSupported` for API
|
|
85
|
+
> parity, but ignore the `stream`/`options` arguments (those runtimes have no streams,
|
|
86
|
+
> CLI args, `tty`, or `os`).
|
|
87
|
+
|
|
68
88
|
## Color support
|
|
69
89
|
|
|
70
|
-
|
|
90
|
+
This package automatically detects the supported color space:
|
|
71
91
|
|
|
72
92
|
- TrueColor
|
|
73
93
|
- ANSI 256 colors
|
|
@@ -114,8 +134,13 @@ The value is not important, e.g., `NO_COLOR=1` `NO_COLOR=true` disable colors.
|
|
|
114
134
|
See standard description by [NO_COLOR](https://no-color.org/).
|
|
115
135
|
|
|
116
136
|
The `FORCE_COLOR` variable should be presents with one of values:\
|
|
117
|
-
`FORCE_COLOR=0` force disable colors\
|
|
118
|
-
`FORCE_COLOR=1` force enable colors
|
|
137
|
+
`FORCE_COLOR=0` (or `FORCE_COLOR=false`) force disable colors\
|
|
138
|
+
`FORCE_COLOR=1`, `2`, `3` (or `FORCE_COLOR=true`) force enable colors at the given level
|
|
139
|
+
|
|
140
|
+
When `FORCE_COLOR` requests color (any value other than `0`/`false`) it takes precedence over the
|
|
141
|
+
`NO_COLOR` environment variable, so `FORCE_COLOR=true NO_COLOR=1` and `FORCE_COLOR=1 NO_COLOR=1` both
|
|
142
|
+
enable colors. The `--no-color` CLI flag still wins over everything, since command-line arguments have
|
|
143
|
+
the highest priority.
|
|
119
144
|
|
|
120
145
|
## CLI arguments
|
|
121
146
|
|
|
@@ -146,6 +171,12 @@ $ ./colors.js --color=true > log.txt # output in file with ANSI codes
|
|
|
146
171
|
>
|
|
147
172
|
> The command line arguments have a higher priority than environment variable.
|
|
148
173
|
|
|
174
|
+
> **Note**
|
|
175
|
+
>
|
|
176
|
+
> A 256-color `TERM` (e.g. `TERM=xterm-256color`) reports level `2` even when the output is piped
|
|
177
|
+
> to a file and not a TTY. This is intentional (ansis-style behaviour). If you need supports-color's
|
|
178
|
+
> stricter TTY-first gating, use `createIsColorSupported("stdout", { isTTY: false })`.
|
|
179
|
+
|
|
149
180
|
## Info
|
|
150
181
|
|
|
151
182
|
For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./packem_shared/SPACE_16_COLORS-CIFY-d7-.cjs"),S=/\b(Chrome|Chromium)\//,t=()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData){const e=navigator.userAgentData.brands.find(o=>o.brand==="Chromium");if(Number(e?.version)>93)return r.SPACE_TRUE_COLORS}if(S.test(navigator.userAgent))return r.SPACE_16_COLORS}return r.SPACE_MONO})(),C=t,u=t,O=(e,o)=>t();exports.SPACE_16_COLORS=r.SPACE_16_COLORS;exports.SPACE_256_COLORS=r.SPACE_256_COLORS;exports.SPACE_MONO=r.SPACE_MONO;exports.SPACE_TRUE_COLORS=r.SPACE_TRUE_COLORS;exports.createIsColorSupported=O;exports.isStderrColorSupported=u;exports.isStdoutColorSupported=C;
|
|
@@ -6,10 +6,39 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
13
34
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
14
35
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Browser equivalent of the server `createIsColorSupported`.
|
|
38
|
+
*
|
|
39
|
+
* The browser runtime cannot inspect a process' streams or CLI flags, so the
|
|
40
|
+
* `stream` argument and options are accepted for API parity but ignored.
|
|
41
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
42
|
+
*/
|
|
43
|
+
declare const createIsColorSupported: (_stream?: "stderr" | "stdout", _options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
44
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -6,10 +6,39 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
13
34
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
14
35
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Browser equivalent of the server `createIsColorSupported`.
|
|
38
|
+
*
|
|
39
|
+
* The browser runtime cannot inspect a process' streams or CLI flags, so the
|
|
40
|
+
* `stream` argument and options are accepted for API parity but ignored.
|
|
41
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
42
|
+
*/
|
|
43
|
+
declare const createIsColorSupported: (_stream?: "stderr" | "stdout", _options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
44
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -6,10 +6,39 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
13
34
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
14
35
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Browser equivalent of the server `createIsColorSupported`.
|
|
38
|
+
*
|
|
39
|
+
* The browser runtime cannot inspect a process' streams or CLI flags, so the
|
|
40
|
+
* `stream` argument and options are accepted for API parity but ignored.
|
|
41
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
42
|
+
*/
|
|
43
|
+
declare const createIsColorSupported: (_stream?: "stderr" | "stdout", _options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
44
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{SPACE_TRUE_COLORS as e,SPACE_16_COLORS as n,SPACE_MONO as a}from"./packem_shared/SPACE_16_COLORS-BEQbKWNs.mjs";import{SPACE_256_COLORS as d}from"./packem_shared/SPACE_16_COLORS-BEQbKWNs.mjs";const i=/\b(Chrome|Chromium)\//,r=()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData){const t=navigator.userAgentData.brands.find(o=>o.brand==="Chromium");if(Number(t?.version)>93)return e}if(i.test(navigator.userAgent))return n}return a})(),C=r,s=r,S=(t,o)=>r();export{n as SPACE_16_COLORS,d as SPACE_256_COLORS,a as SPACE_MONO,e as SPACE_TRUE_COLORS,S as createIsColorSupported,s as isStderrColorSupported,C as isStdoutColorSupported};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./packem_shared/SPACE_16_COLORS-CIFY-d7-.cjs"),S=/\b(Chrome|Chromium)\//,C=()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData){const e=navigator.userAgentData.brands.find(t=>t.brand==="Chromium");if(Number(e?.version)>93)return r.SPACE_TRUE_COLORS}if(S.test(navigator.userAgent))return r.SPACE_16_COLORS}return r.SPACE_MONO})(),u=C,o=()=>process.env.NEXT_RUNTIME?.includes("edge")?r.SPACE_16_COLORS:u(),O=o,s=o,_=(e,t)=>o();exports.SPACE_16_COLORS=r.SPACE_16_COLORS;exports.SPACE_256_COLORS=r.SPACE_256_COLORS;exports.SPACE_MONO=r.SPACE_MONO;exports.SPACE_TRUE_COLORS=r.SPACE_TRUE_COLORS;exports.createIsColorSupported=_;exports.isStderrColorSupported=s;exports.isStdoutColorSupported=O;
|
|
@@ -6,10 +6,39 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
13
34
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
14
35
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Edge-runtime equivalent of the server `createIsColorSupported`.
|
|
38
|
+
*
|
|
39
|
+
* The edge runtime has no `tty`/`os`, so the `stream` argument and options are
|
|
40
|
+
* accepted for API parity but ignored.
|
|
41
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
42
|
+
*/
|
|
43
|
+
declare const createIsColorSupported: (_stream?: "stderr" | "stdout", _options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
44
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -6,10 +6,39 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
13
34
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
14
35
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Edge-runtime equivalent of the server `createIsColorSupported`.
|
|
38
|
+
*
|
|
39
|
+
* The edge runtime has no `tty`/`os`, so the `stream` argument and options are
|
|
40
|
+
* accepted for API parity but ignored.
|
|
41
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
42
|
+
*/
|
|
43
|
+
declare const createIsColorSupported: (_stream?: "stderr" | "stdout", _options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
44
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -6,10 +6,39 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
13
34
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
14
35
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Edge-runtime equivalent of the server `createIsColorSupported`.
|
|
38
|
+
*
|
|
39
|
+
* The edge runtime has no `tty`/`os`, so the `stream` argument and options are
|
|
40
|
+
* accepted for API parity but ignored.
|
|
41
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
42
|
+
*/
|
|
43
|
+
declare const createIsColorSupported: (_stream?: "stderr" | "stdout", _options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
44
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{SPACE_TRUE_COLORS as n,SPACE_16_COLORS as e,SPACE_MONO as s}from"./packem_shared/SPACE_16_COLORS-BEQbKWNs.mjs";import{SPACE_256_COLORS as f}from"./packem_shared/SPACE_16_COLORS-BEQbKWNs.mjs";const i=/\b(Chrome|Chromium)\//,u=()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData){const o=navigator.userAgentData.brands.find(t=>t.brand==="Chromium");if(Number(o?.version)>93)return n}if(i.test(navigator.userAgent))return e}return s})(),a=u,r=()=>process.env.NEXT_RUNTIME?.includes("edge")?e:a(),C=r,S=r,d=(o,t)=>r();export{e as SPACE_16_COLORS,f as SPACE_256_COLORS,s as SPACE_MONO,n as SPACE_TRUE_COLORS,d as createIsColorSupported,S as isStderrColorSupported,C as isStdoutColorSupported};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./packem_shared/SPACE_16_COLORS-CIFY-d7-.cjs"),m=/^-{1,2}(no-color|no-colors|color=false|color=never)$/,p=/^-{1,2}(color=256)$/,I=/^-{1,2}(color=16m|color=full|color=truecolor)$/,U=/^-{1,2}(color|colors|color=true|color=always)$/,b=/-mono|dumb/i,v=/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/,g=/-256(color)?$/i,y=/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i,h=()=>{const _=globalThis.process?.getBuiltinModule;return typeof _!="function"?"":_("node:os").release()},l=(_,s={})=>{const{isTTY:A,sniffFlags:T=!0}=s,n=globalThis,E=n.Deno!=null,i=n.process??n.Deno??{},c=i.argv??i.args??[],P=T?c.indexOf("--"):-1,R=t=>{if(!T)return!1;const S=c.findIndex(N=>t.test(N));return S!==-1&&(P===-1||S<P)};let r={};try{r=E?i.env.toObject():i.env??{}}catch{}const f="FORCE_COLOR",L=f in r,O=r[f]??void 0,d=typeof O=="string",M=typeof O=="number";let o;if(O==="true")o=e.SPACE_16_COLORS;else if(O==="false")o=e.SPACE_MONO;else if(d&&O.length===0)o=e.SPACE_16_COLORS;else if(d&&O.length>0){const t=Number.parseInt(O,10);o=Number.isNaN(t)?void 0:Math.min(t,3)}else M&&(o=Number.isNaN(O)?void 0:Math.min(O,3));if(O!=="true"&&O!=="false"&&o!==void 0&&o<4)return o;const a=L&&o!==void 0&&o>0;if(L&&o===0||R(m)||!a&&"NO_COLOR"in r)return e.SPACE_MONO;if(R(p))return e.SPACE_256_COLORS;if(R(I))return e.SPACE_TRUE_COLORS;if(R(U))return e.SPACE_16_COLORS;const u=o??e.SPACE_MONO;if("TF_BUILD"in r&&"AGENT_NAME"in r)return e.SPACE_16_COLORS;if(r.TERM&&b.test(r.TERM))return u;if((E?n.Deno.build.os:i.platform)==="win32"){if("WT_SESSION"in r)return e.SPACE_TRUE_COLORS;if("ANSICON"in r)return e.SPACE_16_COLORS;try{let t;E?t=n.Deno.osRelease():typeof i.os?.release=="function"?t=i.os.release():t=h();const S=t.split(".");return Number(S[0])>=10&&Number(S[2])>=10586?Number(S[2])>=14931?e.SPACE_TRUE_COLORS:e.SPACE_256_COLORS:e.SPACE_16_COLORS}catch{}}if("CI"in r)return["GITEA_ACTIONS","CIRCLECI","GITHUB_WORKFLOW","GITHUB_ACTIONS"].some(t=>t in r)?e.SPACE_TRUE_COLORS:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(t=>t in r)||r.CI_NAME==="codeship"?e.SPACE_16_COLORS:u;if(r.TERMINAL_EMULATOR?.includes("JediTerm"))return e.SPACE_TRUE_COLORS;if("TEAMCITY_VERSION"in r)return v.test(r.TEAMCITY_VERSION)?e.SPACE_16_COLORS:e.SPACE_MONO;if(r.COLORTERM==="truecolor"||r.TERM==="xterm-kitty"||r.TERM==="xterm-ghostty"||r.TERM==="wezterm")return e.SPACE_TRUE_COLORS;if("TERM_PROGRAM"in r){const t=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return t>=3?e.SPACE_TRUE_COLORS:e.SPACE_256_COLORS;if(r.TERM_PROGRAM==="Apple_Terminal")return e.SPACE_256_COLORS}if(g.test(r.TERM))return e.SPACE_256_COLORS;let C;return A!==void 0?C=A:E?C=_==="out"?n.Deno.stdout.isTerminal():n.Deno.stderr.isTerminal():"PM2_HOME"in r&&"pm_id"in r?C=!0:C=!!i[`std${_}`]?.isTTY,C&&y.test(r.TERM)||"COLORTERM"in r?e.SPACE_16_COLORS:u},D=()=>l("out"),G=()=>l("err"),x=(_="stdout",s={})=>l(_==="stderr"?"err":"out",s);exports.SPACE_16_COLORS=e.SPACE_16_COLORS;exports.SPACE_256_COLORS=e.SPACE_256_COLORS;exports.SPACE_MONO=e.SPACE_MONO;exports.SPACE_TRUE_COLORS=e.SPACE_TRUE_COLORS;exports.createIsColorSupported=x;exports.isStderrColorSupported=G;exports.isStdoutColorSupported=D;
|
|
@@ -6,10 +6,61 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
34
|
+
/**
|
|
35
|
+
* Detect the ANSI color-support level of the current process' **stdout** stream.
|
|
36
|
+
*
|
|
37
|
+
* Honors `FORCE_COLOR`/`NO_COLOR`, `--color`/`--no-color`/`--color=256`/`--color=16m` CLI flags,
|
|
38
|
+
* CI providers, `TERM`/`COLORTERM`, terminal emulators and Windows build numbers.
|
|
39
|
+
* @returns The detected {@link ColorSupportLevel} (`0` none, `1` 16-color, `2` 256-color, `3` truecolor).
|
|
40
|
+
*/
|
|
13
41
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
42
|
+
/**
|
|
43
|
+
* Detect the ANSI color-support level of the current process' **stderr** stream.
|
|
44
|
+
*
|
|
45
|
+
* Useful because stdout and stderr can have different TTY capabilities (e.g. `node app > out.txt`).
|
|
46
|
+
* @returns The detected {@link ColorSupportLevel} (`0` none, `1` 16-color, `2` 256-color, `3` truecolor).
|
|
47
|
+
*/
|
|
14
48
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Create a color-support detector for a specific standard stream with custom options.
|
|
51
|
+
*
|
|
52
|
+
* This is the configurable equivalent of {@link isStdoutColorSupported} /
|
|
53
|
+
* {@link isStderrColorSupported}. It lets library consumers disable CLI flag sniffing
|
|
54
|
+
* (`sniffFlags: false`) when their CLI defines its own `--color` semantics, or force the
|
|
55
|
+
* TTY state (`isTTY`) when probing for a non-standard sink such as a log file.
|
|
56
|
+
* @param stream Which standard stream to probe: `"stdout"` (default) or `"stderr"`.
|
|
57
|
+
* @param options Detection options.
|
|
58
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Detect stdout color support without inspecting `process.argv`:
|
|
62
|
+
* const level = createIsColorSupported("stdout", { sniffFlags: false });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare const createIsColorSupported: (stream?: "stderr" | "stdout", options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
66
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -6,10 +6,61 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
34
|
+
/**
|
|
35
|
+
* Detect the ANSI color-support level of the current process' **stdout** stream.
|
|
36
|
+
*
|
|
37
|
+
* Honors `FORCE_COLOR`/`NO_COLOR`, `--color`/`--no-color`/`--color=256`/`--color=16m` CLI flags,
|
|
38
|
+
* CI providers, `TERM`/`COLORTERM`, terminal emulators and Windows build numbers.
|
|
39
|
+
* @returns The detected {@link ColorSupportLevel} (`0` none, `1` 16-color, `2` 256-color, `3` truecolor).
|
|
40
|
+
*/
|
|
13
41
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
42
|
+
/**
|
|
43
|
+
* Detect the ANSI color-support level of the current process' **stderr** stream.
|
|
44
|
+
*
|
|
45
|
+
* Useful because stdout and stderr can have different TTY capabilities (e.g. `node app > out.txt`).
|
|
46
|
+
* @returns The detected {@link ColorSupportLevel} (`0` none, `1` 16-color, `2` 256-color, `3` truecolor).
|
|
47
|
+
*/
|
|
14
48
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Create a color-support detector for a specific standard stream with custom options.
|
|
51
|
+
*
|
|
52
|
+
* This is the configurable equivalent of {@link isStdoutColorSupported} /
|
|
53
|
+
* {@link isStderrColorSupported}. It lets library consumers disable CLI flag sniffing
|
|
54
|
+
* (`sniffFlags: false`) when their CLI defines its own `--color` semantics, or force the
|
|
55
|
+
* TTY state (`isTTY`) when probing for a non-standard sink such as a log file.
|
|
56
|
+
* @param stream Which standard stream to probe: `"stdout"` (default) or `"stderr"`.
|
|
57
|
+
* @param options Detection options.
|
|
58
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Detect stdout color support without inspecting `process.argv`:
|
|
62
|
+
* const level = createIsColorSupported("stdout", { sniffFlags: false });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare const createIsColorSupported: (stream?: "stderr" | "stdout", options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
66
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -6,10 +6,61 @@
|
|
|
6
6
|
* - `3` - Truecolor 16 million colors support.
|
|
7
7
|
*/
|
|
8
8
|
type ColorSupportLevel = 0 | 1 | 2 | 3;
|
|
9
|
+
/**
|
|
10
|
+
* Options for the configurable `createIsColorSupported` detector.
|
|
11
|
+
*/
|
|
12
|
+
interface CreateIsColorSupportedOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Force the TTY state instead of reading it from the resolved stream.
|
|
15
|
+
*
|
|
16
|
+
* Useful when probing color support for a non-standard sink (e.g. a log file)
|
|
17
|
+
* or when the runtime does not expose `isTTY`. When omitted, the stream's own
|
|
18
|
+
* `isTTY` (or Deno's `isTerminal()`) is used.
|
|
19
|
+
*/
|
|
20
|
+
isTTY?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to inspect `process.argv` for `--color`/`--no-color`-style flags.
|
|
23
|
+
*
|
|
24
|
+
* Set to `false` for library consumers whose CLIs define their own `--color`
|
|
25
|
+
* semantics, so the detector does not react to unrelated flags.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
sniffFlags?: boolean;
|
|
29
|
+
}
|
|
9
30
|
declare const SPACE_MONO = 0;
|
|
10
31
|
declare const SPACE_16_COLORS = 1;
|
|
11
32
|
declare const SPACE_256_COLORS = 2;
|
|
12
33
|
declare const SPACE_TRUE_COLORS = 3;
|
|
34
|
+
/**
|
|
35
|
+
* Detect the ANSI color-support level of the current process' **stdout** stream.
|
|
36
|
+
*
|
|
37
|
+
* Honors `FORCE_COLOR`/`NO_COLOR`, `--color`/`--no-color`/`--color=256`/`--color=16m` CLI flags,
|
|
38
|
+
* CI providers, `TERM`/`COLORTERM`, terminal emulators and Windows build numbers.
|
|
39
|
+
* @returns The detected {@link ColorSupportLevel} (`0` none, `1` 16-color, `2` 256-color, `3` truecolor).
|
|
40
|
+
*/
|
|
13
41
|
declare const isStdoutColorSupported: () => ColorSupportLevel;
|
|
42
|
+
/**
|
|
43
|
+
* Detect the ANSI color-support level of the current process' **stderr** stream.
|
|
44
|
+
*
|
|
45
|
+
* Useful because stdout and stderr can have different TTY capabilities (e.g. `node app > out.txt`).
|
|
46
|
+
* @returns The detected {@link ColorSupportLevel} (`0` none, `1` 16-color, `2` 256-color, `3` truecolor).
|
|
47
|
+
*/
|
|
14
48
|
declare const isStderrColorSupported: () => ColorSupportLevel;
|
|
15
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Create a color-support detector for a specific standard stream with custom options.
|
|
51
|
+
*
|
|
52
|
+
* This is the configurable equivalent of {@link isStdoutColorSupported} /
|
|
53
|
+
* {@link isStderrColorSupported}. It lets library consumers disable CLI flag sniffing
|
|
54
|
+
* (`sniffFlags: false`) when their CLI defines its own `--color` semantics, or force the
|
|
55
|
+
* TTY state (`isTTY`) when probing for a non-standard sink such as a log file.
|
|
56
|
+
* @param stream Which standard stream to probe: `"stdout"` (default) or `"stderr"`.
|
|
57
|
+
* @param options Detection options.
|
|
58
|
+
* @returns The detected {@link ColorSupportLevel}.
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Detect stdout color support without inspecting `process.argv`:
|
|
62
|
+
* const level = createIsColorSupported("stdout", { sniffFlags: false });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare const createIsColorSupported: (stream?: "stderr" | "stdout", options?: CreateIsColorSupportedOptions) => ColorSupportLevel;
|
|
66
|
+
export { type ColorSupportLevel, type CreateIsColorSupportedOptions, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, createIsColorSupported, isStderrColorSupported, isStdoutColorSupported };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{SPACE_MONO as O,SPACE_256_COLORS as T,SPACE_TRUE_COLORS as n,SPACE_16_COLORS as i}from"./packem_shared/SPACE_16_COLORS-BEQbKWNs.mjs";const v=/^-{1,2}(no-color|no-colors|color=false|color=never)$/,g=/^-{1,2}(color=256)$/,y=/^-{1,2}(color=16m|color=full|color=truecolor)$/,P=/^-{1,2}(color|colors|color=true|color=always)$/,h=/-mono|dumb/i,x=/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/,D=/-256(color)?$/i,G=/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i,B=()=>{const u=globalThis.process?.getBuiltinModule;return typeof u!="function"?"":u("node:os").release()},m=(u,d={})=>{const{isTTY:M,sniffFlags:_=!0}=d,l=globalThis,R=l.Deno!=null,s=l.process??l.Deno??{},I=s.argv??s.args??[],C=_?I.indexOf("--"):-1,E=r=>{if(!_)return!1;const f=I.findIndex(b=>r.test(b));return f!==-1&&(C===-1||f<C)};let e={};try{e=R?s.env.toObject():s.env??{}}catch{}const N="FORCE_COLOR",p=N in e,o=e[N]??void 0,A=typeof o=="string",S=typeof o=="number";let t;if(o==="true")t=i;else if(o==="false")t=O;else if(A&&o.length===0)t=i;else if(A&&o.length>0){const r=Number.parseInt(o,10);t=Number.isNaN(r)?void 0:Math.min(r,3)}else S&&(t=Number.isNaN(o)?void 0:Math.min(o,3));if(o!=="true"&&o!=="false"&&t!==void 0&&t<4)return t;const L=p&&t!==void 0&&t>0;if(p&&t===0||E(v)||!L&&"NO_COLOR"in e)return O;if(E(g))return T;if(E(y))return n;if(E(P))return i;const a=t??O;if("TF_BUILD"in e&&"AGENT_NAME"in e)return i;if(e.TERM&&h.test(e.TERM))return a;if((R?l.Deno.build.os:s.platform)==="win32"){if("WT_SESSION"in e)return n;if("ANSICON"in e)return i;try{let r;R?r=l.Deno.osRelease():typeof s.os?.release=="function"?r=s.os.release():r=B();const f=r.split(".");return Number(f[0])>=10&&Number(f[2])>=10586?Number(f[2])>=14931?n:T:i}catch{}}if("CI"in e)return["GITEA_ACTIONS","CIRCLECI","GITHUB_WORKFLOW","GITHUB_ACTIONS"].some(r=>r in e)?n:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(r=>r in e)||e.CI_NAME==="codeship"?i:a;if(e.TERMINAL_EMULATOR?.includes("JediTerm"))return n;if("TEAMCITY_VERSION"in e)return x.test(e.TEAMCITY_VERSION)?i:O;if(e.COLORTERM==="truecolor")return n;if(e.TERM==="xterm-kitty")return n;if(e.TERM==="xterm-ghostty")return n;if(e.TERM==="wezterm")return n;if("TERM_PROGRAM"in e){const r=Number.parseInt((e.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(e.TERM_PROGRAM==="iTerm.app")return r>=3?n:T;if(e.TERM_PROGRAM==="Apple_Terminal")return T}if(D.test(e.TERM))return T;let c;return M!==void 0?c=M:R?c=u==="out"?l.Deno.stdout.isTerminal():l.Deno.stderr.isTerminal():"PM2_HOME"in e&&"pm_id"in e?c=!0:c=!!s[`std${u}`]?.isTTY,c&&G.test(e.TERM)?i:"COLORTERM"in e?i:a},$=()=>m("out"),F=()=>m("err"),V=(u="stdout",d={})=>m(u==="stderr"?"err":"out",d);export{i as SPACE_16_COLORS,T as SPACE_256_COLORS,O as SPACE_MONO,n as SPACE_TRUE_COLORS,V as createIsColorSupported,F as isStderrColorSupported,$ as isStdoutColorSupported};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/is-ansi-color-supported",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.13",
|
|
4
4
|
"description": "Detect whether a terminal or browser supports ansi colors.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"256",
|
|
@@ -58,14 +58,6 @@
|
|
|
58
58
|
"type": "module",
|
|
59
59
|
"exports": {
|
|
60
60
|
".": {
|
|
61
|
-
"import": {
|
|
62
|
-
"types": "./dist/is-color-supported.server.d.mts",
|
|
63
|
-
"default": "./dist/is-color-supported.server.mjs"
|
|
64
|
-
},
|
|
65
|
-
"require": {
|
|
66
|
-
"types": "./dist/is-color-supported.server.d.cts",
|
|
67
|
-
"default": "./dist/is-color-supported.server.cjs"
|
|
68
|
-
},
|
|
69
61
|
"edge-light": {
|
|
70
62
|
"types": "./dist/is-color-supported.edge-light.d.mts",
|
|
71
63
|
"default": "./dist/is-color-supported.edge-light.mjs"
|
|
@@ -73,6 +65,14 @@
|
|
|
73
65
|
"browser": {
|
|
74
66
|
"types": "./dist/is-color-supported.browser.d.mts",
|
|
75
67
|
"default": "./dist/is-color-supported.browser.mjs"
|
|
68
|
+
},
|
|
69
|
+
"import": {
|
|
70
|
+
"types": "./dist/is-color-supported.server.d.mts",
|
|
71
|
+
"default": "./dist/is-color-supported.server.mjs"
|
|
72
|
+
},
|
|
73
|
+
"require": {
|
|
74
|
+
"types": "./dist/is-color-supported.server.d.cts",
|
|
75
|
+
"default": "./dist/is-color-supported.server.cjs"
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"./browser": {
|
|
@@ -104,9 +104,9 @@
|
|
|
104
104
|
"typesVersions": {
|
|
105
105
|
">=5.0": {
|
|
106
106
|
".": [
|
|
107
|
-
"./dist/is-color-supported.server.d.ts",
|
|
108
107
|
"./dist/is-color-supported.edge-light.d.ts",
|
|
109
|
-
"./dist/is-color-supported.browser.d.ts"
|
|
108
|
+
"./dist/is-color-supported.browser.d.ts",
|
|
109
|
+
"./dist/is-color-supported.server.d.ts"
|
|
110
110
|
],
|
|
111
111
|
"edge-light": [
|
|
112
112
|
"./dist/is-color-supported.edge-light.d.ts"
|
|
@@ -125,11 +125,6 @@
|
|
|
125
125
|
"engines": {
|
|
126
126
|
"node": "^22.14.0 || >=24.10.0"
|
|
127
127
|
},
|
|
128
|
-
"os": [
|
|
129
|
-
"darwin",
|
|
130
|
-
"linux",
|
|
131
|
-
"win32"
|
|
132
|
-
],
|
|
133
128
|
"publishConfig": {
|
|
134
129
|
"access": "public",
|
|
135
130
|
"provenance": true
|
|
File without changes
|
|
File without changes
|