dsh-multipane 1.0.50 → 1.0.52
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/LICENSE +21 -21
- package/README.en.md +6 -0
- package/README.md +12 -0
- package/cordis.patch.yml +11 -11
- package/lib/client.js +118 -25
- package/lib/index.js +433 -241
- package/package.json +2 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 weiaisuyan
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 weiaisuyan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
CHANGED
|
@@ -161,6 +161,12 @@ node scripts/check-names.cjs # package name / version / release-age allowanc
|
|
|
161
161
|
|
|
162
162
|
## Changelog
|
|
163
163
|
|
|
164
|
+
### 1.0.51 (2026-11-11)
|
|
165
|
+
|
|
166
|
+
- **The rail's hide threshold is now a setting.** A new card in Settings → UI elements, "Hide the turn rail in narrow panes", adds a 0-600px slider (default 240px, `0` = never hide). The 240px cutoff used to be hard-coded, so a narrow pane always lost the rail and there was no way to change it.
|
|
167
|
+
- Changes take effect immediately without a restart, and each pane is judged on its own width (two- and three-pane layouts do not affect each other).
|
|
168
|
+
- Under the hood the fixed `@container (width<=240px)` rule is replaced by one generated at runtime: container queries accept literals, not CSS variables, so the threshold has to be spliced into the rule text. Only `visibility` is hidden - `display` stays `block` - so the 1.0.46 ratchet (narrow it and it never comes back) cannot return.
|
|
169
|
+
|
|
164
170
|
### 1.0.50 (2026-11-11)
|
|
165
171
|
|
|
166
172
|
- **Root cause of the missing rail in panes: a deadlock.** The host hides the rail with `display:none` whenever its container is 900px or narrower. Once hidden, the rail's internal virtual scroller measures a height of zero and renders no marks at all, and the plugin used "are there marks?" as its show switch - so the switch could never turn on and the rail could never come back. That is why two or three panes (a few hundred pixels each) were always blank, and dragging a pane past 900px suddenly made it appear. The rail is now located structurally, independent of whether marks exist.
|
package/README.md
CHANGED
|
@@ -160,6 +160,18 @@ node scripts/check-names.cjs # 包名 / 版本 / 冷却豁免三处是否一
|
|
|
160
160
|
|
|
161
161
|
## 更新记录
|
|
162
162
|
|
|
163
|
+
### 1.0.52(2026-11-12)
|
|
164
|
+
|
|
165
|
+
- **修「明明更新过,进设置页还提示新版本」**:设置页那个更新按钮只把文件覆盖进 `node_modules\dsh-multipane`,而 profile 的 `package.json` 与 `pnpm-lock.yaml` 里还钉着旧版本号。之后只要在这个 profile 里装/卸**任何**别的插件(pnpm 一跑),它就会按 lockfile 把这个目录重铺回旧版本 —— 用户看到的就是「更新成功了,提示还在」。实测:1.0.51 装上后 9:09 确实在跑,9:42 装了另一个插件,目录又变回 1.0.37
|
|
166
|
+
- 现在自更新成功后同时改两处登记:`package.json` 里的依赖值,以及 `pnpm-lock.yaml` 的 importer(specifier 与 version)、packages 条目(键名与 integrity)、snapshots 键名。全部按文本编辑,保留原文件格式。两处里只要有一处不能确定改对就**一并不改**,并在提示里写明「依赖登记没同步」—— 留一半新一半旧会让 pnpm 以 frozen-lockfile 不一致为由拒绝整个 profile,比退回一版更糟
|
|
167
|
+
- integrity 用下载到的 tgz 现算(sha512),与 npm registry 给的完全一致;新版本号同时写进 `pnpm-workspace.yaml` 的等待期白名单,免得下次 pnpm 解析时被 24 小时新包限制挡住
|
|
168
|
+
|
|
169
|
+
### 1.0.51(2026-11-11)
|
|
170
|
+
|
|
171
|
+
- **轮次导航条的隐藏阈值变成设置项**:设置页「界面元素」新增「窄栏隐藏轮次导航条」,一根 0–600px 的滑杆,默认 240px,`0` = 永不隐藏。以前 240 是写死的,栏一窄就消失、改不了
|
|
172
|
+
- 阈值即时生效、不用重启;每栏按自己的宽度单独判断(2 栏、3 栏互不影响)
|
|
173
|
+
- 实现上把 `@container (width<=240px)` 换成运行时生成的一段规则:容器查询只认固定数字、不认 CSS 变量,所以阈值只能拼进规则文本。仍然只隐藏 `visibility`,`display` 恒为 block —— 不再碰 1.0.46 那个「隐藏后拖回来不出现」的棘轮
|
|
174
|
+
|
|
163
175
|
### 1.0.50(2026-11-11)
|
|
164
176
|
|
|
165
177
|
- **修「窗格里的轮次导航条不出现」的根因**:导航条是死锁的。宿主在容器宽度 ≤900px 时把它 `display:none`;一旦隐藏,它内部的虚拟滚动量不到高度,就一条短横线都不渲染;而插件之前用「里面有没有短横线」当显示开关,于是永远不成立、永远放不出来 —— 分到 2/3 栏(每栏五百多像素)必然全空白,拖到 900px 以上突然出现,就是这个原因。现在只看结构定位那颗导航,与里面有没有短横线无关
|
package/cordis.patch.yml
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# dsh-split-view bundle patch.
|
|
2
|
-
#
|
|
3
|
-
# Installing this package through the official CLI
|
|
4
|
-
# dsh plugin --profile desktop add file:<path-to-this-directory>
|
|
5
|
-
# reconciles `dsh.profile.bundles` against installed packages and appends
|
|
6
|
-
# `dsh-split-view` to the bundle stack; the profile boot then merges this patch
|
|
7
|
-
# (a single `insert` of the plugin row).
|
|
8
|
-
- insert:
|
|
9
|
-
- id: split-view
|
|
10
|
-
name: 'dsh-multipane'
|
|
11
|
-
label: '多栏视图'
|
|
1
|
+
# dsh-split-view bundle patch.
|
|
2
|
+
#
|
|
3
|
+
# Installing this package through the official CLI
|
|
4
|
+
# dsh plugin --profile desktop add file:<path-to-this-directory>
|
|
5
|
+
# reconciles `dsh.profile.bundles` against installed packages and appends
|
|
6
|
+
# `dsh-split-view` to the bundle stack; the profile boot then merges this patch
|
|
7
|
+
# (a single `insert` of the plugin row).
|
|
8
|
+
- insert:
|
|
9
|
+
- id: split-view
|
|
10
|
+
name: 'dsh-multipane'
|
|
11
|
+
label: '多栏视图'
|
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
|
-
|
|
20
|
+
const PLUGIN_VERSION = "1.0.52";
|
|
21
21
|
const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
|
|
22
22
|
|
|
23
23
|
|
|
@@ -229,6 +229,7 @@ window.__ModuleLoader__.load({
|
|
|
229
229
|
"检查失败:{0}": "Check failed: {0}",
|
|
230
230
|
"正在从 npm 下载…": "Downloading from npm…",
|
|
231
231
|
"已更新到 {0},重启 App 后生效": "Updated to {0}; restart the app to apply",
|
|
232
|
+
"已更新到 {0},但依赖登记没同步({1}):下次装/卸别的插件可能把它退回旧版": "Updated to {0}, but the profile's dependency record was not synced ({1}) — installing or removing another plugin later may roll it back",
|
|
232
233
|
"更新失败:{0}": "Update failed: {0}",
|
|
233
234
|
"正在更新…": "Updating…",
|
|
234
235
|
"现在有 {0} 个会话正在运行。更新会替换插件文件,那个会话可能在半路读到新旧混着的代码而报错。确定要继续,就再点一次「仍然更新」。": "{0} sessions are running now. Updating replaces plugin files, so a running session may read a mix of old and new code and fail. Click \"Update anyway\" again to continue.",
|
|
@@ -272,6 +273,11 @@ window.__ModuleLoader__.load({
|
|
|
272
273
|
"已开启:只剩一个标签时再按 Ctrl+W 直接关闭窗口。": "On: pressing Ctrl+W again on the last tab closes the window.",
|
|
273
274
|
"已关闭:双击标签不关闭(中键、× 仍然可用)。": "Off: double-clicking a tab does not close it (middle-click and × still work).",
|
|
274
275
|
"已开启:双击标签直接关闭(中键、× 也可用)。": "On: double-clicking a tab closes it (middle-click and × also work).",
|
|
276
|
+
"窄栏隐藏轮次导航条": "Hide the turn rail in narrow panes",
|
|
277
|
+
"栏宽不超过 {0}px 时隐藏这条导航;每栏按自己的宽度判断。": "Hidden when a pane is {0}px wide or narrower; each pane is judged on its own width.",
|
|
278
|
+
"已关闭:无论栏多窄都显示这条导航。": "Off: the rail stays visible no matter how narrow a pane gets.",
|
|
279
|
+
"隐藏阈值": "Hide below",
|
|
280
|
+
"0 = 永不隐藏;默认 240px": "0 = never hide; default 240px",
|
|
275
281
|
"在侧边栏显示入口": "Show entry in sidebar",
|
|
276
282
|
"已关闭:侧边栏不显示本插件入口。": "Off: the sidebar hides this plugin's entry.",
|
|
277
283
|
"已开启:侧边栏显示本插件入口(默认)。": "On: the sidebar shows this plugin's entry (default).",
|
|
@@ -427,6 +433,8 @@ window.__ModuleLoader__.load({
|
|
|
427
433
|
}
|
|
428
434
|
const STORAGE_KEY = "dsh-split-view:workspace:v1";
|
|
429
435
|
const STYLE_ID = "dsh-split-view-style";
|
|
436
|
+
/* 轮次导航条的阈值规则单独一张表:阈值是设置项,改一次只重写这一小段。 */
|
|
437
|
+
const RAIL_STYLE_ID = "dsh-split-view-rail-threshold";
|
|
430
438
|
const CONTENT_FACTORY = "conversation.content";
|
|
431
439
|
const PANE_SLOT = "split-view.pane";
|
|
432
440
|
const RETAIN_SOURCE = "splitView";
|
|
@@ -950,6 +958,12 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
950
958
|
const LINE_COLOR_IDS = LINE_COLORS.map((item) => item.id);
|
|
951
959
|
const DEFAULT_LINE_COLOR = "graphite";
|
|
952
960
|
|
|
961
|
+
/* 轮次导航条(会话右侧那列短横线)在栏窄到放不下时隐藏。
|
|
962
|
+
1.0.51 起阈值由设置项 railHideBelow 决定,默认 240px;0 = 永不隐藏。 */
|
|
963
|
+
const DEFAULT_RAIL_HIDE_BELOW = 240;
|
|
964
|
+
const RAIL_HIDE_MIN = 0;
|
|
965
|
+
const RAIL_HIDE_MAX = 600;
|
|
966
|
+
|
|
953
967
|
/* 线宽档位。**只作用于分隔条、拖动预览虚线框、虚位标签边框**;
|
|
954
968
|
标签下方的焦点线固定 2px,不跟这个档位走(用户明确要求)。 */
|
|
955
969
|
const LINE_WIDTHS = [
|
|
@@ -1094,7 +1108,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1094
1108
|
viewBarPlacement: state.viewBarPlacement,
|
|
1095
1109
|
viewBarOrder: cleanIdList(state.viewBarOrder),
|
|
1096
1110
|
viewBarHidden: cleanIdList(state.viewBarHidden),
|
|
1097
|
-
hostBar: state.hostBar !== false
|
|
1111
|
+
hostBar: state.hostBar !== false,
|
|
1112
|
+
railHideBelow: clampRailHide(state.railHideBelow)
|
|
1098
1113
|
}
|
|
1099
1114
|
};
|
|
1100
1115
|
}
|
|
@@ -1162,7 +1177,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1162
1177
|
const keys = Object.keys(src).filter((k) => ignore.indexOf(k) < 0);
|
|
1163
1178
|
if (keys.length === 0) throw new Error(t("文件里没有可识别的设置项"));
|
|
1164
1179
|
/* 只接受已知字段,其余忽略:别让陌生键混进 state。 */
|
|
1165
|
-
const known = ["enabled", "showInSidebar", "titlebarDrag", "lineColor", "lineWidth", "lineOpacity", "appearance", "dblclickClose", "ctrlWCloseTab", "ctrlWCloseWindowOnLast", "viewBarPlacement", "viewBarOrder", "viewBarHidden", "hostBar"];
|
|
1180
|
+
const known = ["enabled", "showInSidebar", "titlebarDrag", "lineColor", "lineWidth", "lineOpacity", "appearance", "dblclickClose", "ctrlWCloseTab", "ctrlWCloseWindowOnLast", "viewBarPlacement", "viewBarOrder", "viewBarHidden", "hostBar", "railHideBelow"];
|
|
1166
1181
|
const patch = {};
|
|
1167
1182
|
let applied = 0;
|
|
1168
1183
|
for (const k of keys) {
|
|
@@ -1301,10 +1316,19 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1301
1316
|
viewBarPlacement: DEFAULT_VIEWBAR_PLACEMENT,
|
|
1302
1317
|
viewBarOrder: [],
|
|
1303
1318
|
viewBarHidden: [],
|
|
1304
|
-
hostBar: true
|
|
1319
|
+
hostBar: true,
|
|
1320
|
+
/* 栏宽小于这个值就隐藏轮次导航条;0 = 永不隐藏。 */
|
|
1321
|
+
railHideBelow: DEFAULT_RAIL_HIDE_BELOW
|
|
1305
1322
|
};
|
|
1306
1323
|
}
|
|
1307
1324
|
|
|
1325
|
+
/** 阈值统一成 0–600、10px 一档的整数;坏值回默认,别让存坏的 JSON 把导航条弄没。 */
|
|
1326
|
+
function clampRailHide(value) {
|
|
1327
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_RAIL_HIDE_BELOW;
|
|
1328
|
+
const clamped = Math.min(RAIL_HIDE_MAX, Math.max(RAIL_HIDE_MIN, value));
|
|
1329
|
+
return Math.round(clamped / 10) * 10;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1308
1332
|
/** 只留下字符串 id,去重保序 —— 存坏了的 JSON 不该把设置页搞乱。 */
|
|
1309
1333
|
function cleanIdList(value) {
|
|
1310
1334
|
if (!Array.isArray(value)) return [];
|
|
@@ -1347,7 +1371,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1347
1371
|
viewBarPlacement: VIEWBAR_PLACEMENTS.indexOf(parsed?.viewBarPlacement) >= 0 ? parsed.viewBarPlacement : DEFAULT_VIEWBAR_PLACEMENT,
|
|
1348
1372
|
viewBarOrder: cleanIdList(parsed?.viewBarOrder),
|
|
1349
1373
|
viewBarHidden: cleanIdList(parsed?.viewBarHidden),
|
|
1350
|
-
hostBar: parsed?.hostBar !== false
|
|
1374
|
+
hostBar: parsed?.hostBar !== false,
|
|
1375
|
+
railHideBelow: clampRailHide(parsed?.railHideBelow)
|
|
1351
1376
|
};
|
|
1352
1377
|
} catch {
|
|
1353
1378
|
return DEFAULTS();
|
|
@@ -1373,7 +1398,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1373
1398
|
viewBarPlacement: VIEWBAR_PLACEMENTS.indexOf(prefs.state.viewBarPlacement) >= 0 ? prefs.state.viewBarPlacement : DEFAULT_VIEWBAR_PLACEMENT,
|
|
1374
1399
|
viewBarOrder: cleanIdList(prefs.state.viewBarOrder),
|
|
1375
1400
|
viewBarHidden: cleanIdList(prefs.state.viewBarHidden),
|
|
1376
|
-
hostBar: prefs.state.hostBar !== false
|
|
1401
|
+
hostBar: prefs.state.hostBar !== false,
|
|
1402
|
+
railHideBelow: clampRailHide(prefs.state.railHideBelow)
|
|
1377
1403
|
})
|
|
1378
1404
|
);
|
|
1379
1405
|
} catch {
|
|
@@ -1586,6 +1612,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1586
1612
|
try {
|
|
1587
1613
|
const style = document.getElementById(STYLE_ID);
|
|
1588
1614
|
if (style !== null) style.remove();
|
|
1615
|
+
const railStyle = document.getElementById(RAIL_STYLE_ID);
|
|
1616
|
+
if (railStyle !== null) railStyle.remove();
|
|
1589
1617
|
} catch {
|
|
1590
1618
|
/* 非浏览器环境 */
|
|
1591
1619
|
}
|
|
@@ -1618,6 +1646,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
1618
1646
|
/* 颜色 / 浓度 / 粗细写到 <html>:侧栏会话行在插件根之外,只有根上的变量它读得到。 */
|
|
1619
1647
|
applyLineVars();
|
|
1620
1648
|
prefs.subscribe(applyLineVars);
|
|
1649
|
+
/* 阈值改了要立刻重写那段容器查询,不用重启。 */
|
|
1650
|
+
prefs.subscribe(applyRailThreshold);
|
|
1621
1651
|
/* 把解析后的完整 prefs 立即写回一次。
|
|
1622
1652
|
老用户存的 JSON 里根本没有 showInSidebar 这个键 —— 不写回的话,
|
|
1623
1653
|
每次 read() 都用默认 true 覆盖,导致「关闭侧栏入口」改了等于没改。 */
|
|
@@ -2299,14 +2329,14 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2299
2329
|
.dsv-pane .dsv-body [data-content-phase="active"] .an3WzG_scrollBody:has([data-chat-flow])>.an3WzG_composerSeat{margin-top:0}
|
|
2300
2330
|
/* 宿主聊天滚动管理器在「工具/明细折叠」后会在内容下方预留最多半个滚动区高度的空白,
|
|
2301
2331
|
在窄栏里尤其明显;这里把它的预留位清零。 */
|
|
2302
|
-
.dsv-pane .dsv-body [data-chat-turn-spacer]{height:0!important}
|
|
2303
|
-
|
|
2304
|
-
/* ==== 1.0.46:窗格里的「轮次导航条」不再忽隐忽现(会话右侧那列短横线)====
|
|
2305
|
-
宿主在会话宽度 ≤900px 时整条 display:none,分栏后每栏必然更窄,于是开着插件
|
|
2306
|
-
它就没了。1.0.45 把它放开,却又用 display:none 在窄窗格里收回:来回切 display
|
|
2307
|
-
会让宿主的虚拟滚动把可用高度量成 0 并留在状态里,宽度回来也没人重算 ——
|
|
2308
|
-
拉窄消失后拖回原宽度也回不来(单向棘轮)。现在显示恒为 block(布局与测量
|
|
2309
|
-
一直在),只有窄到放不下时才隐藏**可见性**,恢复宽度立刻可见。
|
|
2332
|
+
.dsv-pane .dsv-body [data-chat-turn-spacer]{height:0!important}
|
|
2333
|
+
|
|
2334
|
+
/* ==== 1.0.46:窗格里的「轮次导航条」不再忽隐忽现(会话右侧那列短横线)====
|
|
2335
|
+
宿主在会话宽度 ≤900px 时整条 display:none,分栏后每栏必然更窄,于是开着插件
|
|
2336
|
+
它就没了。1.0.45 把它放开,却又用 display:none 在窄窗格里收回:来回切 display
|
|
2337
|
+
会让宿主的虚拟滚动把可用高度量成 0 并留在状态里,宽度回来也没人重算 ——
|
|
2338
|
+
拉窄消失后拖回原宽度也回不来(单向棘轮)。现在显示恒为 block(布局与测量
|
|
2339
|
+
一直在),只有窄到放不下时才隐藏**可见性**,恢复宽度立刻可见。
|
|
2310
2340
|
选择器用结构条件、不写宿主的哈希类名(如 SNx2jG_*),宿主升级换了哈希也不会失效。
|
|
2311
2341
|
|
|
2312
2342
|
⚠️ 1.0.50 修正:不能用 nav:has(button[data-index]) 当开关。宿主在容器宽度
|
|
@@ -2315,7 +2345,9 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2315
2345
|
成了死锁。这也正是「分到 3 栏(每栏 ~567px)怎么补都不出现、拖宽到 900px 以上
|
|
2316
2346
|
突然出现」的原因。现在只按结构定位这颗 nav,与里面有没有按钮无关。 */
|
|
2317
2347
|
.dsv-pane .dsv-body [data-conversation-scroll] nav{display:block!important}
|
|
2318
|
-
|
|
2348
|
+
/* 窄到放不下时只隐藏可见性。阈值是设置项(默认 240px,0 = 永不隐藏),而容器查询
|
|
2349
|
+
只认固定数字、不认 CSS 变量,所以这条规则不写在这里:由 railThresholdCss() 生成到
|
|
2350
|
+
独立的 <style> 里,改设置即时重写。 */
|
|
2319
2351
|
/* 窗口最大化时外框有约 7px 溢出到屏幕外,标题栏最顶上那一截落在屏幕外;
|
|
2320
2352
|
标签原来只有 ~26px 高、上下留 9px,光标贴屏幕最顶时落在标签上方的空白里,点不到标签。
|
|
2321
2353
|
把标签命中区拉到标题栏整高(内容仍垂直居中)。只改标签自身横向范围,
|
|
@@ -2414,6 +2446,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2414
2446
|
.dsv-settings h2{margin:0;font-size:17px;font-weight:600}
|
|
2415
2447
|
.dsv-settings p{margin:0;font-size:13px;line-height:1.65;opacity:.72}
|
|
2416
2448
|
.dsv-card{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:13px 16px;border:1px solid var(--dsh-border-color,rgba(128,128,128,.26));border-radius:10px;background:rgba(255,255,255,.012);transition:border-color .15s ease,background-color .15s ease}
|
|
2449
|
+
/* 带滑杆的卡片:标题在上、控件占满整行(横向两列会把滑杆挤成一条缝)。 */
|
|
2450
|
+
.dsv-card-col{flex-direction:column;align-items:stretch;gap:10px}
|
|
2417
2451
|
.dsv-card:hover{border-color:var(--dsh-border-color,rgba(128,128,128,.42));background:rgba(255,255,255,.028)}
|
|
2418
2452
|
.dsv-card-text{display:flex;flex-direction:column;gap:3px;min-width:0}
|
|
2419
2453
|
.dsv-card-title{font-size:13px;font-weight:600;letter-spacing:.01em}
|
|
@@ -2545,16 +2579,42 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
2545
2579
|
可能比 apply() 早 —— 于是先闪一帧「没有样式的白板页」,再跳到正常样式。 */
|
|
2546
2580
|
installStyles();
|
|
2547
2581
|
|
|
2582
|
+
function railThresholdCss(below) {
|
|
2583
|
+
/* 容器查询只认固定数字、不认 CSS 变量,所以阈值只能拼进规则文本。
|
|
2584
|
+
0 = 永不隐藏:返回空串,表里一个字都不留。 */
|
|
2585
|
+
const px = clampRailHide(below);
|
|
2586
|
+
if (!(px > 0)) return "";
|
|
2587
|
+
return `@container (width<=${px}px){.dsv-pane .dsv-body [data-conversation-scroll] nav{visibility:hidden;pointer-events:none}}`;
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
function applyRailThreshold() {
|
|
2591
|
+
try {
|
|
2592
|
+
const el = document.getElementById(RAIL_STYLE_ID);
|
|
2593
|
+
if (el === null) return;
|
|
2594
|
+
const next = railThresholdCss(prefs.state.railHideBelow);
|
|
2595
|
+
if (el.textContent !== next) el.textContent = next;
|
|
2596
|
+
} catch {
|
|
2597
|
+
/* ignore */
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2548
2601
|
/**
|
|
2549
2602
|
* Install the stylesheet once per document.
|
|
2550
2603
|
*/
|
|
2551
2604
|
function installStyles() {
|
|
2552
2605
|
try {
|
|
2553
|
-
if (document.getElementById(STYLE_ID)
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2606
|
+
if (document.getElementById(STYLE_ID) === null) {
|
|
2607
|
+
const style = document.createElement("style");
|
|
2608
|
+
style.id = STYLE_ID;
|
|
2609
|
+
style.textContent = CSS;
|
|
2610
|
+
document.head.appendChild(style);
|
|
2611
|
+
}
|
|
2612
|
+
if (document.getElementById(RAIL_STYLE_ID) === null) {
|
|
2613
|
+
const railStyle = document.createElement("style");
|
|
2614
|
+
railStyle.id = RAIL_STYLE_ID;
|
|
2615
|
+
document.head.appendChild(railStyle);
|
|
2616
|
+
}
|
|
2617
|
+
applyRailThreshold();
|
|
2558
2618
|
} catch (error) {
|
|
2559
2619
|
console.warn("[split-view] styles unavailable:", error);
|
|
2560
2620
|
}
|
|
@@ -3447,8 +3507,8 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
3447
3507
|
return null;
|
|
3448
3508
|
}, []);
|
|
3449
3509
|
|
|
3450
|
-
const paneId = react.useContext(PaneIdCtx);
|
|
3451
|
-
|
|
3510
|
+
const paneId = react.useContext(PaneIdCtx);
|
|
3511
|
+
|
|
3452
3512
|
/* ── 1.0.49:轮次导航条在窗格里不出现的取证 + 修正刺激 ──────────────────
|
|
3453
3513
|
宿主源码(app.asar → dsh-client-ui-chat/lib/client.js)里,那条短横线要同时满足:
|
|
3454
3514
|
1) `scroll.initialized === true` 才渲染 TurnNavigator(第 3622 行);
|
|
@@ -3565,7 +3625,7 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
|
|
|
3565
3625
|
sessionId,
|
|
3566
3626
|
paneId
|
|
3567
3627
|
]);
|
|
3568
|
-
|
|
3628
|
+
|
|
3569
3629
|
if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-empty" }, t("这个版本没有提供会话内容区域"));
|
|
3570
3630
|
|
|
3571
3631
|
// A blank tab is the host's own "new session" page: the content factory
|
|
@@ -4893,7 +4953,7 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
4893
4953
|
h(TabContentMemo, {
|
|
4894
4954
|
sessionId: tabSessionId,
|
|
4895
4955
|
hero: tabHero,
|
|
4896
|
-
active: tabActive,
|
|
4956
|
+
active: tabActive,
|
|
4897
4957
|
sessions,
|
|
4898
4958
|
renderFactorySlot,
|
|
4899
4959
|
SessionProvider,
|
|
@@ -7705,10 +7765,14 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
7705
7765
|
const why = body === null || body === void 0 ? `HTTP ${res.status}` : hostMessage(String(body.message ?? ""));
|
|
7706
7766
|
throw new Error(why === "" ? `HTTP ${res.status}` : why);
|
|
7707
7767
|
}
|
|
7768
|
+
/* 宿主会在 warn 里说明「文件装好了,但 profile 的 package.json / pnpm-lock
|
|
7769
|
+
没改成功」。这种情况不能报成功就完事:下一次装别的插件还是会把它退回旧版,
|
|
7770
|
+
用户会再看到一模一样的「发现新版本」。 */
|
|
7771
|
+
const warn = body !== null && typeof body.warn === "string" ? body.warn.trim() : "";
|
|
7708
7772
|
setUpdate((prev) => ({
|
|
7709
7773
|
...prev,
|
|
7710
7774
|
phase: "done",
|
|
7711
|
-
text: t("已更新到 {0},重启 App 后生效", [target]),
|
|
7775
|
+
text: warn === "" ? t("已更新到 {0},重启 App 后生效", [target]) : t("已更新到 {0},但依赖登记没同步({1}):下次装/卸别的插件可能把它退回旧版", [target, hostMessage(warn)]),
|
|
7712
7776
|
canUpdate: false,
|
|
7713
7777
|
progress: 100,
|
|
7714
7778
|
forceHint: ""
|
|
@@ -7957,6 +8021,35 @@ if (typeof renderFactorySlot !== "function") return h("div", { className: "dsv-e
|
|
|
7957
8021
|
onClick: () => prefs.update({ hostBar: p.hostBar === false })
|
|
7958
8022
|
})
|
|
7959
8023
|
),
|
|
8024
|
+
/* 轮次导航条(会话右侧那列短横线):栏窄到放不下时隐藏。
|
|
8025
|
+
阈值用户可调(1.0.51),0 = 永不隐藏。 */
|
|
8026
|
+
h(
|
|
8027
|
+
"div",
|
|
8028
|
+
{ className: "dsv-card dsv-card-col", key: "rail-threshold" },
|
|
8029
|
+
h(
|
|
8030
|
+
"div",
|
|
8031
|
+
{ className: "dsv-card-text" },
|
|
8032
|
+
h("div", { className: "dsv-card-title" }, t("窄栏隐藏轮次导航条")),
|
|
8033
|
+
h(
|
|
8034
|
+
"div",
|
|
8035
|
+
{ className: "dsv-card-desc" },
|
|
8036
|
+
clampRailHide(p.railHideBelow) > 0
|
|
8037
|
+
? t("栏宽不超过 {0}px 时隐藏这条导航;每栏按自己的宽度判断。", [
|
|
8038
|
+
String(clampRailHide(p.railHideBelow))
|
|
8039
|
+
])
|
|
8040
|
+
: t("已关闭:无论栏多窄都显示这条导航。")
|
|
8041
|
+
)
|
|
8042
|
+
),
|
|
8043
|
+
h(AppearanceWidth, {
|
|
8044
|
+
label: t("隐藏阈值"),
|
|
8045
|
+
hint: t("0 = 永不隐藏;默认 240px"),
|
|
8046
|
+
min: RAIL_HIDE_MIN,
|
|
8047
|
+
max: RAIL_HIDE_MAX,
|
|
8048
|
+
step: 10,
|
|
8049
|
+
value: clampRailHide(p.railHideBelow),
|
|
8050
|
+
onChange: (value) => prefs.update({ railHideBelow: clampRailHide(value) })
|
|
8051
|
+
})
|
|
8052
|
+
),
|
|
7960
8053
|
/* 视图切换条:开关 + 位置 + 逐项列表,三块连在一起
|
|
7961
8054
|
(用户口径 2026-11-08:开关和它的具体设置必须挨着,原来中间隔着别的卡)。 */
|
|
7962
8055
|
h(
|
package/lib/index.js
CHANGED
|
@@ -1,241 +1,433 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host half of dsh-split-view.
|
|
3
|
-
*
|
|
4
|
-
* The feature is a pure client-surface extension: it registers a `main` panel
|
|
5
|
-
* that renders the existing conversation panel several times, each bound to its
|
|
6
|
-
* own session. `apply` therefore has one real job beyond keeping the bundle row
|
|
7
|
-
* mountable: keep this plugin installable through the plugin market on THIS
|
|
8
|
-
* machine.
|
|
9
|
-
*
|
|
10
|
-
* pnpm refuses packages younger than the profile's minimumReleaseAge unless that
|
|
11
|
-
* exact version is listed under minimumReleaseAgeExclude in
|
|
12
|
-
* ~/.dsh/profiles/<profile>/pnpm-workspace.yaml. That list is per-machine and
|
|
13
|
-
* per-profile, so every release used to break "update from the settings page" on
|
|
14
|
-
* any machine whose list had not been edited by hand — something a user should
|
|
15
|
-
* never have to do, and cannot reasonably do without a terminal.
|
|
16
|
-
*
|
|
17
|
-
* The host half has filesystem access, so it keeps the bookkeeping itself: on
|
|
18
|
-
* load, append the running version to the existing dsh-multipane line when it is
|
|
19
|
-
* missing. Nothing here may affect plugin loading, so every path is guarded.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
try {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Host half of dsh-split-view.
|
|
3
|
+
*
|
|
4
|
+
* The feature is a pure client-surface extension: it registers a `main` panel
|
|
5
|
+
* that renders the existing conversation panel several times, each bound to its
|
|
6
|
+
* own session. `apply` therefore has one real job beyond keeping the bundle row
|
|
7
|
+
* mountable: keep this plugin installable through the plugin market on THIS
|
|
8
|
+
* machine.
|
|
9
|
+
*
|
|
10
|
+
* pnpm refuses packages younger than the profile's minimumReleaseAge unless that
|
|
11
|
+
* exact version is listed under minimumReleaseAgeExclude in
|
|
12
|
+
* ~/.dsh/profiles/<profile>/pnpm-workspace.yaml. That list is per-machine and
|
|
13
|
+
* per-profile, so every release used to break "update from the settings page" on
|
|
14
|
+
* any machine whose list had not been edited by hand — something a user should
|
|
15
|
+
* never have to do, and cannot reasonably do without a terminal.
|
|
16
|
+
*
|
|
17
|
+
* The host half has filesystem access, so it keeps the bookkeeping itself: on
|
|
18
|
+
* load, append the running version to the existing dsh-multipane line when it is
|
|
19
|
+
* missing. Nothing here may affect plugin loading, so every path is guarded.
|
|
20
|
+
*
|
|
21
|
+
* The same account has a second half, and skipping it is what made an update look
|
|
22
|
+
* like it never happened: installing the files under node_modules does NOT touch
|
|
23
|
+
* the profile's package.json or pnpm-lock.yaml, which still pin the OLD version.
|
|
24
|
+
* The next `pnpm install` in that profile — installing or removing ANY other
|
|
25
|
+
* plugin — then re-materialises the locked version over the fresh files, silently
|
|
26
|
+
* downgrading this plugin and bringing the "new version available" prompt right
|
|
27
|
+
* back (measured 2026-11-12: 1.0.51 installed, the 9:42 synapse install later,
|
|
28
|
+
* directory 1.0.37 again, settings page still offering 1.0.51). So a successful
|
|
29
|
+
* update now also rewrites both bookkeeping files to the new version and its
|
|
30
|
+
* integrity, and writes neither when either edit cannot be proven exact.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
34
|
+
import { execFile } from "node:child_process";
|
|
35
|
+
import { createHash } from "node:crypto";
|
|
36
|
+
import { homedir } from "node:os";
|
|
37
|
+
import { join } from "node:path";
|
|
38
|
+
import { fileURLToPath } from "node:url";
|
|
39
|
+
|
|
40
|
+
/** Cordis plugin name used by the loader row. */
|
|
41
|
+
export const name = 'dsh-split-view';
|
|
42
|
+
|
|
43
|
+
/** No host services are required. */
|
|
44
|
+
export const inject = [];
|
|
45
|
+
|
|
46
|
+
/** Package name as published; also the name the market knows. */
|
|
47
|
+
const PKG_NAME = "dsh-multipane";
|
|
48
|
+
|
|
49
|
+
function readOwnVersion() {
|
|
50
|
+
try {
|
|
51
|
+
const pkgPath = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
52
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
53
|
+
return typeof pkg.version === "string" ? pkg.version : "";
|
|
54
|
+
} catch {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Append `version` to the dsh-multipane row of one profile's pnpm-workspace.yaml.
|
|
61
|
+
* The row has to be edited in place: pnpm honours only the FIRST rule per package
|
|
62
|
+
* name, so appending a second line for the same name is ignored.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} profileDir absolute path of the profile directory
|
|
65
|
+
* @param {string} version version to allow
|
|
66
|
+
* @returns boolean whether the file was changed
|
|
67
|
+
*/
|
|
68
|
+
function allowVersionOnThisMachine(profileDir, version) {
|
|
69
|
+
const yamlPath = join(profileDir, "pnpm-workspace.yaml");
|
|
70
|
+
if (!existsSync(yamlPath)) return false;
|
|
71
|
+
const lines = readFileSync(yamlPath, "utf8").split(/\r?\n/);
|
|
72
|
+
const index = lines.findIndex((line) => line.indexOf(PKG_NAME + "@") >= 0);
|
|
73
|
+
if (index < 0) return false;
|
|
74
|
+
const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
75
|
+
if (new RegExp("(^|[\\s|])" + escaped + "(\\s|$)").test(lines[index])) return false;
|
|
76
|
+
lines[index] = lines[index].trimEnd() + " || " + version;
|
|
77
|
+
writeFileSync(yamlPath, lines.join("\n"), "utf8");
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Escape a literal string so it can be embedded in a RegExp source.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} text literal text
|
|
85
|
+
* @returns string regex-safe text
|
|
86
|
+
*/
|
|
87
|
+
function escapeRegex(text) {
|
|
88
|
+
return String(text).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* npm-style sha512 integrity of a file ("sha512-" + base64 of the digest).
|
|
93
|
+
*
|
|
94
|
+
* pnpm stores exactly this string as the lockfile entry's integrity. A stale or
|
|
95
|
+
* invented one makes the next install treat the package as tampered with, which
|
|
96
|
+
* is worse than leaving the old entry alone.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} file absolute path of the tarball
|
|
99
|
+
* @returns {string} integrity string, or "" when the file cannot be read
|
|
100
|
+
*/
|
|
101
|
+
function integrityOfFile(file) {
|
|
102
|
+
try {
|
|
103
|
+
return "sha512-" + createHash("sha512").update(readFileSync(file)).digest("base64");
|
|
104
|
+
} catch {
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Point the profile's dependency bookkeeping at `version`.
|
|
111
|
+
*
|
|
112
|
+
* Two files decide what the next `pnpm install` believes about this package:
|
|
113
|
+
* package.json (the specifier the profile asks for) and pnpm-lock.yaml (the
|
|
114
|
+
* specifier it expects, plus the version and integrity it will materialise). If
|
|
115
|
+
* both keep naming the old version, the very next install in the profile
|
|
116
|
+
* silently downgrades the files an update just wrote.
|
|
117
|
+
*
|
|
118
|
+
* Both files are edited as text rather than through a JSON/YAML round-trip, so
|
|
119
|
+
* the user's formatting survives. Nothing is written unless both edits are known
|
|
120
|
+
* to be exact: half-updated bookkeeping (new specifier, old lock entry) would
|
|
121
|
+
* make pnpm reject the whole profile instead of merely rolling this one package
|
|
122
|
+
* back — a much worse failure than the bug being fixed.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} profileDir absolute path of the profile directory
|
|
125
|
+
* @param {string} version version that was just installed
|
|
126
|
+
* @param {string} integrity sha512 integrity of the tarball that was installed
|
|
127
|
+
* @returns {{ok: boolean, changed: boolean, problems: string[]}} result
|
|
128
|
+
*/
|
|
129
|
+
function syncDependencyBookkeeping(profileDir, version, integrity) {
|
|
130
|
+
const pkgPath = join(profileDir, "package.json");
|
|
131
|
+
const lockPath = join(profileDir, "pnpm-lock.yaml");
|
|
132
|
+
const problems = [];
|
|
133
|
+
|
|
134
|
+
let pkgText = "";
|
|
135
|
+
let lockText = "";
|
|
136
|
+
try {
|
|
137
|
+
if (existsSync(pkgPath)) pkgText = readFileSync(pkgPath, "utf8");
|
|
138
|
+
} catch (error) {
|
|
139
|
+
problems.push("读不了 package.json:" + String((error && error.message) || error));
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
if (existsSync(lockPath)) lockText = readFileSync(lockPath, "utf8");
|
|
143
|
+
} catch (error) {
|
|
144
|
+
problems.push("读不了 pnpm-lock.yaml:" + String((error && error.message) || error));
|
|
145
|
+
}
|
|
146
|
+
if (pkgText === "") problems.push("找不到 profile 的 package.json");
|
|
147
|
+
if (lockText === "") problems.push("找不到 pnpm-lock.yaml");
|
|
148
|
+
|
|
149
|
+
/* 依赖行本就存在的三种形状都认:dependencies、devDependencies、optional… 这里只按
|
|
150
|
+
「"dsh-multipane": "<spec>"」这一处文本换掉 spec,不关心它在哪个段里。 */
|
|
151
|
+
const depRe = new RegExp('("' + escapeRegex(PKG_NAME) + '"\\s*:\\s*")[^"]*(")');
|
|
152
|
+
if (pkgText !== "" && !depRe.test(pkgText)) problems.push("package.json 里没有 " + PKG_NAME + " 的依赖行");
|
|
153
|
+
if (problems.length > 0) return { ok: false, changed: false, problems };
|
|
154
|
+
|
|
155
|
+
/* importer 块:specifier 与 version 成对出现,两行都要换。前导换行必须在捕获组里,
|
|
156
|
+
否则替换会把上一行与这一行粘成一行 —— YAML 直接坏掉,pnpm 拒绝整个 profile。 */
|
|
157
|
+
const importerRe = new RegExp("(\\n " + escapeRegex(PKG_NAME) + ":\\n specifier: )([^\\n]*)(\\n version: )([^\\n]*)");
|
|
158
|
+
const hit = lockText.match(importerRe);
|
|
159
|
+
if (hit === null) return { ok: false, changed: false, problems: ["pnpm-lock 里没有 " + PKG_NAME + " 的 importer 块"] };
|
|
160
|
+
/* version 可能带 peer 后缀(1.0.37(@deepseek-ai/dsh@…)),键名里只比裸版本号。 */
|
|
161
|
+
const previous = hit[4].trim().split("(")[0];
|
|
162
|
+
const changed = previous !== version;
|
|
163
|
+
|
|
164
|
+
let nextLock = lockText;
|
|
165
|
+
if (changed) {
|
|
166
|
+
nextLock = nextLock.replace(importerRe, (all, head, spec, mid) => head + version + mid + version);
|
|
167
|
+
/* packages 段与 snapshots 段各有一条键: dsh-multipane@<版本>: */
|
|
168
|
+
const keyRe = new RegExp("(^|\\n)( " + escapeRegex(PKG_NAME) + "@)" + escapeRegex(previous) + "(?=[:(])", "g");
|
|
169
|
+
const keys = (nextLock.match(keyRe) || []).length;
|
|
170
|
+
if (keys < 1) return { ok: false, changed: false, problems: ["pnpm-lock 里找不到 " + PKG_NAME + "@" + previous + " 的条目"] };
|
|
171
|
+
nextLock = nextLock.replace(keyRe, (all, lead, prefix) => lead + prefix + version);
|
|
172
|
+
if (integrity !== "") {
|
|
173
|
+
const resRe = new RegExp("(\\n " + escapeRegex(PKG_NAME) + "@" + escapeRegex(version) + ":\\n resolution: \\{integrity: )[^}\\n]+(\\})");
|
|
174
|
+
if (!resRe.test(nextLock)) return { ok: false, changed: false, problems: ["pnpm-lock 里找不到 " + version + " 的 integrity 行"] };
|
|
175
|
+
nextLock = nextLock.replace(resRe, (all, head, tail) => head + integrity + tail);
|
|
176
|
+
}
|
|
177
|
+
const guard = lockEditProblems(lockText, nextLock, version);
|
|
178
|
+
if (guard.length > 0) {
|
|
179
|
+
return { ok: false, changed: false, problems: guard.map((one) => "pnpm-lock 未写入:" + one) };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const nextPkg = pkgText.replace(depRe, (all, head, tail) => head + version + tail);
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
if (changed) writeFileSync(lockPath, nextLock, "utf8");
|
|
186
|
+
writeFileSync(pkgPath, nextPkg, "utf8");
|
|
187
|
+
} catch (error) {
|
|
188
|
+
try {
|
|
189
|
+
if (changed) writeFileSync(lockPath, lockText, "utf8");
|
|
190
|
+
} catch {
|
|
191
|
+
/* 回滚失败也不抛出:调用方拿 problems 里的原因去提示用户 */
|
|
192
|
+
}
|
|
193
|
+
return { ok: false, changed: false, problems: ["写登记文件失败:" + String((error && error.message) || error)] };
|
|
194
|
+
}
|
|
195
|
+
return { ok: true, changed, problems: [] };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Guard the lockfile edit: only the lines we meant to touch may differ.
|
|
200
|
+
*
|
|
201
|
+
* A text edit that swallows a newline still "looks" fine in the editor but makes
|
|
202
|
+
* the file unparseable, and pnpm then refuses the whole profile instead of merely
|
|
203
|
+
* rolling one package back. Comparing line by line makes that impossible to ship:
|
|
204
|
+
* the edit is accepted only when the line count is unchanged and every changed
|
|
205
|
+
* line is one of the expected shapes.
|
|
206
|
+
*
|
|
207
|
+
* It returns the reasons it refused (empty array = clean) rather than a bare
|
|
208
|
+
* false: a silent rejection is exactly the kind of detail that is impossible to
|
|
209
|
+
* support later, and the caller shows these strings to the user.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} before lock text as read
|
|
212
|
+
* @param {string} after lock text as edited
|
|
213
|
+
* @param {string} version version that was installed
|
|
214
|
+
* @returns {string[]} problems, empty when the edit is clean
|
|
215
|
+
*/
|
|
216
|
+
function lockEditProblems(before, after, version) {
|
|
217
|
+
const a = before.split("\n");
|
|
218
|
+
const b = after.split("\n");
|
|
219
|
+
if (a.length !== b.length) return ["行数从 " + a.length + " 变成 " + b.length];
|
|
220
|
+
/* 预期最多 5 行:importer 的 specifier 与 version、packages 键、snapshots 键、
|
|
221
|
+
packages 条目的 integrity。 */
|
|
222
|
+
const maxChanged = 5;
|
|
223
|
+
const allowed = [
|
|
224
|
+
new RegExp("^ specifier: " + escapeRegex(version) + "$"),
|
|
225
|
+
new RegExp("^ version: " + escapeRegex(version) + "(?:\\(.*\\))?$"),
|
|
226
|
+
/* snapshots 的条目带一个空映射: dsh-multipane@1.0.51: {} */
|
|
227
|
+
new RegExp("^ " + escapeRegex(PKG_NAME) + "@" + escapeRegex(version) + "(?:\\(.*\\))?:(?:\\s*\\{\\s*\\})?$"),
|
|
228
|
+
/^ resolution: \{integrity: sha512-[^}]+\}$/
|
|
229
|
+
];
|
|
230
|
+
const problems = [];
|
|
231
|
+
let changed = 0;
|
|
232
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
233
|
+
if (a[i] === b[i]) continue;
|
|
234
|
+
changed += 1;
|
|
235
|
+
if (changed > maxChanged) {
|
|
236
|
+
problems.push("改了 " + changed + " 行,超过上限 " + maxChanged);
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
if (!allowed.some((rule) => rule.test(b[i]))) {
|
|
240
|
+
problems.push("第 " + (i + 1) + " 行不在预期范围内:" + b[i].trim().slice(0, 60));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (problems.length === 0 && changed === 0) problems.push("没有产生任何改动");
|
|
244
|
+
return problems;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Try every profile that exists on this machine (desktop is what the app uses,
|
|
249
|
+
* web is used by headless checks). Unknown layouts are skipped silently.
|
|
250
|
+
*/
|
|
251
|
+
function ensureMarketInstallable() {
|
|
252
|
+
try {
|
|
253
|
+
const version = readOwnVersion();
|
|
254
|
+
if (version === "") return;
|
|
255
|
+
const root = join(homedir(), ".dsh", "profiles");
|
|
256
|
+
if (!existsSync(root)) return;
|
|
257
|
+
for (const profile of ["desktop", "web"]) {
|
|
258
|
+
try {
|
|
259
|
+
allowVersionOnThisMachine(join(root, profile), version);
|
|
260
|
+
} catch {
|
|
261
|
+
/* 单个 profile 失败不影响另一个,也不影响插件加载 */
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
} catch {
|
|
265
|
+
/* 绝不因为这里失败而挡住插件加载 */
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Mount the host half.
|
|
271
|
+
*
|
|
272
|
+
* @returns void
|
|
273
|
+
*/
|
|
274
|
+
const UPDATE_ROUTE = "/dsh-multipane/update";
|
|
275
|
+
const STATUS_ROUTE = "/dsh-multipane/status";
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Install one published version straight from the npm registry.
|
|
279
|
+
*
|
|
280
|
+
* Why not the package manager: the market path goes through pnpm, which refuses
|
|
281
|
+
* releases younger than the profile's minimumReleaseAge, and the market itself
|
|
282
|
+
* syncs its catalog minutes behind the registry. Downloading the published
|
|
283
|
+
* tarball and unpacking it is what "update from npm" means here — no pnpm, no
|
|
284
|
+
* third-party catalog, no release-age wait.
|
|
285
|
+
*
|
|
286
|
+
* Safety: copy the current directory aside first, and put it back if anything
|
|
287
|
+
* fails, so a half-written plugin can never brick the app. A successful copy is
|
|
288
|
+
* followed by syncDependencyBookkeeping, which makes the profile's package.json
|
|
289
|
+
* and pnpm-lock.yaml name the same version — without that, the next install in
|
|
290
|
+
* this profile rolls the directory straight back.
|
|
291
|
+
*
|
|
292
|
+
* @param {string} profileDir profile directory that owns node_modules
|
|
293
|
+
* @param {string} version version to install
|
|
294
|
+
* @returns {Promise<{ok: boolean, message: string, warn: string}>} result
|
|
295
|
+
*/
|
|
296
|
+
function installFromRegistry(profileDir, version) {
|
|
297
|
+
const target = join(profileDir, "node_modules", PKG_NAME);
|
|
298
|
+
const staging = join(homedir(), ".dsh", ".dsv-update-" + process.pid);
|
|
299
|
+
const backup = join(homedir(), ".dsh", ".dsv-backup-" + process.pid);
|
|
300
|
+
const tarball = join(staging, "pkg.tgz");
|
|
301
|
+
const url = "https://registry.npmjs.org/" + PKG_NAME + "/-/" + PKG_NAME + "-" + version + ".tgz";
|
|
302
|
+
const run = (file, args, options) =>
|
|
303
|
+
new Promise((resolve) => {
|
|
304
|
+
execFile(file, args, Object.assign({ timeout: 120000, windowsHide: true }, options || {}), (error, stdout, stderr) => {
|
|
305
|
+
resolve({ ok: error === null, out: String(stdout || ""), err: String(stderr || (error && error.message) || "") });
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
return (async () => {
|
|
309
|
+
try {
|
|
310
|
+
rmSync(staging, { recursive: true, force: true });
|
|
311
|
+
rmSync(backup, { recursive: true, force: true });
|
|
312
|
+
mkdirSync(staging, { recursive: true });
|
|
313
|
+
const dl = await run("curl", ["-sSL", "--noproxy", "*", "--max-time", "110", "-o", tarball, url]);
|
|
314
|
+
if (!dl.ok || !existsSync(tarball)) return { ok: false, message: "下载失败:" + dl.err.slice(0, 200) };
|
|
315
|
+
/* 必须用 Windows 自带的 bsdtar:git-bash 里的 GNU tar 会把 "C:/…" 当成
|
|
316
|
+
host:path 语法去连远程主机(报 "Cannot connect to C: resolve failed")。 */
|
|
317
|
+
const tarExe = existsSync("C:/Windows/System32/tar.exe") ? "C:/Windows/System32/tar.exe" : "tar";
|
|
318
|
+
const un = await run(tarExe, ["-xzf", tarball, "-C", staging]);
|
|
319
|
+
if (!un.ok) return { ok: false, message: "解压失败:" + un.err.slice(0, 200) };
|
|
320
|
+
const unpacked = join(staging, "package");
|
|
321
|
+
if (!existsSync(join(unpacked, "package.json"))) return { ok: false, message: "包里没有 package.json" };
|
|
322
|
+
const got = JSON.parse(readFileSync(join(unpacked, "package.json"), "utf8")).version;
|
|
323
|
+
if (got !== version) return { ok: false, message: "包内版本是 " + got + ",不是 " + version };
|
|
324
|
+
/* integrity 要从解压前的 tgz 算,解压完 staging 就删了。 */
|
|
325
|
+
const integrity = integrityOfFile(tarball);
|
|
326
|
+
if (existsSync(target)) {
|
|
327
|
+
cpSync(target, backup, { recursive: true });
|
|
328
|
+
}
|
|
329
|
+
rmSync(target, { recursive: true, force: true });
|
|
330
|
+
cpSync(unpacked, target, { recursive: true });
|
|
331
|
+
rmSync(staging, { recursive: true, force: true });
|
|
332
|
+
rmSync(backup, { recursive: true, force: true });
|
|
333
|
+
/* 文件就位只是前半笔账,还要让 profile 的 package.json / pnpm-lock 也指到新版本,
|
|
334
|
+
否则下一次任何 pnpm 安装都会按旧 lockfile 把这个目录重铺回旧版本。 */
|
|
335
|
+
try {
|
|
336
|
+
allowVersionOnThisMachine(profileDir, version);
|
|
337
|
+
} catch {
|
|
338
|
+
/* 免查名单只影响「从插件市场更新」,不影响已经装好的文件 */
|
|
339
|
+
}
|
|
340
|
+
const sync = syncDependencyBookkeeping(profileDir, version, integrity);
|
|
341
|
+
if (sync.ok) return { ok: true, message: "已安装 " + version, warn: "" };
|
|
342
|
+
return { ok: true, message: "已安装 " + version, warn: sync.problems.join(";") };
|
|
343
|
+
} catch (error) {
|
|
344
|
+
try {
|
|
345
|
+
if (existsSync(backup)) {
|
|
346
|
+
rmSync(target, { recursive: true, force: true });
|
|
347
|
+
cpSync(backup, target, { recursive: true });
|
|
348
|
+
}
|
|
349
|
+
} catch {
|
|
350
|
+
/* 回滚失败也不抛出 */
|
|
351
|
+
}
|
|
352
|
+
return { ok: false, message: String((error && error.message) || error) };
|
|
353
|
+
}
|
|
354
|
+
})();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function readJsonBody(request, limit, done) {
|
|
358
|
+
let body = "";
|
|
359
|
+
let aborted = false;
|
|
360
|
+
request.on("data", (chunk) => {
|
|
361
|
+
body += chunk;
|
|
362
|
+
if (body.length > limit) {
|
|
363
|
+
aborted = true;
|
|
364
|
+
request.destroy();
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
request.on("end", () => {
|
|
368
|
+
if (!aborted) done(body);
|
|
369
|
+
});
|
|
370
|
+
request.on("error", () => {
|
|
371
|
+
/* 忽略 */
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export function apply(ctx) {
|
|
376
|
+
try {
|
|
377
|
+
ensureMarketInstallable();
|
|
378
|
+
} catch {
|
|
379
|
+
/* 忽略 */
|
|
380
|
+
}
|
|
381
|
+
try {
|
|
382
|
+
ctx.inject(["webServer"], (host) => {
|
|
383
|
+
const profileDirOf = () => join(homedir(), ".dsh", "profiles", "desktop");
|
|
384
|
+
const routes = [
|
|
385
|
+
{
|
|
386
|
+
kind: "exact",
|
|
387
|
+
path: STATUS_ROUTE,
|
|
388
|
+
handler: (request, response) => {
|
|
389
|
+
response.writeHead(200, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
|
390
|
+
response.end(JSON.stringify({ version: readOwnVersion(), profile: profileDirOf() }));
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
kind: "exact",
|
|
395
|
+
path: UPDATE_ROUTE,
|
|
396
|
+
handler: (request, response) => {
|
|
397
|
+
if (request.method !== "POST") {
|
|
398
|
+
response.writeHead(405, { allow: "POST" });
|
|
399
|
+
response.end("");
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
readJsonBody(request, 4096, (body) => {
|
|
403
|
+
let version = "";
|
|
404
|
+
try {
|
|
405
|
+
version = String(JSON.parse(body).version || "");
|
|
406
|
+
} catch {
|
|
407
|
+
/* 交给下面校验 */
|
|
408
|
+
}
|
|
409
|
+
if (!/^\d+\.\d+\.\d+$/.test(version)) {
|
|
410
|
+
response.writeHead(400, { "content-type": "application/json; charset=utf-8" });
|
|
411
|
+
response.end(JSON.stringify({ ok: false, message: "version 参数不合法" }));
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
installFromRegistry(profileDirOf(), version).then((result) => {
|
|
415
|
+
response.writeHead(result.ok ? 200 : 500, { "content-type": "application/json; charset=utf-8" });
|
|
416
|
+
response.end(JSON.stringify(result));
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
];
|
|
422
|
+
for (const route of routes) {
|
|
423
|
+
try {
|
|
424
|
+
host.webServer.register(route);
|
|
425
|
+
} catch {
|
|
426
|
+
/* 单个路由失败不影响另一个 */
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
} catch {
|
|
431
|
+
/* 拿不到 webServer 就只是没有设置页内的更新入口,插件本身照常工作 */
|
|
432
|
+
}
|
|
433
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-multipane",
|
|
3
|
-
"version":
|
|
3
|
+
"version": "1.0.52",
|
|
4
4
|
"description": "Split the DSH main area into up to four panes, each with its own tab strip, composer and view switcher. Drag a tab to a pane edge to split. Bilingual (zh/en).",
|
|
5
5
|
"displayName": "多栏视图",
|
|
6
6
|
"dshhub": {
|
|
@@ -84,3 +84,4 @@
|
|
|
84
84
|
"access": "public"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
|