dsh-liquid-glass 0.1.0 → 0.2.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/README.md +33 -4
- package/README.zh.md +33 -4
- package/lib/client.js +447 -53
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-liquid-glass)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
8
|
+
|
|
5
9
|
**Liquid glass for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)** — one toggle, and the whole interface turns to glass.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
Translucent theme surfaces and scoped frosted menus over your own background image, with material presets, tint, wallpaper controls, and system accessibility response. The working-tree features below are unreleased; the package version has not changed.
|
|
8
12
|
|
|
9
13
|
## Install
|
|
10
14
|
|
|
@@ -14,11 +18,36 @@ dsh plugin --profile web add dsh-liquid-glass
|
|
|
14
18
|
|
|
15
19
|
Open **Settings → General** — a **Liquid Glass** row appears. It is ON by default; restart once after install.
|
|
16
20
|
|
|
21
|
+
## Preview
|
|
22
|
+
|
|
23
|
+
| Settings | Glass shell | Wallpaper |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
|  |  |  |
|
|
26
|
+
|
|
17
27
|
## What you get
|
|
18
28
|
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
29
|
+
- **Theme surface transparency** through the official ThemeRuntime tokens, with a 3%–95% transparency slider.
|
|
30
|
+
- **Regular, Clear, and Frost presets**, plus cool white, warm gray, and ink tints. Manual transparency fine-tunes the selected preset.
|
|
31
|
+
- **Scoped menu frost** with an independent switch, a settings-card rim color, and a material preview with an inset highlight. Host filter placement stays unchanged.
|
|
32
|
+
- **Wallpaper controls**: cover/contain/fill, nine positions, brightness 20%–200%, and manual dim 0%–60%. Bright local or same-origin images automatically receive at least 35% dim; cross-origin links use manual dim only. Large static uploads are compressed; GIF data is preserved.
|
|
33
|
+
- **System accessibility response**: reduced transparency or increased contrast selects effective Frost material and limits transparency to 50%, without overwriting saved preferences.
|
|
34
|
+
- **Keyboard toggle**: Ctrl/Cmd+Shift+G through the host shortcut service. Change or remove “Toggle Liquid Glass” in the host Keyboard shortcuts settings. Linux Web starts unbound; conflicting defaults fall back to an unbound command.
|
|
35
|
+
|
|
36
|
+
Independent user/assistant opacity floors and general host-panel blur/highlights are not implemented: verified official extension hooks are missing. See [local API evidence and validation limits](docs/v0.2.0-local-evidence.md). Live DSH regression testing remains outstanding. Existing screenshots show the older interface.
|
|
37
|
+
|
|
38
|
+
## Privacy and compatibility
|
|
39
|
+
|
|
40
|
+
- Settings and uploaded backgrounds stay in this browser's `localStorage`; the plugin has no server component and sends no telemetry.
|
|
41
|
+
- The UI integrates through DeepSeek Harness's public client runtime, locale, slot, theme, and shortcut APIs. Shortcut bindings use host-managed device-local storage (localStorage on Web; keybindings.json on Desktop).
|
|
42
|
+
- Light and dark color schemes are supported. A DSH restart is required once after installation so the client bundle can be loaded.
|
|
43
|
+
|
|
44
|
+
## Verify from source
|
|
45
|
+
|
|
46
|
+
The smoke test runs the published client bundle inside a mocked DSH browser runtime and exercises registration, lifecycle, settings, persistence, wallpaper controls and slider bounds:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
node test/smoke.test.mjs
|
|
50
|
+
```
|
|
22
51
|
|
|
23
52
|
## Uninstall
|
|
24
53
|
|
package/README.zh.md
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-liquid-glass)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
8
|
+
|
|
5
9
|
**[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 的液态玻璃**——点一下,整个界面通透起来。
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
通过官方主题接口提供表面透明化、局部菜单磨砂、自定义壁纸、质感预设、色调和系统无障碍响应。下列工作区新功能尚未发布,package.json 版本号未改动。
|
|
8
12
|
|
|
9
13
|
## 安装
|
|
10
14
|
|
|
@@ -14,11 +18,36 @@ dsh plugin --profile web add dsh-liquid-glass
|
|
|
14
18
|
|
|
15
19
|
打开 **设置 → 通用**,出现「液态玻璃」设置行。默认开启;装完重启一次。
|
|
16
20
|
|
|
21
|
+
## 效果预览
|
|
22
|
+
|
|
23
|
+
| 设置 | 玻璃界面 | 自定义壁纸 |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
|  |  |  |
|
|
26
|
+
|
|
17
27
|
## 功能
|
|
18
28
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
29
|
+
- **主题表面透明化**:经官方 ThemeRuntime token 覆盖层生效,透明度主滑块范围为 3%–95%。
|
|
30
|
+
- **标准、清透、磨砂三档预设**,另有冷白、暖灰、墨色;可用透明度滑块微调。
|
|
31
|
+
- **局部菜单磨砂**:可独立关闭;设置卡片使用官方描边色,插件预览面板带内侧高光。宿主原有滤镜作用位置不变。
|
|
32
|
+
- **壁纸控制**:铺满/完整显示/拉伸、九个位置、20%–200% 亮度、0%–60% 手动暗化。明亮的本地或同源图片自动至少暗化 35%;跨域链接只使用手动暗化。静态大图自动压缩,GIF 保留原始数据。
|
|
33
|
+
- **系统无障碍响应**:减透明或增强对比度启用时,临时使用磨砂质感并将透明度限制为最高 50%,不覆盖用户保存的偏好。
|
|
34
|
+
- **快捷键切换**:经宿主快捷键服务注册 Ctrl/Cmd+Shift+G,在宿主「键盘快捷键」设置中可更改或移除「切换液态玻璃」。Linux 网页端默认不绑定;默认组合冲突时退为未绑定命令。
|
|
35
|
+
|
|
36
|
+
人/助手独立消息不透明度下限,以及任意宿主面板的磨砂/内侧高光,因缺少已核实的官方扩展接口而未实现。参见[本地 API 证据与验证限制](docs/v0.2.0-local-evidence.md)。真实 DSH 回归测试仍待完成,现有截图展示的是旧界面。
|
|
37
|
+
|
|
38
|
+
## 隐私与兼容性
|
|
39
|
+
|
|
40
|
+
- 设置和上传的背景仅保存在当前浏览器的 `localStorage` 中;插件没有服务端组件,也不发送遥测数据。
|
|
41
|
+
- 界面仅通过 DeepSeek Harness 的公开客户端运行时、语言、插槽、主题和快捷键 API 集成。快捷键绑定由宿主管理,网页端用 localStorage,桌面端用设备本地 keybindings.json。
|
|
42
|
+
- 支持亮色和暗色方案。安装后需要重启一次 DSH,以便加载客户端 bundle。
|
|
43
|
+
|
|
44
|
+
## 从源码验证
|
|
45
|
+
|
|
46
|
+
冒烟测试会在模拟的 DSH 浏览器运行时中执行实际发布的客户端 bundle,覆盖注册、生命周期、设置、持久化、壁纸控制和滑块边界:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
node test/smoke.test.mjs
|
|
50
|
+
```
|
|
22
51
|
|
|
23
52
|
## 卸载
|
|
24
53
|
|
package/lib/client.js
CHANGED
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
// resolved against the shell's module table — the same shape the shipped ui-*
|
|
7
7
|
// packages emit.
|
|
8
8
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// including the page base) behind one master transparency slider.
|
|
12
|
-
// 2. A full-page custom wallpaper behind everything.
|
|
9
|
+
// Surface transparency, scoped menu frost, and a custom wallpaper.
|
|
10
|
+
// Host materials and shortcuts extend official APIs; see docs/v0.2.0-local-evidence.md.
|
|
13
11
|
// No theme catalog, no accent colors, no packs. Preferences persist in
|
|
14
12
|
// localStorage, the correct boundary for third-party visual preferences (the
|
|
15
13
|
// Host settings wire only exposes an allowlisted namespace set to browser
|
|
@@ -22,7 +20,8 @@ window.__ModuleLoader__.load({
|
|
|
22
20
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
23
21
|
let jsx = require("react/jsx-runtime");
|
|
24
22
|
let _react = require("react");
|
|
25
|
-
|
|
23
|
+
// Platform seed in the official web shell; no /client suffix or inject edge.
|
|
24
|
+
let _client_store = require("@deepseek-ai/dsh-client-store");
|
|
26
25
|
|
|
27
26
|
|
|
28
27
|
//#region constants & storage
|
|
@@ -33,6 +32,49 @@ window.__ModuleLoader__.load({
|
|
|
33
32
|
const DEFAULT_ALPHA = 0.62;
|
|
34
33
|
const GLASS_SOURCE = "dsh-liquid-glass:glass";
|
|
35
34
|
const GLASS_CSS_ID = "dsh-liquid-glass-glass-css";
|
|
35
|
+
const MATERIAL_SOURCE = "dsh-liquid-glass:material";
|
|
36
|
+
const KEY_OPTIONS = "dsh-liquid-glass:options";
|
|
37
|
+
const PRESETS = {
|
|
38
|
+
regular: { alpha: 0.62, blur: 12, saturate: 180 },
|
|
39
|
+
clear: { alpha: 0.35, blur: 6, saturate: 140 },
|
|
40
|
+
frost: { alpha: 0.78, blur: 20, saturate: 200 }
|
|
41
|
+
};
|
|
42
|
+
const TINTS = {
|
|
43
|
+
neutral: { light: "#ffffff", dark: "#151517" },
|
|
44
|
+
cool: { light: "#edf5ff", dark: "#151b26" },
|
|
45
|
+
warm: { light: "#f5f0e8", dark: "#24201c" },
|
|
46
|
+
ink: { light: "#dce2eb", dark: "#10141c" }
|
|
47
|
+
};
|
|
48
|
+
const POSITIONS = ["left top", "center top", "right top", "left center", "center center", "right center", "left bottom", "center bottom", "right bottom"];
|
|
49
|
+
const DEFAULT_OPTIONS = { preset: "regular", tint: "neutral", filter: true, dim: 0, autoDim: true, fit: "cover", position: "center center", brightness: 100 };
|
|
50
|
+
const enumValue = (value, choices, fallback) => choices.includes(value) ? value : fallback;
|
|
51
|
+
const numberValue = (value, min, max, fallback) => typeof value === "number" && Number.isFinite(value) ? Math.round(Math.min(max, Math.max(min, value))) : fallback;
|
|
52
|
+
function readOptions() {
|
|
53
|
+
let saved;
|
|
54
|
+
try { saved = JSON.parse(readStorage(KEY_OPTIONS)); } catch { /* Invalid preferences use defaults. */ }
|
|
55
|
+
const o = saved && typeof saved === "object" ? saved : {};
|
|
56
|
+
return {
|
|
57
|
+
preset: enumValue(o.preset, Object.keys(PRESETS), "regular"),
|
|
58
|
+
tint: enumValue(o.tint, Object.keys(TINTS), "neutral"),
|
|
59
|
+
filter: typeof o.filter === "boolean" ? o.filter : true,
|
|
60
|
+
dim: numberValue(o.dim, 0, 60, 0),
|
|
61
|
+
autoDim: typeof o.autoDim === "boolean" ? o.autoDim : true,
|
|
62
|
+
fit: enumValue(o.fit, ["cover", "contain", "fill"], "cover"),
|
|
63
|
+
position: enumValue(o.position, POSITIONS, "center center"),
|
|
64
|
+
brightness: numberValue(o.brightness, 20, 200, 100)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
let accessibilityActive = false;
|
|
68
|
+
function appearance() {
|
|
69
|
+
const options = readOptions();
|
|
70
|
+
const preset = accessibilityActive ? "frost" : options.preset;
|
|
71
|
+
const material = PRESETS[preset];
|
|
72
|
+
const alpha = accessibilityActive ? Math.max(0.5, readAlpha()) : readAlpha();
|
|
73
|
+
// A preset's exact recipe holds at its default opacity. Making it
|
|
74
|
+
// more transparent reduces blur; increased opacity never adds cost.
|
|
75
|
+
const blur = accessibilityActive ? material.blur : Math.round(material.blur * Math.min(1, alpha / material.alpha) * 10) / 10;
|
|
76
|
+
return { ...options, preset, alpha, blur, saturate: material.saturate, accessibility: accessibilityActive };
|
|
77
|
+
}
|
|
36
78
|
/** Glass defaults to ON: transparency is the whole point of the plugin. */
|
|
37
79
|
const DEFAULT_GLASS_ON = true;
|
|
38
80
|
|
|
@@ -43,7 +85,23 @@ window.__ModuleLoader__.load({
|
|
|
43
85
|
try {
|
|
44
86
|
if (value === null || value === void 0) window.localStorage.removeItem(key);
|
|
45
87
|
else window.localStorage.setItem(key, value);
|
|
46
|
-
|
|
88
|
+
return true;
|
|
89
|
+
} catch { return false; }
|
|
90
|
+
}
|
|
91
|
+
function wallpaperFitsStorage(value) {
|
|
92
|
+
try {
|
|
93
|
+
const storage = window.localStorage;
|
|
94
|
+
let used = 0;
|
|
95
|
+
for (let i = 0; i < storage.length; i++) {
|
|
96
|
+
const key = storage.key(i);
|
|
97
|
+
// Replacing the wallpaper frees its previous value.
|
|
98
|
+
if (key !== KEY_WALLPAPER) used += (storage.getItem(key) || "").length;
|
|
99
|
+
}
|
|
100
|
+
// Assume a typical ~5 MiB budget, estimating UTF-16 values at
|
|
101
|
+
// 2 bytes per code unit. Browser quotas/accounting vary; the
|
|
102
|
+
// actual write can still fail and must report that failure.
|
|
103
|
+
return (used + value.length) * 2 <= 5 * 1024 * 1024;
|
|
104
|
+
} catch { return true; } // If estimation is unavailable, let the write decide.
|
|
47
105
|
}
|
|
48
106
|
const readGlassOn = () => {
|
|
49
107
|
const raw = readStorage(KEY_GLASS);
|
|
@@ -54,7 +112,7 @@ window.__ModuleLoader__.load({
|
|
|
54
112
|
const raw = readStorage(KEY_ALPHA);
|
|
55
113
|
if (raw === null) return DEFAULT_ALPHA;
|
|
56
114
|
const n = Number(raw);
|
|
57
|
-
return Number.isFinite(n) && n > 0 ? Math.min(0.
|
|
115
|
+
return Number.isFinite(n) && n > 0 ? Math.min(0.97, Math.max(0.05, n)) : DEFAULT_ALPHA;
|
|
58
116
|
};
|
|
59
117
|
const readWallpaper = () => readStorage(KEY_WALLPAPER);
|
|
60
118
|
//#endregion
|
|
@@ -75,6 +133,41 @@ window.__ModuleLoader__.load({
|
|
|
75
133
|
|
|
76
134
|
//#region locale
|
|
77
135
|
const zh = {
|
|
136
|
+
"glass.presets": "质感预设",
|
|
137
|
+
"glass.regular": "标准",
|
|
138
|
+
"glass.clear": "清透",
|
|
139
|
+
"glass.frost": "磨砂",
|
|
140
|
+
"glass.tint": "色调",
|
|
141
|
+
"glass.neutral": "原色",
|
|
142
|
+
"glass.cool": "冷白",
|
|
143
|
+
"glass.warm": "暖灰",
|
|
144
|
+
"glass.ink": "墨色",
|
|
145
|
+
"glass.filter": "菜单磨砂",
|
|
146
|
+
"glass.materialHint": "磨砂用于宿主菜单材质;上方可预览效果。",
|
|
147
|
+
"glass.accessibility": "系统减透明或增强对比度已启用:使用磨砂质感,透明度最高 50%。",
|
|
148
|
+
"glass.saveFailed": "设置保存失败,请检查浏览器存储空间或权限。",
|
|
149
|
+
"glass.shortcut": "切换液态玻璃",
|
|
150
|
+
"glass.shortcutHint": "可在设置 → 通用 → 键盘快捷键中更改或移除“切换液态玻璃”。Linux 网页端默认不绑定。",
|
|
151
|
+
"glass.shortcutUnavailable": "快捷键服务不可用,仍可使用上方开关。",
|
|
152
|
+
"glass.shortcutConflict": "默认快捷键不可用;请在键盘快捷键设置中选择可用组合。",
|
|
153
|
+
"wallpaper.dim": "壁纸暗化",
|
|
154
|
+
"wallpaper.autoDim": "自动暗化明亮壁纸(至少 35%)",
|
|
155
|
+
"wallpaper.autoDimHint": "跨域链接只使用手动暗化;自动检测为一次图片采样。",
|
|
156
|
+
"wallpaper.fit": "缩放方式",
|
|
157
|
+
"wallpaper.cover": "铺满",
|
|
158
|
+
"wallpaper.contain": "完整显示",
|
|
159
|
+
"wallpaper.fill": "拉伸",
|
|
160
|
+
"wallpaper.position": "壁纸位置",
|
|
161
|
+
"wallpaper.brightness": "壁纸亮度",
|
|
162
|
+
"position.left top": "左上",
|
|
163
|
+
"position.center top": "上中",
|
|
164
|
+
"position.right top": "右上",
|
|
165
|
+
"position.left center": "左中",
|
|
166
|
+
"position.center center": "居中",
|
|
167
|
+
"position.right center": "右中",
|
|
168
|
+
"position.left bottom": "左下",
|
|
169
|
+
"position.center bottom": "下中",
|
|
170
|
+
"position.right bottom": "右下",
|
|
78
171
|
"row.title": "液态玻璃",
|
|
79
172
|
"row.subtitle": "由 Liquid Glass 提供 · 全界面透明化 + 自定义背景图",
|
|
80
173
|
"glass.toggle": "启用玻璃质感",
|
|
@@ -92,14 +185,52 @@ window.__ModuleLoader__.load({
|
|
|
92
185
|
"wallpaper.save": "保存",
|
|
93
186
|
"wallpaper.unsaved": "有未保存的更改",
|
|
94
187
|
"wallpaper.badUrl": "图片链接加载失败,请检查后重试",
|
|
188
|
+
"wallpaper.badFile": "图片文件读取或解码失败,请选择有效的图片",
|
|
189
|
+
"wallpaper.tooLarge": "GIF 超出本浏览器的预计剩余存储空间,请缩小文件后重试",
|
|
190
|
+
"wallpaper.saveFailed": "背景图保存失败,请释放浏览器存储空间或检查存储权限后重试",
|
|
95
191
|
"wallpaper.checking": "校验中…",
|
|
96
|
-
"wallpaper.hint": "
|
|
192
|
+
"wallpaper.hint": "背景铺满整个页面,保存在本浏览器;过大的静态图片会自动压缩,GIF 保留原图。"
|
|
97
193
|
};
|
|
98
194
|
const en = {
|
|
195
|
+
"glass.presets": "Material preset",
|
|
196
|
+
"glass.regular": "Regular",
|
|
197
|
+
"glass.clear": "Clear",
|
|
198
|
+
"glass.frost": "Frost",
|
|
199
|
+
"glass.tint": "Tint",
|
|
200
|
+
"glass.neutral": "Neutral",
|
|
201
|
+
"glass.cool": "Cool white",
|
|
202
|
+
"glass.warm": "Warm gray",
|
|
203
|
+
"glass.ink": "Ink",
|
|
204
|
+
"glass.filter": "Frosted menus",
|
|
205
|
+
"glass.materialHint": "Frost follows the host menu material. The panel above previews the material.",
|
|
206
|
+
"glass.accessibility": "System transparency or contrast protection is active: Frost material, at most 50% transparency.",
|
|
207
|
+
"glass.saveFailed": "Settings could not be saved. Check browser storage space or permissions.",
|
|
208
|
+
"glass.shortcut": "Toggle Liquid Glass",
|
|
209
|
+
"glass.shortcutHint": "Change or remove “Toggle Liquid Glass” in Settings → General → Keyboard shortcuts. Linux Web starts unbound.",
|
|
210
|
+
"glass.shortcutUnavailable": "Keyboard shortcuts are unavailable; use the switch above.",
|
|
211
|
+
"glass.shortcutConflict": "The default shortcut is unavailable; choose an available binding in Keyboard shortcuts.",
|
|
212
|
+
"wallpaper.dim": "Wallpaper dim",
|
|
213
|
+
"wallpaper.autoDim": "Automatically dim bright wallpaper (at least 35%)",
|
|
214
|
+
"wallpaper.autoDimHint": "Cross-origin links use manual dimming only; automatic detection samples the image once.",
|
|
215
|
+
"wallpaper.fit": "Wallpaper fit",
|
|
216
|
+
"wallpaper.cover": "Cover",
|
|
217
|
+
"wallpaper.contain": "Contain",
|
|
218
|
+
"wallpaper.fill": "Fill",
|
|
219
|
+
"wallpaper.position": "Wallpaper position",
|
|
220
|
+
"wallpaper.brightness": "Brightness",
|
|
221
|
+
"position.left top": "Top left",
|
|
222
|
+
"position.center top": "Top center",
|
|
223
|
+
"position.right top": "Top right",
|
|
224
|
+
"position.left center": "Center left",
|
|
225
|
+
"position.center center": "Center",
|
|
226
|
+
"position.right center": "Center right",
|
|
227
|
+
"position.left bottom": "Bottom left",
|
|
228
|
+
"position.center bottom": "Bottom center",
|
|
229
|
+
"position.right bottom": "Bottom right",
|
|
99
230
|
"row.title": "Liquid Glass",
|
|
100
231
|
"row.subtitle": "Powered by Liquid Glass · full-shell transparency + custom background",
|
|
101
232
|
"glass.toggle": "Enable glassmorphism",
|
|
102
|
-
"glass.alpha": "
|
|
233
|
+
"glass.alpha": "Transparency",
|
|
103
234
|
"glass.hint": "Higher transparency reveals more of the background.",
|
|
104
235
|
"wallpaper.title": "Background",
|
|
105
236
|
"wallpaper.choose": "Choose image…",
|
|
@@ -113,32 +244,113 @@ window.__ModuleLoader__.load({
|
|
|
113
244
|
"wallpaper.save": "Save",
|
|
114
245
|
"wallpaper.unsaved": "Unsaved changes",
|
|
115
246
|
"wallpaper.badUrl": "Image failed to load from this URL. Please check and retry.",
|
|
247
|
+
"wallpaper.badFile": "Image file could not be read or decoded. Please choose a valid image.",
|
|
248
|
+
"wallpaper.tooLarge": "This GIF exceeds the estimated remaining browser storage. Please use a smaller file.",
|
|
249
|
+
"wallpaper.saveFailed": "Background could not be saved. Free browser storage or check storage permissions and retry.",
|
|
116
250
|
"wallpaper.checking": "Checking…",
|
|
117
|
-
"wallpaper.hint": "The background spans the whole page and stays in this browser; large images are compressed
|
|
251
|
+
"wallpaper.hint": "The background spans the whole page and stays in this browser; large static images are compressed, while GIFs keep their original data."
|
|
118
252
|
};
|
|
119
253
|
//#endregion
|
|
120
254
|
|
|
121
255
|
//#region wallpaper layer (full-page background)
|
|
122
256
|
let wallpaperEl = null;
|
|
257
|
+
let wallpaperDimEl = null;
|
|
258
|
+
let wallpaperSample = null;
|
|
259
|
+
let sampleUrl;
|
|
260
|
+
let sampledLuminance = null;
|
|
261
|
+
let wallpaperRevision = 0;
|
|
262
|
+
function canSampleWallpaper(url) {
|
|
263
|
+
if (/^data:image\//i.test(url)) return true;
|
|
264
|
+
try {
|
|
265
|
+
const resolved = new URL(url, window.location.href);
|
|
266
|
+
return /^https?:$/.test(resolved.protocol) && resolved.origin === window.location.origin;
|
|
267
|
+
} catch { return false; }
|
|
268
|
+
}
|
|
269
|
+
function effectiveDim(options = readOptions()) {
|
|
270
|
+
const bright = sampledLuminance !== null && sampledLuminance * options.brightness / 100 > 0.7;
|
|
271
|
+
return Math.max(options.dim, options.autoDim && bright ? 35 : 0);
|
|
272
|
+
}
|
|
273
|
+
function updateDim() {
|
|
274
|
+
if (wallpaperDimEl) wallpaperDimEl.style.backgroundColor = `rgba(0, 0, 0, ${effectiveDim() / 100})`;
|
|
275
|
+
}
|
|
276
|
+
function sampleWallpaper(url) {
|
|
277
|
+
if (url === sampleUrl) return;
|
|
278
|
+
sampleUrl = url;
|
|
279
|
+
sampledLuminance = null;
|
|
280
|
+
const revision = ++wallpaperRevision;
|
|
281
|
+
if (wallpaperSample) wallpaperSample.onload = wallpaperSample.onerror = null;
|
|
282
|
+
wallpaperSample = null;
|
|
283
|
+
updateDim();
|
|
284
|
+
// No CORS retries, proxy, or pixel read for cross-origin URLs.
|
|
285
|
+
if (!canSampleWallpaper(url)) return;
|
|
286
|
+
const image = document.createElement("img");
|
|
287
|
+
wallpaperSample = image;
|
|
288
|
+
image.onload = () => {
|
|
289
|
+
if (revision !== wallpaperRevision) return;
|
|
290
|
+
try {
|
|
291
|
+
const canvas = document.createElement("canvas");
|
|
292
|
+
canvas.width = canvas.height = 16;
|
|
293
|
+
const context = canvas.getContext("2d");
|
|
294
|
+
context.drawImage(image, 0, 0, 16, 16);
|
|
295
|
+
const pixels = context.getImageData(0, 0, 16, 16).data;
|
|
296
|
+
let total = 0, weight = 0;
|
|
297
|
+
for (let i = 0; i < pixels.length; i += 4) {
|
|
298
|
+
const a = pixels[i + 3] / 255;
|
|
299
|
+
total += (0.2126 * pixels[i] + 0.7152 * pixels[i + 1] + 0.0722 * pixels[i + 2]) / 255 * a;
|
|
300
|
+
weight += a;
|
|
301
|
+
}
|
|
302
|
+
sampledLuminance = weight ? total / weight : 0;
|
|
303
|
+
} catch { sampledLuminance = null; } // Includes tainted canvases after redirects.
|
|
304
|
+
image.onload = image.onerror = null;
|
|
305
|
+
wallpaperSample = null;
|
|
306
|
+
updateDim();
|
|
307
|
+
};
|
|
308
|
+
image.onerror = () => {
|
|
309
|
+
if (revision !== wallpaperRevision) return;
|
|
310
|
+
image.onload = image.onerror = null;
|
|
311
|
+
wallpaperSample = null;
|
|
312
|
+
};
|
|
313
|
+
image.src = url;
|
|
314
|
+
}
|
|
123
315
|
|
|
124
316
|
function applyWallpaper() {
|
|
125
317
|
const url = readWallpaper();
|
|
126
318
|
if (url === null) {
|
|
127
|
-
|
|
128
|
-
wallpaperEl = null;
|
|
319
|
+
teardownWallpaper();
|
|
129
320
|
return;
|
|
130
321
|
}
|
|
322
|
+
if (wallpaperDimEl === null) {
|
|
323
|
+
wallpaperDimEl = document.createElement("div");
|
|
324
|
+
wallpaperDimEl.id = "dsh-liquid-glass-wallpaper-dim";
|
|
325
|
+
wallpaperDimEl.style.cssText = "position:fixed;inset:0;z-index:-1;pointer-events:none;";
|
|
326
|
+
// A higher stacking level paints dim above the image regardless of
|
|
327
|
+
// DOM order, with brightness confined to the image.
|
|
328
|
+
document.body.prepend(wallpaperDimEl);
|
|
329
|
+
}
|
|
131
330
|
if (wallpaperEl === null || !document.body.contains(wallpaperEl)) {
|
|
132
331
|
wallpaperEl = document.createElement("div");
|
|
133
|
-
wallpaperEl.style.cssText = "position:fixed;inset:0;z-index:-
|
|
332
|
+
wallpaperEl.style.cssText = "position:fixed;inset:0;z-index:-2;pointer-events:none;background-size:cover;background-position:center;background-repeat:no-repeat;";
|
|
134
333
|
document.body.prepend(wallpaperEl);
|
|
135
334
|
}
|
|
136
|
-
|
|
335
|
+
const options = readOptions();
|
|
336
|
+
wallpaperEl.style.backgroundImage = `url("${url.replace(/["\\\n\r]/g, (c) => `\\${c.charCodeAt(0).toString(16)} `)}")`;
|
|
337
|
+
wallpaperEl.style.backgroundSize = options.fit === "fill" ? "100% 100%" : options.fit;
|
|
338
|
+
wallpaperEl.style.backgroundPosition = options.position;
|
|
339
|
+
wallpaperEl.style.filter = `brightness(${options.brightness}%)`;
|
|
340
|
+
|
|
341
|
+
sampleWallpaper(url);
|
|
342
|
+
updateDim();
|
|
137
343
|
}
|
|
138
344
|
|
|
139
345
|
function teardownWallpaper() {
|
|
140
346
|
wallpaperEl?.remove();
|
|
141
|
-
|
|
347
|
+
wallpaperDimEl?.remove();
|
|
348
|
+
wallpaperEl = wallpaperDimEl = null;
|
|
349
|
+
if (wallpaperSample) wallpaperSample.onload = wallpaperSample.onerror = null;
|
|
350
|
+
wallpaperSample = null;
|
|
351
|
+
sampleUrl = undefined;
|
|
352
|
+
sampledLuminance = null;
|
|
353
|
+
wallpaperRevision++;
|
|
142
354
|
}
|
|
143
355
|
|
|
144
356
|
/** Downscale an image to a JPEG data URL (localStorage quota friendly). */
|
|
@@ -169,20 +381,23 @@ window.__ModuleLoader__.load({
|
|
|
169
381
|
"--dsw-alias-markdown-code-block",
|
|
170
382
|
"--dsw-alias-markdown-inline-code"
|
|
171
383
|
];
|
|
172
|
-
const LIGHT_SURFACE = "#ffffff";
|
|
173
|
-
const DARK_SURFACE = "#151517";
|
|
174
|
-
|
|
175
384
|
let glassDispose = null;
|
|
385
|
+
let materialDispose = null;
|
|
176
386
|
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
|
|
387
|
+
function glassFilterCss(material) {
|
|
388
|
+
const filter = material.filter ? `blur(${material.blur}px) saturate(${material.saturate}%)` : "none";
|
|
389
|
+
// Only a plugin-owned, childless decoration gets a new filter.
|
|
390
|
+
// Host surfaces retain their existing filter placement via the token API.
|
|
391
|
+
return `[data-liquid-glass-preview]::before{backdrop-filter:${filter};-webkit-backdrop-filter:${filter};}`;
|
|
392
|
+
}
|
|
393
|
+
function glassCss(material) {
|
|
394
|
+
const tint = TINTS[material.tint];
|
|
182
395
|
return [
|
|
183
|
-
"/* dsh-liquid-glass
|
|
184
|
-
"
|
|
185
|
-
"
|
|
396
|
+
"/* dsh-liquid-glass: no host DOM selectors or ancestor filters */",
|
|
397
|
+
"[data-liquid-glass-preview]{position:relative;isolation:isolate;border-radius:12px;padding:18px;}",
|
|
398
|
+
`[data-liquid-glass-preview]::before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;border-radius:inherit;background:${toRgba(tint.light, material.alpha)};border:1px solid rgba(255,255,255,0.65);box-shadow:inset 0 1px 0 rgba(255,255,255,0.8);}`,
|
|
399
|
+
`body[data-ds-dark-theme] [data-liquid-glass-preview]::before{background:${toRgba(tint.dark, material.alpha)};border-color:rgba(255,255,255,0.18);box-shadow:inset 0 1px 0 rgba(255,255,255,0.28);}`,
|
|
400
|
+
glassFilterCss(material)
|
|
186
401
|
].join("\n");
|
|
187
402
|
}
|
|
188
403
|
|
|
@@ -197,45 +412,65 @@ window.__ModuleLoader__.load({
|
|
|
197
412
|
function applyGlassInner(ctx) {
|
|
198
413
|
teardownGlass();
|
|
199
414
|
if (!readGlassOn()) return;
|
|
200
|
-
const
|
|
415
|
+
const material = appearance();
|
|
416
|
+
const { alpha } = material;
|
|
417
|
+
const tint = TINTS[material.tint];
|
|
418
|
+
const filter = material.filter ? `blur(${material.blur}px) saturate(${material.saturate}%)` : "none";
|
|
419
|
+
// These are existing host material tokens, not inferred DOM classes.
|
|
420
|
+
materialDispose = ctx.theme.overrideTokens(MATERIAL_SOURCE, {
|
|
421
|
+
"--dsw-menu-backdrop-filter": { light: filter, dark: filter },
|
|
422
|
+
"--dsw-menu-surface-fill": { light: toRgba(tint.light, Math.max(0.55, alpha)), dark: toRgba(tint.dark, Math.max(0.55, alpha)) },
|
|
423
|
+
"--dsw-specific-menu": { light: toRgba(tint.light, Math.max(0.55, alpha)), dark: toRgba(tint.dark, Math.max(0.55, alpha)) },
|
|
424
|
+
"--dsw-alias-settings-card-stroke": { light: "rgba(255, 255, 255, 0.65)", dark: "rgba(255, 255, 255, 0.18)" }
|
|
425
|
+
});
|
|
201
426
|
const overrides = {};
|
|
202
427
|
for (const key of GLASS_TOKENS) {
|
|
203
428
|
overrides[key] = {
|
|
204
|
-
light: toRgba(
|
|
205
|
-
dark: toRgba(
|
|
429
|
+
light: toRgba(tint.light, alpha),
|
|
430
|
+
dark: toRgba(tint.dark, alpha)
|
|
206
431
|
};
|
|
207
432
|
}
|
|
208
433
|
glassDispose = ctx.theme.overrideTokens(GLASS_SOURCE, overrides);
|
|
209
434
|
const style = document.createElement("style");
|
|
210
435
|
style.id = GLASS_CSS_ID;
|
|
211
436
|
style.setAttribute("data-plugin-css", "dsh-liquid-glass");
|
|
212
|
-
style.textContent = glassCss();
|
|
437
|
+
style.textContent = glassCss(material);
|
|
213
438
|
document.head.appendChild(style);
|
|
214
439
|
}
|
|
215
440
|
|
|
216
441
|
function teardownGlass() {
|
|
217
442
|
glassDispose?.();
|
|
218
443
|
glassDispose = null;
|
|
444
|
+
materialDispose?.();
|
|
445
|
+
materialDispose = null;
|
|
219
446
|
document.getElementById(GLASS_CSS_ID)?.remove();
|
|
220
447
|
}
|
|
221
448
|
//#endregion
|
|
222
449
|
|
|
223
450
|
//#region store
|
|
224
451
|
function createGlassStore() {
|
|
225
|
-
return (0,
|
|
452
|
+
return (0, _client_store.defineStore)({
|
|
226
453
|
init: () => ({
|
|
227
454
|
on: DEFAULT_GLASS_ON,
|
|
228
455
|
alpha: DEFAULT_ALPHA,
|
|
229
456
|
wallpaper: null,
|
|
457
|
+
options: DEFAULT_OPTIONS,
|
|
458
|
+
accessibility: false,
|
|
459
|
+
settingsError: false,
|
|
460
|
+
shortcutStatus: "unavailable",
|
|
230
461
|
revision: -1
|
|
231
462
|
}),
|
|
232
463
|
actions: {
|
|
233
|
-
sync: (d, on, alpha, wallpaper, revision) => {
|
|
464
|
+
sync: (d, on, alpha, wallpaper, revision, options, accessibility, settingsError, shortcutStatus) => {
|
|
234
465
|
if (revision <= d.revision) return;
|
|
235
466
|
d.on = on;
|
|
236
467
|
d.alpha = alpha;
|
|
237
468
|
d.wallpaper = wallpaper;
|
|
238
469
|
d.revision = revision;
|
|
470
|
+
d.options = options;
|
|
471
|
+
d.accessibility = accessibility;
|
|
472
|
+
d.settingsError = settingsError;
|
|
473
|
+
d.shortcutStatus = shortcutStatus;
|
|
239
474
|
}
|
|
240
475
|
}
|
|
241
476
|
});
|
|
@@ -409,7 +644,6 @@ window.__ModuleLoader__.load({
|
|
|
409
644
|
width: "40px",
|
|
410
645
|
height: "22px",
|
|
411
646
|
borderRadius: "11px",
|
|
412
|
-
border: "none",
|
|
413
647
|
background: checked ? "var(--dsw-alias-brand-primary)" : "var(--dsw-alias-bg-layer-3)",
|
|
414
648
|
border: checked ? "1px solid transparent" : "1px solid var(--dsw-alias-border-l2)",
|
|
415
649
|
position: "relative",
|
|
@@ -436,21 +670,31 @@ window.__ModuleLoader__.load({
|
|
|
436
670
|
});
|
|
437
671
|
}
|
|
438
672
|
|
|
439
|
-
/**
|
|
673
|
+
/** Decode a picked image, preserving GIF data and compressing static images. */
|
|
440
674
|
const ACCEPTED_IMAGE_TYPES = /^image\/(jpeg|png|webp|gif)$/;
|
|
441
675
|
|
|
442
676
|
function pickImageFile(file, onReady, onError) {
|
|
443
677
|
if (!file) return;
|
|
444
678
|
if (!ACCEPTED_IMAGE_TYPES.test(file.type)) {
|
|
445
|
-
onError?.(
|
|
679
|
+
onError?.("wallpaper.badType");
|
|
446
680
|
return;
|
|
447
681
|
}
|
|
448
682
|
const reader = new FileReader();
|
|
449
683
|
reader.onload = () => {
|
|
684
|
+
const dataUrl = String(reader.result);
|
|
450
685
|
const img = new Image();
|
|
451
|
-
img.onload = () =>
|
|
452
|
-
|
|
686
|
+
img.onload = () => {
|
|
687
|
+
if (file.type === "image/gif") {
|
|
688
|
+
if (!wallpaperFitsStorage(dataUrl)) return onError?.("wallpaper.tooLarge");
|
|
689
|
+
onReady(dataUrl);
|
|
690
|
+
} else {
|
|
691
|
+
onReady(compressImage(img, 1920, 0.85));
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
img.onerror = () => onError?.("wallpaper.badFile");
|
|
695
|
+
img.src = dataUrl;
|
|
453
696
|
};
|
|
697
|
+
reader.onerror = () => onError?.("wallpaper.badFile");
|
|
454
698
|
reader.readAsDataURL(file);
|
|
455
699
|
}
|
|
456
700
|
|
|
@@ -492,16 +736,24 @@ window.__ModuleLoader__.load({
|
|
|
492
736
|
const handleSave = () => {
|
|
493
737
|
if (!dirty || checking) return;
|
|
494
738
|
setError("");
|
|
495
|
-
//
|
|
496
|
-
|
|
739
|
+
// Check again in case other settings used storage since selection.
|
|
740
|
+
if (draft && /^data:image\/gif[;,]/i.test(draft) && !wallpaperFitsStorage(draft)) {
|
|
741
|
+
setError(t("wallpaper.tooLarge"));
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
const applyDraft = () => {
|
|
745
|
+
if (onApply(draft) === false) setError(t("wallpaper.saveFailed"));
|
|
746
|
+
};
|
|
747
|
+
// Picked files were decoded before drafting; remote URLs get a
|
|
748
|
+
// load pre-check so a bad link is rejected with an inline hint.
|
|
497
749
|
if (draft && /^https?:/i.test(draft)) {
|
|
498
750
|
setChecking(true);
|
|
499
751
|
const probe = new Image();
|
|
500
|
-
probe.onload = () => { setChecking(false);
|
|
752
|
+
probe.onload = () => { setChecking(false); applyDraft(); };
|
|
501
753
|
probe.onerror = () => { setChecking(false); setError(t("wallpaper.badUrl")); };
|
|
502
754
|
probe.src = draft;
|
|
503
755
|
} else {
|
|
504
|
-
|
|
756
|
+
applyDraft();
|
|
505
757
|
}
|
|
506
758
|
};
|
|
507
759
|
const saveButton = (0, jsx.jsx)("button", {
|
|
@@ -560,7 +812,7 @@ window.__ModuleLoader__.load({
|
|
|
560
812
|
pickImageFile(
|
|
561
813
|
e.target.files?.[0],
|
|
562
814
|
(dataUrl) => { setDraft(dataUrl); setUrlText(""); setError(""); },
|
|
563
|
-
() => setError(t(
|
|
815
|
+
(key) => setError(t(key))
|
|
564
816
|
);
|
|
565
817
|
e.target.value = "";
|
|
566
818
|
}
|
|
@@ -594,10 +846,26 @@ window.__ModuleLoader__.load({
|
|
|
594
846
|
}
|
|
595
847
|
|
|
596
848
|
/** The single settings row: glass toggle, sliders, background picker. */
|
|
597
|
-
function
|
|
849
|
+
function Choices({ label, value, values, onChange, t, prefix }) {
|
|
850
|
+
return (0, jsx.jsxs)("label", { style: styles.row, children: [
|
|
851
|
+
(0, jsx.jsx)("span", { style: styles.sectionLabel, children: label }),
|
|
852
|
+
(0, jsx.jsx)("select", { value, style: styles.button, onChange: (e) => onChange(e.target.value), children:
|
|
853
|
+
values.map((v) => (0, jsx.jsx)("option", { value: v, children: t(`${prefix}.${v}`) }, v)) })
|
|
854
|
+
] });
|
|
855
|
+
}
|
|
856
|
+
function Check({ label, checked, onChange }) {
|
|
857
|
+
return (0, jsx.jsxs)("label", { style: styles.checkLabel, children: [
|
|
858
|
+
(0, jsx.jsx)("input", { type: "checkbox", checked, onChange: (e) => onChange(e.target.checked) }), label
|
|
859
|
+
] });
|
|
860
|
+
}
|
|
861
|
+
function GlassRow({ t, useStore, setGlass, setAlpha, setWallpaper, setOption, setPreset }) {
|
|
598
862
|
const on = useStore((s) => s.on);
|
|
599
863
|
const alpha = useStore((s) => s.alpha);
|
|
600
864
|
const wallpaper = useStore((s) => s.wallpaper);
|
|
865
|
+
const options = useStore((s) => s.options);
|
|
866
|
+
const accessibility = useStore((s) => s.accessibility);
|
|
867
|
+
const settingsError = useStore((s) => s.settingsError);
|
|
868
|
+
const shortcutStatus = useStore((s) => s.shortcutStatus);
|
|
601
869
|
return (0, jsx.jsxs)("div", {
|
|
602
870
|
style: styles.group,
|
|
603
871
|
children: [
|
|
@@ -609,15 +877,30 @@ window.__ModuleLoader__.load({
|
|
|
609
877
|
]
|
|
610
878
|
}),
|
|
611
879
|
on && (0, jsx.jsx)("div", { style: styles.subtitle, children: t("row.subtitle") }),
|
|
612
|
-
on && (0, jsx.jsx)(Slider, { label: t("glass.alpha"), value: Math.round((1 - alpha) * 100), min: 3, max: 95, step: 1, format: (v) => `${v}%`, onChange: setAlpha }),
|
|
880
|
+
on && (0, jsx.jsx)(Slider, { label: t("glass.alpha"), value: Math.round((1 - alpha) * 100), min: 3, max: accessibility ? 50 : 95, step: 1, format: (v) => `${v}%`, onChange: setAlpha }),
|
|
613
881
|
on && (0, jsx.jsx)("div", { style: styles.hint, children: t("glass.hint") }),
|
|
882
|
+
on && accessibility && (0, jsx.jsx)("div", { role: "status", style: styles.hint, children: t("glass.accessibility") }),
|
|
883
|
+
on && (0, jsx.jsxs)("div", { role: "group", "aria-label": t("glass.presets"), style: styles.row, children:
|
|
884
|
+
Object.keys(PRESETS).map((name) => (0, jsx.jsx)("button", { type: "button", style: styles.button, disabled: accessibility, "aria-pressed": options.preset === name, onClick: () => setPreset(name), children: t(`glass.${name}`) }, name)) }),
|
|
885
|
+
on && (0, jsx.jsx)(Choices, { label: t("glass.tint"), value: options.tint, values: Object.keys(TINTS), onChange: (v) => setOption("tint", v), t, prefix: "glass" }),
|
|
886
|
+
on && (0, jsx.jsx)(Check, { label: t("glass.filter"), checked: options.filter, onChange: (v) => setOption("filter", v) }),
|
|
887
|
+
on && (0, jsx.jsx)("div", { "data-liquid-glass-preview": "", style: { color: "var(--dsw-alias-label-primary)" }, children: t(`glass.${options.preset}`) }),
|
|
888
|
+
on && (0, jsx.jsx)("div", { style: styles.hint, children: t("glass.materialHint") }),
|
|
889
|
+
settingsError && (0, jsx.jsx)("div", { role: "alert", style: styles.dirtyHint, children: t("glass.saveFailed") }),
|
|
890
|
+
(0, jsx.jsx)("div", { style: styles.hint, children: t(shortcutStatus === "unavailable" ? "glass.shortcutUnavailable" : shortcutStatus === "unbound" ? "glass.shortcutConflict" : "glass.shortcutHint") }),
|
|
614
891
|
on && (0, jsx.jsx)("div", { style: styles.sectionLabel, children: t("wallpaper.title") }),
|
|
615
892
|
on && (0, jsx.jsx)(WallpaperSection, {
|
|
616
893
|
url: wallpaper,
|
|
617
894
|
onApply: (value) => setWallpaper(value),
|
|
618
895
|
t
|
|
619
896
|
}),
|
|
620
|
-
on && (0, jsx.jsx)("div", { style: styles.hint, children: t("wallpaper.hint") })
|
|
897
|
+
on && (0, jsx.jsx)("div", { style: styles.hint, children: t("wallpaper.hint") }),
|
|
898
|
+
on && (0, jsx.jsx)(Slider, { label: t("wallpaper.dim"), value: options.dim, min: 0, max: 60, step: 1, format: (v) => `${v}%`, onChange: (v) => setOption("dim", v) }),
|
|
899
|
+
on && (0, jsx.jsx)(Check, { label: t("wallpaper.autoDim"), checked: options.autoDim, onChange: (v) => setOption("autoDim", v) }),
|
|
900
|
+
on && (0, jsx.jsx)("div", { style: styles.hint, children: t("wallpaper.autoDimHint") }),
|
|
901
|
+
on && (0, jsx.jsx)(Choices, { label: t("wallpaper.fit"), value: options.fit, values: ["cover", "contain", "fill"], onChange: (v) => setOption("fit", v), t, prefix: "wallpaper" }),
|
|
902
|
+
on && (0, jsx.jsx)(Choices, { label: t("wallpaper.position"), value: options.position, values: POSITIONS, onChange: (v) => setOption("position", v), t, prefix: "position" }),
|
|
903
|
+
on && (0, jsx.jsx)(Slider, { label: t("wallpaper.brightness"), value: options.brightness, min: 20, max: 200, step: 1, format: (v) => `${v}%`, onChange: (v) => setOption("brightness", v) })
|
|
621
904
|
]
|
|
622
905
|
});
|
|
623
906
|
}
|
|
@@ -626,33 +909,143 @@ window.__ModuleLoader__.load({
|
|
|
626
909
|
//#region plugin body
|
|
627
910
|
const inject = ["slots", "locale", "theme"];
|
|
628
911
|
|
|
912
|
+
let stopRuntime = null;
|
|
629
913
|
function apply(ctx) {
|
|
914
|
+
stopRuntime?.();
|
|
915
|
+
let active = true;
|
|
916
|
+
let settingsError = false;
|
|
917
|
+
let shortcutStatus = "unavailable";
|
|
918
|
+
const mediaDisposers = [];
|
|
919
|
+
const shortcutDisposers = [];
|
|
630
920
|
const store = createGlassStore();
|
|
631
921
|
let bound;
|
|
632
922
|
let revision = 0;
|
|
633
923
|
const sync = () => {
|
|
634
924
|
revision += 1;
|
|
635
|
-
|
|
925
|
+
const material = appearance();
|
|
926
|
+
bound?.sync(readGlassOn(), material.alpha, readWallpaper(), revision, material, accessibilityActive, settingsError, shortcutStatus);
|
|
636
927
|
};
|
|
637
928
|
|
|
929
|
+
const queries = ["(prefers-reduced-transparency: reduce)", "(prefers-contrast: more)"].map((query) => {
|
|
930
|
+
try { return window.matchMedia?.(query); } catch { return null; }
|
|
931
|
+
});
|
|
932
|
+
const updateAccessibility = () => {
|
|
933
|
+
if (!active) return;
|
|
934
|
+
accessibilityActive = queries.some((query) => query?.matches);
|
|
935
|
+
applyGlass(ctx);
|
|
936
|
+
sync();
|
|
937
|
+
};
|
|
938
|
+
accessibilityActive = queries.some((query) => query?.matches);
|
|
939
|
+
for (const query of queries) {
|
|
940
|
+
if (query?.addEventListener) {
|
|
941
|
+
query.addEventListener("change", updateAccessibility);
|
|
942
|
+
mediaDisposers.push(() => query.removeEventListener("change", updateAccessibility));
|
|
943
|
+
} else if (query?.addListener) {
|
|
944
|
+
query.addListener(updateAccessibility);
|
|
945
|
+
mediaDisposers.push(() => query.removeListener(updateAccessibility));
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
const stop = () => {
|
|
949
|
+
if (!active) return;
|
|
950
|
+
active = false;
|
|
951
|
+
for (const dispose of [...mediaDisposers, ...shortcutDisposers]) dispose();
|
|
952
|
+
// overrideTokens disposers emit theme/change too; the handler below
|
|
953
|
+
// must be inert before disposing, or it resurrects the glass layer.
|
|
954
|
+
teardownGlass();
|
|
955
|
+
teardownWallpaper();
|
|
956
|
+
};
|
|
957
|
+
stopRuntime = stop;
|
|
638
958
|
applyWallpaper();
|
|
639
959
|
applyGlass(ctx);
|
|
640
960
|
sync();
|
|
641
961
|
|
|
642
962
|
// A ThemeRuntime rebuild can drop our override layer; re-apply on
|
|
643
|
-
// every theme change event
|
|
644
|
-
// re-tinting is needed here.
|
|
963
|
+
// every theme change event, retaining explicit light/dark tint pairs.
|
|
645
964
|
ctx.on("theme/change", () => {
|
|
646
|
-
if (readGlassOn()) applyGlass(ctx);
|
|
965
|
+
if (active && readGlassOn()) applyGlass(ctx);
|
|
647
966
|
});
|
|
648
967
|
|
|
649
|
-
ctx.effect(() =>
|
|
968
|
+
ctx.effect(() => stop, "liquid-glass: cleanup");
|
|
650
969
|
ctx.effect(() => ctx.locale.register(SETTINGS_NS, { zh, en }), "liquid-glass: dictionaries");
|
|
651
970
|
|
|
971
|
+
// Same optional Cordis injection used by the host theme's shortcuts.
|
|
972
|
+
ctx.inject(["shortcuts"], (scope) => {
|
|
973
|
+
if (!active) return;
|
|
974
|
+
const translate = scope.locale.bind(SETTINGS_NS);
|
|
975
|
+
const binding = { code: "KeyG", modifiers: ["primary", "shift"] };
|
|
976
|
+
const command = {
|
|
977
|
+
id: "liquid-glass.toggle", label: () => translate("glass.shortcut"), aliases: ["liquid glass"],
|
|
978
|
+
defaults: Object.fromEntries(["desktop:macos", "desktop:windows", "desktop:linux", "web:macos", "web:windows"].map((profile) => [profile, binding])),
|
|
979
|
+
regions: ["page"], modals: [],
|
|
980
|
+
resolve: (context) => !active || context.region !== "page" || context.modal !== null ? { status: "pass" } : {
|
|
981
|
+
status: "handled", run: () => {
|
|
982
|
+
if (!active) return;
|
|
983
|
+
settingsError = !writeStorage(KEY_GLASS, readGlassOn() ? "off" : "on");
|
|
984
|
+
if (!settingsError) applyGlass(ctx);
|
|
985
|
+
sync();
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
scope.effect(() => {
|
|
990
|
+
let dispose;
|
|
991
|
+
try {
|
|
992
|
+
dispose = scope.shortcuts.register(command);
|
|
993
|
+
shortcutStatus = "registered";
|
|
994
|
+
} catch {
|
|
995
|
+
// A newer host/plugin may reserve this default. Keep an editable,
|
|
996
|
+
// unbound catalog entry rather than intercepting input ourselves.
|
|
997
|
+
try {
|
|
998
|
+
dispose = scope.shortcuts.register({ ...command, defaults: {} });
|
|
999
|
+
shortcutStatus = "unbound";
|
|
1000
|
+
} catch { shortcutStatus = "unavailable"; }
|
|
1001
|
+
}
|
|
1002
|
+
sync();
|
|
1003
|
+
let disposed = false;
|
|
1004
|
+
const cleanup = () => {
|
|
1005
|
+
if (disposed) return;
|
|
1006
|
+
disposed = true;
|
|
1007
|
+
dispose?.();
|
|
1008
|
+
shortcutStatus = "unavailable";
|
|
1009
|
+
if (active) sync();
|
|
1010
|
+
};
|
|
1011
|
+
shortcutDisposers.push(cleanup);
|
|
1012
|
+
return cleanup;
|
|
1013
|
+
}, "liquid-glass: shortcut");
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
const saveOptions = (next, presetAlpha) => {
|
|
1017
|
+
const previousAlpha = readStorage(KEY_ALPHA);
|
|
1018
|
+
settingsError = false;
|
|
1019
|
+
if (presetAlpha !== undefined && !writeStorage(KEY_ALPHA, String(presetAlpha))) settingsError = true;
|
|
1020
|
+
if (!settingsError && !writeStorage(KEY_OPTIONS, JSON.stringify(next))) {
|
|
1021
|
+
settingsError = true;
|
|
1022
|
+
if (presetAlpha !== undefined) writeStorage(KEY_ALPHA, previousAlpha);
|
|
1023
|
+
}
|
|
1024
|
+
if (!settingsError) { applyGlass(ctx); applyWallpaper(); }
|
|
1025
|
+
sync();
|
|
1026
|
+
return !settingsError;
|
|
1027
|
+
};
|
|
1028
|
+
|
|
652
1029
|
const injected = (actions) => {
|
|
653
1030
|
bound = actions;
|
|
654
1031
|
sync();
|
|
655
1032
|
return {
|
|
1033
|
+
setOption: (key, value) => {
|
|
1034
|
+
const options = readOptions();
|
|
1035
|
+
if (!Object.hasOwn(DEFAULT_OPTIONS, key) || key === "preset") return false;
|
|
1036
|
+
const valid = key === "tint" ? Object.keys(TINTS).includes(value)
|
|
1037
|
+
: key === "fit" ? ["cover", "contain", "fill"].includes(value)
|
|
1038
|
+
: key === "position" ? POSITIONS.includes(value)
|
|
1039
|
+
: key === "filter" || key === "autoDim" ? typeof value === "boolean"
|
|
1040
|
+
: typeof value === "number" && Number.isFinite(value);
|
|
1041
|
+
if (!valid) return false;
|
|
1042
|
+
options[key] = key === "dim" ? numberValue(value, 0, 60, 0) : key === "brightness" ? numberValue(value, 20, 200, 100) : value;
|
|
1043
|
+
return saveOptions(options);
|
|
1044
|
+
},
|
|
1045
|
+
setPreset: (name) => {
|
|
1046
|
+
if (accessibilityActive || !Object.keys(PRESETS).includes(name)) return false;
|
|
1047
|
+
return saveOptions({ ...readOptions(), preset: name }, PRESETS[name].alpha);
|
|
1048
|
+
},
|
|
656
1049
|
setGlass: (on) => {
|
|
657
1050
|
writeStorage(KEY_GLASS, on ? "on" : "off");
|
|
658
1051
|
applyGlass(ctx);
|
|
@@ -661,15 +1054,16 @@ window.__ModuleLoader__.load({
|
|
|
661
1054
|
setAlpha: (percent) => {
|
|
662
1055
|
// UI speaks "transparency %" (bigger = more see-through);
|
|
663
1056
|
// the surface token alpha is the inverse (1 - t/100).
|
|
664
|
-
const alpha = Math.min(0.
|
|
665
|
-
writeStorage(KEY_ALPHA, String(alpha));
|
|
1057
|
+
const alpha = Math.min(0.97, Math.max(0.05, 1 - percent / 100));
|
|
1058
|
+
writeStorage(KEY_ALPHA, String(Math.round(alpha * 1000) / 1000));
|
|
666
1059
|
applyGlass(ctx);
|
|
667
1060
|
sync();
|
|
668
1061
|
},
|
|
669
1062
|
setWallpaper: (url) => {
|
|
670
|
-
writeStorage(KEY_WALLPAPER, url);
|
|
1063
|
+
if (!writeStorage(KEY_WALLPAPER, url)) return false;
|
|
671
1064
|
applyWallpaper();
|
|
672
1065
|
sync();
|
|
1066
|
+
return true;
|
|
673
1067
|
}
|
|
674
1068
|
};
|
|
675
1069
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-liquid-glass",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "DeepSeek Harness 液态玻璃:点一下,整个界面通透起来。透明度随心调,背景图自由换——让你的 Agent 住进风景里。Liquid glass for DeepSeek Harness: one toggle to turn the whole shell translucent, with a live opacity slider and a custom full-page background.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ultronen",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/Ultroncn/dsh-liquid-glass.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://github.com/
|
|
11
|
+
"homepage": "https://github.com/Ultroncn/dsh-liquid-glass",
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/
|
|
13
|
+
"url": "https://github.com/Ultroncn/dsh-liquid-glass/issues"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"deepseek-harness",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
},
|
|
47
47
|
"client": {
|
|
48
48
|
"inject": [
|
|
49
|
-
"@deepseek-ai/dsh-client-runtime",
|
|
50
49
|
"@deepseek-ai/dsh-client-locale",
|
|
51
50
|
"@deepseek-ai/dsh-client-ui-theme"
|
|
52
51
|
],
|