@huaqiu/dsh-tool-plugin-update 0.6.10 → 0.6.12

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/lib/client.js CHANGED
@@ -317,8 +317,8 @@ window.__ModuleLoader__.load({
317
317
  * to `current`: the plugin is at (or ahead of) the offered release, there is
318
318
  * nothing to install, and no install control may be offered for it. Every
319
319
  * other state passes through untouched — `install` (plugin absent locally)
320
- * has no local version to compare, and `blocked`/`ignored`/`current` are
321
- * already non-actionable. Unknown server fields are preserved verbatim: the
320
+ * has no local version to compare, and `ignored`/`current` are already
321
+ * non-actionable. Unknown server fields are preserved verbatim: the
322
322
  * client stays a thin reader of the hq-edge report shape.
323
323
  */
324
324
  function normalizePluginUpdateItem(item) {
@@ -503,10 +503,32 @@ window.__ModuleLoader__.load({
503
503
  return request("/check", { method: "POST" }).then(normalizePluginUpdateReport);
504
504
  }
505
505
  /** POST the install transaction for the confirmed set version. */
506
- function installSet(setVersion) {
506
+ function installSet(setVersion, pluginNames) {
507
507
  return request("/install", {
508
508
  method: "POST",
509
- body: JSON.stringify({ setVersion })
509
+ body: JSON.stringify({
510
+ setVersion,
511
+ ...pluginNames ? { pluginNames } : {}
512
+ })
513
+ });
514
+ }
515
+ /** Persist a per-plugin decision for this release set. */
516
+ function ignorePlugin(setVersion, name) {
517
+ return request("/plugin-ignore", {
518
+ method: "POST",
519
+ body: JSON.stringify({
520
+ setVersion,
521
+ name
522
+ })
523
+ });
524
+ }
525
+ function unignorePlugin(setVersion, name) {
526
+ return request("/plugin-unignore", {
527
+ method: "POST",
528
+ body: JSON.stringify({
529
+ setVersion,
530
+ name
531
+ })
510
532
  });
511
533
  }
512
534
  /** POST ignore for the current offer (set-scoped, persists across restarts). */
@@ -588,7 +610,7 @@ window.__ModuleLoader__.load({
588
610
  entryTooltip: "查看可用的插件更新",
589
611
  viewTitle: "插件更新",
590
612
  viewIntro: "检查并安装可用的插件更新",
591
- viewInfo: "在这里查看插件集的更新。标注为「被阻止」的插件因主机或 HQ Edge 版本不兼容而无法安装;已是最新的插件无需操作。",
613
+ viewInfo: "在这里查看插件集的更新;已是最新的插件无需操作。",
592
614
  refresh: "刷新",
593
615
  close: "关闭",
594
616
  loading: "正在读取插件更新…",
@@ -609,22 +631,9 @@ window.__ModuleLoader__.load({
609
631
  groupCount: (count) => `${count} 个插件`,
610
632
  group: {
611
633
  actionable: "待处理",
612
- blocked: "无法安装",
613
634
  ignored: "已忽略",
614
635
  current: "已是最新"
615
636
  },
616
- state: {
617
- current: "当前",
618
- update: "可更新",
619
- install: "待安装",
620
- ignored: "已忽略",
621
- blocked: "被阻止"
622
- },
623
- blockedReason: {
624
- host: "不适用于当前 EDA 主机",
625
- "hq-edge-version": "当前 HQ Edge 版本不兼容",
626
- "runtime-unknown": "HQ Edge 版本未知,无法校验"
627
- },
628
637
  runtime: {
629
638
  title: "HQ Edge 运行时",
630
639
  current: "当前版本",
@@ -759,7 +768,6 @@ window.__ModuleLoader__.load({
759
768
  allChangelog: "展开全部更新日志",
760
769
  changelogBtn: "日志",
761
770
  changelogTitle: "更新内容:",
762
- blockedBadge: "无法安装",
763
771
  footerCount: (n) => `准备安装 ${n} 项兼容插件`,
764
772
  footerSet: (v) => `版本集: v${v}`,
765
773
  installAllSet: (v) => `一键更新全套插件 (v${v})`,
@@ -781,7 +789,7 @@ window.__ModuleLoader__.load({
781
789
  entryTooltip: "Review available plugin updates",
782
790
  viewTitle: "Plugin Updates",
783
791
  viewIntro: "Check for and install available plugin updates",
784
- viewInfo: "Review the plugin set updates here. A plugin marked Blocked cannot be installed because its host or HQ Edge version is incompatible; a plugin marked Current needs no action.",
792
+ viewInfo: "Review the plugin set updates here. Plugins that are up to date need no action.",
785
793
  refresh: "Refresh",
786
794
  close: "Close",
787
795
  loading: "Reading plugin updates…",
@@ -802,22 +810,9 @@ window.__ModuleLoader__.load({
802
810
  groupCount: (count) => `${count} plugin${count === 1 ? "" : "s"}`,
803
811
  group: {
804
812
  actionable: "Actionable",
805
- blocked: "Blocked",
806
813
  ignored: "Ignored",
807
814
  current: "Up to date"
808
815
  },
809
- state: {
810
- current: "Current",
811
- update: "Update",
812
- install: "Install",
813
- ignored: "Ignored",
814
- blocked: "Blocked"
815
- },
816
- blockedReason: {
817
- host: "Not applicable to the current EDA host",
818
- "hq-edge-version": "Incompatible with the current HQ Edge version",
819
- "runtime-unknown": "HQ Edge version unknown — cannot verify"
820
- },
821
816
  runtime: {
822
817
  title: "HQ Edge Runtime",
823
818
  current: "Current version",
@@ -952,7 +947,6 @@ window.__ModuleLoader__.load({
952
947
  allChangelog: "Expand all changelogs",
953
948
  changelogBtn: "Log",
954
949
  changelogTitle: "What changed:",
955
- blockedBadge: "Cannot install",
956
950
  footerCount: (n) => `Ready to install ${n} compatible plugin${n === 1 ? "" : "s"}`,
957
951
  footerSet: (v) => `Set: v${v}`,
958
952
  installAllSet: (v) => `Update all plugins (v${v})`,
@@ -1059,19 +1053,6 @@ window.__ModuleLoader__.load({
1059
1053
  function shortName(name) {
1060
1054
  return (name.startsWith("@") ? name.slice(name.indexOf("/") + 1) : name).replace(/^dsh-(?:host-|client-)?/, "");
1061
1055
  }
1062
- /** Normalize the server's block reason to a list (it may arrive as a string). */
1063
- function blockedByList(item) {
1064
- const by = item.blockedBy;
1065
- if (Array.isArray(by)) return by.filter((entry) => typeof entry === "string");
1066
- return typeof by === "string" && by.length > 0 ? [by] : [];
1067
- }
1068
- function blockedReason(item, copy) {
1069
- const by = blockedByList(item);
1070
- if (by.includes("host")) return copy.blockedReason.host;
1071
- if (by.includes("hq-edge-version")) return copy.blockedReason["hq-edge-version"];
1072
- if (by.includes("runtime-unknown")) return copy.blockedReason["runtime-unknown"];
1073
- return by.length > 0 ? by.join(", ") : void 0;
1074
- }
1075
1056
  /** Two-letter avatar initials for a card (CJK-safe). */
1076
1057
  function avatarInitials(item) {
1077
1058
  const src = typeof item.displayName === "string" && item.displayName.trim().length > 0 ? item.displayName.trim() : shortName(item.name);
@@ -1092,11 +1073,9 @@ window.__ModuleLoader__.load({
1092
1073
  }
1093
1074
  /** One package card per the mockup: avatar initials, display name + package
1094
1075
  * subtitle, old→new version row (new in emerald), a 日志 toggle expanding the
1095
- * inline changelog. Blocked/incompatible cards are dimmed with a rose
1096
- * 无法安装 badge and a reason line, and carry NO install button. */
1097
- function packageCard(item, copy, open, onToggle) {
1098
- const blocked = item.state === "blocked";
1099
- const card = el("li", blocked ? "hqpu-card hqpu-card--blocked" : "hqpu-card");
1076
+ * inline changelog. */
1077
+ function packageCard(item, copy, open, onToggle, onInstall, onIgnore) {
1078
+ const card = el("li", "hqpu-card");
1100
1079
  card.dataset.pluginName = item.name;
1101
1080
  card.dataset.state = item.state;
1102
1081
  const head = el("div", "hqpu-card-head");
@@ -1117,8 +1096,22 @@ window.__ModuleLoader__.load({
1117
1096
  main.append(ver);
1118
1097
  left.append(avatar, main);
1119
1098
  const right = el("div", "hqpu-card-end");
1120
- if (blocked) right.append(el("span", "hqpu-blocked-badge", copy.ui.blockedBadge));
1121
- else if (Array.isArray(item.changes) && item.changes.length > 0) {
1099
+ if (item.state === "update" || item.state === "install") {
1100
+ const install = el("button", "hqpu-log-toggle", copy.installOne);
1101
+ install.type = "button";
1102
+ install.title = copy.installOneTip;
1103
+ install.addEventListener("click", onInstall);
1104
+ const ignore = el("button", "hqpu-log-toggle", copy.ignore);
1105
+ ignore.type = "button";
1106
+ ignore.addEventListener("click", onIgnore);
1107
+ right.append(install, ignore);
1108
+ } else if (item.state === "ignored") {
1109
+ const show = el("button", "hqpu-log-toggle", copy.unignore);
1110
+ show.type = "button";
1111
+ show.addEventListener("click", onIgnore);
1112
+ right.append(show);
1113
+ }
1114
+ if (Array.isArray(item.changes) && item.changes.length > 0) {
1122
1115
  const toggle = el("button", "hqpu-log-toggle");
1123
1116
  toggle.type = "button";
1124
1117
  toggle.dataset.open = open ? "true" : "false";
@@ -1128,21 +1121,11 @@ window.__ModuleLoader__.load({
1128
1121
  }
1129
1122
  head.append(left, right);
1130
1123
  card.append(head);
1131
- if (!blocked && Array.isArray(item.changes) && item.changes.length > 0) card.append(changelogDrawer(item, copy, open));
1132
- if (blocked) {
1133
- const reason = blockedReason(item, copy);
1134
- const entries = [...reason !== void 0 ? [reason] : [], ...[...item.reasons ?? [], ...item.notes ?? []].filter((e) => typeof e === "string" && e.length > 0)];
1135
- for (const entry of entries) {
1136
- const line = el("p", "hqpu-reason-line");
1137
- line.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 5V8.5M8 11.25h.01M14.5 8a6.5 6.5 0 11-13 0 6.5 6.5 0 0113 0Z"/></svg>`;
1138
- line.append(document.createTextNode(entry));
1139
- card.append(line);
1140
- }
1141
- }
1124
+ if (Array.isArray(item.changes) && item.changes.length > 0) card.append(changelogDrawer(item, copy, open));
1142
1125
  return card;
1143
1126
  }
1144
1127
  /** A section: head (title + count pill + expand-all toggle) then its cards. */
1145
- function group(heading, items, copy, changelogOpen, allOpen, onToggle, onToggleAll) {
1128
+ function group(heading, items, copy, changelogOpen, allOpen, onToggle, onToggleAll, onInstall, onIgnore) {
1146
1129
  if (items.length === 0) return null;
1147
1130
  const section = el("section", "hqpu-group");
1148
1131
  section.dataset.group = heading;
@@ -1151,14 +1134,14 @@ window.__ModuleLoader__.load({
1151
1134
  titleWrap.append(el("span", "", heading));
1152
1135
  titleWrap.append(el("span", "hqpu-count-pill", String(items.length)));
1153
1136
  head.append(titleWrap);
1154
- if (items.some((i) => i.state !== "blocked" && Array.isArray(i.changes) && i.changes.length > 0)) {
1137
+ if (items.some((i) => Array.isArray(i.changes) && i.changes.length > 0)) {
1155
1138
  const all = el("button", "hqpu-all-changelog", copy.ui.allChangelog);
1156
1139
  all.type = "button";
1157
1140
  all.addEventListener("click", onToggleAll);
1158
1141
  head.append(all);
1159
1142
  }
1160
1143
  const list = el("ul", "hqpu-cards");
1161
- for (const item of items) list.append(packageCard(item, copy, allOpen || changelogOpen.has(item.name), () => onToggle(item.name)));
1144
+ for (const item of items) list.append(packageCard(item, copy, allOpen || changelogOpen.has(item.name), () => onToggle(item.name), () => onInstall(item.name), () => onIgnore(item)));
1162
1145
  section.append(head, list);
1163
1146
  return section;
1164
1147
  }
@@ -1634,7 +1617,7 @@ window.__ModuleLoader__.load({
1634
1617
  } else if (typeof runtime.lastError === "string" && runtime.lastError.length > 0) card.append(el("p", "hqpu-status", `${copy.lastError}: ${runtime.lastError}`));
1635
1618
  return card;
1636
1619
  }
1637
- function renderList(section, report, copy, changelogOpen, allOpen, onToggleCard, onToggleAll, onRetryCheck) {
1620
+ function renderList(section, report, copy, changelogOpen, allOpen, onToggleCard, onToggleAll, onRetryCheck, onInstall, onIgnore) {
1638
1621
  section.textContent = "";
1639
1622
  if (report === null) {
1640
1623
  section.append(skeleton(copy));
@@ -1651,12 +1634,11 @@ window.__ModuleLoader__.load({
1651
1634
  const byState = (state) => report.items.filter((item) => item.state === state);
1652
1635
  const order = [
1653
1636
  [copy.group.actionable, [...byState("update"), ...byState("install")]],
1654
- [copy.group.blocked, byState("blocked")],
1655
1637
  [copy.group.ignored, byState("ignored")],
1656
1638
  [copy.group.current, byState("current")]
1657
1639
  ];
1658
1640
  for (const [heading, items] of order) {
1659
- const node = group(heading, items, copy, changelogOpen, allOpen, onToggleCard, onToggleAll);
1641
+ const node = group(heading, items, copy, changelogOpen, allOpen, onToggleCard, onToggleAll, onInstall, onIgnore);
1660
1642
  if (node !== null) section.append(node);
1661
1643
  }
1662
1644
  }
@@ -1669,7 +1651,7 @@ window.__ModuleLoader__.load({
1669
1651
  if (engine !== null) section.append(engine);
1670
1652
  }
1671
1653
  /** Run the install transaction (a new durable job), then let the store poll it. */
1672
- async function runInstall(store, copy) {
1654
+ async function runInstall(store, copy, pluginNames) {
1673
1655
  const report = store.report();
1674
1656
  if (report === null) return;
1675
1657
  if (report.manifestVersion === null) {
@@ -1678,7 +1660,7 @@ window.__ModuleLoader__.load({
1678
1660
  }
1679
1661
  store.setInstalling(true);
1680
1662
  try {
1681
- const result = await installSet(report.manifestVersion);
1663
+ const result = await installSet(report.manifestVersion, pluginNames);
1682
1664
  if (result.error !== void 0) {
1683
1665
  store.setInstalling(false);
1684
1666
  showToast(`${copy.installError}: ${result.error}`, "error");
@@ -1742,7 +1724,7 @@ window.__ModuleLoader__.load({
1742
1724
  * The sticky footer: left meta ("准备安装 N 项兼容插件" / "版本集: vX"), a
1743
1725
  * full-width primary "一键更新全套插件 (vX)" (install = one durable job),
1744
1726
  * a secondary 忽略 wired to the existing ignore/unignore affordance, and the
1745
- * footnote. The count EXCLUDES blocked / ignored / already-current entries.
1727
+ * footnote. The count EXCLUDES ignored / already-current entries.
1746
1728
  */
1747
1729
  function renderFooter(footer, installBtn, ignoreBtn, countEl, setEl, report, copy, installing, store) {
1748
1730
  if (report === null) {
@@ -2036,6 +2018,12 @@ window.__ModuleLoader__.load({
2036
2018
  render();
2037
2019
  }, () => {
2038
2020
  store.check();
2021
+ }, (name) => {
2022
+ runInstall(store, copy, [name]);
2023
+ }, (item) => {
2024
+ const report = store.report();
2025
+ if (report?.manifestVersion === null || report?.manifestVersion === void 0) return;
2026
+ (item.state === "ignored" ? unignorePlugin(report.manifestVersion, item.name) : ignorePlugin(report.manifestVersion, item.name)).then(() => store.check()).catch(() => void 0);
2039
2027
  });
2040
2028
  renderRuntime(runtimeSection, report, copy, runtimeActions, dismissedAlert, () => {
2041
2029
  dismissedAlert = true;
@@ -3513,40 +3501,6 @@ window.__ModuleLoader__.load({
3513
3501
  line-height: 16px;
3514
3502
  }
3515
3503
 
3516
- /* Blocked / incompatible card: dimmed, rose badge, no install button */
3517
- .hqpu-card--blocked {
3518
- opacity: 0.8;
3519
- background: color-mix(in srgb, var(--hq-card) 60%, transparent);
3520
- border-color: var(--hq-border);
3521
- }
3522
- .hqpu-card--blocked .hqpu-avatar {
3523
- background: color-mix(in srgb, var(--hq-card) 50%, transparent);
3524
- border-color: var(--hq-border);
3525
- color: var(--hq-faint);
3526
- }
3527
- .hqpu-card--blocked .hqpu-card-title { color: var(--hq-muted); }
3528
- .hqpu-blocked-badge {
3529
- font-size: 9px;
3530
- padding: 2px 6px;
3531
- border-radius: 4px;
3532
- color: var(--hq-rose);
3533
- background: color-mix(in srgb, var(--hq-rose) 18%, transparent);
3534
- border: 0.5px solid color-mix(in srgb, var(--hq-rose) 40%, transparent);
3535
- }
3536
- .hqpu-reason-line {
3537
- display: flex;
3538
- align-items: flex-start;
3539
- gap: 4px;
3540
- margin: 8px 0 0;
3541
- padding: 6px;
3542
- border-radius: 5px;
3543
- border: 0.5px solid color-mix(in srgb, var(--hq-rose) 20%, transparent);
3544
- background: color-mix(in srgb, var(--hq-rose) 8%, transparent);
3545
- font-size: 10px;
3546
- color: var(--hq-rose);
3547
- }
3548
- .hqpu-reason-line svg { width: 12px; height: 12px; flex: none; margin-top: 1px; }
3549
-
3550
3504
  /* Sticky footer */
3551
3505
  .hqpu-footer {
3552
3506
  flex: none;
@@ -3776,7 +3730,7 @@ window.__ModuleLoader__.load({
3776
3730
  if (report.runtime?.updateAvailable) count += 1;
3777
3731
  if (count === 0) {
3778
3732
  const latest = this.recent[0];
3779
- if (latest !== void 0 && (latest.phase === "failed" || latest.phase === "rolled-back")) count = 1;
3733
+ if (latest !== void 0 && TERMINAL_PHASES.has(latest.phase)) count = 1;
3780
3734
  }
3781
3735
  return count;
3782
3736
  }