dsh-auto-open-web 0.1.15 → 0.1.20

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
@@ -73,6 +73,11 @@ cleanup.
73
73
  self-contained publish is needed. The build machine needs a .NET SDK and the .NET
74
74
  Framework 4.x targeting packs (installed with VS/SDK; without them add the
75
75
  `Microsoft.NETFramework.ReferenceAssemblies` NuGet package to the csproj).
76
+ - **DPI awareness (since 0.1.20)**: the host declares **PerMonitorV2** (`host/app.manifest`
77
+ plus the WinForms `DpiAwareness` section in `App.config`). .NET Framework WinForms is
78
+ DPI-unaware by default, so on 125%/150% scaled displays Windows renders the window at
79
+ 96 DPI and bitmap-stretches it (DPI virtualization) → blurry text and web content.
80
+ Declaring awareness renders natively at the monitor's real DPI, keeping text crisp.
76
81
 
77
82
  ## Configuration
78
83
 
package/README.md CHANGED
@@ -68,6 +68,11 @@ Job Object(强杀也生效)+ 退出清理结束进程树。
68
68
  无需安装任何 .NET Core/10/自包含运行时。构建机需 .NET SDK 与 .NET
69
69
  Framework 4.x 定位包(随 VS/SDK 安装;无定位包时给 csproj 加
70
70
  `Microsoft.NETFramework.ReferenceAssemblies` NuGet 包)。
71
+ - **DPI 感知(自 0.1.20)**:宿主声明 **PerMonitorV2**(`host/app.manifest`
72
+ 清单 + `App.config` 的 WinForms `DpiAwareness` 段)。.NET Framework 的
73
+ WinForms 默认是 DPI 不感知进程,在 125%/150% 等缩放显示器上 Windows 会把
74
+ 窗口按 96 DPI 渲染后整体位图放大(DPI 虚拟化)→ 文字与网页内容发糊;
75
+ 声明感知后按显示器真实 DPI 原生渲染,字迹清晰。
71
76
 
72
77
  ## 配置
73
78
 
Binary file
@@ -3,4 +3,12 @@
3
3
  <startup>
4
4
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5
5
  </startup>
6
+ <!-- .NET Framework 4.7+ WinForms 高 DPI 支持:
7
+ DpiAwareness 让 WinForms 参与每显示器 DPI 缩放(与 app.manifest 的
8
+ PerMonitorV2 声明配合),EnableWindowsFormsHighDpiAutoResizing 启用
9
+ 控件随 DPI 变化的自动缩放。二者缺一,子控件在非 100% 缩放下会发糊/错位。 -->
10
+ <System.Windows.Forms.ApplicationConfigurationSection>
11
+ <add key="DpiAwareness" value="PerMonitorV2" />
12
+ <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
13
+ </System.Windows.Forms.ApplicationConfigurationSection>
6
14
  </configuration>
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
- // react(壳层静态模块)+ dsh-client-runtime(动态包,快照 store)
98
- // runtime 缺失或版本不含 createSnapshotStore 时退化为内置最小实现。
99
- var runtime = null
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
- runtime = require('@deepseek-ai/dsh-client-runtime')
103
+ createSnapshotStore = require('@deepseek-ai/dsh-client-store').createSnapshotStore
102
104
  } catch (e) {
103
- console.error('[auto-open-web] runtime require failed:', e !== null && e !== undefined && e.message !== undefined ? e.message : String(e))
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 = `http://127.0.0.1:${String(server.port)}`;
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 = `http://127.0.0.1:${String(server.port)}`;
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
- void attempt();
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-auto-open-web",
3
- "version": "0.1.15",
3
+ "version": "0.1.20",
4
4
  "description": "Open the DSH Web GUI in an app-style WebView2 window on profile start, with a settings card for browser paths",
5
5
  "repository": {
6
6
  "type": "git",