@linxin666/dsh-client-ui-plugin-manager 0.3.17 → 0.3.19
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 +1 -0
- package/README.zh.md +1 -0
- package/lib/client.js +171 -112
- package/lib/client.js.map +1 -1
- package/lib/index.js +60 -14
- package/lib/types/client/locales.d.ts +6 -0
- package/lib/types/core/protocol.d.ts +19 -0
- package/lib/types/host/rows.d.ts +6 -0
- package/lib/types/host/state.d.ts +24 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -228,9 +228,12 @@ function insertRowsOf(patchText) {
|
|
|
228
228
|
if (!isMap(entry)) continue;
|
|
229
229
|
const id = entry.get("id", true);
|
|
230
230
|
const name = entry.get("name", true);
|
|
231
|
+
const config = entry.get("config", true);
|
|
232
|
+
const plugin = isMap(config) ? config.get("plugin", true) : void 0;
|
|
231
233
|
rows.push({
|
|
232
234
|
id: isScalar(id) && typeof id.value === "string" ? id.value : void 0,
|
|
233
|
-
name: isScalar(name) && typeof name.value === "string" ? name.value : void 0
|
|
235
|
+
name: isScalar(name) && typeof name.value === "string" ? name.value : void 0,
|
|
236
|
+
plugin: isScalar(plugin) && typeof plugin.value === "string" ? plugin.value : void 0
|
|
234
237
|
});
|
|
235
238
|
}
|
|
236
239
|
}
|
|
@@ -560,6 +563,20 @@ function profileExists(profileDir) {
|
|
|
560
563
|
* the read side of the gateway (the write side is the official CLI).
|
|
561
564
|
* @module @linxin666/dsh-client-ui-plugin-manager/host
|
|
562
565
|
*/
|
|
566
|
+
/**
|
|
567
|
+
* Entry rows that must never carry a disabled override: the manager tab
|
|
568
|
+
* itself (the UI performing the write), the family settings surface the tab
|
|
569
|
+
* injects into, and the aggregate compat face (disabling it unmounts the
|
|
570
|
+
* whole folded client bundle while host rows keep running — a half-dead
|
|
571
|
+
* page). Covers both the standalone and the aggregate row ids.
|
|
572
|
+
*/
|
|
573
|
+
const LOCKED_ENTRY_IDS = /* @__PURE__ */ new Set([
|
|
574
|
+
"ui-plugin-manager",
|
|
575
|
+
"web-ui-plugin-manager",
|
|
576
|
+
"ui-web-ui-settings",
|
|
577
|
+
"web-ui-settings",
|
|
578
|
+
"web-ui-compat"
|
|
579
|
+
]);
|
|
563
580
|
/** The node_modules path of one (possibly scoped) package name. */
|
|
564
581
|
function modulePathOf(profileDir, name) {
|
|
565
582
|
return join(profileDir, "node_modules", ...name.split("/"));
|
|
@@ -635,8 +652,14 @@ async function buildPluginRow(facts, name, spec, rowEnabled) {
|
|
|
635
652
|
} catch {
|
|
636
653
|
bundlePatch = "[]";
|
|
637
654
|
}
|
|
638
|
-
const
|
|
639
|
-
const enabled = (
|
|
655
|
+
const insertRows = insertRowsOf(bundlePatch).filter((row) => row.id !== void 0);
|
|
656
|
+
const enabled = (insertRows.length > 0 ? insertRows.map((row) => row.id) : [name]).every((id) => rowEnabled.get(id) ?? true);
|
|
657
|
+
const children = insertRows.length > 1 ? insertRows.map((row) => ({
|
|
658
|
+
id: row.id,
|
|
659
|
+
name: row.plugin ?? row.name ?? row.id,
|
|
660
|
+
enabled: rowEnabled.get(row.id) ?? true,
|
|
661
|
+
...LOCKED_ENTRY_IDS.has(row.id) ? { locked: true } : {}
|
|
662
|
+
})) : void 0;
|
|
640
663
|
return {
|
|
641
664
|
id: name,
|
|
642
665
|
name,
|
|
@@ -646,10 +669,29 @@ async function buildPluginRow(facts, name, spec, rowEnabled) {
|
|
|
646
669
|
spec
|
|
647
670
|
},
|
|
648
671
|
installedAt: "",
|
|
649
|
-
enabled
|
|
672
|
+
enabled,
|
|
673
|
+
...children !== void 0 ? { children } : {}
|
|
650
674
|
};
|
|
651
675
|
}
|
|
652
676
|
/**
|
|
677
|
+
* Find the dependency whose bundle patch claims one entry id (row-level
|
|
678
|
+
* set-enabled target). Reads every dependency's bundle patch; profiles carry
|
|
679
|
+
* a handful of dependencies, so the scan is cheap and needs no index.
|
|
680
|
+
* @param facts - resolved profile locations.
|
|
681
|
+
* @param dependencies - profile dependency names.
|
|
682
|
+
* @param entryId - the claimed entry id to locate.
|
|
683
|
+
* @returns the owning dependency name and the claimed row, or undefined.
|
|
684
|
+
*/
|
|
685
|
+
async function findRowOwner(facts, dependencies, entryId) {
|
|
686
|
+
for (const name of dependencies) {
|
|
687
|
+
const row = (await claimedEntryRowsOf(facts, name)).find((candidate) => candidate.id === entryId);
|
|
688
|
+
if (row !== void 0) return {
|
|
689
|
+
packageName: name,
|
|
690
|
+
row
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
653
695
|
* Build the gateway listing and the layer snapshot.
|
|
654
696
|
* @param facts - resolved profile locations.
|
|
655
697
|
* @param patchText - current profile patch text.
|
|
@@ -1760,11 +1802,6 @@ const VERSION_ESCALATION_TIMEOUT_MS = 5e3;
|
|
|
1760
1802
|
const VERSION_PROBE_TTL_MS = 5 * 6e4;
|
|
1761
1803
|
/** Minimum gap between failed version probes (avoids a spawn per request). */
|
|
1762
1804
|
const VERSION_PROBE_COOLDOWN_MS = 6e4;
|
|
1763
|
-
/**
|
|
1764
|
-
* Entry ids that must stay mounted so the local plugin-management escape hatch
|
|
1765
|
-
* remains available. Aggregate packages may still disable every other entry.
|
|
1766
|
-
*/
|
|
1767
|
-
const SELF_MANAGED_ENTRY_IDS = /* @__PURE__ */ new Set(["ui-plugin-manager", "web-ui-plugin-manager"]);
|
|
1768
1805
|
/** Error text for a caught request or lifecycle failure. */
|
|
1769
1806
|
function messageOf(error) {
|
|
1770
1807
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -2073,16 +2110,25 @@ function makeGatewayRoutes(deps) {
|
|
|
2073
2110
|
}
|
|
2074
2111
|
const outcome = await gateway.withMutationLock(async () => {
|
|
2075
2112
|
const patchText = await readPatchText(facts.patchPath);
|
|
2076
|
-
|
|
2077
|
-
|
|
2113
|
+
const manifest = await readProfileManifest(facts.packageJsonPath);
|
|
2114
|
+
let ownerName = target;
|
|
2115
|
+
let entries;
|
|
2116
|
+
if (manifest.dependencies[target] !== void 0) entries = await claimedEntryRowsOf(facts, target);
|
|
2117
|
+
else {
|
|
2118
|
+
const owner = await findRowOwner(facts, Object.keys(manifest.dependencies), target);
|
|
2119
|
+
if (owner === void 0) return { error: `plugin-manager: plugin ${target} is not installed` };
|
|
2120
|
+
if (!enabled && LOCKED_ENTRY_IDS.has(target)) return { error: `plugin-manager: row ${target} is required by this manager and cannot be disabled` };
|
|
2121
|
+
ownerName = owner.packageName;
|
|
2122
|
+
entries = [owner.row];
|
|
2123
|
+
}
|
|
2078
2124
|
let next = patchText;
|
|
2079
2125
|
for (const entry of entries) {
|
|
2080
|
-
const entryEnabled = enabled ||
|
|
2126
|
+
const entryEnabled = enabled || LOCKED_ENTRY_IDS.has(entry.id);
|
|
2081
2127
|
next = setRowEnabled(next, facts.patchPath, entry.id, entry.name, entryEnabled);
|
|
2082
2128
|
}
|
|
2083
2129
|
if (next !== patchText) await writePatchAtomic(facts.patchPath, next);
|
|
2084
|
-
const plugin = (await snapshotGateway(facts, next)).plugins.find((item) => item.id ===
|
|
2085
|
-
return plugin === void 0 ? { error: `plugin-manager: plugin ${
|
|
2130
|
+
const plugin = (await snapshotGateway(facts, next)).plugins.find((item) => item.id === ownerName);
|
|
2131
|
+
return plugin === void 0 ? { error: `plugin-manager: plugin ${ownerName} is not installed` } : { plugin };
|
|
2086
2132
|
});
|
|
2087
2133
|
if ("error" in outcome) {
|
|
2088
2134
|
writeJson(res, 404, { error: outcome.error });
|
|
@@ -62,6 +62,8 @@ declare const STATIC_ZH: {
|
|
|
62
62
|
gitSource: string;
|
|
63
63
|
enableSwitch: string;
|
|
64
64
|
disableSwitch: string;
|
|
65
|
+
lockedRowHint: string;
|
|
66
|
+
childrenHint: string;
|
|
65
67
|
repairInstallTitle: string;
|
|
66
68
|
repairInstallSpecLabel: string;
|
|
67
69
|
repairInstallErrorLabel: string;
|
|
@@ -143,6 +145,8 @@ export declare const zh: {
|
|
|
143
145
|
gitSource: string;
|
|
144
146
|
enableSwitch: string;
|
|
145
147
|
disableSwitch: string;
|
|
148
|
+
lockedRowHint: string;
|
|
149
|
+
childrenHint: string;
|
|
146
150
|
repairInstallTitle: string;
|
|
147
151
|
repairInstallSpecLabel: string;
|
|
148
152
|
repairInstallErrorLabel: string;
|
|
@@ -224,6 +228,8 @@ export declare const en: {
|
|
|
224
228
|
gitSource: string;
|
|
225
229
|
enableSwitch: string;
|
|
226
230
|
disableSwitch: string;
|
|
231
|
+
lockedRowHint: string;
|
|
232
|
+
childrenHint: string;
|
|
227
233
|
repairInstallTitle: string;
|
|
228
234
|
repairInstallSpecLabel: string;
|
|
229
235
|
repairInstallErrorLabel: string;
|
|
@@ -10,6 +10,17 @@
|
|
|
10
10
|
* protocol.ts); they are a contract observation, not an import.
|
|
11
11
|
* @module @linxin666/dsh-client-ui-plugin-manager/core
|
|
12
12
|
*/
|
|
13
|
+
/** One loader entry row claimed by an installed bundle package (aggregate child). */
|
|
14
|
+
export interface InstalledPluginChild {
|
|
15
|
+
/** The loader entry id, e.g. web-ui-pet. */
|
|
16
|
+
id: string;
|
|
17
|
+
/** Display name: the real plugin package (shell config.plugin) when known. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Saved next-start enablement of this row alone. */
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
/** Rows the manager must never disable (the manager tab itself, the compat face). */
|
|
22
|
+
locked?: boolean;
|
|
23
|
+
}
|
|
13
24
|
/** One installed user-plugin row served by `/plugin-installer list`. */
|
|
14
25
|
export interface InstalledPluginItem {
|
|
15
26
|
id: string;
|
|
@@ -23,6 +34,14 @@ export interface InstalledPluginItem {
|
|
|
23
34
|
/** Saved next-start enablement from the managed profile patch row. */
|
|
24
35
|
enabled: boolean;
|
|
25
36
|
commit?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Entry rows this package's bundle patch claims, present when the package
|
|
39
|
+
* is an aggregate claiming more than one row (gateway mode only — the
|
|
40
|
+
* official channel wire has no children). Child enablement is individually
|
|
41
|
+
* switchable; uninstall stays whole-package (the code ships in one npm
|
|
42
|
+
* package).
|
|
43
|
+
*/
|
|
44
|
+
children?: InstalledPluginChild[];
|
|
26
45
|
}
|
|
27
46
|
/** Point-in-time install/update progress reported by the host. */
|
|
28
47
|
export interface InstallProgressItem {
|
package/lib/types/host/rows.d.ts
CHANGED
|
@@ -65,6 +65,12 @@ export declare function claimedIdsOf(patchText: string): string[];
|
|
|
65
65
|
export interface InsertRow {
|
|
66
66
|
id?: string;
|
|
67
67
|
name?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The real plugin package the row mounts, read from the aggregate shell
|
|
70
|
+
* row's config.plugin. Present on shell-wrapped family rows; the display
|
|
71
|
+
* name of a child row prefers it over the per-family subpath name.
|
|
72
|
+
*/
|
|
73
|
+
plugin?: string;
|
|
68
74
|
}
|
|
69
75
|
/**
|
|
70
76
|
* The insert entries of an installed package's own bundle patch, with both
|
|
@@ -8,6 +8,14 @@
|
|
|
8
8
|
import type { InstalledPluginItem } from '../core/protocol.ts';
|
|
9
9
|
import type { LayerSnapshot } from '../core/patch-diff.ts';
|
|
10
10
|
import { type ProfileFacts } from './profile.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Entry rows that must never carry a disabled override: the manager tab
|
|
13
|
+
* itself (the UI performing the write), the family settings surface the tab
|
|
14
|
+
* injects into, and the aggregate compat face (disabling it unmounts the
|
|
15
|
+
* whole folded client bundle while host rows keep running — a half-dead
|
|
16
|
+
* page). Covers both the standalone and the aggregate row ids.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LOCKED_ENTRY_IDS: ReadonlySet<string>;
|
|
11
19
|
/** The listing result: plugin rows plus the raw layer snapshot for diffs. */
|
|
12
20
|
export interface GatewaySnapshot {
|
|
13
21
|
plugins: InstalledPluginItem[];
|
|
@@ -49,6 +57,22 @@ export declare function claimedEntryRowsOf(facts: ProfileFacts, name: string): P
|
|
|
49
57
|
* @returns the wire-shaped plugin row.
|
|
50
58
|
*/
|
|
51
59
|
export declare function buildPluginRow(facts: ProfileFacts, name: string, spec: string, rowEnabled: ReadonlyMap<string, boolean>): Promise<InstalledPluginItem>;
|
|
60
|
+
/**
|
|
61
|
+
* Find the dependency whose bundle patch claims one entry id (row-level
|
|
62
|
+
* set-enabled target). Reads every dependency's bundle patch; profiles carry
|
|
63
|
+
* a handful of dependencies, so the scan is cheap and needs no index.
|
|
64
|
+
* @param facts - resolved profile locations.
|
|
65
|
+
* @param dependencies - profile dependency names.
|
|
66
|
+
* @param entryId - the claimed entry id to locate.
|
|
67
|
+
* @returns the owning dependency name and the claimed row, or undefined.
|
|
68
|
+
*/
|
|
69
|
+
export declare function findRowOwner(facts: ProfileFacts, dependencies: readonly string[], entryId: string): Promise<{
|
|
70
|
+
packageName: string;
|
|
71
|
+
row: {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
};
|
|
75
|
+
} | undefined>;
|
|
52
76
|
/**
|
|
53
77
|
* Build the gateway listing and the layer snapshot.
|
|
54
78
|
* @param facts - resolved profile locations.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-plugin-manager",
|
|
3
3
|
"description": "Plugin manager tab for the dsh web GUI Plugins settings section: installs plugins from npm or git through the official host channels, lists installed plugins with next-start enablement switches, surfaces install-time conflict actions with undo, and hands failures off to repair conversations.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.19",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|