dsh-theme-engine 26.12.5-162000 → 26.12.5-185500
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/NOTICE +7 -0
- package/README.en.md +20 -18
- package/README.md +20 -18
- package/client/client.js +16 -33
- package/client/src/07-styles.js +5 -3
- package/client/src/12-apply.js +10 -29
- package/docs/DETAIL.md +10 -8
- package/host/audio.js +17 -9
- package/host/diagnostics.js +8 -1
- package/host/helper.js +46 -5
- package/index.js +67 -49
- package/package.json +11 -2
- package/scripts/build-audio.mjs +66 -0
package/NOTICE
CHANGED
|
@@ -2,3 +2,10 @@ DSH Theme Engine
|
|
|
2
2
|
Copyright 2026 DSH Theme Engine contributors
|
|
3
3
|
|
|
4
4
|
This product includes software developed by DSH Theme Engine contributors.
|
|
5
|
+
|
|
6
|
+
Third-party components
|
|
7
|
+
----------------------
|
|
8
|
+
bin/lg-capture.exe and bin/lg-audio.exe are built with GCC (MinGW-w64) and
|
|
9
|
+
statically include libstdc++ and libgcc, distributed under GPLv3 with the GCC
|
|
10
|
+
Runtime Library Exception. The Windows UCRT and system DLLs are provided by
|
|
11
|
+
the operating system.
|
package/README.en.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://github.com/ShuoweiFu/DSH-Theme-Engine/blob/main/README.md#known-edges)
|
|
13
13
|
[](https://github.com/ShuoweiFu/DSH-Theme-Engine/stargazers)
|
|
14
14
|
|
|
15
|
-
Version **v.26.
|
|
15
|
+
Version **v.26.12.05.185500** · Apache-2.0 · DSH Desktop on Windows only
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -35,7 +35,7 @@ The plugin registers no agent tools and injects no prompt text, so it **costs yo
|
|
|
35
35
|
| Module | Where the background comes from | When it exists |
|
|
36
36
|
| --- | --- | --- |
|
|
37
37
|
| Liquid glass | Live desktop capture, or a file / URL you pick | Always (built in) |
|
|
38
|
-
| Wallpaper engine | Your local Steam / Wallpaper Engine library;
|
|
38
|
+
| Wallpaper engine | Your local Steam / Wallpaper Engine library; videos stream directly, web projects render locally in a sandboxed iframe | Always; a reduced shape when WE is missing |
|
|
39
39
|
| elysia395 compatible | [elysia395/dsh-wallpaper-engine](https://github.com/elysia395/dsh-wallpaper-engine) | Only when that plugin is detected |
|
|
40
40
|
|
|
41
41
|
They are mutually exclusive: one sheet of glass supplies the background at any moment. The **island** is not one of them — it is an independent overlay and can be on with any module.
|
|
@@ -67,7 +67,7 @@ The wallpaper branch is one top-to-bottom pipeline: **switch → library → pro
|
|
|
67
67
|
|
|
68
68
|
### Library
|
|
69
69
|
|
|
70
|
-
It reads Steam's `libraryfolders.vdf`, then `steamapps/workshop/431960/*/project.json` plus WE's own `config.json`, and lists video / scene / web projects as a preview grid with search and type filters. Type is labelled on every card;
|
|
70
|
+
It reads Steam's `libraryfolders.vdf`, then `steamapps/workshop/431960/*/project.json` plus WE's own `config.json`, and lists video / scene / web projects as a preview grid with search and type filters. Type is labelled on every card; videos are read straight from their media file, web projects render in a local sandboxed iframe, and scene projects (`scene.pkg`) have no readable frame, so they say so instead of pretending to apply.
|
|
71
71
|
|
|
72
72
|
### Property sheet
|
|
73
73
|
|
|
@@ -91,7 +91,7 @@ Name and save the current parameter set, load, delete, export it as JSON, or pas
|
|
|
91
91
|
|
|
92
92
|
### What it looks like without Wallpaper Engine
|
|
93
93
|
|
|
94
|
-
Deliberately different: **no WE, different UI**. The grid, search
|
|
94
|
+
Deliberately different: **no WE, different UI**. The grid, search and type filters are not rendered at all. What remains is
|
|
95
95
|
|
|
96
96
|
- a status line saying WE was not detected
|
|
97
97
|
- the Steam store link, if you want to install it
|
|
@@ -100,15 +100,13 @@ Deliberately different: **no WE, different UI**. The grid, search, type filters,
|
|
|
100
100
|
|
|
101
101
|
Nothing that looks clickable but does nothing.
|
|
102
102
|
|
|
103
|
-
### How
|
|
103
|
+
### How video / web / scene projects are handled
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
The plugin **never runs `wallpaper64.exe` to change your desktop wallpaper** — what plays on your desktop is yours to decide. Each type is handled separately:
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
asks WE to switch, calls `invalidate()` on its cache, waits 1200 ms and re-reads WE state before capturing the desktop again. It returns `{ ok, switched, id, title, type, file }`, and the UI reports the outcome.
|
|
107
|
+
- **Video**: reads the media file named by `project.json` and streams it into the glass with HTTP Range; WE does not replay it.
|
|
108
|
+
- **Web**: the host mirrors one workshop folder and the client renders it in a `sandbox="allow-scripts"` iframe (no `allow-same-origin`), injecting WE's audio and property runtime API.
|
|
109
|
+
- **Scene**: `scene.pkg` can only be decoded by WE itself; the plugin has no frame to sample, so it says unsupported instead of silently pinning a still.
|
|
112
110
|
|
|
113
111
|
## Where the "black flash on loop" went
|
|
114
112
|
|
|
@@ -160,7 +158,7 @@ Hence five layers of protection: over-budget frame time → lower resolution (1.
|
|
|
160
158
|
|
|
161
159
|
**Wallpaper**: liquid glass on, WE library auto, alignment cover, position 50/50, flip off, speed 1.00×, volume 0, mute on, up to 24 presets, local files in image / video / gif / apng.
|
|
162
160
|
|
|
163
|
-
**Sound**: local playlists (mp3 / flac / wav / ogg / m4a / aac / opus, 0.25–2.0×, volume) or system audio
|
|
161
|
+
**Sound**: local playlists (mp3 / flac / wav / ogg / m4a / aac / opus, 0.25–2.0×, volume) or system audio. System audio is captured by `bin/lg-audio.exe` through WASAPI loopback, **analysis only — never replayed, never uploaded**; a web wallpaper that registers an audio listener starts this chain, and it can be turned off in the sound group. Energy feeds the shader live — the surface rises on bass.
|
|
164
162
|
|
|
165
163
|
**Performance**: smart preset follows the GPU, backend WebGL / WebGPU, max FPS 30 / 60 / 144 by tier, dynamic resolution on, occlusion compositing by tier, wallpaper refresh auto (8 fps stream + 0.22 s digest + 420 ms cross-fade).
|
|
166
164
|
|
|
@@ -178,14 +176,14 @@ The log contains your user name and install paths, so skim it before sending.
|
|
|
178
176
|
- Occluded UWP / DRM / minimised windows may be empty surfaces: skipped rather than pasted black, still listed in `apps`.
|
|
179
177
|
- Borderless capture needs Windows 11 / 10 20348+; older systems get the yellow capture border back, and the background keeps refreshing.
|
|
180
178
|
- Minimised windows stop the render loop — Chromium behaviour, and a power saving one.
|
|
181
|
-
-
|
|
179
|
+
- Scene wallpapers (`scene.pkg`) have no readable frame: the plugin neither switches nor previews them, only shows a hint; web wallpapers render in a local sandboxed iframe, not through WE.
|
|
182
180
|
- Speed and volume apply to `<video>` wallpapers and animations; scene wallpapers are tuned inside WE.
|
|
183
181
|
- Non-Windows platforms get no occlusion compositing — static wallpaper files only.
|
|
184
182
|
- The elysia395 branch is a placeholder: it appears when detected, and settings takeover/migration is still in progress.
|
|
185
183
|
|
|
186
184
|
## Ecosystem
|
|
187
185
|
|
|
188
|
-
- **Wallpaper Engine** (Steam AppID `431960`): library scanning, project typing and property semantics all follow it;
|
|
186
|
+
- **Wallpaper Engine** (Steam AppID `431960`): library scanning, project typing and property semantics all follow it; videos stream directly, web wallpapers render locally, scene wallpapers are unsupported.
|
|
189
187
|
- **[elysia395/dsh-wallpaper-engine](https://github.com/elysia395/dsh-wallpaper-engine)**: the compatibility target of the third module. Both can be installed; only one supplies the background at a time.
|
|
190
188
|
|
|
191
189
|
## Development
|
|
@@ -193,16 +191,20 @@ The log contains your user name and install paths, so skim it before sending.
|
|
|
193
191
|
```powershell
|
|
194
192
|
pnpm build:client # client/src/*.js → client/client.js (Node.js only, no third-party deps)
|
|
195
193
|
pnpm build:capture # tools/capture/lg-capture.cpp → bin/lg-capture.exe (needs clang++, override with LG_CLANG)
|
|
194
|
+
pnpm build:audio # tools/audio/lg-audio.cpp → bin/lg-audio.exe (same toolchain)
|
|
195
|
+
pnpm test # node:test regressions: version parsing, stream cooldown, MIME
|
|
196
|
+
pnpm check # verify client/client.js matches the sources
|
|
196
197
|
```
|
|
197
198
|
|
|
198
199
|
| Path | Role |
|
|
199
200
|
| --- | --- |
|
|
200
|
-
| `index.js` | Host entry: `/liquid-glass/*` routes (including `/
|
|
201
|
-
| `host/` | Wallpaper detection, WE bridge (scan / preview
|
|
202
|
-
| `client/src/` | Front-end sources concatenated `01` → `14` (13 = wallpaper centre and colour modes, 14 = audio matrix) |
|
|
201
|
+
| `index.js` | Host entry: `/liquid-glass/*` routes (including `/web/open`, `/audio/*`, `/log/export`), capture scheduling, module state, update check |
|
|
202
|
+
| `host/` | Wallpaper detection, WE library bridge (scan / preview), persistent capture helper, PowerShell fallback, audio spectrum, web mirror, update check |
|
|
203
|
+
| `client/src/` | Front-end sources concatenated `prologue` + `01` → `14` + `epilogue` (13 = wallpaper centre and colour modes, 14 = audio matrix) |
|
|
203
204
|
| `client/client.js` | Build output, loaded by DSH through `exports["./client"]` |
|
|
204
205
|
| `tools/capture/lg-capture.cpp` | Native capture / compositing helper (WGC + GDI+) |
|
|
205
|
-
| `
|
|
206
|
+
| `tools/audio/lg-audio.cpp` | Native system-audio / FFT helper (WASAPI) |
|
|
207
|
+
| `bin/lg-capture.exe`, `bin/lg-audio.exe` | Prebuilt helpers shipped with the plugin |
|
|
206
208
|
| `docs/DETAIL.md` | Compositing, screen-space mapping, the five-layer guard, shader parameters, module data shapes |
|
|
207
209
|
|
|
208
210
|
Please include host/plugin versions, OS, GPU, reproduction steps and redacted logs in issues.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://github.com/ShuoweiFu/DSH-Theme-Engine/blob/main/README.md#已知边界)
|
|
13
13
|
[](https://github.com/ShuoweiFu/DSH-Theme-Engine/stargazers)
|
|
14
14
|
|
|
15
|
-
当前版本 **v.26.
|
|
15
|
+
当前版本 **v.26.12.05.185500** · Apache-2.0 · 只跑在 Windows 上的 DSH 桌面版
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -35,7 +35,7 @@ DSH 的界面是方的、不透明的、和桌面无关。这个插件做三件
|
|
|
35
35
|
| 模块 | 背景从哪来 | 什么时候出现 |
|
|
36
36
|
| --- | --- | --- |
|
|
37
37
|
| 液态玻璃背景 | 本机桌面捕获,或你指的文件 / URL | 一直有(内置) |
|
|
38
|
-
| 壁纸引擎 | 你本机 Steam 里的 Wallpaper Engine
|
|
38
|
+
| 壁纸引擎 | 你本机 Steam 里的 Wallpaper Engine 库;视频直接流式读取,网页在沙箱 iframe 本地渲染 | 一直有;没装 WE 时是简化形态 |
|
|
39
39
|
| elysia395 兼容 | [elysia395/dsh-wallpaper-engine](https://github.com/elysia395/dsh-wallpaper-engine) | 检测到那个插件才出现 |
|
|
40
40
|
|
|
41
41
|
三者互斥——同一时刻只有一块玻璃在供背景。**灵动岛**不属于它们,是独立叠加层,开哪个背景都能开。
|
|
@@ -67,7 +67,7 @@ plugin_manager install_bundle target="<npm pack 生成的 .tgz>"
|
|
|
67
67
|
|
|
68
68
|
### 库
|
|
69
69
|
|
|
70
|
-
扫描 Steam 的 `libraryfolders.vdf`,再读 `steamapps/workshop/431960/*/project.json` 与 WE 自己的 `config.json`,把视频 / 场景 /
|
|
70
|
+
扫描 Steam 的 `libraryfolders.vdf`,再读 `steamapps/workshop/431960/*/project.json` 与 WE 自己的 `config.json`,把视频 / 场景 / 网页三类项目列成缩略图网格,带搜索框和类型筛选。每条都标了类型;视频项目直接读媒体文件,网页项目在本地沙箱 iframe 里渲染,场景项目(`scene.pkg`)没有可读帧,会明确提示不支持而不是假装应用成功。
|
|
71
71
|
|
|
72
72
|
### 属性
|
|
73
73
|
|
|
@@ -91,7 +91,7 @@ plugin_manager install_bundle target="<npm pack 生成的 .tgz>"
|
|
|
91
91
|
|
|
92
92
|
### 没装 Wallpaper Engine 的样子
|
|
93
93
|
|
|
94
|
-
这是刻意的:**检测不到 WE
|
|
94
|
+
这是刻意的:**检测不到 WE 就换一套界面**。库网格、搜索、类型筛选全部不渲染,只留
|
|
95
95
|
|
|
96
96
|
- 一行状态说明(未检测到 WE)
|
|
97
97
|
- Steam 商店入口(想装的时候点)
|
|
@@ -100,15 +100,13 @@ plugin_manager install_bundle target="<npm pack 生成的 .tgz>"
|
|
|
100
100
|
|
|
101
101
|
不会出现一排点了没反应的按钮。
|
|
102
102
|
|
|
103
|
-
###
|
|
103
|
+
### 视频 / 网页 / 场景怎么处理
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
插件**从不调用 `wallpaper64.exe` 改你的桌面壁纸**——桌面上正在播什么是你自己的事。三种项目分别处理:
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
让 WE 本体换壁纸,`invalidate()` 清缓存后等 1200 ms 再复核一次 WE 状态,然后照常从桌面捕获进玻璃。返回 `{ ok, switched, id, title, type, file }`,界面按结果给提示。
|
|
107
|
+
- **视频**:直接读 `project.json` 指向的媒体文件,用 HTTP Range 流式送进玻璃,不经过 WE 重播。
|
|
108
|
+
- **网页**:宿主只镜像一个 workshop 文件夹,客户端用 `sandbox="allow-scripts"`(不带 `allow-same-origin`)的 iframe 本地渲染,并注入 WE 的音频/属性运行时 API。
|
|
109
|
+
- **场景**:`scene.pkg` 只有 WE 本体能解,插件没有可读帧,所以明确提示不支持;不会偷偷截一张静态图假装是壁纸。
|
|
112
110
|
|
|
113
111
|
## 「循环播放黑一下」是怎么没的
|
|
114
112
|
|
|
@@ -160,7 +158,7 @@ WebGL 与 WebGPU 两条上传路径都加了这道闸。
|
|
|
160
158
|
|
|
161
159
|
**壁纸**:启用液态玻璃开、WE 库自动读取、对齐覆盖、位置 50/50、翻转关、速度 1.00×、音量 0、静音开、预设最多 24 条、本地文件支持图片 / 视频 / gif / apng。
|
|
162
160
|
|
|
163
|
-
**声音**:本机播放列表(mp3 / flac / wav / ogg / m4a / aac / opus,0.25–2.0
|
|
161
|
+
**声音**:本机播放列表(mp3 / flac / wav / ogg / m4a / aac / opus,0.25–2.0×,音量可调),或系统音频。系统音频由 `bin/lg-audio.exe` 通过 WASAPI loopback 采集,**只做分析,不二次播放、不上传**;网页壁纸注册音频监听时会启动这条分析链路,可在声音分组关闭。能量实时喂给 shader,低音落下时液面起伏。
|
|
164
162
|
|
|
165
163
|
**性能**:智能预设跟随显卡、后端 WebGL / WebGPU、最大帧率按档 30 / 60 / 144、自动降分辨率开、遮挡合成按档、壁纸刷新自动(8 fps 流 + 0.22 s digest + 420 ms 交叉淡入)。
|
|
166
164
|
|
|
@@ -178,14 +176,14 @@ WebGL 与 WebGPU 两条上传路径都加了这道闸。
|
|
|
178
176
|
- 被遮挡的 UWP / DRM / 最小化窗口可能是空表面:跳过不贴黑,但 `apps` 里仍会列出。
|
|
179
177
|
- 无边框捕获要 Windows 11 / 10 20348+;更老系统上系统黄框会回来,背景照常刷新。
|
|
180
178
|
- 窗口最小化时 Chromium 会停渲染循环,这是浏览器行为,也顺带省电。
|
|
181
|
-
-
|
|
179
|
+
- 场景壁纸(`scene.pkg`)没有可读帧,插件不切换、不预览,只给提示;网页壁纸由本地沙箱 iframe 渲染,不经过 WE 本体。
|
|
182
180
|
- 倍速 / 音量只作用于 `<video>` 类壁纸与动态图;场景壁纸的播放参数得进 WE 调。
|
|
183
181
|
- 非 Windows 平台没有遮挡合成,只能同步静态壁纸文件。
|
|
184
182
|
- elysia395 分支目前是占位:检测到就出现,接管与迁移还在做。
|
|
185
183
|
|
|
186
184
|
## 生态
|
|
187
185
|
|
|
188
|
-
- **Wallpaper Engine**(Steam AppID `431960
|
|
186
|
+
- **Wallpaper Engine**(Steam AppID `431960`):库扫描、项目类型判断、属性语义都照它来;视频流式读取,网页本地沙箱渲染,场景明确不支持。
|
|
189
187
|
- **[elysia395/dsh-wallpaper-engine](https://github.com/elysia395/dsh-wallpaper-engine)**:第三种背景模块的兼容目标。装了两个可以共存,但同一时间只有一个在供背景。
|
|
190
188
|
|
|
191
189
|
## 开发
|
|
@@ -193,16 +191,20 @@ WebGL 与 WebGPU 两条上传路径都加了这道闸。
|
|
|
193
191
|
```powershell
|
|
194
192
|
pnpm build:client # client/src/*.js → client/client.js(只要 Node.js,无第三方依赖)
|
|
195
193
|
pnpm build:capture # tools/capture/lg-capture.cpp → bin/lg-capture.exe(要 clang++,可用 LG_CLANG 指定)
|
|
194
|
+
pnpm build:audio # tools/audio/lg-audio.cpp → bin/lg-audio.exe(同上)
|
|
195
|
+
pnpm test # node:test 回归:版本解析、流冷却、MIME
|
|
196
|
+
pnpm check # 校验 client/client.js 与源码同步
|
|
196
197
|
```
|
|
197
198
|
|
|
198
199
|
| 路径 | 作用 |
|
|
199
200
|
| --- | --- |
|
|
200
|
-
| `index.js` | 宿主入口:`/liquid-glass/*` 路由(含 `/
|
|
201
|
-
| `host/` | 壁纸识别、WE
|
|
202
|
-
| `client/src/` | 前端源码,`01` → `14` 顺序拼接(13 = 壁纸中枢与颜色模式,14 = 音频矩阵) |
|
|
201
|
+
| `index.js` | 宿主入口:`/liquid-glass/*` 路由(含 `/web/open`、`/audio/*`、`/log/export`)、捕获调度、模块状态、更新检查 |
|
|
202
|
+
| `host/` | 壁纸识别、WE 库桥(扫描 / 预览)、常驻捕获助手、PowerShell 回退、音频频谱、网页镜像、更新检查 |
|
|
203
|
+
| `client/src/` | 前端源码,`prologue` + `01` → `14` + `epilogue` 顺序拼接(13 = 壁纸中枢与颜色模式,14 = 音频矩阵) |
|
|
203
204
|
| `client/client.js` | 构建产物,DSH 通过 `exports["./client"]` 加载 |
|
|
204
205
|
| `tools/capture/lg-capture.cpp` | 原生捕获 / 合成助手(WGC + GDI+) |
|
|
205
|
-
| `
|
|
206
|
+
| `tools/audio/lg-audio.cpp` | 原生系统音频 / FFT 助手(WASAPI) |
|
|
207
|
+
| `bin/lg-capture.exe`、`bin/lg-audio.exe` | 预编译助手,随插件分发 |
|
|
206
208
|
| `docs/DETAIL.md` | 合成原理、屏幕空间映射、五层保命、着色器参数、模块数据形状 |
|
|
207
209
|
|
|
208
210
|
提 issue 请带上宿主 / 插件版本、系统、显卡、复现步骤和脱敏日志。
|
package/client/client.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
const LEGACY_STORAGE_KEYS = ["dsh-liquid-glass.settings.v2"];
|
|
10
10
|
const API = "/liquid-glass";
|
|
11
11
|
/** Bumped whenever the mapping or the settings contract changes; visible via /liquid-glass/state. */
|
|
12
|
-
const CLIENT_BUILD = "v.26.12.05.
|
|
12
|
+
const CLIENT_BUILD = "v.26.12.05.185501";
|
|
13
13
|
const LOAD_TAG = String((globalThis.__lgLoadCount = (globalThis.__lgLoadCount || 0) + 1));
|
|
14
14
|
/**
|
|
15
15
|
* Appearance values are archived per colour mode. These ids and keys are
|
|
@@ -1991,7 +1991,9 @@ html[data-lg-mode="dark"] div[data-composer-card] {
|
|
|
1991
1991
|
* so match on the suffix; the inset hairline keeps the pane edge legible over
|
|
1992
1992
|
* a busy wallpaper.
|
|
1993
1993
|
*/
|
|
1994
|
-
html[data-lg-enabled="on"] [class*="_sidebarCol"] {
|
|
1994
|
+
html[data-lg-enabled="on"][data-lg-module="wallpaper"] [class*="_sidebarCol"] {
|
|
1995
|
+
/* Wallpaper module only: the liquid-glass module keeps the plain token
|
|
1996
|
+
fill so the shader stays readable through the pane. */
|
|
1995
1997
|
/* The pane carries the milky floor itself. The shell token stays at
|
|
1996
1998
|
bare-glass level because the frame and titlebar strip share it. */
|
|
1997
1999
|
background-color: var(--lg-sidebar-fill, rgba(255, 255, 255, 0.14)) !important;
|
|
@@ -2013,7 +2015,7 @@ html[data-lg-enabled="on"] [class*="_sidebarCol"] {
|
|
|
2013
2015
|
* right on top of the brand mark. A pseudo element blurs the same backdrop
|
|
2014
2016
|
* without becoming the containing block of the pane's children.
|
|
2015
2017
|
*/
|
|
2016
|
-
html[data-lg-enabled="on"] [class*="_sidebarCol"]::before {
|
|
2018
|
+
html[data-lg-enabled="on"][data-lg-module="wallpaper"] [class*="_sidebarCol"]::before {
|
|
2017
2019
|
content: "";
|
|
2018
2020
|
position: absolute;
|
|
2019
2021
|
inset: 0;
|
|
@@ -2022,7 +2024,7 @@ html[data-lg-enabled="on"] [class*="_sidebarCol"]::before {
|
|
|
2022
2024
|
backdrop-filter: blur(24px) saturate(1.32);
|
|
2023
2025
|
}
|
|
2024
2026
|
|
|
2025
|
-
html[data-lg-enabled="on"][data-lg-mode="dark"] [class*="_sidebarCol"] {
|
|
2027
|
+
html[data-lg-enabled="on"][data-lg-module="wallpaper"][data-lg-mode="dark"] [class*="_sidebarCol"] {
|
|
2026
2028
|
box-shadow:
|
|
2027
2029
|
inset 0 1px 0 rgba(255, 255, 255, 0.1),
|
|
2028
2030
|
inset -0.5px 0 0 rgba(255, 255, 255, 0.06);
|
|
@@ -6899,6 +6901,8 @@ fn fs(in: VSOut) -> @location(0) vec4<f32> {
|
|
|
6899
6901
|
"hw: hdr " +
|
|
6900
6902
|
JSON.stringify({
|
|
6901
6903
|
side: Math.round(sr.left) + "," + Math.round(sr.width),
|
|
6904
|
+
mod: document.documentElement.dataset.lgModule ?? null,
|
|
6905
|
+
fill: own.backgroundColor,
|
|
6902
6906
|
ownBf: own.backdropFilter || "none",
|
|
6903
6907
|
frostBf: frost.backdropFilter || "none",
|
|
6904
6908
|
frostPos: frost.position + "|" + frost.inset,
|
|
@@ -7134,38 +7138,17 @@ fn fs(in: VSOut) -> @location(0) vec4<f32> {
|
|
|
7134
7138
|
checkUpdates(false);
|
|
7135
7139
|
}, [checkUpdates]);
|
|
7136
7140
|
// One press, one file: the panel collects the page, the host adds
|
|
7137
|
-
// everything it knows and writes the result to disk.
|
|
7138
|
-
//
|
|
7139
|
-
//
|
|
7140
|
-
// The snapshot travels deflated: a full settings tree plus the stored
|
|
7141
|
-
// copy plus the perf JSON outsized the URL one machine's GET survived,
|
|
7142
|
-
// and the export then quietly lost the page half.
|
|
7143
|
-
const packSnapshot = async (snapshot) => {
|
|
7144
|
-
let json = JSON.stringify(snapshot);
|
|
7145
|
-
if (typeof CompressionStream === "function") {
|
|
7146
|
-
try {
|
|
7147
|
-
const stream = new Blob([json]).stream().pipeThrough(new CompressionStream("deflate-raw"));
|
|
7148
|
-
const bytes = new Uint8Array(await new Response(stream).arrayBuffer());
|
|
7149
|
-
let binary = "";
|
|
7150
|
-
for (let index = 0; index < bytes.length; index += 1) binary += String.fromCharCode(bytes[index]);
|
|
7151
|
-
const b64 = btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
7152
|
-
return "?m=d&snap=" + b64;
|
|
7153
|
-
} catch {
|
|
7154
|
-
// No compression in this build: send the JSON itself.
|
|
7155
|
-
}
|
|
7156
|
-
}
|
|
7157
|
-
if (json.length > 12000) {
|
|
7158
|
-
delete snapshot.stored;
|
|
7159
|
-
delete snapshot.perf;
|
|
7160
|
-
json = JSON.stringify(snapshot);
|
|
7161
|
-
}
|
|
7162
|
-
return "?m=j&snap=" + encodeURIComponent(json);
|
|
7163
|
-
};
|
|
7141
|
+
// everything it knows and writes the result to disk. POST because a
|
|
7142
|
+
// diagnostic export must not be triggerable by a plain GET.
|
|
7164
7143
|
const exportLog = useCallback(() => {
|
|
7165
7144
|
setLog({ loading: true });
|
|
7166
7145
|
const snapshot = clientSnapshot(value, perf);
|
|
7167
|
-
|
|
7168
|
-
|
|
7146
|
+
fetch(`${API}/log/export`, {
|
|
7147
|
+
method: "POST",
|
|
7148
|
+
headers: { "content-type": "application/json" },
|
|
7149
|
+
credentials: "same-origin",
|
|
7150
|
+
body: JSON.stringify(snapshot)
|
|
7151
|
+
})
|
|
7169
7152
|
.then((response) => response.json())
|
|
7170
7153
|
.then((data) => {
|
|
7171
7154
|
if (!data || data.ok === false) throw new Error(String((data && data.error) || "export failed"));
|
package/client/src/07-styles.js
CHANGED
|
@@ -278,7 +278,9 @@ html[data-lg-mode="dark"] div[data-composer-card] {
|
|
|
278
278
|
* so match on the suffix; the inset hairline keeps the pane edge legible over
|
|
279
279
|
* a busy wallpaper.
|
|
280
280
|
*/
|
|
281
|
-
html[data-lg-enabled="on"] [class*="_sidebarCol"] {
|
|
281
|
+
html[data-lg-enabled="on"][data-lg-module="wallpaper"] [class*="_sidebarCol"] {
|
|
282
|
+
/* Wallpaper module only: the liquid-glass module keeps the plain token
|
|
283
|
+
fill so the shader stays readable through the pane. */
|
|
282
284
|
/* The pane carries the milky floor itself. The shell token stays at
|
|
283
285
|
bare-glass level because the frame and titlebar strip share it. */
|
|
284
286
|
background-color: var(--lg-sidebar-fill, rgba(255, 255, 255, 0.14)) !important;
|
|
@@ -300,7 +302,7 @@ html[data-lg-enabled="on"] [class*="_sidebarCol"] {
|
|
|
300
302
|
* right on top of the brand mark. A pseudo element blurs the same backdrop
|
|
301
303
|
* without becoming the containing block of the pane's children.
|
|
302
304
|
*/
|
|
303
|
-
html[data-lg-enabled="on"] [class*="_sidebarCol"]::before {
|
|
305
|
+
html[data-lg-enabled="on"][data-lg-module="wallpaper"] [class*="_sidebarCol"]::before {
|
|
304
306
|
content: "";
|
|
305
307
|
position: absolute;
|
|
306
308
|
inset: 0;
|
|
@@ -309,7 +311,7 @@ html[data-lg-enabled="on"] [class*="_sidebarCol"]::before {
|
|
|
309
311
|
backdrop-filter: blur(24px) saturate(1.32);
|
|
310
312
|
}
|
|
311
313
|
|
|
312
|
-
html[data-lg-enabled="on"][data-lg-mode="dark"] [class*="_sidebarCol"] {
|
|
314
|
+
html[data-lg-enabled="on"][data-lg-module="wallpaper"][data-lg-mode="dark"] [class*="_sidebarCol"] {
|
|
313
315
|
box-shadow:
|
|
314
316
|
inset 0 1px 0 rgba(255, 255, 255, 0.1),
|
|
315
317
|
inset -0.5px 0 0 rgba(255, 255, 255, 0.06);
|
package/client/src/12-apply.js
CHANGED
|
@@ -1508,6 +1508,8 @@
|
|
|
1508
1508
|
"hw: hdr " +
|
|
1509
1509
|
JSON.stringify({
|
|
1510
1510
|
side: Math.round(sr.left) + "," + Math.round(sr.width),
|
|
1511
|
+
mod: document.documentElement.dataset.lgModule ?? null,
|
|
1512
|
+
fill: own.backgroundColor,
|
|
1511
1513
|
ownBf: own.backdropFilter || "none",
|
|
1512
1514
|
frostBf: frost.backdropFilter || "none",
|
|
1513
1515
|
frostPos: frost.position + "|" + frost.inset,
|
|
@@ -1743,38 +1745,17 @@
|
|
|
1743
1745
|
checkUpdates(false);
|
|
1744
1746
|
}, [checkUpdates]);
|
|
1745
1747
|
// One press, one file: the panel collects the page, the host adds
|
|
1746
|
-
// everything it knows and writes the result to disk.
|
|
1747
|
-
//
|
|
1748
|
-
//
|
|
1749
|
-
// The snapshot travels deflated: a full settings tree plus the stored
|
|
1750
|
-
// copy plus the perf JSON outsized the URL one machine's GET survived,
|
|
1751
|
-
// and the export then quietly lost the page half.
|
|
1752
|
-
const packSnapshot = async (snapshot) => {
|
|
1753
|
-
let json = JSON.stringify(snapshot);
|
|
1754
|
-
if (typeof CompressionStream === "function") {
|
|
1755
|
-
try {
|
|
1756
|
-
const stream = new Blob([json]).stream().pipeThrough(new CompressionStream("deflate-raw"));
|
|
1757
|
-
const bytes = new Uint8Array(await new Response(stream).arrayBuffer());
|
|
1758
|
-
let binary = "";
|
|
1759
|
-
for (let index = 0; index < bytes.length; index += 1) binary += String.fromCharCode(bytes[index]);
|
|
1760
|
-
const b64 = btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1761
|
-
return "?m=d&snap=" + b64;
|
|
1762
|
-
} catch {
|
|
1763
|
-
// No compression in this build: send the JSON itself.
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
if (json.length > 12000) {
|
|
1767
|
-
delete snapshot.stored;
|
|
1768
|
-
delete snapshot.perf;
|
|
1769
|
-
json = JSON.stringify(snapshot);
|
|
1770
|
-
}
|
|
1771
|
-
return "?m=j&snap=" + encodeURIComponent(json);
|
|
1772
|
-
};
|
|
1748
|
+
// everything it knows and writes the result to disk. POST because a
|
|
1749
|
+
// diagnostic export must not be triggerable by a plain GET.
|
|
1773
1750
|
const exportLog = useCallback(() => {
|
|
1774
1751
|
setLog({ loading: true });
|
|
1775
1752
|
const snapshot = clientSnapshot(value, perf);
|
|
1776
|
-
|
|
1777
|
-
|
|
1753
|
+
fetch(`${API}/log/export`, {
|
|
1754
|
+
method: "POST",
|
|
1755
|
+
headers: { "content-type": "application/json" },
|
|
1756
|
+
credentials: "same-origin",
|
|
1757
|
+
body: JSON.stringify(snapshot)
|
|
1758
|
+
})
|
|
1778
1759
|
.then((response) => response.json())
|
|
1779
1760
|
.then((data) => {
|
|
1780
1761
|
if (!data || data.ok === false) throw new Error(String((data && data.error) || "export failed"));
|
package/docs/DETAIL.md
CHANGED
|
@@ -61,9 +61,9 @@ macOS / Linux 仍走 `System Events` / `gsettings` 的静态路径。
|
|
|
61
61
|
|
|
62
62
|
| 文件 | 职责 |
|
|
63
63
|
| --- | --- |
|
|
64
|
-
| `index.js` |
|
|
64
|
+
| `index.js` | `apply()` 与路由装配(/state、/wallpaper、/web/*、/audio/*、/log、/log/export、/gate)、取源顺序、流看门狗与冷却、700 ms TTL |
|
|
65
65
|
| `host/paths.js` | 缓存目录、TTL、各脚本路径、`bin/lg-capture.exe` 位置 |
|
|
66
|
-
| `host/scripts.js` |
|
|
66
|
+
| `host/scripts.js` | 五个内联 PowerShell 兜底脚本(抓屏、探测、合成、门卫、macOS 壁纸) |
|
|
67
67
|
| `host/run.js` | `run` / `runPowerShellFile` 两个进程帮助函数 |
|
|
68
68
|
| `host/helper.js` | 常驻助手:spawn、行协议、捕获、发布、暗帧闸门、`captureStats` |
|
|
69
69
|
| `host/wallpaper.js` | 壁纸探测、Wallpaper Engine 识别、MIME、文件流 |
|
|
@@ -73,12 +73,14 @@ macOS / Linux 仍走 `System Events` / `gsettings` 的静态路径。
|
|
|
73
73
|
| 文件 | 职责 |
|
|
74
74
|
| --- | --- |
|
|
75
75
|
| `client/client.js` | **构建产物**,不要手改;由 `node scripts/build-client.mjs` 生成 |
|
|
76
|
-
| `client/src/01-bootstrap.js` … `
|
|
76
|
+
| `client/src/_prologue.js` + `01-bootstrap.js` … `14-audio.js` + `_epilogue.js` | 按职责切开的 16 个片段,顺序即拼接顺序 |
|
|
77
77
|
| `scripts/build-client.mjs` | 零依赖拼接器(`--check` 只校验不写) |
|
|
78
78
|
|
|
79
79
|
原生助手:`tools/capture/lg-capture.cpp`(C++ / WGC)→ `node scripts/build-capture.mjs` → `bin/lg-capture.exe`。
|
|
80
80
|
|
|
81
|
-
助手不直接跑打包里的 exe:`host/helper.js` 的 `prepareRunCopy()` 会把它按 `大小-mtime` 复制成 `%TEMP%\dsh-liquid-glass\lg-capture-<size>-<mtime>.exe` 再启动,这样重编 `bin/lg-capture.exe` 不会被运行中的进程锁住,也不用先停插件;同版本副本已存在时直接复用。流式运行时宿主不再做按需捕获(`captureStats.streaming` 就接管暂存文件),避免两个捕获者抢同一个 stage。帧率可在不改会话的前提下原地调整:`--serve` 的 `fps <1-30>` 命令只改 `std::atomic<int> fps`,会话与帧池保持存活,因此不会因为调频闪一次捕获边框;宿主按 `/log` 里客户端 `perf:` 的渲染状态调用 `setStreamFps()`(窗口暂停 2 fps、掉帧到目标 60% 以下 4 fps、正常 8 fps)。
|
|
81
|
+
助手不直接跑打包里的 exe:`host/helper.js` 的 `prepareRunCopy()` 会把它按 `大小-mtime` 复制成 `%TEMP%\dsh-liquid-glass\lg-capture-<size>-<mtime>.exe` 再启动,这样重编 `bin/lg-capture.exe` 不会被运行中的进程锁住,也不用先停插件;同版本副本已存在时直接复用。流式运行时宿主不再做按需捕获(`captureStats.streaming` 就接管暂存文件),避免两个捕获者抢同一个 stage。帧率可在不改会话的前提下原地调整:`--serve` 的 `fps <1-30>` 命令只改 `std::atomic<int> fps`,会话与帧池保持存活,因此不会因为调频闪一次捕获边框;宿主按 `/log` 里客户端 `perf:` 的渲染状态调用 `setStreamFps()`(窗口暂停 2 fps、掉帧到目标 60% 以下 4 fps、正常 8 fps)。
|
|
82
|
+
|
|
83
|
+
流式引擎连续 12 帧 `buildFrame` 失败、或连续 5 次编码失败时,会向 stdout 推一行 `{"event":"error",...}`;宿主收到后立即降回按需捕获,并进入 30 s → 60 s → 2 min → 4 min → 8 min → 10 min 的指数冷却。看门狗每 1.1 s 用 `probe` 检查一次「声称在流式」的助手,连续 3 次不应答就停流并回退。冷却期内的 `/state` 直接走按需捕获,不会再每隔 220 ms 重开一次 WGC 会话。
|
|
82
84
|
|
|
83
85
|
## 成本与性能取舍
|
|
84
86
|
|
|
@@ -208,7 +210,7 @@ iOS 26 的 Liquid Glass 是 RenderServer 的 GPU 着色器:SDF(`CASDFLayer`
|
|
|
208
210
|
- WebGL 不可用(驱动 / 远程桌面)时不再有 CSS 壁纸回退:直接进入第五层静态半透明遮罩(不黑屏),并允许 10 分钟内从提示条重试。
|
|
209
211
|
- 面板内部若有硬编码的不透明色,仍会挡住背景;需要 DSH 把该处改成主题 token。
|
|
210
212
|
- 截图先写到 `wallpaper.stage.jpg`,成功后再 `rename()` 覆盖 `wallpaper.jpg`:客户端要么读到上一张完整 JPEG,要么读到新的一张,不会读到写了一半的文件(半写 JPEG 会解码成黑带,看起来就是壁纸闪一下黑)。
|
|
211
|
-
- 桌面捕获依赖 `Windows.Graphics.Capture`(Windows 10 1903
|
|
213
|
+
- 桌面捕获依赖 `Windows.Graphics.Capture`(Windows 10 1903+)。流式引擎失败时会先发 error、宿主降回按需捕获;按需路径的 `Composer::compose()` 仍保留 `PrintWindow` 兜底,所以更老的系统上功能可用,但可能偶发丢壁纸层,建议把「背景来源」切成壁纸本体。0.17 的无边框(`IGraphicsCaptureSession3`)同样要 Windows 11 / 10 20348+,更老的系统上黄色捕获边框会回来(功能不受影响)。
|
|
212
214
|
- 0.16 起闪黑有三道闸门:引擎按住连续的纯暗帧、宿主拒收「突然变暗」的合成帧(`captureError` 里出现 `discarded a dark capture`)、客户端再按「上一张已接受帧」拒收一次(诊断里的 `capture.refused`)。桌面静止时不会周期性地重抓,因此不会周期性闪。
|
|
213
215
|
|
|
214
216
|
|
|
@@ -219,16 +221,16 @@ v.26.11.21.154004 起,设置页的「壁纸引擎」分支直接读本机 Wall
|
|
|
219
221
|
- 路径发现:注册表 HKCU\Software\Valve\Steam 的 SteamPath,加上每个 Steam 库根目录下 steamapps\libraryfolders.vdf 的 path 列表;路径统一清洗(反斜杠、盘符大小写)。
|
|
220
222
|
- 库扫描:<root>\steamapps\workshop\content\431960\<id>\project.json,取 title / type / file / preview / tags;场景缺 file 时回落到 scene.pkg,网页回落到 index.html。
|
|
221
223
|
- 设置读取:WE 安装目录 config.json 的 users.<user>.general.wallpaperconfig.selectedwallpapers.Monitor0.file,用于标记当前壁纸;wproperties 里保留 schemecolor,供后续智能取色使用。
|
|
222
|
-
- 应用:视频项目直接把文件路径作为壁纸来源(source=we&path=…),由 Range
|
|
224
|
+
- 应用:视频项目直接把文件路径作为壁纸来源(source=we&path=…),由 Range 流式读取;网页项目由宿主镜像一个 workshop 文件夹、客户端在 opaque-origin iframe 里本地渲染;场景项目(scene.pkg)没有可读帧,界面明确提示不支持,插件不会调用 `wallpaper64.exe` 替用户切换桌面。
|
|
223
225
|
- 自定义文件:source=file&path=…,图片 / 视频皆可,图片一次性读取、视频 Range 流式读取。
|
|
224
|
-
-
|
|
226
|
+
- 入口:库网格、搜索、类型筛选、刷新;未检测到 WE 时只留 Steam 商店链接,不渲染点击无反应的按钮。
|
|
225
227
|
|
|
226
228
|
## 声临其境(音频矩阵)
|
|
227
229
|
|
|
228
230
|
v.26.11.21.154004 起,设置页新增「声音」分组:
|
|
229
231
|
|
|
230
232
|
- 本地播放列表:客户端 `<audio>` 元素按顺序循环,源走 `/liquid-glass/media?path=…`(Range 流式,不整段读入);支持 mp3 / flac / wav / ogg / m4a / aac / opus,倍速 1.0–2.0、音量 0–1。
|
|
231
|
-
- 系统音频:`
|
|
233
|
+
- 系统音频:`bin/lg-audio.exe` 通过 WASAPI loopback 采集系统混音,做 FFT 后按行输出 128 个频段值;宿主用 SSE 推给页面,只做分析,不接扬声器、不二次播放、不上传。网页壁纸注册 `wallpaperRegisterAudioListener` 时会启动这条链路。
|
|
232
234
|
- 律动:`audioBeat()` 用 RMS×2.1 + 低频能量×0.95 做快攻慢放包络,返回值经 `onBeat` 回调写进两个后端的 `uBeat` uniform;片元着色器把 warp / ripple / caustic / band 四项乘以 `(1 + uBeat × 系数)`,低音落下时液面起伏、高光呼吸。
|
|
233
235
|
- 播放被浏览器自动播放策略拦截时提示「点试听开始播放」,用户点按钮即恢复。
|
|
234
236
|
|
package/host/audio.js
CHANGED
|
@@ -162,8 +162,11 @@ export function startSpectrum() {
|
|
|
162
162
|
// unconditionally there would orphan the new one.
|
|
163
163
|
const child = spectrumChild;
|
|
164
164
|
let pending = '';
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
child.stdout.setEncoding('utf8');
|
|
166
|
+
child.stdout.on('data', (chunk) => {
|
|
167
|
+
// A stop/start pair leaves the old process's buffered stdout pending.
|
|
168
|
+
// Never let it write bins or publish frames for the new helper.
|
|
169
|
+
if (spectrumChild !== child) return;
|
|
167
170
|
pending += chunk;
|
|
168
171
|
const cut = pending.lastIndexOf('\n');
|
|
169
172
|
if (cut < 0) {
|
|
@@ -183,24 +186,29 @@ export function startSpectrum() {
|
|
|
183
186
|
// chain (capture -> FFT -> host -> page -> wallpaper).
|
|
184
187
|
publish();
|
|
185
188
|
});
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
child.stderr.setEncoding('utf8');
|
|
190
|
+
child.stderr.on('data', (chunk) => {
|
|
191
|
+
if (spectrumChild !== child) return;
|
|
188
192
|
const text = String(chunk).trim();
|
|
189
193
|
if (text) spectrum.error = text.slice(0, 240);
|
|
190
194
|
});
|
|
191
195
|
// A helper that dies mid-write can raise EPIPE on either pipe; unhandled that
|
|
192
196
|
// 'error' event is fatal for the whole host, so absorb both and let the exit
|
|
193
197
|
// handler clear the child.
|
|
194
|
-
|
|
195
|
-
|
|
198
|
+
child.stdout.on('error', () => {});
|
|
199
|
+
child.stderr.on('error', () => {});
|
|
196
200
|
child.on('error', (error) => {
|
|
201
|
+
// A newer helper may already be running; only the current one may write.
|
|
202
|
+
if (spectrumChild !== child) return;
|
|
197
203
|
spectrum.error = 'child: ' + ((error && error.message) || error);
|
|
198
|
-
|
|
204
|
+
spectrumChild = null;
|
|
199
205
|
});
|
|
200
206
|
child.on('exit', (code) => {
|
|
201
|
-
|
|
202
|
-
//
|
|
207
|
+
// Check identity before touching shared state: an old helper killed by
|
|
208
|
+
// stopSpectrum() exits with a non-zero code and used to poison the error
|
|
209
|
+
// of the healthy helper that replaced it.
|
|
203
210
|
if (spectrumChild !== child) return;
|
|
211
|
+
if (code) spectrum.error = 'exit ' + code + (spectrum.error ? ': ' + spectrum.error : '');
|
|
204
212
|
spectrum.bins = null;
|
|
205
213
|
spectrumChild = null;
|
|
206
214
|
});
|
package/host/diagnostics.js
CHANGED
|
@@ -28,7 +28,7 @@ function stamp(date = new Date()) {
|
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/** `26.12.5-
|
|
31
|
+
/** The package.json version, e.g. `26.12.5-184625` — the number npm publishes. */
|
|
32
32
|
async function engineVersion() {
|
|
33
33
|
try {
|
|
34
34
|
const raw = await readFile(join(BUNDLE_ROOT, 'package.json'), 'utf8');
|
|
@@ -198,6 +198,13 @@ function formatReport(payload) {
|
|
|
198
198
|
// left the slow PowerShell path doing the work.
|
|
199
199
|
text += line('helper', capture.helper);
|
|
200
200
|
text += line('fallback', capture.fallback);
|
|
201
|
+
text += line('last fallback', capture.lastFallback);
|
|
202
|
+
text += line('last fallback at', capture.lastFallbackAt ? new Date(capture.lastFallbackAt).toISOString() : '');
|
|
203
|
+
text += line('stream failures', capture.streamFailures);
|
|
204
|
+
text += line(
|
|
205
|
+
'stream cooldown ms',
|
|
206
|
+
capture.streamCooldownUntil ? Math.max(0, capture.streamCooldownUntil - Date.now()) : ''
|
|
207
|
+
);
|
|
201
208
|
text += '\n';
|
|
202
209
|
|
|
203
210
|
text += '== wallpaper engine ==\n';
|
package/host/helper.js
CHANGED
|
@@ -43,8 +43,41 @@ export const captureStats = {
|
|
|
43
43
|
helper: '',
|
|
44
44
|
/** What forced the fallback engine, when it was not the helper. */
|
|
45
45
|
fallback: '',
|
|
46
|
+
/** Last fallback reason, kept even after a successful capture for diagnosis. */
|
|
47
|
+
lastFallback: '',
|
|
48
|
+
/** Epoch ms of the last fallback. */
|
|
49
|
+
lastFallbackAt: 0,
|
|
50
|
+
/** Consecutive stream failures; drives the exponential backoff. */
|
|
51
|
+
streamFailures: 0,
|
|
52
|
+
/** Epoch ms before which ensureStreaming() must not try again. */
|
|
53
|
+
streamCooldownUntil: 0,
|
|
46
54
|
};
|
|
47
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Record a live-stream failure and cool the stream off. Retrying every poll
|
|
58
|
+
* opened a fresh WGC session (and blocked /state for two seconds) each time.
|
|
59
|
+
* 30 s, 60 s, 2 min, 4 min, 8 min, then 10 min.
|
|
60
|
+
* @param {string} [reason]
|
|
61
|
+
* @returns {number} cooldown in ms
|
|
62
|
+
*/
|
|
63
|
+
export function markStreamFailure(reason = '') {
|
|
64
|
+
const failures = (captureStats.streamFailures || 0) + 1;
|
|
65
|
+
captureStats.streamFailures = failures;
|
|
66
|
+
const step = Math.min(failures - 1, 5);
|
|
67
|
+
const delay = Math.min(10 * 60_000, 30_000 * 2 ** step);
|
|
68
|
+
captureStats.streamCooldownUntil = Date.now() + delay;
|
|
69
|
+
if (reason) captureStats.error = String(reason).slice(0, 240);
|
|
70
|
+
return delay;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Remember a fallback without losing it when the next capture succeeds. */
|
|
74
|
+
export function noteFallback(reason) {
|
|
75
|
+
const text = String(reason || '').slice(0, 240);
|
|
76
|
+
captureStats.fallback = text;
|
|
77
|
+
captureStats.lastFallback = text;
|
|
78
|
+
captureStats.lastFallbackAt = Date.now();
|
|
79
|
+
}
|
|
80
|
+
|
|
48
81
|
|
|
49
82
|
|
|
50
83
|
|
|
@@ -193,10 +226,13 @@ export async function startHelper() {
|
|
|
193
226
|
message = line.slice(0, 120);
|
|
194
227
|
}
|
|
195
228
|
captureStats.error = 'stream: ' + (message || 'engine reported an error').slice(0, 200);
|
|
196
|
-
|
|
229
|
+
noteFallback('engine failed, on-demand capture resumed');
|
|
197
230
|
captureStats.streaming = false;
|
|
198
231
|
captureStats.live = false;
|
|
199
|
-
|
|
232
|
+
captureStats.fps = 0;
|
|
233
|
+
markStreamFailure();
|
|
234
|
+
// Do not spawn a helper just to tell it to stop.
|
|
235
|
+
if (helperProcess) void helperCommand('stop\n', 3000).catch(() => {});
|
|
200
236
|
continue;
|
|
201
237
|
}
|
|
202
238
|
if (!helperPending) continue;
|
|
@@ -368,6 +404,9 @@ export async function startStreaming(fps = 8, behind = true) {
|
|
|
368
404
|
}
|
|
369
405
|
captureStats.streaming = true;
|
|
370
406
|
captureStats.fps = fps;
|
|
407
|
+
captureStats.streamFailures = 0;
|
|
408
|
+
captureStats.streamCooldownUntil = 0;
|
|
409
|
+
captureStats.error = '';
|
|
371
410
|
streamDropped = 0;
|
|
372
411
|
streamLastAt = Date.now();
|
|
373
412
|
return true;
|
|
@@ -377,6 +416,7 @@ export async function startStreaming(fps = 8, behind = true) {
|
|
|
377
416
|
export async function stopStreaming() {
|
|
378
417
|
captureStats.streaming = false;
|
|
379
418
|
captureStats.live = false;
|
|
419
|
+
captureStats.fps = 0;
|
|
380
420
|
return helperCommand('stop\n', 6000);
|
|
381
421
|
}
|
|
382
422
|
|
|
@@ -480,15 +520,16 @@ export async function captureDesktop(behind = true) {
|
|
|
480
520
|
const stdout = await run(CAPTURE_EXE, [STAGE_IMAGE_PATH, behind ? '1' : '0'], 20_000);
|
|
481
521
|
const parsed = parseCaptureLine(stdout);
|
|
482
522
|
if (parsed) {
|
|
483
|
-
|
|
523
|
+
noteFallback('resident helper failed, one-shot exe worked');
|
|
484
524
|
return publishCapture(parsed, 'native', startedAt);
|
|
485
525
|
}
|
|
486
526
|
captureStats.error = `native capture failed${stdout ? `: ${stdout.slice(0, 200)}` : ''}`;
|
|
487
527
|
// The report has to say which of the two native paths died and why, or a
|
|
488
528
|
// 3.5 s PowerShell fallback looks like the design instead of a failure.
|
|
489
|
-
|
|
529
|
+
noteFallback(
|
|
490
530
|
'helper: ' + (captureStats.helper || (served ? String(served).slice(0, 160) : 'no reply')) +
|
|
491
|
-
'; native: ' + String(captureStats.error).slice(0, 160)
|
|
531
|
+
'; native: ' + String(captureStats.error).slice(0, 160)
|
|
532
|
+
);
|
|
492
533
|
}
|
|
493
534
|
// Fallback: the PowerShell script (250–600 ms of interpreter start-up).
|
|
494
535
|
await writeFile(COMPOSITE_SCRIPT_PATH, COMPOSITE_SCRIPT, 'utf8');
|
package/index.js
CHANGED
|
@@ -31,19 +31,6 @@ const DEFAULT_CONFIG = {
|
|
|
31
31
|
import { createHash } from 'node:crypto';
|
|
32
32
|
import { readFile, stat } from 'node:fs/promises';
|
|
33
33
|
import { basename } from 'node:path';
|
|
34
|
-
import { inflateRawSync } from 'node:zlib';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The panel deflates its snapshot because a raw JSON of a full settings tree
|
|
38
|
-
* plus the stored copy can pass the length a GET URL survives. Base64url in,
|
|
39
|
-
* plain JSON out; a failure is reported, never silently swallowed.
|
|
40
|
-
* @param {string} value
|
|
41
|
-
* @returns {string}
|
|
42
|
-
*/
|
|
43
|
-
function decodeSnapshot(value) {
|
|
44
|
-
const buf = Buffer.from(String(value).replace(/-/g, '+').replace(/_/g, '/'), 'base64');
|
|
45
|
-
return inflateRawSync(buf).toString('utf8');
|
|
46
|
-
}
|
|
47
34
|
|
|
48
35
|
import { CAPTURE_IMAGE_PATH, STATE_TTL_MS } from './host/paths.js';
|
|
49
36
|
import {
|
|
@@ -57,6 +44,8 @@ import {
|
|
|
57
44
|
streamIsLive,
|
|
58
45
|
helperAlive,
|
|
59
46
|
setStreamFps,
|
|
47
|
+
markStreamFailure,
|
|
48
|
+
noteFallback,
|
|
60
49
|
} from './host/helper.js';
|
|
61
50
|
import { detectWallpaper, jsonResponse, kindOf, mimeOf, readWallpaperEngine, streamFile } from './host/wallpaper.js';
|
|
62
51
|
import { checkForUpdates } from './host/update-check.js';
|
|
@@ -90,6 +79,10 @@ export function apply(ctx, config) {
|
|
|
90
79
|
/** Pending start of the live capture loop. */
|
|
91
80
|
/** @type {Promise<boolean> | null} */
|
|
92
81
|
let streamRequest = null;
|
|
82
|
+
/** Consecutive probes a "streaming" helper failed to answer. */
|
|
83
|
+
let streamMisses = 0;
|
|
84
|
+
/** Which compositing mode the current live stream was started with. */
|
|
85
|
+
let streamBehind = null;
|
|
93
86
|
|
|
94
87
|
/** @type {{ at: number, value: any } | null} */
|
|
95
88
|
let captureAt = 0;
|
|
@@ -155,6 +148,24 @@ export function apply(ctx, config) {
|
|
|
155
148
|
return captureInFlight;
|
|
156
149
|
}
|
|
157
150
|
|
|
151
|
+
/** Start the engine and wait for its first frame. */
|
|
152
|
+
async function beginStream(behind) {
|
|
153
|
+
const ok = await startStreaming(STREAM_FPS, behind).catch(() => false);
|
|
154
|
+
if (!ok) {
|
|
155
|
+
markStreamFailure('stream start failed');
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
streamBehind = behind;
|
|
159
|
+
streamMisses = 0;
|
|
160
|
+
// Wait for the first pushed frame so an on-demand capture never races the
|
|
161
|
+
// engine for the staging file.
|
|
162
|
+
for (let i = 0; i < 40; i++) {
|
|
163
|
+
if (streamIsLive()) return true;
|
|
164
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
165
|
+
}
|
|
166
|
+
return captureStats.streaming;
|
|
167
|
+
}
|
|
168
|
+
|
|
158
169
|
/**
|
|
159
170
|
* Start the helper's live capture loop once. While it runs, the helper keeps
|
|
160
171
|
* pushing the newest composed frame instead of the host asking for one, which
|
|
@@ -164,19 +175,28 @@ export function apply(ctx, config) {
|
|
|
164
175
|
async function ensureStreaming(behind) {
|
|
165
176
|
// A dead helper leaves `streaming` set; only a running process can keep it.
|
|
166
177
|
if (captureStats.streaming && !helperAlive()) captureStats.streaming = false;
|
|
178
|
+
// The engine is configured with `behind` at start time. A toggle must stop
|
|
179
|
+
// the old engine and start a new one, or the checkbox looks dead.
|
|
180
|
+
if (captureStats.streaming && streamBehind !== null && streamBehind !== behind) {
|
|
181
|
+
if (streamRequest) return streamRequest;
|
|
182
|
+
streamRequest = (async () => {
|
|
183
|
+
await stopStreaming().catch(() => {});
|
|
184
|
+
streamBehind = null;
|
|
185
|
+
return beginStream(behind);
|
|
186
|
+
})();
|
|
187
|
+
try {
|
|
188
|
+
return await streamRequest;
|
|
189
|
+
} finally {
|
|
190
|
+
streamRequest = null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
167
193
|
if (captureStats.streaming) return true;
|
|
194
|
+
// A stream that just failed gets a cooling-off period. Retrying on every
|
|
195
|
+
// 220 ms poll opened a fresh WGC session (and blocked /state for two
|
|
196
|
+
// seconds) each time; on-demand capture keeps the wallpaper alive instead.
|
|
197
|
+
if (Date.now() < (captureStats.streamCooldownUntil || 0)) return false;
|
|
168
198
|
if (streamRequest) return streamRequest;
|
|
169
|
-
streamRequest = (
|
|
170
|
-
const ok = await startStreaming(STREAM_FPS, behind).catch(() => false);
|
|
171
|
-
if (!ok) return false;
|
|
172
|
-
// Wait for the first pushed frame so an on-demand capture never races the
|
|
173
|
-
// engine for the staging file.
|
|
174
|
-
for (let i = 0; i < 40; i++) {
|
|
175
|
-
if (streamIsLive()) return true;
|
|
176
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
177
|
-
}
|
|
178
|
-
return captureStats.streaming;
|
|
179
|
-
})();
|
|
199
|
+
streamRequest = beginStream(behind);
|
|
180
200
|
try {
|
|
181
201
|
return await streamRequest;
|
|
182
202
|
} finally {
|
|
@@ -215,9 +235,6 @@ export function apply(ctx, config) {
|
|
|
215
235
|
return captureOnce(behind);
|
|
216
236
|
}
|
|
217
237
|
|
|
218
|
-
/** Consecutive probes a "streaming" helper failed to answer. */
|
|
219
|
-
let streamMisses = 0;
|
|
220
|
-
|
|
221
238
|
/** Poll the cheap fingerprint so a window switch is picked up within ~1 s. */
|
|
222
239
|
function startDesktopWatch() {
|
|
223
240
|
if (desktopWatcher) return;
|
|
@@ -237,10 +254,11 @@ export function apply(ctx, config) {
|
|
|
237
254
|
streamMisses += 1;
|
|
238
255
|
if (streamMisses < 3) return;
|
|
239
256
|
streamMisses = 0;
|
|
240
|
-
|
|
241
|
-
|
|
257
|
+
markStreamFailure('stream stopped answering, falling back to on-demand capture');
|
|
258
|
+
noteFallback('stream watchdog');
|
|
242
259
|
captureStats.streaming = false;
|
|
243
260
|
captureStats.live = false;
|
|
261
|
+
captureStats.fps = 0;
|
|
244
262
|
void stopStreaming().catch(() => {});
|
|
245
263
|
void captureIfChanged(captureBehind ?? true).catch(() => {});
|
|
246
264
|
});
|
|
@@ -495,8 +513,14 @@ export function apply(ctx, config) {
|
|
|
495
513
|
streamFps: captureStats.fps || 0,
|
|
496
514
|
streamFrames: captureStats.frames || 0,
|
|
497
515
|
streamDropped: streamDropCount(),
|
|
516
|
+
streamFailures: captureStats.streamFailures || 0,
|
|
517
|
+
streamCooldownMs: Math.max(0, (captureStats.streamCooldownUntil || 0) - Date.now()),
|
|
498
518
|
borderless: captureStats.borderless,
|
|
499
519
|
captureError: captureStats.error,
|
|
520
|
+
captureHelper: captureStats.helper,
|
|
521
|
+
captureFallback: captureStats.fallback,
|
|
522
|
+
captureLastFallback: captureStats.lastFallback,
|
|
523
|
+
captureLastFallbackAt: captureStats.lastFallbackAt || 0,
|
|
500
524
|
clientError: lastClientError,
|
|
501
525
|
clientOverlayError: lastClientOverlay,
|
|
502
526
|
clientReady: lastClientReady,
|
|
@@ -518,35 +542,29 @@ export function apply(ctx, config) {
|
|
|
518
542
|
kind: 'exact',
|
|
519
543
|
path: '/liquid-glass/log/export',
|
|
520
544
|
resource: async (request) => {
|
|
545
|
+
// A GET used to write a file (and inflate an attacker-controlled query).
|
|
546
|
+
// The panel now POSTs the snapshot; anything else is refused.
|
|
547
|
+
if (String(request.method || 'GET').toUpperCase() !== 'POST') {
|
|
548
|
+
return jsonResponse({ ok: false, error: 'POST required' }, 405);
|
|
549
|
+
}
|
|
521
550
|
try {
|
|
522
551
|
let client = {};
|
|
523
552
|
let raw = '';
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
enc = parsedUrl.searchParams.get('m') === 'd' ? 'd' : 'j';
|
|
529
|
-
raw = parsedUrl.searchParams.get('snap') ?? '';
|
|
530
|
-
seen = 'snap=' + raw.length + ' m=' + enc;
|
|
531
|
-
} catch {
|
|
532
|
-
// No query string: fall through to the body.
|
|
533
|
-
}
|
|
534
|
-
if (raw && enc === 'd') {
|
|
535
|
-
try {
|
|
536
|
-
raw = decodeSnapshot(raw);
|
|
537
|
-
seen += ' inflated=' + raw.length;
|
|
538
|
-
} catch (error) {
|
|
539
|
-
client = { snapshotDecodeError: String(error instanceof Error ? error.message : error) };
|
|
540
|
-
raw = '';
|
|
541
|
-
}
|
|
553
|
+
// Refuse an oversized body before reading it, not after it is in memory.
|
|
554
|
+
const declared = Number(request.headers?.get?.('content-length') || 0);
|
|
555
|
+
if (declared > 4 * 1024 * 1024) {
|
|
556
|
+
return jsonResponse({ ok: false, error: 'snapshot too large' }, 413);
|
|
542
557
|
}
|
|
543
|
-
if (
|
|
558
|
+
if (typeof request.text === 'function') {
|
|
544
559
|
try {
|
|
545
560
|
raw = (await request.text()) || '';
|
|
546
561
|
} catch {
|
|
547
562
|
// An unreadable body only costs the client snapshot.
|
|
548
563
|
}
|
|
549
564
|
}
|
|
565
|
+
if (raw.length > 4 * 1024 * 1024) {
|
|
566
|
+
return jsonResponse({ ok: false, error: 'snapshot too large' }, 413);
|
|
567
|
+
}
|
|
550
568
|
if (raw) {
|
|
551
569
|
try {
|
|
552
570
|
client = JSON.parse(raw);
|
|
@@ -591,7 +609,7 @@ export function apply(ctx, config) {
|
|
|
591
609
|
config: options,
|
|
592
610
|
},
|
|
593
611
|
client,
|
|
594
|
-
{ received:
|
|
612
|
+
{ received: raw ? `post body ${raw.length}` : 'no snapshot' }
|
|
595
613
|
);
|
|
596
614
|
return jsonResponse({
|
|
597
615
|
ok: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-theme-engine",
|
|
3
|
-
"version": "26.12.5-
|
|
3
|
+
"version": "26.12.5-185500",
|
|
4
4
|
"description": "Live wallpaper + liquid-glass background for DeepSeek Harness: native desktop capture, 0.8-grade water shader, contrast-driven adaptive ink, frost-density and tint controls, hardware-adaptive profiles, occluded-window compositing, WebGL/WebGPU backends, five-layer performance guard.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "index.js",
|
|
16
|
+
"os": [
|
|
17
|
+
"win32"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
16
22
|
"exports": {
|
|
17
23
|
".": "./index.js",
|
|
18
24
|
"./client": "./client/client.js",
|
|
@@ -24,7 +30,10 @@
|
|
|
24
30
|
"scripts": {
|
|
25
31
|
"build": "node scripts/build-client.mjs",
|
|
26
32
|
"build:client": "node scripts/build-client.mjs",
|
|
27
|
-
"build:capture": "node scripts/build-capture.mjs"
|
|
33
|
+
"build:capture": "node scripts/build-capture.mjs",
|
|
34
|
+
"build:audio": "node scripts/build-audio.mjs",
|
|
35
|
+
"check": "node scripts/build-client.mjs --check",
|
|
36
|
+
"test": "node --test tests/version.test.mjs tests/helper.test.mjs tests/wallpaper.test.mjs"
|
|
28
37
|
},
|
|
29
38
|
"files": [
|
|
30
39
|
"README.md",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Builds bin/lg-audio.exe from tools/audio/lg-audio.cpp.
|
|
2
|
+
//
|
|
3
|
+
// Like the capture helper, the audio helper ships prebuilt, so it has to be
|
|
4
|
+
// self-contained: a dynamic libstdc++/libgcc would fail on any machine without
|
|
5
|
+
// MSYS2 on PATH. LG_OUT can redirect the output for a test build.
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
7
|
+
import { existsSync, mkdirSync, statSync } from 'node:fs';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
|
|
11
|
+
const root = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
12
|
+
const source = join(root, 'tools', 'audio', 'lg-audio.cpp');
|
|
13
|
+
const output = process.env.LG_OUT || join(root, 'bin', 'lg-audio.exe');
|
|
14
|
+
const linkLibraries = ['-lole32', '-luuid'];
|
|
15
|
+
|
|
16
|
+
function findCompiler() {
|
|
17
|
+
const explicit = process.env.LG_CLANG;
|
|
18
|
+
const candidates = [
|
|
19
|
+
explicit,
|
|
20
|
+
'D:\\msys64\\ucrt64\\bin\\clang++.exe',
|
|
21
|
+
'C:\\msys64\\ucrt64\\bin\\clang++.exe',
|
|
22
|
+
'clang++',
|
|
23
|
+
'g++',
|
|
24
|
+
].filter(Boolean);
|
|
25
|
+
for (const candidate of candidates) {
|
|
26
|
+
if (candidate.includes('\\') || candidate.includes('/')) {
|
|
27
|
+
if (existsSync(candidate)) return candidate;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
execFileSync(candidate, ['--version'], { stdio: 'ignore' });
|
|
32
|
+
return candidate;
|
|
33
|
+
} catch {
|
|
34
|
+
// Try the next candidate.
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!existsSync(source)) {
|
|
41
|
+
console.error(`missing source: ${source}`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const compiler = findCompiler();
|
|
45
|
+
if (!compiler) {
|
|
46
|
+
console.error('no C++ compiler found; set LG_CLANG to the clang++/g++ binary');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
mkdirSync(dirname(output), { recursive: true });
|
|
51
|
+
const args = [
|
|
52
|
+
'-std=c++20',
|
|
53
|
+
'-O2',
|
|
54
|
+
'-static',
|
|
55
|
+
'-static-libgcc',
|
|
56
|
+
'-static-libstdc++',
|
|
57
|
+
'-s',
|
|
58
|
+
'-o',
|
|
59
|
+
output,
|
|
60
|
+
source,
|
|
61
|
+
...linkLibraries,
|
|
62
|
+
];
|
|
63
|
+
console.log(`${compiler} ${args.join(' ')}`);
|
|
64
|
+
execFileSync(compiler, args, { stdio: 'inherit' });
|
|
65
|
+
const { size } = statSync(output);
|
|
66
|
+
console.log(`built ${output} (${size.toLocaleString('en-US')} bytes)`);
|