@lokiyou/pi-nano-footer 0.6.0 → 0.8.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 +23 -12
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -60,6 +60,7 @@ const RAINBOW = [
60
60
  // ═══════════════════════════════════════════════════════════════════════════
61
61
 
62
62
  let working = false;
63
+ let animInterval: ReturnType<typeof setInterval> | undefined;
63
64
 
64
65
  /**
65
66
  * 从 borderColor 函数采样一个字符,提取其中使用的 RGB 色值
@@ -81,17 +82,15 @@ Editor.prototype.render = function (width: number): string[] {
81
82
  const rgb = extractRGB(saved);
82
83
  if (rgb) {
83
84
  const [r, g, b] = rgb;
84
- // 荧光呼吸:
85
- // - 暗处降到 12% 亮度(像灯熄了)
86
- // - 亮处叠加白色辉光(像荧光灯通电)
87
- // - t² 曲线让过渡更锐利,停留暗/亮两端更久
88
- // 周期 ~1s 一次完整呼吸
89
- const t = 0.5 + 0.5 * Math.sin(performance.now() / 350);
90
- const base = 0.12 + 0.88 * t; // 12%~100% 明暗
91
- const glow = Math.min(1, t * 1.4); // 0~1 白色 blending,峰值更亮
92
- const nr = Math.round(Math.min(255, r * base + (255 - r) * glow * 0.35));
93
- const ng = Math.round(Math.min(255, g * base + (255 - g) * glow * 0.35));
94
- const nb = Math.round(Math.min(255, b * base + (255 - b) * glow * 0.35));
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));
95
94
  this.borderColor = (str: string) =>
96
95
  `\x1b[38;2;${nr};${ng};${nb}m${str}\x1b[0m`;
97
96
  }
@@ -168,13 +167,21 @@ export default function (pi: ExtensionAPI) {
168
167
  });
169
168
  pi.on("model_select", () => refresh());
170
169
 
171
- // 工作状态切换 → 控制脉冲发光
170
+ // 工作状态切换 → 控制呼吸发光
172
171
  pi.on("agent_start", () => {
173
172
  working = true;
173
+ // 50ms 间隔主动刷新,保证呼吸动画 20fps 流畅
174
+ if (requestRender) {
175
+ animInterval = setInterval(requestRender, 50);
176
+ }
174
177
  refresh();
175
178
  });
176
179
  pi.on("agent_end", () => {
177
180
  working = false;
181
+ if (animInterval) {
182
+ clearInterval(animInterval);
183
+ animInterval = undefined;
184
+ }
178
185
  refresh();
179
186
  });
180
187
 
@@ -184,6 +191,10 @@ export default function (pi: ExtensionAPI) {
184
191
  pi.on("session_shutdown", (_event, ctx) => {
185
192
  ctx.ui.setFooter(undefined);
186
193
  requestRender = undefined;
194
+ if (animInterval) {
195
+ clearInterval(animInterval);
196
+ animInterval = undefined;
197
+ }
187
198
  });
188
199
  }
189
200
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokiyou/pi-nano-footer",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "超轻量 powerline 风格 footer for Pi Coding Agent — 输入框脉冲发光,霓虹配色,实时显示模型、目录、上下文、token 和费用",
5
5
  "type": "module",
6
6
  "keywords": [