dsh-auto-open-web 0.1.2
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 +18 -0
- package/README.en.md +181 -0
- package/README.md +167 -0
- package/cordis.patch.yml +5 -0
- package/host-publish/DshAppWindow.deps.json +94 -0
- package/host-publish/DshAppWindow.dll +0 -0
- package/host-publish/DshAppWindow.exe +0 -0
- package/host-publish/DshAppWindow.pdb +0 -0
- package/host-publish/DshAppWindow.runtimeconfig.json +20 -0
- package/host-publish/Microsoft.Web.WebView2.Core.dll +0 -0
- package/host-publish/Microsoft.Web.WebView2.Core.xml +6662 -0
- package/host-publish/Microsoft.Web.WebView2.WinForms.dll +0 -0
- package/host-publish/Microsoft.Web.WebView2.WinForms.xml +504 -0
- package/host-publish/Microsoft.Web.WebView2.Wpf.dll +0 -0
- package/host-publish/Microsoft.Web.WebView2.Wpf.xml +1902 -0
- package/host-publish/runtimes/win-arm64/native/WebView2Loader.dll +0 -0
- package/host-publish/runtimes/win-x64/native/WebView2Loader.dll +0 -0
- package/host-publish/runtimes/win-x86/native/WebView2Loader.dll +0 -0
- package/lib/client.js +398 -0
- package/lib/index.js +553 -0
- package/lib/paths.js +27 -0
- package/lib/platform.js +27 -0
- package/lib/posix.js +42 -0
- package/lib/win32.js +347 -0
- package/lib/worker.cjs +174 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jinsiyu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# dsh-auto-open-web
|
|
2
|
+
|
|
3
|
+
A persistent plugin for the `dsh web` profile that automatically opens the DSH Web GUI in an app-style
|
|
4
|
+
window (or browser tab) on profile start, with a configuration card under Settings → Plugin
|
|
5
|
+
configuration (manually maintained browser path, etc.).
|
|
6
|
+
|
|
7
|
+
## Behavior
|
|
8
|
+
|
|
9
|
+
On startup (after the HTTP service binds and the actual listening port is known), the window type is
|
|
10
|
+
selected by `windowKind`:
|
|
11
|
+
|
|
12
|
+
1. **WebView2 host** (`windowKind: webview2`, default, Windows only): launches the bundled
|
|
13
|
+
`DshAppWindow.exe` (WinForms + WebView2, own process, no tab/address bar),
|
|
14
|
+
**loading the GUI root address directly** (no iframe, no wrapper page, no injected scripts).
|
|
15
|
+
**Taskbar/window icon = DSH icon** (the window is owned by the host process, which sets
|
|
16
|
+
`Form.Icon` directly, independent of browser taskbar identity rules).
|
|
17
|
+
**Exits with DSH** (the host watches the parent process PID).
|
|
18
|
+
**Remembers window size/position/maximized state**
|
|
19
|
+
(`%LOCALAPPDATA%\DeepSeekHarness\window-state.json`, saved on close and restored on start;
|
|
20
|
+
falls back to centering when the display layout changes).
|
|
21
|
+
2. **Browser app window** (`windowKind: browser`): a **dedicated Edge/Chrome instance** via `--app`
|
|
22
|
+
(`--user-data-dir=~/.dsh/<browser>-app-profile`, isolated process tree and storage,
|
|
23
|
+
**shares no processes/Cookies/cache with the normal browser**; `--no-first-run` skips the
|
|
24
|
+
first-run welcome page).
|
|
25
|
+
**Exits with DSH (including force-kill)**: the browser instance is placed into a **Job Object**
|
|
26
|
+
(`JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE`, koffi-driven `JOBOBJECT_EXTENDED_LIMIT_INFORMATION`
|
|
27
|
+
structure, 144 bytes verified); whether DSH exits normally or is force-killed
|
|
28
|
+
(`taskkill /F`, crash, shutdown, etc.), the Windows kernel terminates every process in the job
|
|
29
|
+
when its last handle closes — the whole dedicated instance process tree dies with it, with no
|
|
30
|
+
reliance on any exit event. Two extra safety nets: on normal DSH exit a `process 'exit'` handler
|
|
31
|
+
kills the dedicated instance process tree (matching only our own user-data-dir, never the normal
|
|
32
|
+
browser); instances left behind by a force-kill are cleaned up before the next launch.
|
|
33
|
+
3. If the selected type is unavailable (host missing / browser not found / non-Windows, etc.) →
|
|
34
|
+
**nothing is opened** (a log entry is written), with no automatic cross-fallback.
|
|
35
|
+
`appWindow: false` opens nothing automatically.
|
|
36
|
+
|
|
37
|
+
The port comes from the real listening value of the webServer service (`--port` overrides and
|
|
38
|
+
`--port 0` both work). **No waiting needed**: the plugin declares webServer as a hard dependency
|
|
39
|
+
(`inject`), so Cordis only activates it after the webServer plugin's `Service.init()` completes
|
|
40
|
+
(HTTP socket bound, port written) — the port is directly available in `apply`.
|
|
41
|
+
Both modes close with DSH: the webview2 host watches the parent process; the
|
|
42
|
+
browser dedicated instance is ended by the Job Object (also effective on force-kill) plus exit
|
|
43
|
+
cleanup.
|
|
44
|
+
|
|
45
|
+
### WebView2 host requirements (webview2 mode only)
|
|
46
|
+
|
|
47
|
+
- Windows 10 1803+ / Windows 11 / Windows Server 2016+
|
|
48
|
+
(Win7/8.1 reached end of support in 2023-01, see Microsoft announcements)
|
|
49
|
+
- WebView2 Runtime (evergreen, usually preinstalled with Edge; verified with 151.x locally)
|
|
50
|
+
- .NET 10 runtime (installed with the SDK; can be switched to a self-contained publish if needed)
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
Two equivalent ways:
|
|
55
|
+
|
|
56
|
+
1. **Settings card** (recommended): Settings → Plugin configuration → the "自动打开网页"
|
|
57
|
+
(auto-open web) card. Editable fields:
|
|
58
|
+
`appWindow` (independent app window), `windowKind` (WebView2 host / browser app window),
|
|
59
|
+
`browserPath` (browser executable, with a native "Browse" file dialog; located below the
|
|
60
|
+
window-type field and enabled only when "Browser app window" is selected),
|
|
61
|
+
`exitOnWindowClose` (exit DSH when the window closes, off by default).
|
|
62
|
+
After saving, values persist to the settings document (namespace `auto-open-web`); once saved,
|
|
63
|
+
settings take precedence over row configuration.
|
|
64
|
+
2. **Row configuration** (`cordis.patch.yml`): acts as the startup seed, effective until the
|
|
65
|
+
settings card is saved.
|
|
66
|
+
|
|
67
|
+
| Field | Default | Description |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| `appWindow` | `true` | Automatically open the independent app window on start; `false` opens nothing |
|
|
70
|
+
| `windowKind` | `webview2` | `webview2` = WebView2 host (own process, DSH taskbar icon, exits with DSH); `browser` = dedicated `--app` browser instance. If the selected type is unavailable, only a log entry is written and nothing opens |
|
|
71
|
+
| `exitOnWindowClose` | `false` | **(Experimental)** Exit DSH when the auto-opened window closes (off by default; only effective while `appWindow` is on). Triggered only when the window process exits **normally** (user closes the window) → `process.exit(0)`; startup failures/crashes/force-kills (non-zero exit code) do not trigger, preventing accidental exits. **Takes effect immediately in the current session after saving** (the exit listener is always registered; behavior is driven by a live flag), no restart needed |
|
|
72
|
+
| `browserPath` | `''` | Manual browser executable path (single entry, e.g. `C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe`; used only in browser mode), preferred over the built-in candidates Edge → Chrome; a non-existent path is skipped with a warning. The "Browse" button on the card opens a **native file dialog**: same mechanism as the official workspace directory picker (child process + koffi-driven `IFileOpenDialog`; the dialog is the child's first window and is automatically brought to front; no PowerShell). The "Test" button **actually launches** a dedicated `--app` test instance (separate user-data-dir `~/.dsh/<browser>-test-profile`, never pollutes the real instance): after confirming the browser main process stays alive it reports success, then automatically ends that test process tree after a few seconds of display (exact pid, never touches the real instance; the test instance is also placed in the Job Object when available as an exit safety net); the test uses the currently typed path (works even when unsaved), and failures show the reason |
|
|
73
|
+
|
|
74
|
+
### `browserPath` row configuration example
|
|
75
|
+
|
|
76
|
+
Override the row's config by id in `~/.dsh/profiles/web/cordis.patch.yml` (the override replaces the
|
|
77
|
+
whole config; fields not listed fall back to defaults):
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
- id: auto-open-web
|
|
81
|
+
config:
|
|
82
|
+
browserPath: 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Packaging and installation
|
|
86
|
+
|
|
87
|
+
This package is a **bundle**: an npm package carrying a configuration layer — `dsh.bundle` in
|
|
88
|
+
`package.json` declares the patch file (`cordis.patch.yml`), and a profile activates the plugin row
|
|
89
|
+
by package name when installed. Published to the **npm registry** (`dsh-auto-open-web@0.1.2`) and
|
|
90
|
+
**GitHub** (https://github.com/jinsiyu/dsh-auto-open-web, `main` branch).
|
|
91
|
+
|
|
92
|
+
### Packaging
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
cd dsh-auto-open-web
|
|
96
|
+
pnpm pack # the prepack hook compiles the WebView2 host first (dotnet publish), producing dsh-auto-open-web-0.1.2.tgz
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Installation (pick one)
|
|
100
|
+
|
|
101
|
+
**Option 1: source checkout link (development; changes take effect immediately)**
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# absolute path to avoid pnpm self-linking
|
|
105
|
+
dsh plugin --profile web add C:\path\to\dsh-auto-open-web
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Option 2: tarball (published artifact, recommended for delivery; no build permission needed)**
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
dsh plugin --profile web add ./dsh-auto-open-web-0.1.2.tgz
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Option 3: npm registry (after publishing)**
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
dsh plugin --profile web add dsh-auto-open-web
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Option 4: GitHub source**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
dsh plugin --profile web add github:jinsiyu/dsh-auto-open-web#main
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Uninstall
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
dsh plugin --profile web remove dsh-auto-open-web # removes the dependency and its configuration layer together
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Effect and layer order
|
|
133
|
+
|
|
134
|
+
After installation: pnpm adds the package to `profiles/web/node_modules`, and `dsh` appends
|
|
135
|
+
`dsh-auto-open-web` to `dsh.profile.bundles`; at startup the bundle's `cordis.patch.yml` inserts the
|
|
136
|
+
plugin row (`name: auto-open-web`, resolved by package name). After restarting `dsh web`, the
|
|
137
|
+
"自动打开网页" card appears in the settings page (the client bundle is scanned into the browser
|
|
138
|
+
manifest at startup via the modules line, per the `dsh.client` declaration).
|
|
139
|
+
|
|
140
|
+
The effective configuration is composed layer by layer in this order (later layers win per row,
|
|
141
|
+
replacing the whole row's config rather than deep-merging): each bundle's patch (in bundles list
|
|
142
|
+
order) → the profile's own `cordis.patch.yml` → the global `$DSH_HOME/cordis.patch.yml` → the
|
|
143
|
+
`--patch` overlay. Users can override this package's row in their own profile's `cordis.patch.yml`
|
|
144
|
+
without touching the package.
|
|
145
|
+
|
|
146
|
+
### Notes
|
|
147
|
+
|
|
148
|
+
- **The npm package already contains the compiled WebView2 host** (built by the prepack hook before
|
|
149
|
+
publishing); the **GitHub `main` branch and source-checkout installs do not** include
|
|
150
|
+
`host-publish/` (build artifacts are .gitignore'd): for webview2 mode, run
|
|
151
|
+
`pnpm run build:host` inside `node_modules/dsh-auto-open-web` first (requires the .NET SDK);
|
|
152
|
+
browser mode needs no build.
|
|
153
|
+
- If installing by editing `package.json` manually (not via the `dsh plugin` command), you must add
|
|
154
|
+
both the `dependencies` entry and `dsh.profile.bundles`; when using a local `file:` dependency,
|
|
155
|
+
`dsh web` normalizes `file:` to `^0.1.2` at startup, which does not affect runtime.
|
|
156
|
+
|
|
157
|
+
## Icons
|
|
158
|
+
|
|
159
|
+
- GUI page icon: the GUI ships its own `/favicon.svg` (same as index.html).
|
|
160
|
+
- **Taskbar/window icon (WebView2 host)**: the host process sets `Form.Icon` directly to the
|
|
161
|
+
plugin-generated DSH .ico (`~/.dsh/auto-open-web-icon.ico`), independent of browser taskbar
|
|
162
|
+
identity rules. The .ico is built by fetching the local `favicon.svg` and rasterizing it with
|
|
163
|
+
**sharp** (bundled with the deployment, resolved upward at runtime, not declared as a dependency)
|
|
164
|
+
into 16/32/48/64/128/256 PNGs; when sharp is unavailable the host falls back to the default window
|
|
165
|
+
icon.
|
|
166
|
+
|
|
167
|
+
## Platform support
|
|
168
|
+
|
|
169
|
+
- Windows: `windowKind: webview2` (default, DSH taskbar icon) or `windowKind: browser` (dedicated
|
|
170
|
+
`--app` instance); nothing opens if the selected type is unavailable
|
|
171
|
+
- macOS/Linux: `webview2` mode is unavailable (logs and opens nothing); `browser` mode is untested
|
|
172
|
+
(dedicated `--app` instance)
|
|
173
|
+
|
|
174
|
+
## Edge cases
|
|
175
|
+
|
|
176
|
+
- Normal restart: in webview2 mode the old host window exits with the old DSH process; the new DSH
|
|
177
|
+
opens a new host window
|
|
178
|
+
- `browser` mode: after a restart the old window stays as-is (needs a manual refresh; may briefly
|
|
179
|
+
coexist with the new window); when DSH is force-killed (`taskkill /F`, crash), the dedicated
|
|
180
|
+
instance is ended by the Job Object without leftovers
|
|
181
|
+
- Plugin removed: no injected code, no leftover routes, zero residual impact
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# dsh-auto-open-web
|
|
2
|
+
|
|
3
|
+
> English: [README.en.md](README.en.md)
|
|
4
|
+
|
|
5
|
+
dsh web profile 启动后自动打开独立应用窗口(或网页标签页)的常驻插件,并在
|
|
6
|
+
设置 → 插件配置中提供配置卡片(手动维护浏览器位置等)。
|
|
7
|
+
|
|
8
|
+
## 行为
|
|
9
|
+
|
|
10
|
+
启动时(HTTP 服务绑定完成、取得实际监听端口后),按 `windowKind` 选择窗口类型:
|
|
11
|
+
|
|
12
|
+
1. **WebView2 宿主**(`windowKind: webview2`,默认,仅 Windows):启动随包分发的
|
|
13
|
+
`DshAppWindow.exe`(WinForms + WebView2,独立进程,无标签栏/地址栏),
|
|
14
|
+
**直接加载 GUI 根地址**(无 iframe、无包装页、无注入脚本)。
|
|
15
|
+
**任务栏/窗口图标 = DSH 图标**(窗口由宿主进程所有,直接设置 Form.Icon,
|
|
16
|
+
不受浏览器任务栏身份限制)。**随 DSH 退出**(宿主监视父进程 PID)。
|
|
17
|
+
**记忆窗口大小/位置/最大化状态**(`%LOCALAPPDATA%\DeepSeekHarness\window-state.json`,
|
|
18
|
+
关闭时保存、启动时恢复;显示器布局变化时回退居中)。
|
|
19
|
+
2. **浏览器应用窗口**(`windowKind: browser`):`--app` **专用 Edge/Chrome 实例**
|
|
20
|
+
(`--user-data-dir=~/.dsh/<browser>-app-profile`,独立进程树与存储,
|
|
21
|
+
**不与正常浏览器页面共用进程/Cookie/缓存**;`--no-first-run` 跳过首启欢迎页)。
|
|
22
|
+
**随 DSH 退出(含强杀)**:浏览器实例加入 **Job Object**
|
|
23
|
+
(`JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE`,koffi 驱动
|
|
24
|
+
`JOBOBJECT_EXTENDED_LIMIT_INFORMATION` 结构,实测 144 字节);DSH 无论
|
|
25
|
+
正常退出还是被强杀(`taskkill /F`、崩溃、关机等),Windows 内核随作业最后
|
|
26
|
+
一个句柄关闭自动结束作业内全部进程——专用实例整个进程树随之消亡,无需
|
|
27
|
+
依赖任何退出事件。另有两层兜底:DSH 正常退出时 `process 'exit'` 结束该
|
|
28
|
+
专用实例的整个进程树(仅匹配我们自己的 user-data-dir,不影响正常浏览器);
|
|
29
|
+
DSH 被强杀后的残留实例由下次启动前预清理。
|
|
30
|
+
3. 所选类型不可用时(宿主缺失/浏览器找不到/非 Windows 等)→ **不打开任何东西**
|
|
31
|
+
(记录日志),不自动交叉兜底。
|
|
32
|
+
`appWindow: false` 时不自动打开任何窗口。
|
|
33
|
+
|
|
34
|
+
端口取自 webServer 服务的真实监听值(`--port` 自定义、`--port 0` 均正确)。
|
|
35
|
+
**无需等待**:插件把 webServer 声明为硬依赖(`inject`),Cordis 会等
|
|
36
|
+
webServer 插件 `Service.init()` 完成(HTTP socket 已绑定、端口已写入)后才
|
|
37
|
+
激活本插件,apply 时端口直接可用。
|
|
38
|
+
两种模式都随 DSH 退出而关闭:webview2 宿主监视父进程;browser 专用实例由
|
|
39
|
+
Job Object(强杀也生效)+ 退出清理结束进程树。
|
|
40
|
+
|
|
41
|
+
### WebView2 宿主要求(仅 webview2 模式)
|
|
42
|
+
|
|
43
|
+
- Windows 10 1803+ / Windows 11 / Windows Server 2016+
|
|
44
|
+
(Win7/8.1 已于 2023-01 终止支持,见微软公告)
|
|
45
|
+
- WebView2 Runtime(常青版,通常随 Edge 预装;本机已验证 151.x)
|
|
46
|
+
- .NET 10 运行时(随 SDK 安装;也可改为自包含发布,需时再调)
|
|
47
|
+
|
|
48
|
+
## 配置
|
|
49
|
+
|
|
50
|
+
两种途径,等价:
|
|
51
|
+
|
|
52
|
+
1. **设置页卡片**(推荐):设置 → 插件配置 → 「自动打开网页」卡片。可编辑
|
|
53
|
+
`appWindow`(独立应用窗口)、`windowKind`(WebView2 宿主 / 浏览器应用窗口)、
|
|
54
|
+
`browserPath`(浏览器可执行文件,支持「浏览」原生对话框选择;位于窗口类型
|
|
55
|
+
下方,仅选择「浏览器应用窗口」时使能)、
|
|
56
|
+
`exitOnWindowClose`(窗口关闭时退出 DSH,默认关闭)。
|
|
57
|
+
保存后持久化到
|
|
58
|
+
settings 文档(命名空间 `auto-open-web`),首次保存后设置值优先于行配置。
|
|
59
|
+
2. **行配置**(cordis.patch.yml):作为启动种子,设置卡片保存前生效。
|
|
60
|
+
|
|
61
|
+
| 字段 | 默认 | 说明 |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `appWindow` | `true` | 启动时自动打开独立应用窗口;false 时不自动打开任何窗口 |
|
|
64
|
+
| `windowKind` | `webview2` | `webview2` = WebView2 宿主(独立进程、任务栏 DSH 图标、随 DSH 退出);`browser` = 浏览器 `--app` 专用实例。所选类型不可用时仅记录日志、不打开 |
|
|
65
|
+
| `exitOnWindowClose` | `false` | **(实验性)**关闭自动打开的窗口时随之退出 DSH(默认关闭;仅 `appWindow` 开启时生效)。窗口进程**正常**退出(用户关闭窗口)时触发 `process.exit(0)`;启动失败/崩溃/被强杀(非 0 退出码)不触发,避免误退出。**设置卡片保存后当前会话即时生效**(退出监听始终注册、行为由实时标志决定),无需重启 DSH |
|
|
66
|
+
| `browserPath` | `''` | 手动指定的浏览器可执行文件路径(单条,如 `C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe`;仅浏览器模式使用),优先于内置候选 Edge → Chrome;路径不存在会跳过并告警。设置卡片上的「浏览」按钮弹出**原生文件对话框**:与官方工作区目录选择器同一机制(子进程 + koffi 驱动 IFileOpenDialog,对话框是子进程的第一个窗口,自动置顶;不使用 PowerShell)。「测试」按钮**真实拉起**一个 `--app` 专用测试实例(独立 user-data-dir `~/.dsh/<browser>-test-profile`,不污染正式实例):确认浏览器主进程存活后报告成功,窗口展示数秒后自动结束该测试进程树(精确 pid,不动正式实例;Job Object 可用时测试实例也加入作业,DSH 退出时兜底);测试使用当前输入的路径(未保存也能测),失败会显示原因 |
|
|
67
|
+
|
|
68
|
+
### browserPath 行配置示例
|
|
69
|
+
|
|
70
|
+
在 `~/.dsh/profiles/web/cordis.patch.yml` 中按 id 覆写该行的 config(覆写会整体替换 config,未列出的字段用默认值):
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
- id: auto-open-web
|
|
74
|
+
config:
|
|
75
|
+
browserPath: 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 打包与安装
|
|
79
|
+
|
|
80
|
+
本包是**组合包(bundle)**:一个附带配置层的 npm 包——`package.json` 的
|
|
81
|
+
`dsh.bundle` 声明配置层文件(`cordis.patch.yml`),profile 安装它时按包名激活
|
|
82
|
+
插件行。已发布到 **npm registry**(`dsh-auto-open-web@0.1.2`)与 **GitHub**
|
|
83
|
+
(https://github.com/jinsiyu/dsh-auto-open-web,main 分支)。
|
|
84
|
+
|
|
85
|
+
### 打包
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
cd dsh-auto-open-web
|
|
89
|
+
pnpm pack # prepack 钩子自动先编译 WebView2 宿主(dotnet publish),产出 dsh-auto-open-web-0.1.2.tgz
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 安装方式(任选其一)
|
|
93
|
+
|
|
94
|
+
**方式一:源码 checkout 链接(开发期,改动即时生效)**
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 绝对路径,避免 pnpm 自链接
|
|
98
|
+
dsh plugin --profile web add C:\path\to\dsh-auto-open-web
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**方式二:tarball(发布产物,推荐交付;无需构建授权)**
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
dsh plugin --profile web add ./dsh-auto-open-web-0.1.2.tgz
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**方式三:npm 注册表(发布后)**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
dsh plugin --profile web add dsh-auto-open-web
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**方式四:GitHub 源码安装**
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
dsh plugin --profile web add github:jinsiyu/dsh-auto-open-web#main
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 卸载
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
dsh plugin --profile web remove dsh-auto-open-web # 同时移除依赖与对应配置层
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 效果与层顺序
|
|
126
|
+
|
|
127
|
+
安装后:pnpm 将包加入 `profiles/web/node_modules`,`dsh` 把
|
|
128
|
+
`dsh-auto-open-web` 追加到 `dsh.profile.bundles`;启动时 bundle 的
|
|
129
|
+
`cordis.patch.yml` 插入插件行(`name: auto-open-web`,按包名解析)。
|
|
130
|
+
重启 `dsh web` 后设置页出现「自动打开网页」卡片(客户端 bundle 由 modules
|
|
131
|
+
行按 `dsh.client` 声明在启动时扫描进浏览器清单)。
|
|
132
|
+
|
|
133
|
+
生效配置按以下顺序逐层组合(后应用的层按行胜出,整行替换 config 而非深合并):
|
|
134
|
+
每个 bundle 的 patch(按 bundles 列表顺序)→ profile 自己的
|
|
135
|
+
`cordis.patch.yml` → 全局 `$DSH_HOME/cordis.patch.yml` → `--patch` overlay。
|
|
136
|
+
用户可在自己 profile 的 `cordis.patch.yml` 中覆盖本包的行,无需改动包。
|
|
137
|
+
|
|
138
|
+
### 注意事项
|
|
139
|
+
|
|
140
|
+
- **npm 包已含 WebView2 宿主编译产物**(prepack 编译后发布);**GitHub
|
|
141
|
+
main 分支与源码 checkout 方式不含** `host-publish/`(构建产物被
|
|
142
|
+
.gitignore 忽略):webview2 模式需先在 `node_modules/dsh-auto-open-web`
|
|
143
|
+
下执行 `pnpm run build:host` 生成(需 .NET SDK);browser 模式无需构建。
|
|
144
|
+
- 若手动编辑 `package.json` 安装(不经 dsh plugin 命令),需同时追加
|
|
145
|
+
`dependencies` 与 `dsh.profile.bundles` 两项;使用本地 `file:` 依赖时
|
|
146
|
+
`dsh web` 启动会把 `file:` 规范化成 `^0.1.2`,运行时不受影响。
|
|
147
|
+
|
|
148
|
+
## 图标
|
|
149
|
+
|
|
150
|
+
- GUI 页面图标:GUI 自带 `/favicon.svg`(与 index.html 一致)。
|
|
151
|
+
- **任务栏/窗口图标(WebView2 宿主)**:宿主进程直接设置 `Form.Icon` = 插件生成的
|
|
152
|
+
DSH .ico(`~/.dsh/auto-open-web-icon.ico`),与浏览器任务栏身份机制无关。
|
|
153
|
+
.ico 来源:抓取本机 `favicon.svg`,用 **sharp**(部署自带,运行时向上解析,
|
|
154
|
+
未声明为依赖)栅格化为 16/32/48/64/128/256 PNG 后组装;sharp 不可用时
|
|
155
|
+
宿主退回默认窗口图标。
|
|
156
|
+
|
|
157
|
+
## 平台支持
|
|
158
|
+
|
|
159
|
+
- Windows:`windowKind: webview2`(默认,任务栏图标 DSH)或 `windowKind: browser`(--app 专用实例);所选类型不可用则不打开
|
|
160
|
+
- macOS/Linux:`webview2` 模式不可用(会记录日志不打开);`browser` 模式未测试(--app 专用实例)
|
|
161
|
+
|
|
162
|
+
## 边界情况
|
|
163
|
+
|
|
164
|
+
- 正常重启:webview2 模式下旧宿主窗口随旧 DSH 进程退出;新 DSH 打开新宿主窗口
|
|
165
|
+
- `browser` 模式:重启后旧窗口保持原样(需手动刷新;可与新窗口短暂并存);
|
|
166
|
+
DSH 被强杀(`taskkill /F`、崩溃)时专用实例由 Job Object 一并结束,不残留
|
|
167
|
+
- 插件被移除:无注入、无残留路由,零残留影响
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtimeTarget": {
|
|
3
|
+
"name": ".NETCoreApp,Version=v10.0",
|
|
4
|
+
"signature": ""
|
|
5
|
+
},
|
|
6
|
+
"compilationOptions": {},
|
|
7
|
+
"targets": {
|
|
8
|
+
".NETCoreApp,Version=v10.0": {
|
|
9
|
+
"DshAppWindow/0.1.2": {
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"Microsoft.Web.WebView2": "1.0.3124.44",
|
|
12
|
+
"Microsoft.Web.WebView2.Core": "1.0.3124.44",
|
|
13
|
+
"Microsoft.Web.WebView2.WinForms": "1.0.3124.44",
|
|
14
|
+
"Microsoft.Web.WebView2.Wpf": "1.0.3124.44"
|
|
15
|
+
},
|
|
16
|
+
"runtime": {
|
|
17
|
+
"DshAppWindow.dll": {}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"Microsoft.Web.WebView2/1.0.3124.44": {
|
|
21
|
+
"runtimeTargets": {
|
|
22
|
+
"runtimes/win-arm64/native/WebView2Loader.dll": {
|
|
23
|
+
"rid": "win-arm64",
|
|
24
|
+
"assetType": "native",
|
|
25
|
+
"fileVersion": "1.0.3124.44"
|
|
26
|
+
},
|
|
27
|
+
"runtimes/win-x64/native/WebView2Loader.dll": {
|
|
28
|
+
"rid": "win-x64",
|
|
29
|
+
"assetType": "native",
|
|
30
|
+
"fileVersion": "1.0.3124.44"
|
|
31
|
+
},
|
|
32
|
+
"runtimes/win-x86/native/WebView2Loader.dll": {
|
|
33
|
+
"rid": "win-x86",
|
|
34
|
+
"assetType": "native",
|
|
35
|
+
"fileVersion": "1.0.3124.44"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"Microsoft.Web.WebView2.Core/1.0.3124.44": {
|
|
40
|
+
"runtime": {
|
|
41
|
+
"Microsoft.Web.WebView2.Core.dll": {
|
|
42
|
+
"assemblyVersion": "1.0.3124.44",
|
|
43
|
+
"fileVersion": "1.0.3124.44"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"Microsoft.Web.WebView2.WinForms/1.0.3124.44": {
|
|
48
|
+
"runtime": {
|
|
49
|
+
"Microsoft.Web.WebView2.WinForms.dll": {
|
|
50
|
+
"assemblyVersion": "1.0.3124.44",
|
|
51
|
+
"fileVersion": "1.0.3124.44"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"Microsoft.Web.WebView2.Wpf/1.0.3124.44": {
|
|
56
|
+
"runtime": {
|
|
57
|
+
"Microsoft.Web.WebView2.Wpf.dll": {
|
|
58
|
+
"assemblyVersion": "1.0.3124.44",
|
|
59
|
+
"fileVersion": "1.0.3124.44"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"libraries": {
|
|
66
|
+
"DshAppWindow/0.1.2": {
|
|
67
|
+
"type": "project",
|
|
68
|
+
"serviceable": false,
|
|
69
|
+
"sha512": ""
|
|
70
|
+
},
|
|
71
|
+
"Microsoft.Web.WebView2/1.0.3124.44": {
|
|
72
|
+
"type": "package",
|
|
73
|
+
"serviceable": true,
|
|
74
|
+
"sha512": "sha512-sQb+ACD3ILvHxztxqCWLbhYmFNf5dH0HPhVKFYg020rpeQPkadH0nkVOSsgfSyBDMLypI9iMBeD6uVcVxsKLkg==",
|
|
75
|
+
"path": "microsoft.web.webview2/1.0.3124.44",
|
|
76
|
+
"hashPath": "microsoft.web.webview2.1.0.3124.44.nupkg.sha512"
|
|
77
|
+
},
|
|
78
|
+
"Microsoft.Web.WebView2.Core/1.0.3124.44": {
|
|
79
|
+
"type": "reference",
|
|
80
|
+
"serviceable": false,
|
|
81
|
+
"sha512": ""
|
|
82
|
+
},
|
|
83
|
+
"Microsoft.Web.WebView2.WinForms/1.0.3124.44": {
|
|
84
|
+
"type": "reference",
|
|
85
|
+
"serviceable": false,
|
|
86
|
+
"sha512": ""
|
|
87
|
+
},
|
|
88
|
+
"Microsoft.Web.WebView2.Wpf/1.0.3124.44": {
|
|
89
|
+
"type": "reference",
|
|
90
|
+
"serviceable": false,
|
|
91
|
+
"sha512": ""
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"runtimeOptions": {
|
|
3
|
+
"tfm": "net10.0",
|
|
4
|
+
"frameworks": [
|
|
5
|
+
{
|
|
6
|
+
"name": "Microsoft.NETCore.App",
|
|
7
|
+
"version": "10.0.0"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "Microsoft.WindowsDesktop.App",
|
|
11
|
+
"version": "10.0.0"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"configProperties": {
|
|
15
|
+
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
|
|
16
|
+
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
|
|
17
|
+
"CSWINRT_USE_WINDOWS_UI_XAML_PROJECTIONS": false
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
Binary file
|