@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.
Files changed (2) hide show
  1. package/index.ts +13 -28
  2. 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
- * borderColor 函数采样一个字符,提取其中使用的 RGB 色值
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 rgb = extractRGB(saved);
83
- if (rgb) {
84
- const [r, g, b] = rgb;
85
- // 呼吸发光:纯 sin + 60fps 主动刷新
86
- // - 暗处 ~25%,亮处 100% + 柔和白色辉光
87
- // 周期 ~1.2s(从容的呼吸节奏)
88
- const t = 0.5 + 0.5 * Math.sin(performance.now() / 600);
89
- const bright = 0.25 + 0.75 * t; // 25%~100%
90
- const glow = t * t * 0.35; // 0~0.35 白色 blend,t² 让辉光集中在峰值
91
- const nr = Math.round(Math.min(255, r * bright + (255 - r) * glow));
92
- const ng = Math.round(Math.min(255, g * bright + (255 - g) * glow));
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokiyou/pi-nano-footer",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "超轻量 powerline 风格 footer for Pi Coding Agent — 输入框脉冲发光,霓虹配色,实时显示模型、目录、上下文、token 和费用",
5
5
  "type": "module",
6
6
  "keywords": [