@linxin666/dsh-client-ui-plugin-manager 0.4.3 → 0.4.5
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 +22 -8
- package/README.zh.md +22 -8
- package/cordis.patch.yml +14 -1
- package/lib/client.js +569 -10
- package/lib/client.js.map +1 -1
- package/lib/index.js +393 -22
- 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 +54 -2
- package/lib/types/client/plugin-toolbar-mount.d.ts +47 -0
- package/lib/types/core/protocol.d.ts +13 -0
- package/lib/types/core/updates.d.ts +30 -0
- package/lib/types/core/version.d.ts +4 -1
- package/lib/types/host/gateway.d.ts +107 -3
- package/lib/types/host/restart.d.ts +95 -0
- package/lib/types/host/routes.d.ts +10 -1
- package/lib/types/host/state.d.ts +3 -1
- package/lib/types/index.d.ts +7 -2
- package/package.json +13 -13
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);
|
|
@@ -244,13 +256,493 @@ window.__ModuleLoader__.load({
|
|
|
244
256
|
});
|
|
245
257
|
}
|
|
246
258
|
//#endregion
|
|
259
|
+
//#region src/client/body-mutations.ts
|
|
260
|
+
/** Cross-bundle registry key; `Symbol.for` so every module copy agrees. */
|
|
261
|
+
const HUB_KEY = Symbol.for("dsh-web.body-mutation-hub");
|
|
262
|
+
const INVALIDATION_ONLY = Symbol.for("dsh-web.body-mutation-invalidation");
|
|
263
|
+
function needsRecords(subscribers) {
|
|
264
|
+
for (const listener of subscribers) if (!listener[INVALIDATION_ONLY]) return true;
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Subscribe to a coalesced DOM re-check without retaining mutation records.
|
|
269
|
+
* The marked wrapper also works with an older hub, which delivers records
|
|
270
|
+
* that it simply ignores until a page reload picks up the updated hub.
|
|
271
|
+
*/
|
|
272
|
+
function subscribeBodyInvalidations(subscriber) {
|
|
273
|
+
const listener = () => {
|
|
274
|
+
subscriber();
|
|
275
|
+
};
|
|
276
|
+
listener[INVALIDATION_ONLY] = true;
|
|
277
|
+
return subscribeBodyMutations(listener);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Subscribe to body-level childList mutations.
|
|
281
|
+
* @param subscriber - called at most once per animation frame with the records
|
|
282
|
+
* collected since the previous flush; must be safe to run repeatedly.
|
|
283
|
+
* @returns the disposer removing this subscriber (and the observer when it was
|
|
284
|
+
* the last one).
|
|
285
|
+
*/
|
|
286
|
+
function subscribeBodyMutations(subscriber) {
|
|
287
|
+
if (typeof globalThis === "undefined" || typeof document === "undefined") return () => {};
|
|
288
|
+
if (typeof MutationObserver !== "function") return () => {};
|
|
289
|
+
const registry = globalThis;
|
|
290
|
+
let hub = registry[HUB_KEY];
|
|
291
|
+
if (hub === void 0) {
|
|
292
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
293
|
+
const created = {
|
|
294
|
+
observer: void 0,
|
|
295
|
+
subscribers,
|
|
296
|
+
pending: [],
|
|
297
|
+
scheduled: false
|
|
298
|
+
};
|
|
299
|
+
const flush = () => {
|
|
300
|
+
created.frame = void 0;
|
|
301
|
+
created.scheduled = false;
|
|
302
|
+
const batch = created.pending;
|
|
303
|
+
created.pending = [];
|
|
304
|
+
for (const listener of [...subscribers]) {
|
|
305
|
+
if (!subscribers.has(listener)) continue;
|
|
306
|
+
try {
|
|
307
|
+
listener(batch);
|
|
308
|
+
} catch {}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
const schedule = () => {
|
|
312
|
+
if (created.scheduled) return;
|
|
313
|
+
created.scheduled = true;
|
|
314
|
+
if (typeof requestAnimationFrame === "function") created.frame = requestAnimationFrame(flush);
|
|
315
|
+
else flush();
|
|
316
|
+
};
|
|
317
|
+
created.observer = new MutationObserver((records) => {
|
|
318
|
+
if (needsRecords(subscribers)) for (const record of records) created.pending.push(record);
|
|
319
|
+
schedule();
|
|
320
|
+
});
|
|
321
|
+
created.observer.observe(document.body ?? document.documentElement, {
|
|
322
|
+
childList: true,
|
|
323
|
+
subtree: true
|
|
324
|
+
});
|
|
325
|
+
registry[HUB_KEY] = created;
|
|
326
|
+
hub = created;
|
|
327
|
+
}
|
|
328
|
+
const active = hub;
|
|
329
|
+
active.subscribers.add(subscriber);
|
|
330
|
+
let subscribed = true;
|
|
331
|
+
return () => {
|
|
332
|
+
if (!subscribed) return;
|
|
333
|
+
subscribed = false;
|
|
334
|
+
active.subscribers.delete(subscriber);
|
|
335
|
+
if (!needsRecords(active.subscribers)) active.pending = [];
|
|
336
|
+
if (active.subscribers.size === 0 && registry[HUB_KEY] === active) {
|
|
337
|
+
active.observer.disconnect();
|
|
338
|
+
if (active.frame !== void 0 && typeof cancelAnimationFrame === "function") cancelAnimationFrame(active.frame);
|
|
339
|
+
active.frame = void 0;
|
|
340
|
+
active.pending = [];
|
|
341
|
+
active.scheduled = false;
|
|
342
|
+
delete registry[HUB_KEY];
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/core/updates.ts
|
|
348
|
+
/** The npm scope DSH's own packages are published under. */
|
|
349
|
+
const OFFICIAL_SCOPE = "@deepseek-ai/";
|
|
350
|
+
/** Whether a package id is a third-party plugin rather than a DSH-shipped one. */
|
|
351
|
+
function isThirdPartyPlugin(id) {
|
|
352
|
+
return !id.startsWith(OFFICIAL_SCOPE);
|
|
353
|
+
}
|
|
354
|
+
/** The third-party update rows, in host order. */
|
|
355
|
+
function thirdPartyUpdates(items) {
|
|
356
|
+
return items.filter((item) => isThirdPartyPlugin(item.id));
|
|
357
|
+
}
|
|
358
|
+
/** Whether the running DSH host satisfies the row's declared minimum. */
|
|
359
|
+
function isUpdateApplicable(item) {
|
|
360
|
+
return item.compatible !== false;
|
|
361
|
+
}
|
|
362
|
+
/** The third-party rows this runtime can actually apply. */
|
|
363
|
+
function applicableUpdates(items) {
|
|
364
|
+
return thirdPartyUpdates(items).filter(isUpdateApplicable);
|
|
365
|
+
}
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/client/PluginListToolbar.tsx
|
|
368
|
+
/**
|
|
369
|
+
* The list-level toolbar: check every installed third-party plugin for a newer
|
|
370
|
+
* registry release, apply them in one run, then restart DSH to load them.
|
|
371
|
+
*
|
|
372
|
+
* It exists because the official Plugins page compares one package at a time
|
|
373
|
+
* (its `plugins.detail.section` contributions render on a bundle's page), while
|
|
374
|
+
* the answer a user wants when they open the page is "is anything of mine out
|
|
375
|
+
* of date, and can I just fix it". It is mounted beside the page's "Installed"
|
|
376
|
+
* heading (see plugin-toolbar-mount.tsx) because that heading is the page's own
|
|
377
|
+
* chrome and the page declares no seat next to it.
|
|
378
|
+
*
|
|
379
|
+
* Policy lives in core/updates.ts (third-party only, compatibility-gated) and
|
|
380
|
+
* the operations come from the injected face, so this component is pure
|
|
381
|
+
* rendering plus the sequence of calls: nothing here touches the DOM beyond its
|
|
382
|
+
* own subtree.
|
|
383
|
+
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
384
|
+
*/
|
|
385
|
+
/** Error text for a caught request or lifecycle failure. */
|
|
386
|
+
function messageOf(error) {
|
|
387
|
+
if (error instanceof AggregateError) {
|
|
388
|
+
const details = error.errors.map(messageOf).join("; ");
|
|
389
|
+
return details === "" ? error.message : `${error.message}: ${details}`;
|
|
390
|
+
}
|
|
391
|
+
return error instanceof Error ? error.message : String(error);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* The toolbar itself. All state is local: the page around it owns the plugin
|
|
395
|
+
* list, and a restart tears this component down anyway.
|
|
396
|
+
*/
|
|
397
|
+
function PluginListToolbar(props) {
|
|
398
|
+
const { t, isLoopback, checkUpdates, update, restartPlan, restart } = props;
|
|
399
|
+
const [phase, setPhase] = (0, react.useState)("idle");
|
|
400
|
+
const [checked, setChecked] = (0, react.useState)(false);
|
|
401
|
+
/** Every third-party row the last check reported, including the applied ones. */
|
|
402
|
+
const [found, setFound] = (0, react.useState)(0);
|
|
403
|
+
const [rows, setRows] = (0, react.useState)([]);
|
|
404
|
+
const [applied, setApplied] = (0, react.useState)([]);
|
|
405
|
+
const [cursor, setCursor] = (0, react.useState)(void 0);
|
|
406
|
+
const [error, setError] = (0, react.useState)(void 0);
|
|
407
|
+
const [panel, setPanel] = (0, react.useState)("none");
|
|
408
|
+
/** How the host says it would restart, read before the confirmation is shown. */
|
|
409
|
+
const [plan, setPlan] = (0, react.useState)(void 0);
|
|
410
|
+
const [restartMode, setRestartMode] = (0, react.useState)(void 0);
|
|
411
|
+
/** Synchronous in-flight mirror of the phase: a click and a keypress can land in one frame. */
|
|
412
|
+
const busyRef = (0, react.useRef)(false);
|
|
413
|
+
const pending = applicableUpdates(rows);
|
|
414
|
+
/** Close the flyout on Escape, the shell's own dismissal gesture. */
|
|
415
|
+
(0, react.useEffect)(() => {
|
|
416
|
+
if (panel === "none") return;
|
|
417
|
+
const onKey = (event) => {
|
|
418
|
+
if (event.key === "Escape") setPanel("none");
|
|
419
|
+
};
|
|
420
|
+
window.addEventListener("keydown", onKey);
|
|
421
|
+
return () => {
|
|
422
|
+
window.removeEventListener("keydown", onKey);
|
|
423
|
+
};
|
|
424
|
+
}, [panel]);
|
|
425
|
+
const onCheck = () => {
|
|
426
|
+
if (busyRef.current) return;
|
|
427
|
+
busyRef.current = true;
|
|
428
|
+
setPhase("checking");
|
|
429
|
+
setError(void 0);
|
|
430
|
+
setRestartMode(void 0);
|
|
431
|
+
checkUpdates().then((items) => {
|
|
432
|
+
const thirdParty = thirdPartyUpdates(items);
|
|
433
|
+
setRows(thirdParty);
|
|
434
|
+
setFound(thirdParty.length);
|
|
435
|
+
setApplied([]);
|
|
436
|
+
setChecked(true);
|
|
437
|
+
setPanel("list");
|
|
438
|
+
}).catch((reason) => {
|
|
439
|
+
setError(t("failed", { reason: messageOf(reason) }));
|
|
440
|
+
setPanel("list");
|
|
441
|
+
}).finally(() => {
|
|
442
|
+
busyRef.current = false;
|
|
443
|
+
setPhase("idle");
|
|
444
|
+
});
|
|
445
|
+
};
|
|
446
|
+
const onUpdateAll = () => {
|
|
447
|
+
if (busyRef.current) return;
|
|
448
|
+
const queue = applicableUpdates(rows);
|
|
449
|
+
if (queue.length === 0) return;
|
|
450
|
+
busyRef.current = true;
|
|
451
|
+
setPhase("updating");
|
|
452
|
+
setError(void 0);
|
|
453
|
+
(async () => {
|
|
454
|
+
const done = [];
|
|
455
|
+
for (const [index, row] of queue.entries()) {
|
|
456
|
+
setCursor({
|
|
457
|
+
name: row.id,
|
|
458
|
+
index: index + 1,
|
|
459
|
+
total: queue.length
|
|
460
|
+
});
|
|
461
|
+
try {
|
|
462
|
+
await update(row.id);
|
|
463
|
+
} catch (reason) {
|
|
464
|
+
setError(t("failed", { reason: messageOf(reason) }));
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
done.push(row.id);
|
|
468
|
+
setApplied([...done]);
|
|
469
|
+
setRows((current) => current.filter((item) => item.id !== row.id));
|
|
470
|
+
}
|
|
471
|
+
setCursor(void 0);
|
|
472
|
+
})().finally(() => {
|
|
473
|
+
busyRef.current = false;
|
|
474
|
+
setPhase("idle");
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
/** Ask the host how it would restart, then show the confirmation that matches. */
|
|
478
|
+
const onAskRestart = () => {
|
|
479
|
+
if (busyRef.current) return;
|
|
480
|
+
busyRef.current = true;
|
|
481
|
+
setError(void 0);
|
|
482
|
+
restartPlan().then((mode) => {
|
|
483
|
+
setPlan(mode);
|
|
484
|
+
setPanel("restart");
|
|
485
|
+
}).catch((reason) => {
|
|
486
|
+
setError(t("failed", { reason: messageOf(reason) }));
|
|
487
|
+
setPanel("list");
|
|
488
|
+
}).finally(() => {
|
|
489
|
+
busyRef.current = false;
|
|
490
|
+
});
|
|
491
|
+
};
|
|
492
|
+
const onRestart = () => {
|
|
493
|
+
if (busyRef.current) return;
|
|
494
|
+
busyRef.current = true;
|
|
495
|
+
setError(void 0);
|
|
496
|
+
restart().then((mode) => {
|
|
497
|
+
setRestartMode(mode);
|
|
498
|
+
setPlan(void 0);
|
|
499
|
+
setPanel("none");
|
|
500
|
+
}).catch((reason) => {
|
|
501
|
+
setError(t("failed", { reason: messageOf(reason) }));
|
|
502
|
+
}).finally(() => {
|
|
503
|
+
busyRef.current = false;
|
|
504
|
+
});
|
|
505
|
+
};
|
|
506
|
+
const shellProps = {
|
|
507
|
+
"data-dsh-plugin": "plugin-manager",
|
|
508
|
+
"data-dsh-part": "update-toolbar",
|
|
509
|
+
"data-update-toolbar": true
|
|
510
|
+
};
|
|
511
|
+
if (!isLoopback) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
512
|
+
className: plugin_manager_module_css_default.toolbar,
|
|
513
|
+
...shellProps,
|
|
514
|
+
"data-state": "local-only",
|
|
515
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
516
|
+
type: "button",
|
|
517
|
+
className: plugin_manager_module_css_default.toolbarButton,
|
|
518
|
+
disabled: true,
|
|
519
|
+
title: t("localOnlyBody"),
|
|
520
|
+
children: t("checkUpdates")
|
|
521
|
+
})
|
|
522
|
+
});
|
|
523
|
+
const busy = phase !== "idle";
|
|
524
|
+
/** One alert line, rendered in whichever flyout is open when it appears. */
|
|
525
|
+
const errorLine = error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
526
|
+
className: plugin_manager_module_css_default.error,
|
|
527
|
+
role: "alert",
|
|
528
|
+
"data-update-error": true,
|
|
529
|
+
children: error
|
|
530
|
+
});
|
|
531
|
+
/** What is still pending after a partial run (the applied rows leave the list). */
|
|
532
|
+
const remaining = found - applied.length;
|
|
533
|
+
const summary = cursor !== void 0 ? t("updatingAll", {
|
|
534
|
+
name: cursor.name,
|
|
535
|
+
index: String(cursor.index),
|
|
536
|
+
total: String(cursor.total)
|
|
537
|
+
}) : remaining > 0 ? t("updatesAvailable", { count: String(remaining) }) : applied.length > 0 ? t("updateAllDone") : t("noUpdates");
|
|
538
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
539
|
+
className: plugin_manager_module_css_default.toolbar,
|
|
540
|
+
...shellProps,
|
|
541
|
+
"data-state": restartMode ?? phase,
|
|
542
|
+
"aria-busy": busy,
|
|
543
|
+
children: [
|
|
544
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
545
|
+
type: "button",
|
|
546
|
+
className: plugin_manager_module_css_default.toolbarButton,
|
|
547
|
+
"data-update-check": true,
|
|
548
|
+
disabled: busy,
|
|
549
|
+
onClick: onCheck,
|
|
550
|
+
children: phase === "checking" ? t("checking") : t("checkUpdates")
|
|
551
|
+
}),
|
|
552
|
+
checked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
553
|
+
type: "button",
|
|
554
|
+
className: plugin_manager_module_css_default.toolbarSummary,
|
|
555
|
+
"data-update-summary": true,
|
|
556
|
+
"data-pending": pending.length,
|
|
557
|
+
"aria-expanded": panel === "list",
|
|
558
|
+
onClick: () => {
|
|
559
|
+
setPanel(panel === "list" ? "none" : "list");
|
|
560
|
+
},
|
|
561
|
+
children: summary
|
|
562
|
+
}),
|
|
563
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
564
|
+
type: "button",
|
|
565
|
+
className: applied.length > 0 ? `${plugin_manager_module_css_default.toolbarButton} ${plugin_manager_module_css_default.primary}` : plugin_manager_module_css_default.toolbarButton,
|
|
566
|
+
"data-update-restart": true,
|
|
567
|
+
"data-restart-pending": applied.length,
|
|
568
|
+
disabled: busy || restartMode === "relaunch",
|
|
569
|
+
onClick: () => {
|
|
570
|
+
if (panel === "restart") {
|
|
571
|
+
setPanel("none");
|
|
572
|
+
setPlan(void 0);
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
onAskRestart();
|
|
576
|
+
},
|
|
577
|
+
children: restartMode === "relaunch" ? t("restarting") : t("restartNow")
|
|
578
|
+
}),
|
|
579
|
+
restartMode !== void 0 && panel !== "restart" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
580
|
+
className: plugin_manager_module_css_default.toolbarHint,
|
|
581
|
+
role: "status",
|
|
582
|
+
"data-update-restart-hint": restartMode,
|
|
583
|
+
children: restartMode === "shell" ? t("restartDesktopHint") : restartMode === "manual" ? t("restartManualHint") : t("restartRelaunchHint")
|
|
584
|
+
}),
|
|
585
|
+
panel === "list" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
586
|
+
className: plugin_manager_module_css_default.panel,
|
|
587
|
+
"data-update-panel": true,
|
|
588
|
+
role: "group",
|
|
589
|
+
"aria-label": t("updatesPanelTitle"),
|
|
590
|
+
children: [
|
|
591
|
+
errorLine,
|
|
592
|
+
applied.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
593
|
+
className: plugin_manager_module_css_default.ok,
|
|
594
|
+
"data-update-applied": true,
|
|
595
|
+
children: t("updateAllDone")
|
|
596
|
+
}),
|
|
597
|
+
rows.length === 0 && applied.length === 0 && error === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
598
|
+
className: plugin_manager_module_css_default.hint,
|
|
599
|
+
children: t("noUpdates")
|
|
600
|
+
}),
|
|
601
|
+
rows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
602
|
+
className: plugin_manager_module_css_default.panelList,
|
|
603
|
+
children: rows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
604
|
+
className: plugin_manager_module_css_default.panelRow,
|
|
605
|
+
"data-update-row": row.id,
|
|
606
|
+
"data-compatible": isUpdateApplicable(row) ? "yes" : "no",
|
|
607
|
+
children: [
|
|
608
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
609
|
+
className: plugin_manager_module_css_default.panelName,
|
|
610
|
+
children: row.id
|
|
611
|
+
}),
|
|
612
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
613
|
+
className: plugin_manager_module_css_default.panelVersion,
|
|
614
|
+
children: [
|
|
615
|
+
row.current,
|
|
616
|
+
" → ",
|
|
617
|
+
row.latest
|
|
618
|
+
]
|
|
619
|
+
}),
|
|
620
|
+
row.compatible === false && row.requiresDsh !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
621
|
+
className: plugin_manager_module_css_default.compatBlocked,
|
|
622
|
+
children: t("updateBlockedDsh", { min: displayMinimumVersion(row.requiresDsh) })
|
|
623
|
+
})
|
|
624
|
+
]
|
|
625
|
+
}, row.id))
|
|
626
|
+
}),
|
|
627
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
628
|
+
className: plugin_manager_module_css_default.panelActions,
|
|
629
|
+
children: [pending.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
630
|
+
type: "button",
|
|
631
|
+
className: `${plugin_manager_module_css_default.button} ${plugin_manager_module_css_default.primary}`,
|
|
632
|
+
"data-update-all": true,
|
|
633
|
+
disabled: busy,
|
|
634
|
+
onClick: onUpdateAll,
|
|
635
|
+
children: phase === "updating" ? t("updating") : t("updateAll", { count: String(pending.length) })
|
|
636
|
+
}), applied.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
637
|
+
type: "button",
|
|
638
|
+
className: `${plugin_manager_module_css_default.button} ${plugin_manager_module_css_default.primary}`,
|
|
639
|
+
"data-update-panel-restart": true,
|
|
640
|
+
disabled: busy,
|
|
641
|
+
onClick: onAskRestart,
|
|
642
|
+
children: t("restartNow")
|
|
643
|
+
})]
|
|
644
|
+
}),
|
|
645
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
646
|
+
className: plugin_manager_module_css_default.hint,
|
|
647
|
+
children: t("thirdPartyOnly")
|
|
648
|
+
})
|
|
649
|
+
]
|
|
650
|
+
}),
|
|
651
|
+
panel === "restart" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
652
|
+
className: plugin_manager_module_css_default.panel,
|
|
653
|
+
"data-update-restart-panel": true,
|
|
654
|
+
"data-restart-plan": plan,
|
|
655
|
+
role: "group",
|
|
656
|
+
"aria-label": t("restartNow"),
|
|
657
|
+
children: [
|
|
658
|
+
errorLine,
|
|
659
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
660
|
+
className: plugin_manager_module_css_default.hint,
|
|
661
|
+
"data-restart-plan-hint": plan,
|
|
662
|
+
children: plan === "shell" ? t("restartPlanShell") : plan === "manual" ? t("restartPlanManual") : t("restartPlanRelaunch")
|
|
663
|
+
}),
|
|
664
|
+
plan === "shell" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
665
|
+
className: plugin_manager_module_css_default.hint,
|
|
666
|
+
children: t("restartShellWarning")
|
|
667
|
+
}),
|
|
668
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
669
|
+
className: plugin_manager_module_css_default.panelActions,
|
|
670
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
671
|
+
type: "button",
|
|
672
|
+
className: plugin_manager_module_css_default.button,
|
|
673
|
+
"data-restart-cancel": true,
|
|
674
|
+
onClick: () => {
|
|
675
|
+
setPanel("none");
|
|
676
|
+
setPlan(void 0);
|
|
677
|
+
},
|
|
678
|
+
children: t("cancel")
|
|
679
|
+
}), plan !== "manual" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
680
|
+
type: "button",
|
|
681
|
+
className: `${plugin_manager_module_css_default.button} ${plugin_manager_module_css_default.primary}`,
|
|
682
|
+
"data-restart-confirm": true,
|
|
683
|
+
onClick: onRestart,
|
|
684
|
+
children: t("restartConfirm")
|
|
685
|
+
})]
|
|
686
|
+
})
|
|
687
|
+
]
|
|
688
|
+
})
|
|
689
|
+
]
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* The official page's "Installed" group heading, when it is mounted. Class
|
|
694
|
+
* names are CSS-module hashes in the official bundle, so the seat is found
|
|
695
|
+
* through the page's own data attributes plus DOM position.
|
|
696
|
+
* @returns the heading element to append into, or undefined off the list view.
|
|
697
|
+
*/
|
|
698
|
+
function toolbarSeat() {
|
|
699
|
+
const head = (document.querySelector("[data-plugin-panel]")?.querySelector("[data-plugin-group=\"bundles\"]"))?.firstElementChild;
|
|
700
|
+
return head instanceof HTMLElement ? head : void 0;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Mount the toolbar into the Installed heading.
|
|
704
|
+
* @param options - props factory and the optional locale subscription.
|
|
705
|
+
* @returns disposer removing the container, its observers and its React root.
|
|
706
|
+
*/
|
|
707
|
+
function mountPluginListToolbar(options) {
|
|
708
|
+
if (typeof document === "undefined") return () => {};
|
|
709
|
+
if (document.querySelector("[data-dsh-plugin-manager-toolbar]") !== null) return () => {};
|
|
710
|
+
const container = document.createElement("div");
|
|
711
|
+
container.setAttribute("data-dsh-plugin-manager-toolbar", "");
|
|
712
|
+
container.className = plugin_manager_module_css_default.mount;
|
|
713
|
+
const root = (0, react_dom_client.createRoot)(container);
|
|
714
|
+
const render = () => {
|
|
715
|
+
root.render((0, react.createElement)(PluginListToolbar, options.props()));
|
|
716
|
+
};
|
|
717
|
+
render();
|
|
718
|
+
/** Keep the container inside the heading; detach while the list is away. */
|
|
719
|
+
const place = () => {
|
|
720
|
+
const seat = toolbarSeat();
|
|
721
|
+
if (seat === void 0) {
|
|
722
|
+
container.remove();
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
if (container.parentElement !== seat) seat.append(container);
|
|
726
|
+
};
|
|
727
|
+
place();
|
|
728
|
+
const unsubscribeBody = subscribeBodyInvalidations(place);
|
|
729
|
+
const unsubscribeLocale = options.subscribe === void 0 ? (() => {}) : options.subscribe(render);
|
|
730
|
+
return () => {
|
|
731
|
+
unsubscribeBody();
|
|
732
|
+
unsubscribeLocale();
|
|
733
|
+
root.unmount();
|
|
734
|
+
container.remove();
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
//#endregion
|
|
247
738
|
//#region src/client/locales.ts
|
|
248
739
|
/**
|
|
249
740
|
* Locale dictionaries for the plugin-manager's official-page patch. The zh
|
|
250
741
|
* dictionary is the key source; the en dictionary mirrors the exact key set.
|
|
251
742
|
*
|
|
252
|
-
* The key set covers only what this package
|
|
253
|
-
*
|
|
743
|
+
* The key set covers only what this package renders: the check-for-updates
|
|
744
|
+
* block on a bundle's page in the official Plugins panel, and the list-level
|
|
745
|
+
* update toolbar mounted beside that panel's "Installed" heading.
|
|
254
746
|
* The former tab's keys (inventory, conflicts, repair seeds, safe mode,
|
|
255
747
|
* aggregate children) left with that tab.
|
|
256
748
|
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
@@ -267,6 +759,23 @@ window.__ModuleLoader__.load({
|
|
|
267
759
|
"updateRequiresDsh": "需要 DSH ≥ {min}",
|
|
268
760
|
"updateBlockedDsh": "需要 DSH ≥ {min},请先升级 DSH 再更新",
|
|
269
761
|
"restartHint": "插件变更将在重启应用后生效。",
|
|
762
|
+
"updatesAvailable": "{count} 个可更新",
|
|
763
|
+
"updateAll": "全部更新({count})",
|
|
764
|
+
"updatingAll": "更新 {name}({index}/{total})",
|
|
765
|
+
"updateAllDone": "更新完成,重启后生效。",
|
|
766
|
+
"updatesPanelTitle": "插件更新",
|
|
767
|
+
"thirdPartyOnly": "只检查第三方插件;官方 @deepseek-ai/ 包随 DSH 本体升级。",
|
|
768
|
+
"restartNow": "立即重启",
|
|
769
|
+
"restarting": "正在重启…",
|
|
770
|
+
"restartConfirm": "确认重启",
|
|
771
|
+
"restartPlanRelaunch": "会重启 DSH 服务,正在运行的任务会中断。",
|
|
772
|
+
"restartPlanShell": "桌面版通过系统对话框重启:确认后会弹出官方的「应用无法启动或已意外停止」对话框,请在对话框中点「重启」。",
|
|
773
|
+
"restartPlanManual": "当前进程无法自动重启,请手动重启 DSH。",
|
|
774
|
+
"restartShellWarning": "它同时会写一份崩溃报告;也可以手动重启:退出 DeepSeek Harness(⌘Q)后重新打开。",
|
|
775
|
+
"restartDesktopHint": "请在随后出现的系统对话框中选择「重启」。",
|
|
776
|
+
"restartRelaunchHint": "已请求重启;服务恢复后刷新页面即可。",
|
|
777
|
+
"restartManualHint": "当前进程无法自动重启,请手动重启 DSH。",
|
|
778
|
+
"cancel": "取消",
|
|
270
779
|
"failed": "操作失败:{reason}",
|
|
271
780
|
"fetching": "正在获取插件信息…",
|
|
272
781
|
"downloading": "正在下载…",
|
|
@@ -288,6 +797,23 @@ window.__ModuleLoader__.load({
|
|
|
288
797
|
"updateRequiresDsh": "Requires DSH >= {min}",
|
|
289
798
|
"updateBlockedDsh": "Requires DSH >= {min}; upgrade DSH before updating",
|
|
290
799
|
"restartHint": "Plugin changes take effect after restarting the application.",
|
|
800
|
+
"updatesAvailable": "{count} updates available",
|
|
801
|
+
"updateAll": "Update all ({count})",
|
|
802
|
+
"updatingAll": "Updating {name} ({index}/{total})",
|
|
803
|
+
"updateAllDone": "Updated; restart to take effect.",
|
|
804
|
+
"updatesPanelTitle": "Plugin updates",
|
|
805
|
+
"thirdPartyOnly": "Third-party plugins only; @deepseek-ai/ packages upgrade with DSH itself.",
|
|
806
|
+
"restartNow": "Restart now",
|
|
807
|
+
"restarting": "Restarting…",
|
|
808
|
+
"restartConfirm": "Restart",
|
|
809
|
+
"restartPlanRelaunch": "The DSH service restarts; running tasks are interrupted.",
|
|
810
|
+
"restartPlanShell": "The desktop app restarts through its system dialog: confirming shows the official \"DeepSeek Harness is unavailable\" dialog; click Restart in it.",
|
|
811
|
+
"restartPlanManual": "This process cannot restart itself; restart DSH yourself.",
|
|
812
|
+
"restartShellWarning": "It also writes a crash report. You can instead restart manually: quit DeepSeek Harness (Cmd+Q) and open it again.",
|
|
813
|
+
"restartDesktopHint": "Choose Restart in the system dialog that follows.",
|
|
814
|
+
"restartRelaunchHint": "Restart requested; reload the page once the server is back.",
|
|
815
|
+
"restartManualHint": "This process cannot restart itself; restart DSH yourself.",
|
|
816
|
+
"cancel": "Cancel",
|
|
291
817
|
"failed": "Operation failed: {reason}",
|
|
292
818
|
"fetching": "Fetching plugin metadata…",
|
|
293
819
|
"downloading": "Downloading…",
|
|
@@ -403,6 +929,17 @@ window.__ModuleLoader__.load({
|
|
|
403
929
|
});
|
|
404
930
|
}
|
|
405
931
|
/**
|
|
932
|
+
* Validate and normalize a `restart` response value.
|
|
933
|
+
* @param value - decoded but untrusted response value.
|
|
934
|
+
* @returns the mode the host actually used.
|
|
935
|
+
*/
|
|
936
|
+
function parseRestartMode(value) {
|
|
937
|
+
const restart = isRecord(value) ? value.restart : void 0;
|
|
938
|
+
const mode = isRecord(restart) ? restart.mode : void 0;
|
|
939
|
+
if (mode !== "relaunch" && mode !== "shell" && mode !== "manual") throw new Error("plugin-manager: response must contain a restart mode");
|
|
940
|
+
return mode;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
406
943
|
* Validate and normalize a `failures` response value.
|
|
407
944
|
* @param value - decoded but untrusted response value.
|
|
408
945
|
* @returns the typed failures snapshot.
|
|
@@ -437,7 +974,7 @@ window.__ModuleLoader__.load({
|
|
|
437
974
|
/** The building package's version, when the bundle carries it. */
|
|
438
975
|
function bakedVersion() {
|
|
439
976
|
try {
|
|
440
|
-
return "0.4.
|
|
977
|
+
return "0.4.5";
|
|
441
978
|
} catch {
|
|
442
979
|
return;
|
|
443
980
|
}
|
|
@@ -509,6 +1046,7 @@ window.__ModuleLoader__.load({
|
|
|
509
1046
|
const UNINSTALL_ENDPOINT = "uninstall";
|
|
510
1047
|
const SET_ENABLED_ENDPOINT = "set-enabled";
|
|
511
1048
|
const CHECK_UPDATES_ENDPOINT = "check-updates";
|
|
1049
|
+
const RESTART_ENDPOINT = "restart";
|
|
512
1050
|
const STATUS_ENDPOINT = "status";
|
|
513
1051
|
const FAILURES_ENDPOINT = "failures";
|
|
514
1052
|
const GATEWAY_PREFIX = "api/plugin-manager";
|
|
@@ -639,7 +1177,9 @@ window.__ModuleLoader__.load({
|
|
|
639
1177
|
kind: "idle",
|
|
640
1178
|
stage: "fetch"
|
|
641
1179
|
},
|
|
642
|
-
failures: async () => parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`))
|
|
1180
|
+
failures: async () => parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`)),
|
|
1181
|
+
restartPlan: async () => parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`)),
|
|
1182
|
+
restart: async () => parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`, { method: "POST" }))
|
|
643
1183
|
};
|
|
644
1184
|
let modePromise;
|
|
645
1185
|
const ensureMode = () => {
|
|
@@ -689,6 +1229,8 @@ window.__ModuleLoader__.load({
|
|
|
689
1229
|
return item;
|
|
690
1230
|
},
|
|
691
1231
|
checkUpdates: async () => await ensureMode() === "official" ? official.checkUpdates() : gateway.checkUpdates(),
|
|
1232
|
+
restartPlan: () => gateway.restartPlan(),
|
|
1233
|
+
restart: () => gateway.restart(),
|
|
692
1234
|
status: async () => await ensureMode() === "official" ? official.status() : gateway.status(),
|
|
693
1235
|
failures: async () => await ensureMode() === "official" ? official.failures() : gateway.failures(),
|
|
694
1236
|
onChange: (cb) => {
|
|
@@ -716,6 +1258,23 @@ window.__ModuleLoader__.load({
|
|
|
716
1258
|
try {
|
|
717
1259
|
if (!ctx.get("pluginManager")) ctx.provide(PLUGIN_MANAGER_SERVICE, face);
|
|
718
1260
|
} catch {}
|
|
1261
|
+
ctx.effect(() => {
|
|
1262
|
+
try {
|
|
1263
|
+
return mountPluginListToolbar({
|
|
1264
|
+
props: () => ({
|
|
1265
|
+
isLoopback: face.isLoopback,
|
|
1266
|
+
checkUpdates: face.checkUpdates,
|
|
1267
|
+
update: face.update,
|
|
1268
|
+
restartPlan: face.restartPlan,
|
|
1269
|
+
restart: face.restart,
|
|
1270
|
+
t: ctx.locale.bind(NS)
|
|
1271
|
+
}),
|
|
1272
|
+
subscribe: (listener) => ctx.locale.subscribe(listener)
|
|
1273
|
+
});
|
|
1274
|
+
} catch {
|
|
1275
|
+
return () => {};
|
|
1276
|
+
}
|
|
1277
|
+
}, "plugin-manager: update toolbar");
|
|
719
1278
|
ctx.slots.inject("plugins.detail.section", () => {
|
|
720
1279
|
try {
|
|
721
1280
|
return ctx.slots.register({
|