@pi-unipi/utility 2.0.4 → 2.0.7
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/README.md +3 -0
- package/package.json +1 -1
- package/src/display/capabilities.ts +29 -15
package/README.md
CHANGED
|
@@ -128,9 +128,12 @@ import { detectCapabilities, getIcon } from "@pi-unipi/utility/display/capabilit
|
|
|
128
128
|
|
|
129
129
|
const caps = detectCapabilities();
|
|
130
130
|
console.log("Nerd Font:", caps.nerdFont);
|
|
131
|
+
console.log("Truecolor:", caps.truecolor);
|
|
131
132
|
console.log(getIcon("", "[OK]")); // Uses Nerd Font if available
|
|
132
133
|
```
|
|
133
134
|
|
|
135
|
+
Capability detection distinguishes basic color, xterm-256-compatible terminals, and truecolor-capable terminals. Apple Terminal is treated as color-capable but not truecolor-capable so renderers can fall back safely.
|
|
136
|
+
|
|
134
137
|
## Privacy
|
|
135
138
|
|
|
136
139
|
The analytics collector is privacy-respecting:
|
package/package.json
CHANGED
|
@@ -42,24 +42,38 @@ function detectColorSupport(): { color: boolean; truecolor: boolean } {
|
|
|
42
42
|
const term = env.TERM || "";
|
|
43
43
|
const termProgram = env.TERM_PROGRAM || "";
|
|
44
44
|
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
45
|
+
// Apple Terminal.app does NOT support 24-bit truecolor (longstanding
|
|
46
|
+
// limitation as of macOS 26). Force 256-colour even if some wrapper
|
|
47
|
+
// leaked COLORTERM=truecolor into the environment.
|
|
48
|
+
const isAppleTerminal = termProgram === "Apple_Terminal";
|
|
49
|
+
|
|
50
|
+
// Truecolor TERM_PROGRAM allow-list. Note: terminfo names like
|
|
51
|
+
// "xterm-256color" / "screen-256color" / "tmux-256color" advertise
|
|
52
|
+
// 256-colour, NOT truecolor — they must not appear here.
|
|
53
|
+
const truecolorTermPrograms = [
|
|
54
|
+
"iTerm.app",
|
|
55
|
+
"WezTerm",
|
|
56
|
+
"Alacritty",
|
|
57
|
+
"vscode",
|
|
58
|
+
"Hyper",
|
|
59
|
+
"Warp",
|
|
56
60
|
"ghostty",
|
|
61
|
+
"Ghostty",
|
|
62
|
+
"zed",
|
|
63
|
+
"Zed",
|
|
64
|
+
"cursor",
|
|
65
|
+
"Cursor",
|
|
57
66
|
];
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
// Truecolor TERM tokens (the rare TERM that *does* advertise truecolor).
|
|
69
|
+
const truecolorTermTokens = ["truecolor", "24bit", "alacritty", "kitty", "wezterm"];
|
|
70
|
+
|
|
71
|
+
const hasTruecolor = isAppleTerminal
|
|
72
|
+
? false
|
|
73
|
+
: env.COLORTERM === "truecolor" ||
|
|
74
|
+
env.COLORTERM === "24bit" ||
|
|
75
|
+
truecolorTermPrograms.includes(termProgram) ||
|
|
76
|
+
truecolorTermTokens.some((t) => term.includes(t));
|
|
63
77
|
|
|
64
78
|
// Basic color support
|
|
65
79
|
const hasColor =
|