@kkutysllb/dsh-terminal 1.0.1 → 1.1.1

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.
Files changed (4) hide show
  1. package/README.md +51 -4
  2. package/client.js +25 -5
  3. package/entry.js +13 -10
  4. package/package.json +13 -1
package/README.md CHANGED
@@ -4,6 +4,43 @@
4
4
 
5
5
  自 KCoder 内置包独立发布的 dsh 插件(v1.0.0 起独立版本线)。
6
6
 
7
+ ## QiLin 双通道适配(v1.1.0 起)
8
+
9
+ manifest 同时声明 `qilin` 与 `dsh` 两个通道的 `bundle.patch` / `client`:
10
+ QiLin(dsh alpha.2 合并后)的插件管理器只认原生键 `qilin.bundle.patch`
11
+ (缺失会报"没有声明组合包"),DSH 宿主仍读 `dsh.*`;两通道指向同一份
12
+ `cordis.patch.yml` 与 client 交付物,行为完全一致。
13
+
14
+ ## QiLin 引擎安装
15
+
16
+ ```bash
17
+ # npm registry(推荐:版本可被插件管理检测,用户手动更新)
18
+ # npm registry (recommended: version detection with manual updates)
19
+ qilin plugin --profile qilin add @kkutysllb/dsh-terminal
20
+
21
+ # GitHub 直装 / install straight from GitHub
22
+ qilin plugin --profile qilin add github:kkutysllb/dsh-terminal
23
+ ```
24
+
25
+ 装完在 QiLin 设置 → 内置插件里可见、可启停;终端面板经标题栏
26
+ "切换内嵌终端"开关展开。
27
+
28
+ ### 注意事项(QiLin)
29
+
30
+ - **必须经 `qilin plugin add` 装进 profile**:包会落到 profile 私有的
31
+ `~/.qilin/profiles/<name>/node_modules`——裸包名原生解析的第一跳。
32
+ **不要**手工把包目录放进共享的 `~/.qilin/profiles/node_modules`:
33
+ dsh alpha.2 合并后的 runtime+enforce 解析把该目录划为安装保留区,
34
+ 放那里的 bundle 层包激活时直接 `failed to import`。
35
+ - **引擎版本**:运行需要带 dsh 兼容层的 QiLin 3.0.0+;插件**管理**
36
+ (设置页展示/启停)要求 3.0.2+(alpha.2 合并后只认
37
+ `qilin.bundle.patch` 原生键)。
38
+ - **node-pty 依赖**:契约 `^1.1.0`,与引擎生态共享同一物理包;不可解
39
+ 析时插件保持挂载并渲染降级卡(`/dsh-terminal/api/deps` 给出 cause
40
+ 与可粘贴修复命令),不拖垮宿主。
41
+ - **OpenKylin 桌面端**:内置终端由产品启动脚本自动物化(vendor 直提 +
42
+ bundle 注册,同样落 profile 私有锚),无需手动安装。
43
+
7
44
  ## 真实终端语义(模式平移自 dsh-coding-sidebar 的 pty-deps / pty-manager)
8
45
 
9
46
  - **内核级伪终端**:node-pty `spawn`(macOS/Linux 走 forkpty,Windows 走
@@ -21,14 +58,24 @@
21
58
  Windows `DSH_TERMINAL_SHELL` → pwsh 探测链(PATH + 已知安装目录)→
22
59
  `powershell.exe`;POSIX 以登录 shell 启动(读 profile 文件)。
23
60
 
24
- node-pty 版本契约:`^1.1.0`,与 DSH core(`@deepseek-ai/dsh-subprocess-local`)
25
- range——同 range 同 integrity 让 pnpm 两侧解析到同一物理包(一份
26
- native 绑定,无漂移)。
61
+ node-pty 版本契约:`^1.1.0`(v1.1.1 起声明于 dependencies),与 DSH core
62
+ (`@deepseek-ai/dsh-subprocess-local`)同 range——同 range 同 integrity 让
63
+ pnpm 两侧解析到同一物理包(一份 native 绑定,无漂移)。dsh 0.1.6-alpha.2
64
+ 起依赖解析默认运行时模式且共享保留区(`profiles/node_modules`)被排除,
65
+ 未声明的提升副本不再可解析——声明依赖是唯一稳定入口。
27
66
 
28
67
  ## 安装
29
68
 
30
69
  ```bash
31
- dsh plugin install @kkutysllb/dsh-terminal
70
+ # npm registry(推荐:版本可被插件管理检测,用户手动更新)
71
+ # npm registry (recommended: version detection with manual updates)
72
+ dsh plugin --profile web add @kkutysllb/dsh-terminal
73
+
74
+ # GitHub 直装 / install straight from GitHub
75
+ dsh plugin --profile web add github:kkutysllb/dsh-terminal
76
+
77
+ # 或从 dsh-plugins 真源仓 / or from the dsh-plugins monorepo
78
+ dsh plugin --profile web add github:kkutysllb/dsh-plugins#dsh-terminal
32
79
  ```
33
80
 
34
81
  ## 形态
package/client.js CHANGED
@@ -830,18 +830,38 @@ body[data-ds-dark-theme] #${BTN_ID}{color:rgba(232,234,237,.8)}
830
830
  /* ---- 窗口 resize → 重排(view 时代 win.on('resize') 的等价物) ---- */
831
831
  window.addEventListener('resize', () => layout())
832
832
 
833
- /* ---- 右侧栏宽度探针(better-sidebar 浮层;面板右边界让位) ---- */
834
- // better-sidebar 把面板实时宽度写在根变量 --dsh-sidebar-width
835
- //(展开/拖宽 setProperty、收起 removeProperty)。监听 style 属性
836
- // 变化即得右边界,无变量时视作收起(0)。
833
+ /* ---- 右侧栏宽度探针(面板右边界让位) ---- */
834
+ // KCoder better-sidebar 把面板实时宽度写在根变量 --dsh-sidebar-width
835
+ //(展开/拖宽 setProperty、收起 removeProperty),监听 style 属性变
836
+ // 化即得右边界。QiLin AppFrame 右栏不写该变量 → 回退为直接量
837
+ // [data-rightbar-col] 列宽,开合/拖宽由 ResizeObserver 驱动重排,
838
+ // 终端面板右边界精确停在右侧栏左缘,不侵占其下方区域。
837
839
  let rightPanelW = 0
840
+ let rightbarWatched = null
841
+ const armRightbarWatcher = () => {
842
+ const el = document.querySelector('[data-rightbar-col]')
843
+ if (el === null) return null
844
+ if (rightbarRo !== null && rightbarWatched !== el) { rightbarRo.observe(el); rightbarWatched = el }
845
+ return el
846
+ }
838
847
  const readRightPanel = () => {
839
- const w = Number.parseFloat(document.documentElement.style.getPropertyValue('--dsh-sidebar-width'))
848
+ let w = Number.parseFloat(document.documentElement.style.getPropertyValue('--dsh-sidebar-width'))
849
+ if (!Number.isFinite(w) || w <= 0) {
850
+ const el = armRightbarWatcher()
851
+ w = el !== null ? el.getBoundingClientRect().width : 0
852
+ }
840
853
  const next = Number.isFinite(w) && w > 0 ? Math.round(w) : 0
841
854
  if (next !== rightPanelW) { rightPanelW = next; layout() }
842
855
  }
856
+ const rightbarRo = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(readRightPanel) : null
843
857
  readRightPanel()
844
858
  new MutationObserver(readRightPanel).observe(document.documentElement, { attributes: true, attributeFilter: ['style'] })
859
+ // 右栏列晚于本脚本初始化(React 挂载在后):DOM 变化兜底重探,
860
+ // 探到即交棒 ResizeObserver 并停表,避免常驻监听
861
+ const rightbarMountMo = new MutationObserver(() => {
862
+ if (armRightbarWatcher() !== null) { readRightPanel(); rightbarMountMo.disconnect() }
863
+ })
864
+ if (rightbarWatched === null) rightbarMountMo.observe(document.body, { childList: true, subtree: true })
845
865
 
846
866
  /* ---- 标题栏按钮(theme-watcher 注入宿主,时序不保证 → 轮询等待) ---- */
847
867
  const injectBtn = () => {
package/entry.js CHANGED
@@ -15,11 +15,13 @@
15
15
  * 安全边界与 dsh-git-panel 同款:isTrusted(loopback 放行 +
16
16
  * webRuntime.trustedHosts);写操作 POST-only;SSE 为只读推送。
17
17
  *
18
- * pty 引擎:node-pty(VS Code 同款,内核级伪终端 openpty/ConPTY),经
19
- * createRequire 从运行时 node_modules 解析(bundle 物化在 profile
20
- * node_modules 下,向上可达 profiles/node_modules/node-pty——dsh-tool-bash
21
- * 已带)。真实终端健壮性(模式平移自 dsh-coding-sidebar 的 pty-deps/
22
- * pty-manager):
18
+ * pty 引擎:node-pty(VS Code 同款,内核级伪终端 openpty/ConPTY),
19
+ * package.json dependencies 声明 ^1.1.0——profile 安装图内的合法包,
20
+ * createRequire 从插件自身解析(dsh 0.1.6-alpha.2 起运行时解析
21
+ * enforce:候选在共享保留区 profiles/node_modules 前截断,向上的
22
+ * 提升副本不再是解析来源;声明依赖即入 generation,隔离/hoisted
23
+ * 布局都解析得到)。真实终端健壮性(模式平移自 dsh-coding-sidebar
24
+ * 的 pty-deps/pty-manager):
23
25
  * - 懒加载永不抛错:模块导入不触发 native 绑定加载;加载失败缓存原因,
24
26
  * 插件保持挂载(降级态),deps 路由给出修复命令,不拖垮宿主;
25
27
  * - ensureSpawnHelper:补回包管理器剥掉的 spawn-helper 可执行位(缺失
@@ -141,14 +143,15 @@ function isProfileRoot(dir) {
141
143
 
142
144
  /**
143
145
  * 探测本插件安装所在的 profile 目录:插件模块的最近双证祖先(profile
144
- * 根,插件从其 node_modules 解析);探测不到回退 $DSH_HOME/profiles/web
145
- * (标准 web profile);仍不像则 null。
146
+ * 根,插件从其 node_modules 解析);探测不到回退 <宿主 home>/profiles/web
147
+ * ($QILIN_HOME → $DSH_HOME → ~/.dsh,标准 web profile);仍不像则 null。
146
148
  */
147
149
  export function findProfileDir(fromFile = fileURLToPath(import.meta.url)) {
148
150
  const detected = walkUp(realDir(fromFile), isProfileRoot)
149
151
  if (detected !== null) return detected
150
- const home = process.env.DSH_HOME !== undefined && process.env.DSH_HOME.trim() !== ''
151
- ? process.env.DSH_HOME
152
+ const configured = process.env.QILIN_HOME ?? process.env.DSH_HOME
153
+ const home = configured !== undefined && configured.trim() !== ''
154
+ ? configured
152
155
  : join(homedir(), '.dsh')
153
156
  const web = join(home, 'profiles', 'web')
154
157
  return isProfileRoot(web) ? realpathSync(web) : null
@@ -163,7 +166,7 @@ export function buildRepairCommand(options = {}) {
163
166
  const profileDir = options.profileDir !== undefined ? options.profileDir : findProfileDir()
164
167
  const name = profileDir !== null ? basename(profileDir) : 'web'
165
168
  return {
166
- command: 'dsh plugin --profile "' + name + '" install',
169
+ command: 'dsh plugin --profile "' + name + '" add @kkutysllb/dsh-terminal@latest',
167
170
  note: "If pnpm 11 blocked node-pty's build script, ensure allowBuilds: node-pty: true"
168
171
  + " in the profile's pnpm-workspace.yaml, then rerun the install command.",
169
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kkutysllb/dsh-terminal",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "dsh-external in-box dsh bundle: embedded terminal panel (node-pty backed multi-tab shells, per-workspace buckets, xterm.js UI) as a bottom dock inside the dsh web page, replacing the retired Electron host terminal-panel.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -42,5 +42,17 @@
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"
45
+ },
46
+ "qilin": {
47
+ "bundle": {
48
+ "patch": "./cordis.patch.yml"
49
+ },
50
+ "client": {
51
+ "inject": [],
52
+ "platform": "web"
53
+ }
54
+ },
55
+ "dependencies": {
56
+ "node-pty": "^1.1.0"
45
57
  }
46
58
  }