@sushant-kum/ccstatus 0.4.2 → 0.4.4

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-3SF24XVL.js";
17
+ } from "./chunk-QEGRKLAH.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.2";
680
+ var VERSION = "0.4.4";
681
681
 
682
682
  // src/screens/menu.tsx
683
683
  import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
@@ -29,47 +29,65 @@ 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);
32
+ function willMerge(cells, index) {
33
+ const cell = cells[index];
34
+ if (!cell || !cell.merge || cell.flex || index === 0) {
35
+ return false;
43
36
  }
44
- return text + " ".repeat(deficit);
37
+ return !(cells[index - 1]?.flex ?? true);
38
+ }
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;
45
50
  }
46
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);
47
55
  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);
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));
52
60
  }
53
61
  });
54
62
  }
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
- )
63
+ return lineRuns.map(
64
+ (runs) => runs.flatMap((run, j) => {
65
+ if (isFlexRun(run)) {
66
+ return run.map((c) => ({ ...c }));
67
+ }
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
+ });
76
+ })
59
77
  );
60
78
  }
61
79
 
62
80
  // ../core/src/layout/compose.ts
63
81
  function mergeCells(cells) {
64
82
  const out = [];
65
- for (const c of cells) {
83
+ cells.forEach((c, i) => {
66
84
  const prev = out[out.length - 1];
67
- if (c.merge && prev && !prev.flex && !c.flex) {
85
+ if (willMerge(cells, i) && prev) {
68
86
  prev.text = `${prev.text}${c.text}`;
69
87
  } else {
70
88
  out.push({ ...c });
71
89
  }
72
- }
90
+ });
73
91
  return out;
74
92
  }
75
93
  function truncate(segs, width) {
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-UZEENPJL.js");
7
+ const { runStatusline } = await import("./statusline-cmd-OVE66FV3.js");
8
8
  await runStatusline();
9
9
  } else {
10
10
  const { render } = await import("ink");
11
- const { App } = await import("./app-BVTV7HRG.js");
11
+ const { App } = await import("./app-6JK5LUBR.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-3SF24XVL.js";
9
+ } from "./chunk-QEGRKLAH.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.2",
3
+ "version": "0.4.4",
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",