@linxin666/dsh-client-ui-plugin-manager 0.4.4 → 0.4.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.i18n.yaml +2 -2
- package/README.md +20 -6
- package/README.zh.md +20 -6
- package/cordis.patch.yml +14 -1
- package/lib/client.js +579 -11
- package/lib/client.js.map +1 -1
- package/lib/index.js +410 -25
- package/lib/types/client/PluginListToolbar.d.ts +44 -0
- package/lib/types/client/body-mutations.d.ts +45 -0
- package/lib/types/client/index.d.ts +18 -1
- package/lib/types/client/locales.d.ts +57 -2
- package/lib/types/client/plugin-toolbar-mount.d.ts +47 -0
- package/lib/types/core/protocol.d.ts +19 -0
- package/lib/types/core/updates.d.ts +30 -0
- package/lib/types/core/version.d.ts +4 -1
- package/lib/types/host/detached-work.d.ts +44 -0
- package/lib/types/host/gateway.d.ts +1 -1
- package/lib/types/host/profile.d.ts +28 -0
- package/lib/types/host/restart.d.ts +95 -0
- package/lib/types/host/routes.d.ts +16 -1
- package/lib/types/host/state.d.ts +3 -1
- package/lib/types/index.d.ts +7 -2
- package/package.json +18 -15
package/lib/client.js
CHANGED
|
@@ -6,6 +6,7 @@ window.__ModuleLoader__.load({
|
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let react_dom_client = require("react-dom/client");
|
|
9
10
|
//#region src/core/version.ts
|
|
10
11
|
const MINIMUM_RANGE_PATTERN = /^>=\s*(v?\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
11
12
|
/**
|
|
@@ -22,7 +23,7 @@ window.__ModuleLoader__.load({
|
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
24
25
|
//#region \0dsh-css:packages/dsh-plugin-manager/src/client/plugin-manager.module.css.mjs
|
|
25
|
-
const css = ".ZsMDKq_section{max-width:760px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:10px;display:flex}.ZsMDKq_title{margin:0;font-size:13px;font-weight:600;line-height:20px}.ZsMDKq_notice{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:8px;flex-direction:column;gap:8px;padding:16px;display:flex}.ZsMDKq_notice p{color:var(--dsw-alias-label-secondary);margin:0}.ZsMDKq_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px}.ZsMDKq_actionRow{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.ZsMDKq_button{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm,6px);color:var(--dsw-alias-label-primary);background:0 0;padding:5px 12px;font-size:12.5px;line-height:18px}.ZsMDKq_button:hover:enabled{background:var(--dsw-alias-interactive-bg-hover)}.ZsMDKq_button:disabled{cursor:default;opacity:.55}.ZsMDKq_button:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.ZsMDKq_primary{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-primary-fill);border-color:var(--dsw-alias-button-primary-fill)}.ZsMDKq_primary:hover:enabled{background:var(--dsw-alias-button-primary-hover);border-color:var(--dsw-alias-button-primary-hover)}.ZsMDKq_latest{color:var(--dsw-alias-state-business-primary);font-size:12px}.ZsMDKq_compatHint{color:var(--dsw-alias-label-tertiary);font-size:12px}.ZsMDKq_compatBlocked{color:var(--dsw-alias-label-danger);font-size:12px}.ZsMDKq_ok{color:var(--dsw-alias-state-success-primary);margin:0;font-size:12px}.ZsMDKq_error{color:var(--dsw-alias-label-danger);word-break:break-word;margin:0;font-size:12px}.ZsMDKq_progressRow{flex-direction:column;gap:6px;display:flex}.ZsMDKq_progressTrack{background:var(--dsw-alias-bg-layer-2);border-radius:3px;height:6px;overflow:hidden}.ZsMDKq_progressBar{background:var(--dsw-alias-state-business-primary);height:100%;transition:width .2s}.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:1.2s ease-in-out infinite ZsMDKq_pluginManagerIndeterminate}@keyframes ZsMDKq_pluginManagerIndeterminate{0%{transform:translate(-100%)}to{transform:translate(250%)}}@media (prefers-reduced-motion:reduce){.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:none}}.ZsMDKq_restartRow{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-brand);border-radius:8px;padding:10px 12px}.ZsMDKq_restartRow p{color:var(--dsw-alias-brand-primary);margin:0}";
|
|
26
|
+
const css = ".ZsMDKq_section{max-width:760px;color:var(--dsw-alias-label-primary);flex-direction:column;gap:10px;display:flex}.ZsMDKq_title{margin:0;font-size:13px;font-weight:600;line-height:20px}.ZsMDKq_notice{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);border-radius:8px;flex-direction:column;gap:8px;padding:16px;display:flex}.ZsMDKq_notice p{color:var(--dsw-alias-label-secondary);margin:0}.ZsMDKq_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px}.ZsMDKq_actionRow{flex-wrap:wrap;align-items:center;gap:10px;display:flex}.ZsMDKq_button{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm,6px);color:var(--dsw-alias-label-primary);background:0 0;padding:5px 12px;font-size:12.5px;line-height:18px}.ZsMDKq_button:hover:enabled{background:var(--dsw-alias-interactive-bg-hover)}.ZsMDKq_button:disabled{cursor:default;opacity:.55}.ZsMDKq_button:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.ZsMDKq_primary{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-primary-fill);border-color:var(--dsw-alias-button-primary-fill)}.ZsMDKq_primary:hover:enabled{background:var(--dsw-alias-button-primary-hover);border-color:var(--dsw-alias-button-primary-hover)}.ZsMDKq_latest{color:var(--dsw-alias-state-business-primary);font-size:12px}.ZsMDKq_compatHint{color:var(--dsw-alias-label-tertiary);font-size:12px}.ZsMDKq_compatBlocked{color:var(--dsw-alias-label-danger);font-size:12px}.ZsMDKq_ok{color:var(--dsw-alias-state-success-primary);margin:0;font-size:12px}.ZsMDKq_error{color:var(--dsw-alias-label-danger);word-break:break-word;margin:0;font-size:12px}.ZsMDKq_progressRow{flex-direction:column;gap:6px;display:flex}.ZsMDKq_progressTrack{background:var(--dsw-alias-bg-layer-2);border-radius:3px;height:6px;overflow:hidden}.ZsMDKq_progressBar{background:var(--dsw-alias-state-business-primary);height:100%;transition:width .2s}.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:1.2s ease-in-out infinite ZsMDKq_pluginManagerIndeterminate}@keyframes ZsMDKq_pluginManagerIndeterminate{0%{transform:translate(-100%)}to{transform:translate(250%)}}@media (prefers-reduced-motion:reduce){.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:none}}.ZsMDKq_restartRow{border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-brand);border-radius:8px;padding:10px 12px}.ZsMDKq_restartRow p{color:var(--dsw-alias-brand-primary);margin:0}.ZsMDKq_mount{align-self:center;margin-left:auto;position:relative}.ZsMDKq_toolbar{color:var(--dsw-alias-label-primary);align-items:center;gap:8px;font-size:12.5px;line-height:18px;display:flex;position:relative}.ZsMDKq_toolbarButton{font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm,6px);color:var(--dsw-alias-label-primary);background:0 0;padding:3px 10px}.ZsMDKq_toolbarButton:hover:enabled{background:var(--dsw-alias-interactive-bg-hover)}.ZsMDKq_toolbarButton:disabled{cursor:default;opacity:.55}.ZsMDKq_toolbarButton:focus-visible,.ZsMDKq_toolbarSummary:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}.ZsMDKq_toolbarSummary{font:inherit;cursor:pointer;color:var(--dsw-alias-label-secondary);background:0 0;border:0;padding:3px 2px}.ZsMDKq_toolbarSummary:hover{color:var(--dsw-alias-label-primary)}.ZsMDKq_toolbarHint{max-width:320px;color:var(--dsw-alias-label-tertiary)}.ZsMDKq_panel{z-index:40;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);width:max-content;min-width:260px;max-width:min(440px,60vw);max-height:320px;box-shadow:var(--dsw-shadow-lv3,0 8px 24px #00000024);text-align:left;border-radius:10px;flex-direction:column;gap:8px;padding:12px;display:flex;position:absolute;top:calc(100% + 6px);right:0;overflow:auto}.ZsMDKq_panelActions{justify-content:flex-end;gap:8px;display:flex}.ZsMDKq_panelList{flex-direction:column;gap:6px;margin:0;padding:0;list-style:none;display:flex}.ZsMDKq_panelRow{flex-wrap:wrap;align-items:baseline;gap:6px;display:flex}.ZsMDKq_panelName{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);word-break:break-all;font-size:12px}.ZsMDKq_panelVersion{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:12px}";
|
|
26
27
|
const tagId = "@linxin666/dsh-client-ui-plugin-manager/packages/dsh-plugin-manager/src/client/plugin-manager.module.css";
|
|
27
28
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
28
29
|
const tag = document.createElement("style");
|
|
@@ -39,8 +40,15 @@ window.__ModuleLoader__.load({
|
|
|
39
40
|
"error": "ZsMDKq_error",
|
|
40
41
|
"hint": "ZsMDKq_hint",
|
|
41
42
|
"latest": "ZsMDKq_latest",
|
|
43
|
+
"mount": "ZsMDKq_mount",
|
|
42
44
|
"notice": "ZsMDKq_notice",
|
|
43
45
|
"ok": "ZsMDKq_ok",
|
|
46
|
+
"panel": "ZsMDKq_panel",
|
|
47
|
+
"panelActions": "ZsMDKq_panelActions",
|
|
48
|
+
"panelList": "ZsMDKq_panelList",
|
|
49
|
+
"panelName": "ZsMDKq_panelName",
|
|
50
|
+
"panelRow": "ZsMDKq_panelRow",
|
|
51
|
+
"panelVersion": "ZsMDKq_panelVersion",
|
|
44
52
|
"pluginManagerIndeterminate": "ZsMDKq_pluginManagerIndeterminate",
|
|
45
53
|
"primary": "ZsMDKq_primary",
|
|
46
54
|
"progressBar": "ZsMDKq_progressBar",
|
|
@@ -48,7 +56,11 @@ window.__ModuleLoader__.load({
|
|
|
48
56
|
"progressTrack": "ZsMDKq_progressTrack",
|
|
49
57
|
"restartRow": "ZsMDKq_restartRow",
|
|
50
58
|
"section": "ZsMDKq_section",
|
|
51
|
-
"title": "ZsMDKq_title"
|
|
59
|
+
"title": "ZsMDKq_title",
|
|
60
|
+
"toolbar": "ZsMDKq_toolbar",
|
|
61
|
+
"toolbarButton": "ZsMDKq_toolbarButton",
|
|
62
|
+
"toolbarHint": "ZsMDKq_toolbarHint",
|
|
63
|
+
"toolbarSummary": "ZsMDKq_toolbarSummary"
|
|
52
64
|
};
|
|
53
65
|
//#endregion
|
|
54
66
|
//#region src/client/PluginUpdatePatch.tsx
|
|
@@ -73,9 +85,9 @@ window.__ModuleLoader__.load({
|
|
|
73
85
|
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
74
86
|
*/
|
|
75
87
|
/** Error text for a caught request or lifecycle failure. */
|
|
76
|
-
function messageOf(error) {
|
|
88
|
+
function messageOf$1(error) {
|
|
77
89
|
if (error instanceof AggregateError) {
|
|
78
|
-
const details = error.errors.map(messageOf).join("; ");
|
|
90
|
+
const details = error.errors.map(messageOf$1).join("; ");
|
|
79
91
|
return details === "" ? error.message : `${error.message}: ${details}`;
|
|
80
92
|
}
|
|
81
93
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -143,7 +155,7 @@ window.__ModuleLoader__.load({
|
|
|
143
155
|
setFound(items.find((item) => item.id === name));
|
|
144
156
|
setChecked(true);
|
|
145
157
|
}).catch((reason) => {
|
|
146
|
-
setError(t("failed", { reason: messageOf(reason) }));
|
|
158
|
+
setError(t("failed", { reason: messageOf$1(reason) }));
|
|
147
159
|
}).finally(() => {
|
|
148
160
|
busyRef.current = false;
|
|
149
161
|
setBusy(void 0);
|
|
@@ -159,7 +171,7 @@ window.__ModuleLoader__.load({
|
|
|
159
171
|
setChecked(false);
|
|
160
172
|
setDirty(true);
|
|
161
173
|
}).catch((reason) => {
|
|
162
|
-
setError(t("failed", { reason: messageOf(reason) }));
|
|
174
|
+
setError(t("failed", { reason: messageOf$1(reason) }));
|
|
163
175
|
}).finally(() => {
|
|
164
176
|
busyRef.current = false;
|
|
165
177
|
setBusy(void 0);
|
|
@@ -173,6 +185,7 @@ window.__ModuleLoader__.load({
|
|
|
173
185
|
});
|
|
174
186
|
const requiresDsh = found?.requiresDsh;
|
|
175
187
|
const blocked = found?.compatible === false;
|
|
188
|
+
const unverified = blocked && found?.hostVersion === void 0;
|
|
176
189
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
177
190
|
className: plugin_manager_module_css_default.section,
|
|
178
191
|
"data-update-patch": true,
|
|
@@ -204,7 +217,8 @@ window.__ModuleLoader__.load({
|
|
|
204
217
|
found !== void 0 && requiresDsh !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
205
218
|
className: blocked ? plugin_manager_module_css_default.compatBlocked : plugin_manager_module_css_default.compatHint,
|
|
206
219
|
"data-update-compat": blocked ? "blocked" : "ok",
|
|
207
|
-
|
|
220
|
+
"data-update-compat-reason": blocked ? unverified ? "unverified" : "below-minimum" : void 0,
|
|
221
|
+
children: !blocked ? t("updateRequiresDsh", { min: displayMinimumVersion(requiresDsh) }) : unverified ? t("updateUnverifiedDsh", { min: displayMinimumVersion(requiresDsh) }) : t("updateBlockedDsh", { min: displayMinimumVersion(requiresDsh) })
|
|
208
222
|
}),
|
|
209
223
|
found !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
210
224
|
type: "button",
|
|
@@ -244,13 +258,494 @@ window.__ModuleLoader__.load({
|
|
|
244
258
|
});
|
|
245
259
|
}
|
|
246
260
|
//#endregion
|
|
261
|
+
//#region src/client/body-mutations.ts
|
|
262
|
+
/** Cross-bundle registry key; `Symbol.for` so every module copy agrees. */
|
|
263
|
+
const HUB_KEY = Symbol.for("dsh-web.body-mutation-hub");
|
|
264
|
+
const INVALIDATION_ONLY = Symbol.for("dsh-web.body-mutation-invalidation");
|
|
265
|
+
function needsRecords(subscribers) {
|
|
266
|
+
for (const listener of subscribers) if (!listener[INVALIDATION_ONLY]) return true;
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Subscribe to a coalesced DOM re-check without retaining mutation records.
|
|
271
|
+
* The marked wrapper also works with an older hub, which delivers records
|
|
272
|
+
* that it simply ignores until a page reload picks up the updated hub.
|
|
273
|
+
*/
|
|
274
|
+
function subscribeBodyInvalidations(subscriber) {
|
|
275
|
+
const listener = () => {
|
|
276
|
+
subscriber();
|
|
277
|
+
};
|
|
278
|
+
listener[INVALIDATION_ONLY] = true;
|
|
279
|
+
return subscribeBodyMutations(listener);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Subscribe to body-level childList mutations.
|
|
283
|
+
* @param subscriber - called at most once per animation frame with the records
|
|
284
|
+
* collected since the previous flush; must be safe to run repeatedly.
|
|
285
|
+
* @returns the disposer removing this subscriber (and the observer when it was
|
|
286
|
+
* the last one).
|
|
287
|
+
*/
|
|
288
|
+
function subscribeBodyMutations(subscriber) {
|
|
289
|
+
if (typeof globalThis === "undefined" || typeof document === "undefined") return () => {};
|
|
290
|
+
if (typeof MutationObserver !== "function") return () => {};
|
|
291
|
+
const registry = globalThis;
|
|
292
|
+
let hub = registry[HUB_KEY];
|
|
293
|
+
if (hub === void 0) {
|
|
294
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
295
|
+
const created = {
|
|
296
|
+
observer: void 0,
|
|
297
|
+
subscribers,
|
|
298
|
+
pending: [],
|
|
299
|
+
scheduled: false
|
|
300
|
+
};
|
|
301
|
+
const flush = () => {
|
|
302
|
+
created.frame = void 0;
|
|
303
|
+
created.scheduled = false;
|
|
304
|
+
const batch = created.pending;
|
|
305
|
+
created.pending = [];
|
|
306
|
+
for (const listener of [...subscribers]) {
|
|
307
|
+
if (!subscribers.has(listener)) continue;
|
|
308
|
+
try {
|
|
309
|
+
listener(batch);
|
|
310
|
+
} catch {}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
const schedule = () => {
|
|
314
|
+
if (created.scheduled) return;
|
|
315
|
+
created.scheduled = true;
|
|
316
|
+
if (typeof requestAnimationFrame === "function") created.frame = requestAnimationFrame(flush);
|
|
317
|
+
else flush();
|
|
318
|
+
};
|
|
319
|
+
created.observer = new MutationObserver((records) => {
|
|
320
|
+
if (needsRecords(subscribers)) for (const record of records) created.pending.push(record);
|
|
321
|
+
schedule();
|
|
322
|
+
});
|
|
323
|
+
created.observer.observe(document.body ?? document.documentElement, {
|
|
324
|
+
childList: true,
|
|
325
|
+
subtree: true
|
|
326
|
+
});
|
|
327
|
+
registry[HUB_KEY] = created;
|
|
328
|
+
hub = created;
|
|
329
|
+
}
|
|
330
|
+
const active = hub;
|
|
331
|
+
active.subscribers.add(subscriber);
|
|
332
|
+
let subscribed = true;
|
|
333
|
+
return () => {
|
|
334
|
+
if (!subscribed) return;
|
|
335
|
+
subscribed = false;
|
|
336
|
+
active.subscribers.delete(subscriber);
|
|
337
|
+
if (!needsRecords(active.subscribers)) active.pending = [];
|
|
338
|
+
if (active.subscribers.size === 0 && registry[HUB_KEY] === active) {
|
|
339
|
+
active.observer.disconnect();
|
|
340
|
+
if (active.frame !== void 0 && typeof cancelAnimationFrame === "function") cancelAnimationFrame(active.frame);
|
|
341
|
+
active.frame = void 0;
|
|
342
|
+
active.pending = [];
|
|
343
|
+
active.scheduled = false;
|
|
344
|
+
delete registry[HUB_KEY];
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/core/updates.ts
|
|
350
|
+
/** The npm scope DSH's own packages are published under. */
|
|
351
|
+
const OFFICIAL_SCOPE = "@deepseek-ai/";
|
|
352
|
+
/** Whether a package id is a third-party plugin rather than a DSH-shipped one. */
|
|
353
|
+
function isThirdPartyPlugin(id) {
|
|
354
|
+
return !id.startsWith(OFFICIAL_SCOPE);
|
|
355
|
+
}
|
|
356
|
+
/** The third-party update rows, in host order. */
|
|
357
|
+
function thirdPartyUpdates(items) {
|
|
358
|
+
return items.filter((item) => isThirdPartyPlugin(item.id));
|
|
359
|
+
}
|
|
360
|
+
/** Whether the running DSH host satisfies the row's declared minimum. */
|
|
361
|
+
function isUpdateApplicable(item) {
|
|
362
|
+
return item.compatible !== false;
|
|
363
|
+
}
|
|
364
|
+
/** The third-party rows this runtime can actually apply. */
|
|
365
|
+
function applicableUpdates(items) {
|
|
366
|
+
return thirdPartyUpdates(items).filter(isUpdateApplicable);
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/client/PluginListToolbar.tsx
|
|
370
|
+
/**
|
|
371
|
+
* The list-level toolbar: check every installed third-party plugin for a newer
|
|
372
|
+
* registry release, apply them in one run, then restart DSH to load them.
|
|
373
|
+
*
|
|
374
|
+
* It exists because the official Plugins page compares one package at a time
|
|
375
|
+
* (its `plugins.detail.section` contributions render on a bundle's page), while
|
|
376
|
+
* the answer a user wants when they open the page is "is anything of mine out
|
|
377
|
+
* of date, and can I just fix it". It is mounted beside the page's "Installed"
|
|
378
|
+
* heading (see plugin-toolbar-mount.tsx) because that heading is the page's own
|
|
379
|
+
* chrome and the page declares no seat next to it.
|
|
380
|
+
*
|
|
381
|
+
* Policy lives in core/updates.ts (third-party only, compatibility-gated) and
|
|
382
|
+
* the operations come from the injected face, so this component is pure
|
|
383
|
+
* rendering plus the sequence of calls: nothing here touches the DOM beyond its
|
|
384
|
+
* own subtree.
|
|
385
|
+
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
386
|
+
*/
|
|
387
|
+
/** Error text for a caught request or lifecycle failure. */
|
|
388
|
+
function messageOf(error) {
|
|
389
|
+
if (error instanceof AggregateError) {
|
|
390
|
+
const details = error.errors.map(messageOf).join("; ");
|
|
391
|
+
return details === "" ? error.message : `${error.message}: ${details}`;
|
|
392
|
+
}
|
|
393
|
+
return error instanceof Error ? error.message : String(error);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* The toolbar itself. All state is local: the page around it owns the plugin
|
|
397
|
+
* list, and a restart tears this component down anyway.
|
|
398
|
+
*/
|
|
399
|
+
function PluginListToolbar(props) {
|
|
400
|
+
const { t, isLoopback, checkUpdates, update, restartPlan, restart } = props;
|
|
401
|
+
const [phase, setPhase] = (0, react.useState)("idle");
|
|
402
|
+
const [checked, setChecked] = (0, react.useState)(false);
|
|
403
|
+
/** Every third-party row the last check reported, including the applied ones. */
|
|
404
|
+
const [found, setFound] = (0, react.useState)(0);
|
|
405
|
+
const [rows, setRows] = (0, react.useState)([]);
|
|
406
|
+
const [applied, setApplied] = (0, react.useState)([]);
|
|
407
|
+
const [cursor, setCursor] = (0, react.useState)(void 0);
|
|
408
|
+
const [error, setError] = (0, react.useState)(void 0);
|
|
409
|
+
const [panel, setPanel] = (0, react.useState)("none");
|
|
410
|
+
/** How the host says it would restart, read before the confirmation is shown. */
|
|
411
|
+
const [plan, setPlan] = (0, react.useState)(void 0);
|
|
412
|
+
const [restartMode, setRestartMode] = (0, react.useState)(void 0);
|
|
413
|
+
/** Synchronous in-flight mirror of the phase: a click and a keypress can land in one frame. */
|
|
414
|
+
const busyRef = (0, react.useRef)(false);
|
|
415
|
+
const pending = applicableUpdates(rows);
|
|
416
|
+
/** Close the flyout on Escape, the shell's own dismissal gesture. */
|
|
417
|
+
(0, react.useEffect)(() => {
|
|
418
|
+
if (panel === "none") return;
|
|
419
|
+
const onKey = (event) => {
|
|
420
|
+
if (event.key === "Escape") setPanel("none");
|
|
421
|
+
};
|
|
422
|
+
window.addEventListener("keydown", onKey);
|
|
423
|
+
return () => {
|
|
424
|
+
window.removeEventListener("keydown", onKey);
|
|
425
|
+
};
|
|
426
|
+
}, [panel]);
|
|
427
|
+
const onCheck = () => {
|
|
428
|
+
if (busyRef.current) return;
|
|
429
|
+
busyRef.current = true;
|
|
430
|
+
setPhase("checking");
|
|
431
|
+
setError(void 0);
|
|
432
|
+
setRestartMode(void 0);
|
|
433
|
+
checkUpdates().then((items) => {
|
|
434
|
+
const thirdParty = thirdPartyUpdates(items);
|
|
435
|
+
setRows(thirdParty);
|
|
436
|
+
setFound(thirdParty.length);
|
|
437
|
+
setApplied([]);
|
|
438
|
+
setChecked(true);
|
|
439
|
+
setPanel("list");
|
|
440
|
+
}).catch((reason) => {
|
|
441
|
+
setError(t("failed", { reason: messageOf(reason) }));
|
|
442
|
+
setPanel("list");
|
|
443
|
+
}).finally(() => {
|
|
444
|
+
busyRef.current = false;
|
|
445
|
+
setPhase("idle");
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
const onUpdateAll = () => {
|
|
449
|
+
if (busyRef.current) return;
|
|
450
|
+
const queue = applicableUpdates(rows);
|
|
451
|
+
if (queue.length === 0) return;
|
|
452
|
+
busyRef.current = true;
|
|
453
|
+
setPhase("updating");
|
|
454
|
+
setError(void 0);
|
|
455
|
+
(async () => {
|
|
456
|
+
const done = [];
|
|
457
|
+
for (const [index, row] of queue.entries()) {
|
|
458
|
+
setCursor({
|
|
459
|
+
name: row.id,
|
|
460
|
+
index: index + 1,
|
|
461
|
+
total: queue.length
|
|
462
|
+
});
|
|
463
|
+
try {
|
|
464
|
+
await update(row.id);
|
|
465
|
+
} catch (reason) {
|
|
466
|
+
setError(t("failed", { reason: messageOf(reason) }));
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
done.push(row.id);
|
|
470
|
+
setApplied([...done]);
|
|
471
|
+
setRows((current) => current.filter((item) => item.id !== row.id));
|
|
472
|
+
}
|
|
473
|
+
setCursor(void 0);
|
|
474
|
+
})().finally(() => {
|
|
475
|
+
busyRef.current = false;
|
|
476
|
+
setPhase("idle");
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
/** Ask the host how it would restart, then show the confirmation that matches. */
|
|
480
|
+
const onAskRestart = () => {
|
|
481
|
+
if (busyRef.current) return;
|
|
482
|
+
busyRef.current = true;
|
|
483
|
+
setError(void 0);
|
|
484
|
+
restartPlan().then((mode) => {
|
|
485
|
+
setPlan(mode);
|
|
486
|
+
setPanel("restart");
|
|
487
|
+
}).catch((reason) => {
|
|
488
|
+
setError(t("failed", { reason: messageOf(reason) }));
|
|
489
|
+
setPanel("list");
|
|
490
|
+
}).finally(() => {
|
|
491
|
+
busyRef.current = false;
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
const onRestart = () => {
|
|
495
|
+
if (busyRef.current) return;
|
|
496
|
+
busyRef.current = true;
|
|
497
|
+
setError(void 0);
|
|
498
|
+
restart().then((mode) => {
|
|
499
|
+
setRestartMode(mode);
|
|
500
|
+
setPlan(void 0);
|
|
501
|
+
setPanel("none");
|
|
502
|
+
}).catch((reason) => {
|
|
503
|
+
setError(t("failed", { reason: messageOf(reason) }));
|
|
504
|
+
}).finally(() => {
|
|
505
|
+
busyRef.current = false;
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
const shellProps = {
|
|
509
|
+
"data-dsh-plugin": "plugin-manager",
|
|
510
|
+
"data-dsh-part": "update-toolbar",
|
|
511
|
+
"data-update-toolbar": true
|
|
512
|
+
};
|
|
513
|
+
if (!isLoopback) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
514
|
+
className: plugin_manager_module_css_default.toolbar,
|
|
515
|
+
...shellProps,
|
|
516
|
+
"data-state": "local-only",
|
|
517
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
518
|
+
type: "button",
|
|
519
|
+
className: plugin_manager_module_css_default.toolbarButton,
|
|
520
|
+
disabled: true,
|
|
521
|
+
title: t("localOnlyBody"),
|
|
522
|
+
children: t("checkUpdates")
|
|
523
|
+
})
|
|
524
|
+
});
|
|
525
|
+
const busy = phase !== "idle";
|
|
526
|
+
/** One alert line, rendered in whichever flyout is open when it appears. */
|
|
527
|
+
const errorLine = error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
528
|
+
className: plugin_manager_module_css_default.error,
|
|
529
|
+
role: "alert",
|
|
530
|
+
"data-update-error": true,
|
|
531
|
+
children: error
|
|
532
|
+
});
|
|
533
|
+
/** What is still pending after a partial run (the applied rows leave the list). */
|
|
534
|
+
const remaining = found - applied.length;
|
|
535
|
+
const summary = cursor !== void 0 ? t("updatingAll", {
|
|
536
|
+
name: cursor.name,
|
|
537
|
+
index: String(cursor.index),
|
|
538
|
+
total: String(cursor.total)
|
|
539
|
+
}) : remaining > 0 ? t("updatesAvailable", { count: String(remaining) }) : applied.length > 0 ? t("updateAllDone") : t("noUpdates");
|
|
540
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
541
|
+
className: plugin_manager_module_css_default.toolbar,
|
|
542
|
+
...shellProps,
|
|
543
|
+
"data-state": restartMode ?? phase,
|
|
544
|
+
"aria-busy": busy,
|
|
545
|
+
children: [
|
|
546
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
547
|
+
type: "button",
|
|
548
|
+
className: plugin_manager_module_css_default.toolbarButton,
|
|
549
|
+
"data-update-check": true,
|
|
550
|
+
disabled: busy,
|
|
551
|
+
onClick: onCheck,
|
|
552
|
+
children: phase === "checking" ? t("checking") : t("checkUpdates")
|
|
553
|
+
}),
|
|
554
|
+
checked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
555
|
+
type: "button",
|
|
556
|
+
className: plugin_manager_module_css_default.toolbarSummary,
|
|
557
|
+
"data-update-summary": true,
|
|
558
|
+
"data-pending": pending.length,
|
|
559
|
+
"aria-expanded": panel === "list",
|
|
560
|
+
onClick: () => {
|
|
561
|
+
setPanel(panel === "list" ? "none" : "list");
|
|
562
|
+
},
|
|
563
|
+
children: summary
|
|
564
|
+
}),
|
|
565
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
566
|
+
type: "button",
|
|
567
|
+
className: applied.length > 0 ? `${plugin_manager_module_css_default.toolbarButton} ${plugin_manager_module_css_default.primary}` : plugin_manager_module_css_default.toolbarButton,
|
|
568
|
+
"data-update-restart": true,
|
|
569
|
+
"data-restart-pending": applied.length,
|
|
570
|
+
disabled: busy || restartMode === "relaunch",
|
|
571
|
+
onClick: () => {
|
|
572
|
+
if (panel === "restart") {
|
|
573
|
+
setPanel("none");
|
|
574
|
+
setPlan(void 0);
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
onAskRestart();
|
|
578
|
+
},
|
|
579
|
+
children: restartMode === "relaunch" ? t("restarting") : t("restartNow")
|
|
580
|
+
}),
|
|
581
|
+
restartMode !== void 0 && panel !== "restart" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
582
|
+
className: plugin_manager_module_css_default.toolbarHint,
|
|
583
|
+
role: "status",
|
|
584
|
+
"data-update-restart-hint": restartMode,
|
|
585
|
+
children: restartMode === "shell" ? t("restartDesktopHint") : restartMode === "manual" ? t("restartManualHint") : t("restartRelaunchHint")
|
|
586
|
+
}),
|
|
587
|
+
panel === "list" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
588
|
+
className: plugin_manager_module_css_default.panel,
|
|
589
|
+
"data-update-panel": true,
|
|
590
|
+
role: "group",
|
|
591
|
+
"aria-label": t("updatesPanelTitle"),
|
|
592
|
+
children: [
|
|
593
|
+
errorLine,
|
|
594
|
+
applied.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
595
|
+
className: plugin_manager_module_css_default.ok,
|
|
596
|
+
"data-update-applied": true,
|
|
597
|
+
children: t("updateAllDone")
|
|
598
|
+
}),
|
|
599
|
+
rows.length === 0 && applied.length === 0 && error === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
600
|
+
className: plugin_manager_module_css_default.hint,
|
|
601
|
+
children: t("noUpdates")
|
|
602
|
+
}),
|
|
603
|
+
rows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
604
|
+
className: plugin_manager_module_css_default.panelList,
|
|
605
|
+
children: rows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
606
|
+
className: plugin_manager_module_css_default.panelRow,
|
|
607
|
+
"data-update-row": row.id,
|
|
608
|
+
"data-compatible": isUpdateApplicable(row) ? "yes" : "no",
|
|
609
|
+
children: [
|
|
610
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
611
|
+
className: plugin_manager_module_css_default.panelName,
|
|
612
|
+
children: row.id
|
|
613
|
+
}),
|
|
614
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
615
|
+
className: plugin_manager_module_css_default.panelVersion,
|
|
616
|
+
children: [
|
|
617
|
+
row.current,
|
|
618
|
+
" → ",
|
|
619
|
+
row.latest
|
|
620
|
+
]
|
|
621
|
+
}),
|
|
622
|
+
row.compatible === false && row.requiresDsh !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
623
|
+
className: plugin_manager_module_css_default.compatBlocked,
|
|
624
|
+
"data-update-row-compat-reason": row.hostVersion === void 0 ? "unverified" : "below-minimum",
|
|
625
|
+
children: row.hostVersion === void 0 ? t("updateUnverifiedDsh", { min: displayMinimumVersion(row.requiresDsh) }) : t("updateBlockedDsh", { min: displayMinimumVersion(row.requiresDsh) })
|
|
626
|
+
})
|
|
627
|
+
]
|
|
628
|
+
}, row.id))
|
|
629
|
+
}),
|
|
630
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
631
|
+
className: plugin_manager_module_css_default.panelActions,
|
|
632
|
+
children: [pending.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
633
|
+
type: "button",
|
|
634
|
+
className: `${plugin_manager_module_css_default.button} ${plugin_manager_module_css_default.primary}`,
|
|
635
|
+
"data-update-all": true,
|
|
636
|
+
disabled: busy,
|
|
637
|
+
onClick: onUpdateAll,
|
|
638
|
+
children: phase === "updating" ? t("updating") : t("updateAll", { count: String(pending.length) })
|
|
639
|
+
}), applied.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
640
|
+
type: "button",
|
|
641
|
+
className: `${plugin_manager_module_css_default.button} ${plugin_manager_module_css_default.primary}`,
|
|
642
|
+
"data-update-panel-restart": true,
|
|
643
|
+
disabled: busy,
|
|
644
|
+
onClick: onAskRestart,
|
|
645
|
+
children: t("restartNow")
|
|
646
|
+
})]
|
|
647
|
+
}),
|
|
648
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
649
|
+
className: plugin_manager_module_css_default.hint,
|
|
650
|
+
children: t("thirdPartyOnly")
|
|
651
|
+
})
|
|
652
|
+
]
|
|
653
|
+
}),
|
|
654
|
+
panel === "restart" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
655
|
+
className: plugin_manager_module_css_default.panel,
|
|
656
|
+
"data-update-restart-panel": true,
|
|
657
|
+
"data-restart-plan": plan,
|
|
658
|
+
role: "group",
|
|
659
|
+
"aria-label": t("restartNow"),
|
|
660
|
+
children: [
|
|
661
|
+
errorLine,
|
|
662
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
663
|
+
className: plugin_manager_module_css_default.hint,
|
|
664
|
+
"data-restart-plan-hint": plan,
|
|
665
|
+
children: plan === "shell" ? t("restartPlanShell") : plan === "manual" ? t("restartPlanManual") : t("restartPlanRelaunch")
|
|
666
|
+
}),
|
|
667
|
+
plan === "shell" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
668
|
+
className: plugin_manager_module_css_default.hint,
|
|
669
|
+
children: t("restartShellWarning")
|
|
670
|
+
}),
|
|
671
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
672
|
+
className: plugin_manager_module_css_default.panelActions,
|
|
673
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
674
|
+
type: "button",
|
|
675
|
+
className: plugin_manager_module_css_default.button,
|
|
676
|
+
"data-restart-cancel": true,
|
|
677
|
+
onClick: () => {
|
|
678
|
+
setPanel("none");
|
|
679
|
+
setPlan(void 0);
|
|
680
|
+
},
|
|
681
|
+
children: t("cancel")
|
|
682
|
+
}), plan !== "manual" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
683
|
+
type: "button",
|
|
684
|
+
className: `${plugin_manager_module_css_default.button} ${plugin_manager_module_css_default.primary}`,
|
|
685
|
+
"data-restart-confirm": true,
|
|
686
|
+
onClick: onRestart,
|
|
687
|
+
children: t("restartConfirm")
|
|
688
|
+
})]
|
|
689
|
+
})
|
|
690
|
+
]
|
|
691
|
+
})
|
|
692
|
+
]
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* The official page's "Installed" group heading, when it is mounted. Class
|
|
697
|
+
* names are CSS-module hashes in the official bundle, so the seat is found
|
|
698
|
+
* through the page's own data attributes plus DOM position.
|
|
699
|
+
* @returns the heading element to append into, or undefined off the list view.
|
|
700
|
+
*/
|
|
701
|
+
function toolbarSeat() {
|
|
702
|
+
const head = (document.querySelector("[data-plugin-panel]")?.querySelector("[data-plugin-group=\"bundles\"]"))?.firstElementChild;
|
|
703
|
+
return head instanceof HTMLElement ? head : void 0;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Mount the toolbar into the Installed heading.
|
|
707
|
+
* @param options - props factory and the optional locale subscription.
|
|
708
|
+
* @returns disposer removing the container, its observers and its React root.
|
|
709
|
+
*/
|
|
710
|
+
function mountPluginListToolbar(options) {
|
|
711
|
+
if (typeof document === "undefined") return () => {};
|
|
712
|
+
if (document.querySelector("[data-dsh-plugin-manager-toolbar]") !== null) return () => {};
|
|
713
|
+
const container = document.createElement("div");
|
|
714
|
+
container.setAttribute("data-dsh-plugin-manager-toolbar", "");
|
|
715
|
+
container.className = plugin_manager_module_css_default.mount;
|
|
716
|
+
const root = (0, react_dom_client.createRoot)(container);
|
|
717
|
+
const render = () => {
|
|
718
|
+
root.render((0, react.createElement)(PluginListToolbar, options.props()));
|
|
719
|
+
};
|
|
720
|
+
render();
|
|
721
|
+
/** Keep the container inside the heading; detach while the list is away. */
|
|
722
|
+
const place = () => {
|
|
723
|
+
const seat = toolbarSeat();
|
|
724
|
+
if (seat === void 0) {
|
|
725
|
+
container.remove();
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
if (container.parentElement !== seat) seat.append(container);
|
|
729
|
+
};
|
|
730
|
+
place();
|
|
731
|
+
const unsubscribeBody = subscribeBodyInvalidations(place);
|
|
732
|
+
const unsubscribeLocale = options.subscribe === void 0 ? (() => {}) : options.subscribe(render);
|
|
733
|
+
return () => {
|
|
734
|
+
unsubscribeBody();
|
|
735
|
+
unsubscribeLocale();
|
|
736
|
+
root.unmount();
|
|
737
|
+
container.remove();
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
//#endregion
|
|
247
741
|
//#region src/client/locales.ts
|
|
248
742
|
/**
|
|
249
743
|
* Locale dictionaries for the plugin-manager's official-page patch. The zh
|
|
250
744
|
* dictionary is the key source; the en dictionary mirrors the exact key set.
|
|
251
745
|
*
|
|
252
|
-
* The key set covers only what this package
|
|
253
|
-
*
|
|
746
|
+
* The key set covers only what this package renders: the check-for-updates
|
|
747
|
+
* block on a bundle's page in the official Plugins panel, and the list-level
|
|
748
|
+
* update toolbar mounted beside that panel's "Installed" heading.
|
|
254
749
|
* The former tab's keys (inventory, conflicts, repair seeds, safe mode,
|
|
255
750
|
* aggregate children) left with that tab.
|
|
256
751
|
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
@@ -266,7 +761,25 @@ window.__ModuleLoader__.load({
|
|
|
266
761
|
"latest": "最新 {version}",
|
|
267
762
|
"updateRequiresDsh": "需要 DSH ≥ {min}",
|
|
268
763
|
"updateBlockedDsh": "需要 DSH ≥ {min},请先升级 DSH 再更新",
|
|
764
|
+
"updateUnverifiedDsh": "无法确认本机 DSH 版本(需要 DSH ≥ {min}),已暂停更新",
|
|
269
765
|
"restartHint": "插件变更将在重启应用后生效。",
|
|
766
|
+
"updatesAvailable": "{count} 个可更新",
|
|
767
|
+
"updateAll": "全部更新({count})",
|
|
768
|
+
"updatingAll": "更新 {name}({index}/{total})",
|
|
769
|
+
"updateAllDone": "更新完成,重启后生效。",
|
|
770
|
+
"updatesPanelTitle": "插件更新",
|
|
771
|
+
"thirdPartyOnly": "只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。",
|
|
772
|
+
"restartNow": "立即重启",
|
|
773
|
+
"restarting": "正在重启…",
|
|
774
|
+
"restartConfirm": "确认重启",
|
|
775
|
+
"restartPlanRelaunch": "会重启 DSH 服务,正在运行的任务会中断。",
|
|
776
|
+
"restartPlanShell": "桌面版通过系统对话框重启:确认后会弹出官方的「应用无法启动或已意外停止」对话框,请在对话框中点「重启」。",
|
|
777
|
+
"restartPlanManual": "当前进程无法自动重启,请手动重启 DSH。",
|
|
778
|
+
"restartShellWarning": "它同时会写一份崩溃报告;也可以手动重启:退出 DeepSeek Harness(⌘Q)后重新打开。",
|
|
779
|
+
"restartDesktopHint": "请在随后出现的系统对话框中选择「重启」。",
|
|
780
|
+
"restartRelaunchHint": "已请求重启;服务恢复后刷新页面即可。",
|
|
781
|
+
"restartManualHint": "当前进程无法自动重启,请手动重启 DSH。",
|
|
782
|
+
"cancel": "取消",
|
|
270
783
|
"failed": "操作失败:{reason}",
|
|
271
784
|
"fetching": "正在获取插件信息…",
|
|
272
785
|
"downloading": "正在下载…",
|
|
@@ -287,7 +800,25 @@ window.__ModuleLoader__.load({
|
|
|
287
800
|
"latest": "Latest {version}",
|
|
288
801
|
"updateRequiresDsh": "Requires DSH >= {min}",
|
|
289
802
|
"updateBlockedDsh": "Requires DSH >= {min}; upgrade DSH before updating",
|
|
803
|
+
"updateUnverifiedDsh": "Cannot confirm the local DSH version (this update needs DSH >= {min}); update paused",
|
|
290
804
|
"restartHint": "Plugin changes take effect after restarting the application.",
|
|
805
|
+
"updatesAvailable": "{count} updates available",
|
|
806
|
+
"updateAll": "Update all ({count})",
|
|
807
|
+
"updatingAll": "Updating {name} ({index}/{total})",
|
|
808
|
+
"updateAllDone": "Updated; restart to take effect.",
|
|
809
|
+
"updatesPanelTitle": "Plugin updates",
|
|
810
|
+
"thirdPartyOnly": "Third-party plugins only; @deepseek-ai/ packages upgrade with DSH itself.",
|
|
811
|
+
"restartNow": "Restart now",
|
|
812
|
+
"restarting": "Restarting…",
|
|
813
|
+
"restartConfirm": "Restart",
|
|
814
|
+
"restartPlanRelaunch": "The DSH service restarts; running tasks are interrupted.",
|
|
815
|
+
"restartPlanShell": "The desktop app restarts through its system dialog: confirming shows the official \"DeepSeek Harness is unavailable\" dialog; click Restart in it.",
|
|
816
|
+
"restartPlanManual": "This process cannot restart itself; restart DSH yourself.",
|
|
817
|
+
"restartShellWarning": "It also writes a crash report. You can instead restart manually: quit DeepSeek Harness (Cmd+Q) and open it again.",
|
|
818
|
+
"restartDesktopHint": "Choose Restart in the system dialog that follows.",
|
|
819
|
+
"restartRelaunchHint": "Restart requested; reload the page once the server is back.",
|
|
820
|
+
"restartManualHint": "This process cannot restart itself; restart DSH yourself.",
|
|
821
|
+
"cancel": "Cancel",
|
|
291
822
|
"failed": "Operation failed: {reason}",
|
|
292
823
|
"fetching": "Fetching plugin metadata…",
|
|
293
824
|
"downloading": "Downloading…",
|
|
@@ -399,10 +930,25 @@ window.__ModuleLoader__.load({
|
|
|
399
930
|
if (typeof update.compatible !== "boolean") throw new Error(`plugin-manager: update row ${String(index)} is invalid`);
|
|
400
931
|
row.compatible = update.compatible;
|
|
401
932
|
}
|
|
933
|
+
if (update.hostVersion !== void 0) {
|
|
934
|
+
if (!isString(update.hostVersion)) throw new Error(`plugin-manager: update row ${String(index)} is invalid`);
|
|
935
|
+
row.hostVersion = update.hostVersion;
|
|
936
|
+
}
|
|
402
937
|
return row;
|
|
403
938
|
});
|
|
404
939
|
}
|
|
405
940
|
/**
|
|
941
|
+
* Validate and normalize a `restart` response value.
|
|
942
|
+
* @param value - decoded but untrusted response value.
|
|
943
|
+
* @returns the mode the host actually used.
|
|
944
|
+
*/
|
|
945
|
+
function parseRestartMode(value) {
|
|
946
|
+
const restart = isRecord(value) ? value.restart : void 0;
|
|
947
|
+
const mode = isRecord(restart) ? restart.mode : void 0;
|
|
948
|
+
if (mode !== "relaunch" && mode !== "shell" && mode !== "manual") throw new Error("plugin-manager: response must contain a restart mode");
|
|
949
|
+
return mode;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
406
952
|
* Validate and normalize a `failures` response value.
|
|
407
953
|
* @param value - decoded but untrusted response value.
|
|
408
954
|
* @returns the typed failures snapshot.
|
|
@@ -437,7 +983,7 @@ window.__ModuleLoader__.load({
|
|
|
437
983
|
/** The building package's version, when the bundle carries it. */
|
|
438
984
|
function bakedVersion() {
|
|
439
985
|
try {
|
|
440
|
-
return "0.4.
|
|
986
|
+
return "0.4.6";
|
|
441
987
|
} catch {
|
|
442
988
|
return;
|
|
443
989
|
}
|
|
@@ -509,6 +1055,7 @@ window.__ModuleLoader__.load({
|
|
|
509
1055
|
const UNINSTALL_ENDPOINT = "uninstall";
|
|
510
1056
|
const SET_ENABLED_ENDPOINT = "set-enabled";
|
|
511
1057
|
const CHECK_UPDATES_ENDPOINT = "check-updates";
|
|
1058
|
+
const RESTART_ENDPOINT = "restart";
|
|
512
1059
|
const STATUS_ENDPOINT = "status";
|
|
513
1060
|
const FAILURES_ENDPOINT = "failures";
|
|
514
1061
|
const GATEWAY_PREFIX = "api/plugin-manager";
|
|
@@ -639,7 +1186,9 @@ window.__ModuleLoader__.load({
|
|
|
639
1186
|
kind: "idle",
|
|
640
1187
|
stage: "fetch"
|
|
641
1188
|
},
|
|
642
|
-
failures: async () => parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`))
|
|
1189
|
+
failures: async () => parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`)),
|
|
1190
|
+
restartPlan: async () => parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`)),
|
|
1191
|
+
restart: async () => parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`, { method: "POST" }))
|
|
643
1192
|
};
|
|
644
1193
|
let modePromise;
|
|
645
1194
|
const ensureMode = () => {
|
|
@@ -689,6 +1238,8 @@ window.__ModuleLoader__.load({
|
|
|
689
1238
|
return item;
|
|
690
1239
|
},
|
|
691
1240
|
checkUpdates: async () => await ensureMode() === "official" ? official.checkUpdates() : gateway.checkUpdates(),
|
|
1241
|
+
restartPlan: () => gateway.restartPlan(),
|
|
1242
|
+
restart: () => gateway.restart(),
|
|
692
1243
|
status: async () => await ensureMode() === "official" ? official.status() : gateway.status(),
|
|
693
1244
|
failures: async () => await ensureMode() === "official" ? official.failures() : gateway.failures(),
|
|
694
1245
|
onChange: (cb) => {
|
|
@@ -716,6 +1267,23 @@ window.__ModuleLoader__.load({
|
|
|
716
1267
|
try {
|
|
717
1268
|
if (!ctx.get("pluginManager")) ctx.provide(PLUGIN_MANAGER_SERVICE, face);
|
|
718
1269
|
} catch {}
|
|
1270
|
+
ctx.effect(() => {
|
|
1271
|
+
try {
|
|
1272
|
+
return mountPluginListToolbar({
|
|
1273
|
+
props: () => ({
|
|
1274
|
+
isLoopback: face.isLoopback,
|
|
1275
|
+
checkUpdates: face.checkUpdates,
|
|
1276
|
+
update: face.update,
|
|
1277
|
+
restartPlan: face.restartPlan,
|
|
1278
|
+
restart: face.restart,
|
|
1279
|
+
t: ctx.locale.bind(NS)
|
|
1280
|
+
}),
|
|
1281
|
+
subscribe: (listener) => ctx.locale.subscribe(listener)
|
|
1282
|
+
});
|
|
1283
|
+
} catch {
|
|
1284
|
+
return () => {};
|
|
1285
|
+
}
|
|
1286
|
+
}, "plugin-manager: update toolbar");
|
|
719
1287
|
ctx.slots.inject("plugins.detail.section", () => {
|
|
720
1288
|
try {
|
|
721
1289
|
return ctx.slots.register({
|