@vibedev-si/dsh-vibedev 0.3.4 → 0.3.6
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/README.md +42 -3
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/client/client.js +1328 -75
- package/lib/account/index.d.ts +40 -6
- package/lib/account/latency.d.ts +81 -0
- package/lib/{anthropic-messages-KOS0z8Fy.js → anthropic-messages-BgIfgjNt.js} +11 -11
- package/lib/audio/request.d.ts +5 -0
- package/lib/feedback/client-info.d.ts +51 -0
- package/lib/feedback/index.d.ts +46 -0
- package/lib/feedback/observe.d.ts +43 -0
- package/lib/feedback/queue.d.ts +110 -0
- package/lib/feedback/recent-errors.d.ts +59 -0
- package/lib/feedback/routes.d.ts +31 -0
- package/lib/feedback/uploader.d.ts +131 -0
- package/lib/feedback/wire.d.ts +128 -0
- package/lib/gateway/assets.d.ts +38 -5
- package/lib/gateway/catalog.d.ts +11 -0
- package/lib/gateway/errors.d.ts +10 -3
- package/lib/gateway/http.d.ts +12 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +2008 -373
- package/lib/{node-vkDR3GtK.js → node-Br-0fshF.js} +2 -2
- package/lib/{node-Cujw_a4_.js → node-D58f7Ea6.js} +5 -5
- package/lib/video/plan.d.ts +17 -2
- package/package.json +4 -1
package/client/client.js
CHANGED
|
@@ -5,8 +5,236 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region src/client/feedback-store.ts
|
|
9
|
+
/**
|
|
10
|
+
* The feedback dialog's state and its two Host routes: the text of the
|
|
11
|
+
* optional "recent errors" attachment (`GET /api/dsh-vibedev/feedback/attachment`)
|
|
12
|
+
* and the submission (`POST /api/dsh-vibedev/feedback`).
|
|
13
|
+
*
|
|
14
|
+
* The attachment is sent only when its box is ticked, and then exactly the
|
|
15
|
+
* text the dialog showed. Free of React and the DOM (fetch is injectable), so
|
|
16
|
+
* the whole flow is tested in node.
|
|
17
|
+
*/
|
|
18
|
+
/** The categories DeepSeek Harness files feedback under, in its order. */
|
|
19
|
+
const FEEDBACK_CATEGORIES = [
|
|
20
|
+
"task-result",
|
|
21
|
+
"instruction-following",
|
|
22
|
+
"product-interaction",
|
|
23
|
+
"service-stability",
|
|
24
|
+
"resource-cost",
|
|
25
|
+
"security-privacy-permission",
|
|
26
|
+
"other"
|
|
27
|
+
];
|
|
28
|
+
const FEEDBACK_ROUTE = "/api/dsh-vibedev/feedback";
|
|
29
|
+
const FEEDBACK_ATTACHMENT_ROUTE = "/api/dsh-vibedev/feedback/attachment";
|
|
30
|
+
/** The gateway's limit on the text, in code points. */
|
|
31
|
+
const FEEDBACK_MAX_TEXT = 4e3;
|
|
32
|
+
const INITIAL = {
|
|
33
|
+
open: false,
|
|
34
|
+
category: void 0,
|
|
35
|
+
text: "",
|
|
36
|
+
attach: false,
|
|
37
|
+
preview: { status: "idle" },
|
|
38
|
+
phase: { kind: "editing" }
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Text cut to the gateway's limit, counted in code points as the gateway counts it.
|
|
42
|
+
* @param text - the text.
|
|
43
|
+
* @returns at most 4,000 code points.
|
|
44
|
+
*/
|
|
45
|
+
function limitText(text) {
|
|
46
|
+
const characters = [...text];
|
|
47
|
+
return characters.length <= 4e3 ? text : characters.slice(0, FEEDBACK_MAX_TEXT).join("");
|
|
48
|
+
}
|
|
49
|
+
/** The text's length in code points. */
|
|
50
|
+
function textLength(text) {
|
|
51
|
+
let count = 0;
|
|
52
|
+
for (const _ of text) count++;
|
|
53
|
+
return count;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether the dialog can send: a category or some text, and, with the box ticked, the attachment already shown.
|
|
57
|
+
* @param state - the dialog state.
|
|
58
|
+
* @returns true when something would be sent.
|
|
59
|
+
*/
|
|
60
|
+
function canSend(state) {
|
|
61
|
+
return state.phase.kind === "editing" && (state.category !== void 0 || state.text.trim() !== "") && !(state.attach && state.preview.status === "loading");
|
|
62
|
+
}
|
|
63
|
+
/** The feedback dialog's store. */
|
|
64
|
+
var FeedbackStore = class {
|
|
65
|
+
options;
|
|
66
|
+
state = INITIAL;
|
|
67
|
+
listeners = /* @__PURE__ */ new Set();
|
|
68
|
+
/** Bumped by every opening and closing, so an answer for an earlier opening is ignored. */
|
|
69
|
+
generation = 0;
|
|
70
|
+
/**
|
|
71
|
+
* @param options - fetch (a test seam).
|
|
72
|
+
*/
|
|
73
|
+
constructor(options = {}) {
|
|
74
|
+
this.options = options;
|
|
75
|
+
}
|
|
76
|
+
subscribe = (listener) => {
|
|
77
|
+
this.listeners.add(listener);
|
|
78
|
+
return () => {
|
|
79
|
+
this.listeners.delete(listener);
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
getSnapshot = () => this.state;
|
|
83
|
+
set(change) {
|
|
84
|
+
this.state = {
|
|
85
|
+
...this.state,
|
|
86
|
+
...change
|
|
87
|
+
};
|
|
88
|
+
for (const listener of this.listeners) listener();
|
|
89
|
+
}
|
|
90
|
+
fetch(path, init) {
|
|
91
|
+
return (this.options.fetch ?? globalThis.fetch)(path, init);
|
|
92
|
+
}
|
|
93
|
+
/** Open the dialog with an empty form. */
|
|
94
|
+
open() {
|
|
95
|
+
this.generation++;
|
|
96
|
+
this.state = {
|
|
97
|
+
...INITIAL,
|
|
98
|
+
open: true
|
|
99
|
+
};
|
|
100
|
+
for (const listener of this.listeners) listener();
|
|
101
|
+
}
|
|
102
|
+
/** Close it; whatever was sent or queued carries on without the dialog. */
|
|
103
|
+
close() {
|
|
104
|
+
this.generation++;
|
|
105
|
+
this.state = INITIAL;
|
|
106
|
+
for (const listener of this.listeners) listener();
|
|
107
|
+
}
|
|
108
|
+
/** Choose a category, or none. */
|
|
109
|
+
setCategory(category) {
|
|
110
|
+
if (this.state.phase.kind !== "editing") return;
|
|
111
|
+
this.set({
|
|
112
|
+
category,
|
|
113
|
+
phase: { kind: "editing" }
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/** Change the text (cut to 4,000 code points). */
|
|
117
|
+
setText(text) {
|
|
118
|
+
if (this.state.phase.kind !== "editing") return;
|
|
119
|
+
this.set({
|
|
120
|
+
text: limitText(text),
|
|
121
|
+
phase: { kind: "editing" }
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Tick or untick "attach recent errors". Ticking reads the text that would be sent, every time, so what the dialog
|
|
126
|
+
* shows is what goes.
|
|
127
|
+
* @param attach - the box's new state.
|
|
128
|
+
* @returns once the preview (if any) is read.
|
|
129
|
+
*/
|
|
130
|
+
async setAttach(attach) {
|
|
131
|
+
if (this.state.phase.kind !== "editing") return;
|
|
132
|
+
if (!attach) {
|
|
133
|
+
this.set({ attach: false });
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const generation = ++this.generation;
|
|
137
|
+
this.set({
|
|
138
|
+
attach: true,
|
|
139
|
+
preview: { status: "loading" }
|
|
140
|
+
});
|
|
141
|
+
let preview;
|
|
142
|
+
try {
|
|
143
|
+
const response = await this.fetch(FEEDBACK_ATTACHMENT_ROUTE);
|
|
144
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
145
|
+
const body = await response.json();
|
|
146
|
+
if (typeof body.content !== "string" || typeof body.entries !== "number" || typeof body.bytes !== "number") throw new Error("not a preview");
|
|
147
|
+
preview = {
|
|
148
|
+
status: "ready",
|
|
149
|
+
preview: {
|
|
150
|
+
content: body.content,
|
|
151
|
+
entries: body.entries,
|
|
152
|
+
bytes: body.bytes
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
} catch {
|
|
156
|
+
preview = { status: "failed" };
|
|
157
|
+
}
|
|
158
|
+
if (generation === this.generation) this.set({ preview });
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Send the feedback: the category and text, and the shown attachment only when its box is ticked.
|
|
162
|
+
* @param locale - the language the dialog is in.
|
|
163
|
+
* @returns once the Host answered.
|
|
164
|
+
*/
|
|
165
|
+
async submit(locale) {
|
|
166
|
+
const state = this.state;
|
|
167
|
+
if (!canSend(state)) return;
|
|
168
|
+
const generation = ++this.generation;
|
|
169
|
+
const shown = state.attach && state.preview.status === "ready" && state.preview.preview.content !== "" ? state.preview.preview.content : void 0;
|
|
170
|
+
this.set({ phase: { kind: "sending" } });
|
|
171
|
+
let phase;
|
|
172
|
+
try {
|
|
173
|
+
const response = await this.fetch(FEEDBACK_ROUTE, {
|
|
174
|
+
method: "POST",
|
|
175
|
+
headers: { "content-type": "application/json" },
|
|
176
|
+
body: JSON.stringify({
|
|
177
|
+
...state.category === void 0 ? {} : { category: state.category },
|
|
178
|
+
...state.text.trim() === "" ? {} : { text: state.text },
|
|
179
|
+
...shown === void 0 ? {} : { attachment: { content: shown } },
|
|
180
|
+
...locale === void 0 ? {} : { locale }
|
|
181
|
+
})
|
|
182
|
+
});
|
|
183
|
+
const body = await response.json().catch(() => void 0);
|
|
184
|
+
if (response.status === 409 && body?.error?.code === "SIGNED_OUT") phase = { kind: "signed-out" };
|
|
185
|
+
else if (response.status === 400) phase = {
|
|
186
|
+
kind: "editing",
|
|
187
|
+
error: "invalid"
|
|
188
|
+
};
|
|
189
|
+
else if (!response.ok) phase = {
|
|
190
|
+
kind: "editing",
|
|
191
|
+
error: "failed"
|
|
192
|
+
};
|
|
193
|
+
else if (body?.status === "sent") phase = { kind: "sent" };
|
|
194
|
+
else if (body?.status === "queued") phase = {
|
|
195
|
+
kind: "queued",
|
|
196
|
+
reason: body.reason === "offline" || body.reason === "signed-out" ? body.reason : "later"
|
|
197
|
+
};
|
|
198
|
+
else phase = {
|
|
199
|
+
kind: "editing",
|
|
200
|
+
error: "rejected",
|
|
201
|
+
...typeof body?.code === "string" ? { code: body.code } : {}
|
|
202
|
+
};
|
|
203
|
+
} catch {
|
|
204
|
+
phase = {
|
|
205
|
+
kind: "editing",
|
|
206
|
+
error: "failed"
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (generation === this.generation) this.set({ phase });
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
//#endregion
|
|
8
213
|
//#region src/client/account-store.ts
|
|
214
|
+
/**
|
|
215
|
+
* The VibeDev account as the browser half sees it: one store the Settings
|
|
216
|
+
* section and the sidebar status share. It reads the Host route
|
|
217
|
+
* (`GET /api/dsh-vibedev/account`) on start, every 2 s while a sign-in waits
|
|
218
|
+
* for the browser, and whenever the window regains focus. Otherwise it keeps a
|
|
219
|
+
* long poll open (`?since=<revision>`), which the Host answers as soon as the
|
|
220
|
+
* balance or the person changes — a charge shows within seconds; a Host
|
|
221
|
+
* without long polls is read every minute. The actions call the sign-in,
|
|
222
|
+
* cancel and sign-out routes.
|
|
223
|
+
*
|
|
224
|
+
* The balance card (hovering the sidebar row) and the row's menu ask for a
|
|
225
|
+
* fresh balance when the one shown was read more than 10 s ago, and the card
|
|
226
|
+
* measures the network latency to the gateway (`POST /api/dsh-vibedev/latency`)
|
|
227
|
+
* when it opens and the last measurement is more than a minute old, or when
|
|
228
|
+
* asked to; never on a timer. Each of these runs at most once at a time.
|
|
229
|
+
*
|
|
230
|
+
* The account menus' 意见反馈 dialog has its own small store (`feedback`),
|
|
231
|
+
* on the same Host connection.
|
|
232
|
+
*
|
|
233
|
+
* Kept free of React and of the DOM beyond `fetch` and timers (both
|
|
234
|
+
* injectable) so it can be tested in node.
|
|
235
|
+
*/
|
|
9
236
|
const ACCOUNT_ROUTE = "/api/dsh-vibedev/account";
|
|
237
|
+
const LATENCY_ROUTE = "/api/dsh-vibedev/latency";
|
|
10
238
|
const PENDING_POLL_MS = 2e3;
|
|
11
239
|
const IDLE_POLL_MS = 6e4;
|
|
12
240
|
/** After a failed long poll, the next one waits this long (the Host may be restarting). */
|
|
@@ -15,12 +243,6 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
15
243
|
function displayName(view) {
|
|
16
244
|
return view?.user?.nickname ?? view?.user?.email;
|
|
17
245
|
}
|
|
18
|
-
/** The balance as text, e.g. `¥12.50`. */
|
|
19
|
-
function balanceText(view) {
|
|
20
|
-
const balance = view?.balance;
|
|
21
|
-
if (balance === void 0) return void 0;
|
|
22
|
-
return `${balance.currency === "CNY" ? "¥" : balance.currency === "USD" ? "$" : `${balance.currency} `}${balance.amount}`;
|
|
23
|
-
}
|
|
24
246
|
/** The account store. */
|
|
25
247
|
var AccountStore = class {
|
|
26
248
|
options;
|
|
@@ -28,21 +250,33 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
28
250
|
view: void 0,
|
|
29
251
|
loadFailed: false,
|
|
30
252
|
busy: void 0,
|
|
31
|
-
actionError: void 0
|
|
253
|
+
actionError: void 0,
|
|
254
|
+
refreshing: false,
|
|
255
|
+
latency: { measuring: false }
|
|
32
256
|
};
|
|
33
257
|
listeners = /* @__PURE__ */ new Set();
|
|
34
258
|
timer;
|
|
35
259
|
reading;
|
|
260
|
+
/** The running read asks the Host to read the balance again. */
|
|
261
|
+
readingFresh = false;
|
|
262
|
+
/** A fresh read asked for while a plain one ran: it starts when that one ends. */
|
|
263
|
+
queuedFresh;
|
|
264
|
+
measuring;
|
|
36
265
|
stopped = true;
|
|
37
266
|
unsubscribeFocus;
|
|
38
267
|
/** The open long poll, when one is. */
|
|
39
268
|
watching;
|
|
269
|
+
/** The feedback dialog the account menus open, on the same Host connection. */
|
|
270
|
+
feedback;
|
|
40
271
|
/**
|
|
41
|
-
* @param options - fetch, timers, window opening and
|
|
272
|
+
* @param options - fetch, timers, window opening, focus and the clock (test seams).
|
|
42
273
|
*/
|
|
43
274
|
constructor(options = {}) {
|
|
44
275
|
this.options = options;
|
|
276
|
+
this.feedback = new FeedbackStore(options.fetch === void 0 ? {} : { fetch: options.fetch });
|
|
45
277
|
}
|
|
278
|
+
/** The store's clock (epoch ms), which the card's "N 秒前" reads as well. */
|
|
279
|
+
now = () => (this.options.now ?? Date.now)();
|
|
46
280
|
/** Subscribe for useSyncExternalStore. */
|
|
47
281
|
subscribe = (listener) => {
|
|
48
282
|
this.listeners.add(listener);
|
|
@@ -143,26 +377,101 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
143
377
|
})();
|
|
144
378
|
}
|
|
145
379
|
/**
|
|
146
|
-
* Read the account now.
|
|
380
|
+
* Read the account now. One read runs at a time: a second call shares it, and a fresh read asked for while a
|
|
381
|
+
* plain one runs starts as soon as that one ends (so the balance is still read again).
|
|
147
382
|
* @param fresh - ask the Host to read the balance again.
|
|
148
383
|
*/
|
|
149
384
|
refresh(fresh = false) {
|
|
150
|
-
this.reading
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
385
|
+
const running = this.reading;
|
|
386
|
+
if (running !== void 0) {
|
|
387
|
+
if (!fresh || this.readingFresh) return running;
|
|
388
|
+
if (!this.state.refreshing) this.set({ refreshing: true });
|
|
389
|
+
this.queuedFresh ??= running.then(() => {
|
|
390
|
+
this.queuedFresh = void 0;
|
|
391
|
+
return this.refresh(true);
|
|
392
|
+
});
|
|
393
|
+
return this.queuedFresh;
|
|
394
|
+
}
|
|
395
|
+
this.readingFresh = fresh;
|
|
396
|
+
if (fresh && !this.state.refreshing) this.set({ refreshing: true });
|
|
397
|
+
const reading = this.read(fresh).finally(() => {
|
|
398
|
+
this.reading = void 0;
|
|
399
|
+
this.readingFresh = false;
|
|
400
|
+
this.schedule();
|
|
401
|
+
});
|
|
402
|
+
this.reading = reading;
|
|
403
|
+
return reading;
|
|
404
|
+
}
|
|
405
|
+
async read(fresh) {
|
|
406
|
+
try {
|
|
407
|
+
const response = await this.fetch(fresh ? `${ACCOUNT_ROUTE}?fresh=1` : ACCOUNT_ROUTE);
|
|
408
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
409
|
+
this.set({
|
|
410
|
+
view: await response.json(),
|
|
411
|
+
loadFailed: false,
|
|
412
|
+
...fresh ? { refreshing: false } : {}
|
|
413
|
+
});
|
|
414
|
+
} catch {
|
|
415
|
+
this.set({
|
|
416
|
+
loadFailed: true,
|
|
417
|
+
...fresh ? { refreshing: false } : {}
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Read the balance again when the one shown was read more than {@link FRESH_READ_AFTER_MS} ago (or never), for
|
|
423
|
+
* the balance card and the account menu; a recent one is kept, and nothing is read while nobody is signed in.
|
|
424
|
+
* @returns once the read (if any) ended.
|
|
425
|
+
*/
|
|
426
|
+
refreshIfStale() {
|
|
427
|
+
const view = this.state.view;
|
|
428
|
+
if (view === void 0 || view.source === "none") return Promise.resolve();
|
|
429
|
+
if (view.readAt !== void 0 && this.now() - view.readAt <= 1e4) return Promise.resolve();
|
|
430
|
+
return this.refresh(true);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Measure the network latency to the gateway (the Host times `GET /health`). One measurement runs at a time.
|
|
434
|
+
* @param fresh - measure again even when the Host measured within the last minute (重新测速).
|
|
435
|
+
* @returns once the measurement ended.
|
|
436
|
+
*/
|
|
437
|
+
measureLatency(fresh = false) {
|
|
438
|
+
if (this.measuring !== void 0) return this.measuring;
|
|
439
|
+
const measuring = this.measure(fresh).finally(() => {
|
|
440
|
+
this.measuring = void 0;
|
|
441
|
+
});
|
|
442
|
+
this.measuring = measuring;
|
|
443
|
+
return measuring;
|
|
444
|
+
}
|
|
445
|
+
async measure(fresh) {
|
|
446
|
+
this.set({ latency: {
|
|
447
|
+
...this.state.latency,
|
|
448
|
+
measuring: true
|
|
449
|
+
} });
|
|
450
|
+
try {
|
|
451
|
+
const response = await this.fetch(fresh ? `${LATENCY_ROUTE}?fresh=1` : LATENCY_ROUTE, { method: "POST" });
|
|
452
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
453
|
+
const result = await response.json();
|
|
454
|
+
if (typeof result.measuredAt !== "number" || !Array.isArray(result.samplesMs)) throw new Error("not a latency result");
|
|
455
|
+
this.set({ latency: {
|
|
456
|
+
measuring: false,
|
|
457
|
+
result
|
|
458
|
+
} });
|
|
459
|
+
} catch {
|
|
460
|
+
this.set({ latency: {
|
|
461
|
+
...this.state.latency,
|
|
462
|
+
measuring: false,
|
|
463
|
+
requestFailed: true
|
|
464
|
+
} });
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* The balance card opened: a fresh balance when the one shown is more than 10 s old, and a latency measurement
|
|
469
|
+
* when the last one is more than a minute old (or there is none).
|
|
470
|
+
*/
|
|
471
|
+
openedCard() {
|
|
472
|
+
this.refreshIfStale();
|
|
473
|
+
const last = this.state.latency.result;
|
|
474
|
+
if (this.measuring === void 0 && (last === void 0 || this.now() - last.measuredAt > 6e4)) this.measureLatency();
|
|
166
475
|
}
|
|
167
476
|
/** Start a sign-in: the Host opens the system browser; when it could not, the page opens the link. */
|
|
168
477
|
async signIn() {
|
|
@@ -227,6 +536,133 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
227
536
|
}
|
|
228
537
|
};
|
|
229
538
|
//#endregion
|
|
539
|
+
//#region src/client/balance-format.ts
|
|
540
|
+
/**
|
|
541
|
+
* The unit words of the page's language, as its dictionary names them (`numberStyle`).
|
|
542
|
+
* @param t - the plugin's dictionary.
|
|
543
|
+
* @returns `en` for the English dictionary, else `zh`.
|
|
544
|
+
*/
|
|
545
|
+
function numberStyleOf(t) {
|
|
546
|
+
return t("numberStyle") === "en" ? "en" : "zh";
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* The amount as the console writes it: `Number(value).toFixed(2)`, read back as exact cents.
|
|
550
|
+
* @param value - decimal text or a number.
|
|
551
|
+
* @returns the cents and the sign, or undefined for anything that is not a finite number.
|
|
552
|
+
*/
|
|
553
|
+
function centsOf(value) {
|
|
554
|
+
const number = typeof value === "number" ? value : value.trim() === "" ? NaN : Number(value);
|
|
555
|
+
if (!Number.isFinite(number)) return void 0;
|
|
556
|
+
const fixed = Math.abs(number) < 1e21 ? number.toFixed(2) : `${BigInt(number)}.00`;
|
|
557
|
+
const match = /^(-?)(\d+)\.(\d{2})$/.exec(fixed);
|
|
558
|
+
if (match === null) return void 0;
|
|
559
|
+
const cents = BigInt(`${match[2]}${match[3]}`);
|
|
560
|
+
return {
|
|
561
|
+
negative: match[1] === "-" && cents !== 0n,
|
|
562
|
+
cents
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
const grouped = (digits) => digits.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
566
|
+
/**
|
|
567
|
+
* What goes before the digits.
|
|
568
|
+
* @param currency - the currency code.
|
|
569
|
+
* @returns `¥` for CNY, `$` for USD, else the code and a space.
|
|
570
|
+
*/
|
|
571
|
+
function currencyPrefix(currency) {
|
|
572
|
+
return currency === "CNY" ? "¥" : currency === "USD" ? "$" : `${currency} `;
|
|
573
|
+
}
|
|
574
|
+
function full({ negative, cents }, currency) {
|
|
575
|
+
const digits = cents.toString().padStart(3, "0");
|
|
576
|
+
return `${negative ? "-" : ""}${currencyPrefix(currency)}${grouped(digits.slice(0, -2))}.${digits.slice(-2)}`;
|
|
577
|
+
}
|
|
578
|
+
/** From which amount (in yuan) each unit is used, and how many yuan it stands for, largest first. */
|
|
579
|
+
const SCALES = {
|
|
580
|
+
zh: [{
|
|
581
|
+
from: 100000000n,
|
|
582
|
+
unit: 100000000n,
|
|
583
|
+
suffix: "亿"
|
|
584
|
+
}, {
|
|
585
|
+
from: 10000n,
|
|
586
|
+
unit: 10000n,
|
|
587
|
+
suffix: "万"
|
|
588
|
+
}],
|
|
589
|
+
en: [
|
|
590
|
+
{
|
|
591
|
+
from: 1000000000n,
|
|
592
|
+
unit: 1000000000n,
|
|
593
|
+
suffix: "B"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
from: 1000000n,
|
|
597
|
+
unit: 1000000n,
|
|
598
|
+
suffix: "M"
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
from: 10000n,
|
|
602
|
+
unit: 1000n,
|
|
603
|
+
suffix: "K"
|
|
604
|
+
}
|
|
605
|
+
]
|
|
606
|
+
};
|
|
607
|
+
/**
|
|
608
|
+
* The full form: two decimals as the console writes them, with thousands separators.
|
|
609
|
+
* @param amount - decimal text or a number; undefined when unknown.
|
|
610
|
+
* @param currency - the currency code.
|
|
611
|
+
* @returns e.g. `¥99,976,091.91`, `-¥3.50`, `$12.00`; undefined when there is no finite amount.
|
|
612
|
+
*/
|
|
613
|
+
function formatMoney(amount, currency) {
|
|
614
|
+
const value = amount === void 0 ? void 0 : centsOf(amount);
|
|
615
|
+
return value === void 0 ? void 0 : full(value, currency);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* The compact form for the sidebar row.
|
|
619
|
+
* @param amount - decimal text or a number; undefined when unknown.
|
|
620
|
+
* @param currency - the currency code.
|
|
621
|
+
* @param style - 万 / 亿 (zh) or K / M / B (en).
|
|
622
|
+
* @returns e.g. `¥9,997.6万`, `¥99.97M`, `¥8,000.50`; undefined when there is no finite amount.
|
|
623
|
+
*/
|
|
624
|
+
function formatMoneyCompact(amount, currency, style) {
|
|
625
|
+
const value = amount === void 0 ? void 0 : centsOf(amount);
|
|
626
|
+
if (value === void 0) return void 0;
|
|
627
|
+
const scale = SCALES[style].find((item) => value.cents >= item.from * 100n);
|
|
628
|
+
if (scale === void 0) return full(value, currency);
|
|
629
|
+
const hundredths = value.cents / scale.unit;
|
|
630
|
+
const fraction = (hundredths % 100n).toString().padStart(2, "0").replace(/0+$/, "");
|
|
631
|
+
return `${value.negative ? "-" : ""}${currencyPrefix(currency)}${grouped((hundredths / 100n).toString())}${fraction === "" ? "" : `.${fraction}`}${scale.suffix}`;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Whether an amount reads as more than zero at two decimals (a hold of 0.001 is not worth a line).
|
|
635
|
+
* @param amount - decimal text, or undefined.
|
|
636
|
+
* @returns true for a positive amount.
|
|
637
|
+
*/
|
|
638
|
+
function isPositiveAmount(amount) {
|
|
639
|
+
const value = amount === void 0 ? void 0 : centsOf(amount);
|
|
640
|
+
return value !== void 0 && !value.negative && value.cents > 0n;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* The total of what can be spent and what is held, added the way the console adds them (as numbers).
|
|
644
|
+
* @param amount - the available amount.
|
|
645
|
+
* @param frozen - the held amount, when known.
|
|
646
|
+
* @returns the sum, or undefined when the available amount is not a number.
|
|
647
|
+
*/
|
|
648
|
+
function totalAmount(amount, frozen) {
|
|
649
|
+
const available = Number(amount);
|
|
650
|
+
const held = frozen === void 0 ? 0 : Number(frozen);
|
|
651
|
+
if (amount.trim() === "" || !Number.isFinite(available)) return void 0;
|
|
652
|
+
return Number.isFinite(held) ? available + held : available;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* The balance in one of the two forms.
|
|
656
|
+
* @param balance - the balance, when known.
|
|
657
|
+
* @param form - `full` for details, `compact` for the sidebar row.
|
|
658
|
+
* @param style - unit words for the compact form.
|
|
659
|
+
* @returns the text, or undefined without a usable balance.
|
|
660
|
+
*/
|
|
661
|
+
function balanceText(balance, form = "full", style = "zh") {
|
|
662
|
+
if (balance === void 0) return void 0;
|
|
663
|
+
return form === "full" ? formatMoney(balance.amount, balance.currency) : formatMoneyCompact(balance.amount, balance.currency, style);
|
|
664
|
+
}
|
|
665
|
+
//#endregion
|
|
230
666
|
//#region src/client/sign-in-presentation.ts
|
|
231
667
|
/** @param attempt - latest safe Host snapshot. @returns a locale key for a terminal login failure. */
|
|
232
668
|
function failureKey(attempt) {
|
|
@@ -372,7 +808,69 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
372
808
|
sidebarMenu: "VibeDev 账号",
|
|
373
809
|
sidebarIntro: "登录后可用 VibeDev 的模型和媒体生成",
|
|
374
810
|
settings: "设置",
|
|
375
|
-
accountMenu: "VibeDev 账号菜单"
|
|
811
|
+
accountMenu: "VibeDev 账号菜单",
|
|
812
|
+
numberStyle: "zh",
|
|
813
|
+
balanceFrozen: "冻结中:{amount},任务结束后结算",
|
|
814
|
+
cardTitle: "VibeDev 余额",
|
|
815
|
+
cardAvailable: "可用",
|
|
816
|
+
cardFrozen: "冻结中",
|
|
817
|
+
cardFrozenNote: "视频等任务提交时预扣,结束后结算",
|
|
818
|
+
cardTotal: "合计",
|
|
819
|
+
cardUpdated: "{ago}更新",
|
|
820
|
+
cardReading: "更新中…",
|
|
821
|
+
cardReadFailed: "读取失败,显示的是 {ago}的余额",
|
|
822
|
+
cardReadFailedNow: "读取失败,显示的是刚才读到的余额",
|
|
823
|
+
cardReadFailedNone: "余额读取失败",
|
|
824
|
+
agoNow: "刚刚",
|
|
825
|
+
agoSeconds: "{n} 秒前",
|
|
826
|
+
agoMinutes: "{n} 分钟前",
|
|
827
|
+
agoHours: "{n} 小时前",
|
|
828
|
+
cardLatency: "网络延迟",
|
|
829
|
+
cardLatencyNote: "到 VibeDev 网关的网络,非模型速度",
|
|
830
|
+
cardMeasuring: "测速中…",
|
|
831
|
+
cardRemeasure: "重新测速",
|
|
832
|
+
cardMeasureFailed: "测速没有完成",
|
|
833
|
+
latencyFast: "很快",
|
|
834
|
+
latencyNormal: "正常",
|
|
835
|
+
latencySlow: "较慢",
|
|
836
|
+
latencyVerySlow: "很慢",
|
|
837
|
+
latencyUnreachable: "无法连接",
|
|
838
|
+
latencyTimeout: "超时",
|
|
839
|
+
latencyNetwork: "网络错误",
|
|
840
|
+
latencyHttp: "HTTP {status}",
|
|
841
|
+
localeTag: "zh-CN",
|
|
842
|
+
close: "关闭",
|
|
843
|
+
feedbackMenu: "意见反馈",
|
|
844
|
+
feedbackTitle: "意见反馈",
|
|
845
|
+
feedbackIntro: "告诉我们哪里好用、哪里需要改进。反馈会随你的 VibeDev 账号发送给 VibeDev 团队。",
|
|
846
|
+
feedbackCategories: "反馈分类",
|
|
847
|
+
categoryTaskResult: "任务结果",
|
|
848
|
+
categoryInstructionFollowing: "指令理解与遵循",
|
|
849
|
+
categoryProductInteraction: "产品功能与交互",
|
|
850
|
+
categoryServiceStability: "稳定性和速度",
|
|
851
|
+
categoryResourceCost: "资源使用与费用",
|
|
852
|
+
categorySecurityPrivacyPermission: "安全隐私与权限",
|
|
853
|
+
categoryOther: "其他",
|
|
854
|
+
feedbackDetail: "反馈详情",
|
|
855
|
+
feedbackPlaceholder: "遇到了什么问题,或者有什么建议?",
|
|
856
|
+
feedbackCount: "{n} / {max}",
|
|
857
|
+
feedbackAttach: "附上最近的报错信息(可能包含文件路径或代码片段)",
|
|
858
|
+
feedbackAttachLoading: "正在读取报错信息…",
|
|
859
|
+
feedbackAttachPreview: "将附上以下内容({entries} 条,{size}):",
|
|
860
|
+
feedbackAttachEmpty: "最近没有报错,不会附带内容。",
|
|
861
|
+
feedbackAttachFailed: "没能读取报错信息,这次不会附带。",
|
|
862
|
+
feedbackSend: "发送",
|
|
863
|
+
feedbackSending: "正在发送…",
|
|
864
|
+
feedbackCancel: "取消",
|
|
865
|
+
feedbackDone: "完成",
|
|
866
|
+
feedbackSent: "已发送,谢谢!",
|
|
867
|
+
feedbackQueuedOffline: "已保存,联网后会自动发送",
|
|
868
|
+
feedbackQueuedLater: "已保存,稍后会自动发送",
|
|
869
|
+
feedbackQueuedSignedOut: "已保存,登录 VibeDev 后会自动发送",
|
|
870
|
+
feedbackErrorFailed: "没能发送,请检查网络后重试。",
|
|
871
|
+
feedbackErrorInvalid: "内容不符合要求,请修改后重试。",
|
|
872
|
+
feedbackErrorRejected: "VibeDev 没有接受这条反馈({code})。",
|
|
873
|
+
feedbackSignedOut: "意见反馈会随你的 VibeDev 账号发送,不会匿名提交。请先登录 VibeDev。"
|
|
376
874
|
};
|
|
377
875
|
const en = {
|
|
378
876
|
spending: "Spending",
|
|
@@ -448,7 +946,69 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
448
946
|
sidebarMenu: "VibeDev account",
|
|
449
947
|
sidebarIntro: "Sign in to use the VibeDev models and media generation",
|
|
450
948
|
settings: "Settings",
|
|
451
|
-
accountMenu: "VibeDev account menu"
|
|
949
|
+
accountMenu: "VibeDev account menu",
|
|
950
|
+
numberStyle: "en",
|
|
951
|
+
balanceFrozen: "On hold: {amount}, settled when the tasks end",
|
|
952
|
+
cardTitle: "VibeDev balance",
|
|
953
|
+
cardAvailable: "Available",
|
|
954
|
+
cardFrozen: "On hold",
|
|
955
|
+
cardFrozenNote: "Held when a video task starts, settled when it ends",
|
|
956
|
+
cardTotal: "Total",
|
|
957
|
+
cardUpdated: "Updated {ago}",
|
|
958
|
+
cardReading: "Updating…",
|
|
959
|
+
cardReadFailed: "Could not read it; this is the balance from {ago}",
|
|
960
|
+
cardReadFailedNow: "Could not read it; this is the balance read moments ago",
|
|
961
|
+
cardReadFailedNone: "The balance could not be read",
|
|
962
|
+
agoNow: "just now",
|
|
963
|
+
agoSeconds: "{n} s ago",
|
|
964
|
+
agoMinutes: "{n} min ago",
|
|
965
|
+
agoHours: "{n} h ago",
|
|
966
|
+
cardLatency: "Latency",
|
|
967
|
+
cardLatencyNote: "Round trip to the VibeDev gateway, not model speed",
|
|
968
|
+
cardMeasuring: "measuring…",
|
|
969
|
+
cardRemeasure: "Test again",
|
|
970
|
+
cardMeasureFailed: "could not be measured",
|
|
971
|
+
latencyFast: "Fast",
|
|
972
|
+
latencyNormal: "Normal",
|
|
973
|
+
latencySlow: "Slow",
|
|
974
|
+
latencyVerySlow: "Very slow",
|
|
975
|
+
latencyUnreachable: "Unreachable",
|
|
976
|
+
latencyTimeout: "timed out",
|
|
977
|
+
latencyNetwork: "network error",
|
|
978
|
+
latencyHttp: "HTTP {status}",
|
|
979
|
+
localeTag: "en",
|
|
980
|
+
close: "Close",
|
|
981
|
+
feedbackMenu: "Feedback",
|
|
982
|
+
feedbackTitle: "Feedback",
|
|
983
|
+
feedbackIntro: "Tell us what works and what needs improving. Feedback is sent to the VibeDev team with your VibeDev account.",
|
|
984
|
+
feedbackCategories: "Category",
|
|
985
|
+
categoryTaskResult: "Task result",
|
|
986
|
+
categoryInstructionFollowing: "Instruction understanding and following",
|
|
987
|
+
categoryProductInteraction: "Product features and interaction",
|
|
988
|
+
categoryServiceStability: "Stability and speed",
|
|
989
|
+
categoryResourceCost: "Resource usage and cost",
|
|
990
|
+
categorySecurityPrivacyPermission: "Security, privacy, and permissions",
|
|
991
|
+
categoryOther: "Other",
|
|
992
|
+
feedbackDetail: "Feedback details",
|
|
993
|
+
feedbackPlaceholder: "What went wrong, or what would you like to see?",
|
|
994
|
+
feedbackCount: "{n} / {max}",
|
|
995
|
+
feedbackAttach: "Attach recent error messages (may include file paths or code snippets)",
|
|
996
|
+
feedbackAttachLoading: "Reading the error messages…",
|
|
997
|
+
feedbackAttachPreview: "This will be attached ({entries} entries, {size}):",
|
|
998
|
+
feedbackAttachEmpty: "No recent errors; nothing will be attached.",
|
|
999
|
+
feedbackAttachFailed: "Could not read the error messages; nothing will be attached.",
|
|
1000
|
+
feedbackSend: "Send",
|
|
1001
|
+
feedbackSending: "Sending…",
|
|
1002
|
+
feedbackCancel: "Cancel",
|
|
1003
|
+
feedbackDone: "Done",
|
|
1004
|
+
feedbackSent: "Sent. Thank you!",
|
|
1005
|
+
feedbackQueuedOffline: "Saved; it will be sent automatically once you are online",
|
|
1006
|
+
feedbackQueuedLater: "Saved; it will be sent automatically later",
|
|
1007
|
+
feedbackQueuedSignedOut: "Saved; it will be sent once you sign in to VibeDev",
|
|
1008
|
+
feedbackErrorFailed: "Could not send it. Check your connection and try again.",
|
|
1009
|
+
feedbackErrorInvalid: "The feedback was not accepted as written. Edit it and try again.",
|
|
1010
|
+
feedbackErrorRejected: "VibeDev did not accept this feedback ({code}).",
|
|
1011
|
+
feedbackSignedOut: "Feedback is sent with your VibeDev account, never anonymously. Sign in to VibeDev first."
|
|
452
1012
|
};
|
|
453
1013
|
/**
|
|
454
1014
|
* Fill `{name}` placeholders.
|
|
@@ -466,7 +1026,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
466
1026
|
* balance and how many VibeDev models the pickers list, top up, sign out.
|
|
467
1027
|
* The DeepSeek account keeps its own section; this one never touches it.
|
|
468
1028
|
*/
|
|
469
|
-
const styles$
|
|
1029
|
+
const styles$2 = {
|
|
470
1030
|
page: {
|
|
471
1031
|
display: "flex",
|
|
472
1032
|
flexDirection: "column",
|
|
@@ -547,7 +1107,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
547
1107
|
}
|
|
548
1108
|
function ExternalLink(props) {
|
|
549
1109
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
550
|
-
style: styles$
|
|
1110
|
+
style: styles$2.link,
|
|
551
1111
|
href: props.href,
|
|
552
1112
|
target: "_blank",
|
|
553
1113
|
rel: "noreferrer",
|
|
@@ -560,13 +1120,14 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
560
1120
|
* @returns the section content.
|
|
561
1121
|
*/
|
|
562
1122
|
function AccountSection({ t, store, routeName }) {
|
|
563
|
-
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot);
|
|
1123
|
+
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
564
1124
|
(0, react.useEffect)(() => {
|
|
565
1125
|
store.refresh(true);
|
|
566
1126
|
}, [store]);
|
|
567
1127
|
const view = state.view;
|
|
568
1128
|
const who = displayName(view);
|
|
569
|
-
const balance = balanceText(view);
|
|
1129
|
+
const balance = balanceText(view?.balance, "full");
|
|
1130
|
+
const held = view?.balance !== void 0 && isPositiveAmount(view.balance.frozen) ? formatMoney(view.balance.frozen, view.balance.currency) : void 0;
|
|
570
1131
|
let status;
|
|
571
1132
|
let details = null;
|
|
572
1133
|
let actions = null;
|
|
@@ -574,11 +1135,11 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
574
1135
|
else if (view.pending !== void 0) {
|
|
575
1136
|
status = view.attempt?.phase === "committing" ? t("signInCommitting") : view.attempt?.phase === "exchanging" ? t("signInExchanging") : t("signingIn");
|
|
576
1137
|
details = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: view.attempt === void 0 || view.attempt.phase === "waiting-browser" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
577
|
-
style: styles$
|
|
1138
|
+
style: styles$2.line,
|
|
578
1139
|
children: t("pendingStatus")
|
|
579
1140
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
580
1141
|
type: "button",
|
|
581
|
-
style: styles$
|
|
1142
|
+
style: styles$2.link,
|
|
582
1143
|
onClick: () => {
|
|
583
1144
|
store.openPending();
|
|
584
1145
|
},
|
|
@@ -605,7 +1166,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
605
1166
|
children: state.busy === "sign-in" ? t("signingIn") : t("signIn")
|
|
606
1167
|
});
|
|
607
1168
|
details = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
608
|
-
style: styles$
|
|
1169
|
+
style: styles$2.quiet,
|
|
609
1170
|
children: [
|
|
610
1171
|
t("registerHint"),
|
|
611
1172
|
" ",
|
|
@@ -619,18 +1180,22 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
619
1180
|
status = view.source === "host" ? fill(t("hostStatus"), { who: who === void 0 ? "" : `:${who}` }) : view.source === "key" ? t("keyStatus") : who === void 0 ? t("signedInPlugin") : fill(t("signedInAs"), { who });
|
|
620
1181
|
details = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
621
1182
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
622
|
-
style: styles$
|
|
1183
|
+
style: styles$2.line,
|
|
623
1184
|
children: balance === void 0 ? t("balanceUnknown") : fill(t("balance"), { amount: balance })
|
|
624
1185
|
}),
|
|
1186
|
+
held === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1187
|
+
style: styles$2.quiet,
|
|
1188
|
+
children: fill(t("balanceFrozen"), { amount: held })
|
|
1189
|
+
}),
|
|
625
1190
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
626
|
-
style: styles$
|
|
1191
|
+
style: styles$2.line,
|
|
627
1192
|
children: view.models.hidden === "host-account" ? t("modelsHost") : fill(t("modelsListed"), {
|
|
628
1193
|
name: routeName,
|
|
629
1194
|
count: view.models.count
|
|
630
1195
|
})
|
|
631
1196
|
}),
|
|
632
1197
|
view.source === "host" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
633
|
-
style: styles$
|
|
1198
|
+
style: styles$2.quiet,
|
|
634
1199
|
children: t("hostHint")
|
|
635
1200
|
}) : null
|
|
636
1201
|
] });
|
|
@@ -674,22 +1239,22 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
674
1239
|
const loginFailure = view?.source === "none" ? failureKey(view.attempt) : void 0;
|
|
675
1240
|
const supportDetails = loginFailure === void 0 ? void 0 : safeSupportDetails(view?.attempt);
|
|
676
1241
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
677
|
-
style: styles$
|
|
1242
|
+
style: styles$2.page,
|
|
678
1243
|
"data-dsh-vibedev-account": true,
|
|
679
1244
|
children: [
|
|
680
1245
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
681
|
-
style: styles$
|
|
1246
|
+
style: styles$2.title,
|
|
682
1247
|
children: t("accountTitle")
|
|
683
1248
|
}),
|
|
684
1249
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
685
|
-
style: styles$
|
|
1250
|
+
style: styles$2.intro,
|
|
686
1251
|
children: fill(t("accountIntro"), { name: routeName })
|
|
687
1252
|
}),
|
|
688
1253
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
689
|
-
style: styles$
|
|
1254
|
+
style: styles$2.card,
|
|
690
1255
|
children: [
|
|
691
1256
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
692
|
-
style: styles$
|
|
1257
|
+
style: styles$2.statusRow,
|
|
693
1258
|
role: "status",
|
|
694
1259
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
|
|
695
1260
|
state: statusDot(state),
|
|
@@ -698,21 +1263,21 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
698
1263
|
}),
|
|
699
1264
|
details,
|
|
700
1265
|
actions === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
701
|
-
style: styles$
|
|
1266
|
+
style: styles$2.actions,
|
|
702
1267
|
children: actions
|
|
703
1268
|
}),
|
|
704
1269
|
error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
705
|
-
style: styles$
|
|
1270
|
+
style: styles$2.error,
|
|
706
1271
|
role: "alert",
|
|
707
1272
|
children: error
|
|
708
1273
|
}),
|
|
709
1274
|
loginFailure === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
710
|
-
style: styles$
|
|
1275
|
+
style: styles$2.error,
|
|
711
1276
|
role: "alert",
|
|
712
1277
|
children: t(loginFailure)
|
|
713
1278
|
}),
|
|
714
1279
|
supportDetails === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
715
|
-
style: styles$
|
|
1280
|
+
style: styles$2.quiet,
|
|
716
1281
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: t("signInDiagnostic") }), supportDetails]
|
|
717
1282
|
})
|
|
718
1283
|
]
|
|
@@ -789,7 +1354,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
789
1354
|
* output folder, the pinned models, and how the account works. Edits are
|
|
790
1355
|
* staged and written together by the save, like every settings page there.
|
|
791
1356
|
*/
|
|
792
|
-
const styles = {
|
|
1357
|
+
const styles$1 = {
|
|
793
1358
|
section: {
|
|
794
1359
|
padding: "12px 0",
|
|
795
1360
|
borderTop: "0.5px solid var(--dsw-alias-border-l2)"
|
|
@@ -849,14 +1414,14 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
849
1414
|
};
|
|
850
1415
|
function Section(props) {
|
|
851
1416
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
852
|
-
style: props.first === true ? styles.firstSection : styles.section,
|
|
1417
|
+
style: props.first === true ? styles$1.firstSection : styles$1.section,
|
|
853
1418
|
children: [
|
|
854
1419
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
|
|
855
|
-
style: styles.sectionTitle,
|
|
1420
|
+
style: styles$1.sectionTitle,
|
|
856
1421
|
children: props.title
|
|
857
1422
|
}),
|
|
858
1423
|
props.hint === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
859
|
-
style: styles.sectionHint,
|
|
1424
|
+
style: styles$1.sectionHint,
|
|
860
1425
|
children: props.hint
|
|
861
1426
|
}),
|
|
862
1427
|
props.children
|
|
@@ -872,7 +1437,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
872
1437
|
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot);
|
|
873
1438
|
const site = (0, react.useSyncExternalStore)(account.subscribe, account.getSnapshot).view?.links.register;
|
|
874
1439
|
if (state.status === "loading") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
875
|
-
style: styles.quiet,
|
|
1440
|
+
style: styles$1.quiet,
|
|
876
1441
|
role: "status",
|
|
877
1442
|
children: t("loading")
|
|
878
1443
|
});
|
|
@@ -908,14 +1473,14 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
908
1473
|
first: true,
|
|
909
1474
|
title: t("spending"),
|
|
910
1475
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
911
|
-
style: styles.switchRow,
|
|
1476
|
+
style: styles$1.switchRow,
|
|
912
1477
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
913
|
-
style: styles.switchText,
|
|
1478
|
+
style: styles$1.switchText,
|
|
914
1479
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
915
|
-
style: styles.label,
|
|
1480
|
+
style: styles$1.label,
|
|
916
1481
|
children: t("confirmSpending")
|
|
917
1482
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
918
|
-
style: styles.hint,
|
|
1483
|
+
style: styles$1.hint,
|
|
919
1484
|
children: t("confirmSpendingHint")
|
|
920
1485
|
})]
|
|
921
1486
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
|
|
@@ -951,10 +1516,10 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
951
1516
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Section, {
|
|
952
1517
|
title: t("account"),
|
|
953
1518
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
954
|
-
style: styles.hint,
|
|
1519
|
+
style: styles$1.hint,
|
|
955
1520
|
children: t("accountHint")
|
|
956
1521
|
}), site === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
957
|
-
style: styles.link,
|
|
1522
|
+
style: styles$1.link,
|
|
958
1523
|
href: site,
|
|
959
1524
|
target: "_blank",
|
|
960
1525
|
rel: "noreferrer",
|
|
@@ -965,21 +1530,660 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
965
1530
|
});
|
|
966
1531
|
}
|
|
967
1532
|
//#endregion
|
|
1533
|
+
//#region src/client/BalanceCard.tsx
|
|
1534
|
+
/**
|
|
1535
|
+
* The balance card: resting the pointer on the sidebar's VibeDev row shows
|
|
1536
|
+
* what can be spent, what running tasks hold (only while they hold something)
|
|
1537
|
+
* and the total — each written in full, as the gateway's console writes them —
|
|
1538
|
+
* then how fresh that is, with 刷新, and the network latency to the gateway,
|
|
1539
|
+
* with 重新测速.
|
|
1540
|
+
*
|
|
1541
|
+
* Opening it reads the balance again when the one shown is more than 10 s old,
|
|
1542
|
+
* and measures the latency when the last measurement is more than a minute old
|
|
1543
|
+
* (account-store.ts). A balance that could not be read again is never passed
|
|
1544
|
+
* off as fresh: the card says the read failed and how old the balance shown is.
|
|
1545
|
+
*
|
|
1546
|
+
* It is the content of the DSH primitives' compact HoverCard, whose surface is
|
|
1547
|
+
* dark in both themes, so it takes the fixed light-on-dark steps DSH's own
|
|
1548
|
+
* hover cards use (the static theme tokens, with their values as fallbacks).
|
|
1549
|
+
*/
|
|
1550
|
+
/** DSH's hover-card text steps on its always-dark surface (white title, then two greys). */
|
|
1551
|
+
const TEXT = "var(--dsw-static-neutral-bluish-00, #ffffff)";
|
|
1552
|
+
const SECONDARY = "var(--dsw-static-neutral-bluish-300, #cfd3d6)";
|
|
1553
|
+
const TERTIARY = "var(--dsw-static-neutral-bluish-400, #adb2b8)";
|
|
1554
|
+
/** The action color DSH gives text buttons on its always-dark surfaces (the toast's action). */
|
|
1555
|
+
const ACTION = "var(--dsw-static-deepseek-400, #7aaaff)";
|
|
1556
|
+
const WARN = "var(--dsw-alias-state-warn-primary, #f59e0b)";
|
|
1557
|
+
const RULE = "color-mix(in srgb, var(--dsw-static-neutral-bluish-00, #ffffff) 12%, transparent)";
|
|
1558
|
+
/** A layout effect in the browser; where nothing is laid out (rendering to markup) a plain effect, which never runs. */
|
|
1559
|
+
const useBrowserLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
1560
|
+
const styles = {
|
|
1561
|
+
card: {
|
|
1562
|
+
display: "flex",
|
|
1563
|
+
flexDirection: "column",
|
|
1564
|
+
gap: 8,
|
|
1565
|
+
fontSize: 12,
|
|
1566
|
+
lineHeight: "16px",
|
|
1567
|
+
color: SECONDARY
|
|
1568
|
+
},
|
|
1569
|
+
title: {
|
|
1570
|
+
fontSize: 14,
|
|
1571
|
+
lineHeight: "20px",
|
|
1572
|
+
fontWeight: 500,
|
|
1573
|
+
color: TEXT
|
|
1574
|
+
},
|
|
1575
|
+
who: {
|
|
1576
|
+
marginTop: -6,
|
|
1577
|
+
overflow: "hidden",
|
|
1578
|
+
textOverflow: "ellipsis",
|
|
1579
|
+
whiteSpace: "nowrap"
|
|
1580
|
+
},
|
|
1581
|
+
amounts: {
|
|
1582
|
+
display: "flex",
|
|
1583
|
+
flexDirection: "column",
|
|
1584
|
+
gap: 4
|
|
1585
|
+
},
|
|
1586
|
+
row: {
|
|
1587
|
+
display: "flex",
|
|
1588
|
+
alignItems: "baseline",
|
|
1589
|
+
justifyContent: "space-between",
|
|
1590
|
+
gap: 12
|
|
1591
|
+
},
|
|
1592
|
+
value: {
|
|
1593
|
+
fontSize: 13,
|
|
1594
|
+
lineHeight: "18px",
|
|
1595
|
+
color: TEXT,
|
|
1596
|
+
fontVariantNumeric: "tabular-nums",
|
|
1597
|
+
whiteSpace: "nowrap"
|
|
1598
|
+
},
|
|
1599
|
+
note: { color: TERTIARY },
|
|
1600
|
+
rule: {
|
|
1601
|
+
height: 0,
|
|
1602
|
+
borderTop: `0.5px solid ${RULE}`
|
|
1603
|
+
},
|
|
1604
|
+
line: {
|
|
1605
|
+
display: "flex",
|
|
1606
|
+
flexWrap: "wrap",
|
|
1607
|
+
alignItems: "flex-start",
|
|
1608
|
+
justifyContent: "space-between",
|
|
1609
|
+
columnGap: 8,
|
|
1610
|
+
rowGap: 2
|
|
1611
|
+
},
|
|
1612
|
+
lineText: {
|
|
1613
|
+
display: "flex",
|
|
1614
|
+
alignItems: "center",
|
|
1615
|
+
gap: 6,
|
|
1616
|
+
minWidth: 0
|
|
1617
|
+
},
|
|
1618
|
+
dot: {
|
|
1619
|
+
display: "inline-flex",
|
|
1620
|
+
["--dsw-alias-label-tertiary"]: TERTIARY
|
|
1621
|
+
},
|
|
1622
|
+
warn: { color: WARN },
|
|
1623
|
+
action: {
|
|
1624
|
+
flex: "none",
|
|
1625
|
+
marginLeft: "auto",
|
|
1626
|
+
padding: 0,
|
|
1627
|
+
border: "none",
|
|
1628
|
+
background: "none",
|
|
1629
|
+
font: "inherit",
|
|
1630
|
+
lineHeight: "inherit",
|
|
1631
|
+
color: ACTION,
|
|
1632
|
+
cursor: "pointer"
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
/**
|
|
1636
|
+
* How long ago, in the dictionary's words.
|
|
1637
|
+
* @param t - the dictionary.
|
|
1638
|
+
* @param ms - the age in milliseconds.
|
|
1639
|
+
* @returns e.g. 刚刚, 12 秒前, 3 分钟前, 2 小时前.
|
|
1640
|
+
*/
|
|
1641
|
+
function agoText(t, ms) {
|
|
1642
|
+
const seconds = Math.max(0, Math.floor(ms / 1e3));
|
|
1643
|
+
if (seconds < 5) return t("agoNow");
|
|
1644
|
+
if (seconds < 60) return fill(t("agoSeconds"), { n: seconds });
|
|
1645
|
+
const minutes = Math.floor(seconds / 60);
|
|
1646
|
+
if (minutes < 60) return fill(t("agoMinutes"), { n: minutes });
|
|
1647
|
+
return fill(t("agoHours"), { n: Math.floor(minutes / 60) });
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* @param result - one measurement.
|
|
1651
|
+
* @returns its grade.
|
|
1652
|
+
*/
|
|
1653
|
+
function latencyGrade(result) {
|
|
1654
|
+
const ms = result.medianMs;
|
|
1655
|
+
if (result.error !== void 0 || ms === void 0) return "unreachable";
|
|
1656
|
+
return ms < 150 ? "fast" : ms < 300 ? "normal" : ms < 800 ? "slow" : "very-slow";
|
|
1657
|
+
}
|
|
1658
|
+
const GRADE_KEYS = {
|
|
1659
|
+
fast: "latencyFast",
|
|
1660
|
+
normal: "latencyNormal",
|
|
1661
|
+
slow: "latencySlow",
|
|
1662
|
+
"very-slow": "latencyVerySlow",
|
|
1663
|
+
unreachable: "latencyUnreachable"
|
|
1664
|
+
};
|
|
1665
|
+
/**
|
|
1666
|
+
* The card's freshness line.
|
|
1667
|
+
* @param t - the dictionary.
|
|
1668
|
+
* @param state - the account state.
|
|
1669
|
+
* @param now - the store's clock.
|
|
1670
|
+
* @returns the text, whether it reports a failure, and whether a read is running.
|
|
1671
|
+
*/
|
|
1672
|
+
function freshnessLine(t, state, now) {
|
|
1673
|
+
if (state.refreshing) return {
|
|
1674
|
+
text: t("cardReading"),
|
|
1675
|
+
failed: false,
|
|
1676
|
+
reading: true
|
|
1677
|
+
};
|
|
1678
|
+
const view = state.view;
|
|
1679
|
+
const readAt = view?.readAt;
|
|
1680
|
+
if (state.loadFailed || view?.readFailedAt !== void 0) {
|
|
1681
|
+
if (readAt === void 0 || view?.balance === void 0) return {
|
|
1682
|
+
text: t("cardReadFailedNone"),
|
|
1683
|
+
failed: true,
|
|
1684
|
+
reading: false
|
|
1685
|
+
};
|
|
1686
|
+
const age = now - readAt;
|
|
1687
|
+
return {
|
|
1688
|
+
text: age < 5e3 ? t("cardReadFailedNow") : fill(t("cardReadFailed"), { ago: agoText(t, age) }),
|
|
1689
|
+
failed: true,
|
|
1690
|
+
reading: false
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
return {
|
|
1694
|
+
text: readAt === void 0 ? "" : fill(t("cardUpdated"), { ago: agoText(t, now - readAt) }),
|
|
1695
|
+
failed: false,
|
|
1696
|
+
reading: false
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
/**
|
|
1700
|
+
* The card's latency line.
|
|
1701
|
+
* @param t - the dictionary.
|
|
1702
|
+
* @param latency - the latency state.
|
|
1703
|
+
* @returns the dot and the text, e.g. 网络延迟 162 ms · 正常.
|
|
1704
|
+
*/
|
|
1705
|
+
function latencyLine(t, latency) {
|
|
1706
|
+
const label = t("cardLatency");
|
|
1707
|
+
if (latency.measuring) return {
|
|
1708
|
+
dot: "ongoing",
|
|
1709
|
+
text: `${label} ${t("cardMeasuring")}`
|
|
1710
|
+
};
|
|
1711
|
+
if (latency.requestFailed === true) return {
|
|
1712
|
+
dot: "idle",
|
|
1713
|
+
text: `${label} ${t("cardMeasureFailed")}`
|
|
1714
|
+
};
|
|
1715
|
+
const result = latency.result;
|
|
1716
|
+
if (result === void 0) return {
|
|
1717
|
+
dot: "idle",
|
|
1718
|
+
text: label
|
|
1719
|
+
};
|
|
1720
|
+
const grade = latencyGrade(result);
|
|
1721
|
+
if (grade === "unreachable") {
|
|
1722
|
+
const error = result.error;
|
|
1723
|
+
const reason = error?.kind === "http" ? fill(t("latencyHttp"), { status: error.status ?? "" }) : error?.kind === "timeout" ? t("latencyTimeout") : t("latencyNetwork");
|
|
1724
|
+
return {
|
|
1725
|
+
dot: "error",
|
|
1726
|
+
text: `${label} ${t("latencyUnreachable")} · ${reason}`
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
return {
|
|
1730
|
+
dot: grade === "fast" || grade === "normal" ? "done" : "warning",
|
|
1731
|
+
text: `${label} ${result.medianMs} ms · ${t(GRADE_KEYS[grade])}`
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
function Amount({ label, value }) {
|
|
1735
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1736
|
+
style: styles.row,
|
|
1737
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1738
|
+
style: styles.value,
|
|
1739
|
+
children: value
|
|
1740
|
+
})]
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* The card's content.
|
|
1745
|
+
* @param props - the dictionary, the shared account store, and who is signed in when the row itself does not say
|
|
1746
|
+
* (the collapsed sidebar).
|
|
1747
|
+
* @returns the content (the HoverCard mounts it only while the card is open).
|
|
1748
|
+
*/
|
|
1749
|
+
function BalanceCard({ t, store, who }) {
|
|
1750
|
+
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1751
|
+
(0, react.useEffect)(() => {
|
|
1752
|
+
store.openedCard();
|
|
1753
|
+
}, [store]);
|
|
1754
|
+
const [, setTick] = (0, react.useState)(0);
|
|
1755
|
+
(0, react.useEffect)(() => {
|
|
1756
|
+
const timer = setInterval(() => {
|
|
1757
|
+
setTick((tick) => tick + 1);
|
|
1758
|
+
}, 1e3);
|
|
1759
|
+
return () => {
|
|
1760
|
+
clearInterval(timer);
|
|
1761
|
+
};
|
|
1762
|
+
}, []);
|
|
1763
|
+
const body = (0, react.useRef)(null);
|
|
1764
|
+
const height = (0, react.useRef)(void 0);
|
|
1765
|
+
useBrowserLayoutEffect(() => {
|
|
1766
|
+
const next = body.current?.offsetHeight;
|
|
1767
|
+
if (height.current !== void 0 && next !== height.current) window.dispatchEvent(new Event("scroll"));
|
|
1768
|
+
height.current = next;
|
|
1769
|
+
});
|
|
1770
|
+
const balance = state.view?.balance;
|
|
1771
|
+
const available = balance === void 0 ? void 0 : formatMoney(balance.amount, balance.currency);
|
|
1772
|
+
const held = balance !== void 0 && isPositiveAmount(balance.frozen) ? formatMoney(balance.frozen, balance.currency) : void 0;
|
|
1773
|
+
const total = balance === void 0 ? void 0 : formatMoney(totalAmount(balance.amount, balance.frozen), balance.currency);
|
|
1774
|
+
const freshness = freshnessLine(t, state, store.now());
|
|
1775
|
+
const latency = latencyLine(t, state.latency);
|
|
1776
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1777
|
+
ref: body,
|
|
1778
|
+
style: styles.card,
|
|
1779
|
+
"data-dsh-vibedev-balance-card": true,
|
|
1780
|
+
children: [
|
|
1781
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1782
|
+
style: styles.title,
|
|
1783
|
+
children: t("cardTitle")
|
|
1784
|
+
}),
|
|
1785
|
+
who === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1786
|
+
style: styles.who,
|
|
1787
|
+
children: who
|
|
1788
|
+
}),
|
|
1789
|
+
available === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: t("balanceUnknown") }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1790
|
+
style: styles.amounts,
|
|
1791
|
+
children: [
|
|
1792
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Amount, {
|
|
1793
|
+
label: t("cardAvailable"),
|
|
1794
|
+
value: available
|
|
1795
|
+
}),
|
|
1796
|
+
held === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Amount, {
|
|
1797
|
+
label: t("cardFrozen"),
|
|
1798
|
+
value: held
|
|
1799
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1800
|
+
style: styles.note,
|
|
1801
|
+
children: t("cardFrozenNote")
|
|
1802
|
+
})] }),
|
|
1803
|
+
total === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Amount, {
|
|
1804
|
+
label: t("cardTotal"),
|
|
1805
|
+
value: total
|
|
1806
|
+
})
|
|
1807
|
+
]
|
|
1808
|
+
}),
|
|
1809
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: styles.rule }),
|
|
1810
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1811
|
+
style: styles.line,
|
|
1812
|
+
role: "status",
|
|
1813
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1814
|
+
style: freshness.failed ? styles.warn : void 0,
|
|
1815
|
+
children: freshness.text
|
|
1816
|
+
}), freshness.reading ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1817
|
+
type: "button",
|
|
1818
|
+
style: styles.action,
|
|
1819
|
+
onClick: () => {
|
|
1820
|
+
store.refresh(true);
|
|
1821
|
+
},
|
|
1822
|
+
children: t("refresh")
|
|
1823
|
+
})]
|
|
1824
|
+
}),
|
|
1825
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: styles.rule }),
|
|
1826
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1827
|
+
style: styles.line,
|
|
1828
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1829
|
+
style: styles.lineText,
|
|
1830
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1831
|
+
style: styles.dot,
|
|
1832
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
|
|
1833
|
+
state: latency.dot,
|
|
1834
|
+
size: 10
|
|
1835
|
+
})
|
|
1836
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: latency.text })]
|
|
1837
|
+
}), state.latency.measuring ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1838
|
+
type: "button",
|
|
1839
|
+
style: styles.action,
|
|
1840
|
+
onClick: () => {
|
|
1841
|
+
store.measureLatency(true);
|
|
1842
|
+
},
|
|
1843
|
+
children: t("cardRemeasure")
|
|
1844
|
+
})]
|
|
1845
|
+
}),
|
|
1846
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1847
|
+
style: styles.note,
|
|
1848
|
+
children: t("cardLatencyNote")
|
|
1849
|
+
})
|
|
1850
|
+
]
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* The row takes the foot's free width, like the account launcher it stands in for: the card then opens beside the
|
|
1855
|
+
* sidebar, and a long name ends in an ellipsis. The grid stretches the menu's (inline) anchor wrapper to that width.
|
|
1856
|
+
*/
|
|
1857
|
+
const rowArea = {
|
|
1858
|
+
flex: 1,
|
|
1859
|
+
minWidth: 0
|
|
1860
|
+
};
|
|
1861
|
+
const rowFill = {
|
|
1862
|
+
display: "grid",
|
|
1863
|
+
gridTemplateColumns: "minmax(0, 1fr)"
|
|
1864
|
+
};
|
|
1865
|
+
/**
|
|
1866
|
+
* A sidebar account row with the balance card beside it (after the primitives' usual half-second rest).
|
|
1867
|
+
* @param props - the dictionary, the shared store, whether the card may open (not while the row's menu is open,
|
|
1868
|
+
* which holds the pointer and the same facts; not while signed out), who is signed in when the row does not show it,
|
|
1869
|
+
* and the row with its menu.
|
|
1870
|
+
* @returns the row.
|
|
1871
|
+
*/
|
|
1872
|
+
function BalanceHover({ t, store, disabled, who, children }) {
|
|
1873
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1874
|
+
style: rowArea,
|
|
1875
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.HoverCard, {
|
|
1876
|
+
disabled,
|
|
1877
|
+
anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1878
|
+
style: rowFill,
|
|
1879
|
+
children
|
|
1880
|
+
}),
|
|
1881
|
+
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceCard, {
|
|
1882
|
+
t,
|
|
1883
|
+
store,
|
|
1884
|
+
who
|
|
1885
|
+
})
|
|
1886
|
+
})
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
//#endregion
|
|
1890
|
+
//#region src/client/FeedbackDialog.tsx
|
|
1891
|
+
/**
|
|
1892
|
+
* The account menus' 意见反馈 dialog: a category, the text (at most 4,000
|
|
1893
|
+
* characters, counted), and an unticked box that attaches recent error
|
|
1894
|
+
* messages — ticking it shows the exact text that would be sent, and its size,
|
|
1895
|
+
* before anything is sent. Then 已发送,谢谢! when VibeDev took it, 已保存…
|
|
1896
|
+
* when it was kept to send later, or what went wrong. Signed out it explains
|
|
1897
|
+
* that feedback goes with the VibeDev account and offers the sign-in: nothing
|
|
1898
|
+
* is ever sent anonymously.
|
|
1899
|
+
*
|
|
1900
|
+
* DSH primitives (Modal, Button, Checkbox, StateDot) and theme tokens; the
|
|
1901
|
+
* chips and the text field follow DSH's own message-feedback dialog, styled by
|
|
1902
|
+
* a small stylesheet this component inserts once (inline styles cannot carry
|
|
1903
|
+
* hover and focus states).
|
|
1904
|
+
*/
|
|
1905
|
+
const CATEGORY_KEYS = {
|
|
1906
|
+
"task-result": "categoryTaskResult",
|
|
1907
|
+
"instruction-following": "categoryInstructionFollowing",
|
|
1908
|
+
"product-interaction": "categoryProductInteraction",
|
|
1909
|
+
"service-stability": "categoryServiceStability",
|
|
1910
|
+
"resource-cost": "categoryResourceCost",
|
|
1911
|
+
"security-privacy-permission": "categorySecurityPrivacyPermission",
|
|
1912
|
+
"other": "categoryOther"
|
|
1913
|
+
};
|
|
1914
|
+
const PREFIX = "dsh-vibedev-fb";
|
|
1915
|
+
/** The dialog's rules: DSH's message-feedback dialog geometry, its chips and text field, on theme tokens only. */
|
|
1916
|
+
const FEEDBACK_STYLES = `
|
|
1917
|
+
.${PREFIX}-dialog.${PREFIX}-dialog { width: min(488px, 100%); }
|
|
1918
|
+
.${PREFIX}-body { display: flex; flex-direction: column; gap: 14px; }
|
|
1919
|
+
.${PREFIX}-chips { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
1920
|
+
.${PREFIX}-chip { height: 28px; padding: 0 12px; border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-sm);
|
|
1921
|
+
background: transparent; color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; line-height: 18px; cursor: pointer;
|
|
1922
|
+
transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
|
|
1923
|
+
.${PREFIX}-chip:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
1924
|
+
.${PREFIX}-chip[aria-pressed='true'], .${PREFIX}-chip[aria-pressed='true']:hover:not(:disabled) {
|
|
1925
|
+
border-color: var(--dsw-alias-button-primary-fill); background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }
|
|
1926
|
+
.${PREFIX}-chip:disabled { cursor: default; opacity: 0.4; }
|
|
1927
|
+
.${PREFIX}-chip:focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: 2px; }
|
|
1928
|
+
.${PREFIX}-field { display: flex; flex-direction: column; gap: 4px; }
|
|
1929
|
+
.${PREFIX}-text { display: block; width: 100%; min-height: 116px; max-height: 240px; box-sizing: border-box; padding: 12px 14px;
|
|
1930
|
+
border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-lg); background: var(--dsw-alias-bg-layer-1);
|
|
1931
|
+
color: var(--dsw-alias-label-primary); font: inherit; font-size: 14px; line-height: 22px; field-sizing: content; resize: none;
|
|
1932
|
+
transition: border-color 120ms ease, box-shadow 120ms ease; }
|
|
1933
|
+
.${PREFIX}-text::placeholder { color: var(--dsw-alias-label-caption); }
|
|
1934
|
+
.${PREFIX}-text:focus { outline: none; border-color: var(--dsw-alias-border-l3); box-shadow: 0 0 0 1px var(--dsw-alias-state-business-primary); }
|
|
1935
|
+
.${PREFIX}-count { align-self: flex-end; font-size: 12px; line-height: 16px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }
|
|
1936
|
+
.${PREFIX}-note { margin: 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }
|
|
1937
|
+
.${PREFIX}-preview { margin: 0; max-height: 156px; overflow: auto; padding: 10px 12px; border-radius: var(--dsw-radius-md);
|
|
1938
|
+
background: var(--dsw-alias-bg-skeleton); color: var(--dsw-alias-label-secondary); font-family: var(--ds-font-family-code);
|
|
1939
|
+
font-size: 11px; line-height: 17px; white-space: pre-wrap; word-break: break-all; }
|
|
1940
|
+
.${PREFIX}-error { margin: 0; font-size: 13px; line-height: 20px; color: var(--dsw-alias-state-error-primary); }
|
|
1941
|
+
.${PREFIX}-result { display: flex; align-items: center; gap: 10px; padding: 8px 0 4px; font-size: 15px; line-height: 22px; color: var(--dsw-alias-label-primary); }
|
|
1942
|
+
.${PREFIX}-prompt { margin: 0; font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary); }
|
|
1943
|
+
@media (prefers-reduced-motion: reduce) { .${PREFIX}-chip, .${PREFIX}-text { transition: none; } }
|
|
1944
|
+
`;
|
|
1945
|
+
let styleUsers = 0;
|
|
1946
|
+
let styleElement;
|
|
1947
|
+
/** Insert the stylesheet while any dialog is mounted. */
|
|
1948
|
+
function useFeedbackStyles() {
|
|
1949
|
+
(0, react.useInsertionEffect)(() => {
|
|
1950
|
+
if (styleUsers++ === 0) {
|
|
1951
|
+
styleElement = document.createElement("style");
|
|
1952
|
+
styleElement.dataset.dshVibedevFeedback = "";
|
|
1953
|
+
styleElement.textContent = FEEDBACK_STYLES;
|
|
1954
|
+
document.head.appendChild(styleElement);
|
|
1955
|
+
}
|
|
1956
|
+
return () => {
|
|
1957
|
+
if (--styleUsers === 0) {
|
|
1958
|
+
styleElement?.remove();
|
|
1959
|
+
styleElement = void 0;
|
|
1960
|
+
}
|
|
1961
|
+
};
|
|
1962
|
+
}, []);
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* A size for people: bytes, else kilobytes with one decimal.
|
|
1966
|
+
* @param bytes - the size.
|
|
1967
|
+
* @returns e.g. `512 B`, `3.4 KB`.
|
|
1968
|
+
*/
|
|
1969
|
+
function sizeText(bytes) {
|
|
1970
|
+
return bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
|
|
1971
|
+
}
|
|
1972
|
+
/** The line under the form for a failed attempt. */
|
|
1973
|
+
function errorText(t, phase) {
|
|
1974
|
+
if (phase.error === "failed") return t("feedbackErrorFailed");
|
|
1975
|
+
if (phase.error === "invalid") return t("feedbackErrorInvalid");
|
|
1976
|
+
if (phase.error === "rejected") return fill(t("feedbackErrorRejected"), { code: phase.code ?? "—" });
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* The body and footer for the current state.
|
|
1980
|
+
* @param props - the dictionary, the state and the actions.
|
|
1981
|
+
* @returns the dialog's children and footer.
|
|
1982
|
+
*/
|
|
1983
|
+
function feedbackView(props) {
|
|
1984
|
+
const { t, state } = props;
|
|
1985
|
+
const phase = state.phase;
|
|
1986
|
+
if (!props.signedIn || phase.kind === "signed-out") return {
|
|
1987
|
+
body: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1988
|
+
className: `${PREFIX}-prompt`,
|
|
1989
|
+
role: "status",
|
|
1990
|
+
children: t("feedbackSignedOut")
|
|
1991
|
+
}),
|
|
1992
|
+
footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1993
|
+
variant: "ghost",
|
|
1994
|
+
onClick: props.onClose,
|
|
1995
|
+
children: t("feedbackCancel")
|
|
1996
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1997
|
+
variant: "primary",
|
|
1998
|
+
disabled: props.signingIn,
|
|
1999
|
+
onClick: props.onSignIn,
|
|
2000
|
+
children: props.signingIn ? t("signingIn") : t("signIn")
|
|
2001
|
+
})] })
|
|
2002
|
+
};
|
|
2003
|
+
if (phase.kind === "sent" || phase.kind === "queued") {
|
|
2004
|
+
const text = phase.kind === "sent" ? t("feedbackSent") : phase.reason === "offline" ? t("feedbackQueuedOffline") : phase.reason === "signed-out" ? t("feedbackQueuedSignedOut") : t("feedbackQueuedLater");
|
|
2005
|
+
return {
|
|
2006
|
+
body: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2007
|
+
className: `${PREFIX}-result`,
|
|
2008
|
+
role: "status",
|
|
2009
|
+
"data-feedback-result": phase.kind,
|
|
2010
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
|
|
2011
|
+
state: phase.kind === "sent" ? "done" : "warning",
|
|
2012
|
+
size: 12
|
|
2013
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: text })]
|
|
2014
|
+
}),
|
|
2015
|
+
footer: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2016
|
+
variant: "primary",
|
|
2017
|
+
onClick: props.onClose,
|
|
2018
|
+
children: t("feedbackDone")
|
|
2019
|
+
})
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
2022
|
+
const sending = phase.kind === "sending";
|
|
2023
|
+
const error = phase.kind === "editing" ? errorText(t, phase) : void 0;
|
|
2024
|
+
const preview = state.preview;
|
|
2025
|
+
let attachment = null;
|
|
2026
|
+
if (state.attach) {
|
|
2027
|
+
if (preview.status === "loading" || preview.status === "idle") attachment = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2028
|
+
className: `${PREFIX}-note`,
|
|
2029
|
+
children: t("feedbackAttachLoading")
|
|
2030
|
+
});
|
|
2031
|
+
else if (preview.status === "failed") attachment = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2032
|
+
className: `${PREFIX}-note`,
|
|
2033
|
+
children: t("feedbackAttachFailed")
|
|
2034
|
+
});
|
|
2035
|
+
else if (preview.preview.entries === 0 || preview.preview.content === "") attachment = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2036
|
+
className: `${PREFIX}-note`,
|
|
2037
|
+
children: t("feedbackAttachEmpty")
|
|
2038
|
+
});
|
|
2039
|
+
else attachment = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2040
|
+
className: `${PREFIX}-note`,
|
|
2041
|
+
children: fill(t("feedbackAttachPreview"), {
|
|
2042
|
+
entries: preview.preview.entries,
|
|
2043
|
+
size: sizeText(preview.preview.bytes)
|
|
2044
|
+
})
|
|
2045
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
2046
|
+
className: `${PREFIX}-preview`,
|
|
2047
|
+
"data-feedback-attachment": true,
|
|
2048
|
+
tabIndex: 0,
|
|
2049
|
+
children: preview.preview.content
|
|
2050
|
+
})] });
|
|
2051
|
+
}
|
|
2052
|
+
return {
|
|
2053
|
+
body: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2054
|
+
className: `${PREFIX}-body`,
|
|
2055
|
+
children: [
|
|
2056
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2057
|
+
className: `${PREFIX}-chips`,
|
|
2058
|
+
role: "group",
|
|
2059
|
+
"aria-label": t("feedbackCategories"),
|
|
2060
|
+
children: FEEDBACK_CATEGORIES.map((category) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2061
|
+
type: "button",
|
|
2062
|
+
className: `${PREFIX}-chip`,
|
|
2063
|
+
"aria-pressed": state.category === category,
|
|
2064
|
+
disabled: sending,
|
|
2065
|
+
onClick: () => {
|
|
2066
|
+
props.onCategory(state.category === category ? void 0 : category);
|
|
2067
|
+
},
|
|
2068
|
+
children: t(CATEGORY_KEYS[category])
|
|
2069
|
+
}, category))
|
|
2070
|
+
}),
|
|
2071
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2072
|
+
className: `${PREFIX}-field`,
|
|
2073
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
2074
|
+
className: `${PREFIX}-text`,
|
|
2075
|
+
"data-modal-autofocus": true,
|
|
2076
|
+
"aria-label": t("feedbackDetail"),
|
|
2077
|
+
placeholder: t("feedbackPlaceholder"),
|
|
2078
|
+
value: state.text,
|
|
2079
|
+
readOnly: sending,
|
|
2080
|
+
onChange: (event) => {
|
|
2081
|
+
props.onText(event.target.value);
|
|
2082
|
+
}
|
|
2083
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2084
|
+
className: `${PREFIX}-count`,
|
|
2085
|
+
"aria-live": "polite",
|
|
2086
|
+
children: fill(t("feedbackCount"), {
|
|
2087
|
+
n: textLength(state.text),
|
|
2088
|
+
max: FEEDBACK_MAX_TEXT
|
|
2089
|
+
})
|
|
2090
|
+
})]
|
|
2091
|
+
}),
|
|
2092
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
2093
|
+
checked: state.attach,
|
|
2094
|
+
disabled: sending,
|
|
2095
|
+
label: t("feedbackAttach"),
|
|
2096
|
+
onChange: (next) => {
|
|
2097
|
+
props.onAttach(next);
|
|
2098
|
+
}
|
|
2099
|
+
}),
|
|
2100
|
+
attachment,
|
|
2101
|
+
error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2102
|
+
className: `${PREFIX}-error`,
|
|
2103
|
+
role: "alert",
|
|
2104
|
+
children: error
|
|
2105
|
+
})
|
|
2106
|
+
]
|
|
2107
|
+
}),
|
|
2108
|
+
footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2109
|
+
variant: "ghost",
|
|
2110
|
+
disabled: sending,
|
|
2111
|
+
onClick: props.onClose,
|
|
2112
|
+
children: t("feedbackCancel")
|
|
2113
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2114
|
+
variant: "primary",
|
|
2115
|
+
disabled: !canSend(state),
|
|
2116
|
+
onClick: props.onSubmit,
|
|
2117
|
+
"data-feedback-send": true,
|
|
2118
|
+
children: sending ? t("feedbackSending") : t("feedbackSend")
|
|
2119
|
+
})] })
|
|
2120
|
+
};
|
|
2121
|
+
}
|
|
2122
|
+
/**
|
|
2123
|
+
* The dialog, open while the account store's feedback dialog is.
|
|
2124
|
+
* @param props - the dictionary and the shared account store.
|
|
2125
|
+
* @returns the Modal (portaled to the page body), or nothing while closed.
|
|
2126
|
+
*/
|
|
2127
|
+
function FeedbackDialog({ t, store }) {
|
|
2128
|
+
useFeedbackStyles();
|
|
2129
|
+
const account = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2130
|
+
const state = (0, react.useSyncExternalStore)(store.feedback.subscribe, store.feedback.getSnapshot, store.feedback.getSnapshot);
|
|
2131
|
+
const view = account.view;
|
|
2132
|
+
const signedIn = view !== void 0 && view.source !== "none";
|
|
2133
|
+
const close = () => {
|
|
2134
|
+
store.feedback.close();
|
|
2135
|
+
};
|
|
2136
|
+
const { body, footer } = feedbackView({
|
|
2137
|
+
t,
|
|
2138
|
+
state,
|
|
2139
|
+
signedIn,
|
|
2140
|
+
signingIn: account.busy === "sign-in" || view?.pending !== void 0,
|
|
2141
|
+
onCategory: (category) => {
|
|
2142
|
+
store.feedback.setCategory(category);
|
|
2143
|
+
},
|
|
2144
|
+
onText: (text) => {
|
|
2145
|
+
store.feedback.setText(text);
|
|
2146
|
+
},
|
|
2147
|
+
onAttach: (attach) => {
|
|
2148
|
+
store.feedback.setAttach(attach);
|
|
2149
|
+
},
|
|
2150
|
+
onSubmit: () => {
|
|
2151
|
+
store.feedback.submit(t("localeTag"));
|
|
2152
|
+
},
|
|
2153
|
+
onSignIn: () => {
|
|
2154
|
+
store.signIn();
|
|
2155
|
+
},
|
|
2156
|
+
onClose: close
|
|
2157
|
+
});
|
|
2158
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
|
|
2159
|
+
open: state.open,
|
|
2160
|
+
title: t("feedbackTitle"),
|
|
2161
|
+
closeLabel: t("close"),
|
|
2162
|
+
...signedIn && (state.phase.kind === "editing" || state.phase.kind === "sending") ? { description: t("feedbackIntro") } : {},
|
|
2163
|
+
className: `${PREFIX}-dialog`,
|
|
2164
|
+
onClose: close,
|
|
2165
|
+
footer,
|
|
2166
|
+
children: body
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
//#endregion
|
|
968
2170
|
//#region src/client/PrimaryLauncher.tsx
|
|
969
2171
|
/**
|
|
970
2172
|
* The VibeDev account as the app's main account (`settings.launcher`, the row
|
|
971
2173
|
* at the very foot of the sidebar), used where the VibeDev account leads (the
|
|
972
2174
|
* VibeDev app, `primary: true`). Signed in: the person's initial, name and
|
|
973
|
-
* balance, with a menu for Settings, top-up, usage and
|
|
974
|
-
*
|
|
975
|
-
*
|
|
976
|
-
*
|
|
2175
|
+
* balance (short: `¥9,997.6万`), with a menu for Settings, top-up, usage and
|
|
2176
|
+
* sign-out, and the balance card (BalanceCard.tsx) when the pointer rests on
|
|
2177
|
+
* it. Signed out: "登录 VibeDev". It opens Settings the way the launcher it
|
|
2178
|
+
* replaces does. Inside DeepSeek Harness the plugin keeps to its smaller
|
|
2179
|
+
* sidebar entry (SidebarAccount.tsx) and this is not registered.
|
|
977
2180
|
*/
|
|
978
2181
|
const row = {
|
|
979
2182
|
display: "flex",
|
|
980
2183
|
alignItems: "center",
|
|
981
2184
|
gap: 10,
|
|
982
2185
|
width: "100%",
|
|
2186
|
+
minWidth: 0,
|
|
983
2187
|
padding: "6px 10px",
|
|
984
2188
|
border: "none",
|
|
985
2189
|
borderRadius: 10,
|
|
@@ -1014,7 +2218,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1014
2218
|
height: 28,
|
|
1015
2219
|
borderRadius: "50%",
|
|
1016
2220
|
background: "var(--dsw-alias-brand-primary, #3b82f6)",
|
|
1017
|
-
color: "#fff",
|
|
2221
|
+
color: "var(--dsw-alias-label-primary-foreground, #fff)",
|
|
1018
2222
|
fontSize: 13,
|
|
1019
2223
|
fontWeight: 600,
|
|
1020
2224
|
lineHeight: 1
|
|
@@ -1055,7 +2259,8 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1055
2259
|
* @returns the row with its menu.
|
|
1056
2260
|
*/
|
|
1057
2261
|
function PrimaryLauncher({ t, store, owner }) {
|
|
1058
|
-
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot);
|
|
2262
|
+
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2263
|
+
const feedbackOpen = (0, react.useSyncExternalStore)(store.feedback.subscribe, () => store.feedback.getSnapshot().open, () => store.feedback.getSnapshot().open);
|
|
1059
2264
|
const [open, setOpen] = (0, react.useState)(false);
|
|
1060
2265
|
const wide = owner.wide !== false;
|
|
1061
2266
|
const settingsWasOpen = (0, react.useRef)(false);
|
|
@@ -1067,7 +2272,8 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1067
2272
|
const signedIn = view !== void 0 && view.source !== "none";
|
|
1068
2273
|
const pending = !signedIn && view?.pending !== void 0;
|
|
1069
2274
|
const who = displayName(view);
|
|
1070
|
-
const balance = balanceText(view);
|
|
2275
|
+
const balance = balanceText(view?.balance, "full");
|
|
2276
|
+
const short = balanceText(view?.balance, "compact", numberStyleOf(t));
|
|
1071
2277
|
const title = signedIn ? who ?? t("sidebarSignedIn") : pending ? t("sidebarPending") : t("signIn");
|
|
1072
2278
|
const settings = {
|
|
1073
2279
|
id: "settings",
|
|
@@ -1099,6 +2305,10 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1099
2305
|
id: "usage",
|
|
1100
2306
|
label: t("usage")
|
|
1101
2307
|
},
|
|
2308
|
+
{
|
|
2309
|
+
id: "feedback",
|
|
2310
|
+
label: t("feedbackMenu")
|
|
2311
|
+
},
|
|
1102
2312
|
...view.source === "plugin" ? [{
|
|
1103
2313
|
type: "separator",
|
|
1104
2314
|
id: "separator-sign-out"
|
|
@@ -1148,6 +2358,10 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1148
2358
|
type: "separator",
|
|
1149
2359
|
id: "separator-settings"
|
|
1150
2360
|
},
|
|
2361
|
+
{
|
|
2362
|
+
id: "feedback",
|
|
2363
|
+
label: t("feedbackMenu")
|
|
2364
|
+
},
|
|
1151
2365
|
settings
|
|
1152
2366
|
];
|
|
1153
2367
|
const face = signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1155,7 +2369,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1155
2369
|
"aria-hidden": "true",
|
|
1156
2370
|
children: initialOf(who)
|
|
1157
2371
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconUserOutlineMedium, { size: 16 });
|
|
1158
|
-
|
|
2372
|
+
const menu = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
1159
2373
|
open,
|
|
1160
2374
|
side: "top",
|
|
1161
2375
|
align: "start",
|
|
@@ -1165,12 +2379,13 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1165
2379
|
type: "button",
|
|
1166
2380
|
style: !wide ? railRow : signedIn ? signedInRow : signedOutRow,
|
|
1167
2381
|
"aria-label": wide ? t("accountMenu") : title,
|
|
1168
|
-
title: wide ? void 0 : title,
|
|
2382
|
+
title: wide || signedIn ? void 0 : title,
|
|
1169
2383
|
"aria-haspopup": "menu",
|
|
1170
2384
|
"aria-expanded": open,
|
|
1171
2385
|
"data-dsh-vibedev-launcher": true,
|
|
1172
2386
|
"data-signed-in": signedIn,
|
|
1173
2387
|
onClick: () => {
|
|
2388
|
+
if (!open && signedIn) store.refreshIfStale();
|
|
1174
2389
|
setOpen((value) => !value);
|
|
1175
2390
|
},
|
|
1176
2391
|
children: [face, wide ? signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
@@ -1180,7 +2395,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1180
2395
|
children: who ?? t("sidebarSignedIn")
|
|
1181
2396
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1182
2397
|
style: subText,
|
|
1183
|
-
children:
|
|
2398
|
+
children: short === void 0 ? "VibeDev" : `VibeDev · ${short}`
|
|
1184
2399
|
})]
|
|
1185
2400
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1186
2401
|
style: ellipsis,
|
|
@@ -1198,27 +2413,40 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1198
2413
|
else if (id === "sign-out") store.signOut();
|
|
1199
2414
|
else if (id === "cancel") store.cancel();
|
|
1200
2415
|
else if (id === "open-pending") store.openPending();
|
|
2416
|
+
else if (id === "feedback") store.feedback.open();
|
|
1201
2417
|
else if (view === void 0) return;
|
|
1202
2418
|
else if (id === "top-up") store.openLink(view.links.topUp);
|
|
1203
2419
|
else if (id === "usage") store.openLink(view.links.usage);
|
|
1204
2420
|
else if (id === "register") store.openLink(view.links.register);
|
|
1205
2421
|
}
|
|
1206
2422
|
});
|
|
2423
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceHover, {
|
|
2424
|
+
t,
|
|
2425
|
+
store,
|
|
2426
|
+
disabled: open || !signedIn || feedbackOpen,
|
|
2427
|
+
who: wide ? void 0 : title,
|
|
2428
|
+
children: menu
|
|
2429
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FeedbackDialog, {
|
|
2430
|
+
t,
|
|
2431
|
+
store
|
|
2432
|
+
})] });
|
|
1207
2433
|
}
|
|
1208
2434
|
//#endregion
|
|
1209
2435
|
//#region src/client/SidebarAccount.tsx
|
|
1210
2436
|
/**
|
|
1211
2437
|
* The sidebar foot's VibeDev status (`sidebar.footer.action`): "登录 VibeDev",
|
|
1212
|
-
* "正在登录 VibeDev…" or "VibeDev 已登录", with a menu for the account
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
2438
|
+
* "正在登录 VibeDev…" or "VibeDev 已登录", with a menu for the account (and its
|
|
2439
|
+
* 意见反馈 dialog), and, signed in, the balance card (BalanceCard.tsx) when the
|
|
2440
|
+
* pointer rests on it. The Harness's own account entry (the DeepSeek account)
|
|
2441
|
+
* stays where it is; in the VibeDev app, whose account entry already is the
|
|
2442
|
+
* VibeDev account, this shows nothing.
|
|
1216
2443
|
*/
|
|
1217
2444
|
const trigger = {
|
|
1218
2445
|
display: "flex",
|
|
1219
2446
|
alignItems: "center",
|
|
1220
2447
|
gap: 8,
|
|
1221
2448
|
width: "100%",
|
|
2449
|
+
minWidth: 0,
|
|
1222
2450
|
minHeight: 32,
|
|
1223
2451
|
padding: "0 10px",
|
|
1224
2452
|
border: "none",
|
|
@@ -1247,7 +2475,8 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1247
2475
|
* @returns the entry, or nothing until the account is known and inside the VibeDev app.
|
|
1248
2476
|
*/
|
|
1249
2477
|
function SidebarAccount({ t, store, wide }) {
|
|
1250
|
-
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot);
|
|
2478
|
+
const state = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
2479
|
+
const feedbackOpen = (0, react.useSyncExternalStore)(store.feedback.subscribe, () => store.feedback.getSnapshot().open, () => store.feedback.getSnapshot().open);
|
|
1251
2480
|
const [open, setOpen] = (0, react.useState)(false);
|
|
1252
2481
|
const view = state.view;
|
|
1253
2482
|
if (view === void 0 || view.source === "host") return null;
|
|
@@ -1255,7 +2484,7 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1255
2484
|
const pending = !signedIn && view.pending !== void 0;
|
|
1256
2485
|
const text = pending ? t("sidebarPending") : signedIn ? t("sidebarSignedIn") : t("sidebarSignedOut");
|
|
1257
2486
|
const who = displayName(view);
|
|
1258
|
-
const balance = balanceText(view);
|
|
2487
|
+
const balance = balanceText(view.balance, "full");
|
|
1259
2488
|
const items = signedIn ? [
|
|
1260
2489
|
{
|
|
1261
2490
|
type: "label",
|
|
@@ -1279,6 +2508,10 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1279
2508
|
id: "usage",
|
|
1280
2509
|
label: t("usage")
|
|
1281
2510
|
},
|
|
2511
|
+
{
|
|
2512
|
+
id: "feedback",
|
|
2513
|
+
label: t("feedbackMenu")
|
|
2514
|
+
},
|
|
1282
2515
|
...view.source === "plugin" ? [{
|
|
1283
2516
|
id: "sign-out",
|
|
1284
2517
|
label: t("signOut"),
|
|
@@ -1314,9 +2547,17 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1314
2547
|
{
|
|
1315
2548
|
id: "register",
|
|
1316
2549
|
label: `${t("registerHint")} ${t("registerLink")}`
|
|
2550
|
+
},
|
|
2551
|
+
{
|
|
2552
|
+
type: "separator",
|
|
2553
|
+
id: "separator"
|
|
2554
|
+
},
|
|
2555
|
+
{
|
|
2556
|
+
id: "feedback",
|
|
2557
|
+
label: t("feedbackMenu")
|
|
1317
2558
|
}
|
|
1318
2559
|
];
|
|
1319
|
-
|
|
2560
|
+
const menu = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
1320
2561
|
open,
|
|
1321
2562
|
side: "top",
|
|
1322
2563
|
align: "start",
|
|
@@ -1326,11 +2567,12 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1326
2567
|
type: "button",
|
|
1327
2568
|
style: wide ? trigger : railTrigger,
|
|
1328
2569
|
"aria-label": wide ? void 0 : text,
|
|
1329
|
-
title: wide ? void 0 : text,
|
|
2570
|
+
title: wide || signedIn ? void 0 : text,
|
|
1330
2571
|
"aria-haspopup": "menu",
|
|
1331
2572
|
"aria-expanded": open,
|
|
1332
2573
|
"data-dsh-vibedev-sidebar": true,
|
|
1333
2574
|
onClick: () => {
|
|
2575
|
+
if (!open && signedIn) store.refreshIfStale();
|
|
1334
2576
|
setOpen((value) => !value);
|
|
1335
2577
|
},
|
|
1336
2578
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
|
|
@@ -1351,11 +2593,22 @@ window.__ModuleLoader__.load({ id: "@vibedev-si/dsh-vibedev", factory: (require)
|
|
|
1351
2593
|
else if (id === "sign-out") store.signOut();
|
|
1352
2594
|
else if (id === "cancel") store.cancel();
|
|
1353
2595
|
else if (id === "open-pending") store.openPending();
|
|
2596
|
+
else if (id === "feedback") store.feedback.open();
|
|
1354
2597
|
else if (id === "top-up") store.openLink(view.links.topUp);
|
|
1355
2598
|
else if (id === "usage") store.openLink(view.links.usage);
|
|
1356
2599
|
else if (id === "register") store.openLink(view.links.register);
|
|
1357
2600
|
}
|
|
1358
2601
|
});
|
|
2602
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BalanceHover, {
|
|
2603
|
+
t,
|
|
2604
|
+
store,
|
|
2605
|
+
disabled: open || !signedIn || feedbackOpen,
|
|
2606
|
+
who: wide ? void 0 : who === void 0 ? text : fill(t("signedInAs"), { who }),
|
|
2607
|
+
children: menu
|
|
2608
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FeedbackDialog, {
|
|
2609
|
+
t,
|
|
2610
|
+
store
|
|
2611
|
+
})] });
|
|
1359
2612
|
}
|
|
1360
2613
|
//#endregion
|
|
1361
2614
|
//#region src/client/index.ts
|