dsh-sub2api 0.4.2 → 0.4.3
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/CHANGELOG.md +15 -0
- package/lib/client.js +68 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.3
|
|
4
|
+
|
|
5
|
+
Interface polish, driven by an audit against the host's real design tokens.
|
|
6
|
+
|
|
7
|
+
- **Dark mode actually uses the warning colour.** The panel asked for
|
|
8
|
+
`--dsw-alias-state-warning-primary`; DSH defines `state-warn-primary`. The name
|
|
9
|
+
never matched, so the amber fell back to a light-mode value on dark surfaces.
|
|
10
|
+
- Keyboard focus is visible again: inline styles cannot express `:focus-visible`,
|
|
11
|
+
so one scoped stylesheet carries the ring, and buttons, rows and inputs gained
|
|
12
|
+
hover and pressed states that work on both themes.
|
|
13
|
+
- `prefers-reduced-motion` is respected.
|
|
14
|
+
- Model search matches the display name as well as the id, appears from five
|
|
15
|
+
models instead of nine, and reports how many matched.
|
|
16
|
+
- Progress bars are 6px tall with a real `progressbar` role and value.
|
|
17
|
+
|
|
3
18
|
## 0.4.2
|
|
4
19
|
|
|
5
20
|
Recharge and key handling, which are the two places where a mistake costs
|
package/lib/client.js
CHANGED
|
@@ -159,10 +159,41 @@ window.__ModuleLoader__.load({
|
|
|
159
159
|
base: "var(--dsw-alias-bg-base, #ffffff)",
|
|
160
160
|
accent: "var(--dsw-alias-state-business-primary, #2563eb)",
|
|
161
161
|
ok: "var(--dsw-alias-state-success-primary, #15803d)",
|
|
162
|
-
warn
|
|
162
|
+
// DSH names it `warn`, not `warning`: the wrong name silently falls back
|
|
163
|
+
// to this light-mode amber and reads badly on a dark surface.
|
|
164
|
+
warn: "var(--dsw-alias-state-warn-primary, #b45309)",
|
|
163
165
|
bad: "var(--dsw-alias-state-error-primary, #dc2626)",
|
|
164
166
|
};
|
|
165
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Focus rings for keyboard users.
|
|
170
|
+
*
|
|
171
|
+
* Everything here is inline styles, which cannot express `:focus-visible`,
|
|
172
|
+
* so a single scoped stylesheet carries the rule and the roots opt in with
|
|
173
|
+
* `data-sub2api`.
|
|
174
|
+
*/
|
|
175
|
+
const FOCUS_CSS = [
|
|
176
|
+
"[data-sub2api] :focus-visible{outline:2px solid " + C.accent + ";outline-offset:2px;border-radius:8px}",
|
|
177
|
+
"[data-sub2api] input:focus-visible{outline-offset:1px}",
|
|
178
|
+
"[data-sub2api] button:focus:not(:focus-visible){outline:none}",
|
|
179
|
+
// A neutral overlay reads correctly on both light and dark surfaces,
|
|
180
|
+
// which `filter: brightness()` does not.
|
|
181
|
+
"[data-sub2api] [data-sub2api-btn]:not(:disabled):hover{box-shadow:inset 0 0 0 999px rgba(127,127,127,.09)}",
|
|
182
|
+
"[data-sub2api] [data-sub2api-btn]:not(:disabled):active{box-shadow:inset 0 0 0 999px rgba(127,127,127,.16)}",
|
|
183
|
+
"[data-sub2api] [data-sub2api-row]:hover{background:rgba(127,127,127,.055)}",
|
|
184
|
+
"@media (prefers-reduced-motion: reduce){[data-sub2api] *{transition:none!important;animation:none!important}}",
|
|
185
|
+
].join("");
|
|
186
|
+
|
|
187
|
+
function installFocusStyles(doc) {
|
|
188
|
+
const id = "sub2api-focus";
|
|
189
|
+
if (!doc || typeof doc.getElementById !== "function") return;
|
|
190
|
+
if (doc.getElementById(id)) return;
|
|
191
|
+
const style = doc.createElement("style");
|
|
192
|
+
style.id = id;
|
|
193
|
+
style.textContent = FOCUS_CSS;
|
|
194
|
+
(doc.head || doc.documentElement).appendChild(style);
|
|
195
|
+
}
|
|
196
|
+
|
|
166
197
|
const T = {
|
|
167
198
|
card: {
|
|
168
199
|
border: "0.5px solid " + C.line,
|
|
@@ -215,7 +246,11 @@ window.__ModuleLoader__.load({
|
|
|
215
246
|
// Destructive: rebuilding the key revokes the one in use.
|
|
216
247
|
danger: { border: "1px solid " + C.bad, background: "transparent", color: C.bad },
|
|
217
248
|
};
|
|
218
|
-
return h("button", {
|
|
249
|
+
return h("button", {
|
|
250
|
+
"data-sub2api-btn": "",
|
|
251
|
+
style: { ...base, ...(variants[variant] || {}), ...style },
|
|
252
|
+
...rest,
|
|
253
|
+
}, children);
|
|
219
254
|
}
|
|
220
255
|
|
|
221
256
|
function Card({ title, meta, children, id, aside }) {
|
|
@@ -341,8 +376,17 @@ window.__ModuleLoader__.load({
|
|
|
341
376
|
h("div", { style: { display: "flex", justifyContent: "space-between", fontSize: 11.5, color: C.muted } },
|
|
342
377
|
h("span", null, label),
|
|
343
378
|
h("span", null, Math.round(p) + "%")),
|
|
344
|
-
h("div", {
|
|
345
|
-
|
|
379
|
+
h("div", {
|
|
380
|
+
role: "progressbar",
|
|
381
|
+
"aria-label": label + "用量",
|
|
382
|
+
"aria-valuenow": Math.round(p),
|
|
383
|
+
"aria-valuemin": 0,
|
|
384
|
+
"aria-valuemax": 100,
|
|
385
|
+
style: { height: 6, borderRadius: 999, background: C.sunken, marginTop: 4, overflow: "hidden" },
|
|
386
|
+
},
|
|
387
|
+
h("div", {
|
|
388
|
+
style: { width: p + "%", height: "100%", background: tone, borderRadius: 999, transition: "width 240ms ease" },
|
|
389
|
+
})),
|
|
346
390
|
);
|
|
347
391
|
}
|
|
348
392
|
|
|
@@ -998,6 +1042,7 @@ window.__ModuleLoader__.load({
|
|
|
998
1042
|
};
|
|
999
1043
|
|
|
1000
1044
|
return h("div", {
|
|
1045
|
+
"data-sub2api-row": "",
|
|
1001
1046
|
style: {
|
|
1002
1047
|
display: "flex",
|
|
1003
1048
|
alignItems: "center",
|
|
@@ -1005,6 +1050,7 @@ window.__ModuleLoader__.load({
|
|
|
1005
1050
|
padding: "7px 12px",
|
|
1006
1051
|
borderTop: "0.5px solid " + C.line,
|
|
1007
1052
|
fontSize: 13,
|
|
1053
|
+
transition: "background 120ms ease",
|
|
1008
1054
|
},
|
|
1009
1055
|
},
|
|
1010
1056
|
h("input", {
|
|
@@ -1069,7 +1115,10 @@ window.__ModuleLoader__.load({
|
|
|
1069
1115
|
|
|
1070
1116
|
const filtered = useMemo(() => {
|
|
1071
1117
|
const q = query.trim().toLowerCase();
|
|
1072
|
-
|
|
1118
|
+
if (q === "") return everything;
|
|
1119
|
+
return everything.filter((m) =>
|
|
1120
|
+
m.id.toLowerCase().includes(q) || String(m.displayName ?? "").toLowerCase().includes(q),
|
|
1121
|
+
);
|
|
1073
1122
|
}, [everything, query]);
|
|
1074
1123
|
|
|
1075
1124
|
const toggle = (id) => {
|
|
@@ -1139,13 +1188,18 @@ window.__ModuleLoader__.load({
|
|
|
1139
1188
|
),
|
|
1140
1189
|
expanded
|
|
1141
1190
|
? h("div", null,
|
|
1142
|
-
everything.length >
|
|
1143
|
-
? h("div", { style: { marginBottom: 8 } },
|
|
1191
|
+
everything.length > 4
|
|
1192
|
+
? h("div", { style: { marginBottom: 8, display: "flex", gap: 8, alignItems: "center" } },
|
|
1144
1193
|
h(TextField, {
|
|
1145
|
-
placeholder: "搜索模型",
|
|
1194
|
+
placeholder: "搜索模型 id 或名称",
|
|
1146
1195
|
value: query,
|
|
1147
1196
|
onChange: (e) => setQuery(e.target.value),
|
|
1148
|
-
|
|
1197
|
+
style: { flex: 1 },
|
|
1198
|
+
}),
|
|
1199
|
+
query.trim() === ""
|
|
1200
|
+
? null
|
|
1201
|
+
: h("span", { style: { ...T.hint, whiteSpace: "nowrap" } },
|
|
1202
|
+
`${filtered.length} / ${everything.length}`))
|
|
1149
1203
|
: null,
|
|
1150
1204
|
h("div", {
|
|
1151
1205
|
style: { maxHeight: 300, overflow: "auto", border: "0.5px solid " + C.line, borderRadius: 12 },
|
|
@@ -1436,7 +1490,10 @@ window.__ModuleLoader__.load({
|
|
|
1436
1490
|
}
|
|
1437
1491
|
|
|
1438
1492
|
function Section() {
|
|
1439
|
-
|
|
1493
|
+
useEffect(() => {
|
|
1494
|
+
installFocusStyles(typeof document === "undefined" ? undefined : document);
|
|
1495
|
+
}, []);
|
|
1496
|
+
return h("div", { "data-sub2api": "" }, h(Boundary, null, h(SectionInner, null)));
|
|
1440
1497
|
}
|
|
1441
1498
|
|
|
1442
1499
|
// ------------------------------------------------------------ badge
|
|
@@ -1481,6 +1538,7 @@ window.__ModuleLoader__.load({
|
|
|
1481
1538
|
|
|
1482
1539
|
return h("button", {
|
|
1483
1540
|
type: "button",
|
|
1541
|
+
"data-sub2api": "",
|
|
1484
1542
|
title: detail,
|
|
1485
1543
|
"aria-label": `Psapi ${known ? "余额 " + money(balance) : "余额未知"},点击${low ? "去充值" : "刷新"}`,
|
|
1486
1544
|
onClick,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sub2api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Psapi (sub.pscly.cc) provider for DeepSeek Harness: zero-friction signup, auto-provisioned API key, upstream model sync, balance and recharge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-only",
|