@linxin666/dsh-client-ui-plugin-manager 0.3.1 → 0.3.3
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 +7 -2
- package/README.zh.md +7 -2
- package/lib/client.js +79 -0
- package/lib/client.js.map +1 -1
- package/lib/index.js +340 -4
- package/lib/types/client/telemetry.d.ts +26 -0
- package/lib/types/core/conflict.d.ts +1 -1
- package/lib/types/core/protocol.d.ts +8 -0
- package/lib/types/host/gateway.d.ts +17 -1
- package/lib/types/host/http.d.ts +1 -1
- package/lib/types/host/legacy-migration.d.ts +33 -0
- package/lib/types/host/loopback.d.ts +1 -1
- package/lib/types/host/profile.d.ts +10 -0
- package/lib/types/mount-once.d.ts +1 -1
- package/package.json +1 -1
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# node scripts/verify-docs.mjs --write <dir>
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 68fd72c19e97b17a815377bed7a5f5b84c4ee978
|
|
6
|
+
README.zh.md: 01677555b5e23327a64f6cfaf8ae7a8c59ae1580
|
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Plugin manager tab for the dsh web GUI Plugins settings section: installs plugin
|
|
|
10
10
|
- Dual-channel transport: on runtimes with the official installer services (DSHCode and the 1.0.4 checkout web), every operation rides the official `/plugin-installer` and `/plugin-control` loopback RPC channels; on the npm-published web runtime those channels do not exist, so the package's host half mounts a loopback-fenced HTTP gateway that spawns the official `dsh plugin` CLI for installs/removals (the single writer) and writes `disabled` override rows for enablement.
|
|
11
11
|
- Installs plugins from an npm package name or a git repository URL, with progress.
|
|
12
12
|
- Lists installed user plugins with next-start enable switches, update checks (registry, npm sources), verified npm updates, and uninstall.
|
|
13
|
+
- Detects the legacy aggregate `@linxin666/dsh-web-ui-all` and converts its update action into a transactional migration to `@linxin666/dsh-web-all`; the gateway removes the legacy package, installs the current package at an exact version, restores the legacy layer position, and verifies `--dump-config` before reporting success.
|
|
13
14
|
- Verifies DSH runtime compatibility before npm updates (issue #754): update checks read the declared minimum DSH version from the latest manifest (`dsh.engines.dsh` with a top-level `engines.dsh` fallback), show the requirement beside the update button, disable the button when the running DSH is below it, and the host update route returns 412 before starting any CLI job when the runtime cannot be verified.
|
|
14
15
|
- Shows the built-in product switches when the official plugin-control surface exists.
|
|
15
16
|
- Surfaces install-time conflict actions: the product-snapshot diff around each install (official mode) or the profile layer diff around each CLI run (gateway mode), with undo for reversible actions and an `Ask the agent to fix` handoff on every conflict row.
|
|
@@ -28,8 +29,8 @@ dsh plugin --profile web add @linxin666/dsh-client-ui-plugin-manager
|
|
|
28
29
|
### From the repository (development)
|
|
29
30
|
|
|
30
31
|
```sh
|
|
31
|
-
git clone https://github.com/zhu1090093659/dsh-web
|
|
32
|
-
cd dsh-web
|
|
32
|
+
git clone https://github.com/zhu1090093659/dsh-web.git
|
|
33
|
+
cd dsh-web
|
|
33
34
|
pnpm install && pnpm -r build
|
|
34
35
|
dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
|
|
35
36
|
```
|
|
@@ -81,6 +82,10 @@ The contract source of truth is `src/core/service.ts` (`PluginManagerService`).
|
|
|
81
82
|
- The profile name (from `--profile` / `DSH_PROFILE`) is validated against path traversal before any file is touched; patch writes go through a backup copy plus tmp-write + atomic rename (`cordis.patch.yml.bak-plugin-manager`).
|
|
82
83
|
- The duplicate-mount safeguard writes only the profile manifest's `dsh.profile.bundles`, under the same backup + tmp-write + atomic-rename discipline as patch writes (`package.json.bak-plugin-manager`). It removes only entries the CLI just added that duplicate an existing patch-row mount, and a failed safeguard write fails the job visibly rather than silently leaving a boot-breaking state.
|
|
83
84
|
|
|
85
|
+
## Telemetry
|
|
86
|
+
|
|
87
|
+
The browser half sends one anonymous install heartbeat per UTC day to dsh-market.com: a random localStorage id plus this package's name, nothing else. The server stores only a salted hash of that id, never IP addresses, and exposes aggregate counts only. See [docs/telemetry.md](../../docs/telemetry.md) for the full contract.
|
|
88
|
+
|
|
84
89
|
## License
|
|
85
90
|
|
|
86
91
|
BSD-3-Clause.
|
package/README.zh.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
- 双通道传输:带官方安装器服务的运行时(DSHCode 与 1.0.4 checkout 版 web)走官方 `/plugin-installer`、`/plugin-control` loopback RPC 通道;npm 发布的官方 web 没有这些通道,本包的 host 半区挂载 loopback 门禁的 HTTP 网关——安装/卸载 spawn 官方 `dsh plugin` CLI(唯一写入器),启停写入 `disabled` 覆盖行。
|
|
11
11
|
- 从 npm 包名或 git 仓库 URL 安装插件,带进度。
|
|
12
12
|
- 列出已装用户插件:下次启动生效的启用开关、更新检查(npm 源走 registry)、已核验的 npm 更新与卸载。
|
|
13
|
+
- 检测旧聚合包 `@linxin666/dsh-web-ui-all`,把更新动作转换为到 `@linxin666/dsh-web-all` 的事务迁移;网关先移除旧包、安装精确版本的新包、恢复旧聚合包的层顺序,并在 `--dump-config` 通过后才报告成功。
|
|
13
14
|
- 更新前校验 DSH 运行时兼容(issue #754):更新检查读取最新版本清单声明的 DSH 最低版本(`dsh.engines.dsh`,兼容回退读顶层 `engines.dsh`),在更新按钮旁显示要求,运行 DSH 低于要求时禁用按钮;host 更新路由在启动任何 CLI 任务前若无法核实时也会返回 412 并拒绝。
|
|
14
15
|
- 官方 plugin-control 面存在时展示内置产品开关。
|
|
15
16
|
- 安装时冲突对账:官方模式对产品快照前后 diff;网关模式对每次 CLI 运行前后的 profile 层 diff,可撤销的动作给一键撤销,每条冲突都给「让 Agent 修复」转交。
|
|
@@ -28,8 +29,8 @@ dsh plugin --profile web add @linxin666/dsh-client-ui-plugin-manager
|
|
|
28
29
|
### 从仓库安装(开发调试)
|
|
29
30
|
|
|
30
31
|
```sh
|
|
31
|
-
git clone https://github.com/zhu1090093659/dsh-web
|
|
32
|
-
cd dsh-web
|
|
32
|
+
git clone https://github.com/zhu1090093659/dsh-web.git
|
|
33
|
+
cd dsh-web
|
|
33
34
|
pnpm install && pnpm -r build
|
|
34
35
|
dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
|
|
35
36
|
```
|
|
@@ -81,6 +82,10 @@ dsh plugin --profile web add link:$(pwd)/packages/dsh-plugin-manager
|
|
|
81
82
|
- profile 名(来自 `--profile` / `DSH_PROFILE`)在任何文件读写前做路径穿越校验;patch 写入走备份 + tmp + 原子 rename(`cordis.patch.yml.bak-plugin-manager`)。
|
|
82
83
|
- 重复挂载保护只写 profile 清单的 `dsh.profile.bundles`,与 patch 写入同一纪律(备份 + tmp + 原子 rename,备份为 `package.json.bak-plugin-manager`);只移除 CLI 刚加入且与既有 patch 行挂载重复的条目;保护写回失败会让任务显式失败,绝不静默留下破坏下次启动的状态。
|
|
83
84
|
|
|
85
|
+
## 数据遥测
|
|
86
|
+
|
|
87
|
+
浏览器半区每个 UTC 日向 dsh-market.com 发送一次匿名安装心跳:仅含一个 localStorage 随机 ID 与本包名,无其他数据。服务端只存储该 ID 的加盐哈希,不存 IP,且只暴露聚合计数。完整契约见 [docs/telemetry.md](../../docs/telemetry.md)。
|
|
88
|
+
|
|
84
89
|
## 许可证
|
|
85
90
|
|
|
86
91
|
BSD-3-Clause。
|
package/lib/client.js
CHANGED
|
@@ -1180,11 +1180,19 @@ window.__ModuleLoader__.load({
|
|
|
1180
1180
|
if (!isRecord(value) || !Array.isArray(value.updates)) throw new Error("plugin-manager: response must contain an updates array");
|
|
1181
1181
|
return value.updates.map((update, index) => {
|
|
1182
1182
|
if (!isRecord(update) || !isString(update.id) || !isString(update.current) || !isString(update.latest)) throw new Error(`plugin-manager: update row ${String(index)} is invalid`);
|
|
1183
|
+
const kind = update.kind === void 0 ? "update" : update.kind;
|
|
1184
|
+
if (kind !== "update" && kind !== "migrate") throw new Error(`plugin-manager: update row ${String(index)} is invalid`);
|
|
1183
1185
|
const row = {
|
|
1184
1186
|
id: update.id,
|
|
1185
1187
|
current: update.current,
|
|
1186
1188
|
latest: update.latest
|
|
1187
1189
|
};
|
|
1190
|
+
if (kind === "migrate") {
|
|
1191
|
+
if (!isString(update.target) || !isString(update.targetVersion)) throw new Error(`plugin-manager: update row ${String(index)} is invalid`);
|
|
1192
|
+
row.kind = "migrate";
|
|
1193
|
+
row.target = update.target;
|
|
1194
|
+
row.targetVersion = update.targetVersion;
|
|
1195
|
+
}
|
|
1188
1196
|
if (update.requiresDsh !== void 0) {
|
|
1189
1197
|
if (!isString(update.requiresDsh)) throw new Error(`plugin-manager: update row ${String(index)} is invalid`);
|
|
1190
1198
|
row.requiresDsh = update.requiresDsh;
|
|
@@ -1224,6 +1232,76 @@ window.__ModuleLoader__.load({
|
|
|
1224
1232
|
/** The cordis service name the browser half provides the face under. */
|
|
1225
1233
|
const PLUGIN_MANAGER_SERVICE = "pluginManager";
|
|
1226
1234
|
//#endregion
|
|
1235
|
+
//#region src/client/telemetry.ts
|
|
1236
|
+
const VISITOR_KEY = "dsh-web-ui-telemetry-visitor";
|
|
1237
|
+
const DAY_KEY_PREFIX = "dsh-web-ui-telemetry-day:";
|
|
1238
|
+
const ENDPOINT = "https://dsh-market.com/api/telemetry/event";
|
|
1239
|
+
/** The building package's version, when the bundle carries it. */
|
|
1240
|
+
function bakedVersion() {
|
|
1241
|
+
try {
|
|
1242
|
+
return "0.3.3";
|
|
1243
|
+
} catch {
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
/** Read or lazily create the anonymous visitor id; null when storage is unavailable. */
|
|
1248
|
+
function visitorId() {
|
|
1249
|
+
try {
|
|
1250
|
+
const existing = localStorage.getItem(VISITOR_KEY);
|
|
1251
|
+
if (existing && /^[A-Za-z0-9_-]{16,64}$/.test(existing)) return existing;
|
|
1252
|
+
const fresh = crypto.randomUUID().replaceAll("-", "");
|
|
1253
|
+
localStorage.setItem(VISITOR_KEY, fresh);
|
|
1254
|
+
return fresh;
|
|
1255
|
+
} catch {
|
|
1256
|
+
return null;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
/** Drop stale per-day dedup keys so localStorage does not grow forever. */
|
|
1260
|
+
function pruneDayKeys(today) {
|
|
1261
|
+
try {
|
|
1262
|
+
for (let index = localStorage.length - 1; index >= 0; index -= 1) {
|
|
1263
|
+
const key = localStorage.key(index);
|
|
1264
|
+
if (key !== null && key.startsWith(DAY_KEY_PREFIX) && key !== DAY_KEY_PREFIX + today) localStorage.removeItem(key);
|
|
1265
|
+
}
|
|
1266
|
+
} catch {}
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Fire the daily heartbeat for the given items at most once per UTC day per
|
|
1270
|
+
* browser. Never throws and never blocks the caller. Items without an explicit
|
|
1271
|
+
* version inherit the bundle's baked build version.
|
|
1272
|
+
*/
|
|
1273
|
+
function reportDailyHeartbeat(items) {
|
|
1274
|
+
try {
|
|
1275
|
+
if (items.length === 0) return;
|
|
1276
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
1277
|
+
if (navigator.webdriver) return;
|
|
1278
|
+
if (localStorage.getItem(DAY_KEY_PREFIX + today) !== null) return;
|
|
1279
|
+
const visitor = visitorId();
|
|
1280
|
+
if (visitor === null) return;
|
|
1281
|
+
pruneDayKeys(today);
|
|
1282
|
+
const payloadItems = items.map((item) => {
|
|
1283
|
+
const out = { name: item.name };
|
|
1284
|
+
const version = item.version ?? bakedVersion();
|
|
1285
|
+
if (version !== void 0) out.version = version;
|
|
1286
|
+
if (item.channel !== void 0) out.channel = item.channel;
|
|
1287
|
+
return out;
|
|
1288
|
+
});
|
|
1289
|
+
const body = JSON.stringify({
|
|
1290
|
+
kind: "heartbeat",
|
|
1291
|
+
visitor,
|
|
1292
|
+
items: payloadItems
|
|
1293
|
+
});
|
|
1294
|
+
fetch(ENDPOINT, {
|
|
1295
|
+
method: "POST",
|
|
1296
|
+
headers: { "content-type": "application/json" },
|
|
1297
|
+
body,
|
|
1298
|
+
keepalive: true
|
|
1299
|
+
}).then((response) => {
|
|
1300
|
+
if (response.ok) localStorage.setItem(DAY_KEY_PREFIX + today, "1");
|
|
1301
|
+
}).catch(() => {});
|
|
1302
|
+
} catch {}
|
|
1303
|
+
}
|
|
1304
|
+
//#endregion
|
|
1227
1305
|
//#region src/client/index.ts
|
|
1228
1306
|
const NS = "settings.pluginManager";
|
|
1229
1307
|
const CHANNEL = "/plugin-installer";
|
|
@@ -1484,6 +1562,7 @@ window.__ModuleLoader__.load({
|
|
|
1484
1562
|
}
|
|
1485
1563
|
/** Contribute the family plugin-manager tab and provide the shared face. */
|
|
1486
1564
|
function apply(ctx) {
|
|
1565
|
+
reportDailyHeartbeat([{ name: "@linxin666/dsh-client-ui-plugin-manager" }]);
|
|
1487
1566
|
ctx.effect(() => {
|
|
1488
1567
|
try {
|
|
1489
1568
|
return ctx.locale.register(NS, {
|