@sushant-kum/ccstatus 0.2.1 → 0.3.1
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.
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
COLORS,
|
|
4
3
|
LINKABLE,
|
|
4
|
+
asIndex,
|
|
5
5
|
configPath,
|
|
6
6
|
importCcstatusline,
|
|
7
|
+
indexToHex,
|
|
7
8
|
isValidWhen,
|
|
8
9
|
linkedSurfaces,
|
|
9
10
|
loadConfigFile,
|
|
10
11
|
readSnapshot,
|
|
11
12
|
registry,
|
|
12
13
|
render,
|
|
13
|
-
rendererBg,
|
|
14
|
-
rendererColor,
|
|
15
14
|
saveConfigFile,
|
|
16
15
|
snapshotPath,
|
|
17
16
|
writeLinkedLines
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-VCE654NJ.js";
|
|
19
18
|
|
|
20
19
|
// src/app.tsx
|
|
21
20
|
import { Box as Box12, Text as Text12, useApp, useInput as useInput10 } from "ink";
|
|
@@ -92,10 +91,16 @@ import { Box as Box2, Text as Text2 } from "ink";
|
|
|
92
91
|
// src/paint.tsx
|
|
93
92
|
import { Box, Text } from "ink";
|
|
94
93
|
import { jsx } from "react/jsx-runtime";
|
|
95
|
-
var inkColor = (fg) => rendererColor(fg);
|
|
96
|
-
var inkBg = (bg) => rendererBg(bg);
|
|
97
94
|
function paintModel(model) {
|
|
98
|
-
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: model.lines.map((line, i) => /* @__PURE__ */ jsx(Box, { children: line.segments.map((s, j) => /* @__PURE__ */ jsx(
|
|
95
|
+
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: model.lines.map((line, i) => /* @__PURE__ */ jsx(Box, { children: line.segments.map((s, j) => /* @__PURE__ */ jsx(
|
|
96
|
+
Text,
|
|
97
|
+
{
|
|
98
|
+
color: s.fg === void 0 ? void 0 : indexToHex(s.fg),
|
|
99
|
+
backgroundColor: s.bg === void 0 ? void 0 : indexToHex(s.bg),
|
|
100
|
+
children: s.text
|
|
101
|
+
},
|
|
102
|
+
j
|
|
103
|
+
)) }, i)) });
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
// src/preview.tsx
|
|
@@ -1134,21 +1139,40 @@ function Surfaces({ config, setConfig, goHome }) {
|
|
|
1134
1139
|
|
|
1135
1140
|
// src/screens/themes.tsx
|
|
1136
1141
|
import { Box as Box11, Text as Text11, useInput as useInput9 } from "ink";
|
|
1137
|
-
import { useState as useState9 } from "react";
|
|
1138
|
-
|
|
1139
|
-
// src/named-colors.ts
|
|
1140
|
-
var all = [...COLORS];
|
|
1141
|
-
var NAMED_COLORS = [
|
|
1142
|
-
"(none)",
|
|
1143
|
-
...all.filter((c) => !c.startsWith("bg")),
|
|
1144
|
-
...all.filter((c) => c.startsWith("bg"))
|
|
1145
|
-
];
|
|
1146
|
-
|
|
1147
|
-
// src/screens/themes.tsx
|
|
1142
|
+
import { Fragment as Fragment2, useState as useState9 } from "react";
|
|
1148
1143
|
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1149
|
-
var
|
|
1150
|
-
var
|
|
1144
|
+
var PICK_INDICES = Array.from({ length: 240 }, (_, i) => asIndex(16 + i));
|
|
1145
|
+
var CUBE_ROWS = 6;
|
|
1146
|
+
var CUBE_WIDTH = 36;
|
|
1147
|
+
var RAMP_ROW = 6;
|
|
1148
|
+
var RAMP_WIDTH = 24;
|
|
1149
|
+
var NONE_ROW = 7;
|
|
1151
1150
|
var FIELDS3 = ["fg", "bg"];
|
|
1151
|
+
var rowWidth = (row) => row < CUBE_ROWS ? CUBE_WIDTH : row === RAMP_ROW ? RAMP_WIDTH : 1;
|
|
1152
|
+
var posToPick = ({ row, col }) => {
|
|
1153
|
+
if (row >= NONE_ROW) {
|
|
1154
|
+
return void 0;
|
|
1155
|
+
}
|
|
1156
|
+
if (row === RAMP_ROW) {
|
|
1157
|
+
return 216 + col;
|
|
1158
|
+
}
|
|
1159
|
+
return 36 * Math.floor(col / 6) + 6 * row + col % 6;
|
|
1160
|
+
};
|
|
1161
|
+
var indexToPos = (idx) => {
|
|
1162
|
+
if (idx === void 0 || idx < 16 || idx > 255) {
|
|
1163
|
+
return { row: NONE_ROW, col: 0 };
|
|
1164
|
+
}
|
|
1165
|
+
const p = idx - 16;
|
|
1166
|
+
if (p >= 216) {
|
|
1167
|
+
return { row: RAMP_ROW, col: p - 216 };
|
|
1168
|
+
}
|
|
1169
|
+
return { row: Math.floor(p % 36 / 6), col: Math.floor(p / 36) * 6 + p % 6 };
|
|
1170
|
+
};
|
|
1171
|
+
var movePos = (pos, dr, dc) => {
|
|
1172
|
+
const row = Math.max(0, Math.min(NONE_ROW, pos.row + dr));
|
|
1173
|
+
const col = Math.max(0, Math.min(rowWidth(row) - 1, pos.col + dc));
|
|
1174
|
+
return { row, col };
|
|
1175
|
+
};
|
|
1152
1176
|
function uniqueName(base, themes) {
|
|
1153
1177
|
if (!(base in themes)) {
|
|
1154
1178
|
return base;
|
|
@@ -1165,12 +1189,11 @@ function Themes({ config, setConfig, goHome }) {
|
|
|
1165
1189
|
const [mode, setMode] = useState9("list");
|
|
1166
1190
|
const [slot, setSlot] = useState9(0);
|
|
1167
1191
|
const [field, setField] = useState9(0);
|
|
1168
|
-
const [pick, setPick] = useState9(0);
|
|
1192
|
+
const [pick, setPick] = useState9({ row: NONE_ROW, col: 0 });
|
|
1169
1193
|
const name = names[Math.min(sel, names.length - 1)];
|
|
1170
1194
|
const theme = name && config.themes[name] || [];
|
|
1171
1195
|
const count = theme.length;
|
|
1172
1196
|
const slotIdx = Math.min(slot, count - 1);
|
|
1173
|
-
const list = FIELDS3[field] === "fg" ? FG : BG;
|
|
1174
1197
|
const setThemes = (themes, active = config.theme) => setConfig({ ...config, theme: active, themes });
|
|
1175
1198
|
const writeSlot = (index, entry) => {
|
|
1176
1199
|
if (name) {
|
|
@@ -1216,7 +1239,7 @@ function Themes({ config, setConfig, goHome }) {
|
|
|
1216
1239
|
setField(1);
|
|
1217
1240
|
} else if (key.return && slotIdx >= 0) {
|
|
1218
1241
|
const cur = theme[slotIdx]?.[FIELDS3[field] ?? "fg"];
|
|
1219
|
-
setPick(
|
|
1242
|
+
setPick(indexToPos(cur));
|
|
1220
1243
|
setMode("picker");
|
|
1221
1244
|
} else if (input === "a" && name) {
|
|
1222
1245
|
setThemes({ ...config.themes, [name]: [...theme, {}] });
|
|
@@ -1234,22 +1257,25 @@ function Themes({ config, setConfig, goHome }) {
|
|
|
1234
1257
|
if (key.escape) {
|
|
1235
1258
|
setMode("slots");
|
|
1236
1259
|
} else if (key.upArrow) {
|
|
1237
|
-
setPick((p) =>
|
|
1260
|
+
setPick((p) => movePos(p, -1, 0));
|
|
1238
1261
|
} else if (key.downArrow) {
|
|
1239
|
-
setPick((p) =>
|
|
1262
|
+
setPick((p) => movePos(p, 1, 0));
|
|
1263
|
+
} else if (key.leftArrow) {
|
|
1264
|
+
setPick((p) => movePos(p, 0, -1));
|
|
1265
|
+
} else if (key.rightArrow) {
|
|
1266
|
+
setPick((p) => movePos(p, 0, 1));
|
|
1240
1267
|
} else if (key.return && slotIdx >= 0) {
|
|
1241
1268
|
const f = FIELDS3[field] ?? "fg";
|
|
1242
|
-
const
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
}
|
|
1250
|
-
writeSlot(slotIdx, entry);
|
|
1251
|
-
setMode("slots");
|
|
1269
|
+
const pi = posToPick(pick);
|
|
1270
|
+
const chosen = pi === void 0 ? void 0 : PICK_INDICES[pi];
|
|
1271
|
+
const entry = { ...theme[slotIdx] };
|
|
1272
|
+
if (chosen === void 0) {
|
|
1273
|
+
delete entry[f];
|
|
1274
|
+
} else {
|
|
1275
|
+
entry[f] = chosen;
|
|
1252
1276
|
}
|
|
1277
|
+
writeSlot(slotIdx, entry);
|
|
1278
|
+
setMode("slots");
|
|
1253
1279
|
}
|
|
1254
1280
|
}
|
|
1255
1281
|
});
|
|
@@ -1270,42 +1296,65 @@ function Themes({ config, setConfig, goHome }) {
|
|
|
1270
1296
|
return /* @__PURE__ */ jsxs10(Text11, { children: [
|
|
1271
1297
|
on ? "\u25B8 " : " ",
|
|
1272
1298
|
String(i).padEnd(4),
|
|
1273
|
-
/* @__PURE__ */ jsxs10(Text11, { color: inkColor(c.fg), inverse: on && field === 0, children: [
|
|
1274
|
-
" ",
|
|
1275
|
-
c.fg ?? "(none)",
|
|
1276
|
-
" "
|
|
1277
|
-
] }),
|
|
1278
|
-
/* @__PURE__ */ jsxs10(Text11, { backgroundColor: inkBg(c.bg), inverse: on && field === 1, children: [
|
|
1279
|
-
" ",
|
|
1280
|
-
c.bg ?? "(none)",
|
|
1281
|
-
" "
|
|
1282
|
-
] })
|
|
1283
|
-
] }, i);
|
|
1284
|
-
}),
|
|
1285
|
-
mode === "picker" && /* @__PURE__ */ jsxs10(Box11, { flexDirection: "column", children: [
|
|
1286
|
-
/* @__PURE__ */ jsxs10(Text11, { bold: true, children: [
|
|
1287
|
-
"Pick ",
|
|
1288
|
-
FIELDS3[field],
|
|
1289
|
-
" for slot ",
|
|
1290
|
-
slotIdx
|
|
1291
|
-
] }),
|
|
1292
|
-
list.map((c, i) => /* @__PURE__ */ jsxs10(Text11, { color: i === pick ? "cyan" : void 0, children: [
|
|
1293
|
-
i === pick ? "\u25B8 " : " ",
|
|
1294
1299
|
/* @__PURE__ */ jsxs10(
|
|
1295
1300
|
Text11,
|
|
1296
1301
|
{
|
|
1297
|
-
color:
|
|
1298
|
-
|
|
1302
|
+
color: c.fg === void 0 ? void 0 : indexToHex(c.fg),
|
|
1303
|
+
inverse: on && field === 0,
|
|
1299
1304
|
children: [
|
|
1300
1305
|
" ",
|
|
1301
|
-
c
|
|
1306
|
+
c.fg === void 0 ? "(none)" : `idx ${c.fg}`,
|
|
1307
|
+
" "
|
|
1308
|
+
]
|
|
1309
|
+
}
|
|
1310
|
+
),
|
|
1311
|
+
/* @__PURE__ */ jsxs10(
|
|
1312
|
+
Text11,
|
|
1313
|
+
{
|
|
1314
|
+
backgroundColor: c.bg === void 0 ? void 0 : indexToHex(c.bg),
|
|
1315
|
+
inverse: on && field === 1,
|
|
1316
|
+
children: [
|
|
1317
|
+
" ",
|
|
1318
|
+
c.bg === void 0 ? "(none)" : `idx ${c.bg}`,
|
|
1302
1319
|
" "
|
|
1303
1320
|
]
|
|
1304
1321
|
}
|
|
1305
1322
|
)
|
|
1306
|
-
] },
|
|
1323
|
+
] }, i);
|
|
1324
|
+
}),
|
|
1325
|
+
mode === "picker" && /* @__PURE__ */ jsxs10(Box11, { flexDirection: "column", children: [
|
|
1326
|
+
/* @__PURE__ */ jsxs10(Text11, { bold: true, children: [
|
|
1327
|
+
"Pick ",
|
|
1328
|
+
FIELDS3[field],
|
|
1329
|
+
" for slot ",
|
|
1330
|
+
slotIdx
|
|
1331
|
+
] }),
|
|
1332
|
+
Array.from({ length: RAMP_ROW + 1 }, (_, row) => /* @__PURE__ */ jsx10(Text11, { children: Array.from({ length: rowWidth(row) }, (_2, col) => {
|
|
1333
|
+
const pi = posToPick({ row, col });
|
|
1334
|
+
const idx = pi === void 0 ? void 0 : PICK_INDICES[pi];
|
|
1335
|
+
const on = pick.row === row && pick.col === col;
|
|
1336
|
+
return /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
1337
|
+
/* @__PURE__ */ jsx10(
|
|
1338
|
+
Text11,
|
|
1339
|
+
{
|
|
1340
|
+
backgroundColor: idx === void 0 ? void 0 : indexToHex(idx),
|
|
1341
|
+
inverse: on,
|
|
1342
|
+
children: on ? "\u25C6 " : " "
|
|
1343
|
+
}
|
|
1344
|
+
),
|
|
1345
|
+
row < CUBE_ROWS && col % 6 === 5 ? " " : ""
|
|
1346
|
+
] }, col);
|
|
1347
|
+
}) }, row)),
|
|
1348
|
+
/* @__PURE__ */ jsxs10(Text11, { color: pick.row === NONE_ROW ? "cyan" : void 0, children: [
|
|
1349
|
+
pick.row === NONE_ROW ? "\u25B8 " : " ",
|
|
1350
|
+
"(none)"
|
|
1351
|
+
] }),
|
|
1352
|
+
/* @__PURE__ */ jsx10(Text11, { dimColor: true, children: (() => {
|
|
1353
|
+
const pi = posToPick(pick);
|
|
1354
|
+
return pi === void 0 ? "none" : `idx ${PICK_INDICES[pi]}`;
|
|
1355
|
+
})() })
|
|
1307
1356
|
] }),
|
|
1308
|
-
/* @__PURE__ */ jsx10(Text11, { dimColor: true, children: mode === "list" ? "\u2191/\u2193 select \xB7 \u23CE activate \xB7 \u2192 slots \xB7 n new \xB7 d duplicate \xB7 esc back" : mode === "slots" ? "\u2191/\u2193 slot \xB7 \u2190/\u2192 fg/bg \xB7 \u23CE pick \xB7 a add \xB7 x remove \xB7 esc back" : "\u2191/\u2193
|
|
1357
|
+
/* @__PURE__ */ jsx10(Text11, { dimColor: true, children: mode === "list" ? "\u2191/\u2193 select \xB7 \u23CE activate \xB7 \u2192 slots \xB7 n new \xB7 d duplicate \xB7 esc back" : mode === "slots" ? "\u2191/\u2193 slot \xB7 \u2190/\u2192 fg/bg \xB7 \u23CE pick \xB7 a add \xB7 x remove \xB7 esc back" : "\u2191/\u2193 row \xB7 \u2190/\u2192 swatch \xB7 \u23CE set \xB7 esc cancel" })
|
|
1309
1358
|
] });
|
|
1310
1359
|
}
|
|
1311
1360
|
|
|
@@ -31,16 +31,6 @@ function lineToCells(items, config, snapshot, commandOutputs) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// ../core/src/layout/compose.ts
|
|
34
|
-
function bgToFg(bg2) {
|
|
35
|
-
if (!bg2) {
|
|
36
|
-
return void 0;
|
|
37
|
-
}
|
|
38
|
-
if (!bg2.startsWith("bg")) {
|
|
39
|
-
return bg2;
|
|
40
|
-
}
|
|
41
|
-
const rest = bg2.slice(2);
|
|
42
|
-
return rest.charAt(0).toLowerCase() + rest.slice(1);
|
|
43
|
-
}
|
|
44
34
|
function mergeCells(cells) {
|
|
45
35
|
const out = [];
|
|
46
36
|
for (const c of cells) {
|
|
@@ -101,7 +91,7 @@ function composeLine(cells, mode, width, glyph = "\u2592") {
|
|
|
101
91
|
const segs = [];
|
|
102
92
|
const emitStartCap = mode === "powerline" && content.length > 0;
|
|
103
93
|
if (emitStartCap) {
|
|
104
|
-
segs.push({ kind: "cap", text: glyph, fg:
|
|
94
|
+
segs.push({ kind: "cap", text: glyph, fg: content[0]?.bg });
|
|
105
95
|
}
|
|
106
96
|
let ci = 0;
|
|
107
97
|
for (const c of merged) {
|
|
@@ -114,7 +104,7 @@ function composeLine(cells, mode, width, glyph = "\u2592") {
|
|
|
114
104
|
const next = content[ci + 1];
|
|
115
105
|
if (!isLast && next) {
|
|
116
106
|
if (mode === "powerline") {
|
|
117
|
-
segs.push({ kind: "separator", text: glyph, fg:
|
|
107
|
+
segs.push({ kind: "separator", text: glyph, fg: c.bg, bg: next.bg });
|
|
118
108
|
} else if (mode === "space") {
|
|
119
109
|
segs.push({ kind: "separator", text: " " });
|
|
120
110
|
}
|
|
@@ -122,31 +112,61 @@ function composeLine(cells, mode, width, glyph = "\u2592") {
|
|
|
122
112
|
ci += 1;
|
|
123
113
|
}
|
|
124
114
|
if (emitStartCap) {
|
|
125
|
-
segs.push({ kind: "cap", text: glyph, fg:
|
|
115
|
+
segs.push({ kind: "cap", text: glyph, fg: content[content.length - 1]?.bg });
|
|
126
116
|
}
|
|
127
117
|
return truncate(segs, width);
|
|
128
118
|
}
|
|
129
119
|
|
|
130
|
-
// ../core/src/
|
|
131
|
-
|
|
132
|
-
"
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
120
|
+
// ../core/src/colors.ts
|
|
121
|
+
function isColorIndex(x) {
|
|
122
|
+
return typeof x === "number" && Number.isInteger(x) && x >= 16 && x <= 255;
|
|
123
|
+
}
|
|
124
|
+
var asIndex = (n) => n;
|
|
125
|
+
|
|
126
|
+
// ../core/src/theme/xterm256.ts
|
|
127
|
+
var BLACK = asIndex(16);
|
|
128
|
+
var WHITE = asIndex(231);
|
|
129
|
+
var LEVEL = [0, 95, 135, 175, 215, 255];
|
|
130
|
+
function indexToRgb(idx) {
|
|
131
|
+
const i = Math.min(255, Math.max(16, Math.round(idx)));
|
|
132
|
+
if (i >= 232) {
|
|
133
|
+
const g = 8 + (i - 232) * 10;
|
|
134
|
+
return [g, g, g];
|
|
135
|
+
}
|
|
136
|
+
const n = i - 16;
|
|
137
|
+
return [LEVEL[Math.floor(n / 36)] ?? 0, LEVEL[Math.floor(n % 36 / 6)] ?? 0, LEVEL[n % 6] ?? 0];
|
|
138
|
+
}
|
|
139
|
+
var hex2 = (v) => v.toString(16).padStart(2, "0");
|
|
140
|
+
function indexToHex(i) {
|
|
141
|
+
const [r, g, b] = indexToRgb(i);
|
|
142
|
+
return `#${hex2(r)}${hex2(g)}${hex2(b)}`;
|
|
143
|
+
}
|
|
144
|
+
var NAMED_INDEX = /* @__PURE__ */ new Map([
|
|
145
|
+
["black", asIndex(16)],
|
|
146
|
+
["brightBlack", asIndex(240)],
|
|
147
|
+
["gray", asIndex(240)],
|
|
148
|
+
["red", asIndex(160)],
|
|
149
|
+
["brightRed", asIndex(196)],
|
|
150
|
+
["green", asIndex(40)],
|
|
151
|
+
["brightGreen", asIndex(46)],
|
|
152
|
+
["yellow", asIndex(184)],
|
|
153
|
+
["brightYellow", asIndex(226)],
|
|
154
|
+
["blue", asIndex(20)],
|
|
155
|
+
["brightBlue", asIndex(21)],
|
|
156
|
+
["magenta", asIndex(164)],
|
|
157
|
+
["brightMagenta", asIndex(201)],
|
|
158
|
+
["cyan", asIndex(44)],
|
|
159
|
+
["brightCyan", asIndex(51)],
|
|
160
|
+
["white", asIndex(250)],
|
|
161
|
+
["brightWhite", asIndex(231)]
|
|
140
162
|
]);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
function contrastFg(bg2) {
|
|
149
|
-
return LIGHT_BG.has(baseColor(bg2)) ? "black" : "brightWhite";
|
|
163
|
+
|
|
164
|
+
// ../core/src/theme/contrast.ts
|
|
165
|
+
var LUMA_THRESHOLD = 128;
|
|
166
|
+
function contrastFg(bg) {
|
|
167
|
+
const [r, g, b] = indexToRgb(bg);
|
|
168
|
+
const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
169
|
+
return luma >= LUMA_THRESHOLD ? BLACK : WHITE;
|
|
150
170
|
}
|
|
151
171
|
|
|
152
172
|
// ../core/src/layout/palette.ts
|
|
@@ -168,9 +188,9 @@ function assignPaletteColors(cells, theme) {
|
|
|
168
188
|
slot += 1;
|
|
169
189
|
}
|
|
170
190
|
const pal = theme[slot % theme.length];
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
out.push({ ...c, fg
|
|
191
|
+
const bg = pal?.bg;
|
|
192
|
+
const fg = pal?.fg ?? (bg !== void 0 ? contrastFg(bg) : void 0);
|
|
193
|
+
out.push({ ...c, fg, bg });
|
|
174
194
|
prev = c;
|
|
175
195
|
}
|
|
176
196
|
return out;
|
|
@@ -459,53 +479,14 @@ function render(config, snapshot, opts) {
|
|
|
459
479
|
}
|
|
460
480
|
|
|
461
481
|
// ../core/src/ansi.ts
|
|
462
|
-
var
|
|
463
|
-
black: 30,
|
|
464
|
-
red: 31,
|
|
465
|
-
green: 32,
|
|
466
|
-
yellow: 33,
|
|
467
|
-
blue: 34,
|
|
468
|
-
magenta: 35,
|
|
469
|
-
cyan: 36,
|
|
470
|
-
white: 37,
|
|
471
|
-
gray: 90,
|
|
472
|
-
brightBlack: 90,
|
|
473
|
-
brightRed: 91,
|
|
474
|
-
brightGreen: 92,
|
|
475
|
-
brightYellow: 93,
|
|
476
|
-
brightBlue: 94,
|
|
477
|
-
brightMagenta: 95,
|
|
478
|
-
brightCyan: 96,
|
|
479
|
-
brightWhite: 97,
|
|
480
|
-
brightGray: 97
|
|
481
|
-
};
|
|
482
|
-
var BG = {
|
|
483
|
-
bgBlack: 40,
|
|
484
|
-
bgRed: 41,
|
|
485
|
-
bgGreen: 42,
|
|
486
|
-
bgYellow: 43,
|
|
487
|
-
bgBlue: 44,
|
|
488
|
-
bgMagenta: 45,
|
|
489
|
-
bgCyan: 46,
|
|
490
|
-
bgWhite: 47,
|
|
491
|
-
bgGray: 100,
|
|
492
|
-
bgBrightBlack: 100,
|
|
493
|
-
bgBrightRed: 101,
|
|
494
|
-
bgBrightGreen: 102,
|
|
495
|
-
bgBrightYellow: 103,
|
|
496
|
-
bgBrightBlue: 104,
|
|
497
|
-
bgBrightMagenta: 105,
|
|
498
|
-
bgBrightCyan: 106,
|
|
499
|
-
bgBrightWhite: 107,
|
|
500
|
-
bgBrightGray: 107
|
|
501
|
-
};
|
|
482
|
+
var clampIndex = (i) => Math.min(255, Math.max(16, Math.round(i)));
|
|
502
483
|
function sgr(seg) {
|
|
503
484
|
const codes = [];
|
|
504
|
-
if (seg.fg
|
|
505
|
-
codes.push(`\x1B[
|
|
485
|
+
if (seg.fg !== void 0) {
|
|
486
|
+
codes.push(`\x1B[38;5;${clampIndex(seg.fg)}m`);
|
|
506
487
|
}
|
|
507
|
-
if (seg.bg
|
|
508
|
-
codes.push(`\x1B[
|
|
488
|
+
if (seg.bg !== void 0) {
|
|
489
|
+
codes.push(`\x1B[48;5;${clampIndex(seg.bg)}m`);
|
|
509
490
|
}
|
|
510
491
|
if (!codes.length) {
|
|
511
492
|
return seg.text;
|
|
@@ -516,115 +497,95 @@ function toAnsi(model) {
|
|
|
516
497
|
return model.lines.map((line) => line.segments.map(sgr).join("")).join("\n");
|
|
517
498
|
}
|
|
518
499
|
|
|
519
|
-
// ../core/src/colors.ts
|
|
520
|
-
var BASE = [
|
|
521
|
-
"black",
|
|
522
|
-
"white",
|
|
523
|
-
"red",
|
|
524
|
-
"green",
|
|
525
|
-
"yellow",
|
|
526
|
-
"blue",
|
|
527
|
-
"magenta",
|
|
528
|
-
"cyan",
|
|
529
|
-
"gray"
|
|
530
|
-
];
|
|
531
|
-
var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
532
|
-
var fg = BASE.flatMap((c) => [c, `bright${cap(c)}`]);
|
|
533
|
-
var bg = BASE.flatMap((c) => [`bg${cap(c)}`, `bgBright${cap(c)}`]);
|
|
534
|
-
var COLORS = /* @__PURE__ */ new Set([...fg, ...bg]);
|
|
535
|
-
function isColor(x) {
|
|
536
|
-
return typeof x === "string" && COLORS.has(x);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
500
|
// ../core/src/theme/themes.ts
|
|
540
|
-
var mk = (rows) => rows.map(([
|
|
501
|
+
var mk = (rows) => rows.map(([fg, bg]) => ({ fg: asIndex(fg), bg: asIndex(bg) }));
|
|
541
502
|
var builtinThemes = {
|
|
542
|
-
default: [
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
],
|
|
503
|
+
default: mk([
|
|
504
|
+
[16, 44],
|
|
505
|
+
[231, 20],
|
|
506
|
+
[16, 226],
|
|
507
|
+
[231, 240],
|
|
508
|
+
[16, 40]
|
|
509
|
+
]),
|
|
549
510
|
classic: mk([
|
|
550
|
-
[
|
|
551
|
-
[
|
|
552
|
-
[
|
|
553
|
-
[
|
|
554
|
-
[
|
|
555
|
-
[
|
|
556
|
-
[
|
|
557
|
-
[
|
|
511
|
+
[16, 184],
|
|
512
|
+
[16, 250],
|
|
513
|
+
[16, 40],
|
|
514
|
+
[231, 20],
|
|
515
|
+
[16, 164],
|
|
516
|
+
[16, 44],
|
|
517
|
+
[16, 226],
|
|
518
|
+
[231, 160]
|
|
558
519
|
]),
|
|
559
520
|
nord: mk([
|
|
560
|
-
[
|
|
561
|
-
[
|
|
562
|
-
[
|
|
563
|
-
[
|
|
564
|
-
[
|
|
565
|
-
[
|
|
566
|
-
[
|
|
567
|
-
[
|
|
521
|
+
[16, 51],
|
|
522
|
+
[16, 44],
|
|
523
|
+
[16, 20],
|
|
524
|
+
[231, 240],
|
|
525
|
+
[16, 21],
|
|
526
|
+
[16, 40],
|
|
527
|
+
[16, 184],
|
|
528
|
+
[231, 16]
|
|
568
529
|
]),
|
|
569
530
|
dracula: mk([
|
|
570
|
-
[
|
|
571
|
-
[
|
|
572
|
-
[
|
|
573
|
-
[
|
|
574
|
-
[
|
|
575
|
-
[
|
|
576
|
-
[
|
|
577
|
-
[
|
|
531
|
+
[16, 164],
|
|
532
|
+
[16, 201],
|
|
533
|
+
[16, 46],
|
|
534
|
+
[16, 51],
|
|
535
|
+
[16, 226],
|
|
536
|
+
[16, 196],
|
|
537
|
+
[231, 240],
|
|
538
|
+
[231, 164]
|
|
578
539
|
]),
|
|
579
540
|
gruvbox: mk([
|
|
580
|
-
[
|
|
581
|
-
[
|
|
582
|
-
[
|
|
583
|
-
[
|
|
584
|
-
[
|
|
585
|
-
[
|
|
586
|
-
[
|
|
587
|
-
[
|
|
541
|
+
[16, 184],
|
|
542
|
+
[16, 226],
|
|
543
|
+
[16, 40],
|
|
544
|
+
[16, 44],
|
|
545
|
+
[16, 160],
|
|
546
|
+
[16, 164],
|
|
547
|
+
[231, 240],
|
|
548
|
+
[231, 16]
|
|
588
549
|
]),
|
|
589
550
|
monokai: mk([
|
|
590
|
-
[
|
|
591
|
-
[
|
|
592
|
-
[
|
|
593
|
-
[
|
|
594
|
-
[
|
|
595
|
-
[
|
|
596
|
-
[
|
|
597
|
-
[
|
|
551
|
+
[16, 46],
|
|
552
|
+
[16, 226],
|
|
553
|
+
[16, 201],
|
|
554
|
+
[16, 51],
|
|
555
|
+
[16, 196],
|
|
556
|
+
[231, 240],
|
|
557
|
+
[16, 184],
|
|
558
|
+
[231, 16]
|
|
598
559
|
]),
|
|
599
560
|
"one-dark": mk([
|
|
600
|
-
[
|
|
601
|
-
[
|
|
602
|
-
[
|
|
603
|
-
[
|
|
604
|
-
[
|
|
605
|
-
[
|
|
606
|
-
[
|
|
607
|
-
[
|
|
561
|
+
[16, 20],
|
|
562
|
+
[16, 21],
|
|
563
|
+
[16, 40],
|
|
564
|
+
[16, 164],
|
|
565
|
+
[16, 184],
|
|
566
|
+
[16, 44],
|
|
567
|
+
[231, 240],
|
|
568
|
+
[231, 16]
|
|
608
569
|
]),
|
|
609
570
|
solarized: mk([
|
|
610
|
-
[
|
|
611
|
-
[
|
|
612
|
-
[
|
|
613
|
-
[
|
|
614
|
-
[
|
|
615
|
-
[
|
|
616
|
-
[
|
|
617
|
-
[
|
|
571
|
+
[231, 20],
|
|
572
|
+
[16, 44],
|
|
573
|
+
[16, 184],
|
|
574
|
+
[231, 40],
|
|
575
|
+
[231, 164],
|
|
576
|
+
[231, 160],
|
|
577
|
+
[231, 240],
|
|
578
|
+
[231, 16]
|
|
618
579
|
]),
|
|
619
580
|
"tokyo-night": mk([
|
|
620
|
-
[
|
|
621
|
-
[
|
|
622
|
-
[
|
|
623
|
-
[
|
|
624
|
-
[
|
|
625
|
-
[
|
|
626
|
-
[
|
|
627
|
-
[
|
|
581
|
+
[16, 21],
|
|
582
|
+
[16, 20],
|
|
583
|
+
[16, 46],
|
|
584
|
+
[16, 201],
|
|
585
|
+
[16, 226],
|
|
586
|
+
[16, 51],
|
|
587
|
+
[231, 240],
|
|
588
|
+
[231, 16]
|
|
628
589
|
])
|
|
629
590
|
};
|
|
630
591
|
|
|
@@ -4768,8 +4729,8 @@ var sep = external_exports.enum(["powerline", "space", "none"]);
|
|
|
4768
4729
|
var itemSchema = external_exports.object({
|
|
4769
4730
|
id: external_exports.string(),
|
|
4770
4731
|
type: external_exports.string(),
|
|
4771
|
-
fg: external_exports.
|
|
4772
|
-
bg: external_exports.
|
|
4732
|
+
fg: external_exports.unknown().optional(),
|
|
4733
|
+
bg: external_exports.unknown().optional(),
|
|
4773
4734
|
merge: external_exports.boolean().optional(),
|
|
4774
4735
|
align: align.optional(),
|
|
4775
4736
|
rawValue: external_exports.boolean().optional(),
|
|
@@ -4848,6 +4809,28 @@ var WIDGET_TYPES = [
|
|
|
4848
4809
|
|
|
4849
4810
|
// ../core/src/config/validate.ts
|
|
4850
4811
|
var clone2 = (v) => JSON.parse(JSON.stringify(v));
|
|
4812
|
+
var ANSI16 = [
|
|
4813
|
+
16,
|
|
4814
|
+
160,
|
|
4815
|
+
40,
|
|
4816
|
+
184,
|
|
4817
|
+
20,
|
|
4818
|
+
164,
|
|
4819
|
+
44,
|
|
4820
|
+
250,
|
|
4821
|
+
240,
|
|
4822
|
+
196,
|
|
4823
|
+
46,
|
|
4824
|
+
226,
|
|
4825
|
+
21,
|
|
4826
|
+
201,
|
|
4827
|
+
51,
|
|
4828
|
+
231
|
|
4829
|
+
].map(asIndex);
|
|
4830
|
+
var baseName = (name) => {
|
|
4831
|
+
const rest = name.slice(2);
|
|
4832
|
+
return rest.charAt(0).toLowerCase() + rest.slice(1);
|
|
4833
|
+
};
|
|
4851
4834
|
var WIDGET_TYPE_SET = new Set(WIDGET_TYPES);
|
|
4852
4835
|
function cleanStyle(raw, type, warn) {
|
|
4853
4836
|
const style = {};
|
|
@@ -4915,10 +4898,24 @@ function cleanThemes(themes, warn) {
|
|
|
4915
4898
|
if (v === void 0) {
|
|
4916
4899
|
continue;
|
|
4917
4900
|
}
|
|
4918
|
-
if (
|
|
4901
|
+
if (isColorIndex(v)) {
|
|
4919
4902
|
slot[key] = v;
|
|
4903
|
+
} else if (typeof v === "number" && Number.isInteger(v) && v >= 0 && v <= 15) {
|
|
4904
|
+
const mapped = ANSI16[v] ?? asIndex(16);
|
|
4905
|
+
slot[key] = mapped;
|
|
4906
|
+
warn(
|
|
4907
|
+
`color index ${v} dims in the status line; using ${mapped} in theme "${name}" (slot ${i})`
|
|
4908
|
+
);
|
|
4920
4909
|
} else {
|
|
4921
|
-
|
|
4910
|
+
const named = typeof v === "string" ? NAMED_INDEX.get(v) ?? (v.startsWith("bg") ? NAMED_INDEX.get(baseName(v)) : void 0) : void 0;
|
|
4911
|
+
if (named !== void 0) {
|
|
4912
|
+
slot[key] = named;
|
|
4913
|
+
warn(
|
|
4914
|
+
`named colors are now 256-color indices; using ${named} for "${String(v)}" in theme "${name}"`
|
|
4915
|
+
);
|
|
4916
|
+
} else {
|
|
4917
|
+
warn(`dropped invalid color ${String(v)} in theme "${name}" (slot ${i})`);
|
|
4918
|
+
}
|
|
4922
4919
|
}
|
|
4923
4920
|
}
|
|
4924
4921
|
slots.push(slot);
|
|
@@ -5149,21 +5146,6 @@ function importCcstatusline(raw) {
|
|
|
5149
5146
|
return { config: loaded.config, warnings: [...warnings, ...loaded.warnings] };
|
|
5150
5147
|
}
|
|
5151
5148
|
|
|
5152
|
-
// ../core/src/renderer-colors.ts
|
|
5153
|
-
var toInk = (n) => {
|
|
5154
|
-
if (!n) {
|
|
5155
|
-
return void 0;
|
|
5156
|
-
}
|
|
5157
|
-
return n.startsWith("bright") ? (n[6] ?? "").toLowerCase() + n.slice(7) + "Bright" : n;
|
|
5158
|
-
};
|
|
5159
|
-
var rendererColor = (fg2) => toInk(fg2);
|
|
5160
|
-
var rendererBg = (bg2) => {
|
|
5161
|
-
if (!bg2) {
|
|
5162
|
-
return void 0;
|
|
5163
|
-
}
|
|
5164
|
-
return toInk(bg2.startsWith("bg") ? (bg2[2] ?? "").toLowerCase() + bg2.slice(3) : bg2);
|
|
5165
|
-
};
|
|
5166
|
-
|
|
5167
5149
|
// src/config-store.ts
|
|
5168
5150
|
import {
|
|
5169
5151
|
copyFileSync,
|
|
@@ -5334,16 +5316,15 @@ function readSnapshot(path) {
|
|
|
5334
5316
|
|
|
5335
5317
|
export {
|
|
5336
5318
|
registry,
|
|
5319
|
+
asIndex,
|
|
5320
|
+
indexToHex,
|
|
5337
5321
|
render,
|
|
5338
5322
|
toAnsi,
|
|
5339
|
-
COLORS,
|
|
5340
5323
|
isValidWhen,
|
|
5341
5324
|
LINKABLE,
|
|
5342
5325
|
linkedSurfaces,
|
|
5343
5326
|
writeLinkedLines,
|
|
5344
5327
|
importCcstatusline,
|
|
5345
|
-
rendererColor,
|
|
5346
|
-
rendererBg,
|
|
5347
5328
|
configPath,
|
|
5348
5329
|
snapshotPath,
|
|
5349
5330
|
loadConfigFile,
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
var sub = process.argv[2];
|
|
6
6
|
if (sub === "statusline") {
|
|
7
|
-
const { runStatusline } = await import("./statusline-cmd-
|
|
7
|
+
const { runStatusline } = await import("./statusline-cmd-GFPWLYEQ.js");
|
|
8
8
|
await runStatusline();
|
|
9
9
|
} else {
|
|
10
10
|
const { render } = await import("ink");
|
|
11
|
-
const { App } = await import("./app-
|
|
11
|
+
const { App } = await import("./app-JJQ6RQ3D.js");
|
|
12
12
|
render(/* @__PURE__ */ jsx(App, {}));
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sushant-kum/ccstatus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Interactive configurator (npx @sushant-kum/ccstatus) for the ccstatus Claude Code status bar — band, status line, pane, and threshold toasts from one config.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sushant Kumar",
|