dsh-multipane 1.0.21 → 1.0.22

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.md CHANGED
@@ -246,6 +246,13 @@ C:\Users\weiai\.dsh\plugin-src\_probe\sync-client.ps1 -Push # 台式机 ->
246
246
 
247
247
  ## 更新记录
248
248
 
249
+ ### 1.0.22(2026-11-10)
250
+ - **插件自己维护「可安装版本清单」,用户再也不用碰命令行**:pnpm 对新版本有等待期,只有把版本号写进
251
+ `~/.dsh/profiles/<profile>/pnpm-workspace.yaml` 的 `minimumReleaseAgeExclude` 才允许安装。
252
+ 这份清单是**每台机器、每个 profile 各自一份**,以前只在我这台机器上手工加过,别的机器永远装不上新版。
253
+ 现在插件启动时会读自己的版本号并自动补进清单(失败就静默跳过,绝不影响加载)。
254
+ - 效果:在任何一台机器上装过一次本版之后,后续更新都能直接用设置页的「立即更新」。
255
+
249
256
  ### 1.0.21(2026-11-10)
250
257
  - 去掉更新弹窗里给开发者看的技术说明("观察期 / 防供应链投毒"这类话对用户没有用)。
251
258
  现在「看到新版本」的弹窗只有版本对比和一个「立即更新」按钮;只有**真的装失败了**才补一句
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.21";
20
+ const PLUGIN_VERSION = "1.0.22";
21
21
  const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
22
22
  /* 插件市场的公开更新 API v1(dshmarket 提供,见其 UPDATE-API-V1.md)。
23
23
  它自己负责装包/校验版本/回滚,我们只负责触发和显示结果——
package/lib/index.js CHANGED
@@ -1,23 +1,97 @@
1
1
  /**
2
2
  * Host half of dsh-split-view.
3
3
  *
4
- * The plugin is a pure client-surface extension: it registers a `main` panel
5
- * that renders the existing conversation panel twice, each bound to its own
6
- * session. Nothing on the host side needs to change, so `apply` is a no-op
7
- * whose only job is to keep the bundle row mountable.
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.
8
20
  */
9
21
 
22
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
23
+ import { homedir } from "node:os";
24
+ import { join } from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+
10
27
  /** Cordis plugin name used by the loader row. */
11
28
  export const name = 'dsh-split-view';
12
29
 
13
30
  /** No host services are required. */
14
31
  export const inject = [];
15
32
 
33
+ /** Package name as published; also the name the market knows. */
34
+ const PKG_NAME = "dsh-multipane";
35
+
36
+ function readOwnVersion() {
37
+ try {
38
+ const pkgPath = fileURLToPath(new URL("../package.json", import.meta.url));
39
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
40
+ return typeof pkg.version === "string" ? pkg.version : "";
41
+ } catch {
42
+ return "";
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Append `version` to the dsh-multipane row of one profile's pnpm-workspace.yaml.
48
+ * The row has to be edited in place: pnpm honours only the FIRST rule per package
49
+ * name, so appending a second line for the same name is ignored.
50
+ *
51
+ * @param {string} profileDir absolute path of the profile directory
52
+ * @param {string} version version to allow
53
+ * @returns boolean whether the file was changed
54
+ */
55
+ function allowVersionOnThisMachine(profileDir, version) {
56
+ const yamlPath = join(profileDir, "pnpm-workspace.yaml");
57
+ if (!existsSync(yamlPath)) return false;
58
+ const lines = readFileSync(yamlPath, "utf8").split(/\r?\n/);
59
+ const index = lines.findIndex((line) => line.indexOf(PKG_NAME + "@") >= 0);
60
+ if (index < 0) return false;
61
+ const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
62
+ if (new RegExp("(^|[\\s|])" + escaped + "(\\s|$)").test(lines[index])) return false;
63
+ lines[index] = lines[index].trimEnd() + " || " + version;
64
+ writeFileSync(yamlPath, lines.join("\n"), "utf8");
65
+ return true;
66
+ }
67
+
68
+ /**
69
+ * Try every profile that exists on this machine (desktop is what the app uses,
70
+ * web is used by headless checks). Unknown layouts are skipped silently.
71
+ */
72
+ function ensureMarketInstallable() {
73
+ try {
74
+ const version = readOwnVersion();
75
+ if (version === "") return;
76
+ const root = join(homedir(), ".dsh", "profiles");
77
+ if (!existsSync(root)) return;
78
+ for (const profile of ["desktop", "web"]) {
79
+ try {
80
+ allowVersionOnThisMachine(join(root, profile), version);
81
+ } catch {
82
+ /* 单个 profile 失败不影响另一个,也不影响插件加载 */
83
+ }
84
+ }
85
+ } catch {
86
+ /* 绝不因为这里失败而挡住插件加载 */
87
+ }
88
+ }
89
+
16
90
  /**
17
91
  * Mount the host half.
18
92
  *
19
93
  * @returns void
20
94
  */
21
95
  export function apply() {
22
- // Intentionally empty: the whole feature lives in lib/client.js.
96
+ ensureMarketInstallable();
23
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-multipane",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
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",