@visulima/is-ansi-color-supported 3.0.0-alpha.12 → 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 CHANGED
@@ -1,3 +1,15 @@
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
+
1
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)
2
14
 
3
15
  ### 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
- Ansis automatically detects the supported color space:
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";var C=Object.defineProperty;var o=(e,t)=>C(e,"name",{value:t,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./packem_shared/SPACE_MONO-CIFY-d7-.cjs");var u=Object.defineProperty,O=o((e,t)=>u(e,"name",{value:t,configurable:!0}),"t");const i=/\b(Chrome|Chromium)\//,S=O(()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:t})=>t==="Chromium");if(Number(e?.version)>93)return r.SPACE_TRUE_COLORS}if(i.test(navigator.userAgent))return r.SPACE_16_COLORS}return r.SPACE_MONO})(),"isColorSupported"),n=S,a=S;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.isStderrColorSupported=a;exports.isStdoutColorSupported=n;
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- var n=Object.defineProperty;var e=(r,t)=>n(r,"name",{value:t,configurable:!0});import{SPACE_TRUE_COLORS as a,SPACE_16_COLORS as i,SPACE_MONO as u}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";import{SPACE_256_COLORS as v}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";var C=Object.defineProperty,p=e((r,t)=>C(r,"name",{value:t,configurable:!0}),"t");const s=/\b(Chrome|Chromium)\//,o=p(()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData){const r=navigator.userAgentData.brands.find(({brand:t})=>t==="Chromium");if(Number(r?.version)>93)return a}if(s.test(navigator.userAgent))return i}return u})(),"isColorSupported"),m=o,d=o;export{i as SPACE_16_COLORS,v as SPACE_256_COLORS,u as SPACE_MONO,a as SPACE_TRUE_COLORS,d as isStderrColorSupported,m as isStdoutColorSupported};
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";var u=Object.defineProperty;var o=(e,t)=>u(e,"name",{value:t,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./packem_shared/SPACE_MONO-CIFY-d7-.cjs");var C=Object.defineProperty,i=o((e,t)=>C(e,"name",{value:t,configurable:!0}),"t$1");const n=/\b(Chrome|Chromium)\//,O=i(()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:t})=>t==="Chromium");if(Number(e?.version)>93)return r.SPACE_TRUE_COLORS}if(n.test(navigator.userAgent))return r.SPACE_16_COLORS}return r.SPACE_MONO})(),"isColorSupported"),a=O;var s=Object.defineProperty,_=o((e,t)=>s(e,"name",{value:t,configurable:!0}),"o");const S=_(()=>process.env.NEXT_RUNTIME?.includes("edge")?r.SPACE_16_COLORS:a(),"isColorSupported"),d=S,p=S;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.isStderrColorSupported=p;exports.isStdoutColorSupported=d;
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{SPACE_TRUE_COLORS as i,SPACE_16_COLORS as t,SPACE_MONO as u}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";import{SPACE_256_COLORS as _}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";var s=Object.defineProperty,p=o((r,e)=>s(r,"name",{value:e,configurable:!0}),"t$1");const d=/\b(Chrome|Chromium)\//,C=p(()=>(()=>{if(typeof navigator<"u"){if(navigator.userAgentData){const r=navigator.userAgentData.brands.find(({brand:e})=>e==="Chromium");if(Number(r?.version)>93)return i}if(d.test(navigator.userAgent))return t}return u})(),"isColorSupported"),S=C;var f=Object.defineProperty,v=o((r,e)=>f(r,"name",{value:e,configurable:!0}),"o");const n=v(()=>process.env.NEXT_RUNTIME?.includes("edge")?t:S(),"isColorSupported"),g=n,l=n;export{t as SPACE_16_COLORS,_ as SPACE_256_COLORS,u as SPACE_MONO,i as SPACE_TRUE_COLORS,l as isStderrColorSupported,g as isStdoutColorSupported};
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";var f=Object.defineProperty;var c=(_,o)=>f(_,"name",{value:o,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./packem_shared/SPACE_MONO-CIFY-d7-.cjs");var p=Object.defineProperty,R=c((_,o)=>p(_,"name",{value:o,configurable:!0}),"u");const m=/^-{1,2}(no-color|no-colors|color=false|color=never)$/,N=/^-{1,2}(color=256)$/,I=/^-{1,2}(color=16m|color=full|color=truecolor)$/,b=/^-{1,2}(color|colors|color=true|color=always)$/,v=/-mono|dumb/i,U=/^(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,L=R(_=>{const o=globalThis,i=o.Deno!=null,C=o.process??o.Deno??{},s=C.argv??C.args??[],n=R(t=>{const T=s.indexOf("--"),P=s.findIndex(a=>t.test(a));return P!==-1&&(T===-1||P<T)},"oneOfFlags");let r={};try{r=i?C.env.toObject():C.env??{}}catch{}const u="FORCE_COLOR",d=u in r,O=r[u]??void 0,A=Object.prototype.toString.call(O).slice(8,-1)==="String",M=typeof O=="number";let S;if(O==="true")S=e.SPACE_16_COLORS;else if(O==="false")S=e.SPACE_MONO;else if(A&&O.length===0)S=e.SPACE_16_COLORS;else if(A&&O.length>0){const t=Number.parseInt(O,10);S=Number.isNaN(t)?void 0:Math.min(t,3)}else M&&(S=Number.isNaN(O)?void 0:Math.min(O,3));if(O!=="true"&&O!=="false"&&S!==void 0&&S<4)return S;if("NO_COLOR"in r||d&&S===0||n(m))return e.SPACE_MONO;if(n(N))return e.SPACE_256_COLORS;if(n(I))return e.SPACE_TRUE_COLORS;if(n(b))return e.SPACE_16_COLORS;const l=S??e.SPACE_MONO;if("TF_BUILD"in r&&"AGENT_NAME"in r)return e.SPACE_16_COLORS;if(r.TERM&&v.test(r.TERM))return l;if((i?o.Deno.build.os:C.platform)==="win32")try{const t=(i?o.Deno.osRelease():C.os.release()).split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[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:l;if(r.TERMINAL_EMULATOR?.includes("JediTerm"))return e.SPACE_TRUE_COLORS;if("TEAMCITY_VERSION"in r)return U.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 E;return i?E=_==="out"?o.Deno.stdout.isTerminal():o.Deno.stderr.isTerminal():"PM2_HOME"in r&&"pm_id"in r?E=!0:E=!!C[`std${_}`]?.isTTY,E&&y.test(r.TERM)||"COLORTERM"in r?e.SPACE_16_COLORS:l},"isColorSupportedFactory"),D=R(()=>L("out"),"isStdoutColorSupported"),h=R(()=>L("err"),"isStderrColorSupported");exports.SPACE_16_COLORS=e.SPACE_16_COLORS;exports.SPACE_256_COLORS=e.SPACE_256_COLORS;exports.SPACE_MONO=e.SPACE_MONO;exports.SPACE_TRUE_COLORS=e.SPACE_TRUE_COLORS;exports.isStderrColorSupported=h;exports.isStdoutColorSupported=D;
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- export { type ColorSupportLevel, SPACE_16_COLORS, SPACE_256_COLORS, SPACE_MONO, SPACE_TRUE_COLORS, isStderrColorSupported, isStdoutColorSupported };
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
- var b=Object.defineProperty;var _=(u,t)=>b(u,"name",{value:t,configurable:!0});import{SPACE_MONO as f,SPACE_256_COLORS as c,SPACE_TRUE_COLORS as i,SPACE_16_COLORS as l}from"./packem_shared/SPACE_MONO-BEQbKWNs.mjs";var L=Object.defineProperty,E=_((u,t)=>L(u,"name",{value:t,configurable:!0}),"u");const v=/^-{1,2}(no-color|no-colors|color=false|color=never)$/,P=/^-{1,2}(color=256)$/,g=/^-{1,2}(color=16m|color=full|color=truecolor)$/,y=/^-{1,2}(color|colors|color=true|color=always)$/,D=/-mono|dumb/i,h=/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/,x=/-256(color)?$/i,G=/^screen|^tmux|^xterm|^vt[1-5]\d\d|^ansi|color|mintty|rxvt|cygwin|linux/i,I=E(u=>{const t=globalThis,R=t.Deno!=null,s=t.process??t.Deno??{},m=s.argv??s.args??[],O=E(e=>{const M=m.indexOf("--"),C=m.findIndex(A=>e.test(A));return C!==-1&&(M===-1||C<M)},"oneOfFlags");let r={};try{r=R?s.env.toObject():s.env??{}}catch{}const d="FORCE_COLOR",S=d in r,o=r[d]??void 0,p=Object.prototype.toString.call(o).slice(8,-1)==="String",N=typeof o=="number";let n;if(o==="true")n=l;else if(o==="false")n=f;else if(p&&o.length===0)n=l;else if(p&&o.length>0){const e=Number.parseInt(o,10);n=Number.isNaN(e)?void 0:Math.min(e,3)}else N&&(n=Number.isNaN(o)?void 0:Math.min(o,3));if(o!=="true"&&o!=="false"&&n!==void 0&&n<4)return n;if("NO_COLOR"in r||S&&n===0||O(v))return f;if(O(P))return c;if(O(g))return i;if(O(y))return l;const a=n??f;if("TF_BUILD"in r&&"AGENT_NAME"in r)return l;if(r.TERM&&D.test(r.TERM))return a;if((R?t.Deno.build.os:s.platform)==="win32")try{const e=(R?t.Deno.osRelease():s.os.release()).split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?i:c:l}catch{}if("CI"in r)return["GITEA_ACTIONS","CIRCLECI","GITHUB_WORKFLOW","GITHUB_ACTIONS"].some(e=>e in r)?i:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(e=>e in r)||r.CI_NAME==="codeship"?l:a;if(r.TERMINAL_EMULATOR?.includes("JediTerm"))return i;if("TEAMCITY_VERSION"in r)return h.test(r.TEAMCITY_VERSION)?l:f;if(r.COLORTERM==="truecolor")return i;if(r.TERM==="xterm-kitty")return i;if(r.TERM==="xterm-ghostty")return i;if(r.TERM==="wezterm")return i;if("TERM_PROGRAM"in r){const e=Number.parseInt((r.TERM_PROGRAM_VERSION??"").split(".")[0],10);if(r.TERM_PROGRAM==="iTerm.app")return e>=3?i:c;if(r.TERM_PROGRAM==="Apple_Terminal")return c}if(x.test(r.TERM))return c;let T;return R?T=u==="out"?t.Deno.stdout.isTerminal():t.Deno.stderr.isTerminal():"PM2_HOME"in r&&"pm_id"in r?T=!0:T=!!s[`std${u}`]?.isTTY,T&&G.test(r.TERM)?l:"COLORTERM"in r?l:a},"isColorSupportedFactory"),$=E(()=>I("out"),"isStdoutColorSupported"),B=E(()=>I("err"),"isStderrColorSupported");export{l as SPACE_16_COLORS,c as SPACE_256_COLORS,f as SPACE_MONO,i as SPACE_TRUE_COLORS,B as isStderrColorSupported,$ as isStdoutColorSupported};
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.12",
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