@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-WRVJLKMW.js";
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.3";
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 alignColumns(lines, align2, sepWidth) {
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 cells of lines) {
56
- cells.forEach((c, i) => {
57
- if (!c.flex) {
58
- widths[i] = Math.max(widths[i] ?? 0, c.text.length);
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 lines.map(
63
- (cells) => cells.map((c, i) => {
64
- if (c.flex) {
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 padded = justify(c.text, widths[i] ?? c.text.length, align2);
68
- return { ...c, text: willMerge(cells, i) ? " ".repeat(sepWidth) + padded : padded };
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
- if (snapshot.fivePct === null) {
427
- return "Session: \u2014";
428
- }
433
+ const p = snapshot.fivePct ?? 0;
429
434
  const reset = until(snapshot.fiveReset, snapshot.now);
430
- return `Session: ${bar(snapshot.fivePct)} ${pct(snapshot.fivePct)}${reset !== null ? ` ${fmtDur(reset)}` : ""}`;
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
- if (snapshot.weekPct === null) {
438
- return "Weekly: \u2014";
439
- }
442
+ const p = snapshot.weekPct ?? 0;
440
443
  const reset = until(snapshot.weekReset, snapshot.now);
441
- return `Weekly: ${pct(snapshot.weekPct)}${reset !== null ? ` ${fmtDur(reset)}` : ""}`;
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 }) => snapshot.fivePct === null ? null : `Session: ${pct(snapshot.fivePct)}`
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 }) => snapshot.weekPct === null ? null : `Weekly: ${pct(snapshot.weekPct)}`
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
- const sepWidth = config.defaults.separator === "none" ? 0 : 1;
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-APRACBI7.js");
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-UUOO5VUF.js");
11
+ const { App } = await import("./app-EVASPE7J.js");
12
12
  render(/* @__PURE__ */ jsx(App, {}));
13
13
  }
@@ -6,7 +6,7 @@ import {
6
6
  render,
7
7
  snapshotPath,
8
8
  toAnsi
9
- } from "./chunk-WRVJLKMW.js";
9
+ } from "./chunk-YDUSNB5C.js";
10
10
 
11
11
  // src/statusline-cmd.ts
12
12
  function renderStatuslineAnsi(config, snapshot) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sushant-kum/ccstatus",
3
- "version": "0.4.3",
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",