@xixka/dsh-hub 0.2.1-rc.11 → 0.2.1-rc.12
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/jet-hub.js +752 -1108
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/lib/llm-adapter.d.ts.map +1 -1
- package/lib/llm-adapter.js +131 -7
- package/lib/llm-adapter.js.map +1 -1
- package/lib/lobsterai-adapter.d.ts.map +1 -1
- package/lib/lobsterai-adapter.js +54 -15
- package/lib/lobsterai-adapter.js.map +1 -1
- package/lib/opencode-adapter.d.ts +27 -0
- package/lib/opencode-adapter.d.ts.map +1 -1
- package/lib/opencode-adapter.js +57 -8
- package/lib/opencode-adapter.js.map +1 -1
- package/lib/opencode-bun-tls.d.ts +103 -0
- package/lib/opencode-bun-tls.d.ts.map +1 -0
- package/lib/opencode-bun-tls.js +196 -0
- package/lib/opencode-bun-tls.js.map +1 -0
- package/lib/opencode-messages.d.ts +0 -19
- package/lib/opencode-messages.d.ts.map +1 -1
- package/lib/opencode-messages.js +30 -33
- package/lib/opencode-messages.js.map +1 -1
- package/lib/opencode-official-prompt.d.ts +62 -0
- package/lib/opencode-official-prompt.d.ts.map +1 -0
- package/lib/opencode-official-prompt.js +119 -0
- package/lib/opencode-official-prompt.js.map +1 -0
- package/lib/opencode-official-tools.d.ts +27 -0
- package/lib/opencode-official-tools.d.ts.map +1 -0
- package/lib/opencode-official-tools.js +340 -0
- package/lib/opencode-official-tools.js.map +1 -0
- package/lib/opencode-product.d.ts.map +1 -1
- package/lib/opencode-product.js +3 -2
- package/lib/opencode-product.js.map +1 -1
- package/lib/opencode-stream.d.ts.map +1 -1
- package/lib/opencode-stream.js +8 -7
- package/lib/opencode-stream.js.map +1 -1
- package/lib/provider-http-pool.d.ts +14 -0
- package/lib/provider-http-pool.d.ts.map +1 -0
- package/lib/provider-http-pool.js +105 -0
- package/lib/provider-http-pool.js.map +1 -0
- package/lib/raccoon-adapter.d.ts.map +1 -1
- package/lib/raccoon-adapter.js +115 -17
- package/lib/raccoon-adapter.js.map +1 -1
- package/package.json +3 -3
package/lib/client/jet-hub.js
CHANGED
|
@@ -1108,132 +1108,40 @@ var STYLES = `
|
|
|
1108
1108
|
.dim-jh-zcDialog .dim-jh-zcProvider { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; font-size: 13px; }
|
|
1109
1109
|
.dim-jh-zcDialogActions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
1110
1110
|
|
|
1111
|
-
/* ──
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
*
|
|
1146
|
-
* 胶囊本身是**内容自适应**的:宽度由实际文字撑开,短内容就短
|
|
1147
|
-
* (Cline • 5积分 仅 93px),不会有固定留白。下面的 max-width 只在
|
|
1148
|
-
* 内容**过长**时兜底,防止挤压右侧的模型选择器。
|
|
1149
|
-
*
|
|
1150
|
-
* ⚠️ 2026-10-03 上限从 150px 提到 **216px**(用户报障「供应商名字显示不完整」
|
|
1151
|
-
* 之后又提了一次)。两次报障、同一条链路的两个不同成因:
|
|
1152
|
-
* 1. **数字被截**(第一次):整句塞进一个 overflow:hidden 的 span,省略号从右往左
|
|
1153
|
-
* 吃掉了余额。修法是**结构**(拆成可独立收缩的 span,见 badge-model.js 的
|
|
1154
|
-
* readingOf 与 usage-badge.js 的三段式渲染);
|
|
1155
|
-
* 2. **渠道名被截**(第二次):结构修好后,186px 仍不够长渠道名 + 长余额,
|
|
1156
|
-
* 于是省略号落到**名字**上(用户截图:CodeArts (华为…)。216px 解决它。
|
|
1157
|
-
*
|
|
1158
|
-
* **216 是量出来的,不是拍的**:实测 13 个渠道展示名 × 10 种现实读数
|
|
1159
|
-
* (含 123456.78积分 / 9499.84积分 / 94.54MToken / 0积分)共 130 组,
|
|
1160
|
-
* 需要的最宽度是 **209.34px**(WorkBuddy (国际版) • 123456.78积分),
|
|
1161
|
-
* 216px 全部装得下且留 6.7px 余量(字体回退时字宽会变)。
|
|
1162
|
-
*
|
|
1163
|
-
* ⚠️ **上限不能再往上放**:实测把上限放到「无上限」时,极窄 composer(220px)
|
|
1164
|
-
* 下胶囊会**溢出容器 8.3px** —— 那正是 2026-10-02「模型选择器图标被挤没」
|
|
1165
|
-
* 的形态。内容自适应 + 合理上限,两者缺一不可。
|
|
1166
|
-
* 兜底退化顺序:超长时**渠道名**先出省略号,**余额一个字都不会少**
|
|
1167
|
-
* (.dim-jh-badgeReading 是 flex: none)。
|
|
1168
|
-
*
|
|
1169
|
-
* ⚠️ button 元素**本来就是 border-box**(UA 默认样式表),故下面的 box-sizing
|
|
1170
|
-
* 是**显式写出**(防止哪天元素换成 span/div 时语义悄悄变成内容盒),不是修复。
|
|
1171
|
-
* ⚠️⚠️ 本段注释里**不能出现反引号**(本文件整体是 JS 模板字符串,会提前终止)。
|
|
1172
|
-
* ② 容器再窄时(< 720px,媒体查询挂在**全局宽度**上:composer 宽度受
|
|
1173
|
-
* 侧栏影响,用容器查询无法表达「右侧还剩多少」)**只留状态点**,
|
|
1174
|
-
* 文字与 chevron 全部隐藏 —— 此时代理器优先级让给模型选择器。 */
|
|
1175
|
-
/* ⚠️ flex: 0 1 auto(而非 none):胶囊自身也要能收缩。它是 flex: none 时
|
|
1176
|
-
宽度只由 max-width 兜底,而 max-width 只在**内容超标**时生效 —— 容器更窄时
|
|
1177
|
-
它会连同右侧模型选择器一起溢出。允许收缩后,空间不足时胶囊与选择器一起让位,
|
|
1178
|
-
且胶囊内部退化是有序的(先名字出省略号,数字最后才动)。 */
|
|
1179
|
-
.dim-jh-badge { position: relative; display: flex; align-items: center; flex: 0 1 auto; min-width: 0; }
|
|
1180
|
-
/* ⚠️ box-sizing 是**显式写出**的,不是修复:button 的 UA 默认样式表本就是
|
|
1181
|
-
border-box(实测 offsetWidth 与 max-width 相等)。写上它只为在元素类型被改
|
|
1182
|
-
(span/div 默认是 content-box)时语义不悄悄漂移 —— 那种情况下 max-width 会从
|
|
1183
|
-
「占位宽度」变成「内容宽度」,胶囊会突然变宽 19px 而这行代码看着毫无变化。 */
|
|
1184
|
-
.dim-jh-badgeBtn { box-sizing: border-box; display: flex; align-items: center; gap: 5px; max-width: 216px; min-width: 0; padding: 2px 9px; border: .5px solid var(--dsw-alias-border-l2); border-radius: 999px; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-secondary); font: inherit; font-size: 11px; line-height: 1.5; cursor: pointer; white-space: nowrap; font-variant-numeric: tabular-nums; transition: background .15s ease, color .15s ease, border-color .15s ease; }
|
|
1185
|
-
.dim-jh-badgeBtn:hover { background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); }
|
|
1186
|
-
.dim-jh-badgeBtn[aria-expanded="true"] { background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); border-color: color-mix(in srgb, #1677ff 45%, var(--dsw-alias-border-l2)); }
|
|
1187
|
-
/* 聚合「待首次请求」占位胶囊(用户报障 2026-10-08:「也没胶囊了?」)。
|
|
1188
|
-
⚠️ 刻意与 .dim-jh-badgeBtn **外观一致但不共用类名**:那个类名带 cursor:pointer
|
|
1189
|
-
与 :hover 反馈,而这里没有任何可点的东西(无历史 ⇒ 没有余额可展开)。
|
|
1190
|
-
给一个点了没反应的按钮比没有按钮更糟。
|
|
1191
|
-
⚠️ 宽度口径与 .dim-jh-badgeBtn 同步(gap 5px / padding 2px 9px / 字号 11px):
|
|
1192
|
-
两者会在同一位置交替出现(首次请求成功后换成真胶囊),尺寸不一致会看到跳动。 */
|
|
1193
|
-
.dim-jh-badgePending { display: inline-flex; align-items: center; gap: 5px; max-width: 216px; min-width: 0; padding: 2px 9px; border: .5px solid var(--dsw-alias-border-l2); border-radius: 999px; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 1.5; white-space: nowrap; }
|
|
1194
|
-
.dim-jh-badgePending > span:last-child { overflow: hidden; text-overflow: ellipsis; }
|
|
1195
|
-
/* 三段式文本容器:渠道名 + 分隔符 + 读数。
|
|
1196
|
-
⚠️ 必须是 flex 容器,两个文本子项才能各自独立收缩(这正是「数字不被截」的前提)。 */
|
|
1197
|
-
.dim-jh-badgeText { display: flex; align-items: center; min-width: 0; }
|
|
1198
|
-
/* ⚠️ 让位顺序:中段说明(999) → 渠道名(99) → 读数(none,**不参与收缩**)。
|
|
1199
|
-
收缩量按 flex-shrink × flex-basis 加权分配,999 与 99 相差一个数量级,
|
|
1200
|
-
故「包名先走、渠道名其次」,读数一个字都不会少。
|
|
1201
|
-
flex-grow 一律为 0:胶囊是内容自适应宽度,任何 grow 都只会让它在宽容器里虚胖。
|
|
1202
|
-
min-width:0 是省略号生效的前提(flex 子项默认 min-width:auto,会撑破 max-width)。 */
|
|
1203
|
-
.dim-jh-badgeName { flex: 0 99 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1204
|
-
/* 分隔符「•」:定宽不收缩,两侧间距由 margin 给。
|
|
1205
|
-
⚠️ 这里的 3px **不能**换成前后空格:flex 容器把 span 之间只含空白的文本节点
|
|
1206
|
-
渲染成**零宽**(实测 gap=0,节点还在但看不见),空格会静默消失。
|
|
1207
|
-
带空格的那份写法(BADGE_SEP = ' • ')只用于 title / aria-label 那句整文。 */
|
|
1208
|
-
.dim-jh-badgeSep { flex: none; margin: 0 3px; }
|
|
1209
|
-
/* 中段说明(只有套餐模式有值,如包名 Free Plan Subscription)。
|
|
1210
|
-
⚠️ 收缩权重**最大**(999):它比渠道名更该让位 —— 包名多为样板字、且长,
|
|
1211
|
-
而用户认得出自己选的渠道。
|
|
1212
|
-
⚠️ 它被压到 0 宽时(内容过长)该节点仍在,会留下一个「悬空的分隔符」;
|
|
1213
|
-
这在胶囊这一行是可接受的(完整文案在 title 与弹窗里),故不额外做条件渲染。 */
|
|
1214
|
-
.dim-jh-badgeDetail { flex: 0 999 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1215
|
-
/* ⚠️⚠️ 读数必须 flex: none(**完全不收缩**),不能写 flex: 0 1 auto。
|
|
1216
|
-
这是第二处、也是更隐蔽的一处「数字被截」成因,**靠截图才发现**:
|
|
1217
|
-
|
|
1218
|
-
收缩量按 flex-shrink × flex-basis 加权分配,读数那一份虽小却**不为零** ——
|
|
1219
|
-
实测读数被分到 0.77px 的收缩(getBoundingClientRect 宽 78.23 / 内容宽 79)。
|
|
1220
|
-
而 text-overflow: ellipsis 的触发条件是 scrollWidth > clientWidth,
|
|
1221
|
-
**亚像素级的收缩就足以命中** ⇒ 最后一个字被换成「…」,
|
|
1222
|
-
视觉上和「整段被截」一样严重。
|
|
1223
|
-
|
|
1224
|
-
⚠️ 更坑的是**量不出来**:clientWidth 取整,53.97 报成 54,
|
|
1225
|
-
于是 scrollWidth > clientWidth 判为 false —— 我用它写的「数字是否完整」
|
|
1226
|
-
断言一路全绿,而截图里明明白白写着「347.87积…」。
|
|
1227
|
-
教训:判断省略号要看**截图**或用小数宽度(getBoundingClientRect),
|
|
1228
|
-
不能用取整后的 clientWidth。
|
|
1229
|
-
|
|
1230
|
-
⚠️ 类名刻意**不叫 .dim-jh-badgeValue**:那个名字已被弹窗读数占用,且那条规则
|
|
1231
|
-
(font-weight:600)排在样式表更后面 —— 同名会让胶囊数字被静默加粗。
|
|
1232
|
-
|
|
1233
|
-
⇒ 读数恒定完整;全部收缩由 .dim-jh-badgeDetail(999) 与 .dim-jh-badgeName(99)
|
|
1234
|
-
承担,两者最坏缩到 0 也放得下(读数最宽约 97px + 分隔符与内边距 ≈ 131px
|
|
1235
|
-
< 186px 上限)。 */
|
|
1236
|
-
.dim-jh-badgeReading { flex: none; min-width: 0; white-space: nowrap; }
|
|
1111
|
+
/* ── 积分用量(侧边栏板块,2026-10-29 迁自会话输入区徽标) ────────────────
|
|
1112
|
+
板块结构(usage-panel.js):页面标题 → 渠道选择器(chips)→ 用量卡片
|
|
1113
|
+
(usage-badge.js 的 .dim-jh-usageCard;卡片内部沿用原浮层的 .dim-jh-badge*
|
|
1114
|
+
系列与 .dim-jh-quotaBar 进度条,几何口径未动 —— 见下方各条)。
|
|
1115
|
+
⚠️ 原胶囊(.dim-jh-badge / .dim-jh-badgeBtn / .dim-jh-badgeText…)与浮层
|
|
1116
|
+
(.dim-jh-badgePop 及其窄屏 fixed 块)已随会话徽标一并删除:卡片是普通
|
|
1117
|
+
文档流里的块,不存在「定位退化撑坏宿主布局」的那类风险。
|
|
1118
|
+
⚠️ 本段注释里**不能出现反引号**(本文件整体是 JS 模板字符串,会提前终止)。 */
|
|
1119
|
+
.dim-jh-usagePanel { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
|
|
1120
|
+
.dim-jh-usageHead { display: flex; flex-direction: column; gap: 0; }
|
|
1121
|
+
.dim-jh-usageTitle { font-size: 15px; font-weight: 600; line-height: 22px; color: var(--dsw-alias-label-primary); }
|
|
1122
|
+
.dim-jh-usageSub { margin-top: 4px; font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); }
|
|
1123
|
+
/* 渠道选择器:换行排列的 chips。本仓库无 select 先例,按钮组 + aria-pressed
|
|
1124
|
+
与偏好分段控件(.dim-jh-badgePref)同款做法。 */
|
|
1125
|
+
.dim-jh-usageRail { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
1126
|
+
.dim-jh-usageChip { box-sizing: border-box; padding: 3px 10px; border: .5px solid var(--dsw-alias-border-l2); border-radius: 999px; background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-secondary); font: inherit; font-size: 11px; line-height: 1.5; white-space: nowrap; cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease; }
|
|
1127
|
+
.dim-jh-usageChip:hover { background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); }
|
|
1128
|
+
.dim-jh-usageChip[aria-pressed="true"] { border-color: color-mix(in srgb, #1677ff 45%, var(--dsw-alias-border-l2)); background: color-mix(in srgb, #1677ff 10%, var(--dsw-alias-bg-layer-2)); color: var(--dsw-alias-brand-primary); font-weight: 600; }
|
|
1129
|
+
/* 用量卡片:几何口径沿原浮层(宽 280px → 面板里放宽到 480px 上限,字号与
|
|
1130
|
+
节距不动)。flex 列无 gap —— 节与节之间的间距由 .dim-jh-badgeSection 的
|
|
1131
|
+
margin-top 提供(与原 .dim-jh-badgePop 完全同款,不要在这里另加 gap)。 */
|
|
1132
|
+
.dim-jh-usageCard { width: min(480px, 100%); display: flex; flex-direction: column; padding: 9px 12px 12px; border: .5px solid var(--dsw-alias-border-l2); border-radius: 11px; background: var(--dsw-alias-bg-layer-1); box-shadow: 0 1px 2px rgba(0, 0, 0, .06); text-align: left; white-space: normal; }
|
|
1133
|
+
/* 卡片头的渠道名:.dim-jh-badgeTitle 的 max-width:118px 是给 280px 浮层头部
|
|
1134
|
+
量的;面板卡片放宽到 480px,且 auto 渠道名更长(含实际渠道/倍率/倒计时),
|
|
1135
|
+
故放宽上限并允许收缩出省略号(完整文案在 title 悬浮提示里)。 */
|
|
1136
|
+
.dim-jh-usageCard .dim-jh-badgeTitle { flex: 0 1 auto; max-width: none; }
|
|
1137
|
+
/* 读数行:原折叠胶囊的读数迁居后常驻在卡片头部下方(面板没有折叠态)。
|
|
1138
|
+
字号比正文大一档 + 半粗 —— 它是整张卡片的结论行。
|
|
1139
|
+
data-tone 跟头部状态点是同一个值(badgeView 的 tone)。 */
|
|
1140
|
+
.dim-jh-usageReading { display: flex; align-items: baseline; gap: 6px; margin: 2px 0 1px; }
|
|
1141
|
+
.dim-jh-usageReadingValue { font-size: 15px; font-weight: 600; line-height: 22px; font-variant-numeric: tabular-nums; color: var(--dsw-alias-label-primary); }
|
|
1142
|
+
.dim-jh-usageReadingValue[data-tone="warn"] { color: var(--dsw-alias-state-warn-primary); }
|
|
1143
|
+
.dim-jh-usageReadingValue[data-tone="error"] { color: var(--dsw-alias-state-error-primary); }
|
|
1144
|
+
.dim-jh-usageReadingValue[data-tone="muted"] { color: var(--dsw-alias-label-secondary); font-weight: 500; }
|
|
1237
1145
|
/* 「这个读数不完整」的标记(合计少算了账号时才出现),排在读数**之后**。
|
|
1238
1146
|
⚠️ 必须与读数同级 flex: none:它是**补语**,被省略号吃掉就等于没标 —— 而它要
|
|
1239
1147
|
提醒的恰恰是「别把这个数字当真」,看不见比不标更糟。
|
|
@@ -1242,22 +1150,10 @@ var STYLES = `
|
|
|
1242
1150
|
字号小一档并压紧行高,让它读起来像角标而不是读数的一部分。 */
|
|
1243
1151
|
.dim-jh-badgeWarn { flex: none; font-size: 10px; line-height: 1; color: var(--dsw-alias-state-warn-primary); cursor: help; }
|
|
1244
1152
|
|
|
1245
|
-
/* ② 窄屏收敛:只留状态点,文字与 chevron 让位给模型选择器。
|
|
1246
|
-
* 阈值 720px 是实测桌面版在 100% 缩放下「徽标 216px + 模型选择器 ≥ 240px」的临界值。
|
|
1247
|
-
* ⚠️⚠️ 本段的**位置**是功能性的,不要为了排版把它挪到 .dim-jh-badgeText 之前:
|
|
1248
|
-
* 它与 ".dim-jh-badgeText { display: flex }" 特异性相同(都是单个类),
|
|
1249
|
-
* 靠**源顺序**决定胜负 —— 一旦被排到前面,窄屏下 display:none 会被
|
|
1250
|
-
* 后面的 display:flex 覆盖,文字重新出现并挤压模型选择器(静默回归)。 */
|
|
1251
|
-
@media (max-width: 720px) { .dim-jh-badgeText, .dim-jh-badgeBtn > svg, .dim-jh-badgeBtn > .dim-jh-badgeChevron { display: none; } .dim-jh-badgeBtn { max-width: none; padding: 2px 6px; } }
|
|
1252
1153
|
.dim-jh-badgeDot { width: 5px; height: 5px; flex: none; border-radius: 999px; background: var(--dsw-alias-state-success-primary); }
|
|
1253
1154
|
.dim-jh-badgeDot[data-tone="warn"] { background: var(--dsw-alias-state-warn-primary); }
|
|
1254
1155
|
.dim-jh-badgeDot[data-tone="error"] { background: var(--dsw-alias-state-error-primary); }
|
|
1255
1156
|
.dim-jh-badgeDot[data-tone="muted"] { background: var(--dsw-alias-label-tertiary); }
|
|
1256
|
-
.dim-jh-badgePop { position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 40; width: 280px; max-width: min(280px, 86vw); max-height: 58vh; overflow-y: auto; display: flex; flex-direction: column; padding: 9px 10px 10px; border: .5px solid var(--dsw-alias-border-l2); border-radius: 11px; background: var(--dsw-alias-bg-layer-1); box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .14); text-align: left; white-space: normal; }
|
|
1257
|
-
/* 窄屏时徽标只留状态点,弹窗也随之收窄(否则它会盖住模型选择器)。
|
|
1258
|
-
* 宽度写 min() 而非媒体查询覆盖:弹窗是 absolute,媒体查询命中时按钮虽已
|
|
1259
|
-
* 收窄,但弹窗仍按 280px 渲染会显得与触发点不匹配。 */
|
|
1260
|
-
@media (max-width: 720px) { .dim-jh-badgePop { width: 220px; max-width: min(220px, 76vw); } }
|
|
1261
1157
|
.dim-jh-badgeHead { display: flex; align-items: center; gap: 5px; padding-bottom: 7px; }
|
|
1262
1158
|
.dim-jh-badgeTitle { flex: none; max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 600; color: var(--dsw-alias-label-primary); }
|
|
1263
1159
|
.dim-jh-badgeAt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }
|
|
@@ -1358,7 +1254,7 @@ var STYLES = `
|
|
|
1358
1254
|
/* 「展开其余 N 个账号」/「收起」:纯文字按钮,左对齐、不占满宽。
|
|
1359
1255
|
⚠️ 刻意**不复用** .dim-jh-badgeAction:那条规则是 flex:1 的实心按钮(用于签到),
|
|
1360
1256
|
放在明细列表下面会抢走视觉焦点 —— 用户要的是「明细可以收起来」,不是一个主操作。
|
|
1361
|
-
align-self: flex-start
|
|
1257
|
+
align-self: flex-start 是因为父容器(.dim-jh-usageCard)是 flex 列(默认 stretch)。 */
|
|
1362
1258
|
.dim-jh-badgeMore { align-self: flex-start; margin-top: 3px; padding: 1px 0; border: 0; background: none; font: inherit; font-size: 10px; line-height: 1.6; color: var(--dsw-alias-link); cursor: pointer; }
|
|
1363
1259
|
.dim-jh-badgeMore:hover { color: var(--dsw-alias-brand-primary); text-decoration: underline; }
|
|
1364
1260
|
|
|
@@ -1502,85 +1398,6 @@ var STYLES = `
|
|
|
1502
1398
|
.dim-jh-panel { padding: 14px 12px; }
|
|
1503
1399
|
}
|
|
1504
1400
|
|
|
1505
|
-
/* ── 窄屏:用量浮层(聊天输入区那枚徽标展开的面板)──
|
|
1506
|
-
POC(2026-10-17,报障「对话框的这里 ui 也需要适配」,附窄屏截图)。
|
|
1507
|
-
⚠️ 2026-10-20 审计整改:本块的**根因描述与 z-index 论证都被推翻重写**,
|
|
1508
|
-
下面每一段都标了「已订正」。原描述保留在末尾的「历史」段里供追溯。
|
|
1509
|
-
|
|
1510
|
-
## 已订正 ①:真正的失效机制不是「左边缘被裁」
|
|
1511
|
-
原描述说窄屏下浮层左边缘越出视口 89px。按宿主**真实** composer 布局复刻
|
|
1512
|
-
PRE-PR 形态实测:徽标在 .uV2eYG_trailing 里(该行有 margin-left: auto)
|
|
1513
|
-
⇒ 徽标靠**右**(VW=492 时 L=334 R=468),浮层向左展开 220px 得
|
|
1514
|
-
popL=248 ⇒ **完全没有越界**。原描述里 badge=134~151(靠左)在宿主布局中
|
|
1515
|
-
不成立。⇒ 本块的真实收益是「浮层改为视口锚定、不再跟着徽标跑,且更宽」,
|
|
1516
|
-
不是「修裁切」。
|
|
1517
|
-
|
|
1518
|
-
## 已订正 ②:真正需要 CSS 兜底的是**旧内核的 containing block 偏差**
|
|
1519
|
-
宿主 composer 工具行 .uV2eYG_row 带 container-type: inline-size,而徽标
|
|
1520
|
-
是它的后代。实测两引擎行为不同:
|
|
1521
|
-
- Chromium 154:inline-size containment 只含 inline 轴,**不**创建 fixed
|
|
1522
|
-
的 containing block ⇒ fixed 仍按视口锚定(符合规范);
|
|
1523
|
-
- Edge 122:把它当 layout containment ⇒ fixed 改为**相对该祖先**定位
|
|
1524
|
-
⇒ left/right/bottom 全变成「相对 composer 行」的坐标,浮层跟着 composer
|
|
1525
|
-
跑、宽度被压缩(实测 popLeft 24→124、width 476→344)。
|
|
1526
|
-
⇒ 只靠 CSS 无法在旧内核上做视口锚定,故窄屏浮层改由 usage-badge.js
|
|
1527
|
-
**portal 到 document.body**(body 之上无 containment 祖先,两引擎都按视口
|
|
1528
|
-
锚定)。本块仍保留全部承重声明作**兜底**:内联样式一旦被改坏,这里还能挡住。
|
|
1529
|
-
|
|
1530
|
-
## 已订正 ③:bottom 必须用宿主的 composer 高度变量,不能硬编码
|
|
1531
|
-
宿主用 ResizeObserver 把真实 composer 高度写进 --dsh-composer-height
|
|
1532
|
-
(dsh-client-ui-conversation 的 ConversationContent),其 CSS fallback 是
|
|
1533
|
-
**152px**(宿主三处都写 var(--dsh-composer-height,152px))。
|
|
1534
|
-
原实现硬编码 88px —— 实测 composer=152px 时浮层**压住输入区 64px**,并
|
|
1535
|
-
**盖住「用量」徽标按钮**(命中测试点到的不是按钮,是浮层内的 DIV)
|
|
1536
|
-
⇒ 用户点不到。改用变量后 gap=0、徽标可点(两引擎、多档 composer 高度均实测)。
|
|
1537
|
-
⚠️ 该变量能被浮层继承:CSS 变量沿 **DOM 祖先链**继承,与定位方式无关;
|
|
1538
|
-
portal 到 body 后 body 仍在 scroller 的**兄弟**位置?—— 不是,body 是共同祖先,
|
|
1539
|
-
故变量照样继承得到(已实测 popover 侧 getComputedStyle 读到 152px/220px)。
|
|
1540
|
-
|
|
1541
|
-
## 已订正 ④:z-index 的区间是 (1101, 3000),不是 (250, 1000)
|
|
1542
|
-
原论证的下限 250 只考虑了**外部外壳**(dsh-mobile),漏了**宿主自己**:
|
|
1543
|
-
- 宿主 79 处 z-index 里有 **6 处 1100**(chat 的 bRhRbq_panel、
|
|
1544
|
-
conversation 的 JObwrW_panel【composer 里的 ContextMeter,与徽标同一行】、
|
|
1545
|
-
model-selection 的 _7KE1Ra_menu【与徽标同一行的模型选择菜单】、
|
|
1546
|
-
plugin-manager、schedule ×2);
|
|
1547
|
-
- 另有 **3 处全屏 overlay**:attachment 1000、settings-general 1000、
|
|
1548
|
-
settings-account 1001(还有 onboarding 900)。
|
|
1549
|
-
浮层若取 300,上述任一出现就把浮层整块盖住。
|
|
1550
|
-
原上限 1000 的锚点 .dim-jh-loginOverlay 是**死规则**:全仓 className 用法
|
|
1551
|
-
0 命中、git 历史从未渲染过(只剩一条 CSS + 注释);且它与浮层**不在同一
|
|
1552
|
-
stacking context**(分属 settings 页树与 composer 树,两树中间的
|
|
1553
|
-
.dim-jh-page/.dim-jh-layout/.dim-jh-rail/.dim-jh-panel 全无 z-index)
|
|
1554
|
-
⇒ z-index 本就不可比。
|
|
1555
|
-
⇒ 改为按**真正同族**的 .dim-jh-modalOverlay(3000) 定上限,按宿主最高
|
|
1556
|
-
overlay(1001) 与 ContextMeter(1100) 定下限 ⇒ 取 **1200**((1101, 3000) 内)。
|
|
1557
|
-
另注:dsh-mobile 的 [data-shell-overlay] 恰好是 z-index:300(带 !important),
|
|
1558
|
-
原取值与它**完全相等** ⇒ 同层级时后出现的 DOM 胜出,不可预测;1200 也消除了这点。
|
|
1559
|
-
|
|
1560
|
-
⚠️ 本注释内**不得出现反引号**:本文件整体是模板字符串,反引号会提前闭合它
|
|
1561
|
-
(AGENTS.md 红线;本文件的 usage-badge-client.spec.ts 有专条用例逐块扫描注释)。
|
|
1562
|
-
|
|
1563
|
-
## 历史(已推翻,勿据此改回)
|
|
1564
|
-
原描述:根因是「VW=492 badge=134~151 pop=-89~151 L_OVER=true」;取 300 的
|
|
1565
|
-
理由是「下限 > 250 压过 dsh-mobile details、上限 < 1000 因为
|
|
1566
|
-
.dim-jh-loginOverlay 是 1000」;bottom 硬编码 88px。上述三处均已订正。 */
|
|
1567
|
-
@media (max-width: 720px) {
|
|
1568
|
-
.dim-jh-badgePop {
|
|
1569
|
-
position: fixed !important;
|
|
1570
|
-
left: 8px !important;
|
|
1571
|
-
right: 8px !important;
|
|
1572
|
-
top: auto !important;
|
|
1573
|
-
bottom: calc(env(safe-area-inset-bottom, 0px) + var(--dsh-composer-height, 152px)) !important;
|
|
1574
|
-
width: auto !important;
|
|
1575
|
-
max-width: none !important;
|
|
1576
|
-
/* ⚠️ 100dvh 而不是 100vh:移动端地址栏收放会让 100vh 与真实可视高度脱节。
|
|
1577
|
-
外加 max(120px, ...) 下限 —— 原写法在 vh<=140 时算出 0 或负值,实测
|
|
1578
|
-
vh=120 时 max-height 被压成 0px(浮层完全不可见却仍占位)、
|
|
1579
|
-
vh=60 时整块飞出屏幕上方。 */
|
|
1580
|
-
max-height: max(120px, calc(100dvh - 160px)) !important;
|
|
1581
|
-
z-index: 1200 !important;
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
1401
|
|
|
1585
1402
|
/* ── 插件详情页(plugins.bundle.config)的自有设置卡片 ──
|
|
1586
1403
|
|
|
@@ -13444,125 +13261,440 @@ function startCarrierContribution(options = {}) {
|
|
|
13444
13261
|
};
|
|
13445
13262
|
}
|
|
13446
13263
|
|
|
13447
|
-
// plugin-src/client/
|
|
13264
|
+
// plugin-src/client/panel-entry.js
|
|
13265
|
+
var React7 = __toESM(require("react"), 1);
|
|
13266
|
+
|
|
13267
|
+
// plugin-src/client/error-boundary.js
|
|
13448
13268
|
var React6 = __toESM(require("react"), 1);
|
|
13449
|
-
var
|
|
13269
|
+
var NO_ERROR = Symbol("jet-hub:no-error");
|
|
13270
|
+
function describeThrown(error) {
|
|
13271
|
+
try {
|
|
13272
|
+
if (error !== null && error !== void 0 && typeof error.message === "string" && error.message.length > 0) {
|
|
13273
|
+
return error.message;
|
|
13274
|
+
}
|
|
13275
|
+
} catch {
|
|
13276
|
+
}
|
|
13277
|
+
try {
|
|
13278
|
+
return String(error);
|
|
13279
|
+
} catch {
|
|
13280
|
+
return "(抛出值无法转为文本,请查看控制台)";
|
|
13281
|
+
}
|
|
13282
|
+
}
|
|
13283
|
+
function withErrorBoundary(Inner, options) {
|
|
13284
|
+
const label = options !== null && typeof options === "object" && typeof options.label === "string" && options.label.length > 0 ? options.label : "这个面板";
|
|
13285
|
+
class PanelErrorBoundary extends React6.Component {
|
|
13286
|
+
constructor(props) {
|
|
13287
|
+
super(props);
|
|
13288
|
+
this.state = { error: NO_ERROR };
|
|
13289
|
+
}
|
|
13290
|
+
static getDerivedStateFromError(error) {
|
|
13291
|
+
return { error };
|
|
13292
|
+
}
|
|
13293
|
+
componentDidCatch(error, info) {
|
|
13294
|
+
console.error(`[jet-hub] ${label}渲染失败,已拦住(页面其余部分继续可用):`, error, info?.componentStack);
|
|
13295
|
+
}
|
|
13296
|
+
render() {
|
|
13297
|
+
const error = this.state.error;
|
|
13298
|
+
if (error === NO_ERROR) return React6.createElement(Inner, this.props);
|
|
13299
|
+
const message = describeThrown(error);
|
|
13300
|
+
return React6.createElement(
|
|
13301
|
+
"div",
|
|
13302
|
+
{
|
|
13303
|
+
className: "dim-jh-probeNotice",
|
|
13304
|
+
"data-tone": "error",
|
|
13305
|
+
role: "alert",
|
|
13306
|
+
style: { margin: "16px" }
|
|
13307
|
+
},
|
|
13308
|
+
React6.createElement("div", null, `${label}渲染失败,已拦住 —— 其余页面仍可正常使用,不必重启。`),
|
|
13309
|
+
React6.createElement("div", { style: { marginTop: "6px", fontFamily: "monospace", fontSize: "12px" } }, message),
|
|
13310
|
+
// ⚠️ **必须给出可自我恢复的出路**(2026-10-25 审计 A3-2)。
|
|
13311
|
+
//
|
|
13312
|
+
// 本 fallback 是**粘性**的:没有 `key`、也没有 `componentDidUpdate`
|
|
13313
|
+
// 重置 ⇒ 同一实例一旦进 error 就永远显示 fallback(数据恢复了也不回来)。
|
|
13314
|
+
// 审计实测:数据恢复后仍显示 fallback,只有**新建实例**才恢复。
|
|
13315
|
+
//
|
|
13316
|
+
// 而用户其实**不必重启**:宿主 `SettingsPanel` 在 `open === false` 时整棵
|
|
13317
|
+
// 不挂载、`main` 是 keyed 槽 ⇒「关掉设置再打开」/「切走再切回」都能恢复。
|
|
13318
|
+
// 但**这条路径不可发现** —— 用户看到一块报错,不知道关掉再打开就能好。
|
|
13319
|
+
//
|
|
13320
|
+
// ⇒ 两件事:①给一个**就地重试**(`setState` 回 `NO_ERROR`,子树随即重挂载,
|
|
13321
|
+
// 比让用户摸索「关掉再打开」快得多);②把那条路径**写出来**当兜底。
|
|
13322
|
+
React6.createElement(
|
|
13323
|
+
"div",
|
|
13324
|
+
{ style: { marginTop: "8px" } },
|
|
13325
|
+
React6.createElement("button", {
|
|
13326
|
+
type: "button",
|
|
13327
|
+
className: "dim-jh-btn",
|
|
13328
|
+
onClick: () => {
|
|
13329
|
+
this.setState({ error: NO_ERROR });
|
|
13330
|
+
}
|
|
13331
|
+
}, "重试"),
|
|
13332
|
+
React6.createElement(
|
|
13333
|
+
"span",
|
|
13334
|
+
{ style: { marginLeft: "8px", opacity: 0.75 } },
|
|
13335
|
+
"也可以关掉这一节再重新打开(或切到别的页面再切回来)来恢复。"
|
|
13336
|
+
)
|
|
13337
|
+
),
|
|
13338
|
+
React6.createElement(
|
|
13339
|
+
"div",
|
|
13340
|
+
{ style: { marginTop: "6px" } },
|
|
13341
|
+
"这是插件的缺陷,不是你操作错了。把上面这行报错连同「当时点了什么」一起反馈即可。"
|
|
13342
|
+
)
|
|
13343
|
+
);
|
|
13344
|
+
}
|
|
13345
|
+
}
|
|
13346
|
+
PanelErrorBoundary.displayName = `withErrorBoundary(${Inner.displayName || Inner.name || "Component"})`;
|
|
13347
|
+
return PanelErrorBoundary;
|
|
13348
|
+
}
|
|
13450
13349
|
|
|
13451
|
-
// plugin-src/client/
|
|
13452
|
-
var
|
|
13453
|
-
var
|
|
13454
|
-
var
|
|
13455
|
-
var
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
if (resolved === AGGREGATE_PROVIDER_ID) return null;
|
|
13462
|
-
return resolved;
|
|
13350
|
+
// plugin-src/client/panel-entry-store.js
|
|
13351
|
+
var VALID_ENTRIES = ["sidebar", "settings"];
|
|
13352
|
+
var FALLBACK_ENTRY = "sidebar";
|
|
13353
|
+
var JET_HUB_PANEL_KEY = "jet-hub";
|
|
13354
|
+
var JET_HUB_SIDEBAR_ORDER = 20;
|
|
13355
|
+
var PANEL_ENTRY_READ_TIMEOUT_MS = 5e3;
|
|
13356
|
+
var PANEL_ENTRY_READ_ATTEMPTS = 3;
|
|
13357
|
+
var PANEL_ENTRY_RETRY_DELAY_MS = 200;
|
|
13358
|
+
function delay(ms) {
|
|
13359
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
13463
13360
|
}
|
|
13464
|
-
var
|
|
13465
|
-
var
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
return
|
|
13361
|
+
var entry = null;
|
|
13362
|
+
var readFailed = false;
|
|
13363
|
+
var inflight = null;
|
|
13364
|
+
var writeSeq = 0;
|
|
13365
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
13366
|
+
function normalize(raw) {
|
|
13367
|
+
return typeof raw === "string" && VALID_ENTRIES.includes(raw) ? raw : null;
|
|
13471
13368
|
}
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
subscription: "优先订阅",
|
|
13475
|
-
credits: "只看积分"
|
|
13476
|
-
});
|
|
13477
|
-
function normalizeBadgePreference(value) {
|
|
13478
|
-
return BADGE_PREFERENCES.includes(value) ? value : DEFAULT_BADGE_PREFERENCE;
|
|
13369
|
+
function panelEntry() {
|
|
13370
|
+
return entry;
|
|
13479
13371
|
}
|
|
13480
|
-
function
|
|
13481
|
-
|
|
13482
|
-
return quotaWindowsOf(list).slice(0, limit).map(([type, label, win]) => ({ type, label, percent: quotaPercentValue(win?.percentUsed) }));
|
|
13372
|
+
function panelEntryShowsSidebar() {
|
|
13373
|
+
return entry !== "settings";
|
|
13483
13374
|
}
|
|
13484
|
-
function
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
group.quotaWindows = group.quotaWindows ?? /* @__PURE__ */ new Map();
|
|
13506
|
-
if (line !== null) group.quotaLines.push(line);
|
|
13507
|
-
for (const pkg of Array.isArray(balance.packages) ? balance.packages : []) {
|
|
13508
|
-
if (!pkg) continue;
|
|
13509
|
-
const remaining = pkg.remaining;
|
|
13510
|
-
if (typeof remaining !== "number" || !Number.isFinite(remaining)) continue;
|
|
13511
|
-
group.quotaRemainings.push(remaining);
|
|
13512
|
-
const name2 = pkg.name || "未命名";
|
|
13513
|
-
const prev = group.quotaWindows.get(name2);
|
|
13514
|
-
if (prev === void 0 || remaining < prev) group.quotaWindows.set(name2, remaining);
|
|
13515
|
-
}
|
|
13375
|
+
function panelEntryShowsSettings() {
|
|
13376
|
+
return entry === "settings";
|
|
13377
|
+
}
|
|
13378
|
+
function panelEntryReadFailed() {
|
|
13379
|
+
return readFailed;
|
|
13380
|
+
}
|
|
13381
|
+
function subscribePanelEntry(listener) {
|
|
13382
|
+
listeners.add(listener);
|
|
13383
|
+
return () => {
|
|
13384
|
+
listeners.delete(listener);
|
|
13385
|
+
};
|
|
13386
|
+
}
|
|
13387
|
+
function publish(nextEntry, nextFailed) {
|
|
13388
|
+
if (entry === nextEntry && readFailed === nextFailed) return;
|
|
13389
|
+
entry = nextEntry;
|
|
13390
|
+
readFailed = nextFailed;
|
|
13391
|
+
for (const listener of [...listeners]) {
|
|
13392
|
+
try {
|
|
13393
|
+
listener();
|
|
13394
|
+
} catch (caught) {
|
|
13395
|
+
console.error("[jet-hub] 面板入口监听器抛错", caught);
|
|
13516
13396
|
}
|
|
13517
|
-
byUnit.set(unit, group);
|
|
13518
13397
|
}
|
|
13519
|
-
const groups = [...byUnit.values()].sort((a, b) => a.unit < b.unit ? -1 : a.unit > b.unit ? 1 : 0);
|
|
13520
|
-
return { groups, failedCount, okCount };
|
|
13521
13398
|
}
|
|
13522
|
-
function
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
for (const row of list) {
|
|
13526
|
-
const plan = row?.plan;
|
|
13527
|
-
if (!plan) continue;
|
|
13528
|
-
const unit = normalizeUnit(typeof plan.unit === "string" ? plan.unit : "");
|
|
13529
|
-
const key = `${String(plan.name)}\0${unit}`;
|
|
13530
|
-
const group = byKey.get(key) ?? {
|
|
13531
|
-
name: String(plan.name),
|
|
13532
|
-
unit,
|
|
13533
|
-
label: unitLabel(unit),
|
|
13534
|
-
remaining: 0,
|
|
13535
|
-
total: 0,
|
|
13536
|
-
accountCount: 0,
|
|
13537
|
-
deductionEndTime: void 0
|
|
13538
|
-
};
|
|
13539
|
-
group.remaining += Number(plan.remaining) || 0;
|
|
13540
|
-
group.total += Number(plan.total) || 0;
|
|
13541
|
-
group.accountCount += 1;
|
|
13542
|
-
const end = typeof plan.deductionEndTime === "number" && Number.isFinite(plan.deductionEndTime) ? plan.deductionEndTime : void 0;
|
|
13543
|
-
if (end !== void 0 && (group.deductionEndTime === void 0 || end < group.deductionEndTime)) {
|
|
13544
|
-
group.deductionEndTime = end;
|
|
13545
|
-
}
|
|
13546
|
-
byKey.set(key, group);
|
|
13399
|
+
function readSignal() {
|
|
13400
|
+
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") {
|
|
13401
|
+
return AbortSignal.timeout(PANEL_ENTRY_READ_TIMEOUT_MS);
|
|
13547
13402
|
}
|
|
13548
|
-
|
|
13403
|
+
if (typeof AbortController !== "function") return void 0;
|
|
13404
|
+
const controller = new AbortController();
|
|
13405
|
+
const timer = setTimeout(() => controller.abort(), PANEL_ENTRY_READ_TIMEOUT_MS);
|
|
13406
|
+
if (typeof timer === "object" && timer !== null && typeof timer.unref === "function") {
|
|
13407
|
+
timer.unref();
|
|
13408
|
+
}
|
|
13409
|
+
controller.signal?.addEventListener?.("abort", () => clearTimeout(timer), { once: true });
|
|
13410
|
+
return controller.signal;
|
|
13549
13411
|
}
|
|
13550
|
-
function
|
|
13551
|
-
|
|
13552
|
-
const
|
|
13553
|
-
const
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13412
|
+
function loadPanelEntry(rpcCall) {
|
|
13413
|
+
if (inflight !== null) return inflight;
|
|
13414
|
+
const seqAtStart = writeSeq;
|
|
13415
|
+
const task = (async () => {
|
|
13416
|
+
let lastError;
|
|
13417
|
+
for (let attempt = 1; attempt <= PANEL_ENTRY_READ_ATTEMPTS; attempt += 1) {
|
|
13418
|
+
try {
|
|
13419
|
+
const result = await rpcCall("panelEntry.get", {}, readSignal());
|
|
13420
|
+
if (writeSeq !== seqAtStart) return entry ?? FALLBACK_ENTRY;
|
|
13421
|
+
const next = normalize(result?.entry);
|
|
13422
|
+
if (next !== null) {
|
|
13423
|
+
publish(next, false);
|
|
13424
|
+
} else {
|
|
13425
|
+
publish(entry ?? FALLBACK_ENTRY, true);
|
|
13426
|
+
}
|
|
13427
|
+
return entry ?? FALLBACK_ENTRY;
|
|
13428
|
+
} catch (caught) {
|
|
13429
|
+
lastError = caught;
|
|
13430
|
+
if (writeSeq !== seqAtStart) return entry ?? FALLBACK_ENTRY;
|
|
13431
|
+
if (attempt >= PANEL_ENTRY_READ_ATTEMPTS) break;
|
|
13432
|
+
await delay(PANEL_ENTRY_RETRY_DELAY_MS * attempt);
|
|
13433
|
+
if (writeSeq !== seqAtStart) return entry ?? FALLBACK_ENTRY;
|
|
13434
|
+
}
|
|
13435
|
+
}
|
|
13436
|
+
console.warn(
|
|
13437
|
+
`[jet-hub] 读取面板入口偏好失败,按仅侧栏处理(已重试 ${PANEL_ENTRY_READ_ATTEMPTS - 1} 次)`,
|
|
13438
|
+
lastError
|
|
13439
|
+
);
|
|
13440
|
+
if (writeSeq === seqAtStart) publish(entry ?? FALLBACK_ENTRY, true);
|
|
13441
|
+
return entry ?? FALLBACK_ENTRY;
|
|
13442
|
+
})();
|
|
13443
|
+
inflight = task;
|
|
13444
|
+
const clear = () => {
|
|
13445
|
+
if (inflight === task) inflight = null;
|
|
13446
|
+
};
|
|
13447
|
+
void task.then(clear, clear);
|
|
13448
|
+
return task;
|
|
13449
|
+
}
|
|
13450
|
+
async function setPanelEntry(rpcCall, next) {
|
|
13451
|
+
const result = await rpcCall("panelEntry.set", { entry: next });
|
|
13452
|
+
const confirmed = normalize(result?.entry);
|
|
13453
|
+
if (confirmed === null) {
|
|
13454
|
+
throw new Error("面板入口偏好没有返回合法 entry");
|
|
13455
|
+
}
|
|
13456
|
+
writeSeq += 1;
|
|
13457
|
+
publish(confirmed, false);
|
|
13458
|
+
return confirmed;
|
|
13459
|
+
}
|
|
13460
|
+
|
|
13461
|
+
// plugin-src/client/panel-entry.js
|
|
13462
|
+
var JetHubPageForSettings = withErrorBoundary(JetHubPage, { label: "Jet Hub 设置页" });
|
|
13463
|
+
var JetHubPageForMain = withErrorBoundary(JetHubPage, { label: "Jet Hub 面板" });
|
|
13464
|
+
function JetHubSidebarIcon({ size }) {
|
|
13465
|
+
const px = typeof size === "number" && size > 0 ? size : 16;
|
|
13466
|
+
return React7.createElement(
|
|
13467
|
+
"svg",
|
|
13468
|
+
{
|
|
13469
|
+
width: px,
|
|
13470
|
+
height: px,
|
|
13471
|
+
viewBox: "0 0 16 16",
|
|
13472
|
+
fill: "none",
|
|
13473
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
13474
|
+
"aria-hidden": "true"
|
|
13475
|
+
},
|
|
13476
|
+
React7.createElement("path", {
|
|
13477
|
+
d: "M8 1.7 13.5 4.85v6.3L8 14.3 2.5 11.15v-6.3z",
|
|
13478
|
+
stroke: "currentColor",
|
|
13479
|
+
strokeWidth: 1.35,
|
|
13480
|
+
strokeLinejoin: "round"
|
|
13481
|
+
}),
|
|
13482
|
+
React7.createElement("circle", { cx: 8, cy: 8, r: 1.7, fill: "currentColor" })
|
|
13483
|
+
);
|
|
13484
|
+
}
|
|
13485
|
+
function JetHubMainPanel({ rpcCall }) {
|
|
13486
|
+
if (typeof rpcCall !== "function") return null;
|
|
13487
|
+
return React7.createElement(
|
|
13488
|
+
"div",
|
|
13489
|
+
{ className: "dim-jh-panelHost", "data-plugin": "@xixka/dsh-hub" },
|
|
13490
|
+
React7.createElement(JetHubPageForMain, { rpcCall })
|
|
13491
|
+
);
|
|
13492
|
+
}
|
|
13493
|
+
function registerJetHubPanelEntries(ctx, rpcCall) {
|
|
13494
|
+
ctx.slots.inject("main", () => ctx.slots.register({
|
|
13495
|
+
name: "main",
|
|
13496
|
+
key: JET_HUB_PANEL_KEY,
|
|
13497
|
+
inject: () => ({ rpcCall })
|
|
13498
|
+
}, JetHubMainPanel));
|
|
13499
|
+
let layout;
|
|
13500
|
+
ctx.inject(["layout"], (scoped) => {
|
|
13501
|
+
layout = scoped.layout;
|
|
13502
|
+
return () => {
|
|
13503
|
+
layout = void 0;
|
|
13504
|
+
};
|
|
13505
|
+
});
|
|
13506
|
+
const deselectIfActive = () => {
|
|
13507
|
+
try {
|
|
13508
|
+
if (layout?.panelInfo?.getSnapshot?.()?.activePanelId !== JET_HUB_PANEL_KEY) return;
|
|
13509
|
+
layout.selectPanel(null);
|
|
13510
|
+
} catch (caught) {
|
|
13511
|
+
console.warn("[jet-hub] 撤销侧栏入口时取消选中失败", caught);
|
|
13512
|
+
}
|
|
13513
|
+
};
|
|
13514
|
+
ctx.slots.inject("sidebar.panellist", () => {
|
|
13515
|
+
let stopRow;
|
|
13516
|
+
const sync = (visible) => {
|
|
13517
|
+
if (visible && stopRow === void 0) {
|
|
13518
|
+
stopRow = ctx.slots.register({
|
|
13519
|
+
name: "sidebar.panellist",
|
|
13520
|
+
id: JET_HUB_PANEL_KEY,
|
|
13521
|
+
order: JET_HUB_SIDEBAR_ORDER,
|
|
13522
|
+
label: () => "Jet Hub"
|
|
13523
|
+
}, JetHubSidebarIcon);
|
|
13524
|
+
return;
|
|
13525
|
+
}
|
|
13526
|
+
if (!visible && stopRow !== void 0) {
|
|
13527
|
+
const stop = stopRow;
|
|
13528
|
+
stopRow = void 0;
|
|
13529
|
+
stop();
|
|
13530
|
+
deselectIfActive();
|
|
13531
|
+
}
|
|
13532
|
+
};
|
|
13533
|
+
const unsubscribe = subscribePanelEntry(() => sync(panelEntryShowsSidebar()));
|
|
13534
|
+
sync(panelEntryShowsSidebar());
|
|
13535
|
+
let disposed = false;
|
|
13536
|
+
void loadPanelEntry(rpcCall).then(() => {
|
|
13537
|
+
if (!disposed) sync(panelEntryShowsSidebar());
|
|
13538
|
+
});
|
|
13539
|
+
return () => {
|
|
13540
|
+
disposed = true;
|
|
13541
|
+
unsubscribe();
|
|
13542
|
+
if (stopRow !== void 0) {
|
|
13543
|
+
const stop = stopRow;
|
|
13544
|
+
stopRow = void 0;
|
|
13545
|
+
stop();
|
|
13546
|
+
}
|
|
13547
|
+
};
|
|
13548
|
+
});
|
|
13549
|
+
ctx.slots.inject("settings.section", () => {
|
|
13550
|
+
let stopSection;
|
|
13551
|
+
const sync = (visible) => {
|
|
13552
|
+
if (visible && stopSection === void 0) {
|
|
13553
|
+
stopSection = ctx.slots.register({
|
|
13554
|
+
name: "settings.section",
|
|
13555
|
+
id: JET_HUB_PANEL_KEY,
|
|
13556
|
+
order: 50,
|
|
13557
|
+
label: () => "Jet Hub",
|
|
13558
|
+
inject: () => ({ rpcCall })
|
|
13559
|
+
}, JetHubPageForSettings);
|
|
13560
|
+
return;
|
|
13561
|
+
}
|
|
13562
|
+
if (!visible && stopSection !== void 0) {
|
|
13563
|
+
const stop = stopSection;
|
|
13564
|
+
stopSection = void 0;
|
|
13565
|
+
stop();
|
|
13566
|
+
}
|
|
13567
|
+
};
|
|
13568
|
+
const unsubscribe = subscribePanelEntry(() => sync(panelEntryShowsSettings()));
|
|
13569
|
+
sync(panelEntryShowsSettings());
|
|
13570
|
+
let disposed = false;
|
|
13571
|
+
void loadPanelEntry(rpcCall).then(() => {
|
|
13572
|
+
if (!disposed) sync(panelEntryShowsSettings());
|
|
13573
|
+
});
|
|
13574
|
+
return () => {
|
|
13575
|
+
disposed = true;
|
|
13576
|
+
unsubscribe();
|
|
13577
|
+
if (stopSection !== void 0) {
|
|
13578
|
+
const stop = stopSection;
|
|
13579
|
+
stopSection = void 0;
|
|
13580
|
+
stop();
|
|
13581
|
+
}
|
|
13582
|
+
};
|
|
13583
|
+
});
|
|
13584
|
+
}
|
|
13585
|
+
|
|
13586
|
+
// plugin-src/client/usage-panel.js
|
|
13587
|
+
var React9 = __toESM(require("react"), 1);
|
|
13588
|
+
|
|
13589
|
+
// plugin-src/client/usage-badge.js
|
|
13590
|
+
var React8 = __toESM(require("react"), 1);
|
|
13591
|
+
|
|
13592
|
+
// plugin-src/client/badge-model.js
|
|
13593
|
+
var BADGE_PREFERENCES = Object.freeze(["auto", "subscription", "credits"]);
|
|
13594
|
+
var DEFAULT_BADGE_PREFERENCE = "auto";
|
|
13595
|
+
var AUTO_PROVIDER_ID = "jet-hub-auto";
|
|
13596
|
+
var BADGE_SEP = " • ";
|
|
13597
|
+
var HOST_STALE_HINT = "插件宿主未加载最新版本,请重启 DSH 后重试";
|
|
13598
|
+
function describeBadgeError(error, fallback = "") {
|
|
13599
|
+
const message = typeof error?.message === "string" ? error.message : "";
|
|
13600
|
+
if (message.includes("unknown method")) return HOST_STALE_HINT;
|
|
13601
|
+
if (message.includes("unsupported provider")) return HOST_STALE_HINT;
|
|
13602
|
+
return message.length > 0 ? message : fallback;
|
|
13603
|
+
}
|
|
13604
|
+
var BADGE_PREFERENCE_LABELS = Object.freeze({
|
|
13605
|
+
auto: "自动",
|
|
13606
|
+
subscription: "优先订阅",
|
|
13607
|
+
credits: "只看积分"
|
|
13608
|
+
});
|
|
13609
|
+
function normalizeBadgePreference(value) {
|
|
13610
|
+
return BADGE_PREFERENCES.includes(value) ? value : DEFAULT_BADGE_PREFERENCE;
|
|
13611
|
+
}
|
|
13612
|
+
function windowPreview(windows, limit = 2) {
|
|
13613
|
+
const list = Array.isArray(windows) ? windows : [];
|
|
13614
|
+
return quotaWindowsOf(list).slice(0, limit).map(([type, label, win]) => ({ type, label, percent: quotaPercentValue(win?.percentUsed) }));
|
|
13615
|
+
}
|
|
13616
|
+
function creditGroupsOf(accounts) {
|
|
13617
|
+
const rows = Array.isArray(accounts) ? accounts : [];
|
|
13618
|
+
const byUnit = /* @__PURE__ */ new Map();
|
|
13619
|
+
let failedCount = 0;
|
|
13620
|
+
let okCount = 0;
|
|
13621
|
+
for (const row of rows) {
|
|
13622
|
+
const balance = row?.balance;
|
|
13623
|
+
if (!balance || typeof balance.total !== "number" || !Number.isFinite(balance.total)) {
|
|
13624
|
+
failedCount += 1;
|
|
13625
|
+
continue;
|
|
13626
|
+
}
|
|
13627
|
+
okCount += 1;
|
|
13628
|
+
const rawUnit = firstUnitOf(balance.packages) ?? "";
|
|
13629
|
+
const unit = rawUnit === QUOTA_UNIT ? QUOTA_UNIT : normalizeUnit(rawUnit);
|
|
13630
|
+
const group = byUnit.get(unit) ?? { unit, label: unitLabel(unit), total: 0, accountCount: 0 };
|
|
13631
|
+
group.total += balance.total;
|
|
13632
|
+
group.accountCount += 1;
|
|
13633
|
+
if (unit === QUOTA_UNIT) {
|
|
13634
|
+
const line = formatQuotaLine(balance.packages, unit);
|
|
13635
|
+
group.quotaLines = group.quotaLines ?? [];
|
|
13636
|
+
group.quotaRemainings = group.quotaRemainings ?? [];
|
|
13637
|
+
group.quotaWindows = group.quotaWindows ?? /* @__PURE__ */ new Map();
|
|
13638
|
+
if (line !== null) group.quotaLines.push(line);
|
|
13639
|
+
for (const pkg of Array.isArray(balance.packages) ? balance.packages : []) {
|
|
13640
|
+
if (!pkg) continue;
|
|
13641
|
+
const remaining = pkg.remaining;
|
|
13642
|
+
if (typeof remaining !== "number" || !Number.isFinite(remaining)) continue;
|
|
13643
|
+
group.quotaRemainings.push(remaining);
|
|
13644
|
+
const name2 = pkg.name || "未命名";
|
|
13645
|
+
const prev = group.quotaWindows.get(name2);
|
|
13646
|
+
if (prev === void 0 || remaining < prev) group.quotaWindows.set(name2, remaining);
|
|
13647
|
+
}
|
|
13648
|
+
}
|
|
13649
|
+
byUnit.set(unit, group);
|
|
13650
|
+
}
|
|
13651
|
+
const groups = [...byUnit.values()].sort((a, b) => a.unit < b.unit ? -1 : a.unit > b.unit ? 1 : 0);
|
|
13652
|
+
return { groups, failedCount, okCount };
|
|
13653
|
+
}
|
|
13654
|
+
function planGroupsOf(rows) {
|
|
13655
|
+
const list = Array.isArray(rows) ? rows : [];
|
|
13656
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
13657
|
+
for (const row of list) {
|
|
13658
|
+
const plan = row?.plan;
|
|
13659
|
+
if (!plan) continue;
|
|
13660
|
+
const unit = normalizeUnit(typeof plan.unit === "string" ? plan.unit : "");
|
|
13661
|
+
const key = `${String(plan.name)}\0${unit}`;
|
|
13662
|
+
const group = byKey.get(key) ?? {
|
|
13663
|
+
name: String(plan.name),
|
|
13664
|
+
unit,
|
|
13665
|
+
label: unitLabel(unit),
|
|
13666
|
+
remaining: 0,
|
|
13667
|
+
total: 0,
|
|
13668
|
+
accountCount: 0,
|
|
13669
|
+
deductionEndTime: void 0
|
|
13670
|
+
};
|
|
13671
|
+
group.remaining += Number(plan.remaining) || 0;
|
|
13672
|
+
group.total += Number(plan.total) || 0;
|
|
13673
|
+
group.accountCount += 1;
|
|
13674
|
+
const end = typeof plan.deductionEndTime === "number" && Number.isFinite(plan.deductionEndTime) ? plan.deductionEndTime : void 0;
|
|
13675
|
+
if (end !== void 0 && (group.deductionEndTime === void 0 || end < group.deductionEndTime)) {
|
|
13676
|
+
group.deductionEndTime = end;
|
|
13677
|
+
}
|
|
13678
|
+
byKey.set(key, group);
|
|
13679
|
+
}
|
|
13680
|
+
return [...byKey.values()].sort((a, b) => b.remaining - a.remaining);
|
|
13681
|
+
}
|
|
13682
|
+
function badgeView(input) {
|
|
13683
|
+
const providerLabel2 = String(input?.providerLabel ?? "Jet Hub");
|
|
13684
|
+
const preference = normalizeBadgePreference(input?.preference);
|
|
13685
|
+
const accounts = Array.isArray(input?.accounts) ? input.accounts : [];
|
|
13686
|
+
const subscription = input?.subscription;
|
|
13687
|
+
const loading = input?.loading === true;
|
|
13688
|
+
const failed = input?.failed === true;
|
|
13689
|
+
const placeholder = (mode2, reading2, tone) => ({
|
|
13690
|
+
mode: mode2,
|
|
13691
|
+
preference,
|
|
13692
|
+
name: providerLabel2,
|
|
13693
|
+
detail: "",
|
|
13694
|
+
reading: reading2,
|
|
13695
|
+
text: composeText(providerLabel2, "", reading2),
|
|
13696
|
+
tone,
|
|
13697
|
+
groups: [],
|
|
13566
13698
|
planGroups: [],
|
|
13567
13699
|
windows: [],
|
|
13568
13700
|
failedCount: 0,
|
|
@@ -13720,199 +13852,40 @@ function formatUpdatedAt(ms) {
|
|
|
13720
13852
|
}
|
|
13721
13853
|
|
|
13722
13854
|
// plugin-src/client/usage-badge.js
|
|
13723
|
-
var POPOVER_ANCHOR_STYLE = Object.freeze({
|
|
13724
|
-
position: "absolute",
|
|
13725
|
-
right: 0,
|
|
13726
|
-
bottom: "calc(100% + 8px)",
|
|
13727
|
-
maxHeight: "58vh",
|
|
13728
|
-
overflowY: "auto",
|
|
13729
|
-
zIndex: 40
|
|
13730
|
-
});
|
|
13731
|
-
var NARROW_BREAKPOINT_PX = 720;
|
|
13732
|
-
function isNarrowViewport() {
|
|
13733
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return false;
|
|
13734
|
-
return window.matchMedia(`(max-width: ${NARROW_BREAKPOINT_PX}px)`).matches;
|
|
13735
|
-
}
|
|
13736
|
-
var NARROW_POPOVER_STYLE = Object.freeze({
|
|
13737
|
-
position: "fixed",
|
|
13738
|
-
left: 8,
|
|
13739
|
-
right: 8,
|
|
13740
|
-
top: "auto",
|
|
13741
|
-
bottom: "calc(env(safe-area-inset-bottom, 0px) + var(--dsh-composer-height, 152px))",
|
|
13742
|
-
width: "auto",
|
|
13743
|
-
maxWidth: "none",
|
|
13744
|
-
maxHeight: "max(120px, calc(100dvh - 160px))",
|
|
13745
|
-
overflowY: "auto",
|
|
13746
|
-
zIndex: 1200
|
|
13747
|
-
});
|
|
13748
|
-
var COMPOSER_HEIGHT_FALLBACK_PX = 152;
|
|
13749
|
-
function readComposerHeightPx(anchor) {
|
|
13750
|
-
if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") {
|
|
13751
|
-
return COMPOSER_HEIGHT_FALLBACK_PX;
|
|
13752
|
-
}
|
|
13753
|
-
let node = anchor;
|
|
13754
|
-
while (node !== null && node !== void 0) {
|
|
13755
|
-
const raw = window.getComputedStyle(node).getPropertyValue("--dsh-composer-height").trim();
|
|
13756
|
-
if (raw !== "") {
|
|
13757
|
-
const parsed = Number.parseFloat(raw);
|
|
13758
|
-
if (Number.isFinite(parsed) && parsed > 0) return parsed;
|
|
13759
|
-
}
|
|
13760
|
-
node = node.parentElement;
|
|
13761
|
-
}
|
|
13762
|
-
return COMPOSER_HEIGHT_FALLBACK_PX;
|
|
13763
|
-
}
|
|
13764
13855
|
var BADGE_POLL_MS = 6e4;
|
|
13765
|
-
var ACTIVE_PROVIDER_POLL_MS = 5e3;
|
|
13766
13856
|
var CLAIM_NOTICE_MS = 8e3;
|
|
13767
13857
|
var CLAIM_NOTICE_WARN_MS = 2e4;
|
|
13768
13858
|
var CREDITS_COLLAPSED_LIMIT = 5;
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
const resolveDirectory = props.resolveDirectory;
|
|
13772
|
-
const [directory, setDirectory] = React6.useState(null);
|
|
13773
|
-
const resolvedRef = React6.useRef(false);
|
|
13774
|
-
const snapshotErrorRef = React6.useRef(false);
|
|
13775
|
-
React6.useEffect(() => {
|
|
13776
|
-
if (typeof resolveDirectory !== "function") return void 0;
|
|
13777
|
-
if (resolvedRef.current) return void 0;
|
|
13778
|
-
let alive = true;
|
|
13779
|
-
const timers = [];
|
|
13780
|
-
let attempt = 0;
|
|
13781
|
-
const tryResolve = () => {
|
|
13782
|
-
if (!alive || resolvedRef.current) return;
|
|
13783
|
-
let resolved = null;
|
|
13784
|
-
try {
|
|
13785
|
-
resolved = resolveDirectory();
|
|
13786
|
-
} catch {
|
|
13787
|
-
resolved = null;
|
|
13788
|
-
}
|
|
13789
|
-
if (!alive) return;
|
|
13790
|
-
if (resolved !== null && resolved !== void 0 && resolved.store !== void 0) {
|
|
13791
|
-
resolvedRef.current = true;
|
|
13792
|
-
const store = resolved.store;
|
|
13793
|
-
setDirectory(store);
|
|
13794
|
-
if (typeof resolved.load === "function") {
|
|
13795
|
-
Promise.resolve(resolved.load()).catch((error) => {
|
|
13796
|
-
console.warn("[jet-hub usage] 目录 load() 失败,徽标将不显示:", error);
|
|
13797
|
-
});
|
|
13798
|
-
}
|
|
13799
|
-
return;
|
|
13800
|
-
}
|
|
13801
|
-
attempt += 1;
|
|
13802
|
-
if (attempt >= RESOLVE_RETRY_DELAYS.length) {
|
|
13803
|
-
console.warn("[jet-hub usage] 目录解析最终失败,徽标不显示");
|
|
13804
|
-
return;
|
|
13805
|
-
}
|
|
13806
|
-
timers.push(setTimeout(tryResolve, RESOLVE_RETRY_DELAYS[attempt - 1]));
|
|
13807
|
-
};
|
|
13808
|
-
tryResolve();
|
|
13809
|
-
return () => {
|
|
13810
|
-
alive = false;
|
|
13811
|
-
for (const timer of timers) clearTimeout(timer);
|
|
13812
|
-
};
|
|
13813
|
-
}, [resolveDirectory]);
|
|
13814
|
-
const safe = (fn) => () => {
|
|
13815
|
-
try {
|
|
13816
|
-
return directory ? fn(directory) : void 0;
|
|
13817
|
-
} catch (error) {
|
|
13818
|
-
if (!snapshotErrorRef.current) {
|
|
13819
|
-
snapshotErrorRef.current = true;
|
|
13820
|
-
console.warn("[jet-hub usage] 读目录快照失败(store 上应有 getSnapshot):", error);
|
|
13821
|
-
}
|
|
13822
|
-
return void 0;
|
|
13823
|
-
}
|
|
13824
|
-
};
|
|
13825
|
-
const state = React6.useSyncExternalStore(
|
|
13826
|
-
// ⚠️ 订阅要**真的转发 onChange**(用户切模型时徽标跟着更新);
|
|
13827
|
-
// try/catch 只为把「订阅时才发现抛错」这一类也收进徽标内部。
|
|
13828
|
-
(onChange) => {
|
|
13829
|
-
if (!directory) return () => {
|
|
13830
|
-
};
|
|
13831
|
-
try {
|
|
13832
|
-
return directory.subscribe(onChange);
|
|
13833
|
-
} catch {
|
|
13834
|
-
return () => {
|
|
13835
|
-
};
|
|
13836
|
-
}
|
|
13837
|
-
},
|
|
13838
|
-
safe((d) => d.getSnapshot()),
|
|
13839
|
-
safe((d) => d.getSnapshot())
|
|
13840
|
-
);
|
|
13841
|
-
let provider = state?.current?.provider;
|
|
13842
|
-
const modelId = state?.current?.model;
|
|
13843
|
-
const readActiveProvider = props.readActiveProvider;
|
|
13844
|
-
const [activeProvider, setActiveProvider] = React6.useState(null);
|
|
13845
|
-
const isAggregate = provider === AGGREGATE_PROVIDER_ID;
|
|
13846
|
-
React6.useEffect(() => {
|
|
13847
|
-
if (!isAggregate || typeof readActiveProvider !== "function") return void 0;
|
|
13848
|
-
let alive = true;
|
|
13849
|
-
let timer = null;
|
|
13850
|
-
const refresh = () => {
|
|
13851
|
-
Promise.resolve().then(() => readActiveProvider(modelId)).then((value) => {
|
|
13852
|
-
if (!alive) return;
|
|
13853
|
-
setActiveProvider(value?.provider ?? null);
|
|
13854
|
-
}).catch(() => {
|
|
13855
|
-
if (alive) setActiveProvider(null);
|
|
13856
|
-
});
|
|
13857
|
-
};
|
|
13858
|
-
refresh();
|
|
13859
|
-
timer = setInterval(refresh, ACTIVE_PROVIDER_POLL_MS);
|
|
13860
|
-
return () => {
|
|
13861
|
-
alive = false;
|
|
13862
|
-
if (timer !== null) clearInterval(timer);
|
|
13863
|
-
};
|
|
13864
|
-
}, [isAggregate, readActiveProvider, modelId]);
|
|
13865
|
-
if (isAggregate) {
|
|
13866
|
-
provider = resolveBadgeProvider(provider, activeProvider === null ? null : { provider: activeProvider });
|
|
13867
|
-
}
|
|
13868
|
-
if (isAggregate && provider === null) {
|
|
13869
|
-
return React6.createElement("span", {
|
|
13870
|
-
className: "dim-jh-badgePending",
|
|
13871
|
-
role: "status",
|
|
13872
|
-
title: "聚合(跨渠道):尚未发出过请求,还不知道会走哪个渠道。发送一条消息后这里会显示实际使用的渠道与积分。"
|
|
13873
|
-
}, [
|
|
13874
|
-
React6.createElement("span", { key: "dot", className: "dim-jh-badgeDot", "data-tone": "muted" }),
|
|
13875
|
-
React6.createElement("span", { key: "text" }, "聚合 · 待首次请求")
|
|
13876
|
-
]);
|
|
13877
|
-
}
|
|
13859
|
+
function UsageBadgeCard(props) {
|
|
13860
|
+
const provider = props.provider;
|
|
13878
13861
|
if (typeof provider !== "string" || provider.length === 0) return null;
|
|
13879
13862
|
if (provider === AUTO_PROVIDER_ID) {
|
|
13880
|
-
return
|
|
13863
|
+
return React8.createElement(UsageBadgeActive, { ...props, provider });
|
|
13881
13864
|
}
|
|
13882
13865
|
if (!supportsCreditBalance(provider)) return null;
|
|
13883
|
-
return
|
|
13866
|
+
return React8.createElement(UsageBadgeActive, { ...props, provider });
|
|
13884
13867
|
}
|
|
13885
13868
|
function UsageBadgeActive(props) {
|
|
13886
13869
|
const { provider, providerLabel: providerLabel2, readBadge, writePreference, setAutoCheckin, dismissAutoCheckin, claimCredits } = props;
|
|
13887
13870
|
const label = providerLabel2(provider);
|
|
13888
|
-
const [snapshot, setSnapshot] =
|
|
13889
|
-
const [failed, setFailed] =
|
|
13890
|
-
const [readError, setReadError] =
|
|
13891
|
-
const [busy, setBusy] =
|
|
13892
|
-
const [
|
|
13893
|
-
const [
|
|
13894
|
-
const [
|
|
13895
|
-
const [
|
|
13896
|
-
const [
|
|
13897
|
-
const [
|
|
13898
|
-
const [
|
|
13899
|
-
const
|
|
13900
|
-
const root = React6.useRef(null);
|
|
13901
|
-
const popRef = React6.useRef(null);
|
|
13902
|
-
const read = React6.useRef(() => {
|
|
13871
|
+
const [snapshot, setSnapshot] = React8.useState(null);
|
|
13872
|
+
const [failed, setFailed] = React8.useState(false);
|
|
13873
|
+
const [readError, setReadError] = React8.useState("");
|
|
13874
|
+
const [busy, setBusy] = React8.useState(false);
|
|
13875
|
+
const [preference, setPreference] = React8.useState(null);
|
|
13876
|
+
const [prefError, setPrefError] = React8.useState("");
|
|
13877
|
+
const [autoError, setAutoError] = React8.useState("");
|
|
13878
|
+
const [claiming, setClaiming] = React8.useState(null);
|
|
13879
|
+
const [claimProgress, setClaimProgress] = React8.useState(null);
|
|
13880
|
+
const [claimNotice, setClaimNotice] = React8.useState(null);
|
|
13881
|
+
const [creditsExpanded, setCreditsExpanded] = React8.useState(false);
|
|
13882
|
+
const read = React8.useRef(() => {
|
|
13903
13883
|
});
|
|
13904
|
-
const claimInFlightRef =
|
|
13905
|
-
|
|
13884
|
+
const claimInFlightRef = React8.useRef(false);
|
|
13885
|
+
React8.useEffect(() => {
|
|
13906
13886
|
ensureJetHubStyles();
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
if (element === null) return;
|
|
13910
|
-
const position = window.getComputedStyle(element).position;
|
|
13911
|
-
if (position !== "absolute" && position !== "fixed") {
|
|
13912
|
-
console.warn(`[jet-hub] 浮层定位异常(position=${position}):会撑高输入区(检查 POPOVER_ANCHOR_STYLE / NARROW_POPOVER_STYLE 是否被改坏)`);
|
|
13913
|
-
}
|
|
13914
|
-
}, [open]);
|
|
13915
|
-
React6.useEffect(() => {
|
|
13887
|
+
}, []);
|
|
13888
|
+
React8.useEffect(() => {
|
|
13916
13889
|
setSnapshot(null);
|
|
13917
13890
|
setFailed(false);
|
|
13918
13891
|
setClaimNotice(null);
|
|
@@ -13920,7 +13893,7 @@ function UsageBadgeActive(props) {
|
|
|
13920
13893
|
setAutoError("");
|
|
13921
13894
|
setCreditsExpanded(false);
|
|
13922
13895
|
}, [provider]);
|
|
13923
|
-
|
|
13896
|
+
React8.useEffect(() => {
|
|
13924
13897
|
let alive = true;
|
|
13925
13898
|
let inFlight = false;
|
|
13926
13899
|
const load = async (options = {}) => {
|
|
@@ -13965,25 +13938,7 @@ function UsageBadgeActive(props) {
|
|
|
13965
13938
|
document.removeEventListener("visibilitychange", onVisible);
|
|
13966
13939
|
};
|
|
13967
13940
|
}, [provider, readBadge]);
|
|
13968
|
-
|
|
13969
|
-
if (!open) return void 0;
|
|
13970
|
-
const onDown = (event) => {
|
|
13971
|
-
if (!(event.target instanceof Node)) return;
|
|
13972
|
-
const insideRoot = root.current !== null && root.current.contains(event.target);
|
|
13973
|
-
const insidePop = popRef.current !== null && popRef.current.contains(event.target);
|
|
13974
|
-
if (!insideRoot && !insidePop) setOpen(false);
|
|
13975
|
-
};
|
|
13976
|
-
const onKey = (event) => {
|
|
13977
|
-
if (event.key === "Escape") setOpen(false);
|
|
13978
|
-
};
|
|
13979
|
-
document.addEventListener("mousedown", onDown);
|
|
13980
|
-
document.addEventListener("keydown", onKey);
|
|
13981
|
-
return () => {
|
|
13982
|
-
document.removeEventListener("mousedown", onDown);
|
|
13983
|
-
document.removeEventListener("keydown", onKey);
|
|
13984
|
-
};
|
|
13985
|
-
}, [open]);
|
|
13986
|
-
React6.useEffect(() => {
|
|
13941
|
+
React8.useEffect(() => {
|
|
13987
13942
|
if (claimNotice === null) return void 0;
|
|
13988
13943
|
const ms = claimNotice.tone === "warn" ? CLAIM_NOTICE_WARN_MS : CLAIM_NOTICE_MS;
|
|
13989
13944
|
const timer = setTimeout(() => setClaimNotice(null), ms);
|
|
@@ -14143,62 +14098,23 @@ function UsageBadgeActive(props) {
|
|
|
14143
14098
|
const tone = failed && snapshot === null ? "error" : view.tone;
|
|
14144
14099
|
const title = [view.text, view.incompleteNote, view.failureReason].filter((part) => part !== "").join("\n");
|
|
14145
14100
|
const ariaLabel = `${label} 用量:${view.text}${view.incompleteNote === "" ? "" : `(${view.incompleteNote})`}`;
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
React6.createElement("span", { key: "sep", className: "dim-jh-badgeSep" }, "•"),
|
|
14149
|
-
// 空串时**不渲染**该节点:留一个空 span 会白吃一个 5px 的 gap
|
|
14150
|
-
//(.dim-jh-badgeText 用的是 .dim-jh-badgeBtn 的 gap)。只有套餐模式有中段。
|
|
14151
|
-
view.detail === "" ? null : React6.createElement("span", { key: "detail", className: "dim-jh-badgeDetail" }, view.detail),
|
|
14152
|
-
// ⚠️ 类名是 Reading 而**不是** Value:.dim-jh-badgeValue 已被弹窗里的读数占用
|
|
14153
|
-
//(那条规则带 font-weight:600,且排在样式表更后面 —— 同名会让胶囊里的数字
|
|
14154
|
-
// 被静默加粗、并拿到 flex:none 而无法收缩)。
|
|
14155
|
-
React6.createElement("span", { key: "value", className: "dim-jh-badgeReading" }, view.reading),
|
|
14156
|
-
/**
|
|
14157
|
-
* 「这个数字不完整」的标记(用户 2026-10-03 要求)。
|
|
14158
|
-
*
|
|
14159
|
-
* 合计少算了几个账号时,数字本身**看不出任何异常**,故必须有个可见标记 ——
|
|
14160
|
-
* 但它是**补语而不是读数**,故:
|
|
14161
|
-
* - 单独成 span,`flex: none`(与读数同级):被省略号吃掉就等于没标;
|
|
14162
|
-
* - 排在读数**之后**:不干扰「先看数字」的阅读顺序;
|
|
14163
|
-
* - 不参与 `view.text`:那句话是 `title` / `aria-label` 用的纯读数。
|
|
14164
|
-
*
|
|
14165
|
-
* ⚠️ `aria-hidden` 是**故意**的:同一句话已经并进按钮的 `aria-label`,
|
|
14166
|
-
* 不隐藏会被读屏念两遍。鼠标用户的解释走 `title`。
|
|
14167
|
-
*/
|
|
14168
|
-
view.incompleteNote === "" ? null : React6.createElement("span", {
|
|
14169
|
-
key: "incomplete",
|
|
14170
|
-
className: "dim-jh-badgeWarn",
|
|
14171
|
-
title: view.incompleteNote,
|
|
14172
|
-
"aria-hidden": "true"
|
|
14173
|
-
}, "⚠")
|
|
14174
|
-
]);
|
|
14175
|
-
return React6.createElement("div", { className: "dim-jh-badge", ref: root }, [
|
|
14176
|
-
React6.createElement("button", {
|
|
14177
|
-
key: "btn",
|
|
14178
|
-
type: "button",
|
|
14179
|
-
className: "dim-jh-badgeBtn",
|
|
14180
|
-
"aria-expanded": open,
|
|
14181
|
-
"aria-label": ariaLabel,
|
|
14182
|
-
title,
|
|
14183
|
-
onClick: () => setOpen((was) => !was)
|
|
14184
|
-
}, [
|
|
14185
|
-
React6.createElement("span", { key: "dot", className: "dim-jh-badgeDot", "data-tone": tone }),
|
|
14186
|
-
collapsed
|
|
14187
|
-
]),
|
|
14188
|
-
open ? renderPopover() : null
|
|
14189
|
-
]);
|
|
14190
|
-
function renderPopover() {
|
|
14101
|
+
return React8.createElement("div", { className: "dim-jh-usageCard" }, renderCardBody());
|
|
14102
|
+
function renderCardBody() {
|
|
14191
14103
|
const stamp = snapshot === null ? "" : formatUpdatedAt(value?.generatedAt ?? snapshot.at);
|
|
14192
14104
|
const children = [
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14105
|
+
React8.createElement("div", { key: "head", className: "dim-jh-badgeHead" }, [
|
|
14106
|
+
React8.createElement("span", { key: "dot", className: "dim-jh-badgeDot", "data-tone": tone }),
|
|
14107
|
+
// ⚠️ 渠道名用 `badgeName` 而不是 `label`:auto 渠道的 label 是裸 id
|
|
14108
|
+
//(虚拟渠道不在 registry 里,providerLabel 只能原样返回),而 badgeName
|
|
14109
|
+
// 已由 autoBadgeName 拼成「自动 → 实际渠道 · 倍率 · 倒计时」—— 那正是
|
|
14110
|
+
// 用户要核对的信息;其余渠道两者相同(badgeName 的 fallback 就是 label)。
|
|
14111
|
+
React8.createElement("span", { key: "title", className: "dim-jh-badgeTitle" }, badgeName),
|
|
14112
|
+
React8.createElement(
|
|
14197
14113
|
"span",
|
|
14198
14114
|
{ key: "at", className: "dim-jh-badgeAt" },
|
|
14199
14115
|
snapshot === null ? "读取中…" : `${stamp === "" ? "已读取" : stamp}${value?.cached === true ? " · 缓存" : ""}`
|
|
14200
14116
|
),
|
|
14201
|
-
|
|
14117
|
+
React8.createElement("button", {
|
|
14202
14118
|
key: "auto",
|
|
14203
14119
|
type: "button",
|
|
14204
14120
|
className: "dim-jh-badgeAuto",
|
|
@@ -14210,8 +14126,8 @@ function UsageBadgeActive(props) {
|
|
|
14210
14126
|
onClick: () => {
|
|
14211
14127
|
void onToggleAutoCheckin();
|
|
14212
14128
|
}
|
|
14213
|
-
}, auto?.running === true ? "…" :
|
|
14214
|
-
|
|
14129
|
+
}, auto?.running === true ? "…" : React8.createElement("span", { className: "dim-jh-badgeAutoDot" })),
|
|
14130
|
+
React8.createElement("button", {
|
|
14215
14131
|
key: "refresh",
|
|
14216
14132
|
type: "button",
|
|
14217
14133
|
className: "dim-jh-badgeRefresh",
|
|
@@ -14223,57 +14139,55 @@ function UsageBadgeActive(props) {
|
|
|
14223
14139
|
]),
|
|
14224
14140
|
// 开关写入失败时单独一行说明:它属于设置写入,混进偏好那行会让人以为
|
|
14225
14141
|
// 是「显示偏好」没保存。
|
|
14226
|
-
autoError === "" ? null :
|
|
14142
|
+
autoError === "" ? null : React8.createElement("div", { key: "autoErr", className: "dim-jh-badgeFail", role: "alert" }, autoError),
|
|
14143
|
+
// 读数行:原折叠胶囊的「名字 • 读数」迁居后只保留**读数**(名字已在头部,
|
|
14144
|
+
// auto 的实际渠道也在头部);「不完整」警示角标随行 —— 它是读数的补语。
|
|
14145
|
+
React8.createElement("div", {
|
|
14146
|
+
key: "reading",
|
|
14147
|
+
className: "dim-jh-usageReading",
|
|
14148
|
+
title,
|
|
14149
|
+
"aria-label": ariaLabel
|
|
14150
|
+
}, [
|
|
14151
|
+
React8.createElement("span", {
|
|
14152
|
+
key: "value",
|
|
14153
|
+
className: "dim-jh-usageReadingValue",
|
|
14154
|
+
"data-tone": tone
|
|
14155
|
+
}, view.reading),
|
|
14156
|
+
// ⚠️ aria-hidden 是**故意**的:同一句话已并入读数行的 aria-label,
|
|
14157
|
+
// 不隐藏会被读屏念两遍;鼠标用户的解释走 title。
|
|
14158
|
+
view.incompleteNote === "" ? null : React8.createElement("span", {
|
|
14159
|
+
key: "incomplete",
|
|
14160
|
+
className: "dim-jh-badgeWarn",
|
|
14161
|
+
title: view.incompleteNote,
|
|
14162
|
+
"aria-hidden": "true"
|
|
14163
|
+
}, "⚠")
|
|
14164
|
+
]),
|
|
14227
14165
|
renderPreference()
|
|
14228
14166
|
];
|
|
14229
14167
|
if (snapshot === null) {
|
|
14230
|
-
children.push(
|
|
14168
|
+
children.push(React8.createElement("div", {
|
|
14231
14169
|
key: "placeholder",
|
|
14232
14170
|
className: failed ? "dim-jh-badgeFail" : "dim-jh-badgeNote",
|
|
14233
14171
|
role: failed ? "alert" : void 0
|
|
14234
14172
|
}, failed ? readError === "" ? "用量不可用,可点右上角 ↻ 重试" : `${readError}(可点右上角 ↻ 重试)` : "正在读取用量…(首次要逐账号查询,可能要几秒)"));
|
|
14235
14173
|
children.push(renderClaim());
|
|
14236
|
-
return
|
|
14174
|
+
return children;
|
|
14237
14175
|
}
|
|
14238
14176
|
children.push(renderSubscription());
|
|
14239
14177
|
children.push(renderCredits());
|
|
14240
14178
|
children.push(renderClaim());
|
|
14241
14179
|
children.push(renderFoot());
|
|
14242
|
-
return
|
|
14243
|
-
}
|
|
14244
|
-
function wrapPopover(children) {
|
|
14245
|
-
const narrow = isNarrowViewport();
|
|
14246
|
-
if (!narrow) {
|
|
14247
|
-
return React6.createElement("div", {
|
|
14248
|
-
className: "dim-jh-badgePop",
|
|
14249
|
-
style: POPOVER_ANCHOR_STYLE,
|
|
14250
|
-
ref: popRef
|
|
14251
|
-
}, children);
|
|
14252
|
-
}
|
|
14253
|
-
const composerHeight = readComposerHeightPx(root.current);
|
|
14254
|
-
const style = {
|
|
14255
|
-
...NARROW_POPOVER_STYLE,
|
|
14256
|
-
// ⚠️ React 的内联样式对自定义属性(`--x`)是原样下发的,故这里可以
|
|
14257
|
-
// 直接用 CSS 变量名作 key。
|
|
14258
|
-
"--dsh-composer-height": `${composerHeight}px`
|
|
14259
|
-
};
|
|
14260
|
-
const node = React6.createElement("div", {
|
|
14261
|
-
className: "dim-jh-badgePop",
|
|
14262
|
-
style,
|
|
14263
|
-
ref: popRef
|
|
14264
|
-
}, children);
|
|
14265
|
-
if (typeof document === "undefined" || document.body === null || document.body === void 0) return node;
|
|
14266
|
-
return (0, import_react_dom.createPortal)(node, document.body, "jet-hub-badge-pop");
|
|
14180
|
+
return children;
|
|
14267
14181
|
}
|
|
14268
14182
|
function renderPreference() {
|
|
14269
|
-
return
|
|
14183
|
+
return React8.createElement("div", {
|
|
14270
14184
|
key: "pref",
|
|
14271
14185
|
className: "dim-jh-badgePref",
|
|
14272
14186
|
// ⚠️ 三档的差别必须写清:auto 与 credits 在**有订阅时**表现不同
|
|
14273
14187
|
//(auto 会回落,credits 不回落到订阅)—— 只说「优先显示哪个」会让人以为两档一样。
|
|
14274
14188
|
title: "显示偏好:「自动」= 优先显示一共能用的余额(没有余额读数才显示订阅窗口/套餐);「优先订阅」= 只看窗口与套餐;「只看积分」= 强制只显示余额,也是套餐判定不准时的兜底"
|
|
14275
14189
|
}, [
|
|
14276
|
-
...BADGE_PREFERENCES.map((item) =>
|
|
14190
|
+
...BADGE_PREFERENCES.map((item) => React8.createElement("button", {
|
|
14277
14191
|
key: item,
|
|
14278
14192
|
type: "button",
|
|
14279
14193
|
className: "dim-jh-badgePrefBtn",
|
|
@@ -14282,7 +14196,7 @@ function UsageBadgeActive(props) {
|
|
|
14282
14196
|
void onPickPreference(item);
|
|
14283
14197
|
}
|
|
14284
14198
|
}, BADGE_PREFERENCE_LABELS[item])),
|
|
14285
|
-
prefError === "" ? null :
|
|
14199
|
+
prefError === "" ? null : React8.createElement("span", { key: "err", className: "dim-jh-badgeFail" }, prefError)
|
|
14286
14200
|
]);
|
|
14287
14201
|
}
|
|
14288
14202
|
function renderSubscription() {
|
|
@@ -14292,47 +14206,47 @@ function UsageBadgeActive(props) {
|
|
|
14292
14206
|
const rows = Array.isArray(subscription.accounts) ? subscription.accounts : [];
|
|
14293
14207
|
const account = rows.find((row) => row?.ok === true) ?? rows[0];
|
|
14294
14208
|
const windows = account === void 0 ? [] : quotaWindowsOf(account.windows ?? []);
|
|
14295
|
-
return
|
|
14296
|
-
|
|
14297
|
-
...windows.length === 0 ? [
|
|
14209
|
+
return React8.createElement("div", { key: "sub", className: "dim-jh-badgeSection" }, [
|
|
14210
|
+
React8.createElement("div", { key: "title", className: "dim-jh-badgeSectionTitle" }, "订阅额度"),
|
|
14211
|
+
...windows.length === 0 ? [React8.createElement(
|
|
14298
14212
|
"div",
|
|
14299
14213
|
{ key: "empty", className: "dim-jh-badgeNote" },
|
|
14300
14214
|
account?.ok === true ? "该账号没有额度窗口" : account?.error || "订阅额度不可用"
|
|
14301
|
-
)] : [
|
|
14215
|
+
)] : [React8.createElement(
|
|
14302
14216
|
"div",
|
|
14303
14217
|
{ key: "wins", className: "dim-jh-badgeWins" },
|
|
14304
14218
|
windows.map(([type, windowLabel, win]) => {
|
|
14305
14219
|
const percent = quotaPercentValue(win?.percentUsed);
|
|
14306
14220
|
const left = quotaResetsIn(win?.resetsAt);
|
|
14307
|
-
return
|
|
14308
|
-
|
|
14309
|
-
|
|
14221
|
+
return React8.createElement("div", { key: type, className: "dim-jh-badgeWin" }, [
|
|
14222
|
+
React8.createElement("span", { key: "l", className: "dim-jh-badgeWinLabel" }, windowLabel),
|
|
14223
|
+
React8.createElement(
|
|
14310
14224
|
"div",
|
|
14311
14225
|
{ key: "bar", className: "dim-jh-quotaBar" },
|
|
14312
|
-
|
|
14226
|
+
React8.createElement("div", {
|
|
14313
14227
|
key: "fill",
|
|
14314
14228
|
className: "dim-jh-quotaBarFill",
|
|
14315
14229
|
"data-tone": quotaTone(percent),
|
|
14316
14230
|
style: { width: `${percent}%` }
|
|
14317
14231
|
})
|
|
14318
14232
|
),
|
|
14319
|
-
|
|
14320
|
-
left === "" ? null :
|
|
14233
|
+
React8.createElement("span", { key: "v", className: "dim-jh-badgeValue" }, formatQuotaPercent(percent)),
|
|
14234
|
+
left === "" ? null : React8.createElement("span", { key: "r", className: "dim-jh-badgeWinReset", title: left }, left)
|
|
14321
14235
|
]);
|
|
14322
14236
|
})
|
|
14323
14237
|
)]
|
|
14324
14238
|
]);
|
|
14325
14239
|
}
|
|
14326
14240
|
const groups = view.planGroups;
|
|
14327
|
-
return
|
|
14328
|
-
|
|
14329
|
-
...groups.length === 0 ? [
|
|
14241
|
+
return React8.createElement("div", { key: "sub", className: "dim-jh-badgeSection" }, [
|
|
14242
|
+
React8.createElement("div", { key: "title", className: "dim-jh-badgeSectionTitle" }, "订阅套餐"),
|
|
14243
|
+
...groups.length === 0 ? [React8.createElement("div", { key: "empty", className: "dim-jh-badgeNote" }, "没有可用的套餐包")] : groups.map((group) => React8.createElement("div", {
|
|
14330
14244
|
key: `${group.name}\0${group.unit}`,
|
|
14331
14245
|
className: "dim-jh-badgeRow"
|
|
14332
14246
|
}, [
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14247
|
+
React8.createElement("div", { key: "head", className: "dim-jh-badgeRowHead" }, [
|
|
14248
|
+
React8.createElement("span", { key: "l", className: "dim-jh-badgeRowName", title: group.name }, group.name),
|
|
14249
|
+
React8.createElement(
|
|
14336
14250
|
"span",
|
|
14337
14251
|
{ key: "v", className: "dim-jh-badgeValue" },
|
|
14338
14252
|
// ⚠️ 数值与单位之间**不留空格**(`100.00M / 200.00MToken`):
|
|
@@ -14345,7 +14259,7 @@ function UsageBadgeActive(props) {
|
|
|
14345
14259
|
`${formatUnits(group.remaining, group.unit) ?? "?"} / ${formatUnits(group.total, group.unit) ?? "?"}${group.label}`
|
|
14346
14260
|
)
|
|
14347
14261
|
]),
|
|
14348
|
-
|
|
14262
|
+
React8.createElement(
|
|
14349
14263
|
"div",
|
|
14350
14264
|
{ key: "note", className: "dim-jh-badgeRowNote" },
|
|
14351
14265
|
[
|
|
@@ -14365,17 +14279,17 @@ function UsageBadgeActive(props) {
|
|
|
14365
14279
|
limit: CREDITS_COLLAPSED_LIMIT,
|
|
14366
14280
|
expanded: creditsExpanded
|
|
14367
14281
|
});
|
|
14368
|
-
return
|
|
14282
|
+
return React8.createElement("div", { key: "credits", className: "dim-jh-badgeSection" }, [
|
|
14369
14283
|
// 合计放进节标题右侧,省掉一整行
|
|
14370
|
-
|
|
14284
|
+
React8.createElement("div", { key: "title", className: "dim-jh-badgeSectionTitle" }, [
|
|
14371
14285
|
// ⚠️ 节标题的单位标签走**纯函数**(`creditSectionLabel`),不在这里写三元:
|
|
14372
14286
|
// 原写法是 `quotaGroup === undefined ? '积分' : unitLabel(...)` —— 那个
|
|
14373
14287
|
// 兜底分支把 **ZCode 的 token** 冒充成了积分(真实缺陷,2026-10-05 复审
|
|
14374
14288
|
// PR !56 时发现),渲染成「积分 … 94.54MToken」自相矛盾的一屏。
|
|
14375
14289
|
// 判据收进 `badge-model.js` 是为了能被单测锁死(组件里没法测 —— 本仓库
|
|
14376
14290
|
// node_modules 没有 react)。
|
|
14377
|
-
|
|
14378
|
-
accounts.length === 0 || sum === "" ? null :
|
|
14291
|
+
React8.createElement("span", { key: "l" }, creditSectionLabel(view.groups)),
|
|
14292
|
+
accounts.length === 0 || sum === "" ? null : React8.createElement(
|
|
14379
14293
|
"span",
|
|
14380
14294
|
{ key: "sum", className: "dim-jh-badgeSectionSum" },
|
|
14381
14295
|
// ⚠️ 「合计」二字只对**可累加的余额**成立。配额窗口是并行百分比,
|
|
@@ -14384,18 +14298,18 @@ function UsageBadgeActive(props) {
|
|
|
14384
14298
|
quotaGroup === void 0 ? `合计 ${sum}` : sum
|
|
14385
14299
|
)
|
|
14386
14300
|
]),
|
|
14387
|
-
...accounts.length === 0 ? [
|
|
14301
|
+
...accounts.length === 0 ? [React8.createElement(
|
|
14388
14302
|
"div",
|
|
14389
14303
|
{ key: "empty", className: "dim-jh-badgeNote" },
|
|
14390
14304
|
value?.disabledCount > 0 ? "该渠道的账号全部已停用" : "该渠道还没有账号(可在 Jet Hub 设置页添加)"
|
|
14391
|
-
)] : shown.map((row) =>
|
|
14392
|
-
|
|
14393
|
-
|
|
14305
|
+
)] : shown.map((row) => React8.createElement("div", { key: row.accountId, className: "dim-jh-badgeRow" }, [
|
|
14306
|
+
React8.createElement("div", { key: "head", className: "dim-jh-badgeRowHead" }, [
|
|
14307
|
+
React8.createElement("span", {
|
|
14394
14308
|
key: "l",
|
|
14395
14309
|
className: "dim-jh-badgeRowName",
|
|
14396
14310
|
title: row.nickname || row.accountId
|
|
14397
14311
|
}, row.nickname || row.accountId),
|
|
14398
|
-
|
|
14312
|
+
React8.createElement("span", {
|
|
14399
14313
|
key: "v",
|
|
14400
14314
|
className: "dim-jh-badgeValue",
|
|
14401
14315
|
"data-tone": row.balance === null ? "warn" : "ok",
|
|
@@ -14406,7 +14320,7 @@ function UsageBadgeActive(props) {
|
|
|
14406
14320
|
// 存在时才占一行。用户 2026-10-12 明确要求三档分色。
|
|
14407
14321
|
row.balance === null ? null : renderSplitNote(splitParts(row.balance, windowDays, provider))
|
|
14408
14322
|
])),
|
|
14409
|
-
hidden === 0 ? null :
|
|
14323
|
+
hidden === 0 ? null : React8.createElement("button", {
|
|
14410
14324
|
key: "more",
|
|
14411
14325
|
type: "button",
|
|
14412
14326
|
className: "dim-jh-badgeMore",
|
|
@@ -14417,14 +14331,14 @@ function UsageBadgeActive(props) {
|
|
|
14417
14331
|
}
|
|
14418
14332
|
function renderNote(text) {
|
|
14419
14333
|
if (typeof text !== "string" || text.length === 0) return null;
|
|
14420
|
-
return
|
|
14334
|
+
return React8.createElement("div", { key: "note", className: "dim-jh-badgeRowNote" }, text);
|
|
14421
14335
|
}
|
|
14422
14336
|
function renderSplitNote(parts) {
|
|
14423
14337
|
if (!Array.isArray(parts) || parts.length === 0) return null;
|
|
14424
14338
|
const children = [];
|
|
14425
14339
|
parts.forEach((part, index) => {
|
|
14426
|
-
if (index > 0) children.push(
|
|
14427
|
-
children.push(
|
|
14340
|
+
if (index > 0) children.push(React8.createElement("span", { key: `sep-${part.key}`, className: "dim-jh-badgeNoteSep" }, " · "));
|
|
14341
|
+
children.push(React8.createElement("span", {
|
|
14428
14342
|
key: part.key,
|
|
14429
14343
|
className: "dim-jh-badgeNotePart",
|
|
14430
14344
|
"data-tone": part.tone,
|
|
@@ -14444,14 +14358,14 @@ function UsageBadgeActive(props) {
|
|
|
14444
14358
|
...part.countdown === void 0 ? {} : { title: `最早作废:${part.countdown}` }
|
|
14445
14359
|
}, part.countdown === void 0 ? part.text : `${part.text}(${part.countdown})`));
|
|
14446
14360
|
});
|
|
14447
|
-
return
|
|
14361
|
+
return React8.createElement("div", { key: "note", className: "dim-jh-badgeRowNote" }, children);
|
|
14448
14362
|
}
|
|
14449
14363
|
function renderClaim() {
|
|
14450
14364
|
const canClaimCurrent = supportsDailyCheckin(provider);
|
|
14451
14365
|
const allBusy = claiming === "all";
|
|
14452
|
-
return
|
|
14453
|
-
|
|
14454
|
-
canClaimCurrent ?
|
|
14366
|
+
return React8.createElement("div", { key: "claim", className: "dim-jh-badgeSection dim-jh-badgeClaim" }, [
|
|
14367
|
+
React8.createElement("div", { key: "row", className: "dim-jh-badgeClaimRow" }, [
|
|
14368
|
+
canClaimCurrent ? React8.createElement("button", {
|
|
14455
14369
|
key: "cur",
|
|
14456
14370
|
type: "button",
|
|
14457
14371
|
className: "dim-jh-badgeAction",
|
|
@@ -14466,7 +14380,7 @@ function UsageBadgeActive(props) {
|
|
|
14466
14380
|
void onClaim();
|
|
14467
14381
|
}
|
|
14468
14382
|
}, claiming === "current" ? "领取中…" : "签到(本渠道)") : null,
|
|
14469
|
-
|
|
14383
|
+
React8.createElement("button", {
|
|
14470
14384
|
key: "all",
|
|
14471
14385
|
type: "button",
|
|
14472
14386
|
className: "dim-jh-badgeAction",
|
|
@@ -14489,19 +14403,19 @@ function UsageBadgeActive(props) {
|
|
|
14489
14403
|
* (WorkBuddy 国际版 / Cline / Raccoon 后端没有签到接口,Raccoon 的每日积分由
|
|
14490
14404
|
* 服务端自动发放)。少了这一句,用户只能靠猜。
|
|
14491
14405
|
*/
|
|
14492
|
-
canClaimCurrent ? null :
|
|
14406
|
+
canClaimCurrent ? null : React8.createElement(
|
|
14493
14407
|
"div",
|
|
14494
14408
|
{ key: "nocount", className: "dim-jh-badgeNote" },
|
|
14495
14409
|
"该渠道没有签到接口,签到请用「全部渠道签到」"
|
|
14496
14410
|
),
|
|
14497
|
-
claimNotice === null ? null :
|
|
14411
|
+
claimNotice === null ? null : React8.createElement("div", {
|
|
14498
14412
|
key: "notice",
|
|
14499
14413
|
className: "dim-jh-badgeNotice",
|
|
14500
14414
|
"data-tone": claimNotice.tone
|
|
14501
14415
|
}, claimNotice.text),
|
|
14502
14416
|
// 「需要用户操作」的提示单独列出(后端显式字段 actionRequired),
|
|
14503
14417
|
// 混进计数行会被读漏,而它的价值就在于被看到。
|
|
14504
|
-
...(claimNotice?.notes || []).map((message, index) =>
|
|
14418
|
+
...(claimNotice?.notes || []).map((message, index) => React8.createElement("div", {
|
|
14505
14419
|
key: `note-${index}`,
|
|
14506
14420
|
className: "dim-jh-badgeNotice",
|
|
14507
14421
|
"data-tone": "warn"
|
|
@@ -14515,12 +14429,12 @@ function UsageBadgeActive(props) {
|
|
|
14515
14429
|
const running = auto.running === true;
|
|
14516
14430
|
if (!running && channels.length === 0) return null;
|
|
14517
14431
|
const stamp = running ? "" : formatUpdatedAt(auto.lastAt);
|
|
14518
|
-
return
|
|
14432
|
+
return React8.createElement("div", { key: "autostatus", className: "dim-jh-badgeAutoStatus" }, [
|
|
14519
14433
|
// 小关闭按钮在**文字上方**(用户:「在文字上方放个小按钮,点击直接关闭」)。
|
|
14520
|
-
|
|
14434
|
+
React8.createElement(
|
|
14521
14435
|
"div",
|
|
14522
14436
|
{ key: "closerow", className: "dim-jh-badgeAutoCloseRow" },
|
|
14523
|
-
|
|
14437
|
+
React8.createElement("button", {
|
|
14524
14438
|
key: "close",
|
|
14525
14439
|
type: "button",
|
|
14526
14440
|
className: "dim-jh-badgeAutoClose",
|
|
@@ -14531,409 +14445,210 @@ function UsageBadgeActive(props) {
|
|
|
14531
14445
|
}
|
|
14532
14446
|
}, "×")
|
|
14533
14447
|
),
|
|
14534
|
-
|
|
14448
|
+
React8.createElement(
|
|
14535
14449
|
"div",
|
|
14536
14450
|
{ key: "head", className: "dim-jh-badgeAutoStatusHead" },
|
|
14537
14451
|
running ? "自动签到 · 进行中…" : `自动签到${stamp === "" ? "" : ` · ${stamp}`}:${auto.lastResult}`
|
|
14538
14452
|
),
|
|
14539
|
-
channels.length === 0 ? null :
|
|
14453
|
+
channels.length === 0 ? null : React8.createElement(
|
|
14540
14454
|
"div",
|
|
14541
14455
|
{ key: "channels", className: "dim-jh-badgeAutoChannels" },
|
|
14542
|
-
channels.map((entry2, index) =>
|
|
14456
|
+
channels.map((entry2, index) => React8.createElement("span", {
|
|
14543
14457
|
key: `${entry2.provider}-${index}`,
|
|
14544
14458
|
className: "dim-jh-badgeAutoChannel"
|
|
14545
14459
|
}, `${providerLabel2(entry2.provider)} ${entry2.text}`))
|
|
14546
14460
|
)
|
|
14547
|
-
]);
|
|
14548
|
-
}
|
|
14549
|
-
function renderFoot() {
|
|
14550
|
-
const parts = [];
|
|
14551
|
-
if (value?.disabledCount > 0) parts.push(`另有 ${value.disabledCount} 个账号已停用,未计入`);
|
|
14552
|
-
if (view.failedCount > 0) parts.push(view.incompleteNote === "" ? `${view.failedCount} 个账号读取失败` : view.incompleteNote);
|
|
14553
|
-
if (failed && snapshot !== null) parts.push("本次刷新失败,显示的是上一次读数");
|
|
14554
|
-
if (parts.length === 0) return null;
|
|
14555
|
-
return
|
|
14556
|
-
}
|
|
14557
|
-
}
|
|
14558
|
-
function balanceLine(balance) {
|
|
14559
|
-
const packages = balance.packages || [];
|
|
14560
|
-
const unit = packages.find((pkg) => pkg && pkg.unit)?.unit;
|
|
14561
|
-
const quota = formatQuotaLine(packages, unit);
|
|
14562
|
-
if (quota !== null) return quota;
|
|
14563
|
-
const text = formatUnits(balance.total, unit) ?? "0";
|
|
14564
|
-
return `${text}${unitLabel(unit)}`;
|
|
14565
|
-
}
|
|
14566
|
-
function splitParts(balance, windowDays, provider) {
|
|
14567
|
-
const packages = balance.packages || [];
|
|
14568
|
-
const unit = packages.find((pkg) => pkg && pkg.unit)?.unit;
|
|
14569
|
-
if (unit === QUOTA_UNIT) {
|
|
14570
|
-
const parts2 = [];
|
|
14571
|
-
for (const pkg of packages) {
|
|
14572
|
-
if (!pkg) continue;
|
|
14573
|
-
const left = quotaResetsIn(pkg.cycleEndTime);
|
|
14574
|
-
if (left.length > 0) parts2.push({ key: pkg.name || "unnamed", text: `${pkg.name || "未命名"} ${left}`, tone: "muted" });
|
|
14575
|
-
}
|
|
14576
|
-
return parts2;
|
|
14577
|
-
}
|
|
14578
|
-
const format = (value) => formatUnits(value, unit);
|
|
14579
|
-
const poolText = formatPoolSplitLine(packages, format, provider === "loomy" ? "永久" : "长期");
|
|
14580
|
-
if (poolText !== null) return [{ key: "pool", text: poolText, tone: "muted" }];
|
|
14581
|
-
const now = Date.now();
|
|
14582
|
-
const parts = expirySplitParts(splitCreditsByExpiry(packages, windowDays, now), format, now);
|
|
14583
|
-
const exclusive = exclusivePoolRemainingOf(packages);
|
|
14584
|
-
if (exclusive > 0) {
|
|
14585
|
-
parts.push({ key: "exclusive", text: `另有 ${format(exclusive)} 专属(不计入)`, tone: "muted" });
|
|
14586
|
-
}
|
|
14587
|
-
return parts;
|
|
14588
|
-
}
|
|
14589
|
-
function summarizeClaim(result) {
|
|
14590
|
-
const summary = result?.summary;
|
|
14591
|
-
if (summary === void 0) return { tone: "ok", text: "签到完成", notes: [] };
|
|
14592
|
-
const parts = [];
|
|
14593
|
-
if (summary.claimed > 0) {
|
|
14594
|
-
const amount = formatClaimGains(
|
|
14595
|
-
summary.totalByUnit || { credit: Number(summary.totalCredit) || 0, token: 0 }
|
|
14596
|
-
);
|
|
14597
|
-
parts.push(amount === null ? `${summary.claimed} 个账号领取成功` : `${summary.claimed} 个账号领取成功,共 ${amount}`);
|
|
14598
|
-
}
|
|
14599
|
-
if (summary.alreadyClaimed > 0) parts.push(`${summary.alreadyClaimed} 个今天已领`);
|
|
14600
|
-
if (summary.inactive > 0) parts.push(`${summary.inactive} 个活动未开启`);
|
|
14601
|
-
if (summary.failed > 0) {
|
|
14602
|
-
const reason = (result.results || []).find((row) => row?.outcome?.kind === "failed")?.outcome?.message;
|
|
14603
|
-
parts.push(`${summary.failed} 个失败${reason ? `:${reason}` : ""}`);
|
|
14604
|
-
}
|
|
14605
|
-
const notes = (result?.results || []).map((row) => row?.outcome).filter((outcome) => outcome?.actionRequired === true && typeof outcome.message === "string" && outcome.message.length > 0).map((outcome) => outcome.message).filter((message, index, all) => all.indexOf(message) === index);
|
|
14606
|
-
return {
|
|
14607
|
-
tone: summary.failed > 0 || notes.length > 0 ? "warn" : "ok",
|
|
14608
|
-
text: parts.length === 0 ? "签到完成(无可领取的账号)" : parts.join(";"),
|
|
14609
|
-
notes
|
|
14610
|
-
};
|
|
14611
|
-
}
|
|
14612
|
-
|
|
14613
|
-
// plugin-src/client/panel-entry.js
|
|
14614
|
-
var React8 = __toESM(require("react"), 1);
|
|
14615
|
-
|
|
14616
|
-
// plugin-src/client/error-boundary.js
|
|
14617
|
-
var React7 = __toESM(require("react"), 1);
|
|
14618
|
-
var NO_ERROR = Symbol("jet-hub:no-error");
|
|
14619
|
-
function describeThrown(error) {
|
|
14620
|
-
try {
|
|
14621
|
-
if (error !== null && error !== void 0 && typeof error.message === "string" && error.message.length > 0) {
|
|
14622
|
-
return error.message;
|
|
14623
|
-
}
|
|
14624
|
-
} catch {
|
|
14625
|
-
}
|
|
14626
|
-
try {
|
|
14627
|
-
return String(error);
|
|
14628
|
-
} catch {
|
|
14629
|
-
return "(抛出值无法转为文本,请查看控制台)";
|
|
14630
|
-
}
|
|
14631
|
-
}
|
|
14632
|
-
function withErrorBoundary(Inner, options) {
|
|
14633
|
-
const label = options !== null && typeof options === "object" && typeof options.label === "string" && options.label.length > 0 ? options.label : "这个面板";
|
|
14634
|
-
class PanelErrorBoundary extends React7.Component {
|
|
14635
|
-
constructor(props) {
|
|
14636
|
-
super(props);
|
|
14637
|
-
this.state = { error: NO_ERROR };
|
|
14638
|
-
}
|
|
14639
|
-
static getDerivedStateFromError(error) {
|
|
14640
|
-
return { error };
|
|
14641
|
-
}
|
|
14642
|
-
componentDidCatch(error, info) {
|
|
14643
|
-
console.error(`[jet-hub] ${label}渲染失败,已拦住(页面其余部分继续可用):`, error, info?.componentStack);
|
|
14644
|
-
}
|
|
14645
|
-
render() {
|
|
14646
|
-
const error = this.state.error;
|
|
14647
|
-
if (error === NO_ERROR) return React7.createElement(Inner, this.props);
|
|
14648
|
-
const message = describeThrown(error);
|
|
14649
|
-
return React7.createElement(
|
|
14650
|
-
"div",
|
|
14651
|
-
{
|
|
14652
|
-
className: "dim-jh-probeNotice",
|
|
14653
|
-
"data-tone": "error",
|
|
14654
|
-
role: "alert",
|
|
14655
|
-
style: { margin: "16px" }
|
|
14656
|
-
},
|
|
14657
|
-
React7.createElement("div", null, `${label}渲染失败,已拦住 —— 其余页面仍可正常使用,不必重启。`),
|
|
14658
|
-
React7.createElement("div", { style: { marginTop: "6px", fontFamily: "monospace", fontSize: "12px" } }, message),
|
|
14659
|
-
// ⚠️ **必须给出可自我恢复的出路**(2026-10-25 审计 A3-2)。
|
|
14660
|
-
//
|
|
14661
|
-
// 本 fallback 是**粘性**的:没有 `key`、也没有 `componentDidUpdate`
|
|
14662
|
-
// 重置 ⇒ 同一实例一旦进 error 就永远显示 fallback(数据恢复了也不回来)。
|
|
14663
|
-
// 审计实测:数据恢复后仍显示 fallback,只有**新建实例**才恢复。
|
|
14664
|
-
//
|
|
14665
|
-
// 而用户其实**不必重启**:宿主 `SettingsPanel` 在 `open === false` 时整棵
|
|
14666
|
-
// 不挂载、`main` 是 keyed 槽 ⇒「关掉设置再打开」/「切走再切回」都能恢复。
|
|
14667
|
-
// 但**这条路径不可发现** —— 用户看到一块报错,不知道关掉再打开就能好。
|
|
14668
|
-
//
|
|
14669
|
-
// ⇒ 两件事:①给一个**就地重试**(`setState` 回 `NO_ERROR`,子树随即重挂载,
|
|
14670
|
-
// 比让用户摸索「关掉再打开」快得多);②把那条路径**写出来**当兜底。
|
|
14671
|
-
React7.createElement(
|
|
14672
|
-
"div",
|
|
14673
|
-
{ style: { marginTop: "8px" } },
|
|
14674
|
-
React7.createElement("button", {
|
|
14675
|
-
type: "button",
|
|
14676
|
-
className: "dim-jh-btn",
|
|
14677
|
-
onClick: () => {
|
|
14678
|
-
this.setState({ error: NO_ERROR });
|
|
14679
|
-
}
|
|
14680
|
-
}, "重试"),
|
|
14681
|
-
React7.createElement(
|
|
14682
|
-
"span",
|
|
14683
|
-
{ style: { marginLeft: "8px", opacity: 0.75 } },
|
|
14684
|
-
"也可以关掉这一节再重新打开(或切到别的页面再切回来)来恢复。"
|
|
14685
|
-
)
|
|
14686
|
-
),
|
|
14687
|
-
React7.createElement(
|
|
14688
|
-
"div",
|
|
14689
|
-
{ style: { marginTop: "6px" } },
|
|
14690
|
-
"这是插件的缺陷,不是你操作错了。把上面这行报错连同「当时点了什么」一起反馈即可。"
|
|
14691
|
-
)
|
|
14692
|
-
);
|
|
14693
|
-
}
|
|
14694
|
-
}
|
|
14695
|
-
PanelErrorBoundary.displayName = `withErrorBoundary(${Inner.displayName || Inner.name || "Component"})`;
|
|
14696
|
-
return PanelErrorBoundary;
|
|
14697
|
-
}
|
|
14698
|
-
|
|
14699
|
-
// plugin-src/client/panel-entry-store.js
|
|
14700
|
-
var VALID_ENTRIES = ["sidebar", "settings"];
|
|
14701
|
-
var FALLBACK_ENTRY = "sidebar";
|
|
14702
|
-
var JET_HUB_PANEL_KEY = "jet-hub";
|
|
14703
|
-
var JET_HUB_SIDEBAR_ORDER = 20;
|
|
14704
|
-
var PANEL_ENTRY_READ_TIMEOUT_MS = 5e3;
|
|
14705
|
-
var PANEL_ENTRY_READ_ATTEMPTS = 3;
|
|
14706
|
-
var PANEL_ENTRY_RETRY_DELAY_MS = 200;
|
|
14707
|
-
function delay(ms) {
|
|
14708
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14709
|
-
}
|
|
14710
|
-
var entry = null;
|
|
14711
|
-
var readFailed = false;
|
|
14712
|
-
var inflight = null;
|
|
14713
|
-
var writeSeq = 0;
|
|
14714
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
14715
|
-
function normalize(raw) {
|
|
14716
|
-
return typeof raw === "string" && VALID_ENTRIES.includes(raw) ? raw : null;
|
|
14717
|
-
}
|
|
14718
|
-
function panelEntry() {
|
|
14719
|
-
return entry;
|
|
14720
|
-
}
|
|
14721
|
-
function panelEntryShowsSidebar() {
|
|
14722
|
-
return entry !== "settings";
|
|
14723
|
-
}
|
|
14724
|
-
function panelEntryShowsSettings() {
|
|
14725
|
-
return entry === "settings";
|
|
14726
|
-
}
|
|
14727
|
-
function panelEntryReadFailed() {
|
|
14728
|
-
return readFailed;
|
|
14729
|
-
}
|
|
14730
|
-
function subscribePanelEntry(listener) {
|
|
14731
|
-
listeners.add(listener);
|
|
14732
|
-
return () => {
|
|
14733
|
-
listeners.delete(listener);
|
|
14734
|
-
};
|
|
14735
|
-
}
|
|
14736
|
-
function publish(nextEntry, nextFailed) {
|
|
14737
|
-
if (entry === nextEntry && readFailed === nextFailed) return;
|
|
14738
|
-
entry = nextEntry;
|
|
14739
|
-
readFailed = nextFailed;
|
|
14740
|
-
for (const listener of [...listeners]) {
|
|
14741
|
-
try {
|
|
14742
|
-
listener();
|
|
14743
|
-
} catch (caught) {
|
|
14744
|
-
console.error("[jet-hub] 面板入口监听器抛错", caught);
|
|
14745
|
-
}
|
|
14461
|
+
]);
|
|
14462
|
+
}
|
|
14463
|
+
function renderFoot() {
|
|
14464
|
+
const parts = [];
|
|
14465
|
+
if (value?.disabledCount > 0) parts.push(`另有 ${value.disabledCount} 个账号已停用,未计入`);
|
|
14466
|
+
if (view.failedCount > 0) parts.push(view.incompleteNote === "" ? `${view.failedCount} 个账号读取失败` : view.incompleteNote);
|
|
14467
|
+
if (failed && snapshot !== null) parts.push("本次刷新失败,显示的是上一次读数");
|
|
14468
|
+
if (parts.length === 0) return null;
|
|
14469
|
+
return React8.createElement("div", { key: "foot", className: "dim-jh-badgeFoot" }, parts.join(" · "));
|
|
14746
14470
|
}
|
|
14747
14471
|
}
|
|
14748
|
-
function
|
|
14749
|
-
|
|
14750
|
-
|
|
14472
|
+
function balanceLine(balance) {
|
|
14473
|
+
const packages = balance.packages || [];
|
|
14474
|
+
const unit = packages.find((pkg) => pkg && pkg.unit)?.unit;
|
|
14475
|
+
const quota = formatQuotaLine(packages, unit);
|
|
14476
|
+
if (quota !== null) return quota;
|
|
14477
|
+
const text = formatUnits(balance.total, unit) ?? "0";
|
|
14478
|
+
return `${text}${unitLabel(unit)}`;
|
|
14479
|
+
}
|
|
14480
|
+
function splitParts(balance, windowDays, provider) {
|
|
14481
|
+
const packages = balance.packages || [];
|
|
14482
|
+
const unit = packages.find((pkg) => pkg && pkg.unit)?.unit;
|
|
14483
|
+
if (unit === QUOTA_UNIT) {
|
|
14484
|
+
const parts2 = [];
|
|
14485
|
+
for (const pkg of packages) {
|
|
14486
|
+
if (!pkg) continue;
|
|
14487
|
+
const left = quotaResetsIn(pkg.cycleEndTime);
|
|
14488
|
+
if (left.length > 0) parts2.push({ key: pkg.name || "unnamed", text: `${pkg.name || "未命名"} ${left}`, tone: "muted" });
|
|
14489
|
+
}
|
|
14490
|
+
return parts2;
|
|
14751
14491
|
}
|
|
14752
|
-
|
|
14753
|
-
const
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14492
|
+
const format = (value) => formatUnits(value, unit);
|
|
14493
|
+
const poolText = formatPoolSplitLine(packages, format, provider === "loomy" ? "永久" : "长期");
|
|
14494
|
+
if (poolText !== null) return [{ key: "pool", text: poolText, tone: "muted" }];
|
|
14495
|
+
const now = Date.now();
|
|
14496
|
+
const parts = expirySplitParts(splitCreditsByExpiry(packages, windowDays, now), format, now);
|
|
14497
|
+
const exclusive = exclusivePoolRemainingOf(packages);
|
|
14498
|
+
if (exclusive > 0) {
|
|
14499
|
+
parts.push({ key: "exclusive", text: `另有 ${format(exclusive)} 专属(不计入)`, tone: "muted" });
|
|
14757
14500
|
}
|
|
14758
|
-
|
|
14759
|
-
return controller.signal;
|
|
14501
|
+
return parts;
|
|
14760
14502
|
}
|
|
14761
|
-
function
|
|
14762
|
-
|
|
14763
|
-
|
|
14764
|
-
const
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
const result = await rpcCall("panelEntry.get", {}, readSignal());
|
|
14769
|
-
if (writeSeq !== seqAtStart) return entry ?? FALLBACK_ENTRY;
|
|
14770
|
-
const next = normalize(result?.entry);
|
|
14771
|
-
if (next !== null) {
|
|
14772
|
-
publish(next, false);
|
|
14773
|
-
} else {
|
|
14774
|
-
publish(entry ?? FALLBACK_ENTRY, true);
|
|
14775
|
-
}
|
|
14776
|
-
return entry ?? FALLBACK_ENTRY;
|
|
14777
|
-
} catch (caught) {
|
|
14778
|
-
lastError = caught;
|
|
14779
|
-
if (writeSeq !== seqAtStart) return entry ?? FALLBACK_ENTRY;
|
|
14780
|
-
if (attempt >= PANEL_ENTRY_READ_ATTEMPTS) break;
|
|
14781
|
-
await delay(PANEL_ENTRY_RETRY_DELAY_MS * attempt);
|
|
14782
|
-
if (writeSeq !== seqAtStart) return entry ?? FALLBACK_ENTRY;
|
|
14783
|
-
}
|
|
14784
|
-
}
|
|
14785
|
-
console.warn(
|
|
14786
|
-
`[jet-hub] 读取面板入口偏好失败,按仅侧栏处理(已重试 ${PANEL_ENTRY_READ_ATTEMPTS - 1} 次)`,
|
|
14787
|
-
lastError
|
|
14503
|
+
function summarizeClaim(result) {
|
|
14504
|
+
const summary = result?.summary;
|
|
14505
|
+
if (summary === void 0) return { tone: "ok", text: "签到完成", notes: [] };
|
|
14506
|
+
const parts = [];
|
|
14507
|
+
if (summary.claimed > 0) {
|
|
14508
|
+
const amount = formatClaimGains(
|
|
14509
|
+
summary.totalByUnit || { credit: Number(summary.totalCredit) || 0, token: 0 }
|
|
14788
14510
|
);
|
|
14789
|
-
|
|
14790
|
-
return entry ?? FALLBACK_ENTRY;
|
|
14791
|
-
})();
|
|
14792
|
-
inflight = task;
|
|
14793
|
-
const clear = () => {
|
|
14794
|
-
if (inflight === task) inflight = null;
|
|
14795
|
-
};
|
|
14796
|
-
void task.then(clear, clear);
|
|
14797
|
-
return task;
|
|
14798
|
-
}
|
|
14799
|
-
async function setPanelEntry(rpcCall, next) {
|
|
14800
|
-
const result = await rpcCall("panelEntry.set", { entry: next });
|
|
14801
|
-
const confirmed = normalize(result?.entry);
|
|
14802
|
-
if (confirmed === null) {
|
|
14803
|
-
throw new Error("面板入口偏好没有返回合法 entry");
|
|
14511
|
+
parts.push(amount === null ? `${summary.claimed} 个账号领取成功` : `${summary.claimed} 个账号领取成功,共 ${amount}`);
|
|
14804
14512
|
}
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14513
|
+
if (summary.alreadyClaimed > 0) parts.push(`${summary.alreadyClaimed} 个今天已领`);
|
|
14514
|
+
if (summary.inactive > 0) parts.push(`${summary.inactive} 个活动未开启`);
|
|
14515
|
+
if (summary.failed > 0) {
|
|
14516
|
+
const reason = (result.results || []).find((row) => row?.outcome?.kind === "failed")?.outcome?.message;
|
|
14517
|
+
parts.push(`${summary.failed} 个失败${reason ? `:${reason}` : ""}`);
|
|
14518
|
+
}
|
|
14519
|
+
const notes = (result?.results || []).map((row) => row?.outcome).filter((outcome) => outcome?.actionRequired === true && typeof outcome.message === "string" && outcome.message.length > 0).map((outcome) => outcome.message).filter((message, index, all) => all.indexOf(message) === index);
|
|
14520
|
+
return {
|
|
14521
|
+
tone: summary.failed > 0 || notes.length > 0 ? "warn" : "ok",
|
|
14522
|
+
text: parts.length === 0 ? "签到完成(无可领取的账号)" : parts.join(";"),
|
|
14523
|
+
notes
|
|
14524
|
+
};
|
|
14808
14525
|
}
|
|
14809
14526
|
|
|
14810
|
-
// plugin-src/client/panel
|
|
14811
|
-
var
|
|
14812
|
-
var
|
|
14813
|
-
|
|
14527
|
+
// plugin-src/client/usage-panel.js
|
|
14528
|
+
var USAGE_PANEL_KEY = "jet-hub-usage";
|
|
14529
|
+
var USAGE_SIDEBAR_ORDER = 21;
|
|
14530
|
+
var AUTO_ENTRY_LABEL = "自动 · 临期优先";
|
|
14531
|
+
function usagePanelProviders() {
|
|
14532
|
+
return [
|
|
14533
|
+
{ id: AUTO_PROVIDER_ID, label: AUTO_ENTRY_LABEL },
|
|
14534
|
+
...PROVIDER_REGISTRY.filter((d) => supportsCreditBalance(d.id)).map((d) => ({ id: d.id, label: d.label }))
|
|
14535
|
+
];
|
|
14536
|
+
}
|
|
14537
|
+
function UsageSidebarIcon({ size }) {
|
|
14814
14538
|
const px = typeof size === "number" && size > 0 ? size : 16;
|
|
14815
|
-
return
|
|
14816
|
-
|
|
14817
|
-
|
|
14818
|
-
|
|
14819
|
-
|
|
14820
|
-
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
|
|
14825
|
-
|
|
14826
|
-
|
|
14539
|
+
return React9.createElement("svg", {
|
|
14540
|
+
width: px,
|
|
14541
|
+
height: px,
|
|
14542
|
+
viewBox: "0 0 16 16",
|
|
14543
|
+
fill: "none",
|
|
14544
|
+
"aria-hidden": "true"
|
|
14545
|
+
}, [
|
|
14546
|
+
React9.createElement("ellipse", {
|
|
14547
|
+
key: "top",
|
|
14548
|
+
cx: 8,
|
|
14549
|
+
cy: 4.2,
|
|
14550
|
+
rx: 5.2,
|
|
14551
|
+
ry: 2.6,
|
|
14552
|
+
stroke: "currentColor",
|
|
14553
|
+
strokeWidth: 1.35
|
|
14554
|
+
}),
|
|
14555
|
+
React9.createElement("path", {
|
|
14556
|
+
key: "mid",
|
|
14557
|
+
d: "M2.8 4.2v3.3c0 1.44 2.33 2.6 5.2 2.6s5.2-1.16 5.2-2.6V4.2",
|
|
14827
14558
|
stroke: "currentColor",
|
|
14828
14559
|
strokeWidth: 1.35,
|
|
14829
|
-
|
|
14560
|
+
strokeLinecap: "round"
|
|
14830
14561
|
}),
|
|
14831
|
-
|
|
14832
|
-
|
|
14562
|
+
React9.createElement("path", {
|
|
14563
|
+
key: "bot",
|
|
14564
|
+
d: "M2.8 7.5v3.3c0 1.44 2.33 2.6 5.2 2.6s5.2-1.16 5.2-2.6V7.5",
|
|
14565
|
+
stroke: "currentColor",
|
|
14566
|
+
strokeWidth: 1.35,
|
|
14567
|
+
strokeLinecap: "round"
|
|
14568
|
+
})
|
|
14569
|
+
]);
|
|
14833
14570
|
}
|
|
14834
|
-
|
|
14571
|
+
var UsagePanelPageForMain = withErrorBoundary(UsagePanelPage, { label: "积分用量面板" });
|
|
14572
|
+
function UsagePanelMain({ rpcCall }) {
|
|
14835
14573
|
if (typeof rpcCall !== "function") return null;
|
|
14836
|
-
return
|
|
14574
|
+
return React9.createElement(
|
|
14837
14575
|
"div",
|
|
14838
|
-
{ className: "dim-jh-panelHost", "data-plugin": "@xixka/dsh-hub" },
|
|
14839
|
-
|
|
14576
|
+
{ className: "dim-jh-panelHost dim-jh-usageHost", "data-plugin": "@xixka/dsh-hub" },
|
|
14577
|
+
React9.createElement(UsagePanelPageForMain, { rpcCall })
|
|
14840
14578
|
);
|
|
14841
14579
|
}
|
|
14842
|
-
function
|
|
14580
|
+
function UsagePanelPage({ rpcCall }) {
|
|
14581
|
+
const [provider, setProvider] = React9.useState(AUTO_PROVIDER_ID);
|
|
14582
|
+
const entries = React9.useMemo(usagePanelProviders, []);
|
|
14583
|
+
const api = React9.useMemo(() => ({
|
|
14584
|
+
providerLabel,
|
|
14585
|
+
readBadge: (target, options) => rpcCall("usage.badge", { provider: target, ...options }),
|
|
14586
|
+
// 显示偏好(自动 / 优先订阅 / 只看积分):宿主回落语义见 usage-badge.js 的 renderPreference。
|
|
14587
|
+
writePreference: (preference) => rpcCall("usage.badgePreference", { preference }),
|
|
14588
|
+
// 自动签到开关(全局一个,不分渠道):宿主在「打开」时会立刻跑一轮。
|
|
14589
|
+
setAutoCheckin: (enabled) => rpcCall("usage.autoCheckin", { enabled }),
|
|
14590
|
+
// 关闭那行常驻的自动签到状态文字(只关当前这一轮,下一轮会重新出现)。
|
|
14591
|
+
dismissAutoCheckin: () => rpcCall("usage.autoCheckin", { dismiss: true }),
|
|
14592
|
+
// 一键领取:每日签到 + (buddy / workbuddy 的)成长中心任务。
|
|
14593
|
+
//
|
|
14594
|
+
// ⚠️ runTasks 缺省**必须为 false** —— 同一个方法也是「每日首次启动自动签到」
|
|
14595
|
+
// 的执行体(宿主 auto-checkin 的 claim 回调)。成长一轮单账号 90~270s、
|
|
14596
|
+
// 全串行,默认开启等于每次开机自动打几十个上游请求。
|
|
14597
|
+
// budgetMs 缺省由宿主取 10 分钟;传 0 或负数表示不限时。
|
|
14598
|
+
claimCredits: (target, runTasks, budgetMs) => rpcCall("credits.claimAll", { provider: target, runTasks, budgetMs })
|
|
14599
|
+
}), [rpcCall]);
|
|
14600
|
+
return React9.createElement("div", { className: "dim-jh-usagePanel" }, [
|
|
14601
|
+
React9.createElement("div", { key: "head", className: "dim-jh-usageHead" }, [
|
|
14602
|
+
React9.createElement("h2", { key: "title", className: "dim-jh-usageTitle" }, "积分用量"),
|
|
14603
|
+
React9.createElement(
|
|
14604
|
+
"div",
|
|
14605
|
+
{ key: "sub", className: "dim-jh-usageSub" },
|
|
14606
|
+
"各渠道的余额、订阅与签到。账号的添加、启停与改名仍在 Jet Hub 设置页。"
|
|
14607
|
+
)
|
|
14608
|
+
]),
|
|
14609
|
+
/**
|
|
14610
|
+
* 渠道选择器:按钮组 + `aria-pressed`(本仓库无 <select> 先例,偏好分段
|
|
14611
|
+
* 控件同款做法)。chips 自动换行 —— 十几个渠道在窄面板里一行放不下。
|
|
14612
|
+
*/
|
|
14613
|
+
React9.createElement("div", {
|
|
14614
|
+
key: "rail",
|
|
14615
|
+
className: "dim-jh-usageRail",
|
|
14616
|
+
role: "group",
|
|
14617
|
+
"aria-label": "选择要查看用量的渠道"
|
|
14618
|
+
}, entries.map((entry2) => React9.createElement("button", {
|
|
14619
|
+
key: entry2.id,
|
|
14620
|
+
type: "button",
|
|
14621
|
+
className: "dim-jh-usageChip",
|
|
14622
|
+
"aria-pressed": provider === entry2.id,
|
|
14623
|
+
"data-active": provider === entry2.id ? "true" : "false",
|
|
14624
|
+
title: entry2.id === AUTO_PROVIDER_ID ? "自动路由(临期优先)当前实际使用的渠道的用量" : `${entry2.label} 的用量`,
|
|
14625
|
+
onClick: () => {
|
|
14626
|
+
setProvider(entry2.id);
|
|
14627
|
+
}
|
|
14628
|
+
}, entry2.label))),
|
|
14629
|
+
React9.createElement(UsageBadgeCard, {
|
|
14630
|
+
key: "card",
|
|
14631
|
+
provider,
|
|
14632
|
+
...api
|
|
14633
|
+
})
|
|
14634
|
+
]);
|
|
14635
|
+
}
|
|
14636
|
+
function registerUsagePanelEntries(ctx, rpcCall) {
|
|
14843
14637
|
ctx.slots.inject("main", () => ctx.slots.register({
|
|
14844
14638
|
name: "main",
|
|
14845
|
-
key:
|
|
14639
|
+
key: USAGE_PANEL_KEY,
|
|
14846
14640
|
inject: () => ({ rpcCall })
|
|
14847
|
-
},
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
});
|
|
14855
|
-
const deselectIfActive = () => {
|
|
14856
|
-
try {
|
|
14857
|
-
if (layout?.panelInfo?.getSnapshot?.()?.activePanelId !== JET_HUB_PANEL_KEY) return;
|
|
14858
|
-
layout.selectPanel(null);
|
|
14859
|
-
} catch (caught) {
|
|
14860
|
-
console.warn("[jet-hub] 撤销侧栏入口时取消选中失败", caught);
|
|
14861
|
-
}
|
|
14862
|
-
};
|
|
14863
|
-
ctx.slots.inject("sidebar.panellist", () => {
|
|
14864
|
-
let stopRow;
|
|
14865
|
-
const sync = (visible) => {
|
|
14866
|
-
if (visible && stopRow === void 0) {
|
|
14867
|
-
stopRow = ctx.slots.register({
|
|
14868
|
-
name: "sidebar.panellist",
|
|
14869
|
-
id: JET_HUB_PANEL_KEY,
|
|
14870
|
-
order: JET_HUB_SIDEBAR_ORDER,
|
|
14871
|
-
label: () => "Jet Hub"
|
|
14872
|
-
}, JetHubSidebarIcon);
|
|
14873
|
-
return;
|
|
14874
|
-
}
|
|
14875
|
-
if (!visible && stopRow !== void 0) {
|
|
14876
|
-
const stop = stopRow;
|
|
14877
|
-
stopRow = void 0;
|
|
14878
|
-
stop();
|
|
14879
|
-
deselectIfActive();
|
|
14880
|
-
}
|
|
14881
|
-
};
|
|
14882
|
-
const unsubscribe = subscribePanelEntry(() => sync(panelEntryShowsSidebar()));
|
|
14883
|
-
sync(panelEntryShowsSidebar());
|
|
14884
|
-
let disposed = false;
|
|
14885
|
-
void loadPanelEntry(rpcCall).then(() => {
|
|
14886
|
-
if (!disposed) sync(panelEntryShowsSidebar());
|
|
14887
|
-
});
|
|
14888
|
-
return () => {
|
|
14889
|
-
disposed = true;
|
|
14890
|
-
unsubscribe();
|
|
14891
|
-
if (stopRow !== void 0) {
|
|
14892
|
-
const stop = stopRow;
|
|
14893
|
-
stopRow = void 0;
|
|
14894
|
-
stop();
|
|
14895
|
-
}
|
|
14896
|
-
};
|
|
14897
|
-
});
|
|
14898
|
-
ctx.slots.inject("settings.section", () => {
|
|
14899
|
-
let stopSection;
|
|
14900
|
-
const sync = (visible) => {
|
|
14901
|
-
if (visible && stopSection === void 0) {
|
|
14902
|
-
stopSection = ctx.slots.register({
|
|
14903
|
-
name: "settings.section",
|
|
14904
|
-
id: JET_HUB_PANEL_KEY,
|
|
14905
|
-
order: 50,
|
|
14906
|
-
label: () => "Jet Hub",
|
|
14907
|
-
inject: () => ({ rpcCall })
|
|
14908
|
-
}, JetHubPageForSettings);
|
|
14909
|
-
return;
|
|
14910
|
-
}
|
|
14911
|
-
if (!visible && stopSection !== void 0) {
|
|
14912
|
-
const stop = stopSection;
|
|
14913
|
-
stopSection = void 0;
|
|
14914
|
-
stop();
|
|
14915
|
-
}
|
|
14916
|
-
};
|
|
14917
|
-
const unsubscribe = subscribePanelEntry(() => sync(panelEntryShowsSettings()));
|
|
14918
|
-
sync(panelEntryShowsSettings());
|
|
14919
|
-
let disposed = false;
|
|
14920
|
-
void loadPanelEntry(rpcCall).then(() => {
|
|
14921
|
-
if (!disposed) sync(panelEntryShowsSettings());
|
|
14922
|
-
});
|
|
14923
|
-
return () => {
|
|
14924
|
-
disposed = true;
|
|
14925
|
-
unsubscribe();
|
|
14926
|
-
if (stopSection !== void 0) {
|
|
14927
|
-
const stop = stopSection;
|
|
14928
|
-
stopSection = void 0;
|
|
14929
|
-
stop();
|
|
14930
|
-
}
|
|
14931
|
-
};
|
|
14932
|
-
});
|
|
14641
|
+
}, UsagePanelMain));
|
|
14642
|
+
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
14643
|
+
name: "sidebar.panellist",
|
|
14644
|
+
id: USAGE_PANEL_KEY,
|
|
14645
|
+
order: USAGE_SIDEBAR_ORDER,
|
|
14646
|
+
label: () => "积分用量"
|
|
14647
|
+
}, UsageSidebarIcon));
|
|
14933
14648
|
}
|
|
14934
14649
|
|
|
14935
14650
|
// plugin-src/client/settings-card.js
|
|
14936
|
-
var
|
|
14651
|
+
var React10 = __toESM(require("react"), 1);
|
|
14937
14652
|
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
14938
14653
|
var OPTIONS = [
|
|
14939
14654
|
{ id: "sidebar", label: "仅侧栏" },
|
|
@@ -14947,17 +14662,17 @@ function currentEntry() {
|
|
|
14947
14662
|
return panelEntry() ?? "sidebar";
|
|
14948
14663
|
}
|
|
14949
14664
|
function JetHubPanelEntryCard({ rpcCall }) {
|
|
14950
|
-
const [entry2, setEntry] =
|
|
14951
|
-
const [open, setOpen] =
|
|
14952
|
-
const [busy, setBusy] =
|
|
14953
|
-
const [readFailed2, setReadFailed] =
|
|
14954
|
-
const [writeFailed, setWriteFailed] =
|
|
14955
|
-
const busyRef =
|
|
14956
|
-
|
|
14665
|
+
const [entry2, setEntry] = React10.useState(currentEntry);
|
|
14666
|
+
const [open, setOpen] = React10.useState(false);
|
|
14667
|
+
const [busy, setBusy] = React10.useState(false);
|
|
14668
|
+
const [readFailed2, setReadFailed] = React10.useState(() => panelEntryReadFailed());
|
|
14669
|
+
const [writeFailed, setWriteFailed] = React10.useState(false);
|
|
14670
|
+
const busyRef = React10.useRef(false);
|
|
14671
|
+
React10.useEffect(() => subscribePanelEntry(() => {
|
|
14957
14672
|
setEntry(currentEntry());
|
|
14958
14673
|
setReadFailed(panelEntryReadFailed());
|
|
14959
14674
|
}), []);
|
|
14960
|
-
|
|
14675
|
+
React10.useEffect(() => {
|
|
14961
14676
|
if (typeof rpcCall !== "function") return;
|
|
14962
14677
|
void loadPanelEntry(rpcCall).then(() => {
|
|
14963
14678
|
setEntry(currentEntry());
|
|
@@ -14965,7 +14680,7 @@ function JetHubPanelEntryCard({ rpcCall }) {
|
|
|
14965
14680
|
});
|
|
14966
14681
|
}, [rpcCall]);
|
|
14967
14682
|
const selectedLabel = OPTIONS.find((option) => option.id === entry2)?.label ?? OPTIONS[0].label;
|
|
14968
|
-
const choose =
|
|
14683
|
+
const choose = React10.useCallback(async (next) => {
|
|
14969
14684
|
if (typeof rpcCall !== "function") return;
|
|
14970
14685
|
if (busyRef.current) return;
|
|
14971
14686
|
busyRef.current = true;
|
|
@@ -14982,24 +14697,24 @@ function JetHubPanelEntryCard({ rpcCall }) {
|
|
|
14982
14697
|
setBusy(false);
|
|
14983
14698
|
}
|
|
14984
14699
|
}, [rpcCall]);
|
|
14985
|
-
return
|
|
14700
|
+
return React10.createElement(
|
|
14986
14701
|
"div",
|
|
14987
14702
|
{ className: "dim-jh-cardStack" },
|
|
14988
|
-
|
|
14703
|
+
React10.createElement(
|
|
14989
14704
|
"div",
|
|
14990
14705
|
{ className: "dim-jh-cardRow" },
|
|
14991
|
-
|
|
14706
|
+
React10.createElement(
|
|
14992
14707
|
"div",
|
|
14993
14708
|
{ className: "dim-jh-cardRowText" },
|
|
14994
|
-
|
|
14995
|
-
|
|
14709
|
+
React10.createElement("div", { className: "dim-jh-cardTitle" }, CARD_TITLE),
|
|
14710
|
+
React10.createElement(
|
|
14996
14711
|
"div",
|
|
14997
14712
|
{ className: "dim-jh-cardDesc" },
|
|
14998
14713
|
// 两种失败各有各的说法:读失败说「读到的是默认值」,写失败说「刚才那次没存上」。
|
|
14999
14714
|
writeFailed ? CARD_DESC_WRITE_FAILED : readFailed2 ? CARD_DESC_READ_FAILED : CARD_DESC
|
|
15000
14715
|
)
|
|
15001
14716
|
),
|
|
15002
|
-
|
|
14717
|
+
React10.createElement(import_dsh_client_ui_primitives.Menu, {
|
|
15003
14718
|
open,
|
|
15004
14719
|
onClose: () => setOpen(false),
|
|
15005
14720
|
items: OPTIONS.map((option) => ({ id: option.id, label: option.label })),
|
|
@@ -15012,7 +14727,7 @@ function JetHubPanelEntryCard({ rpcCall }) {
|
|
|
15012
14727
|
// ⚠️ **必须开**:卡片在插件页的滚动 detail 列里,就地展开的列表会被
|
|
15013
14728
|
// overflow 裁剪(两个参考实现都踩过并留了这条注释)。
|
|
15014
14729
|
portal: true,
|
|
15015
|
-
anchor:
|
|
14730
|
+
anchor: React10.createElement(
|
|
15016
14731
|
"button",
|
|
15017
14732
|
{
|
|
15018
14733
|
type: "button",
|
|
@@ -15023,7 +14738,7 @@ function JetHubPanelEntryCard({ rpcCall }) {
|
|
|
15023
14738
|
onClick: () => setOpen((value) => !value)
|
|
15024
14739
|
},
|
|
15025
14740
|
selectedLabel,
|
|
15026
|
-
|
|
14741
|
+
React10.createElement(import_dsh_client_ui_primitives.IconChevronDownOutlineRegular, { className: "dim-jh-cardChevron" })
|
|
15027
14742
|
)
|
|
15028
14743
|
})
|
|
15029
14744
|
)
|
|
@@ -15032,9 +14747,8 @@ function JetHubPanelEntryCard({ rpcCall }) {
|
|
|
15032
14747
|
|
|
15033
14748
|
// plugin-src/client/index.js
|
|
15034
14749
|
var name = "jet-hub-client";
|
|
15035
|
-
var inject = ["slots", "connection"
|
|
14750
|
+
var inject = ["slots", "connection"];
|
|
15036
14751
|
var JetHubPanelEntryCardGuarded = withErrorBoundary(JetHubPanelEntryCard, { label: "插件详情页卡片" });
|
|
15037
|
-
var UsageBadgeGuarded = withErrorBoundary(UsageBadge, { label: "用量徽标" });
|
|
15038
14752
|
function apply(ctx) {
|
|
15039
14753
|
ctx.effect(() => installJetHubStyles(), "jet-hub: install styles");
|
|
15040
14754
|
const rpcCall = async (endpoint, payload, signal) => {
|
|
@@ -15048,77 +14762,7 @@ function apply(ctx) {
|
|
|
15048
14762
|
key: "@xixka/dsh-hub",
|
|
15049
14763
|
inject: () => ({ rpcCall })
|
|
15050
14764
|
}, JetHubPanelEntryCardGuarded));
|
|
15051
|
-
ctx
|
|
15052
|
-
name: "conversation.input.right",
|
|
15053
|
-
id: "jet-hub-usage",
|
|
15054
|
-
order: 100,
|
|
15055
|
-
inject: (sessionId) => ({
|
|
15056
|
-
// ⚠️⚠️ **必须惰性取目录,不能在 inject 里取**(真机事故 2026-10-02)。
|
|
15057
|
-
//
|
|
15058
|
-
// 原写法 `directory: ctx.modelDirectories.directoryFor(sessionId).store`
|
|
15059
|
-
// 有两个问题:
|
|
15060
|
-
// 1. `directoryFor` 是**惰性 getter** —— 写 `directoryFor(sessionId).store`
|
|
15061
|
-
// 里的 `.store` 才触发求值,而求值发生在**槽位 inject 期**(即会话
|
|
15062
|
-
// 输入区渲染的同步路径上)。桌面版此时它内部要访问未注入的
|
|
15063
|
-
// `remote.session`,直接抛 `cannot get property "remote.session"
|
|
15064
|
-
// without inject`(Web 版不走那条分支,故只在 desktop 复现)。
|
|
15065
|
-
// 2. 该异常发生在渲染关键路径上,**会让整个会话输入区渲染中断** ——
|
|
15066
|
-
// 表现为模型选择器点不动(用户报障),远不止「徽标不显示」。
|
|
15067
|
-
//
|
|
15068
|
-
// ⇒ 改为交出一个**取值函数** `resolveDirectory()`,由组件在自己的
|
|
15069
|
-
// effect 里调用:失败被组件自身的 try/catch 兜住,影响面收敛到
|
|
15070
|
-
// 「徽标不显示」,绝不影响模型选择器。
|
|
15071
|
-
//
|
|
15072
|
-
// ⚠️⚠️ **必须同时交出 `store` 与 `load`(真机事故 2026-10-02 的真正根因)
|
|
15073
|
-
//
|
|
15074
|
-
// 读 `dsh-client-ui-model-selection` 的 `ModelDirectory` 源码得到两个事实:
|
|
15075
|
-
// ① 它的**公开方法是 `load()` / `syncInputs()`,没有 `getSnapshot()` /
|
|
15076
|
-
// `subscribe()`** —— 那两个在 `this.store` 上。我第一版只交出实例,
|
|
15077
|
-
// 组件调 `directory.getSnapshot()` 得到 `undefined` → TypeError →
|
|
15078
|
-
// 被 safe() 吞掉 → `provider` 恒为空 → **徽标永不显示**。
|
|
15079
|
-
// ② `store` 的初值是 `{ current: null, status: 'idle' }`,**只有
|
|
15080
|
-
// `await load()` 之后** `syncInputs()` 才把真实 `current` 填进去。
|
|
15081
|
-
// 徽标自己不发模型目录请求(`usage.badge` 按 provider 查),
|
|
15082
|
-
// 所以必须由它调 `load()`,否则 `current` 永远是 null。
|
|
15083
|
-
//
|
|
15084
|
-
// 两者缺一不可:只给 store 不 load → current 为 null;
|
|
15085
|
-
// 只给实例不 load 也不 store → getSnapshot 不存在。
|
|
15086
|
-
resolveDirectory: () => {
|
|
15087
|
-
const directory = ctx.modelDirectories.directoryFor(sessionId);
|
|
15088
|
-
return {
|
|
15089
|
-
store: directory.store,
|
|
15090
|
-
load: () => directory.load()
|
|
15091
|
-
};
|
|
15092
|
-
},
|
|
15093
|
-
providerLabel,
|
|
15094
|
-
readBadge: (provider, options) => rpcCall("usage.badge", { provider, ...options }),
|
|
15095
|
-
/**
|
|
15096
|
-
* 聚合 provider「上次**实际**转发成功的渠道」(P3)。
|
|
15097
|
-
*
|
|
15098
|
-
* ⚠️ 宿主侧该端点是**纯内存读**(零网络零余额查询)—— 徽标在**门控阶段**
|
|
15099
|
-
* 就要用它把 `aggregate` 重定向成真实渠道,而门控是同步渲染路径。
|
|
15100
|
-
* ⚠️ 返回 `{ provider: null }` 表示无历史 ⇒ 徽标**不渲染**。
|
|
15101
|
-
*/
|
|
15102
|
-
readActiveProvider: (canonicalId) => rpcCall("aggregate.activeProvider", canonicalId === void 0 ? {} : { canonicalId }),
|
|
15103
|
-
// ⚠️ **这里曾有一个 `readExpiryOrder` prop,已删除**(真实死代码,审计实测指出):
|
|
15104
|
-
// 它在 `c12b3ab` 上就已**零消费者** —— `AggregatePanel` 自己直接
|
|
15105
|
-
// `rpcCall('aggregate.expiryOrder', {})`(`jet-hub.js`),从不经过本 prop。
|
|
15106
|
-
// 本仓库把死代码视为缺陷(会让人以为「面板是通过 prop 取数的」而找错地方)。
|
|
15107
|
-
// ⚠️ 端点本身仍在(`aggregate.expiryOrder`)—— 删的只是这个没人用的转发 prop。
|
|
15108
|
-
writePreference: (preference) => rpcCall("usage.badgePreference", { preference }),
|
|
15109
|
-
// 自动签到开关(全局一个,不分渠道):宿主在「打开」时会立刻跑一轮。
|
|
15110
|
-
setAutoCheckin: (enabled) => rpcCall("usage.autoCheckin", { enabled }),
|
|
15111
|
-
// 关闭那行**常驻**的自动签到状态文字(只关当前这一轮,下一轮会重新出现)。
|
|
15112
|
-
dismissAutoCheckin: () => rpcCall("usage.autoCheckin", { dismiss: true }),
|
|
15113
|
-
// 一键领取:每日签到 + (buddy / workbuddy 的)成长中心任务。
|
|
15114
|
-
//
|
|
15115
|
-
// ⚠️ runTasks 缺省**必须为 false** —— 同一个方法也是「每日首次启动自动签到」
|
|
15116
|
-
// 的执行体(宿主 auto-checkin 的 claim 回调)。成长一轮单账号 90~270s、
|
|
15117
|
-
// 全串行,默认开启等于每次开机自动打几十个上游请求。
|
|
15118
|
-
// budgetMs 缺省由宿主取 10 分钟;传 0 或负数表示不限时。
|
|
15119
|
-
claimCredits: (provider, runTasks, budgetMs) => rpcCall("credits.claimAll", { provider, runTasks, budgetMs })
|
|
15120
|
-
})
|
|
15121
|
-
}, UsageBadgeGuarded));
|
|
14765
|
+
registerUsagePanelEntries(ctx, rpcCall);
|
|
15122
14766
|
}
|
|
15123
14767
|
|
|
15124
14768
|
return module.exports;
|