dsh-auto-open-web 0.1.13 → 0.1.15

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
@@ -68,7 +68,11 @@ cleanup.
68
68
  - Windows 10 1803+ / Windows 11 / Windows Server 2016+
69
69
  (Win7/8.1 reached end of support in 2023-01, see Microsoft announcements)
70
70
  - WebView2 Runtime (evergreen, usually preinstalled with Edge; verified with 151.x locally)
71
- - .NET 10 runtime (installed with the SDK; can be switched to a self-contained publish if needed)
71
+ - **No .NET 10 runtime required**: since 0.1.15 the host targets **.NET Framework 4.7.2**,
72
+ built into Windows 10 1803+ / Windows 11 (4.8.x on Win11) — no .NET Core/10 runtime or
73
+ self-contained publish is needed. The build machine needs a .NET SDK and the .NET
74
+ Framework 4.x targeting packs (installed with VS/SDK; without them add the
75
+ `Microsoft.NETFramework.ReferenceAssemblies` NuGet package to the csproj).
72
76
 
73
77
  ## Configuration
74
78
 
@@ -201,8 +205,13 @@ without touching the package.
201
205
  plugin-generated DSH .ico (`~/.dsh/auto-open-web-icon.ico`), independent of browser taskbar
202
206
  identity rules. The .ico is built by fetching the local `favicon.svg` and rasterizing it with
203
207
  **sharp** (bundled with the deployment, resolved upward at runtime, not declared as a dependency)
204
- into 16/32/48/64/128/256 PNGs; when sharp is unavailable the host falls back to the default window
205
- icon.
208
+ into 16/32/48/64/128/256 PNGs.
209
+ - **Fixed-icon policy (since 0.1.14)**: once written, the .ico is cached and reused — later
210
+ starts return the existing non-empty cache directly (no favicon fetch / rasterization, so the
211
+ icon cannot vanish on a transient favicon/sharp failure, and starts are faster); it is
212
+ generated only when the cache is missing. **Extra safety net**: `host/icon.ico` (same source as
213
+ the cache) is embedded into the host exe via `<ApplicationIcon>`, so even with a missing cache
214
+ the window/taskbar shows the DSH icon instead of the default one.
206
215
 
207
216
  ## Platform support
208
217
 
package/README.md CHANGED
@@ -63,7 +63,11 @@ Job Object(强杀也生效)+ 退出清理结束进程树。
63
63
  - Windows 10 1803+ / Windows 11 / Windows Server 2016+
64
64
  (Win7/8.1 已于 2023-01 终止支持,见微软公告)
65
65
  - WebView2 Runtime(常青版,通常随 Edge 预装;本机已验证 151.x)
66
- - .NET 10 运行时(随 SDK 安装;也可改为自包含发布,需时再调)
66
+ - **无 .NET 10 运行时要求**:宿主自 0.1.15 起目标 **.NET Framework 4.7.2**,
67
+ 由 Windows 10 1803+ / Windows 11 **操作系统自带**(Win11 为 4.8.x),
68
+ 无需安装任何 .NET Core/10/自包含运行时。构建机需 .NET SDK 与 .NET
69
+ Framework 4.x 定位包(随 VS/SDK 安装;无定位包时给 csproj 加
70
+ `Microsoft.NETFramework.ReferenceAssemblies` NuGet 包)。
67
71
 
68
72
  ## 配置
69
73
 
@@ -191,8 +195,12 @@ dsh plugin --profile web remove dsh-auto-open-web # 同时移除依赖与对
191
195
  - **任务栏/窗口图标(WebView2 宿主)**:宿主进程直接设置 `Form.Icon` = 插件生成的
192
196
  DSH .ico(`~/.dsh/auto-open-web-icon.ico`),与浏览器任务栏身份机制无关。
193
197
  .ico 来源:抓取本机 `favicon.svg`,用 **sharp**(部署自带,运行时向上解析,
194
- 未声明为依赖)栅格化为 16/32/48/64/128/256 PNG 后组装;sharp 不可用时
195
- 宿主退回默认窗口图标。
198
+ 未声明为依赖)栅格化为 16/32/48/64/128/256 PNG 后组装。
199
+ - **图标固定策略(自 0.1.14)**:生成的 .ico 一经写盘即**缓存固定**——后续启动
200
+ 检测到缓存存在且非空就直接复用,不再抓取 favicon/栅格化(图标不会因某次
201
+ favicon 或 sharp 瞬时失败而消失,启动也更快);仅缓存缺失时生成一次。
202
+ 另有**兜底**:`host/icon.ico`(与缓存同源)已通过 `<ApplicationIcon>`
203
+ 嵌入宿主 exe,即使缓存文件缺失,窗口/任务栏也显示 DSH 图标而非默认图标。
196
204
 
197
205
  ## 平台支持
198
206
 
Binary file
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <configuration>
3
+ <startup>
4
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5
+ </startup>
6
+ </configuration>
Binary file
Binary file
package/lib/index.js CHANGED
@@ -31,7 +31,7 @@
31
31
  * (WebView2 宿主例外:随 DSH 退出而关闭)。
32
32
  */
33
33
  import { spawn } from 'node:child_process';
34
- import { existsSync, rmSync, writeFileSync } from 'node:fs';
34
+ import { existsSync, rmSync, statSync, writeFileSync } from 'node:fs';
35
35
  import { createRequire } from 'node:module';
36
36
  import { join } from 'node:path';
37
37
  import { pathToFileURL } from 'node:url';
@@ -354,8 +354,13 @@ function normalizeState(next) {
354
354
  // ── 图标栅格化(WebView2 宿主窗口图标需要 .ico;共通) ─────────────────────
355
355
  //
356
356
  // GUI 自带的 manifest 只有 SVG 图标(favicon.svg)。这里抓取本机 favicon.svg,
357
- // 用 sharp(部署自带,运行时向上解析,未声明为依赖)栅格化为多尺寸 PNG 并缓存,
358
- // 再组装成 .ico 供宿主窗口的 Form.Icon 使用;失败仅告警(宿主退回默认图标)。
357
+ // 用 sharp(部署自带,运行时向上解析,未声明为依赖)栅格化为多尺寸 PNG,
358
+ // 再组装成 .ico 供宿主窗口的 Form.Icon 使用;失败仅告警(宿主退回内置图标)。
359
+ //
360
+ // **图标固定策略**(0.1.14):生成的 .ico 缓存于 `~/.dsh/auto-open-web-icon.ico`,
361
+ // 缓存存在且非空时**直接复用,不再每次启动抓取 favicon 并栅格化**——图标一经
362
+ // 生成即固定不变,也不会因某次启动的 favicon/sharp 瞬时失败而消失;
363
+ // 仅缓存缺失(首次运行/被删除)时生成一次,之后永不改写。
359
364
  let iconCache = null;
360
365
  let iconFetching = null;
361
366
 
@@ -414,13 +419,15 @@ function buildIco(pngs) {
414
419
  return Buffer.concat([header, ...entries, ...sizes.map((s) => pngs.get(s))]);
415
420
  }
416
421
 
417
- /** 生成宿主窗口用的 DSH .ico(缓存于 ~/.dsh/auto-open-web-icon.ico),失败返回 null。 */
422
+ /** 生成宿主窗口用的 DSH .ico(缓存于 ~/.dsh/auto-open-web-icon.ico),失败返回 null。
423
+ * 缓存存在且非空时直接复用(固定图标,不再生成);仅在缓存缺失时生成并写盘。 */
418
424
  async function ensureIconFile(server) {
425
+ const out = join(dshHome(), 'auto-open-web-icon.ico');
419
426
  try {
427
+ if (existsSync(out) && statSync(out).size > 0) return out;
420
428
  const icons = await getIcons(server);
421
429
  if (icons === null) return null;
422
430
  const ico = buildIco(icons.pngs);
423
- const out = join(dshHome(), 'auto-open-web-icon.ico');
424
431
  writeFileSync(out, ico);
425
432
  return out;
426
433
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-auto-open-web",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
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",
@@ -1,94 +0,0 @@
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.5": {
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.5": {
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
@@ -1,20 +0,0 @@
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
- }