@sushant-kum/ccstatus 0.4.3 → 0.4.5
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-YDUSNB5C.js";
|
|
18
18
|
|
|
19
19
|
// src/app.tsx
|
|
20
20
|
import { Box as Box12, Text as Text12, useApp, useInput as useInput10 } from "ink";
|
|
@@ -677,7 +677,7 @@ var LOGO_ART = [
|
|
|
677
677
|
];
|
|
678
678
|
|
|
679
679
|
// src/version.ts
|
|
680
|
-
var VERSION = "0.4.
|
|
680
|
+
var VERSION = "0.4.5";
|
|
681
681
|
|
|
682
682
|
// src/screens/menu.tsx
|
|
683
683
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
@@ -29,20 +29,6 @@ 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
32
|
function willMerge(cells, index) {
|
|
47
33
|
const cell = cells[index];
|
|
48
34
|
if (!cell || !cell.merge || cell.flex || index === 0) {
|
|
@@ -50,22 +36,43 @@ function willMerge(cells, index) {
|
|
|
50
36
|
}
|
|
51
37
|
return !(cells[index - 1]?.flex ?? true);
|
|
52
38
|
}
|
|
53
|
-
function
|
|
39
|
+
function groupRuns(cells) {
|
|
40
|
+
const runs = [];
|
|
41
|
+
cells.forEach((c, i) => {
|
|
42
|
+
const run = runs[runs.length - 1];
|
|
43
|
+
if (run && willMerge(cells, i)) {
|
|
44
|
+
run.push(c);
|
|
45
|
+
} else {
|
|
46
|
+
runs.push([c]);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return runs;
|
|
50
|
+
}
|
|
51
|
+
function alignColumns(lines, align2) {
|
|
52
|
+
const runWidth = (run) => run.reduce((n, c) => n + c.text.length, 0);
|
|
53
|
+
const isFlexRun = (run) => run.length === 1 && (run[0]?.flex ?? false);
|
|
54
|
+
const lineRuns = lines.map(groupRuns);
|
|
54
55
|
const widths = [];
|
|
55
|
-
for (const
|
|
56
|
-
|
|
57
|
-
if (!
|
|
58
|
-
widths[
|
|
56
|
+
for (const runs of lineRuns) {
|
|
57
|
+
runs.forEach((run, j) => {
|
|
58
|
+
if (!isFlexRun(run)) {
|
|
59
|
+
widths[j] = Math.max(widths[j] ?? 0, runWidth(run));
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
return
|
|
63
|
-
(
|
|
64
|
-
if (
|
|
65
|
-
return c;
|
|
63
|
+
return lineRuns.map(
|
|
64
|
+
(runs) => runs.flatMap((run, j) => {
|
|
65
|
+
if (isFlexRun(run)) {
|
|
66
|
+
return run.map((c) => ({ ...c }));
|
|
66
67
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
68
|
+
const deficit = (widths[j] ?? runWidth(run)) - runWidth(run);
|
|
69
|
+
const leftPad = deficit <= 0 ? 0 : align2 === "right" ? deficit : align2 === "center" ? Math.floor(deficit / 2) : 0;
|
|
70
|
+
const rightPad = deficit <= 0 ? 0 : deficit - leftPad;
|
|
71
|
+
return run.map((c, k) => {
|
|
72
|
+
const lead = k === 0 ? " ".repeat(leftPad) : "";
|
|
73
|
+
const tail = k === run.length - 1 ? " ".repeat(rightPad) : "";
|
|
74
|
+
return { ...c, text: `${lead}${c.text}${tail}` };
|
|
75
|
+
});
|
|
69
76
|
})
|
|
70
77
|
);
|
|
71
78
|
}
|
|
@@ -423,22 +430,18 @@ register({
|
|
|
423
430
|
type: "rate-limit-5h",
|
|
424
431
|
label: "Session limit",
|
|
425
432
|
format: ({ snapshot }) => {
|
|
426
|
-
|
|
427
|
-
return "Session: \u2014";
|
|
428
|
-
}
|
|
433
|
+
const p = snapshot.fivePct ?? 0;
|
|
429
434
|
const reset = until(snapshot.fiveReset, snapshot.now);
|
|
430
|
-
return `Session: ${bar(
|
|
435
|
+
return `Session: ${bar(p)} ${pct(p)}${reset !== null ? ` ${fmtDur(reset)}` : ""}`;
|
|
431
436
|
}
|
|
432
437
|
});
|
|
433
438
|
register({
|
|
434
439
|
type: "rate-limit-week",
|
|
435
440
|
label: "Weekly limit",
|
|
436
441
|
format: ({ snapshot }) => {
|
|
437
|
-
|
|
438
|
-
return "Weekly: \u2014";
|
|
439
|
-
}
|
|
442
|
+
const p = snapshot.weekPct ?? 0;
|
|
440
443
|
const reset = until(snapshot.weekReset, snapshot.now);
|
|
441
|
-
return `Weekly: ${pct(
|
|
444
|
+
return `Weekly: ${pct(p)}${reset !== null ? ` ${fmtDur(reset)}` : ""}`;
|
|
442
445
|
}
|
|
443
446
|
});
|
|
444
447
|
register({
|
|
@@ -452,12 +455,14 @@ register({
|
|
|
452
455
|
register({
|
|
453
456
|
type: "session-usage",
|
|
454
457
|
label: "Session %",
|
|
455
|
-
format: ({ snapshot }) =>
|
|
458
|
+
format: ({ snapshot }) => `Session: ${pct(snapshot.fivePct ?? 0)}`
|
|
459
|
+
// unknown shows 0% (DEC-0033)
|
|
456
460
|
});
|
|
457
461
|
register({
|
|
458
462
|
type: "weekly-usage",
|
|
459
463
|
label: "Weekly %",
|
|
460
|
-
format: ({ snapshot }) =>
|
|
464
|
+
format: ({ snapshot }) => `Weekly: ${pct(snapshot.weekPct ?? 0)}`
|
|
465
|
+
// unknown shows 0% (DEC-0033)
|
|
461
466
|
});
|
|
462
467
|
register({
|
|
463
468
|
type: "reset-timer",
|
|
@@ -519,8 +524,7 @@ function render(config, snapshot, opts) {
|
|
|
519
524
|
const theme = Object.hasOwn(config.themes, config.theme) ? config.themes[config.theme] ?? [] : [];
|
|
520
525
|
let lineCells = surface.lines.map((items) => lineToCells(items, config, snapshot, outputs)).filter((cells) => cells.length > 0);
|
|
521
526
|
if (config.defaults.alignColumns) {
|
|
522
|
-
|
|
523
|
-
lineCells = alignColumns(lineCells, config.defaults.align, sepWidth);
|
|
527
|
+
lineCells = alignColumns(lineCells, config.defaults.align);
|
|
524
528
|
}
|
|
525
529
|
const lines = lineCells.map((cells) => assignPaletteColors(cells, theme)).map((cells) => ({
|
|
526
530
|
segments: composeLine(cells, config.defaults.separator, opts.width, config.defaults.glyph)
|
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-XD2FWV3G.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-EVASPE7J.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.5",
|
|
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",
|