dsh-multipane 1.0.12 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +13 -0
  2. package/lib/client.js +218 -45
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -246,6 +246,19 @@ C:\Users\weiai\.dsh\plugin-src\_probe\sync-client.ps1 -Push # 台式机 ->
246
246
 
247
247
  ## 更新记录
248
248
 
249
+ ### 1.0.14(2026-11-10)
250
+ - **设置页内直接更新**:检查到新版本后**弹窗**显示「当前版本 → 新版本」,弹窗里就有「立即更新」按钮,
251
+ 点它由插件市场装包并在弹窗里跑进度条,完成后给「刷新页面」。全程不用去插件页输入包名。
252
+ - **最新版只提示一句话**:`已是最新版本(X)`,不弹窗、不打扰。
253
+ - **市场观察期可强制**:刚发布的版本市场会先观察一段时间;这时弹窗仍会出现,并多一个「强制更新」
254
+ (走市场 API 的 `force: true`),不想等就直接装。
255
+ - 市场不可用(没装 dshmarket)时,弹窗说明「本机没有可用插件市场,需手动安装」,不会假装能更新。
256
+
257
+ ### 1.0.13(2026-11-10)
258
+ - 修「明明有新版本却报已是最新」:插件市场对新发布的版本有**观察期**(release-age 策略),
259
+ 这段时间它返回 `updateAvailable: false` 但 `latestVersion` 更高。现在会明确提示「新版本 X 已发布,
260
+ 市场还在观察期,过几分钟再检查」,而不是把它和「真的没有新版」混成一回事。
261
+
249
262
  ### 1.0.12(2026-11-10)
250
263
  - 修上一版读取更新结果的两个字段:`restartRequired` 实际在 `outcome` 里、失败原因在 `failure.message`(不在顶层)。
251
264
  之前会把「需要重启」误判成「刷新即可」,失败时也只显示状态名而不是市场给的原因。
package/lib/client.js CHANGED
@@ -17,7 +17,7 @@ window.__ModuleLoader__.load({
17
17
  */
18
18
  const PLUGIN_LABEL = "多栏视图";
19
19
  /* 与 package.json 的 version 必须一致(发版时两处同改;check-names.cjs 会校验)。 */
20
- const PLUGIN_VERSION = "1.0.12";
20
+ const PLUGIN_VERSION = "1.0.14";
21
21
  const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
22
22
  /* 插件市场的公开更新 API v1(dshmarket 提供,见其 UPDATE-API-V1.md)。
23
23
  它自己负责装包/校验版本/回滚,我们只负责触发和显示结果——
@@ -1808,6 +1808,23 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
1808
1808
  .dsv-update-text[data-phase="done"]{opacity:1;color:#7bd88f}
1809
1809
  .dsv-update-text[data-phase="available"],.dsv-update-text[data-phase="available-manual"]{opacity:1;color:#e8c07a}
1810
1810
  .dsv-update-text[data-phase="error"]{opacity:.95;color:#e08888}
1811
+ /* 更新弹窗:发现新版 → 弹窗里看版本、点更新、看进度、完成后刷新 */
1812
+ .dsv-modal-mask{position:fixed;inset:0;background:rgba(0,0,0,.62);z-index:9999;display:flex;align-items:center;justify-content:center}
1813
+ .dsv-modal{width:min(430px,90vw);border-radius:14px;border:1px solid var(--dsh-border-color,rgba(128,128,128,.32));background:var(--dsv-page-bg,#1b1b1d);box-shadow:0 24px 60px -20px rgba(0,0,0,.85);padding:18px 20px;display:flex;flex-direction:column;gap:12px}
1814
+ .dsv-modal-title{font-size:15px;font-weight:600;line-height:1.4}
1815
+ .dsv-modal-body{display:flex;flex-direction:column;gap:7px;font-size:12.5px;line-height:1.65;opacity:.88}
1816
+ .dsv-modal-row{display:flex;justify-content:space-between;gap:12px}
1817
+ .dsv-modal-row b{font-weight:600}
1818
+ .dsv-modal-note{font-size:11.5px;line-height:1.65;color:#e8c07a;opacity:.95}
1819
+ .dsv-modal-err{font-size:11.5px;line-height:1.65;color:#e08888}
1820
+ .dsv-modal-bar{height:4px;border-radius:2px;background:rgba(255,255,255,.12);overflow:hidden}
1821
+ .dsv-modal-bar > i{display:block;height:100%;border-radius:2px;background:var(--dsh-accent-color,#4a8cf7);transition:width .2s ease}
1822
+ .dsv-modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:2px}
1823
+ .dsv-modal-actions button{height:30px;border-radius:8px;font-size:12.5px;font-family:inherit;cursor:pointer;padding:0 14px;border:1px solid var(--dsh-border-color,rgba(128,128,128,.32));background:rgba(255,255,255,.03);color:inherit}
1824
+ .dsv-modal-actions button:hover{background:rgba(255,255,255,.08)}
1825
+ .dsv-modal-actions button[data-primary="1"]{background:var(--dsh-accent-color,#4a8cf7);border-color:transparent;color:#fff;font-weight:500}
1826
+ .dsv-modal-actions button[data-primary="1"]:hover{filter:brightness(1.08)}
1827
+ .dsv-modal-actions button:disabled{opacity:.55;cursor:default}
1811
1828
  .dsv-page-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
1812
1829
  .dsv-page-title{font-size:19px;font-weight:700;letter-spacing:.01em;margin:0}
1813
1830
  .dsv-badge{display:inline-flex;align-items:center;gap:5px;height:20px;padding:0 8px;border-radius:999px;font-size:11px;font-weight:600;border:1px solid transparent}
@@ -6400,9 +6417,32 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6400
6417
  它自己负责装包、校验版本、保留回滚点,并且明确返回 refreshRequired / restartRequired。
6401
6418
  市场没装或接口不可用时,回退成「直接查 npm registry + 提示手动安装」。
6402
6419
  注意:**不要自己跑 npm install** —— 会覆盖正在运行的插件文件,破坏市场的一致性校验。 */
6403
- const [update, setUpdate] = react.useState({ phase: "idle", text: "", canUpdate: false, opId: "" });
6420
+ /* phase: idle | checking | latest | available | updating | done | error
6421
+ modal: 是否显示弹窗;forceHint: 市场还在观察期,可强制更新;progress: 0-100 */
6422
+ const [update, setUpdate] = react.useState({
6423
+ phase: "idle",
6424
+ text: "",
6425
+ canUpdate: false,
6426
+ opId: "",
6427
+ modal: false,
6428
+ installed: PLUGIN_VERSION,
6429
+ latest: "",
6430
+ forceHint: "",
6431
+ progress: null
6432
+ });
6433
+ const closeModal = () => setUpdate((prev) => ({ ...prev, modal: false }));
6404
6434
  const checkUpdate = async () => {
6405
- setUpdate({ phase: "checking", text: "正在检查…", canUpdate: false, opId: "" });
6435
+ setUpdate({
6436
+ phase: "checking",
6437
+ text: "正在检查…",
6438
+ canUpdate: false,
6439
+ opId: "",
6440
+ modal: false,
6441
+ installed: PLUGIN_VERSION,
6442
+ latest: "",
6443
+ forceHint: "",
6444
+ progress: null
6445
+ });
6406
6446
  try {
6407
6447
  const capsRes = await fetch(MARKET_CAPS_URL, { cache: "no-store" });
6408
6448
  if (capsRes.ok === true) {
@@ -6415,11 +6455,45 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6415
6455
  if (info === void 0 || info === null) throw new Error("返回里没有版本信息");
6416
6456
  const installed = String(info.installedVersion ?? PLUGIN_VERSION);
6417
6457
  const latest = String(info.latestVersion ?? installed);
6418
- setUpdate(
6419
- info.updateAvailable === true
6420
- ? { phase: "available", text: `发现新版本 ${latest}(当前 ${installed})`, canUpdate: true, opId: "" }
6421
- : { phase: "latest", text: `已是最新版本(${installed})`, canUpdate: false, opId: "" }
6422
- );
6458
+ if (info.updateAvailable === true) {
6459
+ setUpdate({
6460
+ phase: "available",
6461
+ text: `发现新版本 ${latest}`,
6462
+ canUpdate: true,
6463
+ opId: "",
6464
+ modal: true,
6465
+ installed,
6466
+ latest,
6467
+ forceHint: "",
6468
+ progress: null
6469
+ });
6470
+ } else if (compareVersion(latest, installed) > 0) {
6471
+ /* 市场看到了更新的版本但暂不放行(新版本观察期,防供应链投毒)。
6472
+ 这种情况照样弹窗,但把「强制更新」摆出来——否则用户只能干等。 */
6473
+ setUpdate({
6474
+ phase: "available",
6475
+ text: `新版本 ${latest} 已发布(市场观察期)`,
6476
+ canUpdate: true,
6477
+ opId: "",
6478
+ modal: true,
6479
+ installed,
6480
+ latest,
6481
+ forceHint: "插件市场对刚发布的版本有观察期,通常十几分钟到几十分钟。可以稍后再试,也可以直接点「强制更新」现在就装。",
6482
+ progress: null
6483
+ });
6484
+ } else {
6485
+ setUpdate({
6486
+ phase: "latest",
6487
+ text: `已是最新版本(${installed})`,
6488
+ canUpdate: false,
6489
+ opId: "",
6490
+ modal: false,
6491
+ installed,
6492
+ latest,
6493
+ forceHint: "",
6494
+ progress: null
6495
+ });
6496
+ }
6423
6497
  return;
6424
6498
  }
6425
6499
  const res = await fetch(`${NPM_LATEST_URL}?t=${Date.now()}`, { cache: "no-store" });
@@ -6429,22 +6503,27 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6429
6503
  if (latest === "") throw new Error("返回里没有版本号");
6430
6504
  const newer = compareVersion(latest, PLUGIN_VERSION) > 0;
6431
6505
  setUpdate({
6432
- phase: newer ? "available-manual" : "latest",
6433
- text: newer ? `发现新版本 ${latest}(当前 ${PLUGIN_VERSION}):到「插件」页填 ${PKG_NAME}@${latest} 安装` : `已是最新版本(${PLUGIN_VERSION})`,
6506
+ phase: newer ? "available" : "latest",
6507
+ text: newer ? `发现新版本 ${latest}` : `已是最新版本(${PLUGIN_VERSION})`,
6434
6508
  canUpdate: false,
6435
- opId: ""
6509
+ opId: "",
6510
+ modal: newer,
6511
+ installed: PLUGIN_VERSION,
6512
+ latest,
6513
+ forceHint: newer ? "本机没有可用的插件市场(dshmarket),无法在这里自动安装。到「插件」页填 " + PKG_NAME + "@" + latest + " 安装。" : "",
6514
+ progress: null
6436
6515
  });
6437
6516
  } catch (err) {
6438
6517
  setUpdate({ phase: "error", text: `检查失败:${String((err && err.message) || err)}`, canUpdate: false, opId: "" });
6439
6518
  }
6440
6519
  };
6441
- const runUpdate = async () => {
6442
- setUpdate({ phase: "updating", text: "正在更新…", canUpdate: false, opId: "" });
6520
+ const runUpdate = async (force) => {
6521
+ setUpdate((prev) => ({ ...prev, phase: "updating", text: "正在更新…", canUpdate: false, progress: 0 }));
6443
6522
  try {
6444
6523
  const res = await fetch(MARKET_UPDATES_URL, {
6445
6524
  method: "POST",
6446
6525
  headers: { "Content-Type": "application/json" },
6447
- body: JSON.stringify({ packageName: PKG_NAME })
6526
+ body: JSON.stringify(force === true ? { packageName: PKG_NAME, force: true } : { packageName: PKG_NAME })
6448
6527
  });
6449
6528
  if (res.status !== 202) {
6450
6529
  let detail = "";
@@ -6472,25 +6551,54 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6472
6551
  /* restartRequired / refreshRequired 都在 outcome 里(实测 2026-11-10),不在顶层 */
6473
6552
  const outcome = op.outcome === null || op.outcome === void 0 ? {} : op.outcome;
6474
6553
  const needRestart = outcome.restartRequired === true;
6475
- setUpdate({
6554
+ setUpdate((prev) => ({
6555
+ ...prev,
6476
6556
  phase: "done",
6477
6557
  text: `已更新${got === "" ? "" : "到 " + got}${needRestart ? ",重启 App 后生效" : ",刷新页面即可生效"}`,
6478
6558
  canUpdate: false,
6479
- opId
6480
- });
6559
+ opId,
6560
+ modal: true,
6561
+ progress: 100,
6562
+ forceHint: ""
6563
+ }));
6481
6564
  return;
6482
6565
  }
6483
6566
  if (state === "failed" || state === "cancelled" || state === "rolled-back") {
6484
6567
  /* 失败详情在 failure: {code, message, retryable}(实测 2026-11-10) */
6485
6568
  const fail = op.failure === null || op.failure === void 0 ? {} : op.failure;
6569
+ const code = String(fail.code ?? "");
6570
+ /* 这三种都是「市场还在观察这个版本」而不是真失败 —— 给「强制更新」而不是报错 */
6571
+ if (code === "RELEASE_TOO_FRESH" || code === "VERSION_UNCHANGED" || code === "OPERATION_BUSY") {
6572
+ setUpdate((prev) => ({
6573
+ ...prev,
6574
+ phase: "available",
6575
+ text: `新版本 ${prev.latest}(市场观察期)`,
6576
+ canUpdate: true,
6577
+ progress: null,
6578
+ forceHint: "插件市场还没放行这个版本。点「强制更新」现在装,或稍后再试。"
6579
+ }));
6580
+ return;
6581
+ }
6486
6582
  throw new Error(String(fail.message ?? fail.code ?? state));
6487
6583
  }
6488
6584
  const pct = op.progress === null || op.progress === void 0 ? void 0 : op.progress.percent;
6489
- setUpdate((prev) => ({ ...prev, text: typeof pct === "number" ? `正在更新… ${Math.round(pct)}%` : "正在更新…" }));
6585
+ setUpdate((prev) => ({
6586
+ ...prev,
6587
+ text: typeof pct === "number" ? `正在更新… ${Math.round(pct)}%` : "正在更新…",
6588
+ progress: typeof pct === "number" ? pct : prev.progress
6589
+ }));
6490
6590
  }
6491
6591
  throw new Error("等待超时,请到插件市场查看结果");
6492
6592
  } catch (err) {
6493
- setUpdate({ phase: "error", text: `更新失败:${String((err && err.message) || err)}`, canUpdate: false, opId: "" });
6593
+ setUpdate((prev) => ({
6594
+ ...prev,
6595
+ phase: "error",
6596
+ text: `更新失败:${String((err && err.message) || err)}`,
6597
+ canUpdate: false,
6598
+ opId: "",
6599
+ modal: true,
6600
+ progress: null
6601
+ }));
6494
6602
  }
6495
6603
  };
6496
6604
  return h(
@@ -6538,31 +6646,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6538
6646
  onClick: checkUpdate
6539
6647
  },
6540
6648
  update.phase === "checking" ? "检查中…" : "检查更新"
6541
- ),
6542
- update.canUpdate === true
6543
- ? h(
6544
- "button",
6545
- { type: "button", className: "dsv-mini-btn", "data-on": "1", onClick: runUpdate },
6546
- "立即更新"
6547
- )
6548
- : null,
6549
- update.phase === "done"
6550
- ? h(
6551
- "button",
6552
- {
6553
- type: "button",
6554
- className: "dsv-mini-btn",
6555
- onClick: () => {
6556
- try {
6557
- window.location.reload();
6558
- } catch {
6559
- /* 忽略 */
6560
- }
6561
- }
6562
- },
6563
- "刷新页面"
6564
- )
6565
- : null
6649
+ )
6566
6650
  ),
6567
6651
  /* ── 区块一:基本 ── */
6568
6652
  h(
@@ -6782,7 +6866,96 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6782
6866
  },
6783
6867
  h("span", { className: "dsv-enter-label" }, "进入会话")
6784
6868
  )
6785
- )
6869
+ ),
6870
+ /* 更新弹窗:发现新版本时弹出来,版本对比 + 进度 + 一键更新/刷新,全程不用离开设置页 */
6871
+ update.modal === true
6872
+ ? h(
6873
+ "div",
6874
+ { className: "dsv-modal-mask", onClick: closeModal },
6875
+ h(
6876
+ "div",
6877
+ {
6878
+ className: "dsv-modal",
6879
+ onClick: (event) => {
6880
+ event.stopPropagation();
6881
+ }
6882
+ },
6883
+ h(
6884
+ "div",
6885
+ { className: "dsv-modal-title" },
6886
+ update.phase === "done" ? "更新完成" : update.phase === "error" ? "更新没有完成" : `发现新版本 ${update.latest}`
6887
+ ),
6888
+ h(
6889
+ "div",
6890
+ { className: "dsv-modal-body" },
6891
+ h(
6892
+ "div",
6893
+ { className: "dsv-modal-row" },
6894
+ h("span", null, "当前版本"),
6895
+ h("b", null, update.installed)
6896
+ ),
6897
+ update.phase === "done" || update.phase === "error"
6898
+ ? null
6899
+ : h(
6900
+ "div",
6901
+ { className: "dsv-modal-row" },
6902
+ h("span", null, "新版本"),
6903
+ h("b", null, update.latest)
6904
+ ),
6905
+ update.progress === null || update.progress === void 0
6906
+ ? null
6907
+ : h(
6908
+ "div",
6909
+ { className: "dsv-modal-bar" },
6910
+ h("i", { style: { width: `${Math.max(4, Math.min(100, update.progress))}%` } })
6911
+ ),
6912
+ update.forceHint !== ""
6913
+ ? h("div", { className: "dsv-modal-note" }, update.forceHint)
6914
+ : null,
6915
+ update.phase === "done" ? h("div", null, update.text) : null,
6916
+ update.phase === "error" ? h("div", { className: "dsv-modal-err" }, update.text) : null
6917
+ ),
6918
+ h(
6919
+ "div",
6920
+ { className: "dsv-modal-actions" },
6921
+ update.phase === "done"
6922
+ ? h(
6923
+ "button",
6924
+ {
6925
+ type: "button",
6926
+ "data-primary": "1",
6927
+ onClick: () => {
6928
+ try {
6929
+ window.location.reload();
6930
+ } catch {
6931
+ /* 忽略 */
6932
+ }
6933
+ }
6934
+ },
6935
+ "刷新页面"
6936
+ )
6937
+ : [
6938
+ h(
6939
+ "button",
6940
+ { key: "later", type: "button", onClick: closeModal },
6941
+ "稍后"
6942
+ ),
6943
+ h(
6944
+ "button",
6945
+ {
6946
+ key: "go",
6947
+ type: "button",
6948
+ "data-primary": "1",
6949
+ disabled: update.phase === "updating" || update.canUpdate !== true,
6950
+ onClick: () => runUpdate(update.forceHint !== "")
6951
+ },
6952
+ update.phase === "updating" ? "更新中…" : update.forceHint !== "" && update.canUpdate === true ? "强制更新" : "立即更新"
6953
+ )
6954
+ ]
6955
+ )
6956
+ )
6957
+ )
6958
+ : null
6786
6959
  );
6787
6960
  }
6788
6961
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-multipane",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Hermes-style tabbed workspace for the DSH main area: drag sessions in, split into up to four columns, close tabs.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",