dsh-auto-open-web 0.1.15 → 0.1.19
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/host-publish/DshAppWindow.exe +0 -0
- package/host-publish/DshAppWindow.pdb +0 -0
- package/lib/client.js +17 -6
- package/lib/index.js +41 -3
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
package/lib/client.js
CHANGED
|
@@ -94,15 +94,26 @@ window.__ModuleLoader__.load({
|
|
|
94
94
|
injectCss(CONTROLS_TAG, CONTROLS_CSS)
|
|
95
95
|
|
|
96
96
|
// ── 共享模块 ─────────────────────────────────────────────────────────
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
|
|
97
|
+
// 快照 store 解析顺序(与 gowin 插件同款,双版本兼容):
|
|
98
|
+
// @deepseek-ai/dsh-client-store(当前壳层静态模块,dsh >= 0.1.2-alpha.1)
|
|
99
|
+
// → @deepseek-ai/dsh-client-runtime(rc8 动态包) → 内置最小实现。
|
|
100
|
+
// 缺失或版本不含 createSnapshotStore 时退化为内置实现,绝不抛错。
|
|
101
|
+
var createSnapshotStore = null
|
|
100
102
|
try {
|
|
101
|
-
|
|
103
|
+
createSnapshotStore = require('@deepseek-ai/dsh-client-store').createSnapshotStore
|
|
102
104
|
} catch (e) {
|
|
103
|
-
console.error('[auto-open-web]
|
|
105
|
+
console.error('[auto-open-web] dsh-client-store require failed:', e !== null && e !== undefined && e.message !== undefined ? e.message : String(e))
|
|
106
|
+
}
|
|
107
|
+
if (createSnapshotStore === undefined || createSnapshotStore === null) {
|
|
108
|
+
try {
|
|
109
|
+
createSnapshotStore = require('@deepseek-ai/dsh-client-runtime').createSnapshotStore
|
|
110
|
+
} catch (e) {
|
|
111
|
+
console.error('[auto-open-web] dsh-client-runtime require failed:', e !== null && e !== undefined && e.message !== undefined ? e.message : String(e))
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (createSnapshotStore === undefined || createSnapshotStore === null) {
|
|
115
|
+
createSnapshotStore = fallbackSnapshotStore
|
|
104
116
|
}
|
|
105
|
-
var createSnapshotStore = runtime !== null && runtime.createSnapshotStore !== undefined ? runtime.createSnapshotStore : fallbackSnapshotStore
|
|
106
117
|
function fallbackSnapshotStore(init) {
|
|
107
118
|
let value = init
|
|
108
119
|
const listeners = new Set()
|
package/lib/index.js
CHANGED
|
@@ -481,6 +481,17 @@ export function apply(ctx, config) {
|
|
|
481
481
|
return;
|
|
482
482
|
}
|
|
483
483
|
|
|
484
|
+
// 认证 GUI 地址:当前 dsh web 的连接服务提供带进程启动令牌的 URL(browser-auth:
|
|
485
|
+
// 首次访问 /?token= 交换签名 cookie;直接打开裸地址会得到 401「authentication
|
|
486
|
+
// required」)。连接服务缺失时以裸地址兜底(旧版 dsh 无认证,行为不变)。
|
|
487
|
+
const guiUrl = () => {
|
|
488
|
+
const base = `http://127.0.0.1:${String(server.port)}`;
|
|
489
|
+
const connection = ctx.get('connection');
|
|
490
|
+
return connection !== undefined && typeof connection.authenticatedUrl === 'function'
|
|
491
|
+
? connection.authenticatedUrl(base)
|
|
492
|
+
: base;
|
|
493
|
+
};
|
|
494
|
+
|
|
484
495
|
// ---- 配置状态:行配置为种子;settings 命名空间持久化(设置卡片写入) ----
|
|
485
496
|
const settingsSvc = ctx.get('settings');
|
|
486
497
|
let scope = null;
|
|
@@ -573,7 +584,7 @@ export function apply(ctx, config) {
|
|
|
573
584
|
sendJson(res, 200, { ok: false, error: 'webServer 端口不可用,请稍后重试' });
|
|
574
585
|
return;
|
|
575
586
|
}
|
|
576
|
-
const url =
|
|
587
|
+
const url = guiUrl();
|
|
577
588
|
const result = await testBrowserLaunch(resolved.exe, resolved.browser, url);
|
|
578
589
|
if (result.ok !== true) {
|
|
579
590
|
sendJson(res, 200, { ok: false, error: result.error });
|
|
@@ -597,7 +608,7 @@ export function apply(ctx, config) {
|
|
|
597
608
|
console.error('[auto-open-web] webServer port unavailable; not opening anything');
|
|
598
609
|
return;
|
|
599
610
|
}
|
|
600
|
-
const url =
|
|
611
|
+
const url = guiUrl();
|
|
601
612
|
|
|
602
613
|
// 与官方相同的打开抑制:--no-open(webStartup.openBrowser === false)或
|
|
603
614
|
// SSH 会话时不打开任何窗口/页面(官方同样不交接)。
|
|
@@ -667,5 +678,32 @@ export function apply(ctx, config) {
|
|
|
667
678
|
// 行为与未安装本插件时的官方默认完全一致。
|
|
668
679
|
await fallbackOpen('appWindow disabled (official default-browser handoff)');
|
|
669
680
|
};
|
|
670
|
-
|
|
681
|
+
// 与官方 web-app 相同:等连接服务就绪后打开,URL 才携带启动令牌
|
|
682
|
+
// (browser-auth)。双版本兼容:旧版 dsh(rc8)没有连接服务或它没有
|
|
683
|
+
// authenticatedUrl——后者会走 guiUrl 的裸地址回退;前者等待数秒仍无
|
|
684
|
+
// 连接服务时以裸地址兜底打开,保持 rc8 原有的自动打开行为。
|
|
685
|
+
let opened = false;
|
|
686
|
+
const openOnce = () => {
|
|
687
|
+
if (opened) return;
|
|
688
|
+
opened = true;
|
|
689
|
+
// 与官方 web-app 的 announceReady 完全相同:等 Loader 树完全 settle 后再
|
|
690
|
+
// 打开。否则窗口会在宿主控制器(workspace/session-controller)仍未就绪时
|
|
691
|
+
// 首载,工作区/会话列表为空,必须刷新一次才能看到。
|
|
692
|
+
const settled = ctx.get('loader')?.await?.();
|
|
693
|
+
if (settled === undefined) {
|
|
694
|
+
void attempt();
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
void settled.then(() => {
|
|
698
|
+
// 树在等待期间被退出(SIGTERM / appExit):静默跳过。
|
|
699
|
+
if (ctx.get('webServer') === undefined) return;
|
|
700
|
+
void attempt();
|
|
701
|
+
}, () => { /* 启动失败由 fail-loud 报告 */ });
|
|
702
|
+
};
|
|
703
|
+
if (ctx.get('connection') !== undefined) {
|
|
704
|
+
openOnce();
|
|
705
|
+
} else {
|
|
706
|
+
ctx.inject(['connection'], () => { openOnce(); });
|
|
707
|
+
setTimeout(() => { if (ctx.get('connection') === undefined) openOnce(); }, 5000);
|
|
708
|
+
}
|
|
671
709
|
}
|
package/package.json
CHANGED