ccstatusline-zh 2.2.32 → 2.2.34
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/README.md +16 -11
- package/dist/{ccstatusline-xsgtxzjt.js → ccstatusline-jp52tswn.js} +23186 -22385
- package/dist/{ccstatusline-s1q4ap7d.js → ccstatusline-rdsx5ab1.js} +16 -12
- package/dist/ccstatusline.js +54 -23
- package/dist/{devtools-3w5md92d.js → devtools-nceaxkjz.js} +1713 -2407
- package/dist/{hooks-z0173m0m.js → hooks-0wev7tf6.js} +2 -2
- package/dist/{index-3881ds5x.js → index-pzts8765.js} +268 -137
- package/package.json +3 -3
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
source_default,
|
|
3
3
|
stripAnsi,
|
|
4
4
|
GRADIENT_PRESET_NAMES,
|
|
5
|
-
stripOscCodes,
|
|
6
5
|
getVisibleWidth,
|
|
7
6
|
truncateStyledText,
|
|
8
7
|
COLOR_MAP,
|
|
@@ -34,6 +33,7 @@ import {
|
|
|
34
33
|
setEnabledHideStates,
|
|
35
34
|
getHideKeybind,
|
|
36
35
|
getHideModifierText,
|
|
36
|
+
sanitizeTerminalText,
|
|
37
37
|
require_react,
|
|
38
38
|
Box_default,
|
|
39
39
|
Text,
|
|
@@ -41,8 +41,10 @@ import {
|
|
|
41
41
|
Transform,
|
|
42
42
|
use_input_default,
|
|
43
43
|
use_app_default,
|
|
44
|
+
getPlainInput,
|
|
44
45
|
shouldInsertInput,
|
|
45
46
|
require_jsx_runtime,
|
|
47
|
+
BlinkingCursor,
|
|
46
48
|
useTextCursor,
|
|
47
49
|
CYCLE_NUMBER_STYLE_ACTION,
|
|
48
50
|
NUMBER_STYLE_LABELS,
|
|
@@ -81,11 +83,12 @@ import {
|
|
|
81
83
|
validateImportFile,
|
|
82
84
|
applyImport,
|
|
83
85
|
saveInstallationMetadata
|
|
84
|
-
} from "./ccstatusline-
|
|
86
|
+
} from "./ccstatusline-jp52tswn.js";
|
|
85
87
|
import {
|
|
88
|
+
assignPowerlineThemeSlots,
|
|
86
89
|
advanceGlobalPowerlineThemeIndex,
|
|
87
90
|
advanceGlobalSeparatorIndex
|
|
88
|
-
} from "./ccstatusline-
|
|
91
|
+
} from "./ccstatusline-rdsx5ab1.js";
|
|
89
92
|
import {
|
|
90
93
|
__toESM,
|
|
91
94
|
__commonJS
|
|
@@ -2542,7 +2545,10 @@ function openExternalUrl(url) {
|
|
|
2542
2545
|
}
|
|
2543
2546
|
|
|
2544
2547
|
// src/utils/powerline.ts
|
|
2545
|
-
import {
|
|
2548
|
+
import {
|
|
2549
|
+
execFileSync as execFileSync3,
|
|
2550
|
+
execSync
|
|
2551
|
+
} from "node:child_process";
|
|
2546
2552
|
import * as fs2 from "node:fs";
|
|
2547
2553
|
import * as os3 from "node:os";
|
|
2548
2554
|
import * as path2 from "node:path";
|
|
@@ -2674,12 +2680,9 @@ async function installPowerlineFonts() {
|
|
|
2674
2680
|
if (!fs2.existsSync(fontDir)) {
|
|
2675
2681
|
fs2.mkdirSync(fontDir, { recursive: true });
|
|
2676
2682
|
}
|
|
2677
|
-
const tempDir = path2.join(os3.tmpdir(),
|
|
2683
|
+
const tempDir = fs2.mkdtempSync(path2.join(os3.tmpdir(), "ccstatusline-powerline-fonts-"));
|
|
2678
2684
|
try {
|
|
2679
|
-
|
|
2680
|
-
fs2.rmSync(tempDir, { recursive: true, force: true });
|
|
2681
|
-
}
|
|
2682
|
-
execSync(`git clone --depth=1 https://github.com/powerline/fonts.git "${tempDir}"`, {
|
|
2685
|
+
execFileSync3("git", ["clone", "--depth=1", "https://github.com/powerline/fonts.git", tempDir], {
|
|
2683
2686
|
stdio: "pipe",
|
|
2684
2687
|
encoding: "utf8",
|
|
2685
2688
|
windowsHide: true
|
|
@@ -2688,10 +2691,10 @@ async function installPowerlineFonts() {
|
|
|
2688
2691
|
const installScript = path2.join(tempDir, "install.sh");
|
|
2689
2692
|
if (fs2.existsSync(installScript)) {
|
|
2690
2693
|
fs2.chmodSync(installScript, 493);
|
|
2691
|
-
|
|
2694
|
+
execFileSync3(installScript, [], {
|
|
2695
|
+
cwd: tempDir,
|
|
2692
2696
|
stdio: "pipe",
|
|
2693
2697
|
encoding: "utf8",
|
|
2694
|
-
shell: "/bin/bash",
|
|
2695
2698
|
windowsHide: true
|
|
2696
2699
|
});
|
|
2697
2700
|
if (platform === "linux") {
|
|
@@ -2780,6 +2783,10 @@ import * as https from "node:https";
|
|
|
2780
2783
|
var NPM_REGISTRY_LATEST_URL = "https://registry.npmjs.org/ccstatusline-zh/latest";
|
|
2781
2784
|
var DEFAULT_REGISTRY_TIMEOUT_MS = 5000;
|
|
2782
2785
|
var GLOBAL_UPDATE_TIMEOUT_MS = 120000;
|
|
2786
|
+
var RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
2787
|
+
function isReleaseVersion(version) {
|
|
2788
|
+
return RELEASE_VERSION.test(version);
|
|
2789
|
+
}
|
|
2783
2790
|
function parseVersion(version) {
|
|
2784
2791
|
return version.split(/[.-]/).map((part) => {
|
|
2785
2792
|
const parsed = Number.parseInt(part, 10);
|
|
@@ -2900,6 +2907,9 @@ async function checkForUpdates({
|
|
|
2900
2907
|
}) {
|
|
2901
2908
|
try {
|
|
2902
2909
|
const latestVersion = await latestVersionFetcher(timeoutMs);
|
|
2910
|
+
if (!isReleaseVersion(latestVersion)) {
|
|
2911
|
+
throw new Error("npm 仓库返回了无效的版本号");
|
|
2912
|
+
}
|
|
2903
2913
|
return buildUpdateCheckResult({
|
|
2904
2914
|
currentVersion,
|
|
2905
2915
|
latestVersion,
|
|
@@ -2955,6 +2965,9 @@ function fetchLatestNpmVersion(timeoutMs = DEFAULT_REGISTRY_TIMEOUT_MS) {
|
|
|
2955
2965
|
});
|
|
2956
2966
|
}
|
|
2957
2967
|
function runGlobalPackageInstall(packageManager, version, { platform = process.platform } = {}) {
|
|
2968
|
+
if (!isReleaseVersion(version)) {
|
|
2969
|
+
return Promise.reject(new Error("不是有效的 ccstatusline-zh 发布版本"));
|
|
2970
|
+
}
|
|
2958
2971
|
const executable = getPackageManagerExecutable(packageManager, platform);
|
|
2959
2972
|
const args = packageManager === "npm" ? ["install", "-g", `ccstatusline-zh@${version}`] : ["add", "-g", `ccstatusline-zh@${version}`];
|
|
2960
2973
|
return new Promise((resolve, reject) => {
|
|
@@ -3531,9 +3544,9 @@ var CONFIRM_OPTIONS = [
|
|
|
3531
3544
|
value: false
|
|
3532
3545
|
}
|
|
3533
3546
|
];
|
|
3534
|
-
var ConfirmDialog = ({ message, onConfirm, onCancel, inline = false }) => {
|
|
3547
|
+
var ConfirmDialog = ({ message, onConfirm, onCancel, inline = false, busy = false }) => {
|
|
3535
3548
|
use_input_default((_, key) => {
|
|
3536
|
-
if (key.escape) {
|
|
3549
|
+
if (key.escape && !busy) {
|
|
3537
3550
|
onCancel();
|
|
3538
3551
|
}
|
|
3539
3552
|
});
|
|
@@ -3558,7 +3571,10 @@ var ConfirmDialog = ({ message, onConfirm, onCancel, inline = false }) => {
|
|
|
3558
3571
|
}),
|
|
3559
3572
|
/* @__PURE__ */ jsx_runtime2.jsx(Box_default, {
|
|
3560
3573
|
marginTop: 1,
|
|
3561
|
-
children: /* @__PURE__ */ jsx_runtime2.jsx(
|
|
3574
|
+
children: busy ? /* @__PURE__ */ jsx_runtime2.jsx(Text, {
|
|
3575
|
+
color: "yellow",
|
|
3576
|
+
children: "正在处理,请稍候..."
|
|
3577
|
+
}) : /* @__PURE__ */ jsx_runtime2.jsx(List, {
|
|
3562
3578
|
items: CONFIRM_OPTIONS,
|
|
3563
3579
|
onSelect: (confirmed) => {
|
|
3564
3580
|
if (confirmed) {
|
|
@@ -3623,7 +3639,6 @@ function resetWidgetStyling(widgets, widgetId) {
|
|
|
3623
3639
|
backgroundColor,
|
|
3624
3640
|
bold,
|
|
3625
3641
|
dim,
|
|
3626
|
-
numberFormat,
|
|
3627
3642
|
...restWidget
|
|
3628
3643
|
} = widget;
|
|
3629
3644
|
return restWidget;
|
|
@@ -3636,7 +3651,6 @@ function clearAllWidgetStyling(widgets) {
|
|
|
3636
3651
|
backgroundColor,
|
|
3637
3652
|
bold,
|
|
3638
3653
|
dim,
|
|
3639
|
-
numberFormat,
|
|
3640
3654
|
...restWidget
|
|
3641
3655
|
} = widget;
|
|
3642
3656
|
return restWidget;
|
|
@@ -3727,6 +3741,7 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3727
3741
|
const [editingBackground, setEditingBackground] = import_react5.useState(false);
|
|
3728
3742
|
const hasNoItems = colorableWidgets.length === 0;
|
|
3729
3743
|
use_input_default((input, key) => {
|
|
3744
|
+
const shortcut = getPlainInput(input, key);
|
|
3730
3745
|
if (hasNoItems) {
|
|
3731
3746
|
onBack();
|
|
3732
3747
|
return;
|
|
@@ -3859,17 +3874,21 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3859
3874
|
} else {
|
|
3860
3875
|
onBack();
|
|
3861
3876
|
}
|
|
3862
|
-
} else if (
|
|
3877
|
+
} else if (key.return) {
|
|
3878
|
+
if (highlightedItemId === "back") {
|
|
3879
|
+
onBack();
|
|
3880
|
+
}
|
|
3881
|
+
} else if (shortcut === "h" || shortcut === "H") {
|
|
3863
3882
|
if (highlightedItemId && highlightedItemId !== "back" && settings.colorLevel === 3) {
|
|
3864
3883
|
setHexInputMode(true);
|
|
3865
3884
|
setHexInput("");
|
|
3866
3885
|
}
|
|
3867
|
-
} else if (
|
|
3886
|
+
} else if (shortcut === "a" || shortcut === "A") {
|
|
3868
3887
|
if (highlightedItemId && highlightedItemId !== "back" && settings.colorLevel === 2) {
|
|
3869
3888
|
setAnsi256InputMode(true);
|
|
3870
3889
|
setAnsi256Input("");
|
|
3871
3890
|
}
|
|
3872
|
-
} else if (
|
|
3891
|
+
} else if (shortcut === "g" || shortcut === "G") {
|
|
3873
3892
|
if (highlightedItemId && highlightedItemId !== "back" && !editingBackground && settings.colorLevel >= 2) {
|
|
3874
3893
|
setGradientMode(true);
|
|
3875
3894
|
setGradientIndex(0);
|
|
@@ -3877,15 +3896,19 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3877
3896
|
setGradientStartHex("");
|
|
3878
3897
|
setGradientHexInput("");
|
|
3879
3898
|
}
|
|
3880
|
-
} else if (
|
|
3899
|
+
} else if (shortcut === "s" || shortcut === "S") {
|
|
3881
3900
|
if (!settings.powerline.enabled && !settings.defaultSeparator) {
|
|
3882
3901
|
setShowSeparators(!showSeparators);
|
|
3902
|
+
const highlightedWidget = colorableWidgets.find((widget) => widget.id === highlightedItemId);
|
|
3903
|
+
if (showSeparators && highlightedWidget?.type === "separator") {
|
|
3904
|
+
setHighlightedItemId(colorableWidgets.find((widget) => widget.type !== "separator")?.id ?? null);
|
|
3905
|
+
}
|
|
3883
3906
|
}
|
|
3884
|
-
} else if (
|
|
3907
|
+
} else if (shortcut === "f" || shortcut === "F") {
|
|
3885
3908
|
if (colorableWidgets.length > 0) {
|
|
3886
3909
|
setEditingBackground(!editingBackground);
|
|
3887
3910
|
}
|
|
3888
|
-
} else if (
|
|
3911
|
+
} else if (shortcut === "b" || shortcut === "B") {
|
|
3889
3912
|
if (highlightedItemId && highlightedItemId !== "back") {
|
|
3890
3913
|
const selectedWidget = colorableWidgets.find((widget) => widget.id === highlightedItemId);
|
|
3891
3914
|
if (selectedWidget) {
|
|
@@ -3893,7 +3916,7 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3893
3916
|
onUpdate(newItems);
|
|
3894
3917
|
}
|
|
3895
3918
|
}
|
|
3896
|
-
} else if (
|
|
3919
|
+
} else if (shortcut === "d" || shortcut === "D") {
|
|
3897
3920
|
if (highlightedItemId && highlightedItemId !== "back") {
|
|
3898
3921
|
const selectedWidget = colorableWidgets.find((widget) => widget.id === highlightedItemId);
|
|
3899
3922
|
if (selectedWidget) {
|
|
@@ -3901,7 +3924,7 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3901
3924
|
onUpdate(newItems);
|
|
3902
3925
|
}
|
|
3903
3926
|
}
|
|
3904
|
-
} else if (
|
|
3927
|
+
} else if (shortcut === "r" || shortcut === "R") {
|
|
3905
3928
|
if (highlightedItemId && highlightedItemId !== "back") {
|
|
3906
3929
|
const selectedWidget = colorableWidgets.find((widget) => widget.id === highlightedItemId);
|
|
3907
3930
|
if (selectedWidget) {
|
|
@@ -3909,7 +3932,7 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3909
3932
|
onUpdate(newItems);
|
|
3910
3933
|
}
|
|
3911
3934
|
}
|
|
3912
|
-
} else if (
|
|
3935
|
+
} else if (shortcut === "c" || shortcut === "C") {
|
|
3913
3936
|
setShowClearConfirm(true);
|
|
3914
3937
|
} else if (key.leftArrow || key.rightArrow) {
|
|
3915
3938
|
if (highlightedItemId && highlightedItemId !== "back") {
|
|
@@ -3991,11 +4014,6 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
3991
4014
|
};
|
|
3992
4015
|
});
|
|
3993
4016
|
menuItems.push({ label: "← 返回", value: "back" });
|
|
3994
|
-
const handleSelect = (selected) => {
|
|
3995
|
-
if (selected.value === "back") {
|
|
3996
|
-
onBack();
|
|
3997
|
-
}
|
|
3998
|
-
};
|
|
3999
4017
|
const handleHighlight = (item) => {
|
|
4000
4018
|
setHighlightedItemId(item.value);
|
|
4001
4019
|
};
|
|
@@ -4322,7 +4340,6 @@ var ColorMenu = ({ widgets, lineIndex, settings, onUpdate, onBack }) => {
|
|
|
4322
4340
|
}, item.value))
|
|
4323
4341
|
}) : /* @__PURE__ */ jsx_runtime3.jsx(SelectInput_default, {
|
|
4324
4342
|
items: menuItems,
|
|
4325
|
-
onSelect: handleSelect,
|
|
4326
4343
|
onHighlight: handleHighlight,
|
|
4327
4344
|
initialIndex: Math.max(0, menuItems.findIndex((item) => item.value === highlightedItemId)),
|
|
4328
4345
|
indicatorComponent: ({ isSelected }) => /* @__PURE__ */ jsx_runtime3.jsx(Text, {
|
|
@@ -4390,7 +4407,7 @@ function ExportConfigDialog({ onExport, onCancel }) {
|
|
|
4390
4407
|
/* @__PURE__ */ jsx_runtime4.jsx(Text, {
|
|
4391
4408
|
children: inputValue
|
|
4392
4409
|
}),
|
|
4393
|
-
/* @__PURE__ */ jsx_runtime4.jsx(
|
|
4410
|
+
/* @__PURE__ */ jsx_runtime4.jsx(BlinkingCursor, {
|
|
4394
4411
|
inverse: true,
|
|
4395
4412
|
children: " "
|
|
4396
4413
|
})
|
|
@@ -4442,7 +4459,7 @@ function ImportConfigDialog({ onFileChosen, onCancel }) {
|
|
|
4442
4459
|
/* @__PURE__ */ jsx_runtime5.jsx(Text, {
|
|
4443
4460
|
children: inputValue
|
|
4444
4461
|
}),
|
|
4445
|
-
/* @__PURE__ */ jsx_runtime5.jsx(
|
|
4462
|
+
/* @__PURE__ */ jsx_runtime5.jsx(BlinkingCursor, {
|
|
4446
4463
|
inverse: true,
|
|
4447
4464
|
children: " "
|
|
4448
4465
|
})
|
|
@@ -4472,6 +4489,9 @@ function getImportPreviewKeys(current, imported) {
|
|
|
4472
4489
|
function getImportPreviewSettings(current, validation, mode) {
|
|
4473
4490
|
return applyImport(current, validation.data, mode, validation.presentKeys);
|
|
4474
4491
|
}
|
|
4492
|
+
function escapeControlCharacters(text) {
|
|
4493
|
+
return text.replace(/[\x00-\x1f\x7f-\x9f]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
4494
|
+
}
|
|
4475
4495
|
function formatScalar(value) {
|
|
4476
4496
|
if (value === null || value === undefined) {
|
|
4477
4497
|
return "无";
|
|
@@ -4480,9 +4500,16 @@ function formatScalar(value) {
|
|
|
4480
4500
|
return String(value);
|
|
4481
4501
|
}
|
|
4482
4502
|
if (typeof value === "string") {
|
|
4483
|
-
return value || "(空)";
|
|
4503
|
+
return escapeControlCharacters(value) || "(空)";
|
|
4484
4504
|
}
|
|
4485
|
-
return JSON.stringify(value);
|
|
4505
|
+
return escapeControlCharacters(JSON.stringify(value));
|
|
4506
|
+
}
|
|
4507
|
+
function getCustomCommands(settings) {
|
|
4508
|
+
return settings.lines.flat().filter((widget) => widget.type === "custom-command" && widget.commandPath).map((widget) => widget.commandPath ?? "");
|
|
4509
|
+
}
|
|
4510
|
+
function getImportedCommands(current, preview) {
|
|
4511
|
+
const existing = new Set(getCustomCommands(current));
|
|
4512
|
+
return [...new Set(getCustomCommands(preview).filter((command) => !existing.has(command)))];
|
|
4486
4513
|
}
|
|
4487
4514
|
function diffObject(current, imported, prefix) {
|
|
4488
4515
|
const keys = new Set([...Object.keys(current), ...Object.keys(imported)]);
|
|
@@ -4547,8 +4574,10 @@ function ImportPreviewDialog({
|
|
|
4547
4574
|
onCancel
|
|
4548
4575
|
}) {
|
|
4549
4576
|
const [previewMode, setPreviewMode] = import_react8.useState("replace");
|
|
4577
|
+
const [pendingMode, setPendingMode] = import_react8.useState(null);
|
|
4550
4578
|
const previewSettings = getImportPreviewSettings(currentSettings, validation, previewMode);
|
|
4551
4579
|
const topLevelKeys = getImportPreviewKeys(currentSettings, previewSettings);
|
|
4580
|
+
const importedCommands = getImportedCommands(currentSettings, previewSettings);
|
|
4552
4581
|
const items = [
|
|
4553
4582
|
{ label: "全部替换", value: "replace", description: "使用导入的配置覆盖所有设置" },
|
|
4554
4583
|
{ label: "合并", value: "merge", description: "将导入的设置覆盖到当前设置之上" },
|
|
@@ -4558,9 +4587,51 @@ function ImportPreviewDialog({
|
|
|
4558
4587
|
function handleSelect(value) {
|
|
4559
4588
|
if (value === "cancel" || value === "back") {
|
|
4560
4589
|
onCancel();
|
|
4561
|
-
|
|
4562
|
-
onApply(value);
|
|
4590
|
+
return;
|
|
4563
4591
|
}
|
|
4592
|
+
const commands = getImportedCommands(currentSettings, getImportPreviewSettings(currentSettings, validation, value));
|
|
4593
|
+
if (commands.length > 0) {
|
|
4594
|
+
setPendingMode(value);
|
|
4595
|
+
return;
|
|
4596
|
+
}
|
|
4597
|
+
onApply(value);
|
|
4598
|
+
}
|
|
4599
|
+
if (pendingMode) {
|
|
4600
|
+
const commands = getImportedCommands(currentSettings, getImportPreviewSettings(currentSettings, validation, pendingMode));
|
|
4601
|
+
const confirmItems = [
|
|
4602
|
+
{ label: "取消", value: "cancel", description: "返回预览,不导入配置" },
|
|
4603
|
+
{ label: "应用并运行这些命令", value: "confirm", description: "导入配置,包括上述命令" }
|
|
4604
|
+
];
|
|
4605
|
+
return /* @__PURE__ */ jsx_runtime6.jsxs(Box_default, {
|
|
4606
|
+
flexDirection: "column",
|
|
4607
|
+
children: [
|
|
4608
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4609
|
+
bold: true,
|
|
4610
|
+
children: "导入预览"
|
|
4611
|
+
}),
|
|
4612
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4613
|
+
color: "yellow",
|
|
4614
|
+
children: `是否应用此次导入?它将新增 ${commands.length} 条 Shell 命令,每次渲染状态行时都会运行:`
|
|
4615
|
+
}),
|
|
4616
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Box_default, {
|
|
4617
|
+
flexDirection: "column",
|
|
4618
|
+
marginLeft: 4,
|
|
4619
|
+
children: commands.map((command, index) => /* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4620
|
+
children: `$ ${escapeControlCharacters(command)}`
|
|
4621
|
+
}, index))
|
|
4622
|
+
}),
|
|
4623
|
+
/* @__PURE__ */ jsx_runtime6.jsx(List, {
|
|
4624
|
+
items: confirmItems,
|
|
4625
|
+
onSelect: (choice) => {
|
|
4626
|
+
if (choice === "confirm") {
|
|
4627
|
+
onApply(pendingMode);
|
|
4628
|
+
return;
|
|
4629
|
+
}
|
|
4630
|
+
setPendingMode(null);
|
|
4631
|
+
}
|
|
4632
|
+
})
|
|
4633
|
+
]
|
|
4634
|
+
});
|
|
4564
4635
|
}
|
|
4565
4636
|
function handleSelectionChange(value) {
|
|
4566
4637
|
if (value === "replace" || value === "merge") {
|
|
@@ -4593,7 +4664,7 @@ function ImportPreviewDialog({
|
|
|
4593
4664
|
marginLeft: 4,
|
|
4594
4665
|
children: [
|
|
4595
4666
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4596
|
-
children: `${e.path}: `
|
|
4667
|
+
children: `${escapeControlCharacters(e.path)}: `
|
|
4597
4668
|
}),
|
|
4598
4669
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4599
4670
|
color: "red",
|
|
@@ -4624,7 +4695,7 @@ function ImportPreviewDialog({
|
|
|
4624
4695
|
marginLeft: 4,
|
|
4625
4696
|
children: [
|
|
4626
4697
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4627
|
-
children: `${e.path}: `
|
|
4698
|
+
children: `${escapeControlCharacters(e.path)}: `
|
|
4628
4699
|
}),
|
|
4629
4700
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4630
4701
|
color: "red",
|
|
@@ -4646,7 +4717,7 @@ function ImportPreviewDialog({
|
|
|
4646
4717
|
diffRows.push(/* @__PURE__ */ jsx_runtime6.jsxs(Box_default, {
|
|
4647
4718
|
children: [
|
|
4648
4719
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4649
|
-
children: ` ${key}: `
|
|
4720
|
+
children: ` ${escapeControlCharacters(key)}: `
|
|
4650
4721
|
}),
|
|
4651
4722
|
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4652
4723
|
color: "red",
|
|
@@ -4677,6 +4748,23 @@ function ImportPreviewDialog({
|
|
|
4677
4748
|
flexDirection: "column",
|
|
4678
4749
|
children: diffRows
|
|
4679
4750
|
}),
|
|
4751
|
+
importedCommands.length > 0 && /* @__PURE__ */ jsx_runtime6.jsxs(Box_default, {
|
|
4752
|
+
flexDirection: "column",
|
|
4753
|
+
marginTop: 1,
|
|
4754
|
+
children: [
|
|
4755
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4756
|
+
color: "yellow",
|
|
4757
|
+
children: "此次导入新增的 Shell 命令将在每次渲染状态行时运行:"
|
|
4758
|
+
}),
|
|
4759
|
+
/* @__PURE__ */ jsx_runtime6.jsx(Box_default, {
|
|
4760
|
+
flexDirection: "column",
|
|
4761
|
+
marginLeft: 4,
|
|
4762
|
+
children: importedCommands.map((command, index) => /* @__PURE__ */ jsx_runtime6.jsx(Text, {
|
|
4763
|
+
children: `$ ${escapeControlCharacters(command)}`
|
|
4764
|
+
}, index))
|
|
4765
|
+
})
|
|
4766
|
+
]
|
|
4767
|
+
}),
|
|
4680
4768
|
/* @__PURE__ */ jsx_runtime6.jsx(List, {
|
|
4681
4769
|
items,
|
|
4682
4770
|
onSelect: handleSelect,
|
|
@@ -4735,6 +4823,7 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4735
4823
|
const currentBgIndex = bgColors.indexOf(settings.overrideBackgroundColor ?? "none");
|
|
4736
4824
|
const currentFgIndex = fgColors.indexOf(settings.overrideForegroundColor ?? "none");
|
|
4737
4825
|
use_input_default((input, key) => {
|
|
4826
|
+
const shortcut = getPlainInput(input, key);
|
|
4738
4827
|
if (editingPadding) {
|
|
4739
4828
|
if (key.return) {
|
|
4740
4829
|
const updatedSettings = {
|
|
@@ -4845,11 +4934,11 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4845
4934
|
} else {
|
|
4846
4935
|
if (key.escape) {
|
|
4847
4936
|
onBack();
|
|
4848
|
-
} else if (
|
|
4937
|
+
} else if (shortcut === "p" || shortcut === "P") {
|
|
4849
4938
|
setEditingPadding(true);
|
|
4850
|
-
} else if ((
|
|
4939
|
+
} else if ((shortcut === "s" || shortcut === "S") && !isPowerlineEnabled) {
|
|
4851
4940
|
setEditingSeparator(true);
|
|
4852
|
-
} else if ((
|
|
4941
|
+
} else if ((shortcut === "i" || shortcut === "I") && !isPowerlineEnabled) {
|
|
4853
4942
|
const newInheritColors = !inheritColors;
|
|
4854
4943
|
setInheritColors(newInheritColors);
|
|
4855
4944
|
const updatedSettings = {
|
|
@@ -4857,7 +4946,7 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4857
4946
|
inheritSeparatorColors: newInheritColors
|
|
4858
4947
|
};
|
|
4859
4948
|
onUpdate(updatedSettings);
|
|
4860
|
-
} else if ((
|
|
4949
|
+
} else if ((shortcut === "b" || shortcut === "B") && !isPowerlineEnabled) {
|
|
4861
4950
|
const nextIndex = (currentBgIndex + 1) % bgColors.length;
|
|
4862
4951
|
const nextBgColor = bgColors[nextIndex];
|
|
4863
4952
|
const updatedSettings = {
|
|
@@ -4865,13 +4954,13 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4865
4954
|
overrideBackgroundColor: nextBgColor === "none" ? undefined : nextBgColor
|
|
4866
4955
|
};
|
|
4867
4956
|
onUpdate(updatedSettings);
|
|
4868
|
-
} else if ((
|
|
4957
|
+
} else if ((shortcut === "c" || shortcut === "C") && !isPowerlineEnabled) {
|
|
4869
4958
|
const updatedSettings = {
|
|
4870
4959
|
...settings,
|
|
4871
4960
|
overrideBackgroundColor: undefined
|
|
4872
4961
|
};
|
|
4873
4962
|
onUpdate(updatedSettings);
|
|
4874
|
-
} else if (
|
|
4963
|
+
} else if (shortcut === "o" || shortcut === "O") {
|
|
4875
4964
|
const newGlobalBold = !globalBold;
|
|
4876
4965
|
setGlobalBold(newGlobalBold);
|
|
4877
4966
|
const updatedSettings = {
|
|
@@ -4879,7 +4968,7 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4879
4968
|
globalBold: newGlobalBold
|
|
4880
4969
|
};
|
|
4881
4970
|
onUpdate(updatedSettings);
|
|
4882
|
-
} else if (
|
|
4971
|
+
} else if (shortcut === "m" || shortcut === "M") {
|
|
4883
4972
|
const newMinimalistMode = !minimalistMode;
|
|
4884
4973
|
setMinimalistMode(newMinimalistMode);
|
|
4885
4974
|
const updatedSettings = {
|
|
@@ -4887,10 +4976,10 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4887
4976
|
minimalistMode: newMinimalistMode
|
|
4888
4977
|
};
|
|
4889
4978
|
onUpdate(updatedSettings);
|
|
4890
|
-
} else if (
|
|
4979
|
+
} else if (shortcut === "n" || shortcut === "N") {
|
|
4891
4980
|
setNumberFormatMode(true);
|
|
4892
4981
|
setNumberFormatKindIndex(0);
|
|
4893
|
-
} else if (
|
|
4982
|
+
} else if (shortcut === "f" || shortcut === "F") {
|
|
4894
4983
|
const nextIndex = (currentFgIndex + 1) % fgColors.length;
|
|
4895
4984
|
const nextFgColor = fgColors[nextIndex];
|
|
4896
4985
|
const updatedSettings = {
|
|
@@ -4898,19 +4987,19 @@ var GlobalOverridesMenu = ({ settings, onUpdate, onBack }) => {
|
|
|
4898
4987
|
overrideForegroundColor: nextFgColor === "none" ? undefined : nextFgColor
|
|
4899
4988
|
};
|
|
4900
4989
|
onUpdate(updatedSettings);
|
|
4901
|
-
} else if (
|
|
4990
|
+
} else if (shortcut === "g" || shortcut === "G") {
|
|
4902
4991
|
setGradientMode(true);
|
|
4903
4992
|
setGradientIndex(0);
|
|
4904
4993
|
setGradientCustomStep(null);
|
|
4905
4994
|
setGradientStartHex("");
|
|
4906
4995
|
setGradientHexInput("");
|
|
4907
|
-
} else if (
|
|
4996
|
+
} else if (shortcut === "x" || shortcut === "X") {
|
|
4908
4997
|
const updatedSettings = {
|
|
4909
4998
|
...settings,
|
|
4910
4999
|
overrideForegroundColor: undefined
|
|
4911
5000
|
};
|
|
4912
5001
|
onUpdate(updatedSettings);
|
|
4913
|
-
} else if (
|
|
5002
|
+
} else if (shortcut === "d" || shortcut === "D") {
|
|
4914
5003
|
const paddingSides = DefaultPaddingSideSchema.options;
|
|
4915
5004
|
const currentIndex = paddingSides.indexOf(settings.defaultPaddingSide);
|
|
4916
5005
|
const nextSide = paddingSides[(currentIndex + 1) % paddingSides.length] ?? "both";
|
|
@@ -5401,6 +5490,7 @@ var HideStatesEditor = ({ widget, states, onComplete, onCancel }) => {
|
|
|
5401
5490
|
const [selectedIndex, setSelectedIndex] = import_react10.useState(0);
|
|
5402
5491
|
const [enabledKeys, setEnabledKeys] = import_react10.useState(() => getEnabledHideStates(widget, states));
|
|
5403
5492
|
use_input_default((input, key) => {
|
|
5493
|
+
const shortcut = getPlainInput(input, key);
|
|
5404
5494
|
if (key.return) {
|
|
5405
5495
|
onComplete(setEnabledHideStates(widget, states, enabledKeys));
|
|
5406
5496
|
} else if (key.escape) {
|
|
@@ -5409,7 +5499,7 @@ var HideStatesEditor = ({ widget, states, onComplete, onCancel }) => {
|
|
|
5409
5499
|
setSelectedIndex(selectedIndex - 1 < 0 ? states.length - 1 : selectedIndex - 1);
|
|
5410
5500
|
} else if (key.downArrow && states.length > 0) {
|
|
5411
5501
|
setSelectedIndex(selectedIndex + 1 > states.length - 1 ? 0 : selectedIndex + 1);
|
|
5412
|
-
} else if (
|
|
5502
|
+
} else if (shortcut === " ") {
|
|
5413
5503
|
const state = states[selectedIndex];
|
|
5414
5504
|
if (state) {
|
|
5415
5505
|
setEnabledKeys(enabledKeys.includes(state.key) ? enabledKeys.filter((enabledKey) => enabledKey !== state.key) : [...enabledKeys, state.key]);
|
|
@@ -5649,7 +5739,7 @@ var import_react12 = __toESM(require_react(), 1);
|
|
|
5649
5739
|
|
|
5650
5740
|
// src/tui/components/LabelEditor.tsx
|
|
5651
5741
|
var jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
|
|
5652
|
-
var LabelEditor = ({ widget, defaultLabel, onComplete, onCancel }) => {
|
|
5742
|
+
var LabelEditor = ({ widget, defaultLabel, onComplete, onCancel, onPreview }) => {
|
|
5653
5743
|
const { getText, display, handleInput } = useTextCursor(getLabel(widget, defaultLabel));
|
|
5654
5744
|
use_input_default((input, key) => {
|
|
5655
5745
|
if (key.return) {
|
|
@@ -5659,7 +5749,11 @@ var LabelEditor = ({ widget, defaultLabel, onComplete, onCancel }) => {
|
|
|
5659
5749
|
} else if (key.tab) {
|
|
5660
5750
|
onComplete(clearLabel(widget));
|
|
5661
5751
|
} else {
|
|
5752
|
+
const previousText = getText();
|
|
5662
5753
|
handleInput(input, key);
|
|
5754
|
+
if (getText() !== previousText) {
|
|
5755
|
+
onPreview?.(setLabel(widget, getText()));
|
|
5756
|
+
}
|
|
5663
5757
|
}
|
|
5664
5758
|
});
|
|
5665
5759
|
return /* @__PURE__ */ jsx_runtime10.jsxs(Box_default, {
|
|
@@ -5689,6 +5783,16 @@ var LabelEditor = ({ widget, defaultLabel, onComplete, onCancel }) => {
|
|
|
5689
5783
|
});
|
|
5690
5784
|
};
|
|
5691
5785
|
|
|
5786
|
+
// src/utils/move-item.ts
|
|
5787
|
+
function moveItem(items, fromIndex, toIndex) {
|
|
5788
|
+
const moved = [...items];
|
|
5789
|
+
const [item] = moved.splice(fromIndex, 1);
|
|
5790
|
+
if (item !== undefined) {
|
|
5791
|
+
moved.splice(toIndex, 0, item);
|
|
5792
|
+
}
|
|
5793
|
+
return moved;
|
|
5794
|
+
}
|
|
5795
|
+
|
|
5692
5796
|
// src/tui/components/items-editor/input-handlers.ts
|
|
5693
5797
|
function setPickerState(setWidgetPicker, normalizeState, updater) {
|
|
5694
5798
|
setWidgetPicker((prev) => {
|
|
@@ -5872,24 +5976,12 @@ function handleMoveInputMode({
|
|
|
5872
5976
|
setMoveMode
|
|
5873
5977
|
}) {
|
|
5874
5978
|
if (key.upArrow && widgets.length > 1) {
|
|
5875
|
-
const newWidgets = [...widgets];
|
|
5876
5979
|
const targetIndex = selectedIndex - 1 < 0 ? widgets.length - 1 : selectedIndex - 1;
|
|
5877
|
-
|
|
5878
|
-
const prev = newWidgets[targetIndex];
|
|
5879
|
-
if (temp && prev) {
|
|
5880
|
-
[newWidgets[selectedIndex], newWidgets[targetIndex]] = [prev, temp];
|
|
5881
|
-
}
|
|
5882
|
-
onUpdate(newWidgets);
|
|
5980
|
+
onUpdate(moveItem(widgets, selectedIndex, targetIndex));
|
|
5883
5981
|
setSelectedIndex(targetIndex);
|
|
5884
5982
|
} else if (key.downArrow && widgets.length > 1) {
|
|
5885
|
-
const newWidgets = [...widgets];
|
|
5886
5983
|
const targetIndex = selectedIndex + 1 > widgets.length - 1 ? 0 : selectedIndex + 1;
|
|
5887
|
-
|
|
5888
|
-
const next = newWidgets[targetIndex];
|
|
5889
|
-
if (temp && next) {
|
|
5890
|
-
[newWidgets[selectedIndex], newWidgets[targetIndex]] = [next, temp];
|
|
5891
|
-
}
|
|
5892
|
-
onUpdate(newWidgets);
|
|
5984
|
+
onUpdate(moveItem(widgets, selectedIndex, targetIndex));
|
|
5893
5985
|
setSelectedIndex(targetIndex);
|
|
5894
5986
|
} else if (key.escape || key.return) {
|
|
5895
5987
|
setMoveMode(false);
|
|
@@ -5912,6 +6004,7 @@ function handleNormalInputMode({
|
|
|
5912
6004
|
setCustomEditorWidget,
|
|
5913
6005
|
getUniqueBackgroundColor
|
|
5914
6006
|
}) {
|
|
6007
|
+
const shortcut = getPlainInput(input, key);
|
|
5915
6008
|
if (key.upArrow && widgets.length > 0) {
|
|
5916
6009
|
setSelectedIndex(selectedIndex - 1 < 0 ? widgets.length - 1 : selectedIndex - 1);
|
|
5917
6010
|
} else if (key.downArrow && widgets.length > 0) {
|
|
@@ -5922,17 +6015,17 @@ function handleNormalInputMode({
|
|
|
5922
6015
|
openWidgetPicker("change");
|
|
5923
6016
|
} else if (key.return && widgets.length > 0) {
|
|
5924
6017
|
setMoveMode(true);
|
|
5925
|
-
} else if (
|
|
6018
|
+
} else if (shortcut === "a") {
|
|
5926
6019
|
openWidgetPicker("add");
|
|
5927
|
-
} else if (
|
|
6020
|
+
} else if (shortcut === "i") {
|
|
5928
6021
|
openWidgetPicker("insert");
|
|
5929
|
-
} else if (
|
|
6022
|
+
} else if (shortcut === "d" && widgets.length > 0) {
|
|
5930
6023
|
const newWidgets = widgets.filter((_, i) => i !== selectedIndex);
|
|
5931
6024
|
onUpdate(newWidgets);
|
|
5932
6025
|
if (selectedIndex >= newWidgets.length && selectedIndex > 0) {
|
|
5933
6026
|
setSelectedIndex(selectedIndex - 1);
|
|
5934
6027
|
}
|
|
5935
|
-
} else if (
|
|
6028
|
+
} else if (shortcut === "k" && widgets.length > 0) {
|
|
5936
6029
|
const source = widgets[selectedIndex];
|
|
5937
6030
|
if (!source) {
|
|
5938
6031
|
return;
|
|
@@ -5952,11 +6045,11 @@ function handleNormalInputMode({
|
|
|
5952
6045
|
];
|
|
5953
6046
|
onUpdate(newWidgets);
|
|
5954
6047
|
setSelectedIndex(insertIndex);
|
|
5955
|
-
} else if (
|
|
6048
|
+
} else if (shortcut === "c") {
|
|
5956
6049
|
if (widgets.length > 0) {
|
|
5957
6050
|
setShowClearConfirm(true);
|
|
5958
6051
|
}
|
|
5959
|
-
} else if (
|
|
6052
|
+
} else if (shortcut === " " && widgets.length > 0) {
|
|
5960
6053
|
const currentWidget = widgets[selectedIndex];
|
|
5961
6054
|
if (currentWidget?.type === "separator") {
|
|
5962
6055
|
const currentChar = currentWidget.character ?? "|";
|
|
@@ -5966,7 +6059,7 @@ function handleNormalInputMode({
|
|
|
5966
6059
|
newWidgets[selectedIndex] = { ...currentWidget, character: nextChar };
|
|
5967
6060
|
onUpdate(newWidgets);
|
|
5968
6061
|
}
|
|
5969
|
-
} else if (
|
|
6062
|
+
} else if (shortcut === "r" && widgets.length > 0) {
|
|
5970
6063
|
const currentWidget = widgets[selectedIndex];
|
|
5971
6064
|
if (currentWidget && currentWidget.type !== "separator" && currentWidget.type !== "flex-separator") {
|
|
5972
6065
|
const widgetImpl = getWidget(currentWidget.type);
|
|
@@ -5977,14 +6070,15 @@ function handleNormalInputMode({
|
|
|
5977
6070
|
newWidgets[selectedIndex] = { ...currentWidget, rawValue: !currentWidget.rawValue };
|
|
5978
6071
|
onUpdate(newWidgets);
|
|
5979
6072
|
}
|
|
5980
|
-
} else if (
|
|
6073
|
+
} else if (shortcut === "m" && widgets.length > 0) {
|
|
5981
6074
|
const currentWidget = widgets[selectedIndex];
|
|
5982
|
-
|
|
6075
|
+
const isLastWidget = selectedIndex === widgets.length - 1;
|
|
6076
|
+
if (currentWidget && (!isLastWidget || currentWidget.merge) && currentWidget.type !== "separator" && currentWidget.type !== "flex-separator") {
|
|
5983
6077
|
const newWidgets = [...widgets];
|
|
5984
6078
|
let nextMergeState;
|
|
5985
6079
|
if (currentWidget.merge === undefined) {
|
|
5986
6080
|
nextMergeState = true;
|
|
5987
|
-
} else if (currentWidget.merge === true) {
|
|
6081
|
+
} else if (currentWidget.merge === true && !isLastWidget) {
|
|
5988
6082
|
nextMergeState = "no-padding";
|
|
5989
6083
|
} else {
|
|
5990
6084
|
nextMergeState = undefined;
|
|
@@ -5997,7 +6091,7 @@ function handleNormalInputMode({
|
|
|
5997
6091
|
}
|
|
5998
6092
|
onUpdate(newWidgets);
|
|
5999
6093
|
}
|
|
6000
|
-
} else if (
|
|
6094
|
+
} else if (shortcut === "x" && widgets.length > 0) {
|
|
6001
6095
|
const currentWidget = widgets[selectedIndex];
|
|
6002
6096
|
if (canExcludeAlign && currentWidget && currentWidget.type !== "separator" && currentWidget.type !== "flex-separator") {
|
|
6003
6097
|
const newWidgets = [...widgets];
|
|
@@ -6019,8 +6113,8 @@ function handleNormalInputMode({
|
|
|
6019
6113
|
return;
|
|
6020
6114
|
}
|
|
6021
6115
|
const customKeybinds = getCustomKeybindsForWidget(widgetImpl, currentWidget);
|
|
6022
|
-
const matchedKeybind = customKeybinds.find((kb) => kb.key ===
|
|
6023
|
-
if (matchedKeybind
|
|
6116
|
+
const matchedKeybind = customKeybinds.find((kb) => kb.key === shortcut);
|
|
6117
|
+
if (matchedKeybind) {
|
|
6024
6118
|
if (matchedKeybind.action === EDIT_HIDE_STATES_ACTION || matchedKeybind.action === EDIT_LABEL_ACTION) {
|
|
6025
6119
|
setCustomEditorWidget({ widget: currentWidget, impl: widgetImpl, action: matchedKeybind.action });
|
|
6026
6120
|
return;
|
|
@@ -6054,13 +6148,16 @@ function isMergedIntoPreviousWidget(widgets, index) {
|
|
|
6054
6148
|
}
|
|
6055
6149
|
return Boolean(widgets[index - 1]?.merge);
|
|
6056
6150
|
}
|
|
6057
|
-
var ItemsEditor = ({ widgets, onUpdate, onBack, lineNumber, settings }) => {
|
|
6151
|
+
var ItemsEditor = ({ widgets, onUpdate, onPreviewChange, onBack, lineNumber, settings }) => {
|
|
6058
6152
|
const [selectedIndex, setSelectedIndex] = import_react12.useState(0);
|
|
6059
6153
|
const [moveMode, setMoveMode] = import_react12.useState(false);
|
|
6060
6154
|
const [customEditorWidget, setCustomEditorWidget] = import_react12.useState(null);
|
|
6061
6155
|
const [widgetPicker, setWidgetPicker] = import_react12.useState(null);
|
|
6062
6156
|
const [showClearConfirm, setShowClearConfirm] = import_react12.useState(false);
|
|
6063
6157
|
const separatorChars = ["|", "-", ",", " "];
|
|
6158
|
+
import_react12.useEffect(() => () => {
|
|
6159
|
+
onPreviewChange?.(null);
|
|
6160
|
+
}, [onPreviewChange]);
|
|
6064
6161
|
const widgetCatalog = getWidgetCatalog(settings);
|
|
6065
6162
|
const widgetCategories = ["全部", ...getWidgetCatalogCategories(widgetCatalog)];
|
|
6066
6163
|
const getUniqueBackgroundColor = (insertIndex) => {
|
|
@@ -6083,9 +6180,11 @@ var ItemsEditor = ({ widgets, onUpdate, onBack, lineNumber, settings }) => {
|
|
|
6083
6180
|
const newWidgets = [...widgets];
|
|
6084
6181
|
newWidgets[selectedIndex] = updatedWidget;
|
|
6085
6182
|
onUpdate(newWidgets);
|
|
6183
|
+
onPreviewChange?.(null);
|
|
6086
6184
|
setCustomEditorWidget(null);
|
|
6087
6185
|
};
|
|
6088
6186
|
const handleEditorCancel = () => {
|
|
6187
|
+
onPreviewChange?.(null);
|
|
6089
6188
|
setCustomEditorWidget(null);
|
|
6090
6189
|
};
|
|
6091
6190
|
const getCustomKeybindsForWidget = (widgetImpl, widget) => {
|
|
@@ -6156,7 +6255,7 @@ var ItemsEditor = ({ widgets, onUpdate, onBack, lineNumber, settings }) => {
|
|
|
6156
6255
|
canToggleRaw = false;
|
|
6157
6256
|
}
|
|
6158
6257
|
}
|
|
6159
|
-
const canMerge = currentWidget && selectedIndex < widgets.length - 1 && !isSeparator && !isFlexSeparator;
|
|
6258
|
+
const canMerge = currentWidget && (selectedIndex < widgets.length - 1 || Boolean(currentWidget.merge)) && !isSeparator && !isFlexSeparator;
|
|
6160
6259
|
const canExcludeAlign = Boolean(currentWidget) && !isSeparator && !isFlexSeparator && settings.powerline.enabled && settings.powerline.autoAlign && !isMergedIntoPreviousWidget(widgets, selectedIndex);
|
|
6161
6260
|
const hasWidgets = widgets.length > 0;
|
|
6162
6261
|
use_input_default((input, key) => {
|
|
@@ -6263,7 +6362,12 @@ var ItemsEditor = ({ widgets, onUpdate, onBack, lineNumber, settings }) => {
|
|
|
6263
6362
|
widget: customEditorWidget.widget,
|
|
6264
6363
|
defaultLabel: customEditorWidget.impl.getLabelPrefix(customEditorWidget.widget),
|
|
6265
6364
|
onComplete: handleEditorComplete,
|
|
6266
|
-
onCancel: handleEditorCancel
|
|
6365
|
+
onCancel: handleEditorCancel,
|
|
6366
|
+
onPreview: (updatedWidget) => {
|
|
6367
|
+
const previewWidgets = [...widgets];
|
|
6368
|
+
previewWidgets[selectedIndex] = updatedWidget;
|
|
6369
|
+
onPreviewChange?.(previewWidgets);
|
|
6370
|
+
}
|
|
6267
6371
|
});
|
|
6268
6372
|
}
|
|
6269
6373
|
if (customEditorWidget?.impl.renderEditor) {
|
|
@@ -6708,6 +6812,7 @@ var LineSelector = ({
|
|
|
6708
6812
|
const powerlineTheme = settings ? settings.powerline.theme : undefined;
|
|
6709
6813
|
const isThemeManaged = blockIfPowerlineActive && powerlineEnabled && powerlineTheme && powerlineTheme !== "custom";
|
|
6710
6814
|
use_input_default((input, key) => {
|
|
6815
|
+
const shortcut = getPlainInput(input, key);
|
|
6711
6816
|
if (showDeleteDialog) {
|
|
6712
6817
|
return;
|
|
6713
6818
|
}
|
|
@@ -6717,24 +6822,14 @@ var LineSelector = ({
|
|
|
6717
6822
|
}
|
|
6718
6823
|
if (moveMode) {
|
|
6719
6824
|
if (key.upArrow && localLines.length > 1) {
|
|
6720
|
-
const newLines = [...localLines];
|
|
6721
6825
|
const targetIndex = selectedIndex - 1 < 0 ? localLines.length - 1 : selectedIndex - 1;
|
|
6722
|
-
const
|
|
6723
|
-
const prev = newLines[targetIndex];
|
|
6724
|
-
if (temp && prev) {
|
|
6725
|
-
[newLines[selectedIndex], newLines[targetIndex]] = [prev, temp];
|
|
6726
|
-
}
|
|
6826
|
+
const newLines = moveItem(localLines, selectedIndex, targetIndex);
|
|
6727
6827
|
setLocalLines(newLines);
|
|
6728
6828
|
onLinesUpdate(newLines);
|
|
6729
6829
|
setSelectedIndex(targetIndex);
|
|
6730
6830
|
} else if (key.downArrow && localLines.length > 1) {
|
|
6731
|
-
const newLines = [...localLines];
|
|
6732
6831
|
const targetIndex = selectedIndex + 1 > localLines.length - 1 ? 0 : selectedIndex + 1;
|
|
6733
|
-
const
|
|
6734
|
-
const next = newLines[targetIndex];
|
|
6735
|
-
if (temp && next) {
|
|
6736
|
-
[newLines[selectedIndex], newLines[targetIndex]] = [next, temp];
|
|
6737
|
-
}
|
|
6832
|
+
const newLines = moveItem(localLines, selectedIndex, targetIndex);
|
|
6738
6833
|
setLocalLines(newLines);
|
|
6739
6834
|
onLinesUpdate(newLines);
|
|
6740
6835
|
setSelectedIndex(targetIndex);
|
|
@@ -6743,7 +6838,7 @@ var LineSelector = ({
|
|
|
6743
6838
|
}
|
|
6744
6839
|
return;
|
|
6745
6840
|
}
|
|
6746
|
-
switch (
|
|
6841
|
+
switch (shortcut) {
|
|
6747
6842
|
case "a":
|
|
6748
6843
|
if (allowEditing) {
|
|
6749
6844
|
appendLine();
|
|
@@ -7335,7 +7430,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7335
7430
|
}
|
|
7336
7431
|
};
|
|
7337
7432
|
const separators = getItems();
|
|
7338
|
-
const invertBgs = mode === "separator" ? powerlineConfig.separatorInvertBackground : [];
|
|
7433
|
+
const invertBgs = mode === "separator" ? separators.map((_, i) => powerlineConfig.separatorInvertBackground[i] ?? false) : [];
|
|
7339
7434
|
const [selectedIndex, setSelectedIndex] = import_react14.useState(0);
|
|
7340
7435
|
const [hexInputMode, setHexInputMode] = import_react14.useState(false);
|
|
7341
7436
|
const [hexInput, setHexInput] = import_react14.useState("");
|
|
@@ -7396,6 +7491,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7396
7491
|
});
|
|
7397
7492
|
};
|
|
7398
7493
|
use_input_default((input, key) => {
|
|
7494
|
+
const shortcut = getPlainInput(input, key);
|
|
7399
7495
|
if (hexInputMode) {
|
|
7400
7496
|
if (key.escape) {
|
|
7401
7497
|
setHexInputMode(false);
|
|
@@ -7458,7 +7554,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7458
7554
|
newInvertBgs[selectedIndex] = isLeftFacing;
|
|
7459
7555
|
}
|
|
7460
7556
|
updateSeparators(newSeparators, mode === "separator" ? newInvertBgs : undefined);
|
|
7461
|
-
} else if (
|
|
7557
|
+
} else if (shortcut === "a" || shortcut === "A") {
|
|
7462
7558
|
const newSeparators = [...separators];
|
|
7463
7559
|
const newInvertBgs = mode === "separator" ? [...invertBgs] : [];
|
|
7464
7560
|
const defaultChar = presetSeparators[0]?.char ?? "";
|
|
@@ -7478,7 +7574,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7478
7574
|
updateSeparators(newSeparators, newInvertBgs);
|
|
7479
7575
|
setSelectedIndex(selectedIndex + 1);
|
|
7480
7576
|
}
|
|
7481
|
-
} else if (
|
|
7577
|
+
} else if (shortcut === "i" || shortcut === "I") {
|
|
7482
7578
|
const newSeparators = [...separators];
|
|
7483
7579
|
const newInvertBgs = mode === "separator" ? [...invertBgs] : [];
|
|
7484
7580
|
const defaultChar = presetSeparators[0]?.char ?? "";
|
|
@@ -7497,23 +7593,23 @@ var PowerlineSeparatorEditor = ({
|
|
|
7497
7593
|
}
|
|
7498
7594
|
updateSeparators(newSeparators, newInvertBgs);
|
|
7499
7595
|
}
|
|
7500
|
-
} else if ((
|
|
7596
|
+
} else if ((shortcut === "d" || shortcut === "D") && (mode !== "separator" || separators.length > 1)) {
|
|
7501
7597
|
const newSeparators = separators.filter((_, i) => i !== selectedIndex);
|
|
7502
7598
|
const newInvertBgs = mode === "separator" ? invertBgs.filter((_, i) => i !== selectedIndex) : [];
|
|
7503
7599
|
updateSeparators(newSeparators, newInvertBgs);
|
|
7504
7600
|
setSelectedIndex(Math.min(selectedIndex, Math.max(0, newSeparators.length - 1)));
|
|
7505
|
-
} else if (
|
|
7601
|
+
} else if (shortcut === "c" || shortcut === "C") {
|
|
7506
7602
|
if (mode === "separator") {
|
|
7507
7603
|
updateSeparators([""], [false]);
|
|
7508
7604
|
} else {
|
|
7509
7605
|
updateSeparators([]);
|
|
7510
7606
|
}
|
|
7511
7607
|
setSelectedIndex(0);
|
|
7512
|
-
} else if (
|
|
7608
|
+
} else if (shortcut === "h" || shortcut === "H") {
|
|
7513
7609
|
setHexInputMode(true);
|
|
7514
7610
|
setHexInput("");
|
|
7515
7611
|
setCursorPos(0);
|
|
7516
|
-
} else if ((
|
|
7612
|
+
} else if ((shortcut === "t" || shortcut === "T") && mode === "separator") {
|
|
7517
7613
|
const newInvertBgs = [...invertBgs];
|
|
7518
7614
|
newInvertBgs[selectedIndex] = !(newInvertBgs[selectedIndex] ?? false);
|
|
7519
7615
|
updateSeparators(separators, newInvertBgs);
|
|
@@ -7555,9 +7651,7 @@ var PowerlineSeparatorEditor = ({
|
|
|
7555
7651
|
children: [
|
|
7556
7652
|
"U+",
|
|
7557
7653
|
hexInput.slice(0, cursorPos),
|
|
7558
|
-
/* @__PURE__ */ jsx_runtime15.jsx(
|
|
7559
|
-
backgroundColor: "gray",
|
|
7560
|
-
color: "black",
|
|
7654
|
+
/* @__PURE__ */ jsx_runtime15.jsx(BlinkingCursor, {
|
|
7561
7655
|
children: hexInput[cursorPos] ?? "_"
|
|
7562
7656
|
}),
|
|
7563
7657
|
hexInput.slice(cursorPos + 1),
|
|
@@ -7631,15 +7725,17 @@ function applyCustomPowerlineTheme(settings, themeName) {
|
|
|
7631
7725
|
if (!themeColors) {
|
|
7632
7726
|
return null;
|
|
7633
7727
|
}
|
|
7728
|
+
let nextLineSlot = 0;
|
|
7634
7729
|
const lines = settings.lines.map((line) => {
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7730
|
+
const { slots, nextSlot } = assignPowerlineThemeSlots(line, settings.powerline.continueThemeAcrossLines ? nextLineSlot : 0);
|
|
7731
|
+
nextLineSlot = nextSlot;
|
|
7732
|
+
return line.map((widget, index) => {
|
|
7733
|
+
const slot = slots[index];
|
|
7734
|
+
if (typeof slot !== "number") {
|
|
7638
7735
|
return widget;
|
|
7639
7736
|
}
|
|
7640
|
-
const fgColor = themeColors.fg[
|
|
7641
|
-
const bgColor = themeColors.bg[
|
|
7642
|
-
widgetColorIndex++;
|
|
7737
|
+
const fgColor = themeColors.fg[slot % themeColors.fg.length];
|
|
7738
|
+
const bgColor = themeColors.bg[slot % themeColors.bg.length];
|
|
7643
7739
|
return {
|
|
7644
7740
|
...widget,
|
|
7645
7741
|
color: fgColor,
|
|
@@ -7692,13 +7788,14 @@ var PowerlineThemeSelector = ({
|
|
|
7692
7788
|
});
|
|
7693
7789
|
}, [selectedIndex, themes]);
|
|
7694
7790
|
use_input_default((input, key) => {
|
|
7791
|
+
const shortcut = getPlainInput(input, key);
|
|
7695
7792
|
if (showCustomizeConfirm) {
|
|
7696
7793
|
return;
|
|
7697
7794
|
}
|
|
7698
7795
|
if (key.escape) {
|
|
7699
7796
|
onUpdate(originalSettingsRef.current);
|
|
7700
7797
|
onBack();
|
|
7701
|
-
} else if (
|
|
7798
|
+
} else if (shortcut === "c" || shortcut === "C") {
|
|
7702
7799
|
const currentThemeName = themes[selectedIndex];
|
|
7703
7800
|
if (currentThemeName && currentThemeName !== "custom") {
|
|
7704
7801
|
setShowCustomizeConfirm(true);
|
|
@@ -7926,6 +8023,7 @@ var PowerlineSetup = ({
|
|
|
7926
8023
|
const hasGlobalFgOverride = Boolean(settings.overrideForegroundColor && settings.overrideForegroundColor !== "none");
|
|
7927
8024
|
const globalOverrideMessage = hasGlobalFgOverride ? "⚠ 前景色全局覆盖已激活" : null;
|
|
7928
8025
|
use_input_default((input, key) => {
|
|
8026
|
+
const shortcut = getPlainInput(input, key);
|
|
7929
8027
|
if (fontInstallMessage || installingFonts) {
|
|
7930
8028
|
if (fontInstallMessage && !key.escape) {
|
|
7931
8029
|
onClearMessage();
|
|
@@ -7938,7 +8036,7 @@ var PowerlineSetup = ({
|
|
|
7938
8036
|
if (screen === "menu") {
|
|
7939
8037
|
if (key.escape) {
|
|
7940
8038
|
onBack();
|
|
7941
|
-
} else if (
|
|
8039
|
+
} else if (shortcut === "t" || shortcut === "T") {
|
|
7942
8040
|
if (!powerlineConfig.enabled) {
|
|
7943
8041
|
if (hasManualSeparatorItems) {
|
|
7944
8042
|
setConfirmingEnable(true);
|
|
@@ -7954,9 +8052,9 @@ var PowerlineSetup = ({
|
|
|
7954
8052
|
}
|
|
7955
8053
|
});
|
|
7956
8054
|
}
|
|
7957
|
-
} else if (
|
|
8055
|
+
} else if (shortcut === "i" || shortcut === "I") {
|
|
7958
8056
|
setConfirmingFontInstall(true);
|
|
7959
|
-
} else if ((
|
|
8057
|
+
} else if ((shortcut === "a" || shortcut === "A") && powerlineConfig.enabled) {
|
|
7960
8058
|
onUpdate({
|
|
7961
8059
|
...settings,
|
|
7962
8060
|
powerline: {
|
|
@@ -7964,7 +8062,7 @@ var PowerlineSetup = ({
|
|
|
7964
8062
|
autoAlign: !powerlineConfig.autoAlign
|
|
7965
8063
|
}
|
|
7966
8064
|
});
|
|
7967
|
-
} else if ((
|
|
8065
|
+
} else if ((shortcut === "c" || shortcut === "C") && powerlineConfig.enabled) {
|
|
7968
8066
|
onUpdate({
|
|
7969
8067
|
...settings,
|
|
7970
8068
|
powerline: {
|
|
@@ -8662,7 +8760,7 @@ var renderSingleLine = (widgets, terminalWidth, settings, lineIndex, globalSepar
|
|
|
8662
8760
|
};
|
|
8663
8761
|
var PREVIEW_LINE_INDENT = " ";
|
|
8664
8762
|
function preparePreviewLineForTerminal(line, terminalWidth) {
|
|
8665
|
-
const printableLine =
|
|
8763
|
+
const printableLine = sanitizeTerminalText(line).replace(/\x1b\\/g, "\x07");
|
|
8666
8764
|
const availableWidth = Math.max(0, terminalWidth - getVisibleWidth(PREVIEW_LINE_INDENT));
|
|
8667
8765
|
return truncateStyledText(printableLine, availableWidth, { ellipsis: true });
|
|
8668
8766
|
}
|
|
@@ -9368,11 +9466,12 @@ function getPinnedMismatchItems(mismatch, canRunPackageManager) {
|
|
|
9368
9466
|
var PinnedVersionMismatchScreen = ({
|
|
9369
9467
|
mismatch,
|
|
9370
9468
|
canRunPackageManager,
|
|
9469
|
+
updating,
|
|
9371
9470
|
onUpdate,
|
|
9372
9471
|
onExit
|
|
9373
9472
|
}) => {
|
|
9374
9473
|
use_input_default((_, key) => {
|
|
9375
|
-
if (key.escape) {
|
|
9474
|
+
if (key.escape && !updating) {
|
|
9376
9475
|
onExit();
|
|
9377
9476
|
}
|
|
9378
9477
|
});
|
|
@@ -9415,7 +9514,13 @@ var PinnedVersionMismatchScreen = ({
|
|
|
9415
9514
|
]
|
|
9416
9515
|
})
|
|
9417
9516
|
}),
|
|
9418
|
-
/* @__PURE__ */ jsx_runtime23.jsx(
|
|
9517
|
+
updating ? /* @__PURE__ */ jsx_runtime23.jsx(Box_default, {
|
|
9518
|
+
marginTop: 1,
|
|
9519
|
+
children: /* @__PURE__ */ jsx_runtime23.jsx(Text, {
|
|
9520
|
+
color: "yellow",
|
|
9521
|
+
children: `正在将 ${mismatch.packageManager} 全局安装更新至 v${mismatch.runningVersion},请稍候...`
|
|
9522
|
+
})
|
|
9523
|
+
}) : /* @__PURE__ */ jsx_runtime23.jsx(List, {
|
|
9419
9524
|
marginTop: 1,
|
|
9420
9525
|
items: getPinnedMismatchItems(mismatch, canRunPackageManager),
|
|
9421
9526
|
onSelect: (value) => {
|
|
@@ -9481,8 +9586,8 @@ function getPinnedGlobalRelaunchCommand(packageManager) {
|
|
|
9481
9586
|
}
|
|
9482
9587
|
return "ccstatusline-zh";
|
|
9483
9588
|
}
|
|
9484
|
-
function getPinnedVersionMismatch(installation, runningVersion, relaunchCommand) {
|
|
9485
|
-
if (installation.method !== "pinned" || !installation.installedVersion || installation.packageManager === "unknown" || !runningVersion || installation.installedVersion === runningVersion) {
|
|
9589
|
+
function getPinnedVersionMismatch(installation, runningVersion, relaunchCommand, versionInstalledThisSession = null) {
|
|
9590
|
+
if (installation.method !== "pinned" || !installation.installedVersion || installation.packageManager === "unknown" || !runningVersion || installation.installedVersion === runningVersion || installation.installedVersion === versionInstalledThisSession) {
|
|
9486
9591
|
return null;
|
|
9487
9592
|
}
|
|
9488
9593
|
return {
|
|
@@ -9532,7 +9637,7 @@ function buildConfigLoadWarning(configLoadError) {
|
|
|
9532
9637
|
}
|
|
9533
9638
|
return `⚠ ${configLoadError}——当前显示默认配置;在此保存将覆盖原文件。`;
|
|
9534
9639
|
}
|
|
9535
|
-
function buildInvalidConfigSaveConfirm(configLoadError, onConfirm) {
|
|
9640
|
+
function buildInvalidConfigSaveConfirm(configLoadError, onConfirm, returnScreen = "main") {
|
|
9536
9641
|
if (!configLoadError) {
|
|
9537
9642
|
return null;
|
|
9538
9643
|
}
|
|
@@ -9542,7 +9647,7 @@ function buildInvalidConfigSaveConfirm(configLoadError, onConfirm) {
|
|
|
9542
9647
|
onConfirm();
|
|
9543
9648
|
return Promise.resolve();
|
|
9544
9649
|
},
|
|
9545
|
-
cancelScreen:
|
|
9650
|
+
cancelScreen: returnScreen
|
|
9546
9651
|
};
|
|
9547
9652
|
}
|
|
9548
9653
|
var App = () => {
|
|
@@ -9553,6 +9658,7 @@ var App = () => {
|
|
|
9553
9658
|
const [configLoadError, setConfigLoadError] = import_react21.useState(null);
|
|
9554
9659
|
const [screen, setScreen] = import_react21.useState("main");
|
|
9555
9660
|
const [selectedLine, setSelectedLine] = import_react21.useState(0);
|
|
9661
|
+
const [previewWidgets, setPreviewWidgets] = import_react21.useState(null);
|
|
9556
9662
|
const [menuSelections, setMenuSelections] = import_react21.useState({});
|
|
9557
9663
|
const [confirmDialog, setConfirmDialog] = import_react21.useState(null);
|
|
9558
9664
|
const [isClaudeInstalled, setIsClaudeInstalled] = import_react21.useState(false);
|
|
@@ -9570,9 +9676,12 @@ var App = () => {
|
|
|
9570
9676
|
const [flowNotice, setFlowNotice] = import_react21.useState(null);
|
|
9571
9677
|
const [globalPackageInstallations, setGlobalPackageInstallations] = import_react21.useState([]);
|
|
9572
9678
|
const [updatesReturnScreen, setUpdatesReturnScreen] = import_react21.useState("main");
|
|
9679
|
+
const [versionInstalledThisSession, setVersionInstalledThisSession] = import_react21.useState(null);
|
|
9573
9680
|
const [hasLoadedClaudeStatus, setHasLoadedClaudeStatus] = import_react21.useState(false);
|
|
9574
9681
|
const [hasLoadedInstalledState, setHasLoadedInstalledState] = import_react21.useState(false);
|
|
9575
9682
|
const [importValidation, setImportValidation] = import_react21.useState(null);
|
|
9683
|
+
const [actionInFlight, setActionInFlight] = import_react21.useState(false);
|
|
9684
|
+
const actionInFlightRef = import_react21.useRef(false);
|
|
9576
9685
|
import_react21.useEffect(() => {
|
|
9577
9686
|
loadClaudeStatusLineState().then((statusLineState) => {
|
|
9578
9687
|
setExistingStatusLine(statusLineState.existingStatusLine);
|
|
@@ -9631,7 +9740,7 @@ var App = () => {
|
|
|
9631
9740
|
const installation = getCurrentInstallation(isClaudeInstalled, existingStatusLine, settings);
|
|
9632
9741
|
const activeCommand = installation.method === "pinned" || installation.method === "self-managed" ? inspectActiveGlobalCommand({ commandAvailability }) : null;
|
|
9633
9742
|
const effectiveInstallation = getPathInferredInstallation(installation, activeCommand);
|
|
9634
|
-
const mismatch = getPinnedVersionMismatch(effectiveInstallation, getPackageVersion(), "ccstatusline-zh");
|
|
9743
|
+
const mismatch = getPinnedVersionMismatch(effectiveInstallation, getPackageVersion(), "ccstatusline-zh", versionInstalledThisSession);
|
|
9635
9744
|
if (mismatch) {
|
|
9636
9745
|
return;
|
|
9637
9746
|
}
|
|
@@ -9654,11 +9763,12 @@ var App = () => {
|
|
|
9654
9763
|
}
|
|
9655
9764
|
})();
|
|
9656
9765
|
};
|
|
9766
|
+
const returnScreen = screen;
|
|
9657
9767
|
const saveGuard = buildInvalidConfigSaveConfirm(configLoadError, () => {
|
|
9658
9768
|
setConfirmDialog(null);
|
|
9659
|
-
setScreen(
|
|
9769
|
+
setScreen(returnScreen);
|
|
9660
9770
|
performSave();
|
|
9661
|
-
});
|
|
9771
|
+
}, returnScreen);
|
|
9662
9772
|
if (saveGuard) {
|
|
9663
9773
|
setConfirmDialog(saveGuard);
|
|
9664
9774
|
setScreen("confirm");
|
|
@@ -9741,12 +9851,15 @@ ${resolutionWarning}`,
|
|
|
9741
9851
|
color: "green"
|
|
9742
9852
|
});
|
|
9743
9853
|
}
|
|
9744
|
-
} catch {
|
|
9745
|
-
setFlashMessage(
|
|
9746
|
-
|
|
9747
|
-
|
|
9854
|
+
} catch (err) {
|
|
9855
|
+
setFlashMessage(null);
|
|
9856
|
+
setFlowNotice({
|
|
9857
|
+
title: "安装失败",
|
|
9858
|
+
message: err instanceof Error ? err.message : String(err),
|
|
9859
|
+
color: "red",
|
|
9860
|
+
continueScreen: "install"
|
|
9748
9861
|
});
|
|
9749
|
-
setScreen("
|
|
9862
|
+
setScreen("flowNotice");
|
|
9750
9863
|
}
|
|
9751
9864
|
setConfirmDialog(null);
|
|
9752
9865
|
}
|
|
@@ -9782,6 +9895,7 @@ Claude 设置不会被修改。`,
|
|
|
9782
9895
|
action: async () => {
|
|
9783
9896
|
try {
|
|
9784
9897
|
await runGlobalUpdateAction(action);
|
|
9898
|
+
setVersionInstalledThisSession(action.version);
|
|
9785
9899
|
const installation = {
|
|
9786
9900
|
method: "pinned",
|
|
9787
9901
|
installedVersion: action.version
|
|
@@ -9875,7 +9989,18 @@ ${resolutionWarning}`,
|
|
|
9875
9989
|
const currentInstallation = getCurrentInstallation(isClaudeInstalled, existingStatusLine, settings);
|
|
9876
9990
|
const activeGlobalCommand = currentInstallation.method === "pinned" || currentInstallation.method === "self-managed" ? inspectActiveGlobalCommand({ commandAvailability }) : null;
|
|
9877
9991
|
const effectiveInstallation = getPathInferredInstallation(currentInstallation, activeGlobalCommand);
|
|
9878
|
-
const pinnedVersionMismatch = effectiveInstallation.method === "pinned" && effectiveInstallation.packageManager !== "unknown" ? getPinnedVersionMismatch(effectiveInstallation, runningVersion, getPinnedGlobalRelaunchCommand(effectiveInstallation.packageManager)) : null;
|
|
9992
|
+
const pinnedVersionMismatch = effectiveInstallation.method === "pinned" && effectiveInstallation.packageManager !== "unknown" ? getPinnedVersionMismatch(effectiveInstallation, runningVersion, getPinnedGlobalRelaunchCommand(effectiveInstallation.packageManager), versionInstalledThisSession) : null;
|
|
9993
|
+
const runActionOnce = (action) => {
|
|
9994
|
+
if (actionInFlightRef.current) {
|
|
9995
|
+
return;
|
|
9996
|
+
}
|
|
9997
|
+
actionInFlightRef.current = true;
|
|
9998
|
+
setActionInFlight(true);
|
|
9999
|
+
action().finally(() => {
|
|
10000
|
+
actionInFlightRef.current = false;
|
|
10001
|
+
setActionInFlight(false);
|
|
10002
|
+
});
|
|
10003
|
+
};
|
|
9879
10004
|
const handlePinnedVersionMismatchUpdate = async (mismatch) => {
|
|
9880
10005
|
try {
|
|
9881
10006
|
await runGlobalPackageInstall(mismatch.packageManager, mismatch.runningVersion);
|
|
@@ -10108,8 +10233,9 @@ ${GITHUB_REPO_URL}`,
|
|
|
10108
10233
|
/* @__PURE__ */ jsx_runtime23.jsx(PinnedVersionMismatchScreen, {
|
|
10109
10234
|
mismatch: pinnedVersionMismatch,
|
|
10110
10235
|
canRunPackageManager: commandAvailability[pinnedVersionMismatch.packageManager],
|
|
10236
|
+
updating: actionInFlight,
|
|
10111
10237
|
onUpdate: () => {
|
|
10112
|
-
handlePinnedVersionMismatchUpdate(pinnedVersionMismatch);
|
|
10238
|
+
runActionOnce(() => handlePinnedVersionMismatchUpdate(pinnedVersionMismatch));
|
|
10113
10239
|
},
|
|
10114
10240
|
onExit: exit
|
|
10115
10241
|
})
|
|
@@ -10129,6 +10255,7 @@ ${GITHUB_REPO_URL}`,
|
|
|
10129
10255
|
setScreen("items");
|
|
10130
10256
|
};
|
|
10131
10257
|
const configWarning = buildConfigLoadWarning(configLoadError);
|
|
10258
|
+
const previewLines = screen === "items" && previewWidgets ? settings.lines.map((line, index) => index === selectedLine ? previewWidgets : line) : settings.lines;
|
|
10132
10259
|
return /* @__PURE__ */ jsx_runtime23.jsxs(Box_default, {
|
|
10133
10260
|
flexDirection: "column",
|
|
10134
10261
|
children: [
|
|
@@ -10163,7 +10290,7 @@ ${GITHUB_REPO_URL}`,
|
|
|
10163
10290
|
children: `配置文件:${getConfigPath()}`
|
|
10164
10291
|
}),
|
|
10165
10292
|
/* @__PURE__ */ jsx_runtime23.jsx(StatusLinePreview, {
|
|
10166
|
-
lines:
|
|
10293
|
+
lines: previewLines,
|
|
10167
10294
|
terminalWidth,
|
|
10168
10295
|
settings,
|
|
10169
10296
|
onTruncationChange: setPreviewIsTruncated
|
|
@@ -10206,6 +10333,7 @@ ${GITHUB_REPO_URL}`,
|
|
|
10206
10333
|
onUpdate: (widgets) => {
|
|
10207
10334
|
updateLine(selectedLine, widgets);
|
|
10208
10335
|
},
|
|
10336
|
+
onPreviewChange: setPreviewWidgets,
|
|
10209
10337
|
onBack: () => {
|
|
10210
10338
|
setMenuSelections((prev) => ({ ...prev, lines: selectedLine }));
|
|
10211
10339
|
setScreen("lines");
|
|
@@ -10279,7 +10407,10 @@ ${GITHUB_REPO_URL}`,
|
|
|
10279
10407
|
}),
|
|
10280
10408
|
screen === "confirm" && confirmDialog && /* @__PURE__ */ jsx_runtime23.jsx(ConfirmDialog, {
|
|
10281
10409
|
message: confirmDialog.message,
|
|
10282
|
-
|
|
10410
|
+
busy: actionInFlight,
|
|
10411
|
+
onConfirm: () => {
|
|
10412
|
+
runActionOnce(confirmDialog.action);
|
|
10413
|
+
},
|
|
10283
10414
|
onCancel: () => {
|
|
10284
10415
|
setScreen(getConfirmCancelScreen(confirmDialog));
|
|
10285
10416
|
setConfirmDialog(null);
|