wallpaper-engine-dsh 0.1.0 → 0.1.2
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.md +40 -67
- package/README.zh.md +39 -68
- package/lib/client.js +571 -143
- package/lib/core.js +96 -4
- package/lib/index.js +32 -69
- package/package.json +17 -2
package/README.md
CHANGED
|
@@ -2,56 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
A DSH bundle that
|
|
5
|
+
A DSH bundle that turns your local **Wallpaper Engine** library into the live background of the DSH web GUI (`dsh web`). Video wallpapers play behind the chat, web wallpapers render in place, and scene/application wallpapers join in as still images — with crossfade transitions, liquid-glass panels, rotation lists, search, a resource monitor, and a bilingual UI.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Features
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| WE type | Rendered by | Portable to DSH? |
|
|
17
|
-
|---|---|---|
|
|
18
|
-
| **Scene** | WE's own 3D engine | ❌ native shaders/objects |
|
|
19
|
-
| **Video** | a plain media file | ✅ plays in `<video>` |
|
|
20
|
-
| **Web** | HTML + assets | ✅ loads in a sandboxed `<iframe>` |
|
|
21
|
-
| **Application** | an injected external window | ❌ |
|
|
22
|
-
|
|
23
|
-
Unlike simpler integrations, **multi-file Web wallpapers work here**: the host serves a wallpaper's bundled sub-assets (`js`/`css`/images) from inside its project directory, with strict containment checks.
|
|
24
|
-
|
|
25
|
-
## Architecture
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
┌───────────────────────────── DSH web ─────────────────────────────┐
|
|
29
|
-
│ Browser half (lib/client.js) │
|
|
30
|
-
│ settings.general.item slot → picker UI (grid, sliders, lists) │
|
|
31
|
-
│ fixed layer behind the app frame → <video> / sandboxed iframe │
|
|
32
|
-
└──────────────▲────────────────────────────────────────────────────┘
|
|
33
|
-
│ same-origin HTTP
|
|
34
|
-
┌──────────────┴────────────────────────────────────────────────────┐
|
|
35
|
-
│ Host half (lib/index.js, Cordis plugin, inject: ['webServer']) │
|
|
36
|
-
│ GET /we-background/inventory[?refresh=1] JSON + cached 30 s │
|
|
37
|
-
│ GET /we-background/media/<token>[/asset…] Range + containment │
|
|
38
|
-
│ GET /we-background/preview/<token> preview image │
|
|
39
|
-
└──────────────▲────────────────────────────────────────────────────┘
|
|
40
|
-
│ pure functions
|
|
41
|
-
┌──────────────┴────────────────────────────────────────────────────┐
|
|
42
|
-
│ Core (lib/core.js) — tested │
|
|
43
|
-
│ VDF parser · Steam discovery · project validation · playlists │
|
|
44
|
-
│ Range parsing · path containment · MIME │
|
|
45
|
-
└───────────────────────────────────────────────────────────────────┘
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Security model
|
|
49
|
-
|
|
50
|
-
- **Random tokens, not encoded paths.** Media URLs carry a 72-bit random token minted per inventory build; knowing a filesystem path grants nothing. Rebuilding the inventory re-mints every token.
|
|
51
|
-
- **Double containment.** `project.json`-declared files must resolve inside their project directory, and web-wallpaper sub-assets must resolve inside the project dir (`..` → 403).
|
|
52
|
-
- **Sandboxed web wallpapers.** Third-party wallpaper JS runs in an iframe with `sandbox="allow-scripts"` (no `allow-same-origin`) and `referrerpolicy="no-referrer"` — an opaque origin that cannot touch DSH storage, cookies, or APIs.
|
|
53
|
-
- **Loopback + nosniff.** All responses are same-origin with `X-Content-Type-Options: nosniff`.
|
|
54
|
-
- Only enumerated files are ever served; there is no arbitrary-file route.
|
|
9
|
+
- **Whole-library browsing** — video and web wallpapers render live; scene and application wallpapers show their preview as a static background. Everything with a preview or playable file is selectable, badged by type (Video / Web / Still).
|
|
10
|
+
- **Search** — filter the grid instantly by title or workshop id.
|
|
11
|
+
- **Rotation lists** — any number of carousel lists, each with its own wallpapers, interval (1–120 min) and order (sequence/random). Your first playable Wallpaper Engine playlist is imported automatically; others can be imported into any list.
|
|
12
|
+
- **Four live sliders** — wallpaper blur, scrim, border contrast, and glass frosting, all instant and persisted.
|
|
13
|
+
- **Resource monitor** — FPS readout with a low-framerate hint, plus auto-pause when the tab is hidden or the battery runs low (both optional).
|
|
14
|
+
- **Bilingual** — the settings UI follows the shell's Language preference (Chinese/English), with a manual override in the picker.
|
|
15
|
+
- **Crossfade** — wallpaper switches and clearing fade smoothly instead of snapping.
|
|
55
16
|
|
|
56
17
|
## Install
|
|
57
18
|
|
|
@@ -59,49 +20,61 @@ Unlike simpler integrations, **multi-file Web wallpapers work here**: the host s
|
|
|
59
20
|
dsh plugin --profile web add wallpaper-engine-dsh
|
|
60
21
|
```
|
|
61
22
|
|
|
62
|
-
|
|
23
|
+
Or from a checkout (live-linked for development):
|
|
63
24
|
|
|
64
25
|
```sh
|
|
65
26
|
git clone https://github.com/Weilv-D/wallpaper-engine-dsh.git
|
|
66
27
|
dsh plugin --profile web add link:<absolute path to the cloned folder>
|
|
67
28
|
```
|
|
68
29
|
|
|
69
|
-
Restart `dsh web`, then open **Settings → General →
|
|
30
|
+
Restart `dsh web`, then open **Settings → General → Wallpaper Engine**.
|
|
70
31
|
|
|
71
32
|
## Usage
|
|
72
33
|
|
|
73
|
-
1. Pick a
|
|
74
|
-
2.
|
|
75
|
-
3.
|
|
76
|
-
4.
|
|
77
|
-
5. The
|
|
34
|
+
1. Pick a wallpaper from the thumbnail grid — it fades in behind the app. Use the search box to narrow large libraries.
|
|
35
|
+
2. **Pause/Play** controls video playback; **Close** fades the wallpaper out; **Refresh** rescans the library (new workshop subscriptions appear without reloading the page).
|
|
36
|
+
3. Tune the blend with the sliders. On busy wallpapers, raise **Scrim** and **Borders** until text is comfortable; the UI follows DSH's light/dark theme automatically.
|
|
37
|
+
4. Create rotation lists with **New**, fill them from the grid or import a WE playlist, then enable **Auto-rotate**.
|
|
38
|
+
5. The resource row shows the current frame rate and offers two auto-pause switches. `prefers-reduced-motion` starts videos paused.
|
|
39
|
+
6. The Language control switches the picker between Chinese and English; on Auto it follows the shell setting.
|
|
40
|
+
|
|
41
|
+
Your selection persists in the browser's `localStorage`.
|
|
42
|
+
|
|
43
|
+
## How it works
|
|
44
|
+
|
|
45
|
+
The bundle has two halves:
|
|
78
46
|
|
|
79
|
-
|
|
47
|
+
- A **host plugin** discovers the Wallpaper Engine install (Steam registry entry, `libraryfolders.vdf`, standard probe paths across Windows/macOS/Linux), enumerates projects from the default/my-projects folders and the workshop, and serves a JSON inventory plus the media bytes over same-origin routes:
|
|
48
|
+
- `GET /we-background/inventory[?refresh=1]`
|
|
49
|
+
- `GET /we-background/media/<token>[/asset…]` — with HTTP Range support for video seeking; web wallpapers can fetch their bundled sub-assets
|
|
50
|
+
- `GET /we-background/preview/<token>`
|
|
51
|
+
- A **browser plugin** renders the chosen wallpaper on a fixed layer behind the app frame, contributes the settings UI, and keeps every effect on DSH design tokens so themes apply cleanly.
|
|
52
|
+
|
|
53
|
+
The host answers from a 30-second inventory cache; discovery is resolved once at startup and reused. The bundle registers no model tools and adds no prompt text.
|
|
80
54
|
|
|
81
55
|
## Limitations
|
|
82
56
|
|
|
83
|
-
- Scene and
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
- The glass effect rides DSH design tokens; a shell redesign that renames tokens degrades the frosting gracefully (transparency stays, blur may drop).
|
|
57
|
+
- Scene and application wallpapers render as still images; their live animation remains Wallpaper Engine's desktop job.
|
|
58
|
+
- Web wallpapers run isolated from the page's storage, so ones that persist state across loads won't keep it.
|
|
59
|
+
- The glass effect reads DSH design tokens; if a future shell redesign renames them, frosting degrades to plain transparency.
|
|
87
60
|
|
|
88
61
|
## Development
|
|
89
62
|
|
|
90
63
|
```sh
|
|
91
|
-
npm install #
|
|
64
|
+
npm install # builds lib/client.js via the prepare hook
|
|
92
65
|
npm test # unit tests for the pure core (node:test)
|
|
93
66
|
npm run build # regenerate lib/client.js from src/client.js
|
|
94
67
|
npm run verify # boot the emitted bundle in a vm sandbox and assert behaviour
|
|
95
68
|
```
|
|
96
69
|
|
|
97
|
-
`lib/core.js`
|
|
70
|
+
Layout: `lib/core.js` (pure, tested logic), `lib/index.js` (host plugin), `src/client.js` (browser source) → `lib/client.js` (built artifact; do not hand-edit). `npm run prepublishOnly` runs the full gate: test → build → verify.
|
|
98
71
|
|
|
99
72
|
## Releasing
|
|
100
73
|
|
|
101
|
-
|
|
74
|
+
Releases publish automatically via GitHub Actions and npm Trusted Publishing (OIDC, no stored tokens). One command does everything locally:
|
|
102
75
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
76
|
+
```sh
|
|
77
|
+
npm run release # patch bump; also release:minor / release:major
|
|
78
|
+
```
|
|
106
79
|
|
|
107
|
-
|
|
80
|
+
It bumps `version`, commits, tags `v<version>`, and pushes both. The tag push triggers the publish workflow: full gate → tag ↔ version check → `npm publish --provenance` → the GitHub Release is created automatically with generated notes.
|
package/README.zh.md
CHANGED
|
@@ -2,56 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
一个 DSH bundle:把本机 **Wallpaper Engine**
|
|
5
|
+
一个 DSH bundle:把本机 **Wallpaper Engine** 壁纸库变成 DSH web GUI(`dsh web`)的动态背景。视频壁纸在聊天界面背后播放,网页壁纸原地渲染,场景/应用壁纸以预览图作为静态背景——带交叉淡入、液态玻璃面板、轮播列表、搜索和资源监控。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 功能
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| WE 类型 | 渲染方 | 可移植到 DSH? |
|
|
17
|
-
|---|---|---|
|
|
18
|
-
| **Scene** | WE 自有 3D 引擎 | ❌ 原生 shader/模型 |
|
|
19
|
-
| **Video** | 普通媒体文件 | ✅ `<video>` 直接播放 |
|
|
20
|
-
| **Web** | HTML + 资源 | ✅ 沙箱 `<iframe>` 加载 |
|
|
21
|
-
| **Application** | 注入的外部窗口 | ❌ |
|
|
22
|
-
|
|
23
|
-
与更简单的集成不同,**多文件 Web 壁纸在这里可以正常工作**:宿主会服务项目目录内打包的子资源(`js`/`css`/图片),并做严格的路径约束检查。
|
|
24
|
-
|
|
25
|
-
## 架构
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
┌───────────────────────────── DSH web ─────────────────────────────┐
|
|
29
|
-
│ 浏览器半端(lib/client.js) │
|
|
30
|
-
│ settings.general.item 槽位 → 选择器 UI(网格、滑杆、列表) │
|
|
31
|
-
│ 应用框架之下的固定层 → <video> / 沙箱 iframe │
|
|
32
|
-
└──────────────▲────────────────────────────────────────────────────┘
|
|
33
|
-
│ 同源 HTTP
|
|
34
|
-
┌──────────────┴────────────────────────────────────────────────────┐
|
|
35
|
-
│ 宿主半端(lib/index.js,Cordis 插件,inject: ['webServer']) │
|
|
36
|
-
│ GET /we-background/inventory[?refresh=1] JSON,缓存 30 秒 │
|
|
37
|
-
│ GET /we-background/media/<token>[/资源…] Range + 路径约束 │
|
|
38
|
-
│ GET /we-background/preview/<token> 预览图 │
|
|
39
|
-
└──────────────▲────────────────────────────────────────────────────┘
|
|
40
|
-
│ 纯函数
|
|
41
|
-
┌──────────────┴────────────────────────────────────────────────────┐
|
|
42
|
-
│ 核心层(lib/core.js)—— 有测试 │
|
|
43
|
-
│ VDF 解析 · Steam 发现 · 项目校验 · 播放列表 │
|
|
44
|
-
│ Range 解析 · 路径约束 · MIME │
|
|
45
|
-
└───────────────────────────────────────────────────────────────────┘
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## 安全模型
|
|
49
|
-
|
|
50
|
-
- **随机 token,不是路径编码。** 媒体 URL 携带每次构建清单时铸造的 72 位随机 token;知道文件系统路径没有任何用处。重建清单会重新铸造全部 token,旧 URL 即刻失效。
|
|
51
|
-
- **双重路径约束。** `project.json` 声明的文件必须解析在项目目录内;Web 壁纸的子资源同样必须解析在项目目录内(`..` 穿越返回 403)。
|
|
52
|
-
- **Web 壁纸沙箱化。** 第三方壁纸 JS 运行在 `sandbox="allow-scripts"`(不含 `allow-same-origin`)且 `referrerpolicy="no-referrer"` 的 iframe 中——不透明源,无法触碰 DSH 的存储、Cookie 或 API。
|
|
53
|
-
- **回环 + nosniff。** 全部响应同源,携带 `X-Content-Type-Options: nosniff`。
|
|
54
|
-
- 只有被枚举过的文件可被服务,不存在任意文件路由。
|
|
9
|
+
- **全库浏览** —— 视频与网页壁纸动态渲染;场景与应用壁纸显示预览图作为静态背景。凡是有预览图或可播放文件的壁纸都可选用,按类型标注角标(视频 / 网页 / 静态)。
|
|
10
|
+
- **搜索** —— 按标题或创意工坊 ID 即时筛选网格。
|
|
11
|
+
- **轮播列表** —— 可建任意多个列表,各自拥有壁纸集合、切换间隔(1–120 分钟)和顺序(顺序/随机)。首次运行自动导入第一个可播放的 Wallpaper Engine 播放列表,其余列表可随时导入。
|
|
12
|
+
- **四个实时滑杆** —— 壁纸模糊、暗化、边框对比、玻璃磨砂,即时生效并持久保存。
|
|
13
|
+
- **资源监控** —— 帧率读数与低帧率提示,页面隐藏或电量不足时自动暂停(均可开关)。
|
|
14
|
+
- **中英双语** —— 设置界面跟随 DSH 的"语言"偏好自动切换,也可在面板内手动指定。
|
|
15
|
+
- **交叉淡入** —— 切换与关闭都平滑过渡,不生硬跳变。
|
|
55
16
|
|
|
56
17
|
## 安装
|
|
57
18
|
|
|
@@ -59,31 +20,43 @@
|
|
|
59
20
|
dsh plugin --profile web add wallpaper-engine-dsh
|
|
60
21
|
```
|
|
61
22
|
|
|
62
|
-
|
|
23
|
+
或从源码检出安装(便于开发,改动即时生效):
|
|
63
24
|
|
|
64
25
|
```sh
|
|
65
26
|
git clone https://github.com/Weilv-D/wallpaper-engine-dsh.git
|
|
66
27
|
dsh plugin --profile web add link:<克隆文件夹的绝对路径>
|
|
67
28
|
```
|
|
68
29
|
|
|
69
|
-
重启 `dsh web
|
|
30
|
+
重启 `dsh web`,打开 **设置 → 通用 → 壁纸背景 (Wallpaper Engine)**。
|
|
70
31
|
|
|
71
32
|
## 使用
|
|
72
33
|
|
|
73
|
-
1.
|
|
74
|
-
2. **暂停/播放**
|
|
75
|
-
3.
|
|
76
|
-
4.
|
|
77
|
-
5.
|
|
34
|
+
1. 从缩略图网格选择壁纸,它会在界面背后淡入。壁纸库较大时用搜索框快速定位。
|
|
35
|
+
2. **暂停/播放** 控制视频播放;**关闭** 淡出壁纸;**刷新** 重新扫描壁纸库,新订阅的创意工坊壁纸无需刷新页面即可出现。
|
|
36
|
+
3. 用滑杆调节融合效果。壁纸太花时调高 **暗化** 和 **边框** 直到文字清晰;界面跟随 DSH 明暗主题自动适配。
|
|
37
|
+
4. 用 **新建** 创建轮播列表,从网格挑选或导入 WE 播放列表,然后开启 **自动轮转**。
|
|
38
|
+
5. 资源行显示当前帧率,并提供两个自动暂停开关。系统开启 `prefers-reduced-motion` 时视频默认暂停。
|
|
39
|
+
6. "语言"控件在中英文之间切换面板;选"自动"则跟随 DSH 的语言设置。
|
|
40
|
+
|
|
41
|
+
选择持久化在浏览器的 `localStorage` 中。
|
|
42
|
+
|
|
43
|
+
## 工作原理
|
|
44
|
+
|
|
45
|
+
bundle 分为两半:
|
|
78
46
|
|
|
79
|
-
|
|
47
|
+
- **宿主插件** 负责发现 Wallpaper Engine 安装位置(Steam 注册表项、`libraryfolders.vdf`、Windows/macOS/Linux 标准探测路径),从默认项目、我的项目和创意工坊目录枚举壁纸,并通过同源路由提供 JSON 清单与媒体数据:
|
|
48
|
+
- `GET /we-background/inventory[?refresh=1]`
|
|
49
|
+
- `GET /we-background/media/<token>[/资源…]` —— 支持 HTTP Range,视频可拖动进度;网页壁纸可加载其打包的子资源
|
|
50
|
+
- `GET /we-background/preview/<token>`
|
|
51
|
+
- **浏览器插件** 把选中的壁纸渲染在应用框架之下的固定层,提供设置界面,所有视觉效果都读 DSH 设计令牌,主题切换自然生效。
|
|
52
|
+
|
|
53
|
+
清单由宿主缓存 30 秒;安装发现只解析一次。本插件不注册模型工具,不占用 prompt。
|
|
80
54
|
|
|
81
55
|
## 限制
|
|
82
56
|
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
- 玻璃效果依托 DSH 设计令牌;若外壳重构重命名令牌,效果会优雅降级(透明度保留,模糊可能消失)。
|
|
57
|
+
- 场景与应用壁纸以静态图呈现,其动态渲染仍是 Wallpaper Engine 桌面的职责。
|
|
58
|
+
- 网页壁纸与页面存储隔离,需要跨加载保存状态的壁纸无法保留状态。
|
|
59
|
+
- 玻璃效果读 DSH 设计令牌;若未来外壳重构重命名令牌,磨砂会退化为普通半透明。
|
|
87
60
|
|
|
88
61
|
## 开发
|
|
89
62
|
|
|
@@ -94,16 +67,14 @@ npm run build # 从 src/client.js 重新生成 lib/client.js
|
|
|
94
67
|
npm run verify # 在 vm 沙箱中启动产物并断言行为
|
|
95
68
|
```
|
|
96
69
|
|
|
97
|
-
|
|
70
|
+
目录结构:`lib/core.js`(纯逻辑,有测试)、`lib/index.js`(宿主插件)、`src/client.js`(浏览器源码)→ `lib/client.js`(构建产物,请勿手改)。`npm run prepublishOnly` 执行完整门禁:test → build → verify。
|
|
98
71
|
|
|
99
72
|
## 发布
|
|
100
73
|
|
|
101
|
-
发布由 GitHub Actions
|
|
102
|
-
|
|
103
|
-
1. 提升 `package.json` 的 `version` 并推送。
|
|
104
|
-
2. 创建 tag 为 `v<版本号>` 的 GitHub Release(必须与 `package.json` 一致)。
|
|
105
|
-
3. 工作流自动跑完整门禁、校验 tag ↔ 版本号,并带 `--provenance` 溯源发布。
|
|
74
|
+
发布由 GitHub Actions 通过 npm Trusted Publishing(OIDC,无需存储令牌)自动完成。本地只需一条命令:
|
|
106
75
|
|
|
107
|
-
|
|
76
|
+
```sh
|
|
77
|
+
npm run release # 补丁版本;另有 release:minor / release:major
|
|
78
|
+
```
|
|
108
79
|
|
|
109
|
-
|
|
80
|
+
它会提升版本号、提交、打 `v<版本号>` 标签并一并推送。标签推送触发发布工作流:完整门禁 → 校验标签与版本一致 → `npm publish --provenance` → 自动创建带更新说明的 GitHub Release。
|