dsh-multipane 1.0.13 → 1.0.15

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 +14 -0
  2. package/lib/client.js +214 -50
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -246,6 +246,20 @@ C:\Users\weiai\.dsh\plugin-src\_probe\sync-client.ps1 -Push # 台式机 ->
246
246
 
247
247
  ## 更新记录
248
248
 
249
+ ### 1.0.15(2026-11-10)
250
+ - 修 1.0.11~1.0.14 里「立即更新」必然失败的问题:插件市场的 POST 响应把 `operationId` 放在 `operation` 对象里
251
+ (`{schema, operation:{operationId}}`),之前读的是顶层,所以每次都报「没有返回操作 id」。
252
+ - 观察期不再承诺「强制更新」:实测市场即使收到 `force: true` 仍会拒绝(`OPERATION_BUSY`,该版本被 held),
253
+ 这是市场侧硬限制。现在文案改成「过一会儿点重新检查」,按钮也换成「重新检查」,不误导。
254
+
255
+ ### 1.0.14(2026-11-10)
256
+ - **设置页内直接更新**:检查到新版本后**弹窗**显示「当前版本 → 新版本」,弹窗里就有「立即更新」按钮,
257
+ 点它由插件市场装包并在弹窗里跑进度条,完成后给「刷新页面」。全程不用去插件页输入包名。
258
+ - **最新版只提示一句话**:`已是最新版本(X)`,不弹窗、不打扰。
259
+ - **市场观察期可强制**:刚发布的版本市场会先观察一段时间;这时弹窗仍会出现,并多一个「强制更新」
260
+ (走市场 API 的 `force: true`),不想等就直接装。
261
+ - 市场不可用(没装 dshmarket)时,弹窗说明「本机没有可用插件市场,需手动安装」,不会假装能更新。
262
+
249
263
  ### 1.0.13(2026-11-10)
250
264
  - 修「明明有新版本却报已是最新」:插件市场对新发布的版本有**观察期**(release-age 策略),
251
265
  这段时间它返回 `updateAvailable: false` 但 `latestVersion` 更高。现在会明确提示「新版本 X 已发布,
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.13";
20
+ const PLUGIN_VERSION = "1.0.15";
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) {
@@ -6416,19 +6456,43 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6416
6456
  const installed = String(info.installedVersion ?? PLUGIN_VERSION);
6417
6457
  const latest = String(info.latestVersion ?? installed);
6418
6458
  if (info.updateAvailable === true) {
6419
- setUpdate({ phase: "available", text: `发现新版本 ${latest}(当前 ${installed})`, canUpdate: true, opId: "" });
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
+ });
6420
6470
  } else if (compareVersion(latest, installed) > 0) {
6421
- /* 市场已经看到更新的版本,但暂不放行:新发布的版本有观察期(release-age 策略,
6422
- 防供应链投毒)。这种情况不能报「已是最新」——版本号明明更高,
6423
- 用户会以为检查坏了(2026-11-10 实测:1.0.12 发布后立刻查就是这样)。 */
6471
+ /* 市场看到了更新的版本但暂不放行(新版本观察期,防供应链投毒)。
6472
+ 这种情况照样弹窗,但把「强制更新」摆出来——否则用户只能干等。 */
6424
6473
  setUpdate({
6425
- phase: "available-manual",
6426
- text: `新版本 ${latest} 已发布,插件市场还在观察期(新版本有等待策略),过几分钟再点一次检查`,
6427
- canUpdate: false,
6428
- opId: ""
6474
+ phase: "available",
6475
+ text: `新版本 ${latest} 已发布(市场观察期)`,
6476
+ canUpdate: true,
6477
+ opId: "",
6478
+ modal: true,
6479
+ installed,
6480
+ latest,
6481
+ forceHint: "插件市场对刚发布的版本有观察期(通常十几分钟到几小时,防供应链投毒),这段时间装会被市场拒绝。过一会儿点「重新检查」,放行后再更新即可。",
6482
+ progress: null
6429
6483
  });
6430
6484
  } else {
6431
- setUpdate({ phase: "latest", text: `已是最新版本(${installed})`, canUpdate: false, opId: "" });
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
+ });
6432
6496
  }
6433
6497
  return;
6434
6498
  }
@@ -6439,22 +6503,27 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6439
6503
  if (latest === "") throw new Error("返回里没有版本号");
6440
6504
  const newer = compareVersion(latest, PLUGIN_VERSION) > 0;
6441
6505
  setUpdate({
6442
- phase: newer ? "available-manual" : "latest",
6443
- text: newer ? `发现新版本 ${latest}(当前 ${PLUGIN_VERSION}):到「插件」页填 ${PKG_NAME}@${latest} 安装` : `已是最新版本(${PLUGIN_VERSION})`,
6506
+ phase: newer ? "available" : "latest",
6507
+ text: newer ? `发现新版本 ${latest}` : `已是最新版本(${PLUGIN_VERSION})`,
6444
6508
  canUpdate: false,
6445
- opId: ""
6509
+ opId: "",
6510
+ modal: newer,
6511
+ installed: PLUGIN_VERSION,
6512
+ latest,
6513
+ forceHint: newer ? "本机没有可用的插件市场(dshmarket),无法在这里自动安装。到「插件」页填 " + PKG_NAME + "@" + latest + " 安装。" : "",
6514
+ progress: null
6446
6515
  });
6447
6516
  } catch (err) {
6448
6517
  setUpdate({ phase: "error", text: `检查失败:${String((err && err.message) || err)}`, canUpdate: false, opId: "" });
6449
6518
  }
6450
6519
  };
6451
- const runUpdate = async () => {
6452
- setUpdate({ phase: "updating", text: "正在更新…", canUpdate: false, opId: "" });
6520
+ const runUpdate = async (force) => {
6521
+ setUpdate((prev) => ({ ...prev, phase: "updating", text: "正在更新…", canUpdate: false, progress: 0 }));
6453
6522
  try {
6454
6523
  const res = await fetch(MARKET_UPDATES_URL, {
6455
6524
  method: "POST",
6456
6525
  headers: { "Content-Type": "application/json" },
6457
- body: JSON.stringify({ packageName: PKG_NAME })
6526
+ body: JSON.stringify(force === true ? { packageName: PKG_NAME, force: true } : { packageName: PKG_NAME })
6458
6527
  });
6459
6528
  if (res.status !== 202) {
6460
6529
  let detail = "";
@@ -6466,7 +6535,9 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6466
6535
  throw new Error(`HTTP ${res.status}${detail === "" ? "" : ":" + detail}`);
6467
6536
  }
6468
6537
  const created = await res.json();
6469
- const opId = String((created && created.operationId) || "");
6538
+ /* 实测返回形状:{ schema, operation: { operationId, state, ... } } —— id 在 operation 里,不在顶层 */
6539
+ const createdOp = created === null || created === void 0 ? {} : created.operation ?? created;
6540
+ const opId = String((createdOp && createdOp.operationId) || (created && created.operationId) || "");
6470
6541
  if (opId === "") throw new Error("没有返回操作 id");
6471
6542
  setUpdate((prev) => ({ ...prev, opId }));
6472
6543
  for (let step = 0; step < 80; step += 1) {
@@ -6482,25 +6553,53 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6482
6553
  /* restartRequired / refreshRequired 都在 outcome 里(实测 2026-11-10),不在顶层 */
6483
6554
  const outcome = op.outcome === null || op.outcome === void 0 ? {} : op.outcome;
6484
6555
  const needRestart = outcome.restartRequired === true;
6485
- setUpdate({
6556
+ setUpdate((prev) => ({
6557
+ ...prev,
6486
6558
  phase: "done",
6487
6559
  text: `已更新${got === "" ? "" : "到 " + got}${needRestart ? ",重启 App 后生效" : ",刷新页面即可生效"}`,
6488
6560
  canUpdate: false,
6489
- opId
6490
- });
6561
+ opId,
6562
+ modal: true,
6563
+ progress: 100,
6564
+ forceHint: ""
6565
+ }));
6491
6566
  return;
6492
6567
  }
6493
6568
  if (state === "failed" || state === "cancelled" || state === "rolled-back") {
6494
6569
  /* 失败详情在 failure: {code, message, retryable}(实测 2026-11-10) */
6495
6570
  const fail = op.failure === null || op.failure === void 0 ? {} : op.failure;
6571
+ const code = String(fail.code ?? "");
6572
+ /* 这三种都是「市场还在观察这个版本」而不是真失败 —— 给「强制更新」而不是报错 */
6573
+ if (code === "RELEASE_TOO_FRESH" || code === "VERSION_UNCHANGED" || code === "OPERATION_BUSY") {
6574
+ setUpdate((prev) => ({
6575
+ ...prev,
6576
+ phase: "available",
6577
+ text: `新版本 ${prev.latest}(市场观察期)`,
6578
+ canUpdate: true,
6579
+ progress: null,
6580
+ forceHint: "插件市场还没放行这个版本。点「强制更新」现在装,或稍后再试。"
6581
+ }));
6582
+ return;
6583
+ }
6496
6584
  throw new Error(String(fail.message ?? fail.code ?? state));
6497
6585
  }
6498
6586
  const pct = op.progress === null || op.progress === void 0 ? void 0 : op.progress.percent;
6499
- setUpdate((prev) => ({ ...prev, text: typeof pct === "number" ? `正在更新… ${Math.round(pct)}%` : "正在更新…" }));
6587
+ setUpdate((prev) => ({
6588
+ ...prev,
6589
+ text: typeof pct === "number" ? `正在更新… ${Math.round(pct)}%` : "正在更新…",
6590
+ progress: typeof pct === "number" ? pct : prev.progress
6591
+ }));
6500
6592
  }
6501
6593
  throw new Error("等待超时,请到插件市场查看结果");
6502
6594
  } catch (err) {
6503
- setUpdate({ phase: "error", text: `更新失败:${String((err && err.message) || err)}`, canUpdate: false, opId: "" });
6595
+ setUpdate((prev) => ({
6596
+ ...prev,
6597
+ phase: "error",
6598
+ text: `更新失败:${String((err && err.message) || err)}`,
6599
+ opId: "",
6600
+ modal: true,
6601
+ progress: null
6602
+ }));
6504
6603
  }
6505
6604
  };
6506
6605
  return h(
@@ -6548,31 +6647,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6548
6647
  onClick: checkUpdate
6549
6648
  },
6550
6649
  update.phase === "checking" ? "检查中…" : "检查更新"
6551
- ),
6552
- update.canUpdate === true
6553
- ? h(
6554
- "button",
6555
- { type: "button", className: "dsv-mini-btn", "data-on": "1", onClick: runUpdate },
6556
- "立即更新"
6557
- )
6558
- : null,
6559
- update.phase === "done"
6560
- ? h(
6561
- "button",
6562
- {
6563
- type: "button",
6564
- className: "dsv-mini-btn",
6565
- onClick: () => {
6566
- try {
6567
- window.location.reload();
6568
- } catch {
6569
- /* 忽略 */
6570
- }
6571
- }
6572
- },
6573
- "刷新页面"
6574
- )
6575
- : null
6650
+ )
6576
6651
  ),
6577
6652
  /* ── 区块一:基本 ── */
6578
6653
  h(
@@ -6792,7 +6867,96 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6792
6867
  },
6793
6868
  h("span", { className: "dsv-enter-label" }, "进入会话")
6794
6869
  )
6795
- )
6870
+ ),
6871
+ /* 更新弹窗:发现新版本时弹出来,版本对比 + 进度 + 一键更新/刷新,全程不用离开设置页 */
6872
+ update.modal === true
6873
+ ? h(
6874
+ "div",
6875
+ { className: "dsv-modal-mask", onClick: closeModal },
6876
+ h(
6877
+ "div",
6878
+ {
6879
+ className: "dsv-modal",
6880
+ onClick: (event) => {
6881
+ event.stopPropagation();
6882
+ }
6883
+ },
6884
+ h(
6885
+ "div",
6886
+ { className: "dsv-modal-title" },
6887
+ update.phase === "done" ? "更新完成" : update.phase === "error" ? "更新没有完成" : `发现新版本 ${update.latest}`
6888
+ ),
6889
+ h(
6890
+ "div",
6891
+ { className: "dsv-modal-body" },
6892
+ h(
6893
+ "div",
6894
+ { className: "dsv-modal-row" },
6895
+ h("span", null, "当前版本"),
6896
+ h("b", null, update.installed)
6897
+ ),
6898
+ update.phase === "done" || update.phase === "error"
6899
+ ? null
6900
+ : h(
6901
+ "div",
6902
+ { className: "dsv-modal-row" },
6903
+ h("span", null, "新版本"),
6904
+ h("b", null, update.latest)
6905
+ ),
6906
+ update.progress === null || update.progress === void 0
6907
+ ? null
6908
+ : h(
6909
+ "div",
6910
+ { className: "dsv-modal-bar" },
6911
+ h("i", { style: { width: `${Math.max(4, Math.min(100, update.progress))}%` } })
6912
+ ),
6913
+ update.forceHint !== ""
6914
+ ? h("div", { className: "dsv-modal-note" }, update.forceHint)
6915
+ : null,
6916
+ update.phase === "done" ? h("div", null, update.text) : null,
6917
+ update.phase === "error" ? h("div", { className: "dsv-modal-err" }, update.text) : null
6918
+ ),
6919
+ h(
6920
+ "div",
6921
+ { className: "dsv-modal-actions" },
6922
+ update.phase === "done"
6923
+ ? h(
6924
+ "button",
6925
+ {
6926
+ type: "button",
6927
+ "data-primary": "1",
6928
+ onClick: () => {
6929
+ try {
6930
+ window.location.reload();
6931
+ } catch {
6932
+ /* 忽略 */
6933
+ }
6934
+ }
6935
+ },
6936
+ "刷新页面"
6937
+ )
6938
+ : [
6939
+ h(
6940
+ "button",
6941
+ { key: "later", type: "button", onClick: closeModal },
6942
+ "稍后"
6943
+ ),
6944
+ h(
6945
+ "button",
6946
+ {
6947
+ key: "go",
6948
+ type: "button",
6949
+ "data-primary": "1",
6950
+ disabled: update.phase === "updating",
6951
+ onClick: () => (update.canUpdate === true ? runUpdate(false) : checkUpdate())
6952
+ },
6953
+ update.phase === "updating" ? "更新中…" : update.canUpdate === true ? "立即更新" : "重新检查"
6954
+ )
6955
+ ]
6956
+ )
6957
+ )
6958
+ )
6959
+ : null
6796
6960
  );
6797
6961
  }
6798
6962
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-multipane",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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",