dsh-any-deepseek 0.0.32 → 0.0.34
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/adapter.d.ts +94 -3
- package/lib/client.js +273 -10
- package/lib/config.d.ts +38 -3
- package/lib/failover.d.ts +139 -0
- package/lib/http.d.ts +30 -0
- package/lib/index.js +530 -166
- package/lib/route.d.ts +55 -21
- package/package.json +1 -1
package/lib/adapter.d.ts
CHANGED
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
* single point of failure for model traffic.
|
|
25
25
|
*/
|
|
26
26
|
import { LlmAdapter } from '@deepseek-ai/dsh-llm';
|
|
27
|
-
import type { GenerateOptions, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, PreparedAdapterCall, StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm';
|
|
27
|
+
import type { GenerateOptions, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, PreparedAdapterCall, ResolvedRetryPolicy, StreamChunk, TokenUsage } from '@deepseek-ai/dsh-llm';
|
|
28
28
|
import { credentialRef } from '@deepseek-ai/dsh-credentials';
|
|
29
29
|
import { type Api, type AssistantMessage, type AssistantMessageEvent, type Context as PiContext, type Model } from '@earendil-works/pi-ai';
|
|
30
30
|
import { openAICompletionsApi } from '@earendil-works/pi-ai/api/openai-completions.lazy';
|
|
31
31
|
import { type ChannelModality } from './presets.js';
|
|
32
32
|
import type { ResolvedChannel } from './channels.js';
|
|
33
|
+
import { SupplyCursor } from './failover.js';
|
|
33
34
|
import type { LedgerEntry } from './usage-ledger.js';
|
|
34
35
|
/** The single provider route this plugin owns. */
|
|
35
36
|
export declare const PROVIDER_ID = "any-deepseek";
|
|
@@ -55,6 +56,51 @@ export declare const PROVIDER_NAME = "Any DeepSeek";
|
|
|
55
56
|
* model's.
|
|
56
57
|
*/
|
|
57
58
|
export declare const MODEL_INPUT_MODALITIES: readonly ChannelModality[];
|
|
59
|
+
/**
|
|
60
|
+
* Retry budget this provider asks the harness to use, per request.
|
|
61
|
+
*
|
|
62
|
+
* ## Why the provider owns this number at all
|
|
63
|
+
*
|
|
64
|
+
* The harness stores one retry policy **per registered route**, captured at registration
|
|
65
|
+
* (`dsh-llm/lib/index.js:1876`: `adapter.providerRetryPolicy(provider) ?? resolveRetryPolicy(undefined, …)`),
|
|
66
|
+
* and hands it to the `agent/request-error` waterfall on every failed attempt
|
|
67
|
+
* (`dsh-agent-loop/lib/index.js:934`). The `dsh-llm-retry` plugin is the consumer that acts on it.
|
|
68
|
+
* An adapter that does not override `providerRetryPolicy` gets the host default —
|
|
69
|
+
* **5 retries** (`dsh-llm/lib/types/retry-policy.js:12`).
|
|
70
|
+
*
|
|
71
|
+
* Owner request (2026-11-10): 「把 dsh 的模型调用重试 patch 到 100」. Behind a relay that returns
|
|
72
|
+
* intermittent 5xx (e.g. the upstream `workspace_billing_scope_unavailable` that motivated 0.0.32),
|
|
73
|
+
* five attempts can all land inside one outage window and the turn dies. A larger budget costs
|
|
74
|
+
* nothing when the relay is healthy — the policy is only consulted after a failure.
|
|
75
|
+
*
|
|
76
|
+
* ## What this deliberately does NOT change
|
|
77
|
+
*
|
|
78
|
+
* `retryableCodes`, `backoff` and `mode` stay at the host's values. Raising only the COUNT keeps
|
|
79
|
+
* the failure taxonomy exactly as the host defines it: auth and quota are still not retried, and
|
|
80
|
+
* `CONTEXT_WINDOW_EXCEEDED` still never retries (0.0.32's whole point). A policy that widened the
|
|
81
|
+
* code set would be this plugin deciding which failures are recoverable — it does not get to.
|
|
82
|
+
*
|
|
83
|
+
* ⚠️ **This is a request, not a guarantee**: the policy reaches `dsh-llm-retry` through the host's
|
|
84
|
+
* registration, so an installation without that plugin simply ignores it (still one attempt per
|
|
85
|
+
* stream, as `dsh-llm` documents).
|
|
86
|
+
*/
|
|
87
|
+
export declare const PROVIDER_MAX_RETRIES = 100;
|
|
88
|
+
/**
|
|
89
|
+
* The resolved retry policy this route registers.
|
|
90
|
+
*
|
|
91
|
+
* ⚠️ **The backoff fields are FLAT here, not nested under `backoff`.** The host's INPUT shape
|
|
92
|
+
* (`RetryPolicyConfig`) nests them, but its RESOLVED shape does not:
|
|
93
|
+
* `ResolvedNormalRetryPolicy extends ResolvedRetryBackoff` (`dsh-llm/lib/types/retry-policy.d.ts:46-50`),
|
|
94
|
+
* so the policy a `providerRetryPolicy()` implementation returns carries
|
|
95
|
+
* `initialDelayMs` / `maxDelayMs` / `jitterRatio` as siblings of `mode` and `maxRetries`. The
|
|
96
|
+
* distinction is only visible because TypeScript rejected the nested form — worth pinning here so
|
|
97
|
+
* the next reader does not "tidy" it back into a nested object that silently fails to typecheck
|
|
98
|
+
* (and, in a JavaScript build, would silently fall back to defaults instead).
|
|
99
|
+
*
|
|
100
|
+
* Values mirror `dsh-llm/lib/types/retry-policy.js:13-22` exactly; if the host changes those
|
|
101
|
+
* defaults, this stays pinned to what it says rather than silently following.
|
|
102
|
+
*/
|
|
103
|
+
export declare const PROVIDER_RETRY_POLICY: ResolvedRetryPolicy;
|
|
58
104
|
/**
|
|
59
105
|
* The reasoning levels in force for one channel.
|
|
60
106
|
*
|
|
@@ -77,8 +123,20 @@ export declare function effectiveReasoningEfforts(channel: ResolvedChannel | und
|
|
|
77
123
|
export interface AdapterDeps {
|
|
78
124
|
/** Enabled, resolved channels in configuration order. */
|
|
79
125
|
channels: () => readonly ResolvedChannel[];
|
|
80
|
-
/** The configured channel id. */
|
|
126
|
+
/** The configured selection: a channel id, or {@link SUPPLY_GROUP_ID}. */
|
|
81
127
|
current: () => string | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* The supply group and its sticky cursor.
|
|
130
|
+
*
|
|
131
|
+
* Returned as one object rather than two accessors because they must be read together: a cursor
|
|
132
|
+
* index is meaningless against a different member list, and `SupplyCursor` itself resets the
|
|
133
|
+
* position when the list changes (see its note). Splitting them would let a caller pass a cursor
|
|
134
|
+
* from one list to another.
|
|
135
|
+
*/
|
|
136
|
+
supply: () => {
|
|
137
|
+
members: readonly string[];
|
|
138
|
+
cursor: SupplyCursor;
|
|
139
|
+
};
|
|
82
140
|
/**
|
|
83
141
|
* Resolve a credential REFERENCE name to its value; undefined when unconfigured.
|
|
84
142
|
*
|
|
@@ -273,6 +331,15 @@ export declare class AnyDeepSeekAdapter extends LlmAdapter {
|
|
|
273
331
|
private readonly deps;
|
|
274
332
|
constructor(deps: AdapterDeps);
|
|
275
333
|
providerInfo(provider: string): LlmProviderInfo;
|
|
334
|
+
/**
|
|
335
|
+
* The retry budget this route asks the harness to use.
|
|
336
|
+
*
|
|
337
|
+
* 🔴 Without this override the host substitutes its own default (5 retries) — and the failure is
|
|
338
|
+
* completely silent: requests still work, they just give up sooner. See
|
|
339
|
+
* {@link PROVIDER_RETRY_POLICY} for why 100 and what is deliberately left untouched.
|
|
340
|
+
* @returns the frozen policy captured at registration.
|
|
341
|
+
*/
|
|
342
|
+
providerRetryPolicy(_provider: string): ResolvedRetryPolicy;
|
|
276
343
|
/**
|
|
277
344
|
* Advertise exactly one model — **unconditionally**.
|
|
278
345
|
*
|
|
@@ -302,8 +369,32 @@ export declare class AnyDeepSeekAdapter extends LlmAdapter {
|
|
|
302
369
|
* here is what stops a panel change from landing in the middle of a recorded step.
|
|
303
370
|
*/
|
|
304
371
|
prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
|
|
372
|
+
/**
|
|
373
|
+
* Stream one request, walking the supply group when a member cannot serve.
|
|
374
|
+
*
|
|
375
|
+
* ## The shape, and why it is a loop rather than recursion
|
|
376
|
+
*
|
|
377
|
+
* A request gets an ORDERED candidate list: the head (whatever `current` names, or the group's
|
|
378
|
+
* sticky member) plus, when the group is serving, every remaining member after it. Each round
|
|
379
|
+
* is one complete attempt — key, wire, stream, ledger line — and the loop only continues when
|
|
380
|
+
* the attempt failed in a way that says "this CHANNEL cannot serve" (`shouldFailover`) *and*
|
|
381
|
+
* nothing has been handed to the consumer yet.
|
|
382
|
+
*
|
|
383
|
+
* 🔴 **The "nothing emitted yet" precondition is not a nicety; without it this feature corrupts
|
|
384
|
+
* messages.** Once a chunk has been yielded it is gone — the harness has written it to the
|
|
385
|
+
* session and will show it to the user. Switching suppliers afterwards would concatenate two
|
|
386
|
+
* different models' output into one message, with no way to tell which sentence came from
|
|
387
|
+
* where. So a mid-stream failure is reported, never retried on another relay; only a failure
|
|
388
|
+
* that happened BEFORE the first chunk is switchable.
|
|
389
|
+
*
|
|
390
|
+
* ## Ledger: one line per ATTEMPT
|
|
391
|
+
*
|
|
392
|
+
* Not one per request. "This request cost 40k tokens at relay A and then 2k at relay B" is a
|
|
393
|
+
* fact about two accounts, and collapsing it into one line under B's name would make A's spend
|
|
394
|
+
* invisible — the exact class of silent miscount this ledger exists to prevent (decision 3).
|
|
395
|
+
*/
|
|
305
396
|
stream(options: GenerateOptions): AsyncGenerator<StreamChunk>;
|
|
306
|
-
/** The channel the
|
|
397
|
+
/** The channel that will serve the next request, if any (used for model metadata). */
|
|
307
398
|
private selected;
|
|
308
399
|
}
|
|
309
400
|
/** Re-export the credential helper so callers build references the same way the adapter does. */
|
package/lib/client.js
CHANGED
|
@@ -8,20 +8,34 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
//#region src/client/panel-api.ts
|
|
10
10
|
/**
|
|
11
|
-
* The
|
|
11
|
+
* The `current` sentinel meaning "the supply group serves requests".
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ Must match `SUPPLY_GROUP_ID` in `src/config.ts`. It is duplicated rather than imported
|
|
14
|
+
* because that module pulls in schemastery and the node runtime; the client bundle must not carry
|
|
15
|
+
* either. The value is asserted in a test so the two cannot drift silently.
|
|
16
|
+
*/
|
|
17
|
+
const SUPPLY_GROUP_ID = "__group__";
|
|
18
|
+
/**
|
|
19
|
+
* The label the sidebar shows for the live supplier.
|
|
12
20
|
*
|
|
13
21
|
* 🔴 Owner request 2026-11-03: the sidebar should name the live provider so it does not require
|
|
14
22
|
* opening Settings. Owner constraint the same day: 「左下角空间小,字少点,表意明确即可」 — the seat is
|
|
15
23
|
* 256px wide and already carries a usage figure, so this returns the SHORTEST true sentence:
|
|
16
24
|
* just the channel's own label, with no 「当前供应商:」 prefix on every line.
|
|
17
25
|
*
|
|
18
|
-
*
|
|
26
|
+
* 🟢 Owner request 2026-11-12 extended this to the supply group (「给用户供应组是一种选择的感觉」):
|
|
27
|
+
* when the group is serving, the answer is not one channel but "the group, currently on X". That
|
|
28
|
+
* fact is shown as `供应组 · <label>` — 4 characters of prefix, which fits the 256px seat, and names
|
|
29
|
+
* BOTH truths: a group is in charge, and this is who it is talking to right now.
|
|
30
|
+
*
|
|
31
|
+
* Four states, kept distinct for the same reason the balance row does it:
|
|
32
|
+
* · `供应组 · 名字` when the group serves and its current member resolves;
|
|
33
|
+
* · `供应组` alone when the group serves but has no resolvable member yet (a setup state);
|
|
19
34
|
* · a label when a channel is selected and found;
|
|
20
35
|
* · `undefined` when nothing is selected — the caller renders nothing, because "no provider" is
|
|
21
36
|
* already visible as the model picker being unset and a red line here would be noise;
|
|
22
|
-
* · `未找到` when `current` names a channel that no longer exists. That one IS worth a word:
|
|
23
|
-
*
|
|
24
|
-
* something gone and only they can fix it.
|
|
37
|
+
* · `未找到` when `current` names a channel that no longer exists. That one IS worth a word: only
|
|
38
|
+
* the user can fix a dangling selection.
|
|
25
39
|
* @param response - the `/channels` body, or undefined before it loads.
|
|
26
40
|
* @returns the short label, or undefined when there is nothing to say.
|
|
27
41
|
*/
|
|
@@ -29,6 +43,12 @@ window.__ModuleLoader__.load({
|
|
|
29
43
|
if (response === void 0) return void 0;
|
|
30
44
|
const id = response.current;
|
|
31
45
|
if (id === void 0 || id === "") return void 0;
|
|
46
|
+
if (id === "__group__") {
|
|
47
|
+
const serving = response.supply?.serving;
|
|
48
|
+
if (serving === void 0) return "供应组";
|
|
49
|
+
const channel = response.channels.find((candidate) => candidate.id === serving);
|
|
50
|
+
return channel === void 0 ? "供应组" : `供应组 · ${channel.label}`;
|
|
51
|
+
}
|
|
32
52
|
const channel = response.channels.find((candidate) => candidate.id === id);
|
|
33
53
|
return channel === void 0 ? "未找到" : channel.label;
|
|
34
54
|
}
|
|
@@ -240,6 +260,21 @@ window.__ModuleLoader__.load({
|
|
|
240
260
|
}
|
|
241
261
|
}
|
|
242
262
|
/**
|
|
263
|
+
* Return the supply group to its first member.
|
|
264
|
+
*
|
|
265
|
+
* 🔴 The sticky cursor lives in the host's memory, so topping up the first relay is not enough to
|
|
266
|
+
* get back onto it — this is the button that does it. POST because it mutates state that outlives
|
|
267
|
+
* the request (a prefetched GET would silently undo a fallback the user was relying on).
|
|
268
|
+
* @returns true when the host accepted the reset.
|
|
269
|
+
*/
|
|
270
|
+
async function resetSupplyGroup() {
|
|
271
|
+
try {
|
|
272
|
+
return (await fetch(`${BASE}/supply/reset`, { method: "POST" })).ok;
|
|
273
|
+
} catch {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
243
278
|
* Spend one real request to check a channel.
|
|
244
279
|
*
|
|
245
280
|
* This is the only panel action that costs tokens, which is why it is a button rather than
|
|
@@ -318,7 +353,7 @@ window.__ModuleLoader__.load({
|
|
|
318
353
|
}
|
|
319
354
|
//#endregion
|
|
320
355
|
//#region \0ad-css:src/client/SettingsPage
|
|
321
|
-
const css$1 = "/* Panel styles.\n *\n * 🔴 There are NO `--dsw-alias-*` design tokens on this host (measured 2026-10-21: the document\n * declares 29 custom properties and not one is a colour). This file used to reference a dozen of\n * them, every one falling back to a hardcoded LIGHT value (`rgba(0,0,0,0.12)` and friends) — so\n * on the dark theme the borders and dividers were effectively invisible.\n *\n * ⇒ Derive everything from `currentColor`, which the host sets per theme. `color-mix` gives the\n * low-contrast borders and fills that a token would have provided, and it follows the theme\n * automatically instead of assuming one palette.\n */\n\n.ad-page {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 4px 2px 12px;\n}\n\n/* One place to change the two theme-derived values the whole panel uses. */\n.ad-page {\n --ad-line: color-mix(in srgb, currentColor 18%, transparent);\n --ad-line-strong: color-mix(in srgb, currentColor 32%, transparent);\n --ad-fill-subtle: color-mix(in srgb, currentColor 7%, transparent);\n /*\n * 🔴 The ACTIVE channel is green (owner request 2026-10-25: 「激活的样式用绿色」).\n *\n * It used to be derived from `currentColor`, which made the live row look like every other\n * \"slightly emphasised\" row — the same neutral tint as a hover or a selected input. Green says\n * \"this one is ON\" in a way a grey tint cannot, and it matches the key-configured dot and the\n * 密钥已配置 text that were already green, so the panel now uses one colour for one meaning:\n * green = working / live. Red stays reserved for destructive and for failures.\n *\n * Kept as one token so the mark (border + bar + fill + badge) can never drift apart between\n * the four places it is applied.\n */\n --ad-active: #2f855a;\n --ad-active-fill: color-mix(in srgb, var(--ad-active) 12%, transparent);\n --ad-danger: #e5534b;\n}\n\n.ad-head {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.ad-title {\n margin: 0;\n font-size: 15px;\n font-weight: 600;\n}\n\n.ad-intro {\n margin: 0;\n font-size: 12px;\n line-height: 1.6;\n opacity: 0.72;\n}\n\n.ad-error {\n border: 1px solid var(--ad-danger);\n border-radius: 6px;\n padding: 8px 10px;\n font-size: 12px;\n}\n\n.ad-section {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.ad-sectionTitle {\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n opacity: 0.6;\n}\n\n.ad-rows {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n/*\n * 🔴 Compact rows (owner request 2026-10-24: 「每个渠道高度希望小一些,紧凑些」).\n *\n * The row used to be a four-line stack — title / model·api·baseURL / key line / balance — and\n * with five channels that is most of the panel spent on air. The fix is layout, not information:\n * everything stays on screen, but the secondary facts move BESIDE the name instead of under it.\n *\n * What changed and why:\n * · padding 10px→7px and gap 6px→4px: the row now reads as one line of text plus a hairline of\n * metadata, instead of a card with its own interior spacing;\n * · `ad-rowMain` became a ROW (was a column): the title line and the meta line share one axis,\n * so the row is two text lines tall at most, not four;\n * · the meta line keeps `flex-wrap` — on a narrow panel it may wrap, and that is the correct\n * trade: a row that stays readable beats one that clips the endpoint URL.\n */\n.ad-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n border: 1px solid var(--ad-line);\n border-radius: 8px;\n padding: 7px 10px;\n /*\n * The left edge is reserved on EVERY row so the current one does not shift its content when\n * selected — a row that reindents on click makes the list feel like it moved.\n */\n border-left: 3px solid transparent;\n}\n\n/*\n * 🔴 The narrow-viewport layout: the action buttons get their own line.\n *\n * Measured on the owner's phone (2026-11-06 screenshot): 390px viewport, ~340px of content. Four\n * buttons at min-width 56px + 8px gaps need ~272px; together with a name column that cannot be\n * narrower than one word, they do not fit side by side. Below ~520px they now wrap below the\n * name instead of squeezing it into a vertical strip.\n *\n * Chosen as a media query rather than left to flex alone: without an explicit basis the group\n * wraps only when its CONTENT overflows, which leaves the name column at min-content width for a\n * long stretch before that happens — the exact state the screenshot was taken in.\n */\n@media (max-width: 520px) {\n .ad-rowActions {\n flex-basis: 100%;\n }\n .ad-btn {\n flex: 1 1 auto;\n min-width: 0;\n }\n}\n\n/*\n * 🔴 The current channel is marked in GREEN (owner 2026-10-25: 「激活的样式用绿色」).\n *\n * Previously the marks were derived from `currentColor` — a neutral bar, a stronger border and a\n * grey tint. All three were so low-contrast that the live row read as \"merely hovered\", which is\n * exactly what the owner was reacting to.\n *\n * Green is also the coherent choice: the key dot and 密钥已配置 text were already green, so the\n * panel now uses ONE colour for ONE meaning (green = working / live), and red stays reserved for\n * destructive actions and failures.\n *\n * Four marks read from the same token so they cannot drift apart: left bar, border, fill, badge.\n */\n.ad-row-current {\n border-color: var(--ad-active);\n border-left-color: var(--ad-active);\n background: var(--ad-active-fill);\n}\n\n/* The 当前 badge is the textual confirmation, for when colour alone is not enough (colour-blind\n readers, screenshots, forced-colours mode). */\n.ad-row-current .ad-badge {\n border-color: var(--ad-active);\n color: var(--ad-active);\n opacity: 1;\n font-weight: 600;\n}\n\n/* The live row's NAME goes green too: the name is where the eye lands first, so marking only the\n border leaves the reader to connect two separate cues. */\n.ad-row-current .ad-rowTitle {\n color: var(--ad-active);\n}\n\n/*\n * The row's content is a COLUMN of at most two lines: (1) name + status, (2) everything else.\n * It was a four-line stack before the compactness pass — see the note on `.ad-row`.\n */\n.ad-rowMain {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n flex: 1 1 auto;\n}\n\n.ad-rowTitleLine {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n font-weight: 500;\n min-width: 0;\n}\n\n.ad-rowTitle {\n white-space: nowrap;\n}\n\n.ad-badge {\n font-size: 10px;\n padding: 1px 6px;\n border-radius: 999px;\n border: 1px solid currentColor;\n opacity: 0.8;\n}\n\n.ad-warn {\n color: #b7791f;\n cursor: help;\n}\n\n/*\n * The live-state line under a channel's name: probe verdict and/or balance, nothing else.\n *\n * 🔴 It shrank twice at the owner's request, and the history matters:\n * 2026-10-24 「紧凑些」 — four stacked lines (endpoint identity / key state / verdict / balance)\n * became one wrapping line;\n * 2026-10-25 「这部分不要了」 — endpoint identity and key state were removed outright. What\n * remains is only what changes at runtime: did the probe pass, what is\n * the balance. Those two cannot be derived from anything else on screen,\n * which is why they survived while model/api/baseURL did not.\n *\n * The element is rendered ONLY when one of them exists, so an unprobed, unpriced channel shows a\n * single-line row with no orphan gap.\n */\n.ad-rowDetail {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n column-gap: 6px;\n row-gap: 2px;\n font-size: 11px;\n opacity: 0.66;\n min-width: 0;\n}\n\n.ad-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n word-break: break-all;\n}\n\n.ad-sep {\n opacity: 0.5;\n}\n\n/*\n * 🔴 Every control that acts on a channel lives here — and it MUST be allowed to shrink/wrap.\n *\n * This block is what made the panel unusable on a phone (owner 2026-11-06, screenshot from a\n * 390px-wide viewport). The row itself was already `flex-wrap: wrap`, so the actions SHOULD have\n * dropped to their own line; `flex-shrink: 0` here kept the group at its full intrinsic width\n * (~4 buttons ≈ 272px) inside a ~340px content box, and `.ad-rowMain` — which then had only about\n * 60px left — collapsed to its min-content width, printing `deepseek-v4.1-flash` and the balance\n * one fragment per line. Every control stayed on screen; none of them was readable.\n *\n * Three properties, each doing a different job:\n * · flex-basis 100% + the wrap rule below ⇒ the group takes its own line on narrow screens;\n * · flex-wrap + no flex-shrink:0 ⇒ it may wrap again rather than overflow if the width shrinks\n * further, and on a wide panel it stays on the title line exactly as before;\n * · it keeps `margin-left: auto` so that, once wrapped, the buttons stay right-aligned under the\n * row instead of drifting back under the name.\n */\n.ad-rowActions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n margin-left: auto;\n min-width: 0;\n}\n\n/*\n * Buttons: sized to be hit, not guessed at.\n *\n * The previous 4px/10px padding made a 22px-tall target, which is below the comfortable\n * threshold and made the row actions (测试 / 移除) look like text rather than controls. 6px/12px\n * with a minimum width gives each one a real box while keeping the row compact — a row action is\n * secondary, so it should be easy to hit and easy to ignore.\n */\n.ad-btn {\n font-size: 11px;\n font-family: inherit;\n line-height: 1.5;\n padding: 5px 12px;\n min-width: 56px;\n min-height: 26px;\n border-radius: 6px;\n border: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n cursor: pointer;\n transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;\n}\n\n.ad-btn:hover:not(:disabled) {\n border-color: var(--ad-line-strong);\n background: var(--ad-fill-subtle);\n}\n\n.ad-btn:disabled {\n opacity: 0.45;\n cursor: default;\n}\n\n.ad-btn-quiet {\n opacity: 0.85;\n}\n\n.ad-probe {\n font-size: 11px;\n padding-top: 2px;\n}\n\n.ad-probe-ok {\n color: #2f855a;\n}\n\n.ad-probe-bad {\n color: #c53030;\n word-break: break-word;\n}\n\n.ad-hint,\n.ad-empty,\n.ad-note {\n margin: 0;\n font-size: 11px;\n line-height: 1.6;\n opacity: 0.66;\n}\n\n.ad-dot {\n width: 8px;\n height: 8px;\n border-radius: 50%;\n flex-shrink: 0;\n display: inline-block;\n}\n\n.ad-dot-on {\n background: #2f855a;\n}\n\n.ad-dot-off {\n border: 1px solid currentColor;\n opacity: 0.5;\n}\n\n.ad-dot-unknown {\n background: linear-gradient(90deg, currentColor 50%, transparent 50%);\n opacity: 0.5;\n}\n\n/* The channel row is a radio \"pick\" zone: the whole left side is clickable, and the radio sits\n at the start of the line so \"which one is live\" is readable down a single column. */\n.ad-rowPick {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n flex: 1;\n min-width: 0;\n cursor: pointer;\n}\n\n.ad-rowPick input[type='radio'] {\n flex: none;\n /* Optically centred against the first text line rather than the row box. */\n margin-top: 3px;\n accent-color: var(--ad-line-strong);\n cursor: pointer;\n}\n\n/* The switch is gone: selection is the only axis (see `channels.ts`). Keeping the rules would\n invite someone to bring the second axis back. */\n\n/* ── top-level tabs (渠道 / 用量) ──────────────────────────────────────────── */\n\n/*\n * The panel answers two questions asked at different moments: \"which relay serves me and does\n * its key work\" and \"what has each relay cost\". They used to be stacked on one scroll, so\n * reading the cost table meant scrolling past every channel row. As tabs, each answer gets the\n * whole panel and the reader never scrolls to reach the second one.\n *\n * The selected tab is marked by a bottom rule plus full opacity — not by colour alone, because\n * this host ships no colour tokens and a colour-only cue would vary with the theme.\n */\n.ad-tabs {\n display: flex;\n gap: 4px;\n border-bottom: 1px solid var(--ad-line);\n}\n\n.ad-tab {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n /* Comfortable click target: 28px tall is enough to hit without aiming, and still compact\n enough that two tabs do not dominate the panel. */\n padding: 6px 14px;\n font-size: 12px;\n font-family: inherit;\n border: none;\n border-bottom: 2px solid transparent;\n /* Pulled down over the container's rule so the selected tab's underline replaces it. */\n margin-bottom: -1px;\n background: transparent;\n color: inherit;\n opacity: 0.62;\n cursor: pointer;\n}\n\n.ad-tab:hover {\n opacity: 0.85;\n}\n\n.ad-tab-on {\n opacity: 1;\n font-weight: 600;\n border-bottom-color: currentColor;\n}\n\n/* A count on the channel tab, so \"how many do I have\" is answered without opening it. */\n.ad-tabCount {\n font-size: 10px;\n font-weight: 500;\n min-width: 16px;\n padding: 0 4px;\n border-radius: 999px;\n text-align: center;\n background: var(--ad-fill-subtle);\n opacity: 0.8;\n}\n\n/* ── segmented control (按渠道 / 按天 / 刷新) ─────────────────────────────── */\n\n/*\n * A segmented control rather than free-floating pill buttons: these three share one meaning\n * (\"how the table below is grouped, and re-read it\"), so they are drawn as one object. The\n * borders collapse to avoid double lines between neighbours.\n */\n.ad-segmented {\n display: inline-flex;\n align-items: stretch;\n border: 1px solid var(--ad-line);\n border-radius: 7px;\n overflow: hidden;\n}\n\n.ad-seg {\n padding: 4px 11px;\n font-size: 11px;\n font-family: inherit;\n border: none;\n border-right: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n opacity: 0.7;\n cursor: pointer;\n}\n\n.ad-seg:last-child {\n border-right: none;\n}\n\n.ad-seg:hover:not(:disabled) {\n opacity: 1;\n background: var(--ad-fill-subtle);\n}\n\n.ad-seg-on {\n opacity: 1;\n font-weight: 600;\n background: var(--ad-fill-subtle);\n}\n\n/* Refresh is an action, not a grouping — a gap separates it from the choice it refreshes. */\n.ad-seg-refresh {\n border-left: 1px solid var(--ad-line);\n}\n\n.ad-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11px;\n}\n\n.ad-table th,\n.ad-table td {\n padding: 5px 8px;\n border-bottom: 1px solid var(--ad-line);\n text-align: left;\n}\n\n.ad-table th {\n font-weight: 500;\n opacity: 0.6;\n}\n\n.ad-num {\n text-align: right;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n\n.ad-total td {\n font-weight: 600;\n border-bottom: none;\n}\n\n/* ── add-channel form ─────────────────────────────────────────────────────── */\n\n.ad-addForm {\n display: flex;\n flex-direction: column;\n gap: 14px;\n border: 1px dashed var(--ad-line);\n border-radius: 8px;\n padding: 14px;\n}\n\n.ad-field {\n display: flex;\n flex-direction: column;\n gap: 5px;\n font-size: 11px;\n}\n\n/* The label row: the field name, plus a required/optional marker that says which is which. */\n.ad-field > span:first-child {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n font-weight: 500;\n opacity: 0.9;\n}\n\n/*\n * 必选 / 可空 as a small marker rather than a sentence.\n *\n * The add form used to leave the reader guessing which fields could be skipped — and the one\n * field that could not be skipped (the key) looked exactly like the two that could. The marker\n * is text, not colour, so it survives both themes and any colour-blindness.\n */\n.ad-req,\n.ad-opt {\n font-style: normal;\n font-size: 10px;\n font-weight: 400;\n padding: 1px 5px;\n border-radius: 4px;\n opacity: 0.7;\n}\n\n.ad-req {\n border: 1px solid var(--ad-line-strong);\n}\n\n.ad-opt {\n border: 1px dotted var(--ad-line);\n}\n\n/* Why this field exists, in one line — printed under the control, not hidden in a tooltip. */\n.ad-fieldHelp {\n font-size: 11px;\n line-height: 1.55;\n opacity: 0.6;\n}\n\n.ad-input {\n font-size: 12px;\n font-family: inherit;\n /* 6px/9px keeps the control the same height as a `.ad-btn` (26px), so a field and its button\n on one line align without a per-case override. */\n padding: 5px 9px;\n min-height: 26px;\n border-radius: 6px;\n border: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n}\n\n.ad-input:focus-visible {\n outline: 2px solid var(--ad-line-strong);\n outline-offset: 1px;\n border-color: var(--ad-line-strong);\n}\n\n/*\n * 🔴 A native `<select>` cannot be themed by leaving the background transparent.\n *\n * The popup list is drawn by the browser, not by the closed control's box: the options inherit\n * nothing from it, so `background: transparent` made them render in the platform default (light)\n * palette against this dark theme — reported by the owner and measured on the real host.\n *\n * 🔴 SECOND correction (measured 2026-10-21): this file used `var(--dsw-alias-color-*, #fallback)`\n * throughout, and **none of those variables exist**. The host declares only 29 custom properties\n * in total and not one is a colour token, so every `var()` here was falling back — and a fallback\n * that happens to be set inside a shorthand can be silently dropped (the select's background\n * computed to `rgba(0,0,0,0)`, i.e. still transparent, which is exactly the bug).\n *\n * ⇒ Use only values this file controls, derived from `currentColor` (the host sets a light text\n * colour on both themes) plus explicit translucent layers. No host token is assumed.\n */\nselect.ad-input {\n /* Tells the engine which palette to use for the popup. This part DID work. */\n color-scheme: dark light;\n /*\n * Paint the closed box with a layer that follows the surrounding text colour, so it matches\n * whichever theme is active instead of hardcoding a dark value into a light theme.\n */\n background-color: color-mix(in srgb, currentColor 8%, transparent);\n color: inherit;\n cursor: pointer;\n padding-right: 22px;\n /* Room for the chevron drawn below, so text never runs under it. */\n appearance: none;\n background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),\n linear-gradient(135deg, currentColor 50%, transparent 50%);\n background-position: calc(100% - 12px) calc(50% + 1px), calc(100% - 8px) calc(50% + 1px);\n background-size: 4px 4px, 4px 4px;\n background-repeat: no-repeat;\n}\n\nselect.ad-input:hover:not(:disabled) {\n background-color: color-mix(in srgb, currentColor 14%, transparent);\n}\n\nselect.ad-input:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n\n/*\n * The popup itself follows `color-scheme`; these keep the option rows explicit for engines that\n * honour per-option colours. `color-scheme: dark` above is what actually stops the light-on-dark\n * list, because the popup is native chrome rather than a styled element.\n */\nselect.ad-input option {\n background-color: Canvas;\n color: CanvasText;\n}\n\n.ad-fieldError {\n margin: 0;\n font-size: 11px;\n color: #c53030;\n}\n\n/* ── balance ──────────────────────────────────────────────────────────────── */\n\n/*\n * Remaining balance.\n *\n * A fact about this channel, not a control. The subtle fill marks it as a measurement rather than\n * a warning: the words themselves say whether it is fine (\"72.50 USD\") or not (\"(余额不足)\").\n */\n.ad-balance {\n font-variant-numeric: tabular-nums;\n font-size: 11px;\n padding: 1px 6px;\n border-radius: 4px;\n background: var(--ad-fill-subtle);\n}\n\n/* A section heading with one action on its right (currently: 查询余额). */\n.ad-sectionBar {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px;\n}\n\n/* The reference name, not a secret: monospace so it lines up and misreads as a name, not a value. */\n.ad-keyName {\n font-size: 10px;\n padding: 1px 5px;\n border-radius: 4px;\n background: var(--ad-fill-subtle);\n opacity: 0.8;\n}\n\n/* A text-shaped action. Styled as a link because it opens an inline editor, not a dialog. */\n.ad-link {\n font-size: 11px;\n padding: 0;\n border: none;\n background: none;\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n opacity: 0.75;\n cursor: pointer;\n}\n\n.ad-link:hover {\n opacity: 1;\n}\n\n/* The inline key editor: one masked field and one button, on the same line as the fact above. */\n.ad-keyForm {\n display: flex;\n align-items: center;\n gap: 6px;\n padding-top: 4px;\n}\n\n.ad-keyForm .ad-input {\n flex: 1;\n min-width: 0;\n}\n\n/* A destructive action is quiet until hovered: it should be findable, not inviting. */\n.ad-btn-danger {\n opacity: 0.6;\n}\n\n.ad-btn-danger:hover:not(:disabled) {\n opacity: 1;\n border-color: var(--ad-danger);\n color: var(--ad-danger);\n}\n\n/*\n * The one hint that must not be skimmed past: where the key ends up.\n *\n * It carries a left rule and slightly higher opacity than an ordinary hint, because a reader who\n * skips it has been told something false by omission — the key IS in the profile document.\n */\n.ad-hint-warn {\n padding: 8px 10px;\n border-left: 3px solid var(--ad-line-strong);\n background: var(--ad-fill-subtle);\n border-radius: 0 6px 6px 0;\n opacity: 0.82;\n}\n\n/*\n * The table can be wider than a narrow settings pane (ten columns of numbers). Scrolling it\n * inside its own box keeps the tab strip and the channel list reachable, instead of pushing the\n * whole panel sideways.\n */\n.ad-tableWrap {\n overflow-x: auto;\n /* A hint that there is more to the right, without a scrollbar competing with the borders. */\n scrollbar-width: thin;\n}\n\n.ad-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11px;\n}\n\n/* The first column is a name, not a number: keep it from being squeezed by the numeric columns. */\n.ad-table th:first-child,\n.ad-table td:first-child {\n white-space: nowrap;\n padding-right: 14px;\n}\n\n/* ── footer ───────────────────────────────────────────────────────────────── */\n\n/*\n * States what this thing is (MIT, open, improvable) and where it lives. A user deciding whether\n * to fork it or add a relay should not have to search for the source.\n */\n.ad-foot {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: 8px;\n padding-top: 10px;\n border-top: 1px solid var(--ad-line);\n font-size: 11px;\n opacity: 0.6;\n}\n\n.ad-footLink {\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-size: 10px;\n}\n\n.ad-footLink:hover {\n opacity: 0.9;\n}\n";
|
|
356
|
+
const css$1 = "/* Panel styles.\n *\n * 🔴 There are NO `--dsw-alias-*` design tokens on this host (measured 2026-10-21: the document\n * declares 29 custom properties and not one is a colour). This file used to reference a dozen of\n * them, every one falling back to a hardcoded LIGHT value (`rgba(0,0,0,0.12)` and friends) — so\n * on the dark theme the borders and dividers were effectively invisible.\n *\n * ⇒ Derive everything from `currentColor`, which the host sets per theme. `color-mix` gives the\n * low-contrast borders and fills that a token would have provided, and it follows the theme\n * automatically instead of assuming one palette.\n */\n\n.ad-page {\n display: flex;\n flex-direction: column;\n gap: 20px;\n padding: 4px 2px 12px;\n}\n\n/* One place to change the two theme-derived values the whole panel uses. */\n.ad-page {\n --ad-line: color-mix(in srgb, currentColor 18%, transparent);\n --ad-line-strong: color-mix(in srgb, currentColor 32%, transparent);\n --ad-fill-subtle: color-mix(in srgb, currentColor 7%, transparent);\n /*\n * 🔴 The ACTIVE channel is green (owner request 2026-10-25: 「激活的样式用绿色」).\n *\n * It used to be derived from `currentColor`, which made the live row look like every other\n * \"slightly emphasised\" row — the same neutral tint as a hover or a selected input. Green says\n * \"this one is ON\" in a way a grey tint cannot, and it matches the key-configured dot and the\n * 密钥已配置 text that were already green, so the panel now uses one colour for one meaning:\n * green = working / live. Red stays reserved for destructive and for failures.\n *\n * Kept as one token so the mark (border + bar + fill + badge) can never drift apart between\n * the four places it is applied.\n */\n --ad-active: #2f855a;\n --ad-active-fill: color-mix(in srgb, var(--ad-active) 12%, transparent);\n --ad-danger: #e5534b;\n}\n\n.ad-head {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.ad-title {\n margin: 0;\n font-size: 15px;\n font-weight: 600;\n}\n\n.ad-intro {\n margin: 0;\n font-size: 12px;\n line-height: 1.6;\n opacity: 0.72;\n}\n\n.ad-error {\n border: 1px solid var(--ad-danger);\n border-radius: 6px;\n padding: 8px 10px;\n font-size: 12px;\n}\n\n.ad-section {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.ad-sectionTitle {\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.04em;\n text-transform: uppercase;\n opacity: 0.6;\n}\n\n.ad-rows {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n/*\n * 🔴 Compact rows (owner request 2026-10-24: 「每个渠道高度希望小一些,紧凑些」).\n *\n * The row used to be a four-line stack — title / model·api·baseURL / key line / balance — and\n * with five channels that is most of the panel spent on air. The fix is layout, not information:\n * everything stays on screen, but the secondary facts move BESIDE the name instead of under it.\n *\n * What changed and why:\n * · padding 10px→7px and gap 6px→4px: the row now reads as one line of text plus a hairline of\n * metadata, instead of a card with its own interior spacing;\n * · `ad-rowMain` became a ROW (was a column): the title line and the meta line share one axis,\n * so the row is two text lines tall at most, not four;\n * · the meta line keeps `flex-wrap` — on a narrow panel it may wrap, and that is the correct\n * trade: a row that stays readable beats one that clips the endpoint URL.\n */\n.ad-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n border: 1px solid var(--ad-line);\n border-radius: 8px;\n padding: 7px 10px;\n /*\n * The left edge is reserved on EVERY row so the current one does not shift its content when\n * selected — a row that reindents on click makes the list feel like it moved.\n */\n border-left: 3px solid transparent;\n}\n\n/*\n * 🔴 The narrow-viewport layout: the action buttons get their own line.\n *\n * Measured on the owner's phone (2026-11-06 screenshot): 390px viewport, ~340px of content. Four\n * buttons at min-width 56px + 8px gaps need ~272px; together with a name column that cannot be\n * narrower than one word, they do not fit side by side. Below ~520px they now wrap below the\n * name instead of squeezing it into a vertical strip.\n *\n * Chosen as a media query rather than left to flex alone: without an explicit basis the group\n * wraps only when its CONTENT overflows, which leaves the name column at min-content width for a\n * long stretch before that happens — the exact state the screenshot was taken in.\n */\n@media (max-width: 520px) {\n .ad-rowActions {\n flex-basis: 100%;\n }\n .ad-btn {\n flex: 1 1 auto;\n min-width: 0;\n }\n}\n\n/*\n * 🔴 The current channel is marked in GREEN (owner 2026-10-25: 「激活的样式用绿色」).\n *\n * Previously the marks were derived from `currentColor` — a neutral bar, a stronger border and a\n * grey tint. All three were so low-contrast that the live row read as \"merely hovered\", which is\n * exactly what the owner was reacting to.\n *\n * Green is also the coherent choice: the key dot and 密钥已配置 text were already green, so the\n * panel now uses ONE colour for ONE meaning (green = working / live), and red stays reserved for\n * destructive actions and failures.\n *\n * Four marks read from the same token so they cannot drift apart: left bar, border, fill, badge.\n */\n.ad-row-current {\n border-color: var(--ad-active);\n border-left-color: var(--ad-active);\n background: var(--ad-active-fill);\n}\n\n/* The 当前 badge is the textual confirmation, for when colour alone is not enough (colour-blind\n readers, screenshots, forced-colours mode). */\n.ad-row-current .ad-badge {\n border-color: var(--ad-active);\n color: var(--ad-active);\n opacity: 1;\n font-weight: 600;\n}\n\n/* The live row's NAME goes green too: the name is where the eye lands first, so marking only the\n border leaves the reader to connect two separate cues. */\n.ad-row-current .ad-rowTitle {\n color: var(--ad-active);\n}\n\n/*\n * The row's content is a COLUMN of at most two lines: (1) name + status, (2) everything else.\n * It was a four-line stack before the compactness pass — see the note on `.ad-row`.\n */\n.ad-rowMain {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n flex: 1 1 auto;\n}\n\n.ad-rowTitleLine {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 13px;\n font-weight: 500;\n min-width: 0;\n}\n\n.ad-rowTitle {\n white-space: nowrap;\n}\n\n.ad-badge {\n font-size: 10px;\n padding: 1px 6px;\n border-radius: 999px;\n border: 1px solid currentColor;\n opacity: 0.8;\n}\n\n.ad-warn {\n color: #b7791f;\n cursor: help;\n}\n\n/*\n * The live-state line under a channel's name: probe verdict and/or balance, nothing else.\n *\n * 🔴 It shrank twice at the owner's request, and the history matters:\n * 2026-10-24 「紧凑些」 — four stacked lines (endpoint identity / key state / verdict / balance)\n * became one wrapping line;\n * 2026-10-25 「这部分不要了」 — endpoint identity and key state were removed outright. What\n * remains is only what changes at runtime: did the probe pass, what is\n * the balance. Those two cannot be derived from anything else on screen,\n * which is why they survived while model/api/baseURL did not.\n *\n * The element is rendered ONLY when one of them exists, so an unprobed, unpriced channel shows a\n * single-line row with no orphan gap.\n */\n.ad-rowDetail {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n column-gap: 6px;\n row-gap: 2px;\n font-size: 11px;\n opacity: 0.66;\n min-width: 0;\n}\n\n.ad-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n word-break: break-all;\n}\n\n.ad-sep {\n opacity: 0.5;\n}\n\n/*\n * 🔴 Every control that acts on a channel lives here — and it MUST be allowed to shrink/wrap.\n *\n * This block is what made the panel unusable on a phone (owner 2026-11-06, screenshot from a\n * 390px-wide viewport). The row itself was already `flex-wrap: wrap`, so the actions SHOULD have\n * dropped to their own line; `flex-shrink: 0` here kept the group at its full intrinsic width\n * (~4 buttons ≈ 272px) inside a ~340px content box, and `.ad-rowMain` — which then had only about\n * 60px left — collapsed to its min-content width, printing `deepseek-v4.1-flash` and the balance\n * one fragment per line. Every control stayed on screen; none of them was readable.\n *\n * Three properties, each doing a different job:\n * · flex-basis 100% + the wrap rule below ⇒ the group takes its own line on narrow screens;\n * · flex-wrap + no flex-shrink:0 ⇒ it may wrap again rather than overflow if the width shrinks\n * further, and on a wide panel it stays on the title line exactly as before;\n * · it keeps `margin-left: auto` so that, once wrapped, the buttons stay right-aligned under the\n * row instead of drifting back under the name.\n */\n.ad-rowActions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n margin-left: auto;\n min-width: 0;\n}\n\n/*\n * ── the supply group row (owner 2026-11-12) ─────────────────────────────────\n *\n * 🔴 The group is a MEMBER OF THE CHANNEL RADIO GROUP that happens to be a container, and the\n * styling has to say both things at once:\n *\n * · it must read as a CHOICE (the same radio, the same current-row marks) — owner's requirement\n * was 「给用户供应组是一种选择的感觉」, and the browser's radio semantics then guarantee the\n * thing he actually asked for: selecting the group unselects every channel below it;\n * · it must also read as a CONTAINER, because its members are edited and ordered here.\n *\n * Hence: same border/background language as `.ad-row`, but stacked (the member editor sits under\n * the title line) and with a muted \"explainer\" line so an unused feature still explains itself.\n */\n.ad-groupRow {\n /* A container, not a one-line row: the picker stays on top, the editor stacks beneath it. */\n flex-wrap: wrap;\n align-items: flex-start;\n}\n\n/* The member editor spans the full width under the picker, so member rows never wrap awkwardly. */\n.ad-groupEditor {\n flex-basis: 100%;\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding-top: 6px;\n margin-top: 2px;\n border-top: 1px dashed var(--ad-line);\n}\n\n.ad-groupCount {\n font-size: 11px;\n opacity: 0.6;\n}\n\n/* The live cursor and the last switch are state, not decoration — they get the full-opacity\n treatment the balance row reserves for facts the reader cannot derive. */\n.ad-groupLive,\n.ad-groupSwitch {\n opacity: 1;\n font-size: 11px;\n}\n\n.ad-groupSwitch {\n color: #b7791f;\n}\n\n.ad-groupDangling {\n color: #c53030;\n opacity: 1;\n font-size: 11px;\n}\n\n.ad-groupMembers {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n\n/*\n * One member line: rank · name · ↑ ↓ 移出.\n *\n * `min-width: 0` + `flex: 1` on the name is the same lesson as `.ad-rowMain`: without it a long\n * label refuses to shrink and pushes the buttons out of the panel (decision 82).\n */\n.ad-groupMember {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 4px 8px;\n border: 1px solid var(--ad-line);\n border-radius: 6px;\n border-left: 3px solid transparent;\n font-size: 12px;\n}\n\n/* The member currently serving gets the same green left bar as the live channel row, so \"which\n one is talking to the relay\" is one colour in one place. */\n.ad-groupMemberLive {\n border-left-color: var(--ad-active);\n}\n\n.ad-groupRank {\n flex: none;\n width: 18px;\n text-align: center;\n opacity: 0.55;\n font-variant-numeric: tabular-nums;\n}\n\n.ad-groupName {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.ad-groupAdd {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-wrap: wrap;\n}\n\n/* The select shares the panel's input look; it must be allowed to shrink on a narrow screen. */\n.ad-groupAdd .ad-input {\n flex: 1 1 120px;\n min-width: 0;\n}\n\n/*\n * Buttons: sized to be hit, not guessed at.\n *\n * The previous 4px/10px padding made a 22px-tall target, which is below the comfortable\n * threshold and made the row actions (测试 / 移除) look like text rather than controls. 6px/12px\n * with a minimum width gives each one a real box while keeping the row compact — a row action is\n * secondary, so it should be easy to hit and easy to ignore.\n */\n.ad-btn {\n font-size: 11px;\n font-family: inherit;\n line-height: 1.5;\n padding: 5px 12px;\n min-width: 56px;\n min-height: 26px;\n border-radius: 6px;\n border: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n cursor: pointer;\n transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;\n}\n\n.ad-btn:hover:not(:disabled) {\n border-color: var(--ad-line-strong);\n background: var(--ad-fill-subtle);\n}\n\n.ad-btn:disabled {\n opacity: 0.45;\n cursor: default;\n}\n\n.ad-btn-quiet {\n opacity: 0.85;\n}\n\n.ad-probe {\n font-size: 11px;\n padding-top: 2px;\n}\n\n.ad-probe-ok {\n color: #2f855a;\n}\n\n.ad-probe-bad {\n color: #c53030;\n word-break: break-word;\n}\n\n.ad-hint,\n.ad-empty,\n.ad-note {\n margin: 0;\n font-size: 11px;\n line-height: 1.6;\n opacity: 0.66;\n}\n\n.ad-dot {\n width: 8px;\n height: 8px;\n border-radius: 50%;\n flex-shrink: 0;\n display: inline-block;\n}\n\n.ad-dot-on {\n background: #2f855a;\n}\n\n.ad-dot-off {\n border: 1px solid currentColor;\n opacity: 0.5;\n}\n\n.ad-dot-unknown {\n background: linear-gradient(90deg, currentColor 50%, transparent 50%);\n opacity: 0.5;\n}\n\n/* The channel row is a radio \"pick\" zone: the whole left side is clickable, and the radio sits\n at the start of the line so \"which one is live\" is readable down a single column. */\n.ad-rowPick {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n flex: 1;\n min-width: 0;\n cursor: pointer;\n}\n\n.ad-rowPick input[type='radio'] {\n flex: none;\n /* Optically centred against the first text line rather than the row box. */\n margin-top: 3px;\n accent-color: var(--ad-line-strong);\n cursor: pointer;\n}\n\n/* The switch is gone: selection is the only axis (see `channels.ts`). Keeping the rules would\n invite someone to bring the second axis back. */\n\n/* ── top-level tabs (渠道 / 用量) ──────────────────────────────────────────── */\n\n/*\n * The panel answers two questions asked at different moments: \"which relay serves me and does\n * its key work\" and \"what has each relay cost\". They used to be stacked on one scroll, so\n * reading the cost table meant scrolling past every channel row. As tabs, each answer gets the\n * whole panel and the reader never scrolls to reach the second one.\n *\n * The selected tab is marked by a bottom rule plus full opacity — not by colour alone, because\n * this host ships no colour tokens and a colour-only cue would vary with the theme.\n */\n.ad-tabs {\n display: flex;\n gap: 4px;\n border-bottom: 1px solid var(--ad-line);\n}\n\n.ad-tab {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n /* Comfortable click target: 28px tall is enough to hit without aiming, and still compact\n enough that two tabs do not dominate the panel. */\n padding: 6px 14px;\n font-size: 12px;\n font-family: inherit;\n border: none;\n border-bottom: 2px solid transparent;\n /* Pulled down over the container's rule so the selected tab's underline replaces it. */\n margin-bottom: -1px;\n background: transparent;\n color: inherit;\n opacity: 0.62;\n cursor: pointer;\n}\n\n.ad-tab:hover {\n opacity: 0.85;\n}\n\n.ad-tab-on {\n opacity: 1;\n font-weight: 600;\n border-bottom-color: currentColor;\n}\n\n/* A count on the channel tab, so \"how many do I have\" is answered without opening it. */\n.ad-tabCount {\n font-size: 10px;\n font-weight: 500;\n min-width: 16px;\n padding: 0 4px;\n border-radius: 999px;\n text-align: center;\n background: var(--ad-fill-subtle);\n opacity: 0.8;\n}\n\n/* ── segmented control (按渠道 / 按天 / 刷新) ─────────────────────────────── */\n\n/*\n * A segmented control rather than free-floating pill buttons: these three share one meaning\n * (\"how the table below is grouped, and re-read it\"), so they are drawn as one object. The\n * borders collapse to avoid double lines between neighbours.\n */\n.ad-segmented {\n display: inline-flex;\n align-items: stretch;\n border: 1px solid var(--ad-line);\n border-radius: 7px;\n overflow: hidden;\n}\n\n.ad-seg {\n padding: 4px 11px;\n font-size: 11px;\n font-family: inherit;\n border: none;\n border-right: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n opacity: 0.7;\n cursor: pointer;\n}\n\n.ad-seg:last-child {\n border-right: none;\n}\n\n.ad-seg:hover:not(:disabled) {\n opacity: 1;\n background: var(--ad-fill-subtle);\n}\n\n.ad-seg-on {\n opacity: 1;\n font-weight: 600;\n background: var(--ad-fill-subtle);\n}\n\n/* Refresh is an action, not a grouping — a gap separates it from the choice it refreshes. */\n.ad-seg-refresh {\n border-left: 1px solid var(--ad-line);\n}\n\n.ad-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11px;\n}\n\n.ad-table th,\n.ad-table td {\n padding: 5px 8px;\n border-bottom: 1px solid var(--ad-line);\n text-align: left;\n}\n\n.ad-table th {\n font-weight: 500;\n opacity: 0.6;\n}\n\n.ad-num {\n text-align: right;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n\n.ad-total td {\n font-weight: 600;\n border-bottom: none;\n}\n\n/* ── add-channel form ─────────────────────────────────────────────────────── */\n\n.ad-addForm {\n display: flex;\n flex-direction: column;\n gap: 14px;\n border: 1px dashed var(--ad-line);\n border-radius: 8px;\n padding: 14px;\n}\n\n.ad-field {\n display: flex;\n flex-direction: column;\n gap: 5px;\n font-size: 11px;\n}\n\n/* The label row: the field name, plus a required/optional marker that says which is which. */\n.ad-field > span:first-child {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n font-weight: 500;\n opacity: 0.9;\n}\n\n/*\n * 必选 / 可空 as a small marker rather than a sentence.\n *\n * The add form used to leave the reader guessing which fields could be skipped — and the one\n * field that could not be skipped (the key) looked exactly like the two that could. The marker\n * is text, not colour, so it survives both themes and any colour-blindness.\n */\n.ad-req,\n.ad-opt {\n font-style: normal;\n font-size: 10px;\n font-weight: 400;\n padding: 1px 5px;\n border-radius: 4px;\n opacity: 0.7;\n}\n\n.ad-req {\n border: 1px solid var(--ad-line-strong);\n}\n\n.ad-opt {\n border: 1px dotted var(--ad-line);\n}\n\n/* Why this field exists, in one line — printed under the control, not hidden in a tooltip. */\n.ad-fieldHelp {\n font-size: 11px;\n line-height: 1.55;\n opacity: 0.6;\n}\n\n.ad-input {\n font-size: 12px;\n font-family: inherit;\n /* 6px/9px keeps the control the same height as a `.ad-btn` (26px), so a field and its button\n on one line align without a per-case override. */\n padding: 5px 9px;\n min-height: 26px;\n border-radius: 6px;\n border: 1px solid var(--ad-line);\n background: transparent;\n color: inherit;\n}\n\n.ad-input:focus-visible {\n outline: 2px solid var(--ad-line-strong);\n outline-offset: 1px;\n border-color: var(--ad-line-strong);\n}\n\n/*\n * 🔴 A native `<select>` cannot be themed by leaving the background transparent.\n *\n * The popup list is drawn by the browser, not by the closed control's box: the options inherit\n * nothing from it, so `background: transparent` made them render in the platform default (light)\n * palette against this dark theme — reported by the owner and measured on the real host.\n *\n * 🔴 SECOND correction (measured 2026-10-21): this file used `var(--dsw-alias-color-*, #fallback)`\n * throughout, and **none of those variables exist**. The host declares only 29 custom properties\n * in total and not one is a colour token, so every `var()` here was falling back — and a fallback\n * that happens to be set inside a shorthand can be silently dropped (the select's background\n * computed to `rgba(0,0,0,0)`, i.e. still transparent, which is exactly the bug).\n *\n * ⇒ Use only values this file controls, derived from `currentColor` (the host sets a light text\n * colour on both themes) plus explicit translucent layers. No host token is assumed.\n */\nselect.ad-input {\n /* Tells the engine which palette to use for the popup. This part DID work. */\n color-scheme: dark light;\n /*\n * Paint the closed box with a layer that follows the surrounding text colour, so it matches\n * whichever theme is active instead of hardcoding a dark value into a light theme.\n */\n background-color: color-mix(in srgb, currentColor 8%, transparent);\n color: inherit;\n cursor: pointer;\n padding-right: 22px;\n /* Room for the chevron drawn below, so text never runs under it. */\n appearance: none;\n background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),\n linear-gradient(135deg, currentColor 50%, transparent 50%);\n background-position: calc(100% - 12px) calc(50% + 1px), calc(100% - 8px) calc(50% + 1px);\n background-size: 4px 4px, 4px 4px;\n background-repeat: no-repeat;\n}\n\nselect.ad-input:hover:not(:disabled) {\n background-color: color-mix(in srgb, currentColor 14%, transparent);\n}\n\nselect.ad-input:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n\n/*\n * The popup itself follows `color-scheme`; these keep the option rows explicit for engines that\n * honour per-option colours. `color-scheme: dark` above is what actually stops the light-on-dark\n * list, because the popup is native chrome rather than a styled element.\n */\nselect.ad-input option {\n background-color: Canvas;\n color: CanvasText;\n}\n\n.ad-fieldError {\n margin: 0;\n font-size: 11px;\n color: #c53030;\n}\n\n/* ── balance ──────────────────────────────────────────────────────────────── */\n\n/*\n * Remaining balance.\n *\n * A fact about this channel, not a control. The subtle fill marks it as a measurement rather than\n * a warning: the words themselves say whether it is fine (\"72.50 USD\") or not (\"(余额不足)\").\n */\n.ad-balance {\n font-variant-numeric: tabular-nums;\n font-size: 11px;\n padding: 1px 6px;\n border-radius: 4px;\n background: var(--ad-fill-subtle);\n}\n\n/* A section heading with one action on its right (currently: 查询余额). */\n.ad-sectionBar {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px;\n}\n\n/* The reference name, not a secret: monospace so it lines up and misreads as a name, not a value. */\n.ad-keyName {\n font-size: 10px;\n padding: 1px 5px;\n border-radius: 4px;\n background: var(--ad-fill-subtle);\n opacity: 0.8;\n}\n\n/* A text-shaped action. Styled as a link because it opens an inline editor, not a dialog. */\n.ad-link {\n font-size: 11px;\n padding: 0;\n border: none;\n background: none;\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n opacity: 0.75;\n cursor: pointer;\n}\n\n.ad-link:hover {\n opacity: 1;\n}\n\n/* The inline key editor: one masked field and one button, on the same line as the fact above. */\n.ad-keyForm {\n display: flex;\n align-items: center;\n gap: 6px;\n padding-top: 4px;\n}\n\n.ad-keyForm .ad-input {\n flex: 1;\n min-width: 0;\n}\n\n/* A destructive action is quiet until hovered: it should be findable, not inviting. */\n.ad-btn-danger {\n opacity: 0.6;\n}\n\n.ad-btn-danger:hover:not(:disabled) {\n opacity: 1;\n border-color: var(--ad-danger);\n color: var(--ad-danger);\n}\n\n/*\n * The one hint that must not be skimmed past: where the key ends up.\n *\n * It carries a left rule and slightly higher opacity than an ordinary hint, because a reader who\n * skips it has been told something false by omission — the key IS in the profile document.\n */\n.ad-hint-warn {\n padding: 8px 10px;\n border-left: 3px solid var(--ad-line-strong);\n background: var(--ad-fill-subtle);\n border-radius: 0 6px 6px 0;\n opacity: 0.82;\n}\n\n/*\n * The table can be wider than a narrow settings pane (ten columns of numbers). Scrolling it\n * inside its own box keeps the tab strip and the channel list reachable, instead of pushing the\n * whole panel sideways.\n */\n.ad-tableWrap {\n overflow-x: auto;\n /* A hint that there is more to the right, without a scrollbar competing with the borders. */\n scrollbar-width: thin;\n}\n\n.ad-table {\n width: 100%;\n border-collapse: collapse;\n font-size: 11px;\n}\n\n/* The first column is a name, not a number: keep it from being squeezed by the numeric columns. */\n.ad-table th:first-child,\n.ad-table td:first-child {\n white-space: nowrap;\n padding-right: 14px;\n}\n\n/* ── footer ───────────────────────────────────────────────────────────────── */\n\n/*\n * States what this thing is (MIT, open, improvable) and where it lives. A user deciding whether\n * to fork it or add a relay should not have to search for the source.\n */\n.ad-foot {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: 8px;\n padding-top: 10px;\n border-top: 1px solid var(--ad-line);\n font-size: 11px;\n opacity: 0.6;\n}\n\n.ad-footLink {\n color: inherit;\n text-decoration: underline;\n text-underline-offset: 2px;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-size: 10px;\n}\n\n.ad-footLink:hover {\n opacity: 0.9;\n}\n";
|
|
322
357
|
if (typeof document !== "undefined" && document.querySelector("style[data-ad-css=\"SettingsPage\"]") === null) {
|
|
323
358
|
const tag = document.createElement("style");
|
|
324
359
|
tag.setAttribute("data-ad-css", "SettingsPage");
|
|
@@ -419,6 +454,20 @@ window.__ModuleLoader__.load({
|
|
|
419
454
|
const [probing, setProbing] = (0, react.useState)(null);
|
|
420
455
|
const [verdict, setVerdict] = (0, react.useState)({});
|
|
421
456
|
const [error, setError] = (0, react.useState)(null);
|
|
457
|
+
/**
|
|
458
|
+
* The supply group's live state from `/channels` (members, cursor position, last switch).
|
|
459
|
+
*
|
|
460
|
+
* 🔴 Kept SEPARATE from `rows` and from the settings document on purpose. `rows` is "what
|
|
461
|
+
* channels exist"; `supplyGroup.members` in the settings document is "what the user configured";
|
|
462
|
+
* this is "what the router is actually doing". The panel needs all three to explain a fallback
|
|
463
|
+
* ("member 1 ran out of quota, so requests now go to member 2") — merge any two and the third
|
|
464
|
+
* question becomes unanswerable.
|
|
465
|
+
*/
|
|
466
|
+
const [supply, setSupply] = (0, react.useState)(void 0);
|
|
467
|
+
/** Whether the balance-less "reset to first member" request is in flight. */
|
|
468
|
+
const [supplyResetting, setSupplyResetting] = (0, react.useState)(false);
|
|
469
|
+
/** Which channel id the group editor is offering to append (empty = picker closed). */
|
|
470
|
+
const [addingMember, setAddingMember] = (0, react.useState)("");
|
|
422
471
|
/** The "add a channel" form. Collapsed until asked for — an empty panel is not a form. */
|
|
423
472
|
const [adding, setAdding] = (0, react.useState)(false);
|
|
424
473
|
const [newId, setNewId] = (0, react.useState)("");
|
|
@@ -457,6 +506,7 @@ window.__ModuleLoader__.load({
|
|
|
457
506
|
setRows(loaded.channels);
|
|
458
507
|
setPresets(loaded.presets);
|
|
459
508
|
setModel(loaded.model);
|
|
509
|
+
setSupply(loaded.supply);
|
|
460
510
|
setStats(statsNow);
|
|
461
511
|
}, [
|
|
462
512
|
loadChannels,
|
|
@@ -487,10 +537,63 @@ window.__ModuleLoader__.load({
|
|
|
487
537
|
});
|
|
488
538
|
}, [refresh]);
|
|
489
539
|
const current = settings.value?.current ?? "";
|
|
540
|
+
/** Whether the supply group is the selected supplier — ONE fact, read from ONE field. */
|
|
541
|
+
const groupSelected = current === SUPPLY_GROUP_ID;
|
|
542
|
+
/** The configured member list, as this panel last read it from the settings document. */
|
|
543
|
+
const members = (() => {
|
|
544
|
+
const raw = settings.value?.supplyGroup?.members;
|
|
545
|
+
return Array.isArray(raw) ? raw.filter((id) => typeof id === "string") : [];
|
|
546
|
+
})();
|
|
490
547
|
const select = (id) => {
|
|
491
548
|
write(() => setField(["current"], id));
|
|
492
549
|
};
|
|
493
550
|
/**
|
|
551
|
+
* Write the whole member list.
|
|
552
|
+
*
|
|
553
|
+
* One write per edit, and the list is replaced WHOLE rather than patched index by index:
|
|
554
|
+
* `members` is an ordered array, so a per-index write could interleave with a concurrent read
|
|
555
|
+
* (the same revision-conflict shape that produced decision 85) and leave the order scrambled.
|
|
556
|
+
* @param next - the complete new order.
|
|
557
|
+
*/
|
|
558
|
+
const writeMembers = (next) => {
|
|
559
|
+
write(() => setField(["supplyGroup", "members"], [...next]), "保存供应组失败");
|
|
560
|
+
};
|
|
561
|
+
/** Move one member one position earlier or later. */
|
|
562
|
+
const moveMember = (index, delta) => {
|
|
563
|
+
const target = index + delta;
|
|
564
|
+
if (target < 0 || target >= members.length) return;
|
|
565
|
+
const next = [...members];
|
|
566
|
+
const [item] = next.splice(index, 1);
|
|
567
|
+
next.splice(target, 0, item);
|
|
568
|
+
writeMembers(next);
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* Switch the supplier: the group, or one channel.
|
|
572
|
+
*
|
|
573
|
+
* 🔴 Both arms write the SAME field (`current`) — that is the whole point of the sentinel design.
|
|
574
|
+
* Writing the group means "the group serves", and every channel row stops being the selection in
|
|
575
|
+
* exactly the way it already does when a different channel is picked.
|
|
576
|
+
*/
|
|
577
|
+
const selectGroup = () => {
|
|
578
|
+
write(() => setField(["current"], SUPPLY_GROUP_ID), "启用供应组失败");
|
|
579
|
+
};
|
|
580
|
+
/** Clear the sticky cursor so the group starts from its first member again. */
|
|
581
|
+
const resetGroupCursor = async () => {
|
|
582
|
+
setSupplyResetting(true);
|
|
583
|
+
try {
|
|
584
|
+
if (!await resetSupplyGroup()) {
|
|
585
|
+
setError("重置供应组失败:宿主拒绝了这个请求");
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
setError(null);
|
|
589
|
+
await refresh();
|
|
590
|
+
} catch (cause) {
|
|
591
|
+
setError(`重置供应组失败:${cause instanceof Error ? cause.message : String(cause)}`);
|
|
592
|
+
} finally {
|
|
593
|
+
setSupplyResetting(false);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
/**
|
|
494
597
|
* Run one settings write and surface a refusal.
|
|
495
598
|
*
|
|
496
599
|
* A write can be refused for reasons the user can act on (read-only deployment, the settings
|
|
@@ -711,11 +814,171 @@ window.__ModuleLoader__.load({
|
|
|
711
814
|
className: "ad-empty",
|
|
712
815
|
children: "还没有渠道。点下面的「添加渠道」,选一个规格、粘一个 key 就能用。"
|
|
713
816
|
}),
|
|
714
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
817
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
|
|
715
818
|
className: "ad-rows",
|
|
716
819
|
role: "radiogroup",
|
|
717
|
-
"aria-label": "
|
|
718
|
-
children:
|
|
820
|
+
"aria-label": "选择当前供应商",
|
|
821
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
822
|
+
className: `ad-row ad-groupRow${groupSelected ? " ad-row-current" : ""}`,
|
|
823
|
+
"aria-current": groupSelected ? "true" : void 0,
|
|
824
|
+
"data-current": groupSelected ? "true" : "false",
|
|
825
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
826
|
+
className: "ad-rowPick",
|
|
827
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
828
|
+
type: "radio",
|
|
829
|
+
name: "ad-current-channel",
|
|
830
|
+
checked: groupSelected,
|
|
831
|
+
onChange: () => selectGroup()
|
|
832
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
833
|
+
className: "ad-rowMain",
|
|
834
|
+
children: [
|
|
835
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
836
|
+
className: "ad-rowTitleLine",
|
|
837
|
+
children: [
|
|
838
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
839
|
+
className: "ad-rowTitle",
|
|
840
|
+
children: "供应组"
|
|
841
|
+
}),
|
|
842
|
+
groupSelected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
843
|
+
className: "ad-badge",
|
|
844
|
+
children: "当前"
|
|
845
|
+
}),
|
|
846
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
847
|
+
className: "ad-groupCount",
|
|
848
|
+
children: members.length > 0 ? `${members.length} 个渠道` : "未配置"
|
|
849
|
+
})
|
|
850
|
+
]
|
|
851
|
+
}),
|
|
852
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
853
|
+
className: "ad-rowDetail",
|
|
854
|
+
children: "按顺序使用,遇到余额不足或密钥失效时自动换下一个,供应不中断"
|
|
855
|
+
}),
|
|
856
|
+
groupSelected && supply !== void 0 && supply.serving !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
857
|
+
className: "ad-rowDetail ad-groupLive",
|
|
858
|
+
children: [
|
|
859
|
+
"正在使用:",
|
|
860
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: rows.find((row) => row.id === supply.serving)?.label ?? supply.serving }),
|
|
861
|
+
"(第 ",
|
|
862
|
+
supply.position + 1,
|
|
863
|
+
" 位)"
|
|
864
|
+
]
|
|
865
|
+
}),
|
|
866
|
+
groupSelected && supply?.lastSwitch !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
867
|
+
className: "ad-rowDetail ad-groupSwitch",
|
|
868
|
+
children: [
|
|
869
|
+
"最近切换:",
|
|
870
|
+
rows.find((row) => row.id === supply.lastSwitch.from)?.label ?? supply.lastSwitch.from,
|
|
871
|
+
" → ",
|
|
872
|
+
rows.find((row) => row.id === supply.lastSwitch.to)?.label ?? supply.lastSwitch.to,
|
|
873
|
+
"(",
|
|
874
|
+
supply.lastSwitch.code,
|
|
875
|
+
")"
|
|
876
|
+
]
|
|
877
|
+
}),
|
|
878
|
+
supply !== void 0 && supply.dangling.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
879
|
+
className: "ad-rowDetail ad-groupDangling",
|
|
880
|
+
children: [
|
|
881
|
+
"找不到这些渠道:",
|
|
882
|
+
supply.dangling.join("、"),
|
|
883
|
+
"(已跳过)"
|
|
884
|
+
]
|
|
885
|
+
})
|
|
886
|
+
]
|
|
887
|
+
})]
|
|
888
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
889
|
+
className: "ad-groupEditor",
|
|
890
|
+
children: [
|
|
891
|
+
members.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
892
|
+
className: "ad-empty",
|
|
893
|
+
children: "还没放渠道进来。选一个渠道加进来,就会按下面的顺序依次使用。"
|
|
894
|
+
}),
|
|
895
|
+
members.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
|
|
896
|
+
className: "ad-groupMembers",
|
|
897
|
+
children: members.map((id, index) => {
|
|
898
|
+
const row = rows.find((candidate) => candidate.id === id);
|
|
899
|
+
const live = groupSelected && supply?.serving === id;
|
|
900
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
901
|
+
className: `ad-groupMember${live ? " ad-groupMemberLive" : ""}`,
|
|
902
|
+
children: [
|
|
903
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
904
|
+
className: "ad-groupRank",
|
|
905
|
+
children: index + 1
|
|
906
|
+
}),
|
|
907
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
908
|
+
className: "ad-groupName",
|
|
909
|
+
children: row?.label ?? `${id}(找不到)`
|
|
910
|
+
}),
|
|
911
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
912
|
+
type: "button",
|
|
913
|
+
className: "ad-btn ad-btn-quiet",
|
|
914
|
+
disabled: index === 0,
|
|
915
|
+
title: "往上移(更优先)",
|
|
916
|
+
onClick: () => moveMember(index, -1),
|
|
917
|
+
children: "↑"
|
|
918
|
+
}),
|
|
919
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
920
|
+
type: "button",
|
|
921
|
+
className: "ad-btn ad-btn-quiet",
|
|
922
|
+
disabled: index === members.length - 1,
|
|
923
|
+
title: "往下移(更靠后)",
|
|
924
|
+
onClick: () => moveMember(index, 1),
|
|
925
|
+
children: "↓"
|
|
926
|
+
}),
|
|
927
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
928
|
+
type: "button",
|
|
929
|
+
className: "ad-btn ad-btn-danger",
|
|
930
|
+
title: "移出供应组(不删除渠道本身)",
|
|
931
|
+
onClick: () => writeMembers(members.filter((candidate) => candidate !== id)),
|
|
932
|
+
children: "移出"
|
|
933
|
+
})
|
|
934
|
+
]
|
|
935
|
+
}, id);
|
|
936
|
+
})
|
|
937
|
+
}),
|
|
938
|
+
(() => {
|
|
939
|
+
const addable = rows.filter((row) => !members.includes(row.id));
|
|
940
|
+
if (addable.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
941
|
+
className: "ad-hint",
|
|
942
|
+
children: "所有渠道都已在供应组里。"
|
|
943
|
+
});
|
|
944
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
945
|
+
className: "ad-groupAdd",
|
|
946
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
947
|
+
className: "ad-input",
|
|
948
|
+
value: addingMember,
|
|
949
|
+
onChange: (event) => setAddingMember(event.target.value),
|
|
950
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
951
|
+
value: "",
|
|
952
|
+
children: "选一个渠道加进来…"
|
|
953
|
+
}), addable.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
954
|
+
value: row.id,
|
|
955
|
+
children: row.label
|
|
956
|
+
}, row.id))]
|
|
957
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
958
|
+
type: "button",
|
|
959
|
+
className: "ad-btn",
|
|
960
|
+
disabled: addingMember === "",
|
|
961
|
+
onClick: () => {
|
|
962
|
+
writeMembers([...members, addingMember]);
|
|
963
|
+
setAddingMember("");
|
|
964
|
+
},
|
|
965
|
+
children: "加进来"
|
|
966
|
+
})]
|
|
967
|
+
});
|
|
968
|
+
})(),
|
|
969
|
+
groupSelected && members.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
970
|
+
type: "button",
|
|
971
|
+
className: "ad-link",
|
|
972
|
+
disabled: supplyResetting,
|
|
973
|
+
title: "把下一个请求重新从第 1 位开始(充值后想马上用回第一个时有意义)",
|
|
974
|
+
onClick: () => {
|
|
975
|
+
resetGroupCursor();
|
|
976
|
+
},
|
|
977
|
+
children: supplyResetting ? "重置中…" : "从第 1 位重新开始"
|
|
978
|
+
})
|
|
979
|
+
]
|
|
980
|
+
})]
|
|
981
|
+
}), rows.map((row) => {
|
|
719
982
|
const isCurrent = current === row.id;
|
|
720
983
|
const probeResult = verdict[row.id];
|
|
721
984
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
@@ -814,7 +1077,7 @@ window.__ModuleLoader__.load({
|
|
|
814
1077
|
]
|
|
815
1078
|
})]
|
|
816
1079
|
}, row.id);
|
|
817
|
-
})
|
|
1080
|
+
})]
|
|
818
1081
|
}),
|
|
819
1082
|
adding ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
820
1083
|
className: "ad-addForm",
|