dsh-mini 0.1.1 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xiaoxin3309
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.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # dsh-mini
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/dsh-mini.svg)](https://www.npmjs.com/package/dsh-mini)
4
+ [![license](https://img.shields.io/npm/l/dsh-mini.svg)](LICENSE)
5
+
6
+ 仓库 https://github.com/xiaoxin3309/dsh-mini | npm 包名 `dsh-mini`
7
+
3
8
  把当前会话一键弹出成一个**独立置顶小窗**,小窗里有整屏截图和框选截图两个键(截图时小窗自己不进入画面,图片直接插进输入框);在任意程序里选中文字,还会就地弹出「问大肥鱼」小药丸,点一下把小窗叫出来并引用那段话。
4
9
 
5
10
  ```
@@ -18,7 +23,7 @@
18
23
 
19
24
  三个部分:
20
25
 
21
- 1. **宿主半身**(`lib/index.js`,跑在 DSH 的 Node 进程里):注册 `/dsh-hud/*` 路由,
26
+ 1. **宿主半身**(`lib/index.js`,跑在 DSH 的 Node 进程里):注册 `/dsh-mini/*` 路由,
22
27
  负责拼地址(`webApp.getAdvertisedUrl()` + `connection.authenticatedUrl()`)、起窗口、转发截图。
23
28
  2. **浏览器半身**(`lib/client.js`,跑在页面里):主窗只注册一个「弹出此窗口」按钮;
24
29
  小窗里由原生壳的标题条负责交互,所以不再重复渲染按钮。
@@ -84,6 +89,22 @@ PNG → base64 → `postMessage` 给页面 → 走 Lexical 粘贴事件塞进输
84
89
  小窗打开的是**当前会话**;再点一次「弹出此窗口」不会开第二个窗口,只是把已有窗口提到前面
85
90
  (带会话参数时才重新导航)。
86
91
 
92
+ ## 系统要求
93
+
94
+ 跑起来需要的东西,**除了第一行都必须由机器自备**(`dsh-mini` 只带插件代码 + `app/bin` 里那 4 个文件):
95
+
96
+ | 依赖 | 谁提供 | 说明 |
97
+ |---|---|---|
98
+ | `node` ≥ 20 + DSH ≥ 0.2.0-rc.1 | DSH 本体 | `dsh.compatibility` 声明的范围 |
99
+ | Windows 10 1903+ / 11,**x64** | 系统 | 原生壳按 `/platform:x64` 编译,`WebView2Loader.dll` 只有 win-x64;`package.json` 有 `"os": ["win32"]` |
100
+ | **.NET Framework 4.x**(4.7.2 以上) | 系统自带 | 原生壳是 WinForms + `csc` 编的 .NET Framework exe;`UIAutomationClient`/`UIAutomationTypes`/`WindowsBase` 都用 GAC 里的系统版本,不用另外装 |
101
+ | **Microsoft Edge WebView2 Runtime** | **需要自备** | 小窗就是 WebView2 窗口,没有它开不出画面。Win11 通常自带;Win10 多数机器随 Edge 已装。缺的话原生壳会弹窗给出官方下载地址(Evergreen 包),装完重开小窗即可。**包内不含 runtime**(几百 MB,且应走系统更新) |
102
+ | Windows PowerShell 5.1 | 系统自带 | 只在浏览器回退模式(`backend:"edge"`)和 `scripts/native-status.ps1` 查进程时用;原生模式下截图/划词全是 C# |
103
+ | 剪贴板、全局热键 | 用户权限 | 划词读选区用的 UIA/`Ctrl+C` 走当前用户桌面;管理员窗口(UIPI)里的选区读不到,这是 Windows 的限制 |
104
+
105
+ 数据目录固定是 `%LOCALAPPDATA%\dsh-hud\`(`config.ini`、`window.txt`、日志、WebView2 用户数据),
106
+ 改名前后没动过,装到别的机器上也是这个路径、按用户隔离。
107
+
87
108
  ## 安装(本机已做)
88
109
 
89
110
  profile 走 `link:` 依赖,和 `tju-plugin` 一样:
@@ -112,12 +133,12 @@ profile 走 `link:` 依赖,和 `tju-plugin` 一样:
112
133
 
113
134
  | 路由 | 方法 | 作用 |
114
135
  |---|---|---|
115
- | `/dsh-hud/open` | POST | `{sessionId?}` → 起小窗(`backend:"native"`)或复用已有窗口 |
116
- | `/dsh-hud/close` | POST | 关掉小窗 |
117
- | `/dsh-hud/focus` | POST | 重新置顶 |
118
- | `/dsh-hud/shot` | POST | 截全屏(不含小窗),回 dataURL |
119
- | `/dsh-hud/state` | GET | 小窗是否在跑 |
120
- | `/dsh-hud/trace` | GET | 诊断信标:把 `step/detail` 追加到 `%LOCALAPPDATA%\dsh-hud\trace.log` |
136
+ | `/dsh-mini/open` | POST | `{sessionId?}` → 起小窗(`backend:"native"`)或复用已有窗口 |
137
+ | `/dsh-mini/close` | POST | 关掉小窗 |
138
+ | `/dsh-mini/focus` | POST | 重新置顶 |
139
+ | `/dsh-mini/shot` | POST | 截全屏(不含小窗),回 dataURL |
140
+ | `/dsh-mini/state` | GET | 小窗是否在跑 |
141
+ | `/dsh-mini/trace` | GET | 诊断信标:把 `step/detail` 追加到 `%LOCALAPPDATA%\dsh-hud\trace.log` |
121
142
 
122
143
  ## 构建原生壳
123
144
 
package/app/HudWindow.cs CHANGED
@@ -1,4 +1,4 @@
1
- using System;
1
+ using System;
2
2
  using System.Collections.Generic;
3
3
  using System.Diagnostics;
4
4
  using System.Drawing;
@@ -1258,6 +1258,24 @@ namespace DshHud
1258
1258
  return;
1259
1259
  }
1260
1260
 
1261
+ // Fail fast with an actionable message when this machine has no WebView2
1262
+ // Runtime: the window cannot render anything without it, and an async throw
1263
+ // inside WebView init would otherwise surface as a bare error or a dead window.
1264
+ try
1265
+ {
1266
+ CoreWebView2Environment.GetAvailableBrowserVersionString();
1267
+ }
1268
+ catch (Exception)
1269
+ {
1270
+ MessageBox.Show(
1271
+ "\u5C0F\u7A97\u9700\u8981 Microsoft Edge WebView2 Runtime\uFF0C\u672C\u673A\u6CA1\u6709\u627E\u5230\u3002\r\n\r\n" +
1272
+ "\u4E0B\u8F7D\u5730\u5740\uFF08\u5B98\u65B9\uFF0CEvergreen \u5B89\u88C5\u5305\uFF09\uFF1A\r\n" +
1273
+ "https://go.microsoft.com/fwlink/p/?LinkId=2124703\r\n\r\n" +
1274
+ "Windows 11 \u901A\u5E38\u81EA\u5E26\uFF1BWindows 10 \u5982\u679C\u6CA1\u6709\uFF0C\u88C5\u5B8C\u91CD\u5F00\u5C0F\u7A97\u5373\u53EF\u3002",
1275
+ "DSH \u5C0F\u7A97", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1276
+ return;
1277
+ }
1278
+
1261
1279
  string dir = Path.Combine(
1262
1280
  Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "dsh-hud");
1263
1281
  Directory.CreateDirectory(dir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mini",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "DSH 常驻小窗插件:把当前会话一键弹出为独立置顶小窗(WebView2 原生窗口),含整屏/框选截图、划词「问大肥鱼」、全局快捷键与截图自动复制",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -13,7 +13,14 @@
13
13
  "screenshot",
14
14
  "webview2"
15
15
  ],
16
- "homepage": "https://www.npmjs.com/package/dsh-mini",
16
+ "homepage": "https://github.com/xiaoxin3309/dsh-mini#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/xiaoxin3309/dsh-mini.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/xiaoxin3309/dsh-mini/issues"
23
+ },
17
24
  "os": [
18
25
  "win32"
19
26
  ],
@@ -60,7 +60,7 @@ DSH composer 里本来就有模型选择槽位:`conversation.input.model`(
60
60
  ┌─ DSH 主窗(Electron)─────────────┐
61
61
  │ 右上角 [⧉ 弹出此窗口] │
62
62
  └───────────┬───────────────────────┘
63
- │ POST /dsh-hud/open {href}
63
+ │ POST /dsh-mini/open {href}
64
64
  ┌───────────▼───────────────────────┐
65
65
  │ 宿主插件 dsh-hud-window │
66
66
  │ connection.authenticatedUrl() │
@@ -157,9 +157,9 @@ HUD 标志用 **cookie `dsh_hud=1`**(由壳的 CookieManager 在导航前写
157
157
  解决「浅色页面套一圈黑框」(用户反馈的第一个问题)。
158
158
  * 会话交接:宿主把 `session=<id>` 拼进地址,壳同时写 `dsh_hud` / `dsh_hud_session` 两个 cookie
159
159
  (因为 token 登录后 302 会丢掉整个 query),页面侧 `uiWorkspace.openSession(sessionId)` 落到该会话。
160
- * 按钮链路实测:`POST /dsh-hud/open` → `backend:"native"` → 窗口起来并显示当前会话;
160
+ * 按钮链路实测:`POST /dsh-mini/open` → `backend:"native"` → 窗口起来并显示当前会话;
161
161
  再点一次只把已有窗口提到前面,不重复开窗。
162
- * 诊断:`/dsh-hud/trace` 信标 + `%LOCALAPPDATA%\dsh-hud\trace.log`,配合 UI Automation 的 `Invoke`
162
+ * 诊断:`/dsh-mini/trace` 信标 + `%LOCALAPPDATA%\dsh-hud\trace.log`,配合 UI Automation 的 `Invoke`
163
163
  才定位到「主窗 `location.href` 是 `dsh-app:` 自定义协议,客户端给不出可用地址」这个根因
164
164
  —— 最终改成「客户端只给 sessionId,地址由宿主 `webApp.getAdvertisedUrl()` 拼」。
165
165