ccstatusline 2.0.8 → 2.0.9
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.
- package/dist/ccstatusline.js +92 -64
- package/package.json +1 -1
package/dist/ccstatusline.js
CHANGED
|
@@ -51037,7 +51037,7 @@ import { execSync as execSync3 } from "child_process";
|
|
|
51037
51037
|
import * as fs5 from "fs";
|
|
51038
51038
|
import * as path4 from "path";
|
|
51039
51039
|
var __dirname = "/Users/sirmalloc/Projects/Personal/ccstatusline/src/utils";
|
|
51040
|
-
var PACKAGE_VERSION = "2.0.
|
|
51040
|
+
var PACKAGE_VERSION = "2.0.9";
|
|
51041
51041
|
function getPackageVersion() {
|
|
51042
51042
|
if (/^\d+\.\d+\.\d+/.test(PACKAGE_VERSION)) {
|
|
51043
51043
|
return PACKAGE_VERSION;
|
|
@@ -52038,7 +52038,7 @@ function formatTokens(count) {
|
|
|
52038
52038
|
return `${(count / 1000).toFixed(1)}k`;
|
|
52039
52039
|
return count.toString();
|
|
52040
52040
|
}
|
|
52041
|
-
function renderPowerlineStatusLine(widgets, settings, context, lineIndex = 0, globalSeparatorOffset = 0,
|
|
52041
|
+
function renderPowerlineStatusLine(widgets, settings, context, lineIndex = 0, globalSeparatorOffset = 0, preRenderedWidgets, preCalculatedMaxWidths) {
|
|
52042
52042
|
const powerlineConfig = settings.powerline;
|
|
52043
52043
|
const config2 = powerlineConfig ?? {};
|
|
52044
52044
|
const separators = config2.separators ?? [""];
|
|
@@ -52101,12 +52101,13 @@ function renderPowerlineStatusLine(widgets, settings, context, lineIndex = 0, gl
|
|
|
52101
52101
|
if (widget.type === "separator" || widget.type === "flex-separator") {
|
|
52102
52102
|
continue;
|
|
52103
52103
|
}
|
|
52104
|
-
|
|
52105
|
-
|
|
52106
|
-
widgetText =
|
|
52107
|
-
|
|
52108
|
-
|
|
52109
|
-
|
|
52104
|
+
const preRendered = preRenderedWidgets[i];
|
|
52105
|
+
if (preRendered?.content) {
|
|
52106
|
+
widgetText = preRendered.content;
|
|
52107
|
+
try {
|
|
52108
|
+
const widgetImpl = getWidget(widget.type);
|
|
52109
|
+
defaultColor = widgetImpl.getDefaultColor();
|
|
52110
|
+
} catch {}
|
|
52110
52111
|
}
|
|
52111
52112
|
if (widgetText) {
|
|
52112
52113
|
const padding = settings.defaultPadding ?? "";
|
|
@@ -52146,47 +52147,10 @@ function renderPowerlineStatusLine(widgets, settings, context, lineIndex = 0, gl
|
|
|
52146
52147
|
if (widgetElements.length === 0)
|
|
52147
52148
|
return "";
|
|
52148
52149
|
const autoAlign = config2.autoAlign;
|
|
52149
|
-
if (autoAlign
|
|
52150
|
-
const maxWidths = [];
|
|
52151
|
-
const allLinesElements = [];
|
|
52152
|
-
for (const lineWidgets of allLinesWidgets) {
|
|
52153
|
-
const filteredLineWidgets = lineWidgets.filter((w) => w.type !== "separator" && w.type !== "flex-separator");
|
|
52154
|
-
const lineElements = [];
|
|
52155
|
-
for (const widget of filteredLineWidgets) {
|
|
52156
|
-
let widgetText = "";
|
|
52157
|
-
try {
|
|
52158
|
-
const widgetImpl = getWidget(widget.type);
|
|
52159
|
-
widgetText = widgetImpl.render(widget, context, settings) ?? "";
|
|
52160
|
-
} catch {
|
|
52161
|
-
continue;
|
|
52162
|
-
}
|
|
52163
|
-
if (widgetText) {
|
|
52164
|
-
const padding = settings.defaultPadding ?? "";
|
|
52165
|
-
const paddedText = `${padding}${widgetText}${padding}`;
|
|
52166
|
-
lineElements.push({
|
|
52167
|
-
content: paddedText,
|
|
52168
|
-
bgColor: widget.backgroundColor,
|
|
52169
|
-
fgColor: widget.color,
|
|
52170
|
-
widget
|
|
52171
|
-
});
|
|
52172
|
-
}
|
|
52173
|
-
}
|
|
52174
|
-
allLinesElements.push(lineElements);
|
|
52175
|
-
}
|
|
52176
|
-
for (let pos = 0;pos < Math.max(...allLinesElements.map((line) => line.length)); pos++) {
|
|
52177
|
-
let maxWidth = 0;
|
|
52178
|
-
for (const lineElements of allLinesElements) {
|
|
52179
|
-
const element = lineElements[pos];
|
|
52180
|
-
if (element) {
|
|
52181
|
-
const plainLength = element.content.replace(ANSI_REGEX, "").length;
|
|
52182
|
-
maxWidth = Math.max(maxWidth, plainLength);
|
|
52183
|
-
}
|
|
52184
|
-
}
|
|
52185
|
-
maxWidths.push(maxWidth);
|
|
52186
|
-
}
|
|
52150
|
+
if (autoAlign) {
|
|
52187
52151
|
for (let i = 0;i < widgetElements.length; i++) {
|
|
52188
52152
|
const element = widgetElements[i];
|
|
52189
|
-
const maxWidth =
|
|
52153
|
+
const maxWidth = preCalculatedMaxWidths[i];
|
|
52190
52154
|
if (element && maxWidth !== undefined) {
|
|
52191
52155
|
const currentLength = element.content.replace(ANSI_REGEX, "").length;
|
|
52192
52156
|
const paddingNeeded = maxWidth - currentLength;
|
|
@@ -52356,17 +52320,74 @@ function formatSeparator(sep) {
|
|
|
52356
52320
|
}
|
|
52357
52321
|
return sep;
|
|
52358
52322
|
}
|
|
52359
|
-
function
|
|
52360
|
-
const
|
|
52323
|
+
function preRenderAllWidgets(allLinesWidgets, settings, context) {
|
|
52324
|
+
const preRenderedLines = [];
|
|
52325
|
+
for (const lineWidgets of allLinesWidgets) {
|
|
52326
|
+
const preRenderedLine = [];
|
|
52327
|
+
for (const widget of lineWidgets) {
|
|
52328
|
+
if (widget.type === "separator" || widget.type === "flex-separator") {
|
|
52329
|
+
preRenderedLine.push({
|
|
52330
|
+
content: "",
|
|
52331
|
+
plainLength: 0,
|
|
52332
|
+
widget
|
|
52333
|
+
});
|
|
52334
|
+
continue;
|
|
52335
|
+
}
|
|
52336
|
+
let widgetText = "";
|
|
52337
|
+
try {
|
|
52338
|
+
const widgetImpl = getWidget(widget.type);
|
|
52339
|
+
widgetText = widgetImpl.render(widget, context, settings) ?? "";
|
|
52340
|
+
} catch {
|
|
52341
|
+
preRenderedLine.push({
|
|
52342
|
+
content: "",
|
|
52343
|
+
plainLength: 0,
|
|
52344
|
+
widget
|
|
52345
|
+
});
|
|
52346
|
+
continue;
|
|
52347
|
+
}
|
|
52348
|
+
const plainLength = widgetText.replace(ANSI_REGEX, "").length;
|
|
52349
|
+
preRenderedLine.push({
|
|
52350
|
+
content: widgetText,
|
|
52351
|
+
plainLength,
|
|
52352
|
+
widget
|
|
52353
|
+
});
|
|
52354
|
+
}
|
|
52355
|
+
preRenderedLines.push(preRenderedLine);
|
|
52356
|
+
}
|
|
52357
|
+
return preRenderedLines;
|
|
52358
|
+
}
|
|
52359
|
+
function calculateMaxWidthsFromPreRendered(preRenderedLines, settings) {
|
|
52360
|
+
const maxWidths = [];
|
|
52361
|
+
const defaultPadding = settings.defaultPadding ?? "";
|
|
52362
|
+
const paddingLength = defaultPadding.length;
|
|
52363
|
+
for (const preRenderedLine of preRenderedLines) {
|
|
52364
|
+
const filteredWidgets = preRenderedLine.filter((w) => w.widget.type !== "separator" && w.widget.type !== "flex-separator" && w.content);
|
|
52365
|
+
for (let pos = 0;pos < filteredWidgets.length; pos++) {
|
|
52366
|
+
const widget = filteredWidgets[pos];
|
|
52367
|
+
if (!widget)
|
|
52368
|
+
continue;
|
|
52369
|
+
const totalWidth = widget.plainLength + paddingLength * 2;
|
|
52370
|
+
const currentMax = maxWidths[pos];
|
|
52371
|
+
if (currentMax === undefined) {
|
|
52372
|
+
maxWidths[pos] = totalWidth;
|
|
52373
|
+
} else {
|
|
52374
|
+
maxWidths[pos] = Math.max(currentMax, totalWidth);
|
|
52375
|
+
}
|
|
52376
|
+
}
|
|
52377
|
+
}
|
|
52378
|
+
return maxWidths;
|
|
52379
|
+
}
|
|
52380
|
+
function renderStatusLineWithInfo(widgets, settings, context, preRenderedWidgets, preCalculatedMaxWidths) {
|
|
52381
|
+
const line = renderStatusLine(widgets, settings, context, preRenderedWidgets, preCalculatedMaxWidths);
|
|
52361
52382
|
const wasTruncated = line.includes("...");
|
|
52362
52383
|
return { line, wasTruncated };
|
|
52363
52384
|
}
|
|
52364
|
-
function renderStatusLine(widgets, settings, context,
|
|
52385
|
+
function renderStatusLine(widgets, settings, context, preRenderedWidgets, preCalculatedMaxWidths) {
|
|
52365
52386
|
const colorLevel = getColorLevelString(settings.colorLevel);
|
|
52366
52387
|
const powerlineSettings = settings.powerline;
|
|
52367
52388
|
const isPowerlineMode = Boolean(powerlineSettings?.enabled);
|
|
52368
52389
|
if (isPowerlineMode)
|
|
52369
|
-
return renderPowerlineStatusLine(widgets, settings, context, context.lineIndex ?? 0, context.globalSeparatorIndex ?? 0,
|
|
52390
|
+
return renderPowerlineStatusLine(widgets, settings, context, context.lineIndex ?? 0, context.globalSeparatorIndex ?? 0, preRenderedWidgets, preCalculatedMaxWidths);
|
|
52370
52391
|
const applyColorsWithOverride = (text, foregroundColor, backgroundColor, bold) => {
|
|
52371
52392
|
let fgColor = foregroundColor;
|
|
52372
52393
|
if (settings.overrideForegroundColor && settings.overrideForegroundColor !== "none") {
|
|
@@ -52445,10 +52466,17 @@ function renderStatusLine(widgets, settings, context, allLinesWidgets) {
|
|
|
52445
52466
|
continue;
|
|
52446
52467
|
}
|
|
52447
52468
|
try {
|
|
52448
|
-
|
|
52449
|
-
|
|
52469
|
+
let widgetText;
|
|
52470
|
+
let defaultColor = "white";
|
|
52471
|
+
const preRendered = preRenderedWidgets[i];
|
|
52472
|
+
if (preRendered?.content) {
|
|
52473
|
+
widgetText = preRendered.content;
|
|
52474
|
+
try {
|
|
52475
|
+
const widgetImpl = getWidget(widget.type);
|
|
52476
|
+
defaultColor = widgetImpl.getDefaultColor();
|
|
52477
|
+
} catch {}
|
|
52478
|
+
}
|
|
52450
52479
|
if (widgetText) {
|
|
52451
|
-
const defaultColor = widgetImpl.getDefaultColor();
|
|
52452
52480
|
if (widget.type === "custom-command" && widget.preserveColors) {
|
|
52453
52481
|
let finalOutput = widgetText;
|
|
52454
52482
|
if (widget.maxWidth && widget.maxWidth > 0) {
|
|
@@ -56365,30 +56393,30 @@ var PowerlineSetup = ({
|
|
|
56365
56393
|
// src/tui/components/StatusLinePreview.tsx
|
|
56366
56394
|
var import_react42 = __toESM(require_react(), 1);
|
|
56367
56395
|
var jsx_dev_runtime14 = __toESM(require_jsx_dev_runtime(), 1);
|
|
56368
|
-
var renderSingleLine = (widgets, terminalWidth, widthDetectionAvailable, settings, lineIndex, globalSeparatorIndex,
|
|
56396
|
+
var renderSingleLine = (widgets, terminalWidth, widthDetectionAvailable, settings, lineIndex, globalSeparatorIndex, preRenderedWidgets, preCalculatedMaxWidths) => {
|
|
56369
56397
|
const context = {
|
|
56370
56398
|
terminalWidth,
|
|
56371
56399
|
isPreview: true,
|
|
56372
56400
|
lineIndex,
|
|
56373
56401
|
globalSeparatorIndex
|
|
56374
56402
|
};
|
|
56375
|
-
return renderStatusLineWithInfo(widgets, settings, context,
|
|
56403
|
+
return renderStatusLineWithInfo(widgets, settings, context, preRenderedWidgets, preCalculatedMaxWidths);
|
|
56376
56404
|
};
|
|
56377
56405
|
var StatusLinePreview = ({ lines, terminalWidth, settings, onTruncationChange }) => {
|
|
56378
56406
|
const widthDetectionAvailable = import_react42.default.useMemo(() => canDetectTerminalWidth(), []);
|
|
56379
56407
|
const { renderedLines, anyTruncated } = import_react42.default.useMemo(() => {
|
|
56380
56408
|
if (!settings)
|
|
56381
56409
|
return { renderedLines: [], anyTruncated: false };
|
|
56382
|
-
const
|
|
56383
|
-
const
|
|
56384
|
-
const allLinesWidgets = isPowerlineMode && autoAlign ? lines : undefined;
|
|
56410
|
+
const preRenderedLines = preRenderAllWidgets(lines, settings, { terminalWidth, isPreview: true });
|
|
56411
|
+
const preCalculatedMaxWidths = calculateMaxWidthsFromPreRendered(preRenderedLines, settings);
|
|
56385
56412
|
let globalSeparatorIndex = 0;
|
|
56386
56413
|
const result = [];
|
|
56387
56414
|
let truncated = false;
|
|
56388
56415
|
for (let i = 0;i < lines.length; i++) {
|
|
56389
56416
|
const lineItems = lines[i];
|
|
56390
56417
|
if (lineItems && lineItems.length > 0) {
|
|
56391
|
-
const
|
|
56418
|
+
const preRenderedWidgets = preRenderedLines[i] ?? [];
|
|
56419
|
+
const renderResult = renderSingleLine(lineItems, terminalWidth, widthDetectionAvailable, settings, i, globalSeparatorIndex, preRenderedWidgets, preCalculatedMaxWidths);
|
|
56392
56420
|
result.push(renderResult.line);
|
|
56393
56421
|
if (renderResult.wasTruncated) {
|
|
56394
56422
|
truncated = true;
|
|
@@ -58330,15 +58358,15 @@ async function renderMultipleLines(data) {
|
|
|
58330
58358
|
blockMetrics,
|
|
58331
58359
|
isPreview: false
|
|
58332
58360
|
};
|
|
58333
|
-
const
|
|
58334
|
-
const
|
|
58335
|
-
const allLinesWidgets = isPowerlineMode && autoAlign ? lines : undefined;
|
|
58361
|
+
const preRenderedLines = preRenderAllWidgets(lines, settings, context);
|
|
58362
|
+
const preCalculatedMaxWidths = calculateMaxWidthsFromPreRendered(preRenderedLines, settings);
|
|
58336
58363
|
let globalSeparatorIndex = 0;
|
|
58337
58364
|
for (let i = 0;i < lines.length; i++) {
|
|
58338
58365
|
const lineItems = lines[i];
|
|
58339
58366
|
if (lineItems && lineItems.length > 0) {
|
|
58340
58367
|
const lineContext = { ...context, lineIndex: i, globalSeparatorIndex };
|
|
58341
|
-
const
|
|
58368
|
+
const preRenderedWidgets = preRenderedLines[i] ?? [];
|
|
58369
|
+
const line = renderStatusLine(lineItems, settings, lineContext, preRenderedWidgets, preCalculatedMaxWidths);
|
|
58342
58370
|
const strippedLine = line.replace(/\x1b\[[0-9;]*m/g, "").trim();
|
|
58343
58371
|
if (strippedLine.length > 0) {
|
|
58344
58372
|
const nonMergedWidgets = lineItems.filter((_, idx) => idx === lineItems.length - 1 || !lineItems[idx]?.merge);
|