@lokiyou/pi-nano-footer 0.8.0 → 0.9.0
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/index.ts +13 -28
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -46,9 +46,6 @@ const C = {
|
|
|
46
46
|
border: "#dfe6e9",
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
// ── ANSI 24-bit true color 正则(用于从 borderColor 函数提取颜色) ──
|
|
50
|
-
const ANSI_RE = /\x1b\[38;2;(\d+);(\d+);(\d+)m/;
|
|
51
|
-
|
|
52
49
|
// ── Rainbow 色表(high / xhigh 思考等级用) ──
|
|
53
50
|
const RAINBOW = [
|
|
54
51
|
"#b281d6", "#d787af", "#febc38", "#e4c00f",
|
|
@@ -62,16 +59,8 @@ const RAINBOW = [
|
|
|
62
59
|
let working = false;
|
|
63
60
|
let animInterval: ReturnType<typeof setInterval> | undefined;
|
|
64
61
|
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
*/
|
|
68
|
-
function extractRGB(fn: (str: string) => string): [number, number, number] | null {
|
|
69
|
-
const sample = fn("─");
|
|
70
|
-
// borderColor 输出格式:\x1b[38;2;R;G;Bm─\x1b[0m
|
|
71
|
-
const m = sample.match(ANSI_RE);
|
|
72
|
-
if (!m) return null;
|
|
73
|
-
return [parseInt(m[1]), parseInt(m[2]), parseInt(m[3])];
|
|
74
|
-
}
|
|
62
|
+
/** 工作状态呼吸色:暖橙 #ff9f1c,代表 processing/运行中 */
|
|
63
|
+
const WORK_RGB: [number, number, number] = [0xff, 0x9f, 0x1c];
|
|
75
64
|
|
|
76
65
|
/** 保存原始 render */
|
|
77
66
|
const origRender = Editor.prototype.render;
|
|
@@ -79,21 +68,17 @@ const origRender = Editor.prototype.render;
|
|
|
79
68
|
Editor.prototype.render = function (width: number): string[] {
|
|
80
69
|
if (working) {
|
|
81
70
|
const saved = this.borderColor;
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const nb = Math.round(Math.min(255, b * bright + (255 - b) * glow));
|
|
94
|
-
this.borderColor = (str: string) =>
|
|
95
|
-
`\x1b[38;2;${nr};${ng};${nb}m${str}\x1b[0m`;
|
|
96
|
-
}
|
|
71
|
+
const [r, g, b] = WORK_RGB;
|
|
72
|
+
// 更快呼吸 + 暖橙 processing 色
|
|
73
|
+
// 周期 ~600ms(比之前快一倍),60fps 驱动
|
|
74
|
+
const t = 0.5 + 0.5 * Math.sin(performance.now() / 300);
|
|
75
|
+
const bright = 0.25 + 0.75 * t;
|
|
76
|
+
const glow = t * t * 0.35;
|
|
77
|
+
const nr = Math.round(Math.min(255, r * bright + (255 - r) * glow));
|
|
78
|
+
const ng = Math.round(Math.min(255, g * bright + (255 - g) * glow));
|
|
79
|
+
const nb = Math.round(Math.min(255, b * bright + (255 - b) * glow));
|
|
80
|
+
this.borderColor = (str: string) =>
|
|
81
|
+
`\x1b[38;2;${nr};${ng};${nb}m${str}\x1b[0m`;
|
|
97
82
|
try {
|
|
98
83
|
return origRender.call(this, width);
|
|
99
84
|
} finally {
|