dsh-multipane 1.0.36 → 1.0.37

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/README.en.md CHANGED
@@ -161,6 +161,10 @@ node scripts/check-names.cjs # package name / version / release-age allowanc
161
161
 
162
162
  ## Changelog
163
163
 
164
+ ### 1.0.37 (2026-11-11)
165
+
166
+ - **Fixed Ctrl+W dying on a second machine**: the host's Ctrl+W binding lives in a per-device file (`keybindings.json` in Electron's userData), so configuring one machine left the next one back on "close the window". The plugin now releases that binding itself on startup (via the host's `ctx.shortcuts.edit()`) and restores it when the switch is turned off or the plugin is disabled — no manual file copying on new machines
167
+
164
168
  ### 1.0.36 (2026-11-11)
165
169
 
166
170
  - **Ctrl+W closes the tab, with two switches**: the settings page gains "Ctrl+W closes the tab" (master) and "Close the window on the last tab" (depends on the former; greyed out and disabled while the master is off). Pressing Ctrl+W on the last remaining tab now closes the window instead of appearing to do nothing
package/README.md CHANGED
@@ -160,6 +160,10 @@ node scripts/check-names.cjs # 包名 / 版本 / 冷却豁免三处是否一
160
160
 
161
161
  ## 更新记录
162
162
 
163
+ ### 1.0.37(2026-11-11)
164
+
165
+ - **修「换台机器 Ctrl+W 就失效」**:宿主的 Ctrl+W 绑定是**每台设备本地一份**(Electron userData 的 `keybindings.json`),手工配好这台、换机器又变回关窗口。现在插件启动时自己把这个绑定交出来(走宿主的 `ctx.shortcuts.edit()`),关掉「Ctrl+W 关闭标签」开关或停用插件时再还回去 —— 换机器、重装、清配置都不用手工补
166
+
163
167
  ### 1.0.36(2026-11-11)
164
168
 
165
169
  - **Ctrl+W 关标签,两个开关可配**:设置页「界面元素」新增「Ctrl+W 关闭标签」(总开关)与「最后一个标签时关闭窗口」(依赖前者,前者关闭时自动变灰禁用)。只剩一个标签时再按 Ctrl+W 直接关窗口,不再像以前那样「按了没反应」
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.36";
20
+ const PLUGIN_VERSION = "1.0.37";
21
21
  const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
22
22
 
23
23
 
@@ -3741,6 +3741,60 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
3741
3741
  *
3742
3742
  * 设置页 / 插件停用时页面上没有 .dsv-pane,直接放行给宿主。
3743
3743
  */
3744
+ /**
3745
+ * 让宿主把 Ctrl+W(命令 `page.close`)的绑定交出来。
3746
+ *
3747
+ * 为什么必须这么做:Windows/macOS Desktop 的快捷键服务在**局部处理器之前**由可信
3748
+ * preload 拦截已接受的完整组合 —— 插件在渲染层 addEventListener 根本收不到 Ctrl+W
3749
+ * (合成事件能收到是假象,真实按键进不到 DOM)。宿主把「关闭页面」注册成 `page.close`
3750
+ * (code:KeyW + modifiers:[primary]),只有把它的绑定清掉,按键才会落到 DOM 被我们接管。
3751
+ *
3752
+ * 那份偏好是**每台设备本地一份**(Electron userData 的 keybindings.json),
3753
+ * 所以不能靠手工放文件,也不能靠换机器时同步 —— 插件自己写。
3754
+ * 走宿主的 `ctx.shortcuts.edit()`,由宿主负责序列化与校验,格式变了也是宿主自己的事。
3755
+ * 官方语义:`binding: null` = 清除该命令的绑定;`reset` = 恢复默认(把 Ctrl+W 还回去)。
3756
+ *
3757
+ * 只在「插件已启用 且 Ctrl+W 关标签开关打开」时清空;关掉开关或停用插件就还回去。
3758
+ * 宿主没有这个服务 / 命令改名 / 版本不兼容时,全部静默降级(回到「Ctrl+W 关窗口」),
3759
+ * 不会让插件崩掉,也不会吞掉用户其它快捷键。
3760
+ */
3761
+ function syncHostCtrlWBinding() {
3762
+ const shortcuts = service("shortcuts");
3763
+ if (shortcuts === void 0 || typeof shortcuts.edit !== "function") return;
3764
+ if (typeof shortcuts.config?.getSnapshot !== "function") return;
3765
+ let snapshot = null;
3766
+ try {
3767
+ snapshot = shortcuts.config.getSnapshot();
3768
+ } catch {
3769
+ return;
3770
+ }
3771
+ if (snapshot === null || snapshot === void 0 || snapshot.status !== "ready") return;
3772
+ const profile = `${shortcuts.runtime ?? "desktop"}:${shortcuts.platform ?? "windows"}`;
3773
+ const overrides = snapshot.document?.profiles?.[profile] ?? {};
3774
+ const has = Object.prototype.hasOwnProperty.call(overrides, "page.close");
3775
+ const isCleared = has && overrides["page.close"] === null;
3776
+ const wantCleared = prefs.state.enabled === true && prefs.state.ctrlWCloseTab !== false;
3777
+ if (isCleared === wantCleared) return;
3778
+ const action = wantCleared
3779
+ ? { type: "set", id: "page.close", binding: null }
3780
+ : { type: "reset", id: "page.close" };
3781
+ try {
3782
+ const result = shortcuts.edit(action, snapshot.revision);
3783
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
3784
+ result.then(
3785
+ (outcome) => {
3786
+ if (outcome !== null && outcome !== void 0 && outcome.status !== "saved") {
3787
+ console.warn("[split-view] page.close 绑定同步未完成:", outcome.status);
3788
+ }
3789
+ },
3790
+ (error) => console.warn("[split-view] page.close 绑定同步失败:", error)
3791
+ );
3792
+ }
3793
+ } catch (error) {
3794
+ console.warn("[split-view] page.close 绑定同步异常:", error);
3795
+ }
3796
+ }
3797
+
3744
3798
  function installCloseTabShortcut() {
3745
3799
  const totalTabs = () => {
3746
3800
  const state = LIVE_STATE;
@@ -9344,6 +9398,34 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
9344
9398
  /* 栏内标签切换:Ctrl+Tab / Ctrl+Shift+Tab。设置页没有 .dsv-pane,自然不会触发。 */
9345
9399
  ctx.effect(() => installTabCycling(), "dsh-split-view: tab cycling shortcut");
9346
9400
  ctx.effect(() => installCloseTabShortcut(), "dsh-split-view: ctrl+w closes the tab");
9401
+ /* 把宿主的 page.close 绑定交出来,否则 Ctrl+W 在原生层就被吃掉、插件永远收不到。
9402
+ 跟随启用状态与「Ctrl+W 关闭标签」开关变化;值没变时不写盘。 */
9403
+ ctx.effect(() => {
9404
+ syncHostCtrlWBinding();
9405
+ /* 宿主的 shortcuts 配置是异步加载的:插件 apply 时它往往还是 loading,
9406
+ 只在 prefs 变化时重试会永远错过 → 这里也订阅它,等它 ready 再写一次。 */
9407
+ const stops = [prefs.subscribe(syncHostCtrlWBinding)];
9408
+ try {
9409
+ const shortcuts = service("shortcuts");
9410
+ if (shortcuts !== void 0 && typeof shortcuts.config?.subscribe === "function") {
9411
+ stops.push(shortcuts.config.subscribe(() => syncHostCtrlWBinding()));
9412
+ }
9413
+ } catch {
9414
+ /* 服务不可用就算了 */
9415
+ }
9416
+ /* 兜底:异步服务晚到时再补一次(幂等,值没变不写盘)。 */
9417
+ const timers = [setTimeout(syncHostCtrlWBinding, 1500), setTimeout(syncHostCtrlWBinding, 4000)];
9418
+ return () => {
9419
+ for (const stop of stops) {
9420
+ try {
9421
+ if (typeof stop === "function") stop();
9422
+ } catch {
9423
+ /* 忽略 */
9424
+ }
9425
+ }
9426
+ for (const timer of timers) clearTimeout(timer);
9427
+ };
9428
+ }, "dsh-split-view: release host ctrl+w binding");
9347
9429
 
9348
9430
  /* 把「锁定标签」作为一项贡献进宿主的**会话右键菜单**。
9349
9431
  标签上右键 → 打开的就是宿主这份菜单(open 见 TabItem),所以标签右键与侧栏会话行右键
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-multipane",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
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": {