dsh-auto-open-web 0.1.4 → 0.1.9

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
@@ -31,7 +31,12 @@ selected by `windowKind`:
31
31
  kills the dedicated instance process tree (matching only our own user-data-dir, never the normal
32
32
  browser); instances left behind by a force-kill are cleaned up before the next launch.
33
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.
34
+ **falls back to the official default-browser handoff** the URL is given to the OS default
35
+ browser (plain tab), so the user can always reach the GUI. The implementation mirrors exactly
36
+ how the DSH core (web-app bundle) opens the page at startup: it prefers the `open` package
37
+ shipped with the DSH deployment (win32 = PowerShell Start, darwin = `open`, linux = `xdg-open`);
38
+ when the package is unavailable it falls back to a native platform launch
39
+ (win32 = `cmd /c start`, darwin = `open`, linux = `xdg-open`).
35
40
  `appWindow: false` opens nothing automatically.
36
41
 
37
42
  The port comes from the real listening value of the webServer service (`--port` overrides and
@@ -42,6 +47,13 @@ Both modes close with DSH: the webview2 host watches the parent process; the
42
47
  browser dedicated instance is ended by the Job Object (also effective on force-kill) plus exit
43
48
  cleanup.
44
49
 
50
+ > **Relationship with DSH's core browser handoff**: the DSH core (web-app bundle) opens the GUI
51
+ > in the system default browser at startup by default (`openBrowser: true` — a plain tab/window,
52
+ > not an app window). Installing this plugin flips `web-runtime.openBrowser` to `false` via the
53
+ > plugin's bundle patch, so only the plugin's app-style window opens and no ordinary browser page
54
+ > pops up; uninstalling the plugin restores the default behavior (or use `dsh web --no-open`
55
+ > to disable it temporarily).
56
+
45
57
  ### WebView2 host requirements (webview2 mode only)
46
58
 
47
59
  - Windows 10 1803+ / Windows 11 / Windows Server 2016+
@@ -59,15 +71,17 @@ Two equivalent ways:
59
71
  `browserPath` (browser executable, with a native "Browse" file dialog; located below the
60
72
  window-type field and enabled only when "Browser app window" is selected),
61
73
  `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.
74
+ After saving, values persist through the **official settings domain** (client `settingsScope`)
75
+ to the settings document (namespace `auto-open-web`); once saved,
76
+ settings take precedence over row configuration. The host keeps only the "Browse" / "Test"
77
+ helper routes (capabilities the official channel cannot cover).
64
78
  2. **Row configuration** (`cordis.patch.yml`): acts as the startup seed, effective until the
65
79
  settings card is saved.
66
80
 
67
81
  | Field | Default | Description |
68
82
  | --- | --- | --- |
69
83
  | `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 |
84
+ | `windowKind` | `webview2` | `webview2` = WebView2 host (own process, DSH taskbar icon, exits with DSH); `browser` = dedicated `--app` browser instance. If the selected type is unavailable, it falls back to the default-browser handoff (official open method, plain tab) |
71
85
  | `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
86
  | `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
87
 
@@ -86,14 +100,14 @@ whole config; fields not listed fall back to defaults):
86
100
 
87
101
  This package is a **bundle**: an npm package carrying a configuration layer — `dsh.bundle` in
88
102
  `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.4`) and
103
+ by package name when installed. Published to the **npm registry** (`dsh-auto-open-web@0.1.5`) and
90
104
  **GitHub** (https://github.com/jinsiyu/dsh-auto-open-web, `main` branch).
91
105
 
92
106
  ### Packaging
93
107
 
94
108
  ```bash
95
109
  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.4.tgz
110
+ pnpm pack # the prepack hook compiles the WebView2 host first (dotnet publish), producing dsh-auto-open-web-0.1.5.tgz
97
111
  ```
98
112
 
99
113
  ### Installation (pick one)
@@ -108,7 +122,7 @@ dsh plugin --profile web add C:\path\to\dsh-auto-open-web
108
122
  **Option 2: tarball (published artifact, recommended for delivery; no build permission needed)**
109
123
 
110
124
  ```bash
111
- dsh plugin --profile web add ./dsh-auto-open-web-0.1.4.tgz
125
+ dsh plugin --profile web add ./dsh-auto-open-web-0.1.5.tgz
112
126
  ```
113
127
 
114
128
  **Option 3: npm registry (after publishing)**
@@ -145,34 +159,30 @@ without touching the package.
145
159
 
146
160
  ### Notes
147
161
 
148
- - **DSH version requirement**: this plugin supports **dsh `>=0.1.0-rc.7 <0.2.0`** (declared as an
149
- optional peer, provided by the DSH deployment, no install warnings). `settings.plugin.item`
150
- became a keyed slot in that release; the card registers with both `id` and `key` so it mounts on
151
- both old and new dsh generations. Below the supported range the host logs a clear error at
152
- startup (pointing to a dsh upgrade) and the card may not mount.
162
+ - **Zero dependencies**: every runtime dependency is provided by the **DSH deployment** and
163
+ declared as an optional peer (no install warnings):
164
+ - `@deepseek-ai/dsh` (the host; declares the compatibility range `>=0.1.0-rc.7 <0.2.0`
165
+ `settings.plugin.item` became a keyed slot in that release, registration requires
166
+ `options.key`; no runtime version check is performed)
167
+ - `@deepseek-ai/schemastery` (config schema validator; resolved at runtime: normal import
168
+ first, then the DSH deployment copy under the Windows global npm layout)
169
+ - `koffi` (Windows only: Job Object / process verification / native file dialog; same runtime
170
+ deployment-copy resolution, failure only degrades)
171
+ So no platform ever hits build-script blocking — HarmonyOS and other environments without
172
+ koffi prebuilds install out of the box; posix platforms use the posix fallback adapter (browser
173
+ mode works; webview2 / native dialog unavailable), and the platform adapter is loaded
174
+ conditionally so win32.js is never evaluated on posix.
175
+ - This package does not depend on `@deepseek-ai/cordis` (zero code references; the plugin identity
176
+ comes from the `dsh.bundle` / `dsh.client` fields, and Cordis is provided by the DSH deployment
177
+ at runtime), so installation produces no peer warnings.
153
178
  - **The npm package already contains the compiled WebView2 host** (built by the prepack hook before
154
179
  publishing); the **GitHub `main` branch and source-checkout installs do not** include
155
180
  `host-publish/` (build artifacts are .gitignore'd): for webview2 mode, run
156
181
  `pnpm run build:host` inside `node_modules/dsh-auto-open-web` first (requires the .NET SDK);
157
182
  browser mode needs no build.
158
- - This package does not depend on `@deepseek-ai/cordis` (zero code references; the plugin identity
159
- comes from the `dsh.bundle` / `dsh.client` fields, and Cordis is provided by the DSH deployment
160
- at runtime), so installation produces no peer warnings.
161
- - **Zero koffi dependency declared**: koffi (driving Windows Job Object / process verification /
162
- native file dialog) ships with the **DSH deployment itself** (the official native picker
163
- `@deepseek-ai/dsh-host-directory-picker-native` depends on koffi, so the deployment always has
164
- it). The plugin resolves it at runtime: normal resolution (profile-installed or manual
165
- `pnpm add koffi`) first, then the DSH deployment copy under the Windows global npm layout; if
166
- resolution fails, capabilities only degrade (Job Object unavailable → exit / pre-launch cleanup
167
- still apply; process verification skipped; native dialog unavailable) with a log entry.
168
- **Therefore no platform ever hits koffi build-script blocking** — HarmonyOS and other
169
- environments without koffi prebuilds install out of the box, with no `pnpm-workspace.yaml` or
170
- other configuration needed; posix platforms use the posix fallback adapter (browser mode works;
171
- webview2 / native dialog unavailable), and the platform adapter is loaded conditionally so
172
- win32.js is never evaluated on posix.
173
183
  - If installing by editing `package.json` manually (not via the `dsh plugin` command), you must add
174
184
  both the `dependencies` entry and `dsh.profile.bundles`; when using a local `file:` dependency,
175
- `dsh web` normalizes `file:` to `^0.1.4` at startup, which does not affect runtime.
185
+ `dsh web` normalizes `file:` to `^0.1.5` at startup, which does not affect runtime.
176
186
 
177
187
  ## Icons
178
188
 
@@ -187,8 +197,8 @@ without touching the package.
187
197
  ## Platform support
188
198
 
189
199
  - Windows: `windowKind: webview2` (default, DSH taskbar icon) or `windowKind: browser` (dedicated
190
- `--app` instance); nothing opens if the selected type is unavailable
191
- - macOS/Linux: `webview2` mode is unavailable (logs and opens nothing); `browser` mode is untested
200
+ `--app` instance); falls back to the default-browser handoff (official open method, plain tab) if the selected type is unavailable
201
+ - macOS/Linux: `webview2` mode is unavailable (falls back to the default-browser handoff); `browser` mode is untested
192
202
  (dedicated `--app` instance)
193
203
 
194
204
  ## Edge cases
package/README.md CHANGED
@@ -27,8 +27,13 @@ dsh web profile 启动后自动打开独立应用窗口(或网页标签页)
27
27
  依赖任何退出事件。另有两层兜底:DSH 正常退出时 `process 'exit'` 结束该
28
28
  专用实例的整个进程树(仅匹配我们自己的 user-data-dir,不影响正常浏览器);
29
29
  DSH 被强杀后的残留实例由下次启动前预清理。
30
- 3. 所选类型不可用时(宿主缺失/浏览器找不到/非 Windows 等)→ **不打开任何东西**
31
- (记录日志),不自动交叉兜底。
30
+ 3. **默认浏览器打开(最后兜底)**:所选类型不可用时(宿主缺失/浏览器找不到/
31
+ 非 Windows 等)→ **降级为官方同款的默认浏览器交接**——把 URL 交给操作系统
32
+ 默认浏览器(普通标签页),保证用户至少能打开 GUI。实现与 DSH 核心
33
+ (web-app bundle)启动时打开网页的方式一致:优先用 DSH 部署自带的
34
+ `open` 包(win32 = PowerShell Start,darwin = `open`,linux = `xdg-open`),
35
+ `open` 包不可用时退回平台原生拉起(win32 = `cmd /c start`,darwin = `open`,
36
+ linux = `xdg-open`)。
32
37
  `appWindow: false` 时不自动打开任何窗口。
33
38
 
34
39
  端口取自 webServer 服务的真实监听值(`--port` 自定义、`--port 0` 均正确)。
@@ -38,6 +43,12 @@ webServer 插件 `Service.init()` 完成(HTTP socket 已绑定、端口已写
38
43
  两种模式都随 DSH 退出而关闭:webview2 宿主监视父进程;browser 专用实例由
39
44
  Job Object(强杀也生效)+ 退出清理结束进程树。
40
45
 
46
+ > **与 DSH 核心浏览器交接的关系**:DSH 核心(web-app bundle)默认会在启动后
47
+ > 用系统默认浏览器打开 GUI(`openBrowser: true`,普通标签页/窗口,非独立窗口)。
48
+ > 安装本插件后,插件的 bundle 补丁会把 `web-runtime.openBrowser` 置为 `false`,
49
+ > 只保留插件的独立应用窗口,不再弹出普通浏览器页面;卸载插件后恢复默认行为
50
+ > (临时关闭也可用 `dsh web --no-open`)。
51
+
41
52
  ### WebView2 宿主要求(仅 webview2 模式)
42
53
 
43
54
  - Windows 10 1803+ / Windows 11 / Windows Server 2016+
@@ -54,8 +65,9 @@ Job Object(强杀也生效)+ 退出清理结束进程树。
54
65
  `browserPath`(浏览器可执行文件,支持「浏览」原生对话框选择;位于窗口类型
55
66
  下方,仅选择「浏览器应用窗口」时使能)、
56
67
  `exitOnWindowClose`(窗口关闭时退出 DSH,默认关闭)。
57
- 保存后持久化到
58
- settings 文档(命名空间 `auto-open-web`),首次保存后设置值优先于行配置。
68
+ 保存后经**官方 settings 域**(客户端 settingsScope)持久化到
69
+ settings 文档(命名空间 `auto-open-web`),首次保存后设置值优先于行配置;
70
+ 宿主仅保留「浏览」「测试」辅助路由(官方通道无法覆盖的能力)。
59
71
  2. **行配置**(cordis.patch.yml):作为启动种子,设置卡片保存前生效。
60
72
 
61
73
  | 字段 | 默认 | 说明 |
@@ -79,14 +91,14 @@ Job Object(强杀也生效)+ 退出清理结束进程树。
79
91
 
80
92
  本包是**组合包(bundle)**:一个附带配置层的 npm 包——`package.json` 的
81
93
  `dsh.bundle` 声明配置层文件(`cordis.patch.yml`),profile 安装它时按包名激活
82
- 插件行。已发布到 **npm registry**(`dsh-auto-open-web@0.1.4`)与 **GitHub**
94
+ 插件行。已发布到 **npm registry**(`dsh-auto-open-web@0.1.5`)与 **GitHub**
83
95
  (https://github.com/jinsiyu/dsh-auto-open-web,main 分支)。
84
96
 
85
97
  ### 打包
86
98
 
87
99
  ```bash
88
100
  cd dsh-auto-open-web
89
- pnpm pack # prepack 钩子自动先编译 WebView2 宿主(dotnet publish),产出 dsh-auto-open-web-0.1.4.tgz
101
+ pnpm pack # prepack 钩子自动先编译 WebView2 宿主(dotnet publish),产出 dsh-auto-open-web-0.1.5.tgz
90
102
  ```
91
103
 
92
104
  ### 安装方式(任选其一)
@@ -101,7 +113,7 @@ dsh plugin --profile web add C:\path\to\dsh-auto-open-web
101
113
  **方式二:tarball(发布产物,推荐交付;无需构建授权)**
102
114
 
103
115
  ```bash
104
- dsh plugin --profile web add ./dsh-auto-open-web-0.1.4.tgz
116
+ dsh plugin --profile web add ./dsh-auto-open-web-0.1.5.tgz
105
117
  ```
106
118
 
107
119
  **方式三:npm 注册表(发布后)**
@@ -137,27 +149,25 @@ dsh plugin --profile web remove dsh-auto-open-web # 同时移除依赖与对
137
149
 
138
150
  ### 注意事项
139
151
 
140
- - **dsh 版本要求**:本插件支持 **dsh `>=0.1.0-rc.7 <0.2.0`**(peer 声明,由 DSH 部署
141
- 提供,安装无警告)。`settings.plugin.item` 自该版本起为 keyed 插槽,卡片注册
142
- 同时提供 `id` `key` 以兼容新旧两代 dsh;低于支持范围时宿主启动会记录
143
- 明确错误日志(提示升级 dsh),卡片可能无法挂载。
152
+ - **本包零 dependencies**:所有运行时依赖均由 **DSH 部署提供**,以 optional
153
+ peer 声明(安装无警告):
154
+ - `@deepseek-ai/dsh`(宿主,声明兼容范围 `>=0.1.0-rc.7 <0.2.0`,
155
+ `settings.plugin.item` 自该版本起为 keyed 插槽,注册需 `options.key`;
156
+ 不做运行时版本检测)
157
+ - `@deepseek-ai/schemastery`(配置 schema 校验器;运行时解析:常规 import
158
+ 优先,其次 Windows 全局 npm 布局下的 DSH 部署副本)
159
+ - `koffi`(仅 Windows 的 Job Object / 进程校验 / 原生对话框;同样运行时
160
+ 解析部署副本,失败仅降级)
161
+ 因此任何平台安装都无构建拦截——鸿蒙等无 koffi 预编译的环境开箱即装;
162
+ posix 平台走 posix 降级适配器(browser 模式可用;webview2 / 原生对话框
163
+ 不可用),且平台适配器按平台条件加载,posix 上完全不求值 win32.js。
144
164
  - **npm 包已含 WebView2 宿主编译产物**(prepack 编译后发布);**GitHub
145
165
  main 分支与源码 checkout 方式不含** `host-publish/`(构建产物被
146
166
  .gitignore 忽略):webview2 模式需先在 `node_modules/dsh-auto-open-web`
147
167
  下执行 `pnpm run build:host` 生成(需 .NET SDK);browser 模式无需构建。
148
- - **本包零 koffi 依赖声明**:koffi(驱动 Windows 的 Job Object / 进程校验 /
149
- 原生对话框)由 **DSH 部署自带**(官方原生选择器
150
- `@deepseek-ai/dsh-host-directory-picker-native` 依赖 koffi,部署必带),
151
- 插件运行时解析:常规解析(profile 已装/手动 `pnpm add koffi`)优先,
152
- 其次 Windows 全局 npm 布局下的 DSH 部署副本;解析失败仅降级(Job
153
- Object 不可用 → 退出/预清理兜底;进程校验跳过;对话框不可用)并记录
154
- 日志。**因此任何平台安装都无 koffi 构建拦截**——鸿蒙等无 koffi
155
- 预编译的环境开箱即装,无需 `pnpm-workspace.yaml` 等额外配置;posix
156
- 平台走 posix 降级适配器(browser 模式可用;webview2 / 原生对话框
157
- 不可用),且平台适配器按平台条件加载,posix 上完全不求值 win32.js。
158
168
  - 若手动编辑 `package.json` 安装(不经 dsh plugin 命令),需同时追加
159
169
  `dependencies` 与 `dsh.profile.bundles` 两项;使用本地 `file:` 依赖时
160
- `dsh web` 启动会把 `file:` 规范化成 `^0.1.4`,运行时不受影响。
170
+ `dsh web` 启动会把 `file:` 规范化成 `^0.1.5`,运行时不受影响。
161
171
 
162
172
  ## 图标
163
173
 
@@ -170,8 +180,8 @@ dsh plugin --profile web remove dsh-auto-open-web # 同时移除依赖与对
170
180
 
171
181
  ## 平台支持
172
182
 
173
- - Windows:`windowKind: webview2`(默认,任务栏图标 DSH)或 `windowKind: browser`(--app 专用实例);所选类型不可用则不打开
174
- - macOS/Linux:`webview2` 模式不可用(会记录日志不打开);`browser` 模式未测试(--app 专用实例)
183
+ - Windows:`windowKind: webview2`(默认,任务栏图标 DSH)或 `windowKind: browser`(--app 专用实例);所选类型不可用时降级为默认浏览器打开(官方同款,普通标签页)
184
+ - macOS/Linux:`webview2` 模式不可用(降级为默认浏览器打开);`browser` 模式未测试(--app 专用实例)
175
185
 
176
186
  ## 边界情况
177
187
 
package/cordis.patch.yml CHANGED
@@ -3,3 +3,15 @@
3
3
  - insert:
4
4
  - id: auto-open-web
5
5
  name: dsh-auto-open-web
6
+
7
+ # 本插件用独立应用窗口打开 GUI,替代 DSH 核心(web-app bundle)启动后的
8
+ # 默认浏览器交接,避免同时弹出普通浏览器页面(核心的 openBrowser 默认 true,
9
+ # 会以普通标签页/窗口打开 GUI;插件窗口才是"独立应用窗口")。
10
+ # 补丁按 id 整体替换 config,故逐键重述 web-runtime 原配置,仅把
11
+ # openBrowser 置为 false(trustedHosts 保留 webStartup 提供的原表达式)。
12
+ - id: web-runtime
13
+ config:
14
+ openBrowser: false
15
+ printUrl: true
16
+ surfaceContext: true
17
+ trustedHosts: !!js ctx.webStartup.trustedHosts
@@ -6,7 +6,7 @@
6
6
  "compilationOptions": {},
7
7
  "targets": {
8
8
  ".NETCoreApp,Version=v10.0": {
9
- "DshAppWindow/0.1.4": {
9
+ "DshAppWindow/0.1.5": {
10
10
  "dependencies": {
11
11
  "Microsoft.Web.WebView2": "1.0.3124.44",
12
12
  "Microsoft.Web.WebView2.Core": "1.0.3124.44",
@@ -63,7 +63,7 @@
63
63
  }
64
64
  },
65
65
  "libraries": {
66
- "DshAppWindow/0.1.4": {
66
+ "DshAppWindow/0.1.5": {
67
67
  "type": "project",
68
68
  "serviceable": false,
69
69
  "sha512": ""
Binary file
Binary file
Binary file