@sushant-kum/ccstatus 0.4.0 → 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 };
|
|
@@ -662,7 +695,14 @@ var defaultConfig = {
|
|
|
662
695
|
version: 1,
|
|
663
696
|
theme: "default",
|
|
664
697
|
themes: structuredClone(builtinThemes),
|
|
665
|
-
defaults: {
|
|
698
|
+
defaults: {
|
|
699
|
+
separator: "powerline",
|
|
700
|
+
padding: 1,
|
|
701
|
+
align: "left",
|
|
702
|
+
glyph: "\u2592",
|
|
703
|
+
invert: false,
|
|
704
|
+
alignColumns: false
|
|
705
|
+
},
|
|
666
706
|
surfaces: {
|
|
667
707
|
band: {
|
|
668
708
|
enabled: true,
|
|
@@ -4806,7 +4846,8 @@ var configSchema = external_exports.object({
|
|
|
4806
4846
|
padding: external_exports.number().int().min(0).catch(1),
|
|
4807
4847
|
align,
|
|
4808
4848
|
glyph: external_exports.string().min(1),
|
|
4809
|
-
invert: external_exports.boolean()
|
|
4849
|
+
invert: external_exports.boolean(),
|
|
4850
|
+
alignColumns: external_exports.boolean()
|
|
4810
4851
|
}).partial().default({}),
|
|
4811
4852
|
surfaces: external_exports.object({
|
|
4812
4853
|
band: surfaceLayoutSchema.optional(),
|
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.4.
|
|
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",
|