@sushant-kum/ccstatus 0.4.3 → 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-WRVJLKMW.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.3";
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,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
  }
@@ -519,8 +526,7 @@ function render(config, snapshot, opts) {
519
526
  const theme = Object.hasOwn(config.themes, config.theme) ? config.themes[config.theme] ?? [] : [];
520
527
  let lineCells = surface.lines.map((items) => lineToCells(items, config, snapshot, outputs)).filter((cells) => cells.length > 0);
521
528
  if (config.defaults.alignColumns) {
522
- const sepWidth = config.defaults.separator === "none" ? 0 : 1;
523
- lineCells = alignColumns(lineCells, config.defaults.align, sepWidth);
529
+ lineCells = alignColumns(lineCells, config.defaults.align);
524
530
  }
525
531
  const lines = lineCells.map((cells) => assignPaletteColors(cells, theme)).map((cells) => ({
526
532
  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-OVE66FV3.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-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-WRVJLKMW.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.3",
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",