@linxin666/dsh-client-ui-plugin-manager 0.4.12 → 0.4.14
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 +6 -2
- package/README.zh.md +6 -2
- package/cordis.patch.yml +9 -0
- package/lib/client.js +825 -16
- package/lib/client.js.map +1 -1
- package/lib/index.js +686 -138
- package/lib/types/client/BuiltinPlugins.d.ts +41 -0
- package/lib/types/client/PluginListToolbar.d.ts +5 -4
- package/lib/types/client/builtin-plugins-mount.d.ts +42 -0
- package/lib/types/client/index.d.ts +10 -8
- package/lib/types/client/locales.d.ts +93 -0
- package/lib/types/client/native-faces.d.ts +61 -0
- package/lib/types/core/builtin.d.ts +178 -0
- package/lib/types/core/protocol.d.ts +33 -4
- package/lib/types/host/bundle-guard.d.ts +12 -1
- package/lib/types/host/gateway.d.ts +189 -2
- package/lib/types/host/legacy-migration.d.ts +2 -2
- package/lib/types/host/restart.d.ts +96 -4
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +5 -2
package/lib/client.js
CHANGED
|
@@ -7,6 +7,7 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let react_dom_client = require("react-dom/client");
|
|
10
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
10
11
|
//#region src/core/version.ts
|
|
11
12
|
const MINIMUM_RANGE_PATTERN = /^>=\s*(v?\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/;
|
|
12
13
|
/**
|
|
@@ -25,7 +26,7 @@ window.__ModuleLoader__.load({
|
|
|
25
26
|
}
|
|
26
27
|
//#endregion
|
|
27
28
|
//#region \0dsh-css:packages/dsh-plugin-manager/src/client/plugin-manager.module.css.mjs
|
|
28
|
-
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);
|
|
29
|
+
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{transform-origin:0;width:100%;height:100%;transform:scaleX(var(--plugin-manager-progress,0));background:var(--dsw-alias-state-business-primary);transition:transform .2s}.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:1.2s ease-in-out infinite ZsMDKq_pluginManagerIndeterminate;transform:none}@keyframes ZsMDKq_pluginManagerIndeterminate{0%{transform:translate(-100%)}to{transform:translate(250%)}}@media (prefers-reduced-motion:reduce){.ZsMDKq_progressBar{transition:none}.ZsMDKq_progressBar[data-indeterminate=true]{width:40%;animation:none;transform: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}.ZsMDKq_restartRequired{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.ZsMDKq_restartRequiredLine{color:var(--dsw-alias-label-secondary);font-size:12px}.ZsMDKq_builtinMount{min-width:0}.ZsMDKq_builtinGroup{min-width:0;color:var(--dsw-alias-label-primary);flex-direction:column;gap:8px;display:flex}.ZsMDKq_builtinHead{align-items:center;gap:8px;min-width:0;display:flex}.ZsMDKq_builtinTitle{min-width:0;margin:0;font-size:14px;font-weight:500;line-height:22px}.ZsMDKq_builtinCount{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;flex:none;font-size:12px;line-height:18px}.ZsMDKq_builtinScope{font:inherit;cursor:pointer;color:var(--dsw-alias-label-secondary);background:0 0;border:0;flex:none;margin-inline-start:auto;padding:3px 2px;font-size:12px;line-height:18px}.ZsMDKq_builtinScope:hover{color:var(--dsw-alias-label-primary)}.ZsMDKq_builtinScope: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_builtinList{flex-direction:column;gap:2px;margin:0;padding:0;list-style:none;display:flex}.ZsMDKq_builtinRow{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:flex-start;gap:12px;min-width:0;padding:12px 2px;display:flex}.ZsMDKq_builtinRow:last-child{border-bottom:0}.ZsMDKq_builtinMain{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.ZsMDKq_builtinName{overflow-wrap:anywhere;font-size:13px;line-height:20px}.ZsMDKq_builtinModule{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;font-size:12px;line-height:18px}.ZsMDKq_builtinOwner{color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;font-size:12px;line-height:18px}.ZsMDKq_builtinReason{color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;font-size:12px;line-height:18px}.ZsMDKq_presetGroup{border-top:.5px solid var(--dsw-alias-border-l2);flex-direction:column;gap:6px;min-width:0;padding-top:12px;display:flex}.ZsMDKq_presetTitle{margin:0;font-size:13px;font-weight:500;line-height:20px}.ZsMDKq_presetList{flex-direction:column;gap:6px;margin:0;padding:0;list-style:none;display:flex}.ZsMDKq_presetCard{flex-direction:column;gap:2px;min-width:0;display:flex}.ZsMDKq_presetHead{align-items:baseline;gap:6px;min-width:0;display:flex}.ZsMDKq_presetName{overflow-wrap:anywhere;font-size:13px;line-height:20px}.ZsMDKq_presetTag{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.ZsMDKq_presetRows{flex-direction:column;gap:2px;margin:0;padding:0 0 0 12px;list-style:none;display:flex}.ZsMDKq_presetRow{align-items:baseline;gap:8px;min-width:0;font-size:12px;line-height:18px;display:flex}.ZsMDKq_presetRowName{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}.ZsMDKq_presetRowState{color:var(--dsw-alias-label-tertiary);flex:none}";
|
|
29
30
|
const tagId = "@linxin666/dsh-client-ui-plugin-manager/packages/dsh-plugin-manager/src/client/plugin-manager.module.css";
|
|
30
31
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
31
32
|
const tag = document.createElement("style");
|
|
@@ -36,6 +37,19 @@ window.__ModuleLoader__.load({
|
|
|
36
37
|
}
|
|
37
38
|
var plugin_manager_module_css_default = {
|
|
38
39
|
"actionRow": "ZsMDKq_actionRow",
|
|
40
|
+
"builtinCount": "ZsMDKq_builtinCount",
|
|
41
|
+
"builtinGroup": "ZsMDKq_builtinGroup",
|
|
42
|
+
"builtinHead": "ZsMDKq_builtinHead",
|
|
43
|
+
"builtinList": "ZsMDKq_builtinList",
|
|
44
|
+
"builtinMain": "ZsMDKq_builtinMain",
|
|
45
|
+
"builtinModule": "ZsMDKq_builtinModule",
|
|
46
|
+
"builtinMount": "ZsMDKq_builtinMount",
|
|
47
|
+
"builtinName": "ZsMDKq_builtinName",
|
|
48
|
+
"builtinOwner": "ZsMDKq_builtinOwner",
|
|
49
|
+
"builtinReason": "ZsMDKq_builtinReason",
|
|
50
|
+
"builtinRow": "ZsMDKq_builtinRow",
|
|
51
|
+
"builtinScope": "ZsMDKq_builtinScope",
|
|
52
|
+
"builtinTitle": "ZsMDKq_builtinTitle",
|
|
39
53
|
"button": "ZsMDKq_button",
|
|
40
54
|
"compatBlocked": "ZsMDKq_compatBlocked",
|
|
41
55
|
"compatHint": "ZsMDKq_compatHint",
|
|
@@ -52,6 +66,17 @@ window.__ModuleLoader__.load({
|
|
|
52
66
|
"panelRow": "ZsMDKq_panelRow",
|
|
53
67
|
"panelVersion": "ZsMDKq_panelVersion",
|
|
54
68
|
"pluginManagerIndeterminate": "ZsMDKq_pluginManagerIndeterminate",
|
|
69
|
+
"presetCard": "ZsMDKq_presetCard",
|
|
70
|
+
"presetGroup": "ZsMDKq_presetGroup",
|
|
71
|
+
"presetHead": "ZsMDKq_presetHead",
|
|
72
|
+
"presetList": "ZsMDKq_presetList",
|
|
73
|
+
"presetName": "ZsMDKq_presetName",
|
|
74
|
+
"presetRow": "ZsMDKq_presetRow",
|
|
75
|
+
"presetRowName": "ZsMDKq_presetRowName",
|
|
76
|
+
"presetRowState": "ZsMDKq_presetRowState",
|
|
77
|
+
"presetRows": "ZsMDKq_presetRows",
|
|
78
|
+
"presetTag": "ZsMDKq_presetTag",
|
|
79
|
+
"presetTitle": "ZsMDKq_presetTitle",
|
|
55
80
|
"primary": "ZsMDKq_primary",
|
|
56
81
|
"progressBar": "ZsMDKq_progressBar",
|
|
57
82
|
"progressRow": "ZsMDKq_progressRow",
|
|
@@ -88,6 +113,12 @@ window.__ModuleLoader__.load({
|
|
|
88
113
|
* official primitives bundle.
|
|
89
114
|
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
90
115
|
*/
|
|
116
|
+
/**
|
|
117
|
+
* The custom property carrying the determinate fraction (0 to 1). The bar is a
|
|
118
|
+
* full-width element the stylesheet scales along its own axis, so a progress
|
|
119
|
+
* tick repaints one compositor property instead of re-laying-out the row.
|
|
120
|
+
*/
|
|
121
|
+
const PROGRESS_VARIABLE = "--plugin-manager-progress";
|
|
91
122
|
/** Error text for a caught request or lifecycle failure. */
|
|
92
123
|
function messageOf$1(error) {
|
|
93
124
|
if (error instanceof AggregateError) {
|
|
@@ -254,8 +285,9 @@ window.__ModuleLoader__.load({
|
|
|
254
285
|
className: plugin_manager_module_css_default.progressTrack,
|
|
255
286
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
256
287
|
className: plugin_manager_module_css_default.progressBar,
|
|
257
|
-
style: progress.percent === void 0 ? void 0 : {
|
|
258
|
-
"data-indeterminate": progress.percent === void 0 ? "true" : void 0
|
|
288
|
+
style: progress.percent === void 0 ? void 0 : { [PROGRESS_VARIABLE]: String(progress.percent / 100) },
|
|
289
|
+
"data-indeterminate": progress.percent === void 0 ? "true" : void 0,
|
|
290
|
+
"data-update-progress": progress.percent === void 0 ? "indeterminate" : "determinate"
|
|
259
291
|
})
|
|
260
292
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
261
293
|
className: plugin_manager_module_css_default.hint,
|
|
@@ -368,6 +400,638 @@ window.__ModuleLoader__.load({
|
|
|
368
400
|
};
|
|
369
401
|
}
|
|
370
402
|
//#endregion
|
|
403
|
+
//#region src/core/builtin.ts
|
|
404
|
+
/**
|
|
405
|
+
* Select the built-in group's two scopes in one pass: every Loader entry, the
|
|
406
|
+
* ones no installed bundle contributes, and which bundle contributes the rest.
|
|
407
|
+
*
|
|
408
|
+
* The default scope is the subtraction the group shipped with; the wider scope is
|
|
409
|
+
* the same rows plus the ones a bundle's patch inserts, each named after that
|
|
410
|
+
* bundle — the reason a reader meets them again on the bundle's own page.
|
|
411
|
+
* @param inventory - the Loader snapshot.
|
|
412
|
+
* @param bundles - every installed bundle, or undefined when `listBundles()`
|
|
413
|
+
* failed; both scopes then list every entry and the group says so.
|
|
414
|
+
* @param plugins - the manager's plugin rows, or undefined when that read
|
|
415
|
+
* failed; an unread row is reported as `unknown` rather than guessed writable.
|
|
416
|
+
* @returns both scopes, the ownership map behind them, and the roster state.
|
|
417
|
+
*/
|
|
418
|
+
function selectBuiltinEntries(inventory, bundles, plugins) {
|
|
419
|
+
const owners = /* @__PURE__ */ new Map();
|
|
420
|
+
for (const bundle of bundles ?? []) {
|
|
421
|
+
if (bundle.installed === false) continue;
|
|
422
|
+
for (const row of bundle.rows ?? []) if (row.entryId !== void 0 && !owners.has(row.entryId)) owners.set(row.entryId, bundle.name ?? "");
|
|
423
|
+
}
|
|
424
|
+
const writability = /* @__PURE__ */ new Map();
|
|
425
|
+
for (const plugin of plugins ?? []) writability.set(plugin.entryId, plugin.readOnlyReason ?? "writable");
|
|
426
|
+
const allRows = inventory.entries.map((entry) => {
|
|
427
|
+
const shared = {
|
|
428
|
+
entryId: entry.entryId,
|
|
429
|
+
moduleName: entry.moduleName,
|
|
430
|
+
meta: entry.meta,
|
|
431
|
+
enabled: entry.enabled,
|
|
432
|
+
write: writability.get(entry.entryId) ?? "unknown"
|
|
433
|
+
};
|
|
434
|
+
const ownedBy = owners.get(entry.entryId);
|
|
435
|
+
return ownedBy === void 0 ? shared : {
|
|
436
|
+
...shared,
|
|
437
|
+
ownedBy
|
|
438
|
+
};
|
|
439
|
+
});
|
|
440
|
+
return {
|
|
441
|
+
rows: allRows.filter((row) => row.ownedBy === void 0),
|
|
442
|
+
allRows,
|
|
443
|
+
owners,
|
|
444
|
+
bundles: bundles === void 0 ? "unconfirmed" : "confirmed"
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Read one `remote.<namespace>` answer.
|
|
449
|
+
*
|
|
450
|
+
* The API gateway wraps every namespace result as `{ ok, value | error }`, and a
|
|
451
|
+
* carrier that hands the bare value back must not be mistaken for a failure —
|
|
452
|
+
* so an object is treated as an envelope only when its `ok` really is a boolean,
|
|
453
|
+
* and anything else passes through as the value itself.
|
|
454
|
+
* @param raw - the resolved answer, exactly as the namespace returned it.
|
|
455
|
+
* @returns the unwrapped value, or the envelope's error code.
|
|
456
|
+
*/
|
|
457
|
+
function readRemoteAnswer(raw) {
|
|
458
|
+
if (typeof raw === "object" && raw !== null && typeof raw.ok === "boolean") {
|
|
459
|
+
const envelope = raw;
|
|
460
|
+
if (envelope.ok) return {
|
|
461
|
+
ok: true,
|
|
462
|
+
value: envelope.value
|
|
463
|
+
};
|
|
464
|
+
return {
|
|
465
|
+
ok: false,
|
|
466
|
+
code: envelope.error?.code
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
ok: true,
|
|
471
|
+
value: raw
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Read one `setPluginEnabled` answer.
|
|
476
|
+
*
|
|
477
|
+
* The official manager folds a refusal into the resolved result
|
|
478
|
+
* (`application: 'failed'` with an `error.code`) instead of rejecting, so a
|
|
479
|
+
* resolved promise is not a success. Both answer shapes are accepted because
|
|
480
|
+
* the gateway's envelope and the bare `ChangeResult` are the same call seen
|
|
481
|
+
* through two carriers.
|
|
482
|
+
* @param raw - the resolved answer.
|
|
483
|
+
* @returns the outcome the switch should show.
|
|
484
|
+
*/
|
|
485
|
+
function readChangeResult(raw) {
|
|
486
|
+
const answer = readRemoteAnswer(raw);
|
|
487
|
+
if (!answer.ok) return {
|
|
488
|
+
ok: false,
|
|
489
|
+
code: answer.code ?? "operation-error"
|
|
490
|
+
};
|
|
491
|
+
const result = answer.value;
|
|
492
|
+
const application = result?.application;
|
|
493
|
+
if (application === void 0) return {
|
|
494
|
+
ok: false,
|
|
495
|
+
code: "operation-error"
|
|
496
|
+
};
|
|
497
|
+
if (application === "failed" || application === "cancelled") return {
|
|
498
|
+
ok: false,
|
|
499
|
+
code: result.error?.code ?? application
|
|
500
|
+
};
|
|
501
|
+
return {
|
|
502
|
+
ok: true,
|
|
503
|
+
application,
|
|
504
|
+
restartReason: result.restartReason
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/client/BuiltinPlugins.tsx
|
|
509
|
+
/**
|
|
510
|
+
* The "Built-in plugins" group at the bottom of the official Plugins page.
|
|
511
|
+
*
|
|
512
|
+
* By default it lists every global Loader entry no installed bundle contributes —
|
|
513
|
+
* the rows a profile patch inserts itself (the Computer Use pair among them) and
|
|
514
|
+
* the rows the host ships globally — each with the official manager's own switch,
|
|
515
|
+
* so a row is enabled or disabled by exactly the call the official page makes.
|
|
516
|
+
* One control widens that list to every Loader entry and names, on each row a
|
|
517
|
+
* bundle adds, the bundle that adds it: those rows are the ones a reader also
|
|
518
|
+
* meets on that bundle's own page, and the answer to "why is this here twice" is
|
|
519
|
+
* that sentence. Below it, the agent preset compositions the same inventory
|
|
520
|
+
* reports are rendered read-only: a preset's rows are composed per session and
|
|
521
|
+
* only a Loader context can decide a `!!js` condition, so nothing here offers
|
|
522
|
+
* them a switch.
|
|
523
|
+
*
|
|
524
|
+
* Every state shown is the Loader's own: after an accepted write the group
|
|
525
|
+
* re-reads instead of trusting the answer, a refusal is named by the code the
|
|
526
|
+
* manager returned, and a locked row says which lock it is.
|
|
527
|
+
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
528
|
+
*/
|
|
529
|
+
/** Which refusal code reads as which sentence. */
|
|
530
|
+
const REFUSAL_KEYS = {
|
|
531
|
+
"management-required": "builtinReasonManagementRequired",
|
|
532
|
+
"unaddressable": "builtinReasonUnaddressable"
|
|
533
|
+
};
|
|
534
|
+
/** Which restart reason reads as which sentence. */
|
|
535
|
+
const RESTART_KEYS = {
|
|
536
|
+
"no-hmr": "builtinRestartNoHmr",
|
|
537
|
+
"package-moved": "builtinRestartPackageMoved",
|
|
538
|
+
"host-module": "builtinRestartHostModule",
|
|
539
|
+
"unmanaged-plugin": "builtinRestartUnmanagedPlugin",
|
|
540
|
+
"module-comparison": "builtinRestartModuleComparison"
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* The one reason a failure this component could not name may show: the manager's
|
|
544
|
+
* own generic code. A caught exception keeps its message out of the interface —
|
|
545
|
+
* a host diagnostic can carry an absolute path — and is logged instead.
|
|
546
|
+
*/
|
|
547
|
+
const FALLBACK_CODE = "operation-error";
|
|
548
|
+
/** Log one caught failure where a developer can read it, naming what failed. */
|
|
549
|
+
function warnFailure(what, error) {
|
|
550
|
+
console.warn(`plugin-manager: ${what}`, error);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* What one refusal code reads as. A code this package has no sentence for is
|
|
554
|
+
* shown as the code itself: the manager named it, and a guessed sentence would
|
|
555
|
+
* be worse than the name it gave.
|
|
556
|
+
*/
|
|
557
|
+
function refusalText(code, t) {
|
|
558
|
+
const key = REFUSAL_KEYS[code];
|
|
559
|
+
return key === void 0 ? code : t(key);
|
|
560
|
+
}
|
|
561
|
+
/** Why a row's switch is locked, in the reader's language. */
|
|
562
|
+
function writeReason(write, t) {
|
|
563
|
+
if (write === "writable") return "";
|
|
564
|
+
if (write === "unknown") return t("builtinReasonUnknown");
|
|
565
|
+
return refusalText(write, t);
|
|
566
|
+
}
|
|
567
|
+
/** Why a write needs a restart, in the reader's language. */
|
|
568
|
+
function restartReason(reason, t) {
|
|
569
|
+
if (reason === void 0) return t("builtinRestartUnnamed");
|
|
570
|
+
const key = RESTART_KEYS[reason];
|
|
571
|
+
return key === void 0 ? t("builtinRestartUnnamed") : t(key);
|
|
572
|
+
}
|
|
573
|
+
/** One row's display title, falling back to the module it names. */
|
|
574
|
+
function rowTitle(row, resolveText) {
|
|
575
|
+
const title = row.meta?.title;
|
|
576
|
+
if (title === void 0) return row.moduleName;
|
|
577
|
+
const resolved = resolveText(title);
|
|
578
|
+
return resolved === "" ? row.moduleName : resolved;
|
|
579
|
+
}
|
|
580
|
+
/** One preset row's state, as the composition reports it. */
|
|
581
|
+
function presetRowState(row) {
|
|
582
|
+
if (row.enabled === "conditional") return "conditional";
|
|
583
|
+
return row.enabled ? "on" : "off";
|
|
584
|
+
}
|
|
585
|
+
/** One preset row's state text; a conditional row names its own expression. */
|
|
586
|
+
function presetRowText(row, t) {
|
|
587
|
+
if (row.enabled === "conditional") return row.condition === void 0 ? t("presetRowConditionalUnnamed") : t("presetRowConditional", { condition: row.condition });
|
|
588
|
+
return row.enabled ? t("presetRowOn") : t("presetRowOff");
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Read one manager list, treating a refused or failed read as unknown. A row
|
|
592
|
+
* whose writability could not be read is shown locked, never writable.
|
|
593
|
+
*/
|
|
594
|
+
async function readList(read) {
|
|
595
|
+
try {
|
|
596
|
+
const answer = readRemoteAnswer(await read());
|
|
597
|
+
if (!answer.ok) return void 0;
|
|
598
|
+
return Array.isArray(answer.value) ? answer.value : void 0;
|
|
599
|
+
} catch (error) {
|
|
600
|
+
warnFailure("built-in group list read failed", error);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Whether an inventory answer is really a snapshot. The namespace hands back
|
|
606
|
+
* `entries`; anything else — a bare null, an envelope with no value, a value
|
|
607
|
+
* whose entries is not a list — is a failure this group reports rather than one
|
|
608
|
+
* it walks into.
|
|
609
|
+
*/
|
|
610
|
+
function isInventory(value) {
|
|
611
|
+
return typeof value === "object" && value !== null && Array.isArray(value.entries);
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Read the whole group: the Loader snapshot, then the two manager lists that
|
|
615
|
+
* decide which entries are built-in and which of them can be written.
|
|
616
|
+
* @param remote - the sampled official faces.
|
|
617
|
+
* @returns the group's state; a read this deployment cannot serve stays a state,
|
|
618
|
+
* never an exception.
|
|
619
|
+
*/
|
|
620
|
+
async function readGroup(remote) {
|
|
621
|
+
const inventoryFace = remote.inventory;
|
|
622
|
+
if (inventoryFace === null) return { kind: "unavailable" };
|
|
623
|
+
try {
|
|
624
|
+
const answer = readRemoteAnswer(await inventoryFace.list());
|
|
625
|
+
if (!answer.ok) return {
|
|
626
|
+
kind: "failed",
|
|
627
|
+
code: answer.code ?? FALLBACK_CODE
|
|
628
|
+
};
|
|
629
|
+
if (!isInventory(answer.value)) return {
|
|
630
|
+
kind: "failed",
|
|
631
|
+
code: FALLBACK_CODE
|
|
632
|
+
};
|
|
633
|
+
const inventory = answer.value;
|
|
634
|
+
const manager = remote.manager;
|
|
635
|
+
const [plugins, bundles] = await Promise.all([manager === null ? Promise.resolve(void 0) : readList(() => manager.listPlugins()), manager === null ? Promise.resolve(void 0) : readList(() => manager.listBundles())]);
|
|
636
|
+
const selection = selectBuiltinEntries(inventory, bundles, plugins);
|
|
637
|
+
return {
|
|
638
|
+
kind: "ready",
|
|
639
|
+
rows: selection.rows,
|
|
640
|
+
allRows: selection.allRows,
|
|
641
|
+
bundles: selection.bundles,
|
|
642
|
+
presets: Array.isArray(inventory.agentPresets) ? inventory.agentPresets : []
|
|
643
|
+
};
|
|
644
|
+
} catch (error) {
|
|
645
|
+
warnFailure("built-in group read failed", error);
|
|
646
|
+
return {
|
|
647
|
+
kind: "failed",
|
|
648
|
+
code: FALLBACK_CODE
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* The group itself. All state is local: the page around it owns the plugin list,
|
|
654
|
+
* and the Loader is the only truth this component reports.
|
|
655
|
+
*/
|
|
656
|
+
function BuiltinPlugins(props) {
|
|
657
|
+
const { t, remote, resolveText } = props;
|
|
658
|
+
const [state, setState] = (0, react.useState)({ kind: "loading" });
|
|
659
|
+
/** Bumped after an accepted write, so the group reads the Loader again. */
|
|
660
|
+
const [reload, setReload] = (0, react.useState)(0);
|
|
661
|
+
/** The one write in flight, mirrored into the switches before the re-read. */
|
|
662
|
+
const [pending, setPending] = (0, react.useState)(void 0);
|
|
663
|
+
/** Synchronous in-flight mirror: two clicks can land in one frame. */
|
|
664
|
+
const writingRef = (0, react.useRef)(false);
|
|
665
|
+
const [notice, setNotice] = (0, react.useState)(void 0);
|
|
666
|
+
(0, react.useEffect)(() => {
|
|
667
|
+
let live = true;
|
|
668
|
+
readGroup(remote).then((next) => {
|
|
669
|
+
if (live) setState(next);
|
|
670
|
+
});
|
|
671
|
+
return () => {
|
|
672
|
+
live = false;
|
|
673
|
+
};
|
|
674
|
+
}, [remote, reload]);
|
|
675
|
+
/**
|
|
676
|
+
* Which scope the list shows. Switching it only picks between the two sets the
|
|
677
|
+
* last read already answered with: it never reads again and never touches a
|
|
678
|
+
* row's enablement, so a reader can widen the list without the Loader moving.
|
|
679
|
+
*/
|
|
680
|
+
const [scope, setScope] = (0, react.useState)("default");
|
|
681
|
+
const listId = (0, react.useId)();
|
|
682
|
+
const ready = state.kind === "ready" ? state : void 0;
|
|
683
|
+
const rows = ready === void 0 ? [] : scope === "all" ? ready.allRows : ready.rows;
|
|
684
|
+
/** Rows the default scope leaves out: what the scope control would add. */
|
|
685
|
+
const ownedCount = ready === void 0 ? 0 : ready.allRows.length - ready.rows.length;
|
|
686
|
+
const presets = ready === void 0 ? [] : ready.presets;
|
|
687
|
+
/**
|
|
688
|
+
* The visible label of each row: its name, and the line under it — the module, or
|
|
689
|
+
* the entry id when the name already is that module. Two rows carrying the same
|
|
690
|
+
* pair read identically, which is the only case where the row has to say which
|
|
691
|
+
* entry it is; a title two rows share is exactly that case, and so is a module
|
|
692
|
+
* several rows name. Counted over the list on screen, so each scope answers for
|
|
693
|
+
* itself and switching scope neither reads nor writes anything.
|
|
694
|
+
*/
|
|
695
|
+
const labels = /* @__PURE__ */ new Map();
|
|
696
|
+
const labelCounts = /* @__PURE__ */ new Map();
|
|
697
|
+
for (const row of rows) {
|
|
698
|
+
const title = rowTitle(row, resolveText);
|
|
699
|
+
const label = `${title}\u0000${title === row.moduleName ? row.entryId : row.moduleName}`;
|
|
700
|
+
labels.set(row.entryId, label);
|
|
701
|
+
labelCounts.set(label, (labelCounts.get(label) ?? 0) + 1);
|
|
702
|
+
}
|
|
703
|
+
/** Whether this row's visible labels are shared with another row on screen. */
|
|
704
|
+
const collides = (entryId) => (labelCounts.get(labels.get(entryId) ?? "") ?? 0) > 1;
|
|
705
|
+
/**
|
|
706
|
+
* Ask the official manager to enable or disable one row, then re-read. The
|
|
707
|
+
* switch moves first and comes back on a refusal, so what it shows afterwards
|
|
708
|
+
* is the answer this deployment gave rather than the click that produced it.
|
|
709
|
+
*/
|
|
710
|
+
const toggle = (row, next) => {
|
|
711
|
+
const manager = remote.manager;
|
|
712
|
+
if (manager === null || row.write !== "writable" || writingRef.current) return;
|
|
713
|
+
writingRef.current = true;
|
|
714
|
+
setPending({
|
|
715
|
+
entryId: row.entryId,
|
|
716
|
+
enabled: next
|
|
717
|
+
});
|
|
718
|
+
setNotice(void 0);
|
|
719
|
+
(async () => {
|
|
720
|
+
let outcome;
|
|
721
|
+
try {
|
|
722
|
+
outcome = readChangeResult(await manager.setPluginEnabled(row.entryId, next));
|
|
723
|
+
} catch (error) {
|
|
724
|
+
warnFailure("built-in group write failed", error);
|
|
725
|
+
outcome = {
|
|
726
|
+
ok: false,
|
|
727
|
+
code: FALLBACK_CODE
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
writingRef.current = false;
|
|
731
|
+
setPending(void 0);
|
|
732
|
+
if (!outcome.ok) {
|
|
733
|
+
setNotice({
|
|
734
|
+
tone: "error",
|
|
735
|
+
text: t(next ? "builtinFailedEnable" : "builtinFailedDisable", { reason: refusalText(outcome.code, t) })
|
|
736
|
+
});
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
setNotice(outcome.application === "restart-required" ? {
|
|
740
|
+
tone: "note",
|
|
741
|
+
text: t("builtinRestartRequired", { reason: restartReason(outcome.restartReason, t) })
|
|
742
|
+
} : outcome.application === "overridden" ? {
|
|
743
|
+
tone: "note",
|
|
744
|
+
text: t("builtinOverridden", { name: rowTitle(row, resolveText) })
|
|
745
|
+
} : void 0);
|
|
746
|
+
setReload((token) => token + 1);
|
|
747
|
+
})();
|
|
748
|
+
};
|
|
749
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
750
|
+
className: plugin_manager_module_css_default.builtinGroup,
|
|
751
|
+
"data-dsh-plugin": "plugin-manager",
|
|
752
|
+
"data-dsh-part": "builtin-group",
|
|
753
|
+
"data-builtin-state": state.kind,
|
|
754
|
+
"data-builtin-bundles": state.kind === "ready" ? state.bundles : void 0,
|
|
755
|
+
"data-builtin-scope": scope,
|
|
756
|
+
"aria-busy": state.kind === "loading",
|
|
757
|
+
children: [
|
|
758
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
759
|
+
className: plugin_manager_module_css_default.builtinHead,
|
|
760
|
+
children: [
|
|
761
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
762
|
+
className: plugin_manager_module_css_default.builtinTitle,
|
|
763
|
+
children: t("builtinGroup")
|
|
764
|
+
}),
|
|
765
|
+
ready !== void 0 && ready.bundles === "confirmed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
766
|
+
className: plugin_manager_module_css_default.builtinCount,
|
|
767
|
+
"data-builtin-count": rows.length,
|
|
768
|
+
children: rows.length
|
|
769
|
+
}),
|
|
770
|
+
ownedCount > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
771
|
+
type: "button",
|
|
772
|
+
className: plugin_manager_module_css_default.builtinScope,
|
|
773
|
+
"data-dsh-part": "builtin-scope",
|
|
774
|
+
"aria-expanded": scope === "all",
|
|
775
|
+
"aria-controls": listId,
|
|
776
|
+
onClick: () => {
|
|
777
|
+
setScope(scope === "all" ? "default" : "all");
|
|
778
|
+
},
|
|
779
|
+
children: t(scope === "all" ? "builtinScopeCollapse" : "builtinScopeExpand", { count: String(ownedCount) })
|
|
780
|
+
})
|
|
781
|
+
]
|
|
782
|
+
}),
|
|
783
|
+
state.kind === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
784
|
+
className: plugin_manager_module_css_default.hint,
|
|
785
|
+
role: "status",
|
|
786
|
+
children: t("builtinReading")
|
|
787
|
+
}),
|
|
788
|
+
state.kind === "unavailable" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
789
|
+
className: plugin_manager_module_css_default.hint,
|
|
790
|
+
children: t("builtinUnavailable")
|
|
791
|
+
}),
|
|
792
|
+
state.kind === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
793
|
+
className: plugin_manager_module_css_default.error,
|
|
794
|
+
role: "alert",
|
|
795
|
+
children: t("builtinFailed", { reason: state.code })
|
|
796
|
+
}),
|
|
797
|
+
state.kind === "ready" && state.bundles === "unconfirmed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
798
|
+
className: plugin_manager_module_css_default.hint,
|
|
799
|
+
"data-builtin-unconfirmed": true,
|
|
800
|
+
children: t("builtinUnconfirmed")
|
|
801
|
+
}),
|
|
802
|
+
notice !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
803
|
+
className: notice.tone === "error" ? plugin_manager_module_css_default.error : plugin_manager_module_css_default.hint,
|
|
804
|
+
role: notice.tone === "error" ? "alert" : "status",
|
|
805
|
+
"data-dsh-part": "builtin-notice",
|
|
806
|
+
"data-notice-tone": notice.tone,
|
|
807
|
+
children: notice.text
|
|
808
|
+
}),
|
|
809
|
+
ready !== void 0 && rows.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
810
|
+
className: plugin_manager_module_css_default.hint,
|
|
811
|
+
children: t("builtinEmpty")
|
|
812
|
+
}),
|
|
813
|
+
rows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
814
|
+
className: plugin_manager_module_css_default.builtinList,
|
|
815
|
+
id: listId,
|
|
816
|
+
children: rows.map((row) => {
|
|
817
|
+
const title = rowTitle(row, resolveText);
|
|
818
|
+
const reason = writeReason(row.write, t);
|
|
819
|
+
const locked = row.write !== "writable";
|
|
820
|
+
const checked = pending?.entryId === row.entryId ? pending.enabled : row.enabled;
|
|
821
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
822
|
+
className: plugin_manager_module_css_default.builtinRow,
|
|
823
|
+
"data-dsh-part": "builtin-row",
|
|
824
|
+
"data-entry-id": row.entryId,
|
|
825
|
+
"data-write": row.write,
|
|
826
|
+
"data-owned-by": row.ownedBy,
|
|
827
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
828
|
+
className: plugin_manager_module_css_default.builtinMain,
|
|
829
|
+
children: [
|
|
830
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
831
|
+
className: plugin_manager_module_css_default.builtinName,
|
|
832
|
+
children: title
|
|
833
|
+
}),
|
|
834
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
835
|
+
className: plugin_manager_module_css_default.builtinModule,
|
|
836
|
+
children: title === row.moduleName ? row.entryId : row.moduleName
|
|
837
|
+
}),
|
|
838
|
+
collides(row.entryId) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
839
|
+
className: plugin_manager_module_css_default.builtinModule,
|
|
840
|
+
"data-entry-revealed": row.entryId,
|
|
841
|
+
children: row.entryId
|
|
842
|
+
}),
|
|
843
|
+
row.ownedBy !== void 0 && row.ownedBy !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
844
|
+
className: plugin_manager_module_css_default.builtinOwner,
|
|
845
|
+
"data-dsh-part": "builtin-owner",
|
|
846
|
+
children: t("builtinOwnedBy", { name: row.ownedBy })
|
|
847
|
+
}),
|
|
848
|
+
locked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
849
|
+
className: plugin_manager_module_css_default.builtinReason,
|
|
850
|
+
children: reason
|
|
851
|
+
})
|
|
852
|
+
]
|
|
853
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
|
|
854
|
+
checked,
|
|
855
|
+
label: t("builtinToggle", { name: title }),
|
|
856
|
+
disabled: locked || pending !== void 0 || remote.manager === null,
|
|
857
|
+
...locked ? { title: reason } : {},
|
|
858
|
+
onChange: (next) => {
|
|
859
|
+
toggle(row, next);
|
|
860
|
+
}
|
|
861
|
+
})]
|
|
862
|
+
}, row.entryId);
|
|
863
|
+
})
|
|
864
|
+
}),
|
|
865
|
+
presets.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
866
|
+
className: plugin_manager_module_css_default.presetGroup,
|
|
867
|
+
"data-dsh-part": "preset-group",
|
|
868
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
|
|
869
|
+
className: plugin_manager_module_css_default.presetTitle,
|
|
870
|
+
children: t("presetGroup")
|
|
871
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
872
|
+
className: plugin_manager_module_css_default.presetList,
|
|
873
|
+
children: presets.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
874
|
+
className: plugin_manager_module_css_default.presetCard,
|
|
875
|
+
"data-dsh-part": "preset",
|
|
876
|
+
"data-preset-id": preset.id,
|
|
877
|
+
"data-default": preset.isDefault ? "yes" : "no",
|
|
878
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
879
|
+
className: plugin_manager_module_css_default.presetHead,
|
|
880
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
881
|
+
className: plugin_manager_module_css_default.presetName,
|
|
882
|
+
children: preset.name ?? preset.id
|
|
883
|
+
}), preset.isDefault && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
884
|
+
className: plugin_manager_module_css_default.presetTag,
|
|
885
|
+
children: t("presetDefault")
|
|
886
|
+
})]
|
|
887
|
+
}), preset.broken === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
888
|
+
className: plugin_manager_module_css_default.presetRows,
|
|
889
|
+
children: preset.rows.map((row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
890
|
+
className: plugin_manager_module_css_default.presetRow,
|
|
891
|
+
"data-dsh-part": "preset-row",
|
|
892
|
+
"data-preset-state": presetRowState(row),
|
|
893
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
894
|
+
className: plugin_manager_module_css_default.presetRowName,
|
|
895
|
+
children: row.moduleName
|
|
896
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
897
|
+
className: plugin_manager_module_css_default.presetRowState,
|
|
898
|
+
children: presetRowText(row, t)
|
|
899
|
+
})]
|
|
900
|
+
}, row.entryId ?? `${preset.id}:${String(index)}`))
|
|
901
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
902
|
+
className: plugin_manager_module_css_default.hint,
|
|
903
|
+
children: t("presetBroken", { reason: preset.broken })
|
|
904
|
+
})]
|
|
905
|
+
}, preset.id))
|
|
906
|
+
})]
|
|
907
|
+
})
|
|
908
|
+
]
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* The official page's installed panel, when the list view is mounted.
|
|
913
|
+
* @returns the element the group belongs after, or undefined off the list view.
|
|
914
|
+
*/
|
|
915
|
+
function builtinGroupSeat() {
|
|
916
|
+
const panel = document.querySelector("[data-plugin-panel]")?.querySelector("[data-plugin-group=\"bundles\"]")?.parentElement;
|
|
917
|
+
return panel instanceof HTMLElement ? panel : void 0;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Mount the built-in plugin group after the installed panel.
|
|
921
|
+
* @param options - props factory and the optional locale subscription.
|
|
922
|
+
* @returns disposer removing the container, its observers and its React root.
|
|
923
|
+
*/
|
|
924
|
+
function mountBuiltinPluginGroup(options) {
|
|
925
|
+
if (typeof document === "undefined") return () => {};
|
|
926
|
+
if (document.querySelector("[data-dsh-plugin-manager-builtin]") !== null) return () => {};
|
|
927
|
+
const container = document.createElement("div");
|
|
928
|
+
container.setAttribute("data-dsh-plugin-manager-builtin", "");
|
|
929
|
+
container.className = plugin_manager_module_css_default.builtinMount;
|
|
930
|
+
const root = (0, react_dom_client.createRoot)(container);
|
|
931
|
+
const render = () => {
|
|
932
|
+
root.render((0, react.createElement)(BuiltinPlugins, options.props()));
|
|
933
|
+
};
|
|
934
|
+
render();
|
|
935
|
+
/**
|
|
936
|
+
* Keep the container immediately after the installed panel; detach while the
|
|
937
|
+
* list is away. React owns the page's children and appends its own blocks
|
|
938
|
+
* (a failure notice among them) after that panel, so the anchor is the
|
|
939
|
+
* panel's next sibling rather than the panel's last child.
|
|
940
|
+
*/
|
|
941
|
+
const place = () => {
|
|
942
|
+
const seat = builtinGroupSeat();
|
|
943
|
+
if (seat === void 0) {
|
|
944
|
+
container.remove();
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
if (container.previousElementSibling !== seat) seat.after(container);
|
|
948
|
+
};
|
|
949
|
+
place();
|
|
950
|
+
const unsubscribeBody = subscribeBodyInvalidations(place);
|
|
951
|
+
const unsubscribeLocale = options.subscribe === void 0 ? (() => {}) : options.subscribe(render);
|
|
952
|
+
return () => {
|
|
953
|
+
unsubscribeBody();
|
|
954
|
+
unsubscribeLocale();
|
|
955
|
+
root.unmount();
|
|
956
|
+
container.remove();
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
//#endregion
|
|
960
|
+
//#region src/client/native-faces.ts
|
|
961
|
+
let snapshot = {
|
|
962
|
+
version: 0,
|
|
963
|
+
inventory: null,
|
|
964
|
+
manager: null
|
|
965
|
+
};
|
|
966
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
967
|
+
/**
|
|
968
|
+
* Merge one face change into the snapshot and notify subscribers. `version`
|
|
969
|
+
* always moves, so a consumer that keys its read on it re-reads after a swap.
|
|
970
|
+
* @param patch - the faces to replace; an omitted face keeps its current value.
|
|
971
|
+
*/
|
|
972
|
+
function patchRemote(patch) {
|
|
973
|
+
snapshot = {
|
|
974
|
+
version: snapshot.version + 1,
|
|
975
|
+
inventory: patch.inventory === void 0 ? snapshot.inventory : patch.inventory,
|
|
976
|
+
manager: patch.manager === void 0 ? snapshot.manager : patch.manager
|
|
977
|
+
};
|
|
978
|
+
for (const listener of [...listeners]) try {
|
|
979
|
+
listener();
|
|
980
|
+
} catch {}
|
|
981
|
+
}
|
|
982
|
+
/** The current snapshot (stable reference between changes). */
|
|
983
|
+
function getRemoteSnapshot() {
|
|
984
|
+
return snapshot;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Subscribe to snapshot changes.
|
|
988
|
+
* @param listener - called after every face swap or forwarded change event.
|
|
989
|
+
* @returns the unsubscribe function.
|
|
990
|
+
*/
|
|
991
|
+
function subscribeRemote(listener) {
|
|
992
|
+
listeners.add(listener);
|
|
993
|
+
return () => {
|
|
994
|
+
listeners.delete(listener);
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Bridge the official faces into the snapshot. Uses `ctx.inject` (not the
|
|
999
|
+
* plugin's module-level inject array) so each face stays optional.
|
|
1000
|
+
* @param ctx - the client context the plugin runs in.
|
|
1001
|
+
*/
|
|
1002
|
+
function bridgeRemoteNamespaces(ctx) {
|
|
1003
|
+
ctx.inject(["remote.pluginInventory"], (inner) => {
|
|
1004
|
+
inner.effect(() => {
|
|
1005
|
+
patchRemote({ inventory: inner.get("remote.pluginInventory") ?? null });
|
|
1006
|
+
return () => {
|
|
1007
|
+
patchRemote({ inventory: null });
|
|
1008
|
+
};
|
|
1009
|
+
}, "plugin-manager: built-in group inventory face");
|
|
1010
|
+
});
|
|
1011
|
+
ctx.inject(["remote.pluginManager"], (inner) => {
|
|
1012
|
+
inner.effect(() => {
|
|
1013
|
+
patchRemote({ manager: inner.get("remote.pluginManager") ?? null });
|
|
1014
|
+
return () => {
|
|
1015
|
+
patchRemote({ manager: null });
|
|
1016
|
+
};
|
|
1017
|
+
}, "plugin-manager: built-in group manager face");
|
|
1018
|
+
});
|
|
1019
|
+
ctx.inject(["remote"], (inner) => {
|
|
1020
|
+
inner.effect(() => {
|
|
1021
|
+
const remote = inner.get("remote");
|
|
1022
|
+
let off;
|
|
1023
|
+
try {
|
|
1024
|
+
off = remote?.$on?.("plugin-manager/changed", () => {
|
|
1025
|
+
patchRemote({});
|
|
1026
|
+
});
|
|
1027
|
+
} catch {}
|
|
1028
|
+
return () => {
|
|
1029
|
+
off?.();
|
|
1030
|
+
};
|
|
1031
|
+
}, "plugin-manager: built-in group change feed");
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
//#endregion
|
|
371
1035
|
//#region src/core/updates.ts
|
|
372
1036
|
/** The npm scope DSH's own packages are published under. */
|
|
373
1037
|
const OFFICIAL_SCOPE = "@deepseek-ai/";
|
|
@@ -415,6 +1079,17 @@ window.__ModuleLoader__.load({
|
|
|
415
1079
|
return error instanceof Error ? error.message : String(error);
|
|
416
1080
|
}
|
|
417
1081
|
/**
|
|
1082
|
+
* The consequence confirming produces, in the reader's language. It states
|
|
1083
|
+
* what the host will actually do, so a systemd plan names the unit that goes
|
|
1084
|
+
* down and comes back.
|
|
1085
|
+
*/
|
|
1086
|
+
function planCopy(plan, t) {
|
|
1087
|
+
if (plan?.mode === "systemd") return t("restartPlanSystemd", { unit: plan.unit });
|
|
1088
|
+
if (plan?.mode === "shell") return t("restartPlanShell");
|
|
1089
|
+
if (plan?.mode === "manual") return t("restartPlanManual");
|
|
1090
|
+
return t("restartPlanRelaunch");
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
418
1093
|
* The toolbar itself. All state is local: the page around it owns the plugin
|
|
419
1094
|
* list, and a restart tears this component down anyway.
|
|
420
1095
|
*/
|
|
@@ -515,8 +1190,8 @@ window.__ModuleLoader__.load({
|
|
|
515
1190
|
if (busyRef.current) return;
|
|
516
1191
|
busyRef.current = true;
|
|
517
1192
|
setError(void 0);
|
|
518
|
-
restartPlan().then((
|
|
519
|
-
setPlan(
|
|
1193
|
+
restartPlan().then((answer) => {
|
|
1194
|
+
setPlan(answer);
|
|
520
1195
|
setPanel("restart");
|
|
521
1196
|
}).catch((reason) => {
|
|
522
1197
|
setError(t("failed", { reason: messageOf(reason) }));
|
|
@@ -557,6 +1232,13 @@ window.__ModuleLoader__.load({
|
|
|
557
1232
|
})
|
|
558
1233
|
});
|
|
559
1234
|
const busy = phase !== "idle";
|
|
1235
|
+
/**
|
|
1236
|
+
* The host leaves once the route accepts a relaunch or a systemd restart:
|
|
1237
|
+
* both replace this process, so the action is spent and reads as in progress.
|
|
1238
|
+
*/
|
|
1239
|
+
const hostLeaves = restartMode === "relaunch" || restartMode === "systemd";
|
|
1240
|
+
/** The mode the plan read named; the confirmation only opens after one arrived. */
|
|
1241
|
+
const planMode = plan?.mode;
|
|
560
1242
|
/** One alert line, rendered in whichever flyout is open when it appears. */
|
|
561
1243
|
const errorLine = error === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
562
1244
|
className: plugin_manager_module_css_default.error,
|
|
@@ -601,7 +1283,7 @@ window.__ModuleLoader__.load({
|
|
|
601
1283
|
className: applied.length > 0 ? `${plugin_manager_module_css_default.toolbarButton} ${plugin_manager_module_css_default.primary}` : plugin_manager_module_css_default.toolbarButton,
|
|
602
1284
|
"data-update-restart": true,
|
|
603
1285
|
"data-restart-pending": applied.length,
|
|
604
|
-
disabled: busy ||
|
|
1286
|
+
disabled: busy || hostLeaves,
|
|
605
1287
|
onClick: () => {
|
|
606
1288
|
if (panel === "restart") {
|
|
607
1289
|
setPanel("none");
|
|
@@ -610,7 +1292,7 @@ window.__ModuleLoader__.load({
|
|
|
610
1292
|
}
|
|
611
1293
|
onAskRestart();
|
|
612
1294
|
},
|
|
613
|
-
children:
|
|
1295
|
+
children: hostLeaves ? t("restarting") : t("restartNow")
|
|
614
1296
|
}),
|
|
615
1297
|
restartMode !== void 0 && panel !== "restart" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
616
1298
|
className: plugin_manager_module_css_default.toolbarHint,
|
|
@@ -706,17 +1388,17 @@ window.__ModuleLoader__.load({
|
|
|
706
1388
|
panel === "restart" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
707
1389
|
className: plugin_manager_module_css_default.panel,
|
|
708
1390
|
"data-update-restart-panel": true,
|
|
709
|
-
"data-restart-plan":
|
|
1391
|
+
"data-restart-plan": planMode,
|
|
710
1392
|
role: "group",
|
|
711
1393
|
"aria-label": t("restartNow"),
|
|
712
1394
|
children: [
|
|
713
1395
|
errorLine,
|
|
714
1396
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
715
1397
|
className: plugin_manager_module_css_default.hint,
|
|
716
|
-
"data-restart-plan-hint":
|
|
717
|
-
children:
|
|
1398
|
+
"data-restart-plan-hint": planMode,
|
|
1399
|
+
children: planCopy(plan, t)
|
|
718
1400
|
}),
|
|
719
|
-
|
|
1401
|
+
planMode === "shell" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
720
1402
|
className: plugin_manager_module_css_default.hint,
|
|
721
1403
|
children: t("restartShellWarning")
|
|
722
1404
|
}),
|
|
@@ -731,7 +1413,7 @@ window.__ModuleLoader__.load({
|
|
|
731
1413
|
setPlan(void 0);
|
|
732
1414
|
},
|
|
733
1415
|
children: t("cancel")
|
|
734
|
-
}),
|
|
1416
|
+
}), planMode !== "manual" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
735
1417
|
type: "button",
|
|
736
1418
|
className: `${plugin_manager_module_css_default.button} ${plugin_manager_module_css_default.primary}`,
|
|
737
1419
|
"data-restart-confirm": true,
|
|
@@ -828,6 +1510,7 @@ window.__ModuleLoader__.load({
|
|
|
828
1510
|
"restartConfirm": "确认重启",
|
|
829
1511
|
"restartPlanRelaunch": "会重启 DSH 服务,正在运行的任务会中断。",
|
|
830
1512
|
"restartPlanShell": "桌面版重启由应用外壳执行:确认后宿主进程会退出,由外壳重新拉起。",
|
|
1513
|
+
"restartPlanSystemd": "会由 systemd 重启 {unit},正在运行的任务会中断。",
|
|
831
1514
|
"restartPlanManual": "当前进程无法自动重启,请手动重启 DSH。",
|
|
832
1515
|
"restartShellWarning": "它同时会写一份崩溃报告;也可以手动重启:退出 DeepSeek Harness(⌘Q)后重新打开。",
|
|
833
1516
|
"restartDesktopHint": "请在随后出现的系统对话框中选择「重启」。",
|
|
@@ -840,6 +1523,36 @@ window.__ModuleLoader__.load({
|
|
|
840
1523
|
"downloadingPercent": "正在下载 {percent}%",
|
|
841
1524
|
"extracting": "正在解压…",
|
|
842
1525
|
"writing": "正在写入配置…",
|
|
1526
|
+
"builtinGroup": "内置插件",
|
|
1527
|
+
"builtinReading": "正在读取内置插件…",
|
|
1528
|
+
"builtinEmpty": "没有内置插件。",
|
|
1529
|
+
"builtinUnavailable": "当前部署没有提供插件清单接口,无法列出内置插件。",
|
|
1530
|
+
"builtinFailed": "无法读取内置插件:{reason}",
|
|
1531
|
+
"builtinUnconfirmed": "无法读取已安装组合包的行清单,这里按全部 Loader 条目列出。",
|
|
1532
|
+
"builtinScopeExpand": "显示已归属组合包的行({count})",
|
|
1533
|
+
"builtinScopeCollapse": "隐藏已归属组合包的行({count})",
|
|
1534
|
+
"builtinOwnedBy": "来自 {name}",
|
|
1535
|
+
"builtinToggle": "启用插件 {name}",
|
|
1536
|
+
"builtinFailedEnable": "启用失败:{reason}",
|
|
1537
|
+
"builtinFailedDisable": "停用失败:{reason}",
|
|
1538
|
+
"builtinReasonManagementRequired": "插件管理所需,不能停用或卸载",
|
|
1539
|
+
"builtinReasonUnaddressable": "当前 profile 的 patch 无法唯一定位这一项",
|
|
1540
|
+
"builtinReasonUnknown": "无法确定这一项能否改写",
|
|
1541
|
+
"builtinRestartRequired": "这次改动需要重启 DSH 才能加载:{reason}",
|
|
1542
|
+
"builtinOverridden": "更高层的 profile 覆盖了 {name} 的这一改动,未生效。",
|
|
1543
|
+
"builtinRestartUnnamed": "当前 profile 只在启动时应用更改。",
|
|
1544
|
+
"builtinRestartNoHmr": "这个 profile 只在启动时应用更改。",
|
|
1545
|
+
"builtinRestartPackageMoved": "已安装的插件包解析到了另一个目录,或者改动替换了 DSH 安装自带的包。",
|
|
1546
|
+
"builtinRestartHostModule": "改动涉及 DSH 自身已加载的模块。",
|
|
1547
|
+
"builtinRestartUnmanagedPlugin": "改动涉及一个不受插件列表管理的插件。",
|
|
1548
|
+
"builtinRestartModuleComparison": "DSH 无法把已加载的插件与磁盘上的文件做比较。",
|
|
1549
|
+
"presetGroup": "Agent 预设",
|
|
1550
|
+
"presetDefault": "默认",
|
|
1551
|
+
"presetBroken": "无法读取该预设的组合:{reason}",
|
|
1552
|
+
"presetRowOn": "已开启",
|
|
1553
|
+
"presetRowOff": "已关闭",
|
|
1554
|
+
"presetRowConditional": "条件启用:{condition}",
|
|
1555
|
+
"presetRowConditionalUnnamed": "条件启用",
|
|
843
1556
|
"localOnlyTitle": "仅限本机操作",
|
|
844
1557
|
"localOnlyBody": "为了保护主机配置,插件管理只能从本机打开。"
|
|
845
1558
|
};
|
|
@@ -869,6 +1582,7 @@ window.__ModuleLoader__.load({
|
|
|
869
1582
|
"restartConfirm": "Restart",
|
|
870
1583
|
"restartPlanRelaunch": "The DSH service restarts; running tasks are interrupted.",
|
|
871
1584
|
"restartPlanShell": "The desktop app performs the restart: confirming stops the host process and the shell brings a new one up.",
|
|
1585
|
+
"restartPlanSystemd": "systemd restarts {unit}; running tasks are interrupted.",
|
|
872
1586
|
"restartPlanManual": "This process cannot restart itself; restart DSH yourself.",
|
|
873
1587
|
"restartShellWarning": "It also writes a crash report. You can instead restart manually: quit DeepSeek Harness (Cmd+Q) and open it again.",
|
|
874
1588
|
"restartDesktopHint": "Choose Restart in the system dialog that follows.",
|
|
@@ -881,6 +1595,36 @@ window.__ModuleLoader__.load({
|
|
|
881
1595
|
"downloadingPercent": "Downloading {percent}%",
|
|
882
1596
|
"extracting": "Extracting…",
|
|
883
1597
|
"writing": "Writing configuration…",
|
|
1598
|
+
"builtinGroup": "Built-in plugins",
|
|
1599
|
+
"builtinReading": "Reading built-in plugins…",
|
|
1600
|
+
"builtinEmpty": "No built-in plugins.",
|
|
1601
|
+
"builtinUnavailable": "This deployment publishes no plugin inventory, so built-in plugins cannot be listed.",
|
|
1602
|
+
"builtinFailed": "Could not read the built-in plugins: {reason}",
|
|
1603
|
+
"builtinUnconfirmed": "The installed bundles could not be read, so every Loader entry is listed here.",
|
|
1604
|
+
"builtinScopeExpand": "Show the rows these bundles own ({count})",
|
|
1605
|
+
"builtinScopeCollapse": "Hide the rows these bundles own ({count})",
|
|
1606
|
+
"builtinOwnedBy": "From {name}",
|
|
1607
|
+
"builtinToggle": "Enable plugin {name}",
|
|
1608
|
+
"builtinFailedEnable": "Could not enable it: {reason}",
|
|
1609
|
+
"builtinFailedDisable": "Could not disable it: {reason}",
|
|
1610
|
+
"builtinReasonManagementRequired": "Plugin management needs it; it cannot be switched off or uninstalled",
|
|
1611
|
+
"builtinReasonUnaddressable": "The profile patch cannot address this one uniquely",
|
|
1612
|
+
"builtinReasonUnknown": "Whether this one can be written is unknown",
|
|
1613
|
+
"builtinRestartRequired": "This change needs a DSH restart: {reason}",
|
|
1614
|
+
"builtinOverridden": "A higher profile layer overrides this change to {name}, so it did not take effect.",
|
|
1615
|
+
"builtinRestartUnnamed": "This profile applies changes only at startup.",
|
|
1616
|
+
"builtinRestartNoHmr": "This profile applies changes only at startup.",
|
|
1617
|
+
"builtinRestartPackageMoved": "An installed package now resolves to another directory, or the change replaces a package the DSH installation provides.",
|
|
1618
|
+
"builtinRestartHostModule": "The change reaches modules DSH itself loaded.",
|
|
1619
|
+
"builtinRestartUnmanagedPlugin": "The change reaches a plugin running outside the plugin list.",
|
|
1620
|
+
"builtinRestartModuleComparison": "DSH could not compare the loaded plugins with their files.",
|
|
1621
|
+
"presetGroup": "Agent presets",
|
|
1622
|
+
"presetDefault": "Default",
|
|
1623
|
+
"presetBroken": "This preset composition cannot be read: {reason}",
|
|
1624
|
+
"presetRowOn": "On",
|
|
1625
|
+
"presetRowOff": "Off",
|
|
1626
|
+
"presetRowConditional": "Conditional: {condition}",
|
|
1627
|
+
"presetRowConditionalUnnamed": "Conditional",
|
|
884
1628
|
"localOnlyTitle": "Available on this computer only",
|
|
885
1629
|
"localOnlyBody": "To protect host configuration, plugin management is only available from a local browser."
|
|
886
1630
|
};
|
|
@@ -888,6 +1632,22 @@ window.__ModuleLoader__.load({
|
|
|
888
1632
|
const en = STATIC_EN;
|
|
889
1633
|
//#endregion
|
|
890
1634
|
//#region src/core/protocol.ts
|
|
1635
|
+
/**
|
|
1636
|
+
* The unit name shape a systemd restart may name. Deliberately conservative:
|
|
1637
|
+
* the host derives the value from its own cgroup and the browser re-validates
|
|
1638
|
+
* it before the confirmation names a unit, so a value outside this shape is
|
|
1639
|
+
* wire drift rather than a unit worth restarting. The one position that is
|
|
1640
|
+
* refused is a leading `-`: this name travels as the last argv element of
|
|
1641
|
+
* `systemctl --user restart --no-block <unit>`, where a leading `-` reads as
|
|
1642
|
+
* another option instead of a unit. Everything else systemd itself accepts is
|
|
1643
|
+
* kept, including a first `_` or `:` (`_x.service` and `:x.service` are
|
|
1644
|
+
* valid unit names).
|
|
1645
|
+
*/
|
|
1646
|
+
const SYSTEMD_UNIT_RE = /^(?!-)[a-zA-Z0-9:_.@-]+\.service$/;
|
|
1647
|
+
/** Whether a value is a systemd unit name this package asks systemd to restart. */
|
|
1648
|
+
function isSystemdUnitName(value) {
|
|
1649
|
+
return SYSTEMD_UNIT_RE.test(value);
|
|
1650
|
+
}
|
|
891
1651
|
/** Whether a decoded value is a non-array object. */
|
|
892
1652
|
function isRecord(value) {
|
|
893
1653
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -1011,17 +1771,39 @@ window.__ModuleLoader__.load({
|
|
|
1011
1771
|
});
|
|
1012
1772
|
}
|
|
1013
1773
|
/**
|
|
1014
|
-
* Validate and normalize a `restart` response value
|
|
1774
|
+
* Validate and normalize a `restart` response value, reading the mode a POST
|
|
1775
|
+
* answer carries.
|
|
1015
1776
|
* @param value - decoded but untrusted response value.
|
|
1016
1777
|
* @returns the mode the host actually used.
|
|
1017
1778
|
*/
|
|
1018
1779
|
function parseRestartMode(value) {
|
|
1019
1780
|
const restart = isRecord(value) ? value.restart : void 0;
|
|
1020
1781
|
const mode = isRecord(restart) ? restart.mode : void 0;
|
|
1021
|
-
if (mode !== "relaunch" && mode !== "shell" && mode !== "manual") throw new Error("plugin-manager: response must contain a restart mode");
|
|
1782
|
+
if (mode !== "relaunch" && mode !== "shell" && mode !== "systemd" && mode !== "manual") throw new Error("plugin-manager: response must contain a restart mode");
|
|
1022
1783
|
return mode;
|
|
1023
1784
|
}
|
|
1024
1785
|
/**
|
|
1786
|
+
* Validate and normalize a restart PLAN response value (the GET answer).
|
|
1787
|
+
*
|
|
1788
|
+
* The plan is read before the confirmation is shown, so this parser fails
|
|
1789
|
+
* closed: an unknown mode, or a systemd plan that does not name a unit of the
|
|
1790
|
+
* accepted shape, throws instead of letting the panel promise a restart the
|
|
1791
|
+
* host cannot actually perform.
|
|
1792
|
+
* @param value - decoded but untrusted response value.
|
|
1793
|
+
* @returns the plan the host would carry out.
|
|
1794
|
+
*/
|
|
1795
|
+
function parseRestartPlan(value) {
|
|
1796
|
+
const mode = parseRestartMode(value);
|
|
1797
|
+
if (mode !== "systemd") return { mode };
|
|
1798
|
+
const restart = isRecord(value) ? value.restart : void 0;
|
|
1799
|
+
const unit = isRecord(restart) ? restart.unit : void 0;
|
|
1800
|
+
if (!isString(unit) || !isSystemdUnitName(unit)) throw new Error("plugin-manager: response must name the systemd unit a systemd restart uses");
|
|
1801
|
+
return {
|
|
1802
|
+
mode,
|
|
1803
|
+
unit
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1025
1807
|
* Validate and normalize a `failures` response value.
|
|
1026
1808
|
* @param value - decoded but untrusted response value.
|
|
1027
1809
|
* @returns the typed failures snapshot.
|
|
@@ -1058,7 +1840,7 @@ window.__ModuleLoader__.load({
|
|
|
1058
1840
|
/** The building package's version, when the bundle carries it. */
|
|
1059
1841
|
function bakedVersion() {
|
|
1060
1842
|
try {
|
|
1061
|
-
return "0.4.
|
|
1843
|
+
return "0.4.14";
|
|
1062
1844
|
} catch {
|
|
1063
1845
|
return;
|
|
1064
1846
|
}
|
|
@@ -1290,7 +2072,7 @@ window.__ModuleLoader__.load({
|
|
|
1290
2072
|
stage: "fetch"
|
|
1291
2073
|
},
|
|
1292
2074
|
failures: async () => parseFailuresSnapshot(await gatewayJson(`${GATEWAY_PREFIX}/failures`)),
|
|
1293
|
-
restartPlan: async () =>
|
|
2075
|
+
restartPlan: async () => parseRestartPlan(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`)),
|
|
1294
2076
|
restart: async () => parseRestartMode(await gatewayJson(`${GATEWAY_PREFIX}/${RESTART_ENDPOINT}`, { method: "POST" }))
|
|
1295
2077
|
};
|
|
1296
2078
|
let modePromise;
|
|
@@ -1370,6 +2152,11 @@ window.__ModuleLoader__.load({
|
|
|
1370
2152
|
try {
|
|
1371
2153
|
if (!ctx.get("pluginManager")) ctx.provide(PLUGIN_MANAGER_SERVICE, face);
|
|
1372
2154
|
} catch {}
|
|
2155
|
+
try {
|
|
2156
|
+
bridgeRemoteNamespaces(ctx);
|
|
2157
|
+
} catch (error) {
|
|
2158
|
+
console.warn("plugin-manager: bridging the official plugin faces failed", error);
|
|
2159
|
+
}
|
|
1373
2160
|
ctx.effect(() => {
|
|
1374
2161
|
try {
|
|
1375
2162
|
return mountPluginListToolbar({
|
|
@@ -1387,6 +2174,28 @@ window.__ModuleLoader__.load({
|
|
|
1387
2174
|
return () => {};
|
|
1388
2175
|
}
|
|
1389
2176
|
}, "plugin-manager: update toolbar");
|
|
2177
|
+
ctx.effect(() => {
|
|
2178
|
+
try {
|
|
2179
|
+
return mountBuiltinPluginGroup({
|
|
2180
|
+
props: () => ({
|
|
2181
|
+
remote: getRemoteSnapshot(),
|
|
2182
|
+
resolveText: (text) => ctx.locale.resolveText(text),
|
|
2183
|
+
t: ctx.locale.bind(NS)
|
|
2184
|
+
}),
|
|
2185
|
+
subscribe: (listener) => {
|
|
2186
|
+
const offLocale = ctx.locale.subscribe(listener);
|
|
2187
|
+
const offRemote = subscribeRemote(listener);
|
|
2188
|
+
return () => {
|
|
2189
|
+
offLocale();
|
|
2190
|
+
offRemote();
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2194
|
+
} catch (error) {
|
|
2195
|
+
console.warn("plugin-manager: mounting the built-in plugin group failed", error);
|
|
2196
|
+
return () => {};
|
|
2197
|
+
}
|
|
2198
|
+
}, "plugin-manager: built-in plugin group");
|
|
1390
2199
|
ctx.slots.inject("plugins.detail.section", () => {
|
|
1391
2200
|
try {
|
|
1392
2201
|
return ctx.slots.register({
|