balance-dsh 2.1.8 → 2.1.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/lib/client.js CHANGED
@@ -695,12 +695,26 @@ window.__ModuleLoader__.load({
695
695
  时长与曲线与刷新白条 balance-wipe-head 完全一致(.58s cubic-bezier(.34,.7,.26,1))。 */
696
696
  .balance-footer__timeline-pointer{position:absolute;left:0;top:-1px;bottom:-1px;width:2px;margin-left:-1px;background:var(--dsw-alias-label-primary,#fff);box-shadow:0 0 3px rgba(255,255,255,.7),0 0 2px rgba(0,0,0,.55);pointer-events:none;z-index:2}
697
697
  .balance-footer__timeline-pointer--intro{animation:balance-ptr-in 580ms cubic-bezier(.34,.7,.26,1) both;will-change:left}
698
- /* 闸门没开时的样子:待在终点但**不可见**(2026-11-02 用户要求指针动画排队)。
699
- 不加这条的话,等闸门的这 640ms 里指针会明晃晃站在终点,闸门一开又跳回 3px 重滑 —— 看得见的闪。 */
700
- .balance-footer__timeline-pointer--pending{opacity:0}
701
- /* from 固定 = pct 0 的位置(0% + 3px 内缩);to 读元素上的自定义属性,即最终落点。
698
+ /* 闸门没开时的样子:**停在 0 点(00:00 的位置)但保持可见**(2026-11-02 第二十六轮)。
699
+ 用户原话:「加载插件之后 指针在0点处滑到当前时段 所以说指针全程不要消失在时段条上」。
700
+ 原来这里是 opacity:0(等闸门的这几百毫秒里指针看不见,闸门一开才从左边滑出来),
701
+ 看起来就是「指针先没了、再冒出来」。现在位置由 state 的 pct:0 决定,这里不再改透明度。
702
+ ⚠️ 别再往这条规则里塞 opacity:0 / visibility:hidden / display:none。 */
703
+ .balance-footer__timeline-pointer--pending{opacity:1}
704
+ /* from 固定 = pct 0 的位置(0% + 2px 内缩,= 组件的 inset,两处必须同值);to 读元素上的自定义属性,即最终落点。
702
705
  both 让动画结束后停在 to,摘掉 --intro 时 inline left 恰好同值,不会跳。 */
703
- @keyframes balance-ptr-in{from{left:3px}to{left:var(--balance-ptr-to,3px)}}
706
+ @keyframes balance-ptr-in{from{left:2px}to{left:var(--balance-ptr-to,2px)}}
707
+ /* 跨零点:从最右端扫回最左端(2026-11-02 用户:「从 23:59 到第二天 00:00 是从最右边向左滑到最左边」)。
708
+ 三个刻意的取舍:
709
+ 1) **不写 fill-mode**:动画一结束就回落到 inline left,而 to 与 inline left 同值,收尾看不出跳。
710
+ 写 both 反而会把 left 永久钉在动画终点,把此后每分钟的落位全盖住(入场那条必须 both,
711
+ 是因为它要靠 both 顶到 JS 摘类那一刻;这条不需要,所以也就不用定时器摘类)。
712
+ 2) 时长与色带换日的交叉淡入 BAND_FADE_MS(620ms)同值 —— 零点那一瞬是「指针扫回来 + 颜色淡过去」
713
+ 同一个动作,不该一快一慢。
714
+ 3) from 用 calc(100% - 2px) 而不是 100%:指针 2px 宽、以 left 为中心线,100% 会有一半被裁掉
715
+ (2px 与组件里的 inset 是同一个数,改一处必须两处一起改)。 */
716
+ .balance-footer__timeline-pointer--midnight{animation:balance-ptr-midnight 620ms linear}
717
+ @keyframes balance-ptr-midnight{from{left:calc(100% - 2px)}to{left:var(--balance-ptr-to,2px)}}
704
718
  /* ── 侧栏入口的红点 + 未读高亮 ─────────────────────────────────────────── */
705
719
  .balance-panel-icon{position:relative;display:inline-flex;align-items:center;justify-content:center}
706
720
  /* 未读时图标本身染成品牌色,比周围灰图标更跳 */
@@ -2622,7 +2636,7 @@ const CN_CALENDAR_SOURCES = [
2622
2636
  // ─── 时段刻度条:色带固定 = 一整天,指针随时刻从左走到右 ────────────────
2623
2637
  // 轨道铺满当天 00:00 → 次日 00:00 的时段色带(不滚动),指针位置 = 现在时刻在当天的比例。
2624
2638
  // 指针每秒前进一次(pointerNow 独立节拍),CSS transition:left 1s linear 补成连续滑动;
2625
- // 跨零点那一帧用 --snap 关掉过渡,直接落到新一天的起点。
2639
+ // 稳态每分钟对齐一次直接落位;**跨零点**那一拍挂 --midnight,从右端扫回左端(见那条 CSS)。
2626
2640
  const DAY_MS = 24 * 3600000;
2627
2641
  /** 当天 00:00(北京时间)的毫秒时间戳。色带、指针、跨零点判定共用同一个基准。 */
2628
2642
  function dayStartOf(now) {
@@ -2632,6 +2646,16 @@ const CN_CALENDAR_SOURCES = [
2632
2646
  function pointerPercent(now) {
2633
2647
  return ((now - dayStartOf(now)) / DAY_MS) * 100;
2634
2648
  }
2649
+ /** 跨零点判定:返回这一拍所属的那一天 + 要不要「从右端扫回左端」。
2650
+ *
2651
+ * 只有**往前**跨天才扫(2026-11-02 用户要求)。时钟被调回去(NTP 校时 / 手动改系统时间 /
2652
+ * 换时区导致 dayStart 变小)就照旧直接落位 —— 那种情况下右→左的扫动没有意义,
2653
+ * 反而会让人以为时间真的走完了一天。
2654
+ * 一次跨多天(机器睡眠 / 笔记本合盖过夜)也只扫一次,不连播。 */
2655
+ function pointerSweepPlan(prevDayStart, now) {
2656
+ const dayStart = dayStartOf(now);
2657
+ return { dayStart, sweep: dayStart > prevDayStart };
2658
+ }
2635
2659
  /** 生成刻度条:当天色带渐变 + 时段文字 + 指针位置。
2636
2660
  * @returns {{ gradient: string, pointerPct: number }} */
2637
2661
  // 纯函数结果缓存:buildTimeline(now) 完全由 now 决定(内部 currentPeriod 都显式传了 t),
@@ -3972,12 +3996,16 @@ function TimelinePointer() {
3972
3996
  const expired = Date.now() - PLUGIN_LOADED_AT > POINTER_INTRO_MAX_AGE_MS;
3973
3997
  const wantIntro = !pointerIntroDone && !expired;
3974
3998
  // 排队(2026-11-02 用户要求「指针的动画排队 插件加载完再开始」):
3975
- // 闸门还没开就先挂 --pending(opacity:0)待在终点,等 loadAnimDoneAt() 到了再挂 --intro
3976
- // 从 3px 滑过来。注意**不能**直接挂 --intro 挂着 CSS 动画等它 —— 那动画是从插入时刻起跑的,
3977
- // 不存在"延迟起播"这回事;而先显示终点位置又会看得见闪一下,所以中间需要这个隐形态。
3999
+ // 闸门还没开就先挂 --pending 待在**0 点**,等 loadAnimDoneAt() 到了再挂 --intro
4000
+ // 从 3px 滑到当前时段。
4001
+ // ⚠️ 注意**不能**直接挂 --intro 挂着 CSS 动画等它 —— 那动画是从插入时刻起跑的,
4002
+ // 不存在"延迟起播"这回事。
4003
+ // ⚠️ 也**不能**像原来那样「待在终点 + 不可见」:用户 2026-11-02 第二十六轮要求
4004
+ // 「指针全程不要消失在时段条上」,所以待命位置必须是 0 点、而且看得见 —— 闸门一开
4005
+ // 顺着同一个点往右滑(keyframes from:3px 正好等于 0 点的落点),全程连续、不闪不消失。
3978
4006
  const waiting = wantIntro && Date.now() < loadAnimDoneAt();
3979
4007
  return {
3980
- pct: pointerPercent(Date.now()),
4008
+ pct: waiting ? 0 : pointerPercent(Date.now()),
3981
4009
  intro: wantIntro && !waiting,
3982
4010
  pending: waiting,
3983
4011
  };
@@ -3995,10 +4023,19 @@ function TimelinePointer() {
3995
4023
  const scheduleIdle = () => {
3996
4024
  idleTimer = setTimeout(tick, idleIn(Date.now()));
3997
4025
  };
4026
+ // 上一拍所属的那一天(北京时间 00:00 起点)。挂载时初始化 → 打开页面那一刻不会误播扫回动画。
4027
+ let lastDayStart = dayStartOf(Date.now());
4028
+ // 跨零点的次数,兼作 span 的 key:每次跨天都 +1 让节点重挂,CSS animation 才会重新起播
4029
+ // (只靠 class 的 true→false→true 在「一次睡过好几天」时会漏掉一次重播)。
4030
+ let sweepSeq = 0;
3998
4031
  function tick() {
3999
- // 稳态:不带动画直接落位(每分钟才动 0.069%,跳过去看不出来),
4000
- // 下一拍对齐到下一个整分钟。跨零点也走这里,不会反向滑回去。
4001
- setView({ pct: pointerPercent(Date.now()), intro: false, pending: false });
4032
+ // 稳态:不带动画直接落位(每分钟才动 0.069%,跳过去看不出来),下一拍对齐到下一个整分钟。
4033
+ // 跨零点例外:那一拍带上 sweep,指针从右端扫回左端(见 CSS 的 --midnight)。
4034
+ const now = Date.now();
4035
+ const plan = pointerSweepPlan(lastDayStart, now);
4036
+ lastDayStart = plan.dayStart;
4037
+ if (plan.sweep) sweepSeq += 1;
4038
+ setView({ pct: pointerPercent(now), intro: false, pending: false, sweep: sweepSeq });
4002
4039
  scheduleIdle();
4003
4040
  }
4004
4041
  /** 闸门开:把落点按「现在」重算一次(等闸门这几百毫秒里时刻在走),再挂 --intro 起播。 */
@@ -4028,20 +4065,30 @@ function TimelinePointer() {
4028
4065
  // 依赖故意为空:只在挂载时读一次初值,之后由 CSS animation + 分钟对齐自己跑。
4029
4066
  // eslint-disable-next-line react-hooks/exhaustive-deps
4030
4067
  }, []);
4031
- // 刻度两端各留 3px 余量:指针 2px 宽、margin-left 让它以 left 为中心线,直接贴 0%/100%
4068
+ // 刻度两端各留 2px 余量:指针 2px 宽、margin-left 让它以 left 为中心线,直接贴 0%/100%
4032
4069
  // 会有一半被父级 overflow 裁掉,看着就像指针跑到轨道外面去了。
4033
- // 把 [0,100] 线性压进 [3px, 100% - 3px]:中心线 = inset + (p/100) × (宽 - 2 × inset),
4070
+ // 把 [0,100] 线性压进 [2px, 100% - 2px]:中心线 = inset + (p/100) × (宽 - 2 × inset),
4034
4071
  // 展开成 calc 就是「p% + inset px - (p/100) × 2 × inset px」。
4072
+ // ⚠️ 2026-11-02 第二十七轮:3px → 2px(用户「指针的0点往左一个像素吧」)。
4073
+ // `inset` 与两条 keyframes 的端点(`balance-ptr-in{from:2px}` / `balance-ptr-midnight{from:calc(100% - 2px)}`)
4074
+ // **必须同值**:差 1px 的话「待命 0 点 → 入场起跳」和「跨零点扫回起点」都会当场跳一下。
4035
4075
  const pct = view.pct;
4036
- const inset = 3;
4076
+ const inset = 2;
4037
4077
  const shift = inset - (pct / 100) * 2 * inset;
4038
4078
  const pos = "calc(" + pct.toFixed(4) + "% + " + shift.toFixed(2) + "px)";
4079
+ // 跨零点扫回:次数兼作 key(每次跨天都重挂,animation 才会重播)。
4080
+ // 入场 / 隐身排队期间不挂 —— 那两个动作优先,别在首屏那一刻抢同一根竖条。
4081
+ const sweepSeq = view.sweep || 0;
4082
+ const sweepClass =
4083
+ !view.intro && !view.pending && sweepSeq > 0 ? " balance-footer__timeline-pointer--midnight" : "";
4039
4084
  return jsx.jsx("span", {
4040
- className: view.intro
4041
- ? "balance-footer__timeline-pointer balance-footer__timeline-pointer--intro"
4042
- : view.pending
4043
- ? "balance-footer__timeline-pointer balance-footer__timeline-pointer--pending"
4044
- : "balance-footer__timeline-pointer",
4085
+ key: "pointer-" + sweepSeq,
4086
+ className:
4087
+ (view.intro
4088
+ ? "balance-footer__timeline-pointer balance-footer__timeline-pointer--intro"
4089
+ : view.pending
4090
+ ? "balance-footer__timeline-pointer balance-footer__timeline-pointer--pending"
4091
+ : "balance-footer__timeline-pointer") + sweepClass,
4045
4092
  // left 给稳态用;--balance-ptr-to 是 keyframes 的终点(两者取值相同)。
4046
4093
  style: { left: pos, "--balance-ptr-to": pos },
4047
4094
  });
package/lib/index.js CHANGED
@@ -1077,7 +1077,7 @@ function formatBalance(balance) {
1077
1077
  // | { status:"failed" } (网络失败;官方明确“失败绝不变成 0 余额”)
1078
1078
  // client 是 AccountClientMetadata(version / locale / timezoneOffsetSeconds),
1079
1079
  // 缺字段会在平台侧组装请求头时抛错,所以三个字段都要给。
1080
- const PLUGIN_VERSION = "2.1.8";
1080
+ const PLUGIN_VERSION = "2.1.9";
1081
1081
 
1082
1082
  /** 斜杠命令名(2026-10-31 定案:用带作者后缀的全名,避免和别的余额插件撞车,也不设备用名)。
1083
1083
  * ⚠️ DSH 的 COMMAND_NAME = /^[a-z][a-z0-9_-]*$/u —— **只允许小写**。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "balance-dsh",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "在 DeepSeek Harness 中显示 DeepSeek 账户余额和当前会话 token/费用消耗(含高峰/空闲峰谷计费)。仅支持 DeepSeek 官方模型与账号,暂不支持其他大模型。",
5
5
  "author": "Rannist",
6
6
  "type": "module",