silvery 0.17.0 → 0.17.2
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/dist/UPNG-AVSMjiFE.mjs +5076 -0
- package/dist/UPNG-AVSMjiFE.mjs.map +1 -0
- package/dist/__vite-browser-external-2447137e-D3GdsvS_.mjs +6 -0
- package/dist/__vite-browser-external-2447137e-D3GdsvS_.mjs.map +1 -0
- package/dist/animation-C_PTO0uH.mjs +304 -0
- package/dist/animation-C_PTO0uH.mjs.map +1 -0
- package/dist/ansi-CXLE_pt1.mjs +71 -0
- package/dist/ansi-CXLE_pt1.mjs.map +1 -0
- package/dist/ansi-zmNzgkPB.d.mts +49 -0
- package/dist/ansi-zmNzgkPB.d.mts.map +1 -0
- package/dist/apng-DCWY913R.mjs +3 -0
- package/dist/apng-ENBAJk-H.mjs +70 -0
- package/dist/apng-ENBAJk-H.mjs.map +1 -0
- package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
- package/dist/backend-CkIkIHR-.mjs +13396 -0
- package/dist/backend-CkIkIHR-.mjs.map +1 -0
- package/dist/backends-CkvbG3js.mjs +1181 -0
- package/dist/backends-CkvbG3js.mjs.map +1 -0
- package/dist/backends-CyJqNLeK.mjs +3 -0
- package/dist/chunk-BSw8zbkd.mjs +37 -0
- package/dist/cli-B-k7Bm56.mjs +4 -0
- package/dist/context-QreF3UHr.mjs +64 -0
- package/dist/context-QreF3UHr.mjs.map +1 -0
- package/dist/derive-D7bFJdfU.d.mts +28 -0
- package/dist/derive-D7bFJdfU.d.mts.map +1 -0
- package/dist/devtools-CscuKaDK.mjs +89 -0
- package/dist/devtools-CscuKaDK.mjs.map +1 -0
- package/dist/devtools-D4oGc6LY.mjs +2 -0
- package/dist/eta-DLiVPaSD.mjs +110 -0
- package/dist/eta-DLiVPaSD.mjs.map +1 -0
- package/dist/flexily-zero-adapter-DmG4Ge8t.mjs +3376 -0
- package/dist/flexily-zero-adapter-DmG4Ge8t.mjs.map +1 -0
- package/dist/flexily-zero-adapter-GHwEW11s.mjs +2 -0
- package/dist/gif-BaJNREpP.mjs +3 -0
- package/dist/gif-Bp6fIyN3.mjs +73 -0
- package/dist/gif-Bp6fIyN3.mjs.map +1 -0
- package/dist/gifenc-GiVCZ9-3.mjs +730 -0
- package/dist/gifenc-GiVCZ9-3.mjs.map +1 -0
- package/dist/image-Dx7gYjkq.mjs +346 -0
- package/dist/image-Dx7gYjkq.mjs.map +1 -0
- package/dist/index-CBcSpGSM.d.mts +3416 -0
- package/dist/index-CBcSpGSM.d.mts.map +1 -0
- package/dist/index-DCVL3jHo.d.mts +634 -0
- package/dist/index-DCVL3jHo.d.mts.map +1 -0
- package/dist/index-p-wBs_wH.d.mts +175 -0
- package/dist/index-p-wBs_wH.d.mts.map +1 -0
- package/dist/index.d.mts +7296 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +9399 -0
- package/dist/index.mjs.map +1 -0
- package/dist/key-mapping-BsUHe_nk.mjs +3 -0
- package/dist/key-mapping-DsyfLEdC.mjs +132 -0
- package/dist/key-mapping-DsyfLEdC.mjs.map +1 -0
- package/dist/layout-engine-B3dsnVLU.mjs +50 -0
- package/dist/layout-engine-B3dsnVLU.mjs.map +1 -0
- package/dist/layout-engine-D_lSR4i9.mjs +2 -0
- package/dist/multi-progress-C0-rkn86.d.mts +180 -0
- package/dist/multi-progress-C0-rkn86.d.mts.map +1 -0
- package/dist/multi-progress-CQVB9lES.mjs +219 -0
- package/dist/multi-progress-CQVB9lES.mjs.map +1 -0
- package/dist/node-Dedx-6xF.mjs +1085 -0
- package/dist/node-Dedx-6xF.mjs.map +1 -0
- package/dist/pipeline-DDOPrjuY.mjs +4387 -0
- package/dist/pipeline-DDOPrjuY.mjs.map +1 -0
- package/dist/progress-bar-COPSBlT9.mjs +155 -0
- package/dist/progress-bar-COPSBlT9.mjs.map +1 -0
- package/dist/reconciler-2lp5VXK7.mjs +16506 -0
- package/dist/reconciler-2lp5VXK7.mjs.map +1 -0
- package/dist/render-string-BXvxTg5P.mjs +201 -0
- package/dist/render-string-BXvxTg5P.mjs.map +1 -0
- package/dist/render-string-hvfpVtoP.mjs +2 -0
- package/dist/resvg-js-V6oMi8CY.mjs +203 -0
- package/dist/resvg-js-V6oMi8CY.mjs.map +1 -0
- package/dist/runtime-BjDHNTxJ.mjs +8723 -0
- package/dist/runtime-BjDHNTxJ.mjs.map +1 -0
- package/dist/runtime.d.mts +2 -0
- package/dist/runtime.mjs +3 -0
- package/dist/spinner-Cgej6Vnb.d.mts +127 -0
- package/dist/spinner-Cgej6Vnb.d.mts.map +1 -0
- package/dist/spinner-DSByknyx.mjs +298 -0
- package/dist/spinner-DSByknyx.mjs.map +1 -0
- package/dist/src-9B5k0JmY.mjs +1629 -0
- package/dist/src-9B5k0JmY.mjs.map +1 -0
- package/dist/src-C9f3hiVG.mjs +3620 -0
- package/dist/src-C9f3hiVG.mjs.map +1 -0
- package/dist/src-fJVbhdn-.mjs +816 -0
- package/dist/src-fJVbhdn-.mjs.map +1 -0
- package/dist/theme.d.mts +115 -0
- package/dist/theme.d.mts.map +1 -0
- package/dist/theme.mjs +8 -0
- package/dist/theme.mjs.map +1 -0
- package/dist/types-Bhj5QkIQ.mjs +13 -0
- package/dist/types-Bhj5QkIQ.mjs.map +1 -0
- package/dist/types-CDgkE-Rw.d.mts +241 -0
- package/dist/types-CDgkE-Rw.d.mts.map +1 -0
- package/dist/ui/animation.d.mts +2 -0
- package/dist/ui/animation.mjs +2 -0
- package/dist/ui/ansi.d.mts +2 -0
- package/dist/ui/ansi.mjs +2 -0
- package/dist/ui/cli.d.mts +5 -0
- package/dist/ui/cli.mjs +7 -0
- package/dist/ui/display.d.mts +35 -0
- package/dist/ui/display.d.mts.map +1 -0
- package/dist/ui/display.mjs +123 -0
- package/dist/ui/display.mjs.map +1 -0
- package/dist/ui/image.d.mts +2 -0
- package/dist/ui/image.mjs +2 -0
- package/dist/ui/input.d.mts +184 -0
- package/dist/ui/input.d.mts.map +1 -0
- package/dist/ui/input.mjs +285 -0
- package/dist/ui/input.mjs.map +1 -0
- package/dist/ui/progress.d.mts +249 -0
- package/dist/ui/progress.d.mts.map +1 -0
- package/dist/ui/progress.mjs +858 -0
- package/dist/ui/progress.mjs.map +1 -0
- package/dist/ui/react.d.mts +280 -0
- package/dist/ui/react.d.mts.map +1 -0
- package/dist/ui/react.mjs +413 -0
- package/dist/ui/react.mjs.map +1 -0
- package/dist/ui/utils.d.mts +86 -0
- package/dist/ui/utils.d.mts.map +1 -0
- package/dist/ui/utils.mjs +2 -0
- package/dist/ui/wrappers.d.mts +3 -0
- package/dist/ui/wrappers.mjs +2 -0
- package/dist/ui.d.mts +6 -0
- package/dist/ui.mjs +7 -0
- package/dist/useLatest-BMIYXd6e.d.mts +154 -0
- package/dist/useLatest-BMIYXd6e.d.mts.map +1 -0
- package/dist/useLayout-BG2cGl15.mjs +139 -0
- package/dist/useLayout-BG2cGl15.mjs.map +1 -0
- package/dist/with-text-input-CmHf_9d6.d.mts +284 -0
- package/dist/with-text-input-CmHf_9d6.d.mts.map +1 -0
- package/dist/wrapper-Dqh0zi2W.mjs +3527 -0
- package/dist/wrapper-Dqh0zi2W.mjs.map +1 -0
- package/dist/wrappers-hhL8EQ_n.mjs +810 -0
- package/dist/wrappers-hhL8EQ_n.mjs.map +1 -0
- package/dist/yoga-adapter-BJ9SOhTY.mjs +245 -0
- package/dist/yoga-adapter-BJ9SOhTY.mjs.map +1 -0
- package/dist/yoga-adapter-Daq6-dw1.mjs +2 -0
- package/package.json +48 -75
- package/CHANGELOG.md +0 -319
- package/dist/chalk.js +0 -4
- package/dist/index.js +0 -270
- package/dist/ink.js +0 -142
- package/dist/runtime.js +0 -135
- package/dist/theme.js +0 -7
- package/dist/ui/animation.js +0 -3
- package/dist/ui/ansi.js +0 -3
- package/dist/ui/cli.js +0 -9
- package/dist/ui/display.js +0 -4
- package/dist/ui/image.js +0 -4
- package/dist/ui/input.js +0 -3
- package/dist/ui/progress.js +0 -9
- package/dist/ui/react.js +0 -4
- package/dist/ui/utils.js +0 -3
- package/dist/ui/wrappers.js +0 -15
- package/dist/ui.js +0 -18
- package/src/index.ts +0 -73
- package/src/runtime.ts +0 -4
- package/src/theme.ts +0 -4
- package/src/ui/animation.ts +0 -2
- package/src/ui/ansi.ts +0 -2
- package/src/ui/cli.ts +0 -3
- package/src/ui/display.ts +0 -2
- package/src/ui/image.ts +0 -2
- package/src/ui/input.ts +0 -2
- package/src/ui/progress.ts +0 -2
- package/src/ui/react.ts +0 -2
- package/src/ui/utils.ts +0 -2
- package/src/ui/wrappers.ts +0 -2
- package/src/ui.ts +0 -4
|
@@ -0,0 +1,1629 @@
|
|
|
1
|
+
import { i as __require, n as __esmMin } from "./chunk-BSw8zbkd.mjs";
|
|
2
|
+
import "string-width";
|
|
3
|
+
//#region packages/ansi/src/detection.ts
|
|
4
|
+
/**
|
|
5
|
+
* Detect if terminal supports cursor control (repositioning).
|
|
6
|
+
* Returns false for dumb terminals and piped output.
|
|
7
|
+
*/
|
|
8
|
+
function detectCursor(stdout) {
|
|
9
|
+
if (!stdout.isTTY) return false;
|
|
10
|
+
if (process.env.TERM === "dumb") return false;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Detect if terminal can read raw keystrokes.
|
|
15
|
+
* Requires stdin to be a TTY with raw mode support.
|
|
16
|
+
*/
|
|
17
|
+
function detectInput(stdin) {
|
|
18
|
+
if (!stdin.isTTY) return false;
|
|
19
|
+
return typeof stdin.setRawMode === "function";
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Detect color level supported by terminal.
|
|
23
|
+
* Returns null if no color support.
|
|
24
|
+
*
|
|
25
|
+
* Checks (in order):
|
|
26
|
+
* 1. NO_COLOR env var - forces no color
|
|
27
|
+
* 2. FORCE_COLOR env var - forces color level
|
|
28
|
+
* 3. COLORTERM=truecolor - truecolor support
|
|
29
|
+
* 4. TERM patterns - detect from terminal type
|
|
30
|
+
* 5. CI detection - basic colors in CI
|
|
31
|
+
*/
|
|
32
|
+
function detectColor(stdout) {
|
|
33
|
+
if (process.env.NO_COLOR !== void 0) return null;
|
|
34
|
+
const forceColor = process.env.FORCE_COLOR;
|
|
35
|
+
if (forceColor !== void 0) {
|
|
36
|
+
if (forceColor === "0" || forceColor === "false") return null;
|
|
37
|
+
if (forceColor === "1") return "basic";
|
|
38
|
+
if (forceColor === "2") return "256";
|
|
39
|
+
if (forceColor === "3") return "truecolor";
|
|
40
|
+
return "basic";
|
|
41
|
+
}
|
|
42
|
+
if (!stdout.isTTY) return null;
|
|
43
|
+
if (process.env.TERM === "dumb") return null;
|
|
44
|
+
const colorTerm = process.env.COLORTERM;
|
|
45
|
+
if (colorTerm === "truecolor" || colorTerm === "24bit") return "truecolor";
|
|
46
|
+
const term = process.env.TERM ?? "";
|
|
47
|
+
if (term.includes("truecolor") || term.includes("24bit") || term.includes("xterm-ghostty") || term.includes("xterm-kitty") || term.includes("wezterm")) return "truecolor";
|
|
48
|
+
if (term.includes("256color") || term.includes("256")) return "256";
|
|
49
|
+
const termProgram = process.env.TERM_PROGRAM;
|
|
50
|
+
if (termProgram === "iTerm.app" || termProgram === "Apple_Terminal") return termProgram === "iTerm.app" ? "truecolor" : "256";
|
|
51
|
+
if (termProgram === "Ghostty" || termProgram === "WezTerm") return "truecolor";
|
|
52
|
+
if (process.env.KITTY_WINDOW_ID) return "truecolor";
|
|
53
|
+
if (term.includes("xterm") || term.includes("color") || term.includes("ansi")) return "basic";
|
|
54
|
+
if (CI_ENVS.some((env) => process.env[env] !== void 0)) return "basic";
|
|
55
|
+
if (process.env.WT_SESSION) return "truecolor";
|
|
56
|
+
return "basic";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Detect if terminal can render unicode symbols.
|
|
60
|
+
* Based on TERM, locale, and known terminal apps.
|
|
61
|
+
*/
|
|
62
|
+
function detectUnicode() {
|
|
63
|
+
if (process.env.CI) {
|
|
64
|
+
if (process.env.GITHUB_ACTIONS) return true;
|
|
65
|
+
}
|
|
66
|
+
const lang = process.env.LANG ?? process.env.LC_ALL ?? process.env.LC_CTYPE ?? "";
|
|
67
|
+
if (lang.toLowerCase().includes("utf-8") || lang.toLowerCase().includes("utf8")) return true;
|
|
68
|
+
if (process.env.WT_SESSION) return true;
|
|
69
|
+
const termProgram = process.env.TERM_PROGRAM ?? "";
|
|
70
|
+
if ([
|
|
71
|
+
"iTerm.app",
|
|
72
|
+
"Ghostty",
|
|
73
|
+
"WezTerm",
|
|
74
|
+
"Apple_Terminal"
|
|
75
|
+
].includes(termProgram)) return true;
|
|
76
|
+
if (process.env.KITTY_WINDOW_ID) return true;
|
|
77
|
+
const term = process.env.TERM ?? "";
|
|
78
|
+
if (term.includes("xterm") || term.includes("rxvt") || term.includes("screen") || term.includes("tmux")) return true;
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Default capabilities (assumes modern terminal with full support).
|
|
83
|
+
*/
|
|
84
|
+
function defaultCaps() {
|
|
85
|
+
return {
|
|
86
|
+
program: "",
|
|
87
|
+
term: "",
|
|
88
|
+
colorLevel: "truecolor",
|
|
89
|
+
kittyKeyboard: false,
|
|
90
|
+
kittyGraphics: false,
|
|
91
|
+
sixel: false,
|
|
92
|
+
osc52: false,
|
|
93
|
+
hyperlinks: false,
|
|
94
|
+
notifications: false,
|
|
95
|
+
bracketedPaste: true,
|
|
96
|
+
mouse: true,
|
|
97
|
+
syncOutput: false,
|
|
98
|
+
unicode: true,
|
|
99
|
+
underlineStyles: true,
|
|
100
|
+
underlineColor: true,
|
|
101
|
+
textEmojiWide: true,
|
|
102
|
+
textSizingSupported: false,
|
|
103
|
+
darkBackground: true,
|
|
104
|
+
nerdfont: false
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Check if macOS is in dark mode by reading the system appearance preference.
|
|
109
|
+
* Uses `defaults read -g AppleInterfaceStyle` — returns "Dark" when dark mode
|
|
110
|
+
* is active, exits non-zero when light mode. ~2ms via spawnSync.
|
|
111
|
+
*
|
|
112
|
+
* Result is cached after first call to avoid repeated process spawns.
|
|
113
|
+
*/
|
|
114
|
+
function detectMacOSDarkMode() {
|
|
115
|
+
if (cachedMacOSDarkMode !== void 0) return cachedMacOSDarkMode;
|
|
116
|
+
try {
|
|
117
|
+
const { spawnSync } = __require("child_process");
|
|
118
|
+
cachedMacOSDarkMode = spawnSync("defaults", [
|
|
119
|
+
"read",
|
|
120
|
+
"-g",
|
|
121
|
+
"AppleInterfaceStyle"
|
|
122
|
+
], {
|
|
123
|
+
encoding: "utf-8",
|
|
124
|
+
timeout: 500
|
|
125
|
+
}).stdout?.trim() === "Dark";
|
|
126
|
+
} catch {
|
|
127
|
+
cachedMacOSDarkMode = false;
|
|
128
|
+
}
|
|
129
|
+
return cachedMacOSDarkMode;
|
|
130
|
+
}
|
|
131
|
+
/** Detect terminal capabilities from environment variables.
|
|
132
|
+
* Synchronous. Minimal I/O: may run `defaults` on macOS for Apple_Terminal.
|
|
133
|
+
*/
|
|
134
|
+
function detectTerminalCaps() {
|
|
135
|
+
const program = process.env.TERM_PROGRAM ?? "";
|
|
136
|
+
const term = process.env.TERM ?? "";
|
|
137
|
+
const colorTerm = process.env.COLORTERM ?? "";
|
|
138
|
+
const noColor = process.env.NO_COLOR !== void 0;
|
|
139
|
+
const isAppleTerminal = program === "Apple_Terminal";
|
|
140
|
+
let colorLevel = "none";
|
|
141
|
+
if (!noColor) {
|
|
142
|
+
if (isAppleTerminal) colorLevel = "256";
|
|
143
|
+
else if (colorTerm === "truecolor" || colorTerm === "24bit") colorLevel = "truecolor";
|
|
144
|
+
else if (term.includes("256color")) colorLevel = "256";
|
|
145
|
+
else if (process.stdout?.isTTY) colorLevel = "basic";
|
|
146
|
+
}
|
|
147
|
+
const isKitty = term === "xterm-kitty";
|
|
148
|
+
const isITerm = program === "iTerm.app";
|
|
149
|
+
const isGhostty = program === "ghostty";
|
|
150
|
+
const isWezTerm = program === "WezTerm";
|
|
151
|
+
const isAlacritty = program === "Alacritty";
|
|
152
|
+
const isFoot = term === "foot" || term === "foot-extra";
|
|
153
|
+
const isModern = isKitty || isITerm || isGhostty || isWezTerm || isFoot;
|
|
154
|
+
let isKittyWithTextSizing = false;
|
|
155
|
+
if (isKitty) {
|
|
156
|
+
const parts = (process.env.TERM_PROGRAM_VERSION ?? "").split(".");
|
|
157
|
+
const major = Number(parts[0]) || 0;
|
|
158
|
+
const minor = Number(parts[1]) || 0;
|
|
159
|
+
isKittyWithTextSizing = major > 0 || major === 0 && minor >= 40;
|
|
160
|
+
}
|
|
161
|
+
let darkBackground = !isAppleTerminal;
|
|
162
|
+
const colorFgBg = process.env.COLORFGBG;
|
|
163
|
+
if (colorFgBg) {
|
|
164
|
+
const parts = colorFgBg.split(";");
|
|
165
|
+
const bg = parseInt(parts[parts.length - 1] ?? "", 10);
|
|
166
|
+
if (!isNaN(bg)) darkBackground = bg < 7;
|
|
167
|
+
} else if (isAppleTerminal) darkBackground = detectMacOSDarkMode();
|
|
168
|
+
let nerdfont = isModern || isAlacritty;
|
|
169
|
+
const nfEnv = process.env.NERDFONT;
|
|
170
|
+
if (nfEnv === "0" || nfEnv === "false") nerdfont = false;
|
|
171
|
+
else if (nfEnv === "1" || nfEnv === "true") nerdfont = true;
|
|
172
|
+
const underlineExtensions = isModern || isAlacritty;
|
|
173
|
+
return {
|
|
174
|
+
program,
|
|
175
|
+
term,
|
|
176
|
+
colorLevel,
|
|
177
|
+
kittyKeyboard: isKitty || isGhostty || isWezTerm || isFoot,
|
|
178
|
+
kittyGraphics: isKitty || isGhostty,
|
|
179
|
+
sixel: isFoot || isWezTerm,
|
|
180
|
+
osc52: isModern || isAlacritty,
|
|
181
|
+
hyperlinks: isModern || isAlacritty,
|
|
182
|
+
notifications: isITerm || isKitty,
|
|
183
|
+
bracketedPaste: true,
|
|
184
|
+
mouse: true,
|
|
185
|
+
syncOutput: isModern || isAlacritty,
|
|
186
|
+
unicode: true,
|
|
187
|
+
underlineStyles: underlineExtensions,
|
|
188
|
+
underlineColor: underlineExtensions,
|
|
189
|
+
textEmojiWide: !isAppleTerminal,
|
|
190
|
+
textSizingSupported: isKittyWithTextSizing,
|
|
191
|
+
darkBackground,
|
|
192
|
+
nerdfont
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
var CI_ENVS, cachedMacOSDarkMode;
|
|
196
|
+
var init_detection = __esmMin((() => {
|
|
197
|
+
CI_ENVS = [
|
|
198
|
+
"CI",
|
|
199
|
+
"GITHUB_ACTIONS",
|
|
200
|
+
"GITLAB_CI",
|
|
201
|
+
"JENKINS_URL",
|
|
202
|
+
"BUILDKITE",
|
|
203
|
+
"CIRCLECI",
|
|
204
|
+
"TRAVIS"
|
|
205
|
+
];
|
|
206
|
+
}));
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region packages/ansi/src/sgr-codes.ts
|
|
209
|
+
/**
|
|
210
|
+
* SGR (Select Graphic Rendition) color code helpers.
|
|
211
|
+
*
|
|
212
|
+
* Shared by buffer.ts (styleToAnsiCodes) and output-phase.ts (styleTransition).
|
|
213
|
+
* Emits the shortest possible SGR code string for a given color.
|
|
214
|
+
*/
|
|
215
|
+
/**
|
|
216
|
+
* Emit the shortest SGR code string for a foreground color.
|
|
217
|
+
* - Basic 0-7: 4-bit code (30+N)
|
|
218
|
+
* - Extended 8-255: 256-color (38;5;N)
|
|
219
|
+
* - RGB: true color (38;2;R;G;B)
|
|
220
|
+
*/
|
|
221
|
+
function fgColorCode(color) {
|
|
222
|
+
if (typeof color === "number") {
|
|
223
|
+
if (color >= 0 && color <= 7) return `${30 + color}`;
|
|
224
|
+
return `38;5;${color}`;
|
|
225
|
+
}
|
|
226
|
+
return `38;2;${color.r};${color.g};${color.b}`;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Emit the shortest SGR code string for a background color.
|
|
230
|
+
* - Basic 0-7: 4-bit code (40+N)
|
|
231
|
+
* - Extended 8-255: 256-color (48;5;N)
|
|
232
|
+
* - RGB: true color (48;2;R;G;B)
|
|
233
|
+
*/
|
|
234
|
+
function bgColorCode(color) {
|
|
235
|
+
if (typeof color === "number") {
|
|
236
|
+
if (color >= 0 && color <= 7) return `${40 + color}`;
|
|
237
|
+
return `48;5;${color}`;
|
|
238
|
+
}
|
|
239
|
+
return `48;2;${color.r};${color.g};${color.b}`;
|
|
240
|
+
}
|
|
241
|
+
var init_sgr_codes = __esmMin((() => {}));
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region packages/ansi/src/utils.ts
|
|
244
|
+
var init_utils = __esmMin((() => {}));
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region packages/ansi/src/color-maps.ts
|
|
247
|
+
/** Find nearest ANSI 16 color index for an RGB value. */
|
|
248
|
+
function nearestAnsi16(r, g, b) {
|
|
249
|
+
let bestIdx = 0;
|
|
250
|
+
let bestDist = Infinity;
|
|
251
|
+
for (let i = 0; i < 16; i++) {
|
|
252
|
+
const [cr, cg, cb] = ANSI_16_COLORS[i];
|
|
253
|
+
const dist = (r - cr) ** 2 + (g - cg) ** 2 + (b - cb) ** 2;
|
|
254
|
+
if (dist < bestDist) {
|
|
255
|
+
bestDist = dist;
|
|
256
|
+
bestIdx = i;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return bestIdx;
|
|
260
|
+
}
|
|
261
|
+
/** Convert RGB to 256-color index (using the 6x6x6 color cube). */
|
|
262
|
+
function rgbToAnsi256(r, g, b) {
|
|
263
|
+
if (r === g && g === b) {
|
|
264
|
+
if (r < 8) return 16;
|
|
265
|
+
if (r > 248) return 231;
|
|
266
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
267
|
+
}
|
|
268
|
+
const ri = Math.round(r / 255 * 5);
|
|
269
|
+
const gi = Math.round(g / 255 * 5);
|
|
270
|
+
const bi = Math.round(b / 255 * 5);
|
|
271
|
+
return 16 + 36 * ri + 6 * gi + bi;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Generate SGR foreground code for an RGB color at the given color level.
|
|
275
|
+
* Returns the SGR parameter string (e.g., "31" or "38;5;196" or "38;2;255;0;0").
|
|
276
|
+
*/
|
|
277
|
+
function fgFromRgb(r, g, b, level) {
|
|
278
|
+
if (level === "truecolor") return `38;2;${r};${g};${b}`;
|
|
279
|
+
if (level === "256") return `38;5;${rgbToAnsi256(r, g, b)}`;
|
|
280
|
+
const idx = nearestAnsi16(r, g, b);
|
|
281
|
+
return idx < 8 ? `${30 + idx}` : `${82 + idx}`;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Generate SGR background code for an RGB color at the given color level.
|
|
285
|
+
*/
|
|
286
|
+
function bgFromRgb(r, g, b, level) {
|
|
287
|
+
if (level === "truecolor") return `48;2;${r};${g};${b}`;
|
|
288
|
+
if (level === "256") return `48;5;${rgbToAnsi256(r, g, b)}`;
|
|
289
|
+
const idx = nearestAnsi16(r, g, b);
|
|
290
|
+
return idx < 8 ? `${40 + idx}` : `${92 + idx}`;
|
|
291
|
+
}
|
|
292
|
+
var MODIFIERS, FG_COLORS, BG_COLORS, ANSI_16_COLORS;
|
|
293
|
+
var init_color_maps = __esmMin((() => {
|
|
294
|
+
MODIFIERS = {
|
|
295
|
+
reset: [0, 0],
|
|
296
|
+
bold: [1, 22],
|
|
297
|
+
dim: [2, 22],
|
|
298
|
+
italic: [3, 23],
|
|
299
|
+
underline: [4, 24],
|
|
300
|
+
inverse: [7, 27],
|
|
301
|
+
hidden: [8, 28],
|
|
302
|
+
strikethrough: [9, 29],
|
|
303
|
+
overline: [53, 55]
|
|
304
|
+
};
|
|
305
|
+
FG_COLORS = {
|
|
306
|
+
black: 30,
|
|
307
|
+
red: 31,
|
|
308
|
+
green: 32,
|
|
309
|
+
yellow: 33,
|
|
310
|
+
blue: 34,
|
|
311
|
+
magenta: 35,
|
|
312
|
+
cyan: 36,
|
|
313
|
+
white: 37,
|
|
314
|
+
blackBright: 90,
|
|
315
|
+
gray: 90,
|
|
316
|
+
grey: 90,
|
|
317
|
+
redBright: 91,
|
|
318
|
+
greenBright: 92,
|
|
319
|
+
yellowBright: 93,
|
|
320
|
+
blueBright: 94,
|
|
321
|
+
magentaBright: 95,
|
|
322
|
+
cyanBright: 96,
|
|
323
|
+
whiteBright: 97
|
|
324
|
+
};
|
|
325
|
+
BG_COLORS = {
|
|
326
|
+
bgBlack: 40,
|
|
327
|
+
bgRed: 41,
|
|
328
|
+
bgGreen: 42,
|
|
329
|
+
bgYellow: 43,
|
|
330
|
+
bgBlue: 44,
|
|
331
|
+
bgMagenta: 45,
|
|
332
|
+
bgCyan: 46,
|
|
333
|
+
bgWhite: 47,
|
|
334
|
+
bgBlackBright: 100,
|
|
335
|
+
bgGray: 100,
|
|
336
|
+
bgGrey: 100,
|
|
337
|
+
bgRedBright: 101,
|
|
338
|
+
bgGreenBright: 102,
|
|
339
|
+
bgYellowBright: 103,
|
|
340
|
+
bgBlueBright: 104,
|
|
341
|
+
bgMagentaBright: 105,
|
|
342
|
+
bgCyanBright: 106,
|
|
343
|
+
bgWhiteBright: 107
|
|
344
|
+
};
|
|
345
|
+
ANSI_16_COLORS = [
|
|
346
|
+
[
|
|
347
|
+
0,
|
|
348
|
+
0,
|
|
349
|
+
0
|
|
350
|
+
],
|
|
351
|
+
[
|
|
352
|
+
128,
|
|
353
|
+
0,
|
|
354
|
+
0
|
|
355
|
+
],
|
|
356
|
+
[
|
|
357
|
+
0,
|
|
358
|
+
128,
|
|
359
|
+
0
|
|
360
|
+
],
|
|
361
|
+
[
|
|
362
|
+
128,
|
|
363
|
+
128,
|
|
364
|
+
0
|
|
365
|
+
],
|
|
366
|
+
[
|
|
367
|
+
0,
|
|
368
|
+
0,
|
|
369
|
+
128
|
|
370
|
+
],
|
|
371
|
+
[
|
|
372
|
+
128,
|
|
373
|
+
0,
|
|
374
|
+
128
|
|
375
|
+
],
|
|
376
|
+
[
|
|
377
|
+
0,
|
|
378
|
+
128,
|
|
379
|
+
128
|
|
380
|
+
],
|
|
381
|
+
[
|
|
382
|
+
192,
|
|
383
|
+
192,
|
|
384
|
+
192
|
|
385
|
+
],
|
|
386
|
+
[
|
|
387
|
+
128,
|
|
388
|
+
128,
|
|
389
|
+
128
|
|
390
|
+
],
|
|
391
|
+
[
|
|
392
|
+
255,
|
|
393
|
+
0,
|
|
394
|
+
0
|
|
395
|
+
],
|
|
396
|
+
[
|
|
397
|
+
0,
|
|
398
|
+
255,
|
|
399
|
+
0
|
|
400
|
+
],
|
|
401
|
+
[
|
|
402
|
+
255,
|
|
403
|
+
255,
|
|
404
|
+
0
|
|
405
|
+
],
|
|
406
|
+
[
|
|
407
|
+
0,
|
|
408
|
+
0,
|
|
409
|
+
255
|
|
410
|
+
],
|
|
411
|
+
[
|
|
412
|
+
255,
|
|
413
|
+
0,
|
|
414
|
+
255
|
|
415
|
+
],
|
|
416
|
+
[
|
|
417
|
+
0,
|
|
418
|
+
255,
|
|
419
|
+
255
|
|
420
|
+
],
|
|
421
|
+
[
|
|
422
|
+
255,
|
|
423
|
+
255,
|
|
424
|
+
255
|
|
425
|
+
]
|
|
426
|
+
];
|
|
427
|
+
}));
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region packages/ansi/src/terminal-control.ts
|
|
430
|
+
/**
|
|
431
|
+
* Enable mouse tracking with full hover support.
|
|
432
|
+
*
|
|
433
|
+
* Uses two modes:
|
|
434
|
+
* - **1003** (any-event tracking): Reports ALL mouse motion — clicks, drags, AND hover.
|
|
435
|
+
* This is what makes onMouseEnter/onMouseLeave work. Without it, only clicks are reported.
|
|
436
|
+
* - **1006** (SGR encoding): Decimal coordinates with no 223-column limit.
|
|
437
|
+
*
|
|
438
|
+
* WARNING: Do NOT replace 1003 with 1000+1002. The xterm mouse modes form a hierarchy:
|
|
439
|
+
* 1000 = clicks only
|
|
440
|
+
* 1002 = clicks + drag (motion while button held)
|
|
441
|
+
* 1003 = clicks + drag + hover (ALL motion, even without button)
|
|
442
|
+
* Mode 1003 supersedes 1000 and 1002. Using 1000+1002 instead of 1003 silently
|
|
443
|
+
* disables hover — onMouseEnter/onMouseLeave stop firing with no error.
|
|
444
|
+
*/
|
|
445
|
+
function enableMouse() {
|
|
446
|
+
return `${CSI$1}?1003h${CSI$1}?1006h`;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Disable mouse tracking. Disables in reverse order of enabling.
|
|
450
|
+
*/
|
|
451
|
+
function disableMouse() {
|
|
452
|
+
return `${CSI$1}?1006l${CSI$1}?1003l`;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Enable the Kitty keyboard protocol (push mode).
|
|
456
|
+
*
|
|
457
|
+
* Sends CSI > flags u to opt into the specified modes.
|
|
458
|
+
* Supported by: Ghostty, Kitty, WezTerm, foot. Ignored by unsupported terminals.
|
|
459
|
+
*
|
|
460
|
+
* Flags are a bitfield:
|
|
461
|
+
*
|
|
462
|
+
* | Flag | Bit | Description |
|
|
463
|
+
* | ---- | --- | ----------------------------------------- |
|
|
464
|
+
* | 1 | 0 | Disambiguate escape codes |
|
|
465
|
+
* | 2 | 1 | Report event types (press/repeat/release) |
|
|
466
|
+
* | 4 | 2 | Report alternate keys |
|
|
467
|
+
* | 8 | 3 | Report all keys as escape codes |
|
|
468
|
+
* | 16 | 4 | Report associated text |
|
|
469
|
+
*
|
|
470
|
+
* @param flags Bitfield of Kitty keyboard flags
|
|
471
|
+
*/
|
|
472
|
+
function enableKittyKeyboard(flags = 1) {
|
|
473
|
+
return `${CSI$1}>${flags}u`;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Disable the Kitty keyboard protocol (pop mode stack).
|
|
477
|
+
* Sends CSI < u to restore the previous keyboard mode.
|
|
478
|
+
*/
|
|
479
|
+
function disableKittyKeyboard() {
|
|
480
|
+
return `${CSI$1}<u`;
|
|
481
|
+
}
|
|
482
|
+
var ESC$3, CSI$1;
|
|
483
|
+
var init_terminal_control = __esmMin((() => {
|
|
484
|
+
ESC$3 = "\x1B";
|
|
485
|
+
CSI$1 = `${ESC$3}[`;
|
|
486
|
+
`${ESC$3}`;
|
|
487
|
+
}));
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region packages/color/src/color.ts
|
|
490
|
+
/** Parse #rrggbb or #rgb to [r, g, b]. Returns null for invalid input. */
|
|
491
|
+
function hexToRgb(hex) {
|
|
492
|
+
if (hex[0] !== "#") return null;
|
|
493
|
+
const h = hex.slice(1);
|
|
494
|
+
if (h.length === 3) return [
|
|
495
|
+
parseInt(h[0] + h[0], 16),
|
|
496
|
+
parseInt(h[1] + h[1], 16),
|
|
497
|
+
parseInt(h[2] + h[2], 16)
|
|
498
|
+
];
|
|
499
|
+
if (h.length === 6) return [
|
|
500
|
+
parseInt(h.slice(0, 2), 16),
|
|
501
|
+
parseInt(h.slice(2, 4), 16),
|
|
502
|
+
parseInt(h.slice(4, 6), 16)
|
|
503
|
+
];
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
/** Convert [r, g, b] (0-255) to hex string. */
|
|
507
|
+
function rgbToHex(r, g, b) {
|
|
508
|
+
const clamp = (n) => Math.max(0, Math.min(255, Math.round(n)));
|
|
509
|
+
return `#${clamp(r).toString(16).padStart(2, "0")}${clamp(g).toString(16).padStart(2, "0")}${clamp(b).toString(16).padStart(2, "0")}`.toUpperCase();
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Blend two hex colors. t=0 returns a, t=1 returns b.
|
|
513
|
+
* For non-hex inputs (ANSI names), returns `a` unchanged.
|
|
514
|
+
*/
|
|
515
|
+
function blend(a, b, t) {
|
|
516
|
+
const rgbA = hexToRgb(a);
|
|
517
|
+
const rgbB = hexToRgb(b);
|
|
518
|
+
if (!rgbA || !rgbB) return a;
|
|
519
|
+
return rgbToHex(rgbA[0] + (rgbB[0] - rgbA[0]) * t, rgbA[1] + (rgbB[1] - rgbA[1]) * t, rgbA[2] + (rgbB[2] - rgbA[2]) * t);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Brighten a hex color. amount=0.1 adds 10% lightness toward white.
|
|
523
|
+
* For non-hex inputs (ANSI names), returns the color unchanged.
|
|
524
|
+
*/
|
|
525
|
+
function brighten(color, amount) {
|
|
526
|
+
return blend(color, "#FFFFFF", amount);
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Darken a hex color. amount=0.1 adds 10% darkness toward black.
|
|
530
|
+
* For non-hex inputs (ANSI names), returns the color unchanged.
|
|
531
|
+
*/
|
|
532
|
+
function darken(color, amount) {
|
|
533
|
+
return blend(color, "#000000", amount);
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Linearize an sRGB channel value (0-255) for luminance calculation.
|
|
537
|
+
* Per WCAG 2.1: values below the threshold use a linear scale,
|
|
538
|
+
* above use the gamma-corrected formula.
|
|
539
|
+
*/
|
|
540
|
+
function channelLuminance(c) {
|
|
541
|
+
const s = c / 255;
|
|
542
|
+
return s <= .03928 ? s / 12.92 : Math.pow((s + .055) / 1.055, 2.4);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Compute relative luminance of a hex color per WCAG 2.1.
|
|
546
|
+
* Returns a value between 0 (darkest) and 1 (lightest), or null for invalid input.
|
|
547
|
+
*/
|
|
548
|
+
function relativeLuminance(hex) {
|
|
549
|
+
const rgb = hexToRgb(hex);
|
|
550
|
+
if (!rgb) return null;
|
|
551
|
+
return .2126 * channelLuminance(rgb[0]) + .7152 * channelLuminance(rgb[1]) + .0722 * channelLuminance(rgb[2]);
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Pick black or white text for readability on the given background.
|
|
555
|
+
* Uses relative luminance (WCAG formula).
|
|
556
|
+
*/
|
|
557
|
+
function contrastFg(bg) {
|
|
558
|
+
const luminance = relativeLuminance(bg);
|
|
559
|
+
if (luminance === null) return "#FFFFFF";
|
|
560
|
+
return luminance > .179 ? "#000000" : "#FFFFFF";
|
|
561
|
+
}
|
|
562
|
+
function rgbToHsl(r, g, b) {
|
|
563
|
+
r /= 255;
|
|
564
|
+
g /= 255;
|
|
565
|
+
b /= 255;
|
|
566
|
+
const max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
567
|
+
const l = (max + min) / 2;
|
|
568
|
+
if (max === min) return [
|
|
569
|
+
0,
|
|
570
|
+
0,
|
|
571
|
+
l
|
|
572
|
+
];
|
|
573
|
+
const d = max - min;
|
|
574
|
+
const s = l > .5 ? d / (2 - max - min) : d / (max + min);
|
|
575
|
+
let h = 0;
|
|
576
|
+
if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
577
|
+
else if (max === g) h = ((b - r) / d + 2) / 6;
|
|
578
|
+
else h = ((r - g) / d + 4) / 6;
|
|
579
|
+
return [
|
|
580
|
+
h * 360,
|
|
581
|
+
s,
|
|
582
|
+
l
|
|
583
|
+
];
|
|
584
|
+
}
|
|
585
|
+
function hslToHex(h, s, l) {
|
|
586
|
+
h = (h % 360 + 360) % 360;
|
|
587
|
+
const a = s * Math.min(l, 1 - l);
|
|
588
|
+
const f = (n) => {
|
|
589
|
+
const k = (n + h / 30) % 12;
|
|
590
|
+
return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
591
|
+
};
|
|
592
|
+
return rgbToHex(f(0) * 255, f(8) * 255, f(4) * 255);
|
|
593
|
+
}
|
|
594
|
+
function hexToHsl(hex) {
|
|
595
|
+
const rgb = hexToRgb(hex);
|
|
596
|
+
if (!rgb) return null;
|
|
597
|
+
return rgbToHsl(rgb[0], rgb[1], rgb[2]);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Desaturate a hex color by reducing saturation.
|
|
601
|
+
* amount=0.4 reduces saturation by 40%.
|
|
602
|
+
* For non-hex inputs, returns the color unchanged.
|
|
603
|
+
*/
|
|
604
|
+
function desaturate(color, amount) {
|
|
605
|
+
const hsl = hexToHsl(color);
|
|
606
|
+
if (!hsl) return color;
|
|
607
|
+
const [h, s, l] = hsl;
|
|
608
|
+
return hslToHex(h, s * (1 - amount), l);
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Get the complementary color (180° hue rotation).
|
|
612
|
+
* For non-hex inputs, returns the color unchanged.
|
|
613
|
+
*/
|
|
614
|
+
function complement(color) {
|
|
615
|
+
const hsl = hexToHsl(color);
|
|
616
|
+
if (!hsl) return color;
|
|
617
|
+
const [h, s, l] = hsl;
|
|
618
|
+
return hslToHex(h + 180, s, l);
|
|
619
|
+
}
|
|
620
|
+
var init_color = __esmMin((() => {}));
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region packages/color/src/contrast.ts
|
|
623
|
+
/**
|
|
624
|
+
* Check contrast ratio between foreground and background colors.
|
|
625
|
+
*
|
|
626
|
+
* Uses the WCAG 2.1 relative luminance formula to compute the contrast
|
|
627
|
+
* ratio and check AA (>= 4.5:1) and AAA (>= 7:1) compliance for normal text.
|
|
628
|
+
*
|
|
629
|
+
* @param fg - Foreground hex color (e.g. "#FFFFFF")
|
|
630
|
+
* @param bg - Background hex color (e.g. "#000000")
|
|
631
|
+
* @returns Contrast ratio and AA/AAA pass/fail, or null if colors are not valid hex
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* const result = checkContrast("#FFFFFF", "#000000")
|
|
636
|
+
* // { ratio: 21, aa: true, aaa: true }
|
|
637
|
+
*
|
|
638
|
+
* const poor = checkContrast("#777777", "#888888")
|
|
639
|
+
* // { ratio: ~1.3, aa: false, aaa: false }
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
function checkContrast(fg, bg) {
|
|
643
|
+
const fgLum = relativeLuminance(fg);
|
|
644
|
+
const bgLum = relativeLuminance(bg);
|
|
645
|
+
if (fgLum === null || bgLum === null) return null;
|
|
646
|
+
const lighter = Math.max(fgLum, bgLum);
|
|
647
|
+
const darker = Math.min(fgLum, bgLum);
|
|
648
|
+
const ratio = (lighter + .05) / (darker + .05);
|
|
649
|
+
return {
|
|
650
|
+
ratio,
|
|
651
|
+
aa: ratio >= 4.5,
|
|
652
|
+
aaa: ratio >= 7
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Adjust a color's lightness until it meets a minimum contrast ratio
|
|
657
|
+
* against a reference color. Preserves hue and saturation — only
|
|
658
|
+
* lightness is shifted, and only as much as needed.
|
|
659
|
+
*
|
|
660
|
+
* Returns the original color unchanged if it already meets the target.
|
|
661
|
+
*
|
|
662
|
+
* @param color - The color to adjust (hex)
|
|
663
|
+
* @param against - The reference background color (hex)
|
|
664
|
+
* @param minRatio - Minimum contrast ratio to achieve (e.g. 4.5 for AA)
|
|
665
|
+
* @returns Adjusted hex color meeting the target, or original if already OK
|
|
666
|
+
*
|
|
667
|
+
* For impossible targets (e.g. 21:1 against mid-gray), returns the
|
|
668
|
+
* best achievable color (near-black or near-white in the same hue).
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```typescript
|
|
672
|
+
* // Yellow on white — too low contrast, gets darkened
|
|
673
|
+
* ensureContrast("#FFAB91", "#FFFFFF", 4.5) // → "#B35600" (darker orange)
|
|
674
|
+
*
|
|
675
|
+
* // Blue on dark bg — already fine, returned unchanged
|
|
676
|
+
* ensureContrast("#5C9FFF", "#1A1A2E", 4.5) // → "#5C9FFF"
|
|
677
|
+
* ```
|
|
678
|
+
*/
|
|
679
|
+
function ensureContrast(color, against, minRatio) {
|
|
680
|
+
const current = checkContrast(color, against);
|
|
681
|
+
if (!current) return color;
|
|
682
|
+
if (current.ratio >= minRatio) return color;
|
|
683
|
+
const hsl = hexToHsl(color);
|
|
684
|
+
if (!hsl) return color;
|
|
685
|
+
const [h, s] = hsl;
|
|
686
|
+
const lightBg = contrastFg(against) === "#000000";
|
|
687
|
+
let lo, hi;
|
|
688
|
+
if (lightBg) {
|
|
689
|
+
lo = 0;
|
|
690
|
+
hi = hsl[2];
|
|
691
|
+
} else {
|
|
692
|
+
lo = hsl[2];
|
|
693
|
+
hi = 1;
|
|
694
|
+
}
|
|
695
|
+
for (let i = 0; i < 20; i++) {
|
|
696
|
+
const mid = (lo + hi) / 2;
|
|
697
|
+
const r = checkContrast(hslToHex(h, s, mid), against);
|
|
698
|
+
if (!r) break;
|
|
699
|
+
if (lightBg) if (r.ratio >= minRatio) lo = mid;
|
|
700
|
+
else hi = mid;
|
|
701
|
+
else if (r.ratio >= minRatio) hi = mid;
|
|
702
|
+
else lo = mid;
|
|
703
|
+
}
|
|
704
|
+
return hslToHex(h, s, lightBg ? lo : hi);
|
|
705
|
+
}
|
|
706
|
+
var init_contrast = __esmMin((() => {
|
|
707
|
+
init_color();
|
|
708
|
+
}));
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region packages/color/src/index.ts
|
|
711
|
+
var init_src$1 = __esmMin((() => {
|
|
712
|
+
init_color();
|
|
713
|
+
init_contrast();
|
|
714
|
+
}));
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region packages/ansi/src/style/colors.ts
|
|
717
|
+
var THEME_TOKEN_DEFAULTS;
|
|
718
|
+
var init_colors = __esmMin((() => {
|
|
719
|
+
init_src$1();
|
|
720
|
+
init_color_maps();
|
|
721
|
+
THEME_TOKEN_DEFAULTS = {
|
|
722
|
+
primary: 33,
|
|
723
|
+
secondary: 36,
|
|
724
|
+
accent: 35,
|
|
725
|
+
error: 31,
|
|
726
|
+
warning: 33,
|
|
727
|
+
success: 32,
|
|
728
|
+
info: 36,
|
|
729
|
+
muted: 2,
|
|
730
|
+
link: 34,
|
|
731
|
+
border: 90,
|
|
732
|
+
surface: 37
|
|
733
|
+
};
|
|
734
|
+
}));
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region packages/ansi/src/style/style.ts
|
|
737
|
+
/**
|
|
738
|
+
* Resolve a color value against a theme — the canonical token resolver.
|
|
739
|
+
*
|
|
740
|
+
* If the color starts with `$`, looks up the token in the theme.
|
|
741
|
+
* Supports `$primary`, `$surface-bg` (hyphens stripped), `$color0`–`$color15` (palette).
|
|
742
|
+
* Non-`$` strings pass through unchanged. Returns undefined if no theme or unknown token.
|
|
743
|
+
*
|
|
744
|
+
* Compatible with @silvery/theme's Theme type (or any object with string properties).
|
|
745
|
+
*/
|
|
746
|
+
function resolveThemeColor(name, theme) {
|
|
747
|
+
if (!name) return void 0;
|
|
748
|
+
if (!name.startsWith("$")) return name;
|
|
749
|
+
if (!theme) return void 0;
|
|
750
|
+
return resolveToken(name, theme);
|
|
751
|
+
}
|
|
752
|
+
/** Internal: resolve a token name (with or without $ prefix) against a theme. */
|
|
753
|
+
function resolveToken(name, theme) {
|
|
754
|
+
if (!theme) return void 0;
|
|
755
|
+
const token = name.startsWith("$") ? name.slice(1) : name;
|
|
756
|
+
if (token.startsWith("color")) {
|
|
757
|
+
const idx = parseInt(token.slice(5), 10);
|
|
758
|
+
if (idx >= 0 && idx < 16 && theme.palette && idx < theme.palette.length) return theme.palette[idx];
|
|
759
|
+
}
|
|
760
|
+
const val = theme[token.replace(/-/g, "")];
|
|
761
|
+
return typeof val === "string" ? val : void 0;
|
|
762
|
+
}
|
|
763
|
+
/** Convert chalk numeric level (0-3) to ColorLevel. */
|
|
764
|
+
function fromChalkLevel(n) {
|
|
765
|
+
if (n <= 0) return null;
|
|
766
|
+
if (n === 1) return "basic";
|
|
767
|
+
if (n === 2) return "256";
|
|
768
|
+
return "truecolor";
|
|
769
|
+
}
|
|
770
|
+
/** Convert ColorLevel to chalk numeric level (0-3). */
|
|
771
|
+
function toChalkLevel(cl) {
|
|
772
|
+
if (cl === null) return 0;
|
|
773
|
+
if (cl === "basic") return 1;
|
|
774
|
+
if (cl === "256") return 2;
|
|
775
|
+
return 3;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Create a style object for terminal output.
|
|
779
|
+
*
|
|
780
|
+
* @param options - Color level and optional theme
|
|
781
|
+
* @returns A chainable style object (chalk-compatible API)
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* ```ts
|
|
785
|
+
* import { createStyle } from "@silvery/ansi"
|
|
786
|
+
*
|
|
787
|
+
* const s = createStyle()
|
|
788
|
+
* console.log(s.bold.red("Error!"))
|
|
789
|
+
* console.log(s.hex("#818cf8")("Indigo"))
|
|
790
|
+
*
|
|
791
|
+
* // With theme
|
|
792
|
+
* const s = createStyle({ theme })
|
|
793
|
+
* console.log(s.primary("Deploy"))
|
|
794
|
+
* console.log(s.success("Done"))
|
|
795
|
+
* ```
|
|
796
|
+
*/
|
|
797
|
+
function createStyle(options) {
|
|
798
|
+
const ref = {
|
|
799
|
+
level: null,
|
|
800
|
+
theme: options?.theme
|
|
801
|
+
};
|
|
802
|
+
if (options?.level !== void 0) ref.level = options.level;
|
|
803
|
+
else try {
|
|
804
|
+
ref.level = detectColor(process.stdout);
|
|
805
|
+
} catch {
|
|
806
|
+
ref.level = null;
|
|
807
|
+
}
|
|
808
|
+
return createChainWithRef({
|
|
809
|
+
opens: [],
|
|
810
|
+
closes: []
|
|
811
|
+
}, ref);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Create a chain that reads level from a mutable ref.
|
|
815
|
+
* This allows `style.level = 3` to affect all subsequent calls.
|
|
816
|
+
*/
|
|
817
|
+
function createChainWithRef(state, ref) {
|
|
818
|
+
const proxyRef = { proxy: null };
|
|
819
|
+
const handler = {
|
|
820
|
+
apply(_target, _thisArg, args) {
|
|
821
|
+
const level = ref.level;
|
|
822
|
+
if (state.visible && level === null) return "";
|
|
823
|
+
let text;
|
|
824
|
+
if (args.length === 0) text = "";
|
|
825
|
+
else if (Array.isArray(args[0]) && "raw" in args[0]) text = String.raw(args[0], ...args.slice(1));
|
|
826
|
+
else if (args.length > 1) text = args.map((a) => String(a ?? "")).join(" ");
|
|
827
|
+
else text = String(args[0] ?? "");
|
|
828
|
+
if (text === "") return "";
|
|
829
|
+
if (level === null || state.opens.length === 0) return text;
|
|
830
|
+
const open = `${ESC$2}${state.opens.join(";")}m`;
|
|
831
|
+
const close = `${ESC$2}${state.closes.join(";")}m`;
|
|
832
|
+
for (const closeCode of state.closes) {
|
|
833
|
+
const closeSeq = `${ESC$2}${closeCode}m`;
|
|
834
|
+
const parts = text.split(closeSeq);
|
|
835
|
+
if (parts.length > 1) text = parts.join(`${closeSeq}${open}`);
|
|
836
|
+
}
|
|
837
|
+
if (text.includes("\n")) text = text.replace(/\r?\n/g, `${close}$&${open}`);
|
|
838
|
+
return `${open}${text}${close}`;
|
|
839
|
+
},
|
|
840
|
+
get(_target, prop) {
|
|
841
|
+
if (typeof prop === "symbol") return void 0;
|
|
842
|
+
if (prop === "level") return toChalkLevel(ref.level);
|
|
843
|
+
if (prop === "resolve") return (token) => resolveToken(token, ref.theme);
|
|
844
|
+
if (prop === "visible") return createChainWithRef({
|
|
845
|
+
...state,
|
|
846
|
+
visible: true
|
|
847
|
+
}, ref);
|
|
848
|
+
if (prop === "call" || prop === "apply" || prop === "bind") return Function.prototype[prop].bind(proxyRef.proxy);
|
|
849
|
+
const level = ref.level;
|
|
850
|
+
if (prop === "hex" || prop === "bgHex") return (color) => {
|
|
851
|
+
if (level === null) return createChainWithRef(state, ref);
|
|
852
|
+
const rgb = hexToRgb(color);
|
|
853
|
+
if (!rgb) return createChainWithRef(state, ref);
|
|
854
|
+
const code = prop === "hex" ? fgFromRgb(rgb[0], rgb[1], rgb[2], level) : bgFromRgb(rgb[0], rgb[1], rgb[2], level);
|
|
855
|
+
const close = prop === "hex" ? "39" : "49";
|
|
856
|
+
return createChainWithRef({
|
|
857
|
+
opens: [...state.opens, code],
|
|
858
|
+
closes: [...state.closes, close]
|
|
859
|
+
}, ref);
|
|
860
|
+
};
|
|
861
|
+
if (prop === "rgb" || prop === "bgRgb") return (r, g, b) => {
|
|
862
|
+
if (level === null) return createChainWithRef(state, ref);
|
|
863
|
+
const code = prop === "rgb" ? fgFromRgb(r, g, b, level) : bgFromRgb(r, g, b, level);
|
|
864
|
+
const close = prop === "rgb" ? "39" : "49";
|
|
865
|
+
return createChainWithRef({
|
|
866
|
+
opens: [...state.opens, code],
|
|
867
|
+
closes: [...state.closes, close]
|
|
868
|
+
}, ref);
|
|
869
|
+
};
|
|
870
|
+
if (prop === "ansi256") return (code) => {
|
|
871
|
+
if (level === null) return createChainWithRef(state, ref);
|
|
872
|
+
return createChainWithRef({
|
|
873
|
+
opens: [...state.opens, `38;5;${code}`],
|
|
874
|
+
closes: [...state.closes, "39"]
|
|
875
|
+
}, ref);
|
|
876
|
+
};
|
|
877
|
+
if (prop === "bgAnsi256") return (code) => {
|
|
878
|
+
if (level === null) return createChainWithRef(state, ref);
|
|
879
|
+
return createChainWithRef({
|
|
880
|
+
opens: [...state.opens, `48;5;${code}`],
|
|
881
|
+
closes: [...state.closes, "49"]
|
|
882
|
+
}, ref);
|
|
883
|
+
};
|
|
884
|
+
if (prop in MODIFIERS) {
|
|
885
|
+
if (level === null) return createChainWithRef(state, ref);
|
|
886
|
+
const [open, close] = MODIFIERS[prop];
|
|
887
|
+
return createChainWithRef({
|
|
888
|
+
opens: [...state.opens, String(open)],
|
|
889
|
+
closes: [...state.closes, String(close)]
|
|
890
|
+
}, ref);
|
|
891
|
+
}
|
|
892
|
+
if (prop in FG_COLORS) {
|
|
893
|
+
if (level === null) return createChainWithRef(state, ref);
|
|
894
|
+
return createChainWithRef({
|
|
895
|
+
opens: [...state.opens, String(FG_COLORS[prop])],
|
|
896
|
+
closes: [...state.closes, "39"]
|
|
897
|
+
}, ref);
|
|
898
|
+
}
|
|
899
|
+
if (prop in BG_COLORS) {
|
|
900
|
+
if (level === null) return createChainWithRef(state, ref);
|
|
901
|
+
return createChainWithRef({
|
|
902
|
+
opens: [...state.opens, String(BG_COLORS[prop])],
|
|
903
|
+
closes: [...state.closes, "49"]
|
|
904
|
+
}, ref);
|
|
905
|
+
}
|
|
906
|
+
if (THEME_TOKENS.has(prop)) {
|
|
907
|
+
if (level === null) return createChainWithRef(state, ref);
|
|
908
|
+
const hex = resolveToken(prop, ref.theme);
|
|
909
|
+
if (hex) {
|
|
910
|
+
const rgb = hexToRgb(hex);
|
|
911
|
+
if (rgb) {
|
|
912
|
+
const code = fgFromRgb(rgb[0], rgb[1], rgb[2], level);
|
|
913
|
+
if (prop === "link") return createChainWithRef({
|
|
914
|
+
opens: [
|
|
915
|
+
...state.opens,
|
|
916
|
+
code,
|
|
917
|
+
"4"
|
|
918
|
+
],
|
|
919
|
+
closes: [
|
|
920
|
+
...state.closes,
|
|
921
|
+
"39",
|
|
922
|
+
"24"
|
|
923
|
+
]
|
|
924
|
+
}, ref);
|
|
925
|
+
return createChainWithRef({
|
|
926
|
+
opens: [...state.opens, code],
|
|
927
|
+
closes: [...state.closes, "39"]
|
|
928
|
+
}, ref);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
const fallback = THEME_TOKEN_DEFAULTS[prop];
|
|
932
|
+
if (fallback !== void 0) {
|
|
933
|
+
if (prop === "muted") return createChainWithRef({
|
|
934
|
+
opens: [...state.opens, String(fallback)],
|
|
935
|
+
closes: [...state.closes, "22"]
|
|
936
|
+
}, ref);
|
|
937
|
+
if (prop === "link") return createChainWithRef({
|
|
938
|
+
opens: [
|
|
939
|
+
...state.opens,
|
|
940
|
+
String(fallback),
|
|
941
|
+
"4"
|
|
942
|
+
],
|
|
943
|
+
closes: [
|
|
944
|
+
...state.closes,
|
|
945
|
+
"39",
|
|
946
|
+
"24"
|
|
947
|
+
]
|
|
948
|
+
}, ref);
|
|
949
|
+
return createChainWithRef({
|
|
950
|
+
opens: [...state.opens, String(fallback)],
|
|
951
|
+
closes: [...state.closes, "39"]
|
|
952
|
+
}, ref);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
set(_target, prop, value) {
|
|
957
|
+
if (prop === "level") {
|
|
958
|
+
ref.level = fromChalkLevel(value);
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
961
|
+
return false;
|
|
962
|
+
},
|
|
963
|
+
has(_target, prop) {
|
|
964
|
+
if (prop === "level") return true;
|
|
965
|
+
if (typeof prop === "symbol") return false;
|
|
966
|
+
return prop in MODIFIERS || prop in FG_COLORS || prop in BG_COLORS || THEME_TOKENS.has(prop) || KNOWN_METHODS.has(prop);
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
const target = function() {};
|
|
970
|
+
const proxy = new Proxy(target, handler);
|
|
971
|
+
proxyRef.proxy = proxy;
|
|
972
|
+
return proxy;
|
|
973
|
+
}
|
|
974
|
+
var ESC$2, KNOWN_METHODS, THEME_TOKENS;
|
|
975
|
+
var init_style = __esmMin((() => {
|
|
976
|
+
init_detection();
|
|
977
|
+
init_colors();
|
|
978
|
+
ESC$2 = "\x1B[";
|
|
979
|
+
KNOWN_METHODS = new Set([
|
|
980
|
+
"hex",
|
|
981
|
+
"rgb",
|
|
982
|
+
"bgHex",
|
|
983
|
+
"bgRgb",
|
|
984
|
+
"ansi256",
|
|
985
|
+
"bgAnsi256",
|
|
986
|
+
"resolve"
|
|
987
|
+
]);
|
|
988
|
+
THEME_TOKENS = new Set([
|
|
989
|
+
"primary",
|
|
990
|
+
"secondary",
|
|
991
|
+
"accent",
|
|
992
|
+
"error",
|
|
993
|
+
"warning",
|
|
994
|
+
"success",
|
|
995
|
+
"info",
|
|
996
|
+
"muted",
|
|
997
|
+
"link",
|
|
998
|
+
"border",
|
|
999
|
+
"surface"
|
|
1000
|
+
]);
|
|
1001
|
+
createStyle();
|
|
1002
|
+
}));
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region packages/ansi/src/style/mixed-proxy.ts
|
|
1005
|
+
/**
|
|
1006
|
+
* Create a proxy that wraps a style instance with additional properties.
|
|
1007
|
+
*
|
|
1008
|
+
* The proxy makes the result:
|
|
1009
|
+
* - Callable: result('text') applies current styles
|
|
1010
|
+
* - Chainable: result.bold.red('text') chains styles
|
|
1011
|
+
* - Extended: result.anyExtraProp accesses extra properties
|
|
1012
|
+
*
|
|
1013
|
+
* Extra properties take priority over style properties on name collision.
|
|
1014
|
+
*/
|
|
1015
|
+
function createMixedStyle(style, extra) {
|
|
1016
|
+
return createChainProxy(style, extra);
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Internal recursive proxy builder for style chain + extra properties.
|
|
1020
|
+
*/
|
|
1021
|
+
function createChainProxy(currentStyle, extra) {
|
|
1022
|
+
const handler = {
|
|
1023
|
+
apply(_target, _thisArg, args) {
|
|
1024
|
+
return currentStyle(...args);
|
|
1025
|
+
},
|
|
1026
|
+
get(_target, prop) {
|
|
1027
|
+
if (prop in extra) {
|
|
1028
|
+
const value = extra[prop];
|
|
1029
|
+
if (typeof value === "function") return value;
|
|
1030
|
+
return value;
|
|
1031
|
+
}
|
|
1032
|
+
if (typeof prop === "symbol") {
|
|
1033
|
+
if (prop === Symbol.dispose) return extra[Symbol.dispose];
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
if (STYLE_METHODS.has(prop)) {
|
|
1037
|
+
const method = currentStyle[prop];
|
|
1038
|
+
if (typeof method === "function") return (...args) => {
|
|
1039
|
+
return createChainProxy(method.apply(currentStyle, args), extra);
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
const styleProp = currentStyle[prop];
|
|
1043
|
+
if (styleProp !== void 0) {
|
|
1044
|
+
if (typeof styleProp === "function" || typeof styleProp === "object") return createChainProxy(styleProp, extra);
|
|
1045
|
+
return styleProp;
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
set(_target, prop, value) {
|
|
1049
|
+
extra[prop] = value;
|
|
1050
|
+
return true;
|
|
1051
|
+
},
|
|
1052
|
+
defineProperty(_target, prop, descriptor) {
|
|
1053
|
+
Object.defineProperty(extra, prop, descriptor);
|
|
1054
|
+
return true;
|
|
1055
|
+
},
|
|
1056
|
+
has(_target, prop) {
|
|
1057
|
+
if (prop in extra) return true;
|
|
1058
|
+
if (typeof prop === "string" && prop in currentStyle) return true;
|
|
1059
|
+
return false;
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
const proxyTarget = function() {};
|
|
1063
|
+
return new Proxy(proxyTarget, handler);
|
|
1064
|
+
}
|
|
1065
|
+
var STYLE_METHODS;
|
|
1066
|
+
var init_mixed_proxy = __esmMin((() => {
|
|
1067
|
+
STYLE_METHODS = new Set([
|
|
1068
|
+
"hex",
|
|
1069
|
+
"bgHex",
|
|
1070
|
+
"rgb",
|
|
1071
|
+
"bgRgb",
|
|
1072
|
+
"ansi256",
|
|
1073
|
+
"bgAnsi256"
|
|
1074
|
+
]);
|
|
1075
|
+
}));
|
|
1076
|
+
//#endregion
|
|
1077
|
+
//#region packages/ansi/src/theme/derive.ts
|
|
1078
|
+
function deriveTheme(palette, mode = "truecolor", adjustments) {
|
|
1079
|
+
if (mode === "ansi16") return deriveAnsi16Theme(palette);
|
|
1080
|
+
return deriveTruecolorTheme(palette, adjustments);
|
|
1081
|
+
}
|
|
1082
|
+
function deriveTruecolorTheme(p, adjustments) {
|
|
1083
|
+
const dark = p.dark ?? true;
|
|
1084
|
+
const bg = p.background;
|
|
1085
|
+
function ensure(token, color, against, target) {
|
|
1086
|
+
const result = ensureContrast(color, against, target);
|
|
1087
|
+
if (adjustments && result !== color) {
|
|
1088
|
+
const before = checkContrast(color, against);
|
|
1089
|
+
const after = checkContrast(result, against);
|
|
1090
|
+
adjustments.push({
|
|
1091
|
+
token,
|
|
1092
|
+
from: color,
|
|
1093
|
+
to: result,
|
|
1094
|
+
against,
|
|
1095
|
+
target,
|
|
1096
|
+
ratioBefore: before?.ratio ?? 0,
|
|
1097
|
+
ratioAfter: after?.ratio ?? 0
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
return result;
|
|
1101
|
+
}
|
|
1102
|
+
const surfacebg = blend(bg, p.foreground, .05);
|
|
1103
|
+
const popoverbg = blend(bg, p.foreground, .08);
|
|
1104
|
+
const fg = ensure("fg", p.foreground, popoverbg, AA);
|
|
1105
|
+
const primary = ensure("primary", p.primary ?? (dark ? p.yellow : p.blue), bg, AA);
|
|
1106
|
+
const accent = ensure("accent", complement(primary), bg, AA);
|
|
1107
|
+
const secondary = ensure("secondary", blend(primary, accent, .35), bg, AA);
|
|
1108
|
+
const error = ensure("error", p.red, bg, AA);
|
|
1109
|
+
const warning = ensure("warning", p.yellow, bg, AA);
|
|
1110
|
+
const success = ensure("success", p.green, bg, AA);
|
|
1111
|
+
const info = ensure("info", blend(fg, accent, .5), bg, AA);
|
|
1112
|
+
const link = ensure("link", dark ? p.brightBlue : p.blue, bg, AA);
|
|
1113
|
+
const mutedbg = blend(bg, p.foreground, .04);
|
|
1114
|
+
const muted = ensure("muted", blend(fg, bg, .4), mutedbg, AA);
|
|
1115
|
+
const disabledfg = ensure("disabledfg", blend(fg, bg, .5), bg, DIM);
|
|
1116
|
+
const border = ensure("border", blend(bg, p.foreground, .15), bg, FAINT);
|
|
1117
|
+
const inputborder = ensure("inputborder", blend(bg, p.foreground, .25), bg, CONTROL);
|
|
1118
|
+
const selection = ensure("selection", p.selectionForeground, p.selectionBackground, AA);
|
|
1119
|
+
const cursor = ensure("cursor", p.cursorText, p.cursorColor, AA);
|
|
1120
|
+
return {
|
|
1121
|
+
name: p.name ?? (dark ? "derived-dark" : "derived-light"),
|
|
1122
|
+
bg,
|
|
1123
|
+
fg,
|
|
1124
|
+
muted,
|
|
1125
|
+
mutedbg,
|
|
1126
|
+
surface: fg,
|
|
1127
|
+
surfacebg,
|
|
1128
|
+
popover: fg,
|
|
1129
|
+
popoverbg,
|
|
1130
|
+
inverse: contrastFg(blend(fg, bg, .1)),
|
|
1131
|
+
inversebg: blend(fg, bg, .1),
|
|
1132
|
+
cursor,
|
|
1133
|
+
cursorbg: p.cursorColor,
|
|
1134
|
+
selection,
|
|
1135
|
+
selectionbg: p.selectionBackground,
|
|
1136
|
+
primary,
|
|
1137
|
+
primaryfg: contrastFg(primary),
|
|
1138
|
+
secondary,
|
|
1139
|
+
secondaryfg: contrastFg(secondary),
|
|
1140
|
+
accent,
|
|
1141
|
+
accentfg: contrastFg(accent),
|
|
1142
|
+
error,
|
|
1143
|
+
errorfg: contrastFg(error),
|
|
1144
|
+
warning,
|
|
1145
|
+
warningfg: contrastFg(warning),
|
|
1146
|
+
success,
|
|
1147
|
+
successfg: contrastFg(success),
|
|
1148
|
+
info,
|
|
1149
|
+
infofg: contrastFg(info),
|
|
1150
|
+
border,
|
|
1151
|
+
inputborder,
|
|
1152
|
+
focusborder: link,
|
|
1153
|
+
link,
|
|
1154
|
+
disabledfg,
|
|
1155
|
+
palette: [
|
|
1156
|
+
p.black,
|
|
1157
|
+
p.red,
|
|
1158
|
+
p.green,
|
|
1159
|
+
p.yellow,
|
|
1160
|
+
p.blue,
|
|
1161
|
+
p.magenta,
|
|
1162
|
+
p.cyan,
|
|
1163
|
+
p.white,
|
|
1164
|
+
p.brightBlack,
|
|
1165
|
+
p.brightRed,
|
|
1166
|
+
p.brightGreen,
|
|
1167
|
+
p.brightYellow,
|
|
1168
|
+
p.brightBlue,
|
|
1169
|
+
p.brightMagenta,
|
|
1170
|
+
p.brightCyan,
|
|
1171
|
+
p.brightWhite
|
|
1172
|
+
]
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
function deriveAnsi16Theme(p) {
|
|
1176
|
+
const dark = p.dark ?? true;
|
|
1177
|
+
const primaryColor = dark ? p.yellow : p.blue;
|
|
1178
|
+
return {
|
|
1179
|
+
name: p.name ?? (dark ? "derived-ansi16-dark" : "derived-ansi16-light"),
|
|
1180
|
+
bg: p.background,
|
|
1181
|
+
fg: p.foreground,
|
|
1182
|
+
muted: p.white,
|
|
1183
|
+
mutedbg: p.black,
|
|
1184
|
+
surface: p.foreground,
|
|
1185
|
+
surfacebg: p.black,
|
|
1186
|
+
popover: p.foreground,
|
|
1187
|
+
popoverbg: p.black,
|
|
1188
|
+
inverse: p.black,
|
|
1189
|
+
inversebg: p.brightWhite,
|
|
1190
|
+
cursor: p.cursorText,
|
|
1191
|
+
cursorbg: p.cursorColor,
|
|
1192
|
+
selection: p.selectionForeground,
|
|
1193
|
+
selectionbg: p.selectionBackground,
|
|
1194
|
+
primary: primaryColor,
|
|
1195
|
+
primaryfg: p.black,
|
|
1196
|
+
secondary: p.magenta,
|
|
1197
|
+
secondaryfg: p.black,
|
|
1198
|
+
accent: p.cyan,
|
|
1199
|
+
accentfg: p.black,
|
|
1200
|
+
error: dark ? p.brightRed : p.red,
|
|
1201
|
+
errorfg: p.black,
|
|
1202
|
+
warning: p.yellow,
|
|
1203
|
+
warningfg: p.black,
|
|
1204
|
+
success: dark ? p.brightGreen : p.green,
|
|
1205
|
+
successfg: p.black,
|
|
1206
|
+
info: p.cyan,
|
|
1207
|
+
infofg: p.black,
|
|
1208
|
+
border: p.brightBlack,
|
|
1209
|
+
inputborder: p.brightBlack,
|
|
1210
|
+
focusborder: dark ? p.brightBlue : p.blue,
|
|
1211
|
+
link: dark ? p.brightBlue : p.blue,
|
|
1212
|
+
disabledfg: p.brightBlack,
|
|
1213
|
+
palette: [
|
|
1214
|
+
p.black,
|
|
1215
|
+
p.red,
|
|
1216
|
+
p.green,
|
|
1217
|
+
p.yellow,
|
|
1218
|
+
p.blue,
|
|
1219
|
+
p.magenta,
|
|
1220
|
+
p.cyan,
|
|
1221
|
+
p.white,
|
|
1222
|
+
p.brightBlack,
|
|
1223
|
+
p.brightRed,
|
|
1224
|
+
p.brightGreen,
|
|
1225
|
+
p.brightYellow,
|
|
1226
|
+
p.brightBlue,
|
|
1227
|
+
p.brightMagenta,
|
|
1228
|
+
p.brightCyan,
|
|
1229
|
+
p.brightWhite
|
|
1230
|
+
]
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
var AA, DIM, FAINT, CONTROL;
|
|
1234
|
+
var init_derive = __esmMin((() => {
|
|
1235
|
+
init_src$1();
|
|
1236
|
+
AA = 4.5;
|
|
1237
|
+
DIM = 3;
|
|
1238
|
+
FAINT = 1.5;
|
|
1239
|
+
CONTROL = 3;
|
|
1240
|
+
}));
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region packages/ansi/src/theme/default-palettes.ts
|
|
1243
|
+
var ansi16DarkTheme, ansi16LightTheme;
|
|
1244
|
+
var init_default_palettes = __esmMin((() => {
|
|
1245
|
+
ansi16DarkTheme = {
|
|
1246
|
+
name: "dark-ansi16",
|
|
1247
|
+
bg: "",
|
|
1248
|
+
fg: "whiteBright",
|
|
1249
|
+
muted: "white",
|
|
1250
|
+
mutedbg: "black",
|
|
1251
|
+
surface: "whiteBright",
|
|
1252
|
+
surfacebg: "black",
|
|
1253
|
+
popover: "whiteBright",
|
|
1254
|
+
popoverbg: "black",
|
|
1255
|
+
inverse: "black",
|
|
1256
|
+
inversebg: "whiteBright",
|
|
1257
|
+
cursor: "black",
|
|
1258
|
+
cursorbg: "yellow",
|
|
1259
|
+
selection: "black",
|
|
1260
|
+
selectionbg: "yellow",
|
|
1261
|
+
primary: "yellow",
|
|
1262
|
+
primaryfg: "black",
|
|
1263
|
+
secondary: "white",
|
|
1264
|
+
secondaryfg: "black",
|
|
1265
|
+
accent: "blueBright",
|
|
1266
|
+
accentfg: "black",
|
|
1267
|
+
error: "redBright",
|
|
1268
|
+
errorfg: "black",
|
|
1269
|
+
warning: "yellow",
|
|
1270
|
+
warningfg: "black",
|
|
1271
|
+
success: "greenBright",
|
|
1272
|
+
successfg: "black",
|
|
1273
|
+
info: "cyan",
|
|
1274
|
+
infofg: "black",
|
|
1275
|
+
border: "gray",
|
|
1276
|
+
inputborder: "gray",
|
|
1277
|
+
focusborder: "blueBright",
|
|
1278
|
+
link: "blueBright",
|
|
1279
|
+
disabledfg: "gray",
|
|
1280
|
+
palette: [
|
|
1281
|
+
"black",
|
|
1282
|
+
"red",
|
|
1283
|
+
"green",
|
|
1284
|
+
"yellow",
|
|
1285
|
+
"blue",
|
|
1286
|
+
"magenta",
|
|
1287
|
+
"cyan",
|
|
1288
|
+
"white",
|
|
1289
|
+
"blackBright",
|
|
1290
|
+
"redBright",
|
|
1291
|
+
"greenBright",
|
|
1292
|
+
"yellowBright",
|
|
1293
|
+
"blueBright",
|
|
1294
|
+
"magentaBright",
|
|
1295
|
+
"cyanBright",
|
|
1296
|
+
"whiteBright"
|
|
1297
|
+
]
|
|
1298
|
+
};
|
|
1299
|
+
ansi16LightTheme = {
|
|
1300
|
+
name: "light-ansi16",
|
|
1301
|
+
bg: "",
|
|
1302
|
+
fg: "black",
|
|
1303
|
+
muted: "blackBright",
|
|
1304
|
+
mutedbg: "white",
|
|
1305
|
+
surface: "black",
|
|
1306
|
+
surfacebg: "white",
|
|
1307
|
+
popover: "black",
|
|
1308
|
+
popoverbg: "white",
|
|
1309
|
+
inverse: "whiteBright",
|
|
1310
|
+
inversebg: "black",
|
|
1311
|
+
cursor: "black",
|
|
1312
|
+
cursorbg: "blue",
|
|
1313
|
+
selection: "black",
|
|
1314
|
+
selectionbg: "cyan",
|
|
1315
|
+
primary: "blue",
|
|
1316
|
+
primaryfg: "black",
|
|
1317
|
+
secondary: "blue",
|
|
1318
|
+
secondaryfg: "black",
|
|
1319
|
+
accent: "cyan",
|
|
1320
|
+
accentfg: "black",
|
|
1321
|
+
error: "red",
|
|
1322
|
+
errorfg: "black",
|
|
1323
|
+
warning: "yellow",
|
|
1324
|
+
warningfg: "black",
|
|
1325
|
+
success: "green",
|
|
1326
|
+
successfg: "black",
|
|
1327
|
+
info: "cyan",
|
|
1328
|
+
infofg: "black",
|
|
1329
|
+
border: "gray",
|
|
1330
|
+
inputborder: "gray",
|
|
1331
|
+
focusborder: "blue",
|
|
1332
|
+
link: "blueBright",
|
|
1333
|
+
disabledfg: "gray",
|
|
1334
|
+
palette: [
|
|
1335
|
+
"black",
|
|
1336
|
+
"red",
|
|
1337
|
+
"green",
|
|
1338
|
+
"yellow",
|
|
1339
|
+
"blue",
|
|
1340
|
+
"magenta",
|
|
1341
|
+
"cyan",
|
|
1342
|
+
"white",
|
|
1343
|
+
"blackBright",
|
|
1344
|
+
"redBright",
|
|
1345
|
+
"greenBright",
|
|
1346
|
+
"yellowBright",
|
|
1347
|
+
"blueBright",
|
|
1348
|
+
"magentaBright",
|
|
1349
|
+
"cyanBright",
|
|
1350
|
+
"whiteBright"
|
|
1351
|
+
]
|
|
1352
|
+
};
|
|
1353
|
+
}));
|
|
1354
|
+
//#endregion
|
|
1355
|
+
//#region packages/ansi/src/theme/types.ts
|
|
1356
|
+
var COLOR_PALETTE_FIELDS;
|
|
1357
|
+
var init_types = __esmMin((() => {
|
|
1358
|
+
COLOR_PALETTE_FIELDS = [
|
|
1359
|
+
"black",
|
|
1360
|
+
"red",
|
|
1361
|
+
"green",
|
|
1362
|
+
"yellow",
|
|
1363
|
+
"blue",
|
|
1364
|
+
"magenta",
|
|
1365
|
+
"cyan",
|
|
1366
|
+
"white",
|
|
1367
|
+
"brightBlack",
|
|
1368
|
+
"brightRed",
|
|
1369
|
+
"brightGreen",
|
|
1370
|
+
"brightYellow",
|
|
1371
|
+
"brightBlue",
|
|
1372
|
+
"brightMagenta",
|
|
1373
|
+
"brightCyan",
|
|
1374
|
+
"brightWhite",
|
|
1375
|
+
"foreground",
|
|
1376
|
+
"background",
|
|
1377
|
+
"cursorColor",
|
|
1378
|
+
"cursorText",
|
|
1379
|
+
"selectionBackground",
|
|
1380
|
+
"selectionForeground"
|
|
1381
|
+
];
|
|
1382
|
+
}));
|
|
1383
|
+
//#endregion
|
|
1384
|
+
//#region packages/ansi/src/osc-palette.ts
|
|
1385
|
+
function queryPaletteColor(index, write) {
|
|
1386
|
+
if (index < 0 || index > 255) throw new RangeError(`Palette index must be 0-255, got ${index}`);
|
|
1387
|
+
write(`${ESC$1}]4;${index};?${BEL$1}`);
|
|
1388
|
+
}
|
|
1389
|
+
function queryMultiplePaletteColors(indices, write) {
|
|
1390
|
+
for (const index of indices) queryPaletteColor(index, write);
|
|
1391
|
+
}
|
|
1392
|
+
function setPaletteColor(index, color, write) {
|
|
1393
|
+
if (index < 0 || index > 255) throw new RangeError(`Palette index must be 0-255, got ${index}`);
|
|
1394
|
+
write(`${ESC$1}]4;${index};${color}${BEL$1}`);
|
|
1395
|
+
}
|
|
1396
|
+
function parsePaletteResponse(input) {
|
|
1397
|
+
const prefixIdx = input.indexOf(OSC4_PREFIX);
|
|
1398
|
+
if (prefixIdx === -1) return null;
|
|
1399
|
+
const bodyStart = prefixIdx + OSC4_PREFIX.length;
|
|
1400
|
+
let bodyEnd = input.indexOf(BEL$1, bodyStart);
|
|
1401
|
+
if (bodyEnd === -1) bodyEnd = input.indexOf(`${ESC$1}\\`, bodyStart);
|
|
1402
|
+
if (bodyEnd === -1) return null;
|
|
1403
|
+
const body = input.slice(bodyStart, bodyEnd);
|
|
1404
|
+
const match = OSC4_BODY_RE.exec(body);
|
|
1405
|
+
if (!match) return null;
|
|
1406
|
+
const index = Number.parseInt(match[1], 10);
|
|
1407
|
+
if (index < 0 || index > 255) return null;
|
|
1408
|
+
return {
|
|
1409
|
+
index,
|
|
1410
|
+
color: `#${normalizeHexChannel$1(match[2])}${normalizeHexChannel$1(match[3])}${normalizeHexChannel$1(match[4])}`
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
function normalizeHexChannel$1(hex) {
|
|
1414
|
+
switch (hex.length) {
|
|
1415
|
+
case 1: return hex + hex;
|
|
1416
|
+
case 2: return hex;
|
|
1417
|
+
default: return hex.slice(0, 2);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
var ESC$1, BEL$1, OSC4_PREFIX, OSC4_BODY_RE;
|
|
1421
|
+
var init_osc_palette = __esmMin((() => {
|
|
1422
|
+
ESC$1 = "\x1B";
|
|
1423
|
+
BEL$1 = "\x07";
|
|
1424
|
+
OSC4_PREFIX = `${ESC$1}]4;`;
|
|
1425
|
+
OSC4_BODY_RE = /^(\d+);rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})$/;
|
|
1426
|
+
}));
|
|
1427
|
+
//#endregion
|
|
1428
|
+
//#region packages/ansi/src/osc-colors.ts
|
|
1429
|
+
function normalizeHexChannel(hex) {
|
|
1430
|
+
switch (hex.length) {
|
|
1431
|
+
case 1: return hex + hex;
|
|
1432
|
+
case 2: return hex;
|
|
1433
|
+
default: return hex.slice(0, 2);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
function parseOscColorResponse(input, oscCode) {
|
|
1437
|
+
const prefix = `${ESC}]${oscCode};`;
|
|
1438
|
+
const prefixIdx = input.indexOf(prefix);
|
|
1439
|
+
if (prefixIdx === -1) return null;
|
|
1440
|
+
const bodyStart = prefixIdx + prefix.length;
|
|
1441
|
+
let bodyEnd = input.indexOf(BEL, bodyStart);
|
|
1442
|
+
if (bodyEnd === -1) bodyEnd = input.indexOf(`${ESC}\\`, bodyStart);
|
|
1443
|
+
if (bodyEnd === -1) return null;
|
|
1444
|
+
const body = input.slice(bodyStart, bodyEnd);
|
|
1445
|
+
const match = RGB_BODY_RE.exec(body);
|
|
1446
|
+
if (!match) return null;
|
|
1447
|
+
return `#${normalizeHexChannel(match[1])}${normalizeHexChannel(match[2])}${normalizeHexChannel(match[3])}`;
|
|
1448
|
+
}
|
|
1449
|
+
async function queryOscColor(write, read, oscCode, timeoutMs) {
|
|
1450
|
+
write(`${ESC}]${oscCode};?${BEL}`);
|
|
1451
|
+
const data = await read(timeoutMs);
|
|
1452
|
+
if (data == null) return null;
|
|
1453
|
+
return parseOscColorResponse(data, oscCode);
|
|
1454
|
+
}
|
|
1455
|
+
async function queryForegroundColor(write, read, timeoutMs = 200) {
|
|
1456
|
+
return queryOscColor(write, read, 10, timeoutMs);
|
|
1457
|
+
}
|
|
1458
|
+
async function queryBackgroundColor(write, read, timeoutMs = 200) {
|
|
1459
|
+
return queryOscColor(write, read, 11, timeoutMs);
|
|
1460
|
+
}
|
|
1461
|
+
async function queryCursorColor(write, read, timeoutMs = 200) {
|
|
1462
|
+
return queryOscColor(write, read, 12, timeoutMs);
|
|
1463
|
+
}
|
|
1464
|
+
function setForegroundColor(write, color) {
|
|
1465
|
+
write(`${ESC}]10;${color}${BEL}`);
|
|
1466
|
+
}
|
|
1467
|
+
function setBackgroundColor(write, color) {
|
|
1468
|
+
write(`${ESC}]11;${color}${BEL}`);
|
|
1469
|
+
}
|
|
1470
|
+
function setCursorColor(write, color) {
|
|
1471
|
+
write(`${ESC}]12;${color}${BEL}`);
|
|
1472
|
+
}
|
|
1473
|
+
function resetForegroundColor(write) {
|
|
1474
|
+
write(`${ESC}]110${BEL}`);
|
|
1475
|
+
}
|
|
1476
|
+
function resetBackgroundColor(write) {
|
|
1477
|
+
write(`${ESC}]111${BEL}`);
|
|
1478
|
+
}
|
|
1479
|
+
function resetCursorColor(write) {
|
|
1480
|
+
write(`${ESC}]112${BEL}`);
|
|
1481
|
+
}
|
|
1482
|
+
async function detectColorScheme(write, read, timeoutMs = 200) {
|
|
1483
|
+
const bg = await queryBackgroundColor(write, read, timeoutMs);
|
|
1484
|
+
if (bg == null) return null;
|
|
1485
|
+
const r = parseInt(bg.slice(1, 3), 16) / 255;
|
|
1486
|
+
const g = parseInt(bg.slice(3, 5), 16) / 255;
|
|
1487
|
+
const b = parseInt(bg.slice(5, 7), 16) / 255;
|
|
1488
|
+
return .2126 * r + .7152 * g + .0722 * b > .5 ? "light" : "dark";
|
|
1489
|
+
}
|
|
1490
|
+
var ESC, BEL, RGB_BODY_RE;
|
|
1491
|
+
var init_osc_colors = __esmMin((() => {
|
|
1492
|
+
ESC = "\x1B";
|
|
1493
|
+
BEL = "\x07";
|
|
1494
|
+
RGB_BODY_RE = /rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})/;
|
|
1495
|
+
}));
|
|
1496
|
+
//#endregion
|
|
1497
|
+
//#region packages/ansi/src/theme/detect.ts
|
|
1498
|
+
async function detectTerminalPalette(timeoutMs = 150) {
|
|
1499
|
+
const stdin = process.stdin;
|
|
1500
|
+
const stdout = process.stdout;
|
|
1501
|
+
if (!stdin.isTTY || !stdout.isTTY) return null;
|
|
1502
|
+
const wasRaw = stdin.isRaw;
|
|
1503
|
+
if (!wasRaw) stdin.setRawMode(true);
|
|
1504
|
+
let buffer = "";
|
|
1505
|
+
const onData = (chunk) => {
|
|
1506
|
+
buffer += chunk.toString();
|
|
1507
|
+
};
|
|
1508
|
+
stdin.on("data", onData);
|
|
1509
|
+
try {
|
|
1510
|
+
const write = (s) => {
|
|
1511
|
+
stdout.write(s);
|
|
1512
|
+
};
|
|
1513
|
+
const read = (ms) => new Promise((resolve) => {
|
|
1514
|
+
if (buffer.length > 0) {
|
|
1515
|
+
const result = buffer;
|
|
1516
|
+
buffer = "";
|
|
1517
|
+
resolve(result);
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
const timer = setTimeout(() => {
|
|
1521
|
+
resolve(buffer.length > 0 ? buffer : null);
|
|
1522
|
+
buffer = "";
|
|
1523
|
+
}, ms);
|
|
1524
|
+
const check = (_chunk) => {
|
|
1525
|
+
clearTimeout(timer);
|
|
1526
|
+
stdin.removeListener("data", check);
|
|
1527
|
+
const result = buffer;
|
|
1528
|
+
buffer = "";
|
|
1529
|
+
resolve(result);
|
|
1530
|
+
};
|
|
1531
|
+
stdin.on("data", check);
|
|
1532
|
+
});
|
|
1533
|
+
const bg = await queryBackgroundColor(write, read, timeoutMs);
|
|
1534
|
+
const fg = await queryForegroundColor(write, read, timeoutMs);
|
|
1535
|
+
const ansi = new Array(16).fill(null);
|
|
1536
|
+
queryMultiplePaletteColors(Array.from({ length: 16 }, (_, i) => i), write);
|
|
1537
|
+
await new Promise((resolve) => setTimeout(resolve, timeoutMs));
|
|
1538
|
+
const remaining = buffer;
|
|
1539
|
+
buffer = "";
|
|
1540
|
+
if (remaining) {
|
|
1541
|
+
const oscPrefix = "\x1B]4;";
|
|
1542
|
+
let pos = 0;
|
|
1543
|
+
while (pos < remaining.length) {
|
|
1544
|
+
const nextOsc = remaining.indexOf(oscPrefix, pos);
|
|
1545
|
+
if (nextOsc === -1) break;
|
|
1546
|
+
let end = remaining.indexOf("\x07", nextOsc);
|
|
1547
|
+
if (end === -1) end = remaining.indexOf("\x1B\\", nextOsc);
|
|
1548
|
+
if (end === -1) break;
|
|
1549
|
+
const parsed = parsePaletteResponse(remaining.slice(nextOsc, end + 1));
|
|
1550
|
+
if (parsed && parsed.index >= 0 && parsed.index < 16) ansi[parsed.index] = parsed.color;
|
|
1551
|
+
pos = end + 1;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
const dark = bg ? isDarkColor(bg) : true;
|
|
1555
|
+
const palette = { dark };
|
|
1556
|
+
if (bg) palette.background = bg;
|
|
1557
|
+
if (fg) palette.foreground = fg;
|
|
1558
|
+
const ansiFields = [
|
|
1559
|
+
"black",
|
|
1560
|
+
"red",
|
|
1561
|
+
"green",
|
|
1562
|
+
"yellow",
|
|
1563
|
+
"blue",
|
|
1564
|
+
"magenta",
|
|
1565
|
+
"cyan",
|
|
1566
|
+
"white",
|
|
1567
|
+
"brightBlack",
|
|
1568
|
+
"brightRed",
|
|
1569
|
+
"brightGreen",
|
|
1570
|
+
"brightYellow",
|
|
1571
|
+
"brightBlue",
|
|
1572
|
+
"brightMagenta",
|
|
1573
|
+
"brightCyan",
|
|
1574
|
+
"brightWhite"
|
|
1575
|
+
];
|
|
1576
|
+
for (let i = 0; i < 16; i++) if (ansi[i]) palette[ansiFields[i]] = ansi[i];
|
|
1577
|
+
if (fg) {
|
|
1578
|
+
palette.cursorColor = fg;
|
|
1579
|
+
palette.selectionForeground = fg;
|
|
1580
|
+
}
|
|
1581
|
+
if (bg) palette.cursorText = bg;
|
|
1582
|
+
if (ansi[4]) palette.selectionBackground = ansi[4];
|
|
1583
|
+
return {
|
|
1584
|
+
fg,
|
|
1585
|
+
bg,
|
|
1586
|
+
ansi,
|
|
1587
|
+
dark,
|
|
1588
|
+
palette
|
|
1589
|
+
};
|
|
1590
|
+
} finally {
|
|
1591
|
+
stdin.removeListener("data", onData);
|
|
1592
|
+
if (!wasRaw) stdin.setRawMode(false);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
function isDarkColor(hex) {
|
|
1596
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
1597
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
1598
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
1599
|
+
return .2126 * r + .7152 * g + .0722 * b <= .5;
|
|
1600
|
+
}
|
|
1601
|
+
var init_detect = __esmMin((() => {
|
|
1602
|
+
init_osc_palette();
|
|
1603
|
+
init_osc_colors();
|
|
1604
|
+
})), CSI;
|
|
1605
|
+
var init_color_scheme = __esmMin((() => {
|
|
1606
|
+
CSI = `[`;
|
|
1607
|
+
`${CSI}`;
|
|
1608
|
+
`${CSI}`;
|
|
1609
|
+
}));
|
|
1610
|
+
//#endregion
|
|
1611
|
+
//#region packages/ansi/src/index.ts
|
|
1612
|
+
var init_src = __esmMin((() => {
|
|
1613
|
+
init_detection();
|
|
1614
|
+
init_sgr_codes();
|
|
1615
|
+
init_utils();
|
|
1616
|
+
init_terminal_control();
|
|
1617
|
+
init_style();
|
|
1618
|
+
init_mixed_proxy();
|
|
1619
|
+
init_derive();
|
|
1620
|
+
init_default_palettes();
|
|
1621
|
+
init_types();
|
|
1622
|
+
init_detect();
|
|
1623
|
+
init_osc_palette();
|
|
1624
|
+
init_color_scheme();
|
|
1625
|
+
}));
|
|
1626
|
+
//#endregion
|
|
1627
|
+
export { contrastFg as A, enableKittyKeyboard as B, resolveThemeColor as C, blend as D, ensureContrast as E, hslToHex as F, detectColor as G, bgColorCode as H, rgbToHex as I, detectTerminalCaps as J, detectCursor as K, rgbToHsl as L, desaturate as M, hexToHsl as N, brighten as O, hexToRgb as P, disableKittyKeyboard as R, createStyle as S, checkContrast as T, fgColorCode as U, enableMouse as V, defaultCaps as W, detectUnicode as Y, COLOR_PALETTE_FIELDS as _, queryCursorColor as a, deriveTheme as b, resetCursorColor as c, setCursorColor as d, setForegroundColor as f, setPaletteColor as g, queryPaletteColor as h, queryBackgroundColor as i, darken as j, complement as k, resetForegroundColor as l, queryMultiplePaletteColors as m, detectTerminalPalette as n, queryForegroundColor as o, parsePaletteResponse as p, detectInput as q, detectColorScheme as r, resetBackgroundColor as s, init_src as t, setBackgroundColor as u, ansi16DarkTheme as v, init_src$1 as w, createMixedStyle as x, ansi16LightTheme as y, disableMouse as z };
|
|
1628
|
+
|
|
1629
|
+
//# sourceMappingURL=src-9B5k0JmY.mjs.map
|