dsh-any-background 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tkingxiao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # dsh-any-background
2
+
3
+ <a href="https://github.com/Tkingxiao/dsh-any-background" target="_blank">
4
+ <img src="https://img.shields.io/github/stars/Tkingxiao/dsh-any-background?style=social" alt="GitHub stars" />
5
+ </a>
6
+
7
+ English | [中文](README.zh.md)
8
+
9
+ A **DeepSeek Harness** appearance plugin that lets you fully customize the Web UI with a custom theme color, background wallpaper, and fine-grained opacity controls.
10
+
11
+ <p align="center">
12
+ <a href="https://star-history.com/#/Tkingxiao/dsh-any-background" target="_blank">
13
+ <img src="https://api.star-history.com/svg?repos=Tkingxiao/dsh-any-background&type=Date" alt="Star History Chart" width="600" />
14
+ </a>
15
+ </p>
16
+
17
+ ---
18
+
19
+ ## Features
20
+
21
+ - **PS-style Color Wheel** — Pick hue on the ring, adjust saturation & lightness in the inscribed square. Generates a full set of 30+ CSS design tokens in real time and applies them instantly.
22
+ - **Background Wallpaper** — Choose any image as your wallpaper. Drag to pan, scroll to zoom inside a viewport-proportional editor. What you see is what you get.
23
+ - **Opacity Controls** — Separate sliders for main interface background opacity, settings panel opacity, and wallpaper opacity.
24
+ - **Blur Effect** — Adjustable wallpaper blur (0–60 px) for a frosted-glass look.
25
+ - **Persistent** — All settings (color, wallpaper, opacity, blur, editor position) are saved to `localStorage` and restored on next launch.
26
+ - **Bilingual** — Full Chinese / English UI with automatic locale detection.
27
+ - **Theme Watchdog** — A background watchdog re-asserts the custom theme if the host resets it, so your pick never silently disappears.
28
+
29
+ ## Project Structure
30
+
31
+ ```
32
+ dsh-any-background/
33
+ ├── package.json # Package metadata, dsh.client declaration, dependencies
34
+ ├── cordis.patch.yml # Bundle patch layer (inserted into profile composition)
35
+ ├── cordis.yml # Patch overlay for dev usage (pnpm dsh web --patch)
36
+ ├── tsdown.config.ts # Build config: node-half (ESM) + client-half (CJS browser bundle)
37
+ ├── src/
38
+ │ ├── index.ts # Node half — empty shell for Cordis loader mount
39
+ │ ├── invariant.ts # Invariant companion (registers package ownership)
40
+ │ └── client/
41
+ │ └── index.tsx # Browser half — ALL UI logic lives here
42
+ ├── lib/ # Built output, committed so installs need no build step
43
+ │ ├── index.js # Node entry
44
+ │ ├── invariant.js # Invariant entry
45
+ │ ├── client.js # Browser bundle (wrapped for __ModuleLoader__)
46
+ │ └── client.js.map # Source map
47
+ ├── README.md # This file (English)
48
+ └── README.zh.md # 中文版
49
+ ```
50
+
51
+ ## Implementation
52
+
53
+ The plugin is a **pure client-side** Cordis plugin. The node half is an empty shell; all behavior lives in `src/client/index.tsx`.
54
+
55
+ ### Architecture
56
+
57
+ ```
58
+ ┌─────────────────────────────────────────────────────────┐
59
+ │ apply(ctx) — Plugin entry point │
60
+ ├─────────────────────────────────────────────────────────┤
61
+ │ │
62
+ │ 1. Restore saved color → registerCustom() → setTheme │
63
+ │ 2. Inject gradient <style> into <head> │
64
+ │ 3. Create state store (defineStore) │
65
+ │ 4. applyWp() → wallpaper + token overrides │
66
+ │ 5. Listen theme/change → re-apply │
67
+ │ 6. ResizeObserver → viewport-aware re-positioning │
68
+ │ 7. Locale registration (zh/en) │
69
+ │ 8. Settings section injection (ThemeSection) │
70
+ │ 9. Deferred boot restore (300ms, 1500ms) │
71
+ │ 10. Theme watchdog (1s interval) │
72
+ │ │
73
+ └─────────────────────────────────────────────────────────┘
74
+ ```
75
+
76
+ ### Color Wheel
77
+
78
+ - Single `<canvas>` element: hue ring (360° segments) + inscribed SL square (HSV S-V plane).
79
+ - `hitTest()` determines whether a click lands on the ring (hue) or square (saturation/lightness).
80
+ - HSV values from the canvas are converted to HSL via `hsvToHsl()` before passing to `genTokens()`.
81
+ - `genTokens()` generates 30+ CSS custom properties (`--dsw-alias-*`) for the picked color, choosing dark or light scheme based on lightness.
82
+ - The full token set is written as inline styles on `<body>`, so the theme color never depends on the theme service's timing.
83
+
84
+ ### Background Wallpaper
85
+
86
+ - A `<div>` with `position:fixed; z-index:-1` is prepended to `<body>`.
87
+ - Image is compressed via Canvas API (max 1600px side, JPEG quality 0.75) and stored as base64 in `localStorage`.
88
+ - The editor modal shows a viewport-proportional rectangle; drag to pan, scroll to zoom (0.1×–10×).
89
+ - Committed position is stored as fractional center coordinates + natural image size, so the layout survives viewport changes.
90
+ - Wallpaper opacity is applied directly to the `<div>` element; background color opacity is applied via inline token overrides.
91
+
92
+ ### Opacity System
93
+
94
+ Three independent opacity layers, each with its own slider and `localStorage` key:
95
+
96
+ | Layer | localStorage key | Default | Mechanism |
97
+ |-------|-----------------|---------|-----------|
98
+ | Main interface | `dsh-any-background:opacity` | 85% | Inline CSS variable on `<body>` |
99
+ | Settings panel | `dsh-any-background:settings-opacity` | 100% | CSS variable on `<html>` via `[aria-modal]` selector |
100
+ | Wallpaper | `dsh-any-background:wallpaper-opacity` | 100% | Direct `style.opacity` on wallpaper `<div>` |
101
+
102
+ ## Installation
103
+
104
+ ### Method 1: npm install (Recommended)
105
+
106
+ Install the plugin directly from GitHub into your Web profile:
107
+
108
+ ```sh
109
+ dsh plugin --profile web add github:Tkingxiao/dsh-any-background
110
+ ```
111
+
112
+ Then launch the Web UI:
113
+
114
+ ```sh
115
+ dsh web
116
+ ```
117
+
118
+ The plugin will appear as a **"Theme"** section in the Settings panel.
119
+
120
+ ### Method 2: npx (No Global Install)
121
+
122
+ If you don't have `dsh` installed globally, use `npx`:
123
+
124
+ ```sh
125
+ npx @deepseek-ai/dsh plugin --profile web add github:Tkingxiao/dsh-any-background
126
+ ```
127
+
128
+ Then launch:
129
+
130
+ ```sh
131
+ npx @deepseek-ai/dsh web
132
+ ```
133
+
134
+ ### Method 3: Local Build (Development)
135
+
136
+ The `lib/` directory is committed, so installs need no build step. To rebuild after
137
+ editing `src/`, run the bundle script (needs Node + pnpm):
138
+
139
+ ```sh
140
+ # 1. Clone this repo
141
+ git clone https://github.com/Tkingxiao/dsh-any-background.git
142
+ cd dsh-any-background
143
+
144
+ # 2. Install the build tool
145
+ pnpm install
146
+
147
+ # 3. Rebuild lib/
148
+ pnpm run bundle
149
+
150
+ # 4. Install the plugin into the web profile (from the local checkout)
151
+ dsh plugin --profile web add -w .
152
+
153
+ # 5. Launch
154
+ dsh web
155
+ ```
156
+
157
+ ## Dependencies
158
+
159
+ | Package | Purpose |
160
+ |---------|---------|
161
+ | `@deepseek-ai/cordis` | Plugin framework (Cordis) |
162
+ | `@deepseek-ai/dsh-client-runtime` | Client runtime + `defineStore` |
163
+ | `@deepseek-ai/dsh-client-locale` | i18n (Chinese/English) |
164
+ | `@deepseek-ai/dsh-client-ui-theme` | Theme service (register/setTheme/overrideTokens) |
165
+ | `@deepseek-ai/dsh-invariants` | Package invariant companion |
166
+ | `react` ^18.2.0 | UI rendering |
167
+
168
+ ## License
169
+
170
+ MIT
package/README.zh.md ADDED
@@ -0,0 +1,169 @@
1
+ # dsh-any-background
2
+
3
+ <a href="https://github.com/Tkingxiao/dsh-any-background" target="_blank">
4
+ <img src="https://img.shields.io/github/stars/Tkingxiao/dsh-any-background?style=social" alt="GitHub stars" />
5
+ </a>
6
+
7
+ [English](README.md) | 中文
8
+
9
+ 一个 **DeepSeek Harness** 外观插件,让你完全自定义 Web 端的主题色、背景壁纸和透明度控制。
10
+
11
+ <p align="center">
12
+ <a href="https://star-history.com/#/Tkingxiao/dsh-any-background" target="_blank">
13
+ <img src="https://api.star-history.com/svg?repos=Tkingxiao/dsh-any-background&type=Date" alt="Star 历史趋势图" width="600" />
14
+ </a>
15
+ </p>
16
+
17
+ ---
18
+
19
+ ## 功能特性
20
+
21
+ - **PS 风格色轮** — 在色相环上选取色相,在内嵌方形中调整饱和度与明度。实时生成 30+ 个 CSS 设计令牌并立即生效。
22
+ - **背景壁纸** — 选择任意图片作为壁纸。在视口比例的编辑器中拖动平移、滚轮缩放,所见即所得。
23
+ - **透明度控制** — 主界面背景透明度、设置面板透明度、壁纸透明度各自独立滑块控制。
24
+ - **模糊效果** — 可调壁纸模糊(0–60 px),打造毛玻璃质感。
25
+ - **持久化存储** — 所有设置(颜色、壁纸、透明度、模糊、编辑器位置)保存到 `localStorage`,下次启动自动恢复。
26
+ - **中英双语** — 完整的中英文界面,自动跟随语言设置。
27
+ - **主题守护** — 后台看门狗定期重新激活自定义主题,即使宿主重置也不会丢失你的选择。
28
+
29
+ ## 项目结构
30
+
31
+ ```
32
+ dsh-any-background/
33
+ ├── package.json # 包元数据、dsh.client 声明、依赖
34
+ ├── cordis.patch.yml # 捆绑补丁层(插入到 profile 组合配置中)
35
+ ├── cordis.yml # 开发用补丁覆盖层(pnpm dsh web --patch)
36
+ ├── tsdown.config.ts # 构建配置:Node 端(ESM)+ 客户端(CJS 浏览器包)
37
+ ├── src/
38
+ │ ├── index.ts # Node 端 — 空壳,供 Cordis 加载器挂载
39
+ │ ├── invariant.ts # 不变量 companion(注册包所有权)
40
+ │ └── client/
41
+ │ └── index.tsx # 浏览器端 — 所有 UI 逻辑都在这里
42
+ ├── lib/ # 构建产物(已提交,安装无需构建步骤)
43
+ │ ├── index.js # Node 入口
44
+ │ ├── invariant.js # 不变量入口
45
+ │ ├── client.js # 浏览器包(经 __ModuleLoader__ 包装)
46
+ │ └── client.js.map # 源码映射
47
+ ├── README.md # 英文版说明
48
+ └── README.zh.md # 本文件(中文)
49
+ ```
50
+
51
+ ## 实现原理
52
+
53
+ 本插件是一个**纯客户端** Cordis 插件。Node 端是空壳,所有行为都在 `src/client/index.tsx` 中实现。
54
+
55
+ ### 架构
56
+
57
+ ```
58
+ ┌─────────────────────────────────────────────────────────┐
59
+ │ apply(ctx) — 插件入口 │
60
+ ├─────────────────────────────────────────────────────────┤
61
+ │ │
62
+ │ 1. 恢复保存的颜色 → registerCustom() → setTheme │
63
+ │ 2. 注入渐变 <style> 到 <head> │
64
+ │ 3. 创建状态存储(defineStore) │
65
+ │ 4. applyWp() → 壁纸 + 令牌覆盖 │
66
+ │ 5. 监听 theme/change → 重新应用 │
67
+ │ 6. ResizeObserver → 视口感知重定位 │
68
+ │ 7. 语言注册(中/英) │
69
+ │ 8. 设置面板注入(ThemeSection) │
70
+ │ 9. 延迟启动恢复(300ms, 1500ms) │
71
+ │ 10. 主题守护(1 秒间隔) │
72
+ │ │
73
+ └─────────────────────────────────────────────────────────┘
74
+ ```
75
+
76
+ ### 色轮
77
+
78
+ - 单个 `<canvas>` 元素:色相环(360° 分段)+ 内嵌 SL 方形(HSV S-V 平面)。
79
+ - `hitTest()` 判断点击落在色相环(色相)还是方形(饱和度/明度)上。
80
+ - 色轮拾取的 HSV 值通过 `hsvToHsl()` 转换为 HSL 后传给 `genTokens()`。
81
+ - `genTokens()` 根据所选颜色生成 30+ 个 CSS 自定义属性(`--dsw-alias-*`),根据明度自动选择深色或浅色方案。
82
+ - 完整令牌集以内联样式写入 `<body>`,主题色完全不依赖主题服务的时序。
83
+
84
+ ### 背景壁纸
85
+
86
+ - 一个 `position:fixed; z-index:-1` 的 `<div>` 被插入到 `<body>` 最前面。
87
+ - 图片通过 Canvas API 压缩(最大边 1600px,JPEG 质量 0.75),以 base64 存入 `localStorage`。
88
+ - 编辑器弹窗显示视口比例的矩形区域;拖动平移,滚轮缩放(0.1×–10×)。
89
+ - 提交的位置以分数中心坐标 + 原始图片尺寸存储,布局在视口变化时保持一致。
90
+ - 壁纸透明度直接作用于 `<div>` 元素;背景色透明度通过内联令牌覆盖实现。
91
+
92
+ ### 透明度体系
93
+
94
+ 三个独立的透明度层,各有独立滑块和 `localStorage` 键:
95
+
96
+ | 层 | localStorage 键 | 默认值 | 实现方式 |
97
+ |----|-----------------|--------|---------|
98
+ | 主界面 | `dsh-any-background:opacity` | 85% | `<body>` 上的内联 CSS 变量 |
99
+ | 设置面板 | `dsh-any-background:settings-opacity` | 100% | `<html>` 上的 CSS 变量,通过 `[aria-modal]` 选择器定位 |
100
+ | 壁纸 | `dsh-any-background:wallpaper-opacity` | 100% | 壁纸 `<div>` 上的 `style.opacity` |
101
+
102
+ ## 安装方式
103
+
104
+ ### 方式一:npm 安装(推荐)
105
+
106
+ 直接从 GitHub 安装插件到 Web profile:
107
+
108
+ ```sh
109
+ dsh plugin --profile web add github:Tkingxiao/dsh-any-background
110
+ ```
111
+
112
+ 然后启动 Web UI:
113
+
114
+ ```sh
115
+ dsh web
116
+ ```
117
+
118
+ 插件将作为 **"主题"** 分区出现在设置面板中。
119
+
120
+ ### 方式二:npx(无需全局安装)
121
+
122
+ 如果没有全局安装 `dsh`,可以使用 `npx`:
123
+
124
+ ```sh
125
+ npx @deepseek-ai/dsh plugin --profile web add github:Tkingxiao/dsh-any-background
126
+ ```
127
+
128
+ 然后启动:
129
+
130
+ ```sh
131
+ npx @deepseek-ai/dsh web
132
+ ```
133
+
134
+ ### 方式三:本地构建(开发模式)
135
+
136
+ `lib/` 目录已提交,安装无需构建步骤。若修改了 `src/` 需要重新构建(需 Node + pnpm):
137
+
138
+ ```sh
139
+ # 1. 克隆本仓库
140
+ git clone https://github.com/Tkingxiao/dsh-any-background.git
141
+ cd dsh-any-background
142
+
143
+ # 2. 安装构建工具
144
+ pnpm install
145
+
146
+ # 3. 重新构建 lib/
147
+ pnpm run bundle
148
+
149
+ # 4. 从本地安装到 web profile
150
+ dsh plugin --profile web add -w .
151
+
152
+ # 5. 启动
153
+ dsh web
154
+ ```
155
+
156
+ ## 依赖
157
+
158
+ | 包名 | 用途 |
159
+ |------|------|
160
+ | `@deepseek-ai/cordis` | 插件框架(Cordis) |
161
+ | `@deepseek-ai/dsh-client-runtime` | 客户端运行时 + `defineStore` |
162
+ | `@deepseek-ai/dsh-client-locale` | 国际化(中/英) |
163
+ | `@deepseek-ai/dsh-client-ui-theme` | 主题服务(register/setTheme/overrideTokens) |
164
+ | `@deepseek-ai/dsh-invariants` | 包不变量 companion |
165
+ | `react` ^18.2.0 | UI 渲染 |
166
+
167
+ ## 许可证
168
+
169
+ MIT
@@ -0,0 +1,8 @@
1
+ # Deep Midnight theme plugin: bundle patch layer.
2
+ # When this package is installed into a profile via `dsh plugin add`,
3
+ # this patch is applied as a layer, inserting the theme plugin row
4
+ # into the composed configuration.
5
+
6
+ - insert:
7
+ - id: dsh-any-background
8
+ name: 'dsh-any-background'