dsh-auto-open-web 0.1.9 → 0.1.13

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/lib/platform.js CHANGED
@@ -1,29 +1,29 @@
1
- // dsh-auto-open-web — 平台适配器选择。
2
- //
3
- // 共通逻辑(index.js)只依赖本模块暴露的统一接口,不直接触碰平台差异:
4
- // isWindows 平台标识
5
- // resolveBrowserExe(path) → {browser, exe} | null
6
- // ensureBrowserJob() → job | {handle:null}(降级标记)
7
- // assignToBrowserJob(job, pid) → boolean
8
- // killDedicatedBrowserInstances(browser)
9
- // killProcessTree(pid)
10
- // pickBrowserExe() → Promise<string | null>
11
- // resolveHostExe() → string | null
12
- // openDefaultBrowser(url) → Promise<boolean>(原生拉起默认浏览器,兜底)
13
- //
14
- // 按平台**条件加载**适配器(ESM 顶层 await):
15
- // - Windows:加载 win32.js(koffi 驱动 Job Object / 进程校验 / 原生对话框)
16
- // - 其他平台(含鸿蒙等无 koffi 预编译的环境):加载 posix.js 降级实现,
17
- // 完全不求值 win32.js——koffi 仅 Windows 需要(optionalDependencies),
18
- // posix 平台不安装、不加载、不依赖。
19
- const impl = process.platform === 'win32' ? await import('./win32.js') : await import('./posix.js');
20
-
21
- export const isWindows = impl.isWindows;
22
- export const resolveBrowserExe = impl.resolveBrowserExe;
23
- export const ensureBrowserJob = impl.ensureBrowserJob;
24
- export const assignToBrowserJob = impl.assignToBrowserJob;
25
- export const killDedicatedBrowserInstances = impl.killDedicatedBrowserInstances;
26
- export const killProcessTree = impl.killProcessTree;
27
- export const pickBrowserExe = impl.pickBrowserExe;
28
- export const resolveHostExe = impl.resolveHostExe;
29
- export const openDefaultBrowser = impl.openDefaultBrowser;
1
+ // dsh-auto-open-web — 平台适配器选择。
2
+ //
3
+ // 共通逻辑(index.js)只依赖本模块暴露的统一接口,不直接触碰平台差异:
4
+ // isWindows 平台标识
5
+ // resolveBrowserExe(path) → {browser, exe} | null
6
+ // ensureBrowserJob() → job | {handle:null}(降级标记)
7
+ // assignToBrowserJob(job, pid) → boolean
8
+ // killDedicatedBrowserInstances(browser)
9
+ // killProcessTree(pid)
10
+ // pickBrowserExe() → Promise<string | null>
11
+ // resolveHostExe() → string | null
12
+ // openDefaultBrowser(url) → Promise<boolean>(原生拉起默认浏览器,兜底)
13
+ //
14
+ // 按平台**条件加载**适配器(ESM 顶层 await):
15
+ // - Windows:加载 win32.js(koffi 驱动 Job Object / 进程校验 / 原生对话框)
16
+ // - 其他平台(含鸿蒙等无 koffi 预编译的环境):加载 posix.js 降级实现,
17
+ // 完全不求值 win32.js——koffi 仅 Windows 需要(optionalDependencies),
18
+ // posix 平台不安装、不加载、不依赖。
19
+ const impl = process.platform === 'win32' ? await import('./win32.js') : await import('./posix.js');
20
+
21
+ export const isWindows = impl.isWindows;
22
+ export const resolveBrowserExe = impl.resolveBrowserExe;
23
+ export const ensureBrowserJob = impl.ensureBrowserJob;
24
+ export const assignToBrowserJob = impl.assignToBrowserJob;
25
+ export const killDedicatedBrowserInstances = impl.killDedicatedBrowserInstances;
26
+ export const killProcessTree = impl.killProcessTree;
27
+ export const pickBrowserExe = impl.pickBrowserExe;
28
+ export const resolveHostExe = impl.resolveHostExe;
29
+ export const openDefaultBrowser = impl.openDefaultBrowser;
package/lib/posix.js CHANGED
@@ -1,65 +1,65 @@
1
- // dsh-auto-open-web — 非 Windows 平台适配器(降级/尽力而为实现)。
2
- //
3
- // 与 win32.js 保持同一接口(platform.js 按 process.platform 选择):
4
- // - 浏览器候选:无(返回 null,调用方记日志不打开)
5
- // - Job Object:不可用({handle:null} 降级,退出/预清理兜底)
6
- // - 专用实例清理:无操作(Unix 下浏览器实例由 Job-less 方式管理,暂无实现)
7
- // - 进程树终止:尽力而为(SIGKILL 单进程,后代进程不保证)
8
- // - 原生文件对话框:不支持(返回 null,卡片提示手动输入)
9
- // - WebView2 宿主:无(返回 null,webview2 模式降级到最后兜底)
10
- // - 默认浏览器打开:原生拉起(darwin: open;linux: xdg-open)
11
- import { spawn } from 'node:child_process';
12
-
13
- export const isWindows = false;
14
-
15
- export function resolveBrowserExe() {
16
- return null;
17
- }
18
-
19
- export async function ensureBrowserJob() {
20
- return { handle: null };
21
- }
22
-
23
- export function assignToBrowserJob() {
24
- return false;
25
- }
26
-
27
- export function killDedicatedBrowserInstances() {
28
- /* 无操作:Unix 暂无专用实例清理实现 */
29
- }
30
-
31
- export function killProcessTree(pid) {
32
- try {
33
- process.kill(pid, 'SIGKILL');
34
- } catch {
35
- /* ignore */
36
- }
37
- }
38
-
39
- export function pickBrowserExe() {
40
- return Promise.resolve(null);
41
- }
42
-
43
- export function resolveHostExe() {
44
- return null;
45
- }
46
-
47
- /**
48
- * 原生默认浏览器打开(最后兜底,open 包不可用时):darwin 用 open,其余
49
- * 平台用 xdg-open。detached + stdio ignore,不阻塞 DSH;启动失败返回 false。
50
- */
51
- export function openDefaultBrowser(url) {
52
- const command = process.platform === 'darwin' ? 'open' : 'xdg-open';
53
- return new Promise((resolve) => {
54
- let child;
55
- try {
56
- child = spawn(command, [url], { detached: true, stdio: 'ignore' });
57
- } catch {
58
- resolve(false);
59
- return;
60
- }
61
- child.on('error', () => resolve(false));
62
- child.on('exit', (code) => resolve(code === 0));
63
- child.unref();
64
- });
65
- }
1
+ // dsh-auto-open-web — 非 Windows 平台适配器(降级/尽力而为实现)。
2
+ //
3
+ // 与 win32.js 保持同一接口(platform.js 按 process.platform 选择):
4
+ // - 浏览器候选:无(返回 null,调用方记日志不打开)
5
+ // - Job Object:不可用({handle:null} 降级,退出/预清理兜底)
6
+ // - 专用实例清理:无操作(Unix 下浏览器实例由 Job-less 方式管理,暂无实现)
7
+ // - 进程树终止:尽力而为(SIGKILL 单进程,后代进程不保证)
8
+ // - 原生文件对话框:不支持(返回 null,卡片提示手动输入)
9
+ // - WebView2 宿主:无(返回 null,webview2 模式降级到最后兜底)
10
+ // - 默认浏览器打开:原生拉起(darwin: open;linux: xdg-open)
11
+ import { spawn } from 'node:child_process';
12
+
13
+ export const isWindows = false;
14
+
15
+ export function resolveBrowserExe() {
16
+ return null;
17
+ }
18
+
19
+ export async function ensureBrowserJob() {
20
+ return { handle: null };
21
+ }
22
+
23
+ export function assignToBrowserJob() {
24
+ return false;
25
+ }
26
+
27
+ export function killDedicatedBrowserInstances() {
28
+ /* 无操作:Unix 暂无专用实例清理实现 */
29
+ }
30
+
31
+ export function killProcessTree(pid) {
32
+ try {
33
+ process.kill(pid, 'SIGKILL');
34
+ } catch {
35
+ /* ignore */
36
+ }
37
+ }
38
+
39
+ export function pickBrowserExe() {
40
+ return Promise.resolve(null);
41
+ }
42
+
43
+ export function resolveHostExe() {
44
+ return null;
45
+ }
46
+
47
+ /**
48
+ * 原生默认浏览器打开(最后兜底,open 包不可用时):darwin 用 open,其余
49
+ * 平台用 xdg-open。detached + stdio ignore,不阻塞 DSH;启动失败返回 false。
50
+ */
51
+ export function openDefaultBrowser(url) {
52
+ const command = process.platform === 'darwin' ? 'open' : 'xdg-open';
53
+ return new Promise((resolve) => {
54
+ let child;
55
+ try {
56
+ child = spawn(command, [url], { detached: true, stdio: 'ignore' });
57
+ } catch {
58
+ resolve(false);
59
+ return;
60
+ }
61
+ child.on('error', () => resolve(false));
62
+ child.on('exit', (code) => resolve(code === 0));
63
+ child.unref();
64
+ });
65
+ }
package/package.json CHANGED
@@ -1,61 +1,61 @@
1
- {
2
- "name": "dsh-auto-open-web",
3
- "version": "0.1.9",
4
- "description": "Open the DSH Web GUI in an app-style WebView2 window on profile start, with a settings card for browser paths",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/jinsiyu/dsh-auto-open-web.git"
8
- },
9
- "type": "module",
10
- "main": "lib/index.js",
11
- "scripts": {
12
- "build:host": "dotnet publish host/DshAppWindow.csproj -c Release -o host-publish --nologo",
13
- "prepack": "npm run build:host"
14
- },
15
- "exports": {
16
- ".": "./lib/index.js",
17
- "./client": "./lib/client.js",
18
- "./package.json": "./package.json"
19
- },
20
- "dsh": {
21
- "bundle": {
22
- "patch": "./cordis.patch.yml"
23
- },
24
- "client": {
25
- "platform": "web",
26
- "inject": [
27
- "@deepseek-ai/dsh-client-connection",
28
- "@deepseek-ai/dsh-api-remotes",
29
- "@deepseek-ai/dsh-client-ui-settings",
30
- "@deepseek-ai/dsh-client-runtime",
31
- "@deepseek-ai/dsh-client-locale"
32
- ]
33
- }
34
- },
35
- "files": [
36
- "lib/index.js",
37
- "lib/client.js",
38
- "lib/worker.cjs",
39
- "lib/paths.js",
40
- "lib/platform.js",
41
- "lib/win32.js",
42
- "lib/posix.js",
43
- "host-publish",
44
- "cordis.patch.yml",
45
- "README.md",
46
- "README.en.md"
47
- ],
48
- "peerDependencies": {
49
- "@deepseek-ai/dsh": ">=0.1.0-rc.7 <0.2.0",
50
- "@deepseek-ai/schemastery": "^3.18.1"
51
- },
52
- "peerDependenciesMeta": {
53
- "@deepseek-ai/dsh": {
54
- "optional": true
55
- },
56
- "@deepseek-ai/schemastery": {
57
- "optional": true
58
- }
59
- },
60
- "license": "MIT"
61
- }
1
+ {
2
+ "name": "dsh-auto-open-web",
3
+ "version": "0.1.13",
4
+ "description": "Open the DSH Web GUI in an app-style WebView2 window on profile start, with a settings card for browser paths",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/jinsiyu/dsh-auto-open-web.git"
8
+ },
9
+ "type": "module",
10
+ "main": "lib/index.js",
11
+ "scripts": {
12
+ "build:host": "dotnet publish host/DshAppWindow.csproj -c Release -o host-publish --nologo",
13
+ "prepack": "npm run build:host"
14
+ },
15
+ "exports": {
16
+ ".": "./lib/index.js",
17
+ "./client": "./lib/client.js",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "dsh": {
21
+ "bundle": {
22
+ "patch": "./cordis.patch.yml"
23
+ },
24
+ "client": {
25
+ "platform": "web",
26
+ "inject": [
27
+ "@deepseek-ai/dsh-client-connection",
28
+ "@deepseek-ai/dsh-api-remotes",
29
+ "@deepseek-ai/dsh-client-ui-settings",
30
+ "@deepseek-ai/dsh-client-runtime",
31
+ "@deepseek-ai/dsh-client-locale"
32
+ ]
33
+ }
34
+ },
35
+ "files": [
36
+ "lib/index.js",
37
+ "lib/client.js",
38
+ "lib/worker.cjs",
39
+ "lib/paths.js",
40
+ "lib/platform.js",
41
+ "lib/win32.js",
42
+ "lib/posix.js",
43
+ "host-publish",
44
+ "cordis.patch.yml",
45
+ "README.md",
46
+ "README.en.md"
47
+ ],
48
+ "peerDependencies": {
49
+ "@deepseek-ai/dsh": ">=0.1.0-rc.8 <0.2.0",
50
+ "@deepseek-ai/schemastery": "^3.18.1"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "@deepseek-ai/dsh": {
54
+ "optional": true
55
+ },
56
+ "@deepseek-ai/schemastery": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "license": "MIT"
61
+ }