dsh-plugin-mesh 0.5.9 → 0.5.10
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/client/client.js +132 -28
- package/lib/_selftest-workbench.mjs +57 -23
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -1694,6 +1694,36 @@ window.__ModuleLoader__.load({
|
|
|
1694
1694
|
.mesh-demo-foot { flex: 0 0 auto; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--mesh-line); flex-wrap: wrap; }
|
|
1695
1695
|
.mesh-demo-note { margin-right: auto; font-size: 10.5px; color: var(--mesh-muted); align-self: center; }
|
|
1696
1696
|
|
|
1697
|
+
/* ── 安装确认弹窗:一次点击 → 一个说清楚要发生什么的弹窗 ── */
|
|
1698
|
+
.mesh-confirm-layer {
|
|
1699
|
+
position: fixed; inset: 0; z-index: 2147482700;
|
|
1700
|
+
display: flex; align-items: center; justify-content: center;
|
|
1701
|
+
padding: 22px; background: rgba(12, 14, 18, .46);
|
|
1702
|
+
animation: mesh-view-in 140ms ease both;
|
|
1703
|
+
}
|
|
1704
|
+
.mesh-confirm-card {
|
|
1705
|
+
width: min(430px, 100%);
|
|
1706
|
+
background: var(--mesh-surface); color: var(--mesh-fg);
|
|
1707
|
+
border: 1px solid var(--mesh-line); border-radius: 16px;
|
|
1708
|
+
box-shadow: 0 24px 70px rgba(0,0,0,.34);
|
|
1709
|
+
overflow: hidden; animation: mesh-detail-in 180ms var(--mesh-ease-out) both;
|
|
1710
|
+
}
|
|
1711
|
+
.mesh-confirm-head { display: flex; align-items: center; gap: 9px; padding: 16px 18px 6px; }
|
|
1712
|
+
.mesh-confirm-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
|
|
1713
|
+
.mesh-confirm-body { padding: 4px 18px 14px; font-size: 12px; line-height: 1.7; }
|
|
1714
|
+
.mesh-confirm-body p { margin: 0 0 8px; color: var(--mesh-muted); }
|
|
1715
|
+
.mesh-confirm-ver {
|
|
1716
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
1717
|
+
font-size: 12px; color: var(--mesh-fg);
|
|
1718
|
+
}
|
|
1719
|
+
.mesh-confirm-list { margin: 0 0 10px; padding-left: 18px; color: var(--mesh-muted); }
|
|
1720
|
+
.mesh-confirm-list li { margin: 2px 0; }
|
|
1721
|
+
.mesh-confirm-warn { color: var(--mesh-warn); font-size: 11.5px; margin: 0; }
|
|
1722
|
+
.mesh-confirm-foot {
|
|
1723
|
+
display: flex; gap: 8px; justify-content: flex-end;
|
|
1724
|
+
padding: 12px 18px 16px; border-top: 1px solid var(--mesh-line);
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1697
1727
|
/* 主页底部的派发面板:视觉上跟卡片同级,但不参与拖动/隐藏。 */
|
|
1698
1728
|
.mesh-dispatch {
|
|
1699
1729
|
margin-top: 16px;
|
|
@@ -6818,7 +6848,6 @@ window.__ModuleLoader__.load({
|
|
|
6818
6848
|
const checking = phase === "checking";
|
|
6819
6849
|
const state = (install && install.state) || "idle";
|
|
6820
6850
|
const running = state === "running";
|
|
6821
|
-
const armed = state === "armed";
|
|
6822
6851
|
const installFailed = state === "failed";
|
|
6823
6852
|
const busy = checking || running;
|
|
6824
6853
|
const pending =
|
|
@@ -6894,12 +6923,10 @@ window.__ModuleLoader__.load({
|
|
|
6894
6923
|
disabled: running,
|
|
6895
6924
|
title: installFailed
|
|
6896
6925
|
? `上次安装失败:${String(install.error || "未知原因")};点一下重试`
|
|
6897
|
-
:
|
|
6898
|
-
|
|
6899
|
-
: `一键安装 v${report.latest}(先校验 sha512,可加载检查通过才替换)`,
|
|
6900
|
-
"aria-label": armed ? `确认安装 v${report.latest}` : `安装 v${report.latest}`,
|
|
6926
|
+
: `安装 v${report.latest}(先弹确认,再下载、校验、替换)`,
|
|
6927
|
+
"aria-label": `安装 v${report.latest}`,
|
|
6901
6928
|
},
|
|
6902
|
-
installFailed ? "安装失败" : running ? "安装中…" :
|
|
6929
|
+
installFailed ? "安装失败" : running ? "安装中…" : `新版本 v${report.latest}`,
|
|
6903
6930
|
)
|
|
6904
6931
|
: null,
|
|
6905
6932
|
failed && !canInstall
|
|
@@ -6919,14 +6946,88 @@ window.__ModuleLoader__.load({
|
|
|
6919
6946
|
);
|
|
6920
6947
|
}
|
|
6921
6948
|
|
|
6949
|
+
/**
|
|
6950
|
+
* 安装确认弹窗:一次点击就打开,把"要发生什么"说清楚再动手。
|
|
6951
|
+
*
|
|
6952
|
+
* 为什么不是"点两下":旧版把第一次点击做成静默确认态,按钮文案虽然变了,
|
|
6953
|
+
* 但没有别的提示,很多人点一下就以为装完了(真机反馈:点一次就重启,
|
|
6954
|
+
* 结果还是旧版本)。确认应该是一个看得见的弹窗,而不是一个容易错过的按钮状态。
|
|
6955
|
+
*/
|
|
6956
|
+
function InstallConfirm({ report, busy, onCancel, onConfirm }) {
|
|
6957
|
+
const to = report && report.latest ? String(report.latest) : "";
|
|
6958
|
+
const from = report ? String(report.current || report.diskVersion || "?") : "?";
|
|
6959
|
+
react.useEffect(() => {
|
|
6960
|
+
const onKey = (e) => {
|
|
6961
|
+
if (e.key === "Escape" && !busy) onCancel();
|
|
6962
|
+
};
|
|
6963
|
+
document.addEventListener("keydown", onKey);
|
|
6964
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
6965
|
+
}, [busy, onCancel]);
|
|
6966
|
+
if (!report || report.hasUpdate !== true || !to) return null;
|
|
6967
|
+
return h(
|
|
6968
|
+
"div",
|
|
6969
|
+
{
|
|
6970
|
+
className: "mesh-confirm-layer",
|
|
6971
|
+
role: "dialog",
|
|
6972
|
+
"aria-modal": "true",
|
|
6973
|
+
"aria-label": `安装 v${to}`,
|
|
6974
|
+
onClick: (e) => {
|
|
6975
|
+
if (e.target === e.currentTarget && !busy) onCancel();
|
|
6976
|
+
},
|
|
6977
|
+
},
|
|
6978
|
+
h(
|
|
6979
|
+
"div",
|
|
6980
|
+
{ className: "mesh-confirm-card" },
|
|
6981
|
+
h(
|
|
6982
|
+
"div",
|
|
6983
|
+
{ className: "mesh-confirm-head" },
|
|
6984
|
+
h(Icon, { name: "arrowUp", size: 15 }),
|
|
6985
|
+
h("span", { className: "mesh-confirm-title" }, `安装 Mesh v${to}?`),
|
|
6986
|
+
),
|
|
6987
|
+
h(
|
|
6988
|
+
"div",
|
|
6989
|
+
{ className: "mesh-confirm-body" },
|
|
6990
|
+
h(
|
|
6991
|
+
"p",
|
|
6992
|
+
null,
|
|
6993
|
+
"当前 ",
|
|
6994
|
+
h("span", { className: "mesh-confirm-ver" }, `v${from}`),
|
|
6995
|
+
" → 目标 ",
|
|
6996
|
+
h("span", { className: "mesh-confirm-ver" }, `v${to}`),
|
|
6997
|
+
),
|
|
6998
|
+
h(
|
|
6999
|
+
"ul",
|
|
7000
|
+
{ className: "mesh-confirm-list" },
|
|
7001
|
+
h("li", null, "从 npm 下载,并校验 sha512"),
|
|
7002
|
+
h("li", null, "可加载检查通过后才替换文件;旧版本会备份,可回滚"),
|
|
7003
|
+
h("li", null, "装完在顶部点「重启生效」;只改界面时会提示重载即可"),
|
|
7004
|
+
),
|
|
7005
|
+
h("p", { className: "mesh-confirm-warn" }, "重启 DSH 会中断当前会话。"),
|
|
7006
|
+
),
|
|
7007
|
+
h(
|
|
7008
|
+
"div",
|
|
7009
|
+
{ className: "mesh-confirm-foot" },
|
|
7010
|
+
h(Button, { variant: "ghost", disabled: busy, onClick: onCancel }, "取消"),
|
|
7011
|
+
h(
|
|
7012
|
+
Button,
|
|
7013
|
+
{ variant: "primary", loading: busy, onClick: onConfirm },
|
|
7014
|
+
busy ? "安装中…" : `安装 v${to}`,
|
|
7015
|
+
),
|
|
7016
|
+
),
|
|
7017
|
+
),
|
|
7018
|
+
);
|
|
7019
|
+
}
|
|
7020
|
+
|
|
6922
7021
|
/**
|
|
6923
7022
|
* 检查更新的容器:进主页**静默**查一次(宿主机缓存 30 分钟),点一下强查。
|
|
6924
|
-
*
|
|
7023
|
+
* 点「新版本」→ 弹确认框 → 点「安装」才真的动手。
|
|
6925
7024
|
*/
|
|
6926
7025
|
function UpdateLink({ push }) {
|
|
6927
7026
|
const [phase, setPhase] = react.useState("idle");
|
|
6928
7027
|
const [report, setReport] = react.useState(null);
|
|
6929
7028
|
const [install, setInstall] = react.useState({ state: "idle", error: "" });
|
|
7029
|
+
// 安装确认弹窗:点「新版本」打开,点「安装」才真的开始
|
|
7030
|
+
const [confirmOpen, setConfirmOpen] = react.useState(false);
|
|
6930
7031
|
const alive = react.useRef(true);
|
|
6931
7032
|
const run = react.useCallback(
|
|
6932
7033
|
async (force, announce) => {
|
|
@@ -6970,19 +7071,9 @@ window.__ModuleLoader__.load({
|
|
|
6970
7071
|
alive.current = false;
|
|
6971
7072
|
};
|
|
6972
7073
|
}, [run]);
|
|
6973
|
-
// 确认态 6 秒后自动取消:避免"上次点了一半"的按钮一直挂着。
|
|
6974
|
-
react.useEffect(() => {
|
|
6975
|
-
if (install.state !== "armed") return;
|
|
6976
|
-
const timer = setTimeout(() => setInstall({ state: "idle", error: "" }), 6000);
|
|
6977
|
-
return () => clearTimeout(timer);
|
|
6978
|
-
}, [install.state]);
|
|
6979
|
-
|
|
6980
7074
|
const startInstall = react.useCallback(async () => {
|
|
6981
7075
|
if (!report || report.ok !== true || !report.latest) return;
|
|
6982
|
-
|
|
6983
|
-
setInstall({ state: "armed", error: "" });
|
|
6984
|
-
return;
|
|
6985
|
-
}
|
|
7076
|
+
setConfirmOpen(false);
|
|
6986
7077
|
setInstall({ state: "running", error: "" });
|
|
6987
7078
|
try {
|
|
6988
7079
|
const r = await api("/upgrade", { version: report.latest });
|
|
@@ -7008,7 +7099,7 @@ window.__ModuleLoader__.load({
|
|
|
7008
7099
|
setInstall({ state: "failed", error: String((e && e.message) || e) });
|
|
7009
7100
|
push("error", `安装失败:${String((e && e.message) || e)}`);
|
|
7010
7101
|
}
|
|
7011
|
-
}, [
|
|
7102
|
+
}, [push, report, run]);
|
|
7012
7103
|
|
|
7013
7104
|
const restart = react.useCallback(async () => {
|
|
7014
7105
|
try {
|
|
@@ -7040,15 +7131,27 @@ window.__ModuleLoader__.load({
|
|
|
7040
7131
|
}
|
|
7041
7132
|
}, [push]);
|
|
7042
7133
|
|
|
7043
|
-
return h(
|
|
7044
|
-
|
|
7045
|
-
|
|
7046
|
-
|
|
7047
|
-
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7134
|
+
return h(
|
|
7135
|
+
react.Fragment,
|
|
7136
|
+
null,
|
|
7137
|
+
h(UpdateLinkView, {
|
|
7138
|
+
phase,
|
|
7139
|
+
report,
|
|
7140
|
+
install,
|
|
7141
|
+
onCheck: () => run(true, true),
|
|
7142
|
+
onInstall: () => setConfirmOpen(true),
|
|
7143
|
+
onRestart: restart,
|
|
7144
|
+
onReload: reload,
|
|
7145
|
+
}),
|
|
7146
|
+
confirmOpen
|
|
7147
|
+
? h(InstallConfirm, {
|
|
7148
|
+
report,
|
|
7149
|
+
busy: install.state === "running",
|
|
7150
|
+
onCancel: () => setConfirmOpen(false),
|
|
7151
|
+
onConfirm: startInstall,
|
|
7152
|
+
})
|
|
7153
|
+
: null,
|
|
7154
|
+
);
|
|
7052
7155
|
}
|
|
7053
7156
|
|
|
7054
7157
|
function HomeMetaLinks({ state, push }) {
|
|
@@ -8763,6 +8866,7 @@ window.__ModuleLoader__.load({
|
|
|
8763
8866
|
HomeMetaLinks,
|
|
8764
8867
|
UpdateLink,
|
|
8765
8868
|
UpdateLinkView,
|
|
8869
|
+
InstallConfirm,
|
|
8766
8870
|
FeedbackLink,
|
|
8767
8871
|
feedbackBody,
|
|
8768
8872
|
feedbackIssueUrl,
|
|
@@ -145,6 +145,7 @@ const {
|
|
|
145
145
|
HomeSwitchBar,
|
|
146
146
|
UpdateLink,
|
|
147
147
|
UpdateLinkView,
|
|
148
|
+
InstallConfirm,
|
|
148
149
|
FeedbackLink,
|
|
149
150
|
DemoOverlay,
|
|
150
151
|
ApprovalBar,
|
|
@@ -1157,30 +1158,63 @@ test("有更新:一行小字「新版本 v0.6.0」,不铺命令、不占卡
|
|
|
1157
1158
|
assert.ok(!txt.includes("curl"), "升级命令不再铺在页面上");
|
|
1158
1159
|
});
|
|
1159
1160
|
|
|
1160
|
-
test("
|
|
1161
|
-
let
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
});
|
|
1177
|
-
return btn;
|
|
1178
|
-
};
|
|
1179
|
-
const armed = view({ state: "armed", error: "" });
|
|
1180
|
-
const btn = findInstallBtn(armed);
|
|
1181
|
-
assert.ok(btn, "确认态要有一个「确认安装 v0.6.0」按钮");
|
|
1161
|
+
test("一键安装:点「新版本」只打开确认弹窗,不会直接装", () => {
|
|
1162
|
+
let requested = 0;
|
|
1163
|
+
const el = UpdateLinkView({
|
|
1164
|
+
phase: "done",
|
|
1165
|
+
report: updateReport,
|
|
1166
|
+
install: { state: "idle", error: "" },
|
|
1167
|
+
onCheck: noop,
|
|
1168
|
+
onInstall: () => {
|
|
1169
|
+
requested += 1;
|
|
1170
|
+
},
|
|
1171
|
+
});
|
|
1172
|
+
let btn = null;
|
|
1173
|
+
walk(el, (n) => {
|
|
1174
|
+
if (n.type === "button" && textOf(n).join("").includes("新版本 v0.6.0")) btn = n;
|
|
1175
|
+
});
|
|
1176
|
+
assert.ok(btn, "缺少「新版本 v0.6.0」入口");
|
|
1182
1177
|
btn.props.onClick();
|
|
1183
|
-
assert.equal(
|
|
1178
|
+
assert.equal(requested, 1, "点击入口应当是打开确认,而不是直接安装");
|
|
1179
|
+
});
|
|
1180
|
+
|
|
1181
|
+
test("确认弹窗:说清版本、校验与重启代价,安装/取消各走各的", () => {
|
|
1182
|
+
let confirmed = 0;
|
|
1183
|
+
let cancelled = 0;
|
|
1184
|
+
const el = InstallConfirm({
|
|
1185
|
+
report: updateReport,
|
|
1186
|
+
busy: false,
|
|
1187
|
+
onCancel: () => {
|
|
1188
|
+
cancelled += 1;
|
|
1189
|
+
},
|
|
1190
|
+
onConfirm: () => {
|
|
1191
|
+
confirmed += 1;
|
|
1192
|
+
},
|
|
1193
|
+
});
|
|
1194
|
+
const txt = textOf(el).join(" ");
|
|
1195
|
+
assert.ok(txt.includes("安装 Mesh v0.6.0"), txt);
|
|
1196
|
+
assert.ok(txt.includes("v0.5.6") && txt.includes("v0.6.0"), txt);
|
|
1197
|
+
assert.ok(txt.includes("sha512"), "要说明会做完整性校验");
|
|
1198
|
+
assert.ok(txt.includes("备份"), "要说明旧版可回滚");
|
|
1199
|
+
assert.ok(txt.includes("重启"), "要提前说重启代价");
|
|
1200
|
+
let installBtn = null;
|
|
1201
|
+
let cancelBtn = null;
|
|
1202
|
+
walk(el, (n) => {
|
|
1203
|
+
const label = n.type === "button" ? textOf(n).join("") : "";
|
|
1204
|
+
if (label === "安装 v0.6.0") installBtn = n;
|
|
1205
|
+
if (label === "取消") cancelBtn = n;
|
|
1206
|
+
});
|
|
1207
|
+
assert.ok(installBtn && cancelBtn, "缺少安装或取消按钮");
|
|
1208
|
+
installBtn.props.onClick();
|
|
1209
|
+
cancelBtn.props.onClick();
|
|
1210
|
+
assert.equal(confirmed, 1);
|
|
1211
|
+
assert.equal(cancelled, 1);
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
test("确认弹窗安装中:按钮显示「安装中…」,取消被禁用", () => {
|
|
1215
|
+
const el = InstallConfirm({ report: updateReport, busy: true, onCancel: noop, onConfirm: noop });
|
|
1216
|
+
const txt = textOf(el).join(" ");
|
|
1217
|
+
assert.ok(txt.includes("安装中…"), txt);
|
|
1184
1218
|
});
|
|
1185
1219
|
|
|
1186
1220
|
test("安装中 / 安装失败:状态写在字面上,失败不悄悄回到「有新版本」", () => {
|
package/lib/index.js
CHANGED
|
@@ -108,7 +108,7 @@ import {
|
|
|
108
108
|
export const name = "dsh-plugin-mesh";
|
|
109
109
|
export const inject = ["tools", "webServer"];
|
|
110
110
|
|
|
111
|
-
const VERSION = "0.5.
|
|
111
|
+
const VERSION = "0.5.10";
|
|
112
112
|
// 诊断用:进程启动时间 + 入口真实路径。磁盘上的版本**不在这里缓存** ——
|
|
113
113
|
// 升级之后进程还跑旧代码,版本号必须现读磁盘才能立刻反映出来(真踩过:
|
|
114
114
|
// 磁盘升到 0.5.1,进程还在 0.5.0,界面显示 0.5.0)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-mesh",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "把跑不完的活交给另一台电脑;跑完,结果回到你面前。两台装了 DSH 的电脑各装一次,自动互相发现,任务派过去由对端的 agent 执行,结果派回来。Hand a long task to another machine: your DSH instances find each other, the peer runs it, and the result comes back. No pairing codes, no IPs, no Tailscale client.",
|
|
6
6
|
"license": "MIT",
|