@zhangfengshun/dsh-remote-ssh 2.3.2 → 2.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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  本文件的版本号与 `package.json` 的 `version` 保持一致。每个版本对应一个 Cordis Package 快照(`pkg-N`)。
4
4
 
5
+ ## [2.3.3] — 修复工作区图标替换不生效
6
+ ### 修复
7
+ - 2.3.2 的图标替换向上爬找「直接子级含 svg 的祖先」,但壳层工作区行的文件夹 svg 位于标题的**前兄弟槽位**(`projectRow > [slot.folder(svg), …, projectText > title]`),不是任何祖先的直接子级 → 匹配后静默跳过、图标从未被替换。改为:从标题向上最多 4 层,取每层容器的**第一个子元素**,首个含 svg 的即行首文件夹槽位;并将「插入新节点」改为**原位改写**该 svg 的 viewBox/尺寸/内容(不插入/删除节点,避免 React 对账风险;展开态切换重建 svg 后由观察器 500ms 内自动重刷)。
8
+
5
9
  ## [2.3.2] — 远程工作区图标改为单个「地球角标文件夹」
6
10
  ### 变更
7
11
  - **工作区标题去掉 🌐 前缀**:新建远程工作区的原生标题不再带 🌐(此前标题 emoji + 壳层文件夹图标造成「文件夹 + 地球」双重标识);启动自愈同步剥掉既有工作区标题中的旧 🌐 前缀(仅限已知旧形态,不覆盖自定义标题)。
package/lib/client.js CHANGED
@@ -1139,7 +1139,8 @@ window.__ModuleLoader__.load({
1139
1139
  // ---- 远程工作区图标:单个「地球角标文件夹」SVG 替换壳层默认纯文件夹图标 ----
1140
1140
  // 壳层工作区行的文件夹图标是固定原语(IconFolderOpen16/Close16),无 per-workspace
1141
1141
  // 图标 API;旧方案在标题里塞 🌐 emoji 造成「文件夹 + 地球」双重标识。现按标题文本
1142
- // 定位远程工作区行,隐藏原 svg 并插入内联「地球角标文件夹」svg(data 标记防重入)。
1142
+ // 定位远程工作区行,找到行首 slot.folder 槽位(标题的前兄弟),把其中的 svg
1143
+ // 原位改写为「地球角标文件夹」内容 —— 不插入/删除节点,避免 React 对账风险。
1143
1144
  var remoteTitles = new Set();
1144
1145
  function refreshRemoteTitles() {
1145
1146
  api("listWorkspaces").then(function (r) {
@@ -1153,20 +1154,10 @@ window.__ModuleLoader__.load({
1153
1154
  swapWorkspaceIconsIn(document.body); // 标题集就绪后补一次全量替换
1154
1155
  }).catch(function () {});
1155
1156
  }
1156
- function folderGlobeSvg() {
1157
- var NS = "http://www.w3.org/2000/svg";
1158
- var svg = document.createElementNS(NS, "svg");
1159
- svg.setAttribute("viewBox", "0 0 20 16");
1160
- svg.setAttribute("width", "16");
1161
- svg.setAttribute("height", "16");
1162
- svg.setAttribute("aria-hidden", "true");
1163
- svg.setAttribute("data-rssh-folder-globe", "1");
1164
- svg.innerHTML =
1165
- '<path d="M2.4 4.2c0-1.05.85-1.9 1.9-1.9h3.1c.52 0 1.02.21 1.39.58l1.05 1.05c.28.28.66.44 1.06.44h6.3c1.05 0 1.9.85 1.9 1.9v6.53c0 1.05-.85 1.9-1.9 1.9H4.3c-1.05 0-1.9-.85-1.9-1.9V4.2z" fill="none" stroke="currentColor" stroke-width="1.2"/>' +
1166
- '<circle cx="6.3" cy="12.1" r="3.1" fill="var(--dsw-alias-state-business-primary, #4c6ef5)" stroke="var(--dsw-alias-bg-layer-1, #1b1b1b)" stroke-width="0.8"/>' +
1167
- '<g fill="none" stroke="#ffffff" stroke-width="0.75"><circle cx="6.3" cy="12.1" r="1.95"/><ellipse cx="6.3" cy="12.1" rx="0.95" ry="1.95"/><path d="M4.35 12.1h3.9"/></g>';
1168
- return svg;
1169
- }
1157
+ var FOLDER_GLOBE_INNER =
1158
+ '<path d="M2.4 4.2c0-1.05.85-1.9 1.9-1.9h3.1c.52 0 1.02.21 1.39.58l1.05 1.05c.28.28.66.44 1.06.44h6.3c1.05 0 1.9.85 1.9 1.9v6.53c0 1.05-.85 1.9-1.9 1.9H4.3c-1.05 0-1.9-.85-1.9-1.9V4.2z" fill="none" stroke="currentColor" stroke-width="1.2"/>' +
1159
+ '<circle cx="6.3" cy="12.1" r="3.1" fill="var(--dsw-alias-state-business-primary, #4c6ef5)" stroke="var(--dsw-alias-bg-layer-1, #1b1b1b)" stroke-width="0.8"/>' +
1160
+ '<g fill="none" stroke="#ffffff" stroke-width="0.75"><circle cx="6.3" cy="12.1" r="1.95"/><ellipse cx="6.3" cy="12.1" rx="0.95" ry="1.95"/><path d="M4.35 12.1h3.9"/></g>';
1170
1161
  function swapWorkspaceIconsIn(root) {
1171
1162
  if (!remoteTitles.size) return;
1172
1163
  try {
@@ -1177,18 +1168,27 @@ window.__ModuleLoader__.load({
1177
1168
  var t = (el.textContent || "").trim();
1178
1169
  if (!t || !remoteTitles.has(t) || el.childElementCount > 2) continue;
1179
1170
  el.setAttribute("data-rssh-title-scan", "1");
1180
- // 向上找最近的「直接子级含 svg」的容器(壳层 slot.folder 槽位)
1181
- var p = el, slot = null, guard = 0;
1182
- while (p && p.nodeType === 1 && p !== document.body && guard++ < 6) {
1183
- if (p.querySelector(":scope > svg")) { slot = p; break; }
1184
- p = p.parentElement;
1171
+ // 行结构:projectRow > [slot.folder(svg), slot.chevron(svg), projectText > span.title, ...]
1172
+ // 从标题元素向上最多 4 层,取每层容器的第一个子元素——首个含 svg 的即行首
1173
+ // 文件夹槽位;将其 svg 原位改写为地球角标文件夹(React 复用同一节点,
1174
+ // 展开态切换会重建 svg,观察器 500ms 内自动重刷)。
1175
+ var holder = el;
1176
+ for (var hop = 0; hop < 4 && holder && holder.parentElement; hop++) {
1177
+ var row = holder.parentElement;
1178
+ var first = row.children && row.children[0];
1179
+ if (first && first.querySelector && first.querySelector("svg")) {
1180
+ var oldSvg = first.querySelector("svg");
1181
+ if (oldSvg.getAttribute("data-rssh-folder-globe") !== "1") {
1182
+ oldSvg.setAttribute("data-rssh-folder-globe", "1");
1183
+ oldSvg.setAttribute("viewBox", "0 0 20 16");
1184
+ oldSvg.setAttribute("width", "16");
1185
+ oldSvg.setAttribute("height", "16");
1186
+ oldSvg.innerHTML = FOLDER_GLOBE_INNER;
1187
+ }
1188
+ break;
1189
+ }
1190
+ holder = row;
1185
1191
  }
1186
- if (!slot) continue;
1187
- var old = slot.querySelector(":scope > svg");
1188
- if (old && old.getAttribute("data-rssh-folder-globe") === "1") continue;
1189
- if (old) old.style.display = "none";
1190
- var mine = folderGlobeSvg();
1191
- if (old) slot.insertBefore(mine, old); else slot.appendChild(mine);
1192
1192
  }
1193
1193
  } catch (e) {}
1194
1194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangfengshun/dsh-remote-ssh",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "DSH web plugin: VSCode Remote-SSH-like remote development (SSH to supercomputers/servers, remote workspace, file explorer, integrated terminal), integrated with dsh-better-sidebar and DSH settings.",
5
5
  "keywords": [
6
6
  "dsh",