@sushant-kum/ccstatus 0.3.5 → 0.4.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.
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
saveConfigFile,
|
|
15
15
|
snapshotPath,
|
|
16
16
|
writeLinkedLines
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3SF24XVL.js";
|
|
18
18
|
|
|
19
19
|
// src/app.tsx
|
|
20
20
|
import { Box as Box12, Text as Text12, useApp, useInput as useInput10 } from "ink";
|
|
@@ -132,7 +132,8 @@ import { Box as Box3, Text as Text3, useInput } from "ink";
|
|
|
132
132
|
import { useState } from "react";
|
|
133
133
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
134
134
|
var SEPARATORS = ["powerline", "space", "none"];
|
|
135
|
-
var
|
|
135
|
+
var ALIGNS = ["left", "center", "right"];
|
|
136
|
+
var FIELDS = ["separator", "padding", "alignColumns", "align"];
|
|
136
137
|
function Defaults({ config, setConfig, goHome }) {
|
|
137
138
|
const [focus, setFocus] = useState(0);
|
|
138
139
|
const d = config.defaults;
|
|
@@ -142,11 +143,17 @@ function Defaults({ config, setConfig, goHome }) {
|
|
|
142
143
|
const i = SEPARATORS.indexOf(d.separator);
|
|
143
144
|
const next = SEPARATORS[(i + dir + SEPARATORS.length) % SEPARATORS.length] ?? d.separator;
|
|
144
145
|
setConfig({ ...config, defaults: { ...d, separator: next } });
|
|
145
|
-
} else {
|
|
146
|
+
} else if (field === "padding") {
|
|
146
147
|
const next = Math.min(4, Math.max(0, d.padding + dir));
|
|
147
148
|
if (next !== d.padding) {
|
|
148
149
|
setConfig({ ...config, defaults: { ...d, padding: next } });
|
|
149
150
|
}
|
|
151
|
+
} else if (field === "alignColumns") {
|
|
152
|
+
setConfig({ ...config, defaults: { ...d, alignColumns: !d.alignColumns } });
|
|
153
|
+
} else {
|
|
154
|
+
const i = ALIGNS.indexOf(d.align);
|
|
155
|
+
const next = ALIGNS[(i + dir + ALIGNS.length) % ALIGNS.length] ?? d.align;
|
|
156
|
+
setConfig({ ...config, defaults: { ...d, align: next } });
|
|
150
157
|
}
|
|
151
158
|
};
|
|
152
159
|
useInput((_i, key) => {
|
|
@@ -162,21 +169,22 @@ function Defaults({ config, setConfig, goHome }) {
|
|
|
162
169
|
cycle(1);
|
|
163
170
|
}
|
|
164
171
|
});
|
|
165
|
-
const row = (idx, name, value) => /* @__PURE__ */ jsxs2(Text3, { color: focus === idx ? "cyan" : void 0, children: [
|
|
172
|
+
const row = (idx, name, value, note) => /* @__PURE__ */ jsxs2(Text3, { color: focus === idx ? "cyan" : void 0, children: [
|
|
166
173
|
focus === idx ? "\u25B8 " : " ",
|
|
167
174
|
name,
|
|
168
175
|
": ",
|
|
169
|
-
value
|
|
176
|
+
value,
|
|
177
|
+
note ? /* @__PURE__ */ jsxs2(Text3, { color: "gray", children: [
|
|
178
|
+
" ",
|
|
179
|
+
note
|
|
180
|
+
] }) : null
|
|
170
181
|
] });
|
|
171
182
|
return /* @__PURE__ */ jsxs2(Box3, { flexDirection: "column", children: [
|
|
172
183
|
/* @__PURE__ */ jsx2(Text3, { bold: true, children: "Global defaults" }),
|
|
173
184
|
row(0, "separator", d.separator),
|
|
174
185
|
row(1, "padding", String(d.padding)),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
d.align,
|
|
178
|
-
" (stored, not yet applied)"
|
|
179
|
-
] }),
|
|
186
|
+
row(2, "align columns", d.alignColumns ? "on" : "off"),
|
|
187
|
+
row(3, "align", d.align, d.alignColumns ? void 0 : "(applies when align columns is on)"),
|
|
180
188
|
/* @__PURE__ */ jsx2(Text3, { dimColor: true, children: "\u2191/\u2193 field \xB7 \u2190/\u2192 change \xB7 esc back" })
|
|
181
189
|
] });
|
|
182
190
|
}
|
|
@@ -318,7 +326,7 @@ import { useState as useState3 } from "react";
|
|
|
318
326
|
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
319
327
|
var SURFACES = LINKABLE;
|
|
320
328
|
var FIELDS2 = ["raw", "merge", "align"];
|
|
321
|
-
var
|
|
329
|
+
var ALIGNS2 = ["left", "center", "right"];
|
|
322
330
|
var WIDGETS = Object.values(registry);
|
|
323
331
|
var wrap = (i, n) => (i + n) % n;
|
|
324
332
|
var makeId = (type) => `${type}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
|
|
@@ -413,7 +421,7 @@ function Items({ config, setConfig, goHome }) {
|
|
|
413
421
|
} else if (f === "merge") {
|
|
414
422
|
patch({ merge: !cur.merge });
|
|
415
423
|
} else {
|
|
416
|
-
patch({ align:
|
|
424
|
+
patch({ align: ALIGNS2[wrap(ALIGNS2.indexOf(cur.align ?? "left") + dir + 3, 3)] ?? "left" });
|
|
417
425
|
}
|
|
418
426
|
};
|
|
419
427
|
const move = (dir) => {
|
|
@@ -29,6 +29,35 @@ function itemToCell(item, config, snapshot, commandOutputs) {
|
|
|
29
29
|
function lineToCells(items, config, snapshot, commandOutputs) {
|
|
30
30
|
return items.map((it) => itemToCell(it, config, snapshot, commandOutputs)).filter((c) => c !== null);
|
|
31
31
|
}
|
|
32
|
+
function justify(text, width, align2) {
|
|
33
|
+
const deficit = width - text.length;
|
|
34
|
+
if (deficit <= 0) {
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
if (align2 === "right") {
|
|
38
|
+
return " ".repeat(deficit) + text;
|
|
39
|
+
}
|
|
40
|
+
if (align2 === "center") {
|
|
41
|
+
const left = Math.floor(deficit / 2);
|
|
42
|
+
return " ".repeat(left) + text + " ".repeat(deficit - left);
|
|
43
|
+
}
|
|
44
|
+
return text + " ".repeat(deficit);
|
|
45
|
+
}
|
|
46
|
+
function alignColumns(lines, align2) {
|
|
47
|
+
const widths = [];
|
|
48
|
+
for (const cells of lines) {
|
|
49
|
+
cells.forEach((c, i) => {
|
|
50
|
+
if (!c.flex) {
|
|
51
|
+
widths[i] = Math.max(widths[i] ?? 0, c.text.length);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return lines.map(
|
|
56
|
+
(cells) => cells.map(
|
|
57
|
+
(c, i) => c.flex ? c : { ...c, text: justify(c.text, widths[i] ?? c.text.length, align2) }
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
32
61
|
|
|
33
62
|
// ../core/src/layout/compose.ts
|
|
34
63
|
function mergeCells(cells) {
|
|
@@ -477,7 +506,11 @@ function render(config, snapshot, opts) {
|
|
|
477
506
|
}
|
|
478
507
|
const outputs = opts.commandOutputs ?? {};
|
|
479
508
|
const theme = Object.hasOwn(config.themes, config.theme) ? config.themes[config.theme] ?? [] : [];
|
|
480
|
-
|
|
509
|
+
let lineCells = surface.lines.map((items) => lineToCells(items, config, snapshot, outputs)).filter((cells) => cells.length > 0);
|
|
510
|
+
if (config.defaults.alignColumns) {
|
|
511
|
+
lineCells = alignColumns(lineCells, config.defaults.align);
|
|
512
|
+
}
|
|
513
|
+
const lines = lineCells.map((cells) => assignPaletteColors(cells, theme)).map((cells) => ({
|
|
481
514
|
segments: composeLine(cells, config.defaults.separator, opts.width, config.defaults.glyph)
|
|
482
515
|
}));
|
|
483
516
|
return { lines };
|
|
@@ -504,7 +537,27 @@ function toAnsi(model) {
|
|
|
504
537
|
|
|
505
538
|
// ../core/src/theme/themes.ts
|
|
506
539
|
var mk = (rows) => rows.map(([fg, bg]) => ({ fg: asIndex(fg), bg: asIndex(bg) }));
|
|
540
|
+
var zip = (fg, bg) => fg.map((f, i) => ({ fg: asIndex(f), bg: asIndex(bg[i] ?? f) }));
|
|
507
541
|
var builtinThemes = {
|
|
542
|
+
default: mk([
|
|
543
|
+
[16, 44],
|
|
544
|
+
[231, 20],
|
|
545
|
+
[16, 226],
|
|
546
|
+
[231, 240],
|
|
547
|
+
[16, 40]
|
|
548
|
+
]),
|
|
549
|
+
nord: zip([16, 254, 231, 231, 16], [73, 239, 25, 96, 152]),
|
|
550
|
+
"nord-aurora": zip([231, 16, 231, 16, 16], [131, 220, 68, 108, 176]),
|
|
551
|
+
monokai: zip([235, 255, 235, 16, 235], [148, 238, 186, 141, 81]),
|
|
552
|
+
solarized: zip([231, 234, 254, 16, 234], [33, 136, 240, 37, 254]),
|
|
553
|
+
minimal: zip([255, 232, 255, 232, 252], [240, 251, 233, 248, 236]),
|
|
554
|
+
dracula: zip([235, 235, 235, 235, 231], [141, 253, 204, 117, 236]),
|
|
555
|
+
catppuccin: zip([235, 255, 235, 235, 235], [176, 238, 150, 210, 111]),
|
|
556
|
+
gruvbox: zip([16, 235, 235, 16, 235], [167, 214, 246, 109, 142]),
|
|
557
|
+
onedark: zip([235, 251, 235, 16, 235], [75, 237, 114, 204, 180]),
|
|
558
|
+
tokyonight: zip([16, 234, 16, 234, 234], [111, 248, 176, 221, 80])
|
|
559
|
+
};
|
|
560
|
+
var legacyBuiltinThemes = {
|
|
508
561
|
default: mk([
|
|
509
562
|
[16, 44],
|
|
510
563
|
[231, 20],
|
|
@@ -593,6 +646,30 @@ var builtinThemes = {
|
|
|
593
646
|
[231, 16]
|
|
594
647
|
])
|
|
595
648
|
};
|
|
649
|
+
var legacyThemeAliases = {
|
|
650
|
+
"one-dark": "onedark",
|
|
651
|
+
"tokyo-night": "tokyonight",
|
|
652
|
+
classic: "default"
|
|
653
|
+
};
|
|
654
|
+
function sameTheme(a, b) {
|
|
655
|
+
return a.length === b.length && a.every((s, i) => s.fg === b[i]?.fg && s.bg === b[i]?.bg);
|
|
656
|
+
}
|
|
657
|
+
function withBuiltinThemes(saved) {
|
|
658
|
+
const out = {};
|
|
659
|
+
for (const [name, theme] of Object.entries(saved)) {
|
|
660
|
+
const legacy2 = legacyBuiltinThemes[name];
|
|
661
|
+
if (legacy2 && sameTheme(theme, legacy2)) {
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
out[name] = theme;
|
|
665
|
+
}
|
|
666
|
+
for (const [name, theme] of Object.entries(builtinThemes)) {
|
|
667
|
+
if (!Object.hasOwn(out, name)) {
|
|
668
|
+
out[name] = theme.map((s) => ({ ...s }));
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return out;
|
|
672
|
+
}
|
|
596
673
|
|
|
597
674
|
// ../core/src/toast.ts
|
|
598
675
|
var TOAST_FIELDS = {
|
|
@@ -618,7 +695,14 @@ var defaultConfig = {
|
|
|
618
695
|
version: 1,
|
|
619
696
|
theme: "default",
|
|
620
697
|
themes: structuredClone(builtinThemes),
|
|
621
|
-
defaults: {
|
|
698
|
+
defaults: {
|
|
699
|
+
separator: "powerline",
|
|
700
|
+
padding: 1,
|
|
701
|
+
align: "left",
|
|
702
|
+
glyph: "\u2592",
|
|
703
|
+
invert: false,
|
|
704
|
+
alignColumns: false
|
|
705
|
+
},
|
|
622
706
|
surfaces: {
|
|
623
707
|
band: {
|
|
624
708
|
enabled: true,
|
|
@@ -4762,7 +4846,8 @@ var configSchema = external_exports.object({
|
|
|
4762
4846
|
padding: external_exports.number().int().min(0).catch(1),
|
|
4763
4847
|
align,
|
|
4764
4848
|
glyph: external_exports.string().min(1),
|
|
4765
|
-
invert: external_exports.boolean()
|
|
4849
|
+
invert: external_exports.boolean(),
|
|
4850
|
+
alignColumns: external_exports.boolean()
|
|
4766
4851
|
}).partial().default({}),
|
|
4767
4852
|
surfaces: external_exports.object({
|
|
4768
4853
|
band: surfaceLayoutSchema.optional(),
|
|
@@ -4975,15 +5060,17 @@ function loadConfig(raw) {
|
|
|
4975
5060
|
}
|
|
4976
5061
|
return layout;
|
|
4977
5062
|
};
|
|
4978
|
-
const
|
|
4979
|
-
const themes = Object.keys(cleaned).length ? cleaned : clone2(builtinThemes);
|
|
4980
|
-
if (!Object.hasOwn(themes, "default")) {
|
|
4981
|
-
themes["default"] = clone2(builtinThemes["default"] ?? []);
|
|
4982
|
-
}
|
|
5063
|
+
const themes = withBuiltinThemes(cleanThemes(p.themes, warn));
|
|
4983
5064
|
let theme = p.theme;
|
|
4984
5065
|
if (!Object.hasOwn(themes, theme)) {
|
|
4985
|
-
|
|
4986
|
-
|
|
5066
|
+
const alias = legacyThemeAliases[theme];
|
|
5067
|
+
if (alias && Object.hasOwn(themes, alias)) {
|
|
5068
|
+
warn(`theme "${theme}" was renamed; using "${alias}"`);
|
|
5069
|
+
theme = alias;
|
|
5070
|
+
} else {
|
|
5071
|
+
warn(`theme "${theme}" not found; using "default"`);
|
|
5072
|
+
theme = "default";
|
|
5073
|
+
}
|
|
4987
5074
|
}
|
|
4988
5075
|
const config = {
|
|
4989
5076
|
version: 1,
|
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-UZEENPJL.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-6T35K6F2.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.4.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",
|