1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
var supportsColor;
if ("Bun" in globalThis) {
if (Bun.enableANSIColors) {
const colors = {
level: 2,
hasBasic: true,
has256: true,
has16m: false,
};
supportsColor = {
stdout: colors,
stderr: colors,
};
} else {
supportsColor = {
stdout: false,
stderr: false,
};
}
} else {
const isBlinkBasedBrowser = /\b(Chrome|Chromium)\//.test(navigator.userAgent);
const colorSupport = isBlinkBasedBrowser
? {
level: 1,
hasBasic: true,
has256: false,
has16m: false,
}
: false;
supportsColor = {
stdout: colorSupport,
stderr: colorSupport,
};
}
export default supportsColor;
export const stdout = supportsColor.stdout;
export const stderr = supportsColor.stderr;
export { supportsColor };
|